From db98496bb0100861213549d77942b4e5434a7535 Mon Sep 17 00:00:00 2001 From: l4check Date: Mon, 14 Feb 2011 10:32:37 +0000 Subject: [PATCH] update git-svn-id: http://svn.tudos.org/repos/oc/tudos/trunk@30 d050ee49-bd90-4346-b210-929a50b99cfc --- kernel/fiasco/src/Makefile | 1 + kernel/fiasco/src/Modules.ux | 2 +- kernel/fiasco/src/jdb/jdb_attach_irq.cpp | 25 +-- kernel/fiasco/src/jdb/jdb_io_apic.cpp | 9 +- kernel/fiasco/src/jdb/jdb_tcb.cpp | 33 ++-- kernel/fiasco/src/jdb/jdb_thread_list.cpp | 2 +- .../kern/arm/bsp/config-arm-pxa_sa1100.cpp | 5 - .../src/kern/arm/bsp/imx/config-arm-imx.cpp | 8 - .../bsp/integrator/config-arm-integrator.cpp | 4 - .../arm/bsp/kirkwood/config-arm-kirkwood.cpp | 6 - .../kern/arm/bsp/omap3/config-arm-omap3.cpp | 5 - .../arm/bsp/realview/config-arm-realview.cpp | 6 - .../kern/arm/bsp/s3c/config-arm-s3c2410.cpp | 4 - .../kern/arm/bsp/tegra2/config-arm-tegra2.cpp | 8 +- kernel/fiasco/src/kern/arm/thread-arm.cpp | 12 +- kernel/fiasco/src/kern/context-vcpu.cpp | 4 +- kernel/fiasco/src/kern/dirq_io_apic.cpp | 76 +++++--- kernel/fiasco/src/kern/fpu.cpp | 2 +- kernel/fiasco/src/kern/hpet.cpp | 7 +- kernel/fiasco/src/kern/ia32/32/entry.S | 20 +- .../src/kern/ia32/32/mem_layout-ia32-32.cpp | 7 +- .../src/kern/ia32/32/thread-ia32-32.cpp | 1 + .../src/kern/ia32/64/mem_layout-ia32-64.cpp | 6 +- .../src/kern/ia32/64/thread-ia32-64.cpp | 6 +- kernel/fiasco/src/kern/ia32/config-ia32.cpp | 6 +- kernel/fiasco/src/kern/ia32/context-ia32.cpp | 2 +- kernel/fiasco/src/kern/ia32/cpu-ia32.cpp | 25 +-- .../src/kern/ia32/dirq_pic_pin-ia32-ux.cpp | 2 +- .../src/kern/ia32/kernel_thread-ia32.cpp | 4 +- kernel/fiasco/src/kern/ia32/kmem-ia32.cpp | 3 +- .../fiasco/src/kern/ia32/mem_layout-ia32.cpp | 16 ++ kernel/fiasco/src/kern/ia32/startup-ia32.cpp | 5 +- kernel/fiasco/src/kern/ia32/vm_svm.cpp | 8 +- kernel/fiasco/src/kern/ia32/vm_vmx.cpp | 8 +- kernel/fiasco/src/kern/io_apic.cpp | 179 +++++++++++------- kernel/fiasco/src/kern/irq_controller.cpp | 2 +- .../bsp/mpc52xx/config-ppc32-mpc52xx.cpp | 4 - .../kern/ppc32/bsp/qemu/config-ppc32-qemu.cpp | 3 - kernel/fiasco/src/kern/ppc32/thread-ppc32.cpp | 1 + kernel/fiasco/src/kern/syscalls.cpp | 2 - kernel/fiasco/src/kern/tcboffset_in.h | 2 +- kernel/fiasco/src/kern/thread-ipc.cpp | 8 +- kernel/fiasco/src/kern/thread.cpp | 10 + kernel/fiasco/src/kern/ux/config-ux.cpp | 2 - kernel/fiasco/src/kern/ux/cpu-ux.cpp | 14 +- kernel/fiasco/src/kern/ux/mem_layout-ux.cpp | 4 + kernel/fiasco/src/kern/ux/usermode.cpp | 2 +- l4/conf/Makeconf.boot.example | 2 +- l4/pkg/bootstrap/server/src/gunzip.c | 2 +- l4/pkg/bootstrap/server/src/uncompress.c | 4 +- l4/pkg/examples/sys/vcpu/vcpu.cc | 8 +- l4/pkg/fuxfprov/server/src/main.cc | 5 +- l4/pkg/io/server/src/pci.cc | 2 +- l4/pkg/l4con/server/src/ev.c | 4 + l4/pkg/l4re/util/include/region_mapping_svr | 2 +- l4/pkg/l4sys/include/thread.h | 4 +- l4/pkg/libstdc++-v3/contrib.inc | 1 + l4/pkg/libvbus/include/vbus.h | 47 +++-- l4/pkg/libvbus/include/vbus_types.h | 19 +- l4/pkg/libvcpu/include/vcpu | 26 ++- l4/pkg/libvcpu/lib/src/vcpu.cc | 6 +- 61 files changed, 408 insertions(+), 295 deletions(-) diff --git a/kernel/fiasco/src/Makefile b/kernel/fiasco/src/Makefile index 66c8bbafc..1bcd2748f 100644 --- a/kernel/fiasco/src/Makefile +++ b/kernel/fiasco/src/Makefile @@ -84,6 +84,7 @@ else # ! no ABI include $(srcdir)/Makeconf include $(MODULES_FILE) +MODULES_FILES += $(srcdir)/Modules.generic ifdef SUBSYSTEMS _modules_read_ = true diff --git a/kernel/fiasco/src/Modules.ux b/kernel/fiasco/src/Modules.ux index 08d7f11e8..fa6067d42 100644 --- a/kernel/fiasco/src/Modules.ux +++ b/kernel/fiasco/src/Modules.ux @@ -67,7 +67,7 @@ VPATH += kern/$(CONFIG_XARCH) kern/ia32/32 kern/ia32 kern VPATH += jdb/ia32 jdb/ia32/32 jdb/ux jdb PRIVATE_INCDIR += kern/$(CONFIG_XARCH) kern/ia32/32 kern/ia32 kern -KERNEL_EXTRA-$(CONFIG_UX_CON)) += ux_con +KERNEL_EXTRA-$(CONFIG_UX_CON) += ux_con KERNEL_EXTRA-$(CONFIG_UX_NET) += ux_net KERNEL_EXTRA += $(KERNEL_EXTRA-y) diff --git a/kernel/fiasco/src/jdb/jdb_attach_irq.cpp b/kernel/fiasco/src/jdb/jdb_attach_irq.cpp index 8c83e6b31..4f9cb52ab 100644 --- a/kernel/fiasco/src/jdb/jdb_attach_irq.cpp +++ b/kernel/fiasco/src/jdb/jdb_attach_irq.cpp @@ -52,7 +52,7 @@ Jdb_attach_irq::action( int cmd, void *&args, char const *&, int & ) { Irq *r; putchar('\n'); - for (unsigned i = 0; i < Config::Max_num_irqs; ++i) + for (unsigned i = 0; i < Config::Max_num_dirqs; ++i) { r = static_cast(Irq_chip::hw_chip->irq(i)); if (!r) @@ -168,32 +168,25 @@ PUBLIC Kobject_common * Jdb_kobject_irq::follow_link(Kobject_common *o) { - Irq_sender *t = dcast(Kobject::from_dbg(o->dbg_info())); - if (!t || !t->owner() || (Smword)t->owner() == -1) - return o; - - return Kobject::from_dbg(static_cast(t->owner())->dbg_info()); + Irq_sender *t = Kobject::dcast(o); + return t ? Kobject::pointer_to_obj(t->owner()) : 0; } PUBLIC bool Jdb_kobject_irq::show_kobject(Kobject_common *, int) { return true; } -#if 0 - Thread *t = Kobject::dcast(o); - return show(t, level); -#endif PUBLIC int Jdb_kobject_irq::show_kobject_short(char *buf, int max, Kobject_common *o) { - Irq *t = Kobject::dcast(o); - Kobject_common *d = follow_link(o); - int cnt = 0; - return cnt + snprintf(buf, max, " I=%3lx %s L=%lx T=%lx F=%x", - t->irq(), t->pin()->pin_type(), t->obj_id(), - d ? d->dbg_info()->dbg_id() : 0, (unsigned)t->pin()->flags()); + Irq_sender *t = Kobject::dcast(o); + Kobject_common *w = follow_link(o); + return snprintf(buf, max, " I=%3lx %s L=%lx T=%lx F=%x", + t->irq(), t->pin()->pin_type(), t->obj_id(), + w ? w->dbg_info()->dbg_id() : 0, + (unsigned)t->pin()->flags()); } static diff --git a/kernel/fiasco/src/jdb/jdb_io_apic.cpp b/kernel/fiasco/src/jdb/jdb_io_apic.cpp index 9025c89fd..6261689fe 100644 --- a/kernel/fiasco/src/jdb/jdb_io_apic.cpp +++ b/kernel/fiasco/src/jdb/jdb_io_apic.cpp @@ -68,7 +68,14 @@ Jdb_io_apic_module::action (int cmd, void *&, char const *&, int &) return NOTHING; } printf("\nState of IO APIC\n"); - Io_apic::dump(); + for (unsigned i = 0; i < Io_apic::Max_ioapics; ++i) + { + Io_apic *a = Io_apic::apic(i); + if (!a->valid()) + break; + + a->dump(); + } // print global LAPIC state unsigned khz; diff --git a/kernel/fiasco/src/jdb/jdb_tcb.cpp b/kernel/fiasco/src/jdb/jdb_tcb.cpp index ae56f69ca..f9a24b5d0 100644 --- a/kernel/fiasco/src/jdb/jdb_tcb.cpp +++ b/kernel/fiasco/src/jdb/jdb_tcb.cpp @@ -506,29 +506,29 @@ whole_screen: char time_str[12]; - putstr("thread: "); + putstr("thread : "); Jdb_kobject::print_uid(t, 3); print_thread_uid_raw(t); - printf("CPU %3u ", t->cpu()); + printf("\tCPU: %u ", t->cpu()); printf("\tprio: %02x mode: %s\n", t->sched()->prio(), t->mode() & Context::Periodic ? t->mode() & Context::Nonstrict ? "Per (IRT)" : "Per (SP)" : "Con"); - printf("state: %03lx ", t->state(false)); + printf("state : %03lx ", t->state(false)); Jdb_thread::print_state_long(t); - putstr("\n\nwait for: "); + putstr("\nwait for: "); if (!t->partner()) - putstr("--- "); + putstr("--- "); else Jdb_thread::print_partner(t, 4); - putstr(" polling: "); + putstr(" polling: "); Jdb_thread::print_snd_partner(t, 3); - putstr("\trcv descr: "); + putstr("rcv descr: "); if (t->state(false) & Thread_ipc_receiving_mask) printf("%08lx", t->rcv_regs()->from_spec()); @@ -563,18 +563,18 @@ whole_screen: t->sched()->left(), t->sched()->quantum(), Config::char_micro); print_kobject(t, t->_pager.raw()); - putstr("\ttask: "); + putstr("\ttask : "); if (t->space() == Kernel_task::kernel_task()) putstr(" kernel "); else print_kobject(static_cast(t->space())); - putstr("\tutcb: "); - printf("%08lx", (Mword)t->utcb().kern()); - putstr("\nexc-hndl: "); print_kobject(t, t->_exc_handler.raw()); + printf("\tUTCB : %08lx/%08lx", + (Mword)t->utcb().kern(), (Mword)t->utcb().usr().get()); + #if 0 putstr("\tready lnk: "); if (t->state(false) & Thread_ready) @@ -599,22 +599,23 @@ whole_screen: putchar('\n'); - putstr("vCPU st: "); + putstr("vCPU : "); if (t->state(false) & Thread_vcpu_enabled) { char st1[7]; char st2[7]; Vcpu_state *v = t->vcpu_state().kern(); - printf("c=%s s=%s sf=%c e-ip=%08lx e-sp=%08lx S=", + printf("%08lx/%08lx S=", (Mword)v, (Mword)t->vcpu_state().usr().get()); + print_kobject(static_cast(t->vcpu_user_space())); + putchar('\n'); + printf("vCPU : c=%s s=%s sf=%c e-ip=%08lx e-sp=%08lx\n", vcpu_state_str(v->state, st1, sizeof(st1)), vcpu_state_str(v->_saved_state, st2, sizeof(st2)), (v->sticky_flags & Vcpu_state::Sf_irq_pending) ? 'P' : '-', v->_entry_ip, v->_entry_sp); - print_kobject(static_cast(t->vcpu_user_space())); } else - putstr("---"); - putchar('\n'); + putstr("---\nvCPU : ---\n"); Address ksp = is_current_thread ? ef->ksp() : (Address)t->get_kernel_sp(); diff --git a/kernel/fiasco/src/jdb/jdb_thread_list.cpp b/kernel/fiasco/src/jdb/jdb_thread_list.cpp index bd7ad0d31..fd9cf076f 100644 --- a/kernel/fiasco/src/jdb/jdb_thread_list.cpp +++ b/kernel/fiasco/src/jdb/jdb_thread_list.cpp @@ -746,7 +746,7 @@ Jdb_thread_list::list_threads(Thread *t_start, char pr) Thread_busy | Thread_rcvlong_in_progress)) && (!t->partner()->id().is_irq() || - t->partner()->id().irq() > Config::Max_num_irqs)) + t->partner()->id().irq() > Config::Max_num_dirqs)) { t_current = static_cast(t->partner()); redraw = true; diff --git a/kernel/fiasco/src/kern/arm/bsp/config-arm-pxa_sa1100.cpp b/kernel/fiasco/src/kern/arm/bsp/config-arm-pxa_sa1100.cpp index ff98dcddd..943183a3a 100644 --- a/kernel/fiasco/src/kern/arm/bsp/config-arm-pxa_sa1100.cpp +++ b/kernel/fiasco/src/kern/arm/bsp/config-arm-pxa_sa1100.cpp @@ -13,12 +13,7 @@ public: enum { Scheduling_irq = 26, - scheduler_irq_vector = Scheduling_irq, - Max_num_irqs = 64, Max_num_dirqs = 32, - - Vkey_irq = 27, - Tbuf_irq = 28, }; }; diff --git a/kernel/fiasco/src/kern/arm/bsp/imx/config-arm-imx.cpp b/kernel/fiasco/src/kern/arm/bsp/imx/config-arm-imx.cpp index 5e5cbc316..e03f69c6f 100644 --- a/kernel/fiasco/src/kern/arm/bsp/imx/config-arm-imx.cpp +++ b/kernel/fiasco/src/kern/arm/bsp/imx/config-arm-imx.cpp @@ -8,11 +8,7 @@ public: enum { Scheduling_irq = 26, - scheduler_irq_vector = Scheduling_irq, - Max_num_irqs = 66, Max_num_dirqs = 64, - Vkey_irq = 64, - Tbuf_irq = 65, }; }; @@ -26,11 +22,7 @@ public: enum { Scheduling_irq = 40, - scheduler_irq_vector = Scheduling_irq, - Max_num_irqs = 130, Max_num_dirqs = 128, - Vkey_irq = 128, - Tbuf_irq = 129, }; }; diff --git a/kernel/fiasco/src/kern/arm/bsp/integrator/config-arm-integrator.cpp b/kernel/fiasco/src/kern/arm/bsp/integrator/config-arm-integrator.cpp index b283f5086..7c84754ae 100644 --- a/kernel/fiasco/src/kern/arm/bsp/integrator/config-arm-integrator.cpp +++ b/kernel/fiasco/src/kern/arm/bsp/integrator/config-arm-integrator.cpp @@ -8,11 +8,7 @@ public: enum { Scheduling_irq = 6, - scheduler_irq_vector = Scheduling_irq, - Max_num_irqs = 50, Max_num_dirqs = 48, - Vkey_irq = 48, - Tbuf_irq = 49, }; }; diff --git a/kernel/fiasco/src/kern/arm/bsp/kirkwood/config-arm-kirkwood.cpp b/kernel/fiasco/src/kern/arm/bsp/kirkwood/config-arm-kirkwood.cpp index b7f25cc60..679b0c057 100644 --- a/kernel/fiasco/src/kern/arm/bsp/kirkwood/config-arm-kirkwood.cpp +++ b/kernel/fiasco/src/kern/arm/bsp/kirkwood/config-arm-kirkwood.cpp @@ -7,13 +7,7 @@ EXTENSION class Config public: enum { - Max_num_irqs = 66, Max_num_dirqs = 64, - - Vkey_irq = 64, - Tbuf_irq = 65, - Scheduling_irq = 1, - scheduler_irq_vector = Scheduling_irq, }; }; diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/config-arm-omap3.cpp b/kernel/fiasco/src/kern/arm/bsp/omap3/config-arm-omap3.cpp index 5bafe56ec..7cfd2d152 100644 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/config-arm-omap3.cpp +++ b/kernel/fiasco/src/kern/arm/bsp/omap3/config-arm-omap3.cpp @@ -12,11 +12,6 @@ public: enum { Scheduling_irq = 37, - scheduler_irq_vector = Scheduling_irq, - Max_num_irqs = 98, Max_num_dirqs = 96, - - Vkey_irq = 96, - Tbuf_irq = 97, }; }; diff --git a/kernel/fiasco/src/kern/arm/bsp/realview/config-arm-realview.cpp b/kernel/fiasco/src/kern/arm/bsp/realview/config-arm-realview.cpp index 2b58c8eb8..b92a83e34 100644 --- a/kernel/fiasco/src/kern/arm/bsp/realview/config-arm-realview.cpp +++ b/kernel/fiasco/src/kern/arm/bsp/realview/config-arm-realview.cpp @@ -7,11 +7,7 @@ EXTENSION class Config public: enum { - Max_num_irqs = 258, Max_num_dirqs = 256, - - Vkey_irq = 256, - Tbuf_irq = 257, }; }; @@ -23,7 +19,6 @@ public: enum { Scheduling_irq = 36, - scheduler_irq_vector = Scheduling_irq, }; }; @@ -35,7 +30,6 @@ public: enum { Scheduling_irq = 29, - scheduler_irq_vector = Scheduling_irq, }; }; diff --git a/kernel/fiasco/src/kern/arm/bsp/s3c/config-arm-s3c2410.cpp b/kernel/fiasco/src/kern/arm/bsp/s3c/config-arm-s3c2410.cpp index 8577f31ee..610898c1e 100644 --- a/kernel/fiasco/src/kern/arm/bsp/s3c/config-arm-s3c2410.cpp +++ b/kernel/fiasco/src/kern/arm/bsp/s3c/config-arm-s3c2410.cpp @@ -8,11 +8,7 @@ public: enum { Scheduling_irq = 14, - scheduler_irq_vector = Scheduling_irq, - Max_num_irqs = 67, Max_num_dirqs = 65, - Vkey_irq = 65, - Tbuf_irq = 66, }; }; diff --git a/kernel/fiasco/src/kern/arm/bsp/tegra2/config-arm-tegra2.cpp b/kernel/fiasco/src/kern/arm/bsp/tegra2/config-arm-tegra2.cpp index fe5149723..2d8fc444f 100644 --- a/kernel/fiasco/src/kern/arm/bsp/tegra2/config-arm-tegra2.cpp +++ b/kernel/fiasco/src/kern/arm/bsp/tegra2/config-arm-tegra2.cpp @@ -7,13 +7,7 @@ EXTENSION class Config public: enum { - Max_num_irqs = 258, - Max_num_dirqs = 256, - - Vkey_irq = 256, - Tbuf_irq = 257, - + Max_num_dirqs = 160, Scheduling_irq = 29, - scheduler_irq_vector = Scheduling_irq, }; }; diff --git a/kernel/fiasco/src/kern/arm/thread-arm.cpp b/kernel/fiasco/src/kern/arm/thread-arm.cpp index 3fa00c2bc..3a7786412 100644 --- a/kernel/fiasco/src/kern/arm/thread-arm.cpp +++ b/kernel/fiasco/src/kern/arm/thread-arm.cpp @@ -47,11 +47,13 @@ Thread::print_page_fault_error(Mword e) (e & 0x00020000)?'r':'w'); } -PUBLIC template inline +PUBLIC inline void FIASCO_NORETURN -Thread::fast_return_to_user(Mword ip, Mword sp, T arg) +Thread::fast_return_to_user(Mword ip, Mword sp, Vcpu_state *arg) { extern char __iret[]; + assert_kdb((regs()->psr & Proc::Status_mode_mask) == Proc::Status_mode_user); + regs()->ip(ip); regs()->sp(sp); // user-sp is in lazy user state and thus handled by // fill_user_state() @@ -60,7 +62,7 @@ Thread::fast_return_to_user(Mword ip, Mword sp, T arg) regs()->psr &= ~Proc::Status_thumb; { - register Mword r0 asm("r0") = (Mword)arg; + register Vcpu_state *r0 asm("r0") = arg; asm volatile ("mov sp, %0 \t\n" @@ -142,8 +144,8 @@ extern "C" { { #if 0 // Double PF detect static unsigned long last_pfa = ~0UL; - LOG_MSG_3VAL(current(),"PF", pfa, last_pfa, pc); - if (last_pfa == pfa) + LOG_MSG_3VAL(current(),"PF", pfa, error_code, pc); + if (last_pfa == pfa || pfa == 0) kdb_ke("DBF"); last_pfa = pfa; #endif diff --git a/kernel/fiasco/src/kern/context-vcpu.cpp b/kernel/fiasco/src/kern/context-vcpu.cpp index a926f97e7..6fdf6551d 100644 --- a/kernel/fiasco/src/kern/context-vcpu.cpp +++ b/kernel/fiasco/src/kern/context-vcpu.cpp @@ -40,7 +40,7 @@ Context::vcpu_save_state_and_upcall() } PUBLIC inline NEEDS["fpu.h"] -void +bool Context::vcpu_enter_kernel_mode(Vcpu_state *vcpu) { if (EXPECT_FALSE(state() & Thread_vcpu_enabled)) @@ -66,9 +66,11 @@ Context::vcpu_enter_kernel_mode(Vcpu_state *vcpu) Fpu::enable(); space()->switchin_context(vcpu_user_space()); + return true; } } } + return false; } diff --git a/kernel/fiasco/src/kern/dirq_io_apic.cpp b/kernel/fiasco/src/kern/dirq_io_apic.cpp index f5108362c..6370be8ae 100644 --- a/kernel/fiasco/src/kern/dirq_io_apic.cpp +++ b/kernel/fiasco/src/kern/dirq_io_apic.cpp @@ -26,6 +26,7 @@ IMPLEMENTATION: #include "receiver.h" #include "idt.h" #include "irq.h" +#include "vkey.h" enum { @@ -46,18 +47,21 @@ Dirq_io_apic::Chip::legacy_override(unsigned irq) IMPLEMENT unsigned Dirq_io_apic::Chip::nr_irqs() const -{ return Io_apic::nr_irqs(); } +{ return Io_apic::total_irqs(); } IMPLEMENT void Dirq_io_apic::Chip::setup(Irq_base *irq, unsigned irqnum) { + unsigned apic_idx = Io_apic::find_apic(irqnum); + irqnum -= Io_apic::apic(apic_idx)->gsi_offset(); + //irq->pin()->set_mode(Default_mode); if (irq->pin()->get_mode() & Irq::Trigger_level) - irq->pin()->replace(irqnum); + irq->pin()->replace(apic_idx, irqnum); else - irq->pin()->replace(irqnum); + irq->pin()->replace(apic_idx, irqnum); } IMPLEMENT @@ -67,9 +71,15 @@ Dirq_io_apic::Chip::alloc(Irq_base *irq, unsigned irqnum) if (!Dirq_pic_pin::Chip::alloc(irq, irqnum)) return false; - Io_apic_entry e = Io_apic::apic()->read_entry(irqnum); + + unsigned apic_idx = Io_apic::find_apic(irqnum); + Io_apic *a = Io_apic::apic(apic_idx); + unsigned lirqn = irqnum - a->gsi_offset(); + + + Io_apic_entry e = a->read_entry(lirqn); e.vector(vector(irqnum)); - Io_apic::apic()->write_entry(irqnum, e); + a->write_entry(lirqn, e); return true; } @@ -97,28 +107,50 @@ Mword to_io_apic_polarity(unsigned mode) : Io_apic_entry::High_active; } -class Pin_io_apic_level : public Dirq_pic_pin +class Pin_io_apic_level : public Irq_pin { public: - explicit Pin_io_apic_level(unsigned irq) : Dirq_pic_pin(irq) {} + explicit Pin_io_apic_level(unsigned apic, unsigned irq) + { payload()[0] = apic + (irq << 16); } + + unsigned irq() const { return payload()[0] >> 16; } + unsigned apic_idx() const { return payload()[0] & 0xffff; } + Io_apic *apic() const { return Io_apic::apic(apic_idx()); } + unsigned gsi() const { return apic()->gsi_offset() + irq(); } }; class Pin_io_apic_edge : public Pin_io_apic_level { public: - explicit Pin_io_apic_edge(unsigned irq) : Pin_io_apic_level(irq) {} + explicit Pin_io_apic_edge(unsigned apic, unsigned irq) + : Pin_io_apic_level(apic, irq) {} }; +PUBLIC +bool +Pin_io_apic_level::check_debug_irq() +{ + return !Vkey::check_(gsi()); +} +PUBLIC +void +Pin_io_apic_level::unbind_irq() +{ + do_mask(); + disable(); + Irq_chip::hw_chip->free(Irq::self(this), gsi()); + replace(); +} PUBLIC void Pin_io_apic_level::disable() { extern char entry_int_apic_ignore[]; - unsigned vector = this->vector(); + unsigned vector = Dirq_pic_pin::Chip::vector(gsi()); + Dirq_pic_pin::Chip::vfree(Irq_base::self(this), vector); Idt::set_entry(vector, Address(&entry_int_apic_ignore), false); - disable_vector(); } PUBLIC void @@ -132,12 +164,12 @@ Pin_io_apic_edge::do_mask_and_ack() PUBLIC void Pin_io_apic_edge::do_set_mode(unsigned mode) { - Io_apic_entry e = Io_apic::apic()->read_entry(irq()); + Io_apic_entry e = apic()->read_entry(irq()); e.polarity(to_io_apic_polarity(mode)); e.trigger(to_io_apic_trigger(mode)); - Io_apic::apic()->write_entry(irq(), e); + apic()->write_entry(irq(), e); if (mode & Irq::Trigger_level) - new (this) Pin_io_apic_level(irq()); + new (this) Pin_io_apic_level(apic_idx(), irq()); } @@ -145,8 +177,8 @@ PUBLIC void Pin_io_apic_level::do_mask() { assert (cpu_lock.test()); - Io_apic::mask(irq()); - Io_apic::sync(); + apic()->mask(irq()); + apic()->sync(); } @@ -165,8 +197,8 @@ Pin_io_apic_level::do_mask_and_ack() { assert (cpu_lock.test()); __mask(); - Io_apic::mask(irq()); - Io_apic::sync(); + apic()->mask(irq()); + apic()->sync(); Apic::irq_ack(); } @@ -175,25 +207,25 @@ PUBLIC void Pin_io_apic_level::do_unmask() { assert (cpu_lock.test()); - Io_apic::unmask(irq()); + apic()->unmask(irq()); } PUBLIC void Pin_io_apic_level::set_cpu(unsigned cpu) { - Io_apic::set_dest(irq(), Cpu::cpus.cpu(cpu).phys_id()); + apic()->set_dest(irq(), Cpu::cpus.cpu(cpu).phys_id()); } PUBLIC void Pin_io_apic_level::do_set_mode(unsigned mode) { - Io_apic_entry e = Io_apic::apic()->read_entry(irq()); + Io_apic_entry e = apic()->read_entry(irq()); e.polarity(to_io_apic_polarity(mode)); e.trigger(to_io_apic_trigger(mode)); - Io_apic::apic()->write_entry(irq(), e); + apic()->write_entry(irq(), e); if (!(mode & Irq::Trigger_level)) - new (this) Pin_io_apic_edge(irq()); + new (this) Pin_io_apic_edge(apic_idx(), irq()); } diff --git a/kernel/fiasco/src/kern/fpu.cpp b/kernel/fiasco/src/kern/fpu.cpp index 09629f02f..6caf09e89 100644 --- a/kernel/fiasco/src/kern/fpu.cpp +++ b/kernel/fiasco/src/kern/fpu.cpp @@ -75,7 +75,7 @@ unsigned Fpu::state_size() IMPLEMENT inline unsigned Fpu::state_align() -{ return 0; } +{ return 1; } IMPLEMENT void Fpu::init(unsigned) diff --git a/kernel/fiasco/src/kern/hpet.cpp b/kernel/fiasco/src/kern/hpet.cpp index f1c4df8a2..17cf76f9c 100644 --- a/kernel/fiasco/src/kern/hpet.cpp +++ b/kernel/fiasco/src/kern/hpet.cpp @@ -174,11 +174,14 @@ Hpet::init() Address offs; Address a = _acpi_hpet->base_address.addr; - Kmem::map_phys_page(a, Mem_layout::Hpet_page, false, true, &offs); + Address va = Mem_layout::alloc_io_vmem(Config::PAGE_SIZE); + assert (va); + + Kmem::map_phys_page(a, va, false, true, &offs); Kip::k()->add_mem_region(Mem_desc(a, a + 1023, Mem_desc::Reserved)); - _hpet = (Hpet_device *)(Mem_layout::Hpet_page + offs); + _hpet = (Hpet_device *)(va + offs); _hpet->dump(); diff --git a/kernel/fiasco/src/kern/ia32/32/entry.S b/kernel/fiasco/src/kern/ia32/32/entry.S index 9f306cc7a..8948a31b1 100644 --- a/kernel/fiasco/src/kern/ia32/32/entry.S +++ b/kernel/fiasco/src/kern/ia32/32/entry.S @@ -127,11 +127,13 @@ _slowtraps: slowtraps: #ifdef CONFIG_PF_UX # define REG_GS CPU_GS +# define REG_FS CPU_FS #else # define REG_GS %gs +# define REG_FS %fs #endif - pushl %fs /* we save the segment regs in the trap */ + pushl REG_FS /* we save the segment regs in the trap */ pushl REG_GS /* state, but we do not restore them. We */ pushl %ds /* rather reload them using */ pushl %es /* RESET_{KERNEL,USER}_SEGMENTS */ @@ -183,7 +185,7 @@ in_slowtrap: addl $4*2,%esp /* Pop ds, es segment registers */ popl REG_GS - popl %fs /* Restore segment registers */ + popl REG_FS /* Restore segment registers */ popa addl $4*2,%esp /* Pop trap number and error code */ iret @@ -655,8 +657,8 @@ leave_by_vcpu_upcall: call thread_restore_exc_state ESP_TO_TCB_AT %ecx - mov OFS__THREAD__USER_VCPU(%ecx), %eax /* vcpu state poiner from TCB */ - mov OFS__THREAD__VCPU_STATE(%ecx), %ecx /* vcpu state poiner from TCB */ + mov OFS__THREAD__USER_VCPU(%ecx), %eax /* vcpu state pointer from TCB */ + mov OFS__THREAD__VCPU_STATE(%ecx), %ecx /* vcpu state pointer from TCB */ addl $(VAL__SIZEOF_TRAP_STATE - 20), %ecx /* skip return frame */ mov SCRATCH_REGISTER_SIZE(%esp), %edx mov %edx, (%ecx) /* EIP */ @@ -685,13 +687,7 @@ leave_by_vcpu_upcall: /*add SCRATCH_REGISTER_SIZE, %esp*/ -#ifdef CONFIG_PF_UX -# define REG_GS CPU_GS -#else -# define REG_GS %gs -#endif - - pushl %fs /* we save the segment regs in the trap */ + pushl REG_FS /* we save the segment regs in the trap */ pushl REG_GS /* state, but we do not restore them. We */ pushl %ds /* rather reload them using */ pushl %es /* RESET_{KERNEL,USER}_SEGMENTS */ @@ -711,7 +707,7 @@ vcpu_resume: //popl %es //popl %ds popl REG_GS - popl %fs + popl REG_FS popa addl $(2*4), %esp iret diff --git a/kernel/fiasco/src/kern/ia32/32/mem_layout-ia32-32.cpp b/kernel/fiasco/src/kern/ia32/32/mem_layout-ia32-32.cpp index 18aa1e215..b2b72adf3 100644 --- a/kernel/fiasco/src/kern/ia32/32/mem_layout-ia32-32.cpp +++ b/kernel/fiasco/src/kern/ia32/32/mem_layout-ia32-32.cpp @@ -23,12 +23,10 @@ public: Space_index = 0xea000000, ///< % 4MB Service_page = 0xeac00000, ///< % 4MB global mappings Local_apic_page = Service_page + 0x0000, ///< % 4KB - Io_apic_page = Service_page + 0x1000, Kmem_tmp_page_1 = Service_page + 0x2000, ///< % 4KB size 8KB Kmem_tmp_page_2 = Service_page + 0x4000, ///< % 4KB size 8KB Tbuf_status_page = Service_page + 0x6000, ///< % 4KB Tbuf_ustatus_page = Tbuf_status_page, - Hpet_page = Service_page + 0x7000, ///< % 4KB Jdb_bench_page = Service_page + 0x8000, ///< % 4KB Jdb_bts_area = Service_page + 0xf000, ///< % 4KB size 0x81000 Utcb_ptr_page = Service_page + 0xfd000, ///< % 4KB @@ -38,9 +36,8 @@ public: Tbuf_buffer_area = Service_page + 0x200000, ///< % 2MB Tbuf_ubuffer_area = Tbuf_buffer_area, // 0xeb800000-0xec000000 (8MB) free - __free_1 = 0xec000000, ///< % 4MB - __free_2 = 0xec400000, ///< % 4MB - __free_3 = 0xec800000, ///< % 4MB + Io_map_area_start = 0xec000000, + Io_map_area_end = 0xec800000, __free_4 = 0xec880000, ///< % 4MB Jdb_debug_start = 0xecc00000, ///< % 4MB JDB symbols/lines Jdb_debug_end = 0xee000000, ///< % 4MB diff --git a/kernel/fiasco/src/kern/ia32/32/thread-ia32-32.cpp b/kernel/fiasco/src/kern/ia32/32/thread-ia32-32.cpp index 992f2bd66..a8be398bd 100644 --- a/kernel/fiasco/src/kern/ia32/32/thread-ia32-32.cpp +++ b/kernel/fiasco/src/kern/ia32/32/thread-ia32-32.cpp @@ -6,6 +6,7 @@ Thread::fast_return_to_user(Mword ip, Mword sp, T arg) { assert_kdb(cpu_lock.test()); assert_kdb(current() == this); + assert_kdb(Config::Is_ux || (regs()->cs() & 3 == 3)); regs()->ip(ip); regs()->sp(sp); diff --git a/kernel/fiasco/src/kern/ia32/64/mem_layout-ia32-64.cpp b/kernel/fiasco/src/kern/ia32/64/mem_layout-ia32-64.cpp index 2d460e55b..535f8e4e2 100644 --- a/kernel/fiasco/src/kern/ia32/64/mem_layout-ia32-64.cpp +++ b/kernel/fiasco/src/kern/ia32/64/mem_layout-ia32-64.cpp @@ -23,12 +23,10 @@ public: Space_index = 200, Service_page = 0xffffffffeac00000UL, ///< % 4MB global mappings Local_apic_page = Service_page + 0x0000, ///< % 4KB - Io_apic_page = Service_page + 0x1000, ///< % 4KB Kmem_tmp_page_1 = Service_page + 0x2000, ///< % 4KB size 8KB Kmem_tmp_page_2 = Service_page + 0x4000, ///< % 4KB size 8KB Tbuf_status_page = Service_page + 0x6000, ///< % 4KB Tbuf_ustatus_page = Tbuf_status_page, - Hpet_page = Service_page + 0x7000, ///< % 4KB Jdb_bench_page = Service_page + 0x8000, ///< % 4KB Utcb_ptr_page = Service_page + 0xfd000, ///< % 4KB Utcb_ptr_offset = Utcb_ptr_page, @@ -37,8 +35,8 @@ public: Tbuf_buffer_area = Service_page + 0x200000, ///< % 2MB Tbuf_ubuffer_area = Tbuf_buffer_area, // 0xffffffffeb800000-0xfffffffffec000000 (8MB) free - ___free_1 = 0xffffffffec000000UL, ///< % 4MB - ___free_2 = 0xffffffffec400000UL, ///< % 4MB + Io_map_area_start = 0xffffffffec000000UL, + Io_map_area_end = 0xffffffffec800000UL, ___free_3 = 0xffffffffec800000UL, ///< % 4MB ___free_4 = 0xffffffffec880000UL, ///< % 4MB Jdb_debug_start = 0xffffffffecc00000UL, ///< % 4MB JDB symbols/lines diff --git a/kernel/fiasco/src/kern/ia32/64/thread-ia32-64.cpp b/kernel/fiasco/src/kern/ia32/64/thread-ia32-64.cpp index 13745db77..910d10984 100644 --- a/kernel/fiasco/src/kern/ia32/64/thread-ia32-64.cpp +++ b/kernel/fiasco/src/kern/ia32/64/thread-ia32-64.cpp @@ -6,6 +6,10 @@ PUBLIC template inline void FIASCO_NORETURN Thread::fast_return_to_user(Mword ip, Mword sp, T arg) { + assert_kdb(cpu_lock.test()); + assert_kdb(current() == this); + assert_kdb(regs()->cs() & 3 == 3); + regs()->ip(ip); regs()->sp(sp); asm volatile @@ -25,7 +29,7 @@ Thread::invoke_arch(L4_msg_tag & /*tag*/, Utcb * /*utcb*/) } IMPLEMENT inline -Mword +Mword Thread::user_sp() const { return exception_triggered()?_exc_cont.sp(regs()):regs()->sp(); } diff --git a/kernel/fiasco/src/kern/ia32/config-ia32.cpp b/kernel/fiasco/src/kern/ia32/config-ia32.cpp index 01b1986a9..6fae47130 100644 --- a/kernel/fiasco/src/kern/ia32/config-ia32.cpp +++ b/kernel/fiasco/src/kern/ia32/config-ia32.cpp @@ -12,11 +12,7 @@ public: // can access user memory directly Access_user_mem = Access_user_mem_direct, - Max_num_dirqs = 32, - - Tbuf_irq = Max_num_dirqs + 0, - - Max_num_irqs = Max_num_dirqs + 4, + Max_num_dirqs = 128, /// Timer vector used with APIC timer or IOAPIC Apic_timer_vector = APIC_IRQ_BASE + 0, diff --git a/kernel/fiasco/src/kern/ia32/context-ia32.cpp b/kernel/fiasco/src/kern/ia32/context-ia32.cpp index d28e9ad92..036e2be61 100644 --- a/kernel/fiasco/src/kern/ia32/context-ia32.cpp +++ b/kernel/fiasco/src/kern/ia32/context-ia32.cpp @@ -46,7 +46,7 @@ Context::switchin_context(Context *from) load_segments(); // update the global UTCB pointer to make the thread find its UTCB - // using gs:[0] + // using fs:[0] Mem_layout::user_utcb_ptr(current_cpu()) = utcb().usr(); } diff --git a/kernel/fiasco/src/kern/ia32/cpu-ia32.cpp b/kernel/fiasco/src/kern/ia32/cpu-ia32.cpp index 4db8ed4cd..161108c61 100644 --- a/kernel/fiasco/src/kern/ia32/cpu-ia32.cpp +++ b/kernel/fiasco/src/kern/ia32/cpu-ia32.cpp @@ -1184,15 +1184,6 @@ Cpu::get_ss() return val; } -PUBLIC static inline -Unsigned32 -Cpu::get_fs() -{ - Unsigned32 val; - asm volatile ("mov %%fs, %0" : "=rm" (val)); - return val; -} - PUBLIC static inline void Cpu::set_ds(Unsigned32 val) @@ -1203,12 +1194,6 @@ void Cpu::set_es(Unsigned32 val) { asm volatile ("mov %0, %%es" : : "rm" (val)); } -PUBLIC static inline -void -Cpu::set_fs(Unsigned32 val) -{ asm volatile ("mov %0, %%fs" : : "rm" (val)); } - - //---------------------------------------------------------------------------- IMPLEMENTATION[ia32, amd64]: @@ -1668,11 +1653,21 @@ Cpu::enable_ldt(Address addr, int size) } +PUBLIC static inline +Unsigned32 +Cpu::get_fs() +{ Unsigned32 val; asm volatile ("mov %%fs, %0" : "=rm" (val)); return val; } + PUBLIC static inline Unsigned32 Cpu::get_gs() { Unsigned32 val; asm volatile ("mov %%gs, %0" : "=rm" (val)); return val; } +PUBLIC static inline +void +Cpu::set_fs(Unsigned32 val) +{ asm volatile ("mov %0, %%fs" : : "rm" (val)); } + PUBLIC static inline void Cpu::set_gs(Unsigned32 val) diff --git a/kernel/fiasco/src/kern/ia32/dirq_pic_pin-ia32-ux.cpp b/kernel/fiasco/src/kern/ia32/dirq_pic_pin-ia32-ux.cpp index 1b26f2d45..c53ea4e55 100644 --- a/kernel/fiasco/src/kern/ia32/dirq_pic_pin-ia32-ux.cpp +++ b/kernel/fiasco/src/kern/ia32/dirq_pic_pin-ia32-ux.cpp @@ -26,7 +26,7 @@ public: unsigned nr_irqs() const { return 16; } bool valloc(Irq_base *irq, unsigned vector); - bool vfree(Irq_base *irq, unsigned vector); + static bool vfree(Irq_base *irq, unsigned vector); virtual void disable_irq(unsigned vector); protected: diff --git a/kernel/fiasco/src/kern/ia32/kernel_thread-ia32.cpp b/kernel/fiasco/src/kern/ia32/kernel_thread-ia32.cpp index b7d89c14c..29d035215 100644 --- a/kernel/fiasco/src/kern/ia32/kernel_thread-ia32.cpp +++ b/kernel/fiasco/src/kern/ia32/kernel_thread-ia32.cpp @@ -37,7 +37,7 @@ Kernel_thread::bootstrap_arch() // // initialize interrupts // - if (!Io_apic::apic()) + if (!Io_apic::active()) { Irq_chip::hw_chip->reserve(2); // reserve cascade irq Pic::enable_locked(2); // allow cascaded irqs @@ -64,7 +64,7 @@ Kernel_thread::bootstrap_arch() } else { - if (!Io_apic::apic() && !user_irq0 + if (!Io_apic::active() && !user_irq0 && !Config::scheduler_mode == Config::SCHED_PIT) Irq_chip::hw_chip->reserve(0); // reserve irq0 even though } diff --git a/kernel/fiasco/src/kern/ia32/kmem-ia32.cpp b/kernel/fiasco/src/kern/ia32/kmem-ia32.cpp index 31ac0a661..069f6b768 100644 --- a/kernel/fiasco/src/kern/ia32/kmem-ia32.cpp +++ b/kernel/fiasco/src/kern/ia32/kmem-ia32.cpp @@ -296,7 +296,8 @@ void Kmem::map_phys_page(Address phys, Address virt, bool cached, bool global, Address *offs=0) { - Pdir::Iter i = kdir->walk(Virt_addr(virt)); + Pdir::Iter i = kdir->walk(Virt_addr(virt), 100, Mapped_allocator::allocator() +); Pte_base *e = i.e; Mword pte = phys & Config::PAGE_MASK; diff --git a/kernel/fiasco/src/kern/ia32/mem_layout-ia32.cpp b/kernel/fiasco/src/kern/ia32/mem_layout-ia32.cpp index a2152b031..d31b902fa 100644 --- a/kernel/fiasco/src/kern/ia32/mem_layout-ia32.cpp +++ b/kernel/fiasco/src/kern/ia32/mem_layout-ia32.cpp @@ -4,12 +4,28 @@ EXTENSION class Mem_layout { public: enum { Io_port_max = (1UL << 16) }; + + static Address _io_map_ptr; }; IMPLEMENTATION [ia32 || amd64 || ux]: #include "static_assert.h" +Address Mem_layout::_io_map_ptr = Mem_layout::Io_map_area_end; + +PUBLIC static inline +Address +Mem_layout::alloc_io_vmem(unsigned long bytes) +{ + bytes = (bytes + Config::PAGE_SIZE - 1) & ~(Config::PAGE_SIZE - 1); + if (_io_map_ptr - bytes < Io_map_area_start) + return 0; + + _io_map_ptr -= bytes; + return _io_map_ptr; +} + PUBLIC static inline NEEDS["static_assert.h"] template< typename V > bool diff --git a/kernel/fiasco/src/kern/ia32/startup-ia32.cpp b/kernel/fiasco/src/kern/ia32/startup-ia32.cpp index c4328a5c3..4cd0c14d4 100644 --- a/kernel/fiasco/src/kern/ia32/startup-ia32.cpp +++ b/kernel/fiasco/src/kern/ia32/startup-ia32.cpp @@ -74,9 +74,10 @@ Startup::stage2() { unsigned const pic_pin = Io_apic::legacy_override(Config::scheduler_irq_vector - Pic_base); - Io_apic_entry e = Io_apic::apic()->read_entry(pic_pin); + // assume the legacy irqs are routet to IO-APIC 0 + Io_apic_entry e = Io_apic::apic(0)->read_entry(pic_pin); e.vector(Config::Apic_timer_vector); - Io_apic::apic()->write_entry(pic_pin, e); + Io_apic::apic(0)->write_entry(pic_pin, e); Config::scheduler_irq_vector = Config::Apic_timer_vector; } } diff --git a/kernel/fiasco/src/kern/ia32/vm_svm.cpp b/kernel/fiasco/src/kern/ia32/vm_svm.cpp index a42a422f9..bf6a27aca 100644 --- a/kernel/fiasco/src/kern/ia32/vm_svm.cpp +++ b/kernel/fiasco/src/kern/ia32/vm_svm.cpp @@ -681,7 +681,7 @@ Vm_svm::resume_vcpu(Context *ctxt, Vcpu_state *vcpu, bool user_mode) int r = do_resume_vcpu(ctxt, vcpu, vmcb_s); - // test for error or non-IRQ exit resason + // test for error or non-IRQ exit reason if (r <= 0) return r; @@ -695,8 +695,10 @@ Vm_svm::resume_vcpu(Context *ctxt, Vcpu_state *vcpu, bool user_mode) // leave the kernel to not overwrite the vcpu-regs // with bogus state. Thread *t = nonull_static_cast(ctxt); - if (t->exception_triggered()) - t->fast_return_to_user(vcpu->_entry_ip, vcpu->_entry_sp, t->vcpu_state().usr().get()); + + if (t->continuation_test_and_restore()) + t->fast_return_to_user(vcpu->_entry_ip, vcpu->_entry_sp, + t->vcpu_state().usr().get()); } } diff --git a/kernel/fiasco/src/kern/ia32/vm_vmx.cpp b/kernel/fiasco/src/kern/ia32/vm_vmx.cpp index eac02623f..2f73948e9 100644 --- a/kernel/fiasco/src/kern/ia32/vm_vmx.cpp +++ b/kernel/fiasco/src/kern/ia32/vm_vmx.cpp @@ -560,7 +560,7 @@ Vm_vmx::resume_vcpu(Context *ctxt, Vcpu_state *vcpu, bool user_mode) int r = do_resume_vcpu(ctxt, vcpu, vmcs_s); - // test for error or non-IRQ exit resason + // test for error or non-IRQ exit reason if (r <= 0) return r; @@ -574,8 +574,8 @@ Vm_vmx::resume_vcpu(Context *ctxt, Vcpu_state *vcpu, bool user_mode) // leave the kernel to not overwrite the vcpu-regs // with bogus state. Thread *t = nonull_static_cast(ctxt); - if (t->exception_triggered()) - t->fast_return_to_user(vcpu->_entry_ip, vcpu->_entry_sp, t->vcpu_state().usr().get()); + if (t->continuation_test_and_restore()) + t->fast_return_to_user(vcpu->_entry_ip, vcpu->_entry_sp, + t->vcpu_state().usr().get()); } } - diff --git a/kernel/fiasco/src/kern/io_apic.cpp b/kernel/fiasco/src/kern/io_apic.cpp index 1a6df7d61..ee83b7149 100644 --- a/kernel/fiasco/src/kern/io_apic.cpp +++ b/kernel/fiasco/src/kern/io_apic.cpp @@ -44,15 +44,25 @@ public: class Io_apic { -private: - Unsigned32 volatile adr; - Unsigned32 dummy[3]; - Unsigned32 volatile data; +public: + enum { Max_ioapics = 6 }; - static Io_apic *_apic; +private: + struct Apic + { + Unsigned32 volatile adr; + Unsigned32 dummy[3]; + Unsigned32 volatile data; + } __attribute__((packed)); + + Apic *_apic; + Spin_lock<> _l; + unsigned _offset; + + static Io_apic _apics[Max_ioapics]; + static unsigned _nr_irqs; static Acpi_madt const *_madt; - static Spin_lock<> _l; -} __attribute__((packed)); +}; IMPLEMENTATION: @@ -62,10 +72,9 @@ IMPLEMENTATION: #include "kip.h" #include "lock_guard.h" -Io_apic *Io_apic::_apic; +Io_apic Io_apic::_apics[Io_apic::Max_ioapics]; Acpi_madt const *Io_apic::_madt; -Spin_lock<> Io_apic::_l; - +unsigned Io_apic::_nr_irqs; PRIVATE inline NEEDS["lock_guard.h"] @@ -73,9 +82,9 @@ Mword Io_apic::read(int reg) { Lock_guard g(&_l); - adr = reg; + _apic->adr = reg; asm volatile ("": : :"memory"); - return data; + return _apic->data; } PRIVATE inline NEEDS["lock_guard.h"] @@ -84,12 +93,12 @@ Io_apic::modify(int reg, Mword set_bits, Mword del_bits) { register Mword tmp; Lock_guard g(&_l); - adr = reg; + _apic->adr = reg; asm volatile ("": : :"memory"); - tmp = data; + tmp = _apic->data; tmp &= ~del_bits; tmp |= set_bits; - data = tmp; + _apic->data = tmp; } PRIVATE inline NEEDS["lock_guard.h"] @@ -97,9 +106,9 @@ void Io_apic::write(int reg, Mword value) { Lock_guard g(&_l); - adr = reg; + _apic->adr = reg; asm volatile ("": : :"memory"); - data = value; + _apic->data = value; } PRIVATE inline @@ -143,20 +152,59 @@ Io_apic::init() } printf("MADT = %p\n", _madt); - Acpi_madt::Io_apic const *ioapic - = static_cast(_madt->find(Acpi_madt::IOAPIC, 0)); + int n_apics = 0; - if (!ioapic) + for (n_apics = 0; + Acpi_madt::Io_apic const *ioapic = static_cast(_madt->find(Acpi_madt::IOAPIC, n_apics)); + ++n_apics) + { + + if (n_apics >= Max_ioapics) + { + printf("Maximum number of IO-APICs exceeded ignore further IO-APICs\n"); + break; + } + + printf("IO-APIC[%2d]: struct: %p adr=%x\n", n_apics, ioapic, ioapic->adr); + + Address offs; + Address va = Mem_layout::alloc_io_vmem(Config::PAGE_SIZE); + assert (va); + + Kmem::map_phys_page(ioapic->adr, va, false, true, &offs); + + Kip::k()->add_mem_region(Mem_desc(ioapic->adr, ioapic->adr + Config::PAGE_SIZE -1, Mem_desc::Reserved)); + + + Io_apic *apic = Io_apic::apic(n_apics); + apic->_apic = (Io_apic::Apic*)(va + offs); + apic->write(0, 0); + unsigned ne = apic->num_entries(); + apic->_offset = _nr_irqs; + _nr_irqs += ne + 1; + + for (unsigned i = 0; i <= ne; ++i) + { + int v = 0x20+i; + Io_apic_entry e(v, Io_apic_entry::Fixed, Io_apic_entry::Physical, + Io_apic_entry::High_active, Io_apic_entry::Edge, 0); + apic->write_entry(i, e); + } + + printf("IO-APIC[%2d]: pins %u\n", n_apics, ne); + apic->dump(); + } + + if (!n_apics) { printf("IO-APIC: Could not find IO-APIC in MADT, skip init\n"); return false; } - printf("IO-APIC: struct: %p adr=%x\n", ioapic, ioapic->adr); + printf("IO-APIC: dual 8259: %s\n", _madt->apic_flags & 1 ? "yes" : "no"); - unsigned tmp = 0; - for (;;++tmp) + for (unsigned tmp = 0;;++tmp) { Acpi_madt::Irq_source const *irq = static_cast(_madt->find(Acpi_madt::Irq_src_ovr, tmp)); @@ -167,35 +215,14 @@ Io_apic::init() printf("IO-APIC: ovr[%2u] %02x -> %x\n", tmp, irq->src, irq->irq); } - if (tmp) - printf("IO-APIC: NOTE IRQ overrides are ignored!\n"); - - Address offs; - Kmem::map_phys_page(ioapic->adr, Mem_layout::Io_apic_page, - false, true, &offs); - - Kip::k()->add_mem_region(Mem_desc(ioapic->adr, ioapic->adr + Config::PAGE_SIZE -1, Mem_desc::Reserved)); - - - Io_apic *apic = (Io_apic*)(Mem_layout::Io_apic_page + offs); - _apic = apic; - apic->write(0, 0); - unsigned ne = apic->num_entries(); - - for (unsigned i = 0; i <= ne; ++i) - { - int v = 0x20+i; - Io_apic_entry e(v, Io_apic_entry::Fixed, Io_apic_entry::Physical, - Io_apic_entry::High_active, Io_apic_entry::Edge, 0); - apic->write_entry(i, e); - } - - printf("IO-APIC: pins %u\n", ne); - dump(); - return true; }; +PUBLIC static +unsigned +Io_apic::total_irqs() +{ return _nr_irqs; } + PUBLIC static unsigned Io_apic::legacy_override(unsigned i) @@ -218,14 +245,14 @@ Io_apic::legacy_override(unsigned i) return i; } -PUBLIC static +PUBLIC void Io_apic::dump() { - unsigned ne = _apic->num_entries(); + unsigned ne = num_entries(); for (unsigned i = 0; i <= ne; ++i) { - Io_apic_entry e = _apic->read_entry(i); + Io_apic_entry e = read_entry(i); printf(" PIN[%2u%c]: vector=%2x, del=%u, dm=%s, dest=%u (%s, %s)\n", i, e.mask() ? 'm' : '.', e.vector(), e.delivery(), e.dest_mode() ? "logical" : "physical", @@ -239,54 +266,74 @@ Io_apic::dump() PUBLIC static inline bool Io_apic::active() -{ return _apic; } +{ return _apics[0]._apic; } -PUBLIC static inline NEEDS["kdb_ke.h", Io_apic::modify] +PUBLIC inline +bool +Io_apic::valid() const { return _apic; } + +PUBLIC inline NEEDS["kdb_ke.h", Io_apic::modify] void Io_apic::mask(unsigned irq) { //assert_kdb(irq <= _apic->num_entries()); - _apic->modify(0x10 + irq * 2, 1UL << 16, 0); + modify(0x10 + irq * 2, 1UL << 16, 0); } -PUBLIC static inline NEEDS["kdb_ke.h", Io_apic::modify] +PUBLIC inline NEEDS["kdb_ke.h", Io_apic::modify] void Io_apic::unmask(unsigned irq) { //assert_kdb(irq <= _apic->num_entries()); - _apic->modify(0x10 + irq * 2, 0, 1UL << 16); + modify(0x10 + irq * 2, 0, 1UL << 16); } -PUBLIC static inline NEEDS["kdb_ke.h", Io_apic::read] +PUBLIC inline NEEDS["kdb_ke.h", Io_apic::read] bool Io_apic::masked(unsigned irq) { //assert_kdb(irq <= _apic->num_entries()); - return _apic->read(0x10 + irq * 2) & (1UL << 16); + return read(0x10 + irq * 2) & (1UL << 16); } -PUBLIC static inline NEEDS[Io_apic::read] +PUBLIC inline NEEDS[Io_apic::read] void Io_apic::sync() { (void)_apic->data; } -PUBLIC static inline NEEDS["kdb_ke.h", Io_apic::modify] +PUBLIC inline NEEDS["kdb_ke.h", Io_apic::modify] void Io_apic::set_dest(unsigned irq, Mword dst) { //assert_kdb(irq <= _apic->num_entries()); - _apic->modify(0x11 + irq * 2, dst & (~0UL << 24), ~0UL << 24); + modify(0x11 + irq * 2, dst & (~0UL << 24), ~0UL << 24); } -PUBLIC static inline NEEDS[Io_apic::num_entries] +PUBLIC inline NEEDS[Io_apic::num_entries] unsigned Io_apic::nr_irqs() -{ return _apic->num_entries() + 1; } +{ return num_entries() + 1; } + +PUBLIC inline +unsigned +Io_apic::gsi_offset() const { return _offset; } PUBLIC static inline Io_apic * -Io_apic::apic() -{ return _apic; } +Io_apic::apic(unsigned idx) +{ return &_apics[idx]; } + +PUBLIC static +unsigned +Io_apic::find_apic(unsigned irqnum) +{ + for (unsigned i = Max_ioapics; i > 0; --i) + { + if (_apics[i-1]._apic && _apics[i-1]._offset < irqnum) + return i - 1; + } + return 0; +}; diff --git a/kernel/fiasco/src/kern/irq_controller.cpp b/kernel/fiasco/src/kern/irq_controller.cpp index 6077c0ae7..dab612275 100644 --- a/kernel/fiasco/src/kern/irq_controller.cpp +++ b/kernel/fiasco/src/kern/irq_controller.cpp @@ -53,7 +53,7 @@ Icu::icu_bind_irq(Irq *irq, unsigned irqnum) return commit_result(-L4_err::EInval); irq->pin()->unbind_irq(); - + if (!c->alloc(irq, irqnum & ~Msi_bit)) return commit_result(-L4_err::EPerm); diff --git a/kernel/fiasco/src/kern/ppc32/bsp/mpc52xx/config-ppc32-mpc52xx.cpp b/kernel/fiasco/src/kern/ppc32/bsp/mpc52xx/config-ppc32-mpc52xx.cpp index 3130d2844..b7c43068f 100644 --- a/kernel/fiasco/src/kern/ppc32/bsp/mpc52xx/config-ppc32-mpc52xx.cpp +++ b/kernel/fiasco/src/kern/ppc32/bsp/mpc52xx/config-ppc32-mpc52xx.cpp @@ -9,10 +9,6 @@ EXTENSION class Config public: enum { - Max_num_dirqs = Pic::IRQ_MAX, - Vkey_irq = Max_num_dirqs, - Tbuf_irq = Max_num_dirqs + 1, - Max_num_irqs = Max_num_dirqs + 2, }; }; diff --git a/kernel/fiasco/src/kern/ppc32/bsp/qemu/config-ppc32-qemu.cpp b/kernel/fiasco/src/kern/ppc32/bsp/qemu/config-ppc32-qemu.cpp index ac60dccfd..f32b34057 100644 --- a/kernel/fiasco/src/kern/ppc32/bsp/qemu/config-ppc32-qemu.cpp +++ b/kernel/fiasco/src/kern/ppc32/bsp/qemu/config-ppc32-qemu.cpp @@ -8,8 +8,5 @@ public: enum { Max_num_dirqs = 3, - Vkey_irq = Max_num_dirqs, - Tbuf_irq = Max_num_dirqs + 1, - Max_num_irqs = Max_num_dirqs + 2, }; }; diff --git a/kernel/fiasco/src/kern/ppc32/thread-ppc32.cpp b/kernel/fiasco/src/kern/ppc32/thread-ppc32.cpp index 704e3071a..2ebdab7a8 100644 --- a/kernel/fiasco/src/kern/ppc32/thread-ppc32.cpp +++ b/kernel/fiasco/src/kern/ppc32/thread-ppc32.cpp @@ -87,6 +87,7 @@ void FIASCO_NORETURN Thread::fast_return_to_user(Mword ip, Mword sp, T arg) { (void)ip; (void)sp; (void)arg; + //assert_kdb(check that exiting privs are user privs); // XXX: UNIMPLEMENTED panic("__builtin_trap()"); } diff --git a/kernel/fiasco/src/kern/syscalls.cpp b/kernel/fiasco/src/kern/syscalls.cpp index 6d3f6fbf3..e43060511 100644 --- a/kernel/fiasco/src/kern/syscalls.cpp +++ b/kernel/fiasco/src/kern/syscalls.cpp @@ -7,7 +7,6 @@ extern "C" void sys_ipc_wrapper() { - // FIXME: use UTCB from user, not the kernel var (remove access utcb assert_kdb (!(current()->state() & Thread_drq_ready)); Thread *curr = current_thread(); @@ -15,7 +14,6 @@ sys_ipc_wrapper() Obj_cap obj = f->ref(); Utcb *utcb = curr->utcb().access(true); - // printf("sys_invoke_object(f=%p, obj=%x)\n", f, f->obj_ref()); unsigned char rights; Kobject_iface *o = obj.deref(&rights); L4_msg_tag e; diff --git a/kernel/fiasco/src/kern/tcboffset_in.h b/kernel/fiasco/src/kern/tcboffset_in.h index 5c42ba1d5..fb1f69cd6 100644 --- a/kernel/fiasco/src/kern/tcboffset_in.h +++ b/kernel/fiasco/src/kern/tcboffset_in.h @@ -37,7 +37,7 @@ #if defined(CONFIG_ARM) DUMP_OFFSET (THREAD, UTCB_SIZE, sizeof(Utcb)) #else - DUMP_MEMBER1 (THREAD, Context, _vcpu_state, VCPU_STATE) + DUMP_MEMBER1 (THREAD, Context, _vcpu_state._k, VCPU_STATE) #endif #if 0 DUMP_MEMBER1 (SCHED_CONTEXT, Sched_context,_owner, OWNER) diff --git a/kernel/fiasco/src/kern/thread-ipc.cpp b/kernel/fiasco/src/kern/thread-ipc.cpp index feca98a97..f95fd298e 100644 --- a/kernel/fiasco/src/kern/thread-ipc.cpp +++ b/kernel/fiasco/src/kern/thread-ipc.cpp @@ -919,7 +919,13 @@ Thread::send_exception(Trap_state *ts) if (_exc_cont.valid()) return 1; - vcpu_enter_kernel_mode(vcpu); + if (vcpu_enter_kernel_mode(vcpu)) + { + // enter_kernel_mode has switched the address space from user to + // kernel space, so reevaluate the address of the VCPU state area + vcpu = vcpu_state().access(); + } + spill_user_state(); LOG_TRACE("VCPU events", "vcpu", this, __context_vcpu_log_fmt, Vcpu_log *l = tbe->payload(); diff --git a/kernel/fiasco/src/kern/thread.cpp b/kernel/fiasco/src/kern/thread.cpp index 83000e4ba..8aefef6ff 100644 --- a/kernel/fiasco/src/kern/thread.cpp +++ b/kernel/fiasco/src/kern/thread.cpp @@ -409,6 +409,16 @@ bool Thread::exception_triggered() const { return _exc_cont.valid(); } +PUBLIC inline +bool +Thread::continuation_test_and_restore() +{ + bool v = _exc_cont.valid(); + if (v) + _exc_cont.restore(regs()); + return v; +} + // // state requests/manipulation // diff --git a/kernel/fiasco/src/kern/ux/config-ux.cpp b/kernel/fiasco/src/kern/ux/config-ux.cpp index b3eeba319..94ba65cf4 100644 --- a/kernel/fiasco/src/kern/ux/config-ux.cpp +++ b/kernel/fiasco/src/kern/ux/config-ux.cpp @@ -43,8 +43,6 @@ public: enum { Scheduling_irq = 0, Max_num_dirqs = 16, - Max_num_irqs = Max_num_dirqs + 4, - Tbuf_irq = Max_num_dirqs + 1, Is_ux = 1, }; }; diff --git a/kernel/fiasco/src/kern/ux/cpu-ux.cpp b/kernel/fiasco/src/kern/ux/cpu-ux.cpp index b3deb360f..dc3bb9e80 100644 --- a/kernel/fiasco/src/kern/ux/cpu-ux.cpp +++ b/kernel/fiasco/src/kern/ux/cpu-ux.cpp @@ -16,6 +16,7 @@ private: static Tss *tss asm ("CPU_TSS"); static int msr_dev; static unsigned long _gs asm ("CPU_GS"); + static unsigned long _fs asm ("CPU_FS"); static Mword _kern_ds asm ("KERN_DS"); static Mword _kern_es asm ("KERN_ES"); @@ -41,7 +42,8 @@ IMPLEMENTATION[ux]: Proc::Status volatile Proc::virtual_processor_state = 0; Tss *Cpu::tss; int Cpu::msr_dev = -1; -unsigned long Cpu::_gs; // XXX percpu +unsigned long Cpu::_gs; // for mp: percpu +unsigned long Cpu::_fs; // for mp: percpu unsigned long Cpu::_kern_ds; unsigned long Cpu::_kern_es; @@ -180,11 +182,21 @@ void Cpu::debugctl_disable() {} +PUBLIC static inline +void +Cpu::set_fs(Unsigned32 val) +{ _fs = val; } + PUBLIC static inline void Cpu::set_gs(Unsigned32 val) { _gs = val; } +PUBLIC static inline +Unsigned32 +Cpu::get_fs() +{ return _fs; } + PUBLIC static inline Unsigned32 Cpu::get_gs() diff --git a/kernel/fiasco/src/kern/ux/mem_layout-ux.cpp b/kernel/fiasco/src/kern/ux/mem_layout-ux.cpp index db9bbae08..e6f3e6211 100644 --- a/kernel/fiasco/src/kern/ux/mem_layout-ux.cpp +++ b/kernel/fiasco/src/kern/ux/mem_layout-ux.cpp @@ -39,6 +39,8 @@ public: Caps_end = 0x5f000000, Idt = 0x5f001000, Tbuf_status_page = 0x5f002000, ///< % 4KB for jdb_tbuf + Io_map_area_start = 0x5f003000, + Io_map_area_end = 0x5f006000, Tbuf_buffer_area = 0x5f200000, ///< % 2MB tracebuffer Io_bitmap = 0x5f800000, ///< % 4MB dummy _Free_1 = 0x5fc00000, ///< % 4MB dummy @@ -64,6 +66,8 @@ public: Caps_end = 0x2f000000, Idt = 0x2f001000, Tbuf_status_page = 0x2f002000, ///< % 4KB for jdb_tbuf + Io_map_area_start = 0x2f003000, + Io_map_area_end = 0x2f006000, Tbuf_buffer_area = 0x2f200000, ///< % 2MB tracebuffer Io_bitmap = 0x2f800000, ///< % 4MB dummy Glibc_mmap_start = 0x40000000, ///< fixed, Linux kernel spec. diff --git a/kernel/fiasco/src/kern/ux/usermode.cpp b/kernel/fiasco/src/kern/ux/usermode.cpp index b6accf932..697cf1e2f 100644 --- a/kernel/fiasco/src/kern/ux/usermode.cpp +++ b/kernel/fiasco/src/kern/ux/usermode.cpp @@ -514,7 +514,7 @@ Usermode::iret_to_user_mode (unsigned _cpu, " Fixing up!\n"); regs.xds = Cpu::kern_ds(); regs.xes = Cpu::kern_es(); - regs.xfs = 0; + regs.xgs = 0; check(ptrace (PTRACE_SETREGS, pid, NULL, ®s)); } else diff --git a/l4/conf/Makeconf.boot.example b/l4/conf/Makeconf.boot.example index b52aeaaac..c0e2d22d0 100644 --- a/l4/conf/Makeconf.boot.example +++ b/l4/conf/Makeconf.boot.example @@ -18,7 +18,7 @@ # files or any other data file you might want to load. Note that the bin and # lib directories of the build-tree are automatically added to the search # path. -# MODULES_SEARCH_PATH = /path/to/cfgs:/path/to/foo:.. +# MODULE_SEARCH_PATH = /path/to/cfgs:/path/to/foo:.. # # 'image' just builds what's configured: # - default: just ELF diff --git a/l4/pkg/bootstrap/server/src/gunzip.c b/l4/pkg/bootstrap/server/src/gunzip.c index 832ff9af5..9c15df569 100644 --- a/l4/pkg/bootstrap/server/src/gunzip.c +++ b/l4/pkg/bootstrap/server/src/gunzip.c @@ -166,7 +166,7 @@ static void initialize_tables (void); static void show_progress(int done, int len) { - int r = printf("%d%%", (done * 100) / len); + int r = printf("%lld%%", ((unsigned long long)done * 100) / len); while (r-- > 0) putchar('\b'); fflush(NULL); diff --git a/l4/pkg/bootstrap/server/src/uncompress.c b/l4/pkg/bootstrap/server/src/uncompress.c index 61d11426e..7e1338876 100644 --- a/l4/pkg/bootstrap/server/src/uncompress.c +++ b/l4/pkg/bootstrap/server/src/uncompress.c @@ -102,9 +102,9 @@ decompress(const char *name, void *start, void *destbuf, if (!compressed_file) return start; - printf(" Uncompressing %s from %p to %p (%d to %d bytes, %+d%%).\n", + printf(" Uncompressing %s from %p to %p (%d to %d bytes, %+lld%%).\n", name, start, destbuf, size, size_uncompressed, - 100*size_uncompressed/size - 100); + 100*(unsigned long long)size_uncompressed/size - 100); // Add 10 to detect too short given size if ((read_size = grub_read(destbuf, size_uncompressed + 10)) diff --git a/l4/pkg/examples/sys/vcpu/vcpu.cc b/l4/pkg/examples/sys/vcpu/vcpu.cc index 06f30141b..45db48635 100644 --- a/l4/pkg/examples/sys/vcpu/vcpu.cc +++ b/l4/pkg/examples/sys/vcpu/vcpu.cc @@ -46,7 +46,7 @@ extern char my_super_code_excp_after[]; #if defined(ARCH_x86) || defined(ARCH_amd64) -static unsigned long gs; +static unsigned long fs; static unsigned long ds; asm @@ -82,7 +82,7 @@ asm static void setup_user_state_arch(L4vcpu::Vcpu *v) { - asm volatile ("mov %%gs, %0" : "=r"(gs)); + asm volatile ("mov %%fs, %0" : "=r"(fs)); asm volatile ("mov %%ds, %0" : "=r"(ds)); #ifndef __amd64__ v->r()->gs = ds; @@ -97,8 +97,8 @@ static void handler_prolog() { asm volatile ("mov %0, %%es \t\n" "mov %0, %%ds \t\n" - "mov %1, %%gs \t\n" - : : "r"(ds), "r"(gs)); + "mov %1, %%fs \t\n" + : : "r"(ds), "r"(fs)); } #elif defined(ARCH_arm) diff --git a/l4/pkg/fuxfprov/server/src/main.cc b/l4/pkg/fuxfprov/server/src/main.cc index 11423ff0b..e94d045db 100644 --- a/l4/pkg/fuxfprov/server/src/main.cc +++ b/l4/pkg/fuxfprov/server/src/main.cc @@ -49,7 +49,7 @@ static L4Re::Util::Registry_server<> server(l4_utcb(), L4Re::Env::env()->factory()); enum { - Max_search_paths = 10, + Max_search_paths = 20, }; static char *search_paths[Max_search_paths]; @@ -499,9 +499,10 @@ Fprov_server::dispatch(l4_umword_t, L4::Ipc_iostream &ios) int main(int argc, char *argv[]) { - setup(argc, argv); try { + setup(argc, argv); + int err = mount("/", fprov_prefix, "fuxfs", 0, 0); if (err == -1) { diff --git a/l4/pkg/io/server/src/pci.cc b/l4/pkg/io/server/src/pci.cc index 3e9598180..6b7da9e66 100644 --- a/l4/pkg/io/server/src/pci.cc +++ b/l4/pkg/io/server/src/pci.cc @@ -532,7 +532,7 @@ Pci_dev::discover_pci_caps() l4_umword_t msg = 0; if (l4_error(system_icu()->icu->msi_info(msi, &msg)) < 0) { - printf("WARNING: could not get MSI message, use noremal IRQ\n"); + printf("WARNING: could not get MSI message, use normal IRQ\n"); continue; } diff --git a/l4/pkg/l4con/server/src/ev.c b/l4/pkg/l4con/server/src/ev.c index 1f378f0c0..c5ae56311 100644 --- a/l4/pkg/l4con/server/src/ev.c +++ b/l4/pkg/l4con/server/src/ev.c @@ -169,6 +169,10 @@ handle_event(struct l4input *ev) /* ignored */ return; } + else if (ev->type == EV_SYN) + { + /* Pass through */ + } else { printf("handle_event: Unknown event type %d\n", ev->type); diff --git a/l4/pkg/l4re/util/include/region_mapping_svr b/l4/pkg/l4re/util/include/region_mapping_svr index 8d31d65bf..683608482 100644 --- a/l4/pkg/l4re/util/include/region_mapping_svr +++ b/l4/pkg/l4re/util/include/region_mapping_svr @@ -191,7 +191,7 @@ int region_pf_handler(RM *rm, IOS &ios) typename RM::Region_handler::Ops::Map_result result; if (int err = n->second.map(addr, n->first, writable, &result)) { - Dbg(Dbg::Warn, "rm").printf("mapping for pf failed with %d @%lx pc=%lx\n", + Dbg(Dbg::Warn, "rm").printf("mapping for page fault failed with %d @%lx pc=%lx\n", err, addr, pc); // generate exception ios << (l4_umword_t)~0; diff --git a/l4/pkg/l4sys/include/thread.h b/l4/pkg/l4sys/include/thread.h index 25f2b0fc0..14955daae 100644 --- a/l4/pkg/l4sys/include/thread.h +++ b/l4/pkg/l4sys/include/thread.h @@ -413,7 +413,9 @@ l4_thread_vcpu_resume_start_u(l4_utcb_t *utcb) L4_NOTHROW; * for the current thread. * \param tag Tag to use, returned by l4_thread_vcpu_resume_start() * - * \return System call result message tag. + * \return System call result message tag. In extended vCPU mode and when + * the virtual interrupts are cleared, the return code 1 flags an incoming + * IPC message, whereas 0 indicates a VM exit. * * To resume into another address space the capability to the target task * must be set in the vCPU-state (\see l4_vcpu_state_t). The task needs diff --git a/l4/pkg/libstdc++-v3/contrib.inc b/l4/pkg/libstdc++-v3/contrib.inc index 7e26a5fea..19590e451 100644 --- a/l4/pkg/libstdc++-v3/contrib.inc +++ b/l4/pkg/libstdc++-v3/contrib.inc @@ -34,6 +34,7 @@ ifeq ("$(GCCMAJORVERSION)", "4") endif STDCXX_CONTRIB_DIR = $(STDCXX_PKG_DIR)/contrib/libstdc++-v3-$(STDCXX_CONTRIB_VERSION) +DEFINES += -Dlinux CPU_H_x86 := i386 CPU_H_ppc32 := powerpc diff --git a/l4/pkg/libvbus/include/vbus.h b/l4/pkg/libvbus/include/vbus.h index 352846a4c..d4186e036 100644 --- a/l4/pkg/libvbus/include/vbus.h +++ b/l4/pkg/libvbus/include/vbus.h @@ -24,10 +24,10 @@ __BEGIN_DECLS /** * \brief Find a device by the HID APCI conforming or L4Io static name. * - * \param vbus capability of the system bus - * \param parent handle to the parent to start the search - * \retval child handle to the found device - * \param hid HID name of the device + * \param vbus Capability of the system bus + * \param parent Handle to the parent to start the search + * \retval child Handle to the found device + * \param hid HID name of the device * \retval devinfo Device information structure (might be NULL) * \retval reshandle Resource handle (might be NULL) * @@ -41,11 +41,11 @@ l4vbus_get_device_by_hid(l4_cap_idx_t vbus, l4vbus_device_handle_t parent, /** * \brief Find next child following \a child. * - * \param vbus capability of the system bus - * \param parent handle to the parent device (use 0 for the system bus) - * \param child handle to the child device (use 0 to get the first + * \param vbus Capability of the system bus + * \param parent Handle to the parent device (use 0 for the system bus) + * \param child Handle to the child device (use 0 to get the first * child) - * \retval next handle to the successor of child + * \retval next Handle to the successor of child * \retval devinfo device information (might be NULL) * * \return 0 on succes, else failure @@ -58,11 +58,11 @@ l4vbus_get_next_device(l4_cap_idx_t vbus, l4vbus_device_handle_t parent, /** * \brief Iterate over the resources of a device * - * \param vbus capability of the system bus - * \param dev handle of the device - * \retval res_idx Index of the resource, the number of resources is - * availabnle in the devinfo from get device functions. - * \retval res descriptor of the resource + * \param vbus Capability of the system bus + * \param dev Handle of the device + * \retval res_idx Index of the resource, the number of resources is + * availabnle in the devinfo from get device functions. + * \retval res Descriptor of the resource * * \return 0 on succes, else failure */ @@ -74,9 +74,9 @@ l4vbus_get_resource(l4_cap_idx_t vbus, l4vbus_device_handle_t dev, /** * \brief Request a resource of a specific type * - * \param vbus capability of the system bus - * \param res descriptor of the resource - * \param flags optional flags + * \param vbus Capability of the system bus + * \param res Descriptor of the resource + * \param flags Optional flags * * \return 0 on succes, else failure * @@ -95,16 +95,25 @@ l4vbus_request_resource(l4_cap_idx_t vbus, l4vbus_resource_t *res, /** * \brief Release a previously requested resource * - * \param vbus capability of the system bus - * \param res descriptor of the resource + * \param vbus Capability of the system bus. + * \param res Descriptor of the resource. * * \return 0 on succes, else failure */ int L4_CV l4vbus_release_resource(l4_cap_idx_t vbus, l4vbus_resource_t *res); +/** + * \brief Get capability of ICU. + * + * \param vbus Capability of the system bus. + * \param icu ICU device handle. + * \param cap Capability slot for the capability. + * + * \return 0 on succes, else failure + */ int L4_CV l4vbus_vicu_get_cap(l4_cap_idx_t vbus, l4vbus_device_handle_t icu, - l4_cap_idx_t res); + l4_cap_idx_t cap); __END_DECLS diff --git a/l4/pkg/libvbus/include/vbus_types.h b/l4/pkg/libvbus/include/vbus_types.h index 0902e3432..d66e1e37e 100644 --- a/l4/pkg/libvbus/include/vbus_types.h +++ b/l4/pkg/libvbus/include/vbus_types.h @@ -15,9 +15,9 @@ typedef l4_mword_t l4vbus_device_handle_t; typedef l4_addr_t l4vbus_paddr_t; typedef struct { - l4_uint16_t type; /**< resource type */ - l4_uint16_t flags; - l4vbus_paddr_t start; /**< start of res. range */ + l4_uint16_t type; /**< Resource type, see l4vbus_resource_type_t */ + l4_uint16_t flags; /**< Flags */ + l4vbus_paddr_t start; /**< Start of res. range */ l4vbus_paddr_t end; /**< (inclusive) end of res. range */ } l4vbus_resource_t; @@ -29,19 +29,18 @@ enum l4vbus_resource_type_t { L4VBUS_RESOURCE_MAX, /**< Maximum resource id */ }; -enum { +enum l4vbus_consts_t { L4VBUS_DEV_NAME_LEN = 64, L4VBUS_MAX_DEPTH = 100, }; typedef struct { - int type; /**< type */ - char name[L4VBUS_DEV_NAME_LEN]; /**< name */ - unsigned num_resources; /**< resources count */ - unsigned flags; + int type; /**< Type */ + char name[L4VBUS_DEV_NAME_LEN]; /**< Name */ + unsigned num_resources; /**< Resources count */ + unsigned flags; /**< Flags */ } l4vbus_device_t; -enum -{ +enum l4vbus_device_flags_t { L4VBUS_DEVICE_F_CHILDREN = 0x10, }; diff --git a/l4/pkg/libvcpu/include/vcpu b/l4/pkg/libvcpu/include/vcpu index 2e7a21d84..4ba4efd70 100644 --- a/l4/pkg/libvcpu/include/vcpu +++ b/l4/pkg/libvcpu/include/vcpu @@ -32,6 +32,12 @@ class State { public: State() {} + + /** + * \brief Initialize state. + * + * \param v Initial state. + */ explicit State(l4vcpu_state_t v) : _s(v) {} /** @@ -66,6 +72,9 @@ private: class Vcpu : private l4_vcpu_state_t { public: + /** + * \brief IRQ status type. + */ typedef l4vcpu_irq_state_t Irq_state; /** @@ -112,8 +121,11 @@ public: /** * \brief Enable the vCPU for event delivery. * + * \param utcb The UTCB to use. * \param do_event_work_cb Call-back function that is called in case an * event (such as an interrupt) is pending. + * \param setup_ipc Call-back function that is called before an + * IPC operation is called. */ void irq_enable(l4_utcb_t *utcb, l4vcpu_event_hndl_t do_event_work_cb, l4vcpu_setup_ipc_t setup_ipc) throw() @@ -123,14 +135,26 @@ public: * \brief Restore a previously saved IRQ/event state. * * \param s IRQ state to be restored. + * \param utcb The UTCB to use. * \param do_event_work_cb Call-back function that is called in case an * event (such as an interrupt) is pending. + * \param setup_ipc Call-back function that is called before an + * IPC operation is called. */ void irq_restore(Irq_state s, l4_utcb_t *utcb, l4vcpu_event_hndl_t do_event_work_cb, l4vcpu_setup_ipc_t setup_ipc) throw() { l4vcpu_irq_restore(this, s, utcb, do_event_work_cb, setup_ipc); } + /** + * \brief Halt/block the vCPU. + * + * \param utcb The UTCB to use. + * \param do_event_work_cb Call-back function that is called in case an + * event (such as an interrupt) is pending. + * \param setup_ipc Call-back function that is called before an + * IPC operation is called. + */ void halt(l4_utcb_t *utcb, l4vcpu_event_hndl_t do_event_work_cb, l4vcpu_setup_ipc_t setup_ipc) throw() { l4vcpu_halt(this, utcb, do_event_work_cb, setup_ipc); } @@ -195,7 +219,7 @@ public: /** * \brief Set vCPU entry instruction pointer. - * \param sp Instruction pointer address to set. + * \param ip Instruction pointer address to set. */ void entry_ip(l4_umword_t ip) { l4_vcpu_state_t::entry_ip = ip; } diff --git a/l4/pkg/libvcpu/lib/src/vcpu.cc b/l4/pkg/libvcpu/lib/src/vcpu.cc index 16d14200c..51bbe1be1 100644 --- a/l4/pkg/libvcpu/lib/src/vcpu.cc +++ b/l4/pkg/libvcpu/lib/src/vcpu.cc @@ -25,9 +25,9 @@ L4_CV void l4vcpu_print_state(l4_vcpu_state_t *vcpu, const char *prefix) L4_NOTHROW { - printf("%svcpu=%p state=%lx savedstate=%lx label=%lx\n", + printf("%svcpu=%p state=%x savedstate=%x label=%lx\n", prefix, vcpu, vcpu->state, vcpu->saved_state, vcpu->i.label); - printf("%ssticky=%lx user_task=%lx\n", + printf("%ssticky=%x user_task=%lx\n", prefix, vcpu->sticky_flags, vcpu->user_task << L4_CAP_SHIFT); printf("%sentry_sp=%lx entry_ip=%lx\n", prefix, vcpu->entry_sp, vcpu->entry_ip); @@ -54,7 +54,7 @@ do_l4vcpu_ext_alloc(L4vcpu::Vcpu **vcpu, L4_CV int l4vcpu_ext_alloc(l4_vcpu_state_t **vcpu, l4_addr_t *ext_state, - l4_cap_idx_t task, l4_cap_idx_t regmgr) L4_NOTHROW + l4_cap_idx_t task, l4_cap_idx_t regmgr) L4_NOTHROW { L4::Cap t(task); L4::Cap r(regmgr); -- 2.39.2