diff --git a/hacking/nix/scope/microkit/default.nix b/hacking/nix/scope/microkit/default.nix index cc8a45c4d..e0db26f8a 100644 --- a/hacking/nix/scope/microkit/default.nix +++ b/hacking/nix/scope/microkit/default.nix @@ -68,6 +68,13 @@ let dontConfigure = true; dontFixup = true; + # TODO make PR upstream to improve flexibility + postPatch = '' + substituteInPlace build_sdk.py --replace \ + '"riscv64-unknown-elf-"' \ + '"${stdenv.cc.targetPrefix}"' + ''; + buildPhase = '' python3 build_sdk.py \ --sel4=${kernelSourcePatched} \ diff --git a/hacking/nix/scope/sources.nix b/hacking/nix/scope/sources.nix index ea2f2c973..65bb39962 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 = "9633b9cf9a29b227512762f3102c7868bae4b840"; # branch "rust-nix" + rev = "2492fa64b2e4930e5f3beb77be8914e5f35a2746"; # branch "rust-nix" local = localRoot + "/microkit"; }; diff --git a/hacking/nix/scope/world/instances/microkit/default.nix b/hacking/nix/scope/world/instances/microkit/default.nix index 2311ff9a7..551e74312 100644 --- a/hacking/nix/scope/world/instances/microkit/default.nix +++ b/hacking/nix/scope/world/instances/microkit/default.nix @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD-2-Clause # -{ lib, stdenv +{ lib, stdenv, hostPlatform , buildPackages, pkgsBuildBuild , linkFarm, symlinkJoin, writeText, runCommand, runCommandCC , callPackage @@ -62,7 +62,7 @@ in { } ); - banscii = maybe isMicrokit (callPackage ./banscii { + banscii = maybe (isMicrokit && seL4Config.PLAT == "qemu-arm-virt") (callPackage ./banscii { inherit canSimulate; inherit mkPD; }); @@ -106,7 +106,7 @@ in { } ); - reset = maybe isMicrokit ( + reset = maybe (isMicrokit && hostPlatform.isAarch64) ( let pd = rec { orig = mkPD rec { diff --git a/hacking/nix/scope/worlds.nix b/hacking/nix/scope/worlds.nix index b0da27149..bade0e7d0 100644 --- a/hacking/nix/scope/worlds.nix +++ b/hacking/nix/scope/worlds.nix @@ -269,13 +269,27 @@ in rec { mk = { mcs ? false , smp ? false + , mkLoaderQEMUArgs ? loader: [ "-kernel" loader ] + + , debugBuild ? null + + , isMicrokit ? false + , microkitBoard ? null + , microkitConfig ? if debugBuild == null || debugBuild then "debug" else "release" + + , extraQEMUArgs ? [] }: let numCores = if smp then "2" else "1"; - qemuMemory = "3072"; + qemuMemory = "2048"; in mkWorld { - inherit kernelLoaderConfig microkitConfig; + inherit kernelLoaderConfig; + inherit isMicrokit; + microkitConfig = { + board = microkitBoard; + config = microkitConfig; + }; kernelConfig = kernelConfigCommon // { QEMU_MEMORY = mkString qemuMemory; KernelArch = mkString "riscv"; @@ -292,9 +306,8 @@ in rec { "-cpu" "rv64" "-smp" numCores "-m" "size=${qemuMemory}" "-nographic" "-serial" "mon:stdio" - "-kernel" loader # "-d" "unimp,guest_errors" - ]; + ] ++ mkLoaderQEMUArgs loader ++ extraQEMUArgs; }; }; in rec { @@ -307,6 +320,11 @@ in rec { smp = mk { mcs = false; smp = true; }; nosmp = mk { mcs = false; smp = false; }; }; + microkit = mk { + mcs = true; + isMicrokit = true; + microkitBoard = "qemu_virt_riscv64"; + }; }; spike = mkWorld { diff --git a/hacking/nix/top-level/default.nix b/hacking/nix/top-level/default.nix index 6947d5c6c..add3a9b18 100644 --- a/hacking/nix/top-level/default.nix +++ b/hacking/nix/top-level/default.nix @@ -19,6 +19,7 @@ in { pkgs.host.aarch64.none.this.worlds.qemu-arm-virt.microkit pkgs.host.aarch32.none.this.worlds.default pkgs.host.riscv64.default.none.this.worlds.default + pkgs.host.riscv64.default.none.this.worlds.qemu-riscv-virt.microkit pkgs.host.riscv32.default.none.this.worlds.default pkgs.host.x86_64.none.this.worlds.default ];