blob: 9cd32c217503b6203bf9b4cf0feebd15b144077f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#!/bin/bash
# EFI-загрузчик + amd64-ядро -> bootx64.efi. Нужны: BINDIR (6c/6a/6l), PLAN9SRC (include),
# и pe64.s/efi.h/mem.h из ../efi (запусти ../efi/fetch_ref.sh).
set -e; cd "$(dirname "$0")"
BIN="${BINDIR:?}"; INC="${PLAN9SRC:?}"; export objtype=amd64
for f in pe64.s efi.h mem.h; do [ -f ../efi/$f ] || { echo "нет ../efi/$f — запусти ../efi/fetch_ref.sh"; exit 1; }; cp ../efi/$f .; done
head -162 pe64.s > pe64min.s
"$BIN/6a" kern64.s; "$BIN/6c" -I"$INC/amd64/include" -I"$INC/sys/include" kernel.c
"$BIN/6l" -l -s -T0x100000 -E _start -o kernel.out kern64.6 kernel.6
python3 -c "d=open('kernel.out','rb').read(); open('kernel_blob.h','w').write('static unsigned char kernel_blob[]={'+','.join(hex(b) for b in d)+'};\nstatic unsigned kernel_len=%d;\n'%len(d))"
"$BIN/6a" -DIMAGEBASE=0x8000 pe64min.s
"$BIN/6c" -I"$INC/amd64/include" -I"$INC/sys/include" efi_load.c
"$BIN/6l" -l -s -R1 -T0x8000 -o boot.out pe64min.6 efi_load.6
dd if=boot.out bs=1 skip=40 of=bootx64.efi 2>/dev/null
echo "bootx64.efi: $(ls -la bootx64.efi|awk '{print $5}') байт"
|