From 52fe694be443b38a164af790f26074e22c17e956 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Thu, 27 Feb 2020 18:17:14 +0100 Subject: [PATCH] Add NOVA driver_manager test --- compositions/pc-drivers.dhall | 284 +++++++++++++++++++++++++++++ packages/default.nix | 8 + packages/genodelabs/capslock.patch | 21 +++ tests/default.nix | 4 +- tests/driver-hw-config.dhall | 4 +- tests/driver_manager.dhall | 110 +++++++++++ tests/driver_manager.nix | 27 +++ tests/driver_manager.rom.dhall | 72 ++++++++ 8 files changed, 527 insertions(+), 3 deletions(-) create mode 100644 compositions/pc-drivers.dhall create mode 100644 packages/genodelabs/capslock.patch create mode 100644 tests/driver_manager.dhall create mode 100644 tests/driver_manager.nix create mode 100644 tests/driver_manager.rom.dhall diff --git a/compositions/pc-drivers.dhall b/compositions/pc-drivers.dhall new file mode 100644 index 0000000..0560c41 --- /dev/null +++ b/compositions/pc-drivers.dhall @@ -0,0 +1,284 @@ +-- SPDX-License-Identifier: CC0-1.0 + +let Genode = env:DHALL_GENODE + +let Prelude = Genode.Prelude + +let XML = Prelude.XML + +let Init = Genode.Init + +let Child = Init.Child + +let Resources = Init.Resources + +let ServiceRoute = Init.ServiceRoute + +let reportRomRoute = + λ(service : Text) + → λ(label : Text) + → ServiceRoute.childLabel service "report_rom" (Some label) (None Text) + +let reportRomReport = reportRomRoute "Report" + +let reportRomROM = reportRomRoute "ROM" + +let drivers = + Init::{ + , services = + [ ServiceRoute.child "Framebuffer" "dynamic" + , ServiceRoute.child "Block" "dynamic" + , ServiceRoute.child "Usb" "usb_drv" + , ServiceRoute.child "Platform" "platform_drv" + , ServiceRoute.child "Input" "input_filter" + , ServiceRoute.child "Rtc" "rtc" + ] + , children = + toMap + { rtc = + Child.flat + Child.Attributes::{ + , binary = "rtc_drv" + , provides = [ "Rtc" ] + , routes = + [ ServiceRoute.parent "IO_PORT" + , ServiceRoute.parent "IO_MEM" + ] + } + , report_rom = + Child.flat + Child.Attributes::{ + , binary = "report_rom" + , resources = Resources::{ ram = Genode.units.MiB 2 } + , provides = [ "ROM", "Report" ] + , config = + Init.Config::{ + , content = + [ XML.text + '' + + + + + + + + + + + '' + ] + } + } + , rom_reporter = + Child.flat + Child.Attributes::{ + , binary = "rom_reporter" + , config = + Init.Config::{ + , content = + [ XML.text + '' + + + + '' + ] + } + , routes = + let routeReportToParent = + λ(label : Text) + → ServiceRoute.parentLabel + "Report" + (Some label) + (Some label) + + in [ reportRomROM "acpi" + , reportRomROM "pci_devices" + , reportRomROM "usb_devices" + , routeReportToParent "acpi" + , routeReportToParent "pci_devices" + , routeReportToParent "usb_devices" + ] + } + , acpi_drv = + Child.flat + Child.Attributes::{ + , binary = "acpi_drv" + , priority = 1 + , resources = + Resources::{ caps = 350, ram = Genode.units.MiB 4 } + , routes = + [ ServiceRoute.parent "IO_MEM" + , reportRomReport "acpi" + , ServiceRoute.parentLabel + "Report" + (Some "smbios_table") + (Some "smbios_table") + ] + } + , platform_drv = + Child.flat + Child.Attributes::{ + , binary = "platform_drv" + , resources = + Resources::{ + , caps = 400 + , ram = Genode.units.MiB 4 + , constrainPhys = True + } + , provides = [ "Acpi", "Platform" ] + , routes = + [ ServiceRoute.parent "IRQ" + , ServiceRoute.parent "IO_MEM" + , ServiceRoute.parent "IO_PORT" + , ServiceRoute.parent "Timer" + , ServiceRoute.parentLabel + "ROM" + (Some "system") + (Some "system") + , reportRomROM "acpi" + , reportRomReport "pci" + ] + , config = + Init.Config::{ + , attributes = toMap { system = "yes" } + , content = + [ XML.text + '' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '' + ] + } + } + , usb_drv = + Child.flat + Child.Attributes::{ + , binary = "usb_drv" + , priority = 1 + , resources = + Resources::{ caps = 200, ram = Genode.units.MiB 16 } + , provides = [ "Input", "Usb" ] + , routes = + [ ServiceRoute.child "Platform" "platform_drv" + , reportRomROM "config" + , reportRomReport "devices" + , ServiceRoute.parentLabel + "Report" + (Some "config") + (Some "usb_active_config") + , ServiceRoute.parent "Timer" + ] + } + , ps2_drv = + Child.flat + Child.Attributes::{ + , binary = "ps2_drv" + , provides = [ "Input" ] + , routes = + [ ServiceRoute.child "Platform" "platform_drv" + , ServiceRoute.parent "Timer" + ] + } + , input_filter = + Child.flat + Child.Attributes::{ + , binary = "input_filter" + , priority = 1 + , resources = Resources::{ ram = Genode.units.MiB 2 } + , provides = [ "Input" ] + , routes = + [ ServiceRoute.parent "Timer" + , ServiceRoute.parentLabel + "ROM" + (Some "config") + (Some "input_filter.config") + , ServiceRoute.childLabel + "Input" + "ps2_drv" + (Some "ps2") + (None Text) + , ServiceRoute.childLabel + "Input" + "usb_drv" + (Some "usb") + (None Text) + ] + } + , driver_manager = + Child.flat + Child.Attributes::{ + , binary = "driver_manager" + , priority = 1 + , routes = + [ reportRomReport "init.config" + , reportRomReport "usb_drv.config" + , ServiceRoute.parentLabel + "Report" + (Some "block_devices") + (Some "block_devices") + , reportRomROM "usb_devices" + , reportRomROM "pci_devices" + , reportRomROM "ahci_ports" + , reportRomROM "nvme_ns" + , ServiceRoute.parentLabel + "ROM" + (Some "usb_policy") + (Some "usb_policy") + ] + } + , dynamic = + Child.flat + Child.Attributes::{ + , binary = "init" + , priority = 1 + , resources = + Resources::{ caps = 1400, ram = Genode.units.MiB 64 } + , provides = [ "Framebuffer", "Block" ] + , routes = + [ ServiceRoute.child "Platform" "platform_drv" + , reportRomReport "ahci_ports" + , reportRomReport "nvme_ns" + , ServiceRoute.child "Usb" "usb_drv" + , reportRomROM "config" + , ServiceRoute.parent "Timer" + , ServiceRoute.parent "Report" + , ServiceRoute.parent "IO_MEM" + , ServiceRoute.parent "IO_PORT" + ] + } + } + } + +in drivers diff --git a/packages/default.nix b/packages/default.nix index 9069824..5d197da 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -51,6 +51,14 @@ in rec { ''; }; + + driver_manager = buildUpstream { + name = "driver_manager"; + arch = "x86_64"; + targets = [ "app/driver_manager" ]; + patches = [ ./genodelabs/capslock.patch ]; + }; + genodeTests = let directoryBlacklist = [ "repos/base-*" diff --git a/packages/genodelabs/capslock.patch b/packages/genodelabs/capslock.patch new file mode 100644 index 0000000..aad957b --- /dev/null +++ b/packages/genodelabs/capslock.patch @@ -0,0 +1,21 @@ +commit 6bc2bd3f4ac2c4e68d7d6dbee164a40b5a72638f +Author: Emery Hemingway +Date: Wed Feb 26 22:35:36 2020 +0100 + + Disable capslock/numlock requirements in driver_manager + + The capslock and numlock state ROMs introduce senseless complexity. + +diff --git a/repos/gems/src/app/driver_manager/main.cc b/repos/gems/src/app/driver_manager/main.cc +index 149911a717..afe62e8297 100644 +--- a/repos/gems/src/app/driver_manager/main.cc ++++ b/repos/gems/src/app/driver_manager/main.cc +@@ -662,8 +662,6 @@ void Driver_manager::Main::_generate_usb_drv_config(Reporter &usb_drv_config, + xml.attribute("ehci", true); + xml.attribute("ohci", _use_ohci); + xml.attribute("xhci", true); +- xml.attribute("capslock_led", "rom"); +- xml.attribute("numlock_led", "rom"); + xml.node("hid", [&] () { }); + xml.node("raw", [&] () { + xml.node("report", [&] () { xml.attribute("devices", true); }); diff --git a/tests/default.nix b/tests/default.nix index 11c2bd8..a6ac08f 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -21,6 +21,7 @@ let nova = (call: ((tests call) // { + driver_manager = call ./driver_manager.nix { }; # noux = call ./noux.nix { }; pci = call ./pci.nix { }; rtc = call ./rtc.nix { }; @@ -54,4 +55,5 @@ let }) (testsToList nova); in with builtins; -listToAttrs ((concatLists (map (testsToList) [ linux nova hw ])) ++ hw-sotest ++ nova-sotest) +listToAttrs ((concatLists (map (testsToList) [ linux nova hw ])) ++ hw-sotest + ++ nova-sotest) diff --git a/tests/driver-hw-config.dhall b/tests/driver-hw-config.dhall index 370d5ed..6454580 100644 --- a/tests/driver-hw-config.dhall +++ b/tests/driver-hw-config.dhall @@ -29,8 +29,8 @@ in λ(boot : Genode.Boot.Type) let manifest = env:MANIFEST in Genode.Boot.toRomPaths - [ manifest.base-hw-pc.lib.ld - , manifest.base-hw-pc.bin.hw_timer_drv + [ manifest.base-hw-pc.bin.hw_timer_drv + , manifest.base-hw-pc.lib.ld , manifest.os.bin.init , manifest.sotest-producer.bin.sotest-harness ] diff --git a/tests/driver_manager.dhall b/tests/driver_manager.dhall new file mode 100644 index 0000000..089baf9 --- /dev/null +++ b/tests/driver_manager.dhall @@ -0,0 +1,110 @@ +-- SPDX-License-Identifier: CC0-1.0 + +let drivers = env:drivers ? ../compositions/pc-drivers.dhall + +let Genode = env:DHALL_GENODE + +let Init = Genode.Init + +let Child = Init.Child + +let Resources = Init.Resources + +let ServiceRoute = Init.ServiceRoute + +let parentRomRoute = + λ(from : Text) + → λ(to : Text) + → ServiceRoute.parentLabel "ROM" (Some from) (Some to) + +let childRomRoute = + λ(child : Text) + → λ(from : Text) + → ServiceRoute.childLabel "ROM" child (Some from) (None Text) + +in Init::{ + , verbose = True + , children = + toMap + { report_rom = + Child.flat + Child.Attributes::{ + , binary = "report_rom" + , provides = [ "ROM", "Report" ] + , config = + Init.Config::{ + , attributes = toMap { verbose = "yes" } + , content = + [ Genode.Prelude.XML.text + '' + + '' + ] + } + } + , drivers = + Init.toChild + drivers + Init.Attributes::{ + , provides = [ "Block", "Framebuffer", "Input" ] + , resources = Init.Resources::{ ram = Genode.units.MiB 4 } + , routes = + [ parentRomRoute + "managed/input_filter" + "input_filter.config" + , parentRomRoute " numlock_remap" "numlock_remap.config" + , childRomRoute "dynamic_rom" "capslock" + , childRomRoute "dynamic_rom" "numlock" + , childRomRoute "dynamic_rom" "system" + , ServiceRoute.child "Report" "report_rom" + , ServiceRoute.parent "Timer" + , Genode.Init.ServiceRoute.parent "IRQ" + , Genode.Init.ServiceRoute.parent "IO_MEM" + , Genode.Init.ServiceRoute.parent "IO_PORT" + ] + } + , dynamic_rom = + Child.flat + Child.Attributes::{ + , binary = "dynamic_rom" + , resources = Resources::{ ram = Genode.units.MiB 4 } + , provides = [ "ROM" ] + , config = + Genode.Init.Config::{ + , content = + [ Genode.Prelude.XML.text + '' + + + + + + + '' + ] + } + } + , test-driver_manager = + Child.flat + Child.Attributes::{ + , binary = "test-driver_manager" + , config = + Init.Config::{ + , content = + [ Genode.Prelude.XML.text + '' + + + + '' + ] + } + , routes = + [ childRomRoute "report_rom" "block_devices" + , ServiceRoute.child "Block" "drivers" + , ServiceRoute.child "Framebuffer" "drivers" + , ServiceRoute.child "Input" "drivers" + ] + } + } + } diff --git a/tests/driver_manager.nix b/tests/driver_manager.nix new file mode 100644 index 0000000..f5e41e3 --- /dev/null +++ b/tests/driver_manager.nix @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: CC0-1.0 + +{ testEnv, pkgs, depot, hostPkgs, ... }: +with pkgs; + +testEnv.mkTest { + name = "driver_manager"; + meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ]; + testEnv = { drivers = ./../compositions/pc-drivers.dhall; }; + testInputs = (with pkgs; [ genodeTests driver_manager ]) ++ (with depot; [ + boot_fb_drv + intel_fb_drv + usb_drv + vesa_drv + ]); + testScript = '' + catch { exec dd if=/dev/zero of=hdd_disk.raw bs=1M count=32 } + catch { exec ${hostPkgs.e2fsprogs}/bin/mke2fs -F bin/hdd_disk.raw } + run_genode_until {.*all expected devices present and accessible.*} 120 + ''; + testConfig = '' + { config = ${./driver_manager.dhall} + , rom = ${./driver_manager.rom.dhall} + } + ''; + qemuArgs = [ "-device ahci,id=ahci" "-drive id=hdd,file=hdd_disk.raw,format=raw,if=none" "-device ide-hd,drive=hdd,bus=ahci.1"]; +} diff --git a/tests/driver_manager.rom.dhall b/tests/driver_manager.rom.dhall new file mode 100644 index 0000000..3df6b33 --- /dev/null +++ b/tests/driver_manager.rom.dhall @@ -0,0 +1,72 @@ +let Genode = env:DHALL_GENODE + +let manifest = env:MANIFEST + +in Genode.Boot.toRomPaths + [ manifest.driver_manager.bin.driver_manager + , manifest.genode-tests.bin.test-driver_manager + , manifest.os.bin.acpi_drv + , manifest.os.bin.ahci_drv + , manifest.os.bin.dynamic_rom + , manifest.os.bin.input_filter + , manifest.os.bin.platform_drv + , manifest.os.bin.ps2_drv + , manifest.os.bin.report_rom + , manifest.os.bin.rom_reporter + , manifest.os.bin.rtc_drv + , manifest.usb_drv.bin.usb_drv + , manifest.vesa_drv.bin.vesa_fb_drv + ] + # Genode.Boot.toRomTexts + ( toMap + { usb_policy = "" } + # [ { mapKey = + "fb_drv.config" + , mapValue = + '' + + + + '' + } + , { mapKey = + "input_filter.config" + , mapValue = + '' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '' + } + ] + )