You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
2.6 KiB
Nix
105 lines
2.6 KiB
Nix
# SPDX-FileCopyrightText: Emery Hemingway
|
|
#
|
|
# SPDX-License-Identifier: LicenseRef-Hippocratic-1.1
|
|
|
|
{ hostPkgs, testPkgs, coreNovaObj }:
|
|
modules:
|
|
|
|
let
|
|
inherit (hostPkgs) lib cdrkit syslinux;
|
|
|
|
addressType = ".quad"; # TODO: 32 or 64 bit?!
|
|
|
|
map' = l: f: lib.concatStrings (lib.imap0 (i: v: (f (toString i) v)) l);
|
|
|
|
mapNames = map' (builtins.attrNames modules);
|
|
mapValues = map' (builtins.attrValues modules);
|
|
|
|
modulesAsm = ''
|
|
.set MIN_PAGE_SIZE_LOG2, 12
|
|
.set DATA_ACCESS_ALIGNM_LOG2, 3
|
|
|
|
.section .data
|
|
|
|
.p2align DATA_ACCESS_ALIGNM_LOG2
|
|
.global _boot_modules_headers_begin
|
|
_boot_modules_headers_begin:
|
|
|
|
'' + (mapNames (i: _: ''
|
|
${addressType} _boot_module_${i}_name
|
|
${addressType} _boot_module_${i}_begin
|
|
${addressType} _boot_module_${i}_end - _boot_module_${i}_begin
|
|
|
|
'')) + ''
|
|
.global _boot_modules_headers_end
|
|
_boot_modules_headers_end:
|
|
|
|
'' + (mapNames (i: name: ''
|
|
.p2align DATA_ACCESS_ALIGNM_LOG2
|
|
_boot_module_${i}_name:
|
|
.string "${name}"
|
|
.byte 0
|
|
|
|
'')) + ''
|
|
.section .data.boot_modules_binaries
|
|
|
|
.global _boot_modules_binaries_begin
|
|
_boot_modules_binaries_begin:
|
|
|
|
'' + (mapValues (i: path: ''
|
|
.p2align MIN_PAGE_SIZE_LOG2
|
|
_boot_module_${i}_begin:
|
|
.incbin "${path}"
|
|
_boot_module_${i}_end:
|
|
|
|
'')) + ''
|
|
.p2align MIN_PAGE_SIZE_LOG2
|
|
.global _boot_modules_binaries_end
|
|
_boot_modules_binaries_end:
|
|
'';
|
|
|
|
syslinuxDir = "${syslinux}/share/syslinux";
|
|
|
|
in hostPkgs.stdenv.mkDerivation {
|
|
name = "nova-genode.iso";
|
|
preferLocalBuild = true;
|
|
buildInputs = [ testPkgs.stdenv.cc hostPkgs.cdrkit ];
|
|
dontUnpack = true;
|
|
dontConfigure = true;
|
|
dontBuild = true;
|
|
inherit modulesAsm;
|
|
installPhase = ''
|
|
mkdir -p boot/syslinux
|
|
|
|
# compile the boot modules into one object file
|
|
$CC -c -x assembler -o boot_modules.o - <<< $modulesAsm
|
|
|
|
# link final image
|
|
$LD -nostdlib \
|
|
-T${./genode.ld} \
|
|
-T${./nova-bss.ld} \
|
|
-z max-page-size=0x1000 \
|
|
-Ttext=0x100000 -gc-sections \
|
|
${coreNovaObj} boot_modules.o \
|
|
-o boot/image.elf
|
|
|
|
strip boot/image.elf
|
|
|
|
# build ISO image
|
|
cp ${testPkgs.nova}/hypervisor* boot/hypervisor
|
|
cp ${./nova-isolinux.cfg} boot/syslinux/isolinux.cfg
|
|
cp \
|
|
${syslinuxDir}/isolinux.bin \
|
|
${syslinuxDir}/ldlinux.c32 \
|
|
${syslinuxDir}/libcom32.c32 \
|
|
${syslinuxDir}/mboot.c32 \
|
|
boot/syslinux
|
|
chmod +w boot/syslinux/isolinux.bin
|
|
mkisofs -o $out \
|
|
-b syslinux/isolinux.bin -c syslinux/boot.cat \
|
|
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
|
-iso-level 2 \
|
|
boot
|
|
'';
|
|
}
|