diff --git a/repos/pc/recipes/src/pc_platform_drv/content.mk b/repos/pc/recipes/src/pc_platform_drv/content.mk new file mode 100644 index 0000000000..a7f7992f97 --- /dev/null +++ b/repos/pc/recipes/src/pc_platform_drv/content.mk @@ -0,0 +1,2 @@ +SRC_DIR = src/drivers/platform/pc +include $(GENODE_DIR)/repos/os/recipes/src/platform_drv/content.inc diff --git a/repos/pc/recipes/src/pc_platform_drv/hash b/repos/pc/recipes/src/pc_platform_drv/hash new file mode 100644 index 0000000000..795e64a934 --- /dev/null +++ b/repos/pc/recipes/src/pc_platform_drv/hash @@ -0,0 +1 @@ +2022-10-05 de4f9225c72915f78eb05e2e534d600d8c744789 diff --git a/repos/pc/recipes/src/pc_platform_drv/used_apis b/repos/pc/recipes/src/pc_platform_drv/used_apis new file mode 100644 index 0000000000..dbf0f2d7f7 --- /dev/null +++ b/repos/pc/recipes/src/pc_platform_drv/used_apis @@ -0,0 +1,4 @@ +base +os +platform_session +report_session diff --git a/repos/pc/src/drivers/platform/pc/main.cc b/repos/pc/src/drivers/platform/pc/main.cc new file mode 100644 index 0000000000..33b8afc3a6 --- /dev/null +++ b/repos/pc/src/drivers/platform/pc/main.cc @@ -0,0 +1,84 @@ +/* + * \brief Platform driver for PC + * \author Stefan Kalkowski + * \date 2022-10-05 + */ + +/* + * 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 + +#include + +namespace Driver { struct Main; }; + +struct Driver::Main +{ + Env & _env; + Attached_rom_dataspace _config_rom { _env, "config" }; + Attached_rom_dataspace _acpi_rom { _env, "acpi" }; + Attached_rom_dataspace _system_rom { _env, "system" }; + Common _common { _env, _config_rom }; + Signal_handler
_config_handler { _env.ep(), *this, + &Main::_handle_config }; + Signal_handler
_system_handler { _env.ep(), *this, + &Main::_system_update }; + + void _handle_config(); + void _reset(); + void _system_update(); + + Main(Genode::Env & e) + : _env(e) + { + _config_rom.sigh(_config_handler); + _acpi_rom.sigh(_system_handler); + _system_rom.sigh(_system_handler); + _handle_config(); + _system_update(); + _common.announce_service(); + } +}; + + +void Driver::Main::_handle_config() +{ + _config_rom.update(); + _common.handle_config(_config_rom.xml()); +} + + +void Driver::Main::_reset() +{ + _acpi_rom.update(); + _acpi_rom.xml().with_optional_sub_node("reset", [&] (Xml_node reset) + { + uint16_t const io_port = reset.attribute_value("io_port", 0); + uint8_t const value = reset.attribute_value("value", 0); + + log("trigger reset by writing value ", value, " to I/O port ", Hex(io_port)); + + try { + Io_port_connection reset_port { _env, io_port, 1 }; + reset_port.outb(io_port, value); + } catch (...) { + error("unable to access reset I/O port ", Hex(io_port)); } + }); +} + + +void Driver::Main::_system_update() +{ + _system_rom.update(); + if (_system_rom.xml().attribute_value("state", String<16>()) == "reset") + _reset(); +} + + +void Component::construct(Genode::Env &env) { + static Driver::Main main(env); } diff --git a/repos/pc/src/drivers/platform/pc/target.mk b/repos/pc/src/drivers/platform/pc/target.mk new file mode 100644 index 0000000000..ccc6087f2c --- /dev/null +++ b/repos/pc/src/drivers/platform/pc/target.mk @@ -0,0 +1,4 @@ +TARGET = pc_platform_drv +REQUIRES = x86 + +include $(call select_from_repositories,src/drivers/platform/target.inc)