mirror of
https://github.com/genodelabs/genode.git
synced 2025-03-10 14:34:38 +00:00
platform_drv: outsource common parts for derivate
Outsource parts of the Main object into a common compound object, common parts of the Makefile description and depot source package. Fix genodelabs/genode#4503
This commit is contained in:
parent
9370e5e4d0
commit
438870e223
17
repos/os/recipes/src/platform_drv/content.inc
Normal file
17
repos/os/recipes/src/platform_drv/content.inc
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
include $(GENODE_DIR)/repos/base/recipes/src/content.inc
|
||||||
|
|
||||||
|
GENERIC_SRC_DIR := $(GENODE_DIR)/repos/os/src/drivers/platform
|
||||||
|
GENERIC_INC_DIR := $(GENODE_DIR)/repos/os/include/pci
|
||||||
|
|
||||||
|
GENERIC_SRC_FILES := $(filter-out target.mk,$(filter-out main.cc,$(notdir $(wildcard $(GENERIC_SRC_DIR)/*.*))))
|
||||||
|
GENERIC_HDR_FILES := $(notdir $(wildcard $(GENERIC_INC_DIR)/*.h))
|
||||||
|
|
||||||
|
MIRROR_FROM_OS_DIR := $(addprefix src/drivers/platform/,$(GENERIC_SRC_FILES)) \
|
||||||
|
$(addprefix include/pci/,$(GENERIC_HDR_FILES))
|
||||||
|
|
||||||
|
content: $(MIRROR_FROM_OS_DIR)
|
||||||
|
|
||||||
|
$(MIRROR_FROM_OS_DIR):
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
cp -r $(GENODE_DIR)/repos/os/$@ $@
|
||||||
|
|
@ -1,7 +1,2 @@
|
|||||||
SRC_DIR = src/drivers/platform
|
SRC_DIR = src/drivers/platform
|
||||||
include $(GENODE_DIR)/repos/base/recipes/src/content.inc
|
include $(GENODE_DIR)/repos/os/recipes/src/platform_drv/content.inc
|
||||||
|
|
||||||
content: include/init/child_policy.h
|
|
||||||
|
|
||||||
include/init/child_policy.h:
|
|
||||||
$(mirror_from_rep_dir)
|
|
||||||
|
89
repos/os/src/drivers/platform/common.h
Normal file
89
repos/os/src/drivers/platform/common.h
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* \brief Platform driver - compound object for all derivate implementations
|
||||||
|
* \author Stefan Kalkowski
|
||||||
|
* \date 2022-05-10
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <root.h>
|
||||||
|
|
||||||
|
namespace Driver { class Common; };
|
||||||
|
|
||||||
|
class Driver::Common
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
Env & _env;
|
||||||
|
Attached_rom_dataspace _devices_rom { _env, "devices" };
|
||||||
|
Reporter _cfg_reporter { _env, "config" };
|
||||||
|
Reporter _dev_reporter { _env, "devices" };
|
||||||
|
Heap _heap { _env.ram(), _env.rm() };
|
||||||
|
Sliced_heap _sliced_heap { _env.ram(), _env.rm() };
|
||||||
|
Device_model _devices { _heap, _dev_reporter };
|
||||||
|
Signal_handler<Common> _dev_handler { _env.ep(), *this,
|
||||||
|
&Common::_handle_devices };
|
||||||
|
Driver::Root _root;
|
||||||
|
|
||||||
|
void _handle_devices();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Heap & heap() { return _heap; }
|
||||||
|
Device_model & devices() { return _devices; }
|
||||||
|
|
||||||
|
void handle_config(Xml_node config);
|
||||||
|
void announce_service();
|
||||||
|
|
||||||
|
Common(Genode::Env & env,
|
||||||
|
Attached_rom_dataspace & config_rom);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void Driver::Common::_handle_devices()
|
||||||
|
{
|
||||||
|
_devices_rom.update();
|
||||||
|
_devices.update(_devices_rom.xml());
|
||||||
|
_root.update_policy();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Driver::Common::handle_config(Xml_node config)
|
||||||
|
{
|
||||||
|
config.for_each_sub_node("report", [&] (Xml_node const node) {
|
||||||
|
_dev_reporter.enabled(node.attribute_value("devices", false));
|
||||||
|
_cfg_reporter.enabled(node.attribute_value("config", false));
|
||||||
|
});
|
||||||
|
|
||||||
|
_root.update_policy();
|
||||||
|
|
||||||
|
if (_cfg_reporter.enabled()) {
|
||||||
|
Reporter::Xml_generator xml(_cfg_reporter, [&] () {
|
||||||
|
config.with_raw_content([&] (char const *src, size_t len) {
|
||||||
|
xml.append(src, len);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Driver::Common::announce_service()
|
||||||
|
{
|
||||||
|
_env.parent().announce(_env.ep().manage(_root));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Driver::Common::Common(Genode::Env & env,
|
||||||
|
Attached_rom_dataspace & config_rom)
|
||||||
|
:
|
||||||
|
_env(env),
|
||||||
|
_root(_env, _sliced_heap, config_rom, _devices)
|
||||||
|
{
|
||||||
|
_handle_devices();
|
||||||
|
_devices_rom.sigh(_dev_handler);
|
||||||
|
}
|
@ -12,59 +12,36 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <base/component.h>
|
#include <base/component.h>
|
||||||
#include <root.h>
|
#include <common.h>
|
||||||
|
|
||||||
namespace Driver { struct Main; };
|
namespace Driver { struct Main; };
|
||||||
|
|
||||||
struct Driver::Main
|
struct Driver::Main
|
||||||
{
|
{
|
||||||
void update();
|
Env & _env;
|
||||||
|
Attached_rom_dataspace _config_rom { _env, "config" };
|
||||||
|
Common _common { _env, _config_rom };
|
||||||
|
Signal_handler<Main> _config_handler { _env.ep(), *this,
|
||||||
|
&Main::_handle_config };
|
||||||
|
|
||||||
Env & env;
|
void _handle_config();
|
||||||
Heap heap { env.ram(), env.rm() };
|
|
||||||
Sliced_heap sliced_heap { env.ram(), env.rm() };
|
|
||||||
Attached_rom_dataspace config_rom { env, "config" };
|
|
||||||
Attached_rom_dataspace devices_rom { env, "devices" };
|
|
||||||
Reporter cfg_reporter { env, "config" };
|
|
||||||
Reporter dev_reporter { env, "devices" };
|
|
||||||
Device_model devices { heap, dev_reporter };
|
|
||||||
Signal_handler<Main> handler { env.ep(), *this,
|
|
||||||
&Main::update };
|
|
||||||
Driver::Root root { env, sliced_heap,
|
|
||||||
config_rom, devices };
|
|
||||||
|
|
||||||
Main(Genode::Env & e)
|
Main(Genode::Env & e)
|
||||||
: env(e)
|
: _env(e)
|
||||||
{
|
{
|
||||||
update();
|
_handle_config();
|
||||||
config_rom.sigh(handler);
|
_config_rom.sigh(_config_handler);
|
||||||
devices_rom.sigh(handler);
|
_common.announce_service();
|
||||||
env.parent().announce(env.ep().manage(root));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void Driver::Main::update()
|
void Driver::Main::_handle_config()
|
||||||
{
|
{
|
||||||
config_rom.update();
|
_config_rom.update();
|
||||||
devices_rom.update();
|
_common.handle_config(_config_rom.xml());
|
||||||
|
|
||||||
config_rom.xml().for_each_sub_node("report", [&] (Xml_node const node) {
|
|
||||||
dev_reporter.enabled(node.attribute_value("devices", false));
|
|
||||||
cfg_reporter.enabled(node.attribute_value("config", false));
|
|
||||||
});
|
|
||||||
|
|
||||||
devices.update(devices_rom.xml());
|
|
||||||
root.update_policy();
|
|
||||||
|
|
||||||
if (cfg_reporter.enabled()) {
|
|
||||||
Reporter::Xml_generator xml(cfg_reporter, [&] () {
|
|
||||||
config_rom.xml().with_raw_content([&] (char const *src, size_t len) {
|
|
||||||
xml.append(src, len);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Component::construct(Genode::Env &env) {
|
void Component::construct(Genode::Env &env) {
|
||||||
static Driver::Main main(env); }
|
static Driver::Main main(env); }
|
||||||
|
16
repos/os/src/drivers/platform/target.inc
Normal file
16
repos/os/src/drivers/platform/target.inc
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
SRC_CC += device.cc
|
||||||
|
SRC_CC += device_component.cc
|
||||||
|
SRC_CC += device_model_policy.cc
|
||||||
|
SRC_CC += device_pd.cc
|
||||||
|
SRC_CC += main.cc
|
||||||
|
SRC_CC += pci.cc
|
||||||
|
SRC_CC += root.cc
|
||||||
|
SRC_CC += session_component.cc
|
||||||
|
|
||||||
|
GENERIC_DIR := $(dir $(call select_from_repositories,src/drivers/platform/target.inc))
|
||||||
|
|
||||||
|
INC_DIR += $(PRG_DIR) $(GENERIC_DIR)
|
||||||
|
LIBS += base
|
||||||
|
|
||||||
|
vpath %.cc $(PRG_DIR)
|
||||||
|
vpath %.cc $(GENERIC_DIR)
|
@ -1,11 +1,3 @@
|
|||||||
TARGET = platform_drv
|
TARGET = platform_drv
|
||||||
SRC_CC += device.cc
|
|
||||||
SRC_CC += device_component.cc
|
include $(PRG_DIR)/target.inc
|
||||||
SRC_CC += device_model_policy.cc
|
|
||||||
SRC_CC += device_pd.cc
|
|
||||||
SRC_CC += main.cc
|
|
||||||
SRC_CC += pci.cc
|
|
||||||
SRC_CC += root.cc
|
|
||||||
SRC_CC += session_component.cc
|
|
||||||
INC_DIR = $(PRG_DIR)
|
|
||||||
LIBS = base
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user