diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-29 09:55:05 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-29 09:55:44 +0100 |
| commit | 2529c8722d6d3491a3e19aa728f4bfce099bcc91 (patch) | |
| tree | 116a1cfb461884b33c6805bde6fcfe868ae5e491 /Private/NewBoot/Source | |
| parent | 202db65935d71650600de9de59e4950ad047a122 (diff) | |
Kernel: Improve BootKit and EFIKit.
TODO: Add File Protocol support and Pool support for EFIKit.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/NewBoot/Source')
| -rw-r--r-- | Private/NewBoot/Source/CDROM/MAHROUSS/.gitkeep | 0 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BIOSAllocApi.inc | 40 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BIOSApiGdt.inc | 36 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BIOSRuntime.cxx | 10 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BIOSRuntime0.asm | 50 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/Boot.cxx (renamed from Private/NewBoot/Source/HEL/AMD64/BootAMD64.cxx) | 5 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx | 12 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/PartitionMap.hxx | 10 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/Processor.cxx | 36 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/Protocol.hxx | 30 | ||||
| -rw-r--r-- | Private/NewBoot/Source/makefile | 2 |
11 files changed, 40 insertions, 191 deletions
diff --git a/Private/NewBoot/Source/CDROM/MAHROUSS/.gitkeep b/Private/NewBoot/Source/CDROM/MAHROUSS/.gitkeep deleted file mode 100644 index e69de29b..00000000 --- a/Private/NewBoot/Source/CDROM/MAHROUSS/.gitkeep +++ /dev/null diff --git a/Private/NewBoot/Source/HEL/AMD64/BIOSAllocApi.inc b/Private/NewBoot/Source/HEL/AMD64/BIOSAllocApi.inc deleted file mode 100644 index a43881fa..00000000 --- a/Private/NewBoot/Source/HEL/AMD64/BIOSAllocApi.inc +++ /dev/null @@ -1,40 +0,0 @@ -;; COPYRIGHT Mahrouss Logic, all rights reserved - -bits 32 - -[global __BIOSLoadRegister] -[global __BIOSAlloc] - -__BIOSLoadRegister: - cmp [ebp - 4], 0 - jmp __BIOSLoadGDT - ret -__BIOSLoadGDT: - lgdt [ebp - 8] - ret - -;; This memory resides in the BIOS Memory Region BMR (0x9000-(0x9000 + 0x1000)) -;; It contains bootloader data. - -__BIOSAlloc: - push ebp - mov ebp, esp - mov eax, __bios_lookup_table -__BIOSAllocLoop: - cmp eax, __end_bios_lookup_table - jne __BIOSAllocDone - add eax, 4 - jmp $ -__BIOSAllocDone: - cmp eax, 0 - je __BIOSAllocLoop - add esp, 12 - mov esp, ebp - pop ebp - ret - -;; Allocation table. - -__bios_lookup_table: - resb 8096 * 4 -__end_bios_lookup_table: diff --git a/Private/NewBoot/Source/HEL/AMD64/BIOSApiGdt.inc b/Private/NewBoot/Source/HEL/AMD64/BIOSApiGdt.inc deleted file mode 100644 index be7a97e3..00000000 --- a/Private/NewBoot/Source/HEL/AMD64/BIOSApiGdt.inc +++ /dev/null @@ -1,36 +0,0 @@ -[BITS 32] - -NewBootGdtRegister: - dw NewBootGdtEnd - NewBootGdt - 1 - dq NewBootGdt - -[BITS 32] - -NewBootGdt: - ;; Entry 0x0: Null descriptor - dd 0x0 - dd 0x0 - ;; Entry 0x8: Code segment -NewBootGdtCode: - dw 0xffff ; Limit - dw 0x0000 ; Base 15:00 - db 0x00 ; Base 23:16 - dw 0xcf9a ; Flags / Limit / Type [F,L,F,Type] - db 0x00 ; Base 32:24 - ;; Entry 0x10: Data segment -NewBootGdtData: - dw 0xffff ; Limit - dw 0x0000 ; Base 15:00 - db 0x00 ; Base 23:16 - dw 0xcf92 ; Flags / Limit / Type [F,L,F,Type] - db 0x00 ;Base 32:24 - ;; Entry 0x18: GS Data segment - dw 0x0100 ; Limit - dw 0x1000 ; Base 15:00 - db 0x00 ; Base 23:16 - dw 0x4092 ; Flags / Limit / Type [F,L,F,Type] - db 0x00 ; Base 32:24 -NewBootGdtEnd: - -NB_CODE: db 0x8 -NB_DATA: db 0x10
\ No newline at end of file diff --git a/Private/NewBoot/Source/HEL/AMD64/BIOSRuntime.cxx b/Private/NewBoot/Source/HEL/AMD64/BIOSRuntime.cxx deleted file mode 100644 index 1cc249ee..00000000 --- a/Private/NewBoot/Source/HEL/AMD64/BIOSRuntime.cxx +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright 2024 Mahrouss Logic, all rights reserved - */ - -#include <BootKit/Boot.hpp> - -// unused now, used to be in dev; -#ifdef __BIOS__ -extern "C" char __runtime_stack[4096] = {0}; -#endif // ifdef __BIOS__ diff --git a/Private/NewBoot/Source/HEL/AMD64/BIOSRuntime0.asm b/Private/NewBoot/Source/HEL/AMD64/BIOSRuntime0.asm deleted file mode 100644 index f5ba44ec..00000000 --- a/Private/NewBoot/Source/HEL/AMD64/BIOSRuntime0.asm +++ /dev/null @@ -1,50 +0,0 @@ -;; Copyright 2024 Mahrouss Logic, all rights reserved - -extern __runtime_stack -global NBRuntimeZero - -bits 16 - -NBRuntimeZero: - cli - - lgdt [NewBootGdtRegister] - - mov ebx, cr0 - or ebx, 1 - mov cr0, ebx - - jmp 0x8:NBProtectedMode - -%include "BIOSApiGdt.inc" - -[bits 32] - -NBMasterPartitionTable: - resb 32 - resw 1 - resw 1 - resw 1 - resb 211 -NBMasterPartitionTableEnd: - -NBProtectedMode: - mov ax, 0x10 ; 0x10 is a stand-in for your data segment - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax - - mov esp, __runtime_stack - jmp 0x8000000 - -NBLoopOne: - cli - hlt - jmp $ - -NBMasterBootRecord: - times 510 - ($-$$) db 0 - dw 0xAA55 -NBEndMasterBootRecord:
\ No newline at end of file diff --git a/Private/NewBoot/Source/HEL/AMD64/BootAMD64.cxx b/Private/NewBoot/Source/HEL/AMD64/Boot.cxx index 39f8761e..96c30c12 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootAMD64.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/Boot.cxx @@ -7,13 +7,14 @@ * ======================================================== */ -#include <BootKit/Boot.hpp> +#include <BootKit/Boot.hxx> constexpr hCore::UInt32 kVGABaseAddress = 0xb8000; -long long int BStrLen(const char *ptr) +hCore::SizeT BStrLen(const char *ptr) { long long int cnt = 0; + while (*ptr != 0) { ++ptr; diff --git a/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx b/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx index d8a26acd..9b00a6a9 100644 --- a/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx @@ -7,11 +7,19 @@ * ======================================================== */ -#include "Protocol.hxx" +#include <BootKit/Boot.hxx> +#include <BootKit/Processor.hxx> +#include <BootKit/Protocol.hxx> extern "C" int EfiMain(void *ImageHandle, EfiSystemTable *SystemTable) { - SystemTable->conOut->output_string(SystemTable->conOut, L"HCORELDR: Preparing Handover structure...\r\n"); + SystemTable->conOut->outputString(SystemTable->conOut, L"HCoreLdr: Starting HCore...\r\n"); + + while (true) + { + rt_cli(); + rt_halt(); + } return 0; } diff --git a/Private/NewBoot/Source/HEL/AMD64/PartitionMap.hxx b/Private/NewBoot/Source/HEL/AMD64/PartitionMap.hxx deleted file mode 100644 index 490cc41a..00000000 --- a/Private/NewBoot/Source/HEL/AMD64/PartitionMap.hxx +++ /dev/null @@ -1,10 +0,0 @@ -/* - * ======================================================== - * - * h-core - * Copyright 2024, Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#include <HALKit/EPM.hxx> diff --git a/Private/NewBoot/Source/HEL/AMD64/Processor.cxx b/Private/NewBoot/Source/HEL/AMD64/Processor.cxx index d2a0c15f..f1f9b617 100644 --- a/Private/NewBoot/Source/HEL/AMD64/Processor.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/Processor.cxx @@ -1,11 +1,11 @@ /* -* ======================================================== -* -* NewBoot -* Copyright 2024 Mahrouss Logic, all rights reserved. -* -* ======================================================== -*/ + * ======================================================== + * + * NewBoot + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ /* * @@ -14,10 +14,24 @@ * */ -extern "C" void rt_halt(void) { asm volatile("hlt"); } +#include <BootKit/Processor.hxx> + +extern "C" void rt_halt(void) +{ + asm volatile("hlt"); +} -extern "C" void rt_cli(void) { asm volatile("cli"); } +extern "C" void rt_cli(void) +{ + asm volatile("cli"); +} -extern "C" void rt_sti(void) { asm volatile("sti"); } +extern "C" void rt_sti(void) +{ + asm volatile("sti"); +} -extern "C" void rt_cld(void) { asm volatile("cld"); } +extern "C" void rt_cld(void) +{ + asm volatile("cld"); +} diff --git a/Private/NewBoot/Source/HEL/AMD64/Protocol.hxx b/Private/NewBoot/Source/HEL/AMD64/Protocol.hxx deleted file mode 100644 index 7e292c7d..00000000 --- a/Private/NewBoot/Source/HEL/AMD64/Protocol.hxx +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ======================================================== - * - * NewBoot - * Copyright 2024 Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#pragma once - -#include <EFIKit/EFI.hxx> - -namespace HEL -{ -using namespace hCore; - -struct HandoverHeader final -{ - Int32 magic; - Int32 type; - Int32 arch; - // WIP -}; -} // namespace HEL - -#define kHandoverMagic 0xBAD55 - -#define kBaseHandoverStruct 0x10000000 -#define kHandoverStructSz sizeof(HEL::HandoverHeader) diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile index c5c382ac..b84f4425 100644 --- a/Private/NewBoot/Source/makefile +++ b/Private/NewBoot/Source/makefile @@ -12,9 +12,11 @@ arch-amd64: $(CC_GNU) $(FLAG_GNU) HEL/AMD64/*.cxx $(LD_GNU) *.o -e efi_main -filealign:16 -shared --subsystem=10 -ffreestanding -o HCORELDR.EXE cp HCORELDR.EXE CDROM/EFI/BOOT/BOOTX64.EFI + cp -r ../../Root ./CDROM/MAHROUSS .PHONY: efi-debug efi-debug: + wget https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd qemu-system-x86_64 -bios OVMF.fd -net none -drive file=fat:rw:CDROM,format=raw -d int .PHONY: clean |
