From 2690e372e04aa07a7ca90bbd490ffba28357ed19 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 7 Jun 2024 09:26:42 +0000 Subject: [PATCH] nix: Support multiple microkit configs Signed-off-by: Nick Spinale --- hacking/nix/scope/microkit/default.nix | 27 +++++++++++++++----------- hacking/nix/scope/sources.nix | 2 +- hacking/nix/scope/worlds.nix | 13 +++++++++++-- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/hacking/nix/scope/microkit/default.nix b/hacking/nix/scope/microkit/default.nix index 1e6cc7949..4a32fe5de 100644 --- a/hacking/nix/scope/microkit/default.nix +++ b/hacking/nix/scope/microkit/default.nix @@ -19,8 +19,7 @@ , rustToolchain ? defaultRustToolchain }: -# no configuration yet -{}: +{ board, config }: let microkitSource = sources.microkit; @@ -77,7 +76,13 @@ let dontFixup = true; buildPhase = '' - python3 build_sdk.py --sel4=${kernelSourcePatched} + python3 build_sdk.py \ + --sel4=${kernelSourcePatched} \ + --only-board ${board} \ + --only-config ${config} \ + --skip-docs \ + --skip-source-tarball + ''; installPhase = '' @@ -115,8 +120,8 @@ let mkSystem = { searchPath, systemXML }: lib.fix (self: runCommand "system" { MICROKIT_SDK = sdk; - MICROKIT_BOARD = "qemu_virt_aarch64"; - MICROKIT_CONFIG = "debug"; + MICROKIT_BOARD = board; + MICROKIT_CONFIG = config; nativeBuildInputs = [ python3Packages.sel4-deps @@ -128,8 +133,8 @@ let { name = "pds"; path = searchPath; } { name = "loader.elf"; path = loader; } { name = "report.txt"; path = "${self}/report.txt"; } - { name = "sdk/monitor.elf"; path = "${sdk}/board/qemu_virt_aarch64/debug/elf/monitor.elf"; } - { name = "sdk/loader.elf"; path = "${sdk}/board/qemu_virt_aarch64/debug/elf/loader.elf"; } + { name = "sdk/monitor.elf"; path = "${sdk}/board/${board}/${config}/elf/monitor.elf"; } + { name = "sdk/loader.elf"; path = "${sdk}/board/${board}/${config}/elf/loader.elf"; } ]; }; } '' @@ -142,7 +147,7 @@ let -r $out/report.txt ''); - exampleSource = microkitSource + "/example/qemu_virt_aarch64/hello"; + exampleSource = microkitSource + "/example/${board}/hello"; examplePDs = stdenv.mkDerivation { name = "example"; @@ -150,8 +155,8 @@ let src = exampleSource; MICROKIT_SDK = sdk; - MICROKIT_BOARD = "qemu_virt_aarch64"; - MICROKIT_CONFIG = "debug"; + MICROKIT_BOARD = board; + MICROKIT_CONFIG = config; MICROKIT_TOOL = "${tool}/bin/microkit"; @@ -169,7 +174,7 @@ let ''; }; - example = mkSystem { + example = assert board == "qemu_virt_aarch64"; mkSystem { searchPath = examplePDs; systemXML = exampleSource + "/hello.system"; }; diff --git a/hacking/nix/scope/sources.nix b/hacking/nix/scope/sources.nix index 05842e74f..56f3f6af0 100644 --- a/hacking/nix/scope/sources.nix +++ b/hacking/nix/scope/sources.nix @@ -62,7 +62,7 @@ in rec { microkit = fetchGit { url = "https://github.com/coliasgroup/microkit.git"; - rev = "9dba402fb9c9a0a52509c005e1d06772ab601295"; # branch "rust-nix" + rev = "9ed293c8908de78ccf7925c6e670093adfba59d4"; # branch "rust-nix" local = localRoot + "/microkit"; }; diff --git a/hacking/nix/scope/worlds.nix b/hacking/nix/scope/worlds.nix index bae73ba6c..e529049ca 100644 --- a/hacking/nix/scope/worlds.nix +++ b/hacking/nix/scope/worlds.nix @@ -42,16 +42,24 @@ in rec { , el2 ? true , hypervisor ? false , cpu ? "cortex-a57" - , isMicrokit ? false , mkSeL4KernelLoaderWithPayloadQEMUArgs ? loader: [ "-kernel" loader ] + + , isMicrokit ? false + , microkitBoard ? null + , microkitConfig ? if debugBuild == null || debugBuild then "debug" else "release" + , extraQEMUArgs ? [] }: let numCores = if smp then "2" else "1"; in mkWorld { - inherit kernelLoaderConfig microkitConfig; + inherit kernelLoaderConfig; inherit isMicrokit; + microkitConfig = { + board = microkitBoard; + config = microkitConfig; + }; kernelConfig = kernelConfigCommon // { ARM_CPU = mkString cpu; KernelArch = mkString "arm"; @@ -97,6 +105,7 @@ in rec { el2 = false; mcs = true; isMicrokit = true; + microkitBoard = "qemu_virt_aarch64"; cpu = "cortex-a53"; mkSeL4KernelLoaderWithPayloadQEMUArgs = loader: [ "-device" "loader,file=${loader},addr=0x70000000,cpu-num=0" ]; extraQEMUArgs = [ "-m" "size=2G" ];