summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-29 22:38:43 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-29 22:38:43 +0100
commita8c17ccd6d97cc78830917dc6282b040b21ba16c (patch)
tree2181e96ccf9c89c677d2208661bce5584a667470 /Private/NewBoot
parent78861f1b16f18a85e9f6890e16eb320412b6ab80 (diff)
Kernel: Update SPECS and TODO list.
Cleaned up the SPECS to get into the point. Current Task: Load kernel into memory. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/NewBoot')
-rw-r--r--Private/NewBoot/BootKit/Boot.hxx84
-rw-r--r--Private/NewBoot/BootKit/Protocol.hxx5
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/Boot.cxx15
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx9
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/Platform.cxx (renamed from Private/NewBoot/Source/HEL/AMD64/Processor.cxx)0
-rw-r--r--Private/NewBoot/Source/makefile8
6 files changed, 76 insertions, 45 deletions
diff --git a/Private/NewBoot/BootKit/Boot.hxx b/Private/NewBoot/BootKit/Boot.hxx
index 07148702..4bdc9c84 100644
--- a/Private/NewBoot/BootKit/Boot.hxx
+++ b/Private/NewBoot/BootKit/Boot.hxx
@@ -7,6 +7,11 @@
* ========================================================
*/
+/***********************************************************************************/
+/// @file Boot.hxx
+/// @brief Bootloader API.
+/***********************************************************************************/
+
#pragma once
#include <NewKit/Defines.hpp>
@@ -15,55 +20,62 @@ using namespace hCore;
typedef void *PEFImage;
-enum
-{
- kSegmentCode = 2,
- kSegmentData = 4,
- kSegmentBss = 6,
+enum {
+ kSegmentCode = 2,
+ kSegmentData = 4,
+ kSegmentBss = 6,
};
/**
* @brief BootKit Text Writer class
* Writes to VGA.
*/
-class BKTextWriter final
-{
- volatile UInt16 *fWhere{nullptr};
+class BKTextWriter final {
+ volatile UInt16 *fWhere{nullptr};
- public:
- void WriteString(const char *c, unsigned char forecolour, unsigned char backcolour, int x, int y);
+ public:
+ void WriteString(const char *c, unsigned char forecolour,
+ unsigned char backcolour, int x, int y);
- void WriteCharacter(char c, unsigned char forecolour, unsigned char backcolour, int x, int y);
+ void WriteCharacter(char c, unsigned char forecolour,
+ unsigned char backcolour, int x, int y);
- public:
- BKTextWriter() = default;
- ~BKTextWriter() = default;
+ public:
+ BKTextWriter() = default;
+ ~BKTextWriter() = default;
- public:
- BKTextWriter &operator=(const BKTextWriter &) = default;
- BKTextWriter(const BKTextWriter &) = default;
+ public:
+ BKTextWriter &operator=(const BKTextWriter &) = default;
+ BKTextWriter(const BKTextWriter &) = default;
};
-enum
-{
- kBlack,
- kBlue,
- kGreen,
- kCyan,
- kRed,
- kMagenta,
- kBrown,
- kLightGray,
- kDarkGray,
- kLightBlue,
- kLightGreen,
- kLightCyan,
- kLightRed,
- kLightMagenta,
- kYellow,
- kWhite,
+enum {
+ kBlack,
+ kBlue,
+ kGreen,
+ kCyan,
+ kRed,
+ kMagenta,
+ kBrown,
+ kLightGray,
+ kDarkGray,
+ kLightBlue,
+ kLightGreen,
+ kLightCyan,
+ kLightRed,
+ kLightMagenta,
+ kYellow,
+ kWhite,
};
-#define BK_START_KERNEL (0x10000000)
+#define BK_START_KERNEL (0x80000000)
hCore::SizeT BStrLen(const char *ptr);
+hCore::SizeT BSetMem(char *src, const char byte, const hCore::SizeT len);
+
+/***********************************************************************************/
+/// Include other APIs.
+/***********************************************************************************/
+
+#include <BootKit/Processor.hxx>
+#include <BootKit/Protocol.hxx>
diff --git a/Private/NewBoot/BootKit/Protocol.hxx b/Private/NewBoot/BootKit/Protocol.hxx
index bcbb43a3..26eef7e7 100644
--- a/Private/NewBoot/BootKit/Protocol.hxx
+++ b/Private/NewBoot/BootKit/Protocol.hxx
@@ -55,8 +55,11 @@ struct HandoverInformationHeader {
SizeT f_VirtualSize;
voidPtr f_PhysicalStart;
SizeT f_PhysicalSize;
- voidPtr f_FirmwareVendorName;
+ Char f_FirmwareVendorName[32];
SizeT f_FirmwareVendorLen;
+ voidPtr f_RsdPtr;
+ voidPtr f_SmBIOS;
+ voidPtr f_RTC;
};
/**
diff --git a/Private/NewBoot/Source/HEL/AMD64/Boot.cxx b/Private/NewBoot/Source/HEL/AMD64/Boot.cxx
index 70f280e6..6bf63ffe 100644
--- a/Private/NewBoot/Source/HEL/AMD64/Boot.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/Boot.cxx
@@ -22,6 +22,21 @@ hCore::SizeT BStrLen(const char *ptr) {
return cnt;
}
+hCore::SizeT BSetMem(char *src, const char byte, const hCore::SizeT len) {
+ hCore::SizeT cnt = 0UL;
+
+ while (*src != 0) {
+ if (cnt > len) break;
+
+ *src = byte;
+ ++src;
+
+ ++cnt;
+ }
+
+ return cnt;
+}
+
/**
@brief puts wrapper over VGA.
*/
diff --git a/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx b/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx
index 5422d368..a1868144 100644
--- a/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx
@@ -8,16 +8,13 @@
*/
#include <BootKit/Boot.hxx>
-#include <BootKit/Processor.hxx>
-#include <BootKit/Protocol.hxx>
// don't remove EfiGUID, it will call initializer_list!
EFI_EXTERN_C int EfiMain(EfiHandlePtr ImageHandle,
EfiSystemTable* SystemTable) {
- EfiCharType* string = L"HCoreLdr: Initializing...\r\n";
-
- SystemTable->ConOut->OutputString(SystemTable->ConOut, string);
+ SystemTable->ConOut->OutputString(SystemTable->ConOut,
+ L"HCoreLdr: Initializing Kernel...\r\n");
EfiLoadImageProtocol* protocol;
EfiGUID guid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
@@ -42,7 +39,7 @@ EFI_EXTERN_C int EfiMain(EfiHandlePtr ImageHandle,
SystemTable->ConOut, L"HCoreLdr: Could not exit Boot Services!\r\n");
SystemTable->ConOut->OutputString(SystemTable->ConOut,
- L"HCoreLdr: Hanging...\r\n");
+ L"HCoreLdr: Entering limbo state...\r\n");
while (true) {
rt_cli();
diff --git a/Private/NewBoot/Source/HEL/AMD64/Processor.cxx b/Private/NewBoot/Source/HEL/AMD64/Platform.cxx
index a0c93ab5..a0c93ab5 100644
--- a/Private/NewBoot/Source/HEL/AMD64/Processor.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/Platform.cxx
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index 1fa6cc46..9ae30d13 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -8,6 +8,10 @@ LD_GNU=x86_64-w64-mingw32-ld
FLAG_GNU=-fshort-wchar -fPIC -D__DBG__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I../../efiSDK/inc -I./ -c -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -D__HAVE_HCORE_APIS__ -D__HCORE__ -I./ -I$(HOME)/
+.PHONY: invalid-recipe
+invalid-recipe:
+ @echo "invalid-recipe: Use make arch-<arch> all instead."
+
.PHONY: arch-amd64
arch-amd64:
$(CC_GNU) $(FLAG_GNU) HEL/AMD64/*.cxx
@@ -15,8 +19,8 @@ arch-amd64:
cp HCORELDR.EXE CDROM/EFI/BOOT/BOOTX64.EFI
cp -r ../../Root ./CDROM/MAHROUSS
-.PHONY: efi-debug
-efi-debug:
+.PHONY: run-efi-debug
+run-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