Nix apps moved to genodepkgs
This commit is contained in:
parent
a1e84f0485
commit
f04d10649f
|
@ -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"
|
||||
'')
|
|
@ -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:
|
||||
''
|
|
@ -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"
|
||||
'')
|
|
@ -1,5 +0,0 @@
|
|||
SERIAL
|
||||
DEFAULT 0
|
||||
LABEL 0
|
||||
KERNEL mboot.c32
|
||||
APPEND /hypervisor iommu novpid serial --- /image.elf
|
|
@ -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:
|
||||
''
|
27
default.nix
27
default.nix
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue