Compare commits

...

3 Commits

9 changed files with 2 additions and 376 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "repos/base-nova/src/NOVA"]
path = repos/base-nova/src/NOVA
url = git://depot.h4ck.me/srv/git/NOVA

View File

@ -1,33 +0,0 @@
{ stdenv, nixpkgs, dhallApps, NOVA, base-nova }:
nixpkgs.writeScriptBin "nova-image" (with nixpkgs.buildPackages;
let inherit (stdenv) cc;
in ''
#!${runtimeShell}
set -eu
CC="${cc}/bin/${cc.targetPrefix}cc"
LD="${buildPackages.binutils}/bin/${buildPackages.binutils.targetPrefix}ld"
TMPDIR="$(${coreutils}/bin/mktemp -p /tmp -d nova-iso.XXXX)"
# trap "rm -rf $TMPDIR" err exit
CORE_NOVA="${base-nova}/lib/core-nova.o"
${dhallApps.dhall.program} text <<< "(${
./modules.as.dhall
}) ($@)" > "$TMPDIR/modules.as"
# compile the boot modules into one object file
$CC -c -x assembler -o "$TMPDIR/boot_modules.o" "$TMPDIR/modules.as"
# link final image
$LD -nostdlib \
-T${../../repos/base/src/ld/genode.ld} \
-T${../../repos/base-nova/src/core/core-bss.ld} \
-z max-page-size=0x1000 \
-Ttext=0x100000 -gc-sections \
"$CORE_NOVA" "$TMPDIR/boot_modules.o" \
-o "image.elf"
'')

View File

@ -1,119 +0,0 @@
let Genode =
env:DHALL_GENODE
? https://git.sr.ht/~ehmry/dhall-genode/blob/v11.0.0/package.dhall sha256:4336da47b739fe6b9e117436404ca56af0cfec15805abb0baf6f5ba366c7e5ce
let Prelude = Genode.Prelude
let Configuration =
{ arch : < x86_32 | x86_64 >
, config : Genode.Init.Type
, rom : Prelude.Map.Type Text Text
}
: Type
in λ ( boot
: Configuration
)
→ let NaturalIndex =
{ index : Natural, value : Text }
let TextIndex = { index : Text, value : Text }
let moduleKeys =
let keys = Prelude.Map.keys Text Text boot.rom
in [ "config" ] # keys
let moduleValues =
let values = Prelude.Map.values Text Text boot.rom
let incbin =
Prelude.List.map
Text
Text
(λ(path : Text) → ".incbin ${Text/show path}")
values
in [ ".ascii ${Text/show (Genode.Init.render boot.config)}" ]
# incbin
let map =
λ(list : List Text)
→ λ(f : TextIndex → Text)
→ let indexedNatural = Prelude.List.indexed Text list
let indexed =
Prelude.List.map
NaturalIndex
TextIndex
( λ(x : NaturalIndex)
→ { index = Prelude.Natural.show (x.index + 1)
, value = x.value
}
)
indexedNatural
let texts = Prelude.List.map TextIndex Text f indexed
in Prelude.Text.concatSep "\n" texts
let mapNames = map moduleKeys
let mapValues = map moduleValues
let addressType = merge { x86_32 = ".long", x86_64 = ".quad" } boot.arch
in ''
.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
( λ ( m
: TextIndex
)
→ ''
${addressType} _boot_module_${m.index}_name
${addressType} _boot_module_${m.index}_begin
${addressType} _boot_module_${m.index}_end - _boot_module_${m.index}_begin
''
)
++ ''
.global _boot_modules_headers_end
_boot_modules_headers_end:
''
++ mapNames
( λ(m : TextIndex)
→ ''
.p2align DATA_ACCESS_ALIGNM_LOG2
_boot_module_${m.index}_name:
.string "${m.value}"
.byte 0
''
)
++ ''
.section .data.boot_modules_binaries
.global _boot_modules_binaries_begin
_boot_modules_binaries_begin:
''
++ mapValues
( λ(m : TextIndex)
→ ''
.p2align MIN_PAGE_SIZE_LOG2
_boot_module_${m.index}_begin:
${m.value}
_boot_module_${m.index}_end:
''
)
++ ''
.p2align MIN_PAGE_SIZE_LOG2
.global _boot_modules_binaries_end
_boot_modules_binaries_end:
''

