diff --git a/repos/base-fiasco/README b/repos/base-fiasco/README index 8129cac57a..c2ad1c696c 100644 --- a/repos/base-fiasco/README +++ b/repos/base-fiasco/README @@ -1,4 +1 @@ This repository contains the L4/Fiasco-specific implementation of Genode. - -For instructions to build and start the Fiasco version of Genode, please -consult the documentation located at 'base-fiasco/doc/fiasco.txt'. diff --git a/repos/base-fiasco/src/core/core_log_out.cc b/repos/base-fiasco/src/core/core_log_out.cc index bdc969e912..7ccdcd68b5 100644 --- a/repos/base-fiasco/src/core/core_log_out.cc +++ b/repos/base-fiasco/src/core/core_log_out.cc @@ -14,7 +14,10 @@ /* core includes */ #include -namespace Fiasco { -#include -} -void Genode::Core_log::out(char const c) { Fiasco::outchar(c); } +/* L4/Fiasco includes */ +#include + +using namespace Genode; + + +void Core_log::out(char const c) { Fiasco::outchar(c); } diff --git a/repos/base-fiasco/src/core/include/ipc_pager.h b/repos/base-fiasco/src/core/include/ipc_pager.h index 083c6c09ac..b0cca99ecc 100644 --- a/repos/base-fiasco/src/core/include/ipc_pager.h +++ b/repos/base-fiasco/src/core/include/ipc_pager.h @@ -27,154 +27,153 @@ /* core includes */ #include -/* Fiasco includes */ -namespace Fiasco { -#include -} +/* L4/Fiasco includes */ +#include namespace Genode { - class Mapping - { - private: - - addr_t _dst_addr; - Fiasco::l4_fpage_t _fpage; - - public: - - /** - * Constructor - */ - Mapping(addr_t dst_addr, addr_t src_addr, - Cache_attribute cacheability, bool, - unsigned l2size, bool rw, bool) - : - _dst_addr(dst_addr), - _fpage(Fiasco::l4_fpage(src_addr, l2size, rw, false)) - { - if (cacheability == WRITE_COMBINED) - _fpage.fp.cache = Fiasco::L4_FPAGE_BUFFERABLE; - } - - /** - * Construct invalid flexpage - */ - Mapping() : _dst_addr(0), _fpage(Fiasco::l4_fpage(0, 0, 0, 0)) { } - - Fiasco::l4_umword_t dst_addr() const { return _dst_addr; } - Fiasco::l4_fpage_t fpage() const { return _fpage; } - - /** - * Prepare map operation - * - * On Fiasco, we need to map a page locally to be able to map it to - * another address space. - */ - void prepare_map_operation() - { - addr_t core_local_addr = _fpage.fp.page << 12; - size_t mapping_size = 1 << _fpage.fp.size; - - for (addr_t i = 0; i < mapping_size; i += L4_PAGESIZE) { - if (_fpage.fp.write) - touch_read_write((unsigned char volatile *)(core_local_addr + i)); - else - touch_read((unsigned char const volatile *)(core_local_addr + i)); - } - } - }; - - - /** - * Special paging server class - */ - class Ipc_pager - { - private: - - Fiasco::l4_threadid_t _last { }; /* origin of last fault message */ - addr_t _pf_addr { 0 }; /* page-fault address */ - addr_t _pf_ip { 0 }; /* instruction pointer of faulter */ - Mapping _reply_mapping { }; /* page-fault answer */ - - public: - - /** - * Wait for a new page fault received as short message IPC - */ - void wait_for_fault(); - - /** - * Reply current page-fault and wait for a new one - * - * Send short flex page and wait for next short-message (register) - * IPC -- pagefault - */ - void reply_and_wait_for_fault(); - - /** - * Request instruction pointer of current page fault - */ - addr_t fault_ip() { return _pf_ip; } - - /** - * Request fault address of current page fault - */ - addr_t fault_addr() { return _pf_addr & ~3; } - - /** - * Set parameters for next reply - */ - void set_reply_mapping(Mapping m) { _reply_mapping = m; } - - /** - * Set destination for next reply - */ - void set_reply_dst(Native_capability pager_object) { - _last.raw = pager_object.local_name(); } - - /** - * Answer call without sending a flex-page mapping - * - * This function is used to acknowledge local calls from one of - * core's region-manager sessions. - */ - void acknowledge_wakeup(); - - /** - * Returns true if the last request was send from a core thread - */ - bool request_from_core() - { - enum { CORE_TASK_ID = 4 }; - return _last.id.task == CORE_TASK_ID; - } - - /** - * Return badge for faulting thread - * - * As Fiasco has no server-defined badges for page-fault messages, we - * interpret the sender ID as badge. - */ - unsigned long badge() const { - return convert_native_thread_id_to_badge(_last); } - - bool write_fault() const { return (_pf_addr & 2); } - - bool exec_fault() const { return false; } - - /** - * Return true if last fault was an exception - */ - bool exception() const - { - /* - * Reflection of exceptions is not supported on this platform. - */ - return false; - } - }; + class Mapping; + class Ipc_pager; } + +class Genode::Mapping +{ + private: + + addr_t _dst_addr; + Fiasco::l4_fpage_t _fpage; + + public: + + /** + * Constructor + */ + Mapping(addr_t dst_addr, addr_t src_addr, + Cache_attribute cacheability, bool, + unsigned l2size, bool rw, bool) + : + _dst_addr(dst_addr), + _fpage(Fiasco::l4_fpage(src_addr, l2size, rw, false)) + { + if (cacheability == WRITE_COMBINED) + _fpage.fp.cache = Fiasco::L4_FPAGE_BUFFERABLE; + } + + /** + * Construct invalid flexpage + */ + Mapping() : _dst_addr(0), _fpage(Fiasco::l4_fpage(0, 0, 0, 0)) { } + + Fiasco::l4_umword_t dst_addr() const { return _dst_addr; } + Fiasco::l4_fpage_t fpage() const { return _fpage; } + + /** + * Prepare map operation + * + * On Fiasco, we need to map a page locally to be able to map it to + * another address space. + */ + void prepare_map_operation() + { + addr_t core_local_addr = _fpage.fp.page << 12; + size_t mapping_size = 1 << _fpage.fp.size; + + for (addr_t i = 0; i < mapping_size; i += L4_PAGESIZE) { + if (_fpage.fp.write) + touch_read_write((unsigned char volatile *)(core_local_addr + i)); + else + touch_read((unsigned char const volatile *)(core_local_addr + i)); + } + } +}; + + +class Genode::Ipc_pager +{ + private: + + Fiasco::l4_threadid_t _last { }; /* origin of last fault message */ + addr_t _pf_addr { 0 }; /* page-fault address */ + addr_t _pf_ip { 0 }; /* instruction pointer of faulter */ + Mapping _reply_mapping { }; /* page-fault answer */ + + public: + + /** + * Wait for a new page fault received as short message IPC + */ + void wait_for_fault(); + + /** + * Reply current page-fault and wait for a new one + * + * Send short flex page and wait for next short-message (register) + * IPC -- pagefault + */ + void reply_and_wait_for_fault(); + + /** + * Request instruction pointer of current page fault + */ + addr_t fault_ip() { return _pf_ip; } + + /** + * Request fault address of current page fault + */ + addr_t fault_addr() { return _pf_addr & ~3; } + + /** + * Set parameters for next reply + */ + void set_reply_mapping(Mapping m) { _reply_mapping = m; } + + /** + * Set destination for next reply + */ + void set_reply_dst(Native_capability pager_object) { + _last.raw = pager_object.local_name(); } + + /** + * Answer call without sending a flex-page mapping + * + * This function is used to acknowledge local calls from one of + * core's region-manager sessions. + */ + void acknowledge_wakeup(); + + /** + * Returns true if the last request was send from a core thread + */ + bool request_from_core() + { + enum { CORE_TASK_ID = 4 }; + return _last.id.task == CORE_TASK_ID; + } + + /** + * Return badge for faulting thread + * + * As Fiasco has no server-defined badges for page-fault messages, we + * interpret the sender ID as badge. + */ + unsigned long badge() const { + return convert_native_thread_id_to_badge(_last); } + + bool write_fault() const { return (_pf_addr & 2); } + + bool exec_fault() const { return false; } + + /** + * Return true if last fault was an exception + */ + bool exception() const + { + /* + * Reflection of exceptions is not supported on this platform. + */ + return false; + } +}; + #endif /* _CORE__INCLUDE__IPC_PAGER_H_ */ diff --git a/repos/base-fiasco/src/core/include/map_local.h b/repos/base-fiasco/src/core/include/map_local.h index c28bca4f28..dc0d7063ce 100644 --- a/repos/base-fiasco/src/core/include/map_local.h +++ b/repos/base-fiasco/src/core/include/map_local.h @@ -18,12 +18,8 @@ #include #include -/* Fiasco includes */ -namespace Fiasco { -#include -#include -#include -} +/* L4/Fiasco includes */ +#include namespace Genode { diff --git a/repos/base-fiasco/src/core/include/platform.h b/repos/base-fiasco/src/core/include/platform.h index 17e2b3f6a3..918c6fd799 100644 --- a/repos/base-fiasco/src/core/include/platform.h +++ b/repos/base-fiasco/src/core/include/platform.h @@ -15,9 +15,13 @@ #ifndef _CORE__INCLUDE__PLATFORM_H_ #define _CORE__INCLUDE__PLATFORM_H_ +/* Genode includes */ #include + +/* base-internal includes */ #include +/* core includes */ #include #include #include @@ -25,150 +29,149 @@ #include #include +namespace Genode { class Platform; } -namespace Genode { - class Platform : public Platform_generic - { - private: +class Genode::Platform : public Platform_generic +{ + private: - /* - * Noncopyable - */ - Platform(Platform const &); - Platform &operator = (Platform const &); + /* + * Noncopyable + */ + Platform(Platform const &); + Platform &operator = (Platform const &); - /* - * Shortcut for the type of allocator instances for physical resources - */ - typedef Synced_range_allocator Phys_allocator; + /* + * Shortcut for the type of allocator instances for physical resources + */ + typedef Synced_range_allocator Phys_allocator; - char _core_label[1]; /* to satisfy _core_pd */ - Platform_pd *_core_pd = nullptr; /* core protection domain object */ - Phys_allocator _ram_alloc; /* RAM allocator */ - Phys_allocator _io_mem_alloc; /* MMIO allocator */ - Phys_allocator _io_port_alloc; /* I/O port allocator */ - Phys_allocator _irq_alloc; /* IRQ allocator */ - Phys_allocator _region_alloc; /* virtual memory allocator for core */ - Rom_fs _rom_fs { }; /* ROM file system */ - Rom_module _kip_rom; /* ROM module for Fiasco KIP */ + char _core_label[1]; /* to satisfy _core_pd */ + Platform_pd *_core_pd = nullptr; /* core protection domain object */ + Phys_allocator _ram_alloc; /* RAM allocator */ + Phys_allocator _io_mem_alloc; /* MMIO allocator */ + Phys_allocator _io_port_alloc; /* I/O port allocator */ + Phys_allocator _irq_alloc; /* IRQ allocator */ + Phys_allocator _region_alloc; /* virtual memory allocator for core */ + Rom_fs _rom_fs { }; /* ROM file system */ + Rom_module _kip_rom; /* ROM module for Fiasco KIP */ - addr_t _vm_start = 0; /* begin of virtual memory */ - size_t _vm_size = 0; /* size of virtual memory */ + addr_t _vm_start = 0; /* begin of virtual memory */ + size_t _vm_size = 0; /* size of virtual memory */ - /* - * We do not export any boot module loaded before FIRST_ROM. - */ - enum { FIRST_ROM = 3 }; + /* + * We do not export any boot module loaded before FIRST_ROM. + */ + enum { FIRST_ROM = 3 }; - /** - * Setup base resources - * - * - Map and provide KIP as ROM module - * - Initializes region allocator - */ - void _setup_basics(); + /** + * Setup base resources + * + * - Map and provide KIP as ROM module + * - Initializes region allocator + */ + void _setup_basics(); - /** - * Setup RAM, IO_MEM, and region allocators - */ - void _setup_mem_alloc(); + /** + * Setup RAM, IO_MEM, and region allocators + */ + void _setup_mem_alloc(); - /** - * Setup I/O port space allocator - */ - void _setup_io_port_alloc(); + /** + * Setup I/O port space allocator + */ + void _setup_io_port_alloc(); - /** - * Setup IRQ allocator - */ - void _setup_irq_alloc(); + /** + * Setup IRQ allocator + */ + void _setup_irq_alloc(); - /** - * Parse multi-boot information and update ROM database - */ - void _init_rom_modules(); + /** + * Parse multi-boot information and update ROM database + */ + void _init_rom_modules(); - /** - * Setup pager for core-internal threads - */ - void _setup_core_pager(); + /** + * Setup pager for core-internal threads + */ + void _setup_core_pager(); - addr_t _rom_module_phys(addr_t virt) { return virt; } + addr_t _rom_module_phys(addr_t virt) { return virt; } - public: - - /** - * Pager object representing the pager of core namely sigma0 - */ - struct Sigma0 : public Pager_object - { - /** - * Constructor - */ - Sigma0(); - - int pager(Ipc_pager &) override { /* never called */ return -1; } - }; - - /** - * Return singleton instance of Sigma0 pager object - */ - static Sigma0 &sigma0(); - - /** - * Core pager thread that handles core-internal page-faults - */ - struct Core_pager : public Platform_thread, public Pager_object - { - /** - * Constructor - */ - Core_pager(Platform_pd &core_pd); - - int pager(Ipc_pager &) override { /* never called */ return -1; } - }; - - /** - * Return singleton instance of core pager object - */ - Core_pager &core_pager(); + public: + /** + * Pager object representing the pager of core namely sigma0 + */ + struct Sigma0 : public Pager_object + { /** * Constructor */ - Platform(); + Sigma0(); + int pager(Ipc_pager &) override { /* never called */ return -1; } + }; + + /** + * Return singleton instance of Sigma0 pager object + */ + static Sigma0 &sigma0(); + + /** + * Core pager thread that handles core-internal page-faults + */ + struct Core_pager : public Platform_thread, public Pager_object + { /** - * Accessor for core pd object + * Constructor */ - Platform_pd &core_pd() - { - if (_core_pd) - return *_core_pd; + Core_pager(Platform_pd &core_pd); - ASSERT_NEVER_CALLED; - } + int pager(Ipc_pager &) override { /* never called */ return -1; } + }; + + /** + * Return singleton instance of core pager object + */ + Core_pager &core_pager(); + + /** + * Constructor + */ + Platform(); + + /** + * Accessor for core pd object + */ + Platform_pd &core_pd() + { + if (_core_pd) + return *_core_pd; + + ASSERT_NEVER_CALLED; + } - /******************************** - ** Generic platform interface ** - ********************************/ + /******************************** + ** Generic platform interface ** + ********************************/ - Range_allocator &core_mem_alloc() override { return _ram_alloc; } - Range_allocator &ram_alloc() override { return _ram_alloc; } - Range_allocator &io_mem_alloc() override { return _io_mem_alloc; } - Range_allocator &io_port_alloc() override { return _io_port_alloc; } - Range_allocator &irq_alloc() override { return _irq_alloc; } - Range_allocator ®ion_alloc() override { return _region_alloc; } - addr_t vm_start() const override { return _vm_start; } - size_t vm_size() const override { return _vm_size; } - Rom_fs &rom_fs() override { return _rom_fs; } + Range_allocator &core_mem_alloc() override { return _ram_alloc; } + Range_allocator &ram_alloc() override { return _ram_alloc; } + Range_allocator &io_mem_alloc() override { return _io_mem_alloc; } + Range_allocator &io_port_alloc() override { return _io_port_alloc; } + Range_allocator &irq_alloc() override { return _irq_alloc; } + Range_allocator ®ion_alloc() override { return _region_alloc; } + addr_t vm_start() const override { return _vm_start; } + size_t vm_size() const override { return _vm_size; } + Rom_fs &rom_fs() override { return _rom_fs; } - size_t max_caps() const override { return Capability_space::max_caps(); } + size_t max_caps() const override { return Capability_space::max_caps(); } - void wait_for_exit() override; - }; -} + void wait_for_exit() override; +}; #endif /* _CORE__INCLUDE__PLATFORM_H_ */ diff --git a/repos/base-fiasco/src/core/include/platform_pd.h b/repos/base-fiasco/src/core/include/platform_pd.h index 8dbd4c415c..1b139f7000 100644 --- a/repos/base-fiasco/src/core/include/platform_pd.h +++ b/repos/base-fiasco/src/core/include/platform_pd.h @@ -17,188 +17,193 @@ #ifndef _CORE__INCLUDE__PLATFORM_PD_H_ #define _CORE__INCLUDE__PLATFORM_PD_H_ +/* Genode includes */ #include + +/* core includes */ #include #include -namespace Fiasco { -#include -} +/* L4/Fiasco includes */ +#include namespace Genode { class Platform_thread; - class Platform_pd : public Address_space - { - private: - - /* - * Noncopyable - */ - Platform_pd(Platform_pd const &); - Platform_pd &operator = (Platform_pd const &); - - enum { - VERSION_BITS = 10, - PD_FIRST = 0x10, - PD_MAX = (1 << 11) - 1, /* leave 0x7ff free for L4_INVALID_ID */ - PD_VERSION_MAX = (1 << 10) - 1, - PD_INVALID = -1, - THREAD_MAX = (1 << 7), - }; - - unsigned _pd_id = 0; - unsigned _version = 0; - - Fiasco::l4_taskid_t _l4_task_id { }; /* L4 task ID */ - - - /********************************************** - ** Threads of this protection domain object ** - **********************************************/ - - Platform_thread *_threads[THREAD_MAX]; - - /** - * Initialize thread allocator - */ - void _init_threads(); - - /** - * Thread iteration for one task - */ - Platform_thread *_next_thread(); - - /** - * Thread allocation - * - * Again a special case for Core thread0. - */ - int _alloc_thread(int thread_id, Platform_thread &thread); - - /** - * Thread deallocation - * - * No special case for Core thread0 here - we just never call it. - */ - void _free_thread(int thread_id); - - - /****************** - ** PD allocator ** - ******************/ - - struct Pd_alloc - { - unsigned reserved : 1; - unsigned free : 1; - unsigned version : VERSION_BITS; - - Pd_alloc(bool r, bool f, unsigned v) - : reserved(r), free(f), version(v) { } - - Pd_alloc() : reserved(0), free(0), version(0) { } - }; - - static Pd_alloc *_pds() - { - static Pd_alloc static_pds[PD_MAX]; - return static_pds; - } - - /** - * Protection-domain creation - * - * The syscall parameter propagates if any L4 kernel function - * should be used. We need the special case for the Core startup. - */ - void _create_pd(bool syscall); - - /** - * Protection domain destruction - * - * No special case for Core here - we just never call it. - */ - void _destroy_pd(); - - /** - * Protection domain allocation - * - * Find free L4 task and use it. We need the special case for Core - * startup. - */ - int _alloc_pd(signed pd_id); - - /** - * Protection domain deallocation - * - * No special case for Core here - we just never call it. - */ - void _free_pd(); - - - /*************** - ** Debugging ** - ***************/ - - void _debug_log_pds(void); - void _debug_log_threads(void); - - public: - - /** - * Constructor - */ - Platform_pd(Allocator &md_alloc, char const *name); - - /** - * Constructor used for core's PD - */ - Platform_pd(char const *name, signed pd_id); - - /** - * Destructor - */ - ~Platform_pd(); - - /** - * Register quota donation at allocator guard - */ - void upgrade_ram_quota(size_t) { } - - /** - * Initialize L4 task facility - */ - static void init(); - - /** - * Bind thread to protection domain - * - * \return true on success - */ - bool bind_thread(Platform_thread &thread); - - /** - * Unbind thread from protection domain - * - * Free the thread's slot and update thread object. - */ - void unbind_thread(Platform_thread &thread); - - /** - * Assign parent interface to protection domain - */ - void assign_parent(Native_capability) { } - - int pd_id() const { return _pd_id; } - - - /***************************** - ** Address-space interface ** - *****************************/ - - void flush(addr_t, size_t, Core_local_addr) override; - }; + class Platform_pd; } + +class Genode::Platform_pd : public Address_space +{ + private: + + /* + * Noncopyable + */ + Platform_pd(Platform_pd const &); + Platform_pd &operator = (Platform_pd const &); + + enum { + VERSION_BITS = 10, + PD_FIRST = 0x10, + PD_MAX = (1 << 11) - 1, /* leave 0x7ff free for L4_INVALID_ID */ + PD_VERSION_MAX = (1 << 10) - 1, + PD_INVALID = -1, + THREAD_MAX = (1 << 7), + }; + + unsigned _pd_id = 0; + unsigned _version = 0; + + Fiasco::l4_taskid_t _l4_task_id { }; /* L4 task ID */ + + + /********************************************** + ** Threads of this protection domain object ** + **********************************************/ + + Platform_thread *_threads[THREAD_MAX]; + + /** + * Initialize thread allocator + */ + void _init_threads(); + + /** + * Thread iteration for one task + */ + Platform_thread *_next_thread(); + + /** + * Thread allocation + * + * Again a special case for Core thread0. + */ + int _alloc_thread(int thread_id, Platform_thread &thread); + + /** + * Thread deallocation + * + * No special case for Core thread0 here - we just never call it. + */ + void _free_thread(int thread_id); + + + /****************** + ** PD allocator ** + ******************/ + + struct Pd_alloc + { + unsigned reserved : 1; + unsigned free : 1; + unsigned version : VERSION_BITS; + + Pd_alloc(bool r, bool f, unsigned v) + : reserved(r), free(f), version(v) { } + + Pd_alloc() : reserved(0), free(0), version(0) { } + }; + + static Pd_alloc *_pds() + { + static Pd_alloc static_pds[PD_MAX]; + return static_pds; + } + + /** + * Protection-domain creation + * + * The syscall parameter propagates if any L4 kernel function + * should be used. We need the special case for the Core startup. + */ + void _create_pd(bool syscall); + + /** + * Protection domain destruction + * + * No special case for Core here - we just never call it. + */ + void _destroy_pd(); + + /** + * Protection domain allocation + * + * Find free L4 task and use it. We need the special case for Core + * startup. + */ + int _alloc_pd(signed pd_id); + + /** + * Protection domain deallocation + * + * No special case for Core here - we just never call it. + */ + void _free_pd(); + + + /*************** + ** Debugging ** + ***************/ + + void _debug_log_pds(void); + void _debug_log_threads(void); + + public: + + /** + * Constructor + */ + Platform_pd(Allocator &md_alloc, char const *name); + + /** + * Constructor used for core's PD + */ + Platform_pd(char const *name, signed pd_id); + + /** + * Destructor + */ + ~Platform_pd(); + + /** + * Register quota donation at allocator guard + */ + void upgrade_ram_quota(size_t) { } + + /** + * Initialize L4 task facility + */ + static void init(); + + /** + * Bind thread to protection domain + * + * \return true on success + */ + bool bind_thread(Platform_thread &thread); + + /** + * Unbind thread from protection domain + * + * Free the thread's slot and update thread object. + */ + void unbind_thread(Platform_thread &thread); + + /** + * Assign parent interface to protection domain + */ + void assign_parent(Native_capability) { } + + int pd_id() const { return _pd_id; } + + + /***************************** + ** Address-space interface ** + *****************************/ + + void flush(addr_t, size_t, Core_local_addr) override; +}; + #endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */ diff --git a/repos/base-fiasco/src/core/include/platform_thread.h b/repos/base-fiasco/src/core/include/platform_thread.h index c2313cda5e..5832fdbb12 100644 --- a/repos/base-fiasco/src/core/include/platform_thread.h +++ b/repos/base-fiasco/src/core/include/platform_thread.h @@ -24,167 +24,169 @@ #include #include -/* Fiasco includes */ -namespace Fiasco { -#include -} +/* L4/Fiasco includes */ +#include namespace Genode { class Platform_pd; - class Platform_thread : Interface - { - private: - - /* - * Noncopyable - */ - Platform_thread(Platform_thread const &); - Platform_thread &operator = (Platform_thread const &); - - int _thread_id = THREAD_INVALID; /* plain thread number */ - - Fiasco::l4_threadid_t _l4_thread_id; - - typedef String<32> Name; - Name const _name; /* thread name that will be - registered at the kernel - debugger */ - Platform_pd *_platform_pd = nullptr; /* protection domain thread - is bound to */ - Pager_object *_pager = nullptr; - - public: - - enum { - THREAD_INVALID = -1, /* invalid thread number */ - }; - - /** - * Constructor - */ - Platform_thread(size_t, const char *name, unsigned priority, - Affinity::Location, addr_t utcb); - - /** - * Constructor used for core-internal threads - */ - Platform_thread(const char *name); - - /** - * Destructor - */ - ~Platform_thread(); - - /** - * Start thread - * - * \param ip instruction pointer to start at - * \param sp stack pointer to use - * - * \retval 0 successful - * \retval -1 thread could not be started - */ - int start(void *ip, void *sp); - - /** - * Pause this thread - */ - void pause(); - - /** - * Enable/disable single stepping - */ - void single_step(bool) { } - - /** - * Resume this thread - */ - void resume(); - - /** - * This thread is about to be bound - * - * \param thread_id local thread ID - * \param l4_thread_id final L4 thread ID - * \param pd platform pd, thread is bound to - */ - void bind(int thread_id, Fiasco::l4_threadid_t l4_thread_id, - Platform_pd &pd); - - /** - * Unbind this thread - */ - void unbind(); - - /** - * Override thread state with 's' - * - * \throw Cpu_session::State_access_failed - */ - void state(Thread_state s); - - /** - * Read thread state - * - * \throw Cpu_session::State_access_failed - */ - Thread_state state(); - - /** - * Set the executing CPU for this thread - * - * SMP is not supported on L4/Fiasco. - */ - void affinity(Affinity::Location) { } - - /** - * Request the affinity of this thread - */ - Affinity::Location affinity() const { return Affinity::Location(); } - - /************************ - ** Accessor functions ** - ************************/ - - /** - * Return/set pager - */ - Pager_object &pager() const - { - if (_pager) - return *_pager; - - ASSERT_NEVER_CALLED; - } - - void pager(Pager_object &pager) { _pager = &pager; } - - /** - * Return identification of thread when faulting - */ - unsigned long pager_object_badge() const { - return convert_native_thread_id_to_badge(_l4_thread_id); } - - /** - * Set CPU quota of the thread to 'quota' - */ - void quota(size_t) { /* not supported*/ } - - /** - * Return execution time consumed by the thread - */ - Trace::Execution_time execution_time() const { return { 0, 0 }; } - - - /******************************* - ** Fiasco-specific Accessors ** - *******************************/ - - int thread_id() const { return _thread_id; } - Fiasco::l4_threadid_t native_thread_id() const { return _l4_thread_id; } - Name name() const { return _name; } - }; + class Platform_thread; } + +class Genode::Platform_thread : Interface +{ + private: + + /* + * Noncopyable + */ + Platform_thread(Platform_thread const &); + Platform_thread &operator = (Platform_thread const &); + + int _thread_id = THREAD_INVALID; /* plain thread number */ + + Fiasco::l4_threadid_t _l4_thread_id; + + typedef String<32> Name; + Name const _name; /* thread name that will be + registered at the kernel + debugger */ + Platform_pd *_platform_pd = nullptr; /* protection domain thread + is bound to */ + Pager_object *_pager = nullptr; + + public: + + enum { + THREAD_INVALID = -1, /* invalid thread number */ + }; + + /** + * Constructor + */ + Platform_thread(size_t, const char *name, unsigned priority, + Affinity::Location, addr_t utcb); + + /** + * Constructor used for core-internal threads + */ + Platform_thread(const char *name); + + /** + * Destructor + */ + ~Platform_thread(); + + /** + * Start thread + * + * \param ip instruction pointer to start at + * \param sp stack pointer to use + * + * \retval 0 successful + * \retval -1 thread could not be started + */ + int start(void *ip, void *sp); + + /** + * Pause this thread + */ + void pause(); + + /** + * Enable/disable single stepping + */ + void single_step(bool) { } + + /** + * Resume this thread + */ + void resume(); + + /** + * This thread is about to be bound + * + * \param thread_id local thread ID + * \param l4_thread_id final L4 thread ID + * \param pd platform pd, thread is bound to + */ + void bind(int thread_id, Fiasco::l4_threadid_t l4_thread_id, + Platform_pd &pd); + + /** + * Unbind this thread + */ + void unbind(); + + /** + * Override thread state with 's' + * + * \throw Cpu_session::State_access_failed + */ + void state(Thread_state s); + + /** + * Read thread state + * + * \throw Cpu_session::State_access_failed + */ + Thread_state state(); + + /** + * Set the executing CPU for this thread + * + * SMP is not supported on L4/Fiasco. + */ + void affinity(Affinity::Location) { } + + /** + * Request the affinity of this thread + */ + Affinity::Location affinity() const { return Affinity::Location(); } + + + /************************ + ** Accessor functions ** + ************************/ + + /** + * Return/set pager + */ + Pager_object &pager() const + { + if (_pager) + return *_pager; + + ASSERT_NEVER_CALLED; + } + + void pager(Pager_object &pager) { _pager = &pager; } + + /** + * Return identification of thread when faulting + */ + unsigned long pager_object_badge() const { + return convert_native_thread_id_to_badge(_l4_thread_id); } + + /** + * Set CPU quota of the thread to 'quota' + */ + void quota(size_t) { /* not supported*/ } + + /** + * Return execution time consumed by the thread + */ + Trace::Execution_time execution_time() const { return { 0, 0 }; } + + + /******************************* + ** Fiasco-specific Accessors ** + *******************************/ + + int thread_id() const { return _thread_id; } + Fiasco::l4_threadid_t native_thread_id() const { return _l4_thread_id; } + Name name() const { return _name; } +}; + #endif /* _CORE__INCLUDE__PLATFORM_THREAD_H_ */ diff --git a/repos/base-fiasco/src/core/include/rpc_cap_factory.h b/repos/base-fiasco/src/core/include/rpc_cap_factory.h index f28c36414d..4ef13ade6e 100644 --- a/repos/base-fiasco/src/core/include/rpc_cap_factory.h +++ b/repos/base-fiasco/src/core/include/rpc_cap_factory.h @@ -14,11 +14,13 @@ #ifndef _CORE__INCLUDE__RPC_CAP_FACTORY_H_ #define _CORE__INCLUDE__RPC_CAP_FACTORY_H_ +/* Genode includes */ #include #include namespace Genode { class Rpc_cap_factory; } + class Genode::Rpc_cap_factory { private: diff --git a/repos/base-fiasco/src/core/include/util.h b/repos/base-fiasco/src/core/include/util.h index 0e7f34e705..d6bac861e4 100644 --- a/repos/base-fiasco/src/core/include/util.h +++ b/repos/base-fiasco/src/core/include/util.h @@ -25,13 +25,8 @@ #include #include -/* Fiasco includes */ -namespace Fiasco { -#include -#include -#include -#include -} +/* L4/Fiasco includes */ +#include namespace Genode { diff --git a/repos/base-fiasco/src/core/io_mem_session_support.cc b/repos/base-fiasco/src/core/io_mem_session_support.cc index 993dce6c41..53517c9b0e 100644 --- a/repos/base-fiasco/src/core/io_mem_session_support.cc +++ b/repos/base-fiasco/src/core/io_mem_session_support.cc @@ -16,11 +16,8 @@ #include #include -/* Fiasco includes */ -namespace Fiasco { -#include -#include -} +/* L4/Fiasco includes */ +#include using namespace Genode; diff --git a/repos/base-fiasco/src/core/irq_session_component.cc b/repos/base-fiasco/src/core/irq_session_component.cc index 0515cc1455..c775e71a98 100644 --- a/repos/base-fiasco/src/core/irq_session_component.cc +++ b/repos/base-fiasco/src/core/irq_session_component.cc @@ -19,15 +19,12 @@ #include #include -/* Fiasco includes */ -namespace Fiasco { -#include -#include -#include -} +/* L4/Fiasco includes */ +#include using namespace Genode; + bool Irq_object::_associate() { using namespace Fiasco; @@ -74,7 +71,9 @@ void Irq_object::_wait_for_irq() L4_IPC_SHORT_MSG, &dw0, &dw1, L4_IPC_NEVER, &result); - if (L4_IPC_IS_ERROR(result)) error("Ipc error ", L4_IPC_ERROR(result)); + if (L4_IPC_IS_ERROR(result)) + error("Ipc error ", L4_IPC_ERROR(result)); + } while (L4_IPC_IS_ERROR(result)); } @@ -106,7 +105,7 @@ void Irq_object::entry() if (!_sig_cap.valid()) continue; - Genode::Signal_transmitter(_sig_cap).submit(1); + Signal_transmitter(_sig_cap).submit(1); _sync_ack.block(); } @@ -142,7 +141,7 @@ Irq_session_component::Irq_session_component(Range_allocator &irq_alloc, Irq_session_component::~Irq_session_component() { - error("Not yet implemented."); + error(__func__, " - not implemented"); } @@ -152,13 +151,13 @@ void Irq_session_component::ack_irq() } -void Irq_session_component::sigh(Genode::Signal_context_capability cap) +void Irq_session_component::sigh(Signal_context_capability cap) { _irq_object.sigh(cap); } -Genode::Irq_session::Info Irq_session_component::info() +Irq_session::Info Irq_session_component::info() { /* no MSI support */ return { .type = Info::Type::INVALID, .address = 0, .value = 0 }; diff --git a/repos/base-fiasco/src/core/pager.cc b/repos/base-fiasco/src/core/pager.cc index bfb242ff63..83242e557b 100644 --- a/repos/base-fiasco/src/core/pager.cc +++ b/repos/base-fiasco/src/core/pager.cc @@ -22,10 +22,8 @@ #include #include -namespace Fiasco { -#include -#include -} +/* L4/Fiasco includes */ +#include using namespace Genode; using namespace Fiasco; @@ -37,7 +35,7 @@ using namespace Fiasco; void Ipc_pager::wait_for_fault() { - l4_msgdope_t result; + l4_msgdope_t result; do { l4_ipc_wait(&_last, @@ -53,7 +51,7 @@ void Ipc_pager::wait_for_fault() void Ipc_pager::reply_and_wait_for_fault() { - l4_msgdope_t result; + l4_msgdope_t result; l4_ipc_reply_and_wait(_last, L4_IPC_SHORT_FPAGE, _reply_mapping.dst_addr(), diff --git a/repos/base-fiasco/src/core/pager_object.cc b/repos/base-fiasco/src/core/pager_object.cc index c798c4240e..794ec818d6 100644 --- a/repos/base-fiasco/src/core/pager_object.cc +++ b/repos/base-fiasco/src/core/pager_object.cc @@ -17,12 +17,8 @@ /* base-internal includes */ #include -/* Fiasco includes */ -namespace Fiasco { -#include -#include -#include -} +/* L4/Fiasco includes */ +#include using namespace Genode; diff --git a/repos/base-fiasco/src/core/platform.cc b/repos/base-fiasco/src/core/platform.cc index 7b6af01ae5..64b1159b52 100644 --- a/repos/base-fiasco/src/core/platform.cc +++ b/repos/base-fiasco/src/core/platform.cc @@ -31,17 +31,11 @@ #include #include -/* Fiasco includes */ -namespace Fiasco { -#include -#include -#include -#include -#include -#include -} +/* L4/Fiasco includes */ +#include using namespace Genode; +using namespace Fiasco; /*********************************** @@ -54,6 +48,7 @@ static Synced_range_allocator &_core_address_ranges() return _core_address_ranges; } + enum { PAGER_STACK_ELEMENTS = 1024 }; static unsigned long _core_pager_stack[PAGER_STACK_ELEMENTS]; static unsigned _core_pager_arg; @@ -66,8 +61,6 @@ static void _core_pager_loop() { unsigned pd_id = _core_pager_arg; - using namespace Fiasco; - l4_threadid_t t; l4_umword_t dw0, dw1; l4_msgdope_t r; @@ -136,7 +129,7 @@ Platform::Sigma0::Sigma0() 0, Affinity::Location(), Session_label(), Cpu_session::Name("sigma0")) { - cap(Capability_space::import(Fiasco::sigma0_threadid, Rpc_obj_key())); + cap(Capability_space::import(sigma0_threadid, Rpc_obj_key())); } @@ -166,8 +159,6 @@ Platform::Core_pager::Core_pager(Platform_pd &core_pd) void *sp = (void *)&_core_pager_stack[PAGER_STACK_ELEMENTS - 1]; start((void *)_core_pager_loop, sp); - using namespace Fiasco; - /* pager0 receives pagefaults from me - for NULL pointer detection */ l4_umword_t d; l4_threadid_t preempter = L4_INVALID_ID; @@ -236,8 +227,6 @@ static inline void remove_region(Region r, Range_allocator &alloc) */ static inline int sigma0_req_region(addr_t *addr, unsigned log2size) { - using namespace Fiasco; - /* XXX sigma0 always maps pages RW */ l4_umword_t req_fpage = l4_fpage(0, log2size, 0, 0).fpage; void* rcv_window = L4_IPC_MAPMSG(0, L4_WHOLE_ADDRESS_SPACE); @@ -246,7 +235,7 @@ static inline int sigma0_req_region(addr_t *addr, unsigned log2size) l4_msgdope_t result; l4_msgtag_t tag; - int err = l4_ipc_call_tag(Fiasco::sigma0_threadid, + int err = l4_ipc_call_tag(sigma0_threadid, L4_IPC_SHORT_MSG, SIGMA0_REQ_FPAGE_ANY, req_fpage, l4_msgtag(L4_MSGTAG_SIGMA0, 0, 0, 0), rcv_window, &base, (l4_umword_t *)&rcv_fpage, @@ -288,8 +277,8 @@ void Platform::_setup_mem_alloc() if (!err) { /* XXX do not allocate page0 */ if (addr == 0) { - Fiasco::l4_fpage_unmap(Fiasco::l4_fpage(0, log2_size, 0, 0), - L4_FP_FLUSH_PAGE | L4_FP_ALL_SPACES); + l4_fpage_unmap(l4_fpage(0, log2_size, 0, 0), + L4_FP_FLUSH_PAGE | L4_FP_ALL_SPACES); continue; } @@ -307,14 +296,14 @@ void Platform::_setup_mem_alloc() } -void Platform::_setup_irq_alloc() { - _irq_alloc.add_range(0, 0x10); } - - -static Fiasco::l4_kernel_info_t *get_kip() +void Platform::_setup_irq_alloc() { - using namespace Fiasco; + _irq_alloc.add_range(0, 0x10); +} + +static l4_kernel_info_t *get_kip() +{ static l4_kernel_info_t *kip = nullptr; if (kip) return kip; @@ -329,7 +318,7 @@ static Fiasco::l4_kernel_info_t *get_kip() l4_msgdope_t r; l4_msgtag_t tag; - err = l4_ipc_call_tag(Fiasco::sigma0_threadid, + err = l4_ipc_call_tag(sigma0_threadid, L4_IPC_SHORT_MSG, SIGMA0_REQ_KIP, 0, l4_msgtag(L4_MSGTAG_SIGMA0, 0, 0, 0), fpage, &dw0, &dw1, @@ -357,10 +346,9 @@ static Fiasco::l4_kernel_info_t *get_kip() return kip; } + void Platform::_setup_basics() { - using namespace Fiasco; - l4_kernel_info_t * kip = get_kip(); /* add KIP as ROM module */ @@ -380,6 +368,7 @@ void Platform::_setup_basics() break; } + if (_vm_size == 0) panic("Virtual memory configuration not found"); @@ -411,7 +400,8 @@ void Platform::_setup_basics() } -Platform::Platform() : +Platform::Platform() +: _ram_alloc(nullptr), _io_mem_alloc(&core_mem_alloc()), _io_port_alloc(&core_mem_alloc()), _irq_alloc(&core_mem_alloc()), _region_alloc(&core_mem_alloc()), @@ -432,7 +422,7 @@ Platform::Platform() : log(_rom_fs); - Fiasco::l4_threadid_t myself = Fiasco::l4_myself(); + l4_threadid_t myself = l4_myself(); Platform_pd::init(); @@ -451,8 +441,8 @@ Platform::Platform() : _core_pd->bind_thread(core_thread); /* we never call _core_thread.start(), so set name directly */ - Fiasco::fiasco_register_thread_name(core_thread.native_thread_id(), - core_thread.name().string()); + fiasco_register_thread_name(core_thread.native_thread_id(), + core_thread.name().string()); /* core log as ROM module */ { diff --git a/repos/base-fiasco/src/core/platform_pd.cc b/repos/base-fiasco/src/core/platform_pd.cc index 3051799286..b8d1b9b017 100644 --- a/repos/base-fiasco/src/core/platform_pd.cc +++ b/repos/base-fiasco/src/core/platform_pd.cc @@ -25,19 +25,13 @@ #include #include -/* Fiasco includes */ -namespace Fiasco { -#include -} +/* L4/Fiasco includes */ +#include using namespace Fiasco; using namespace Genode; -/************************** - ** Static class members ** - **************************/ - static bool _init = false; @@ -64,10 +58,10 @@ void Platform_pd::init() void Platform_pd::_create_pd(bool syscall) { - l4_threadid_t l4t = l4_myself(); - l4t.id.task = _pd_id; - l4t.id.lthread = 0; - l4t.id.version_low = _version; + l4_threadid_t l4t = l4_myself(); + l4t.id.task = _pd_id; + l4t.id.lthread = 0; + l4t.id.version_low = _version; l4_taskid_t nt; if (syscall) diff --git a/repos/base-fiasco/src/core/platform_thread.cc b/repos/base-fiasco/src/core/platform_thread.cc index 242dbc959d..65fdd25249 100644 --- a/repos/base-fiasco/src/core/platform_thread.cc +++ b/repos/base-fiasco/src/core/platform_thread.cc @@ -25,13 +25,8 @@ /* base-internal includes */ #include -/* Fiasco includes */ -namespace Fiasco { -#include -#include -#include -#include -} +/* L4/Fiasco includes */ +#include using namespace Genode; using namespace Fiasco; diff --git a/repos/base-fiasco/src/core/ram_dataspace_support.cc b/repos/base-fiasco/src/core/ram_dataspace_support.cc index 18e63f332d..75e15507ab 100644 --- a/repos/base-fiasco/src/core/ram_dataspace_support.cc +++ b/repos/base-fiasco/src/core/ram_dataspace_support.cc @@ -14,13 +14,18 @@ * under the terms of the GNU Affero General Public License version 3. */ +/* core includes */ #include using namespace Genode; + void Ram_dataspace_factory::_export_ram_ds(Dataspace_component &) { } + + void Ram_dataspace_factory::_revoke_ram_ds(Dataspace_component &) { } + void Ram_dataspace_factory::_clear_ds(Dataspace_component &ds) { memset((void *)ds.phys_addr(), 0, ds.size()); diff --git a/repos/base-fiasco/src/core/spec/x86/platform_x86.cc b/repos/base-fiasco/src/core/spec/x86/platform_x86.cc index a62f979e61..c8f691b55a 100644 --- a/repos/base-fiasco/src/core/spec/x86/platform_x86.cc +++ b/repos/base-fiasco/src/core/spec/x86/platform_x86.cc @@ -11,18 +11,20 @@ * under the terms of the GNU Affero General Public License version 3. */ +/* base-internal includes */ #include -#include "platform.h" -#include "util.h" +/* core includes */ +#include +#include -namespace Fiasco { -#include -} +/* L4/Fiasco includes */ +#include using namespace Genode; using namespace Fiasco; + void Platform::_setup_io_port_alloc() { l4_fpage_t fp; diff --git a/repos/base-fiasco/src/include/base/internal/fiasco_thread_helper.h b/repos/base-fiasco/src/include/base/internal/fiasco_thread_helper.h index 562a5a7073..eb9e22c2c0 100644 --- a/repos/base-fiasco/src/include/base/internal/fiasco_thread_helper.h +++ b/repos/base-fiasco/src/include/base/internal/fiasco_thread_helper.h @@ -14,8 +14,10 @@ #ifndef _INCLUDE__FIASCO__THREAD_HELPER_H_ #define _INCLUDE__FIASCO__THREAD_HELPER_H_ +/* L4/Fiasco includes */ +#include + namespace Fiasco { -#include /** * Sigma0 thread ID diff --git a/repos/base-fiasco/src/include/base/internal/lock_helper.h b/repos/base-fiasco/src/include/base/internal/lock_helper.h index f638e06aba..637e637187 100644 --- a/repos/base-fiasco/src/include/base/internal/lock_helper.h +++ b/repos/base-fiasco/src/include/base/internal/lock_helper.h @@ -22,9 +22,7 @@ #define _INCLUDE__BASE__INTERNAL__LOCK_HELPER_H_ /* L4/Fiasco includes */ -namespace Fiasco { -#include -} +#include /** diff --git a/repos/base-fiasco/src/include/base/internal/native_thread.h b/repos/base-fiasco/src/include/base/internal/native_thread.h index 027e859fd1..fb94535ede 100644 --- a/repos/base-fiasco/src/include/base/internal/native_thread.h +++ b/repos/base-fiasco/src/include/base/internal/native_thread.h @@ -17,10 +17,8 @@ /* Genode includes */ #include -/* Fiasco includes */ -namespace Fiasco { -#include -} +/* L4/Fiasco includes */ +#include namespace Genode { @@ -28,6 +26,7 @@ namespace Genode { struct Native_thread; } + struct Genode::Native_thread { Fiasco::l4_threadid_t l4id; diff --git a/repos/base-fiasco/src/include/base/internal/raw_write_string.h b/repos/base-fiasco/src/include/base/internal/raw_write_string.h index 4283bb7ddb..6b6f9cde80 100644 --- a/repos/base-fiasco/src/include/base/internal/raw_write_string.h +++ b/repos/base-fiasco/src/include/base/internal/raw_write_string.h @@ -14,10 +14,8 @@ #ifndef _INCLUDE__BASE__INTERNAL__RAW_WRITE_STRING_H_ #define _INCLUDE__BASE__INTERNAL__RAW_WRITE_STRING_H_ -/* Fiasco includes */ -namespace Fiasco { -#include -} +/* L4/Fiasco includes */ +#include namespace Genode { diff --git a/repos/base-fiasco/src/include/base/internal/rpc_destination.h b/repos/base-fiasco/src/include/base/internal/rpc_destination.h index 7443be6880..9458ef750c 100644 --- a/repos/base-fiasco/src/include/base/internal/rpc_destination.h +++ b/repos/base-fiasco/src/include/base/internal/rpc_destination.h @@ -14,10 +14,8 @@ #ifndef _INCLUDE__BASE__INTERNAL__RPC_DESTINATION_H_ #define _INCLUDE__BASE__INTERNAL__RPC_DESTINATION_H_ -/* Fiasco includes */ -namespace Fiasco { -#include -} +/* L4/Fiasco includes */ +#include namespace Genode { diff --git a/repos/base-fiasco/src/include/fiasco/syscall.h b/repos/base-fiasco/src/include/fiasco/syscall.h new file mode 100644 index 0000000000..b1f3cc8701 --- /dev/null +++ b/repos/base-fiasco/src/include/fiasco/syscall.h @@ -0,0 +1,29 @@ +/* + * \brief Collection of L4/Fiasco kernel bindings + * \author Norman Feske + * \date 2020-12-06 + */ + +/* + * Copyright (C) 2020 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef _INCLUDE__FIASCO__SYSCALL_H_ +#define _INCLUDE__FIASCO__SYSCALL_H_ + +namespace Fiasco { +#include +#include +#include +#include +#include +#include +#include +#include +#include +} + +#endif /* _INCLUDE__FIASCO__SYSCALL_H_ */ diff --git a/repos/base-fiasco/src/lib/base/capability_raw.cc b/repos/base-fiasco/src/lib/base/capability_raw.cc index 0f19e057e8..85131758aa 100644 --- a/repos/base-fiasco/src/lib/base/capability_raw.cc +++ b/repos/base-fiasco/src/lib/base/capability_raw.cc @@ -11,6 +11,7 @@ * under the terms of the GNU Affero General Public License version 3. */ +/* Genode includes */ #include /* base-internal includes */ diff --git a/repos/base-fiasco/src/lib/base/ipc.cc b/repos/base-fiasco/src/lib/base/ipc.cc index 68e326025d..d20aa41f41 100644 --- a/repos/base-fiasco/src/lib/base/ipc.cc +++ b/repos/base-fiasco/src/lib/base/ipc.cc @@ -20,13 +20,11 @@ #include #include -/* Fiasco includes */ -namespace Fiasco { -#include -#include -} +/* L4/Fiasco includes */ +#include using namespace Genode; +using namespace Fiasco; class Msg_header @@ -34,9 +32,9 @@ class Msg_header private: /* kernel-defined message header */ - Fiasco::l4_fpage_t rcv_fpage; /* unused */ - Fiasco::l4_msgdope_t size_dope; - Fiasco::l4_msgdope_t send_dope; + l4_fpage_t rcv_fpage; /* unused */ + l4_msgdope_t size_dope; + l4_msgdope_t send_dope; public: @@ -47,15 +45,15 @@ class Msg_header * arguments. The kernel does not fetch these data words from memory * but transfers them via the short-IPC registers. */ - Fiasco::l4_umword_t protocol_word; - Fiasco::l4_umword_t num_caps; + l4_umword_t protocol_word; + l4_umword_t num_caps; private: enum { MAX_CAPS_PER_MSG = Msgbuf_base::MAX_CAPS_PER_MSG }; - Fiasco::l4_threadid_t _cap_tid [MAX_CAPS_PER_MSG]; - unsigned long _cap_local_name [MAX_CAPS_PER_MSG]; + l4_threadid_t _cap_tid [MAX_CAPS_PER_MSG]; + unsigned long _cap_local_name [MAX_CAPS_PER_MSG]; size_t _num_msg_words(size_t num_data_words) const { @@ -65,7 +63,7 @@ class Msg_header * Account for the transfer of the protocol word, capability count, * and capability arguments in front of the payload. */ - return 2 + caps_size/sizeof(Fiasco::l4_umword_t) + num_data_words; + return 2 + caps_size/sizeof(l4_umword_t) + num_data_words; } public: @@ -77,8 +75,6 @@ class Msg_header */ void prepare_snd_msg(unsigned long protocol, Msgbuf_base const &snd_msg) { - using namespace Fiasco; - protocol_word = protocol; num_caps = min((unsigned)MAX_CAPS_PER_MSG, snd_msg.used_caps()); @@ -109,8 +105,6 @@ class Msg_header */ void prepare_rcv_msg(Msgbuf_base const &rcv_msg) { - using namespace Fiasco; - size_t const rcv_max_words = rcv_msg.capacity()/sizeof(l4_umword_t); size_dope = L4_IPC_DOPE(_num_msg_words(rcv_max_words), 0); @@ -124,7 +118,7 @@ class Msg_header for (unsigned i = 0; i < min((unsigned)MAX_CAPS_PER_MSG, num_caps); i++) { Rpc_obj_key const rpc_obj_key(_cap_local_name[i]); - bool const cap_valid = !Fiasco::l4_is_invalid_id(_cap_tid[i]); + bool const cap_valid = !l4_is_invalid_id(_cap_tid[i]); Native_capability cap; if (cap_valid) { @@ -147,8 +141,6 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst, Msgbuf_base &snd_msg, Msgbuf_base &rcv_msg, size_t) { - using namespace Fiasco; - Capability_space::Ipc_cap_data const dst_data = Capability_space::ipc_cap_data(dst); @@ -190,8 +182,6 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst, void Genode::ipc_reply(Native_capability caller, Rpc_exception_code exc, Msgbuf_base &snd_msg) { - using namespace Fiasco; - Msg_header &snd_header = snd_msg.header(); snd_header.prepare_snd_msg(exc.value, snd_msg); @@ -209,8 +199,6 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller, Msgbuf_base &reply_msg, Msgbuf_base &request_msg) { - using namespace Fiasco; - l4_msgdope_t ipc_result; bool need_to_wait = true; @@ -276,7 +264,7 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller, Ipc_server::Ipc_server() : - Native_capability(Capability_space::import(Fiasco::l4_myself(), Rpc_obj_key())) + Native_capability(Capability_space::import(l4_myself(), Rpc_obj_key())) { } diff --git a/repos/base-fiasco/src/lib/base/lock.cc b/repos/base-fiasco/src/lib/base/lock.cc index 053120c570..02b31847f4 100644 --- a/repos/base-fiasco/src/lib/base/lock.cc +++ b/repos/base-fiasco/src/lib/base/lock.cc @@ -17,15 +17,14 @@ #include /* L4/Fiasco includes */ -namespace Fiasco { -#include -} +#include using namespace Genode; Lock::Lock(Lock::State initial) -: _state(UNLOCKED), _owner(nullptr) +: + _state(UNLOCKED), _owner(nullptr) { if (initial == LOCKED) lock(); @@ -45,7 +44,7 @@ void Lock::lock(Applicant &myself) * XXX: How to notice cancel-blocking signals issued when being outside the * 'l4_ipc_sleep' system call? */ - while (!Genode::cmpxchg(&_state, UNLOCKED, LOCKED)) + while (!cmpxchg(&_state, UNLOCKED, LOCKED)) Fiasco::l4_ipc_sleep(Fiasco::l4_ipc_timeout(0, 0, 500, 0)); _owner = myself; @@ -55,6 +54,6 @@ void Lock::lock(Applicant &myself) void Lock::unlock() { _owner = Applicant(nullptr); - Genode::memory_barrier(); + memory_barrier(); _state = UNLOCKED; } diff --git a/repos/base-fiasco/src/lib/base/sleep.cc b/repos/base-fiasco/src/lib/base/sleep.cc index 0576dc26b0..abffa79b5f 100644 --- a/repos/base-fiasco/src/lib/base/sleep.cc +++ b/repos/base-fiasco/src/lib/base/sleep.cc @@ -16,9 +16,7 @@ #include /* L4/Fiasco includes */ -namespace Fiasco { -#include -} +#include void Genode::sleep_forever()