mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-19 23:53:55 +00:00
base-linux: coding style
This commit is contained in:
committed by
Christian Helmuth
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user