hw: avoid mandatory function calls in assertions

ref #528
This commit is contained in:
Martin Stein 2013-08-29 12:19:09 +02:00 committed by Norman Feske
parent 385b7cdd31
commit 545a397fa6
5 changed files with 22 additions and 15 deletions

View File

@ -51,10 +51,12 @@ namespace Genode
Platform_pd(char const *label) : _main_thread(0), _label(label)
{
/* get some aligned space for the kernel object */
void * kernel_pd;
void * kernel_pd = 0;
Range_allocator * ram = platform()->ram_alloc();
assert(ram->alloc_aligned(Kernel::pd_size(), &kernel_pd,
Kernel::pd_alignm_log2()).is_ok())
bool kernel_pd_ok =
ram->alloc_aligned(Kernel::pd_size(), &kernel_pd,
Kernel::pd_alignm_log2()).is_ok();
assert(kernel_pd_ok);
/* create kernel object */
_id = Kernel::new_pd(kernel_pd, this);

View File

@ -852,12 +852,13 @@ namespace Kernel
void handle_pagefault(Thread * const user)
{
/* check out cause and attributes of abort */
addr_t va;
bool w;
assert(user->translation_miss(va, w));
addr_t virt_addr = 0;
bool write = 0;
bool is_transl_miss = user->translation_miss(virt_addr, write);
assert(is_transl_miss);
/* the user might be able to resolve the pagefault */
user->pagefault(va, w);
user->pagefault(virt_addr, write);
}

View File

@ -183,7 +183,7 @@ namespace Kernel
*/
unsigned alloc()
{
if (!_valid_id(_first_free_id)) assert(0);
assert(_valid_id(_first_free_id));
_free[_first_free_id] = 0;
unsigned const id = _first_free_id;
_first_free_id_assigned();

View File

@ -71,8 +71,10 @@ Platform_thread::Platform_thread(const char * name,
/* create UTCB for a core thread */
Range_allocator * const ram = platform()->ram_alloc();
assert(ram->alloc_aligned(sizeof(Native_utcb), (void **)&_phys_utcb,
MIN_MAPPING_SIZE_LOG2).is_ok());
bool phys_utcb_ok = ram->alloc_aligned(sizeof(Native_utcb),
(void **)&_phys_utcb,
MIN_MAPPING_SIZE_LOG2).is_ok();
assert(phys_utcb_ok);
_virt_utcb = _phys_utcb;
/* common constructor parts */

View File

@ -70,14 +70,16 @@ void Ipc_pager::resolve_and_wait_for_fault()
_mapping.size_log2, flags);
if (sl2)
{
/* try to get some natural aligned space */
void * space;
assert(platform()->ram_alloc()->alloc_aligned(1<<sl2, &space, sl2).is_ok());
/* try to get some natural aligned RAM */
void * ram;
bool ram_ok = platform()->ram_alloc()->alloc_aligned(1<<sl2, &ram,
sl2).is_ok();
assert(ram_ok);
/* try to translate again with extra space */
/* try to translate again with extra RAM */
sl2 = tlb->insert_translation(_mapping.virt_address,
_mapping.phys_address,
_mapping.size_log2, flags, space);
_mapping.size_log2, flags, ram);
assert(!sl2);
}
/* wake up faulter */