mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 23:10:32 +00:00
ZealBooter: Further cleanup and fix BIOS boot
This commit is contained in:
parent
ee265c8767
commit
1510f65468
4 changed files with 21 additions and 17 deletions
|
@ -51,9 +51,15 @@ rm ../src/Home/Registry.ZC 2> /dev/null
|
|||
rm ../src/Home/MakeHome.ZC 2> /dev/null
|
||||
mount_tempdisk
|
||||
sudo cp -r ../src/* $TMPMOUNT
|
||||
[ ! -d "limine" ] && git clone https://github.com/limine-bootloader/limine.git --branch=v3.0-branch-binary --depth=1
|
||||
|
||||
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
|
||||
|
||||
|
@ -69,8 +75,12 @@ if [ ! -d "ovmf" ]; then
|
|||
cd ..
|
||||
fi
|
||||
|
||||
echo "Testing..."
|
||||
./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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
TIMEOUT=2
|
||||
INTERFACE_RESOLUTION=1024x768
|
||||
|
||||
:ZealOS
|
||||
PROTOCOL=limine
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
|
||||
.global trampoline
|
||||
trampoline:
|
||||
pushq $0x18
|
||||
mov $0x6000, %esp
|
||||
|
||||
lgdt (%rcx)
|
||||
|
||||
pushq $0x30
|
||||
addq $(1f - trampoline), %rax
|
||||
pushq %rax
|
||||
lretq
|
||||
|
@ -10,15 +14,13 @@ trampoline:
|
|||
.code32
|
||||
1:
|
||||
|
||||
mov $0x20, %eax
|
||||
mov $0x10, %eax
|
||||
mov %eax, %ds
|
||||
mov %eax, %es
|
||||
mov %eax, %fs
|
||||
mov %eax, %gs
|
||||
mov %eax, %ss
|
||||
|
||||
lgdt (%ecx)
|
||||
|
||||
mov %cr0, %eax
|
||||
btr $31, %eax
|
||||
mov %eax, %cr0
|
||||
|
@ -31,7 +33,6 @@ trampoline:
|
|||
mov %ebx, %eax
|
||||
mov $2, %ebx
|
||||
|
||||
mov $0x7c00, %esp
|
||||
jmp *%eax
|
||||
|
||||
.global trampoline_end
|
||||
|
|
|
@ -203,14 +203,6 @@ void _start(void) {
|
|||
CKernel->boot_base = (uintptr_t)&CKernel->jmp - (uintptr_t)kernel->address;
|
||||
CKernel->boot_base += final_address;
|
||||
|
||||
CKernel->sys_gdt.boot_ds.lo = 0x00CF92000000FFFF;
|
||||
CKernel->sys_gdt.boot_cs.lo = 0x00CF9A000000FFFF;
|
||||
CKernel->sys_gdt.cs32.lo = 0x00CF9A000000FFFF;
|
||||
CKernel->sys_gdt.cs64.lo = 0x00209A0000000000;
|
||||
CKernel->sys_gdt.cs64_ring3.lo = 0x0020FA0000000000;
|
||||
CKernel->sys_gdt.ds.lo = 0x00CF92000000FFFF;
|
||||
CKernel->sys_gdt.ds_ring3.lo = 0x00CFF2000000FFFF;
|
||||
|
||||
CKernel->sys_gdt_ptr.limit = sizeof(CKernel->sys_gdt) - 1;
|
||||
CKernel->sys_gdt_ptr.base = (void *)&CKernel->sys_gdt - (uintptr_t)kernel->address;
|
||||
CKernel->sys_gdt_ptr.base += final_address;
|
||||
|
@ -251,8 +243,8 @@ void _start(void) {
|
|||
|
||||
void *trampoline_phys = (void *)final_address - ((uintptr_t)trampoline_end - (uintptr_t)trampoline);
|
||||
|
||||
memcpy(trampoline_phys, trampoline, ((uintptr_t)trampoline_end - (uintptr_t)trampoline));
|
||||
memcpy((void *)final_address, CKernel, kernel->size);
|
||||
memmove(trampoline_phys, trampoline, ((uintptr_t)trampoline_end - (uintptr_t)trampoline));
|
||||
memmove((void *)final_address, CKernel, kernel->size);
|
||||
|
||||
asm volatile (
|
||||
"jmp *%0"
|
||||
|
|
Loading…
Reference in a new issue