Skip to content

Commit

Permalink
nix: Support multiple microkit configs
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Jun 8, 2024
1 parent 5ca5213 commit 2690e37
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
27 changes: 16 additions & 11 deletions hacking/nix/scope/microkit/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
, rustToolchain ? defaultRustToolchain
}:

# no configuration yet
{}:
{ board, config }:

let
microkitSource = sources.microkit;
Expand Down Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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
Expand All @@ -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"; }
];
};
} ''
Expand All @@ -142,16 +147,16 @@ let
-r $out/report.txt
'');

exampleSource = microkitSource + "/example/qemu_virt_aarch64/hello";
exampleSource = microkitSource + "/example/${board}/hello";

examplePDs = stdenv.mkDerivation {
name = "example";

src = exampleSource;

MICROKIT_SDK = sdk;
MICROKIT_BOARD = "qemu_virt_aarch64";
MICROKIT_CONFIG = "debug";
MICROKIT_BOARD = board;
MICROKIT_CONFIG = config;

MICROKIT_TOOL = "${tool}/bin/microkit";

Expand All @@ -169,7 +174,7 @@ let
'';
};

example = mkSystem {
example = assert board == "qemu_virt_aarch64"; mkSystem {
searchPath = examplePDs;
systemXML = exampleSource + "/hello.system";
};
Expand Down
2 changes: 1 addition & 1 deletion hacking/nix/scope/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};

Expand Down
13 changes: 11 additions & 2 deletions hacking/nix/scope/worlds.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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" ];
Expand Down

0 comments on commit 2690e37

Please sign in to comment.