mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-17 06:38:28 +00:00
Cleanup of parent-cap handling
This patch alleviates the need for a Native_capability::Dst at the API level. The former use case of this type as argument to Deprecated_env::reinit uses the opaque Native_capability::Raw type instead. The 'Raw' type contains the portion of the capability that is transferred as-is when delegating the capability (i.e., when installing the parent capability into a new component, or when installing a new parent capability into a new forked Noux process). This information can be retrieved via the new Native_capability::raw method. Furthermore, this patch moves the functions for retriving the parent capability to base/internal/parent_cap.h, which is meant to be implemented in platform-specific ways. It replaces the former set of startup/internal/_main_parent_cap.h headers. Issue #1993
This commit is contained in:
50
repos/base-foc/src/include/base/internal/parent_cap.h
Normal file
50
repos/base-foc/src/include/base/internal/parent_cap.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* \brief Interface to obtain the parent capability for the component
|
||||
* \author Norman Feske
|
||||
* \date 2013-09-25
|
||||
*
|
||||
* On Fiasco.OC, we transfer merely the 'local_name' part of the capability
|
||||
* via the '_parent_cap' field of the ELF binary.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006-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.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__BASE__INTERNAL__PARENT_CAP_H_
|
||||
#define _INCLUDE__BASE__INTERNAL__PARENT_CAP_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <parent/capability.h>
|
||||
#include <util/string.h>
|
||||
#include <foc/native_capability.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/crt0.h>
|
||||
|
||||
|
||||
namespace Genode {
|
||||
|
||||
static inline Parent_capability parent_cap()
|
||||
{
|
||||
unsigned long const local_name = _parent_cap;
|
||||
|
||||
static Cap_index *i = cap_map()->insert(local_name,
|
||||
Fiasco::PARENT_CAP);
|
||||
/*
|
||||
* Update local name after a parent capability got reloaded via
|
||||
* 'Platform_env::reload_parent_cap()'.
|
||||
*/
|
||||
if (i->id() != local_name) {
|
||||
cap_map()->remove(i);
|
||||
i = cap_map()->insert(local_name, Fiasco::PARENT_CAP);
|
||||
}
|
||||
|
||||
return reinterpret_cap_cast<Parent>(Native_capability(i));
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__BASE__INTERNAL__PARENT_CAP_H_ */
|
Reference in New Issue
Block a user