Skip to content

Commit

Permalink
sculpt: driver-policy tweaks
Browse files Browse the repository at this point in the history
Allow tweaking the driver selection using the manager config:

- The new attribute 'ps2="no"' suppresses the selection of the PS/2 driver.
- The new attribute 'intel_gpu="no"'suppresses the selection of the
  Intel GPU and fb drivers, letting Sculpt fall back to VESA or boot-fb.

Note that the dynamic change of those attributes is handled in principle
but not advisable. E.g., disabling the intel driver after startup leaves
the hardware in a state that the VESA driver cannot cope with. However,
when statically defining the attributes in sculpt/manager/default, it is
now possible to build an image that uses VESA on an intel machine.

Issue #5174
  • Loading branch information
nfeske committed Apr 8, 2024
1 parent 5742ac0 commit d17aa7d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 19 deletions.
13 changes: 9 additions & 4 deletions repos/gems/src/app/sculpt_manager/driver/fb.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,28 @@ struct Sculpt::Fb_driver : private Noncopyable
void update(Registry<Child_state> &registry, Board_info const &board_info,
Xml_node const &platform)
{
_intel_gpu.conditional(board_info.detected.intel_gfx,
bool const use_intel = board_info.detected.intel_gfx
&& !board_info.options.suppress.intel_gpu;
bool const use_boot_fb = !use_intel && board_info.detected.boot_fb;
bool const use_vesa = !use_boot_fb && board_info.detected.vga;

_intel_gpu.conditional(use_intel,
registry, "intel_gpu", Priority::MULTIMEDIA,
Ram_quota { 32*1024*1024 }, Cap_quota { 1400 });

_intel_fb.conditional(board_info.detected.intel_gfx,
_intel_fb.conditional(use_intel,
registry, "intel_fb", Priority::MULTIMEDIA,
Ram_quota { 16*1024*1024 }, Cap_quota { 800 });

_vesa_fb.conditional(board_info.detected.vesa,
_vesa_fb.conditional(use_vesa,
registry, "vesa_fb", Priority::MULTIMEDIA,
Ram_quota { 8*1024*1024 }, Cap_quota { 110 });

_soc_fb.conditional(board_info.soc.fb && board_info.options.display,
registry, "fb", Priority::MULTIMEDIA,
Ram_quota { 16*1024*1024 }, Cap_quota { 250 });

if (board_info.detected.boot_fb && !_boot_fb.constructed())
if (use_boot_fb && !_boot_fb.constructed())
Boot_fb::with_mode(platform, [&] (Boot_fb::Mode mode) {
_boot_fb.construct(registry, "boot_fb", Priority::MULTIMEDIA,
mode.ram_quota(), Cap_quota { 100 }); });
Expand Down
2 changes: 1 addition & 1 deletion repos/gems/src/app/sculpt_manager/driver/ps2.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct Sculpt::Ps2_driver : private Noncopyable

void update(Registry<Child_state> &registry, Board_info const &board_info)
{
_ps2.conditional(board_info.detected.ps2,
_ps2.conditional(board_info.detected.ps2 && !board_info.options.suppress.ps2,
registry, "ps2", Priority::MULTIMEDIA,
Ram_quota { 1*1024*1024 }, Cap_quota { 100 });
}
Expand Down
10 changes: 9 additions & 1 deletion repos/gems/src/app/sculpt_manager/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,16 @@ struct Sculpt::Main : Input_event_handler,

Rom_handler<Main> _config { _env, "config", *this, &Main::_handle_config };

void _handle_config(Xml_node const &)
void _handle_config(Xml_node const &config)
{
Board_info::Options const orig_options = _driver_options;
_driver_options.suppress.ps2 = !config.attribute_value("ps2", true);
_driver_options.suppress.intel_gpu = !config.attribute_value("intel_gpu", true);
if (orig_options != _driver_options) {
_drivers.update_options(_driver_options);
generate_runtime_config();
}

_handle_storage_devices();
}

Expand Down
30 changes: 17 additions & 13 deletions repos/gems/src/app/sculpt_manager/model/board_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ struct Sculpt::Board_info
*/
struct Detected
{
bool wifi, nic, intel_gfx, boot_fb, vesa, nvme, ahci, usb, ps2;
bool wifi, nic, intel_gfx, boot_fb, vga, nvme, ahci, usb, ps2;

void print(Output &out) const
{
Genode::print(out, "wifi=", wifi, " nic=", nic,
" intel_gfx=", intel_gfx, " boot_fb=", boot_fb,
" vesa=", vesa, " nvme=", nvme,
" vga=", vga, " nvme=", nvme,
" ahci=", ahci, " usb=", usb);
}

Expand Down Expand Up @@ -61,10 +61,22 @@ struct Sculpt::Board_info
{
bool display, usb_net, nic, wifi;

struct Suppress {

bool ps2, intel_gpu;

bool operator != (Suppress const &other) const
{
return ps2 != other.ps2 || intel_gpu != other.intel_gpu;
}

} suppress;

bool operator != (Options const &other) const
{
return display != other.display || usb_net != other.usb_net
|| nic != other.nic || wifi != other.wifi;
return display != other.display || usb_net != other.usb_net
|| nic != other.nic || wifi != other.wifi
|| suppress != other.suppress;
}

} options;
Expand All @@ -82,8 +94,6 @@ Sculpt::Board_info::Detected::from_xml(Xml_node const &devices, Xml_node const &
Boot_fb::with_mode(platform, [&] (Boot_fb::Mode mode) {
detected.boot_fb = mode.valid(); });

bool vga = false;

devices.for_each_sub_node("device", [&] (Xml_node const &device) {

if (device.attribute_value("name", String<16>()) == "ps2")
Expand Down Expand Up @@ -124,19 +134,13 @@ Sculpt::Board_info::Detected::from_xml(Xml_node const &devices, Xml_node const &
detected.ahci = true;

if (matches_class(Pci_class::VGA)) {
vga = true;
detected.vga = true;
if (matches_vendor(Pci_vendor::INTEL))
detected.intel_gfx = true;
}
});
});

if (detected.intel_gfx)
detected.boot_fb = false;

if (vga && !detected.intel_gfx && !detected.boot_fb)
detected.vesa = true;

return detected;
}

Expand Down

0 comments on commit d17aa7d

Please sign in to comment.