View File

@ -1,67 +0,0 @@
{ stdenv, nixpkgs, dhallApps, NOVA, base-nova }:
nixpkgs.writeScriptBin "nova-iso" (with nixpkgs.buildPackages;
let inherit (stdenv) cc;
in ''
#!${runtimeShell}
set -eu
CC="${cc}/bin/${cc.targetPrefix}cc"
LD="${buildPackages.binutils}/bin/${buildPackages.binutils.targetPrefix}ld"
SYSLINUX="${syslinux}/share/syslinux"
TMPDIR="$(${coreutils}/bin/mktemp -p /tmp -d nova-iso.XXXX)"
mkdir -p "$TMPDIR/boot/syslinux"
trap "rm -rf $TMPDIR" err exit
CORE_NOVA="${base-nova}/lib/core-nova.o"
${dhallApps.dhall.program} text <<< "(${
./modules.as.dhall
}) ($@)" > "$TMPDIR/modules.as"
# compile the boot modules into one object file
$CC -c -x assembler -o "$TMPDIR/boot_modules.o" "$TMPDIR/modules.as"
# link final image
$LD -nostdlib \
-T${../../repos/base/src/ld/genode.ld} \
-T${../../repos/base-nova/src/core/core-bss.ld} \
-z max-page-size=0x1000 \
-Ttext=0x100000 -gc-sections \
"$CORE_NOVA" "$TMPDIR/boot_modules.o" \
-o "$TMPDIR/boot/image.elf"
pushd "$TMPDIR"
# build ISO image
cp ${NOVA}/hypervisor* boot/hypervisor
cp ${./isolinux.cfg} boot/syslinux/isolinux.cfg
cp \
$SYSLINUX/isolinux.bin \
$SYSLINUX/ldlinux.c32 \
$SYSLINUX/libcom32.c32 \
$SYSLINUX/mboot.c32 \
boot/syslinux
chmod +w boot/syslinux/isolinux.bin
ISO_FILE="''${DIRSTACK[1]}/nova.iso"
${cdrkit}/bin/mkisofs -o "$ISO_FILE" \
-b syslinux/isolinux.bin -c syslinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-iso-level 2 \
boot
popd
# build test script
QEMU_SCRIPT=boot-qemu.sh
cat > "$QEMU_SCRIPT" << EOF
#!/bin/sh
qemu-system-x86_64 -cdrom nova.iso -machine q35 -serial mon:stdio \$@
EOF
chmod +x "$QEMU_SCRIPT"
'')

View File

@ -1,5 +0,0 @@
SERIAL
DEFAULT 0
LABEL 0
KERNEL mboot.c32
APPEND /hypervisor iommu novpid serial --- /image.elf

View File

