NOVA: extend cap session for base-nova

This commit is contained in:
Alexander Boettcher 2012-08-08 13:20:20 +02:00 committed by Norman Feske
parent 7aa75477e2
commit cb859a4785
3 changed files with 105 additions and 3 deletions

View File

@ -0,0 +1,62 @@
/*
* \brief CAP-session interface
* \author Norman Feske
* \date 2006-06-23
*
* A 'Cap_session' is an allocator of user-level capabilities.
* User-level capabilities are used to reference server objects
* across address spaces.
*/
/*
* 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 _INCLUDE__CAP_SESSION__CAP_SESSION_H_
#define _INCLUDE__CAP_SESSION__CAP_SESSION_H_
#include <base/native_types.h>
#include <session/session.h>
namespace Genode {
struct Cap_session : Session
{
static const char *service_name() { return "CAP"; }
virtual ~Cap_session() { }
/**
* Allocate new unique userland capability
*
* \param ep entry point that will use this capability
*
* \return new userland capability
*/
virtual Native_capability alloc(Native_capability ep,
addr_t entry = 0,
addr_t flags = 0) = 0;
/**
* Free userland capability
*
* \param cap userland capability to free
*/
virtual void free(Native_capability cap) = 0;
/*********************
** RPC declaration **
*********************/
GENODE_RPC(Rpc_alloc, Native_capability, alloc,
Native_capability, addr_t, addr_t);
GENODE_RPC(Rpc_free, void, free, Native_capability);
GENODE_RPC_INTERFACE(Rpc_alloc, Rpc_free);
};
}
#endif /* _INCLUDE__CAP_SESSION__CAP_SESSION_H_ */

View File

@ -0,0 +1,38 @@
/*
* \brief Client-side CAP session interface
* \author Norman Feske
* \date 2006-07-10
*/
/*
* 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 _INCLUDE__CAP_SESSION__CLIENT_H_
#define _INCLUDE__CAP_SESSION__CLIENT_H_
#include <cap_session/capability.h>
#include <cap_session/cap_session.h>
#include <base/rpc_client.h>
namespace Genode {
struct Cap_session_client : Rpc_client<Cap_session>
{
explicit Cap_session_client(Cap_session_capability session)
: Rpc_client<Cap_session>(session) { }
Native_capability alloc(Native_capability ep, addr_t entry = 0,
addr_t flags = 0)
{
return call<Rpc_alloc>(ep, entry, flags);
}
void free(Native_capability cap) { call<Rpc_free>(cap); }
};
}
#endif /* _INCLUDE__CAP_SESSION__CLIENT_H_ */

View File

@ -1,7 +1,7 @@
/*
* \brief Capability allocation service
* \author Norman Feske
* \date 2006-06-26
* \author Alexander Boettcher
* \date 2012-07-27
*/
/*
@ -34,7 +34,9 @@ namespace Genode {
public:
Native_capability alloc(Native_capability ep)
Native_capability alloc(Native_capability ep,
addr_t entry,
addr_t mtd)
{
Lock::Guard lock_guard(_lock());