mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-10 21:01:49 +00:00
parent
cb36d96569
commit
6b94e65a95
@ -19,8 +19,7 @@
|
||||
#include <base/exception.h>
|
||||
#include <base/stdint.h>
|
||||
#include <base/signal.h>
|
||||
|
||||
#include <ram_session/ram_session.h>
|
||||
#include <base/ram_allocator.h>
|
||||
#include <block_session/rpc_object.h>
|
||||
|
||||
namespace Block {
|
||||
@ -64,15 +63,6 @@ class Block::Driver_session : public Driver_session_base,
|
||||
Genode::Dataspace_capability tx_ds,
|
||||
Genode::Rpc_entrypoint &ep)
|
||||
: Session_rpc_object(rm, tx_ds, ep) { }
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \deprecated
|
||||
*/
|
||||
Driver_session(Genode::Dataspace_capability tx_ds,
|
||||
Genode::Rpc_entrypoint &ep) __attribute__((deprecated))
|
||||
: Session_rpc_object(*Genode::env_deprecated()->rm_session(), tx_ds, ep) { }
|
||||
};
|
||||
|
||||
|
||||
@ -89,7 +79,7 @@ class Block::Driver : Genode::Interface
|
||||
Driver(Driver const &);
|
||||
Driver &operator = (Driver const &);
|
||||
|
||||
Genode::Ram_session &_ram_session;
|
||||
Genode::Ram_allocator &_ram;
|
||||
|
||||
Driver_session_base *_session = nullptr;
|
||||
|
||||
@ -104,8 +94,7 @@ class Block::Driver : Genode::Interface
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Driver(Genode::Ram_session &ram_session)
|
||||
: _ram_session(ram_session) { }
|
||||
Driver(Genode::Ram_allocator &ram) : _ram(ram) { }
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -215,7 +204,7 @@ class Block::Driver : Genode::Interface
|
||||
*/
|
||||
virtual Genode::Ram_dataspace_capability
|
||||
alloc_dma_buffer(Genode::size_t size) {
|
||||
return _ram_session.alloc(size); }
|
||||
return _ram.alloc(size); }
|
||||
|
||||
/**
|
||||
* Free buffer which is suitable for DMA.
|
||||
@ -223,7 +212,7 @@ class Block::Driver : Genode::Interface
|
||||
* Note: has to be overriden by DMA-capable devices
|
||||
*/
|
||||
virtual void free_dma_buffer(Genode::Ram_dataspace_capability c) {
|
||||
return _ram_session.free(c); }
|
||||
return _ram.free(c); }
|
||||
|
||||
/**
|
||||
* Synchronize with device.
|
||||
|
@ -49,6 +49,8 @@ class Cli_monitor::Child_base : public Genode::Child_policy
|
||||
|
||||
private:
|
||||
|
||||
Genode::Env &_env;
|
||||
|
||||
Ram &_ram;
|
||||
|
||||
Genode::Allocator &_alloc;
|
||||
@ -59,9 +61,6 @@ class Cli_monitor::Child_base : public Genode::Child_policy
|
||||
Genode::Pd_session_capability _ref_pd_cap;
|
||||
Genode::Pd_session &_ref_pd;
|
||||
|
||||
Genode::Ram_session_capability _ref_ram_cap;
|
||||
Genode::Ram_session &_ref_ram;
|
||||
|
||||
Cap_quota _cap_quota;
|
||||
|
||||
size_t _ram_quota;
|
||||
@ -101,6 +100,26 @@ class Cli_monitor::Child_base : public Genode::Child_policy
|
||||
|
||||
Genode::Child _child;
|
||||
|
||||
Genode::Service &_matching_service(Genode::Service::Name const &name,
|
||||
Genode::Session_label const &label)
|
||||
{
|
||||
Genode::Service *service = nullptr;
|
||||
|
||||
/* check for config file request */
|
||||
if ((service = _config_policy.resolve_session_request(name, label)))
|
||||
return *service;
|
||||
|
||||
/* populate session-local parent service registry on demand */
|
||||
_parent_services.for_each([&] (Parent_service &s) {
|
||||
if (s.name() == name)
|
||||
service = &s; });
|
||||
|
||||
if (service)
|
||||
return *service;
|
||||
|
||||
return *new (_alloc) Parent_service(_parent_services, _env, name);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -112,14 +131,13 @@ class Cli_monitor::Child_base : public Genode::Child_policy
|
||||
* \param alloc allocator used to fill parent-service registry
|
||||
* on demand
|
||||
*/
|
||||
Child_base(Ram &ram,
|
||||
Child_base(Genode::Env &env,
|
||||
Ram &ram,
|
||||
Genode::Allocator &alloc,
|
||||
Name const &label,
|
||||
Binary_name const &binary_name,
|
||||
Genode::Pd_session &ref_pd,
|
||||
Genode::Pd_session_capability ref_pd_cap,
|
||||
Genode::Ram_session &ref_ram,
|
||||
Genode::Ram_session_capability ref_ram_cap,
|
||||
Genode::Region_map &local_rm,
|
||||
Cap_quota cap_quota,
|
||||
Genode::size_t ram_quota,
|
||||
@ -127,13 +145,12 @@ class Cli_monitor::Child_base : public Genode::Child_policy
|
||||
Genode::Signal_context_capability yield_response_sig_cap,
|
||||
Genode::Signal_context_capability exit_sig_cap)
|
||||
:
|
||||
_ram(ram), _alloc(alloc),
|
||||
_env(env), _ram(ram), _alloc(alloc),
|
||||
_label(label), _binary_name(binary_name),
|
||||
_ref_pd_cap (ref_pd_cap), _ref_pd (ref_pd),
|
||||
_ref_ram_cap(ref_ram_cap), _ref_ram(ref_ram),
|
||||
_ref_pd_cap (ref_pd_cap), _ref_pd (ref_pd),
|
||||
_cap_quota(cap_quota), _ram_quota(ram_quota), _ram_limit(ram_limit),
|
||||
_entrypoint(&ref_pd, ENTRYPOINT_STACK_SIZE, _label.string(), false),
|
||||
_config_policy(local_rm, "config", _entrypoint, &ref_ram),
|
||||
_config_policy(local_rm, "config", _entrypoint, &_env.ram()),
|
||||
_yield_response_sigh_cap(yield_response_sig_cap),
|
||||
_exit_sig_cap(exit_sig_cap),
|
||||
_child(local_rm, _entrypoint, *this)
|
||||
@ -183,7 +200,7 @@ class Cli_monitor::Child_base : public Genode::Child_policy
|
||||
if (!amount)
|
||||
return;
|
||||
|
||||
_ram.withdraw_from(_child.ram_session_cap(), amount);
|
||||
_ram.withdraw_from(_child.pd_session_cap(), amount);
|
||||
_ram_quota -= amount;
|
||||
}
|
||||
|
||||
@ -194,12 +211,12 @@ class Cli_monitor::Child_base : public Genode::Child_policy
|
||||
*/
|
||||
void upgrade_ram_quota(size_t amount)
|
||||
{
|
||||
_ram.transfer_to(_child.ram_session_cap(), amount);
|
||||
_ram.transfer_to(_child.pd_session_cap(), amount);
|
||||
_ram_quota += amount;
|
||||
|
||||
/* wake up child if resource request is in flight */
|
||||
size_t const req = requested_ram_quota();
|
||||
if (req && _child.ram().avail_ram().value >= req) {
|
||||
if (req && _child.pd().avail_ram().value >= req) {
|
||||
_child.notify_resource_avail();
|
||||
|
||||
/* clear request state */
|
||||
@ -258,16 +275,16 @@ class Cli_monitor::Child_base : public Genode::Child_policy
|
||||
/**
|
||||
* Return RAM quota status of the child
|
||||
*
|
||||
* XXX should be a const method, but the 'Ram_session' accessors
|
||||
* XXX should be a const method, but the 'Pd_session' accessors
|
||||
* are not const
|
||||
*/
|
||||
Ram_status ram_status()
|
||||
{
|
||||
return Ram_status(_ram_quota,
|
||||
_ram_limit,
|
||||
_ram_quota - _child.ram().ram_quota().value,
|
||||
_child.ram().used_ram().value,
|
||||
_child.ram().avail_ram().value,
|
||||
_ram_quota - _child.pd().ram_quota().value,
|
||||
_child.pd().used_ram().value,
|
||||
_child.pd().avail_ram().value,
|
||||
requested_ram_quota());
|
||||
}
|
||||
|
||||
@ -294,24 +311,12 @@ class Cli_monitor::Child_base : public Genode::Child_policy
|
||||
_ref_pd.transfer_quota(cap, Genode::Ram_quota{_ram_quota});
|
||||
}
|
||||
|
||||
Genode::Service &resolve_session_request(Genode::Service::Name const &name,
|
||||
Genode::Session_state::Args const &args) override
|
||||
Route resolve_session_request(Genode::Service::Name const &name,
|
||||
Genode::Session_label const &label) override
|
||||
{
|
||||
Genode::Service *service = nullptr;
|
||||
|
||||
/* check for config file request */
|
||||
if ((service = _config_policy.resolve_session_request(name.string(), args.string())))
|
||||
return *service;
|
||||
|
||||
/* populate session-local parent service registry on demand */
|
||||
_parent_services.for_each([&] (Parent_service &s) {
|
||||
if (s.name() == name)
|
||||
service = &s; });
|
||||
|
||||
if (service)
|
||||
return *service;
|
||||
|
||||
return *new (_alloc) Parent_service(_parent_services, name);
|
||||
return Route { .service = _matching_service(name, label),
|
||||
.label = label,
|
||||
.diag = Genode::Session::Diag() };
|
||||
}
|
||||
|
||||
void yield_response()
|
||||
@ -319,8 +324,8 @@ class Cli_monitor::Child_base : public Genode::Child_policy
|
||||
if (_withdraw_on_yield_response) {
|
||||
enum { RESERVE = 4*1024*1024 };
|
||||
|
||||
size_t amount = _child.ram().avail_ram().value < RESERVE
|
||||
? 0 : _child.ram().avail_ram().value - RESERVE;
|
||||
size_t amount = _child.pd().avail_ram().value < RESERVE
|
||||
? 0 : _child.pd().avail_ram().value - RESERVE;
|
||||
|
||||
/* try to immediately withdraw freed-up resources */
|
||||
try { withdraw_ram_quota(amount); }
|
||||
|
@ -106,7 +106,7 @@ class Cli_monitor::Ram
|
||||
/**
|
||||
* \throw Transfer_quota_failed
|
||||
*/
|
||||
void withdraw_from(Genode::Ram_session_capability from, size_t amount)
|
||||
void withdraw_from(Genode::Pd_session_capability from, size_t amount)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
@ -121,7 +121,7 @@ class Cli_monitor::Ram
|
||||
/**
|
||||
* \throw Transfer_quota_failed
|
||||
*/
|
||||
void transfer_to(Genode::Ram_session_capability to, size_t amount)
|
||||
void transfer_to(Genode::Pd_session_capability to, size_t amount)
|
||||
{
|
||||
Genode::Lock::Guard guard(_lock);
|
||||
|
||||
|
@ -45,7 +45,7 @@ class Decorator::Window_stack : public Window_base::Draw_behind_fn
|
||||
{
|
||||
for (node = node.sub_node("window"); ; node = node.next()) {
|
||||
|
||||
if (node.has_type("window") && attribute(node, "id", 0UL) == id)
|
||||
if (node.has_type("window") && node.attribute_value("id", 0UL) == id)
|
||||
return node;
|
||||
|
||||
if (node.last()) break;
|
||||
|
@ -38,26 +38,13 @@ class Input::Session_component : public Genode::Rpc_object<Input::Session>
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param env Env containing local region map
|
||||
* \param ram Ram session at which to allocate session buffer
|
||||
* \param ram allocator for the session buffer
|
||||
*/
|
||||
Session_component(Genode::Env &env, Genode::Ram_session &ram)
|
||||
Session_component(Genode::Env &env, Genode::Ram_allocator &ram)
|
||||
:
|
||||
_ds(ram, env.rm(), Event_queue::QUEUE_SIZE*sizeof(Input::Event))
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \noapi
|
||||
* \deprecated
|
||||
*/
|
||||
Session_component() __attribute__((deprecated))
|
||||
: _ds(*Genode::env_deprecated()->ram_session(),
|
||||
*Genode::env_deprecated()->rm_session(),
|
||||
Event_queue::QUEUE_SIZE*sizeof(Input::Event))
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Return reference to event queue of the session
|
||||
*/
|
||||
@ -85,11 +72,6 @@ class Input::Session_component : public Genode::Rpc_object<Input::Session>
|
||||
|
||||
bool pending() const override { return !_event_queue.empty(); }
|
||||
|
||||
/*
|
||||
* \deprecated use 'pending' instead
|
||||
*/
|
||||
bool is_pending() const { return pending(); }
|
||||
|
||||
int flush() override
|
||||
{
|
||||
Input::Event *dst = _ds.local_addr<Input::Event>();
|
||||
|
@ -41,21 +41,18 @@ struct Mixer::Channel
|
||||
|
||||
Channel(Genode::Xml_node const &node)
|
||||
{
|
||||
Genode::String<8> tmp;
|
||||
try { node.attribute("type").value(&tmp); }
|
||||
catch (...) { throw Invalid_channel(); }
|
||||
typedef Genode::String<8> Type;
|
||||
Type const type_name = node.attribute_value("type", Type());
|
||||
|
||||
if (tmp == "input") type = INPUT;
|
||||
else if (tmp == "output") type = OUTPUT;
|
||||
else throw Invalid_channel();
|
||||
if (type_name == "input") type = INPUT;
|
||||
else if (type_name == "output") type = OUTPUT;
|
||||
else throw Invalid_channel();
|
||||
|
||||
try {
|
||||
node.attribute("label").value(&label);
|
||||
number = (Channel::Number) node.attribute_value<long>("number", 0);
|
||||
volume = node.attribute_value<long>("volume", 0);
|
||||
active = node.attribute_value<bool>("active", true);
|
||||
muted = node.attribute_value<bool>("muted", true);
|
||||
} catch (...) { throw Invalid_channel(); }
|
||||
label = node.attribute_value("label", Label());
|
||||
number = (Channel::Number) node.attribute_value("number", 0L);
|
||||
volume = node.attribute_value("volume", 0L);
|
||||
active = node.attribute_value("active", true);
|
||||
muted = node.attribute_value("muted", true);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -34,15 +34,15 @@ class Nic::Communication_buffers
|
||||
Nic::Packet_allocator _rx_packet_alloc;
|
||||
Genode::Attached_ram_dataspace _tx_ds, _rx_ds;
|
||||
|
||||
Communication_buffers(Genode::Allocator &rx_block_md_alloc,
|
||||
Genode::Ram_session &ram_session,
|
||||
Genode::Region_map ®ion_map,
|
||||
Genode::size_t tx_size,
|
||||
Genode::size_t rx_size)
|
||||
Communication_buffers(Genode::Allocator &rx_block_md_alloc,
|
||||
Genode::Ram_allocator &ram,
|
||||
Genode::Region_map ®ion_map,
|
||||
Genode::size_t tx_size,
|
||||
Genode::size_t rx_size)
|
||||
:
|
||||
_rx_packet_alloc(&rx_block_md_alloc),
|
||||
_tx_ds(ram_session, region_map, tx_size),
|
||||
_rx_ds(ram_session, region_map, rx_size)
|
||||
_tx_ds(ram, region_map, tx_size),
|
||||
_rx_ds(ram, region_map, rx_size)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/xml_node.h>
|
||||
#include <base/allocator.h>
|
||||
|
||||
namespace Genode { class Buffered_xml; }
|
||||
|
||||
@ -33,8 +34,13 @@ class Genode::Buffered_xml
|
||||
*/
|
||||
static char const *_init_ptr(Allocator &alloc, Xml_node node)
|
||||
{
|
||||
char *ptr = (char *)alloc.alloc(node.size());
|
||||
Genode::memcpy(ptr, node.addr(), node.size());
|
||||
char *ptr = nullptr;
|
||||
|
||||
node.with_raw_node([&] (char const *start, size_t length) {
|
||||
ptr = (char *)alloc.alloc(length);
|
||||
Genode::memcpy(ptr, start, length);
|
||||
});
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
@ -17,10 +17,10 @@
|
||||
#ifndef _INCLUDE__OS__CHILD_POLICY_DYNAMIC_ROM_H_
|
||||
#define _INCLUDE__OS__CHILD_POLICY_DYNAMIC_ROM_H_
|
||||
|
||||
#include <ram_session/ram_session.h>
|
||||
#include <rom_session/rom_session.h>
|
||||
#include <base/ram_allocator.h>
|
||||
#include <base/rpc_server.h>
|
||||
#include <base/attached_ram_dataspace.h>
|
||||
#include <rom_session/rom_session.h>
|
||||
|
||||
namespace Genode { class Child_policy_dynamic_rom_file; }
|
||||
|
||||
@ -36,8 +36,8 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object<Rom_session>,
|
||||
Child_policy_dynamic_rom_file(Child_policy_dynamic_rom_file const &);
|
||||
Child_policy_dynamic_rom_file &operator = (Child_policy_dynamic_rom_file const &);
|
||||
|
||||
Ram_session *_ram;
|
||||
Region_map &_rm;
|
||||
Ram_allocator *_ram;
|
||||
Region_map &_rm;
|
||||
|
||||
/*
|
||||
* The ROM module may be written and consumed by different threads,
|
||||
@ -85,7 +85,7 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object<Rom_session>,
|
||||
Child_policy_dynamic_rom_file(Region_map &rm,
|
||||
char const *module_name,
|
||||
Rpc_entrypoint &ep,
|
||||
Ram_session *ram)
|
||||
Ram_allocator *ram)
|
||||
:
|
||||
Service("ROM"),
|
||||
_ram(ram), _rm(rm),
|
||||
@ -96,29 +96,6 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object<Rom_session>,
|
||||
_module_name(module_name)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param ram RAM session used to allocate the backing store
|
||||
* for buffering ROM module data
|
||||
*
|
||||
* \deprecated
|
||||
*
|
||||
* If 'ram' is 0, the child policy is ineffective.
|
||||
*/
|
||||
Child_policy_dynamic_rom_file(char const *module_name,
|
||||
Rpc_entrypoint &ep,
|
||||
Ram_session *ram) __attribute__((deprecated))
|
||||
:
|
||||
Service("ROM"),
|
||||
_ram(ram), _rm(*env_deprecated()->rm_session()),
|
||||
_fg(*_ram, _rm, 0), _bg(*_ram, _rm, 0),
|
||||
_bg_has_pending_data(false),
|
||||
_ep(ep),
|
||||
_rom_session_cap(_ep.manage(this)),
|
||||
_module_name(module_name)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
@ -219,16 +196,15 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object<Rom_session>,
|
||||
** Policy interface **
|
||||
**********************/
|
||||
|
||||
Service *resolve_session_request(const char *service_name,
|
||||
const char *args)
|
||||
Service *resolve_session_request(Service::Name const &name,
|
||||
Session_label const &label)
|
||||
{
|
||||
if (!_ram) return 0;
|
||||
if (!_ram) return nullptr;
|
||||
|
||||
/* ignore session requests for non-ROM services */
|
||||
if (strcmp(service_name, "ROM")) return 0;
|
||||
if (name != "ROM") return nullptr;
|
||||
|
||||
/* drop out if request refers to another module name */
|
||||
Session_label const label = label_from_args(args);
|
||||
return _module_name == label.last_element() ? this : 0;
|
||||
}
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ class Genode::Dynamic_rom_session : public Rpc_object<Rom_session>
|
||||
Lock _lock { };
|
||||
|
||||
Rpc_entrypoint &_ep;
|
||||
Ram_session &_ram;
|
||||
Ram_allocator &_ram;
|
||||
Region_map &_rm;
|
||||
Signal_context_capability _sigh { };
|
||||
Content_producer &_content_producer;
|
||||
@ -135,7 +135,7 @@ class Genode::Dynamic_rom_session : public Rpc_object<Rom_session>
|
||||
* Constructor
|
||||
*
|
||||
* \param ep entrypoint serving the ROM session
|
||||
* \param ram RAM session used to allocate the backing
|
||||
* \param ram Allocator used to allocate the backing
|
||||
* store for the dataspace handed out to the
|
||||
* client
|
||||
* \param rm local region map ('env.rm()') required to
|
||||
@ -147,7 +147,7 @@ class Genode::Dynamic_rom_session : public Rpc_object<Rom_session>
|
||||
* The 'Dynamic_rom_session' associates/disassociates itself with 'ep'.
|
||||
*/
|
||||
Dynamic_rom_session(Rpc_entrypoint &ep,
|
||||
Ram_session &ram,
|
||||
Ram_allocator &ram,
|
||||
Region_map &rm,
|
||||
Content_producer &content_producer)
|
||||
:
|
||||
|
@ -78,6 +78,7 @@
|
||||
/* Genode includes */
|
||||
#include <base/env.h>
|
||||
#include <base/signal.h>
|
||||
#include <base/allocator.h>
|
||||
#include <dataspace/client.h>
|
||||
#include <util/string.h>
|
||||
#include <util/construct_at.h>
|
||||
|
@ -375,6 +375,13 @@ class Genode::Path : public Path_base
|
||||
Path(char const *path, char const *pwd = 0)
|
||||
: Path_base(_buf, sizeof(_buf), path, pwd) { }
|
||||
|
||||
/**
|
||||
* Constructor that implicitly imports a 'String'
|
||||
*/
|
||||
template <size_t N>
|
||||
Path(String<N> const &string)
|
||||
: Path_base(_buf, sizeof(_buf), string.string(), nullptr) { }
|
||||
|
||||
static constexpr size_t capacity() { return MAX_LEN; }
|
||||
|
||||
Path& operator=(char const *path)
|
||||
|
@ -64,7 +64,7 @@ class Genode::Session_requester
|
||||
* \param ram backing store for the ROM dataspace
|
||||
* \param rm local address space, needed to populate the dataspace
|
||||
*/
|
||||
Session_requester(Rpc_entrypoint &ep, Ram_session &ram, Region_map &rm)
|
||||
Session_requester(Rpc_entrypoint &ep, Ram_allocator &ram, Region_map &rm)
|
||||
:
|
||||
_session(ep, ram, rm, _content_producer)
|
||||
{ }
|
||||
|
@ -42,7 +42,7 @@ class Genode::Single_session_service
|
||||
{
|
||||
Client(Session_capability cap) : SESSION::Client(cap) { }
|
||||
Client(Region_map &rm, Session_capability cap) : SESSION::Client(rm, cap) { }
|
||||
Session_capability cap() const { return *this; }
|
||||
Session_capability cap() const { return this->rpc_cap(); }
|
||||
};
|
||||
|
||||
typedef Local_service<Client> Service;
|
||||
|
@ -42,8 +42,8 @@ class Genode::Static_parent_services : public Registry<Registered<Parent_service
|
||||
Registered<Parent_service> service;
|
||||
Service_recursive<TAIL...> tail;
|
||||
|
||||
Service_recursive(Registry<Registered<Parent_service> > ®istry)
|
||||
: service(registry, HEAD::service_name()), tail(registry) { }
|
||||
Service_recursive(Env &env, Registry<Registered<Parent_service> > ®istry)
|
||||
: service(registry, env, HEAD::service_name()), tail(env, registry) { }
|
||||
};
|
||||
|
||||
template <typename LAST>
|
||||
@ -51,11 +51,15 @@ class Genode::Static_parent_services : public Registry<Registered<Parent_service
|
||||
{
|
||||
Registered<Parent_service> service;
|
||||
|
||||
Service_recursive(Registry<Registered<Parent_service> > ®istry)
|
||||
: service(registry, LAST::service_name()) { }
|
||||
Service_recursive(Env &env, Registry<Registered<Parent_service> > ®istry)
|
||||
: service(registry, env, LAST::service_name()) { }
|
||||
};
|
||||
|
||||
Service_recursive<SESSION_TYPES...> _service_recursive { *this };
|
||||
Service_recursive<SESSION_TYPES...> _service_recursive;
|
||||
|
||||
public:
|
||||
|
||||
Static_parent_services(Env &env) : _service_recursive(env, *this) { }
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__OS__STATIC_PARENT_SERVICES_H_ */
|
||||
|
@ -136,8 +136,8 @@ struct Rom::Module : private Module_list::Element, Readable_module
|
||||
|
||||
Name _name;
|
||||
|
||||
Genode::Ram_session &_ram;
|
||||
Genode::Region_map &_rm;
|
||||
Genode::Ram_allocator &_ram;
|
||||
Genode::Region_map &_rm;
|
||||
|
||||
Read_policy const &_read_policy;
|
||||
Write_policy const &_write_policy;
|
||||
@ -174,8 +174,7 @@ struct Rom::Module : private Module_list::Element, Readable_module
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param ram RAM session from which to allocate the module's
|
||||
* backing store
|
||||
* \param ram allocator for the module's backing store
|
||||
* \param rm region map of the local address space, needed
|
||||
* to access the allocated backing store
|
||||
* \param name module name
|
||||
@ -184,11 +183,11 @@ struct Rom::Module : private Module_list::Element, Readable_module
|
||||
* \param write_policy policy hook function that is evaluated each
|
||||
* time when the module content is changed
|
||||
*/
|
||||
Module(Genode::Ram_session &ram,
|
||||
Genode::Region_map &rm,
|
||||
Name const &name,
|
||||
Read_policy const &read_policy,
|
||||
Write_policy const &write_policy)
|
||||
Module(Genode::Ram_allocator &ram,
|
||||
Genode::Region_map &rm,
|
||||
Name const &name,
|
||||
Read_policy const &read_policy,
|
||||
Write_policy const &write_policy)
|
||||
:
|
||||
_name(name), _ram(ram), _rm(rm),
|
||||
_read_policy(read_policy), _write_policy(write_policy)
|
||||
|
@ -35,8 +35,8 @@ class Rom::Session_component : public Genode::Rpc_object<Genode::Rom_session>,
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Ram_session &_ram;
|
||||
Genode::Region_map &_rm;
|
||||
Genode::Ram_allocator &_ram;
|
||||
Genode::Region_map &_rm;
|
||||
|
||||
Registry_for_reader &_registry;
|
||||
|
||||
@ -71,7 +71,7 @@ class Rom::Session_component : public Genode::Rpc_object<Genode::Rom_session>,
|
||||
|
||||
public:
|
||||
|
||||
Session_component(Genode::Ram_session &ram, Genode::Region_map &rm,
|
||||
Session_component(Genode::Ram_allocator &ram, Genode::Region_map &rm,
|
||||
Registry_for_reader ®istry,
|
||||
Genode::Session_label const &label)
|
||||
:
|
||||
@ -79,20 +79,6 @@ class Rom::Session_component : public Genode::Rpc_object<Genode::Rom_session>,
|
||||
_registry(registry), _label(label), _module(_init_module(label))
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \deprecated
|
||||
* \noapi
|
||||
*/
|
||||
Session_component(Registry_for_reader ®istry,
|
||||
Genode::Session_label const &label) __attribute__((deprecated))
|
||||
:
|
||||
_ram(*Genode::env_deprecated()->ram_session()),
|
||||
_rm(*Genode::env_deprecated()->rm_session()),
|
||||
_registry(registry), _label(label), _module(_init_module(label))
|
||||
{ }
|
||||
|
||||
~Session_component()
|
||||
{
|
||||
_registry.release(*this, _module);
|
||||
|
@ -11,15 +11,16 @@
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef _INCLUDE__SPEC__X86__PLATFORM_DEVICE__PLATFORM_DEVICE_H_
|
||||
#define _INCLUDE__SPEC__X86__PLATFORM_DEVICE__PLATFORM_DEVICE_H_
|
||||
|
||||
#include <base/rpc.h>
|
||||
#include <base/signal.h>
|
||||
#include <base/exception.h>
|
||||
#include <base/ram_allocator.h>
|
||||
#include <io_mem_session/io_mem_session.h>
|
||||
#include <io_port_session/capability.h>
|
||||
#include <irq_session/capability.h>
|
||||
#include <ram_session/ram_session.h>
|
||||
|
||||
/* os includes */
|
||||
#include <platform_device/device.h>
|
||||
@ -257,3 +258,5 @@ struct Platform::Device : Platform::Abstract_device
|
||||
Rpc_class_code, Rpc_resource, Rpc_config_read,
|
||||
Rpc_config_write, Rpc_irq, Rpc_io_port, Rpc_io_mem);
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__SPEC__X86__PLATFORM_DEVICE__PLATFORM_DEVICE_H_ */
|
||||
|
@ -11,13 +11,14 @@
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef _INCLUDE__SPEC__X86__PLATFORM_SESSION__PLATFORM_SESSION_H_
|
||||
#define _INCLUDE__SPEC__X86__PLATFORM_SESSION__PLATFORM_SESSION_H_
|
||||
|
||||
/* base */
|
||||
/* Genode includes */
|
||||
#include <session/session.h>
|
||||
#include <ram_session/ram_session.h>
|
||||
#include <base/ram_allocator.h>
|
||||
|
||||
/* os */
|
||||
/* os includes */
|
||||
#include <platform_device/platform_device.h>
|
||||
#include <platform_device/capability.h>
|
||||
|
||||
@ -107,3 +108,5 @@ struct Platform::Session : Genode::Session
|
||||
Rpc_release_device, Rpc_alloc_dma_buffer,
|
||||
Rpc_free_dma_buffer, Rpc_device);
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__SPEC__X86__PLATFORM_SESSION__PLATFORM_SESSION_H_ */
|
||||
|
@ -15,7 +15,6 @@
|
||||
#define _INCLUDE__USB__TYPES_H_
|
||||
|
||||
#include <base/stdint.h>
|
||||
#include <base/printf.h>
|
||||
|
||||
namespace Usb {
|
||||
struct Device_descriptor;
|
||||
@ -112,7 +111,7 @@ struct Usb::String
|
||||
void print()
|
||||
{
|
||||
char buffer[128];
|
||||
Genode::printf("%s\n", to_char(buffer, 128));
|
||||
Genode::log(Genode::Cstring(to_char(buffer, 128)));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -156,7 +156,8 @@ class Vfs::Dir_file_system : public File_system
|
||||
/**
|
||||
* Directory name
|
||||
*/
|
||||
char _name[MAX_NAME_LEN];
|
||||
typedef String<MAX_NAME_LEN> Name;
|
||||
Name const _name;
|
||||
|
||||
/**
|
||||
* Returns if path corresponds to top directory of file system
|
||||
@ -244,8 +245,8 @@ class Vfs::Dir_file_system : public File_system
|
||||
if (path[0] == '/')
|
||||
path++;
|
||||
|
||||
Genode::size_t const name_len = strlen(_name);
|
||||
if (strcmp(path, _name, name_len) != 0)
|
||||
Genode::size_t const name_len = strlen(_name.string());
|
||||
if (strcmp(path, _name.string(), name_len) != 0)
|
||||
return 0;
|
||||
path += name_len;
|
||||
|
||||
@ -367,16 +368,12 @@ class Vfs::Dir_file_system : public File_system
|
||||
Genode::Xml_node node,
|
||||
File_system_factory &fs_factory)
|
||||
:
|
||||
_env(env), _vfs_root(!node.has_type("dir"))
|
||||
_env(env),
|
||||
_vfs_root(!node.has_type("dir")),
|
||||
_name(_vfs_root ? Name() : node.attribute_value("name", Name()))
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
/* remember directory name */
|
||||
if (_vfs_root)
|
||||
_name[0] = 0;
|
||||
else
|
||||
node.attribute("name").value(_name, sizeof(_name));
|
||||
|
||||
for (unsigned i = 0; i < node.num_sub_nodes(); i++) {
|
||||
|
||||
Xml_node sub_node = node.sub_node(i);
|
||||
@ -398,10 +395,12 @@ class Vfs::Dir_file_system : public File_system
|
||||
|
||||
Genode::error("failed to create <", sub_node.type(), "> VFS node");
|
||||
try {
|
||||
String<64> value;
|
||||
for (unsigned i = 0; i < 16; ++i) {
|
||||
Xml_attribute attr = sub_node.attribute(i);
|
||||
attr.value(&value);
|
||||
|
||||
Xml_attribute const attr = sub_node.attribute(i);
|
||||
|
||||
String<64> value { };
|
||||
attr.value(value);
|
||||
|
||||
Genode::error("\t", attr.name(), "=\"", value, "\"");
|
||||
}
|
||||
@ -533,14 +532,6 @@ class Vfs::Dir_file_system : public File_system
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if specified path is a directory
|
||||
*
|
||||
* \noapi
|
||||
* \deprecated use 'directory instead
|
||||
*/
|
||||
bool is_directory(char const *path) { return directory(path); }
|
||||
|
||||
char const *leaf_path(char const *path) override
|
||||
{
|
||||
path = _sub_path(path);
|
||||
@ -911,7 +902,7 @@ class Vfs::Dir_file_system : public File_system
|
||||
file_offset index = vfs_handle->seek() / sizeof(Dirent);
|
||||
|
||||
if (index == 0) {
|
||||
strncpy(dirent->name, _name, sizeof(dirent->name));
|
||||
strncpy(dirent->name, _name.string(), sizeof(dirent->name));
|
||||
|
||||
dirent->type = DIRENT_TYPE_DIRECTORY;
|
||||
dirent->fileno = 1;
|
||||
|
@ -71,11 +71,6 @@ class Vfs::Global_file_system_factory : public Vfs::File_system_factory
|
||||
return "vfs_file_system_factory";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name of VFS node
|
||||
*/
|
||||
Node_name _node_name(Genode::Xml_node node);
|
||||
|
||||
/**
|
||||
* Return matching library name for a given vfs node name
|
||||
*/
|
||||
|
@ -33,8 +33,9 @@ class Vfs::Single_file_system : public File_system
|
||||
|
||||
Node_type const _node_type;
|
||||
|
||||
enum { FILENAME_MAX_LEN = 64 };
|
||||
char _filename[FILENAME_MAX_LEN];
|
||||
typedef String<64> Filename;
|
||||
|
||||
Filename _filename { };
|
||||
|
||||
protected:
|
||||
|
||||
@ -76,9 +77,10 @@ class Vfs::Single_file_system : public File_system
|
||||
Genode::Allocator &alloc,
|
||||
Node_type node_type,
|
||||
char const *filename)
|
||||
: Single_vfs_handle(ds, fs, alloc, 0),
|
||||
_node_type(node_type),
|
||||
_filename(filename)
|
||||
:
|
||||
Single_vfs_handle(ds, fs, alloc, 0),
|
||||
_node_type(node_type),
|
||||
_filename(filename)
|
||||
{ }
|
||||
|
||||
Read_result read(char *dst, file_size count,
|
||||
@ -126,21 +128,17 @@ class Vfs::Single_file_system : public File_system
|
||||
|
||||
bool _single_file(const char *path)
|
||||
{
|
||||
return (strlen(path) == (strlen(_filename) + 1)) &&
|
||||
(strcmp(&path[1], _filename) == 0);
|
||||
return (strlen(path) == (strlen(_filename.string()) + 1)) &&
|
||||
(strcmp(&path[1], _filename.string()) == 0);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Single_file_system(Node_type node_type, char const *type_name, Xml_node config)
|
||||
:
|
||||
_node_type(node_type)
|
||||
{
|
||||
strncpy(_filename, type_name, sizeof(_filename));
|
||||
|
||||
try { config.attribute("name").value(_filename, sizeof(_filename)); }
|
||||
catch (...) { }
|
||||
}
|
||||
_node_type(node_type),
|
||||
_filename(config.attribute_value("name", Filename(type_name)))
|
||||
{ }
|
||||
|
||||
|
||||
/*********************************
|
||||
@ -210,7 +208,7 @@ class Vfs::Single_file_system : public File_system
|
||||
try {
|
||||
*out_handle = new (alloc)
|
||||
Single_vfs_dir_handle(*this, *this, alloc,
|
||||
_node_type, _filename);
|
||||
_node_type, _filename.string());
|
||||
return OPENDIR_OK;
|
||||
}
|
||||
catch (Genode::Out_of_ram) { return OPENDIR_ERR_OUT_OF_RAM; }
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <base/lock.h>
|
||||
#include <base/env.h>
|
||||
#include <base/signal.h>
|
||||
#include <base/allocator.h>
|
||||
#include <dataspace/client.h>
|
||||
#include <os/path.h>
|
||||
|
||||
@ -31,7 +32,6 @@ namespace Vfs {
|
||||
using Genode::Ram_dataspace_capability;
|
||||
using Genode::Dataspace_capability;
|
||||
using Genode::Dataspace_client;
|
||||
using Genode::env;
|
||||
using Genode::min;
|
||||
using Genode::ascii_to;
|
||||
using Genode::strncpy;
|
||||
@ -47,6 +47,7 @@ namespace Vfs {
|
||||
using Genode::Signal_context_capability;
|
||||
using Genode::static_cap_cast;
|
||||
using Genode::Interface;
|
||||
using Genode::String;
|
||||
|
||||
typedef Genode::Path<MAX_PATH_LEN> Absolute_path;
|
||||
}
|
||||
|
@ -168,15 +168,9 @@ struct Test::Ping_pong : Test_base
|
||||
|
||||
_block->info(&_block_count, &_block_size, &_block_ops);
|
||||
|
||||
_start = _node.attribute_value("start", 0u);
|
||||
try {
|
||||
Genode::Number_of_bytes tmp;
|
||||
_node.attribute("size").value(&tmp);
|
||||
_size = tmp;
|
||||
|
||||
_node.attribute("length").value(&tmp);
|
||||
_length = tmp;
|
||||
} catch (...) { }
|
||||
_start = _node.attribute_value("start", 0u);
|
||||
_size = _node.attribute_value("size", Number_of_bytes());
|
||||
_length = _node.attribute_value("length", Number_of_bytes());
|
||||
|
||||
if (_size > sizeof(_scratch_buffer)) {
|
||||
Genode::error("request size exceeds scratch buffer size");
|
||||
|
@ -257,14 +257,8 @@ struct Test::Random : Test_base
|
||||
|
||||
_block->info(&_block_count, &_block_size, &_block_ops);
|
||||
|
||||
try {
|
||||
Genode::Number_of_bytes tmp;
|
||||
_node.attribute("size").value(&tmp);
|
||||
_size = tmp;
|
||||
|
||||
_node.attribute("length").value(&tmp);
|
||||
_length = tmp;
|
||||
} catch (...) { }
|
||||
_size = _node.attribute_value("size", Number_of_bytes());
|
||||
_length = _node.attribute_value("length", Number_of_bytes());
|
||||
|
||||
if (_size > sizeof(_scratch_buffer)) {
|
||||
Genode::error("request size exceeds scratch buffer size");
|
||||
|
@ -149,24 +149,20 @@ struct Test::Replay : Test_base
|
||||
|
||||
try {
|
||||
config.for_each_sub_node("request", [&](Xml_node request) {
|
||||
|
||||
typedef Genode::String<8> Type;
|
||||
|
||||
Block::sector_t const nr = request.attribute_value("lba", (Block::sector_t)0u);
|
||||
Genode::size_t const count = request.attribute_value("count", 0UL);
|
||||
Type const type = request.attribute_value("type", Type());
|
||||
|
||||
Block::Packet_descriptor::Opcode op;
|
||||
Block::sector_t nr { 0 };
|
||||
Genode::size_t count { 0 };
|
||||
if (type == "read") { op = Block::Packet_descriptor::READ; }
|
||||
else if (type == "write") { op = Block::Packet_descriptor::WRITE; }
|
||||
else { throw -1; }
|
||||
|
||||
try {
|
||||
request.attribute("lba").value(&nr);
|
||||
request.attribute("count").value(&count);
|
||||
|
||||
Genode::String<8> tmp;
|
||||
request.attribute("type").value(&tmp);
|
||||
if (tmp == "read") { op = Block::Packet_descriptor::READ; }
|
||||
else if (tmp == "write") { op = Block::Packet_descriptor::WRITE; }
|
||||
else { throw -1; }
|
||||
|
||||
Request *req = new (&alloc) Request(op, nr, count);
|
||||
requests.enqueue(req);
|
||||
++request_num;
|
||||
} catch (...) { return; }
|
||||
requests.enqueue(new (&alloc) Request(op, nr, count));
|
||||
++request_num;
|
||||
});
|
||||
} catch (...) {
|
||||
Genode::error("could not read request list");
|
||||
|
@ -196,15 +196,9 @@ struct Test::Sequential : Test_base
|
||||
|
||||
_synchronous = _node.attribute_value("synchronous", false);
|
||||
|
||||
_start = _node.attribute_value("start", 0u);
|
||||
try {
|
||||
Genode::Number_of_bytes tmp;
|
||||
_node.attribute("size").value(&tmp);
|
||||
_size = tmp;
|
||||
|
||||
_node.attribute("length").value(&tmp);
|
||||
_length = tmp;
|
||||
} catch (...) { }
|
||||
_start = _node.attribute_value("start", 0u);
|
||||
_size = _node.attribute_value("size", Genode::Number_of_bytes());
|
||||
_length = _node.attribute_value("length", Genode::Number_of_bytes());
|
||||
|
||||
if (_size > sizeof(_scratch_buffer)) {
|
||||
Genode::error("request size exceeds scratch buffer size");
|
||||
|
@ -31,14 +31,13 @@ struct Cli_monitor::Child : Child_base, private List<Child>::Element
|
||||
|
||||
Argument argument;
|
||||
|
||||
Child(Ram &ram,
|
||||
Child(Genode::Env &env,
|
||||
Ram &ram,
|
||||
Genode::Allocator &alloc,
|
||||
Name const &label,
|
||||
Binary_name const &binary,
|
||||
Genode::Pd_session &ref_pd,
|
||||
Genode::Pd_session_capability ref_pd_cap,
|
||||
Genode::Ram_session &ref_ram,
|
||||
Genode::Ram_session_capability ref_ram_cap,
|
||||
Genode::Region_map &local_rm,
|
||||
Cap_quota cap_quota,
|
||||
Genode::size_t ram_quota,
|
||||
@ -46,14 +45,13 @@ struct Cli_monitor::Child : Child_base, private List<Child>::Element
|
||||
Genode::Signal_context_capability yield_response_sig_cap,
|
||||
Genode::Signal_context_capability exit_sig_cap)
|
||||
:
|
||||
Child_base(ram,
|
||||
Child_base(env,
|
||||
ram,
|
||||
alloc,
|
||||
label,
|
||||
binary,
|
||||
ref_pd,
|
||||
ref_pd_cap,
|
||||
ref_ram,
|
||||
ref_ram_cap,
|
||||
local_rm,
|
||||
cap_quota,
|
||||
ram_quota,
|
||||
|
@ -15,7 +15,6 @@
|
||||
#define _LINE_EDITOR_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/printf.h>
|
||||
#include <terminal_session/connection.h>
|
||||
#include <util/string.h>
|
||||
#include <util/list.h>
|
||||
|
@ -142,7 +142,7 @@ struct Cli_monitor::Main
|
||||
.attribute_value("name", Genode::Number_of_bytes(0));
|
||||
}
|
||||
|
||||
Ram _ram { _env.ram(), _env.ram_session_cap(), _ram_preservation_from_config(),
|
||||
Ram _ram { _env.pd(), _env.pd_session_cap(), _ram_preservation_from_config(),
|
||||
_yield_broadcast_handler, _yield_response_handler };
|
||||
|
||||
Heap _heap { _env.ram(), _env.rm() };
|
||||
@ -162,9 +162,8 @@ struct Cli_monitor::Main
|
||||
/* initialize generic commands */
|
||||
Registered<Help_command> _help_command { _commands };
|
||||
Registered<Kill_command> _kill_command { _commands, _children, _heap };
|
||||
Registered<Start_command> _start_command { _commands, _ram, _heap,
|
||||
Registered<Start_command> _start_command { _commands, _env, _ram, _heap,
|
||||
_env.pd(), _env.pd_session_cap(),
|
||||
_env.ram(), _env.ram_session_cap(),
|
||||
_env.rm(), _children,
|
||||
_subsystem_config_registry,
|
||||
_yield_response_handler,
|
||||
|
@ -31,13 +31,12 @@ class Cli_monitor::Start_command : public Command
|
||||
typedef Genode::Signal_context_capability Signal_context_capability;
|
||||
typedef Genode::Dataspace_capability Dataspace_capability;
|
||||
|
||||
Genode::Env &_env;
|
||||
Ram &_ram;
|
||||
Genode::Allocator &_alloc;
|
||||
Child_registry &_children;
|
||||
Genode::Pd_session &_ref_pd;
|
||||
Genode::Pd_session_capability _ref_pd_cap;
|
||||
Genode::Ram_session &_ref_ram;
|
||||
Genode::Ram_session_capability _ref_ram_cap;
|
||||
Genode::Region_map &_local_rm;
|
||||
Subsystem_config_registry &_subsystem_configs;
|
||||
List<Argument> _arguments { };
|
||||
@ -58,10 +57,10 @@ class Cli_monitor::Start_command : public Command
|
||||
Xml_node rsc = subsystem_node.sub_node("resource");
|
||||
for (;; rsc = rsc.next("resource")) {
|
||||
if (rsc.attribute("name").has_value("RAM")) {
|
||||
rsc.attribute("quantum").value(&ram);
|
||||
rsc.attribute("quantum").value(ram);
|
||||
|
||||
if (rsc.has_attribute("limit"))
|
||||
rsc.attribute("limit").value(&ram_limit);
|
||||
rsc.attribute("limit").value(ram_limit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -85,11 +84,11 @@ class Cli_monitor::Start_command : public Command
|
||||
*
|
||||
* Use subsystem name by default, override with '<binary>' declaration.
|
||||
*/
|
||||
char binary_name[128];
|
||||
strncpy(binary_name, name, sizeof(binary_name));
|
||||
typedef Genode::String<128> Binary_name;
|
||||
Binary_name binary_name;
|
||||
try {
|
||||
Xml_node bin = subsystem_node.sub_node("binary");
|
||||
bin.attribute("name").value(binary_name, sizeof(binary_name));
|
||||
binary_name = bin.attribute_value("name", Binary_name());
|
||||
} catch (...) { }
|
||||
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
@ -109,15 +108,14 @@ class Cli_monitor::Start_command : public Command
|
||||
tprint_bytes(terminal, ram_limit);
|
||||
tprintf(terminal,"\n");
|
||||
}
|
||||
tprintf(terminal, " binary: %s\n", binary_name);
|
||||
tprintf(terminal, " binary: %s\n", binary_name.string());
|
||||
}
|
||||
|
||||
Child *child = 0;
|
||||
try {
|
||||
child = new (_alloc)
|
||||
Child(_ram, _alloc, label, binary_name,
|
||||
_ref_pd, _ref_pd_cap, _ref_ram,
|
||||
_ref_ram_cap, _local_rm,
|
||||
Child(_env, _ram, _alloc, label, binary_name,
|
||||
_ref_pd, _ref_pd_cap, _local_rm,
|
||||
Genode::Cap_quota{caps}, ram, ram_limit,
|
||||
_yield_response_sigh_cap, _exit_sig_cap);
|
||||
}
|
||||
@ -142,7 +140,9 @@ class Cli_monitor::Start_command : public Command
|
||||
/* configure child */
|
||||
try {
|
||||
Xml_node config_node = subsystem_node.sub_node("config");
|
||||
child->configure(config_node.addr(), config_node.size());
|
||||
config_node.with_raw_node([&] (char const *start, size_t length) {
|
||||
child->configure(start, length); });
|
||||
|
||||
if (verbose)
|
||||
tprintf(terminal, " config: inline\n");
|
||||
} catch (...) {
|
||||
@ -162,12 +162,11 @@ class Cli_monitor::Start_command : public Command
|
||||
|
||||
public:
|
||||
|
||||
Start_command(Ram &ram,
|
||||
Start_command(Genode::Env &env,
|
||||
Ram &ram,
|
||||
Genode::Allocator &alloc,
|
||||
Genode::Pd_session &ref_pd,
|
||||
Genode::Pd_session_capability ref_pd_cap,
|
||||
Genode::Ram_session &ref_ram,
|
||||
Genode::Ram_session_capability ref_ram_cap,
|
||||
Genode::Region_map &local_rm,
|
||||
Child_registry &children,
|
||||
Subsystem_config_registry &subsustem_configs,
|
||||
@ -175,10 +174,8 @@ class Cli_monitor::Start_command : public Command
|
||||
Signal_context_capability exit_sig_cap)
|
||||
:
|
||||
Command("start", "create new subsystem"),
|
||||
_ram(ram), _alloc(alloc), _children(children),
|
||||
_ref_pd(ref_pd), _ref_pd_cap(ref_pd_cap),
|
||||
_ref_ram(ref_ram), _ref_ram_cap(ref_ram_cap),
|
||||
_local_rm(local_rm),
|
||||
_env(env), _ram(ram), _alloc(alloc), _children(children),
|
||||
_ref_pd(ref_pd), _ref_pd_cap(ref_pd_cap), _local_rm(local_rm),
|
||||
_subsystem_configs(subsustem_configs),
|
||||
_yield_response_sigh_cap(yield_response_sigh_cap),
|
||||
_exit_sig_cap(exit_sig_cap)
|
||||
@ -194,26 +191,31 @@ class Cli_monitor::Start_command : public Command
|
||||
/* functor for processing a subsystem configuration */
|
||||
auto process_subsystem_config_fn = [&] (Genode::Xml_node node) {
|
||||
|
||||
char name[Parameter::Name::size()];
|
||||
try { node.attribute("name").value(name, sizeof(name)); }
|
||||
catch (Xml_node::Nonexistent_attribute) {
|
||||
PWRN("Missing name in '<subsystem>' configuration");
|
||||
if (!node.has_attribute("name")) {
|
||||
Genode::warning("Missing name in '<subsystem>' configuration");
|
||||
return;
|
||||
}
|
||||
|
||||
typedef Genode::String<64> Name;
|
||||
Name const name = node.attribute_value("name", Name());
|
||||
|
||||
char const *prefix = "config: ";
|
||||
size_t const prefix_len = strlen(prefix);
|
||||
|
||||
char help[Parameter::Short_help::size() + prefix_len];
|
||||
strncpy(help, prefix, ~0);
|
||||
try { node.attribute("help").value(help + prefix_len,
|
||||
sizeof(help) - prefix_len); }
|
||||
try {
|
||||
Genode::Xml_attribute const help_attr = node.attribute("help");
|
||||
help_attr.with_raw_value([&] (char const *start, size_t len) {
|
||||
strncpy(help + prefix_len, start,
|
||||
Genode::min(len, Parameter::Short_help::size())); });
|
||||
}
|
||||
catch (Xml_node::Nonexistent_attribute) {
|
||||
PWRN("Missing help in '<subsystem>' configuration");
|
||||
Genode::warning("Missing help in '<subsystem>' configuration");
|
||||
return;
|
||||
}
|
||||
|
||||
Argument arg(name, help);
|
||||
Argument arg(name.string(), help);
|
||||
fn(arg);
|
||||
};
|
||||
|
||||
|
@ -78,13 +78,13 @@ struct Dummy::Log_service
|
||||
|
||||
struct Root : Root_component<Session_component>
|
||||
{
|
||||
Ram_session &_ram;
|
||||
Pd_session &_pd;
|
||||
|
||||
bool const _verbose;
|
||||
|
||||
Root(Entrypoint &ep, Allocator &alloc, Ram_session &ram, bool verbose)
|
||||
Root(Entrypoint &ep, Allocator &alloc, Pd_session &pd, bool verbose)
|
||||
:
|
||||
Root_component(ep, alloc), _ram(ram), _verbose(verbose)
|
||||
Root_component(ep, alloc), _pd(pd), _verbose(verbose)
|
||||
{ }
|
||||
|
||||
Session_component *_create_session(const char *args, Affinity const &) override
|
||||
@ -97,12 +97,12 @@ struct Dummy::Log_service
|
||||
size_t const ram_quota =
|
||||
Arg_string::find_arg(args, "ram_quota").ulong_value(0);
|
||||
|
||||
if (_ram.avail_ram().value >= ram_quota)
|
||||
if (_pd.avail_ram().value >= ram_quota)
|
||||
log("received session quota upgrade");
|
||||
}
|
||||
};
|
||||
|
||||
Root _root { _env.ep(), _heap, _env.ram(), _verbose };
|
||||
Root _root { _env.ep(), _heap, _env.pd(), _verbose };
|
||||
|
||||
Log_service(Env &env, bool verbose) : _env(env), _verbose(verbose)
|
||||
{
|
||||
@ -162,9 +162,9 @@ struct Dummy::Ram_consumer
|
||||
|
||||
Ram_dataspace_capability _ds_cap { };
|
||||
|
||||
Ram_session &_ram;
|
||||
Ram_allocator &_ram;
|
||||
|
||||
Ram_consumer(Ram_session &ram) : _ram(ram) { }
|
||||
Ram_consumer(Ram_allocator &ram) : _ram(ram) { }
|
||||
|
||||
void release()
|
||||
{
|
||||
@ -286,7 +286,7 @@ struct Dummy::Main
|
||||
Signal_handler<Main> _config_handler { _env.ep(), *this, &Main::_handle_config };
|
||||
|
||||
Ram_consumer _ram_consumer { _env.ram() };
|
||||
Cap_consumer _cap_consumer { _env.ep() };
|
||||
Cap_consumer _cap_consumer { _env.ep() };
|
||||
|
||||
Constructible<Resource_yield_handler> _resource_yield_handler { };
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <pointer/shape_report.h>
|
||||
|
||||
/* local includes */
|
||||
#include "util.h"
|
||||
#include "rom_registry.h"
|
||||
#include "big_mouse.h"
|
||||
|
||||
@ -59,7 +58,7 @@ class Pointer::Main : public Rom::Reader
|
||||
{
|
||||
private:
|
||||
|
||||
typedef Pointer::String String;
|
||||
typedef Genode::String<128> String;
|
||||
|
||||
Genode::Env &_env;
|
||||
|
||||
@ -285,8 +284,6 @@ void Pointer::Main::_update_pointer()
|
||||
|
||||
void Pointer::Main::_handle_hover()
|
||||
{
|
||||
using Pointer::read_string_attribute;
|
||||
|
||||
_hover_ds->update();
|
||||
if (!_hover_ds->valid())
|
||||
return;
|
||||
@ -295,9 +292,8 @@ void Pointer::Main::_handle_hover()
|
||||
try {
|
||||
Genode::Xml_node node(_hover_ds->local_addr<char>());
|
||||
|
||||
Genode::Session_label hovered_label { read_string_attribute(node,
|
||||
"label",
|
||||
String()) };
|
||||
Genode::Session_label hovered_label {
|
||||
node.attribute_value("label", String()) };
|
||||
|
||||
hovered_label = hovered_label.prefix();
|
||||
|
||||
|
@ -26,7 +26,7 @@ struct Rom::Registry : Registry_for_reader, Registry_for_writer, Genode::Noncopy
|
||||
private:
|
||||
|
||||
Genode::Allocator &_md_alloc;
|
||||
Genode::Ram_session &_ram;
|
||||
Genode::Ram_allocator &_ram;
|
||||
Genode::Region_map &_rm;
|
||||
Reader &_reader;
|
||||
|
||||
@ -97,7 +97,7 @@ struct Rom::Registry : Registry_for_reader, Registry_for_writer, Genode::Noncopy
|
||||
public:
|
||||
|
||||
Registry(Genode::Allocator &md_alloc,
|
||||
Genode::Ram_session &ram, Genode::Region_map &rm,
|
||||
Genode::Ram_allocator &ram, Genode::Region_map &rm,
|
||||
Reader &reader)
|
||||
:
|
||||
_md_alloc(md_alloc), _ram(ram), _rm(rm), _reader(reader)
|
||||
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* \brief VirtualBox pointer utilities
|
||||
* \author Christian Helmuth
|
||||
* \date 2015-06-08
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _POINTER_UTIL_H_
|
||||
#define _POINTER_UTIL_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/xml_node.h>
|
||||
#include <util/string.h>
|
||||
|
||||
|
||||
namespace Pointer {
|
||||
typedef Genode::String<64> String;
|
||||
|
||||
inline String read_string_attribute(Genode::Xml_node const &node,
|
||||
char const *attr,
|
||||
String const &default_value);
|
||||
}
|
||||
|
||||
|
||||
Pointer::String Pointer::read_string_attribute(Genode::Xml_node const &node,
|
||||
char const *attr,
|
||||
String const &default_value)
|
||||
{
|
||||
try {
|
||||
char buf[String::capacity()];
|
||||
node.attribute(attr).value(buf, sizeof(buf));
|
||||
return String(Genode::Cstring(buf));
|
||||
} catch (...) { return default_value; }
|
||||
}
|
||||
|
||||
#endif /* _POINTER_UTIL_H_ */
|
@ -67,17 +67,17 @@ void Rom_logger::Main::_handle_update()
|
||||
/*
|
||||
* Query name of ROM module from config
|
||||
*/
|
||||
Rom_name rom_name;
|
||||
try {
|
||||
_config_rom.xml().attribute("rom").value(&rom_name);
|
||||
} catch (...) {
|
||||
Genode::Xml_node const config = _config_rom.xml();
|
||||
|
||||
if (!config.has_attribute("rom")) {
|
||||
Genode::warning("could not determine ROM name from config");
|
||||
return;
|
||||
}
|
||||
|
||||
Rom_name const rom_name = config.attribute_value("rom", Rom_name());
|
||||
|
||||
typedef Genode::String<8> Format_string;
|
||||
Format_string format =
|
||||
_config_rom.xml().attribute_value("format", Format_string("text"));
|
||||
Format_string const format = config.attribute_value("format", Format_string("text"));
|
||||
|
||||
/*
|
||||
* If ROM name changed, reconstruct '_rom_ds'
|
||||
|
@ -53,7 +53,8 @@ struct Rom_reporter::Rom_module
|
||||
_reporter->enabled(true);
|
||||
}
|
||||
|
||||
_reporter->report(xml.addr(), content_size);
|
||||
xml.with_raw_node([&] (char const *start, size_t length) {
|
||||
_reporter->report(start, length); });
|
||||
}
|
||||
|
||||
Rom_module(Env &env, Label const &label) : _env(env), _label(label)
|
||||
|
@ -42,7 +42,7 @@ struct Sequence::Child : Genode::Child_policy
|
||||
{
|
||||
Binary_name name;
|
||||
try {
|
||||
_start_node.sub_node("binary").attribute("name").value(&name);
|
||||
_start_node.sub_node("binary").attribute("name").value(name);
|
||||
return name != "" ? name : _name;
|
||||
}
|
||||
catch (...) { return _name; }
|
||||
@ -85,7 +85,8 @@ struct Sequence::Child : Genode::Child_policy
|
||||
{
|
||||
if (_have_config) {
|
||||
Xml_node config_node = start_node.sub_node("config");
|
||||
_config_policy.load(config_node.addr(), config_node.size());
|
||||
config_node.with_raw_node([&] (char const *start, size_t length) {
|
||||
_config_policy.load(start, length); });
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,17 +109,25 @@ struct Sequence::Child : Genode::Child_policy
|
||||
* Provide a "config" ROM if configured to do so,
|
||||
* otherwise forward directly to the parent.
|
||||
*/
|
||||
Service &resolve_session_request(Service::Name const &name,
|
||||
Session_state::Args const &args)
|
||||
Route resolve_session_request(Service::Name const &name,
|
||||
Session_label const &label) override
|
||||
{
|
||||
auto route = [&] (Service &service) {
|
||||
return Route { .service = service,
|
||||
.label = label,
|
||||
.diag = Session::Diag() }; };
|
||||
|
||||
if (_have_config) {
|
||||
Service *s = _config_policy.resolve_session_request(
|
||||
name.string(), args.string());
|
||||
Service *s =
|
||||
_config_policy.resolve_session_request(name, label);
|
||||
if (s)
|
||||
return *s;
|
||||
return route(*s);
|
||||
}
|
||||
|
||||
return *new (_services_heap) Parent_service(_parent_services, _env, name);
|
||||
Service &service = *new (_services_heap)
|
||||
Parent_service(_parent_services, _env, name);
|
||||
|
||||
return route(service);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -186,7 +186,8 @@ class Usb_filter::Device_registry
|
||||
/* copy other nodes */
|
||||
drv_config.for_each_sub_node([&] (Xml_node &node) {
|
||||
if (!node.has_type("raw")) {
|
||||
xml.append(node.addr(), node.size());
|
||||
node.with_raw_node([&] (char const *start, size_t length) {
|
||||
xml.append(start, length); });
|
||||
return;
|
||||
}
|
||||
});
|
||||
@ -401,7 +402,7 @@ class Usb_filter::Device_registry
|
||||
config.for_each_sub_node("device", add_new_entry);
|
||||
|
||||
try {
|
||||
config.sub_node("client").attribute("label").value(&_client_label);
|
||||
config.sub_node("client").attribute("label").value(_client_label);
|
||||
} catch (...) {
|
||||
error("could not update client label");
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/env.h>
|
||||
#include <base/allocator.h>
|
||||
|
||||
|
||||
namespace Acpi
|
||||
|
@ -120,7 +120,7 @@ struct Ahci
|
||||
log("64-bit support: ", hba.supports_64bit() ? "yes" : "no");
|
||||
}
|
||||
|
||||
void scan_ports(Genode::Region_map &rm, Genode::Ram_session &ram)
|
||||
void scan_ports(Genode::Region_map &rm, Genode::Ram_allocator &ram)
|
||||
{
|
||||
log("number of ports: ", hba.port_count(), " pi: ",
|
||||
Hex(hba.read<Hba::Pi>()));
|
||||
|
@ -823,13 +823,13 @@ struct Port_driver : Port, Block::Driver
|
||||
Ahci_root &root;
|
||||
unsigned &sem;
|
||||
|
||||
Port_driver(Genode::Ram_session &ram,
|
||||
Ahci_root &root,
|
||||
unsigned &sem,
|
||||
Genode::Region_map &rm,
|
||||
Hba &hba,
|
||||
Platform::Hba &platform_hba,
|
||||
unsigned number)
|
||||
Port_driver(Genode::Ram_allocator &ram,
|
||||
Ahci_root &root,
|
||||
unsigned &sem,
|
||||
Genode::Region_map &rm,
|
||||
Hba &hba,
|
||||
Platform::Hba &platform_hba,
|
||||
unsigned number)
|
||||
: Port(rm, hba, platform_hba, number), Block::Driver(ram), root(root),
|
||||
sem(sem) { sem++; }
|
||||
|
||||
|
@ -191,14 +191,14 @@ struct Ata_driver : Port_driver
|
||||
|
||||
Signal_context_capability device_identified;
|
||||
|
||||
Ata_driver(Genode::Allocator &alloc,
|
||||
Genode::Ram_session &ram,
|
||||
Ahci_root &root,
|
||||
unsigned &sem,
|
||||
Genode::Region_map &rm,
|
||||
Hba &hba,
|
||||
Platform::Hba &platform_hba,
|
||||
unsigned number,
|
||||
Ata_driver(Genode::Allocator &alloc,
|
||||
Genode::Ram_allocator &ram,
|
||||
Ahci_root &root,
|
||||
unsigned &sem,
|
||||
Genode::Region_map &rm,
|
||||
Hba &hba,
|
||||
Platform::Hba &platform_hba,
|
||||
unsigned number,
|
||||
Genode::Signal_context_capability device_identified)
|
||||
: Port_driver(ram, root, sem, rm, hba, platform_hba, number),
|
||||
alloc(alloc), device_identified(device_identified)
|
||||
|
@ -24,13 +24,13 @@ struct Atapi_driver : Port_driver
|
||||
unsigned sense_tries = 0;
|
||||
Block::Packet_descriptor pending { };
|
||||
|
||||
Atapi_driver(Genode::Ram_session &ram,
|
||||
Ahci_root &root,
|
||||
unsigned &sem,
|
||||
Genode::Region_map &rm,
|
||||
Hba &hba,
|
||||
Platform::Hba &platform_hba,
|
||||
unsigned number)
|
||||
Atapi_driver(Genode::Ram_allocator &ram,
|
||||
Ahci_root &root,
|
||||
unsigned &sem,
|
||||
Genode::Region_map &rm,
|
||||
Hba &hba,
|
||||
Platform::Hba &platform_hba,
|
||||
unsigned number)
|
||||
: Port_driver(ram, root, sem, rm, hba, platform_hba, number)
|
||||
{
|
||||
Port::init();
|
||||
|
@ -27,11 +27,11 @@ Session_component::Session_component(Genode::Env &env,
|
||||
try {
|
||||
Genode::Xml_node fb = pinfo.sub_node("boot").sub_node("framebuffer");
|
||||
|
||||
fb.attribute("phys").value(&_core_fb.addr);
|
||||
fb.attribute("width").value(&_core_fb.width);
|
||||
fb.attribute("height").value(&_core_fb.height);
|
||||
fb.attribute("bpp").value(&_core_fb.bpp);
|
||||
fb.attribute("pitch").value(&_core_fb.pitch);
|
||||
fb.attribute("phys").value(_core_fb.addr);
|
||||
fb.attribute("width").value(_core_fb.width);
|
||||
fb.attribute("height").value(_core_fb.height);
|
||||
fb.attribute("bpp").value(_core_fb.bpp);
|
||||
fb.attribute("pitch").value(_core_fb.pitch);
|
||||
fb_boot_type = fb.attribute_value("type", 0U);
|
||||
} catch (...) {
|
||||
Genode::error("No boot framebuffer information available.");
|
||||
|
@ -15,11 +15,10 @@
|
||||
#define _TYPES_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <ram_session/ram_session.h>
|
||||
#include <base/ram_allocator.h>
|
||||
|
||||
namespace Igd {
|
||||
|
||||
using Ram_dataspace_capability = Genode::Ram_dataspace_capability;
|
||||
using Ram = Genode::Ram_dataspace_capability;
|
||||
|
||||
using uint8_t = Genode::uint8_t;
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/interface.h>
|
||||
#include <ram_session/ram_session.h>
|
||||
#include <base/ram_allocator.h>
|
||||
|
||||
namespace Utils {
|
||||
|
||||
|
@ -75,7 +75,7 @@ class Platform::Device_pd
|
||||
enum { UPGRADE_CAP_QUOTA = 2 };
|
||||
Genode::Cap_quota const caps { UPGRADE_CAP_QUOTA };
|
||||
_cap_guard.withdraw(caps);
|
||||
_env.pd().transfer_quota(_pd, caps);
|
||||
_env.pd().transfer_quota(_pd.rpc_cap(), caps);
|
||||
}
|
||||
);
|
||||
},
|
||||
@ -83,7 +83,7 @@ class Platform::Device_pd
|
||||
enum { UPGRADE_RAM_QUOTA = 4096 };
|
||||
Genode::Ram_quota const ram { UPGRADE_RAM_QUOTA };
|
||||
_ram_guard.withdraw(ram);
|
||||
_env.pd().transfer_quota(_pd, ram);
|
||||
_env.pd().transfer_quota(_pd.rpc_cap(), ram);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -11,9 +11,11 @@
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef _X86__IRQ_H_
|
||||
#define _X86__IRQ_H_
|
||||
|
||||
#include <base/rpc_server.h>
|
||||
#include <base/allocator.h>
|
||||
#include <util/list.h>
|
||||
#include <irq_session/connection.h>
|
||||
|
||||
@ -182,3 +184,5 @@ class Platform::Irq_routing : public Genode::List<Platform::Irq_routing>::Elemen
|
||||
static unsigned short rewrite(unsigned char bus, unsigned char dev,
|
||||
unsigned char func, unsigned char pin);
|
||||
};
|
||||
|
||||
#endif /* _X86__IRQ_H_ */
|
||||
|
@ -72,13 +72,13 @@ struct Platform::Main
|
||||
|
||||
void system_update()
|
||||
{
|
||||
if (acpi_ready.is_constructed())
|
||||
if (acpi_ready.constructed())
|
||||
acpi_ready->update();
|
||||
|
||||
if (!root.is_constructed())
|
||||
if (!root.constructed())
|
||||
return;
|
||||
|
||||
if (acpi_ready.is_constructed() && acpi_ready->is_valid()) {
|
||||
if (acpi_ready.constructed() && acpi_ready->valid()) {
|
||||
Genode::Xml_node system(acpi_ready->local_addr<char>(),
|
||||
acpi_ready->size());
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <base/heap.h>
|
||||
#include <base/rpc_server.h>
|
||||
#include <base/tslab.h>
|
||||
#include <ram_session/capability.h>
|
||||
#include <root/component.h>
|
||||
|
||||
#include <util/mmio.h>
|
||||
@ -279,11 +278,13 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
return config_space;
|
||||
}
|
||||
|
||||
typedef Genode::String<32> Alias_name;
|
||||
|
||||
/*
|
||||
* List of aliases for PCI Class/Subclas/Prog I/F triple used
|
||||
* by xml config for this platform driver
|
||||
*/
|
||||
unsigned class_subclass_prog(const char * name)
|
||||
unsigned class_subclass_prog(Alias_name const &name)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
@ -304,7 +305,7 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
};
|
||||
|
||||
for (unsigned i = 0; i < sizeof(aliases) / sizeof(aliases[0]); i++) {
|
||||
if (strcmp(aliases[i].alias, name))
|
||||
if (name != aliases[i].alias)
|
||||
continue;
|
||||
|
||||
return 0U | aliases[i].pci_class << 16 |
|
||||
@ -324,58 +325,81 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
|
||||
try {
|
||||
_policy.for_each_sub_node("device", [&] (Xml_node dev) {
|
||||
try {
|
||||
/* enforce restriction based on name name */
|
||||
char policy_name[8];
|
||||
dev.attribute("name").value(policy_name,
|
||||
sizeof(policy_name));
|
||||
|
||||
if (!strcmp(policy_name, name))
|
||||
/* found identical match - permit access */
|
||||
throw true;
|
||||
|
||||
} catch (Xml_attribute::Nonexistent_attribute) { }
|
||||
/* enforce restriction based on name name */
|
||||
if (dev.attribute_value("name", Genode::String<10>()) == name)
|
||||
/* found identical match - permit access */
|
||||
throw true;
|
||||
});
|
||||
} catch (bool result) { return result; }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool _bdf_exactly_specified(Xml_node node)
|
||||
{
|
||||
return node.has_attribute("bus")
|
||||
&& node.has_attribute("device")
|
||||
&& node.has_attribute("function");
|
||||
}
|
||||
|
||||
struct Bdf
|
||||
{
|
||||
unsigned b, d, f;
|
||||
|
||||
bool equals(Bdf const &other) const
|
||||
{
|
||||
return other.b == b && other.d == d && other.f == f;
|
||||
}
|
||||
|
||||
void print(Genode::Output &out) const
|
||||
{
|
||||
Genode::print(out, Genode::Hex(b), ":", Genode::Hex(d), ".", f);
|
||||
}
|
||||
};
|
||||
|
||||
static Bdf _bdf_from_xml(Xml_node node)
|
||||
{
|
||||
return Bdf { .b = node.attribute_value("bus", 0U),
|
||||
.d = node.attribute_value("device", 0U),
|
||||
.f = node.attribute_value("function", 0U) };
|
||||
}
|
||||
|
||||
static bool _bdf_attributes_in_valid_range(Xml_node node)
|
||||
{
|
||||
return _bdf_exactly_specified(node)
|
||||
&& (node.attribute_value("bus", 0U) < Device_config::MAX_BUSES)
|
||||
&& (node.attribute_value("device", 0U) < Device_config::MAX_DEVICES)
|
||||
&& (node.attribute_value("function", 0U) < Device_config::MAX_FUNCTIONS);
|
||||
}
|
||||
|
||||
static bool _bdf_matches(Xml_node node, Bdf bdf)
|
||||
{
|
||||
return _bdf_from_xml(node).equals(bdf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check according session policy device usage
|
||||
*/
|
||||
bool permit_device(Genode::uint8_t b, Genode::uint8_t d,
|
||||
Genode::uint8_t f, unsigned class_code)
|
||||
bool permit_device(Bdf const bdf, unsigned class_code)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
try {
|
||||
_policy.for_each_sub_node("pci", [&] (Xml_node node) {
|
||||
try {
|
||||
unsigned bus, device, function;
|
||||
|
||||
node.attribute("bus").value(&bus);
|
||||
node.attribute("device").value(&device);
|
||||
node.attribute("function").value(&function);
|
||||
|
||||
if (b == bus && d == device && f == function)
|
||||
if (_bdf_exactly_specified(node)) {
|
||||
if (_bdf_matches(node, bdf))
|
||||
throw true;
|
||||
/* check also for class entry */
|
||||
}
|
||||
|
||||
if (!node.has_attribute("class"))
|
||||
return;
|
||||
} catch (Xml_attribute::Nonexistent_attribute) { }
|
||||
|
||||
/* enforce restriction based upon classes */
|
||||
unsigned class_sub_prog = 0;
|
||||
|
||||
try {
|
||||
char alias_class[32];
|
||||
node.attribute("class").value(alias_class,
|
||||
sizeof(alias_class));
|
||||
|
||||
class_sub_prog = class_subclass_prog(alias_class);
|
||||
} catch (Xml_attribute::Nonexistent_attribute) {
|
||||
return;
|
||||
}
|
||||
auto alias = node.attribute_value("class", Alias_name());
|
||||
unsigned const class_sub_prog = class_subclass_prog(alias);
|
||||
|
||||
enum { DONT_CHECK_PROGIF = 8 };
|
||||
/* if class/subclass don't match - deny */
|
||||
@ -383,7 +407,7 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
return;
|
||||
|
||||
/* if this bdf is used by some policy - deny */
|
||||
if (find_dev_in_policy(b, d, f))
|
||||
if (find_dev_in_policy(bdf))
|
||||
return;
|
||||
|
||||
throw true;
|
||||
@ -403,17 +427,14 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
try {
|
||||
_config.xml().for_each_sub_node("policy", [&] (Xml_node policy) {
|
||||
policy.for_each_sub_node("device", [&] (Xml_node device) {
|
||||
try {
|
||||
/* device attribute from policy node */
|
||||
char policy_device[8];
|
||||
device.attribute("name").value(policy_device, sizeof(policy_device));
|
||||
|
||||
if (!strcmp(policy_device, dev_name)) {
|
||||
if (once)
|
||||
throw true;
|
||||
once = true;
|
||||
}
|
||||
} catch (Xml_node::Nonexistent_attribute) { }
|
||||
typedef Genode::String<10> Name;
|
||||
if (device.attribute_value("name", Name()) == dev_name) {
|
||||
|
||||
if (once)
|
||||
throw true;
|
||||
once = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch (bool result) { return result; }
|
||||
@ -424,8 +445,7 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
/**
|
||||
* Lookup a given device name.
|
||||
*/
|
||||
bool find_dev_in_policy(Genode::uint8_t b, Genode::uint8_t d,
|
||||
Genode::uint8_t f, bool once = true)
|
||||
bool find_dev_in_policy(Bdf const bdf, bool once = true)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
@ -433,19 +453,16 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
Xml_node xml = _config.xml();
|
||||
xml.for_each_sub_node("policy", [&] (Xml_node policy) {
|
||||
policy.for_each_sub_node("pci", [&] (Xml_node node) {
|
||||
try {
|
||||
unsigned bus, device, function;
|
||||
|
||||
node.attribute("bus").value(&bus);
|
||||
node.attribute("device").value(&device);
|
||||
node.attribute("function").value(&function);
|
||||
if (_bdf_exactly_specified(node)) {
|
||||
|
||||
if (_bdf_matches(node, bdf)) {
|
||||
|
||||
if (b == bus && d == device && f == function) {
|
||||
if (once)
|
||||
throw true;
|
||||
once = true;
|
||||
}
|
||||
} catch (Xml_node::Nonexistent_attribute) { }
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch (bool result) { return result; }
|
||||
@ -478,32 +495,30 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
/* subtract the RPC session and session dataspace capabilities */
|
||||
_cap_guard.withdraw(Genode::Cap_quota{2});
|
||||
|
||||
/* non-pci devices */
|
||||
/* check policy for non-pci devices */
|
||||
_policy.for_each_sub_node("device", [&] (Genode::Xml_node device_node) {
|
||||
try {
|
||||
char policy_device[8];
|
||||
device_node.attribute("name").value(policy_device,
|
||||
sizeof(policy_device));
|
||||
|
||||
enum { DOUBLET = false };
|
||||
if (!find_dev_in_policy(policy_device, DOUBLET))
|
||||
return;
|
||||
|
||||
Genode::error("'", _label, "' - device "
|
||||
"'", Genode::Cstring(policy_device), "' "
|
||||
"is part of more than one policy");
|
||||
}
|
||||
catch (Genode::Xml_node::Nonexistent_attribute) {
|
||||
if (!device_node.has_attribute("name")) {
|
||||
Genode::error("'", _label, "' - device node "
|
||||
"misses a 'name' attribute");
|
||||
"misses 'name' attribute");
|
||||
throw Genode::Service_denied();
|
||||
}
|
||||
|
||||
typedef Genode::String<16> Name;
|
||||
Name const name = device_node.attribute_value("name", Name());
|
||||
|
||||
enum { DOUBLET = false };
|
||||
if (find_dev_in_policy(name.string(), DOUBLET)) {
|
||||
Genode::error("'", _label, "' - device '", name, "' "
|
||||
"is part of more than one policy");
|
||||
throw Genode::Service_denied();
|
||||
}
|
||||
throw Genode::Service_denied();
|
||||
});
|
||||
|
||||
/* pci devices */
|
||||
_policy.for_each_sub_node("pci", [&] (Genode::Xml_node node) {
|
||||
|
||||
enum { INVALID_CLASS = 0x1000000U };
|
||||
unsigned class_sub_prog = INVALID_CLASS;
|
||||
|
||||
using Genode::Xml_attribute;
|
||||
|
||||
@ -512,21 +527,16 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
* 'function' attributes or a single 'class' attribute.
|
||||
* All other attribute names are traded as wrong.
|
||||
*/
|
||||
try {
|
||||
char alias_class[32];
|
||||
node.attribute("class").value(alias_class,
|
||||
sizeof(alias_class));
|
||||
if (node.has_attribute("class")) {
|
||||
|
||||
class_sub_prog = class_subclass_prog(alias_class);
|
||||
if (class_sub_prog >= INVALID_CLASS) {
|
||||
Alias_name const alias = node.attribute_value("class", Alias_name());
|
||||
|
||||
if (class_subclass_prog(alias) >= INVALID_CLASS) {
|
||||
Genode::error("'", _label, "' - invalid 'class' ",
|
||||
"attribute '", Genode::Cstring(alias_class), "'");
|
||||
"attribute '", alias, "'");
|
||||
throw Genode::Service_denied();
|
||||
}
|
||||
} catch (Xml_attribute::Nonexistent_attribute) { }
|
||||
|
||||
/* if we read a class attribute all is fine */
|
||||
if (class_sub_prog < INVALID_CLASS) {
|
||||
/* sanity check that 'class' is the only attribute */
|
||||
try {
|
||||
node.attribute(1);
|
||||
@ -548,32 +558,23 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
|
||||
} catch (Xml_attribute::Nonexistent_attribute) { }
|
||||
|
||||
try {
|
||||
unsigned bus, device, function;
|
||||
if (_bdf_exactly_specified(node)) {
|
||||
|
||||
node.attribute("bus").value(&bus);
|
||||
node.attribute("device").value(&device);
|
||||
node.attribute("function").value(&function);
|
||||
if (!_bdf_attributes_in_valid_range(node)) {
|
||||
Genode::error("'", _label, "' - "
|
||||
"invalid pci node attributes for bdf");
|
||||
throw Genode::Service_denied();
|
||||
}
|
||||
|
||||
if ((bus >= Device_config::MAX_BUSES) ||
|
||||
(device >= Device_config::MAX_DEVICES) ||
|
||||
(function >= Device_config::MAX_FUNCTIONS))
|
||||
throw Xml_attribute::Nonexistent_attribute();
|
||||
Bdf const bdf = _bdf_from_xml(node);
|
||||
|
||||
enum { DOUBLET = false };
|
||||
if (!find_dev_in_policy(bus, device, function, DOUBLET))
|
||||
return;
|
||||
|
||||
Genode::error("'", _label, "' - device '",
|
||||
Genode::Hex(bus), ":",
|
||||
Genode::Hex(device), ".", function, "' "
|
||||
"is part of more than one policy");
|
||||
|
||||
} catch (Xml_attribute::Nonexistent_attribute) {
|
||||
Genode::error("'", _label, "' - "
|
||||
"invalid pci node attributes for bdf");
|
||||
if (find_dev_in_policy(bdf, DOUBLET)) {
|
||||
Genode::error("'", _label, "' - device '", bdf, "' "
|
||||
"is part of more than one policy");
|
||||
throw Genode::Service_denied();
|
||||
}
|
||||
}
|
||||
throw Genode::Service_denied();
|
||||
});
|
||||
}
|
||||
|
||||
@ -618,14 +619,8 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
*/
|
||||
bool msi_usage()
|
||||
{
|
||||
try {
|
||||
char mode[8];
|
||||
_policy.attribute("irq_mode").value(mode, sizeof(mode));
|
||||
if (!Genode::strcmp("nomsi", mode))
|
||||
return false;
|
||||
} catch (Genode::Xml_node::Nonexistent_attribute) { }
|
||||
|
||||
return true;
|
||||
typedef Genode::String<10> Mode;
|
||||
return _policy.attribute_value("irq_mode", Mode()) != "nomsi";
|
||||
}
|
||||
|
||||
|
||||
@ -686,8 +681,10 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
continue;
|
||||
|
||||
/* check that policy permit access to the matched device */
|
||||
if (permit_device(bus, device, function,
|
||||
config.class_code()))
|
||||
if (permit_device(Bdf { (unsigned)bus,
|
||||
(unsigned)device,
|
||||
(unsigned)function },
|
||||
config.class_code()))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -855,13 +852,9 @@ class Platform::Root : public Genode::Root_component<Session_component>
|
||||
|
||||
xml_acpi.for_each_sub_node("bdf", [&] (Xml_node &node) {
|
||||
|
||||
uint32_t bdf_start = 0;
|
||||
uint32_t func_count = 0;
|
||||
addr_t base = 0;
|
||||
|
||||
node.attribute("start").value(&bdf_start);
|
||||
node.attribute("count").value(&func_count);
|
||||
node.attribute("base").value(&base);
|
||||
uint32_t const bdf_start = node.attribute_value("start", 0U);
|
||||
uint32_t const func_count = node.attribute_value("count", 0U);
|
||||
addr_t const base = node.attribute_value("base", 0UL);
|
||||
|
||||
Session_component::add_config_space(bdf_start, func_count,
|
||||
base, _heap);
|
||||
@ -897,13 +890,9 @@ class Platform::Root : public Genode::Root_component<Session_component>
|
||||
continue;
|
||||
|
||||
if (node.has_type("irq_override")) {
|
||||
unsigned irq = 0xff;
|
||||
unsigned gsi = 0xff;
|
||||
unsigned flags = 0xff;
|
||||
|
||||
node.attribute("irq").value(&irq);
|
||||
node.attribute("gsi").value(&gsi);
|
||||
node.attribute("flags").value(&flags);
|
||||
unsigned const irq = node.attribute_value("irq", 0xffU);
|
||||
unsigned const gsi = node.attribute_value("gsi", 0xffU);
|
||||
unsigned const flags = node.attribute_value("flags", 0xffU);
|
||||
|
||||
if (!acpi_platform) {
|
||||
warning("MADT IRQ ", irq, "-> GSI ", gsi, " flags ",
|
||||
@ -924,9 +913,9 @@ class Platform::Root : public Genode::Root_component<Session_component>
|
||||
}
|
||||
|
||||
if (node.has_type("rmrr")) {
|
||||
uint64_t mem_start = 0, mem_end = 0;
|
||||
node.attribute("start").value(&mem_start);
|
||||
node.attribute("end").value(&mem_end);
|
||||
uint64_t const
|
||||
mem_start = node.attribute_value("start", (uint64_t)0),
|
||||
mem_end = node.attribute_value("end", (uint64_t)0);
|
||||
|
||||
if (node.num_sub_nodes() == 0)
|
||||
throw 3;
|
||||
@ -940,15 +929,15 @@ class Platform::Root : public Genode::Root_component<Session_component>
|
||||
throw 4;
|
||||
|
||||
unsigned bus = 0, dev = 0, func = 0;
|
||||
scope.attribute("bus_start").value(&bus);
|
||||
scope.attribute("bus_start").value(bus);
|
||||
|
||||
for (unsigned p = 0; p < scope.num_sub_nodes(); p++) {
|
||||
Xml_node path = scope.sub_node(p);
|
||||
if (!path.has_type("path"))
|
||||
throw 5;
|
||||
|
||||
path.attribute("dev").value(&dev);
|
||||
path.attribute("func").value(&func);
|
||||
path.attribute("dev") .value(dev);
|
||||
path.attribute("func").value(func);
|
||||
|
||||
Device_config bridge(bus, dev, func,
|
||||
&config_access);
|
||||
@ -964,7 +953,7 @@ class Platform::Root : public Genode::Root_component<Session_component>
|
||||
}
|
||||
|
||||
if (node.has_type("root_bridge")) {
|
||||
node.attribute("bdf").value(&Platform::Bridge::root_bridge_bdf);
|
||||
node.attribute("bdf").value(Platform::Bridge::root_bridge_bdf);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -973,15 +962,10 @@ class Platform::Root : public Genode::Root_component<Session_component>
|
||||
throw __LINE__;
|
||||
}
|
||||
|
||||
unsigned gsi;
|
||||
unsigned bridge_bdf;
|
||||
unsigned device;
|
||||
unsigned device_pin;
|
||||
|
||||
node.attribute("gsi").value(&gsi);
|
||||
node.attribute("bridge_bdf").value(&bridge_bdf);
|
||||
node.attribute("device").value(&device);
|
||||
node.attribute("device_pin").value(&device_pin);
|
||||
unsigned const gsi = node.attribute_value("gsi", 0U),
|
||||
bridge_bdf = node.attribute_value("bridge_bdf", 0U),
|
||||
device = node.attribute_value("device", 0U),
|
||||
device_pin = node.attribute_value("device_pin", 0U);
|
||||
|
||||
/* drop routing information on non ACPI platform */
|
||||
if (!acpi_platform)
|
||||
|
@ -20,7 +20,7 @@
|
||||
using namespace Adma2;
|
||||
|
||||
|
||||
Table::Table(Ram_session &ram, Region_map &rm)
|
||||
Table::Table(Ram_allocator &ram, Region_map &rm)
|
||||
:
|
||||
_ds(ram, rm, _ds_size, UNCACHED),
|
||||
_base_virt(_ds.local_addr<Desc::access_t>()),
|
||||
|
@ -74,7 +74,7 @@ class Adma2::Table
|
||||
|
||||
public:
|
||||
|
||||
Table(Ram_session &ram, Region_map &rm);
|
||||
Table(Ram_allocator &ram, Region_map &rm);
|
||||
|
||||
/**
|
||||
* Marshal descriptors according to block request
|
||||
|
@ -30,7 +30,7 @@ class Sd_card::Driver_base : public Block::Driver,
|
||||
{
|
||||
public:
|
||||
|
||||
Driver_base(Genode::Ram_session &ram)
|
||||
Driver_base(Genode::Ram_allocator &ram)
|
||||
: Block::Driver(ram) { }
|
||||
|
||||
/*******************
|
||||
|
@ -219,32 +219,16 @@ class Uart::Root : public Uart::Root_component
|
||||
|
||||
Session_component *_create_session(const char *args)
|
||||
{
|
||||
try {
|
||||
Session_label label = label_from_args(args);
|
||||
Session_policy policy(label, _config.xml());
|
||||
Session_label const label = label_from_args(args);
|
||||
Session_policy const policy(label, _config.xml());
|
||||
|
||||
unsigned index = 0;
|
||||
policy.attribute("uart").value(&index);
|
||||
unsigned const index = policy.attribute_value("uart", 0U);
|
||||
unsigned const baudrate = policy.attribute_value("baudrate", 0U);
|
||||
bool const detect_size = policy.attribute_value("detect_size", false);
|
||||
|
||||
unsigned baudrate = 0;
|
||||
try {
|
||||
policy.attribute("baudrate").value(&baudrate);
|
||||
} catch (Xml_node::Nonexistent_attribute) { }
|
||||
|
||||
bool detect_size = policy.attribute_value("detect_size", false);
|
||||
|
||||
return new (md_alloc())
|
||||
Session_component(_env, _driver_factory, index,
|
||||
baudrate, detect_size);
|
||||
}
|
||||
catch (Xml_node::Nonexistent_attribute) {
|
||||
Genode::error("Missing \"uart\" attribute in policy definition");
|
||||
throw Genode::Service_denied();
|
||||
}
|
||||
catch (Session_policy::No_policy_defined) {
|
||||
Genode::error("Invalid session request, no matching policy");
|
||||
throw Genode::Service_denied();
|
||||
}
|
||||
return new (md_alloc())
|
||||
Session_component(_env, _driver_factory, index,
|
||||
baudrate, detect_size);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -108,7 +108,7 @@ struct Usb::Block_driver : Usb::Completion,
|
||||
{
|
||||
static Genode::String<256> usb_label;
|
||||
try {
|
||||
node.attribute("label").value(&usb_label);
|
||||
node.attribute("label").value(usb_label);
|
||||
return usb_label.string();
|
||||
} catch (...) { }
|
||||
|
||||
|
@ -54,11 +54,11 @@ Init::Child::apply_config(Xml_node start_node)
|
||||
|
||||
Config_update config_update = CONFIG_UNCHANGED;
|
||||
|
||||
/* import new start node if new version differs */
|
||||
if (start_node.size() != _start_node->xml().size() ||
|
||||
Genode::memcmp(start_node.addr(), _start_node->xml().addr(),
|
||||
start_node.size()) != 0)
|
||||
{
|
||||
/*
|
||||
* Import new start node if new version differs
|
||||
*/
|
||||
if (start_node.differs_from(_start_node->xml())) {
|
||||
|
||||
/*
|
||||
* Check for a change of the version attribute, force restart
|
||||
* if the version changed.
|
||||
@ -85,11 +85,10 @@ Init::Child::apply_config(Xml_node start_node)
|
||||
|
||||
if (config_was_present && config_is_present) {
|
||||
|
||||
Xml_node old_config = _start_node->xml().sub_node(tag);
|
||||
Xml_node new_config = start_node.sub_node(tag);
|
||||
Xml_node const old_config = _start_node->xml().sub_node(tag);
|
||||
Xml_node const new_config = start_node.sub_node(tag);
|
||||
|
||||
if (Genode::memcmp(old_config.addr(), new_config.addr(),
|
||||
min(old_config.size(), new_config.size())))
|
||||
if (new_config.differs_from(old_config))
|
||||
config_update = CONFIG_CHANGED;
|
||||
}
|
||||
|
||||
@ -354,14 +353,14 @@ void Init::Child::report_state(Xml_generator &xml, Report_detail const &detail)
|
||||
if (_heartbeat_enabled && _child.skipped_heartbeats())
|
||||
xml.attribute("skipped_heartbeats", _child.skipped_heartbeats());
|
||||
|
||||
if (detail.child_ram() && _child.ram_session_cap().valid()) {
|
||||
if (detail.child_ram() && _child.pd_session_cap().valid()) {
|
||||
xml.node("ram", [&] () {
|
||||
|
||||
xml.attribute("assigned", String<32> {
|
||||
Number_of_bytes(_resources.assigned_ram_quota.value) });
|
||||
|
||||
if (pd_alive)
|
||||
generate_ram_info(xml, _child.ram());
|
||||
generate_ram_info(xml, _child.pd());
|
||||
|
||||
if (_requested_resources.constructed() && _requested_resources->ram.value)
|
||||
xml.attribute("requested", String<32>(_requested_resources->ram));
|
||||
@ -423,7 +422,7 @@ void Init::Child::init(Pd_session &session, Pd_session_capability cap)
|
||||
catch (Out_of_caps) {
|
||||
error(name(), ": unable to initialize cap quota of PD"); }
|
||||
|
||||
try { _env.ram().transfer_quota(cap, ram_quota); }
|
||||
try { _env.pd().transfer_quota(cap, ram_quota); }
|
||||
catch (Out_of_ram) {
|
||||
error(name(), ": unable to initialize RAM quota of PD"); }
|
||||
}
|
||||
|
@ -286,15 +286,18 @@ class Init::Child : Child_policy, Routed_service::Wakeup
|
||||
if (config_len + 1 /* null termination */ >= dst_len)
|
||||
throw Buffer_capacity_exceeded();
|
||||
|
||||
/*
|
||||
* The 'config.size()' method returns the number of bytes of
|
||||
* the config-node content, which is not null-terminated. Since
|
||||
* 'Genode::strncpy' always null-terminates the result, the
|
||||
* last byte of the source string is not copied. Hence, it is
|
||||
* safe to add '1' to 'config_len' and thereby include the
|
||||
* last actual config-content character in the result.
|
||||
*/
|
||||
Genode::strncpy(dst, config.addr(), config_len + 1);
|
||||
config.with_raw_node([&] (char const *start, size_t length) {
|
||||
|
||||
/*
|
||||
* The 'length' is the number of bytes of the config-node
|
||||
* content, which is not null-terminated. Since
|
||||
* 'Genode::strncpy' always null-terminates the result, the
|
||||
* last byte of the source string is not copied. Hence, it
|
||||
* is safe to add '1' to 'length' and thereby include the
|
||||
* last actual config-content character in the result.
|
||||
*/
|
||||
Genode::strncpy(dst, start, length + 1);
|
||||
});
|
||||
}
|
||||
|
||||
void trigger_update() { _session.trigger_update(); }
|
||||
@ -337,20 +340,27 @@ class Init::Child : Child_policy, Routed_service::Wakeup
|
||||
|
||||
Genode::Child _child { _env.rm(), _env.ep().rpc_ep(), *this };
|
||||
|
||||
struct Ram_pd_accessor : Routed_service::Ram_accessor,
|
||||
Routed_service::Pd_accessor
|
||||
struct Pd_accessor : Routed_service::Pd_accessor
|
||||
{
|
||||
Genode::Child &_child;
|
||||
|
||||
Ram_pd_accessor(Genode::Child &child) : _child(child) { }
|
||||
Pd_accessor(Genode::Child &child) : _child(child) { }
|
||||
|
||||
Ram_session &ram() override { return _child.ram(); }
|
||||
Ram_session_capability ram_cap() const override { return _child.ram_session_cap(); }
|
||||
Pd_session &pd() override { return _child.pd(); }
|
||||
Pd_session_capability pd_cap() const override { return _child.pd_session_cap(); }
|
||||
|
||||
Pd_session &pd() override { return _child.pd(); }
|
||||
Pd_session_capability pd_cap() const override { return _child.pd_session_cap(); }
|
||||
} _pd_accessor { _child };
|
||||
|
||||
} _ram_pd_accessor { _child };
|
||||
struct Ram_accessor : Routed_service::Ram_accessor
|
||||
{
|
||||
Genode::Child &_child;
|
||||
|
||||
Ram_accessor(Genode::Child &child) : _child(child) { }
|
||||
|
||||
Pd_session &ram() override { return _child.pd(); }
|
||||
Pd_session_capability ram_cap() const override { return _child.pd_session_cap(); }
|
||||
|
||||
} _ram_accessor { _child };
|
||||
|
||||
/**
|
||||
* Async_service::Wakeup callback
|
||||
@ -418,7 +428,7 @@ class Init::Child : Child_policy, Routed_service::Wakeup
|
||||
|
||||
new (_alloc)
|
||||
Routed_service(_child_services, this->name(),
|
||||
_ram_pd_accessor, _ram_pd_accessor,
|
||||
_pd_accessor, _ram_accessor,
|
||||
_session_requester.id_space(),
|
||||
_child.session_factory(),
|
||||
name, *this);
|
||||
@ -481,7 +491,7 @@ class Init::Child : Child_policy, Routed_service::Wakeup
|
||||
Ram_quota ram_quota() const { return _resources.assigned_ram_quota; }
|
||||
Cap_quota cap_quota() const { return _resources.assigned_cap_quota; }
|
||||
|
||||
void initiate_env_ram_session()
|
||||
void initiate_env_pd_session()
|
||||
{
|
||||
if (_state == STATE_INITIAL) {
|
||||
_child.initiate_env_ram_session();
|
||||
|
@ -63,7 +63,7 @@ struct Init::Main : State_reporter::Producer,
|
||||
{
|
||||
Ram_quota const preserved_ram = _preserved_ram_from_config(_config_xml);
|
||||
|
||||
Ram_quota avail_ram = _env.ram().avail_ram();
|
||||
Ram_quota avail_ram = _env.pd().avail_ram();
|
||||
|
||||
if (preserved_ram.value > avail_ram.value) {
|
||||
error("RAM preservation exceeds available memory");
|
||||
@ -115,7 +115,7 @@ struct Init::Main : State_reporter::Producer,
|
||||
void produce_state_report(Xml_generator &xml, Report_detail const &detail) const
|
||||
{
|
||||
if (detail.init_ram())
|
||||
xml.node("ram", [&] () { generate_ram_info (xml, _env.ram()); });
|
||||
xml.node("ram", [&] () { generate_ram_info (xml, _env.pd()); });
|
||||
|
||||
if (detail.init_caps())
|
||||
xml.node("caps", [&] () { generate_caps_info(xml, _env.pd()); });
|
||||
@ -444,7 +444,7 @@ void Init::Main::_handle_config()
|
||||
*/
|
||||
_children.for_each_child([&] (Child &child) {
|
||||
if (!child.abandoned())
|
||||
child.initiate_env_ram_session(); });
|
||||
child.initiate_env_pd_session(); });
|
||||
|
||||
/*
|
||||
* Initiate remaining environment sessions of all new children
|
||||
|
@ -162,7 +162,7 @@ void Init::Server::_close_session(Session_state &session,
|
||||
Ram_transfer::Account &service_ram_account = session.service();
|
||||
Cap_transfer::Account &service_cap_account = session.service();
|
||||
|
||||
service_ram_account.try_transfer(_env.ram_session_cap(),
|
||||
service_ram_account.try_transfer(_env.pd_session_cap(),
|
||||
session.donated_ram_quota());
|
||||
|
||||
service_cap_account.try_transfer(_env.pd_session_cap(),
|
||||
@ -233,8 +233,8 @@ void Init::Server::_handle_create_session_request(Xml_node request,
|
||||
|
||||
/* transfer session quota */
|
||||
try {
|
||||
Ram_transfer::Remote_account env_ram_account(_env.ram(), _env.ram_session_cap());
|
||||
Cap_transfer::Remote_account env_cap_account(_env.pd(), _env.pd_session_cap());
|
||||
Ram_transfer::Remote_account env_ram_account(_env.pd(), _env.pd_session_cap());
|
||||
Cap_transfer::Remote_account env_cap_account(_env.pd(), _env.pd_session_cap());
|
||||
|
||||
Ram_transfer ram_transfer(forward_ram_quota, env_ram_account, route.service);
|
||||
Cap_transfer cap_transfer(cap_quota, env_cap_account, route.service);
|
||||
@ -298,8 +298,8 @@ void Init::Server::_handle_upgrade_session_request(Xml_node request,
|
||||
session.phase = Session_state::UPGRADE_REQUESTED;
|
||||
|
||||
try {
|
||||
Ram_transfer::Remote_account env_ram_account(_env.ram(), _env.ram_session_cap());
|
||||
Cap_transfer::Remote_account env_cap_account(_env.pd(), _env.pd_session_cap());
|
||||
Ram_transfer::Remote_account env_ram_account(_env.pd(), _env.pd_session_cap());
|
||||
Cap_transfer::Remote_account env_cap_account(_env.pd(), _env.pd_session_cap());
|
||||
|
||||
Ram_transfer ram_transfer(ram_quota, env_ram_account, session.service());
|
||||
Cap_transfer cap_transfer(cap_quota, env_cap_account, session.service());
|
||||
|
@ -65,24 +65,23 @@ class Init::Routed_service : public Async_service, public Abandonable
|
||||
|
||||
typedef Child_policy::Name Child_name;
|
||||
|
||||
struct Ram_accessor : Interface
|
||||
{
|
||||
virtual Ram_session &ram() = 0;
|
||||
virtual Ram_session_capability ram_cap() const = 0;
|
||||
};
|
||||
|
||||
struct Pd_accessor : Interface
|
||||
{
|
||||
virtual Pd_session &pd() = 0;
|
||||
virtual Pd_session_capability pd_cap() const = 0;
|
||||
};
|
||||
|
||||
struct Ram_accessor : Interface
|
||||
{
|
||||
virtual Pd_session &ram() = 0;
|
||||
virtual Pd_session_capability ram_cap() const = 0;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
Child_name _child_name;
|
||||
|
||||
Ram_accessor &_ram_accessor;
|
||||
Pd_accessor &_pd_accessor;
|
||||
Pd_accessor &_pd_accessor;
|
||||
|
||||
Session_state::Factory &_factory;
|
||||
|
||||
@ -100,16 +99,15 @@ class Init::Routed_service : public Async_service, public Abandonable
|
||||
*/
|
||||
Routed_service(Registry<Routed_service> &services,
|
||||
Child_name const &child_name,
|
||||
Ram_accessor &ram_accessor,
|
||||
Pd_accessor &pd_accessor,
|
||||
Ram_accessor &,
|
||||
Id_space<Parent::Server> &server_id_space,
|
||||
Session_state::Factory &factory,
|
||||
Service::Name const &name,
|
||||
Wakeup &wakeup)
|
||||
:
|
||||
Async_service(name, server_id_space, factory, wakeup),
|
||||
_child_name(child_name),
|
||||
_ram_accessor(ram_accessor), _pd_accessor(pd_accessor),
|
||||
_child_name(child_name), _pd_accessor(pd_accessor),
|
||||
_factory(factory), _registry_element(services, *this)
|
||||
{ }
|
||||
|
||||
@ -120,17 +118,17 @@ class Init::Routed_service : public Async_service, public Abandonable
|
||||
/**
|
||||
* Ram_transfer::Account interface
|
||||
*/
|
||||
void transfer(Ram_session_capability to, Ram_quota amount) override
|
||||
void transfer(Pd_session_capability to, Ram_quota amount) override
|
||||
{
|
||||
if (to.valid()) _ram_accessor.ram().transfer_quota(to, amount);
|
||||
if (to.valid()) _pd_accessor.pd().transfer_quota(to, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ram_transfer::Account interface
|
||||
*/
|
||||
Ram_session_capability cap(Ram_quota) const override
|
||||
Pd_session_capability cap(Ram_quota) const override
|
||||
{
|
||||
return _ram_accessor.ram_cap();
|
||||
return _pd_accessor.pd_cap();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,12 +162,12 @@ namespace Init {
|
||||
}
|
||||
|
||||
|
||||
inline void generate_ram_info(Xml_generator &xml, Ram_session const &ram)
|
||||
inline void generate_ram_info(Xml_generator &xml, Pd_session const &pd)
|
||||
{
|
||||
typedef String<32> Value;
|
||||
xml.attribute("quota", Value(ram.ram_quota()));
|
||||
xml.attribute("used", Value(ram.used_ram()));
|
||||
xml.attribute("avail", Value(ram.avail_ram()));
|
||||
xml.attribute("quota", Value(pd.ram_quota()));
|
||||
xml.attribute("used", Value(pd.used_ram()));
|
||||
xml.attribute("avail", Value(pd.avail_ram()));
|
||||
}
|
||||
|
||||
inline void generate_caps_info(Xml_generator &xml, Pd_session const &pd)
|
||||
@ -196,9 +196,9 @@ namespace Init {
|
||||
|
||||
inline long priority_from_xml(Xml_node start_node, Prio_levels prio_levels)
|
||||
{
|
||||
long priority = Cpu_session::DEFAULT_PRIORITY;
|
||||
try { start_node.attribute("priority").value(&priority); }
|
||||
catch (...) { }
|
||||
long const default_priority = Cpu_session::DEFAULT_PRIORITY;
|
||||
|
||||
long priority = start_node.attribute_value("priority", default_priority);
|
||||
|
||||
/*
|
||||
* All priority declarations in the config file are
|
||||
@ -211,9 +211,9 @@ namespace Init {
|
||||
|
||||
if (priority && (priority >= prio_levels.value)) {
|
||||
long new_prio = prio_levels.value ? prio_levels.value - 1 : 0;
|
||||
char name[Service::Name::capacity()];
|
||||
start_node.attribute("name").value(name, sizeof(name));
|
||||
warning(Cstring(name), ": invalid priority, upgrading "
|
||||
|
||||
Service::Name const name = start_node.attribute_value("name", Service::Name());
|
||||
warning(name, ": invalid priority, upgrading "
|
||||
"from ", -priority, " to ", -new_prio);
|
||||
return new_prio;
|
||||
}
|
||||
|
@ -341,15 +341,12 @@ class Vfs::Block_file_system : public Single_file_system
|
||||
_env(env),
|
||||
_label(config.attribute_value("label", Label())),
|
||||
_block_buffer(0),
|
||||
_block_buffer_count(1),
|
||||
_block_buffer_count(config.attribute_value("block_buffer_count", 1UL)),
|
||||
_tx_source(_block.tx()),
|
||||
_readable(false),
|
||||
_writeable(false),
|
||||
_source_submit_cap(_signal_receiver.manage(&_signal_context))
|
||||
{
|
||||
try { config.attribute("block_buffer_count").value(&_block_buffer_count); }
|
||||
catch (...) { }
|
||||
|
||||
_block.info(&_block_count, &_block_size, &_block_ops);
|
||||
|
||||
_readable = _block_ops.supported(Block::Packet_descriptor::READ);
|
||||
|
@ -111,17 +111,6 @@ Vfs::Global_file_system_factory::_try_create(Vfs::Env &env,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return name of VFS node
|
||||
*/
|
||||
Node_name Vfs::Global_file_system_factory::_node_name(Genode::Xml_node node)
|
||||
{
|
||||
char node_name [Node_name::capacity()];
|
||||
node.type_name(node_name, sizeof(node_name));
|
||||
return Node_name(node_name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return matching library name for a given vfs node name
|
||||
*/
|
||||
@ -173,15 +162,14 @@ Vfs::File_system_factory &Vfs::Global_file_system_factory::_load_factory(Vfs::En
|
||||
/**
|
||||
* Try to load external File_system_factory provider
|
||||
*/
|
||||
bool Vfs::Global_file_system_factory::_probe_external_factory(Vfs::Env &env,
|
||||
Genode::Xml_node node)
|
||||
bool Vfs::Global_file_system_factory::_probe_external_factory(Vfs::Env &env,
|
||||
Genode::Xml_node node)
|
||||
{
|
||||
Library_name const lib_name = _library_name(_node_name(node));
|
||||
Library_name const lib_name = _library_name(node.type());
|
||||
|
||||
try {
|
||||
_list.insert(new (env.alloc())
|
||||
External_entry(_node_name(node).string(),
|
||||
_load_factory(env, lib_name)));
|
||||
External_entry(node.type().string(), _load_factory(env, lib_name)));
|
||||
return true;
|
||||
|
||||
} catch (Factory_not_available) { return false; }
|
||||
|
@ -26,14 +26,7 @@ class Vfs::Inline_file_system : public Single_file_system
|
||||
{
|
||||
private:
|
||||
|
||||
char const * const _base;
|
||||
file_size const _size;
|
||||
|
||||
/*
|
||||
* Noncopyable
|
||||
*/
|
||||
Inline_file_system(Inline_file_system const &);
|
||||
Inline_file_system &operator = (Inline_file_system const &);
|
||||
Xml_node _node;
|
||||
|
||||
class Inline_vfs_handle : public Single_vfs_handle
|
||||
{
|
||||
@ -101,11 +94,16 @@ class Vfs::Inline_file_system : public Single_file_system
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* The 'config' XML node (that points to its content) is stored within
|
||||
* the object after construction time. The underlying backing store
|
||||
* must be kept in tact during the lifefile of the object.
|
||||
*/
|
||||
Inline_file_system(Vfs::Env&, Genode::Xml_node config)
|
||||
:
|
||||
Single_file_system(NODE_TYPE_FILE, name(), config),
|
||||
_base(config.content_base()),
|
||||
_size(config.content_size())
|
||||
Single_file_system(NODE_TYPE_FILE, name(), config), _node(config)
|
||||
{ }
|
||||
|
||||
static char const *name() { return "inline"; }
|
||||
@ -123,8 +121,10 @@ class Vfs::Inline_file_system : public Single_file_system
|
||||
return OPEN_ERR_UNACCESSIBLE;
|
||||
|
||||
try {
|
||||
*out_handle = new (alloc)
|
||||
Inline_vfs_handle(*this, *this, alloc, _base, _size);
|
||||
_node.with_raw_content([&] (char const *base, Genode::size_t size) {
|
||||
*out_handle = new (alloc)
|
||||
Inline_vfs_handle(*this, *this, alloc, base, size);
|
||||
});
|
||||
return OPEN_OK;
|
||||
}
|
||||
catch (Genode::Out_of_ram) { return OPEN_ERR_OUT_OF_RAM; }
|
||||
@ -134,7 +134,8 @@ class Vfs::Inline_file_system : public Single_file_system
|
||||
Stat_result stat(char const *path, Stat &out) override
|
||||
{
|
||||
Stat_result result = Single_file_system::stat(path, out);
|
||||
out.size = _size;
|
||||
_node.with_raw_content([&] (char const *, Genode::size_t size) {
|
||||
out.size = size; });
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
@ -26,28 +26,11 @@ class Vfs::Rom_file_system : public Single_file_system
|
||||
|
||||
enum Rom_type { ROM_TEXT, ROM_BINARY };
|
||||
|
||||
struct Label
|
||||
{
|
||||
enum { LABEL_MAX_LEN = 64 };
|
||||
char string[LABEL_MAX_LEN];
|
||||
bool const binary;
|
||||
typedef String<64> Label;
|
||||
|
||||
Label(Xml_node config)
|
||||
:
|
||||
binary(config.attribute_value("binary", true))
|
||||
{
|
||||
/* obtain label from config */
|
||||
string[0] = 0;
|
||||
try { config.attribute("label").value(string, sizeof(string)); }
|
||||
catch (...)
|
||||
{
|
||||
/* use VFS node name if label was not provided */
|
||||
string[0] = 0;
|
||||
try { config.attribute("name").value(string, sizeof(string)); }
|
||||
catch (...) { }
|
||||
}
|
||||
}
|
||||
} _label;
|
||||
Label const _label;
|
||||
|
||||
bool const _binary;
|
||||
|
||||
Genode::Attached_rom_dataspace _rom;
|
||||
|
||||
@ -125,8 +108,14 @@ class Vfs::Rom_file_system : public Single_file_system
|
||||
Genode::Xml_node config)
|
||||
:
|
||||
Single_file_system(NODE_TYPE_FILE, name(), config),
|
||||
_label(config),
|
||||
_rom(env.env(), _label.string)
|
||||
|
||||
/* use 'label' attribute if present, fall back to 'name' if not */
|
||||
_label(config.attribute_value("label",
|
||||
config.attribute_value("name", Label()))),
|
||||
|
||||
_binary(config.attribute_value("binary", true)),
|
||||
|
||||
_rom(env.env(), _label.string())
|
||||
{ }
|
||||
|
||||
static char const *name() { return "rom"; }
|
||||
@ -147,7 +136,7 @@ class Vfs::Rom_file_system : public Single_file_system
|
||||
|
||||
try {
|
||||
*out_handle = new (alloc)
|
||||
Rom_vfs_handle(*this, *this, alloc, _rom, _label.binary ? ROM_BINARY : ROM_TEXT);
|
||||
Rom_vfs_handle(*this, *this, alloc, _rom, _binary ? ROM_BINARY : ROM_TEXT);
|
||||
return OPEN_OK;
|
||||
}
|
||||
catch (Genode::Out_of_ram) { return OPEN_ERR_OUT_OF_RAM; }
|
||||
|
@ -106,7 +106,8 @@ struct Chroot::Main
|
||||
Session_capability request_session(Parent::Client::Id const &id,
|
||||
Session_state::Args const &args)
|
||||
{
|
||||
char tmp[PATH_MAX_LEN];
|
||||
typedef String<PATH_MAX_LEN> Prefix;
|
||||
|
||||
Path root_path;
|
||||
|
||||
Session_label const label = label_from_args(args.string());
|
||||
@ -114,22 +115,24 @@ struct Chroot::Main
|
||||
|
||||
if (policy.has_attribute("path_prefix")) {
|
||||
/* Use a chroot path from policy and label sub-directories */
|
||||
policy.attribute("path_prefix").value(tmp, sizeof(tmp));
|
||||
root_path.import(tmp);
|
||||
Prefix const prefix = policy.attribute_value("path_prefix", Prefix());
|
||||
root_path.import(prefix.string());
|
||||
root_path.append(path_from_label<Path>(label.string()).string());
|
||||
} else if (policy.has_attribute("path")) {
|
||||
/* Use a chroot path from policy */
|
||||
policy.attribute("path").value(tmp, sizeof(tmp));
|
||||
root_path.import(tmp);
|
||||
root_path.import(policy.attribute_value("path", Prefix()).string());
|
||||
} else {
|
||||
/* generate implicit chroot path from the label */
|
||||
root_path = path_from_label<Path>(label.string());
|
||||
}
|
||||
|
||||
/* extract and append the orginal root */
|
||||
Arg_string::find_arg(args.string(), "root").string(
|
||||
tmp, sizeof(tmp), "/");
|
||||
root_path.append_element(tmp);
|
||||
/* extract and append the session argument */
|
||||
{
|
||||
char tmp[PATH_MAX_LEN];
|
||||
Arg_string::find_arg(args.string(), "root").string(tmp, sizeof(tmp), "/");
|
||||
root_path.append_element(tmp);
|
||||
}
|
||||
|
||||
root_path.remove_trailing('/');
|
||||
|
||||
char const *new_root = root_path.base();
|
||||
|
@ -59,7 +59,7 @@ struct Rom::Registry : Rom::Registry_for_reader, Rom::Registry_for_writer
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Registry(Genode::Ram_session &ram, Genode::Region_map &rm,
|
||||
Registry(Genode::Ram_allocator &ram, Genode::Region_map &rm,
|
||||
Module::Read_policy const &read_policy,
|
||||
Module::Write_policy const &write_policy)
|
||||
:
|
||||
|
@ -120,8 +120,9 @@ class Dynamic_rom::Session_component : public Rpc_object<Genode::Rom_session>
|
||||
if (curr_step.has_type("sleep")
|
||||
&& curr_step.has_attribute("milliseconds")) {
|
||||
|
||||
unsigned long milliseconds = 0;
|
||||
curr_step.attribute("milliseconds").value(&milliseconds);
|
||||
unsigned long const milliseconds =
|
||||
curr_step.attribute_value("milliseconds", 0UL);
|
||||
|
||||
_timer.trigger_once(milliseconds*1000);
|
||||
_log("sleep ", milliseconds, " milliseconds");
|
||||
|
||||
@ -175,9 +176,8 @@ class Dynamic_rom::Session_component : public Rpc_object<Genode::Rom_session>
|
||||
|
||||
/* fill with content of current step */
|
||||
Xml_node step_node = _rom_node.sub_node(_last_content_idx);
|
||||
memcpy(_ram_ds->local_addr<char>(),
|
||||
step_node.content_addr(),
|
||||
step_node.content_size());
|
||||
step_node.with_raw_content([&] (char const *start, size_t size) {
|
||||
memcpy(_ram_ds->local_addr<char>(), start, size); });
|
||||
|
||||
/* cast RAM into ROM dataspace capability */
|
||||
Dataspace_capability ds_cap = static_cap_cast<Dataspace>(_ram_ds->cap());
|
||||
|
@ -80,7 +80,7 @@ class Fs_log::Session_component : public Genode::Rpc_object<Genode::Log_session>
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
if (!msg.is_valid_string()) {
|
||||
if (!msg.valid_string()) {
|
||||
Genode::error("received corrupted string");
|
||||
return 0;
|
||||
}
|
||||
|
@ -92,8 +92,7 @@ struct Input_merger::Main
|
||||
|
||||
config_rom.xml().for_each_sub_node("input", [&] (Xml_node input_node) {
|
||||
try {
|
||||
Label label;
|
||||
input_node.attribute("label").value(&label);
|
||||
Label label = input_node.attribute_value("label", Label());
|
||||
|
||||
try {
|
||||
Input_source *input_source = new (heap)
|
||||
|
@ -56,6 +56,25 @@ class Loader::Child : public Child_policy
|
||||
|
||||
Genode::Child _child;
|
||||
|
||||
Service &_matching_service(Service::Name const &name)
|
||||
{
|
||||
if (name == "Nitpicker") return _local_nitpicker_service;
|
||||
if (name == "ROM") return _local_rom_service;
|
||||
if (name == "CPU") return _local_cpu_service;
|
||||
if (name == "PD") return _local_pd_service;
|
||||
|
||||
/* populate session-local parent service registry on demand */
|
||||
Service *service = nullptr;
|
||||
_parent_services.for_each([&] (Parent_service &s) {
|
||||
if (s.name() == name)
|
||||
service = &s; });
|
||||
|
||||
if (service)
|
||||
return *service;
|
||||
|
||||
return *new (_alloc) Parent_service(_parent_services, _env, name);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Child(Env &env,
|
||||
@ -106,24 +125,12 @@ class Loader::Child : public Child_policy
|
||||
ref_pd().transfer_quota(pd_cap, _ram_quota);
|
||||
}
|
||||
|
||||
Service &resolve_session_request(Service::Name const &name,
|
||||
Session_state::Args const &) override
|
||||
Route resolve_session_request(Service::Name const &name,
|
||||
Session_label const &label) override
|
||||
{
|
||||
if (name == "Nitpicker") return _local_nitpicker_service;
|
||||
if (name == "ROM") return _local_rom_service;
|
||||
if (name == "CPU") return _local_cpu_service;
|
||||
if (name == "PD") return _local_pd_service;
|
||||
|
||||
/* populate session-local parent service registry on demand */
|
||||
Service *service = nullptr;
|
||||
_parent_services.for_each([&] (Parent_service &s) {
|
||||
if (s.name() == name)
|
||||
service = &s; });
|
||||
|
||||
if (service)
|
||||
return *service;
|
||||
|
||||
return *new (_alloc) Parent_service(_parent_services, name);
|
||||
return Route { .service = _matching_service(name),
|
||||
.label = label,
|
||||
.diag = Session::Diag() };
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
/* local includes */
|
||||
#include <child.h>
|
||||
#include <nitpicker.h>
|
||||
#include <ram_session_client_guard.h>
|
||||
#include <rom.h>
|
||||
|
||||
|
||||
@ -206,7 +205,9 @@ class Loader::Session_component : public Rpc_object<Session>
|
||||
Xml_node const _config;
|
||||
Cap_quota const _cap_quota;
|
||||
Ram_quota const _ram_quota;
|
||||
Ram_session_client_guard _local_ram { _env.ram_session_cap(), _ram_quota };
|
||||
Cap_quota_guard _cap_guard { _cap_quota };
|
||||
Ram_quota_guard _ram_guard { _ram_quota };
|
||||
Constrained_ram_allocator _local_ram { _env.ram(), _ram_guard, _cap_guard };
|
||||
Heap _md_alloc { _local_ram, _env.rm() };
|
||||
size_t _subsystem_cap_quota_limit = 0;
|
||||
size_t _subsystem_ram_quota_limit = 0;
|
||||
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* \brief A guard for RAM session clients to limit memory exhaustion
|
||||
* \author Christian Prochaska
|
||||
* \date 2012-04-25
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _RAM_SESSION_CLIENT_GUARD_H_
|
||||
#define _RAM_SESSION_CLIENT_GUARD_H_
|
||||
|
||||
#include <base/lock.h>
|
||||
#include <base/log.h>
|
||||
#include <base/ram_allocator.h>
|
||||
#include <pd_session/client.h>
|
||||
#include <dataspace/client.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Ram_session_client_guard : public Ram_allocator
|
||||
{
|
||||
private:
|
||||
|
||||
Pd_session_client _pd;
|
||||
size_t const _amount; /* total amount */
|
||||
size_t _consumed; /* already consumed bytes */
|
||||
Lock mutable _consumed_lock { };
|
||||
|
||||
public:
|
||||
|
||||
Ram_session_client_guard(Pd_session_capability session, Ram_quota amount)
|
||||
: _pd(session), _amount(amount.value), _consumed(0) { }
|
||||
|
||||
Ram_dataspace_capability alloc(size_t size, Cache_attribute cached) override
|
||||
{
|
||||
Lock::Guard _consumed_lock_guard(_consumed_lock);
|
||||
|
||||
if ((_amount - _consumed) < size) {
|
||||
warning("quota exceeded! amount=", _amount, ", "
|
||||
"size=", size, ", consumed=", _consumed);
|
||||
return Ram_dataspace_capability();
|
||||
}
|
||||
|
||||
Ram_dataspace_capability cap = _pd.alloc(size, cached);
|
||||
|
||||
_consumed += size;
|
||||
|
||||
return cap;
|
||||
}
|
||||
|
||||
void free(Ram_dataspace_capability ds) override
|
||||
{
|
||||
Lock::Guard _consumed_lock_guard(_consumed_lock);
|
||||
|
||||
_consumed -= Dataspace_client(ds).size();
|
||||
|
||||
_pd.free(ds);
|
||||
}
|
||||
|
||||
size_t dataspace_size(Ram_dataspace_capability ds) const override
|
||||
{
|
||||
Lock::Guard _consumed_lock_guard(_consumed_lock);
|
||||
|
||||
return _pd.dataspace_size(ds);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _RAM_SESSION_CLIENT_GUARD_H_ */
|
@ -41,7 +41,7 @@ class Report::Session_component : public Genode::Rpc_object<Session>
|
||||
|
||||
public:
|
||||
|
||||
Session_component(Ram_session &ram,
|
||||
Session_component(Ram_allocator &ram,
|
||||
Region_map &rm,
|
||||
Genode::Session_label const &label,
|
||||
size_t buffer_size)
|
||||
@ -75,8 +75,8 @@ class Report::Root : public Genode::Root_component<Session_component>
|
||||
{
|
||||
private:
|
||||
|
||||
Ram_session &_ram;
|
||||
Region_map &_rm;
|
||||
Ram_allocator &_ram;
|
||||
Region_map &_rm;
|
||||
|
||||
protected:
|
||||
|
||||
@ -98,7 +98,7 @@ class Report::Root : public Genode::Root_component<Session_component>
|
||||
public:
|
||||
|
||||
Root(Entrypoint &ep, Genode::Allocator &md_alloc,
|
||||
Ram_session &ram, Region_map &rm)
|
||||
Ram_allocator &ram, Region_map &rm)
|
||||
:
|
||||
Genode::Root_component<Session_component>(&ep.rpc_ep(), &md_alloc),
|
||||
_ram(ram), _rm(rm)
|
||||
|
@ -99,9 +99,9 @@ class Terminal::Session_component : public Rpc_object<Session, Session_component
|
||||
|
||||
public:
|
||||
|
||||
Session_component(Ram_session &ram,
|
||||
Region_map &rm,
|
||||
size_t io_buffer_size)
|
||||
Session_component(Ram_allocator &ram,
|
||||
Region_map &rm,
|
||||
size_t io_buffer_size)
|
||||
:
|
||||
_io_buffer(ram, rm, io_buffer_size)
|
||||
{ }
|
||||
@ -157,8 +157,8 @@ class Terminal::Root_component : public Genode::Root_component<Session_component
|
||||
{
|
||||
private:
|
||||
|
||||
Ram_session &_ram;
|
||||
Region_map &_rm;
|
||||
Ram_allocator &_ram;
|
||||
Region_map &_rm;
|
||||
|
||||
protected:
|
||||
|
||||
@ -170,10 +170,10 @@ class Terminal::Root_component : public Genode::Root_component<Session_component
|
||||
|
||||
public:
|
||||
|
||||
Root_component(Entrypoint &ep,
|
||||
Allocator &md_alloc,
|
||||
Ram_session &ram,
|
||||
Region_map &rm)
|
||||
Root_component(Entrypoint &ep,
|
||||
Allocator &md_alloc,
|
||||
Ram_allocator &ram,
|
||||
Region_map &rm)
|
||||
:
|
||||
Genode::Root_component<Session_component>(&ep.rpc_ep(), &md_alloc),
|
||||
_ram(ram), _rm(rm)
|
||||
|
@ -41,7 +41,7 @@ class Lx_block_driver : public Block::Driver
|
||||
Genode::Env &_env;
|
||||
|
||||
Block::sector_t _block_count { 0 };
|
||||
Genode::size_t _block_size { 512 };
|
||||
Genode::size_t const _block_size { 512 };
|
||||
Block::Session::Operations _block_ops { };
|
||||
|
||||
int _fd { -1 };
|
||||
@ -51,26 +51,22 @@ class Lx_block_driver : public Block::Driver
|
||||
struct Could_not_open_file : Genode::Exception { };
|
||||
|
||||
Lx_block_driver(Genode::Env &env, Genode::Xml_node config)
|
||||
: Block::Driver(env.ram()), _env(env)
|
||||
:
|
||||
Block::Driver(env.ram()),
|
||||
_env(env),
|
||||
_block_size(config.attribute_value("block_size", Genode::Number_of_bytes()))
|
||||
{
|
||||
Genode::String<256> file;
|
||||
try {
|
||||
config.attribute("file").value(&file);
|
||||
} catch (...) {
|
||||
if (!config.has_attribute("block_size"))
|
||||
Genode::warning("block size missing, assuming 512b");
|
||||
|
||||
bool const writeable = xml_attr_ok(config, "writeable");
|
||||
|
||||
if (!config.has_attribute("file")) {
|
||||
Genode::error("mandatory file attribute missing");
|
||||
throw Could_not_open_file();
|
||||
}
|
||||
|
||||
try {
|
||||
Genode::Number_of_bytes bytes;
|
||||
config.attribute("block_size").value(&bytes);
|
||||
_block_size = bytes;
|
||||
} catch (...) {
|
||||
Genode::warning("block size missing, assuming 512b");
|
||||
}
|
||||
|
||||
bool const writeable = xml_attr_ok(config, "writeable");
|
||||
|
||||
auto const file = config.attribute_value("file", Genode::String<256>());
|
||||
struct stat st;
|
||||
if (stat(file.string(), &st)) {
|
||||
perror("stat");
|
||||
|
@ -108,18 +108,19 @@ void Session_component::set_ipv4_address(Ipv4_address ip_addr)
|
||||
}
|
||||
|
||||
|
||||
Session_component::Session_component(Genode::Ram_session &ram,
|
||||
Session_component::Session_component(Genode::Ram_allocator &ram,
|
||||
Genode::Region_map &rm,
|
||||
Genode::Entrypoint &ep,
|
||||
Genode::size_t amount,
|
||||
Genode::Ram_quota ram_quota,
|
||||
Genode::Cap_quota cap_quota,
|
||||
Genode::size_t tx_buf_size,
|
||||
Genode::size_t rx_buf_size,
|
||||
Mac_address vmac,
|
||||
Net::Nic &nic,
|
||||
bool const &verbose,
|
||||
Genode::Session_label const &label,
|
||||
char *ip_addr)
|
||||
: Stream_allocator(ram, rm, amount),
|
||||
Ip_addr const &ip_addr)
|
||||
: Stream_allocator(ram, rm, ram_quota, cap_quota),
|
||||
Stream_dataspaces(ram, tx_buf_size, rx_buf_size),
|
||||
Session_rpc_object(rm,
|
||||
Stream_dataspaces::tx_ds,
|
||||
@ -133,12 +134,12 @@ Session_component::Session_component(Genode::Ram_session &ram,
|
||||
vlan().mac_tree.insert(&_mac_node);
|
||||
vlan().mac_list.insert(&_mac_node);
|
||||
|
||||
/* static ip parsing */
|
||||
if (ip_addr != 0 && Genode::strlen(ip_addr)) {
|
||||
Ipv4_address ip = Ipv4_packet::ip_from_string(ip_addr);
|
||||
/* static IP parsing */
|
||||
if (ip_addr.valid()) {
|
||||
Ipv4_address ip = Ipv4_packet::ip_from_string(ip_addr.string());
|
||||
|
||||
if (ip == Ipv4_address()) {
|
||||
Genode::warning("Empty or error ip address. Skipped.");
|
||||
Genode::warning("Empty or error IP address. Skipped.");
|
||||
} else {
|
||||
set_ipv4_address(ip);
|
||||
Genode::log("vmac = ", vmac, " ip = ", ip);
|
||||
|
@ -17,10 +17,10 @@
|
||||
/* Genode includes */
|
||||
#include <base/log.h>
|
||||
#include <base/heap.h>
|
||||
#include <base/ram_allocator.h>
|
||||
#include <nic/packet_allocator.h>
|
||||
#include <nic_session/rpc_object.h>
|
||||
#include <nic_session/connection.h>
|
||||
#include <os/ram_session_guard.h>
|
||||
#include <os/session_policy.h>
|
||||
#include <root/component.h>
|
||||
#include <util/arg_string.h>
|
||||
@ -50,18 +50,24 @@ class Net::Stream_allocator
|
||||
{
|
||||
protected:
|
||||
|
||||
Genode::Ram_session_guard _ram;
|
||||
Genode::Heap _heap;
|
||||
::Nic::Packet_allocator _range_alloc;
|
||||
Genode::Ram_quota_guard _ram_guard;
|
||||
Genode::Cap_quota_guard _cap_guard;
|
||||
Genode::Constrained_ram_allocator _ram;
|
||||
Genode::Heap _heap;
|
||||
::Nic::Packet_allocator _range_alloc;
|
||||
|
||||
public:
|
||||
|
||||
Stream_allocator(Genode::Ram_session &ram,
|
||||
Genode::Region_map &rm,
|
||||
Genode::size_t amount)
|
||||
: _ram(ram, amount),
|
||||
_heap(ram, rm),
|
||||
_range_alloc(&_heap) {}
|
||||
Stream_allocator(Genode::Ram_allocator &ram,
|
||||
Genode::Region_map &rm,
|
||||
Genode::Ram_quota ram_quota,
|
||||
Genode::Cap_quota cap_quota)
|
||||
:
|
||||
_ram_guard(ram_quota), _cap_guard(cap_quota),
|
||||
_ram(ram, _ram_guard, _cap_guard),
|
||||
_heap(ram, rm),
|
||||
_range_alloc(&_heap)
|
||||
{ }
|
||||
|
||||
Genode::Range_allocator *range_allocator() {
|
||||
return static_cast<Genode::Range_allocator *>(&_range_alloc); }
|
||||
@ -70,9 +76,9 @@ class Net::Stream_allocator
|
||||
|
||||
struct Net::Stream_dataspace : Genode::Ram_dataspace_capability
|
||||
{
|
||||
Genode::Ram_session &ram;
|
||||
Genode::Ram_allocator &ram;
|
||||
|
||||
Stream_dataspace(Genode::Ram_session &ram, Genode::size_t size)
|
||||
Stream_dataspace(Genode::Ram_allocator &ram, Genode::size_t size)
|
||||
: Genode::Ram_dataspace_capability(ram.alloc(size)), ram(ram) { }
|
||||
|
||||
~Stream_dataspace() { ram.free(*this); }
|
||||
@ -83,7 +89,7 @@ struct Net::Stream_dataspaces
|
||||
{
|
||||
Stream_dataspace tx_ds, rx_ds;
|
||||
|
||||
Stream_dataspaces(Genode::Ram_session &ram, Genode::size_t tx_size,
|
||||
Stream_dataspaces(Genode::Ram_allocator &ram, Genode::size_t tx_size,
|
||||
Genode::size_t rx_size)
|
||||
: tx_ds(ram, tx_size), rx_ds(ram, rx_size) { }
|
||||
};
|
||||
@ -112,6 +118,8 @@ class Net::Session_component : private Net::Stream_allocator,
|
||||
|
||||
public:
|
||||
|
||||
typedef Genode::String<32> Ip_addr;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -123,17 +131,18 @@ class Net::Session_component : private Net::Stream_allocator,
|
||||
* \param rx_buf_size buffer size for rx channel
|
||||
* \param vmac virtual mac address
|
||||
*/
|
||||
Session_component(Genode::Ram_session &ram,
|
||||
Session_component(Genode::Ram_allocator &ram,
|
||||
Genode::Region_map &rm,
|
||||
Genode::Entrypoint &ep,
|
||||
Genode::size_t amount,
|
||||
Genode::Ram_quota ram_quota,
|
||||
Genode::Cap_quota cap_quota,
|
||||
Genode::size_t tx_buf_size,
|
||||
Genode::size_t rx_buf_size,
|
||||
Mac_address vmac,
|
||||
Net::Nic &nic,
|
||||
bool const &verbose,
|
||||
Genode::Session_label const &label,
|
||||
char *ip_addr = 0);
|
||||
Ip_addr const &ip_addr);
|
||||
|
||||
~Session_component();
|
||||
|
||||
@ -200,66 +209,84 @@ class Net::Root : public Genode::Root_component<Net::Session_component>
|
||||
Genode::Xml_node _config;
|
||||
bool const &_verbose;
|
||||
|
||||
struct Policy
|
||||
{
|
||||
Session_component::Ip_addr ip_addr;
|
||||
|
||||
Mac_address mac;
|
||||
};
|
||||
|
||||
static Policy _session_policy(Genode::Session_label const &label,
|
||||
Genode::Xml_node config,
|
||||
Mac_allocator &mac_alloc)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
typedef Session_component::Ip_addr Ip_addr;
|
||||
|
||||
Ip_addr ip_addr { };
|
||||
|
||||
try {
|
||||
Session_policy const policy(label, config);
|
||||
|
||||
/* read IP address from policy */
|
||||
if (!policy.has_attribute("ip_addr"))
|
||||
warning("Missing \"ip_addr\" attribute in policy definition");
|
||||
|
||||
ip_addr = policy.attribute_value("ip_addr", Ip_addr());
|
||||
|
||||
/* determine session MAC address */
|
||||
if (policy.has_attribute("mac")) {
|
||||
|
||||
Mac_address const mac = policy.attribute_value("mac", Mac_address());
|
||||
|
||||
if (mac_alloc.mac_managed_by_allocator(mac)) {
|
||||
Genode::warning("Bad MAC address in policy");
|
||||
throw Service_denied();
|
||||
}
|
||||
return Policy { .ip_addr = ip_addr, .mac = mac };
|
||||
}
|
||||
|
||||
} catch (Session_policy::No_policy_defined) { }
|
||||
|
||||
/*
|
||||
* If no policy is defined or if the policy lacks a 'mac'
|
||||
* attribute, allocate a MAC from the allocator.
|
||||
*/
|
||||
auto alloc_mac = [&] ()
|
||||
{
|
||||
try { return mac_alloc.alloc(); }
|
||||
catch (Mac_allocator::Alloc_failed) {
|
||||
Genode::warning("MAC address allocation failed!"); }
|
||||
|
||||
throw Service_denied();
|
||||
};
|
||||
|
||||
return Policy { .ip_addr = ip_addr, .mac = alloc_mac() };
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
Session_component *_create_session(const char *args)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
enum { MAX_IP_ADDR_LENGTH = 16, };
|
||||
char ip_addr[MAX_IP_ADDR_LENGTH];
|
||||
memset(ip_addr, 0, MAX_IP_ADDR_LENGTH);
|
||||
Session_label const label = label_from_args(args);
|
||||
|
||||
Session_label label;
|
||||
Mac_address mac;
|
||||
try {
|
||||
label = label_from_args(args);
|
||||
Session_policy policy(label, _config);
|
||||
Policy const policy = _session_policy(label, _config, _mac_alloc);
|
||||
|
||||
/* determine session MAC address */
|
||||
try {
|
||||
policy.attribute("mac").value<Mac_address>(&mac);
|
||||
if (_mac_alloc.mac_managed_by_allocator(mac)) {
|
||||
Genode::warning("Bad MAC address in policy");
|
||||
throw Service_denied();
|
||||
}
|
||||
}
|
||||
catch (Xml_node::Nonexistent_attribute) {
|
||||
mac = _mac_alloc.alloc(); }
|
||||
|
||||
policy.attribute("ip_addr").value(ip_addr, sizeof(ip_addr));
|
||||
}
|
||||
catch (Xml_node::Nonexistent_attribute) {
|
||||
Genode::log("Missing \"ip_addr\" attribute in policy definition"); }
|
||||
|
||||
catch (Session_policy::No_policy_defined) {
|
||||
mac = _mac_alloc.alloc(); }
|
||||
|
||||
catch (Mac_allocator::Alloc_failed) {
|
||||
Genode::warning("Mac address allocation failed!");
|
||||
throw Service_denied();
|
||||
}
|
||||
size_t ram_quota =
|
||||
Arg_string::find_arg(args, "ram_quota" ).ulong_value(0);
|
||||
size_t tx_buf_size =
|
||||
size_t const tx_buf_size =
|
||||
Arg_string::find_arg(args, "tx_buf_size").ulong_value(0);
|
||||
size_t rx_buf_size =
|
||||
size_t const rx_buf_size =
|
||||
Arg_string::find_arg(args, "rx_buf_size").ulong_value(0);
|
||||
|
||||
try {
|
||||
return new (md_alloc())
|
||||
Session_component(_env.ram(), _env.rm(), _env.ep(),
|
||||
ram_quota, tx_buf_size, rx_buf_size,
|
||||
mac, _nic, _verbose, label, ip_addr);
|
||||
}
|
||||
catch (Out_of_ram) {
|
||||
Genode::warning("insufficient 'ram_quota'");
|
||||
throw Insufficient_ram_quota();
|
||||
}
|
||||
catch (Out_of_caps) {
|
||||
Genode::warning("insufficient 'cap_quota'");
|
||||
throw Insufficient_cap_quota();
|
||||
}
|
||||
return new (md_alloc())
|
||||
Session_component(_env.ram(), _env.rm(), _env.ep(),
|
||||
ram_quota_from_args(args),
|
||||
cap_quota_from_args(args),
|
||||
tx_buf_size, rx_buf_size,
|
||||
policy.mac, _nic, _verbose, label,
|
||||
policy.ip_addr);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -53,7 +53,7 @@ class Net::Mac_allocator
|
||||
|
||||
void free(Mac_address mac) { _free[mac.addr[5]] = true; }
|
||||
|
||||
bool mac_managed_by_allocator(Mac_address &mac)
|
||||
bool mac_managed_by_allocator(Mac_address const &mac) const
|
||||
{
|
||||
return _base.addr[0] == mac.addr[0] &&
|
||||
_base.addr[1] == mac.addr[1] &&
|
||||
|
@ -26,8 +26,8 @@ using namespace Genode;
|
||||
** Communication_buffer **
|
||||
**************************/
|
||||
|
||||
Communication_buffer::Communication_buffer(Ram_session &ram,
|
||||
Genode::size_t const size)
|
||||
Communication_buffer::Communication_buffer(Ram_allocator &ram,
|
||||
Genode::size_t const size)
|
||||
:
|
||||
Ram_dataspace_capability(ram.alloc(size)), _ram(ram)
|
||||
{ }
|
||||
@ -38,11 +38,11 @@ Communication_buffer::Communication_buffer(Ram_session &ram,
|
||||
****************************/
|
||||
|
||||
Session_component_base::
|
||||
Session_component_base(Allocator &guarded_alloc_backing,
|
||||
size_t const guarded_alloc_amount,
|
||||
Ram_session &buf_ram,
|
||||
size_t const tx_buf_size,
|
||||
size_t const rx_buf_size)
|
||||
Session_component_base(Allocator &guarded_alloc_backing,
|
||||
size_t const guarded_alloc_amount,
|
||||
Ram_allocator &buf_ram,
|
||||
size_t const tx_buf_size,
|
||||
size_t const rx_buf_size)
|
||||
:
|
||||
_guarded_alloc(&guarded_alloc_backing, guarded_alloc_amount),
|
||||
_range_alloc(&_guarded_alloc), _tx_buf(buf_ram, tx_buf_size),
|
||||
|
@ -37,12 +37,12 @@ class Net::Communication_buffer : public Genode::Ram_dataspace_capability
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Ram_session &_ram;
|
||||
Genode::Ram_allocator &_ram;
|
||||
|
||||
public:
|
||||
|
||||
Communication_buffer(Genode::Ram_session &ram,
|
||||
Genode::size_t const size);
|
||||
Communication_buffer(Genode::Ram_allocator &ram,
|
||||
Genode::size_t const size);
|
||||
|
||||
~Communication_buffer() { _ram.free(*this); }
|
||||
};
|
||||
@ -59,11 +59,11 @@ class Net::Session_component_base
|
||||
|
||||
public:
|
||||
|
||||
Session_component_base(Genode::Allocator &guarded_alloc_backing,
|
||||
Genode::size_t const guarded_alloc_amount,
|
||||
Genode::Ram_session &buf_ram,
|
||||
Genode::size_t const tx_buf_size,
|
||||
Genode::size_t const rx_buf_size);
|
||||
Session_component_base(Genode::Allocator &guarded_alloc_backing,
|
||||
Genode::size_t const guarded_alloc_amount,
|
||||
Genode::Ram_allocator &buf_ram,
|
||||
Genode::size_t const tx_buf_size,
|
||||
Genode::size_t const rx_buf_size);
|
||||
};
|
||||
|
||||
|
||||
|
@ -41,9 +41,6 @@ class Nic_loopback::Session_component : public Nic::Session_component
|
||||
* \param rx_buf_size buffer size for rx channel
|
||||
* \param rx_block_md_alloc backing store of the meta data of the
|
||||
* rx block allocator
|
||||
* \param ram_session RAM session to allocate tx and rx buffers
|
||||
* \param ep entry point used for packet stream
|
||||
* channels
|
||||
*/
|
||||
Session_component(size_t const tx_buf_size,
|
||||
size_t const rx_buf_size,
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <timer_session/connection.h>
|
||||
#include <base/allocator.h>
|
||||
#include <net/dhcp.h>
|
||||
|
||||
namespace Net {
|
||||
|
@ -42,7 +42,7 @@ class Nitpicker::Buffer
|
||||
* \throw Out_of_caps
|
||||
* \throw Region_map::Region_conflict
|
||||
*/
|
||||
Buffer(Ram_session &ram, Region_map &rm,
|
||||
Buffer(Ram_allocator &ram, Region_map &rm,
|
||||
Area size, Framebuffer::Mode::Format format, size_t bytes)
|
||||
:
|
||||
_size(size), _format(format), _ram_ds(ram, rm, bytes)
|
||||
|
@ -44,7 +44,7 @@ class Nitpicker::Chunky_texture : public Buffer, public Texture<PT>
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Chunky_texture(Ram_session &ram, Region_map &rm, Area size, bool use_alpha)
|
||||
Chunky_texture(Ram_allocator &ram, Region_map &rm, Area size, bool use_alpha)
|
||||
:
|
||||
Buffer(ram, rm, size, _format(), calc_num_bytes(size, use_alpha)),
|
||||
Texture<PT>((PT *)local_addr(),
|
||||
|
@ -183,21 +183,13 @@ class Nitpicker::Domain_registry
|
||||
|
||||
void _insert(Xml_node domain)
|
||||
{
|
||||
char buf[sizeof(Entry::Name)];
|
||||
buf[0] = 0;
|
||||
bool name_defined = false;
|
||||
try {
|
||||
domain.attribute("name").value(buf, sizeof(buf));
|
||||
name_defined = true;
|
||||
} catch (...) { }
|
||||
Entry::Name const name = domain.attribute_value("name", Entry::Name());
|
||||
|
||||
if (!name_defined) {
|
||||
if (!name.valid()) {
|
||||
error("no valid domain name specified");
|
||||
return;
|
||||
}
|
||||
|
||||
Entry::Name const name(buf);
|
||||
|
||||
if (lookup(name)) {
|
||||
error("domain name \"", name, "\" is not unique");
|
||||
return;
|
||||
|
@ -316,14 +316,10 @@ void Session_component::apply_session_policy(Xml_node config,
|
||||
return;
|
||||
}
|
||||
|
||||
typedef Domain_registry::Entry::Name Domain_name;
|
||||
char buf[sizeof(Domain_name)];
|
||||
buf[0] = 0;
|
||||
try {
|
||||
policy.attribute("domain").value(buf, sizeof(buf)); }
|
||||
catch (...) { }
|
||||
typedef Domain_registry::Entry::Name Name;
|
||||
|
||||
Name const name = policy.attribute_value("domain", Name());
|
||||
|
||||
Domain_name name(buf);
|
||||
_domain = domain_registry.lookup(name);
|
||||
|
||||
if (!_domain)
|
||||
@ -481,7 +477,7 @@ Buffer *Session_component::realloc_buffer(Framebuffer::Mode mode, bool use_alpha
|
||||
if (texture()) {
|
||||
|
||||
enum { PRESERVED_RAM = 128*1024 };
|
||||
if (_env.ram().avail_ram().value > _buffer_size + PRESERVED_RAM) {
|
||||
if (_env.pd().avail_ram().value > _buffer_size + PRESERVED_RAM) {
|
||||
src_texture = static_cast<Texture<PT> const *>(texture());
|
||||
} else {
|
||||
warning("not enough RAM to preserve buffer content during resize");
|
||||
|
@ -273,7 +273,7 @@ class Block::Root :
|
||||
Session_policy policy(label, _config);
|
||||
|
||||
/* read partition attribute */
|
||||
policy.attribute("partition").value(&num);
|
||||
num = policy.attribute_value("partition", -1L);
|
||||
|
||||
/* sessions are not writeable by default */
|
||||
writeable = policy.attribute_value("writeable", false);
|
||||
|
@ -78,7 +78,8 @@ class Ram_block : public Block::Driver
|
||||
*/
|
||||
Ram_block(Env &env, Allocator &alloc,
|
||||
const char *name, size_t block_size)
|
||||
: Block::Driver(env.ram()),
|
||||
:
|
||||
Block::Driver(env.ram()),
|
||||
_env(env), _alloc(&alloc),
|
||||
_rom_ds(new (_alloc) Attached_rom_dataspace(_env, name)),
|
||||
_size(_rom_ds->size()),
|
||||
@ -152,29 +153,28 @@ struct Main
|
||||
Env &env;
|
||||
Allocator &alloc;
|
||||
|
||||
bool use_file { false };
|
||||
char file[64];
|
||||
bool use_file { false };
|
||||
|
||||
typedef String<64> File;
|
||||
File file { };
|
||||
|
||||
size_t size { 0 };
|
||||
size_t block_size { 512 };
|
||||
|
||||
Factory(Env &env, Allocator &alloc,
|
||||
Xml_node config)
|
||||
Factory(Env &env, Allocator &alloc, Xml_node config)
|
||||
: env(env), alloc(alloc)
|
||||
{
|
||||
use_file = config.has_attribute("file");
|
||||
if (use_file) {
|
||||
config.attribute("file").value(file, sizeof(file));
|
||||
file = config.attribute_value("file", File());
|
||||
|
||||
} else {
|
||||
try {
|
||||
Genode::Number_of_bytes bytes;
|
||||
config.attribute("size").value(&bytes);
|
||||
size = bytes;
|
||||
}
|
||||
catch (...) {
|
||||
|
||||
if (!config.has_attribute("size")) {
|
||||
error("neither file nor size attribute specified");
|
||||
throw Exception();
|
||||
}
|
||||
size = config.attribute_value("size", Number_of_bytes());
|
||||
}
|
||||
|
||||
block_size = config.attribute_value("block_size", block_size);
|
||||
@ -185,8 +185,9 @@ struct Main
|
||||
try {
|
||||
if (use_file) {
|
||||
Genode::log("Creating RAM-basd block device populated by file='",
|
||||
Genode::Cstring(file), "' with block size ", block_size);
|
||||
return new (&alloc) Ram_block(env, alloc, file, block_size);
|
||||
file, "' with block size ", block_size);
|
||||
return new (&alloc)
|
||||
Ram_block(env, alloc, file.string(), block_size);
|
||||
} else {
|
||||
Genode::log("Creating RAM-based block device with size ",
|
||||
size, " and block size ", block_size);
|
||||
|
@ -47,7 +47,7 @@ class Ram_fs::Session_component : public File_system::Session_rpc_object
|
||||
typedef File_system::Open_node<Node> Open_node;
|
||||
|
||||
Genode::Entrypoint &_ep;
|
||||
Genode::Ram_session &_ram;
|
||||
Genode::Ram_allocator &_ram;
|
||||
Genode::Allocator &_alloc;
|
||||
Directory &_root;
|
||||
Id_space<File_system::Node> _open_node_registry { };
|
||||
@ -194,7 +194,7 @@ class Ram_fs::Session_component : public File_system::Session_rpc_object
|
||||
* Constructor
|
||||
*/
|
||||
Session_component(size_t tx_buf_size, Genode::Entrypoint &ep,
|
||||
Genode::Ram_session &ram, Genode::Region_map &rm,
|
||||
Genode::Ram_allocator &ram, Genode::Region_map &rm,
|
||||
Genode::Allocator &alloc,
|
||||
Directory &root, bool writable)
|
||||
:
|
||||
@ -535,7 +535,7 @@ class Ram_fs::Root : public Root_component<Session_component>
|
||||
|
||||
Genode::Entrypoint &_ep;
|
||||
Genode::Allocator &_alloc;
|
||||
Genode::Ram_session &_ram;
|
||||
Genode::Ram_allocator &_ram;
|
||||
Genode::Region_map &_rm;
|
||||
Genode::Xml_node const _config;
|
||||
Directory &_root_dir;
|
||||
@ -549,9 +549,7 @@ class Ram_fs::Root : public Root_component<Session_component>
|
||||
* the client's label.
|
||||
*/
|
||||
|
||||
enum { ROOT_MAX_LEN = 256 };
|
||||
Genode::Path<MAX_PATH_LEN> session_root;
|
||||
char tmp[MAX_PATH_LEN];
|
||||
|
||||
Directory *session_root_dir = nullptr;
|
||||
bool writeable = false;
|
||||
@ -564,14 +562,15 @@ class Ram_fs::Root : public Root_component<Session_component>
|
||||
* Determine directory that is used as root directory of
|
||||
* the session. Clients without a specified root are denied.
|
||||
*/
|
||||
try {
|
||||
policy.attribute("root").value(tmp, sizeof(tmp));
|
||||
session_root.import(tmp, "/");
|
||||
} catch (Xml_node::Nonexistent_attribute) {
|
||||
if (!policy.has_attribute("root")) {
|
||||
Genode::error("missing \"root\" attribute in policy definition");
|
||||
throw Service_denied();
|
||||
}
|
||||
|
||||
typedef String<MAX_PATH_LEN> Root;
|
||||
Root const root = policy.attribute_value("root", Root());
|
||||
session_root.import(root.string(), "/");
|
||||
|
||||
/*
|
||||
* Determine if the session is writeable.
|
||||
* Policy overrides client argument, both default to false.
|
||||
@ -585,10 +584,13 @@ class Ram_fs::Root : public Root_component<Session_component>
|
||||
}
|
||||
|
||||
/* apply client's root offset */
|
||||
Arg_string::find_arg(args, "root").string(tmp, sizeof(tmp), "/");
|
||||
if (Genode::strcmp("/", tmp, sizeof(tmp))) {
|
||||
session_root.append("/");
|
||||
session_root.append(tmp);
|
||||
{
|
||||
char tmp[MAX_PATH_LEN] { };
|
||||
Arg_string::find_arg(args, "root").string(tmp, sizeof(tmp), "/");
|
||||
if (Genode::strcmp("/", tmp, sizeof(tmp))) {
|
||||
session_root.append("/");
|
||||
session_root.append(tmp);
|
||||
}
|
||||
}
|
||||
session_root.remove_trailing('/');
|
||||
if (session_root == "/") {
|
||||
@ -641,7 +643,7 @@ class Ram_fs::Root : public Root_component<Session_component>
|
||||
* \param alloc general-purpose allocator
|
||||
* \param root_dir root-directory handle (anchor for fs)
|
||||
*/
|
||||
Root(Genode::Entrypoint &ep, Genode::Ram_session &ram,
|
||||
Root(Genode::Entrypoint &ep, Genode::Ram_allocator &ram,
|
||||
Genode::Region_map &rm, Genode::Xml_node config,
|
||||
Allocator &md_alloc, Allocator &alloc, Directory &root_dir)
|
||||
:
|
||||
@ -652,45 +654,6 @@ class Ram_fs::Root : public Root_component<Session_component>
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Helper for conveniently accessing 'Xml_node' attribute strings
|
||||
*/
|
||||
struct Attribute_string
|
||||
{
|
||||
char buf[File_system::MAX_NAME_LEN];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param attr attribute name
|
||||
* \param fallback if non-null, this is the string used if the attribute
|
||||
* is not defined. If null, the constructor throws
|
||||
* an 'Nonexistent_attribute' exception'
|
||||
* \throw Xml_node::Nonexistent_attribute
|
||||
*/
|
||||
Attribute_string(Genode::Xml_node node, char const *attr, char *fallback = 0)
|
||||
{
|
||||
try { node.attribute(attr).value(buf, sizeof(buf)); }
|
||||
catch (Genode::Xml_node::Nonexistent_attribute) {
|
||||
|
||||
if (fallback) {
|
||||
Genode::strncpy(buf, fallback, sizeof(buf));
|
||||
} else {
|
||||
char type_name[16];
|
||||
node.type_name(type_name, sizeof(type_name));
|
||||
Genode::warning("missing \"", attr, "\" attribute in "
|
||||
"<", Genode::Cstring(type_name), "> node");
|
||||
throw Genode::Xml_node::Nonexistent_attribute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
operator char * () { return buf; }
|
||||
|
||||
void print(Genode::Output &out) const { Genode::print(out, Genode::Cstring(buf)); }
|
||||
};
|
||||
|
||||
|
||||
static void preload_content(Genode::Env &env,
|
||||
Genode::Allocator &alloc,
|
||||
Genode::Xml_node node,
|
||||
@ -705,14 +668,15 @@ static void preload_content(Genode::Env &env,
|
||||
* Lookup name attribtue, let 'Nonexistent_attribute' exception fall
|
||||
* through because this configuration error is considered fatal.
|
||||
*/
|
||||
Attribute_string name(sub_node, "name");
|
||||
typedef String<MAX_NAME_LEN> Name;
|
||||
Name const name = sub_node.attribute_value("name", Name());
|
||||
|
||||
/*
|
||||
* Create directory
|
||||
*/
|
||||
if (sub_node.has_type("dir")) {
|
||||
|
||||
Ram_fs::Directory *sub_dir = new (&alloc) Ram_fs::Directory(name);
|
||||
Ram_fs::Directory *sub_dir = new (&alloc) Ram_fs::Directory(name.string());
|
||||
|
||||
/* traverse into the new directory */
|
||||
preload_content(env, alloc, sub_node, *sub_dir);
|
||||
@ -726,15 +690,15 @@ static void preload_content(Genode::Env &env,
|
||||
if (sub_node.has_type("rom")) {
|
||||
|
||||
/* read "as" attribute, use "name" as default */
|
||||
Attribute_string as(sub_node, "as", name);
|
||||
Name const as = sub_node.attribute_value("as", name);
|
||||
|
||||
/* read file content from ROM module */
|
||||
try {
|
||||
Attached_rom_dataspace rom(env, name);
|
||||
Attached_rom_dataspace rom(env, name.string());
|
||||
|
||||
Ram_fs::File *file = new (&alloc) Ram_fs::File(alloc, as);
|
||||
file->write(rom.local_addr<char>(), rom.size(), 0);
|
||||
dir.adopt_unsynchronized(file);
|
||||
Ram_fs::File &file = *new (&alloc) Ram_fs::File(alloc, as.string());
|
||||
file.write(rom.local_addr<char>(), rom.size(), 0);
|
||||
dir.adopt_unsynchronized(&file);
|
||||
}
|
||||
catch (Rom_connection::Rom_connection_failed) {
|
||||
Genode::warning("failed to open ROM module \"", name, "\""); }
|
||||
@ -747,9 +711,12 @@ static void preload_content(Genode::Env &env,
|
||||
*/
|
||||
if (sub_node.has_type("inline")) {
|
||||
|
||||
Ram_fs::File *file = new (&alloc) Ram_fs::File(alloc, name);
|
||||
file->write(sub_node.content_addr(), sub_node.content_size(), 0);
|
||||
dir.adopt_unsynchronized(file);
|
||||
Ram_fs::File &file = *new (&alloc) Ram_fs::File(alloc, name.string());
|
||||
|
||||
sub_node.with_raw_content([&] (char const *start, size_t length) {
|
||||
file.write(start, length, 0); });
|
||||
|
||||
dir.adopt_unsynchronized(&file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ struct Rom::Registry : Registry_for_reader, Registry_for_writer, Genode::Noncopy
|
||||
private:
|
||||
|
||||
Genode::Allocator &_md_alloc;
|
||||
Genode::Ram_session &_ram;
|
||||
Genode::Ram_allocator &_ram;
|
||||
Genode::Region_map &_rm;
|
||||
Genode::Attached_rom_dataspace &_config_rom;
|
||||
|
||||
@ -119,26 +119,13 @@ struct Rom::Registry : Registry_for_reader, Registry_for_writer, Genode::Noncopy
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
String<Rom::Module::Name::capacity()> report;
|
||||
|
||||
_config_rom.update();
|
||||
|
||||
try {
|
||||
Session_policy policy(rom_label, _config_rom.xml());
|
||||
policy.attribute("report").value(&report);
|
||||
return Rom::Module::Name(report.string());
|
||||
} catch (Session_policy::No_policy_defined) {
|
||||
/* FIXME backwards compatibility, remove at next release */
|
||||
try {
|
||||
Xml_node rom_node = _config_rom.xml().sub_node("rom");
|
||||
warning("parsing legacy <rom> policies");
|
||||
|
||||
Session_policy policy(rom_label, rom_node);
|
||||
policy.attribute("report").value(&report);
|
||||
return Rom::Module::Name(report.string());
|
||||
}
|
||||
catch (Xml_node::Nonexistent_sub_node) { /* no <rom> node */ }
|
||||
catch (Session_policy::No_policy_defined) { }
|
||||
return policy.attribute_value("report", Module::Name());
|
||||
}
|
||||
catch (Session_policy::No_policy_defined) { }
|
||||
|
||||
warning("no valid policy for ROM request '", rom_label, "'");
|
||||
throw Service_denied();
|
||||
@ -147,7 +134,7 @@ struct Rom::Registry : Registry_for_reader, Registry_for_writer, Genode::Noncopy
|
||||
public:
|
||||
|
||||
Registry(Genode::Allocator &md_alloc,
|
||||
Genode::Ram_session &ram, Genode::Region_map &rm,
|
||||
Genode::Ram_allocator &ram, Genode::Region_map &rm,
|
||||
Genode::Attached_rom_dataspace &config_rom)
|
||||
:
|
||||
_md_alloc(md_alloc), _ram(ram), _rm(rm), _config_rom(config_rom)
|
||||
|
@ -35,7 +35,7 @@ class Rom_block : public Block::Driver
|
||||
|
||||
using String = Genode::String<64UL>;
|
||||
|
||||
Rom_block(Env &env, String &name, size_t blk_sz)
|
||||
Rom_block(Env &env, String const &name, size_t blk_sz)
|
||||
: Block::Driver(env.ram()), _env(env), _rom(env, name.string()),
|
||||
_blk_sz(blk_sz) {}
|
||||
|
||||
@ -92,23 +92,22 @@ struct Main
|
||||
|
||||
Block::Driver *create()
|
||||
{
|
||||
Rom_block::String file;
|
||||
size_t blk_sz = 512;
|
||||
Attached_rom_dataspace config(env, "config");
|
||||
|
||||
try {
|
||||
Attached_rom_dataspace config(env, "config");
|
||||
config.xml().attribute("file").value(&file);
|
||||
config.xml().attribute("block_size").value(&blk_sz);
|
||||
}
|
||||
catch (...) { }
|
||||
Rom_block::String const file =
|
||||
config.xml().attribute_value("file", Rom_block::String());
|
||||
|
||||
log("Using file=", file, " as device with block size ", blk_sz, ".");
|
||||
size_t const blk_sz =
|
||||
config.xml().attribute_value("block_size", 512UL);
|
||||
|
||||
log("using file=", file, " as device with block size ", blk_sz, ".");
|
||||
|
||||
try {
|
||||
return new (&heap) Rom_block(env, file, blk_sz);
|
||||
} catch(Rom_connection::Rom_connection_failed) {
|
||||
error("cannot open file ", file);
|
||||
}
|
||||
catch (Rom_connection::Rom_connection_failed) {
|
||||
error("cannot open file ", file); }
|
||||
|
||||
throw Service_denied();
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,6 @@ namespace Rom_filter {
|
||||
typedef Genode::String<80> Node_type_name;
|
||||
typedef Genode::String<80> Attribute_name;
|
||||
|
||||
|
||||
using Genode::env;
|
||||
using Genode::Signal_context_capability;
|
||||
using Genode::Signal_handler;
|
||||
using Genode::Xml_node;
|
||||
@ -439,7 +437,8 @@ class Rom_filter::Input_rom_registry
|
||||
if (!e)
|
||||
throw Nonexistent_input_node();
|
||||
|
||||
xml.append(e->node().addr(), e->node().size());
|
||||
e->node().with_raw_node([&] (char const *start, Genode::size_t length) {
|
||||
xml.append(start, length); });
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -322,26 +322,27 @@ void Rom_filter::Main::_evaluate_node(Xml_node node, Xml_generator &xml)
|
||||
} else
|
||||
|
||||
if (node.has_type("inline")) {
|
||||
char const *src = node.content_base();
|
||||
size_t src_len = node.content_size();
|
||||
|
||||
/*
|
||||
* The 'Xml_generator::append' method puts the content at a fresh
|
||||
* line, and also adds a newline before the closing tag. We strip
|
||||
* eventual newlines from the '<inline>' node content to avoid
|
||||
* double newlines in the output.
|
||||
*/
|
||||
node.with_raw_content([&] (char const *src, size_t len) {
|
||||
|
||||
/* remove leading newline */
|
||||
if (src_len > 0 && src[0] == '\n') {
|
||||
src++;
|
||||
src_len--;
|
||||
}
|
||||
/*
|
||||
* The 'Xml_generator::append' method puts the content at a
|
||||
* fresh line, and also adds a newline before the closing tag.
|
||||
* We strip eventual newlines from the '<inline>' node content
|
||||
* to avoid double newlines in the output.
|
||||
*/
|
||||
|
||||
/* remove trailing whilespace including newlines */
|
||||
for (; src_len > 0 && Genode::is_whitespace(src[src_len - 1]); src_len--);
|
||||
/* remove leading newline */
|
||||
if (len > 0 && src[0] == '\n') {
|
||||
src++;
|
||||
len--;
|
||||
}
|
||||
|
||||
xml.append(src, src_len);
|
||||
/* remove trailing whilespace including newlines */
|
||||
for (; len > 0 && Genode::is_whitespace(src[len - 1]); len--);
|
||||
|
||||
xml.append(src, len);
|
||||
});
|
||||
} else
|
||||
|
||||
if (node.has_type("input")) {
|
||||
|
@ -42,7 +42,7 @@ class Tar_rom::Rom_session_component : public Rpc_object<Rom_session>
|
||||
Rom_session_component(Rom_session_component const &);
|
||||
Rom_session_component &operator = (Rom_session_component const &);
|
||||
|
||||
Ram_session &_ram;
|
||||
Ram_allocator &_ram;
|
||||
|
||||
char const * const _tar_addr;
|
||||
size_t const _tar_size;
|
||||
@ -76,7 +76,7 @@ class Tar_rom::Rom_session_component : public Rpc_object<Rom_session>
|
||||
/**
|
||||
* Initialize dataspace containing the content of the archived file
|
||||
*/
|
||||
Ram_dataspace_capability _init_file_ds(Ram_session &ram, Region_map &rm,
|
||||
Ram_dataspace_capability _init_file_ds(Ram_allocator &ram, Region_map &rm,
|
||||
Session_label const &name)
|
||||
{
|
||||
/* measure size of archive in blocks */
|
||||
@ -151,7 +151,7 @@ class Tar_rom::Rom_session_component : public Rpc_object<Rom_session>
|
||||
*
|
||||
* \throw Service_denied
|
||||
*/
|
||||
Rom_session_component(Ram_session &ram, Region_map &rm,
|
||||
Rom_session_component(Ram_allocator &ram, Region_map &rm,
|
||||
char const *tar_addr, unsigned tar_size,
|
||||
Session_label const &label)
|
||||
:
|
||||
|
@ -14,9 +14,7 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/env.h>
|
||||
#include <base/printf.h>
|
||||
#include <base/rpc_server.h>
|
||||
#include <base/signal.h>
|
||||
#include <util/misc_math.h>
|
||||
|
||||
/* local includes */
|
||||
|
@ -39,12 +39,44 @@ namespace Trace_fs {
|
||||
using File_system::Path;
|
||||
|
||||
class Trace_file_system;
|
||||
struct Policy;
|
||||
struct Main;
|
||||
struct Session_component;
|
||||
struct Root;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Session-specific policy defined by the configuation
|
||||
*/
|
||||
struct Trace_fs::Policy
|
||||
{
|
||||
unsigned interval; /* in milliseconds */
|
||||
unsigned subject_limit;
|
||||
Genode::Number_of_bytes trace_quota;
|
||||
Genode::Number_of_bytes trace_meta_quota;
|
||||
Genode::Number_of_bytes buffer_size;
|
||||
Genode::Number_of_bytes buffer_size_max;
|
||||
unsigned trace_parent_levels;
|
||||
|
||||
static Number_of_bytes _kib(size_t value) { return value * (1 << 10); }
|
||||
static Number_of_bytes _mib(size_t value) { return value * (1 << 20); }
|
||||
|
||||
static Policy from_xml(Xml_node node)
|
||||
{
|
||||
return Policy {
|
||||
.interval = node.attribute_value("interval", 1000U),
|
||||
.subject_limit = node.attribute_value("subject_limit", 128U),
|
||||
.trace_quota = node.attribute_value("trace_quota", _mib(32)),
|
||||
.trace_meta_quota = node.attribute_value("trace_meta_quota", _kib(256)),
|
||||
.buffer_size = node.attribute_value("buffer_size", _kib(32)),
|
||||
.buffer_size_max = node.attribute_value("buffer_size_max", _mib(1)),
|
||||
.trace_parent_levels = node.attribute_value("parent_levels", 0U)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Return true if 'str' is a valid file name
|
||||
*/
|
||||
@ -610,7 +642,7 @@ class Trace_fs::Session_component : public Session_rpc_object
|
||||
typedef File_system::Open_node<Node> Open_node;
|
||||
|
||||
Genode::Entrypoint &_ep;
|
||||
Ram_session &_ram;
|
||||
Ram_allocator &_ram;
|
||||
Allocator &_md_alloc;
|
||||
Directory &_root_dir;
|
||||
Id_space<File_system::Node> _open_node_registry;
|
||||
@ -624,8 +656,11 @@ class Trace_fs::Session_component : public Session_rpc_object
|
||||
Trace::Connection *_trace;
|
||||
Trace_file_system *_trace_fs;
|
||||
|
||||
Signal_handler<Session_component> _process_packet_dispatcher;
|
||||
Signal_handler<Session_component> _fs_update_dispatcher;
|
||||
Signal_handler<Session_component> _process_packet_handler {
|
||||
_ep, *this, &Session_component::_process_packets };
|
||||
|
||||
Signal_handler<Session_component> _fs_update_handler {
|
||||
_ep, *this, &Session_component::_fs_update };
|
||||
|
||||
|
||||
/**************************
|
||||
@ -740,7 +775,7 @@ class Trace_fs::Session_component : public Session_rpc_object
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by signal dispatcher, executed in the context of the main
|
||||
* Called by signal handler, executed in the context of the main
|
||||
* thread (not serialized with the RPC functions)
|
||||
*/
|
||||
void _process_packets()
|
||||
@ -783,42 +818,40 @@ class Trace_fs::Session_component : public Session_rpc_object
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Session_component(size_t tx_buf_size,
|
||||
Genode::Entrypoint &ep,
|
||||
Genode::Ram_session &ram,
|
||||
Genode::Region_map &rm,
|
||||
Genode::Env &env,
|
||||
Directory &root_dir,
|
||||
Allocator &md_alloc,
|
||||
unsigned subject_limit,
|
||||
unsigned poll_interval,
|
||||
size_t trace_quota,
|
||||
size_t trace_meta_quota,
|
||||
size_t trace_parent_levels,
|
||||
size_t buffer_size,
|
||||
size_t buffer_size_max)
|
||||
Session_component(size_t tx_buf_size,
|
||||
Genode::Entrypoint &ep,
|
||||
Genode::Ram_allocator &ram,
|
||||
Genode::Region_map &rm,
|
||||
Genode::Env &env,
|
||||
Directory &root_dir,
|
||||
Allocator &md_alloc,
|
||||
Trace_fs::Policy policy)
|
||||
:
|
||||
Session_rpc_object(ram.alloc(tx_buf_size), rm, ep.rpc_ep()),
|
||||
_ep(ep),
|
||||
_ram(ram),
|
||||
_md_alloc(md_alloc),
|
||||
_root_dir(root_dir),
|
||||
_subject_limit(subject_limit),
|
||||
_poll_interval(poll_interval),
|
||||
|
||||
_subject_limit(policy.subject_limit),
|
||||
_poll_interval(policy.interval),
|
||||
_fs_update_timer(env),
|
||||
_trace(new (&_md_alloc) Genode::Trace::Connection(env, trace_quota, trace_meta_quota, trace_parent_levels)),
|
||||
_trace_fs(new (&_md_alloc) Trace_file_system(rm, _md_alloc, *_trace, _root_dir, buffer_size, buffer_size_max)),
|
||||
_process_packet_dispatcher(_ep, *this, &Session_component::_process_packets),
|
||||
_fs_update_dispatcher(_ep, *this, &Session_component::_fs_update)
|
||||
_trace(new (&_md_alloc)
|
||||
Genode::Trace::Connection(env, policy.trace_quota,
|
||||
policy.trace_meta_quota,
|
||||
policy.trace_parent_levels)),
|
||||
_trace_fs(new (&_md_alloc)
|
||||
Trace_file_system(rm, _md_alloc, *_trace, _root_dir,
|
||||
policy.buffer_size, policy.buffer_size_max))
|
||||
{
|
||||
_tx.sigh_packet_avail(_process_packet_dispatcher);
|
||||
_tx.sigh_ready_to_ack(_process_packet_dispatcher);
|
||||
_tx.sigh_packet_avail(_process_packet_handler);
|
||||
_tx.sigh_ready_to_ack(_process_packet_handler);
|
||||
|
||||
/**
|
||||
* Register '_fs_update' dispatch function as signal handler
|
||||
* for polling the trace session.
|
||||
*/
|
||||
_fs_update_timer.sigh(_fs_update_dispatcher);
|
||||
_fs_update_timer.sigh(_fs_update_handler);
|
||||
|
||||
/**
|
||||
* We need to scale _poll_interval because trigger_periodic()
|
||||
@ -1004,12 +1037,12 @@ class Trace_fs::Root : public Root_component<Session_component>
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Entrypoint &_ep;
|
||||
Genode::Ram_session &_ram;
|
||||
Genode::Region_map &_rm;
|
||||
Genode::Env &_env;
|
||||
Genode::Entrypoint &_ep;
|
||||
Genode::Ram_allocator &_ram;
|
||||
Genode::Region_map &_rm;
|
||||
Genode::Env &_env;
|
||||
|
||||
Directory &_root_dir;
|
||||
Directory &_root_dir;
|
||||
|
||||
Genode::Attached_rom_dataspace _config { _env, "config" };
|
||||
|
||||
@ -1021,74 +1054,18 @@ class Trace_fs::Root : public Root_component<Session_component>
|
||||
* Determine client-specific policy defined implicitly by
|
||||
* the client's label.
|
||||
*/
|
||||
|
||||
enum { ROOT_MAX_LEN = 256 };
|
||||
char root[ROOT_MAX_LEN];
|
||||
root[0] = 0;
|
||||
|
||||
/* default settings */
|
||||
unsigned interval = 1000; /* 1 sec */
|
||||
unsigned subject_limit = 128;
|
||||
|
||||
Genode::Number_of_bytes trace_quota = 32 * (1 << 20); /* 32 MiB */
|
||||
Genode::Number_of_bytes trace_meta_quota = 256 * (1 << 10); /* 256 KiB */
|
||||
Genode::Number_of_bytes buffer_size = 32 * (1 << 10); /* 32 KiB */
|
||||
Genode::Number_of_bytes buffer_size_max = 1 * (1 << 20); /* 1 MiB */
|
||||
unsigned trace_parent_levels = 0;
|
||||
|
||||
Session_label const label = label_from_args(args);
|
||||
try {
|
||||
Session_policy policy(label, _config.xml());
|
||||
|
||||
/*
|
||||
* Override default settings with specific session settings by
|
||||
* evaluating the policy.
|
||||
*/
|
||||
try { policy.attribute("interval").value(&interval); }
|
||||
catch (...) { }
|
||||
try { policy.attribute("subject_limit").value(&subject_limit); }
|
||||
catch (...) { }
|
||||
try { policy.attribute("trace_quota").value(&trace_quota); }
|
||||
catch (...) { }
|
||||
try { policy.attribute("trace_meta_quota").value(&trace_meta_quota); }
|
||||
catch (...) { }
|
||||
try { policy.attribute("parent_levels").value(&trace_parent_levels); }
|
||||
catch (...) { }
|
||||
try { policy.attribute("buffer_size").value(&buffer_size); }
|
||||
catch (...) { }
|
||||
try { policy.attribute("buffer_size_max").value(&buffer_size_max); }
|
||||
catch (...) { }
|
||||
Session_policy policy(label, _config.xml());
|
||||
|
||||
/*
|
||||
* Determine directory that is used as root directory of
|
||||
* the session.
|
||||
*/
|
||||
try {
|
||||
policy.attribute("root").value(root, sizeof(root));
|
||||
|
||||
/*
|
||||
* Make sure the root path is specified with a
|
||||
* leading path delimiter. For performing the
|
||||
* lookup, we skip the first character.
|
||||
*/
|
||||
if (root[0] != '/')
|
||||
throw Lookup_failed();
|
||||
}
|
||||
catch (Xml_node::Nonexistent_attribute) {
|
||||
Genode::error("Missing \"root\" attribute in policy definition");
|
||||
throw Service_denied();
|
||||
}
|
||||
catch (Lookup_failed) {
|
||||
Genode::error("session root directory "
|
||||
"\"", Genode::Cstring(root), "\" does not exist");
|
||||
throw Service_denied();
|
||||
}
|
||||
}
|
||||
catch (Session_policy::No_policy_defined) {
|
||||
Genode::error("Invalid session request, no matching policy");
|
||||
/* make sure that root directory is defined */
|
||||
if (!policy.has_attribute("root")) {
|
||||
Genode::error("Missing \"root\" attribute in policy definition");
|
||||
throw Service_denied();
|
||||
}
|
||||
|
||||
Trace_fs::Policy const attributes = Trace_fs::Policy::from_xml(policy);
|
||||
|
||||
size_t ram_quota =
|
||||
Arg_string::find_arg(args, "ram_quota" ).ulong_value(0);
|
||||
size_t tx_buf_size =
|
||||
@ -1111,10 +1088,7 @@ class Trace_fs::Root : public Root_component<Session_component>
|
||||
}
|
||||
return new (md_alloc())
|
||||
Session_component(tx_buf_size, _ep, _ram, _rm, _env, _root_dir,
|
||||
*md_alloc(), subject_limit, interval,
|
||||
trace_quota, trace_meta_quota,
|
||||
trace_parent_levels, buffer_size,
|
||||
buffer_size_max);
|
||||
*md_alloc(), attributes);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -1127,7 +1101,7 @@ class Trace_fs::Root : public Root_component<Session_component>
|
||||
* data-flow signals of packet streams
|
||||
* \param md_alloc meta-data allocator
|
||||
*/
|
||||
Root(Genode::Entrypoint &ep, Allocator &md_alloc, Ram_session &ram,
|
||||
Root(Genode::Entrypoint &ep, Allocator &md_alloc, Ram_allocator &ram,
|
||||
Region_map &rm, Env &env, Directory &root_dir)
|
||||
:
|
||||
Root_component<Session_component>(&ep.rpc_ep(), &md_alloc),
|
||||
|
@ -40,7 +40,7 @@ class Genode::Serial_driver
|
||||
|
||||
void handle_smc(Vm_base &vm);
|
||||
|
||||
Serial_driver(Ram_session &ram) : _buf(&ram, BUF_SIZE) { }
|
||||
Serial_driver(Ram_allocator &ram) : _buf(&ram, BUF_SIZE) { }
|
||||
};
|
||||
|
||||
#endif /* _SERIAL_DRIVER_H_ */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user