Propagate loader-session errors as exceptions

This commit is contained in:
Norman Feske 2012-06-06 17:30:06 +02:00
parent 7a965bd877
commit 17b60f8d41
3 changed files with 27 additions and 10 deletions

View File

@ -108,6 +108,9 @@ namespace Loader {
/**
* Start subsystem
*
* \throw Rom_module_does_not_exist if the specified binary could
* not obtained as ROM module
*/
virtual void start(Name const &binary, Name const &label = "") = 0;
@ -132,12 +135,17 @@ namespace Loader {
GENODE_RPC(Rpc_alloc_rom_module, Dataspace_capability, alloc_rom_module,
Name const &, size_t);
GENODE_RPC(Rpc_commit_rom_module, void, commit_rom_module, Name const &);
GENODE_RPC_THROW(Rpc_commit_rom_module, void, commit_rom_module,
GENODE_TYPE_LIST(Rom_module_does_not_exist),
Name const &);
GENODE_RPC(Rpc_ram_quota, void, ram_quota, size_t);
GENODE_RPC(Rpc_constrain_geometry, void, constrain_geometry, int, int);
GENODE_RPC(Rpc_view_ready_sigh, void, view_ready_sigh, Signal_context_capability);
GENODE_RPC(Rpc_start, void, start, Name const &, Name const &);
GENODE_RPC(Rpc_view, Nitpicker::View_capability, view);
GENODE_RPC_THROW(Rpc_start, void, start,
GENODE_TYPE_LIST(Rom_module_does_not_exist),
Name const &, Name const &);
GENODE_RPC_THROW(Rpc_view, Nitpicker::View_capability, view,
GENODE_TYPE_LIST(View_does_not_exist));
GENODE_RPC(Rpc_view_geometry, View_geometry, view_geometry);
GENODE_RPC_INTERFACE(Rpc_alloc_rom_module, Rpc_commit_rom_module,

View File

@ -79,9 +79,14 @@ namespace Loader {
Rom_session_capability _rom_session(char const *name)
{
char args[Session::Name::MAX_SIZE];
snprintf(args, sizeof(args), "ram_quota=4K, filename=\"%s\"", name);
return static_cap_cast<Rom_session>(_local_rom_service.session(args));
try {
char args[Session::Name::MAX_SIZE];
snprintf(args, sizeof(args), "ram_quota=4K, filename=\"%s\"", name);
return static_cap_cast<Rom_session>(_local_rom_service.session(args));
} catch (Genode::Parent::Service_denied) {
PERR("Lookup for ROM module \"%s\" failed", name);
throw;
}
}
public:

View File

@ -255,10 +255,14 @@ namespace Loader {
min(_subsystem_ram_quota_limit, _ram_session_client.avail()) :
_ram_session_client.avail();
_child = new (&_md_alloc)
Child(binary_name.string(), label.string(), _ep,
_ram_session_client, ram_quota, _parent_services,
_rom_service, _nitpicker_service, _width, _height);
try {
_child = new (&_md_alloc)
Child(binary_name.string(), label.string(), _ep,
_ram_session_client, ram_quota, _parent_services,
_rom_service, _nitpicker_service, _width, _height);
}
catch (Genode::Parent::Service_denied) {
throw Rom_module_does_not_exist(); }
}
Nitpicker::View_capability view()