Skip to content

Commit

Permalink
Add support for Microkit on riscv64
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Sep 18, 2024
1 parent fd01ea6 commit 1cd063a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
7 changes: 7 additions & 0 deletions hacking/nix/scope/microkit/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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} \
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 = "9633b9cf9a29b227512762f3102c7868bae4b840"; # branch "rust-nix"
rev = "2492fa64b2e4930e5f3beb77be8914e5f35a2746"; # branch "rust-nix"
local = localRoot + "/microkit";
};

Expand Down
6 changes: 3 additions & 3 deletions hacking/nix/scope/world/instances/microkit/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: BSD-2-Clause
#

{ lib, stdenv
{ lib, stdenv, hostPlatform
, buildPackages, pkgsBuildBuild
, linkFarm, symlinkJoin, writeText, runCommand, runCommandCC
, callPackage
Expand Down Expand Up @@ -62,7 +62,7 @@ in {
}
);

banscii = maybe isMicrokit (callPackage ./banscii {
banscii = maybe (isMicrokit && seL4Config.PLAT == "qemu-arm-virt") (callPackage ./banscii {
inherit canSimulate;
inherit mkPD;
});
Expand Down Expand Up @@ -106,7 +106,7 @@ in {
}
);

reset = maybe isMicrokit (
reset = maybe (isMicrokit && hostPlatform.isAarch64) (
let
pd = rec {
orig = mkPD rec {
Expand Down
26 changes: 22 additions & 4 deletions hacking/nix/scope/worlds.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions hacking/nix/top-level/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
Expand Down

0 comments on commit 1cd063a

Please sign in to comment.