sculpt: host PS/2 driver in runtime

Issue #5150
This commit is contained in:
Norman Feske 2024-03-21 14:24:58 +01:00 committed by Christian Helmuth
parent 556a7b8b17
commit e3803fb861
6 changed files with 94 additions and 33 deletions

View File

@ -125,7 +125,7 @@
</route> </route>
<config> <config>
<report devices="yes" iommu="yes"/> <report devices="yes" iommu="yes"/>
<policy label_prefix="ps2_drv"> <device name="ps2"/> </policy> <policy label_prefix="runtime -> ps2"> <device name="ps2"/> </policy>
<policy label_prefix="runtime -> vesa_fb" info="yes"> <pci class="VGA"/> </policy> <policy label_prefix="runtime -> vesa_fb" info="yes"> <pci class="VGA"/> </policy>
<policy label_prefix="dynamic -> ahci_drv"> <pci class="AHCI"/> </policy> <policy label_prefix="dynamic -> ahci_drv"> <pci class="AHCI"/> </policy>
<policy label_prefix="dynamic -> nvme_drv" info="yes"> <pci class="NVME"/> </policy> <policy label_prefix="dynamic -> nvme_drv" info="yes"> <pci class="NVME"/> </policy>
@ -141,23 +141,6 @@
</config> </config>
</start> </start>
<start name="ps2_drv">
<resource name="RAM" quantum="1M"/>
<config capslock_led="rom" numlock_led="rom" system="yes"/>
<route>
<service name="Platform"> <child name="platform_drv"/> </service>
<service name="Event"> <parent label="ps2"/> </service>
<service name="ROM" label="capslock"> <parent label="capslock"/> </service>
<service name="ROM" label="numlock"> <parent label="numlock"/> </service>
<service name="ROM" label="system"> <parent label="system"/> </service>
<service name="ROM"> <parent/> </service>
<service name="PD"> <parent/> </service>
<service name="CPU"> <parent/> </service>
<service name="LOG"> <parent/> </service>
<service name="Timer"> <parent/> </service>
</route>
</start>
<start name="driver_manager"> <start name="driver_manager">
<resource name="RAM" quantum="1M"/> <resource name="RAM" quantum="1M"/>
<route> <route>

View File

@ -8,7 +8,7 @@
<input name="sdl"/> <input name="sdl"/>
</merge> </merge>
</output> </output>
<policy label="drivers -> ps2" input="ps2"/> <policy label="runtime -> ps2" input="ps2"/>
<policy label="runtime -> usb_hid" input="usb"/> <policy label="runtime -> usb_hid" input="usb"/>
<policy label="drivers -> touch" input="touch"/> <policy label="drivers -> touch" input="touch"/>
<policy label="drivers -> sdl" input="sdl"/> <policy label="drivers -> sdl" input="sdl"/>

View File

@ -35,6 +35,6 @@
<include rom="special.chargen"/> <include rom="special.chargen"/>
</chargen> </chargen>
</output> </output>
<policy label="drivers -> ps2" input="ps2"/> <policy label="runtime -> ps2" input="ps2"/>
<policy label="runtime -> usb_hid" input="usb"/> <policy label="runtime -> usb_hid" input="usb"/>
</config> </config>

View File

