mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2025-01-13 16:16:31 +00:00
Implement uefi build script with distinct only-kernel-header recompile step.
This commit is contained in:
parent
2d332d1878
commit
3b1e0af20b
4 changed files with 140 additions and 1 deletions
BIN
build/AUTO-VM-2.ISO
Executable file
BIN
build/AUTO-VM-2.ISO
Executable file
Binary file not shown.
99
build/build-temp-vm-uefi-2.sh
Executable file
99
build/build-temp-vm-uefi-2.sh
Executable file
|
@ -0,0 +1,99 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Build OS using AUTO.ISO minimal auto-install as bootstrap to merge codebase, recompile system, and start temporary VM
|
||||
|
||||
# make sure we are in the correct directory
|
||||
SCRIPT_DIR=$(realpath "$(dirname "$0")")
|
||||
SCRIPT_NAME=$(basename "$0")
|
||||
EXPECTED_DIR=$(realpath "$PWD")
|
||||
|
||||
if test "${EXPECTED_DIR}" != "${SCRIPT_DIR}"
|
||||
then
|
||||
( cd "$SCRIPT_DIR" || exit ; "./$SCRIPT_NAME" "$@" );
|
||||
exit
|
||||
fi
|
||||
|
||||
# Uncomment if you use doas instead of sudo
|
||||
#alias sudo=doas
|
||||
|
||||
TMPDIR="/tmp/zealtmp"
|
||||
TMPDISK="$TMPDIR/ZealOS.raw"
|
||||
TMPMOUNT="$TMPDIR/mnt"
|
||||
|
||||
mount_tempdisk() {
|
||||
sudo modprobe nbd
|
||||
sudo qemu-nbd -c /dev/nbd0 -f raw $TMPDISK
|
||||
sudo partprobe /dev/nbd0
|
||||
sudo mount /dev/nbd0p1 $TMPMOUNT
|
||||
}
|
||||
|
||||
umount_tempdisk() {
|
||||
sync
|
||||
sudo umount $TMPMOUNT
|
||||
sudo qemu-nbd -d /dev/nbd0
|
||||
}
|
||||
|
||||
[ ! -d $TMPMOUNT ] && mkdir -p $TMPMOUNT
|
||||
|
||||
set -e
|
||||
|
||||
echo "Building ZealBooter..."
|
||||
( cd ../zealbooter && make clean all )
|
||||
|
||||
set +e
|
||||
|
||||
echo "Making temp vdisk, running auto-install..."
|
||||
qemu-img create -f raw $TMPDISK 192M
|
||||
qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -cdrom AUTO-VM-2.ISO -device isa-debug-exit
|
||||
|
||||
echo "Mounting vdisk, copying src/Kernel/KStart16.ZC and src/Kernel/KernelA.HH ..."
|
||||
rm ../src/Home/Registry.ZC 2> /dev/null
|
||||
rm ../src/Home/MakeHome.ZC 2> /dev/null
|
||||
mount_tempdisk
|
||||
sudo cp -rf ../src/Kernel/KStart16.ZC $TMPMOUNT/Kernel/
|
||||
sudo cp -rf ../src/Kernel/KernelA.HH $TMPMOUNT/Kernel/
|
||||
umount_tempdisk
|
||||
|
||||
echo "Rebuilding kernel headers..."
|
||||
qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -device isa-debug-exit
|
||||
|
||||
echo "Mounting vdisk and copying src/..."
|
||||
rm ../src/Home/Registry.ZC 2> /dev/null
|
||||
rm ../src/Home/MakeHome.ZC 2> /dev/null
|
||||
mount_tempdisk
|
||||
sudo cp -r ../src/* $TMPMOUNT
|
||||
|
||||
if [ ! -d "limine" ]; then
|
||||
git clone https://github.com/limine-bootloader/limine.git --branch=v3.0-branch-binary --depth=1
|
||||
make -C limine
|
||||
fi
|
||||
|
||||
sudo mkdir -p $TMPMOUNT/EFI/BOOT
|
||||
sudo cp limine/BOOTX64.EFI $TMPMOUNT/EFI/BOOT/BOOTX64.EFI
|
||||
sudo cp limine/limine.sys $TMPMOUNT/
|
||||
sudo cp ../zealbooter/zealbooter.elf $TMPMOUNT/Boot/ZealBooter.ELF
|
||||
umount_tempdisk
|
||||
|
||||
echo "Rebuilding kernel..."
|
||||
qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -device isa-debug-exit
|
||||
|
||||
if [ ! -d "ovmf" ]; then
|
||||
echo "Downloading OVMF..."
|
||||
mkdir ovmf
|
||||
cd ovmf
|
||||
curl -o OVMF-X64.zip https://efi.akeo.ie/OVMF/OVMF-X64.zip
|
||||
7z x OVMF-X64.zip
|
||||
cd ..
|
||||
fi
|
||||
|
||||
./limine/limine-deploy $TMPDISK
|
||||
|
||||
echo "Testing UEFI..."
|
||||
qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -bios ovmf/OVMF.fd -smp 4
|
||||
echo "Testing BIOS..."
|
||||
qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -smp 4
|
||||
|
||||
echo "Deleting temp folder..."
|
||||
rm -rf $TMPDIR
|
||||
echo "Finished."
|
||||
|
|
@ -24,7 +24,9 @@ U0 Auto()
|
|||
Free(in_str);
|
||||
// in_str = MStrPrint("BootHDIns;OnceFlush;Once(\"#include \\\"/Misc/Auto/AutoFullDistro1\\\";;Auto;\");Reboot;");
|
||||
// in_str = MStrPrint("BootHDIns;OnceFlush;Reboot;");
|
||||
in_str = MStrPrint("BootHDIns;OnceFlush;OutU8(0x501,0x31);");
|
||||
// in_str = MStrPrint("BootHDIns;OnceFlush;OutU8(0x501,0x31);");
|
||||
// in_str = MStrPrint("BootHDIns;OnceFlush;Once(\"Sleep(700);In(\\\"CC\\\\n%d\\\\n\\\\n1024\\\\n768\\\\n\\\\n\\\\n\\\");OutU8(0x501,0x31);\");OutU8(0x501,0x31);");
|
||||
in_str = MStrPrint("BootHDIns;OnceFlush;Once(\"#include \\\"/Misc/Auto/AutoFullDistro00\\\";;Auto;\");OutU8(0x501,0x31);");
|
||||
OnceDrive('C', in_str);
|
||||
OutU8(0x501,0x31);
|
||||
}
|
||||
|
|
38
src/Misc/Auto/AutoFullDistro00.ZC
Executable file
38
src/Misc/Auto/AutoFullDistro00.ZC
Executable file
|
@ -0,0 +1,38 @@
|
|||
U0 Auto()
|
||||
{
|
||||
I64 i, ata_port = -1;
|
||||
CAHCIPort *port;
|
||||
U8 *in_str;
|
||||
|
||||
for (i = 0; i < AHCI_MAX_PORTS; i++)
|
||||
|
||||
{
|
||||
if (Bt(&blkdev.ahci_hba->ports_implemented, i))
|
||||
{
|
||||
port = &blkdev.ahci_hba->ports[i];
|
||||
if (port->signature == AHCI_PxSIG_ATA)
|
||||
{
|
||||
ata_port = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BootMHDIns('C');
|
||||
// in_str = MStrPrint("Sleep(700);In(\"CC\\n%d\\n\\n1024\\n768\\n\\n\\n\");", ata_port);
|
||||
in_str = MStrPrint("CC\n%d\n\n1024\n768\n\n\n", ata_port);
|
||||
Sleep(700);
|
||||
In(in_str);
|
||||
// OnceDrive('C', in_str);
|
||||
// Free(in_str);
|
||||
// in_str = MStrPrint("BootHDIns;OnceFlush;Once(\"#include \\\"/Misc/Auto/AutoFullDistro1\\\";;Auto;\");Reboot;");
|
||||
// in_str = MStrPrint("BootHDIns;OnceFlush;Reboot;");
|
||||
// in_str = MStrPrint("BootHDIns;OnceFlush;OutU8(0x501,0x31);");
|
||||
// in_str = MStrPrint("BootHDIns;OnceFlush;Once(\"Sleep(700);In(\\\"CC\\\\n%d\\\\n\\\\n1024\\\\n768\\\\n\\\\n\\\\n\\\");OutU8(0x501,0x31);\");OutU8(0x501,0x31);");
|
||||
// in_str = MStrPrint("BootHDIns;OnceFlush;Once(\"#include \\\"/Misc/Auto/AutoFullDistro00\\\";;Auto;\");OutU8(0x501,0x31);");
|
||||
// OnceDrive('C', in_str);
|
||||
BootHDIns;
|
||||
OnceFlush;
|
||||
OutU8(0x501,0x31);
|
||||
}
|
||||
Auto;
|
Loading…
Reference in a new issue