mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-17 10:19:48 +00:00
base: retire 'Native_config'
This commit moves the parameters of the stack area to the base-internal header 'stack_area.h'. Issue #1832
This commit is contained in:
parent
2490e399dc
commit
76db3b9c06
@ -14,6 +14,7 @@
|
|||||||
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||||
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||||
|
|
||||||
|
/* Genode includes */
|
||||||
#include <base/native_capability.h>
|
#include <base/native_capability.h>
|
||||||
#include <base/stdint.h>
|
#include <base/stdint.h>
|
||||||
|
|
||||||
@ -73,22 +74,6 @@ namespace Genode {
|
|||||||
typedef Native_capability_tpl<Cap_dst_policy> Native_capability;
|
typedef Native_capability_tpl<Cap_dst_policy> Native_capability;
|
||||||
typedef Fiasco::l4_threadid_t Native_connection_state;
|
typedef Fiasco::l4_threadid_t Native_connection_state;
|
||||||
|
|
||||||
struct Native_config
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Stack area configuration
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_area_virtual_base() {
|
|
||||||
return 0x40000000UL; }
|
|
||||||
static constexpr addr_t stack_area_virtual_size() {
|
|
||||||
return 0x10000000UL; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Size of virtual address region holding the stack of one thread
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Native_pd_args { };
|
struct Native_pd_args { };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/crt0.h>
|
#include <base/internal/crt0.h>
|
||||||
#include <base/internal/fiasco_thread_helper.h>
|
#include <base/internal/fiasco_thread_helper.h>
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
/* core includes */
|
/* core includes */
|
||||||
#include <core_parent.h>
|
#include <core_parent.h>
|
||||||
@ -306,8 +307,8 @@ void Platform::_setup_mem_alloc()
|
|||||||
}
|
}
|
||||||
|
|
||||||
region.start = addr; region.end = addr + size;
|
region.start = addr; region.end = addr + size;
|
||||||
if (!region.intersects(Native_config::stack_area_virtual_base(),
|
if (!region.intersects(stack_area_virtual_base(),
|
||||||
Native_config::stack_area_virtual_size())) {
|
stack_area_virtual_size())) {
|
||||||
add_region(region, _ram_alloc);
|
add_region(region, _ram_alloc);
|
||||||
add_region(region, _core_address_ranges());
|
add_region(region, _core_address_ranges());
|
||||||
}
|
}
|
||||||
@ -412,8 +413,8 @@ void Platform::_setup_basics()
|
|||||||
_region_alloc.add_range(_vm_start, _vm_size);
|
_region_alloc.add_range(_vm_start, _vm_size);
|
||||||
|
|
||||||
/* preserve stack area in core's virtual address space */
|
/* preserve stack area in core's virtual address space */
|
||||||
_region_alloc.remove_range(Native_config::stack_area_virtual_base(),
|
_region_alloc.remove_range(stack_area_virtual_base(),
|
||||||
Native_config::stack_area_virtual_size());
|
stack_area_virtual_size());
|
||||||
|
|
||||||
/* I/O memory could be the whole user address space */
|
/* I/O memory could be the whole user address space */
|
||||||
/* FIXME if the kernel helps to find out max address - use info here */
|
/* FIXME if the kernel helps to find out max address - use info here */
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||||
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||||
|
|
||||||
#include <base/native_config.h>
|
|
||||||
#include <base/cap_map.h>
|
#include <base/cap_map.h>
|
||||||
|
|
||||||
namespace Fiasco {
|
namespace Fiasco {
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* \brief Platform-specific stack area definitions
|
|
||||||
* \author Stefan Kalkowski
|
|
||||||
* \date 2014-01-24
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2014 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__SPEC__ARM__BASE__NATIVE_CONFIG_H_
|
|
||||||
#define _INCLUDE__SPEC__ARM__BASE__NATIVE_CONFIG_H_
|
|
||||||
|
|
||||||
#include <base/stdint.h>
|
|
||||||
|
|
||||||
namespace Genode {
|
|
||||||
|
|
||||||
struct Native_config
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Stack area configuration
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_area_virtual_base() {
|
|
||||||
return 0x20000000UL; }
|
|
||||||
static constexpr addr_t stack_area_virtual_size() {
|
|
||||||
return 0x10000000UL; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Size of virtual address region holding the stack of one thread
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _INCLUDE__SPEC__ARM__BASE__NATIVE_CONFIG_H_ */
|
|
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* \brief Platform-specific stack area definitions
|
|
||||||
* \author Stefan Kalkowski
|
|
||||||
* \date 2014-01-24
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2014 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__SPEC__X86__BASE__NATIVE_CONFIG_H_
|
|
||||||
#define _INCLUDE__SPEC__X86__BASE__NATIVE_CONFIG_H_
|
|
||||||
|
|
||||||
#include <base/stdint.h>
|
|
||||||
|
|
||||||
namespace Genode {
|
|
||||||
|
|
||||||
struct Native_config
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Stack area configuration
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_area_virtual_base() {
|
|
||||||
return 0x40000000UL; }
|
|
||||||
static constexpr addr_t stack_area_virtual_size() {
|
|
||||||
return 0x10000000UL; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Size of virtual address region holding the stack of one thread
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _INCLUDE__SPEC__X86__BASE__NATIVE_CONFIG_H_ */
|
|
4
repos/base-foc/lib/mk/spec/arm/base-common.mk
Normal file
4
repos/base-foc/lib/mk/spec/arm/base-common.mk
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# override default stack-area location
|
||||||
|
INC_DIR += $(REP_DIR)/src/include/spec/arm
|
||||||
|
|
||||||
|
include $(REP_DIR)/lib/mk/base-common.inc
|
4
repos/base-foc/lib/mk/spec/arm/base.mk
Normal file
4
repos/base-foc/lib/mk/spec/arm/base.mk
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# override default stack-area location
|
||||||
|
INC_DIR += $(REP_DIR)/src/include/spec/arm
|
||||||
|
|
||||||
|
include $(REP_DIR)/lib/mk/base.inc
|
1
repos/base-foc/lib/mk/spec/x86/base-common.mk
Normal file
1
repos/base-foc/lib/mk/spec/x86/base-common.mk
Normal file
@ -0,0 +1 @@
|
|||||||
|
include $(REP_DIR)/lib/mk/base-common.inc
|
1
repos/base-foc/lib/mk/spec/x86/base.mk
Normal file
1
repos/base-foc/lib/mk/spec/x86/base.mk
Normal file
@ -0,0 +1 @@
|
|||||||
|
include $(REP_DIR)/lib/mk/base.inc
|
@ -29,6 +29,9 @@
|
|||||||
#include <cap_mapping.h>
|
#include <cap_mapping.h>
|
||||||
#include <address_space.h>
|
#include <address_space.h>
|
||||||
|
|
||||||
|
/* base-internal includes */
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
/* Fiasco.OC includes */
|
/* Fiasco.OC includes */
|
||||||
namespace Fiasco {
|
namespace Fiasco {
|
||||||
#include <l4/sys/consts.h>
|
#include <l4/sys/consts.h>
|
||||||
@ -48,8 +51,8 @@ namespace Genode {
|
|||||||
|
|
||||||
addr_t utcb_area_start()
|
addr_t utcb_area_start()
|
||||||
{
|
{
|
||||||
return (Native_config::stack_area_virtual_base() +
|
return stack_area_virtual_base() +
|
||||||
THREAD_MAX * Native_config::stack_virtual_size());
|
THREAD_MAX*stack_virtual_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
Cap_mapping _task;
|
Cap_mapping _task;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/crt0.h>
|
#include <base/internal/crt0.h>
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
/* core includes */
|
/* core includes */
|
||||||
#include <core_parent.h>
|
#include <core_parent.h>
|
||||||
@ -327,8 +328,8 @@ void Platform::_setup_mem_alloc()
|
|||||||
}
|
}
|
||||||
|
|
||||||
region.start = addr; region.end = addr + size;
|
region.start = addr; region.end = addr + size;
|
||||||
if (!region.intersects(Native_config::stack_area_virtual_base(),
|
if (!region.intersects(stack_area_virtual_base(),
|
||||||
Native_config::stack_area_virtual_size())) {
|
stack_area_virtual_size())) {
|
||||||
add_region(region, _ram_alloc);
|
add_region(region, _ram_alloc);
|
||||||
add_region(region, _core_address_ranges());
|
add_region(region, _core_address_ranges());
|
||||||
}
|
}
|
||||||
@ -403,8 +404,8 @@ void Platform::_setup_basics()
|
|||||||
_region_alloc.add_range(_vm_start, _vm_size);
|
_region_alloc.add_range(_vm_start, _vm_size);
|
||||||
|
|
||||||
/* preserve stack area in core's virtual address space */
|
/* preserve stack area in core's virtual address space */
|
||||||
_region_alloc.remove_range(Native_config::stack_area_virtual_base(),
|
_region_alloc.remove_range(stack_area_virtual_base(),
|
||||||
Native_config::stack_area_virtual_size());
|
stack_area_virtual_size());
|
||||||
|
|
||||||
/* preserve utcb- area in core's virtual address space */
|
/* preserve utcb- area in core's virtual address space */
|
||||||
_region_alloc.remove_range((addr_t)l4_utcb(), L4_PAGESIZE * 16);
|
_region_alloc.remove_range((addr_t)l4_utcb(), L4_PAGESIZE * 16);
|
||||||
|
@ -2,6 +2,9 @@ REQUIRES += arm
|
|||||||
SRC_CC += spec/arm/platform_arm.cc \
|
SRC_CC += spec/arm/platform_arm.cc \
|
||||||
spec/arm/ipc_pager.cc
|
spec/arm/ipc_pager.cc
|
||||||
|
|
||||||
|
# override default stack-area location
|
||||||
|
INC_DIR += $(REP_DIR)/src/include/spec/arm
|
||||||
|
|
||||||
include $(REP_DIR)/src/core/target.inc
|
include $(REP_DIR)/src/core/target.inc
|
||||||
|
|
||||||
vpath platform_services.cc $(GEN_CORE_DIR)
|
vpath platform_services.cc $(GEN_CORE_DIR)
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* \brief Stack area layout parameters
|
||||||
|
* \author Norman Feske
|
||||||
|
* \date 2016-03-03
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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__STACK_AREA_H_
|
||||||
|
#define _INCLUDE__BASE__INTERNAL__STACK_AREA_H_
|
||||||
|
|
||||||
|
#include <base/stdint.h>
|
||||||
|
|
||||||
|
namespace Genode {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The base address of the context area differs between ARM and x86 because
|
||||||
|
* roottask on Fiasco.OC uses identity mappings. The virtual address range
|
||||||
|
* of the stack area must not overlap with physical memory. We pick an
|
||||||
|
* address range that lies outside of the RAM of the currently supported
|
||||||
|
* ARM platforms.
|
||||||
|
*/
|
||||||
|
static constexpr addr_t stack_area_virtual_base() { return 0x20000000UL; }
|
||||||
|
static constexpr addr_t stack_area_virtual_size() { return 0x10000000UL; }
|
||||||
|
static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _INCLUDE__BASE__INTERNAL__STACK_AREA_H_ */
|
@ -40,8 +40,6 @@ namespace Genode
|
|||||||
*/
|
*/
|
||||||
struct Native_region;
|
struct Native_region;
|
||||||
|
|
||||||
struct Native_config;
|
|
||||||
|
|
||||||
struct Native_pd_args { };
|
struct Native_pd_args { };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,23 +76,6 @@ struct Genode::Native_region
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Genode::Native_config
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Stack area configuration
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_area_virtual_base() {
|
|
||||||
return 0xe0000000UL; }
|
|
||||||
static constexpr addr_t stack_area_virtual_size() {
|
|
||||||
return 0x10000000UL; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Size of virtual address region holding the stack of one thread
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Genode::Native_utcb
|
class Genode::Native_utcb
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -48,7 +48,7 @@ void Thread_base::_init_platform_thread(size_t weight, Type type)
|
|||||||
}
|
}
|
||||||
/* if we got reinitialized we have to get rid of the old UTCB */
|
/* if we got reinitialized we have to get rid of the old UTCB */
|
||||||
size_t const utcb_size = sizeof(Native_utcb);
|
size_t const utcb_size = sizeof(Native_utcb);
|
||||||
addr_t const stack_area = Native_config::stack_area_virtual_base();
|
addr_t const stack_area = stack_area_virtual_base();
|
||||||
addr_t const utcb_new = (addr_t)&_stack->utcb() - stack_area;
|
addr_t const utcb_new = (addr_t)&_stack->utcb() - stack_area;
|
||||||
Rm_session * const rm = env_stack_area_rm_session();
|
Rm_session * const rm = env_stack_area_rm_session();
|
||||||
|
|
||||||
@ -76,8 +76,7 @@ void Thread_base::_deinit_platform_thread()
|
|||||||
/* detach userland stack */
|
/* detach userland stack */
|
||||||
size_t const size = sizeof(_stack->utcb());
|
size_t const size = sizeof(_stack->utcb());
|
||||||
addr_t utcb = Stack_allocator::addr_to_base(_stack) +
|
addr_t utcb = Stack_allocator::addr_to_base(_stack) +
|
||||||
Native_config::stack_virtual_size() - size -
|
stack_virtual_size() - size - stack_area_virtual_base();
|
||||||
Native_config::stack_area_virtual_base();
|
|
||||||
env_stack_area_rm_session()->detach(utcb);
|
env_stack_area_rm_session()->detach(utcb);
|
||||||
|
|
||||||
if (_pager_cap.valid()) {
|
if (_pager_cap.valid()) {
|
||||||
@ -100,8 +99,7 @@ void Thread_base::start()
|
|||||||
Ram_dataspace_capability ds = _cpu_session->utcb(_thread_cap);
|
Ram_dataspace_capability ds = _cpu_session->utcb(_thread_cap);
|
||||||
size_t const size = sizeof(_stack->utcb());
|
size_t const size = sizeof(_stack->utcb());
|
||||||
addr_t dst = Stack_allocator::addr_to_base(_stack) +
|
addr_t dst = Stack_allocator::addr_to_base(_stack) +
|
||||||
Native_config::stack_virtual_size() - size -
|
stack_virtual_size() - size - stack_area_virtual_base();
|
||||||
Native_config::stack_area_virtual_base();
|
|
||||||
env_stack_area_rm_session()->attach_at(ds, dst, size);
|
env_stack_area_rm_session()->attach_at(ds, dst, size);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
PERR("failed to attach userland stack");
|
PERR("failed to attach userland stack");
|
||||||
|
@ -29,6 +29,9 @@
|
|||||||
#include <translation_table.h>
|
#include <translation_table.h>
|
||||||
#include <trustzone.h>
|
#include <trustzone.h>
|
||||||
|
|
||||||
|
/* base-internal includes */
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
extern int _prog_img_beg;
|
extern int _prog_img_beg;
|
||||||
@ -137,9 +140,8 @@ Platform::Platform()
|
|||||||
_core_only_ram_regions, get_page_size_log2());
|
_core_only_ram_regions, get_page_size_log2());
|
||||||
|
|
||||||
/* preserve stack area in core's virtual address space */
|
/* preserve stack area in core's virtual address space */
|
||||||
_core_mem_alloc.virt_alloc()->remove_range(
|
_core_mem_alloc.virt_alloc()->remove_range(stack_area_virtual_base(),
|
||||||
Native_config::stack_area_virtual_base(),
|
stack_area_virtual_size());
|
||||||
Native_config::stack_area_virtual_size());
|
|
||||||
|
|
||||||
_init_io_port_alloc();
|
_init_io_port_alloc();
|
||||||
|
|
||||||
|
26
repos/base-hw/src/include/base/internal/stack_area.h
Normal file
26
repos/base-hw/src/include/base/internal/stack_area.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* \brief Stack area layout parameters
|
||||||
|
* \author Norman Feske
|
||||||
|
* \date 2016-03-03
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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__STACK_AREA_H_
|
||||||
|
#define _INCLUDE__BASE__INTERNAL__STACK_AREA_H_
|
||||||
|
|
||||||
|
#include <base/stdint.h>
|
||||||
|
|
||||||
|
namespace Genode {
|
||||||
|
|
||||||
|
static constexpr addr_t stack_area_virtual_base() { return 0xe0000000UL; }
|
||||||
|
static constexpr addr_t stack_area_virtual_size() { return 0x10000000UL; }
|
||||||
|
static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _INCLUDE__BASE__INTERNAL__STACK_AREA_H_ */
|
@ -18,16 +18,6 @@
|
|||||||
#include <base/native_capability.h>
|
#include <base/native_capability.h>
|
||||||
#include <base/stdint.h>
|
#include <base/stdint.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* We cannot just include <semaphore.h> and <pthread.h> here
|
|
||||||
* because this would imply the nested inclusion of a myriad
|
|
||||||
* of Linux types and would pollute the namespace for everyone
|
|
||||||
* who includes this header file. We want to cleanly separate
|
|
||||||
* Genode from POSIX.
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern Genode::addr_t _stack_area_start;
|
|
||||||
|
|
||||||
namespace Genode {
|
namespace Genode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,26 +115,6 @@ namespace Genode {
|
|||||||
|
|
||||||
enum { PARENT_SOCKET_HANDLE = 100 };
|
enum { PARENT_SOCKET_HANDLE = 100 };
|
||||||
|
|
||||||
struct Native_config
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Stack area configuration
|
|
||||||
*
|
|
||||||
* Please update platform-specific files after changing these
|
|
||||||
* functions, e.g., 'base-linux/src/ld/stack_area.*.ld'.
|
|
||||||
*/
|
|
||||||
static addr_t stack_area_virtual_base() {
|
|
||||||
return align_addr((addr_t)&_stack_area_start, 20); }
|
|
||||||
|
|
||||||
static constexpr addr_t stack_area_virtual_size() {
|
|
||||||
return 0x10000000UL; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Size of virtual address region holding the stack of one thread
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class Native_pd_args
|
class Native_pd_args
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -60,8 +60,8 @@ addr_t Platform_env_base::Rm_session_mmap::_reserve_local(bool use_loc
|
|||||||
{
|
{
|
||||||
/* special handling for stack area */
|
/* special handling for stack area */
|
||||||
if (use_local_addr
|
if (use_local_addr
|
||||||
&& local_addr == Native_config::stack_area_virtual_base()
|
&& local_addr == stack_area_virtual_base()
|
||||||
&& size == Native_config::stack_area_virtual_size()) {
|
&& size == stack_area_virtual_size()) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* On the first request to reserve the stack area, we flush the
|
* On the first request to reserve the stack area, we flush the
|
||||||
|
@ -50,8 +50,7 @@ class Stack_area_rm_session : public Genode::Rm_session
|
|||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
/* convert stack-area-relative to absolute virtual address */
|
/* convert stack-area-relative to absolute virtual address */
|
||||||
addr_t addr = local_addr;
|
addr_t addr = (addr_t)local_addr + stack_area_virtual_base();
|
||||||
addr += Native_config::stack_area_virtual_base();
|
|
||||||
|
|
||||||
/* use anonymous mmap for allocating stack backing store */
|
/* use anonymous mmap for allocating stack backing store */
|
||||||
int flags = MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE;
|
int flags = MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* \brief Linux-specific utilities for stack area
|
* \brief Linux-specific definitions and utilities for the stack area
|
||||||
* \author Christian Helmuth
|
* \author Christian Helmuth
|
||||||
* \date 2013-09-26
|
* \date 2013-09-26
|
||||||
*/
|
*/
|
||||||
@ -24,12 +24,31 @@
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern Genode::addr_t _stack_area_start;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Genode {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stack area base address
|
||||||
|
*
|
||||||
|
* Please update platform-specific files after changing these
|
||||||
|
* functions, e.g., 'base-linux/src/ld/stack_area.*.ld'.
|
||||||
|
*/
|
||||||
|
static addr_t stack_area_virtual_base() {
|
||||||
|
return align_addr((addr_t)&_stack_area_start, 20); }
|
||||||
|
|
||||||
|
static constexpr addr_t stack_area_virtual_size() { return 0x10000000UL; }
|
||||||
|
static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void flush_stack_area()
|
static inline void flush_stack_area()
|
||||||
{
|
{
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
void * const base = (void *) Native_config::stack_area_virtual_base();
|
void * const base = (void *)stack_area_virtual_base();
|
||||||
size_t const size = Native_config::stack_area_virtual_size();
|
size_t const size = stack_area_virtual_size();
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
if ((ret = lx_munmap(base, size)) < 0) {
|
if ((ret = lx_munmap(base, size)) < 0) {
|
||||||
@ -45,8 +64,8 @@ static inline Genode::addr_t reserve_stack_area()
|
|||||||
|
|
||||||
int const flags = MAP_ANONYMOUS | MAP_PRIVATE;
|
int const flags = MAP_ANONYMOUS | MAP_PRIVATE;
|
||||||
int const prot = PROT_NONE;
|
int const prot = PROT_NONE;
|
||||||
size_t const size = Native_config::stack_area_virtual_size();
|
size_t const size = stack_area_virtual_size();
|
||||||
void * const addr_in = (void *)Native_config::stack_area_virtual_base();
|
void * const addr_in = (void *)stack_area_virtual_base();
|
||||||
void * const addr_out = lx_mmap(addr_in, size, prot, flags, -1, 0);
|
void * const addr_out = lx_mmap(addr_in, size, prot, flags, -1, 0);
|
||||||
|
|
||||||
/* reserve at local address failed - unmap incorrect mapping */
|
/* reserve at local address failed - unmap incorrect mapping */
|
||||||
|
@ -238,22 +238,6 @@ namespace Genode {
|
|||||||
|
|
||||||
typedef int Native_connection_state;
|
typedef int Native_connection_state;
|
||||||
|
|
||||||
struct Native_config
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Stack area configuration
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_area_virtual_base() {
|
|
||||||
return 0xa0000000UL; }
|
|
||||||
static constexpr addr_t stack_area_virtual_size() {
|
|
||||||
return 0x10000000UL; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Size of virtual address region holding the stack of one thread
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Native_pd_args { };
|
struct Native_pd_args { };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/stack.h>
|
#include <base/internal/stack.h>
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
/* base-nova includes */
|
/* base-nova includes */
|
||||||
#include <base/cap_map.h>
|
#include <base/cap_map.h>
|
||||||
@ -40,8 +41,7 @@ Native_utcb * main_thread_utcb()
|
|||||||
{
|
{
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
return reinterpret_cast<Native_utcb *>(
|
return reinterpret_cast<Native_utcb *>(
|
||||||
Native_config::stack_area_virtual_base() +
|
stack_area_virtual_base() + stack_virtual_size() - Nova::PAGE_SIZE_BYTE);
|
||||||
Native_config::stack_virtual_size() - Nova::PAGE_SIZE_BYTE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include <ipc_pager.h>
|
#include <ipc_pager.h>
|
||||||
|
|
||||||
|
/* base-internal includes */
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
/* NOVA includes */
|
/* NOVA includes */
|
||||||
#include <nova/syscalls.h>
|
#include <nova/syscalls.h>
|
||||||
|
|
||||||
@ -126,13 +129,13 @@ static void page_fault_handler()
|
|||||||
pf_type & Ipc_pager::ERR_W ? "W" : "w",
|
pf_type & Ipc_pager::ERR_W ? "W" : "w",
|
||||||
pf_type & Ipc_pager::ERR_P ? "P" : "p");
|
pf_type & Ipc_pager::ERR_P ? "P" : "p");
|
||||||
|
|
||||||
if ((Native_config::stack_area_virtual_base() <= pf_sp) &&
|
if ((stack_area_virtual_base() <= pf_sp) &&
|
||||||
(pf_sp < Native_config::stack_area_virtual_base() +
|
(pf_sp < stack_area_virtual_base() +
|
||||||
Native_config::stack_area_virtual_size()))
|
stack_area_virtual_size()))
|
||||||
{
|
{
|
||||||
addr_t utcb_addr_f = pf_sp / Native_config::stack_virtual_size();
|
addr_t utcb_addr_f = pf_sp / stack_virtual_size();
|
||||||
utcb_addr_f *= Native_config::stack_virtual_size();
|
utcb_addr_f *= stack_virtual_size();
|
||||||
utcb_addr_f += Native_config::stack_virtual_size();
|
utcb_addr_f += stack_virtual_size();
|
||||||
utcb_addr_f -= 4096;
|
utcb_addr_f -= 4096;
|
||||||
|
|
||||||
Nova::Utcb * utcb_fault = reinterpret_cast<Nova::Utcb *>(utcb_addr_f);
|
Nova::Utcb * utcb_fault = reinterpret_cast<Nova::Utcb *>(utcb_addr_f);
|
||||||
@ -398,8 +401,8 @@ Platform::Platform() :
|
|||||||
region_alloc()->remove_range(BDA_VIRT_ADDR, 0x1000);
|
region_alloc()->remove_range(BDA_VIRT_ADDR, 0x1000);
|
||||||
|
|
||||||
/* preserve stack area in core's virtual address space */
|
/* preserve stack area in core's virtual address space */
|
||||||
region_alloc()->remove_range(Native_config::stack_area_virtual_base(),
|
region_alloc()->remove_range(stack_area_virtual_base(),
|
||||||
Native_config::stack_area_virtual_size());
|
stack_area_virtual_size());
|
||||||
|
|
||||||
/* exclude utcb of core pager thread + empty guard pages before and after */
|
/* exclude utcb of core pager thread + empty guard pages before and after */
|
||||||
region_alloc()->remove_range(CORE_PAGER_UTCB_ADDR - get_page_size(),
|
region_alloc()->remove_range(CORE_PAGER_UTCB_ADDR - get_page_size(),
|
||||||
@ -420,14 +423,12 @@ Platform::Platform() :
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (unsigned i = 0; i < sizeof(check) / sizeof(check[0]); i++) {
|
for (unsigned i = 0; i < sizeof(check) / sizeof(check[0]); i++) {
|
||||||
if (Native_config::stack_area_virtual_base() <= check[i] &&
|
if (stack_area_virtual_base() <= check[i] &&
|
||||||
check[i] < Native_config::stack_area_virtual_base() +
|
check[i] < stack_area_virtual_base() + stack_area_virtual_size())
|
||||||
Native_config::stack_area_virtual_size())
|
|
||||||
{
|
{
|
||||||
PERR("overlapping area - [%lx, %lx) vs %lx",
|
PERR("overlapping area - [%lx, %lx) vs %lx",
|
||||||
Native_config::stack_area_virtual_base(),
|
stack_area_virtual_base(), stack_area_virtual_base() +
|
||||||
Native_config::stack_area_virtual_base() +
|
stack_area_virtual_size(), check[i]);
|
||||||
Native_config::stack_area_virtual_size(), check[i]);
|
|
||||||
nova_die();
|
nova_die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include <nova_util.h>
|
#include <nova_util.h>
|
||||||
|
|
||||||
|
/* base-internal includes */
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
/* NOVA includes */
|
/* NOVA includes */
|
||||||
#include <nova/syscalls.h>
|
#include <nova/syscalls.h>
|
||||||
#include <nova/util.h>
|
#include <nova/util.h>
|
||||||
@ -119,8 +122,7 @@ int Platform_thread::start(void *ip, void *sp)
|
|||||||
_sel_exc_base = is_vcpu() ? _pager->exc_pt_vcpu() : _pager->exc_pt_sel_client();
|
_sel_exc_base = is_vcpu() ? _pager->exc_pt_vcpu() : _pager->exc_pt_sel_client();
|
||||||
|
|
||||||
if (!is_vcpu()) {
|
if (!is_vcpu()) {
|
||||||
pd_utcb = Native_config::stack_area_virtual_base() +
|
pd_utcb = stack_area_virtual_base() + stack_virtual_size() - get_page_size();
|
||||||
Native_config::stack_virtual_size() - get_page_size();
|
|
||||||
|
|
||||||
addr_t remap_src[] = { _pd->parent_pt_sel(), _pager->Object_pool<Pager_object>::Entry::cap().local_name() };
|
addr_t remap_src[] = { _pd->parent_pt_sel(), _pager->Object_pool<Pager_object>::Entry::cap().local_name() };
|
||||||
addr_t remap_dst[] = { PT_SEL_PARENT, PT_SEL_MAIN_PAGER };
|
addr_t remap_dst[] = { PT_SEL_PARENT, PT_SEL_MAIN_PAGER };
|
||||||
|
26
repos/base-nova/src/include/base/internal/stack_area.h
Normal file
26
repos/base-nova/src/include/base/internal/stack_area.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* \brief Stack area layout parameters
|
||||||
|
* \author Norman Feske
|
||||||
|
* \date 2016-03-03
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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__STACK_AREA_H_
|
||||||
|
#define _INCLUDE__BASE__INTERNAL__STACK_AREA_H_
|
||||||
|
|
||||||
|
#include <base/stdint.h>
|
||||||
|
|
||||||
|
namespace Genode {
|
||||||
|
|
||||||
|
static constexpr addr_t stack_area_virtual_base() { return 0xa0000000UL; }
|
||||||
|
static constexpr addr_t stack_area_virtual_size() { return 0x10000000UL; }
|
||||||
|
static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _INCLUDE__BASE__INTERNAL__STACK_AREA_H_ */
|
@ -90,22 +90,6 @@ namespace Genode {
|
|||||||
typedef Native_capability_tpl<Cap_dst_policy> Native_capability;
|
typedef Native_capability_tpl<Cap_dst_policy> Native_capability;
|
||||||
typedef Okl4::L4_ThreadId_t Native_connection_state;
|
typedef Okl4::L4_ThreadId_t Native_connection_state;
|
||||||
|
|
||||||
struct Native_config
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Stack area configuration
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_area_virtual_base() {
|
|
||||||
return 0x40000000UL; }
|
|
||||||
static constexpr addr_t stack_area_virtual_size() {
|
|
||||||
return 0x10000000UL; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Size of virtual address region holding the stack of one thread
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Native_pd_args { };
|
struct Native_pd_args { };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/crt0.h>
|
#include <base/internal/crt0.h>
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
/* core includes */
|
/* core includes */
|
||||||
#include <core_parent.h>
|
#include <core_parent.h>
|
||||||
@ -272,8 +273,8 @@ Platform::Platform() :
|
|||||||
_io_port_alloc.add_range(0, 0x10000);
|
_io_port_alloc.add_range(0, 0x10000);
|
||||||
|
|
||||||
/* preserve stack area in core's virtual address space */
|
/* preserve stack area in core's virtual address space */
|
||||||
_core_mem_alloc.virt_alloc()->remove_range(Native_config::stack_area_virtual_base(),
|
_core_mem_alloc.virt_alloc()->remove_range(stack_area_virtual_base(),
|
||||||
Native_config::stack_area_virtual_size());
|
stack_area_virtual_size());
|
||||||
|
|
||||||
_vm_start = 0x1000;
|
_vm_start = 0x1000;
|
||||||
_vm_size = 0xb0000000 - 0x1000;
|
_vm_size = 0xb0000000 - 0x1000;
|
||||||
|
@ -74,22 +74,6 @@ namespace Genode {
|
|||||||
|
|
||||||
typedef Pistachio::L4_ThreadId_t Native_connection_state;
|
typedef Pistachio::L4_ThreadId_t Native_connection_state;
|
||||||
|
|
||||||
struct Native_config
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Stack area configuration
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_area_virtual_base() {
|
|
||||||
return 0x40000000UL; }
|
|
||||||
static constexpr addr_t stack_area_virtual_size() {
|
|
||||||
return 0x10000000UL; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Size of virtual address region holding the stack of one thread
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Native_pd_args { };
|
struct Native_pd_args { };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/crt0.h>
|
#include <base/internal/crt0.h>
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
/* core includes */
|
/* core includes */
|
||||||
#include <core_parent.h>
|
#include <core_parent.h>
|
||||||
@ -434,8 +435,8 @@ void Platform::_setup_mem_alloc()
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
region.start = addr; region.end = addr + size;
|
region.start = addr; region.end = addr + size;
|
||||||
if (region.intersects(Native_config::stack_area_virtual_base(),
|
if (region.intersects(stack_area_virtual_base(),
|
||||||
Native_config::stack_area_virtual_size()) ||
|
stack_area_virtual_size()) ||
|
||||||
intersects_kip_archdep(kip, addr, size)) {
|
intersects_kip_archdep(kip, addr, size)) {
|
||||||
unmap_local(region.start, size >> get_page_size_log2());
|
unmap_local(region.start, size >> get_page_size_log2());
|
||||||
} else {
|
} else {
|
||||||
@ -566,8 +567,8 @@ void Platform::_setup_basics()
|
|||||||
/* configure core's virtual memory, exclude KIP, stack area */
|
/* configure core's virtual memory, exclude KIP, stack area */
|
||||||
_region_alloc.add_range(_vm_start, _vm_size);
|
_region_alloc.add_range(_vm_start, _vm_size);
|
||||||
_region_alloc.remove_range((addr_t)kip, kip_size);
|
_region_alloc.remove_range((addr_t)kip, kip_size);
|
||||||
_region_alloc.remove_range(Native_config::stack_area_virtual_base(),
|
_region_alloc.remove_range(stack_area_virtual_base(),
|
||||||
Native_config::stack_area_virtual_size());
|
stack_area_virtual_size());
|
||||||
|
|
||||||
/* remove KIP and MBI area from region and IO_MEM allocator */
|
/* remove KIP and MBI area from region and IO_MEM allocator */
|
||||||
remove_region(Region((addr_t)kip, (addr_t)kip + kip_size), _region_alloc);
|
remove_region(Region((addr_t)kip, (addr_t)kip + kip_size), _region_alloc);
|
||||||
|
@ -126,22 +126,6 @@ namespace Genode {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Native_config
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Stack-area configuration.
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_area_virtual_base() {
|
|
||||||
return 0x40000000UL; }
|
|
||||||
static constexpr addr_t stack_area_virtual_size() {
|
|
||||||
return 0x10000000UL; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Size of virtual address region holding the stack of one thread
|
|
||||||
*/
|
|
||||||
static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Native_pd_args { };
|
struct Native_pd_args { };
|
||||||
|
|
||||||
typedef int Native_connection_state;
|
typedef int Native_connection_state;
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
#include <cnode.h>
|
#include <cnode.h>
|
||||||
#include <untyped_memory.h>
|
#include <untyped_memory.h>
|
||||||
|
|
||||||
|
/* base-internal includes */
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
static bool const verbose_boot_info = true;
|
static bool const verbose_boot_info = true;
|
||||||
@ -156,8 +159,8 @@ void Platform::_init_allocators()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* preserve stack area in core's virtual address space */
|
/* preserve stack area in core's virtual address space */
|
||||||
_core_mem_alloc.virt_alloc()->remove_range(Native_config::stack_area_virtual_base(),
|
_core_mem_alloc.virt_alloc()->remove_range(stack_area_virtual_base(),
|
||||||
Native_config::stack_area_virtual_size());
|
stack_area_virtual_size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
#include <dataspace_component.h>
|
#include <dataspace_component.h>
|
||||||
#include <untyped_memory.h>
|
#include <untyped_memory.h>
|
||||||
|
|
||||||
|
/* base-internal includes */
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
|
|
||||||
@ -76,7 +79,7 @@ class Stack_area_rm_session : public Rm_session
|
|||||||
}
|
}
|
||||||
|
|
||||||
addr_t const core_local_addr =
|
addr_t const core_local_addr =
|
||||||
Native_config::stack_area_virtual_base() + (addr_t)local_addr;
|
stack_area_virtual_base() + (addr_t)local_addr;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
PDBG("core_local_addr = %lx, phys_addr = %lx, size = 0x%zx",
|
PDBG("core_local_addr = %lx, phys_addr = %lx, size = 0x%zx",
|
||||||
|
@ -280,6 +280,21 @@ class Genode::Thread_base
|
|||||||
*/
|
*/
|
||||||
void *stack_base() const;
|
void *stack_base() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return virtual size reserved for each stack within the stack area
|
||||||
|
*/
|
||||||
|
static size_t stack_virtual_size();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the local base address of the stack area
|
||||||
|
*/
|
||||||
|
static addr_t stack_area_virtual_base();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return total size of the stack area
|
||||||
|
*/
|
||||||
|
static size_t stack_area_virtual_size();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return 'Thread_base' object corresponding to the calling thread
|
* Return 'Thread_base' object corresponding to the calling thread
|
||||||
*
|
*
|
||||||
|
7
repos/base/src/base/env/stack_area.cc
vendored
7
repos/base/src/base/env/stack_area.cc
vendored
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/platform_env_common.h>
|
#include <base/internal/platform_env_common.h>
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
@ -39,10 +40,10 @@ struct Expanding_rm_connection : Connection<Rm_session>, Expanding_rm_session_cl
|
|||||||
struct Stack_area_rm_session : Expanding_rm_connection
|
struct Stack_area_rm_session : Expanding_rm_connection
|
||||||
{
|
{
|
||||||
Stack_area_rm_session()
|
Stack_area_rm_session()
|
||||||
: Expanding_rm_connection(0, Native_config::stack_area_virtual_size())
|
: Expanding_rm_connection(0, stack_area_virtual_size())
|
||||||
{
|
{
|
||||||
addr_t local_base = Native_config::stack_area_virtual_base();
|
addr_t const local_base = stack_area_virtual_base();
|
||||||
size_t size = Native_config::stack_area_virtual_size();
|
size_t const size = stack_area_virtual_size();
|
||||||
|
|
||||||
env()->rm_session()->attach_at(dataspace(), local_base, size);
|
env()->rm_session()->attach_at(dataspace(), local_base, size);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/stack_allocator.h>
|
#include <base/internal/stack_allocator.h>
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
|
|
||||||
Genode::Thread_base *Genode::Thread_base::myself()
|
Genode::Thread_base *Genode::Thread_base::myself()
|
||||||
@ -28,9 +29,8 @@ Genode::Thread_base *Genode::Thread_base::myself()
|
|||||||
* thread.
|
* thread.
|
||||||
*/
|
*/
|
||||||
addr_t sp = (addr_t)(&dummy);
|
addr_t sp = (addr_t)(&dummy);
|
||||||
if (sp < Native_config::stack_area_virtual_base() ||
|
if (sp < Genode::stack_area_virtual_base() ||
|
||||||
sp >= Native_config::stack_area_virtual_base() +
|
sp >= Genode::stack_area_virtual_base() + Genode::stack_area_virtual_size())
|
||||||
Native_config::stack_area_virtual_size())
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
addr_t base = Stack_allocator::addr_to_base(&dummy);
|
addr_t base = Stack_allocator::addr_to_base(&dummy);
|
||||||
|
@ -20,7 +20,7 @@ using namespace Genode;
|
|||||||
|
|
||||||
Stack *Stack_allocator::base_to_stack(addr_t base)
|
Stack *Stack_allocator::base_to_stack(addr_t base)
|
||||||
{
|
{
|
||||||
addr_t result = base + Native_config::stack_virtual_size()
|
addr_t result = base + stack_virtual_size()
|
||||||
- sizeof(Stack);
|
- sizeof(Stack);
|
||||||
return reinterpret_cast<Stack *>(result);
|
return reinterpret_cast<Stack *>(result);
|
||||||
}
|
}
|
||||||
@ -28,21 +28,19 @@ Stack *Stack_allocator::base_to_stack(addr_t base)
|
|||||||
|
|
||||||
addr_t Stack_allocator::addr_to_base(void *addr)
|
addr_t Stack_allocator::addr_to_base(void *addr)
|
||||||
{
|
{
|
||||||
return ((addr_t)addr) & ~(Native_config::stack_virtual_size() - 1);
|
return ((addr_t)addr) & ~(stack_virtual_size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t Stack_allocator::base_to_idx(addr_t base)
|
size_t Stack_allocator::base_to_idx(addr_t base)
|
||||||
{
|
{
|
||||||
return (base - Native_config::stack_area_virtual_base()) /
|
return (base - stack_area_virtual_base()) / stack_virtual_size();
|
||||||
Native_config::stack_virtual_size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
addr_t Stack_allocator::idx_to_base(size_t idx)
|
addr_t Stack_allocator::idx_to_base(size_t idx)
|
||||||
{
|
{
|
||||||
return Native_config::stack_area_virtual_base() +
|
return stack_area_virtual_base() + idx * stack_virtual_size();
|
||||||
idx * Native_config::stack_virtual_size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -51,7 +49,7 @@ Stack_allocator::alloc(Thread_base *thread_base, bool main_thread)
|
|||||||
{
|
{
|
||||||
if (main_thread)
|
if (main_thread)
|
||||||
/* the main-thread stack is the first one */
|
/* the main-thread stack is the first one */
|
||||||
return base_to_stack(Native_config::stack_area_virtual_base());
|
return base_to_stack(stack_area_virtual_base());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Lock::Guard _lock_guard(_threads_lock);
|
Lock::Guard _lock_guard(_threads_lock);
|
||||||
|
@ -56,8 +56,7 @@ void Stack::size(size_t const size)
|
|||||||
throw Thread_base::Stack_too_large();
|
throw Thread_base::Stack_too_large();
|
||||||
|
|
||||||
/* allocate and attach backing store for the stack enhancement */
|
/* allocate and attach backing store for the stack enhancement */
|
||||||
addr_t const ds_addr = _base - ds_size -
|
addr_t const ds_addr = _base - ds_size - stack_area_virtual_base();
|
||||||
Native_config::stack_area_virtual_base();
|
|
||||||
try {
|
try {
|
||||||
Ram_session * const ram = env_stack_area_ram_session();
|
Ram_session * const ram = env_stack_area_ram_session();
|
||||||
Ram_dataspace_capability const ds_cap = ram->alloc(ds_size);
|
Ram_dataspace_capability const ds_cap = ram->alloc(ds_size);
|
||||||
@ -96,7 +95,7 @@ Thread_base::_alloc_stack(size_t stack_size, char const *name, bool main_thread)
|
|||||||
enum { PAGE_SIZE_LOG2 = 12 };
|
enum { PAGE_SIZE_LOG2 = 12 };
|
||||||
size_t ds_size = align_addr(stack_size, PAGE_SIZE_LOG2);
|
size_t ds_size = align_addr(stack_size, PAGE_SIZE_LOG2);
|
||||||
|
|
||||||
if (stack_size >= Native_config::stack_virtual_size() -
|
if (stack_size >= stack_virtual_size() -
|
||||||
sizeof(Native_utcb) - (1UL << PAGE_SIZE_LOG2))
|
sizeof(Native_utcb) - (1UL << PAGE_SIZE_LOG2))
|
||||||
throw Stack_too_large();
|
throw Stack_too_large();
|
||||||
|
|
||||||
@ -106,8 +105,7 @@ Thread_base::_alloc_stack(size_t stack_size, char const *name, bool main_thread)
|
|||||||
* The stack pointer is always located at the top of the stack header.
|
* The stack pointer is always located at the top of the stack header.
|
||||||
*/
|
*/
|
||||||
addr_t ds_addr = Stack_allocator::addr_to_base(stack) +
|
addr_t ds_addr = Stack_allocator::addr_to_base(stack) +
|
||||||
Native_config::stack_virtual_size() -
|
stack_virtual_size() - ds_size;
|
||||||
ds_size;
|
|
||||||
|
|
||||||
/* add padding for UTCB if defined for the platform */
|
/* add padding for UTCB if defined for the platform */
|
||||||
if (sizeof(Native_utcb) >= (1 << PAGE_SIZE_LOG2))
|
if (sizeof(Native_utcb) >= (1 << PAGE_SIZE_LOG2))
|
||||||
@ -117,7 +115,7 @@ Thread_base::_alloc_stack(size_t stack_size, char const *name, bool main_thread)
|
|||||||
Ram_dataspace_capability ds_cap;
|
Ram_dataspace_capability ds_cap;
|
||||||
try {
|
try {
|
||||||
ds_cap = env_stack_area_ram_session()->alloc(ds_size);
|
ds_cap = env_stack_area_ram_session()->alloc(ds_size);
|
||||||
addr_t attach_addr = ds_addr - Native_config::stack_area_virtual_base();
|
addr_t attach_addr = ds_addr - stack_area_virtual_base();
|
||||||
if (attach_addr != (addr_t)env_stack_area_rm_session()->attach_at(ds_cap, attach_addr, ds_size))
|
if (attach_addr != (addr_t)env_stack_area_rm_session()->attach_at(ds_cap, attach_addr, ds_size))
|
||||||
throw Stack_alloc_failed();
|
throw Stack_alloc_failed();
|
||||||
}
|
}
|
||||||
@ -139,7 +137,7 @@ Thread_base::_alloc_stack(size_t stack_size, char const *name, bool main_thread)
|
|||||||
|
|
||||||
void Thread_base::_free_stack(Stack *stack)
|
void Thread_base::_free_stack(Stack *stack)
|
||||||
{
|
{
|
||||||
addr_t ds_addr = stack->base() - Native_config::stack_area_virtual_base();
|
addr_t ds_addr = stack->base() - stack_area_virtual_base();
|
||||||
Ram_dataspace_capability ds_cap = stack->ds_cap();
|
Ram_dataspace_capability ds_cap = stack->ds_cap();
|
||||||
|
|
||||||
/* call de-constructor explicitly before memory gets detached */
|
/* call de-constructor explicitly before memory gets detached */
|
||||||
@ -185,6 +183,24 @@ void *Thread_base::stack_base() const { return (void*)_stack->base(); }
|
|||||||
void Thread_base::stack_size(size_t const size) { _stack->size(size); }
|
void Thread_base::stack_size(size_t const size) { _stack->size(size); }
|
||||||
|
|
||||||
|
|
||||||
|
size_t Thread_base::stack_virtual_size()
|
||||||
|
{
|
||||||
|
return Genode::stack_virtual_size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
addr_t Thread_base::stack_area_virtual_base()
|
||||||
|
{
|
||||||
|
return Genode::stack_area_virtual_base();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
size_t Thread_base::stack_area_virtual_size()
|
||||||
|
{
|
||||||
|
return Genode::stack_area_virtual_size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Thread_base::Thread_base(size_t weight, const char *name, size_t stack_size,
|
Thread_base::Thread_base(size_t weight, const char *name, size_t stack_size,
|
||||||
Type type, Cpu_session *cpu_session)
|
Type type, Cpu_session *cpu_session)
|
||||||
:
|
:
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
#include <base/synced_allocator.h>
|
#include <base/synced_allocator.h>
|
||||||
#include <base/thread.h>
|
#include <base/thread.h>
|
||||||
|
|
||||||
|
/* base-internal includes */
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
/* local includes */
|
/* local includes */
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include <map_local.h>
|
#include <map_local.h>
|
||||||
@ -80,8 +83,7 @@ class Stack_area_rm_session : public Rm_session
|
|||||||
return (addr_t)0;
|
return (addr_t)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
addr_t core_local_addr = Native_config::stack_area_virtual_base() +
|
addr_t core_local_addr = stack_area_virtual_base() + (addr_t)local_addr;
|
||||||
(addr_t)local_addr;
|
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
PDBG("core_local_addr = %lx, phys_addr = %lx, size = 0x%zx",
|
PDBG("core_local_addr = %lx, phys_addr = %lx, size = 0x%zx",
|
||||||
@ -103,12 +105,11 @@ class Stack_area_rm_session : public Rm_session
|
|||||||
{
|
{
|
||||||
using Genode::addr_t;
|
using Genode::addr_t;
|
||||||
|
|
||||||
if ((addr_t)local_addr >= Native_config::stack_area_virtual_size())
|
if ((addr_t)local_addr >= stack_area_virtual_size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
addr_t const detach = Native_config::stack_area_virtual_base() +
|
addr_t const detach = stack_area_virtual_base() + (addr_t)local_addr;
|
||||||
(addr_t)local_addr;
|
addr_t const stack = stack_virtual_size();
|
||||||
addr_t const stack = Native_config::stack_virtual_size();
|
|
||||||
addr_t const pages = ((detach & ~(stack - 1)) + stack - detach)
|
addr_t const pages = ((detach & ~(stack - 1)) + stack - detach)
|
||||||
>> get_page_size_log2();
|
>> get_page_size_log2();
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/stack.h>
|
#include <base/internal/stack.h>
|
||||||
|
#include <base/internal/stack_area.h>
|
||||||
|
|
||||||
namespace Genode { class Stack_allocator; }
|
namespace Genode { class Stack_allocator; }
|
||||||
|
|
||||||
@ -30,8 +31,8 @@ class Genode::Stack_allocator
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
static constexpr size_t MAX_THREADS =
|
static constexpr size_t MAX_THREADS =
|
||||||
Native_config::stack_area_virtual_size() /
|
stack_area_virtual_size() /
|
||||||
Native_config::stack_virtual_size();
|
stack_virtual_size();
|
||||||
|
|
||||||
struct Stack_bit_allocator : Bit_allocator<MAX_THREADS>
|
struct Stack_bit_allocator : Bit_allocator<MAX_THREADS>
|
||||||
{
|
{
|
||||||
|
26
repos/base/src/include/base/internal/stack_area.h
Normal file
26
repos/base/src/include/base/internal/stack_area.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* \brief Stack area layout parameters
|
||||||
|
* \author Norman Feske
|
||||||
|
* \date 2016-03-03
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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__STACK_AREA_H_
|
||||||
|
#define _INCLUDE__BASE__INTERNAL__STACK_AREA_H_
|
||||||
|
|
||||||
|
#include <base/stdint.h>
|
||||||
|
|
||||||
|
namespace Genode {
|
||||||
|
|
||||||
|
static constexpr addr_t stack_area_virtual_base() { return 0x40000000UL; }
|
||||||
|
static constexpr addr_t stack_area_virtual_size() { return 0x10000000UL; }
|
||||||
|
static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _INCLUDE__BASE__INTERNAL__STACK_AREA_H_ */
|
@ -11,12 +11,15 @@
|
|||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Genode includes */
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <base/printf.h>
|
#include <base/printf.h>
|
||||||
#include <os/config.h>
|
#include <os/config.h>
|
||||||
#include <util/list.h>
|
#include <util/list.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
|
#include <base/thread.h>
|
||||||
|
|
||||||
|
/* local includes */
|
||||||
#include <dynamic.h>
|
#include <dynamic.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
|
|
||||||
@ -578,9 +581,10 @@ int main()
|
|||||||
/* print loaded object information */
|
/* print loaded object information */
|
||||||
try {
|
try {
|
||||||
if (Genode::config()->xml_node().attribute("ld_verbose").has_value("yes")) {
|
if (Genode::config()->xml_node().attribute("ld_verbose").has_value("yes")) {
|
||||||
PINF(" %lx .. %lx: stack area", Genode::Native_config::stack_area_virtual_base(),
|
PINF(" %lx .. %lx: stack area",
|
||||||
Genode::Native_config::stack_area_virtual_base() +
|
Genode::Thread_base::stack_area_virtual_base(),
|
||||||
Genode::Native_config::stack_area_virtual_size() - 1);
|
Genode::Thread_base::stack_area_virtual_base() +
|
||||||
|
Genode::Thread_base::stack_area_virtual_size() - 1);
|
||||||
dump_loaded();
|
dump_loaded();
|
||||||
}
|
}
|
||||||
} catch (...) { }
|
} catch (...) { }
|
||||||
|
@ -136,8 +136,8 @@ static void test_main_thread()
|
|||||||
printf("thread base %p\n", myself);
|
printf("thread base %p\n", myself);
|
||||||
|
|
||||||
/* check whether my stack is inside the first stack region */
|
/* check whether my stack is inside the first stack region */
|
||||||
addr_t const stack_slot_base = Native_config::stack_area_virtual_base();
|
addr_t const stack_slot_base = Thread_base::stack_area_virtual_base();
|
||||||
addr_t const stack_slot_size = Native_config::stack_area_virtual_size();
|
addr_t const stack_slot_size = Thread_base::stack_area_virtual_size();
|
||||||
addr_t const stack_slot_top = stack_slot_base + stack_slot_size;
|
addr_t const stack_slot_top = stack_slot_base + stack_slot_size;
|
||||||
|
|
||||||
addr_t const stack_top = (addr_t)myself->stack_top();
|
addr_t const stack_top = (addr_t)myself->stack_top();
|
||||||
@ -271,10 +271,10 @@ static void test_create_as_many_threads()
|
|||||||
{
|
{
|
||||||
printf("running '%s'\n", __func__);
|
printf("running '%s'\n", __func__);
|
||||||
|
|
||||||
addr_t const max = Native_config::stack_area_virtual_size() /
|
addr_t const max = Thread_base::stack_area_virtual_size() /
|
||||||
Native_config::stack_virtual_size();
|
Thread_base::stack_virtual_size();
|
||||||
|
|
||||||
static Cpu_helper * threads[max];
|
Cpu_helper * threads[max];
|
||||||
static char thread_name[8];
|
static char thread_name[8];
|
||||||
|
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
|
@ -127,8 +127,8 @@ static void register_reserved_areas()
|
|||||||
|
|
||||||
size_t bin_sz = (addr_t)&_prog_img_end - (addr_t)&_prog_img_beg;
|
size_t bin_sz = (addr_t)&_prog_img_end - (addr_t)&_prog_img_beg;
|
||||||
L4lx::Env::env()->rm()->reserve_range((addr_t)&_prog_img_beg, bin_sz, "Binary");
|
L4lx::Env::env()->rm()->reserve_range((addr_t)&_prog_img_beg, bin_sz, "Binary");
|
||||||
L4lx::Env::env()->rm()->reserve_range(Native_config::stack_area_virtual_base(),
|
L4lx::Env::env()->rm()->reserve_range(Thread_base::stack_area_virtual_base(),
|
||||||
Native_config::stack_area_virtual_size(),
|
Thread_base::stack_area_virtual_size(),
|
||||||
"Stack Area");
|
"Stack Area");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1414,7 +1414,7 @@ int main(int argc, char **argv)
|
|||||||
* with the actual VM size which is determined below inside this scope.
|
* with the actual VM size which is determined below inside this scope.
|
||||||
*/
|
*/
|
||||||
Vmm::Virtual_reservation
|
Vmm::Virtual_reservation
|
||||||
reservation(Genode::Native_config::stack_area_virtual_base());
|
reservation(Genode::Thread_base::stack_area_virtual_base());
|
||||||
|
|
||||||
Genode::printf("--- Vancouver VMM starting ---\n");
|
Genode::printf("--- Vancouver VMM starting ---\n");
|
||||||
|
|
||||||
@ -1468,9 +1468,9 @@ int main(int argc, char **argv)
|
|||||||
fb_size / 1024 / 1024);
|
fb_size / 1024 / 1024);
|
||||||
|
|
||||||
Genode::printf("[0x%012lx, 0x%012lx) - Genode stack area\n",
|
Genode::printf("[0x%012lx, 0x%012lx) - Genode stack area\n",
|
||||||
Genode::Native_config::stack_area_virtual_base(),
|
Genode::Thread_base::stack_area_virtual_base(),
|
||||||
Genode::Native_config::stack_area_virtual_base() +
|
Genode::Thread_base::stack_area_virtual_base() +
|
||||||
Genode::Native_config::stack_area_virtual_size());
|
Genode::Thread_base::stack_area_virtual_size());
|
||||||
|
|
||||||
Genode::printf("[0x%012lx, 0x%012lx) - VMM program image\n",
|
Genode::printf("[0x%012lx, 0x%012lx) - VMM program image\n",
|
||||||
(Genode::addr_t)&_prog_img_beg,
|
(Genode::addr_t)&_prog_img_beg,
|
||||||
|
@ -68,7 +68,7 @@ static int create_thread(pthread_t *thread, const pthread_attr_t *attr,
|
|||||||
|
|
||||||
Assert(rtthread);
|
Assert(rtthread);
|
||||||
|
|
||||||
size_t stack_size = Genode::Native_config::stack_virtual_size() -
|
size_t stack_size = Genode::Thread_base::stack_virtual_size() -
|
||||||
sizeof(Genode::Native_utcb) - 2 * (1UL << 12);
|
sizeof(Genode::Native_utcb) - 2 * (1UL << 12);
|
||||||
|
|
||||||
if (rtthread->cbStack < stack_size)
|
if (rtthread->cbStack < stack_size)
|
||||||
|
Loading…
Reference in New Issue
Block a user