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

feat(qemu): add support to build qemu w/ different interrupt controllers #14

Merged
merged 12 commits into from
Jun 4, 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
15 changes: 7 additions & 8 deletions pkgs/bao/bao.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
stdenv.mkDerivation rec {
# Derivation to build bao to run the bao test framework (as a guest)
# MUT: bao-hypervisor
pname = "bao-local";
pname = "bao";
version = "1.0.0";

srcs = if bao_srcs_path == " " || bao_srcs_path == null then
fetchFromGitHub {
owner = "bao-project";
repo = "bao-hypervisor";
rev = "0575782359132465128491ab2fa44c16e76b57f8"; # branch: demo
sha256 = "sha256-pCsVpSOuCCQ86HbLbyGpi6nHi5dxa7hbQIuoemE/fSA=";
rev = "692fab8ccfcdb9cffb52f8793e798a0220e7d550";
sha256 = "sha256-LOrTZvAAA8ABnw/R+kqKBq8X6mXLTVsz/XfAJTQP2NA=";
}
else
bao_srcs_path;
Expand Down Expand Up @@ -54,13 +54,12 @@ stdenv.mkDerivation rec {
cd $out/srcs
export ARCH=${setup-cfg.arch}
export CROSS_COMPILE=${setup-cfg.toolchain_name}-


# Build Bao
make PLATFORM=${setup-cfg.platform_name} \
CONFIG_REPO=$out/configs\
CONFIG=$bao_build_cfg\
CPPFLAGS=-DBAO_WRKDIR_IMGS=$out/guests
CONFIG_REPO=$out/configs \
CONFIG=$bao_build_cfg \
CPPFLAGS=-DBAO_WRKDIR_IMGS=$out/guests \
${setup-cfg.irq_flags}
'';

installPhase = ''
Expand Down
4 changes: 3 additions & 1 deletion pkgs/firmware/atf/atf.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
, u-boot
, openssl
, platform
, setup-cfg
}:

stdenv.mkDerivation rec {
Expand All @@ -24,8 +25,9 @@ stdenv.mkDerivation rec {

buildPhase = ''
export CROSS_COMPILE=aarch64-none-elf-
gic_version=$(echo "${setup-cfg.irq_flags}" | grep -oP '(?<=GIC_VERSION=)[^ ]+')
make PLAT=qemu bl1 fip BL33=${u-boot}/bin/u-boot.bin\
QEMU_USE_GIC_DRIVER=QEMU_GICV3
QEMU_USE_GIC_DRIVER=QEMU_$gic_version
'';

installPhase = ''
Expand Down
2 changes: 2 additions & 0 deletions pkgs/firmware/qemu-aarch64-virt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
, fetchFromGitHub
, toolchain
, platform
, setup-cfg
miguelafsilva5 marked this conversation as resolved.
Show resolved Hide resolved
}:
let
u-boot = pkgs.callPackage ./u-boot/u-boot.nix
Expand All @@ -16,6 +17,7 @@ let
inherit toolchain;
inherit u-boot;
inherit platform;
inherit setup-cfg;
};
in
stdenv.mkDerivation rec {
Expand Down
1 change: 1 addition & 0 deletions pkgs/firmware/qemu-riscv64-virt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
, fetchFromGitHub
, toolchain
, platform
, setup-cfg
}:
let
sbi = pkgs.callPackage ./openSBI/openSBI.nix {
Expand Down
7 changes: 6 additions & 1 deletion pkgs/guest/baremetal.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ stdenv.mkDerivation rec {
buildPhase = ''
export ARCH=${setup-cfg.arch}
export CROSS_COMPILE=${setup-cfg.toolchain_name}-
make -C $out PLATFORM=${setup-cfg.platform_name}
if [ ARCH == "aarch64" ]; then
make -C $out PLATFORM=${setup-cfg.platform_name} \
${setup-cfg.irq_flags}
else
make -C $out PLATFORM=${setup-cfg.platform_name}
fi
'';

installPhase = ''
Expand Down
11 changes: 10 additions & 1 deletion pkgs/guest/tf/baremetal.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,16 @@ stdenv.mkDerivation rec {
export CROSS_COMPILE=${setup-cfg.toolchain_name}-
export TESTF_TESTS_DIR=$out/tests/src
export TESTF_REPO_DIR=$out/tests/bao-tests
make -C $out PLATFORM=${setup-cfg.platform_name} BAO_TEST=1 SUITES=${list_suites} TESTS=${list_tests} TESTF_LOG_LEVEL=${log_level}
if [ ARCH == "aarch64" ]; then
make -C $out PLATFORM=${setup-cfg.platform_name} \
BAO_TEST=1 SUITES=${list_suites} TESTS=${list_tests} \
TESTF_LOG_LEVEL=${log_level} \
${setup-cfg.irq_flags}
else
make -C $out PLATFORM=${setup-cfg.platform_name} \
BAO_TEST=1 SUITES=${list_suites} TESTS=${list_tests} \
TESTF_LOG_LEVEL=${log_level}
fi
'';

installPhase = ''
Expand Down
7 changes: 7 additions & 0 deletions pkgs/setup-cfg/setup-cfg.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
, bao-tests ? " "
, tests_srcs ? " "
, baremetal_patch ? " "
, GIC_VERSION ? " "
, IRQC ? " "
, IPIC ? " "
}:
let
platforms-arch = {
Expand Down Expand Up @@ -43,4 +46,8 @@ in {
bao-tests = bao-tests;
tests_srcs = tests_srcs;
baremetal_patch = baremetal_patch;

irq_flags = if platforms-arch.${platform} == "riscv64" then
"IRQC=${IRQC} IPIC=${IPIC}"
else "GIC_VERSION=${GIC_VERSION}";
}
Loading