mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-29 15:44:02 +00:00
update Reporter constructors
The Reporter utility needs a reference to the environment at construction to establish Report connections. Ref #1987 Fix #2232
This commit is contained in:
parent
a4e2999e7d
commit
48150a706b
@ -41,7 +41,7 @@ namespace Audio_in {
|
||||
|
||||
namespace Audio {
|
||||
|
||||
void update_config(Genode::Xml_node);
|
||||
void update_config(Genode::Env &, Genode::Xml_node);
|
||||
|
||||
void init_driver(Genode::Env &, Genode::Allocator &, Genode::Xml_node);
|
||||
|
||||
|
@ -495,7 +495,7 @@ struct Main
|
||||
{
|
||||
config.update();
|
||||
if (!config.is_valid()) { return; }
|
||||
Audio::update_config(config.xml());
|
||||
Audio::update_config(env, config.xml());
|
||||
}
|
||||
|
||||
Main(Genode::Env &env) : env(env)
|
||||
|
@ -1,5 +1,5 @@
|
||||
REQUIRES = x86 pci
|
||||
TARGET = audio_drv
|
||||
SRC_CC = main.cc
|
||||
LIBS = dde_bsd_audio base config
|
||||
LIBS = dde_bsd_audio base
|
||||
INC_DIR += $(REP_DIR)/include
|
||||
|
@ -307,15 +307,44 @@ static void dump_mixer(Mixer const &mixer)
|
||||
}
|
||||
|
||||
|
||||
static Genode::Reporter mixer_reporter = { "mixer_state" };
|
||||
/******************
|
||||
** Audio device **
|
||||
******************/
|
||||
|
||||
|
||||
static void report_mixer(Mixer const &mixer)
|
||||
static bool open_audio_device(dev_t dev)
|
||||
{
|
||||
if (!mixer_reporter.is_enabled()) { return; }
|
||||
if (!drv_loaded())
|
||||
return false;
|
||||
|
||||
try {
|
||||
int err = audioopen(dev, FWRITE|FREAD, 0 /* ifmt */, 0 /* proc */);
|
||||
if (err)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void configure_mixer(Genode::Env &env, Mixer &mixer, Genode::Xml_node config)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
static Reporter mixer_reporter(env, "mixer_state");
|
||||
|
||||
bool const v = config.attribute_value<bool>("report_mixer", false);
|
||||
mixer_reporter.enabled(v);
|
||||
|
||||
config.for_each_sub_node("mixer", [&] (Xml_node node) {
|
||||
char field[32];
|
||||
char value[16];
|
||||
try {
|
||||
node.attribute("field").value(field, sizeof(field));
|
||||
node.attribute("value").value(value, sizeof(value));
|
||||
|
||||
set_mixer_value(mixer, field, value);
|
||||
} catch (Xml_attribute::Nonexistent_attribute) { }
|
||||
});
|
||||
|
||||
if (mixer_reporter.is_enabled()) try {
|
||||
Genode::Reporter::Xml_generator xml(mixer_reporter, [&]() {
|
||||
|
||||
for (unsigned i = 0; i < mixer.num; i++) {
|
||||
@ -343,44 +372,7 @@ static void report_mixer(Mixer const &mixer)
|
||||
}
|
||||
|
||||
|
||||
/******************
|
||||
** Audio device **
|
||||
******************/
|
||||
|
||||
static bool open_audio_device(dev_t dev)
|
||||
{
|
||||
if (!drv_loaded())
|
||||
return false;
|
||||
|
||||
int err = audioopen(dev, FWRITE|FREAD, 0 /* ifmt */, 0 /* proc */);
|
||||
if (err)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void parse_config(Mixer &mixer, Genode::Xml_node config)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
bool const v = config.attribute_value<bool>("report_mixer", false);
|
||||
mixer_reporter.enabled(v);
|
||||
|
||||
config.for_each_sub_node("mixer", [&] (Xml_node node) {
|
||||
char field[32];
|
||||
char value[16];
|
||||
try {
|
||||
node.attribute("field").value(field, sizeof(field));
|
||||
node.attribute("value").value(value, sizeof(value));
|
||||
|
||||
set_mixer_value(mixer, field, value);
|
||||
} catch (Xml_attribute::Nonexistent_attribute) { }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
static bool configure_audio_device(dev_t dev, Genode::Xml_node config)
|
||||
static bool configure_audio_device(Genode::Env &env, dev_t dev, Genode::Xml_node config)
|
||||
{
|
||||
struct audio_info ai;
|
||||
|
||||
@ -427,8 +419,7 @@ static bool configure_audio_device(dev_t dev, Genode::Xml_node config)
|
||||
if (verbose) dump_rinfo();
|
||||
if (verbose) dump_mixer(mixer);
|
||||
|
||||
parse_config(mixer, config);
|
||||
report_mixer(mixer);
|
||||
configure_mixer(env, mixer, config);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -463,7 +454,7 @@ static void run_bsd(void *p)
|
||||
Genode::sleep_forever();
|
||||
}
|
||||
|
||||
adev_usuable = configure_audio_device(adev, args->config);
|
||||
adev_usuable = configure_audio_device(args->env, adev, args->config);
|
||||
|
||||
while (true) {
|
||||
Bsd::scheduler().current()->block_and_schedule();
|
||||
@ -503,12 +494,11 @@ extern "C" void notify_record()
|
||||
** private Audio namespace **
|
||||
*****************************/
|
||||
|
||||
void Audio::update_config(Genode::Xml_node config)
|
||||
void Audio::update_config(Genode::Env &env, Genode::Xml_node config)
|
||||
{
|
||||
if (mixer.info == nullptr) { return; }
|
||||
|
||||
parse_config(mixer, config);
|
||||
report_mixer(mixer);
|
||||
configure_mixer(env, mixer, config);
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <base/attached_dataspace.h>
|
||||
#include <base/attached_ram_dataspace.h>
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <os/reporter.h>
|
||||
#include <blit/blit.h>
|
||||
|
||||
#include <lx_emul_c.h>
|
||||
@ -48,6 +49,7 @@ class Framebuffer::Driver
|
||||
|
||||
Session_component &_session;
|
||||
Timer::Connection _timer;
|
||||
Genode::Reporter _reporter;
|
||||
Genode::Signal_handler<Driver> _poll_handler;
|
||||
unsigned long _poll_ms = 0;
|
||||
|
||||
@ -59,6 +61,7 @@ class Framebuffer::Driver
|
||||
|
||||
Driver(Genode::Env & env, Session_component &session)
|
||||
: _session(session), _timer(env),
|
||||
_reporter(env, "connectors"),
|
||||
_poll_handler(env.ep(), *this, &Driver::_poll) {}
|
||||
|
||||
int width() const { return _config._lx.width; }
|
||||
|
@ -216,18 +216,17 @@ void Framebuffer::Driver::generate_report()
|
||||
}
|
||||
|
||||
/* check for report configuration option */
|
||||
static Genode::Reporter reporter("connectors");
|
||||
try {
|
||||
reporter.enabled(_session.config().sub_node("report")
|
||||
.attribute_value(reporter.name().string(), false));
|
||||
_reporter.enabled(_session.config().sub_node("report")
|
||||
.attribute_value(_reporter.name().string(), false));
|
||||
} catch (...) {
|
||||
reporter.enabled(false);
|
||||
_reporter.enabled(false);
|
||||
}
|
||||
if (!reporter.is_enabled()) return;
|
||||
if (!_reporter.is_enabled()) return;
|
||||
|
||||
/* write new report */
|
||||
try {
|
||||
Genode::Reporter::Xml_generator xml(reporter, [&] ()
|
||||
Genode::Reporter::Xml_generator xml(_reporter, [&] ()
|
||||
{
|
||||
struct drm_connector *c;
|
||||
list_for_each_entry(c, &lx_drm_device->mode_config.connector_list,
|
||||
|
@ -75,66 +75,18 @@ struct Device : List<Device>::Element
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
static Genode::Reporter &device_list_reporter()
|
||||
{
|
||||
static Genode::Reporter _r("devices", "devices", 512*1024);
|
||||
return _r;
|
||||
}
|
||||
|
||||
static void report_device_list()
|
||||
{
|
||||
Genode::Reporter::Xml_generator xml(device_list_reporter(), [&] ()
|
||||
{
|
||||
|
||||
for (Device *d = list()->first(); d; d = d->next()) {
|
||||
xml.node("device", [&] ()
|
||||
{
|
||||
char buf[16];
|
||||
|
||||
unsigned const bus = d->udev->bus->busnum;
|
||||
unsigned const dev = d->udev->devnum;
|
||||
|
||||
Genode::snprintf(buf, sizeof(buf), "usb-%d-%d", bus, dev);
|
||||
xml.attribute("label", buf);
|
||||
|
||||
Genode::snprintf(buf, sizeof(buf), "0x%4x",
|
||||
d->udev->descriptor.idVendor);
|
||||
xml.attribute("vendor_id", buf);
|
||||
|
||||
Genode::snprintf(buf, sizeof(buf), "0x%4x",
|
||||
d->udev->descriptor.idProduct);
|
||||
xml.attribute("product_id", buf);
|
||||
|
||||
Genode::snprintf(buf, sizeof(buf), "0x%4x", bus);
|
||||
xml.attribute("bus", buf);
|
||||
|
||||
Genode::snprintf(buf, sizeof(buf), "0x%4x", dev);
|
||||
xml.attribute("dev", buf);
|
||||
|
||||
usb_interface *iface = d->interface(0);
|
||||
Genode::snprintf(buf, sizeof(buf), "0x%02x",
|
||||
iface->cur_altsetting->desc.bInterfaceClass);
|
||||
xml.attribute("class", buf);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
static void report_device_list();
|
||||
|
||||
Device(usb_device *udev) : udev(udev)
|
||||
{
|
||||
list()->insert(this);
|
||||
|
||||
if (device_list_reporter().enabled())
|
||||
report_device_list();
|
||||
report_device_list();
|
||||
}
|
||||
|
||||
~Device()
|
||||
{
|
||||
list()->remove(this);
|
||||
|
||||
if (device_list_reporter().enabled())
|
||||
report_device_list();
|
||||
report_device_list();
|
||||
}
|
||||
|
||||
usb_interface *interface(unsigned index)
|
||||
@ -568,17 +520,17 @@ class Usb::Session_component : public Session_rpc_object,
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Entrypoint &_ep;
|
||||
unsigned long _vendor;
|
||||
unsigned long _product;
|
||||
long _bus = 0;
|
||||
long _dev = 0;
|
||||
Device *_device = nullptr;
|
||||
Signal_context_capability _sigh_state_change;
|
||||
Signal_rpc_member<Session_component> _packet_avail;
|
||||
Signal_rpc_member<Session_component> _ready_ack;
|
||||
Worker _worker;
|
||||
Ram_dataspace_capability _tx_ds;
|
||||
Genode::Entrypoint &_ep;
|
||||
unsigned long _vendor;
|
||||
unsigned long _product;
|
||||
long _bus = 0;
|
||||
long _dev = 0;
|
||||
Device *_device = nullptr;
|
||||
Signal_context_capability _sigh_state_change;
|
||||
Signal_handler<Session_component> _packet_avail;
|
||||
Signal_handler<Session_component> _ready_ack;
|
||||
Worker _worker;
|
||||
Ram_dataspace_capability _tx_ds;
|
||||
|
||||
|
||||
void _signal_state_change()
|
||||
@ -587,7 +539,7 @@ class Usb::Session_component : public Session_rpc_object,
|
||||
Signal_transmitter(_sigh_state_change).submit(1);
|
||||
}
|
||||
|
||||
void _receive(unsigned)
|
||||
void _receive()
|
||||
{
|
||||
_worker.packet_avail();
|
||||
Lx::scheduler().schedule();
|
||||
@ -802,12 +754,15 @@ class Usb::Root : public Genode::Root_component<Session_component>
|
||||
|
||||
Genode::Env &_env;
|
||||
|
||||
Genode::Signal_rpc_member<Usb::Root> _config_dispatcher = {
|
||||
Genode::Signal_handler<Usb::Root> _config_handler = {
|
||||
_env.ep(), *this, &Usb::Root::_handle_config };
|
||||
|
||||
Genode::Reporter _config_reporter { "config" };
|
||||
Genode::Reporter _config_reporter { _env, "config" };
|
||||
|
||||
void _handle_config(unsigned)
|
||||
Genode::Reporter _device_list_reporter {
|
||||
_env, "devices", "devices", 512*1024 };
|
||||
|
||||
void _handle_config()
|
||||
{
|
||||
Lx_kit::env().config_rom().update();
|
||||
|
||||
@ -886,23 +841,74 @@ class Usb::Root : public Genode::Root_component<Session_component>
|
||||
public:
|
||||
|
||||
Root(Genode::Env &env,
|
||||
Genode::Allocator *md_alloc)
|
||||
: Genode::Root_component<Session_component>(&env.ep().rpc_ep(), md_alloc),
|
||||
Genode::Allocator &md_alloc,
|
||||
bool report_device_list)
|
||||
: Genode::Root_component<Session_component>(env.ep(), md_alloc),
|
||||
_env(env)
|
||||
{
|
||||
Lx_kit::env().config_rom().sigh(_config_dispatcher);
|
||||
Lx_kit::env().config_rom().sigh(_config_handler);
|
||||
_device_list_reporter.enabled(report_device_list);
|
||||
}
|
||||
|
||||
Genode::Reporter &device_list_reporter()
|
||||
{
|
||||
return _device_list_reporter;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static Genode::Constructible<Usb::Root> root;
|
||||
|
||||
|
||||
void Raw::init(Genode::Env &env, bool report_device_list)
|
||||
{
|
||||
Device::device_list_reporter().enabled(report_device_list);
|
||||
static Usb::Root root(env, &Lx::Malloc::mem());
|
||||
env.parent().announce(env.ep().rpc_ep().manage(&root));
|
||||
root.construct(env, Lx::Malloc::mem(), report_device_list);
|
||||
env.parent().announce(env.ep().manage(*root));
|
||||
}
|
||||
|
||||
|
||||
void Device::report_device_list()
|
||||
{
|
||||
if (!root->device_list_reporter().enabled())
|
||||
return;
|
||||
|
||||
Genode::Reporter::Xml_generator xml(root->device_list_reporter(), [&] ()
|
||||
{
|
||||
|
||||
for (Device *d = list()->first(); d; d = d->next()) {
|
||||
xml.node("device", [&] ()
|
||||
{
|
||||
char buf[16];
|
||||
|
||||
unsigned const bus = d->udev->bus->busnum;
|
||||
unsigned const dev = d->udev->devnum;
|
||||
|
||||
Genode::snprintf(buf, sizeof(buf), "usb-%d-%d", bus, dev);
|
||||
xml.attribute("label", buf);
|
||||
|
||||
Genode::snprintf(buf, sizeof(buf), "0x%4x",
|
||||
d->udev->descriptor.idVendor);
|
||||
xml.attribute("vendor_id", buf);
|
||||
|
||||
Genode::snprintf(buf, sizeof(buf), "0x%4x",
|
||||
d->udev->descriptor.idProduct);
|
||||
xml.attribute("product_id", buf);
|
||||
|
||||
Genode::snprintf(buf, sizeof(buf), "0x%4x", bus);
|
||||
xml.attribute("bus", buf);
|
||||
|
||||
Genode::snprintf(buf, sizeof(buf), "0x%4x", dev);
|
||||
xml.attribute("dev", buf);
|
||||
|
||||
usb_interface *iface = d->interface(0);
|
||||
Genode::snprintf(buf, sizeof(buf), "0x%02x",
|
||||
iface->cur_altsetting->desc.bInterfaceClass);
|
||||
xml.attribute("class", buf);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*****************
|
||||
** C interface **
|
||||
*****************/
|
||||
|
@ -299,9 +299,9 @@ struct Floating_window_layouter::Main : Operations
|
||||
|
||||
Attached_dataspace input_ds { input.dataspace() };
|
||||
|
||||
Reporter window_layout_reporter = { "window_layout" };
|
||||
Reporter resize_request_reporter = { "resize_request" };
|
||||
Reporter focus_reporter = { "focus" };
|
||||
Reporter window_layout_reporter = { env, "window_layout" };
|
||||
Reporter resize_request_reporter = { env, "resize_request" };
|
||||
Reporter focus_reporter = { env, "focus" };
|
||||
|
||||
|
||||
bool focused_window_maximized() const
|
||||
|
@ -49,13 +49,13 @@ struct Wm::Main
|
||||
Attached_rom_dataspace resize_request_rom { env, "resize_request" };
|
||||
|
||||
/* pointer position to be consumed by the layouter */
|
||||
Reporter pointer_reporter = { "pointer" };
|
||||
Reporter pointer_reporter = { env, "pointer" };
|
||||
|
||||
/* list of present windows, to be consumed by the layouter */
|
||||
Reporter window_list_reporter = { "window_list" };
|
||||
Reporter window_list_reporter = { env, "window_list" };
|
||||
|
||||
/* request to the layouter to set the focus */
|
||||
Reporter focus_request_reporter = { "focus_request" };
|
||||
Reporter focus_request_reporter = { env, "focus_request" };
|
||||
|
||||
Window_registry window_registry { heap, window_list_reporter };
|
||||
|
||||
|
@ -153,7 +153,7 @@ struct App::Main
|
||||
|
||||
Trace::Connection _trace { _env, 512*1024, 32*1024, 0 };
|
||||
|
||||
Reporter _reporter { "trace_subjects", "trace_subjects", 64*1024 };
|
||||
Reporter _reporter { _env, "trace_subjects", "trace_subjects", 64*1024 };
|
||||
|
||||
static unsigned long _default_period_ms() { return 5000; }
|
||||
|
||||
|
@ -12,11 +12,11 @@
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/component.h>
|
||||
#include <base/allocator_avl.h>
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <os/config.h>
|
||||
#include <base/heap.h>
|
||||
#include <os/reporter.h>
|
||||
#include <os/server.h>
|
||||
#include <util/list.h>
|
||||
#include <util/string.h>
|
||||
#include <util/xml_generator.h>
|
||||
@ -48,16 +48,16 @@ class Usb_filter::Device_registry
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Allocator &_alloc;
|
||||
Server::Entrypoint &_ep;
|
||||
Genode::Env &_env;
|
||||
Genode::Allocator &_alloc;
|
||||
|
||||
Genode::Reporter _reporter { "usb_devices" };
|
||||
Genode::Reporter _reporter { _env, "usb_devices" };
|
||||
|
||||
Attached_rom_dataspace _devices_rom { "devices" };
|
||||
Attached_rom_dataspace _usb_drv_config_rom { "usb_drv_config" };
|
||||
Attached_rom_dataspace _devices_rom { _env, "devices" };
|
||||
Attached_rom_dataspace _usb_drv_config_rom { _env, "usb_drv_config" };
|
||||
|
||||
Genode::Allocator_avl _fs_packet_alloc { &_alloc };
|
||||
File_system::Connection _fs { _fs_packet_alloc, 128*1024, "usb_drv.config" };
|
||||
File_system::Connection _fs { _env, _fs_packet_alloc, "usb_drv.config" };
|
||||
File_system::File_handle _file;
|
||||
|
||||
struct Entry : public Genode::List<Entry>::Element
|
||||
@ -223,10 +223,10 @@ class Usb_filter::Device_registry
|
||||
_fs.close(_file);
|
||||
}
|
||||
|
||||
Genode::Signal_rpc_member<Device_registry> _devices_dispatcher =
|
||||
{ _ep, *this, &Device_registry::_handle_devices };
|
||||
Genode::Signal_handler<Device_registry> _devices_handler =
|
||||
{ _env.ep(), *this, &Device_registry::_handle_devices };
|
||||
|
||||
void _handle_devices(unsigned)
|
||||
void _handle_devices()
|
||||
{
|
||||
_devices_rom.update();
|
||||
|
||||
@ -317,10 +317,10 @@ class Usb_filter::Device_registry
|
||||
});
|
||||
}
|
||||
|
||||
Genode::Signal_rpc_member<Device_registry> _usb_drv_config_dispatcher =
|
||||
{ _ep, *this, &Device_registry::_handle_usb_drv_config };
|
||||
Genode::Signal_handler<Device_registry> _usb_drv_config_handler =
|
||||
{ _env.ep(), *this, &Device_registry::_handle_usb_drv_config };
|
||||
|
||||
void _handle_usb_drv_config(unsigned)
|
||||
void _handle_usb_drv_config()
|
||||
{
|
||||
_usb_drv_config_rom.update();
|
||||
|
||||
@ -357,15 +357,14 @@ class Usb_filter::Device_registry
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Device_registry(Genode::Allocator &alloc,
|
||||
Server::Entrypoint &ep)
|
||||
: _alloc(alloc), _ep(ep)
|
||||
Device_registry(Genode::Env &env, Genode::Allocator &alloc)
|
||||
: _env(env), _alloc(alloc)
|
||||
{
|
||||
_reporter.enabled(true);
|
||||
|
||||
_devices_rom.sigh(_devices_dispatcher);
|
||||
_devices_rom.sigh(_devices_handler);
|
||||
|
||||
_usb_drv_config_rom.sigh(_usb_drv_config_dispatcher);
|
||||
_usb_drv_config_rom.sigh(_usb_drv_config_handler);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -409,30 +408,31 @@ class Usb_filter::Device_registry
|
||||
|
||||
struct Usb_filter::Main
|
||||
{
|
||||
Server::Entrypoint &ep;
|
||||
Genode::Env &_env;
|
||||
|
||||
Genode::Signal_rpc_member<Main> _config_dispatcher =
|
||||
{ ep, *this, &Main::_handle_config };
|
||||
Genode::Heap _heap { _env.ram(), _env.rm() };
|
||||
|
||||
void _handle_config(unsigned)
|
||||
Genode::Attached_rom_dataspace _config { _env, "config" };
|
||||
|
||||
Genode::Signal_handler<Main> _config_handler =
|
||||
{ _env.ep(), *this, &Main::_handle_config };
|
||||
|
||||
void _handle_config()
|
||||
{
|
||||
Genode::config()->reload();
|
||||
device_registry.update_entries(Genode::config()->xml_node());
|
||||
_config.update();
|
||||
device_registry.update_entries(_config.xml());
|
||||
}
|
||||
|
||||
Device_registry device_registry { *Genode::env()->heap(), ep };
|
||||
Device_registry device_registry { _env, _heap };
|
||||
|
||||
Main(Server::Entrypoint &ep) : ep(ep)
|
||||
Main(Genode::Env &env) : _env(env)
|
||||
{
|
||||
Genode::config()->sigh(_config_dispatcher);
|
||||
_config.sigh(_config_handler);
|
||||
|
||||
_handle_config(0);
|
||||
_handle_config();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
namespace Server {
|
||||
char const *name() { return "usb_report_filter_ep"; }
|
||||
size_t stack_size() { return 16*1024*sizeof(addr_t); }
|
||||
void construct(Entrypoint &ep) { static Usb_filter::Main main(ep); }
|
||||
}
|
||||
void Component::construct(Genode::Env &env) {
|
||||
static Usb_filter::Main main(env); }
|
||||
|
@ -1,3 +1,3 @@
|
||||
TARGET = usb_report_filter
|
||||
SRC_CC = main.cc
|
||||
LIBS = base config server
|
||||
LIBS = base
|
||||
|
@ -34,6 +34,8 @@ struct Platform::Main
|
||||
Genode::Env &_env;
|
||||
Genode::Sliced_heap sliced_heap { _env.ram(), _env.rm() };
|
||||
|
||||
Genode::Attached_rom_dataspace _config { _env, "config" };
|
||||
|
||||
Genode::Constructible<Genode::Attached_rom_dataspace> acpi_rom;
|
||||
Genode::Constructible<Platform::Root> root;
|
||||
|
||||
@ -56,7 +58,7 @@ struct Platform::Main
|
||||
|
||||
const char * report_addr = acpi_rom->local_addr<const char>();
|
||||
|
||||
root.construct(_env, sliced_heap, report_addr);
|
||||
root.construct(_env, sliced_heap, _config, report_addr);
|
||||
|
||||
root_cap = _env.ep().manage(*root);
|
||||
|
||||
@ -109,7 +111,7 @@ struct Platform::Main
|
||||
_acpi_report(_env.ep(), *this, &Main::acpi_update),
|
||||
_system_report(_env.ep(), *this, &Main::system_update)
|
||||
{
|
||||
const Genode::Xml_node &config = Genode::config()->xml_node();
|
||||
const Genode::Xml_node config = _config.xml();
|
||||
|
||||
_system_rom = config.attribute_value("system", false);
|
||||
|
||||
@ -135,7 +137,7 @@ struct Platform::Main
|
||||
}
|
||||
|
||||
/* non ACPI platform case */
|
||||
root.construct(_env, sliced_heap, nullptr);
|
||||
root.construct(_env, sliced_heap, _config, nullptr);
|
||||
_env.parent().announce(_env.ep().manage(*root));
|
||||
}
|
||||
};
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <base/allocator_guard.h>
|
||||
#include <base/rpc_server.h>
|
||||
#include <base/tslab.h>
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <ram_session/connection.h>
|
||||
#include <root/component.h>
|
||||
|
||||
@ -196,18 +197,19 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Env &_env;
|
||||
Genode::Rpc_entrypoint &_device_pd_ep;
|
||||
Genode::Ram_session_guard _env_ram;
|
||||
Genode::Ram_session_capability _env_ram_cap;
|
||||
Genode::Region_map &_local_rm;
|
||||
Genode::Heap _md_alloc;
|
||||
Genode::Session_label const _label;
|
||||
Genode::Session_policy const _policy { _label };
|
||||
Genode::List<Device_component> _device_list;
|
||||
Platform::Pci_buses &_pci_bus;
|
||||
Genode::Heap &_global_heap;
|
||||
bool _no_device_pd = false;
|
||||
Genode::Env &_env;
|
||||
Genode::Rpc_entrypoint &_device_pd_ep;
|
||||
Genode::Attached_rom_dataspace &_config;
|
||||
Genode::Ram_session_guard _env_ram;
|
||||
Genode::Ram_session_capability _env_ram_cap;
|
||||
Genode::Region_map &_local_rm;
|
||||
Genode::Heap _md_alloc;
|
||||
Genode::Session_label const _label;
|
||||
Genode::Session_policy const _policy { _label };
|
||||
Genode::List<Device_component> _device_list;
|
||||
Platform::Pci_buses &_pci_bus;
|
||||
Genode::Heap &_global_heap;
|
||||
bool _no_device_pd = false;
|
||||
|
||||
/**
|
||||
* Registry of RAM dataspaces allocated by the session
|
||||
@ -537,7 +539,7 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
using namespace Genode;
|
||||
|
||||
try {
|
||||
config()->xml_node().for_each_sub_node("policy", [&] (Xml_node policy) {
|
||||
_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 */
|
||||
@ -566,7 +568,7 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
using namespace Genode;
|
||||
|
||||
try {
|
||||
Xml_node xml(config()->xml_node());
|
||||
Xml_node xml = _config.xml();
|
||||
xml.for_each_sub_node("policy", [&] (Xml_node policy) {
|
||||
policy.for_each_sub_node("pci", [&] (Xml_node node) {
|
||||
try {
|
||||
@ -594,13 +596,15 @@ class Platform::Session_component : public Genode::Rpc_object<Session>
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Session_component(Genode::Env &env,
|
||||
Genode::Rpc_entrypoint &device_pd_ep,
|
||||
Platform::Pci_buses &buses,
|
||||
Genode::Heap &global_heap,
|
||||
char const *args)
|
||||
Session_component(Genode::Env &env,
|
||||
Genode::Attached_rom_dataspace &config,
|
||||
Genode::Rpc_entrypoint &device_pd_ep,
|
||||
Platform::Pci_buses &buses,
|
||||
Genode::Heap &global_heap,
|
||||
char const *args)
|
||||
:
|
||||
_env(env), _device_pd_ep(device_pd_ep),
|
||||
_config(config),
|
||||
_env_ram(env.ram(), env.ram_session_cap(),
|
||||
Genode::Arg_string::find_arg(args, "ram_quota").long_value(0)),
|
||||
_env_ram_cap(env.ram_session_cap()),
|
||||
@ -1021,9 +1025,11 @@ class Platform::Root : public Genode::Root_component<Session_component>
|
||||
};
|
||||
} fadt;
|
||||
|
||||
Genode::Env &_env;
|
||||
Genode::Env &_env;
|
||||
Genode::Attached_rom_dataspace &_config;
|
||||
|
||||
Genode::Rpc_entrypoint _device_pd_ep;
|
||||
Genode::Heap _heap { _env.ram(), _env.rm() };
|
||||
Genode::Heap _heap { _env.ram(), _env.rm() };
|
||||
Platform::Pci_buses _buses { _env, _heap };
|
||||
|
||||
void _parse_report_rom(Genode::Env &env, const char * acpi_rom)
|
||||
@ -1160,7 +1166,7 @@ class Platform::Root : public Genode::Root_component<Session_component>
|
||||
{
|
||||
try {
|
||||
return new (md_alloc())
|
||||
Session_component(_env, _device_pd_ep, _buses, _heap, args);
|
||||
Session_component(_env, _config, _device_pd_ep, _buses, _heap, args);
|
||||
}
|
||||
catch (Genode::Session_policy::No_policy_defined) {
|
||||
Genode::error("Invalid session request, no matching policy for ",
|
||||
@ -1187,11 +1193,12 @@ class Platform::Root : public Genode::Root_component<Session_component>
|
||||
* components and PCI-device components
|
||||
*/
|
||||
Root(Genode::Env &env, Genode::Allocator &md_alloc,
|
||||
Genode::Attached_rom_dataspace &config,
|
||||
const char *acpi_rom)
|
||||
:
|
||||
Genode::Root_component<Session_component>(&env.ep().rpc_ep(),
|
||||
&md_alloc),
|
||||
_env(env),
|
||||
_env(env), _config(config),
|
||||
_device_pd_ep(&env.pd(), STACK_SIZE, "device_pd_slave")
|
||||
{
|
||||
if (acpi_rom) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
TARGET = platform_drv
|
||||
REQUIRES = x86
|
||||
SRC_CC = main.cc irq.cc pci_device.cc nonpci_devices.cc session.cc
|
||||
LIBS = base config
|
||||
LIBS = base
|
||||
|
||||
INC_DIR = $(PRG_DIR)
|
||||
|
@ -125,7 +125,7 @@ struct Usb::Block_driver : Usb::Completion,
|
||||
/*
|
||||
* Reporter
|
||||
*/
|
||||
Reporter reporter { "devices" };
|
||||
Reporter reporter { env, "devices" };
|
||||
bool _report_device = false;
|
||||
|
||||
/*
|
||||
|
@ -145,7 +145,7 @@ struct Main
|
||||
true, 0, 0, Shape::WIDTH, Shape::HEIGHT, { 0 } };
|
||||
|
||||
Genode::Reporter _reporter {
|
||||
"shape", "shape", sizeof(Vbox_pointer::Shape_report) };
|
||||
_env, "shape", "shape", sizeof(Vbox_pointer::Shape_report) };
|
||||
|
||||
Genode::Signal_handler<Main> _config_handler {
|
||||
_env.ep(), *this, &Main::_handle_config };
|
||||
|
Loading…
x
Reference in New Issue
Block a user