bb00aebc9e
By now Signal_session_component has allocated initial SLAB blocks in constructor, wich crashed with the root components assumptions about the RAM quota needs of session creation. Thus, if the background allocator was already exhausted from component allocation the session was created with broken initial SLAB blocks. fix #574
78 lines
2.2 KiB
C++
78 lines
2.2 KiB
C++
/*
|
|
* \brief Implementation of the SIGNAL service on the HW-core
|
|
* \author Martin Stein
|
|
* \date 2012-05-05
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2012-2013 Genode Labs GmbH
|
|
*
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
* under the terms of the GNU General Public License version 2.
|
|
*/
|
|
|
|
/* Genode includes */
|
|
#include <base/printf.h>
|
|
#include <kernel/syscalls.h>
|
|
|
|
/* core includes */
|
|
#include <signal_session_component.h>
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
Signal_session_component::Signal_session_component(Allocator * const md,
|
|
size_t const ram_quota) :
|
|
_md_alloc(md, ram_quota),
|
|
_receivers_slab(Kernel::signal_receiver_size(), RECEIVERS_SB_SIZE,
|
|
(Slab_block *)&_initial_receivers_sb, &_md_alloc),
|
|
_contexts_slab(Kernel::signal_context_size(), CONTEXTS_SB_SIZE,
|
|
(Slab_block *)&_initial_contexts_sb, &_md_alloc)
|
|
{ }
|
|
|
|
|
|
Signal_session_component::~Signal_session_component()
|
|
{
|
|
PERR("%s: Not implemented", __PRETTY_FUNCTION__);
|
|
while (1) ;
|
|
}
|
|
|
|
|
|
Signal_receiver_capability Signal_session_component::alloc_receiver()
|
|
{
|
|
/* create receiver kernel-object */
|
|
size_t const s = Kernel::signal_receiver_size();
|
|
void * p;
|
|
if (!_receivers_slab.alloc(s, &p)) throw Out_of_metadata();
|
|
unsigned const id = Kernel::new_signal_receiver(p);
|
|
if (!id) throw Out_of_metadata();
|
|
|
|
/* return reference to the new kernel-object */
|
|
Native_capability c(id, 0);
|
|
return reinterpret_cap_cast<Signal_receiver>(c);
|
|
}
|
|
|
|
|
|
Signal_context_capability
|
|
Signal_session_component::alloc_context(Signal_receiver_capability r,
|
|
unsigned imprint)
|
|
{
|
|
/* create context kernel-object */
|
|
size_t const s = Kernel::signal_context_size();
|
|
void * p;
|
|
if (!_contexts_slab.alloc(s, &p)) throw Out_of_metadata();
|
|
unsigned const id = Kernel::new_signal_context(p, r.dst(), imprint);
|
|
if (!id) throw Out_of_metadata();
|
|
|
|
/* return reference to the new kernel-object */
|
|
Native_capability c(id, 0);
|
|
return reinterpret_cap_cast<Signal_context>(c);
|
|
}
|
|
|
|
/**
|
|
* FIXME should regain the kernel-object memory from kernel
|
|
*/
|
|
void Signal_session_component::free_context(Signal_context_capability cap) {
|
|
PDBG("Not implemented"); }
|
|
|