Skip to content

Commit

Permalink
base-foc: rm Cap_selectors and Utcb_regs from API
Browse files Browse the repository at this point in the history
This patch moves those definitions from the Genode API header
(native_types.h) to foc/cap_selectors.h and base/internal/utcb_regs.h.
The former needs to stay at a publicly accessible location because
it is needed by L4Linux. By placing it in a 'foc/' subdirectory, we
distinguish it from the Genode API.

Issue genodelabs#1832
  • Loading branch information
nfeske committed Jan 25, 2016
1 parent ae0fbeb commit cb5861e
Show file tree
Hide file tree
Showing 15 changed files with 137 additions and 50 deletions.
7 changes: 7 additions & 0 deletions repos/base-foc/include/base/cap_alloc.h
Expand Up @@ -14,11 +14,18 @@
#ifndef _INCLUDE__BASE__CAP_ALLOC_H_
#define _INCLUDE__BASE__CAP_ALLOC_H_

/* Genode includes */
#include <base/cap_map.h>
#include <base/native_types.h>
#include <util/assert.h>
#include <util/construct_at.h>

/* Fiasco.OC-specific Genode includes */
#include <foc/cap_selectors.h>

/* base-internal includes */
#include <base/internal/utcb_regs.h>

namespace Genode {

/**
Expand Down
49 changes: 0 additions & 49 deletions repos/base-foc/include/base/native_types.h
Expand Up @@ -23,60 +23,11 @@ namespace Fiasco {
#include <l4/sys/utcb.h>
#include <l4/sys/task.h>

enum Cap_selectors {

/**********************************************
** Capability seclectors controlled by core **
**********************************************/

TASK_CAP = L4_BASE_TASK_CAP, /* use the same task cap selector
like L4Re for compatibility in
L4Linux */

/*
* To not clash with other L4Re cap selector constants (e.g.: L4Linux)
* leave the following selectors (2-7) empty
*/

PARENT_CAP = 0x8UL << L4_CAP_SHIFT, /* cap to parent session */

/*
* Each thread has a designated slot in the core controlled cap
* selector area, where its ipc gate capability (for server threads),
* its irq capability (for locks), and the capability to its pager
* gate are stored
*/
THREAD_AREA_BASE = 0x9UL << L4_CAP_SHIFT, /* offset to thread area */
THREAD_AREA_SLOT = 0x3UL << L4_CAP_SHIFT, /* size of one thread slot */
THREAD_GATE_CAP = 0, /* offset to the ipc gate
cap selector in the slot */
THREAD_PAGER_CAP = 0x1UL << L4_CAP_SHIFT, /* offset to the pager
cap selector in the slot */
THREAD_IRQ_CAP = 0x2UL << L4_CAP_SHIFT, /* offset to the irq cap
selector in the slot */
MAIN_THREAD_CAP = THREAD_AREA_BASE + THREAD_GATE_CAP, /* shortcut to the
main thread's
gate cap */


/*********************************************************
** Capability seclectors controlled by the task itself **
*********************************************************/

USER_BASE_CAP = 0x200UL << L4_CAP_SHIFT,
};

enum Utcb_regs {
UTCB_TCR_BADGE = 1,
UTCB_TCR_THREAD_OBJ = 2
};

struct Capability
{
static bool valid(l4_cap_idx_t idx) {
return !(idx & L4_INVALID_CAP_BIT) && idx != 0; }
};

}

namespace Genode {
Expand Down
64 changes: 64 additions & 0 deletions repos/base-foc/include/foc/cap_selectors.h
@@ -0,0 +1,64 @@
/*
* \brief Static capability selector definitions
* \author Norman Feske
* \date 2009-10-02
*/

/*
* Copyright (C) 2009-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__FOC__CAP_SELECTORS_H_
#define _INCLUDE__FOC__CAP_SELECTORS_H_

namespace Fiasco {
#include <l4/sys/consts.h>

enum Cap_selectors {

/**********************************************
** Capability seclectors controlled by core **
**********************************************/

TASK_CAP = L4_BASE_TASK_CAP, /* use the same task cap selector
like L4Re for compatibility in
L4Linux */

/*
* To not clash with other L4Re cap selector constants (e.g.: L4Linux)
* leave the following selectors (2-7) empty
*/

PARENT_CAP = 0x8UL << L4_CAP_SHIFT, /* cap to parent session */

/*
* Each thread has a designated slot in the core controlled cap
* selector area, where its ipc gate capability (for server threads),
* its irq capability (for locks), and the capability to its pager
* gate are stored
*/
THREAD_AREA_BASE = 0x9UL << L4_CAP_SHIFT, /* offset to thread area */
THREAD_AREA_SLOT = 0x3UL << L4_CAP_SHIFT, /* size of one thread slot */
THREAD_GATE_CAP = 0, /* offset to the ipc gate
cap selector in the slot */
THREAD_PAGER_CAP = 0x1UL << L4_CAP_SHIFT, /* offset to the pager
cap selector in the slot */
THREAD_IRQ_CAP = 0x2UL << L4_CAP_SHIFT, /* offset to the irq cap
selector in the slot */
MAIN_THREAD_CAP = THREAD_AREA_BASE + THREAD_GATE_CAP, /* shortcut to the
main thread's
gate cap */


/*********************************************************
** Capability seclectors controlled by the task itself **
*********************************************************/

USER_BASE_CAP = 0x200UL << L4_CAP_SHIFT,
};
}