@ -45,6 +45,7 @@
#include <view/system_dialog.h> #include <view/system_dialog.h>
#include <view/file_browser_dialog.h> #include <view/file_browser_dialog.h>
#include <fb_driver.h> #include <fb_driver.h>
#include <ps2_driver.h>
#include <usb_driver.h> #include <usb_driver.h>
#include <gui.h> #include <gui.h>
#include <keyboard_focus.h> #include <keyboard_focus.h>
@ -223,14 +224,15 @@ struct Sculpt::Main : Input_event_handler,
_board_info = Board_info::from_xml(_devices.xml(), _platform.xml()); _board_info = Board_info::from_xml(_devices.xml(), _platform.xml());
_fb_driver.update(_child_states, _board_info, _platform.xml()); _fb_driver.update(_child_states, _board_info, _platform.xml());
_ps2_driver.update(_child_states, _board_info);
_update_usb_drivers(); _update_usb_drivers();
update_network_dialog(); update_network_dialog();
generate_runtime_config(); generate_runtime_config();
} }
Ps2_driver _ps2_driver { };
Fb_driver _fb_driver { }; Fb_driver _fb_driver { };
Usb_driver _usb_driver { _env, *this }; Usb_driver _usb_driver { _env, *this };
void _update_usb_drivers() void _update_usb_drivers()
@ -2114,6 +2116,7 @@ void Sculpt::Main::_generate_runtime_config(Xml_generator &xml) const
xml.attribute("height", _affinity_space.height()); xml.attribute("height", _affinity_space.height());
}); });
_ps2_driver.gen_start_node(xml);
_fb_driver .gen_start_nodes(xml); _fb_driver .gen_start_nodes(xml);
_usb_driver.gen_start_nodes(xml); _usb_driver.gen_start_nodes(xml);
@ -2262,7 +2265,7 @@ void Sculpt::Main::_generate_event_filter_config(Xml_generator &xml)
xml.attribute("label", label); xml.attribute("label", label);
xml.attribute("input", input); }); }; xml.attribute("input", input); }); };
gen_policy("drivers -> ps2", "ps2"); gen_policy("runtime -> ps2", "ps2");
gen_policy("runtime -> usb_hid", "usb"); gen_policy("runtime -> usb_hid", "usb");
gen_policy("drivers -> touch", "touch"); gen_policy("drivers -> touch", "touch");
gen_policy("drivers -> sdl", "sdl"); gen_policy("drivers -> sdl", "sdl");

View File

@ -20,15 +20,16 @@ namespace Sculpt { struct Board_info; }
struct Sculpt::Board_info struct Sculpt::Board_info
{ {
bool wifi_present; bool wifi_present,
bool lan_present; lan_present,
bool modem_present; modem_present,
bool intel_gfx_present; intel_gfx_present,
bool boot_fb_present; boot_fb_present,
bool vesa_fb_present; vesa_fb_present,
bool nvme_present; nvme_present,
bool ahci_present; ahci_present,
bool usb_present; usb_present,
ps2_present;
static Board_info from_xml(Xml_node const &devices, Xml_node const &platform) static Board_info from_xml(Xml_node const &devices, Xml_node const &platform)
{ {
@ -40,6 +41,10 @@ struct Sculpt::Board_info
bool vga = false; bool vga = false;
devices.for_each_sub_node("device", [&] (Xml_node const &device) { devices.for_each_sub_node("device", [&] (Xml_node const &device) {
if (device.attribute_value("name", String<16>()) == "ps2")
result.ps2_present = true;
device.with_optional_sub_node("pci-config", [&] (Xml_node const &pci) { device.with_optional_sub_node("pci-config", [&] (Xml_node const &pci) {
enum class Pci_class : unsigned { enum class Pci_class : unsigned {

View File

@ -0,0 +1,70 @@
/*
* \brief Sculpt PS/2-driver management
* \author Norman Feske
* \date 2024-03-21
*/
/*
* Copyright (C) 2024 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 _PS2_DRIVER_H_
#define _PS2_DRIVER_H_
/* local includes */
#include <model/child_exit_state.h>
#include <model/board_info.h>
#include <runtime.h>
namespace Sculpt { struct Ps2_driver; }
struct Sculpt::Ps2_driver : private Noncopyable
{
Constructible<Child_state> _ps2 { };
void gen_start_node(Xml_generator &xml) const
{
if (!_ps2.constructed())
return;
xml.node("start", [&] {
_ps2->gen_start_node_content(xml);
gen_named_node(xml, "binary", "ps2_drv");
xml.node("config", [&] {
xml.attribute("capslock_led", "rom");
xml.attribute("numlock_led", "rom");
xml.attribute("system", "yes");
});
xml.node("route", [&] {
gen_parent_route<Platform::Session>(xml);
gen_parent_rom_route(xml, "capslock", "capslock");
gen_parent_rom_route(xml, "numlock", "numlock");
gen_parent_rom_route(xml, "system", "config -> managed/system");
gen_parent_route<Rom_session> (xml);
gen_parent_route<Cpu_session> (xml);
gen_parent_route<Pd_session> (xml);
gen_parent_route<Log_session> (xml);
gen_parent_route<Timer::Session>(xml);
gen_service_node<Event::Session>(xml, [&] {
xml.node("parent", [&] {
xml.attribute("label", "ps2"); }); });
});
});
};
void update(Registry<Child_state> &registry, Board_info const &board_info)
{
_ps2.conditional(board_info.ps2_present,
registry, "ps2", Priority::MULTIMEDIA,
Ram_quota { 1*1024*1024 }, Cap_quota { 100 });
}
};
#endif /* _PS2_DRIVER_H_ */