@ -1,119 +0,0 @@
let Genode =
env:DHALL_GENODE
? https://git.sr.ht/~ehmry/dhall-genode/blob/v11.0.0/package.dhall sha256:4336da47b739fe6b9e117436404ca56af0cfec15805abb0baf6f5ba366c7e5ce
let Prelude = Genode.Prelude
let Configuration =
{ arch : < x86_32 | x86_64 >
, config : Genode.Init.Type
, rom : Prelude.Map.Type Text Text
}
: Type
in λ ( boot
: Configuration
)
→ let NaturalIndex =
{ index : Natural, value : Text }
let TextIndex = { index : Text, value : Text }
let moduleKeys =
let keys = Prelude.Map.keys Text Text boot.rom
in [ "config" ] # keys
let moduleValues =
let values = Prelude.Map.values Text Text boot.rom
let incbin =
Prelude.List.map
Text
Text
(λ(path : Text) → ".incbin ${Text/show path}")
values
in [ ".ascii ${Text/show (Genode.Init.render boot.config)}" ]
# incbin
let map =
λ(list : List Text)
→ λ(f : TextIndex → Text)
→ let indexedNatural = Prelude.List.indexed Text list
let indexed =
Prelude.List.map
NaturalIndex
TextIndex
( λ(x : NaturalIndex)
→ { index = Prelude.Natural.show (x.index + 1)
, value = x.value
}
)
indexedNatural
let texts = Prelude.List.map TextIndex Text f indexed
in Prelude.Text.concatSep "\n" texts
let mapNames = map moduleKeys
let mapValues = map moduleValues
let addressType = merge { x86_32 = ".long", x86_64 = ".quad" } boot.arch
in ''
.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
( λ ( m
: TextIndex
)
→ ''
${addressType} _boot_module_${m.index}_name
${addressType} _boot_module_${m.index}_begin
${addressType} _boot_module_${m.index}_end - _boot_module_${m.index}_begin
''
)
++ ''
.global _boot_modules_headers_end
_boot_modules_headers_end:
''
++ mapNames
( λ(m : TextIndex)
→ ''
.p2align DATA_ACCESS_ALIGNM_LOG2
_boot_module_${m.index}_name:
.string "${m.value}"
.byte 0
''
)
++ ''
.section .data.boot_modules_binaries
.global _boot_modules_binaries_begin
_boot_modules_binaries_begin:
''
++ mapValues
( λ(m : TextIndex)
→ ''
.p2align MIN_PAGE_SIZE_LOG2
_boot_module_${m.index}_begin:
${m.value}
_boot_module_${m.index}_end:
''
)
++ ''
.p2align MIN_PAGE_SIZE_LOG2
.global _boot_modules_binaries_end
_boot_modules_binaries_end:
''

View File

@ -336,35 +336,8 @@ in rec {
inherit stdenvGcc stdenvLlvm tupConfigGcc tupConfigLlvm;
nova-image = import ./apps/nova-image {
stdenv = stdenvLlvm;
inherit nixpkgs NOVA base-nova;
dhallApps = dhall-haskell.apps.${localSystem};
};
nova-iso = import ./apps/nova-iso {
stdenv = stdenvLlvm;
inherit nixpkgs NOVA base-nova;
dhallApps = dhall-haskell.apps.${localSystem};
};
};
apps = {
core-linux = {
type = "app";
program = "${packages.base-linux}/bin/core-linux";
};
nova-image = {
type = "app";
program = "${packages.nova-image}/bin/nova-image";
};
nova-iso = {
type = "app";
program = "${packages.nova-iso}/bin/nova-iso";
};
};
defaultApp = apps.core-linux;
defaultPackage = packages.base-linux;
devShell = packages.base;
checks = packages;

@ -1 +0,0 @@
Subproject commit fbb002d4d6e2b6eddae4d1f0990fe71307e8c7ca

View File

@ -36,6 +36,6 @@ PKG_LIBS = -L$(DEV_DIR)/lib `$(PKG_CONFIG) --libs alarm cxx ldso-startup timeout
$(REP_DIR)/<startup> \
symbol.map \
|> $(LD) -o %o $(LD_MARCH) $(LDFLAGS) --whole-archive --start-group $(PKG_LIBS) %<base-common> %<base-nova> %<startup> %f --end-group --no-whole-archive $(LIBGCC) \
|> ld-nova.lib.so $(REP_DIR)/<ld> {bin}
|> ld-nova.lib.so $(REP_DIR)/<ld> {lib}
: {bin} |> !collect_bin |>
: foreach {lib} |> !collect_shared |>