From cfb0ef4ff762f299ef1e7962f93c8cb41134848d Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 7 Jun 2024 09:26:42 +0000 Subject: [PATCH 1/2] 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" ]; From 1325c0edc63d6476bb49205209a8ed0a0ce7201c Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 7 Jun 2024 09:49:25 +0000 Subject: [PATCH 2/2] nix: Clean up microkit Signed-off-by: Nick Spinale --- hacking/nix/scope/world/default.nix | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hacking/nix/scope/world/default.nix b/hacking/nix/scope/world/default.nix index 35db1afbc..fd2051fc5 100644 --- a/hacking/nix/scope/world/default.nix +++ b/hacking/nix/scope/world/default.nix @@ -53,6 +53,12 @@ self: with self; microkitForUserspace = microkit; microkitForBoot = microkit; + microkitDir = + let + inherit (worldConfig.microkitConfig) board config; + in + "${microkitForUserspace.sdk}/board/${board}/${config}"; + seL4 = assert !worldConfig.isMicrokit; mkSeL4 worldConfig.kernelConfig; seL4ForUserspace = seL4; @@ -64,21 +70,15 @@ self: with self; seL4IncludeDir = if worldConfig.isMicrokit then - let - d = "${microkitForUserspace.sdk}/board/qemu_virt_aarch64/debug"; - in - "${d}/include" + "${microkitDir}/include" else "${seL4ForUserspace}/libsel4/include"; seL4RustEnvVars = if worldConfig.isMicrokit - then - let - d = "${microkitForUserspace.sdk}/board/qemu_virt_aarch64/debug"; - in { - SEL4_INCLUDE_DIRS = "${d}/include"; - } + then { + SEL4_INCLUDE_DIRS = "${microkitDir}/include"; + } else { SEL4_PREFIX = seL4ForUserspace; };