2
0
Fork 0

Build QEMU script with ISO

This commit is contained in:
Emery Hemingway 2019-11-10 10:19:32 +01:00
parent 410a6522c5
commit 20594a9962
2 changed files with 78 additions and 63 deletions

View File

@ -38,17 +38,24 @@ in {
x86_64-genode.buildNovaIso = { name, rom }: x86_64-genode.buildNovaIso = { name, rom }:
let let
inherit (hostPkgs) cdrkit syslinux; inherit (hostPkgs) cdrkit syslinux;
coreNovaObj = "${testPkgs.genode-base-nova}/lib/core-nova.o"; coreNovaObj = "${testPkgs.genode-base-nova}/lib/core-nova.o";
addressType = ".quad"; # TODO: 32 or 64 bit?! rom' = (with testPkgs; {
init = "${genode-os}/bin/init";
"ld.lib.so" = "${depot.base-nova}/lib/ld.lib.so";
timer = "${genode-base-nova}/bin/nova_timer_drv";
}) // rom;
addressType = ".quad"; # TODO: 32bit?!
map' = with nixpkgs.lib; map' = with nixpkgs.lib;
l: f: l: f:
concatStrings (imap0 (i: v: (f (toString i) v)) l); concatStrings (imap0 (i: v: (f (toString i) v)) l);
mapNames = map' (builtins.attrNames rom); mapNames = map' (builtins.attrNames rom');
mapValues = map' (builtins.attrValues rom); mapValues = map' (builtins.attrValues rom');
modulesAsm = '' modulesAsm = ''
.set MIN_PAGE_SIZE_LOG2, 12 .set MIN_PAGE_SIZE_LOG2, 12
@ -96,27 +103,29 @@ in {
syslinuxDir = "${syslinux}/share/syslinux"; syslinuxDir = "${syslinux}/share/syslinux";
in hostPkgs.stdenv.mkDerivation { in hostPkgs.stdenv.mkDerivation {
name = name + ".iso"; name = name + "-iso";
preferLocalBuild = true; passthru = rom;
buildInputs = [ testPkgs.stdenv.cc hostPkgs.cdrkit ]; passAsFile = [ "modulesAsm" ];
dontUnpack = true;
dontConfigure = true;
dontBuild = true;
inherit modulesAsm; inherit modulesAsm;
installPhase = '' preferLocalBuild = true;
dontUnpack = true;
buildInputs = [ testPkgs.stdenv.cc hostPkgs.cdrkit ];
buildPhase = ''
mkdir -p boot/syslinux mkdir -p boot/syslinux
# compile the boot modules into one object file # compile the boot modules into one object file
$CC -c -x assembler -o boot_modules.o - <<< $modulesAsm $CC -c -x assembler -o boot_modules.o $modulesAsmPath
# link final image # link final image
$LD -nostdlib \ $LD -nostdlib \
-T${./genode.ld} \ -T${./genode.ld} \
-T${./nova-bss.ld} \ -T${./nova-bss.ld} \
-z max-page-size=0x1000 \ -z max-page-size=0x1000 \
-Ttext=0x100000 -gc-sections \ -Ttext=0x100000 -gc-sections \
${coreNovaObj} boot_modules.o \ ${coreNovaObj} boot_modules.o \
-o boot/image.elf -o boot/image.elf
strip boot/image.elf strip boot/image.elf
@ -130,11 +139,22 @@ in {
${syslinuxDir}/mboot.c32 \ ${syslinuxDir}/mboot.c32 \
boot/syslinux boot/syslinux
chmod +w boot/syslinux/isolinux.bin chmod +w boot/syslinux/isolinux.bin
mkisofs -o $out \ mkisofs -o iso \
-b syslinux/isolinux.bin -c syslinux/boot.cat \ -b syslinux/isolinux.bin -c syslinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \ -no-emul-boot -boot-load-size 4 -boot-info-table \
-iso-level 2 \ -iso-level 2 \
boot boot
# build test script
cat > boot-qemu << EOF
#!/bin/sh
${hostPkgs.qemu_test}/bin/qemu-system-x86_64 -cdrom $out/iso -machine q35 \$@
EOF
'';
installPhase = ''
install -Dm444 iso $out/iso
install -Dm555 boot-qemu $out/bin/boot-qemu
''; '';
}; };

View File

@ -23,7 +23,7 @@ let
runTests = driver: runTests = driver:
hostPkgs.stdenv.mkDerivation { hostPkgs.stdenv.mkDerivation {
name = "nova-"+driver.testName; name = "nova-" + driver.testName;
preferLocalBuild = true; preferLocalBuild = true;
buildCommand = '' buildCommand = ''
@ -43,9 +43,6 @@ let
{ {
inherit testConfig; inherit testConfig;
config = ./driver-config.xml; config = ./driver-config.xml;
init = "${genode-os}/bin/init";
"ld.lib.so" = "${depot.base-nova}/lib/ld.lib.so";
timer = "${genode-base-nova}/bin/nova_timer_drv";
} // bootModules); } // bootModules);
iso = lib.x86_64-genode.buildNovaIso { iso = lib.x86_64-genode.buildNovaIso {
@ -58,52 +55,50 @@ let
# Wait for a specific output of a already running spawned proce # Wait for a specific output of a already running spawned proce
# #
proc wait_for_output { wait_for_re timeout_value running_spawn_id } { proc wait_for_output { wait_for_re timeout_value running_spawn_id } {
global output global output
if {$wait_for_re == "forever"} { if {$wait_for_re == "forever"} {
set timeout -1 set timeout -1
interact { interact {
\003 { \003 {
send_user "Expect: 'interact' received 'strg+c' and was cancelled\n"; send_user "Expect: 'interact' received 'strg+c' and was cancelled\n";
exit exit
} }
-i $running_spawn_id -i $running_spawn_id
} }
} else { } else {
set timeout $timeout_value set timeout $timeout_value
} }
expect { expect {
-i $running_spawn_id -re $wait_for_re { } -i $running_spawn_id -re $wait_for_re { }
eof { puts stderr "Error: Spawned process died unexpectedly"; exit -1 } eof { puts stderr "Error: Spawned process died unexpectedly"; exit -1 }
timeout { puts stderr "Error: Test execution timed out"; exit -1 } timeout { puts stderr "Error: Test execution timed out"; exit -1 }
} }
set output $expect_out(buffer) set output $expect_out(buffer)
} }
proc run_genode_until {{wait_for_re forever} {timeout_value 0} {running_spawn_id -1}} { proc run_genode_until {{wait_for_re forever} {timeout_value 0} {running_spawn_id -1}} {
# #
# If a running_spawn_id is specified, wait for the expected output # If a running_spawn_id is specified, wait for the expected output
# #
if {$running_spawn_id != -1} { if {$running_spawn_id != -1} {
wait_for_output $wait_for_re $timeout_value $running_spawn_id wait_for_output $wait_for_re $timeout_value $running_spawn_id
return return
} }
global spawn_id global spawn_id
spawn ${hostPkgs.qemu_test}/bin/qemu-system-x86_64 -cdrom ${iso} -nographic \ spawn ${iso}/bin/boot-qemu -nographic -m size=${toString qemuMem}
-machine q35 -m size=${toString qemuMem} wait_for_output $wait_for_re $timeout_value $spawn_id
wait_for_output $wait_for_re $timeout_value $spawn_id
} }
# TODO: not in TCL # TODO: not in TCL
global env global env
set out $env(out) set out $env(out)
set fd [open "$out/nix-support/hydra-build-products" w] set fd [open "$out/nix-support/hydra-build-products" w]
puts $fd "file iso ${iso}" puts $fd "file iso ${iso}"
close $fd close $fd
''; '';
driver = with hostPkgs; driver = with hostPkgs;