genode/base-nova/src/core/include/cap_session_component.h
Alexander Boettcher 4155585267 NOVA: Adjust native_capability type
It now can hold a right bit used during IPC to demote rights of the to be
transfered capability.

The local_name field in the native_capability type is not needed anymore
in NOVA. Simplify the class, remove it from constructors and adapt all
invocations in base-nova.

Unfortunately local_name in struct Raw is still used in generic base code
(process.cc, reload_parent_cap.cc), however has no effect in base-nova.
2012-08-09 11:09:41 +02:00

71 lines
1.6 KiB
C++

/*
* \brief Capability allocation service
* \author Alexander Boettcher
* \date 2012-07-27
*/
/*
* Copyright (C) 2006-2012 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.
*/
#ifndef _CORE__INCLUDE__CAP_SESSION_COMPONENT_H_
#define _CORE__INCLUDE__CAP_SESSION_COMPONENT_H_
#include <cap_session/cap_session.h>
#include <base/rpc_server.h>
#include <base/lock.h>
namespace Genode {
class Cap_session_component : public Rpc_object<Cap_session>
{
private:
static long _unique_id_cnt;
static Lock &_lock()
{
static Lock static_lock;
return static_lock;
}
public:
Native_capability alloc(Native_capability ep,
addr_t entry,
addr_t mtd)
{
addr_t pt_sel = cap_selector_allocator()->alloc(0);
addr_t pd_sel = Platform_pd::pd_core_sel();
addr_t ec_sel = ep.local_name();
using namespace Nova;
/* create portal */
uint8_t res = create_pt(pt_sel, pd_sel, ec_sel,
Mtd(mtd), entry);
if (res == NOVA_OK)
return Native_capability(pt_sel);
PERR("cap_session - cap=%lx:%lx"
" addr=%lx flags=%lx xpt=%lx res=%u",
ec_sel, ep.local_name(),
entry, mtd, pt_sel, res);
/* cleanup unused selectors */
cap_selector_allocator()->free(pt_sel, 0);
/* XXX revoke ec_sel if it was mapped !!!! */
return Native_capability::invalid_cap();
}
void free(Native_capability cap) { }
};
}
#endif /* _CORE__INCLUDE__CAP_SESSION_COMPONENT_H_ */