base-nova: Coding style

This commit is contained in:
Norman Feske 2013-01-11 23:10:21 +01:00
parent bef78dd9f8
commit 8fe0c6c91c
25 changed files with 125 additions and 98 deletions

View File

@ -198,6 +198,7 @@ namespace Nova {
return syscall_0(NOVA_EC_CTRL, 0, ec);
}
ALWAYS_INLINE
inline uint8_t create_sc(unsigned sc, unsigned pd, unsigned ec, Qpd qpd)
{

View File

@ -174,6 +174,7 @@ namespace Nova {
return syscall_0(NOVA_EC_CTRL, 0, ec);
}
ALWAYS_INLINE
inline uint8_t create_sc(mword_t sc, mword_t pd, mword_t ec, Qpd qpd)
{

View File

@ -22,6 +22,7 @@ namespace Genode {
class Bit_allocator
{
protected:
Bit_array<WORDS> _array;
void _reserve(addr_t bit_start, size_t const num_cap)
@ -40,8 +41,7 @@ namespace Genode {
try {
/*
* Throws exception if array is
* accessed outside bounds
* Throws exception if array is * accessed outside bounds
*/
while (true) {
if (_array.get(i, step)) {

View File

@ -76,9 +76,10 @@ namespace Genode {
struct Raw
{
Dst dst;
/*
* It is obsolete and unused in NOVA,
* however still used by generic base part
* It is obsolete and unused in NOVA, however still used by
* generic base part
*/
addr_t local_name;
};

View File

@ -57,7 +57,8 @@ namespace Genode {
addr_t _initial_esp;
addr_t _initial_eip;
struct {
struct
{
struct Thread_state thread;
addr_t sel_client_ec;
bool valid;

View File

@ -23,11 +23,10 @@ namespace Genode {
{
virtual ~Nova_cpu_session() { }
virtual
Native_capability native_cap(Thread_capability cap) = 0;
virtual Native_capability native_cap(Thread_capability cap) = 0;
virtual Native_capability pause_sync(Thread_capability) = 0;
virtual
Native_capability pause_sync(Thread_capability) = 0;
/*********************
** RPC declaration **

View File

@ -42,6 +42,7 @@ addr_t Cap_selector_allocator::alloc(size_t num_caps_log2)
return ret_base;
}
void Cap_selector_allocator::free(addr_t cap, size_t num_caps_log2)
{
alloc_lock()->lock();

View File

@ -27,6 +27,7 @@ using namespace Nova;
enum { PF_HANDLER_STACK_SIZE = sizeof(addr_t) * 1024 };
extern Genode::addr_t __core_pd_sel;
Utcb * Pager_object::_check_handler(Thread_base *&myself, Pager_object *&obj)
{
Utcb * utcb;
@ -49,6 +50,7 @@ Utcb * Pager_object::_check_handler(Thread_base *&myself, Pager_object *&obj)
sleep_forever();
}
void Pager_object::_page_fault_handler()
{
Ipc_pager ipc_pager;
@ -80,6 +82,7 @@ void Pager_object::_page_fault_handler()
ipc_pager.reply_and_wait_for_fault();
}
void Pager_object::_exception_handler(addr_t portal_id)
{
Thread_base *myself;
@ -100,6 +103,7 @@ void Pager_object::_exception_handler(addr_t portal_id)
reply(myself->stack_top());
}
void Pager_object::_recall_handler()
{
Thread_base *myself;
@ -139,6 +143,7 @@ void Pager_object::_recall_handler()
reply(myself->stack_top());
}
void Pager_object::_startup_handler()
{
Thread_base *myself;
@ -169,7 +174,7 @@ void Pager_object::_invoke_handler()
if (event < PT_SEL_PARENT || event == PT_SEL_STARTUP ||
event == SM_SEL_EC || event == PT_SEL_RECALL) {
/**
/*
* Caller is requesting the SM cap of thread
* this object is paging - it is stored at SM_SEL_EC_CLIENT
*/
@ -188,14 +193,16 @@ void Pager_object::_invoke_handler()
void Pager_object::wake_up() { cancel_blocking(); }
void Pager_object::client_cancel_blocking() {
void Pager_object::client_cancel_blocking()
{
uint8_t res = sm_ctrl(exc_pt_sel() + SM_SEL_EC_CLIENT, SEMAPHORE_UP);
if (res != NOVA_OK)
PWRN("cancel blocking failed");
}
uint8_t Pager_object::client_recall() {
uint8_t Pager_object::client_recall()
{
return ec_ctrl(_state.sel_client_ec);
}
@ -217,7 +224,7 @@ Pager_object::Pager_object(unsigned long badge)
/* creates local EC */
Thread_base::start();
/* Create portal for exception handlers 0x0 - 0xd */
/* create portal for exception handlers 0x0 - 0xd */
for (unsigned i = 0; i < PT_SEL_PAGE_FAULT; i++) {
res = create_pt(exc_pt_sel() + i, pd_sel, _tid.ec_sel,
Mtd(0), (addr_t)_exception_handler);
@ -241,7 +248,7 @@ Pager_object::Pager_object(unsigned long badge)
throw Create_page_fault_pt_failed();
}
/* Create portal for exception handlers 0xf - 0x19 */
/* create portal for exception handlers 0xf - 0x19 */
for (unsigned i = PT_SEL_PAGE_FAULT + 1; i < PT_SEL_PARENT; i++) {
res = create_pt(exc_pt_sel() + i, pd_sel, _tid.ec_sel,
Mtd(0), (addr_t)_exception_handler);
@ -261,7 +268,7 @@ Pager_object::Pager_object(unsigned long badge)
throw Create_startup_pt_failed();
}
/* Create portal for recall handler */
/* create portal for recall handler */
Mtd mtd(Mtd::ESP | Mtd::EIP | Mtd::ACDB | Mtd::EFL | Mtd::EBSD | Mtd::FSGS);
res = create_pt(exc_pt_sel() + PT_SEL_RECALL, pd_sel, _tid.ec_sel,
mtd, (addr_t)_recall_handler);
@ -271,7 +278,7 @@ Pager_object::Pager_object(unsigned long badge)
throw Create_recall_pt_failed();
}
/* Create portal for final cleanup call used during destruction */
/* create portal for final cleanup call used during destruction */
res = create_pt(_pt_cleanup, pd_sel, _tid.ec_sel, Mtd(0),
reinterpret_cast<addr_t>(_invoke_handler));
if (res) {
@ -287,9 +294,10 @@ Pager_object::Pager_object(unsigned long badge)
}
}
Pager_object::~Pager_object()
{
/**
/*
* Revoke all portals of Pager_object from others.
* The portals will be finally revoked during thread destruction.
*/
@ -302,7 +310,8 @@ Pager_object::~Pager_object()
sm_ctrl(sm_cap, SEMAPHORE_UP);
revoke(Obj_crd(sm_cap, 0));
/* Make sure nobody is in the handler anymore by doing an IPC to a
/*
* Make sure nobody is in the handler anymore by doing an IPC to a
* local cap pointing to same serving thread (if not running in the
* context of the serving thread). When the call returns
* we know that nobody is handled by this object anymore, because
@ -315,7 +324,7 @@ Pager_object::~Pager_object()
PERR("failure - cleanup call failed res=%d", res);
}
/* Revoke portal used for the cleanup call */
/* revoke portal used for the cleanup call */
revoke(Obj_crd(_pt_cleanup, 0));
cap_selector_allocator()->free(_pt_cleanup, 0);
cap_selector_allocator()->free(sm_cap, 0);

View File

@ -26,6 +26,7 @@
using namespace Genode;
/***********************
** Server entrypoint **
***********************/
@ -62,13 +63,11 @@ void Rpc_entrypoint::_dissolve(Rpc_object_base *obj)
remove_locked(obj);
/*
* The activation may execute a blocking operation
* in a dispatch function. Before resolving the
* corresponding object, we need to ensure that
* it is no longer used by an activation. Therefore,
* we to need cancel an eventually blocking operation
* and let the activation leave the context of the
* object.
* The activation may execute a blocking operation in a dispatch function.
* Before resolving the corresponding object, we need to ensure that it is
* no longer used by an activation. Therefore, we to need cancel an
* eventually blocking operation and let the activation leave the context
* of the object.
*/
_leave_server_object(obj);
@ -123,7 +122,9 @@ void Rpc_entrypoint::_activation_entry()
ep->_curr_obj = curr_obj;
}
if (!ep->_curr_obj) {
/* Badge is used to suppress error message solely.
/*
* Badge is used to suppress error message solely.
* It's non zero during cleanup call of an
* rpc_object_base object, see _leave_server_object.
*/
@ -205,7 +206,7 @@ Rpc_entrypoint::Rpc_entrypoint(Cap_session *cap_session, size_t stack_size,
_delay_start(Lock::LOCKED),
_cap_session(cap_session)
{
/**
/*
* Create thread if we aren't running in core.
*
* For core this code can't be performed since the sessions aren't
@ -242,7 +243,7 @@ Rpc_entrypoint::Rpc_entrypoint(Cap_session *cap_session, size_t stack_size,
request_event_portal(pager_cap, _tid.exc_pt_sel,
Nova::PT_SEL_RECALL);
/**
/*
* Request native thread cap, _thread_cap only a token.
* The native thread cap is required to attach new rpc objects
* (to create portals bound to the ec)
@ -254,7 +255,7 @@ Rpc_entrypoint::Rpc_entrypoint(Cap_session *cap_session, size_t stack_size,
_tid.ec_sel = ec_cap.local_name();
}
else
/**
/*
* Required for core threads (creates local EC)
*/
Thread_base::start();

View File

@ -19,6 +19,7 @@
using namespace Genode;
Native_capability
Cpu_session_component::native_cap(Thread_capability thread_cap)
{
@ -30,6 +31,7 @@ Cpu_session_component::native_cap(Thread_capability thread_cap)
return thread->platform_thread()->native_cap();
}
Native_capability
Cpu_session_component::pause_sync(Thread_capability thread_cap)
{
@ -41,6 +43,7 @@ Cpu_session_component::pause_sync(Thread_capability thread_cap)
return thread->platform_thread()->pause();
}
void
Cpu_session_component::single_step(Thread_capability thread_cap, bool enable)
{

View File

@ -14,7 +14,7 @@
/* Genode includes */
#include <base/printf.h>
/* Core includes */
/* core includes */
#include <cpu_session_component.h>
using namespace Genode;

View File

@ -28,6 +28,7 @@ enum {
ECHO_EXC_BASE = 0
};
inline void *echo_stack_top()
{
static char echo_stack[ECHO_STACK_SIZE];

View File

@ -29,11 +29,8 @@ namespace Genode {
static long _unique_id_cnt;
class Cap_object : public Native_capability,
public List<Cap_object>::Element
struct Cap_object : Native_capability, List<Cap_object>::Element
{
public:
Cap_object(addr_t cap_sel) : Native_capability(cap_sel) {}
};
@ -47,8 +44,7 @@ namespace Genode {
* Constructor
*/
Cap_session_component(Allocator *md_alloc, const char *args)
:
_cap_slab(md_alloc) { }
: _cap_slab(md_alloc) { }
/**
* Destructor
@ -105,7 +101,8 @@ namespace Genode {
return Native_capability::invalid_cap();
}
void free(Native_capability cap) {
void free(Native_capability cap)
{
if (!cap.valid()) return;
Lock::Guard cap_lock(_cap_lock);

View File

@ -155,6 +155,7 @@ inline int map_local(Nova::Utcb *utcb,
return 0;
}
/**
* Unmap pages from the local address space
*

View File

@ -88,7 +88,6 @@ namespace Genode {
* \return PD selector
*/
static addr_t pd_core_sel() { return __core_pd_sel; }
};
}

View File

@ -36,6 +36,7 @@ enum { verbose_boot_info = true };
Native_utcb *main_thread_utcb();
/**
* Initial value of esp register, saved by the crt0 startup code
*
@ -425,7 +426,6 @@ Platform::Platform() :
Rom_module *rom_module = new (core_mem_alloc())
Rom_module(core_local_addr, mem_desc->size, name);
_rom_fs.insert(rom_module);
}
/* export hypervisor info page as ROM module */

View File

@ -20,6 +20,7 @@
using namespace Genode;
/***************************
** Public object members **
***************************/

View File

@ -64,7 +64,7 @@ int Platform_thread::start(void *ip, void *sp)
return -3;
}
/**
/*
* Create semaphore required for Genode locking.
* It is created at the root pager exception base +
* SM_SEL_EC_CLIENT and can be later on requested by the thread
@ -127,14 +127,14 @@ int Platform_thread::start(void *ip, void *sp)
uint8_t res;
/* Create lock for EC used by lock_helper */
/* create lock for EC used by lock_helper */
res = create_sm(sm_ec_sel, pd_core_sel, 0);
if (res != NOVA_OK) {
PERR("could not create semaphore for new thread");
goto cleanup_base;
}
/* Remap exception portals for first thread */
/* remap exception portals for first thread */
if (map_local((Utcb *)Thread_base::myself()->utcb(),
Obj_crd(_pager->exc_pt_sel(), 4),
Obj_crd(_sel_exc_base, 4)))
@ -155,7 +155,7 @@ int Platform_thread::start(void *ip, void *sp)
goto cleanup_base;
}
/* Remap Genode specific, RECALL and STARTUP portals for first thread */
/* remap Genode specific, RECALL and STARTUP portals for first thread */
for (unsigned i = 0; i < sizeof(remap_dst)/sizeof(remap_dst[0]); i++) {
if (map_local((Utcb *)Thread_base::myself()->utcb(),
Obj_crd(remap_src[i], 0),
@ -172,7 +172,7 @@ int Platform_thread::start(void *ip, void *sp)
goto cleanup_pd;
}
/* Create first thread in task */
/* create first thread in task */
enum { THREAD_GLOBAL = true };
res = create_ec(_sel_ec(), pd_sel, _cpu_no, pd_utcb, 0, 0,
THREAD_GLOBAL);
@ -181,7 +181,7 @@ int Platform_thread::start(void *ip, void *sp)
goto cleanup_pd;
}
/**
/*
* We have to assign the pd here, because after create_sc the thread
* becomes running immediately.
*/
@ -190,10 +190,10 @@ int Platform_thread::start(void *ip, void *sp)
_pager->initial_eip((addr_t)ip);
_pager->initial_esp((addr_t)sp);
/* Let the thread run */
/* let the thread run */
res = create_sc(_sel_sc(), pd_sel, _sel_ec(), Qpd());
if (res != NOVA_OK) {
/**
/*
* Reset pd cap since thread got not running and pd cap will
* be revoked during cleanup.
*/
@ -257,13 +257,15 @@ void Platform_thread::resume()
_pager->wake_up();
}
Thread_state Platform_thread::state()
{
Thread_state s;
if (!_pager) throw Cpu_session::State_access_failed();
_pager->copy_thread_state(&s);
return s;
};
}
void Platform_thread::state(Thread_state s)
{
@ -274,7 +276,7 @@ void Platform_thread::state(Thread_state s)
if (_sel_exc_base != Native_thread::INVALID_INDEX)
throw Cpu_session::State_access_failed();
/**
/*
* _sel_exc_base exception base of thread in caller
* protection domain - not in Core !
* _is_vcpu If true it will run as vCPU,
@ -282,7 +284,8 @@ void Platform_thread::state(Thread_state s)
*/
_sel_exc_base = s.sel_exc_base;
_is_vcpu = s.is_vcpu;
};
}
void Platform_thread::cancel_blocking()
{
@ -291,6 +294,7 @@ void Platform_thread::cancel_blocking()
_pager->client_cancel_blocking();
}
void Platform_thread::single_step(bool on)
{
if (!_pager) return;
@ -298,6 +302,7 @@ void Platform_thread::single_step(bool on)
_pager->single_step(on);
}
unsigned long Platform_thread::pager_object_badge() const
{
return Native_thread::INVALID_INDEX;
@ -305,9 +310,11 @@ unsigned long Platform_thread::pager_object_badge() const
Platform_thread::Platform_thread(const char *name, unsigned, int thread_id)
: _pd(0), _pager(0), _id_base(cap_selector_allocator()->alloc(1)),
:
_pd(0), _pager(0), _id_base(cap_selector_allocator()->alloc(1)),
_sel_exc_base(Native_thread::INVALID_INDEX), _cpu_no(0),
_is_main_thread(false), _is_vcpu(false) { }
_is_main_thread(false), _is_vcpu(false)
{ }
Platform_thread::~Platform_thread()

View File

@ -30,6 +30,7 @@ using namespace Genode;
void Ram_session_component::_export_ram_ds(Dataspace_component *ds) { }
void Ram_session_component::_revoke_ram_ds(Dataspace_component *ds)
{
size_t page_rounded_size = (ds->size() + get_page_size() - 1) & get_page_mask();
@ -48,6 +49,7 @@ void Ram_session_component::_revoke_ram_ds(Dataspace_component *ds)
ds->assign_core_local_addr(0);
}
void Ram_session_component::_clear_ds(Dataspace_component *ds)
{
/*

View File

@ -24,6 +24,7 @@ using namespace Genode;
static const bool verbose = false;
void Rm_client::unmap(addr_t core_local_base, addr_t virt_base, size_t size)
{
addr_t const core_local_end = core_local_base + (size - 1);
@ -48,7 +49,7 @@ void Rm_client::unmap(addr_t core_local_base, addr_t virt_base, size_t size)
+ (0x1000 << crd.order()); /* size of mapping */
} else {
/* This can happen if the region has never been touched */
/* this can happen if the region has never been touched */
if (verbose)
PINF("Nothing mapped at local: %08lx virt: %08lx",

View File

@ -36,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,
Ipc_ostream *ostream,
int cnt)