summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-29 17:12:41 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-29 17:12:41 +0100
commitf03986937db0b927da4b10554801e18e4dc7c43f (patch)
tree408c75b5af373b0a9a42a4b858ce5396af75703a
parent4b7cd3b0536f44a3c95e71550a77df08d9a4c088 (diff)
Kernel: Fix and unified NewBoot handover protocol.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
-rw-r--r--Private/HALKit/AMD64/StartSequence.asm24
-rw-r--r--Private/Linker/Platforms/PC.lds (renamed from Private/Linker/AMD64.ld)1
-rw-r--r--Private/NewBoot/BootKit/Protocol.hxx23
-rw-r--r--Private/makefile2
4 files changed, 42 insertions, 8 deletions
diff --git a/Private/HALKit/AMD64/StartSequence.asm b/Private/HALKit/AMD64/StartSequence.asm
index 45bd1656..efb90843 100644
--- a/Private/HALKit/AMD64/StartSequence.asm
+++ b/Private/HALKit/AMD64/StartSequence.asm
@@ -8,18 +8,28 @@
;; */
[bits 64]
+
+;; Global symbol of this unit
[global Main]
+[global MainUnsupported]
+
+;; External symbols needed by this unit.
[extern RuntimeMain]
[extern __SYSTEM_STACK_END]
-section .text
+%define kTypeKernel 100
+%define kArchAmd64 122
-NewBootMagic: dw 0x55FF66
-NewBootKernel: db "h-core", 0
-NewBootVersion: dw 1
+section .NewBoot
+HandoverMagic: dq 0xBAD55
+HandoverType: dw kTypeKernel
+HandoverArch: dw kArchAmd64
;; This NewBootStart points to Main.
-NewBootStart:
+HandoverStart: dq Main
+
+section .text
+
;; Just a simple setup, we'd also need to tell some before
Main:
mov rsp, __SYSTEM_STACK_END
@@ -30,7 +40,9 @@ L0:
hlt
jmp $
-MainBIOS:
+;; @brief this one is jumped on when an unsupported then gets through the boot stage.
+;; @note: must be ISA compatible!
+MainUnsupported:
cli
hlt
jmp $
diff --git a/Private/Linker/AMD64.ld b/Private/Linker/Platforms/PC.lds
index 39cb0076..77d237e2 100644
--- a/Private/Linker/AMD64.ld
+++ b/Private/Linker/Platforms/PC.lds
@@ -13,6 +13,7 @@ SECTIONS {
. = 0x10000000;
.text : {
+ *(.NewBoot)
*(.text .text.*)
} :text
diff --git a/Private/NewBoot/BootKit/Protocol.hxx b/Private/NewBoot/BootKit/Protocol.hxx
index b33ab32e..c2dc1a9d 100644
--- a/Private/NewBoot/BootKit/Protocol.hxx
+++ b/Private/NewBoot/BootKit/Protocol.hxx
@@ -15,7 +15,28 @@ namespace HEL
{
using namespace hCore;
-struct HandoverHeader final
+/**
+ @brief the kind of executable we're loading.
+*/
+enum
+{
+ kTypeKernel = 100,
+ kTypeKernelDriver = 101,
+ kTypeRsrc = 102,
+ kTypeCount = 3,
+};
+
+/**
+ @brief The executable architecture.
+*/
+
+enum
+{
+ kArchAmd64 = 122,
+ kArchCount = 2,
+};
+
+struct __attribute__((packed)) HandoverHeader final
{
Int32 targetMagic;
Int32 targetType;
diff --git a/Private/makefile b/Private/makefile
index 4c3b8f5b..7e6a6639 100644
--- a/Private/makefile
+++ b/Private/makefile
@@ -13,7 +13,7 @@ ASMFLAGS = -f elf64
KERNEL = hKernel.efi
# The kernel entrypoint
-SCRIPT = --script=Linker/AMD64.ld
+SCRIPT = --script=Linker/Platforms/PC.lds
# we want a flat binary
FMT = elf64