From 3aba7ac2c25e9fee4c3633c6c01ab8e27b38ab29 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Thu, 23 Jan 2020 18:15:32 +0100 Subject: [PATCH] Use Genode.Boot.Rom type when building test images --- apps/linux-image/script.dhall | 52 +++++++++++++++++---------- apps/nova-image/nova-modules.as.dhall | 45 +++++++++++++---------- tests/driver-linux-config.dhall | 22 +++++++----- tests/driver-linux.nix | 1 - tests/driver-nova-config.dhall | 23 ++++++------ tests/driver-nova.nix | 5 +-- tests/log.dhall | 5 ++- tests/pci.dhall | 11 +++--- tests/rtc.dhall | 5 ++- tests/signal.dhall | 5 ++- tests/solo5/blk.dhall | 3 +- tests/solo5/boot-wrapper.dhall | 10 +++--- tests/solo5/default.nix | 1 + tests/solo5/net.dhall | 15 ++++---- tests/solo5/net_2if.dhall | 13 +++---- tests/solo5/simple.dhall | 2 +- tests/solo5/time.dhall | 2 +- 17 files changed, 131 insertions(+), 89 deletions(-) diff --git a/apps/linux-image/script.dhall b/apps/linux-image/script.dhall index f7638a8..8ee0b2c 100644 --- a/apps/linux-image/script.dhall +++ b/apps/linux-image/script.dhall @@ -5,25 +5,39 @@ let Genode = env:DHALL_GENODE let Prelude = Genode.Prelude let Args = - { config : Genode.Init.Type, rom : Genode.Prelude.Map.Type Text Text } + { config : Genode.Init.Type + , rom : Genode.Prelude.Map.Type Text Genode.Boot.Rom + } : Type +let RomEntry = Prelude.Map.Entry Text Genode.Boot.Rom + +let addLine = + λ(e : RomEntry) + → λ(script : Text) + → merge + { RomText = + λ(rom : Text) + → '' + ${script} + echo ${Text/show rom} > ${Text/show e.mapKey} + '' + , RomPath = + λ(rom : Text) + → '' + ${script} + ln -s ${Text/show rom} ${Text/show e.mapKey} + '' + } + e.mapValue + in λ(args : Args) - → let addLink = - λ(e : Prelude.Map.Entry Text Text) - → λ(script : Text) - → script ++ "ln -s ${Text/show e.mapValue} ${Text/show e.mapKey}\n" - - let links = - Prelude.List.fold - (Prelude.Map.Entry Text Text) - args.rom - Text - addLink - "" - - in '' - #!/bin/sh - ${links} - echo ${Text/show (Genode.Init.render args.config)} > config - '' + → Prelude.List.fold + RomEntry + args.rom + Text + addLine + '' + #!/bin/sh + echo ${Text/show (Genode.Init.render args.config)} > config + '' diff --git a/apps/nova-image/nova-modules.as.dhall b/apps/nova-image/nova-modules.as.dhall index e32ddfa..70e3c5d 100644 --- a/apps/nova-image/nova-modules.as.dhall +++ b/apps/nova-image/nova-modules.as.dhall @@ -4,11 +4,12 @@ let Genode = env:DHALL_GENODE let Prelude = Genode.Prelude +let RomMap = Prelude.Map.Type Text Genode.Boot.Rom + +let RomEntry = Prelude.Map.Entry Text Genode.Boot.Rom + let Configuration = - { arch : < x86_32 | x86_64 > - , config : Genode.Init.Type - , rom : Prelude.Map.Type Text Text - } + { arch : < x86_32 | x86_64 >, config : Genode.Init.Type, rom : RomMap } : Type in λ ( boot @@ -19,23 +20,26 @@ in λ ( boot let TextIndex = { index : Text, value : Text } - let moduleKeys = - let keys = Prelude.Map.keys Text Text boot.rom - - in [ "config" ] # keys + let rom = + [ { mapKey = "config" + , mapValue = + Genode.Boot.Rom.RomText (Genode.Init.render boot.config) + } + ] + # boot.rom + + let moduleKeys = Prelude.Map.keys Text Genode.Boot.Rom rom let moduleValues = - let values = Prelude.Map.values Text Text boot.rom + let f = + λ(e : RomEntry) + → merge + { RomText = λ(text : Text) → ".ascii ${Text/show text}" + , RomPath = λ(path : Text) → ".incbin ${Text/show path}" + } + e.mapValue - let incbin = - Prelude.List.map - Text - Text - (λ(path : Text) → ".incbin ${Text/show path}") - values - - in [ ".ascii ${Text/show (Genode.Init.render boot.config)}" ] - # incbin + in Prelude.List.map RomEntry Text f rom let map = λ(list : List Text) @@ -47,7 +51,7 @@ in λ ( boot NaturalIndex TextIndex ( λ(x : NaturalIndex) - → { index = Prelude.Natural.show (x.index + 1) + → { index = Prelude.Natural.show x.index , value = x.value } ) @@ -66,7 +70,9 @@ in λ ( boot in '' .set MIN_PAGE_SIZE_LOG2, 12 .set DATA_ACCESS_ALIGNM_LOG2, 3 + .section .data + .p2align DATA_ACCESS_ALIGNM_LOG2 .global _boot_modules_headers_begin _boot_modules_headers_begin: @@ -94,6 +100,7 @@ in λ ( boot _boot_module_${m.index}_name: .string "${m.value}" .byte 0 + '' ) ++ '' diff --git a/tests/driver-linux-config.dhall b/tests/driver-linux-config.dhall index f47e6f1..c70433c 100644 --- a/tests/driver-linux-config.dhall +++ b/tests/driver-linux-config.dhall @@ -2,7 +2,9 @@ let Genode = env:DHALL_GENODE let Args = - { config : Genode.Init.Type, rom : Genode.Prelude.Map.Type Text Text } + { config : Genode.Init.Type + , rom : Genode.Prelude.Map.Type Text Genode.Boot.Rom + } : Type in λ(args : Args) @@ -29,12 +31,14 @@ in λ(args : Args) let os = env:OS_MANIFEST - in [ { mapKey = "ld.lib.so" - , mapValue = baseLinux.bin.ld-linux.mapValue - } - , baseLinux.bin.linux_timer_drv - , os.bin.init - , baseLinux.bin.core-linux - ] - # args.rom + in Genode.Boot.toRomPaths + [ { mapKey = "ld.lib.so" + , mapValue = baseLinux.bin.ld-linux.mapValue + } + , baseLinux.bin.linux_timer_drv + , os.bin.init + , baseLinux.bin.core-linux + ] + # args.rom + : Genode.Prelude.Map.Type Text Genode.Boot.Rom } diff --git a/tests/driver-linux.nix b/tests/driver-linux.nix index d6cd2db..a1c3beb 100644 --- a/tests/driver-linux.nix +++ b/tests/driver-linux.nix @@ -70,7 +70,6 @@ let global env set env(XDG_CACHE_HOME) /tmp - puts "${apps.linux-image.program} ${./driver-linux-config.dhall} ${testConfig}" exec ${apps.linux-image.program} \ ${./driver-linux-config.dhall} ${testConfig} diff --git a/tests/driver-nova-config.dhall b/tests/driver-nova-config.dhall index 6753548..6d68225 100644 --- a/tests/driver-nova-config.dhall +++ b/tests/driver-nova-config.dhall @@ -2,9 +2,11 @@ let Genode = env:DHALL_GENODE -let Args = - { config : Genode.Init.Type, rom : Genode.Prelude.Map.Type Text Text } - : Type +let Prelude = Genode.Prelude + +let RomMap = Prelude.Map.Type Text Genode.Boot.Rom + +let Args = { config : Genode.Init.Type, rom : RomMap } : Type in λ(args : Args) → { arch = let Arch = < x86_32 | x86_64 > in Arch.x86_64 @@ -65,12 +67,13 @@ in λ(args : Args) let sotest = env:SOTEST_PRODUCER_MANIFEST - in [ { mapKey = "ld.lib.so" - , mapValue = baseNova.lib.ld-nova.mapValue - } - , baseNova.bin.nova_timer_drv - , os.bin.init - , sotest.bin.sotest-harness - ] + in Genode.Boot.toRomPaths + [ { mapKey = "ld.lib.so" + , mapValue = baseNova.lib.ld-nova.mapValue + } + , baseNova.bin.nova_timer_drv + , os.bin.init + , sotest.bin.sotest-harness + ] # args.rom } diff --git a/tests/driver-nova.nix b/tests/driver-nova.nix index 73805d1..e6a2fc6 100644 --- a/tests/driver-nova.nix +++ b/tests/driver-nova.nix @@ -130,20 +130,21 @@ let inherit driver iso test; config = hostPkgs.runCommand (name + ".dhall") env' '' + export XDG_CACHE_HOME=${TMPDIR:-/tmp} ${apps.dhall.program} <<< "(${ ./driver-nova-config.dhall } ${testConfig})" > $out ''; xml = hostPkgs.runCommand (name + ".config") env' '' + export XDG_CACHE_HOME=${TMPDIR:-/tmp} ${apps.render-init.program} "(${ ./driver-nova-config.dhall } ${testConfig}).config" > $out''; sotest = hostPkgs.runCommand "nova-${name}-sotest" env' '' export XDG_CACHE_HOME=${TMPDIR:-/tmp} - ${apps.nova-image.program} image.elf \ - ${./driver-nova-config.dhall} ${testConfig} + ${apps.nova-image.program} image.elf "${./driver-nova-config.dhall} ${testConfig}" cp "${testPkgs.bender}" bender cp "${testPkgs.NOVA}/hypervisor-x86_64" hypervisor mkdir -p $out/nix-support diff --git a/tests/log.dhall b/tests/log.dhall index eb8b889..d9797ed 100644 --- a/tests/log.dhall +++ b/tests/log.dhall @@ -16,5 +16,8 @@ in { config = } } } - , rom = let base = env:BASE_MANIFEST in [ base.bin.test-log ] + , rom = + let base = env:BASE_MANIFEST + + in Genode.Boot.toRomPaths [ base.bin.test-log ] } diff --git a/tests/pci.dhall b/tests/pci.dhall index 823c91e..c41f19b 100644 --- a/tests/pci.dhall +++ b/tests/pci.dhall @@ -76,9 +76,10 @@ in { config = , rom = let os = env:OS_MANIFEST - in [ os.bin.acpi_drv - , os.bin.platform_drv - , os.bin.report_rom - , os.bin.test-pci - ] + in Genode.Boot.toRomPaths + [ os.bin.acpi_drv + , os.bin.platform_drv + , os.bin.report_rom + , os.bin.test-pci + ] } diff --git a/tests/rtc.dhall b/tests/rtc.dhall index c66e4f9..d1a5166 100644 --- a/tests/rtc.dhall +++ b/tests/rtc.dhall @@ -25,5 +25,8 @@ in { config = } } } - , rom = let os = env:OS_MANIFEST in [ os.bin.test-rtc, os.bin.rtc_drv ] + , rom = + let os = env:OS_MANIFEST + + in Genode.Boot.toRomPaths [ os.bin.test-rtc, os.bin.rtc_drv ] } diff --git a/tests/signal.dhall b/tests/signal.dhall index f86e659..3189d72 100644 --- a/tests/signal.dhall +++ b/tests/signal.dhall @@ -16,5 +16,8 @@ in { config = } } } - , rom = let os = env:OS_MANIFEST in [ os.bin.test-signal ] + , rom = + let os = env:OS_MANIFEST + + in Genode.Boot.toRomPaths [ os.bin.test-signal ] } diff --git a/tests/solo5/blk.dhall b/tests/solo5/blk.dhall index 40ecd68..4bb73cf 100644 --- a/tests/solo5/blk.dhall +++ b/tests/solo5/blk.dhall @@ -34,5 +34,6 @@ in { config = } } } - , rom = [ tests.bin.solo5-test_blk, os.bin.ram_block ] + , rom = + Genode.Boot.toRomPaths [ tests.bin.solo5-test_blk, os.bin.ram_block ] } diff --git a/tests/solo5/boot-wrapper.dhall b/tests/solo5/boot-wrapper.dhall index 9b2ffed..de2d463 100644 --- a/tests/solo5/boot-wrapper.dhall +++ b/tests/solo5/boot-wrapper.dhall @@ -4,9 +4,11 @@ let Genode = env:DHALL_GENODE let solo5 = env:SOLO5_MANIFEST -let Args = - { config : Genode.Init.Type, rom : Genode.Prelude.Map.Type Text Text } - : Type +let RomMap = Genode.Prelude.Map.Type Text Genode.Boot.Rom + +let Args = { config : Genode.Init.Type, rom : RomMap } : Type in λ(boot : Args) - → { config = boot.config, rom = boot.rom # [ solo5.lib.solo5 ] } + → { config = boot.config + , rom = Genode.Boot.toRomPaths [ solo5.lib.solo5 ] # boot.rom + } diff --git a/tests/solo5/default.nix b/tests/solo5/default.nix index 2bcf3c5..a2e6bf3 100644 --- a/tests/solo5/default.nix +++ b/tests/solo5/default.nix @@ -56,6 +56,7 @@ let testScript = '' run_genode_until {child "ping" exited with exit value 0} 30 ''; + qemuMem = 64; } { diff --git a/tests/solo5/net.dhall b/tests/solo5/net.dhall index ddaa8ba..a19b920 100644 --- a/tests/solo5/net.dhall +++ b/tests/solo5/net.dhall @@ -43,9 +43,7 @@ in { config = , config = Some ( Genode.Prelude.XML.text - '' - limit - '' + "limit" ) } , ping = @@ -73,9 +71,10 @@ in { config = } } , rom = - [ os.bin.nic_loopback - , os.bin.nic_bridge - , os.bin.ping - , tests.bin.solo5-test_net - ] + Genode.Boot.toRomPaths + [ os.bin.nic_loopback + , os.bin.nic_bridge + , os.bin.ping + , tests.bin.solo5-test_net + ] } diff --git a/tests/solo5/net_2if.dhall b/tests/solo5/net_2if.dhall index e6ff36f..7f4ef2a 100644 --- a/tests/solo5/net_2if.dhall +++ b/tests/solo5/net_2if.dhall @@ -77,10 +77,11 @@ in { config = } } , rom = - [ tests.bin.solo5-test_net_2if - , os.bin.sequence - , os.bin.nic_bridge - , os.bin.nic_loopback - , os.bin.ping - ] + Genode.Boot.toRomPaths + [ tests.bin.solo5-test_net_2if + , os.bin.sequence + , os.bin.nic_bridge + , os.bin.nic_loopback + , os.bin.ping + ] } diff --git a/tests/solo5/simple.dhall b/tests/solo5/simple.dhall index 9cde8bb..7ff1834 100644 --- a/tests/solo5/simple.dhall +++ b/tests/solo5/simple.dhall @@ -35,5 +35,5 @@ in λ(testBinary : Genode.Prelude.Map.Entry Text Text) } } } - , rom = [ testBinary ] + , rom = Genode.Boot.toRomPaths [ testBinary ] } diff --git a/tests/solo5/time.dhall b/tests/solo5/time.dhall index 21340dd..ffbe06e 100644 --- a/tests/solo5/time.dhall +++ b/tests/solo5/time.dhall @@ -29,5 +29,5 @@ in { config = } } } - , rom = [ test, os.bin.rtc_drv ] + , rom = Genode.Boot.toRomPaths [ test, os.bin.rtc_drv ] }