diff options
| author | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-02 12:37:36 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-02 12:37:36 +0100 |
| commit | 167ef193e25aa58e962620558b8e2685cbded476 (patch) | |
| tree | aef93af31d679cc5e9ee251f937b5554d0d978c1 /Private | |
| parent | 1b4bd4df5f5cc15c688a13a169a76a8af69d0700 (diff) | |
NewBoot/Kernel: Finishing Bootloader and protocol.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private')
| -rw-r--r-- | Private/EFIKit/BootProtocol.hxx | 80 | ||||
| -rw-r--r-- | Private/EFIKit/EPM.hxx | 6 | ||||
| -rw-r--r-- | Private/NewBoot/BootKit/Arch/ATA.hxx | 1 | ||||
| -rw-r--r-- | Private/NewBoot/BootKit/EPM.hxx | 2 | ||||
| -rw-r--r-- | Private/NewBoot/BootKit/Protocol.hxx | 58 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx (renamed from Private/NewBoot/Source/HEL/AMD64/ATA.cxx) | 0 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/AMD64-BootKit.cxx (renamed from Private/NewBoot/Source/HEL/AMD64/BootKit.cxx) | 0 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/AMD64-Main.cxx (renamed from Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx) | 1 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/AMD64-Platform.cxx (renamed from Private/NewBoot/Source/HEL/AMD64/Platform.cxx) | 4 | ||||
| -rw-r--r-- | Private/Source/RuntimeMain.cxx | 8 |
10 files changed, 94 insertions, 66 deletions
diff --git a/Private/EFIKit/BootProtocol.hxx b/Private/EFIKit/BootProtocol.hxx new file mode 100644 index 00000000..2978cfed --- /dev/null +++ b/Private/EFIKit/BootProtocol.hxx @@ -0,0 +1,80 @@ +/* + * ======================================================== + * + * NewBoot + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +/** + * @file BootProtocol.hxx + * @author Amlal El Mahrouss (amlalelmahrouss@icloud.com) + * @brief Handover protocol. + * @version 0.1 + * @date 2024-02-02 + * + * @copyright Copyright (c) 2024, Mahrouss Logic + * + */ + +#pragma once + +#include <NewKit/Defines.hpp> + +/* useful macros */ + +#define kHandoverMagic 0xBAD55 + +#define kBaseHandoverStruct 0x80000000 +#define kHandoverStructSz sizeof(HEL::HandoverHeader) + +namespace HCore::HEL { +/** + @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, +}; + +/** +@brief The first struct that we read when inspecting The executable +it tells us more about it and IS format independent. +*/ +struct __attribute__((packed)) HandoverHeader final { + Int32 f_TargetMagic; + Int32 f_TargetType; + Int32 f_TargetArch; + UIntPtr f_TargetStartAddress; +}; + +struct HandoverInformationHeader { + HandoverHeader* f_Header; + voidPtr f_VirtualStart; + SizeT f_VirtualSize; + voidPtr f_PhysicalStart; + SizeT f_PhysicalSize; + Char f_FirmwareVendorName[32]; + SizeT f_FirmwareVendorLen; + voidPtr f_RsdPtr; + voidPtr f_SmBIOS; + voidPtr f_RTC; +}; + +/** + @brief Handover Jump Proc +*/ +typedef UInt64 (*HandoverProc)(HandoverInformationHeader* pHandover); +} // namespace HCore::HEL diff --git a/Private/EFIKit/EPM.hxx b/Private/EFIKit/EPM.hxx index f1cb84ba..8c74d533 100644 --- a/Private/EFIKit/EPM.hxx +++ b/Private/EFIKit/EPM.hxx @@ -16,9 +16,9 @@ #ifndef __PARTITION_MAP__ #define __PARTITION_MAP__ -inline consteval int kUUIDLen = 37; -inline consteval int kNameLen = 32; -inline consteval int kMagicLen = 4; +#define kUUIDLen 37 +#define kNameLen 32 +#define kMagicLen 4 /* the first 512 > x > 1024 bytes of a disk contains this headers. */ diff --git a/Private/NewBoot/BootKit/Arch/ATA.hxx b/Private/NewBoot/BootKit/Arch/ATA.hxx index 8b25a125..4042aaa9 100644 --- a/Private/NewBoot/BootKit/Arch/ATA.hxx +++ b/Private/NewBoot/BootKit/Arch/ATA.hxx @@ -127,6 +127,7 @@ class BATADevice final { }; explicit BATADevice() noexcept; + ~BATADevice() = default; HCORE_COPY_DEFAULT(BATADevice); diff --git a/Private/NewBoot/BootKit/EPM.hxx b/Private/NewBoot/BootKit/EPM.hxx index 803d500c..359eed1b 100644 --- a/Private/NewBoot/BootKit/EPM.hxx +++ b/Private/NewBoot/BootKit/EPM.hxx @@ -9,4 +9,4 @@ #pragma once -#include <HALKit/EPM.hxx> +#include <EFIKit/EPM.hxx> diff --git a/Private/NewBoot/BootKit/Protocol.hxx b/Private/NewBoot/BootKit/Protocol.hxx index 2f84d0a8..b2725794 100644 --- a/Private/NewBoot/BootKit/Protocol.hxx +++ b/Private/NewBoot/BootKit/Protocol.hxx @@ -9,61 +9,5 @@ #pragma once +#include <EFIKit/BootProtocol.hxx> #include <EFIKit/EFI.hxx> - -/* useful macros */ - -#define kHandoverMagic 0xBAD55 - -#define kBaseHandoverStruct 0x80000000 -#define kHandoverStructSz sizeof(HEL::HandoverHeader) - -namespace HCore::HEL { -/** - @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, -}; - -/** -@brief The first struct that we read when inspecting The executable -it tells us more about it and IS format independent. -*/ -struct __attribute__((packed)) HandoverHeader final { - Int32 f_TargetMagic; - Int32 f_TargetType; - Int32 f_TargetArch; - UIntPtr f_TargetStartAddress; -}; - -struct HandoverInformationHeader { - HandoverHeader* f_Header; - voidPtr f_VirtualStart; - SizeT f_VirtualSize; - voidPtr f_PhysicalStart; - SizeT f_PhysicalSize; - Char f_FirmwareVendorName[32]; - SizeT f_FirmwareVendorLen; - voidPtr f_RsdPtr; - voidPtr f_SmBIOS; - voidPtr f_RTC; -}; - -/** - @brief Handover Jump Proc -*/ -typedef UInt64 (*HandoverProc)(HandoverInformationHeader* pHandover); -} // namespace HCore::HEL diff --git a/Private/NewBoot/Source/HEL/AMD64/ATA.cxx b/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx index c289bcf5..c289bcf5 100644 --- a/Private/NewBoot/Source/HEL/AMD64/ATA.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx diff --git a/Private/NewBoot/Source/HEL/AMD64/BootKit.cxx b/Private/NewBoot/Source/HEL/AMD64/AMD64-BootKit.cxx index 600a8fcc..600a8fcc 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootKit.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/AMD64-BootKit.cxx diff --git a/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx b/Private/NewBoot/Source/HEL/AMD64/AMD64-Main.cxx index 8dfd7a71..256c7feb 100644 --- a/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/AMD64-Main.cxx @@ -7,7 +7,6 @@ * ======================================================== */ -#include "NewKit/Defines.hpp" #define __BOOTLOADER__ 1 #include <BootKit/BootKit.hxx> diff --git a/Private/NewBoot/Source/HEL/AMD64/Platform.cxx b/Private/NewBoot/Source/HEL/AMD64/AMD64-Platform.cxx index f92de33b..663d4bcb 100644 --- a/Private/NewBoot/Source/HEL/AMD64/Platform.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/AMD64-Platform.cxx @@ -27,4 +27,6 @@ extern "C" void rt_cld() { asm volatile("cld"); } extern "C" void rt_std() { asm volatile("std"); } -extern "C" void ___chkstk_ms(void) { EFI::Stop(); } +/// @brief Stack check + +extern "C" void ___chkstk_ms(void) {} diff --git a/Private/Source/RuntimeMain.cxx b/Private/Source/RuntimeMain.cxx index 02a7ce09..f103e98c 100644 --- a/Private/Source/RuntimeMain.cxx +++ b/Private/Source/RuntimeMain.cxx @@ -8,8 +8,9 @@ */ #include <ArchKit/Arch.hpp> -#include <KernelKit/CodeManager.hpp> +#include <EFIKit/BootProtocol.hxx> #include <KernelKit/FileManager.hpp> +#include <KernelKit/PEFCodeManager.hxx> #include <NewKit/Json.hpp> #include <NewKit/KernelHeap.hpp> #include <NewKit/UserHeap.hpp> @@ -18,7 +19,8 @@ extern "C" void (*__SYSTEM_FINI)(); extern "C" void (**__SYSTEM_INIT)(); -extern "C" void RuntimeMain() { +extern "C" void RuntimeMain( + HCore::HEL::HandoverInformationHeader* HandoverHeader) { /// Init C++ globals for (HCore::SizeT index_init = 0UL; __SYSTEM_INIT[index_init] != __SYSTEM_FINI; ++index_init) { @@ -31,7 +33,7 @@ extern "C" void RuntimeMain() { MUST_PASS(HCore::ke_init_hal()); HCore::IFilesystemManager::Mount(new HCore::NewFilesystemManager()); - HCore::PEFLoader img("/System/Shell.exe"); + HCore::PEFLoader img("/System/HCoreShell.exe"); if (!HCore::Utils::execute_from_image(img)) { HCore::ke_stop(RUNTIME_CHECK_BOOTSTRAP); |
