mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-20 06:07:59 +00:00
base: unify platform.cc between base, base-linux
This is a preparatory step for merging 'init_platform()' with 'bootstrap_component()'. Issue #4784
This commit is contained in:
parent
54cc70f9b1
commit
3a8c3dcc2d
@ -50,7 +50,7 @@ void Thread::_init_platform_thread(size_t, Type type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Genode::init_thread_bootstrap(Thread_capability main_cap)
|
void Genode::init_thread_bootstrap(Cpu_session &, Thread_capability main_cap)
|
||||||
{
|
{
|
||||||
main_thread_cap(main_cap);
|
main_thread_cap(main_cap);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ void Genode::init_thread_start(Capability<Pd_session> pd_cap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Genode::init_thread_bootstrap(Thread_capability main_cap)
|
void Genode::init_thread_bootstrap(Cpu_session &, Thread_capability main_cap)
|
||||||
{
|
{
|
||||||
main_thread_cap(main_cap);
|
main_thread_cap(main_cap);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ void Genode::init_thread_start(Capability<Pd_session> pd_cap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Genode::init_thread_bootstrap(Thread_capability main_cap)
|
void Genode::init_thread_bootstrap(Cpu_session &, Thread_capability main_cap)
|
||||||
{
|
{
|
||||||
main_thread_cap(main_cap);
|
main_thread_cap(main_cap);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <base/heap.h>
|
#include <base/heap.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
|
#include <base/internal/globals.h>
|
||||||
#include <base/internal/expanding_cpu_session_client.h>
|
#include <base/internal/expanding_cpu_session_client.h>
|
||||||
#include <base/internal/expanding_region_map_client.h>
|
#include <base/internal/expanding_region_map_client.h>
|
||||||
#include <base/internal/expanding_pd_session_client.h>
|
#include <base/internal/expanding_pd_session_client.h>
|
||||||
@ -35,7 +36,9 @@ struct Genode::Platform
|
|||||||
{
|
{
|
||||||
Region_map_mmap rm { false };
|
Region_map_mmap rm { false };
|
||||||
|
|
||||||
Local_parent parent;
|
static Capability<Parent> _obtain_parent_cap();
|
||||||
|
|
||||||
|
Local_parent parent { _obtain_parent_cap(), rm, heap };
|
||||||
|
|
||||||
Pd_session_capability pd_cap =
|
Pd_session_capability pd_cap =
|
||||||
static_cap_cast<Pd_session>(parent.session_cap(Parent::Env::pd()));
|
static_cap_cast<Pd_session>(parent.session_cap(Parent::Env::pd()));
|
||||||
@ -49,15 +52,7 @@ struct Genode::Platform
|
|||||||
|
|
||||||
Heap heap { pd, rm };
|
Heap heap { pd, rm };
|
||||||
|
|
||||||
Platform(Parent_capability cap) : parent(cap, rm, heap)
|
Platform() { _attach_stack_area(); }
|
||||||
{
|
|
||||||
_attach_stack_area();
|
|
||||||
}
|
|
||||||
|
|
||||||
~Platform()
|
|
||||||
{
|
|
||||||
parent.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attach stack area to local address space (for non-hybrid components)
|
* Attach stack area to local address space (for non-hybrid components)
|
||||||
|
@ -26,4 +26,7 @@ void Platform::_attach_stack_area()
|
|||||||
pd._address_space.attach_at(pd._stack_area.dataspace(),
|
pd._address_space.attach_at(pd._stack_area.dataspace(),
|
||||||
stack_area_virtual_base(),
|
stack_area_virtual_base(),
|
||||||
stack_area_virtual_size());
|
stack_area_virtual_size());
|
||||||
|
|
||||||
|
env_stack_area_region_map = &pd._stack_area;
|
||||||
|
env_stack_area_ram_allocator = &pd;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/platform.h>
|
#include <base/internal/platform.h>
|
||||||
#include <base/internal/native_thread.h>
|
#include <base/internal/native_thread.h>
|
||||||
#include <base/internal/globals.h>
|
|
||||||
#include <base/internal/parent_socket_handle.h>
|
#include <base/internal/parent_socket_handle.h>
|
||||||
#include <base/internal/capability_space_tpl.h>
|
#include <base/internal/capability_space_tpl.h>
|
||||||
|
|
||||||
@ -153,10 +152,10 @@ Env_deprecated *Genode::env_deprecated()
|
|||||||
|
|
||||||
Parent *parent() override { return &_pf.parent; }
|
Parent *parent() override { return &_pf.parent; }
|
||||||
Cpu_session *cpu_session() override { return &_pf.cpu; }
|
Cpu_session *cpu_session() override { return &_pf.cpu; }
|
||||||
Cpu_session_capability cpu_session_cap() override { return _pf.cpu_cap; }
|
Cpu_session_capability cpu_session_cap() override { return _pf.cpu.rpc_cap(); }
|
||||||
Region_map *rm_session() override { return &_pf.rm; }
|
Region_map *rm_session() override { return &_pf.rm; }
|
||||||
Pd_session *pd_session() override { return &_pf.pd; }
|
Pd_session *pd_session() override { return &_pf.pd; }
|
||||||
Pd_session_capability pd_session_cap() override { return _pf.pd_cap; }
|
Pd_session_capability pd_session_cap() override { return _pf.pd.rpc_cap(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
static Impl impl { *_platform_ptr };
|
static Impl impl { *_platform_ptr };
|
||||||
@ -165,7 +164,7 @@ Env_deprecated *Genode::env_deprecated()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Parent_capability obtain_parent_cap()
|
Capability<Parent> Platform::_obtain_parent_cap()
|
||||||
{
|
{
|
||||||
long const local_name = get_env_ulong("parent_local_name");
|
long const local_name = get_env_ulong("parent_local_name");
|
||||||
|
|
||||||
@ -190,27 +189,16 @@ void Genode::init_parent_resource_requests(Genode::Env & env)
|
|||||||
|
|
||||||
void Genode::init_platform()
|
void Genode::init_platform()
|
||||||
{
|
{
|
||||||
static Platform platform { obtain_parent_cap() };
|
static Genode::Platform platform;
|
||||||
|
|
||||||
/* allow use of deprecated_env */
|
|
||||||
_platform_ptr = &platform;
|
|
||||||
|
|
||||||
init_log(platform.parent);
|
init_log(platform.parent);
|
||||||
init_rpc_cap_alloc(platform.parent);
|
init_rpc_cap_alloc(platform.parent);
|
||||||
|
init_cap_slab(platform.pd, platform.parent);
|
||||||
init_thread(platform.cpu, platform.rm);
|
init_thread(platform.cpu, platform.rm);
|
||||||
init_thread_start(platform.pd_cap);
|
init_thread_start(platform.pd.rpc_cap());
|
||||||
init_thread_bootstrap(platform.parent.main_thread_cap());
|
init_thread_bootstrap(platform.cpu, platform.parent.main_thread_cap());
|
||||||
|
|
||||||
env_stack_area_region_map = &platform.pd._stack_area;
|
_platform_ptr = &platform;
|
||||||
env_stack_area_ram_allocator = &platform.pd;
|
|
||||||
|
|
||||||
/* register TID and PID of the main thread at core */
|
|
||||||
Linux_native_cpu_client native_cpu(platform.cpu.native_cpu());
|
|
||||||
|
|
||||||
native_cpu.thread_id(platform.parent.main_thread_cap(),
|
|
||||||
lx_getpid(), lx_gettid());
|
|
||||||
|
|
||||||
init_rpc_cap_alloc(platform.parent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,7 +190,11 @@ void Genode::init_thread_start(Capability<Pd_session> pd_cap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Genode::init_thread_bootstrap(Thread_capability main_cap)
|
void Genode::init_thread_bootstrap(Cpu_session &cpu, Thread_capability main_cap)
|
||||||
{
|
{
|
||||||
main_thread_cap(main_cap);
|
main_thread_cap(main_cap);
|
||||||
|
|
||||||
|
/* register TID and PID of the main thread at core */
|
||||||
|
Linux_native_cpu_client native_cpu(cpu.native_cpu());
|
||||||
|
native_cpu.thread_id(main_cap, lx_getpid(), lx_gettid());
|
||||||
}
|
}
|
||||||
|
@ -410,7 +410,14 @@ static void *thread_start(void *arg)
|
|||||||
|
|
||||||
void Genode::init_thread(Cpu_session &, Region_map &) { }
|
void Genode::init_thread(Cpu_session &, Region_map &) { }
|
||||||
void Genode::init_thread_start(Capability<Pd_session>) { }
|
void Genode::init_thread_start(Capability<Pd_session>) { }
|
||||||
void Genode::init_thread_bootstrap(Thread_capability) { }
|
|
||||||
|
|
||||||
|
void Genode::init_thread_bootstrap(Cpu_session &cpu, Thread_capability main_cap)
|
||||||
|
{
|
||||||
|
/* register TID and PID of the main thread at core */
|
||||||
|
Linux_native_cpu_client native_cpu(cpu.native_cpu());
|
||||||
|
native_cpu.thread_id(main_cap, lx_getpid(), lx_gettid());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" void *malloc(::size_t size);
|
extern "C" void *malloc(::size_t size);
|
||||||
|
@ -212,7 +212,7 @@ void Genode::init_thread_start(Capability<Pd_session> pd_cap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Genode::init_thread_bootstrap(Thread_capability main_cap)
|
void Genode::init_thread_bootstrap(Cpu_session &, Thread_capability main_cap)
|
||||||
{
|
{
|
||||||
main_thread_cap(main_cap);
|
main_thread_cap(main_cap);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ void Thread::_init_platform_thread(size_t, Type type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Genode::init_thread_bootstrap(Thread_capability main_cap)
|
void Genode::init_thread_bootstrap(Cpu_session &, Thread_capability main_cap)
|
||||||
{
|
{
|
||||||
main_thread_cap(main_cap);
|
main_thread_cap(main_cap);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ void Genode::Thread::_init_platform_thread(size_t, Type type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Genode::init_thread_bootstrap(Thread_capability main_cap)
|
void Genode::init_thread_bootstrap(Cpu_session &, Thread_capability main_cap)
|
||||||
{
|
{
|
||||||
main_thread_cap(main_cap);
|
main_thread_cap(main_cap);
|
||||||
}
|
}
|
||||||
|
@ -40,4 +40,4 @@ void Genode::Thread::_thread_bootstrap()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Genode::init_thread_bootstrap(Thread_capability) { }
|
void Genode::init_thread_bootstrap(Cpu_session &, Thread_capability) { }
|
||||||
|
@ -44,7 +44,7 @@ namespace Genode {
|
|||||||
void init_heartbeat_monitoring(Env &);
|
void init_heartbeat_monitoring(Env &);
|
||||||
void init_thread(Cpu_session &, Region_map &);
|
void init_thread(Cpu_session &, Region_map &);
|
||||||
void init_thread_start(Capability<Pd_session>);
|
void init_thread_start(Capability<Pd_session>);
|
||||||
void init_thread_bootstrap(Thread_capability);
|
void init_thread_bootstrap(Cpu_session &, Thread_capability);
|
||||||
void deinit_heartbeat_monitoring();
|
void deinit_heartbeat_monitoring();
|
||||||
void exec_static_constructors();
|
void exec_static_constructors();
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/parent_cap.h>
|
#include <base/internal/parent_cap.h>
|
||||||
|
#include <base/internal/globals.h>
|
||||||
#include <base/internal/attached_stack_area.h>
|
#include <base/internal/attached_stack_area.h>
|
||||||
#include <base/internal/expanding_cpu_session_client.h>
|
#include <base/internal/expanding_cpu_session_client.h>
|
||||||
#include <base/internal/expanding_pd_session_client.h>
|
#include <base/internal/expanding_pd_session_client.h>
|
||||||
@ -45,6 +46,12 @@ struct Genode::Platform : Noncopyable
|
|||||||
parent, pd.rpc_cap(), pd.address_space(), Parent::Env::pd() };
|
parent, pd.rpc_cap(), pd.address_space(), Parent::Env::pd() };
|
||||||
|
|
||||||
Attached_stack_area stack_area { parent, pd.rpc_cap() };
|
Attached_stack_area stack_area { parent, pd.rpc_cap() };
|
||||||
|
|
||||||
|
Platform()
|
||||||
|
{
|
||||||
|
env_stack_area_ram_allocator = &pd;
|
||||||
|
env_stack_area_region_map = &stack_area;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _INCLUDE__BASE__INTERNAL__PLATFORM_H_ */
|
#endif /* _INCLUDE__BASE__INTERNAL__PLATFORM_H_ */
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
#include <deprecated/env.h>
|
#include <deprecated/env.h>
|
||||||
#include <base/internal/platform.h>
|
#include <base/internal/platform.h>
|
||||||
#include <base/internal/globals.h>
|
|
||||||
#include <base/connection.h>
|
#include <base/connection.h>
|
||||||
#include <base/service.h>
|
#include <base/service.h>
|
||||||
|
|
||||||
@ -70,10 +69,7 @@ void Genode::init_platform()
|
|||||||
init_cap_slab(platform.pd, platform.parent);
|
init_cap_slab(platform.pd, platform.parent);
|
||||||
init_thread(platform.cpu, platform.rm);
|
init_thread(platform.cpu, platform.rm);
|
||||||
init_thread_start(platform.pd.rpc_cap());
|
init_thread_start(platform.pd.rpc_cap());
|
||||||
init_thread_bootstrap(platform.parent.main_thread_cap());
|
init_thread_bootstrap(platform.cpu, platform.parent.main_thread_cap());
|
||||||
|
|
||||||
env_stack_area_ram_allocator = &platform.pd;
|
|
||||||
env_stack_area_region_map = &platform.stack_area;
|
|
||||||
|
|
||||||
_platform_ptr = &platform;
|
_platform_ptr = &platform;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user