#endif /* _INCLUDE__FOC__CAP_SELECTORS_H_ */
4 changes: 4 additions & 0 deletions repos/base-foc/src/base/ipc/ipc.cc
Expand Up @@ -27,8 +27,12 @@
#include <base/thread.h>
#include <util/assert.h>

/* Fiasco.OC-specific Genode includes */
#include <foc/cap_selectors.h>

/* base-internal includes */
#include <base/internal/lock_helper.h> /* for 'thread_get_my_native_id()' */
#include <base/internal/utcb_regs.h>

/* Fiasco.OC includes */
namespace Fiasco {
Expand Down
4 changes: 4 additions & 0 deletions repos/base-foc/src/base/thread/myself.cc
Expand Up @@ -11,8 +11,12 @@
* under the terms of the GNU General Public License version 2.
*/

/* Genode includes */
#include <base/thread.h>

/* base-internal includes */
#include <base/internal/utcb_regs.h>


Genode::Thread_base *Genode::Thread_base::myself()
{
Expand Down
6 changes: 6 additions & 0 deletions repos/base-foc/src/base/thread/thread_bootstrap.cc
Expand Up @@ -17,6 +17,12 @@
#include <base/thread.h>
#include <base/sleep.h>

/* Fiasco.OC-specific Genode includes */
#include <foc/cap_selectors.h>

/* base-internal includes */
#include <base/internal/utcb_regs.h>


/*****************************
** Startup library support **
Expand Down
5 changes: 5 additions & 0 deletions repos/base-foc/src/base/thread/thread_start.cc
Expand Up @@ -19,9 +19,14 @@
#include <base/sleep.h>
#include <base/env.h>

/* Fiasco.OC-specific Genode includes */
#include <foc/cap_selectors.h>

/* base-internal includes */
#include <base/internal/stack.h>
#include <base/internal/utcb_regs.h>

/* Fiasco.OC includes */
namespace Fiasco {
#include <l4/sys/utcb.h>
}
Expand Down
5 changes: 4 additions & 1 deletion repos/base-foc/src/core/ipc_pager.cc
Expand Up @@ -15,7 +15,10 @@
#include <base/printf.h>
#include <base/thread.h>

/* Core includes */
/* base-internal includes */
#include <base/internal/utcb_regs.h>

/* core includes */
#include <ipc_pager.h>

namespace Fiasco {
Expand Down
3 changes: 3 additions & 0 deletions repos/base-foc/src/core/platform_pd.cc
Expand Up @@ -16,6 +16,9 @@
#include <base/native_types.h>
#include <util/misc_math.h>

/* Fiasco.OC-specific Genode includes */
#include <foc/cap_selectors.h>

/* core includes */
#include <util.h>
#include <platform.h>
Expand Down
1 change: 1 addition & 0 deletions repos/base-foc/src/core/thread_start.cc
Expand Up @@ -18,6 +18,7 @@

/* base-internal includes */
#include <base/internal/stack.h>
#include <base/internal/utcb_regs.h>

/* core includes */
#include <platform.h>
Expand Down
3 changes: 3 additions & 0 deletions repos/base-foc/src/include/base/internal/lock_helper.h
Expand Up @@ -22,6 +22,9 @@
#include <base/native_types.h>
#include <base/thread.h>

/* Fiasco.OC-specific Genode includes */
#include <foc/cap_selectors.h>

/* Fiasco.OC includes */
namespace Fiasco {
#include <l4/sys/kdebug.h>
Expand Down
25 changes: 25 additions & 0 deletions repos/base-foc/src/include/base/internal/utcb_regs.h
@@ -0,0 +1,25 @@
/*
* \brief Offsets within the Fiasco.OC UTCB relied on by Genode
* \author Norman Feske
* \date 2009-10-02
*/

/*
* Copyright (C) 2009-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__UTCB_REGS_H_
#define _INCLUDE__BASE__INTERNAL__UTCB_REGS_H_

namespace Fiasco {

enum Utcb_regs {
UTCB_TCR_BADGE = 1,
UTCB_TCR_THREAD_OBJ = 2
};
}

#endif /* _INCLUDE__BASE__INTERNAL__UTCB_REGS_H_ */
Expand Up @@ -17,6 +17,9 @@
/* Genode includes */
#include <base/native_types.h>

/* Fiasco.OC-specific Genode includes */
#include <foc/cap_selectors.h>

/* base-internal includes */
#include <base/internal/crt0.h>

Expand Down
4 changes: 4 additions & 0 deletions repos/ports-foc/src/lib/l4lx/l4lx_thread.cc
Expand Up @@ -19,6 +19,10 @@
#include <vcpu.h>
#include <l4lx_thread.h>

/* Fiasco.OC-specific Genode includes */
#include <foc/cap_selectors.h>

/* Fiasco.OC includes */
namespace Fiasco {
#include <l4/sys/debugger.h>
}
Expand Down
4 changes: 4 additions & 0 deletions repos/ports-foc/src/lib/l4lx/startup.cc
Expand Up @@ -21,9 +21,13 @@
#include <util/misc_math.h>
#include <os/config.h>

/* Fiasco.OC-specific Genode includes */
#include <foc/cap_selectors.h>

/* L4lx includes */
#include <env.h>

/* Fisco.OC includes */
namespace Fiasco {
#include <l4/re/env.h>
#include <l4/sys/consts.h>
Expand Down

0 comments on commit cb5861e

Please sign in to comment.