diff --git a/build/build-temp-vm-uefi-1.sh b/build/build-temp-vm-uefi-1.sh index 8515eae7..2f584970 100755 --- a/build/build-temp-vm-uefi-1.sh +++ b/build/build-temp-vm-uefi-1.sh @@ -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 diff --git a/src/limine.cfg b/src/limine.cfg index 99be36b6..56701749 100644 --- a/src/limine.cfg +++ b/src/limine.cfg @@ -1,4 +1,5 @@ TIMEOUT=2 +INTERFACE_RESOLUTION=1024x768 :ZealOS PROTOCOL=limine diff --git a/zealbooter/trampoline.S b/zealbooter/trampoline.S index a02d4868..e9003450 100644 --- a/zealbooter/trampoline.S +++ b/zealbooter/trampoline.S @@ -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 diff --git a/zealbooter/zealbooter.c b/zealbooter/zealbooter.c index 0c1b4fce..51a5374d 100644 --- a/zealbooter/zealbooter.c +++ b/zealbooter/zealbooter.c @@ -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"