mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2025-01-14 08:36:31 +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
|
rm ../src/Home/MakeHome.ZC 2> /dev/null
|
||||||
mount_tempdisk
|
mount_tempdisk
|
||||||
sudo cp -r ../src/* $TMPMOUNT
|
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 mkdir -p $TMPMOUNT/EFI/BOOT
|
||||||
sudo cp limine/BOOTX64.EFI $TMPMOUNT/EFI/BOOT/BOOTX64.EFI
|
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
|
sudo cp ../zealbooter/zealbooter.elf $TMPMOUNT/Boot/ZealBooter.ELF
|
||||||
umount_tempdisk
|
umount_tempdisk
|
||||||
|
|
||||||
|
@ -69,8 +75,12 @@ if [ ! -d "ovmf" ]; then
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
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
|
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..."
|
echo "Deleting temp folder..."
|
||||||
rm -rf $TMPDIR
|
rm -rf $TMPDIR
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
TIMEOUT=2
|
TIMEOUT=2
|
||||||
|
INTERFACE_RESOLUTION=1024x768
|
||||||
|
|
||||||
:ZealOS
|
:ZealOS
|
||||||
PROTOCOL=limine
|
PROTOCOL=limine
|
||||||
|
|
|
@ -2,7 +2,11 @@
|
||||||
|
|
||||||
.global trampoline
|
.global trampoline
|
||||||
trampoline:
|
trampoline:
|
||||||
pushq $0x18
|
mov $0x6000, %esp
|
||||||
|
|
||||||
|
lgdt (%rcx)
|
||||||
|
|
||||||
|
pushq $0x30
|
||||||
addq $(1f - trampoline), %rax
|
addq $(1f - trampoline), %rax
|
||||||
pushq %rax
|
pushq %rax
|
||||||
lretq
|
lretq
|
||||||
|
@ -10,15 +14,13 @@ trampoline:
|
||||||
.code32
|
.code32
|
||||||
1:
|
1:
|
||||||
|
|
||||||
mov $0x20, %eax
|
mov $0x10, %eax
|
||||||
mov %eax, %ds
|
mov %eax, %ds
|
||||||
mov %eax, %es
|
mov %eax, %es
|
||||||
mov %eax, %fs
|
mov %eax, %fs
|
||||||
mov %eax, %gs
|
mov %eax, %gs
|
||||||
mov %eax, %ss
|
mov %eax, %ss
|
||||||
|
|
||||||
lgdt (%ecx)
|
|
||||||
|
|
||||||
mov %cr0, %eax
|
mov %cr0, %eax
|
||||||
btr $31, %eax
|
btr $31, %eax
|
||||||
mov %eax, %cr0
|
mov %eax, %cr0
|
||||||
|
@ -31,7 +33,6 @@ trampoline:
|
||||||
mov %ebx, %eax
|
mov %ebx, %eax
|
||||||
mov $2, %ebx
|
mov $2, %ebx
|
||||||
|
|
||||||
mov $0x7c00, %esp
|
|
||||||
jmp *%eax
|
jmp *%eax
|
||||||
|
|
||||||
.global trampoline_end
|
.global trampoline_end
|
||||||
|
|
|
@ -203,14 +203,6 @@ void _start(void) {
|
||||||
CKernel->boot_base = (uintptr_t)&CKernel->jmp - (uintptr_t)kernel->address;
|
CKernel->boot_base = (uintptr_t)&CKernel->jmp - (uintptr_t)kernel->address;
|
||||||
CKernel->boot_base += final_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.limit = sizeof(CKernel->sys_gdt) - 1;
|
||||||
CKernel->sys_gdt_ptr.base = (void *)&CKernel->sys_gdt - (uintptr_t)kernel->address;
|
CKernel->sys_gdt_ptr.base = (void *)&CKernel->sys_gdt - (uintptr_t)kernel->address;
|
||||||
CKernel->sys_gdt_ptr.base += final_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);
|
void *trampoline_phys = (void *)final_address - ((uintptr_t)trampoline_end - (uintptr_t)trampoline);
|
||||||
|
|
||||||
memcpy(trampoline_phys, trampoline, ((uintptr_t)trampoline_end - (uintptr_t)trampoline));
|
memmove(trampoline_phys, trampoline, ((uintptr_t)trampoline_end - (uintptr_t)trampoline));
|
||||||
memcpy((void *)final_address, CKernel, kernel->size);
|
memmove((void *)final_address, CKernel, kernel->size);
|
||||||
|
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"jmp *%0"
|
"jmp *%0"
|
||||||
|
|
Loading…
Reference in a new issue