From 2afa25be1d8b65c0871c429e91058a4e84400cf8 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Fri, 30 Aug 2013 14:15:13 +0200 Subject: [PATCH] hw: no asserts in platform PD ref #528 --- base-hw/src/core/include/platform_pd.h | 24 +++++++++++++----------- base-hw/src/core/platform_pd.cc | 13 +++++++++---- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/base-hw/src/core/include/platform_pd.h b/base-hw/src/core/include/platform_pd.h index 6f5cc3ffa..95c14e889 100644 --- a/base-hw/src/core/include/platform_pd.h +++ b/base-hw/src/core/include/platform_pd.h @@ -16,6 +16,7 @@ /* Genode includes */ #include +#include /* Core includes */ #include @@ -56,11 +57,16 @@ namespace Genode bool kernel_pd_ok = ram->alloc_aligned(Kernel::pd_size(), &kernel_pd, Kernel::pd_alignm_log2()).is_ok(); - assert(kernel_pd_ok); - + if (!kernel_pd_ok) { + PERR("failed to allocate kernel object"); + throw Root::Quota_exceeded(); + } /* create kernel object */ _id = Kernel::new_pd(kernel_pd, this); - assert(_id); + if (!_id) { + PERR("failed to create kernel object"); + throw Root::Unavailable(); + } } /** @@ -86,19 +92,15 @@ namespace Genode return t->join_pd(_id, 0, Address_space::weak_ptr()); } - /** - * Unbind thread from protection domain - * - * Free the thread's slot and update thread object. - */ - void unbind_thread(Platform_thread * t); - /** * Assign parent interface to protection domain */ int assign_parent(Native_capability parent) { - assert(parent.valid()); + if (!parent.valid()) { + PERR("parent invalid"); + return -1; + } _parent = parent; return 0; } diff --git a/base-hw/src/core/platform_pd.cc b/base-hw/src/core/platform_pd.cc index d2446ce1f..ca76841a4 100644 --- a/base-hw/src/core/platform_pd.cc +++ b/base-hw/src/core/platform_pd.cc @@ -21,8 +21,13 @@ using namespace Genode; ** Platform PD ** *****************/ -void Platform_pd::unbind_thread(Platform_thread *thread) { assert(0); } - - -Platform_pd::~Platform_pd() { assert(0); } +Platform_pd::~Platform_pd() +{ + /* + * FIXME: throwing exceptions is not declared for + * 'Pd_root::close' wich is why we can only + * print an error + */ + PERR("not implemented"); +}