base-foc: coding style

- Cosmetic adjustments according to
  https://genode.org/documentation/developer-resources/coding_style

- Replace manual inclusion of kernel headers by one new compound
  header foc/syscall.h

- Rename namespace Fiasco to Foc
This commit is contained in:
Norman Feske
2020-11-27 18:10:19 +01:00
parent 0209a2465d
commit 70ff3d9c90
60 changed files with 1508 additions and 1462 deletions

View File

@ -14,7 +14,13 @@
/* core includes */
#include <core_log.h>
namespace Fiasco {
#include <l4/sys/kdebug.h>
/* Fiasco.OC includes */
#include <foc/syscall.h>
using namespace Genode;
void Core_log::out(char const c)
{
Foc::outchar(c);
}
void Genode::Core_log::out(char const c) { Fiasco::outchar(c); }

View File

@ -20,33 +20,32 @@
#include <base/mutex.h>
#include <synced_range_allocator.h>
namespace Genode {
class Cap_id_allocator
{
private:
enum {
CAP_ID_RANGE = ~0UL,
CAP_ID_MASK = ~3UL,
CAP_ID_NUM_MAX = CAP_ID_MASK >> 2,
CAP_ID_OFFSET = 1 << 2
};
Synced_range_allocator<Allocator_avl> _id_alloc;
Mutex _mutex { };
public:
class Out_of_ids : Exception {};
namespace Genode { class Cap_id_allocator; }
Cap_id_allocator(Allocator &);
class Genode::Cap_id_allocator
{
private:
unsigned long alloc();
void free(unsigned long id);
};
}
enum {
CAP_ID_RANGE = ~0UL,
CAP_ID_MASK = ~3UL,
CAP_ID_NUM_MAX = CAP_ID_MASK >> 2,
CAP_ID_OFFSET = 1 << 2
};
Synced_range_allocator<Allocator_avl> _id_alloc;
Mutex _mutex { };
public:
class Out_of_ids : Exception {};
Cap_id_allocator(Allocator &);
unsigned long alloc();
void free(unsigned long id);
};
#endif /* _CORE__INCLUDE__CAP_ID_ALLOC_H_ */

View File

@ -45,7 +45,9 @@ class Genode::Core_cap_index : public Native_capability::Data
Core_cap_index(Pd_session_component *session = 0,
Platform_thread *pt = 0,
Native_thread gate = Native_thread() )
: _session(session), _pt(pt), _gate(gate) {}
:
_session(session), _pt(pt), _gate(gate)
{ }
Pd_session_component const *session() const { return _session; }
Platform_thread const *pt() const { return _pt; }

View File

@ -1,5 +1,5 @@
/*
* \brief Fiasco.OC specific capability mapping.
* \brief Fiasco.OC specific capability mapping
* \author Stefan Kalkowski
* \date 2012-02-22
*/
@ -18,43 +18,44 @@
#include <cap_index.h>
#include <util/noncopyable.h>
namespace Genode {
namespace Genode { class Cap_mapping; }
/**
* A Cap_mapping embodies a capability of core, and its mapped
* copy in another protection domain.
*/
class Cap_mapping : Noncopyable
{
private:
/**
* Helper function for construction purposes.
*
* Allocates a new capability id and Core_cap_index and inserts
* it in the Cap_map.
*
* \return pointer to newly constructed Core_cap_index object
*/
inline Core_cap_index *_get_cap();
/**
* A Cap_mapping embodies a capability of core, and its mapped
* copy in another protection domain.
*/
class Genode::Cap_mapping : Noncopyable
{
private:
public:
/**
* Helper function for construction purposes.
*
* Allocates a new capability id and Core_cap_index and inserts
* it in the Cap_map.
*
* \return pointer to newly constructed Core_cap_index object
*/
inline Core_cap_index *_get_cap();
Native_capability local; /* reference to cap that is mapped */
Fiasco::l4_cap_idx_t remote; /* index in cap-space of the other pd */
public:
Cap_mapping(bool alloc=false,
Fiasco::l4_cap_idx_t r = Fiasco::L4_INVALID_CAP);
Cap_mapping(Native_capability cap,
Fiasco::l4_cap_idx_t r = Fiasco::L4_INVALID_CAP);
Native_capability local; /* reference to cap that is mapped */
Foc::l4_cap_idx_t remote; /* index in cap-space of the other pd */
/**
* Map the cap in local to corresponding task.
*
* \param task capability of task to map to
*/
void map(Fiasco::l4_cap_idx_t task);
};
}
Cap_mapping(bool alloc=false,
Foc::l4_cap_idx_t r = Foc::L4_INVALID_CAP);
Cap_mapping(Native_capability cap,
Foc::l4_cap_idx_t r = Foc::L4_INVALID_CAP);
/**
* Map the cap in local to corresponding task.
*
* \param task capability of task to map to
*/
void map(Foc::l4_cap_idx_t task);
};
#endif /* _CORE__INCLUDE__CAP_MAPPING_H_ */

View File

@ -28,22 +28,22 @@
/* base-internal includes */
#include <base/internal/native_thread.h>
/* Fiasco includes */
namespace Fiasco {
#include <l4/sys/types.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
namespace Genode {
class Mapping;
class Ipc_pager;
}
class Genode::Mapping
{
private:
addr_t _dst_addr;
Fiasco::l4_fpage_t _fpage { };
Foc::l4_fpage_t _fpage { };
Cache_attribute _cacheability;
bool _iomem;
@ -55,26 +55,27 @@ class Genode::Mapping
Mapping(addr_t dst_addr, addr_t src_addr,
Cache_attribute c, bool io_mem,
unsigned log2size, bool write, bool executable)
: _dst_addr(dst_addr), _cacheability(c), _iomem(io_mem)
:
_dst_addr(dst_addr), _cacheability(c), _iomem(io_mem)
{
typedef Fiasco::L4_fpage_rights Rights;
Rights rights = (write && executable) ? Fiasco::L4_FPAGE_RWX :
(write && !executable) ? Fiasco::L4_FPAGE_RW :
(!write && !executable) ? Fiasco::L4_FPAGE_RO :
Fiasco::L4_FPAGE_RX;
typedef Foc::L4_fpage_rights Rights;
Rights rights = ( write && executable) ? Foc::L4_FPAGE_RWX :
( write && !executable) ? Foc::L4_FPAGE_RW :
(!write && !executable) ? Foc::L4_FPAGE_RO :
Foc::L4_FPAGE_RX;
_fpage = Fiasco::l4_fpage(src_addr, log2size, rights);
_fpage = Foc::l4_fpage(src_addr, log2size, rights);
}
/**
* Construct invalid flexpage
*/
Mapping() : _dst_addr(0), _fpage(Fiasco::l4_fpage_invalid()),
Mapping() : _dst_addr(0), _fpage(Foc::l4_fpage_invalid()),
_cacheability(UNCACHED), _iomem(false) { }
Fiasco::l4_umword_t dst_addr() const { return _dst_addr; }
Foc::l4_umword_t dst_addr() const { return _dst_addr; }
bool grant() const { return false; }
Fiasco::l4_fpage_t fpage() const { return _fpage; }
Foc::l4_fpage_t fpage() const { return _fpage; }
Cache_attribute cacheability() const { return _cacheability; }
bool iomem() const { return _iomem; }
/**
@ -101,8 +102,8 @@ class Genode::Ipc_pager : public Native_capability
addr_t _pf_ip { 0 }; /* ip of faulter */
Mapping _reply_mapping { }; /* page-fault answer */
unsigned long _badge; /* badge of faulting thread */
Fiasco::l4_msgtag_t _tag { }; /* receive message tag */
Fiasco::l4_exc_regs_t _regs { }; /* exception registers */
Foc::l4_msgtag_t _tag { }; /* receive message tag */
Foc::l4_exc_regs_t _regs { }; /* exception registers */
Msg_type _type { PAGEFAULT };
void _parse_msg_type(void);

View File

@ -38,12 +38,12 @@ class Genode::Irq_object
Irq_session::Polarity _polarity; /* interrupt polarity */
unsigned _irq;
Genode::addr_t _msi_addr;
Genode::addr_t _msi_data;
addr_t _msi_addr;
addr_t _msi_data;
Signal_context_capability _sig_cap { };
Fiasco::l4_cap_idx_t _capability() const { return _cap->kcap(); }
Foc::l4_cap_idx_t _capability() const { return _cap->kcap(); }
public:

View File

@ -19,13 +19,8 @@
#include <platform.h>
#include <util.h>
/* Fiasco includes */
namespace Fiasco {
#include <l4/sys/ipc.h>
#include <l4/sigma0/sigma0.h>
#include <l4/sys/task.h>
#include <l4/sys/cache.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
namespace Genode {
@ -47,7 +42,7 @@ namespace Genode {
size_t page_size_log2 = get_page_size_log2();
for (unsigned i = 0; i < num_pages; i++, offset += page_size) {
using namespace Fiasco;
using namespace Foc;
l4_fpage_t snd_fpage = l4_fpage(from_addr + offset,
page_size_log2, L4_FPAGE_RW);
@ -84,7 +79,7 @@ namespace Genode {
static inline bool map_local_io(addr_t from_addr, addr_t to_addr,
size_t num_pages)
{
using namespace Fiasco;
using namespace Foc;
size_t size = num_pages << get_page_size_log2();
@ -129,7 +124,7 @@ namespace Genode {
static inline void unmap_local(addr_t const local_base, size_t const num_pages)
{
using namespace Fiasco;
using namespace Foc;
size_t const size = num_pages << get_page_size_log2();
addr_t addr = local_base;

View File

@ -19,6 +19,7 @@
namespace Genode { struct Pager_object_exception_state; }
struct Genode::Pager_object_exception_state
{
Mutex mutex { };

View File

@ -17,6 +17,7 @@
#define _CORE__INCLUDE__PLATFORM_H_
/* Genode includes */
#include <util/xml_generator.h>
#include <base/synced_allocator.h>
#include <base/allocator_avl.h>
@ -28,163 +29,160 @@
#include <platform_pd.h>
#include <assertion.h>
namespace Fiasco {
struct l4_kernel_info_t;
}
namespace Foc { struct l4_kernel_info_t; }
namespace Genode {
class Xml_generator;
namespace Genode { class Platform; }
class Platform : public Platform_generic
{
private:
/*
* Noncopyable
*/
Platform(Platform const &);
Platform &operator = (Platform const &);
class Genode::Platform : public Platform_generic
{
private:
/**
* Pager object representing the pager of core namely sigma0
*/
struct Sigma0 : public Pager_object
{
/**
* Constructor
*/
Sigma0(Cap_index*);
int pager(Ipc_pager &) override { /* never called */ return -1; }
};
/*
* Shortcut for the type of allocator instances for physical resources
*/
typedef Synced_range_allocator<Allocator_avl> Phys_allocator;
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 */
Cap_id_allocator _cap_id_alloc; /* capability id allocator */
Rom_fs _rom_fs { }; /* ROM file system */
Rom_module _kip_rom; /* ROM module for Fiasco KIP */
Sigma0 _sigma0;
addr_t _vm_start = 0; /* begin of virtual memory */
size_t _vm_size = 0; /* size of virtual memory */
/**
* 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 I/O port space allocator
*/
void _setup_io_port_alloc();
/**
* Setup content of platform_info ROM
*/
void _setup_platform_info(Xml_generator &,
Fiasco::l4_kernel_info_t &);
/**
* Setup IRQ allocator
*/
void _setup_irq_alloc();
/**
* Parse multi-boot information and update ROM database
*/
void _init_rom_modules();
/**
* Setup pager for core-internal threads
*/
void _setup_core_pager();
addr_t _rom_module_phys(addr_t virt) { return virt; }
public:
enum { VCPU_VIRT_EXT_START = 0x1000, VCPU_VIRT_EXT_END = 0x10000 };
/**
* 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, Sigma0 &);
int pager(Ipc_pager &) override { /* never called */ return -1; }
};
/**
* Return singleton instance of core pager object
*/
Core_pager &core_pager();
/**
* Set interrupt trigger/polarity (e.g., level or edge, high or low)
*/
static void setup_irq_mode(unsigned irq_number, unsigned trigger,
unsigned polarity);
/*
* Noncopyable
*/
Platform(Platform const &);
Platform &operator = (Platform const &);
/**
* Pager object representing the pager of core namely sigma0
*/
struct Sigma0 : public Pager_object
{
/**
* Constructor
*/
Platform();
Sigma0(Cap_index*);
int pager(Ipc_pager &) override { /* never called */ return -1; }
};
/*
* Shortcut for the type of allocator instances for physical resources
*/
typedef Synced_range_allocator<Allocator_avl> Phys_allocator;
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 */
Cap_id_allocator _cap_id_alloc; /* capability id allocator */
Rom_fs _rom_fs { }; /* ROM file system */
Rom_module _kip_rom; /* ROM module for Fiasco.OC KIP */
Sigma0 _sigma0;
addr_t _vm_start = 0; /* begin of virtual memory */
size_t _vm_size = 0; /* size of virtual memory */
/**
* 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 I/O port space allocator
*/
void _setup_io_port_alloc();
/**
* Setup content of platform_info ROM
*/
void _setup_platform_info(Xml_generator &,
Foc::l4_kernel_info_t &);
/**
* Setup IRQ allocator
*/
void _setup_irq_alloc();
/**
* Parse multi-boot information and update ROM database
*/
void _init_rom_modules();
/**
* Setup pager for core-internal threads
*/
void _setup_core_pager();
addr_t _rom_module_phys(addr_t virt) { return virt; }
public:
enum { VCPU_VIRT_EXT_START = 0x1000, VCPU_VIRT_EXT_END = 0x10000 };
/**
* Core pager thread that handles core-internal page-faults
*/
struct Core_pager : Platform_thread, Pager_object
{
/**
* Accessor for core pd object
* Constructor
*/
Platform_pd &core_pd()
{
if (_core_pd)
return *_core_pd;
Core_pager(Platform_pd &core_pd, Sigma0 &);
ASSERT_NEVER_CALLED;
}
int pager(Ipc_pager &) override { /* never called */ return -1; }
};
/**
* Return singleton instance of core pager object
*/
Core_pager &core_pager();
/**
* Set interrupt trigger/polarity (e.g., level or edge, high or low)
*/
static void setup_irq_mode(unsigned irq_number, unsigned trigger,
unsigned polarity);
/**
* 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 &region_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; }
Affinity::Space affinity_space() const override;
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 &region_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; }
Affinity::Space affinity_space() const override;
size_t max_caps() const override { return cap_idx_alloc().max_caps(); }
size_t max_caps() const override { return cap_idx_alloc().max_caps(); }
Cap_id_allocator &cap_id_alloc() { return _cap_id_alloc; }
Cap_id_allocator &cap_id_alloc() { return _cap_id_alloc; }
void wait_for_exit() override;
};
}
void wait_for_exit() override;
};
#endif /* _CORE__INCLUDE__PLATFORM_H_ */

View File

@ -34,89 +34,88 @@
#include <base/internal/non_core_stack_area_addr.h>
/* Fiasco.OC includes */
namespace Fiasco {
#include <l4/sys/consts.h>
}
#include <foc/syscall.h>
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 {
UTCB_AREA_SIZE = (Fiasco::THREAD_MAX * Fiasco::L4_UTCB_OFFSET),
};
addr_t utcb_area_start()
{
return NON_CORE_STACK_AREA_ADDR +
Fiasco::THREAD_MAX*stack_virtual_size();
}
Cap_mapping _task;
Cap_mapping _parent { };
Cap_mapping _debug { };
Platform_thread *_threads[Fiasco::THREAD_MAX] { };
public:
class Threads_exhausted : Exception {};
/**
* Constructor for core
*/
Platform_pd(Core_cap_index &);
/**
* Constructor for all tasks except core.
*/
Platform_pd(Allocator &, char const *label);
/**
* Destructor
*/
~Platform_pd();
/**
* Bind thread to protection domain
*/
bool bind_thread(Platform_thread &);
/**
* Unbind thread from protection domain
*
* Free the thread's slot and update thread object.
*/
void unbind_thread(Platform_thread &);
/**
* Assign parent interface to protection domain
*/
void assign_parent(Native_capability parent);
/*******************************
** Fiasco-specific Accessors **
*******************************/
Native_capability native_task() { return _task.local; }
/*****************************
** 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 { UTCB_AREA_SIZE = (Foc::THREAD_MAX * Foc::L4_UTCB_OFFSET), };
addr_t utcb_area_start()
{
return NON_CORE_STACK_AREA_ADDR +
Foc::THREAD_MAX*stack_virtual_size();
}
Cap_mapping _task;
Cap_mapping _parent { };
Cap_mapping _debug { };
Platform_thread *_threads[Foc::THREAD_MAX] { };
public:
class Threads_exhausted : Exception {};
/**
* Constructor for core
*/
Platform_pd(Core_cap_index &);
/**
* Constructor for all tasks except core.
*/
Platform_pd(Allocator &, char const *label);
/**
* Destructor
*/
~Platform_pd();
/**
* Bind thread to protection domain
*/
bool bind_thread(Platform_thread &);
/**
* Unbind thread from protection domain
*
* Free the thread's slot and update thread object.
*/
void unbind_thread(Platform_thread &);
/**
* Assign parent interface to protection domain
*/
void assign_parent(Native_capability parent);
/**********************************
** Fiasco.OC-specific Accessors **
**********************************/
Native_capability native_task() { return _task.local; }
/*****************************
** Address-space interface **
*****************************/
void flush(addr_t, size_t, Core_local_addr) override;
};
#endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */

View File

@ -1,5 +1,5 @@
/*
* \brief Fiasco thread facility
* \brief Fiasco.OC thread facility
* \author Christian Helmuth
* \author Stefan Kalkowski
* \date 2006-04-11
@ -29,180 +29,184 @@
namespace Genode {
class Platform_pd;
class Platform_thread : Interface
{
private:
/*
* Noncopyable
*/
Platform_thread(Platform_thread const &);
Platform_thread &operator = (Platform_thread const &);
enum State { DEAD, RUNNING };
typedef String<32> Name;
friend class Platform_pd;
Name const _name; /* name at kernel debugger */
State _state;
bool _core_thread;
Cap_mapping _thread;
Cap_mapping _gate { };
Cap_mapping _pager { };
Cap_mapping _irq;
addr_t _utcb;
Platform_pd *_platform_pd; /* protection domain thread
is bound to */
Pager_object *_pager_obj;
unsigned _prio;
Affinity::Location _location { };
void _create_thread(void);
void _finalize_construction();
bool _in_syscall(Fiasco::l4_umword_t flags);
public:
enum { DEFAULT_PRIORITY = 128 };
/**
* Constructor for non-core threads
*/
Platform_thread(size_t, const char *name, unsigned priority,
Affinity::Location, addr_t);
/**
* Constructor for core main-thread
*/
Platform_thread(Core_cap_index& thread,
Core_cap_index& irq, const char *name);
/**
* Constructor for core 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 pd platform pd, thread is bound to
*/
void bind(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
*/
Foc_thread_state state();
/**
* Set the executing CPU for this thread
*/
void affinity(Affinity::Location location);
/**
* Get the executing CPU for this thread
*/
Affinity::Location affinity() const;
/**
* Make thread to vCPU
*/
Fiasco::l4_cap_idx_t setup_vcpu(unsigned, Cap_mapping const &,
Cap_mapping &);
/************************
** Accessor functions **
************************/
/**
* Return/set pager
*/
Pager_object &pager() const
{
if (_pager_obj)
return *_pager_obj;
ASSERT_NEVER_CALLED;
}
void pager(Pager_object &pager);
/**
* Return identification of thread when faulting
*/
unsigned long pager_object_badge() {
return (unsigned long) _thread.local.data()->kcap(); }
/**
* Set CPU quota of the thread to 'quota'
*/
void quota(size_t const) { /* not supported*/ }
/**
* Return execution time consumed by the thread
*/
Trace::Execution_time execution_time() const;
/*******************************
** Fiasco-specific Accessors **
*******************************/
Cap_mapping const & thread() const { return _thread; }
Cap_mapping & gate() { return _gate; }
Name name() const { return _name; }
bool core_thread() const { return _core_thread; }
addr_t utcb() const { return _utcb; }
unsigned prio() const { return _prio; }
};
class Platform_thread;
}
class Genode::Platform_thread : Interface
{
private:
/*
* Noncopyable
*/
Platform_thread(Platform_thread const &);
Platform_thread &operator = (Platform_thread const &);
enum State { DEAD, RUNNING };
typedef String<32> Name;
friend class Platform_pd;
Name const _name; /* name at kernel debugger */
State _state;
bool _core_thread;
Cap_mapping _thread;
Cap_mapping _gate { };
Cap_mapping _pager { };
Cap_mapping _irq;
addr_t _utcb;
Platform_pd *_platform_pd; /* protection domain thread is bound to */
Pager_object *_pager_obj;
unsigned _prio;
Affinity::Location _location { };
void _create_thread(void);
void _finalize_construction();
bool _in_syscall(Foc::l4_umword_t flags);
public:
enum { DEFAULT_PRIORITY = 128 };
/**
* Constructor for non-core threads
*/
Platform_thread(size_t, const char *name, unsigned priority,
Affinity::Location, addr_t);
/**
* Constructor for core main-thread
*/
Platform_thread(Core_cap_index& thread,
Core_cap_index& irq, const char *name);
/**
* Constructor for core 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 pd platform pd, thread is bound to
*/
void bind(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
*/
Foc_thread_state state();
/**
* Set the executing CPU for this thread
*/
void affinity(Affinity::Location location);
/**
* Get the executing CPU for this thread
*/
Affinity::Location affinity() const;
/**
* Make thread to vCPU
*/
Foc::l4_cap_idx_t setup_vcpu(unsigned, Cap_mapping const &, Cap_mapping &);
/************************
** Accessor functions **
************************/
/**
* Return/set pager
*/
Pager_object &pager() const
{
if (_pager_obj)
return *_pager_obj;
ASSERT_NEVER_CALLED;
}
void pager(Pager_object &pager);
/**
* Return identification of thread when faulting
*/
unsigned long pager_object_badge()
{
return (unsigned long) _thread.local.data()->kcap();
}
/**
* Set CPU quota of the thread to 'quota'
*/
void quota(size_t const) { /* not supported*/ }
/**
* Return execution time consumed by the thread
*/
Trace::Execution_time execution_time() const;
/**********************************
** Fiasco.OC-specific Accessors **
**********************************/
Cap_mapping const & thread() const { return _thread; }
Cap_mapping & gate() { return _gate; }
Name name() const { return _name; }
bool core_thread() const { return _core_thread; }
addr_t utcb() const { return _utcb; }
unsigned prio() const { return _prio; }
};
#endif /* _CORE__INCLUDE__PLATFORM_THREAD_H_ */

View File

@ -26,11 +26,8 @@
/* base-internal includes */
#include <base/internal/page_size.h>
/* Fiasco includes */
namespace Fiasco {
#include <l4/sys/types.h>
#include <l4/sys/ktrace.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
namespace Genode {
@ -43,7 +40,7 @@ namespace Genode {
inline void touch_ro(const void *addr, unsigned size)
{
using namespace Fiasco;
using namespace Foc;
unsigned char const volatile *bptr;
unsigned char const *eptr;
@ -55,7 +52,8 @@ namespace Genode {
inline void touch_rw(const void *addr, unsigned size)
{
using namespace Fiasco;
using namespace Foc;
unsigned char volatile *bptr;
unsigned char const *eptr;
@ -65,8 +63,8 @@ namespace Genode {
touch_read_write(bptr);
}
inline addr_t trunc_page(addr_t addr) { return Fiasco::l4_trunc_page(addr); }
inline addr_t round_page(addr_t addr) { return Fiasco::l4_round_page(addr); }
inline addr_t trunc_page(addr_t addr) { return Foc::l4_trunc_page(addr); }
inline addr_t round_page(addr_t addr) { return Foc::l4_round_page(addr); }
constexpr size_t get_super_page_size() { return L4_SUPERPAGESIZE; }
constexpr size_t get_super_page_size_log2() { return L4_LOG2_SUPERPAGESIZE; }

View File

@ -19,16 +19,16 @@
#include <base/heap.h>
#include <vm_session/vm_session.h>
/* Core includes */
/* core includes */
#include <cap_mapping.h>
#include <dataspace_component.h>
#include <region_map_component.h>
#include <trace/source_registry.h>
namespace Genode { class Vm_session_component; struct Vcpu; }
struct Genode::Vcpu : Genode::List<Vcpu>::Element
struct Genode::Vcpu : List<Vcpu>::Element
{
private:
@ -50,12 +50,13 @@ struct Genode::Vcpu : Genode::List<Vcpu>::Element
Cap_mapping &recall_cap() { return _recall; }
};
class Genode::Vm_session_component
:
private Ram_quota_guard,
private Cap_quota_guard,
public Rpc_object<Vm_session, Vm_session_component>,
public Region_map_detach
public Rpc_object<Vm_session, Vm_session_component>,
public Region_map_detach
{
private:
@ -88,6 +89,7 @@ class Genode::Vm_session_component
Trace::Source_registry &);
~Vm_session_component();
/*********************************
** Region_map_detach interface **
*********************************/
@ -95,6 +97,7 @@ class Genode::Vm_session_component
void detach(Region_map::Local_addr) override;
void unmap_region(addr_t, size_t) override;
/**************************
** Vm session interface **
**************************/

View File

@ -22,19 +22,21 @@
#include <base/internal/native_utcb.h>
#include <base/internal/cap_map.h>
/* Fiasco includes */
namespace Fiasco {
#include <l4/sys/ipc.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
using namespace Genode;
using namespace Fiasco;
using namespace Foc;
void Ipc_pager::_parse(unsigned long label) {
void Ipc_pager::_parse(unsigned long label)
{
_badge = label & ~0x3;
_parse_msg_type();
if (_type == PAGEFAULT || _type == EXCEPTION)
_parse_pagefault();
if (_type == PAUSE || _type == EXCEPTION)
_regs = *l4_utcb_exc();
}
@ -96,12 +98,15 @@ void Ipc_pager::reply_and_wait_for_fault()
l4_utcb_mr()->mr[0] = _reply_mapping.dst_addr() | L4_ITEM_MAP | grant;
switch (_reply_mapping.cacheability()) {
case WRITE_COMBINED:
l4_utcb_mr()->mr[0] |= L4_FPAGE_BUFFERABLE << 4;
break;
case CACHED:
l4_utcb_mr()->mr[0] |= L4_FPAGE_CACHEABLE << 4;
break;
case UNCACHED:
if (!_reply_mapping.iomem())
l4_utcb_mr()->mr[0] |= L4_FPAGE_BUFFERABLE << 4;
@ -124,7 +129,7 @@ void Ipc_pager::reply_and_wait_for_fault()
void Ipc_pager::acknowledge_wakeup()
{
l4_cap_idx_t dst = Fiasco::Capability::valid(_last.kcap)
l4_cap_idx_t dst = Foc::Capability::valid(_last.kcap)
? _last.kcap : (l4_cap_idx_t)L4_SYSF_REPLY;
/* answer wakeup call from one of core's region-manager sessions */
@ -135,14 +140,14 @@ void Ipc_pager::acknowledge_wakeup()
void Ipc_pager::acknowledge_exception()
{
_regs = *l4_utcb_exc();
l4_cap_idx_t dst = Fiasco::Capability::valid(_last.kcap)
l4_cap_idx_t dst = Foc::Capability::valid(_last.kcap)
? _last.kcap : (l4_cap_idx_t)L4_SYSF_REPLY;
Fiasco::l4_msgtag_t const msg_tag =
Foc::l4_msgtag_t const msg_tag =
l4_ipc_send(dst, l4_utcb(),
l4_msgtag(0, L4_UTCB_EXCEPTION_REGS_SIZE, 0, 0),
L4_IPC_SEND_TIMEOUT_0);
Fiasco::l4_umword_t const err = l4_ipc_error(msg_tag, l4_utcb());
Foc::l4_umword_t const err = l4_ipc_error(msg_tag, l4_utcb());
if (err) {
warning("failed to acknowledge exception, l4_ipc_err=", err);
}
@ -151,7 +156,7 @@ void Ipc_pager::acknowledge_exception()
Ipc_pager::Ipc_pager()
:
Native_capability((Cap_index*)Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_BADGE]),
Native_capability((Cap_index*)Foc::l4_utcb_tcr()->user[Foc::UTCB_TCR_BADGE]),
_badge(0)
{ }

View File

@ -25,18 +25,10 @@
#include <platform.h>
#include <util.h>
/* Fiasco includes */
namespace Fiasco {
#include <l4/sys/icu.h>
#include <l4/sys/irq.h>
#include <l4/sys/factory.h>
#include <l4/sys/types.h>
}
namespace Genode {
class Interrupt_handler;
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
namespace Genode { class Interrupt_handler; }
using namespace Genode;
@ -58,7 +50,7 @@ class Genode::Interrupt_handler : public Thread
void entry() override;
static Fiasco::l4_cap_idx_t handler_cap()
static Foc::l4_cap_idx_t handler_cap()
{
static Interrupt_handler handler;
return handler._thread_cap.data()->kcap();
@ -68,35 +60,40 @@ class Genode::Interrupt_handler : public Thread
enum { MAX_MSIS = 256 };
static class Msi_allocator : public Genode::Bit_array<MAX_MSIS>
static struct Msi_allocator : Bit_array<MAX_MSIS>
{
public:
Msi_allocator()
{
using namespace Foc;
Msi_allocator() {
using namespace Fiasco;
l4_icu_info_t info { };
l4_icu_info_t info { .features = 0, .nr_irqs = 0, .nr_msis = 0 };
l4_msgtag_t res = l4_icu_info(Fiasco::L4_BASE_ICU_CAP, &info);
l4_msgtag_t const res = l4_icu_info(Foc::L4_BASE_ICU_CAP, &info);
if (l4_error(res) || !(info.features & L4_ICU_FLAG_MSI))
set(0, MAX_MSIS);
else
if (info.nr_msis < MAX_MSIS)
set(info.nr_msis, MAX_MSIS - info.nr_msis);
}
if (l4_error(res) || !(info.features & L4_ICU_FLAG_MSI))
set(0, MAX_MSIS);
else
if (info.nr_msis < MAX_MSIS)
set(info.nr_msis, MAX_MSIS - info.nr_msis);
}
} msi_alloc;
bool Genode::Irq_object::associate(unsigned irq, bool msi,
Irq_session::Trigger trigger,
Irq_session::Polarity polarity)
bool Irq_object::associate(unsigned irq, bool msi,
Irq_session::Trigger trigger,
Irq_session::Polarity polarity)
{
using namespace Fiasco;
using namespace Foc;
_irq = irq;
_trigger = trigger;
_polarity = polarity;
if (msi) irq |= L4_ICU_FLAG_MSI;
if (msi)
irq |= L4_ICU_FLAG_MSI;
else
/* set interrupt mode */
Platform::setup_irq_mode(irq, _trigger, _polarity);
@ -124,7 +121,7 @@ bool Genode::Irq_object::associate(unsigned irq, bool msi,
* Architecture Specification
*/
unsigned src_id = 0x0;
Fiasco::l4_icu_msi_info_t info = l4_icu_msi_info_t();
Foc::l4_icu_msi_info_t info = l4_icu_msi_info_t();
if (l4_error(l4_icu_msi_info(L4_BASE_ICU_CAP, irq,
src_id, &info))) {
error("cannot get MSI info");
@ -138,9 +135,9 @@ bool Genode::Irq_object::associate(unsigned irq, bool msi,
}
void Genode::Irq_object::ack_irq()
void Irq_object::ack_irq()
{
using namespace Fiasco;
using namespace Foc;
int err;
l4_msgtag_t tag = l4_irq_unmask(_capability());
@ -149,7 +146,7 @@ void Genode::Irq_object::ack_irq()
}
Genode::Irq_object::Irq_object()
Irq_object::Irq_object()
:
_cap(cap_map().insert(platform_specific().cap_id_alloc().alloc())),
_trigger(Irq_session::TRIGGER_UNCHANGED),
@ -158,15 +155,17 @@ Genode::Irq_object::Irq_object()
{ }
Genode::Irq_object::~Irq_object()
Irq_object::~Irq_object()
{
if (_irq == ~0U)
return;
using namespace Fiasco;
using namespace Foc;
unsigned long irq = _irq;
if (_msi_addr) irq |= L4_ICU_FLAG_MSI;
if (_msi_addr)
irq |= L4_ICU_FLAG_MSI;
if (l4_error(l4_irq_detach(_capability())))
error("cannot detach IRQ");
@ -182,13 +181,14 @@ Genode::Irq_object::~Irq_object()
** IRQ session component **
***************************/
Irq_session_component::Irq_session_component(Range_allocator &irq_alloc,
const char *args)
: _irq_number(Arg_string::find_arg(args, "irq_number").long_value(-1)),
_irq_alloc(irq_alloc), _irq_object()
:
_irq_number(Arg_string::find_arg(args, "irq_number").long_value(-1)),
_irq_alloc(irq_alloc), _irq_object()
{
long msi = Arg_string::find_arg(args, "device_config_phys").long_value(0);
long const msi = Arg_string::find_arg(args, "device_config_phys").long_value(0);
if (msi) {
if (msi_alloc.get(_irq_number, 1)) {
error("unavailable MSI ", _irq_number, " requested");
@ -203,6 +203,7 @@ Irq_session_component::Irq_session_component(Range_allocator &irq_alloc,
}
Irq_args const irq_args(args);
if (_irq_object.associate(_irq_number, msi, irq_args.trigger(),
irq_args.polarity()))
return;
@ -226,13 +227,16 @@ Irq_session_component::~Irq_session_component()
if (_irq_object.msi_address()) {
msi_alloc.clear(_irq_number, 1);
} else {
Genode::addr_t free_irq = _irq_number;
addr_t const free_irq = _irq_number;
_irq_alloc.free((void *)free_irq);
}
}
void Irq_session_component::ack_irq() { _irq_object.ack_irq(); }
void Irq_session_component::ack_irq()
{
_irq_object.ack_irq();
}
void Irq_session_component::sigh(Genode::Signal_context_capability cap)
@ -241,7 +245,7 @@ void Irq_session_component::sigh(Genode::Signal_context_capability cap)
}
Genode::Irq_session::Info Irq_session_component::info()
Irq_session::Info Irq_session_component::info()
{
if (!_irq_object.msi_address())
return { .type = Info::Type::INVALID, .address = 0, .value = 0 };
@ -263,7 +267,7 @@ __attribute__((optimize("-fno-omit-frame-pointer")))
__attribute__((noinline))
void Interrupt_handler::entry()
{
using namespace Fiasco;
using namespace Foc;
int err;
l4_msgtag_t tag;

View File

@ -20,30 +20,23 @@
#include <platform.h>
/* Fiasco.OC includes */
namespace Fiasco {
#include <l4/sys/thread.h>
#include <l4/sys/factory.h>
}
#include <foc/syscall.h>
using namespace Genode;
Genode::Native_capability
Genode::Native_cpu_component::native_cap(Genode::Thread_capability cap)
Native_capability Native_cpu_component::native_cap(Thread_capability cap)
{
using namespace Genode;
auto lambda = [&] (Cpu_thread_component *thread) {
return (!thread) ? Native_capability()
: thread->platform_thread().thread().local;
};
: thread->platform_thread().thread().local; };
return _thread_ep.apply(cap, lambda);
}
Genode::Foc_thread_state
Genode::Native_cpu_component::thread_state(Genode::Thread_capability cap)
Foc_thread_state Native_cpu_component::thread_state(Thread_capability cap)
{
using namespace Genode;
auto lambda = [&] (Cpu_thread_component *thread) {
return (!thread) ? Foc_thread_state()
: thread->platform_thread().state(); };
@ -52,7 +45,7 @@ Genode::Native_cpu_component::thread_state(Genode::Thread_capability cap)
}
Genode::Native_cpu_component::Native_cpu_component(Cpu_session_component &cpu_session, char const *)
Native_cpu_component::Native_cpu_component(Cpu_session_component &cpu_session, char const *)
:
_cpu_session(cpu_session), _thread_ep(_cpu_session._thread_ep)
{
@ -60,7 +53,7 @@ Genode::Native_cpu_component::Native_cpu_component(Cpu_session_component &cpu_se
}
Genode::Native_cpu_component::~Native_cpu_component()
Native_cpu_component::~Native_cpu_component()
{
_thread_ep.dissolve(this);
}

View File

@ -1,5 +1,5 @@
/*
* \brief Fiasco pager framework
* \brief Fiasco.OC pager framework
* \author Norman Feske
* \author Christian Helmuth
* \author Stefan Kalkowski
@ -24,10 +24,7 @@
#include <base/internal/native_thread.h>
/* Fiasco.OC includes */
namespace Fiasco {
#include <l4/sys/factory.h>
#include <l4/sys/ipc.h>
}
#include <foc/syscall.h>
using namespace Genode;
@ -45,6 +42,7 @@ void Pager_entrypoint::entry()
reply_pending = false;
apply(_pager.badge(), [&] (Pager_object *obj) {
/* the pager_object might be destroyed, while we got the message */
if (!obj) {
warning("no pager object found!");
@ -149,7 +147,7 @@ void Pager_entrypoint::dissolve(Pager_object &obj)
Pager_capability Pager_entrypoint::manage(Pager_object &obj)
{
using namespace Fiasco;
using namespace Foc;
Native_capability cap(_cap_factory.alloc(Thread::_thread_cap));

View File

@ -18,16 +18,14 @@
#include <base/internal/cap_map.h>
/* Fiasco.OC includes */
namespace Fiasco {
#include <l4/sys/ipc.h>
}
#include <foc/syscall.h>
using namespace Genode;
void Pager_object::wake_up()
{
using namespace Fiasco;
using namespace Foc;
/*
* Issue IPC to pager, transmitting the pager-object pointer as 'IP'.

View File

@ -1,5 +1,5 @@
/*
* \brief Fiasco platform interface implementation
* \brief Fiasco.OC platform interface implementation
* \author Christian Helmuth
* \author Stefan Kalkowski
* \date 2006-04-11
@ -35,17 +35,8 @@
#include <platform_pd.h>
#include <util.h>
/* Fiasco includes */
namespace Fiasco {
#include <l4/sigma0/sigma0.h>
#include <l4/sys/icu.h>
#include <l4/sys/ipc.h>
#include <l4/sys/kip>
#include <l4/sys/thread.h>
#include <l4/sys/types.h>
#include <l4/sys/utcb.h>
#include <l4/sys/scheduler.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
using namespace Genode;
@ -60,9 +51,12 @@ static Synced_range_allocator<Allocator_avl> &_core_address_ranges()
return _core_address_ranges;
}
enum { PAGER_STACK_ELEMENTS = 1024 };
static unsigned long _core_pager_stack[PAGER_STACK_ELEMENTS];
/**
* Core pager "service loop"
*/
@ -72,13 +66,14 @@ __attribute__((optimize("-fno-omit-frame-pointer")))
__attribute__((noinline))
static void _core_pager_loop()
{
using namespace Fiasco;
using namespace Foc;
bool send_reply = false;
l4_umword_t label;
l4_utcb_t *utcb = l4_utcb();
l4_msgtag_t snd_tag = l4_msgtag(0, 0, 0, 0);
l4_msgtag_t tag;
l4_utcb_t * const utcb = l4_utcb();
bool send_reply = false;
l4_umword_t label;
l4_msgtag_t snd_tag = l4_msgtag(0, 0, 0, 0);
l4_msgtag_t tag;
while (true) {
@ -93,9 +88,9 @@ static void _core_pager_loop()
}
/* read fault information */
l4_umword_t pfa = l4_trunc_page(l4_utcb_mr()->mr[0]);
l4_umword_t ip = l4_utcb_mr()->mr[1];
bool rw = l4_utcb_mr()->mr[0] & 2; //TODO enum
l4_umword_t const pfa = l4_trunc_page(l4_utcb_mr()->mr[0]);
l4_umword_t const ip = l4_utcb_mr()->mr[1];
bool const rw = l4_utcb_mr()->mr[0] & 2; //TODO enum
if (pfa < (l4_umword_t)L4_PAGESIZE) {
@ -156,7 +151,7 @@ Platform::Core_pager::Core_pager(Platform_pd &core_pd, Sigma0 &sigma0)
void *sp = (void *)&_core_pager_stack[PAGER_STACK_ELEMENTS - 1];
start((void *)_core_pager_loop, sp);
using namespace Fiasco;
using namespace Foc;
l4_thread_control_start();
l4_thread_control_pager(thread().local.data()->kcap());
@ -180,10 +175,10 @@ Platform::Core_pager &Platform::core_pager()
struct Region
{
addr_t start;
addr_t end;
addr_t start = 0;
addr_t end = 0;
Region() : start(0), end(0) { }
Region() { }
Region(addr_t s, addr_t e) : start(s), end(e) { }
/**
@ -202,8 +197,8 @@ struct Region
static inline void add_region(Region r, Range_allocator &alloc)
{
/* adjust region */
addr_t start = trunc_page(r.start);
addr_t end = round_page(r.end);
addr_t const start = trunc_page(r.start);
addr_t const end = round_page(r.end);
alloc.add_range(start, end - start);
}
@ -215,8 +210,8 @@ static inline void add_region(Region r, Range_allocator &alloc)
static inline void remove_region(Region r, Range_allocator &alloc)
{
/* adjust region */
addr_t start = trunc_page(r.start);
addr_t end = round_page(r.end);
addr_t const start = trunc_page(r.start);
addr_t const end = round_page(r.end);
alloc.remove_range(start, end - start);
}
@ -227,7 +222,7 @@ static inline void remove_region(Region r, Range_allocator &alloc)
*/
static inline int sigma0_req_region(addr_t *addr, unsigned log2size)
{
using namespace Fiasco;
using namespace Foc;
l4_utcb_mr()->mr[0] = SIGMA0_REQ_FPAGE_ANY;
l4_utcb_mr()->mr[1] = l4_fpage(0, log2size, 0).raw;
@ -251,13 +246,14 @@ static inline int sigma0_req_region(addr_t *addr, unsigned log2size)
}
static Fiasco::l4_kernel_info_t &sigma0_map_kip()
static Foc::l4_kernel_info_t &sigma0_map_kip()
{
using namespace Fiasco;
using namespace Foc;
static l4_kernel_info_t *kip_ptr = nullptr;
if (kip_ptr) return *kip_ptr;
if (kip_ptr)
return *kip_ptr;
/* signal we want to map the KIP */
l4_utcb_mr()->mr[0] = SIGMA0_REQ_KIP;
@ -268,14 +264,14 @@ static Fiasco::l4_kernel_info_t &sigma0_map_kip()
l4_utcb_br()->br[1] = l4_fpage(0, L4_WHOLE_ADDRESS_SPACE, L4_FPAGE_RX).raw;
/* call sigma0 */
l4_msgtag_t tag = l4_ipc_call(L4_BASE_PAGER_CAP,
l4_utcb(),
l4_msgtag(L4_PROTO_SIGMA0, 1, 0, 0),
L4_IPC_NEVER);
l4_msgtag_t const tag = l4_ipc_call(L4_BASE_PAGER_CAP,
l4_utcb(),
l4_msgtag(L4_PROTO_SIGMA0, 1, 0, 0),
L4_IPC_NEVER);
if (l4_ipc_error(tag, l4_utcb()))
panic("kip request to sigma0 failed");
l4_addr_t ret = l4_trunc_page(l4_utcb_mr()->mr[0]);
l4_addr_t const ret = l4_trunc_page(l4_utcb_mr()->mr[0]);
if (!ret)
panic("kip mapping failed");
@ -297,11 +293,12 @@ void Platform::_setup_mem_alloc()
for ( ; beg < end; beg += L4_PAGESIZE) (void)(*beg);
/* request pages of known page size starting with largest */
size_t log2_sizes[] = { L4_LOG2_SUPERPAGESIZE, L4_LOG2_PAGESIZE };
size_t const log2_sizes[] = { L4_LOG2_SUPERPAGESIZE, L4_LOG2_PAGESIZE };
for (unsigned i = 0; i < sizeof(log2_sizes)/sizeof(*log2_sizes); ++i) {
size_t log2_size = log2_sizes[i];
size_t size = 1UL << log2_size;
size_t const log2_size = log2_sizes[i];
size_t const size = 1UL << log2_size;
int err = 0;
addr_t addr = 0;
Region region;
@ -312,10 +309,10 @@ void Platform::_setup_mem_alloc()
if (!err) {
/* XXX do not allocate page0 */
if (addr == 0) {
Fiasco::l4_task_unmap(Fiasco::L4_BASE_TASK_CAP,
Fiasco::l4_fpage(0, log2_size,
Fiasco::L4_FPAGE_RW),
Fiasco::L4_FP_ALL_SPACES);
Foc::l4_task_unmap(Foc::L4_BASE_TASK_CAP,
Foc::l4_fpage(0, log2_size,
Foc::L4_FPAGE_RW),
Foc::L4_FP_ALL_SPACES);
continue;
}
@ -335,10 +332,10 @@ void Platform::_setup_mem_alloc()
void Platform::_setup_irq_alloc()
{
using namespace Fiasco;
using namespace Foc;
l4_icu_info_t info { .features = 0, .nr_irqs = 0, .nr_msis = 0 };
l4_msgtag_t res = l4_icu_info(Fiasco::L4_BASE_ICU_CAP, &info);
l4_msgtag_t res = l4_icu_info(Foc::L4_BASE_ICU_CAP, &info);
if (l4_error(res))
panic("could not determine number of IRQs");
@ -348,7 +345,7 @@ void Platform::_setup_irq_alloc()
void Platform::_setup_basics()
{
using namespace Fiasco;
using namespace Foc;
l4_kernel_info_t const &kip = sigma0_map_kip();
@ -364,12 +361,12 @@ void Platform::_setup_basics()
_rom_fs.insert(&_kip_rom);
/* update multi-boot info pointer from KIP */
addr_t mb_info_addr = kip.user_ptr;
addr_t const mb_info_addr = kip.user_ptr;
log("MBI @ ", Hex(mb_info_addr));
/* parse memory descriptors - look for virtual memory configuration */
/* XXX we support only one VM region (here and also inside RM) */
using Fiasco::L4::Kip::Mem_desc;
using Foc::L4::Kip::Mem_desc;
_vm_start = 0; _vm_size = 0;
Mem_desc const * const desc = Mem_desc::first(&kip);
@ -385,8 +382,8 @@ void Platform::_setup_basics()
panic("Virtual memory configuration not found");
/* configure applicable address space but never use page0 */
_vm_size = _vm_start == 0 ? _vm_size - L4_PAGESIZE : _vm_size;
_vm_start = _vm_start == 0 ? L4_PAGESIZE : _vm_start;
_vm_size = (_vm_start == 0 ? _vm_size - L4_PAGESIZE : _vm_size);
_vm_start = (_vm_start == 0 ? L4_PAGESIZE : _vm_start);
/* reserve virtual range for extended vCPU features - better way XXX ? */
if (_vm_start < VCPU_VIRT_EXT_END) {
@ -412,8 +409,8 @@ void Platform::_setup_basics()
remove_region(Region((addr_t)&kip, (addr_t)&kip + L4_PAGESIZE), _io_mem_alloc);
/* remove core program image memory from region and IO_MEM allocator */
addr_t img_start = (addr_t) &_prog_img_beg;
addr_t img_end = (addr_t) &_prog_img_end;
addr_t const img_start = (addr_t) &_prog_img_beg;
addr_t const img_end = (addr_t) &_prog_img_end;
remove_region(Region(img_start, img_end), _region_alloc);
remove_region(Region(img_start, img_end), _io_mem_alloc);
@ -422,18 +419,22 @@ 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()), _cap_id_alloc(core_mem_alloc()),
_kip_rom((addr_t)&sigma0_map_kip(), L4_PAGESIZE, "l4v2_kip"),
_sigma0(cap_map().insert(_cap_id_alloc.alloc(), Fiasco::L4_BASE_PAGER_CAP))
_sigma0(cap_map().insert(_cap_id_alloc.alloc(), Foc::L4_BASE_PAGER_CAP))
{
/*
* We must be single-threaded at this stage and so this is safe.
*/
static bool initialized = 0;
if (initialized) panic("Platform constructed twice!");
if (initialized)
panic("Platform constructed twice!");
initialized = true;
_setup_basics();
@ -446,10 +447,10 @@ Platform::Platform() :
Core_cap_index &pdi =
*reinterpret_cast<Core_cap_index*>(cap_map().insert(_cap_id_alloc.alloc(),
Fiasco::L4_BASE_TASK_CAP));
Foc::L4_BASE_TASK_CAP));
Core_cap_index &thi =
*reinterpret_cast<Core_cap_index*>(cap_map().insert(_cap_id_alloc.alloc(),
Fiasco::L4_BASE_THREAD_CAP));
Foc::L4_BASE_THREAD_CAP));
Core_cap_index &irqi =
*reinterpret_cast<Core_cap_index*>(cap_map().insert(_cap_id_alloc.alloc()));
@ -476,10 +477,11 @@ Platform::Platform() :
if (ram_alloc().alloc_aligned(size, &phys_ptr, align).error())
return;
if (region_alloc().alloc_aligned(size, &core_local_ptr, align).error())
return;
addr_t const phys_addr = reinterpret_cast<addr_t>(phys_ptr);
addr_t const phys_addr = reinterpret_cast<addr_t>(phys_ptr);
addr_t const core_local_addr = reinterpret_cast<addr_t>(core_local_ptr);
if (!map_local(phys_addr, core_local_addr, pages))
@ -487,18 +489,17 @@ Platform::Platform() :
memset(core_local_ptr, 0, size);
Genode::Xml_generator xml(reinterpret_cast<char *>(core_local_addr),
pages << get_page_size_log2(),
"platform_info", [&] ()
Xml_generator xml(reinterpret_cast<char *>(core_local_addr),
pages << get_page_size_log2(),
"platform_info", [&] ()
{
xml.node("kernel", [&] () { xml.attribute("name", "foc"); });
xml.node("hardware", [&] () {
_setup_platform_info(xml, sigma0_map_kip());
});
_setup_platform_info(xml, sigma0_map_kip()); });
xml.node("affinity-space", [&] () {
xml.attribute("width", affinity_space().width());
xml.attribute("height", affinity_space().height());
});
xml.attribute("height", affinity_space().height()); });
});
_rom_fs.insert(new (core_mem_alloc()) Rom_module(phys_addr, size,
@ -533,6 +534,7 @@ Platform::Platform() :
}
Affinity::Space const cpus = affinity_space();
for (unsigned cpu_id = 0; cpu_id < cpus.width(); cpu_id++)
{
struct Trace_source : public Trace::Source::Info_accessor,
@ -540,7 +542,7 @@ Platform::Platform() :
private Trace::Source
{
Affinity::Location const affinity;
Genode::String<8> const name;
String<8> const name;
/**
* Trace::Source::Info_accessor interface
@ -550,7 +552,7 @@ Platform::Platform() :
uint64_t ec_time = 0;
uint64_t const sc_time = 0;
using namespace Fiasco;
using namespace Foc;
l4_sched_cpu_set_t const cpu = l4_sched_cpu_set(affinity.xpos(), 0);
l4_msgtag_t const res = l4_scheduler_idle_time(L4_BASE_SCHEDULER_CAP,
&cpu, &ec_time);
@ -589,7 +591,7 @@ Platform::Platform() :
void Platform::wait_for_exit()
{
/*
* On Fiasco, Core never exits. So let us sleep forever.
* On Fiasco.OC, core never exits. So let us sleep forever.
*/
sleep_forever();
}
@ -597,8 +599,7 @@ void Platform::wait_for_exit()
Affinity::Space Platform::affinity_space() const
{
using namespace Genode;
using namespace Fiasco;
using namespace Foc;
l4_sched_cpu_set_t cpus = l4_sched_cpu_set(0, 0, 1);
l4_umword_t cpus_max;

View File

@ -1,5 +1,5 @@
/*
* \brief Fiasco protection domain facility
* \brief Fiasco.OC protection domain facility
* \author Christian Helmuth
* \author Stefan Kalkowski
* \date 2006-04-11
@ -22,17 +22,15 @@
#include <platform_pd.h>
#include <map_local.h>
/* Fiasco includes */
namespace Fiasco {
#include <l4/sys/utcb.h>
#include <l4/sys/factory.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
using namespace Fiasco;
using namespace Foc;
using namespace Genode;
static addr_t core_utcb_base() {
static addr_t core_utcb_base()
{
static addr_t base = (addr_t) l4_utcb();
return base;
}
@ -49,9 +47,11 @@ bool Platform_pd::bind_thread(Platform_thread &thread)
* number of threads is limited to 16K / L4_UTCB_OFFSET.
* (see kernel/fiasco/src/kern/kernel_thread-std.cpp:94)
*/
unsigned const thread_max = thread.core_thread() ? 16*1024/L4_UTCB_OFFSET : THREAD_MAX;
unsigned const thread_max = thread.core_thread()
? 16*1024/L4_UTCB_OFFSET : THREAD_MAX;
for (unsigned i = 0; i < thread_max; i++) {
if (_threads[i])
continue;
@ -63,7 +63,7 @@ bool Platform_pd::bind_thread(Platform_thread &thread)
thread._utcb =
reinterpret_cast<addr_t>(utcb_area_start() + i * L4_UTCB_OFFSET);
Fiasco::l4_cap_idx_t cap_offset = THREAD_AREA_BASE + i * THREAD_AREA_SLOT;
Foc::l4_cap_idx_t cap_offset = THREAD_AREA_BASE + i * THREAD_AREA_SLOT;
thread._gate.remote = cap_offset + THREAD_GATE_CAP;
thread._pager.remote = cap_offset + THREAD_PAGER_CAP;
@ -106,7 +106,7 @@ void Platform_pd::unbind_thread(Platform_thread &thread)
void Platform_pd::assign_parent(Native_capability parent)
{
if (_parent.remote == Fiasco::L4_INVALID_CAP && parent.valid()) {
if (_parent.remote == Foc::L4_INVALID_CAP && parent.valid()) {
_parent.local = parent;
_parent.remote = PARENT_CAP;
_parent.map(_task.local.data()->kcap());
@ -129,17 +129,21 @@ static Native_capability debug_cap()
}
Platform_pd::Platform_pd(Core_cap_index &ci)
: _task(Native_capability(&ci), TASK_CAP)
:
_task(Native_capability(&ci), TASK_CAP)
{ }
Platform_pd::Platform_pd(Allocator &, char const *)
: _task(true, TASK_CAP), _debug(debug_cap(), DEBUG_CAP)
:
_task(true, TASK_CAP), _debug(debug_cap(), DEBUG_CAP)
{
l4_fpage_t utcb_area = l4_fpage(utcb_area_start(),
log2<unsigned>(UTCB_AREA_SIZE), 0);
l4_msgtag_t tag = l4_factory_create_task(L4_BASE_FACTORY_CAP,
_task.local.data()->kcap(), utcb_area);
l4_fpage_t const utcb_area = l4_fpage(utcb_area_start(),
log2<unsigned>(UTCB_AREA_SIZE), 0);
l4_msgtag_t const tag = l4_factory_create_task(L4_BASE_FACTORY_CAP,
_task.local.data()->kcap(),
utcb_area);
if (l4_msgtag_has_error(tag))
error("pd creation failed");
}
@ -147,8 +151,7 @@ Platform_pd::Platform_pd(Allocator &, char const *)
Platform_pd::~Platform_pd()
{
for (unsigned i = 0; i < THREAD_MAX; i++) {
for (unsigned i = 0; i < THREAD_MAX; i++)
if (_threads[i])
_threads[i]->unbind();
}
}

View File

@ -1,5 +1,5 @@
/*
* \brief Fiasco thread facility
* \brief Fiasco.OC thread facility
* \author Stefan Kalkowski
* \date 2011-01-04
*/
@ -22,22 +22,16 @@
#include <platform.h>
#include <core_env.h>
/* Fiasco includes */
namespace Fiasco {
#include <l4/sys/debugger.h>
#include <l4/sys/factory.h>
#include <l4/sys/irq.h>
#include <l4/sys/scheduler.h>
#include <l4/sys/thread.h>
#include <l4/sys/types.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
using namespace Genode;
using namespace Fiasco;
using namespace Foc;
Trace::Execution_time Platform_thread::execution_time() const
{
Fiasco::l4_kernel_clock_t us = 0;
Foc::l4_kernel_clock_t us = 0;
l4_thread_stats_time(_thread.local.data()->kcap(), &us);
return { us, 0, 10000 /* quantum readable ?*/, _prio };
}
@ -98,10 +92,11 @@ void Platform_thread::pause()
Foc_thread_state &reg_state = _pager_obj->state.state;
unsigned exc = _pager_obj->state.exceptions;
reg_state.ip = ~0UL;
reg_state.sp = ~0UL;
l4_umword_t flags = L4_THREAD_EX_REGS_TRIGGER_EXCEPTION;
reg_state.ip = ~0UL;
reg_state.sp = ~0UL;
unsigned const exc = _pager_obj->state.exceptions;
l4_umword_t flags = L4_THREAD_EX_REGS_TRIGGER_EXCEPTION;
/* Mark thread to be stopped */
_pager_obj->state.paused = true;
@ -117,7 +112,8 @@ void Platform_thread::pause()
/*
* The thread state ("ready") is encoded in the lowest bit of the flags.
*/
bool in_syscall = (flags & 1) == 0;
bool const in_syscall = (flags & 1) == 0;
_pager_obj->state.mutex.release();
/**
@ -137,12 +133,12 @@ void Platform_thread::pause()
void Platform_thread::single_step(bool enabled)
{
Fiasco::l4_cap_idx_t const tid = thread().local.data()->kcap();
Foc::l4_cap_idx_t const tid = thread().local.data()->kcap();
enum { THREAD_SINGLE_STEP = 0x40000 };
int const flags = enabled ? THREAD_SINGLE_STEP : 0;
Fiasco::l4_thread_ex_regs(tid, ~0UL, ~0UL, flags);
Foc::l4_thread_ex_regs(tid, ~0UL, ~0UL, flags);
}
@ -157,7 +153,7 @@ void Platform_thread::resume()
_pager_obj->state.paused = false;
_pager_obj->state.mutex.release();
/* Send a message to the exception handler, to unblock the client */
/* send a message to the exception handler, to unblock the client */
Msgbuf<16> snd, rcv;
snd.insert(_pager_obj);
ipc_call(_pager_obj->cap(), snd, rcv, 0);
@ -168,7 +164,7 @@ void Platform_thread::bind(Platform_pd &pd)
{
_platform_pd = &pd;
_gate.map(pd.native_task().data()->kcap());
_irq.map(pd.native_task().data()->kcap());
_irq .map(pd.native_task().data()->kcap());
}
@ -211,7 +207,8 @@ void Platform_thread::state(Thread_state s)
Foc_thread_state Platform_thread::state()
{
Foc_thread_state s;
if (_pager_obj) s = _pager_obj->state.state;
if (_pager_obj)
s = _pager_obj->state.state;
s.kcap = _gate.remote;
s.id = _gate.local.local_name();
@ -273,7 +270,7 @@ void Platform_thread::_finalize_construction()
warning("attaching thread's irq failed");
/* set human readable name in kernel debugger */
Fiasco::l4_debugger_set_object_name(_thread.local.data()->kcap(), _name.string());
Foc::l4_debugger_set_object_name(_thread.local.data()->kcap(), _name.string());
/* set priority of thread */
l4_sched_param_t params = l4_sched_param(_prio);
@ -284,15 +281,16 @@ void Platform_thread::_finalize_construction()
Platform_thread::Platform_thread(size_t, const char *name, unsigned prio,
Affinity::Location location, addr_t)
: _name(name),
_state(DEAD),
_core_thread(false),
_thread(true),
_irq(true),
_utcb(0),
_platform_pd(0),
_pager_obj(0),
_prio(Cpu_session::scale_priority(DEFAULT_PRIORITY, prio))
:
_name(name),
_state(DEAD),
_core_thread(false),
_thread(true),
_irq(true),
_utcb(0),
_platform_pd(0),
_pager_obj(0),
_prio(Cpu_session::scale_priority(DEFAULT_PRIORITY, prio))
{
/* XXX remove const cast */
((Core_cap_index *)_thread.local.data())->pt(this);
@ -304,34 +302,34 @@ Platform_thread::Platform_thread(size_t, const char *name, unsigned prio,
Platform_thread::Platform_thread(Core_cap_index &thread,
Core_cap_index &irq, const char *name)
: _name(name),
_state(RUNNING),
_core_thread(true),
_thread(Native_capability(&thread), L4_BASE_THREAD_CAP),
_irq(Native_capability(&irq)),
_utcb(0),
_platform_pd(0),
_pager_obj(0),
_prio(Cpu_session::scale_priority(DEFAULT_PRIORITY, 0))
:
_name(name),
_state(RUNNING),
_core_thread(true),
_thread(Native_capability(&thread), L4_BASE_THREAD_CAP),
_irq(Native_capability(&irq)),
_utcb(0),
_platform_pd(0),
_pager_obj(0),
_prio(Cpu_session::scale_priority(DEFAULT_PRIORITY, 0))
{
/* XXX remove const cast */
((Core_cap_index *)_thread.local.data())->pt(this);
_finalize_construction();
}
Platform_thread::Platform_thread(const char *name)
: _name(name),
_state(DEAD),
_core_thread(true),
_thread(true),
_irq(true),
_utcb(0),
_platform_pd(0),
_pager_obj(0),
_prio(Cpu_session::scale_priority(DEFAULT_PRIORITY, 0))
:
_name(name),
_state(DEAD),
_core_thread(true),
_thread(true),
_irq(true),
_utcb(0),
_platform_pd(0),
_pager_obj(0),
_prio(Cpu_session::scale_priority(DEFAULT_PRIORITY, 0))
{
/* XXX remove const cast */
((Core_cap_index *)_thread.local.data())->pt(this);
_create_thread();
_finalize_construction();
@ -343,36 +341,36 @@ Platform_thread::~Platform_thread()
thread_cap_factory().free(_gate.local);
/*
* We inform our protection domain about thread destruction, which will end up in
* Thread::unbind()
* We inform our protection domain about thread destruction, which will end
* up in Thread::unbind()
*/
if (_platform_pd)
_platform_pd->unbind_thread(*this);
}
Fiasco::l4_cap_idx_t Platform_thread::setup_vcpu(unsigned const vcpu_id,
Foc::l4_cap_idx_t Platform_thread::setup_vcpu(unsigned const vcpu_id,
Cap_mapping const &task_vcpu,
Cap_mapping &vcpu_irq)
{
if (!_platform_pd)
return Fiasco::L4_INVALID_CAP;
if (vcpu_id >= (Platform::VCPU_VIRT_EXT_END - Platform::VCPU_VIRT_EXT_START) / L4_PAGESIZE)
return Fiasco::L4_INVALID_CAP;
return Foc::L4_INVALID_CAP;
Genode::addr_t const vcpu_addr = Platform::VCPU_VIRT_EXT_START +
L4_PAGESIZE * vcpu_id;
l4_fpage_t vm_page = l4_fpage( vcpu_addr, L4_PAGESHIFT, L4_FPAGE_RW);
if (vcpu_id >= (Platform::VCPU_VIRT_EXT_END - Platform::VCPU_VIRT_EXT_START) / L4_PAGESIZE)
return Foc::L4_INVALID_CAP;
addr_t const vcpu_addr = Platform::VCPU_VIRT_EXT_START + L4_PAGESIZE*vcpu_id;
l4_fpage_t const vm_page = l4_fpage( vcpu_addr, L4_PAGESHIFT, L4_FPAGE_RW);
l4_msgtag_t msg = l4_task_add_ku_mem(_platform_pd->native_task().data()->kcap(), vm_page);
if (l4_error(msg)) {
Genode::error("ku_mem failed ", l4_error(msg));
return Fiasco::L4_INVALID_CAP;
error("ku_mem failed ", l4_error(msg));
return Foc::L4_INVALID_CAP;
}
msg = l4_thread_vcpu_control_ext(_thread.local.data()->kcap(), vcpu_addr);
if (l4_error(msg)) {
Genode::error("vcpu_control_exit failed ", l4_error(msg));
return Fiasco::L4_INVALID_CAP;
error("vcpu_control_exit failed ", l4_error(msg));
return Foc::L4_INVALID_CAP;
}
/* attach thread to irq */

View File

@ -15,13 +15,15 @@
#include <ram_dataspace_factory.h>
#include <map_local.h>
namespace Fiasco {
#include <l4/sys/cache.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
using namespace Genode;
void Ram_dataspace_factory::_export_ram_ds(Dataspace_component &) { }
void Ram_dataspace_factory::_revoke_ram_ds(Dataspace_component &) { }
@ -30,6 +32,6 @@ void Ram_dataspace_factory::_clear_ds(Dataspace_component &ds)
memset((void *)ds.phys_addr(), 0, ds.size());
if (ds.cacheability() != CACHED)
Fiasco::l4_cache_dma_coherent(ds.phys_addr(), ds.phys_addr() + ds.size());
Foc::l4_cache_dma_coherent(ds.phys_addr(), ds.phys_addr() + ds.size());
}

View File

@ -26,14 +26,8 @@
#include <base/internal/cap_alloc.h>
#include <base/internal/foc_assert.h>
/* Fiasco includes */
namespace Fiasco {
#include <l4/sys/consts.h>
#include <l4/sys/debugger.h>
#include <l4/sys/factory.h>
#include <l4/sys/task.h>
#include <l4/sys/types.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
using namespace Genode;
@ -42,9 +36,9 @@ using namespace Genode;
** Cap_index_allocator **
***************************/
Genode::Cap_index_allocator &Genode::cap_idx_alloc()
Cap_index_allocator &Genode::cap_idx_alloc()
{
static Genode::Cap_index_allocator_tpl<Core_cap_index,10*1024> alloc;
static Cap_index_allocator_tpl<Core_cap_index,10*1024> alloc;
return alloc;
}
@ -60,11 +54,11 @@ Core_cap_index *Cap_mapping::_get_cap()
}
void Cap_mapping::map(Fiasco::l4_cap_idx_t task)
void Cap_mapping::map(Foc::l4_cap_idx_t task)
{
using namespace Fiasco;
using namespace Foc;
if (!local.valid() || !Fiasco::Capability::valid(remote))
if (!local.valid() || !Foc::Capability::valid(remote))
return;
l4_msgtag_t tag = l4_task_map(task, L4_BASE_TASK_CAP,
@ -75,12 +69,16 @@ void Cap_mapping::map(Fiasco::l4_cap_idx_t task)
}
Cap_mapping::Cap_mapping(bool alloc, Fiasco::l4_cap_idx_t r)
: local(alloc ? _get_cap() : (Native_capability::Data *)nullptr), remote(r) { }
Cap_mapping::Cap_mapping(bool alloc, Foc::l4_cap_idx_t r)
:
local(alloc ? _get_cap() : (Native_capability::Data *)nullptr), remote(r)
{ }
Cap_mapping::Cap_mapping(Native_capability cap, Fiasco::l4_cap_idx_t r)
: local(cap), remote(r) { }
Cap_mapping::Cap_mapping(Native_capability cap, Foc::l4_cap_idx_t r)
:
local(cap), remote(r)
{ }
/***********************
@ -97,7 +95,7 @@ Native_capability Rpc_cap_factory::alloc(Native_capability ep)
}
try {
using namespace Fiasco;
using namespace Foc;
Core_cap_index const * ref = static_cast<Core_cap_index const*>(ep.data());
@ -123,11 +121,13 @@ Native_capability Rpc_cap_factory::alloc(Native_capability ep)
cap_map().remove(idx);
platform_specific().cap_id_alloc().free(id);
return cap;
} else
/* set debugger-name of ipc-gate to thread's name */
Fiasco::l4_debugger_set_object_name(idx->kcap(), ref->pt()->name().string());
// XXX remove cast
} else {
/* set debugger-name of ipc-gate to thread's name */
Foc::l4_debugger_set_object_name(idx->kcap(), ref->pt()->name().string());
}
idx->session((Pd_session_component *)this);
idx->pt(ref->pt());
cap = Native_capability(idx);
@ -144,38 +144,41 @@ Native_capability Rpc_cap_factory::alloc(Native_capability ep)
*/
if (cap.valid())
_pool.insert(new (_entry_slab) Entry(cap));
return cap;
}
void Rpc_cap_factory::free(Native_capability cap)
{
using namespace Fiasco;
using namespace Foc;
if (!cap.valid()) return;
if (!cap.valid())
return;
/* check whether the capability was created by this cap_session */
if (static_cast<Core_cap_index const *>(cap.data())->session() != (Pd_session_component *)this)
return;
Entry * entry = nullptr;
_pool.apply(cap, [&] (Entry *e) {
entry = e;
if (e) {
_pool.remove(e);
Entry * entry_ptr = nullptr;
_pool.apply(cap, [&] (Entry *ptr) {
entry_ptr = ptr;
if (ptr) {
_pool.remove(ptr);
} else
warning("Could not find capability to be deleted");
});
if (entry) destroy(_entry_slab, entry);
if (entry_ptr)
destroy(_entry_slab, entry_ptr);
}
Rpc_cap_factory::~Rpc_cap_factory()
{
_pool.remove_all([this] (Entry *e) {
if (!e) return;
destroy(_entry_slab, e);
});
_pool.remove_all([this] (Entry *ptr) {
if (ptr)
destroy(_entry_slab, ptr); });
}
@ -184,7 +187,8 @@ Rpc_cap_factory::~Rpc_cap_factory()
*******************************/
Cap_id_allocator::Cap_id_allocator(Allocator &alloc)
: _id_alloc(&alloc)
:
_id_alloc(&alloc)
{
_id_alloc.add_range(CAP_ID_OFFSET, CAP_ID_RANGE);
}
@ -197,6 +201,7 @@ unsigned long Cap_id_allocator::alloc()
void *id = nullptr;
if (_id_alloc.alloc(CAP_ID_OFFSET, &id))
return (unsigned long) id;
throw Out_of_ids();
}
@ -210,15 +215,16 @@ void Cap_id_allocator::free(unsigned long id)
}
void Genode::Capability_map::remove(Genode::Cap_index *i)
void Capability_map::remove(Cap_index *i)
{
using namespace Genode;
using namespace Fiasco;
using namespace Foc;
Lock_guard<Spin_lock> guard(_lock);
if (i) {
Core_cap_index* e = static_cast<Core_cap_index*>(_tree.first() ? _tree.first()->find_by_id(i->id()) : 0);
Core_cap_index* e = static_cast<Core_cap_index*>(_tree.first()
? _tree.first()->find_by_id(i->id()) : nullptr);
if (e == i) {
l4_msgtag_t tag = l4_task_unmap(L4_BASE_TASK_CAP,
l4_obj_fpage(i->kcap(), 0, L4_FPAGE_RWX),
@ -226,7 +232,6 @@ void Genode::Capability_map::remove(Genode::Cap_index *i)
if (l4_msgtag_has_error(tag))
error("destruction of ipc-gate ", i->kcap(), " failed!");
platform_specific().cap_id_alloc().free(i->id());
_tree.remove(i);
}

View File

@ -20,10 +20,8 @@
#include <platform.h>
#include <signal_source_component.h>
namespace Fiasco {
#include <l4/sys/factory.h>
#include <l4/sys/irq.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
using namespace Genode;
@ -38,6 +36,7 @@ void Signal_source_component::release(Signal_context_component &context)
_signal_queue.remove(context);
}
void Signal_source_component::submit(Signal_context_component &context,
unsigned long cnt)
{
@ -48,7 +47,7 @@ void Signal_source_component::submit(Signal_context_component &context,
_signal_queue.enqueue(context);
/* wake up client */
Fiasco::l4_irq_trigger(_blocking_semaphore.data()->kcap());
Foc::l4_irq_trigger(_blocking_semaphore.data()->kcap());
}
}
@ -75,7 +74,7 @@ Signal_source_component::Signal_source_component(Rpc_entrypoint &ep)
Signal_source_rpc_object(cap_map().insert(platform_specific().cap_id_alloc().alloc())),
_entrypoint(ep)
{
using namespace Fiasco;
using namespace Foc;
l4_msgtag_t res = l4_factory_create_irq(L4_BASE_FACTORY_CAP,
_blocking_semaphore.data()->kcap());

View File

@ -16,23 +16,22 @@
/* core includes */
#include <ipc_pager.h>
namespace Fiasco {
#include <l4/sys/utcb.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
using namespace Genode;
enum Exceptions { EX_REGS = 0x500000 };
void Genode::Ipc_pager::_parse_exception()
void Ipc_pager::_parse_exception()
{
if (Fiasco::l4_utcb_exc()->err == EX_REGS)
_type = PAUSE;
else
_type = EXCEPTION;
_type = (Foc::l4_utcb_exc()->err == EX_REGS) ? PAUSE : EXCEPTION;
}
void Genode::Ipc_pager::get_regs(Foc_thread_state &state) const
void Ipc_pager::get_regs(Foc_thread_state &state) const
{
state.ip = _regs.pc;
state.sp = _regs.sp;
@ -54,7 +53,7 @@ void Genode::Ipc_pager::get_regs(Foc_thread_state &state) const
}
void Genode::Ipc_pager::set_regs(Foc_thread_state const &state)
void Ipc_pager::set_regs(Foc_thread_state const &state)
{
_regs.pc = state.ip;
_regs.sp = state.sp;
@ -75,7 +74,8 @@ void Genode::Ipc_pager::set_regs(Foc_thread_state const &state)
_regs.cpsr = state.cpsr;
}
bool Genode::Ipc_pager::exec_fault() const
bool Ipc_pager::exec_fault() const
{
return (_pf_addr & 4) && !(_pf_addr & 1);
}

View File

@ -13,9 +13,14 @@
#include <platform.h>
void Genode::Platform::_setup_io_port_alloc() { }
using namespace Genode;
void Genode::Platform::setup_irq_mode(unsigned, unsigned, unsigned) { }
void Genode::Platform::_setup_platform_info(Xml_generator &,
Fiasco::l4_kernel_info_t &) { }
void Platform::_setup_io_port_alloc() { }
void Platform::setup_irq_mode(unsigned, unsigned, unsigned) { }
void Platform::_setup_platform_info(Xml_generator &,
Foc::l4_kernel_info_t &) { }

View File

@ -16,36 +16,35 @@
/* core includes */
#include <ipc_pager.h>
namespace Fiasco {
#include <l4/sys/utcb.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
using namespace Genode;
enum Exceptions { EX_REGS = 0x500000 };
void Genode::Ipc_pager::_parse_exception()
void Ipc_pager::_parse_exception()
{
if (Fiasco::l4_utcb_exc()->err == EX_REGS)
_type = PAUSE;
else
_type = EXCEPTION;
_type = (Foc::l4_utcb_exc()->err == EX_REGS) ? PAUSE : EXCEPTION;
}
void Genode::Ipc_pager::get_regs(Foc_thread_state &state) const
void Ipc_pager::get_regs(Foc_thread_state &state) const
{
state.ip = _regs.pc;
state.sp = _regs.sp;
state.ip = _regs.pc;
state.sp = _regs.sp;
}
void Genode::Ipc_pager::set_regs(Foc_thread_state const &state)
void Ipc_pager::set_regs(Foc_thread_state const &state)
{
_regs.pc = state.ip;
_regs.sp = state.sp;
_regs.pc = state.ip;
_regs.sp = state.sp;
}
bool Genode::Ipc_pager::exec_fault() const
bool Ipc_pager::exec_fault() const
{
return (_pf_addr & 4) && !(_pf_addr & 1);
}

View File

@ -14,20 +14,22 @@
/* core includes */
#include <ipc_pager.h>
namespace Fiasco {
#include <l4/sys/utcb.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
using namespace Genode;
enum Exceptions { EX_REGS = 0xff };
void Genode::Ipc_pager::_parse_exception()
void Ipc_pager::_parse_exception()
{
if (Fiasco::l4_utcb_exc()->trapno == EX_REGS)
_type = PAUSE;
else
_type = EXCEPTION;
_type = (Foc::l4_utcb_exc()->trapno == EX_REGS) ? PAUSE : EXCEPTION;
}
bool Genode::Ipc_pager::exec_fault() const {
return ((_pf_addr & 1) && !write_fault()); }
bool Ipc_pager::exec_fault() const
{
return ((_pf_addr & 1) && !write_fault());
}

View File

@ -21,24 +21,25 @@
#include "util.h"
/* Fiasco.OC includes */
namespace Fiasco {
#include <l4/sys/ipc.h>
#include <l4/sys/icu.h>
#include <l4/sys/kip.h>
}
#include <foc/syscall.h>
void Genode::Platform::_setup_io_port_alloc()
using namespace Genode;
void Platform::_setup_io_port_alloc()
{
using namespace Fiasco;
using namespace Foc;
l4_fpage_t const fpage = l4_iofpage(0, L4_WHOLE_IOADDRESS_SPACE);
l4_fpage_t fpage = l4_iofpage(0, L4_WHOLE_IOADDRESS_SPACE);
l4_utcb_mr()->mr[0] = fpage.raw;
l4_utcb_br()->bdr &= ~L4_BDR_OFFSET_MASK;
l4_utcb_br()->br[0] = L4_ITEM_MAP;
l4_utcb_br()->br[1] = fpage.raw;
l4_msgtag_t tag = l4_ipc_call(L4_BASE_PAGER_CAP, l4_utcb(),
l4_msgtag(L4_PROTO_IO_PAGE_FAULT, 1, 0, 0),
L4_IPC_NEVER);
l4_msgtag_t const tag = l4_ipc_call(L4_BASE_PAGER_CAP, l4_utcb(),
l4_msgtag(L4_PROTO_IO_PAGE_FAULT, 1, 0, 0),
L4_IPC_NEVER);
if (l4_ipc_error(tag, l4_utcb()))
panic("Received no I/O ports from sigma0");
@ -48,10 +49,10 @@ void Genode::Platform::_setup_io_port_alloc()
}
void Genode::Platform::setup_irq_mode(unsigned irq_number, unsigned trigger,
unsigned polarity)
void Platform::setup_irq_mode(unsigned irq_number, unsigned trigger,
unsigned polarity)
{
using namespace Fiasco;
using namespace Foc;
l4_umword_t mode;
@ -65,16 +66,17 @@ void Genode::Platform::setup_irq_mode(unsigned irq_number, unsigned trigger,
} else {
/*
* Translate ACPI interrupt mode (trigger/polarity) to Fiasco APIC
* Translate ACPI interrupt mode (trigger/polarity) to Fiasco.OC APIC
* values. Default is level low
*/
if (trigger == Irq_session::TRIGGER_LEVEL || trigger == Irq_session::TRIGGER_UNCHANGED) {
if (trigger == Irq_session::TRIGGER_LEVEL || trigger == Irq_session::TRIGGER_UNCHANGED) {
if (polarity == Irq_session::POLARITY_LOW || polarity == Irq_session::POLARITY_UNCHANGED)
mode = L4_IRQ_F_LEVEL_LOW;
else
mode = L4_IRQ_F_LEVEL_HIGH;
}
else {
} else {
if (polarity == Irq_session::POLARITY_LOW || polarity == Irq_session::POLARITY_UNCHANGED)
mode = L4_IRQ_F_NEG_EDGE;
else
@ -82,17 +84,14 @@ void Genode::Platform::setup_irq_mode(unsigned irq_number, unsigned trigger,
}
}
/*
* Set mode
*/
if (l4_error(l4_icu_set_mode(L4_BASE_ICU_CAP, irq_number, mode)))
error("setting mode for IRQ ", irq_number, " failed");
}
static bool cpu_name(char const * name) {
using Genode::uint32_t;
static bool cpu_name(char const * name)
{
uint32_t cpuid = 0, edx = 0, ebx = 0, ecx = 0;
asm volatile ("cpuid" : "+a" (cpuid), "=d" (edx), "=b"(ebx), "=c"(ecx));
return ebx == *reinterpret_cast<uint32_t const *>(name) &&
@ -100,15 +99,14 @@ static bool cpu_name(char const * name) {
ecx == *reinterpret_cast<uint32_t const *>(name + 8);
}
void Genode::Platform::_setup_platform_info(Xml_generator &xml,
Fiasco::l4_kernel_info_t &kip)
void Platform::_setup_platform_info(Xml_generator &xml,
Foc::l4_kernel_info_t &kip)
{
xml.node("features", [&] () {
/* XXX better detection required, best told us by kernel !? */
xml.attribute("svm", cpu_name("AuthenticAMD"));
xml.attribute("vmx", cpu_name("GenuineIntel"));
});
xml.attribute("vmx", cpu_name("GenuineIntel")); });
xml.node("tsc", [&] () {
xml.attribute("freq_khz" , kip.frequency_cpu);
});
xml.attribute("freq_khz" , kip.frequency_cpu); });
}

View File

@ -27,6 +27,7 @@ void Genode::platform_add_local_services(Rpc_entrypoint &ep,
{
static Vm_root vm_root(ep, heap, core_env().ram_allocator(),
core_env().local_rm(), trace_sources);
static Core_service<Vm_session_component> vm(services, vm_root);
static Io_port_root io_root(*core_env().pd_session(),

View File

@ -16,8 +16,10 @@
/* core includes */
#include <ipc_pager.h>
using namespace Genode;
void Genode::Ipc_pager::get_regs(Foc_thread_state &state) const
void Ipc_pager::get_regs(Foc_thread_state &state) const
{
state.ip = _regs.ip;
state.sp = _regs.sp;
@ -35,7 +37,7 @@ void Genode::Ipc_pager::get_regs(Foc_thread_state &state) const
}
void Genode::Ipc_pager::set_regs(Foc_thread_state const &state)
void Ipc_pager::set_regs(Foc_thread_state const &state)
{
_regs.ip = state.ip;
_regs.sp = state.sp;

View File

@ -16,8 +16,10 @@
/* core includes */
#include <ipc_pager.h>
using namespace Genode;
void Genode::Ipc_pager::get_regs(Foc_thread_state &state) const
void Ipc_pager::get_regs(Foc_thread_state &state) const
{
state.ip = _regs.ip;
state.sp = _regs.sp;
@ -42,7 +44,7 @@ void Genode::Ipc_pager::get_regs(Foc_thread_state &state) const
}
void Genode::Ipc_pager::set_regs(Foc_thread_state const &state)
void Ipc_pager::set_regs(Foc_thread_state const &state)
{
_regs.ip = state.ip;
_regs.sp = state.sp;

View File

@ -14,6 +14,9 @@
/* base-internal includes */
#include <base/internal/stack_area.h>
using namespace Genode;
/*
* The base address of the context area differs for core, because
* roottask on Fiasco.OC uses identity mappings. The virtual address range
@ -21,4 +24,4 @@
* address range that lies outside of the RAM of the currently supported
* platforms.
*/
Genode::addr_t Genode::stack_area_virtual_base() { return 0x20000000UL; }
addr_t Genode::stack_area_virtual_base() { return 0x20000000UL; }

View File

@ -24,12 +24,8 @@
#include <platform.h>
#include <core_env.h>
namespace Fiasco {
#include <l4/sys/debugger.h>
#include <l4/sys/factory.h>
#include <l4/sys/scheduler.h>
#include <l4/sys/thread.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
using namespace Genode;
@ -45,7 +41,7 @@ void Thread::_init_platform_thread(size_t, Type) { }
void Thread::start()
{
using namespace Fiasco;
using namespace Foc;
/* create and start platform thread */
Platform_thread &pt = *new (platform().core_mem_alloc())
@ -53,7 +49,7 @@ void Thread::start()
platform_specific().core_pd().bind_thread(pt);
l4_utcb_t *foc_utcb = (l4_utcb_t *)(pt.utcb());
l4_utcb_t * const foc_utcb = (l4_utcb_t *)(pt.utcb());
native_thread() = Native_thread(pt.gate().remote);
@ -84,7 +80,7 @@ void Thread::start()
uint64_t const sc_time = 0;
addr_t const kcap = (addr_t) platform_thread.pager_object_badge();
using namespace Fiasco;
using namespace Foc;
l4_kernel_clock_t ec_time = 0;
l4_msgtag_t res = l4_thread_stats_time(kcap, &ec_time);
if (l4_error(res))

View File

@ -20,10 +20,8 @@
#include <pd_session_component.h>
#include <cpu_thread_component.h>
namespace Fiasco {
#include <l4/sys/factory.h>
}
/* Fiasco.OC includes */
#include <foc/syscall.h>
using namespace Genode;
@ -45,7 +43,7 @@ Vm_session_component::Vm_session_component(Rpc_entrypoint &ep,
{
_cap_quota_guard().withdraw(Cap_quota{1});
using namespace Fiasco;
using namespace Foc;
l4_msgtag_t msg = l4_factory_create_vm(L4_BASE_FACTORY_CAP,
_task_vcpu.local.data()->kcap());
if (l4_error(msg)) {
@ -58,6 +56,7 @@ Vm_session_component::Vm_session_component(Rpc_entrypoint &ep,
_map.add_range(0UL - 0x1000, 0x1000);
}
Vm_session_component::~Vm_session_component()
{
for (;Vcpu * vcpu = _vcpus.first();) {
@ -92,7 +91,7 @@ Vcpu::Vcpu(Constrained_ram_allocator &ram_alloc,
throw;
}
Fiasco::l4_msgtag_t msg = l4_factory_create_irq(Fiasco::L4_BASE_FACTORY_CAP,
Foc::l4_msgtag_t msg = l4_factory_create_irq(Foc::L4_BASE_FACTORY_CAP,
_recall.local.data()->kcap());
if (l4_error(msg)) {
_ram_alloc.free(_ds_cap);
@ -122,18 +121,20 @@ Vm_session::Vcpu_id Vm_session_component::_create_vcpu(Thread_capability cap)
Vcpu * vcpu = nullptr;
try {
vcpu = new (_heap) Vcpu(_constrained_md_ram_alloc,
_cap_quota_guard(),
Vcpu_id {_id_alloc});
_cap_quota_guard(),
Vcpu_id {_id_alloc});
Fiasco::l4_cap_idx_t task = thread->platform_thread().setup_vcpu(_id_alloc, _task_vcpu, vcpu->recall_cap());
if (task == Fiasco::L4_INVALID_CAP)
Foc::l4_cap_idx_t task =
thread->platform_thread().setup_vcpu(_id_alloc, _task_vcpu, vcpu->recall_cap());
if (task == Foc::L4_INVALID_CAP)
throw 0;
_ep.apply(vcpu->ds_cap(), [&] (Dataspace_component *ds) {
if (!ds)
throw 1;
/* tell client where to find task cap */
*reinterpret_cast<Fiasco::l4_cap_idx_t *>(ds->phys_addr()) = task;
*reinterpret_cast<Foc::l4_cap_idx_t *>(ds->phys_addr()) = task;
});
} catch (int) {
if (vcpu)
@ -174,7 +175,7 @@ void Vm_session_component::_attach_vm_memory(Dataspace_component &dsc,
Flexpage_iterator flex(dsc.phys_addr() + attribute.offset, attribute.size,
guest_phys, attribute.size, guest_phys);
using namespace Fiasco;
using namespace Foc;
uint8_t flags = L4_FPAGE_RO;
if (dsc.writable() && attribute.writeable)
@ -207,7 +208,7 @@ void Vm_session_component::_detach_vm_memory(addr_t guest_phys, size_t size)
Flexpage page = flex.page();
while (page.valid()) {
using namespace Fiasco;
using namespace Foc;
l4_task_unmap(_task_vcpu.local.data()->kcap(),
l4_fpage(page.addr, page.log2_order, L4_FPAGE_RWX),