Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix: Add support for multiple Microkit configs #149

Merged
merged 2 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
20 changes: 10 additions & 10 deletions hacking/nix/scope/world/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
};
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
Loading