mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-08 11:55:24 +00:00
base-linux: coding style
This commit is contained in:
parent
dc016cbd5c
commit
0dcb526ae5
@ -79,6 +79,7 @@ inline int lx_iopl(int level)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**************************************************
|
||||
** Functions used by core's io mem session code **
|
||||
**************************************************/
|
||||
@ -261,5 +262,4 @@ inline int lx_read(int fd, void *buf, Genode::size_t count)
|
||||
return lx_syscall(SYS_read, fd, buf, count);
|
||||
}
|
||||
|
||||
|
||||
#endif /* _CORE__INCLUDE__CORE_LINUX_SYSCALLS_H_ */
|
||||
|
@ -28,107 +28,116 @@
|
||||
#include <base/internal/capability_space_tpl.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
/**
|
||||
* Deriving classes can own a dataspace to implement conditional behavior
|
||||
*/
|
||||
class Dataspace_owner : Interface { };
|
||||
|
||||
class Dataspace_component : public Rpc_object<Linux_dataspace>
|
||||
{
|
||||
private:
|
||||
|
||||
Filename _fname { }; /* filename for mmap */
|
||||
size_t const _size; /* size of dataspace in bytes */
|
||||
addr_t const _addr; /* meaningless on linux */
|
||||
Native_capability _cap; /* capability / file descriptor */
|
||||
bool const _writable; /* false if read-only */
|
||||
|
||||
/* Holds the dataspace owner if a distinction between owner and
|
||||
* others is necessary on the dataspace, otherwise it is 0 */
|
||||
Dataspace_owner const * const _owner;
|
||||
|
||||
static Filename _file_name(const char *args);
|
||||
size_t _file_size();
|
||||
|
||||
/*
|
||||
* Noncopyable
|
||||
*/
|
||||
Dataspace_component(Dataspace_component const &);
|
||||
Dataspace_component &operator = (Dataspace_component const &);
|
||||
|
||||
static Native_capability _fd_to_cap(int const fd)
|
||||
{
|
||||
return Capability_space::import(Rpc_destination(Lx_sd{fd}), Rpc_obj_key());
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Dataspace_component(size_t size, addr_t addr,
|
||||
Cache_attribute, bool writable,
|
||||
Dataspace_owner * owner)
|
||||
: _size(size), _addr(addr), _cap(), _writable(writable),
|
||||
_owner(owner) { }
|
||||
|
||||
/**
|
||||
* Default constructor returns invalid dataspace
|
||||
*/
|
||||
Dataspace_component()
|
||||
: _size(0), _addr(0), _cap(), _writable(false), _owner(nullptr) { }
|
||||
|
||||
/**
|
||||
* This constructor is only provided for compatibility
|
||||
* reasons and should not be used.
|
||||
*/
|
||||
Dataspace_component(size_t size, addr_t, addr_t phys_addr,
|
||||
Cache_attribute, bool writable, Dataspace_owner *_owner);
|
||||
|
||||
/**
|
||||
* This constructor is especially used for ROM dataspaces
|
||||
*
|
||||
* \param args session parameters containing 'filename' key/value
|
||||
*/
|
||||
Dataspace_component(const char *args);
|
||||
|
||||
/**
|
||||
* Assign file descriptor to dataspace
|
||||
*
|
||||
* The file descriptor assigned to the dataspace will be enable
|
||||
* processes outside of core to mmap the dataspace.
|
||||
*/
|
||||
void fd(int fd) { _cap = _fd_to_cap(fd); }
|
||||
|
||||
/**
|
||||
* Check if dataspace is owned by a specified object
|
||||
*/
|
||||
bool owner(Dataspace_owner const &o) const { return _owner == &o; }
|
||||
|
||||
/**
|
||||
* Detach dataspace from all rm sessions.
|
||||
*/
|
||||
void detach_from_rm_sessions() { }
|
||||
|
||||
|
||||
/*************************
|
||||
** Dataspace interface **
|
||||
*************************/
|
||||
|
||||
size_t size() override { return _size; }
|
||||
addr_t phys_addr() override { return _addr; }
|
||||
bool writable() override { return _writable; }
|
||||
|
||||
|
||||
/****************************************
|
||||
** Linux-specific dataspace interface **
|
||||
****************************************/
|
||||
|
||||
Filename fname() override { return _fname; }
|
||||
|
||||
Untyped_capability fd() override { return _cap; }
|
||||
};
|
||||
class Dataspace_owner;
|
||||
class Dataspace_component;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deriving classes can own a dataspace to implement conditional behavior
|
||||
*/
|
||||
class Genode::Dataspace_owner : Interface { };
|
||||
|
||||
|
||||
class Genode::Dataspace_component : public Rpc_object<Linux_dataspace>
|
||||
{
|
||||
private:
|
||||
|
||||
Filename _fname { }; /* filename for mmap */
|
||||
size_t const _size; /* size of dataspace in bytes */
|
||||
addr_t const _addr; /* meaningless on linux */
|
||||
Native_capability _cap; /* capability / file descriptor */
|
||||
bool const _writable; /* false if read-only */
|
||||
|
||||
/*
|
||||
* Holds the dataspace owner if a distinction between owner and
|
||||
* others is necessary on the dataspace, otherwise it is 0
|
||||
*/
|
||||
Dataspace_owner const * const _owner;
|
||||
|
||||
static Filename _file_name(const char *args);
|
||||
size_t _file_size();
|
||||
|
||||
/*
|
||||
* Noncopyable
|
||||
*/
|
||||
Dataspace_component(Dataspace_component const &);
|
||||
Dataspace_component &operator = (Dataspace_component const &);
|
||||
|
||||
static Native_capability _fd_to_cap(int const fd)
|
||||
{
|
||||
return Capability_space::import(Rpc_destination(Lx_sd{fd}), Rpc_obj_key());
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Dataspace_component(size_t size, addr_t addr,
|
||||
Cache_attribute, bool writable,
|
||||
Dataspace_owner * owner)
|
||||
:
|
||||
_size(size), _addr(addr), _cap(), _writable(writable), _owner(owner)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Default constructor creates invalid dataspace
|
||||
*/
|
||||
Dataspace_component()
|
||||
:
|
||||
_size(0), _addr(0), _cap(), _writable(false), _owner(nullptr)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* This constructor is only provided for compatibility
|
||||
* reasons and should not be used.
|
||||
*/
|
||||
Dataspace_component(size_t size, addr_t, addr_t phys_addr,
|
||||
Cache_attribute, bool writable, Dataspace_owner *_owner);
|
||||
|
||||
/**
|
||||
* This constructor is especially used for ROM dataspaces
|
||||
*
|
||||
* \param args session parameters containing 'filename' key/value
|
||||
*/
|
||||
Dataspace_component(const char *args);
|
||||
|
||||
/**
|
||||
* Assign file descriptor to dataspace
|
||||
*
|
||||
* The file descriptor assigned to the dataspace will be enable
|
||||
* processes outside of core to mmap the dataspace.
|
||||
*/
|
||||
void fd(int fd) { _cap = _fd_to_cap(fd); }
|
||||
|
||||
/**
|
||||
* Check if dataspace is owned by a specified object
|
||||
*/
|
||||
bool owner(Dataspace_owner const &o) const { return _owner == &o; }
|
||||
|
||||
/**
|
||||
* Detach dataspace from all rm sessions.
|
||||
*/
|
||||
void detach_from_rm_sessions() { }
|
||||
|
||||
|
||||
/*************************
|
||||
** Dataspace interface **
|
||||
*************************/
|
||||
|
||||
size_t size() override { return _size; }
|
||||
addr_t phys_addr() override { return _addr; }
|
||||
bool writable() override { return _writable; }
|
||||
|
||||
|
||||
/****************************************
|
||||
** Linux-specific dataspace interface **
|
||||
****************************************/
|
||||
|
||||
Filename fname() override { return _fname; }
|
||||
|
||||
Untyped_capability fd() override { return _cap; }
|
||||
};
|
||||
|
||||
#endif /* _CORE__INCLUDE__DATASPACE_COMPONENT_H_ */
|
||||
|
@ -22,53 +22,52 @@
|
||||
/* core includes */
|
||||
#include <dataspace_component.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Io_mem_session_component : public Rpc_object<Io_mem_session>
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
Range_allocator &_io_mem_alloc;
|
||||
Dataspace_component _ds;
|
||||
Rpc_entrypoint &_ds_ep;
|
||||
Io_mem_dataspace_capability _ds_cap;
|
||||
|
||||
size_t get_arg_size(const char *);
|
||||
addr_t get_arg_phys(const char *);
|
||||
Cache_attribute get_arg_wc(const char *);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param io_mem_alloc MMIO region allocator
|
||||
* \param ram_alloc RAM allocator that will be checked for
|
||||
* region collisions
|
||||
* \param ds_ep entry point to manage the dataspace
|
||||
* corresponding the io_mem session
|
||||
* \param args session construction arguments, in
|
||||
* particular MMIO region base, size and
|
||||
* caching demands
|
||||
*/
|
||||
Io_mem_session_component(Range_allocator &io_mem_alloc,
|
||||
Range_allocator &ram_alloc,
|
||||
Rpc_entrypoint &ds_ep,
|
||||
const char *args);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Io_mem_session_component() { }
|
||||
namespace Genode { class Io_mem_session_component; }
|
||||
|
||||
|
||||
/*****************************
|
||||
** Io-mem session interface **
|
||||
*****************************/
|
||||
class Genode::Io_mem_session_component : public Rpc_object<Io_mem_session>
|
||||
{
|
||||
private:
|
||||
|
||||
Io_mem_dataspace_capability dataspace() override;
|
||||
};
|
||||
}
|
||||
Range_allocator &_io_mem_alloc;
|
||||
Dataspace_component _ds;
|
||||
Rpc_entrypoint &_ds_ep;
|
||||
Io_mem_dataspace_capability _ds_cap;
|
||||
|
||||
size_t get_arg_size(const char *);
|
||||
addr_t get_arg_phys(const char *);
|
||||
Cache_attribute get_arg_wc(const char *);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param io_mem_alloc MMIO region allocator
|
||||
* \param ram_alloc RAM allocator that will be checked for
|
||||
* region collisions
|
||||
* \param ds_ep entry point to manage the dataspace
|
||||
* corresponding the io_mem session
|
||||
* \param args session construction arguments, in
|
||||
* particular MMIO region base, size and
|
||||
* caching demands
|
||||
*/
|
||||
Io_mem_session_component(Range_allocator &io_mem_alloc,
|
||||
Range_allocator &ram_alloc,
|
||||
Rpc_entrypoint &ds_ep,
|
||||
const char *args);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Io_mem_session_component() { }
|
||||
|
||||
|
||||
/*****************************
|
||||
** Io-mem session interface **
|
||||
*****************************/
|
||||
|
||||
Io_mem_dataspace_capability dataspace() override;
|
||||
};
|
||||
|
||||
#endif /* _CORE__INCLUDE__IO_MEM_SESSION_COMPONENT_H_ */
|
||||
|
@ -16,19 +16,16 @@
|
||||
|
||||
#include <base/thread.h>
|
||||
|
||||
namespace Genode
|
||||
{
|
||||
class Irq_object;
|
||||
};
|
||||
namespace Genode { class Irq_object; };
|
||||
|
||||
|
||||
class Genode::Irq_object : public Thread_deprecated<4096>
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
Genode::Signal_context_capability _sig_cap;
|
||||
Genode::Blockade _sync_ack { };
|
||||
Genode::Blockade _sync_bootup { };
|
||||
Signal_context_capability _sig_cap;
|
||||
Blockade _sync_ack { };
|
||||
Blockade _sync_bootup { };
|
||||
unsigned const _irq;
|
||||
int _fd;
|
||||
|
||||
|
@ -20,9 +20,8 @@
|
||||
#include <irq_session/irq_session.h>
|
||||
#include <irq_object.h>
|
||||
|
||||
namespace Genode {
|
||||
class Irq_session_component;
|
||||
}
|
||||
namespace Genode { class Irq_session_component; }
|
||||
|
||||
|
||||
class Genode::Irq_session_component : public Rpc_object<Irq_session>,
|
||||
private List<Irq_session_component>::Element
|
||||
@ -30,8 +29,10 @@ class Genode::Irq_session_component : public Rpc_object<Irq_session>,
|
||||
private:
|
||||
|
||||
friend class List<Irq_session_component>;
|
||||
|
||||
unsigned _irq_number;
|
||||
Genode::Irq_object _irq_object;
|
||||
|
||||
Irq_object _irq_object;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <linux_native_cpu/linux_native_cpu.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Cpu_session_component;
|
||||
class Native_cpu_component;
|
||||
}
|
||||
@ -37,6 +36,7 @@ class Genode::Native_cpu_component : public Rpc_object<Linux_native_cpu,
|
||||
public:
|
||||
|
||||
Native_cpu_component(Cpu_session_component &, char const *);
|
||||
|
||||
~Native_cpu_component();
|
||||
|
||||
void thread_id(Thread_capability, int, int) override;
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <linux_native_pd/linux_native_pd.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Dataspace_component;
|
||||
class Pd_session_component;
|
||||
class Native_pd_component;
|
||||
@ -26,7 +25,7 @@ namespace Genode {
|
||||
|
||||
|
||||
class Genode::Native_pd_component : public Rpc_object<Linux_native_pd,
|
||||
Native_pd_component>
|
||||
Native_pd_component>
|
||||
{
|
||||
private:
|
||||
|
||||
|
@ -3,8 +3,6 @@
|
||||
* \author Norman Feske
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-04-28
|
||||
*
|
||||
* Linux dummies
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -26,36 +24,40 @@
|
||||
#include <rpc_cap_factory.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
struct Pager_object
|
||||
{
|
||||
Thread_capability _thread_cap { };
|
||||
Signal_context_capability _sigh { };
|
||||
|
||||
virtual ~Pager_object() { }
|
||||
|
||||
void exception_handler(Signal_context_capability sigh) { _sigh = sigh; }
|
||||
|
||||
/**
|
||||
* Remember thread cap so that rm_session can tell thread that
|
||||
* rm_client is gone.
|
||||
*/
|
||||
Thread_capability thread_cap() const { return _thread_cap; }
|
||||
void thread_cap(Thread_capability cap) { _thread_cap = cap; }
|
||||
};
|
||||
|
||||
struct Pager_entrypoint
|
||||
{
|
||||
Pager_entrypoint(Rpc_cap_factory &) { }
|
||||
|
||||
template <typename FUNC>
|
||||
auto apply(Pager_capability, FUNC f) -> decltype(f(nullptr)) {
|
||||
return f(nullptr); }
|
||||
|
||||
Pager_capability manage(Pager_object &) { return Pager_capability(); }
|
||||
|
||||
void dissolve(Pager_object &) { }
|
||||
};
|
||||
struct Pager_object;
|
||||
struct Pager_entrypoint;
|
||||
}
|
||||
|
||||
|
||||
struct Genode::Pager_object
|
||||
{
|
||||
Thread_capability _thread_cap { };
|
||||
Signal_context_capability _sigh { };
|
||||
|
||||
virtual ~Pager_object() { }
|
||||
|
||||
void exception_handler(Signal_context_capability sigh) { _sigh = sigh; }
|
||||
|
||||
/**
|
||||
* Remember thread cap so that rm_session can tell thread that
|
||||
* rm_client is gone.
|
||||
*/
|
||||
Thread_capability thread_cap() const { return _thread_cap; }
|
||||
void thread_cap(Thread_capability cap) { _thread_cap = cap; }
|
||||
};
|
||||
|
||||
|
||||
struct Genode::Pager_entrypoint
|
||||
{
|
||||
Pager_entrypoint(Rpc_cap_factory &) { }
|
||||
|
||||
template <typename FUNC>
|
||||
auto apply(Pager_capability, FUNC f) -> decltype(f(nullptr)) {
|
||||
return f(nullptr); }
|
||||
|
||||
Pager_capability manage(Pager_object &) { return Pager_capability(); }
|
||||
|
||||
void dissolve(Pager_object &) { }
|
||||
};
|
||||
|
||||
#endif /* _CORE__INCLUDE__PAGER_H_ */
|
||||
|
@ -15,16 +15,17 @@
|
||||
#ifndef _CORE__INCLUDE__PLATFORM_H_
|
||||
#define _CORE__INCLUDE__PLATFORM_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/allocator_avl.h>
|
||||
#include <base/lock_guard.h>
|
||||
#include <util/arg_string.h>
|
||||
|
||||
/* core-local includes */
|
||||
#include <platform_generic.h>
|
||||
#include <platform_pd.h>
|
||||
#include <platform_thread.h>
|
||||
#include <synced_range_allocator.h>
|
||||
#include <assertion.h>
|
||||
|
||||
#include <util/arg_string.h>
|
||||
|
||||
/**
|
||||
* List of Unix environment variables, initialized by the startup code
|
||||
@ -37,9 +38,11 @@ extern char **lx_environ;
|
||||
*/
|
||||
static unsigned long ram_quota_from_env()
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
for (char **curr = lx_environ; curr && *curr; curr++) {
|
||||
|
||||
Genode::Arg arg = Genode::Arg_string::find_arg(*curr, "GENODE_RAM_QUOTA");
|
||||
Arg arg = Arg_string::find_arg(*curr, "GENODE_RAM_QUOTA");
|
||||
if (arg.valid())
|
||||
return arg.ulong_value(~0);
|
||||
}
|
||||
@ -47,113 +50,109 @@ static unsigned long ram_quota_from_env()
|
||||
return ~0;
|
||||
}
|
||||
|
||||
namespace Genode {
|
||||
|
||||
using namespace Genode;
|
||||
class Genode::Platform : public Platform_generic
|
||||
{
|
||||
private:
|
||||
|
||||
class Platform : public Platform_generic
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* Allocator for core-internal meta data
|
||||
*/
|
||||
Synced_range_allocator<Allocator_avl> _core_mem_alloc;
|
||||
|
||||
/**
|
||||
* Allocator for core-internal meta data
|
||||
*/
|
||||
Synced_range_allocator<Allocator_avl> _core_mem_alloc;
|
||||
Rom_fs _dummy_rom_fs { };
|
||||
|
||||
Rom_fs _dummy_rom_fs { };
|
||||
struct Dummy_allocator : Range_allocator
|
||||
{
|
||||
void free(void *, size_t) override { ASSERT_NEVER_CALLED; }
|
||||
bool need_size_for_free() const override { ASSERT_NEVER_CALLED; }
|
||||
size_t consumed() const override { ASSERT_NEVER_CALLED; }
|
||||
size_t overhead(size_t) const override { ASSERT_NEVER_CALLED; }
|
||||
int add_range (addr_t, size_t ) override { ASSERT_NEVER_CALLED; }
|
||||
int remove_range(addr_t, size_t ) override { ASSERT_NEVER_CALLED; }
|
||||
void free(void *) override { ASSERT_NEVER_CALLED; }
|
||||
size_t avail() const override { ASSERT_NEVER_CALLED; }
|
||||
bool valid_addr(addr_t ) const override { ASSERT_NEVER_CALLED; }
|
||||
bool alloc(size_t, void **) override { ASSERT_NEVER_CALLED; }
|
||||
|
||||
struct Dummy_allocator : Range_allocator
|
||||
Alloc_return alloc_aligned(size_t, void **, int, addr_t, addr_t) override
|
||||
{ ASSERT_NEVER_CALLED; }
|
||||
|
||||
Alloc_return alloc_addr(size_t, addr_t) override
|
||||
{ ASSERT_NEVER_CALLED; }
|
||||
|
||||
} _dummy_alloc { };
|
||||
|
||||
/**
|
||||
* Allocator for pseudo physical memory
|
||||
*/
|
||||
struct Pseudo_ram_allocator : Range_allocator
|
||||
{
|
||||
bool alloc(size_t, void **out_addr) override
|
||||
{
|
||||
void free(void *, size_t) override { ASSERT_NEVER_CALLED; }
|
||||
bool need_size_for_free() const override { ASSERT_NEVER_CALLED; }
|
||||
size_t consumed() const override { ASSERT_NEVER_CALLED; }
|
||||
size_t overhead(size_t) const override { ASSERT_NEVER_CALLED; }
|
||||
int add_range (addr_t, size_t ) override { ASSERT_NEVER_CALLED; }
|
||||
int remove_range(addr_t, size_t ) override { ASSERT_NEVER_CALLED; }
|
||||
void free(void *) override { ASSERT_NEVER_CALLED; }
|
||||
size_t avail() const override { ASSERT_NEVER_CALLED; }
|
||||
bool valid_addr(addr_t ) const override { ASSERT_NEVER_CALLED; }
|
||||
bool alloc(size_t, void **) override { ASSERT_NEVER_CALLED; }
|
||||
*out_addr = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
Alloc_return alloc_aligned(size_t, void **, int, addr_t, addr_t) override
|
||||
{ ASSERT_NEVER_CALLED; }
|
||||
|
||||
Alloc_return alloc_addr(size_t, addr_t) override
|
||||
{ ASSERT_NEVER_CALLED; }
|
||||
|
||||
} _dummy_alloc { };
|
||||
|
||||
/**
|
||||
* Allocator for pseudo physical memory
|
||||
*/
|
||||
struct Pseudo_ram_allocator : Range_allocator
|
||||
Alloc_return alloc_aligned(size_t, void **out_addr, int,
|
||||
addr_t, addr_t) override
|
||||
{
|
||||
bool alloc(size_t, void **out_addr) override
|
||||
{
|
||||
*out_addr = 0;
|
||||
return true;
|
||||
}
|
||||
*out_addr = 0;
|
||||
return Alloc_return::OK;
|
||||
}
|
||||
|
||||
Alloc_return alloc_aligned(size_t, void **out_addr, int,
|
||||
addr_t, addr_t) override
|
||||
{
|
||||
*out_addr = 0;
|
||||
return Alloc_return::OK;
|
||||
}
|
||||
Alloc_return alloc_addr(size_t, addr_t) override
|
||||
{
|
||||
return Alloc_return::OK;
|
||||
}
|
||||
|
||||
Alloc_return alloc_addr(size_t, addr_t) override
|
||||
{
|
||||
return Alloc_return::OK;
|
||||
}
|
||||
int add_range(addr_t, size_t) override { return 0; }
|
||||
int remove_range(addr_t, size_t) override { return 0; }
|
||||
void free(void *) override { }
|
||||
void free(void *, size_t) override { }
|
||||
size_t avail() const override { return ram_quota_from_env(); }
|
||||
bool valid_addr(addr_t) const override { return true; }
|
||||
size_t overhead(size_t) const override { return 0; }
|
||||
bool need_size_for_free() const override { return true; }
|
||||
|
||||
int add_range(addr_t, size_t) override { return 0; }
|
||||
int remove_range(addr_t, size_t) override { return 0; }
|
||||
void free(void *) override { }
|
||||
void free(void *, size_t) override { }
|
||||
size_t avail() const override { return ram_quota_from_env(); }
|
||||
bool valid_addr(addr_t) const override { return true; }
|
||||
size_t overhead(size_t) const override { return 0; }
|
||||
bool need_size_for_free() const override { return true; }
|
||||
} _ram_alloc { };
|
||||
|
||||
} _ram_alloc { };
|
||||
public:
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Platform();
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Platform();
|
||||
|
||||
|
||||
/********************************
|
||||
** Generic platform interface **
|
||||
********************************/
|
||||
/********************************
|
||||
** Generic platform interface **
|
||||
********************************/
|
||||
|
||||
Range_allocator &core_mem_alloc() override { return _core_mem_alloc; }
|
||||
Range_allocator &ram_alloc() override { return _ram_alloc; }
|
||||
Range_allocator &io_mem_alloc() override { return _dummy_alloc; }
|
||||
Range_allocator &io_port_alloc() override { return _dummy_alloc; }
|
||||
Range_allocator &irq_alloc() override { return _dummy_alloc; }
|
||||
Range_allocator ®ion_alloc() override { return _dummy_alloc; }
|
||||
addr_t vm_start() const override { return 0; }
|
||||
size_t vm_size() const override { return 0; }
|
||||
Rom_fs &rom_fs() override { return _dummy_rom_fs; }
|
||||
Range_allocator &core_mem_alloc() override { return _core_mem_alloc; }
|
||||
Range_allocator &ram_alloc() override { return _ram_alloc; }
|
||||
Range_allocator &io_mem_alloc() override { return _dummy_alloc; }
|
||||
Range_allocator &io_port_alloc() override { return _dummy_alloc; }
|
||||
Range_allocator &irq_alloc() override { return _dummy_alloc; }
|
||||
Range_allocator ®ion_alloc() override { return _dummy_alloc; }
|
||||
addr_t vm_start() const override { return 0; }
|
||||
size_t vm_size() const override { return 0; }
|
||||
Rom_fs &rom_fs() override { return _dummy_rom_fs; }
|
||||
|
||||
/*
|
||||
* On Linux, the maximum number of capabilities is primarily
|
||||
* constrained by the limited number of file descriptors within
|
||||
* core. Each dataspace and and each thread consumes one
|
||||
* descriptor. However, all capabilies managed by the same
|
||||
* entrypoint share the same file descriptor such that the fd
|
||||
* limit would be an overly pessimistic upper bound.
|
||||
*
|
||||
* Hence, we define the limit somewhat arbitrary on Linux and
|
||||
* accept that scenarios may break when reaching core's fd limit.
|
||||
*/
|
||||
size_t max_caps() const override { return 10000; }
|
||||
/*
|
||||
* On Linux, the maximum number of capabilities is primarily
|
||||
* constrained by the limited number of file descriptors within
|
||||
* core. Each dataspace and and each thread consumes one
|
||||
* descriptor. However, all capabilies managed by the same
|
||||
* entrypoint share the same file descriptor such that the fd
|
||||
* limit would be an overly pessimistic upper bound.
|
||||
*
|
||||
* Hence, we define the limit somewhat arbitrary on Linux and
|
||||
* accept that scenarios may break when reaching core's fd limit.
|
||||
*/
|
||||
size_t max_caps() const override { return 10000; }
|
||||
|
||||
void wait_for_exit() override;
|
||||
};
|
||||
}
|
||||
void wait_for_exit() override;
|
||||
};
|
||||
|
||||
#endif /* _CORE__INCLUDE__PLATFORM_H_ */
|
||||
|
@ -2,8 +2,6 @@
|
||||
* \brief Linux protection domain facility
|
||||
* \author Norman Feske
|
||||
* \date 2006-06-13
|
||||
*
|
||||
* Pretty dumb.
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -24,6 +22,7 @@ namespace Genode {
|
||||
struct Platform_thread;
|
||||
}
|
||||
|
||||
|
||||
struct Genode::Platform_pd
|
||||
{
|
||||
Platform_pd(Allocator &, char const *) { }
|
||||
|
@ -2,8 +2,6 @@
|
||||
* \brief Linux thread facility
|
||||
* \author Norman Feske
|
||||
* \date 2006-06-13
|
||||
*
|
||||
* Pretty dumb.
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -25,135 +23,133 @@
|
||||
/* core includes */
|
||||
#include <pager.h>
|
||||
|
||||
namespace Genode {
|
||||
namespace Genode { class Platform_thread; }
|
||||
|
||||
class Platform_thread;
|
||||
|
||||
/*
|
||||
* We hold all Platform_thread objects in a list in order to be able to
|
||||
* reflect SIGCHLD as exception signals. When a SIGCHILD occurs, we
|
||||
* determine the PID of the terminated child process via 'wait4'. We use
|
||||
* the list to find the 'Platform_thread' matching the TID, wherei, in
|
||||
* turn, we find the exception handler's 'Signal_context_capability'.
|
||||
*/
|
||||
/*
|
||||
* We hold all Platform_thread objects in a list in order to be able to
|
||||
* reflect SIGCHLD as exception signals. When a SIGCHILD occurs, we
|
||||
* determine the PID of the terminated child process via 'wait4'. We use
|
||||
* the list to find the 'Platform_thread' matching the TID, wherei, in
|
||||
* turn, we find the exception handler's 'Signal_context_capability'.
|
||||
*/
|
||||
|
||||
class Platform_thread : public List<Platform_thread>::Element
|
||||
{
|
||||
private:
|
||||
class Genode::Platform_thread : public List<Platform_thread>::Element
|
||||
{
|
||||
private:
|
||||
|
||||
struct Registry
|
||||
{
|
||||
Mutex _mutex { };
|
||||
List<Platform_thread> _list { };
|
||||
struct Registry
|
||||
{
|
||||
Mutex _mutex { };
|
||||
List<Platform_thread> _list { };
|
||||
|
||||
void insert(Platform_thread *thread);
|
||||
void remove(Platform_thread *thread);
|
||||
|
||||
/**
|
||||
* Trigger exception handler for 'Platform_thread' with matching PID.
|
||||
*/
|
||||
void submit_exception(unsigned long pid);
|
||||
};
|
||||
void insert(Platform_thread *thread);
|
||||
void remove(Platform_thread *thread);
|
||||
|
||||
/**
|
||||
* Return singleton instance of 'Platform_thread::Registry'
|
||||
* Trigger exception handler for 'Platform_thread' with matching PID.
|
||||
*/
|
||||
static Registry &_registry();
|
||||
void submit_exception(unsigned long pid);
|
||||
};
|
||||
|
||||
unsigned long _tid = -1;
|
||||
unsigned long _pid = -1;
|
||||
char _name[32] { };
|
||||
/**
|
||||
* Return singleton instance of 'Platform_thread::Registry'
|
||||
*/
|
||||
static Registry &_registry();
|
||||
|
||||
/*
|
||||
* Dummy pager object that is solely used for storing the
|
||||
* 'Signal_context_capability' for the thread's exception handler.
|
||||
*/
|
||||
Pager_object _pager { };
|
||||
unsigned long _tid = -1;
|
||||
unsigned long _pid = -1;
|
||||
char _name[32] { };
|
||||
|
||||
public:
|
||||
/*
|
||||
* Dummy pager object that is solely used for storing the
|
||||
* 'Signal_context_capability' for the thread's exception handler.
|
||||
*/
|
||||
Pager_object _pager { };
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Platform_thread(size_t, const char *name, unsigned priority,
|
||||
Affinity::Location, addr_t);
|
||||
public:
|
||||
|
||||
~Platform_thread();
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Platform_thread(size_t, const char *name, unsigned priority,
|
||||
Affinity::Location, addr_t);
|
||||
|
||||
/**
|
||||
* Pause this thread
|
||||
*/
|
||||
void pause();
|
||||
~Platform_thread();
|
||||
|
||||
/**
|
||||
* Enable/disable single stepping
|
||||
*/
|
||||
void single_step(bool) { }
|
||||
/**
|
||||
* Pause this thread
|
||||
*/
|
||||
void pause();
|
||||
|
||||
/**
|
||||
* Resume this thread
|
||||
*/
|
||||
void resume();
|
||||
/**
|
||||
* Enable/disable single stepping
|
||||
*/
|
||||
void single_step(bool) { }
|
||||
|
||||
/**
|
||||
* Dummy implementation of platform-thread interface
|
||||
*/
|
||||
Pager_object &pager() { return _pager; }
|
||||
void pager(Pager_object &) { }
|
||||
int start(void *, void *) { return 0; }
|
||||
/**
|
||||
* Resume this thread
|
||||
*/
|
||||
void resume();
|
||||
|
||||
Thread_state state()
|
||||
{
|
||||
warning("Not implemented");
|
||||
throw Cpu_thread::State_access_failed();
|
||||
}
|
||||
/**
|
||||
* Dummy implementation of platform-thread interface
|
||||
*/
|
||||
Pager_object &pager() { return _pager; }
|
||||
void pager(Pager_object &) { }
|
||||
int start(void *, void *) { return 0; }
|
||||
|
||||
void state(Thread_state)
|
||||
{
|
||||
warning("Not implemented");
|
||||
throw Cpu_thread::State_access_failed();
|
||||
}
|
||||
Thread_state state()
|
||||
{
|
||||
warning("Not implemented");
|
||||
throw Cpu_thread::State_access_failed();
|
||||
}
|
||||
|
||||
const char *name() { return _name; }
|
||||
void state(Thread_state)
|
||||
{
|
||||
warning("Not implemented");
|
||||
throw Cpu_thread::State_access_failed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the executing CPU for this thread
|
||||
*
|
||||
* SMP is currently not directly supported on Genode/Linux
|
||||
* (but indirectly by the Linux kernel).
|
||||
*/
|
||||
void affinity(Affinity::Location) { }
|
||||
const char *name() { return _name; }
|
||||
|
||||
/**
|
||||
* Request the affinity of this thread
|
||||
*/
|
||||
Affinity::Location affinity() const { return Affinity::Location(); }
|
||||
/**
|
||||
* Set the executing CPU for this thread
|
||||
*
|
||||
* SMP is currently not directly supported on Genode/Linux
|
||||
* (but indirectly by the Linux kernel).
|
||||
*/
|
||||
void affinity(Affinity::Location) { }
|
||||
|
||||
/**
|
||||
* Register process ID and thread ID of thread
|
||||
*/
|
||||
void thread_id(int pid, int tid) { _pid = pid, _tid = tid; }
|
||||
/**
|
||||
* Request the affinity of this thread
|
||||
*/
|
||||
Affinity::Location affinity() const { return Affinity::Location(); }
|
||||
|
||||
/**
|
||||
* Notify Genode::Signal handler about sigchld
|
||||
*/
|
||||
static void submit_exception(int pid)
|
||||
{
|
||||
_registry().submit_exception(pid);
|
||||
}
|
||||
/**
|
||||
* Register process ID and thread ID of thread
|
||||
*/
|
||||
void thread_id(int pid, int tid) { _pid = pid, _tid = tid; }
|
||||
|
||||
/**
|
||||
* Set CPU quota of the thread to 'quota'
|
||||
*/
|
||||
void quota(size_t const) { /* not supported*/ }
|
||||
/**
|
||||
* Notify Genode::Signal handler about sigchld
|
||||
*/
|
||||
static void submit_exception(int pid)
|
||||
{
|
||||
_registry().submit_exception(pid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return execution time consumed by the thread
|
||||
*/
|
||||
Trace::Execution_time execution_time() const { return { 0, 0 }; }
|
||||
/**
|
||||
* Set CPU quota of the thread to 'quota'
|
||||
*/
|
||||
void quota(size_t const) { /* not supported*/ }
|
||||
|
||||
unsigned long pager_object_badge() const { return 0; }
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Return execution time consumed by the thread
|
||||
*/
|
||||
Trace::Execution_time execution_time() const { return { 0, 0 }; }
|
||||
|
||||
unsigned long pager_object_badge() const { return 0; }
|
||||
};
|
||||
|
||||
#endif /* _CORE__INCLUDE__PLATFORM_THREAD_H_ */
|
||||
|
@ -2,8 +2,6 @@
|
||||
* \brief Core-specific instance of the region-map interface
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-07-17
|
||||
*
|
||||
* Dummies for Linux platform
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -75,8 +73,8 @@ struct Genode::Rm_client : Pager_object
|
||||
{
|
||||
Rm_client(Cpu_session_capability, Thread_capability,
|
||||
Region_map_component &, unsigned long,
|
||||
Affinity::Location, Cpu_session::Name const&,
|
||||
Session_label const&)
|
||||
Affinity::Location, Cpu_session::Name const &,
|
||||
Session_label const &)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
@ -39,10 +39,10 @@ using namespace Genode;
|
||||
*/
|
||||
struct Execve_args
|
||||
{
|
||||
char const *filename;
|
||||
char * const *argv;
|
||||
char * const *envp;
|
||||
Lx_sd const parent_sd;
|
||||
char const *filename;
|
||||
char * const *argv;
|
||||
char * const *envp;
|
||||
Lx_sd const parent_sd;
|
||||
|
||||
Execve_args(char const *filename,
|
||||
char * const *argv,
|
||||
|
@ -27,7 +27,6 @@
|
||||
/* Linux includes */
|
||||
#include <core_linux_syscalls.h>
|
||||
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
@ -88,7 +87,8 @@ static void sigchld_handler(int)
|
||||
|
||||
|
||||
Platform::Platform()
|
||||
: _core_mem_alloc(nullptr)
|
||||
:
|
||||
_core_mem_alloc(nullptr)
|
||||
{
|
||||
/* make 'mmap' behave deterministically */
|
||||
lx_disable_aslr();
|
||||
|
@ -38,7 +38,7 @@ Linux_dataspace::Filename Dataspace_component::_file_name(const char *args)
|
||||
Linux_dataspace::Filename fname;
|
||||
|
||||
if (label.last_element().length() > sizeof(fname.buf)) {
|
||||
Genode::error("file name too long: ", label.last_element());
|
||||
error("file name too long: ", label.last_element());
|
||||
throw Service_denied();
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ Linux_dataspace::Filename Dataspace_component::_file_name(const char *args)
|
||||
}
|
||||
|
||||
|
||||
Genode::size_t Dataspace_component::_file_size()
|
||||
size_t Dataspace_component::_file_size()
|
||||
{
|
||||
struct stat64 s;
|
||||
if (lx_stat(_fname.buf, &s) < 0) throw Service_denied();
|
||||
@ -62,17 +62,21 @@ Genode::size_t Dataspace_component::_file_size()
|
||||
|
||||
|
||||
Dataspace_component::Dataspace_component(const char *args)
|
||||
: _fname(_file_name(args)),
|
||||
_size(_file_size()),
|
||||
_addr(0),
|
||||
_cap(_fd_to_cap(lx_open(_fname.buf, O_RDONLY | LX_O_CLOEXEC, S_IRUSR | S_IXUSR))),
|
||||
_writable(false),
|
||||
_owner(0) { }
|
||||
:
|
||||
_fname(_file_name(args)),
|
||||
_size(_file_size()),
|
||||
_addr(0),
|
||||
_cap(_fd_to_cap(lx_open(_fname.buf, O_RDONLY | LX_O_CLOEXEC, S_IRUSR | S_IXUSR))),
|
||||
_writable(false),
|
||||
_owner(0)
|
||||
{ }
|
||||
|
||||
|
||||
Dataspace_component::Dataspace_component(size_t size, addr_t, addr_t phys_addr,
|
||||
Cache_attribute, bool, Dataspace_owner *_owner) :
|
||||
_size(size), _addr(phys_addr), _cap(), _writable(false), _owner(_owner)
|
||||
Cache_attribute, bool, Dataspace_owner *_owner)
|
||||
:
|
||||
_size(size), _addr(phys_addr), _cap(), _writable(false), _owner(_owner)
|
||||
{
|
||||
warning("Should only be used for IOMEM and not within Linux.");
|
||||
_fname.buf[0] = 0;
|
||||
warning("Should only be used for IOMEM and not within Linux.");
|
||||
_fname.buf[0] = 0;
|
||||
}
|
||||
|
@ -11,48 +11,56 @@
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/log.h>
|
||||
#include <linux_dataspace/client.h>
|
||||
#include <base/internal/page_size.h>
|
||||
|
||||
#include <core_linux_syscalls.h>
|
||||
|
||||
#include <io_mem_session_component.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/page_size.h>
|
||||
|
||||
/* core-local includes */
|
||||
#include <core_linux_syscalls.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
size_t Io_mem_session_component::get_arg_size(const char *)
|
||||
{
|
||||
warning(__func__, " not implemented");
|
||||
return 0;
|
||||
warning(__func__, " not implemented");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
addr_t Io_mem_session_component::get_arg_phys(const char *)
|
||||
{
|
||||
warning(__func__, " not implemented");
|
||||
return 0;
|
||||
warning(__func__, " not implemented");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Io_mem_session_component::Io_mem_session_component(Range_allocator &io_mem_alloc,
|
||||
Range_allocator &,
|
||||
Rpc_entrypoint &ds_ep,
|
||||
const char *args) :
|
||||
_io_mem_alloc(io_mem_alloc),
|
||||
_ds(0, 0, 0, UNCACHED, true, 0),
|
||||
_ds_ep(ds_ep),
|
||||
_ds_cap(Io_mem_dataspace_capability())
|
||||
const char *args)
|
||||
:
|
||||
_io_mem_alloc(io_mem_alloc),
|
||||
_ds(0, 0, 0, UNCACHED, true, 0),
|
||||
_ds_ep(ds_ep),
|
||||
_ds_cap(Io_mem_dataspace_capability())
|
||||
{
|
||||
warning("no io_mem support on Linux (args=\"", args, "\")"); }
|
||||
warning("no io_mem support on Linux (args=\"", args, "\")");
|
||||
}
|
||||
|
||||
|
||||
Cache_attribute Io_mem_session_component::get_arg_wc(const char *)
|
||||
{
|
||||
warning(__func__, " not implemented");
|
||||
return UNCACHED;
|
||||
warning(__func__, " not implemented");
|
||||
return UNCACHED;
|
||||
}
|
||||
|
||||
|
||||
Io_mem_dataspace_capability Io_mem_session_component::dataspace()
|
||||
{
|
||||
return Io_mem_dataspace_capability();
|
||||
return Io_mem_dataspace_capability();
|
||||
}
|
||||
|
@ -11,17 +11,18 @@
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#include <util/string.h>
|
||||
#include <util/arg_string.h>
|
||||
#include <root/root.h>
|
||||
#include <io_port_session_component.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
Genode::Io_port_session_component::Io_port_session_component(Genode::Range_allocator &io_port_alloc, const char *)
|
||||
: _io_port_alloc(io_port_alloc)
|
||||
|
||||
Io_port_session_component::Io_port_session_component(Range_allocator &io_port_alloc,
|
||||
const char *)
|
||||
:
|
||||
_io_port_alloc(io_port_alloc)
|
||||
{
|
||||
Genode::warning("IO PORTS are not supported on base linux");
|
||||
warning("I/O port access is not supported on base linux");
|
||||
}
|
||||
|
||||
Genode::Io_port_session_component::~Io_port_session_component()
|
||||
{}
|
||||
|
||||
Io_port_session_component::~Io_port_session_component() { }
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* \brief IRQ session implementation for base-linux
|
||||
* \brief IRQ session implementation for base-linux
|
||||
* \author Johannes Kliemann
|
||||
* \date 2018-03-14
|
||||
* \date 2018-03-14
|
||||
*
|
||||
*/
|
||||
|
||||
@ -13,68 +13,76 @@
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/log.h>
|
||||
#include <base/thread.h>
|
||||
|
||||
#include <irq_session_component.h>
|
||||
|
||||
/* core-local includes */
|
||||
#include <core_linux_syscalls.h>
|
||||
|
||||
Genode::Irq_session_component::Irq_session_component(Genode::Range_allocator &, const char *)
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
Irq_session_component::Irq_session_component(Range_allocator &, const char *)
|
||||
:
|
||||
_irq_number(0),
|
||||
_irq_object(_irq_number)
|
||||
_irq_number(0), _irq_object(_irq_number)
|
||||
{ }
|
||||
|
||||
Genode::Irq_session_component::~Irq_session_component()
|
||||
|
||||
Irq_session_component::~Irq_session_component()
|
||||
{
|
||||
warning(__func__, " not implemented");
|
||||
}
|
||||
|
||||
void Genode::Irq_session_component::ack_irq()
|
||||
{ }
|
||||
|
||||
void Genode::Irq_session_component::sigh(Genode::Signal_context_capability)
|
||||
{ }
|
||||
void Irq_session_component::ack_irq() { }
|
||||
|
||||
Genode::Irq_session::Info Genode::Irq_session_component::info()
|
||||
|
||||
void Irq_session_component::sigh(Signal_context_capability) { }
|
||||
|
||||
|
||||
Irq_session::Info Irq_session_component::info()
|
||||
{
|
||||
return { .type = Genode::Irq_session::Info::Type::INVALID, .address = 0, .value = 0 };
|
||||
return { .type = Irq_session::Info::Type::INVALID, .address = 0, .value = 0 };
|
||||
}
|
||||
|
||||
Genode::Irq_object::Irq_object(unsigned irq) :
|
||||
|
||||
Irq_object::Irq_object(unsigned irq)
|
||||
:
|
||||
Thread_deprecated<4096>("irq"),
|
||||
_sig_cap(Signal_context_capability()),
|
||||
_irq(irq),
|
||||
_fd(-1)
|
||||
_sig_cap(Signal_context_capability()), _irq(irq), _fd(-1)
|
||||
{
|
||||
Genode::warning(__func__, " not implemented");
|
||||
}
|
||||
|
||||
bool Genode::Irq_object::_associate()
|
||||
{
|
||||
Genode::warning(__func__, " not implemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
void Genode::Irq_object::entry()
|
||||
{
|
||||
Genode::warning(__func__, " not implemented");
|
||||
}
|
||||
|
||||
void Genode::Irq_object::ack_irq()
|
||||
{
|
||||
Genode::warning(__func__, " not implemented");
|
||||
}
|
||||
|
||||
void Genode::Irq_object::start()
|
||||
{
|
||||
Genode::warning(__func__, " not implemented");
|
||||
}
|
||||
|
||||
void Genode::Irq_object::sigh(Signal_context_capability)
|
||||
{
|
||||
Genode::warning(__func__, " not implemented");
|
||||
warning(__func__, " not implemented");
|
||||
}
|
||||
|
||||
|
||||
bool Irq_object::_associate()
|
||||
{
|
||||
warning(__func__, " not implemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Irq_object::entry()
|
||||
{
|
||||
warning(__func__, " not implemented");
|
||||
}
|
||||
|
||||
|
||||
void Irq_object::ack_irq()
|
||||
{
|
||||
warning(__func__, " not implemented");
|
||||
}
|
||||
|
||||
|
||||
void Irq_object::start()
|
||||
{
|
||||
warning(__func__, " not implemented");
|
||||
}
|
||||
|
||||
|
||||
void Irq_object::sigh(Signal_context_capability)
|
||||
{
|
||||
warning(__func__, " not implemented");
|
||||
}
|
||||
|
@ -16,22 +16,11 @@
|
||||
#include <base/service.h>
|
||||
|
||||
/* core includes */
|
||||
#include <core_env.h>
|
||||
#include <platform.h>
|
||||
#include <platform_services.h>
|
||||
#include <io_port_root.h>
|
||||
|
||||
#include <core_linux_syscalls.h>
|
||||
|
||||
/**
|
||||
* Add x86 specific ioport service
|
||||
*/
|
||||
|
||||
namespace Genode
|
||||
{
|
||||
void platform_add_local_services(Rpc_entrypoint &,
|
||||
Sliced_heap &,
|
||||
Registry<Service> &,
|
||||
Trace::Source_registry &)
|
||||
{ }
|
||||
}
|
||||
void Genode::platform_add_local_services(Rpc_entrypoint &,
|
||||
Sliced_heap &,
|
||||
Registry<Service> &,
|
||||
Trace::Source_registry &)
|
||||
{ }
|
||||
|
@ -61,16 +61,20 @@ Genode::size_t Dataspace_component::_file_size()
|
||||
|
||||
|
||||
Dataspace_component::Dataspace_component(const char *args)
|
||||
: _fname(_file_name(args)),
|
||||
_size(_file_size()),
|
||||
_addr(0),
|
||||
_cap(_fd_to_cap(lx_open(_fname.buf, O_RDONLY | LX_O_CLOEXEC, S_IRUSR | S_IXUSR))),
|
||||
_writable(false),
|
||||
_owner(0) { }
|
||||
:
|
||||
_fname(_file_name(args)),
|
||||
_size(_file_size()),
|
||||
_addr(0),
|
||||
_cap(_fd_to_cap(lx_open(_fname.buf, O_RDONLY | LX_O_CLOEXEC, S_IRUSR | S_IXUSR))),
|
||||
_writable(false),
|
||||
_owner(0)
|
||||
{ }
|
||||
|
||||
|
||||
Dataspace_component::Dataspace_component(size_t size, addr_t, addr_t phys_addr,
|
||||
Cache_attribute, bool writable, Dataspace_owner *_owner) :
|
||||
_size(size), _addr(phys_addr), _cap(), _writable(writable), _owner(_owner)
|
||||
Cache_attribute, bool writable, Dataspace_owner *_owner)
|
||||
:
|
||||
_size(size), _addr(phys_addr), _cap(), _writable(writable), _owner(_owner)
|
||||
{
|
||||
_fname.buf[0] = 0;
|
||||
}
|
||||
|
@ -11,17 +11,18 @@
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/log.h>
|
||||
#include <linux_dataspace/client.h>
|
||||
#include <base/internal/page_size.h>
|
||||
|
||||
#include <core_linux_syscalls.h>
|
||||
|
||||
#include <io_mem_session_component.h>
|
||||
|
||||
/* core-local includes */
|
||||
#include <core_linux_syscalls.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
size_t Io_mem_session_component::get_arg_size(const char *args)
|
||||
{
|
||||
size_t const size = Arg_string::find_arg(args, "size").ulong_value(0);
|
||||
@ -38,9 +39,10 @@ addr_t Io_mem_session_component::get_arg_phys(const char *args)
|
||||
return Arg_string::find_arg(args, "base").ulong_value(0);
|
||||
}
|
||||
|
||||
|
||||
Cache_attribute Io_mem_session_component::get_arg_wc(const char *args)
|
||||
{
|
||||
Arg a = Arg_string::find_arg("wc", args);
|
||||
Arg const a = Arg_string::find_arg("wc", args);
|
||||
if (a.valid() && a.bool_value(0)) {
|
||||
return WRITE_COMBINED;
|
||||
} else {
|
||||
@ -58,10 +60,10 @@ Io_mem_session_component::Io_mem_session_component(Range_allocator &io_mem_alloc
|
||||
_ds_ep(ds_ep),
|
||||
_ds_cap(Io_mem_dataspace_capability())
|
||||
{
|
||||
int _fd = -1;
|
||||
int _fd = lx_open("/dev/hwio", O_RDWR | O_SYNC);
|
||||
|
||||
_fd = lx_open("/dev/hwio", O_RDWR | O_SYNC);
|
||||
lx_ioctl_iomem(_fd, (unsigned long)get_arg_phys(args), get_arg_size(args));
|
||||
|
||||
if (_fd > 0) {
|
||||
_ds.fd(_fd);
|
||||
} else {
|
||||
@ -72,7 +74,8 @@ Io_mem_session_component::Io_mem_session_component(Range_allocator &io_mem_alloc
|
||||
_ds_cap = static_cap_cast<Io_mem_dataspace>(static_cap_cast<Dataspace>(_ds_ep.manage(&_ds)));
|
||||
}
|
||||
|
||||
|
||||
Io_mem_dataspace_capability Io_mem_session_component::dataspace()
|
||||
{
|
||||
return _ds_cap;
|
||||
return _ds_cap;
|
||||
}
|
||||
|
@ -11,19 +11,20 @@
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#include <util/string.h>
|
||||
#include <util/arg_string.h>
|
||||
#include <root/root.h>
|
||||
#include <io_port_session_component.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
Genode::Io_port_session_component::Io_port_session_component(Genode::Range_allocator &io_port_alloc, const char *args)
|
||||
: _io_port_alloc(io_port_alloc)
|
||||
|
||||
Io_port_session_component::Io_port_session_component(Range_allocator &io_port_alloc,
|
||||
const char *args)
|
||||
:
|
||||
_io_port_alloc(io_port_alloc)
|
||||
{
|
||||
/* parse for port properties */
|
||||
_base = Arg_string::find_arg(args, "io_port_base").ulong_value(0);
|
||||
_size = Arg_string::find_arg(args, "io_port_size").ulong_value(0);
|
||||
}
|
||||
|
||||
Genode::Io_port_session_component::~Io_port_session_component()
|
||||
{}
|
||||
Io_port_session_component::~Io_port_session_component() { }
|
||||
|
@ -1,8 +1,7 @@
|
||||
/*
|
||||
* \brief IRQ session implementation for base-linux
|
||||
* \brief IRQ session implementation for base-linux
|
||||
* \author Johannes Kliemann
|
||||
* \date 2018-03-14
|
||||
*
|
||||
* \date 2018-03-14
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -13,15 +12,19 @@
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/log.h>
|
||||
#include <base/thread.h>
|
||||
|
||||
/* core-local includes */
|
||||
#include <irq_session_component.h>
|
||||
#include <irq_object.h>
|
||||
|
||||
#include <core_linux_syscalls.h>
|
||||
|
||||
Genode::Irq_session_component::Irq_session_component(Genode::Range_allocator &, const char *args)
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
Irq_session_component::Irq_session_component(Range_allocator &, const char *args)
|
||||
:
|
||||
_irq_number(Arg_string::find_arg(args, "irq_number").long_value(-1)),
|
||||
_irq_object(_irq_number)
|
||||
@ -29,90 +32,93 @@ Genode::Irq_session_component::Irq_session_component(Genode::Range_allocator &,
|
||||
_irq_object.start();
|
||||
}
|
||||
|
||||
Genode::Irq_session_component::~Irq_session_component()
|
||||
|
||||
Irq_session_component::~Irq_session_component()
|
||||
{
|
||||
warning(__func__, " not implemented");
|
||||
}
|
||||
|
||||
void Genode::Irq_session_component::ack_irq()
|
||||
|
||||
void Irq_session_component::ack_irq()
|
||||
{
|
||||
_irq_object.ack_irq();
|
||||
}
|
||||
|
||||
void Genode::Irq_session_component::sigh(Genode::Signal_context_capability cap)
|
||||
|
||||
void Irq_session_component::sigh(Signal_context_capability cap)
|
||||
{
|
||||
_irq_object.sigh(cap);
|
||||
}
|
||||
|
||||
Genode::Irq_session::Info Genode::Irq_session_component::info()
|
||||
|
||||
Irq_session::Info Irq_session_component::info()
|
||||
{
|
||||
return { .type = Genode::Irq_session::Info::Type::INVALID, .address = 0, .value = 0 };
|
||||
return { .type = Irq_session::Info::Type::INVALID, .address = 0, .value = 0 };
|
||||
}
|
||||
|
||||
|
||||
Genode::Irq_object::Irq_object(unsigned irq) :
|
||||
Irq_object::Irq_object(unsigned irq)
|
||||
:
|
||||
Thread_deprecated<4096>("irq"),
|
||||
_sig_cap(Signal_context_capability()),
|
||||
_irq(irq),
|
||||
_fd(-1)
|
||||
_sig_cap(Signal_context_capability()), _irq(irq), _fd(-1)
|
||||
{ }
|
||||
|
||||
bool Genode::Irq_object::_associate()
|
||||
|
||||
bool Irq_object::_associate()
|
||||
{
|
||||
_fd = lx_open("/dev/hwio", O_RDWR | O_SYNC);
|
||||
|
||||
if (_fd < 0){
|
||||
Genode::error("failed to open /dev/hwio");
|
||||
error("failed to open /dev/hwio");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lx_ioctl_irq(_fd, _irq) < 0){
|
||||
Genode::error("failed to request irq");
|
||||
error("failed to request irq");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Genode::Irq_object::entry()
|
||||
|
||||
void Irq_object::entry()
|
||||
{
|
||||
if (!_associate()) {
|
||||
if (!_associate())
|
||||
error("failed to register IRQ ", _irq);
|
||||
}
|
||||
|
||||
_sync_bootup.wakeup();
|
||||
_sync_ack.block();
|
||||
|
||||
while (true) {
|
||||
|
||||
if (lx_read(_fd, 0, 0) < 0) {
|
||||
Genode::warning("failed to read on /dev/hwio");
|
||||
}
|
||||
if (lx_read(_fd, 0, 0) < 0)
|
||||
warning("failed to read on /dev/hwio");
|
||||
|
||||
if(!_sig_cap.valid()){
|
||||
if(!_sig_cap.valid())
|
||||
continue;
|
||||
}
|
||||
|
||||
Genode::Signal_transmitter(_sig_cap).submit(1);
|
||||
Signal_transmitter(_sig_cap).submit(1);
|
||||
|
||||
_sync_ack.block();
|
||||
}
|
||||
}
|
||||
|
||||
void Genode::Irq_object::ack_irq()
|
||||
|
||||
void Irq_object::ack_irq()
|
||||
{
|
||||
_sync_ack.wakeup();
|
||||
}
|
||||
|
||||
void Genode::Irq_object::start()
|
||||
|
||||
void Irq_object::start()
|
||||
{
|
||||
Genode::Thread::start();
|
||||
Thread::start();
|
||||
_sync_bootup.block();
|
||||
}
|
||||
|
||||
void Genode::Irq_object::sigh(Signal_context_capability cap)
|
||||
|
||||
void Irq_object::sigh(Signal_context_capability cap)
|
||||
{
|
||||
_sig_cap = cap;
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,25 +20,19 @@
|
||||
#include <platform.h>
|
||||
#include <platform_services.h>
|
||||
#include <io_port_root.h>
|
||||
|
||||
#include <core_linux_syscalls.h>
|
||||
|
||||
/**
|
||||
* Add x86 specific ioport service
|
||||
*/
|
||||
namespace Genode
|
||||
void Genode::platform_add_local_services(Rpc_entrypoint &,
|
||||
Sliced_heap &md,
|
||||
Registry<Service> ®,
|
||||
Trace::Source_registry &)
|
||||
{
|
||||
void platform_add_local_services(Rpc_entrypoint &,
|
||||
Sliced_heap &md,
|
||||
Registry<Service> ®,
|
||||
Trace::Source_registry &)
|
||||
{
|
||||
if (!lx_iopl(3)) {
|
||||
static Io_port_root io_port_root(*core_env().pd_session(),
|
||||
platform().io_port_alloc(), md);
|
||||
if (!lx_iopl(3)) {
|
||||
static Io_port_root io_port_root(*core_env().pd_session(),
|
||||
platform().io_port_alloc(), md);
|
||||
|
||||
static Core_service<Io_port_session_component>
|
||||
io_port_ls(reg, io_port_root);
|
||||
}
|
||||
}
|
||||
static Core_service<Io_port_session_component>
|
||||
|
||||
io_port_ls(reg, io_port_root);
|
||||
}
|
||||
}
|
||||
|
@ -92,18 +92,16 @@ struct Stack_area_ram_allocator : Genode::Ram_allocator
|
||||
/**
|
||||
* Return single instance of the stack-area RM and RAM session
|
||||
*/
|
||||
namespace Genode {
|
||||
|
||||
Region_map *env_stack_area_region_map;
|
||||
Ram_allocator *env_stack_area_ram_allocator;
|
||||
Genode::Region_map *Genode::env_stack_area_region_map;
|
||||
Genode::Ram_allocator *Genode::env_stack_area_ram_allocator;
|
||||
|
||||
void init_stack_area()
|
||||
{
|
||||
static Stack_area_region_map rm_inst;
|
||||
env_stack_area_region_map = &rm_inst;
|
||||
void Genode::init_stack_area()
|
||||
{
|
||||
static Stack_area_region_map rm_inst;
|
||||
env_stack_area_region_map = &rm_inst;
|
||||
|
||||
static Stack_area_ram_allocator ram_inst;
|
||||
env_stack_area_ram_allocator = &ram_inst;
|
||||
}
|
||||
static Stack_area_ram_allocator ram_inst;
|
||||
env_stack_area_ram_allocator = &ram_inst;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2011-05-22
|
||||
*
|
||||
* A typed capability is a capability tied to one specifiec RPC interface
|
||||
* A typed capability is a capability tied to one specifiec RPC interface.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <base/internal/expanding_parent_client.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Local_session;
|
||||
class Local_parent;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
namespace Genode { struct Native_thread; }
|
||||
|
||||
|
||||
class Genode::Native_thread
|
||||
{
|
||||
private:
|
||||
|
@ -37,8 +37,9 @@ class Genode::Region_map_mmap : public Region_map, public Dataspace
|
||||
private:
|
||||
|
||||
Region_registry _rmap { };
|
||||
bool const _sub_rm; /* false if region map is root */
|
||||
size_t const _size;
|
||||
|
||||
bool const _sub_rm; /* false if region map is root */
|
||||
size_t const _size;
|
||||
|
||||
/**
|
||||
* Base offset of the RM session
|
||||
|
@ -19,30 +19,30 @@
|
||||
#include <base/rpc_client.h>
|
||||
#include <util/string.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
struct Linux_dataspace_client : Rpc_client<Linux_dataspace>
|
||||
{
|
||||
explicit Linux_dataspace_client(Dataspace_capability ds)
|
||||
: Rpc_client<Linux_dataspace>(static_cap_cast<Linux_dataspace>(ds)) { }
|
||||
namespace Genode { struct Linux_dataspace_client; }
|
||||
|
||||
|
||||
/*********************************
|
||||
** Generic dataspace interface **
|
||||
*********************************/
|
||||
|
||||
size_t size() override { return call<Rpc_size>(); }
|
||||
addr_t phys_addr() override { return call<Rpc_phys_addr>(); }
|
||||
bool writable() override { return call<Rpc_writable>(); }
|
||||
struct Genode::Linux_dataspace_client : Rpc_client<Linux_dataspace>
|
||||
{
|
||||
explicit Linux_dataspace_client(Dataspace_capability ds)
|
||||
: Rpc_client<Linux_dataspace>(static_cap_cast<Linux_dataspace>(ds)) { }
|
||||
|
||||
|
||||
/****************************************
|
||||
** Linux-specific dataspace interface **
|
||||
****************************************/
|
||||
/*********************************
|
||||
** Generic dataspace interface **
|
||||
*********************************/
|
||||
|
||||
Filename fname() override { return call<Rpc_fname>(); }
|
||||
Untyped_capability fd() override { return call<Rpc_fd>(); }
|
||||
};
|
||||
}
|
||||
size_t size() override { return call<Rpc_size>(); }
|
||||
addr_t phys_addr() override { return call<Rpc_phys_addr>(); }
|
||||
bool writable() override { return call<Rpc_writable>(); }
|
||||
|
||||
|
||||
/****************************************
|
||||
** Linux-specific dataspace interface **
|
||||
****************************************/
|
||||
|
||||
Filename fname() override { return call<Rpc_fname>(); }
|
||||
Untyped_capability fd() override { return call<Rpc_fd>(); }
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__LINUX_DATASPACE__CLIENT_H_ */
|
||||
|
@ -19,37 +19,37 @@
|
||||
#include <base/ipc.h>
|
||||
#include <base/rpc.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
struct Linux_dataspace : Dataspace
|
||||
{
|
||||
enum { FNAME_LEN = 64 };
|
||||
struct Filename { char buf[FNAME_LEN]; };
|
||||
|
||||
virtual ~Linux_dataspace() { }
|
||||
|
||||
/**
|
||||
* Request name of file that represents the dataspace on Linux
|
||||
*
|
||||
* This function is used for calling execve on files passed as ROM
|
||||
* dataspaces.
|
||||
*/
|
||||
virtual Filename fname() = 0;
|
||||
|
||||
/**
|
||||
* Request file descriptor of the dataspace
|
||||
*/
|
||||
virtual Untyped_capability fd() = 0;
|
||||
|
||||
/*********************
|
||||
** RPC declaration **
|
||||
*********************/
|
||||
namespace Genode { struct Linux_dataspace; }
|
||||
|
||||
|
||||
GENODE_RPC(Rpc_fname, Filename, fname);
|
||||
GENODE_RPC(Rpc_fd, Untyped_capability, fd);
|
||||
GENODE_RPC_INTERFACE_INHERIT(Dataspace, Rpc_fname, Rpc_fd);
|
||||
};
|
||||
}
|
||||
struct Genode::Linux_dataspace : Dataspace
|
||||
{
|
||||
enum { FNAME_LEN = 64 };
|
||||
struct Filename { char buf[FNAME_LEN]; };
|
||||
|
||||
virtual ~Linux_dataspace() { }
|
||||
|
||||
/**
|
||||
* Request name of file that represents the dataspace on Linux
|
||||
*
|
||||
* This function is used for calling execve on files passed as ROM
|
||||
* dataspaces.
|
||||
*/
|
||||
virtual Filename fname() = 0;
|
||||
|
||||
/**
|
||||
* Request file descriptor of the dataspace
|
||||
*/
|
||||
virtual Untyped_capability fd() = 0;
|
||||
|
||||
/*********************
|
||||
** RPC declaration **
|
||||
*********************/
|
||||
|
||||
|
||||
GENODE_RPC(Rpc_fname, Filename, fname);
|
||||
GENODE_RPC(Rpc_fd, Untyped_capability, fd);
|
||||
GENODE_RPC_INTERFACE_INHERIT(Dataspace, Rpc_fname, Rpc_fd);
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__LINUX_DATASPACE__LINUX_DATASPACE_H_ */
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
namespace Genode { struct Linux_native_cpu_client; }
|
||||
|
||||
|
||||
struct Genode::Linux_native_cpu_client : Rpc_client<Linux_native_cpu>
|
||||
{
|
||||
explicit Linux_native_cpu_client(Capability<Native_cpu> cap)
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
namespace Genode { struct Linux_native_pd_client; }
|
||||
|
||||
|
||||
struct Genode::Linux_native_pd_client : Rpc_client<Linux_native_pd>
|
||||
{
|
||||
explicit Linux_native_pd_client(Capability<Native_pd> cap)
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <linux_syscalls.h>
|
||||
#include <base/internal/elf.h>
|
||||
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
|
@ -27,10 +27,15 @@ using namespace Genode;
|
||||
extern char _binary_seccomp_bpf_policy_bin_start[];
|
||||
extern char _binary_seccomp_bpf_policy_bin_end[];
|
||||
|
||||
struct bpf_program {
|
||||
Genode::uint16_t blk_cnt;
|
||||
Genode::uint64_t* blks;
|
||||
};
|
||||
|
||||
namespace Genode {
|
||||
|
||||
struct Bpf_program
|
||||
{
|
||||
uint16_t blk_cnt;
|
||||
uint64_t *blks;
|
||||
};
|
||||
}
|
||||
|
||||
void Genode::binary_ready_hook_for_platform()
|
||||
{
|
||||
@ -40,19 +45,22 @@ void Genode::binary_ready_hook_for_platform()
|
||||
}
|
||||
|
||||
for (char* i = _binary_seccomp_bpf_policy_bin_start;
|
||||
i < _binary_seccomp_bpf_policy_bin_end - sizeof(Genode::uint32_t); i++) {
|
||||
Genode::uint32_t* v = reinterpret_cast<Genode::uint32_t*>(i);
|
||||
i < _binary_seccomp_bpf_policy_bin_end - sizeof(uint32_t); i++) {
|
||||
|
||||
uint32_t *v = reinterpret_cast<uint32_t *>(i);
|
||||
if (*v == 0xCAFEAFFE) {
|
||||
*v = lx_getpid();
|
||||
}
|
||||
}
|
||||
|
||||
bpf_program program;
|
||||
program.blk_cnt = (_binary_seccomp_bpf_policy_bin_end -
|
||||
_binary_seccomp_bpf_policy_bin_start) /
|
||||
sizeof(Genode::uint64_t);
|
||||
program.blks = (Genode::uint64_t*)_binary_seccomp_bpf_policy_bin_start;
|
||||
Genode::uint64_t flags = SECCOMP_FILTER_FLAG_TSYNC;
|
||||
Bpf_program program {
|
||||
.blk_cnt = (uint16_t)((_binary_seccomp_bpf_policy_bin_end -
|
||||
_binary_seccomp_bpf_policy_bin_start) /
|
||||
sizeof(uint64_t)),
|
||||
.blks = (uint64_t *)_binary_seccomp_bpf_policy_bin_start
|
||||
};
|
||||
|
||||
uint64_t flags = SECCOMP_FILTER_FLAG_TSYNC;
|
||||
auto ret = lx_seccomp(SECCOMP_SET_MODE_FILTER, flags, &program);
|
||||
if (ret != 0) {
|
||||
error("SECCOMP_SET_MODE_FILTER failed ", ret);
|
||||
|
@ -19,8 +19,10 @@
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
class Capability_invalid : public Genode::Exception {};
|
||||
|
||||
|
||||
/**
|
||||
* Return pointer to locally implemented region map
|
||||
*
|
||||
|
@ -79,37 +79,45 @@ static Genode::Env *_env_ptr;
|
||||
|
||||
|
||||
namespace Genode {
|
||||
|
||||
extern void bootstrap_component();
|
||||
extern void call_global_static_constructors();
|
||||
|
||||
/*
|
||||
* This function is normally provided by the cxx library, which is not
|
||||
* used for lx_hybrid programs. For lx_hybrid programs, the exception
|
||||
* handling is initialized by the host system's regular startup code.
|
||||
*
|
||||
* However, we conveniently use this function to get hold of the
|
||||
* component's environment and initialize the default log output.
|
||||
*/
|
||||
void init_exception_handling(Env &env)
|
||||
{
|
||||
_env_ptr = &env;
|
||||
|
||||
init_log(env.parent());
|
||||
}
|
||||
struct Thread_meta_data_created;
|
||||
struct Thread_meta_data_adopted;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function is normally provided by the cxx library, which is not
|
||||
* used for lx_hybrid programs. For lx_hybrid programs, the exception
|
||||
* handling is initialized by the host system's regular startup code.
|
||||
*
|
||||
* However, we conveniently use this function to get hold of the
|
||||
* component's environment and initialize the default log output.
|
||||
*/
|
||||
void Genode::init_exception_handling(Env &env)
|
||||
{
|
||||
_env_ptr = &env;
|
||||
|
||||
init_log(env.parent());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Static constructors are handled by the Linux startup code - so implement
|
||||
* this as empty function.
|
||||
*/
|
||||
void Genode::call_global_static_constructors() { }
|
||||
|
||||
|
||||
Genode::size_t Component::stack_size() __attribute__((weak));
|
||||
Genode::size_t Component::stack_size()
|
||||
{
|
||||
return 16UL * 1024 * sizeof(Genode::addr_t);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Hybrid components are not allowed to implement legacy main(). This enables
|
||||
* us to hook in and bootstrap components as usual.
|
||||
@ -184,165 +192,164 @@ static pthread_key_t tls_key()
|
||||
}
|
||||
|
||||
|
||||
namespace Genode {
|
||||
/**
|
||||
* Meta data tied to the thread via the pthread TLS mechanism
|
||||
*/
|
||||
struct Genode::Native_thread::Meta_data
|
||||
{
|
||||
/**
|
||||
* Linux-specific thread meta data
|
||||
*
|
||||
* For non-hybrid programs, this information is located at the
|
||||
* 'Stack'. But the POSIX threads of hybrid programs have no 'Stack'
|
||||
* object. So we have to keep the meta data here.
|
||||
*/
|
||||
Native_thread native_thread { };
|
||||
|
||||
/**
|
||||
* Meta data tied to the thread via the pthread TLS mechanism
|
||||
* Filled out by 'thread_start' function in the stack of the new
|
||||
* thread
|
||||
*/
|
||||
struct Native_thread::Meta_data
|
||||
Thread &thread_base;
|
||||
|
||||
/**
|
||||
* POSIX thread handle
|
||||
*/
|
||||
pthread_t pt { };
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param thread associated 'Thread' object
|
||||
*/
|
||||
Meta_data(Thread *thread) : thread_base(*thread)
|
||||
{
|
||||
/**
|
||||
* Linux-specific thread meta data
|
||||
*
|
||||
* For non-hybrid programs, this information is located at the
|
||||
* 'Stack'. But the POSIX threads of hybrid programs have no 'Stack'
|
||||
* object. So we have to keep the meta data here.
|
||||
*/
|
||||
Native_thread native_thread { };
|
||||
native_thread.meta_data = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filled out by 'thread_start' function in the stack of the new
|
||||
* thread
|
||||
*/
|
||||
Thread &thread_base;
|
||||
virtual ~Meta_data() { }
|
||||
|
||||
/**
|
||||
* POSIX thread handle
|
||||
*/
|
||||
pthread_t pt { };
|
||||
/**
|
||||
* Used to block the constructor until the new thread has initialized
|
||||
* 'id'
|
||||
*/
|
||||
virtual void wait_for_construction() = 0;
|
||||
virtual void constructed() = 0;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param thread associated 'Thread' object
|
||||
*/
|
||||
Meta_data(Thread *thread) : thread_base(*thread)
|
||||
{
|
||||
native_thread.meta_data = this;
|
||||
}
|
||||
/**
|
||||
* Used to block the new thread until 'start' is called
|
||||
*/
|
||||
virtual void wait_for_start() = 0;
|
||||
virtual void started() = 0;
|
||||
|
||||
virtual ~Meta_data() { }
|
||||
/**
|
||||
* Used to block the 'join()' function until the 'entry()' is done
|
||||
*/
|
||||
virtual void wait_for_join() = 0;
|
||||
virtual void joined() = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Thread meta data for a thread created by Genode
|
||||
*/
|
||||
class Genode::Thread_meta_data_created : public Native_thread::Meta_data
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* Used to block the constructor until the new thread has initialized
|
||||
* 'id'
|
||||
*/
|
||||
virtual void wait_for_construction() = 0;
|
||||
virtual void constructed() = 0;
|
||||
Blockade _construct_lock { };
|
||||
|
||||
/**
|
||||
* Used to block the new thread until 'start' is called
|
||||
*/
|
||||
virtual void wait_for_start() = 0;
|
||||
virtual void started() = 0;
|
||||
Blockade _start_lock { };
|
||||
|
||||
/**
|
||||
* Used to block the 'join()' function until the 'entry()' is done
|
||||
*/
|
||||
virtual void wait_for_join() = 0;
|
||||
virtual void joined() = 0;
|
||||
};
|
||||
Blockade _join_lock { };
|
||||
|
||||
/**
|
||||
* Thread meta data for a thread created by Genode
|
||||
*/
|
||||
class Thread_meta_data_created : public Native_thread::Meta_data
|
||||
{
|
||||
private:
|
||||
public:
|
||||
|
||||
/**
|
||||
* Used to block the constructor until the new thread has initialized
|
||||
* 'id'
|
||||
*/
|
||||
Blockade _construct_lock { };
|
||||
Thread_meta_data_created(Thread *thread)
|
||||
: Native_thread::Meta_data(thread) { }
|
||||
|
||||
/**
|
||||
* Used to block the new thread until 'start' is called
|
||||
*/
|
||||
Blockade _start_lock { };
|
||||
void wait_for_construction() override
|
||||
{
|
||||
_construct_lock.block();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to block the 'join()' function until the 'entry()' is done
|
||||
*/
|
||||
Blockade _join_lock { };
|
||||
void constructed() override
|
||||
{
|
||||
_construct_lock.wakeup();
|
||||
}
|
||||
|
||||
public:
|
||||
void wait_for_start() override
|
||||
{
|
||||
_start_lock.block();
|
||||
}
|
||||
|
||||
Thread_meta_data_created(Thread *thread)
|
||||
: Native_thread::Meta_data(thread) { }
|
||||
void started() override
|
||||
{
|
||||
_start_lock.wakeup();
|
||||
}
|
||||
|
||||
void wait_for_construction() override
|
||||
{
|
||||
_construct_lock.block();
|
||||
}
|
||||
void wait_for_join() override
|
||||
{
|
||||
_join_lock.block();
|
||||
}
|
||||
|
||||
void constructed() override
|
||||
{
|
||||
_construct_lock.wakeup();
|
||||
}
|
||||
void joined() override
|
||||
{
|
||||
_join_lock.wakeup();
|
||||
}
|
||||
};
|
||||
|
||||
void wait_for_start() override
|
||||
{
|
||||
_start_lock.block();
|
||||
}
|
||||
|
||||
void started() override
|
||||
{
|
||||
_start_lock.wakeup();
|
||||
}
|
||||
/**
|
||||
* Thread meta data for an adopted thread
|
||||
*/
|
||||
class Genode::Thread_meta_data_adopted : public Native_thread::Meta_data
|
||||
{
|
||||
public:
|
||||
|
||||
void wait_for_join() override
|
||||
{
|
||||
_join_lock.block();
|
||||
}
|
||||
Thread_meta_data_adopted(Thread *thread)
|
||||
: Native_thread::Meta_data(thread) { }
|
||||
|
||||
void joined() override
|
||||
{
|
||||
_join_lock.wakeup();
|
||||
}
|
||||
};
|
||||
void wait_for_construction() override
|
||||
{
|
||||
error("wait_for_construction() called for an adopted thread");
|
||||
}
|
||||
|
||||
/**
|
||||
* Thread meta data for an adopted thread
|
||||
*/
|
||||
class Thread_meta_data_adopted : public Native_thread::Meta_data
|
||||
{
|
||||
public:
|
||||
void constructed() override
|
||||
{
|
||||
error("constructed() called for an adopted thread");
|
||||
}
|
||||
|
||||
Thread_meta_data_adopted(Thread *thread)
|
||||
: Native_thread::Meta_data(thread) { }
|
||||
void wait_for_start() override
|
||||
{
|
||||
error("wait_for_start() called for an adopted thread");
|
||||
}
|
||||
|
||||
void wait_for_construction() override
|
||||
{
|
||||
error("wait_for_construction() called for an adopted thread");
|
||||
}
|
||||
void started() override
|
||||
{
|
||||
error("started() called for an adopted thread");
|
||||
}
|
||||
|
||||
void constructed() override
|
||||
{
|
||||
error("constructed() called for an adopted thread");
|
||||
}
|
||||
void wait_for_join() override
|
||||
{
|
||||
error("wait_for_join() called for an adopted thread");
|
||||
}
|
||||
|
||||
void wait_for_start() override
|
||||
{
|
||||
error("wait_for_start() called for an adopted thread");
|
||||
}
|
||||
|
||||
void started() override
|
||||
{
|
||||
error("started() called for an adopted thread");
|
||||
}
|
||||
|
||||
void wait_for_join() override
|
||||
{
|
||||
error("wait_for_join() called for an adopted thread");
|
||||
}
|
||||
|
||||
void joined() override
|
||||
{
|
||||
error("joined() called for an adopted thread");
|
||||
}
|
||||
};
|
||||
}
|
||||
void joined() override
|
||||
{
|
||||
error("joined() called for an adopted thread");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static void adopt_thread(Native_thread::Meta_data *meta_data)
|
||||
|
@ -19,21 +19,21 @@
|
||||
#define STR(x) STR2(x)
|
||||
|
||||
#define INCBIN(name, file) \
|
||||
__asm__(".section .rodata\n" \
|
||||
".global incbin_" STR(name) "_start\n" \
|
||||
".type incbin_" STR(name) "_start, @object\n" \
|
||||
".balign 16\n" \
|
||||
"incbin_" STR(name) "_start:\n" \
|
||||
".incbin \"" file "\"\n" \
|
||||
\
|
||||
".global incbin_" STR(name) "_end\n" \
|
||||
".type incbin_" STR(name) "_end, @object\n" \
|
||||
".balign 1\n" \
|
||||
"incbin_" STR(name) "_end:\n" \
|
||||
".byte 0\n" \
|
||||
); \
|
||||
extern const __attribute__((aligned(16))) void* incbin_ ## name ## _start; \
|
||||
extern const void* incbin_ ## name ## _end; \
|
||||
__asm__(".section .rodata\n" \
|
||||
".global incbin_" STR(name) "_start\n" \
|
||||
".type incbin_" STR(name) "_start, @object\n" \
|
||||
".balign 16\n" \
|
||||
"incbin_" STR(name) "_start:\n" \
|
||||
".incbin \"" file "\"\n" \
|
||||
\
|
||||
".global incbin_" STR(name) "_end\n" \
|
||||
".type incbin_" STR(name) "_end, @object\n" \
|
||||
".balign 1\n" \
|
||||
"incbin_" STR(name) "_end:\n" \
|
||||
".byte 0\n" \
|
||||
); \
|
||||
extern const __attribute__((aligned(16))) void* incbin_ ## name ## _start; \
|
||||
extern const void* incbin_ ## name ## _end; \
|
||||
|
||||
INCBIN(seccomp_bpf_policy, "seccomp_bpf_policy.bin");
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
static Genode::Blockade *main_wait_lock()
|
||||
{
|
||||
static Genode::Blockade inst;
|
||||
|
Loading…
x
Reference in New Issue
Block a user