summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-03-01 09:37:23 +0100
committerAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-03-01 09:37:23 +0100
commit374d341bf0216294b58f0198dbe4ba986464563f (patch)
treead9fb1a0b02f40f566f09d36531060780457d249
parentc3e8cddf8c689807097f6f956d45e3ba96afec20 (diff)
:boom: See below.
HCoreLdr: Start effort to load HCoreKrnl in case of a non-installer scenario. HCoreKrnl: Start working on disk abstraction (AHCI) and rework PE format header file. Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
-rw-r--r--.vscode/c_cpp_properties.json2
-rw-r--r--Private/Drivers/ACPI/.gitkeep0
-rw-r--r--Private/Drivers/ACPI/ACPI.hpp (renamed from Private/HALKit/AMD64/ACPI/ACPI.hpp)20
-rw-r--r--Private/Drivers/ACPI/ACPIManager.hxx (renamed from Private/HALKit/AMD64/ACPI/ACPIManager.hpp)30
-rw-r--r--Private/Drivers/ACPI/compile_flags.txt4
-rw-r--r--Private/Drivers/AHCI/API.hxx7
-rw-r--r--Private/FSKit/NewFS.hxx11
-rw-r--r--Private/HALKit/AMD64/HalACPIManager.cpp2
-rw-r--r--Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp2
-rw-r--r--Private/KernelKit/DriveManager.hpp11
-rw-r--r--Private/KernelKit/HError.hpp8
-rw-r--r--Private/KernelKit/PE.hpp26
-rw-r--r--Private/KernelKit/ProcessManager.hpp2
-rw-r--r--Private/NewBoot/BootKit/BootKit.hxx2
-rw-r--r--Private/NewBoot/CxxRuntime/unwind.cxx4
-rw-r--r--Private/NewBoot/Source/BootMain.cxx122
-rw-r--r--Private/NewBoot/Source/FileReader.cxx9
-rw-r--r--Private/NewBoot/Source/TextWriter.cxx23
-rw-r--r--Private/NewBoot/Source/makefile2
-rw-r--r--Private/Root/Frameworks/.gitkeep0
-rw-r--r--Private/Source/ProcessManager.cxx4
-rw-r--r--Private/StorageKit/NVME.hpp4
-rw-r--r--Private/StorageKit/PRDT.hpp3
-rw-r--r--Public/Kits/SystemKit/CoreAPI.hxx13
-rw-r--r--Public/Kits/SystemKit/FileAPI.hxx13
-rw-r--r--Public/Kits/SystemKit/HeapAPI.hxx13
-rw-r--r--Public/Kits/SystemKit/ThreadAPI.hxx13
27 files changed, 222 insertions, 128 deletions
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
index ed6e621e..412858d6 100644
--- a/.vscode/c_cpp_properties.json
+++ b/.vscode/c_cpp_properties.json
@@ -7,7 +7,7 @@
"${workspaceFolder}/Private/NewBoot/**",
"${workspaceFolder}/Public/Kits/**",
],
- "defines": ["__HCORE__", "__HAVE_HCORE_APIS__", "__FSKIT_NEWFS__"],
+ "defines": ["__HCORE__", "__HAVE_HCORE_APIS__", "__FSKIT_NEWFS__", "kBootKrnlSections"],
"cStandard": "c17",
"cppStandard": "c++20",
"compilerPath": "/opt/homebrew/bin/x86_64-w64-mingw32-gcc",
diff --git a/Private/Drivers/ACPI/.gitkeep b/Private/Drivers/ACPI/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Private/Drivers/ACPI/.gitkeep
diff --git a/Private/HALKit/AMD64/ACPI/ACPI.hpp b/Private/Drivers/ACPI/ACPI.hpp
index f1a7c27c..1a4329fc 100644
--- a/Private/HALKit/AMD64/ACPI/ACPI.hpp
+++ b/Private/Drivers/ACPI/ACPI.hpp
@@ -1,15 +1,11 @@
-/*
- * ========================================================
- *
- * HCore
- * Date Added: 13/02/2023
- * Copyright Mahrouss Logic, all rights reserved.
- *
- * ========================================================
- */
+/* -------------------------------------------
-#ifndef _INC_ACPI_MANAGER_H
-#define _INC_ACPI_MANAGER_H
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#ifndef __ACPI__
+#define __ACPI__
/**
https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html
@@ -68,4 +64,4 @@ class Address {
};
} // namespace HCore
-#endif // !_INC_ACPI_MANAGER_H
+#endif // !__ACPI__
diff --git a/Private/HALKit/AMD64/ACPI/ACPIManager.hpp b/Private/Drivers/ACPI/ACPIManager.hxx
index 2b447216..dc3dd573 100644
--- a/Private/HALKit/AMD64/ACPI/ACPIManager.hpp
+++ b/Private/Drivers/ACPI/ACPIManager.hxx
@@ -1,27 +1,21 @@
-/*
- * ========================================================
- *
- * HCore
- * Date Added: 20/02/2023
- * Copyright Mahrouss Logic, all rights reserved.
- *
- * ========================================================
- */
-
-#ifndef _INC_ACPI_H
-#define _INC_ACPI_H
-
-#include <HALKit/AMD64/ACPI/ACPI.hpp>
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#ifndef __ACPI_MANAGER__
+#define __ACPI_MANAGER__
+
+#include <Drivers/ACPI/ACPI.hpp>
#include <KernelKit/DebugOutput.hpp>
#include <NewKit/Defines.hpp>
#include <NewKit/Ref.hpp>
namespace HCore {
-class ACPIManager {
+class ACPIManager final {
public:
explicit ACPIManager(voidPtr rsdptr);
-
- public:
~ACPIManager() = default;
ACPIManager &operator=(const ACPIManager &) = default;
@@ -47,4 +41,4 @@ class ACPIManager {
};
} // namespace HCore
-#endif // !_INC_ACPI_H
+#endif // !__ACPI_MANAGER__
diff --git a/Private/Drivers/ACPI/compile_flags.txt b/Private/Drivers/ACPI/compile_flags.txt
new file mode 100644
index 00000000..1bc51142
--- /dev/null
+++ b/Private/Drivers/ACPI/compile_flags.txt
@@ -0,0 +1,4 @@
+-I./
+-I../
+-I../../
+-std=c++20
diff --git a/Private/Drivers/AHCI/API.hxx b/Private/Drivers/AHCI/API.hxx
index 8b137891..2a02b434 100644
--- a/Private/Drivers/AHCI/API.hxx
+++ b/Private/Drivers/AHCI/API.hxx
@@ -1 +1,8 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#pragma once
diff --git a/Private/FSKit/NewFS.hxx b/Private/FSKit/NewFS.hxx
index 0218f666..b340aef5 100644
--- a/Private/FSKit/NewFS.hxx
+++ b/Private/FSKit/NewFS.hxx
@@ -151,17 +151,18 @@ struct PACKED NewPartitionBlock final {
#define kCatalogKindDevice 9
#define kCatalogKindLock 10
-#define kFilesystemSeparator '\\'
+#define kFilesystemSeparator '/'
#define kFilesystemUpDir ".."
-#define kFilesystemRoot "\\"
+#define kFilesystemRoot "/"
#define kFilesystemCR '\r'
#define kFilesystemLF '\n'
#define kFilesystemEOF (-1)
-#define kFilesystemBitWidth sizeof(NewCharType)
-#define kFilesystemLbaType HCore::Lba
+#define kFilesystemBitWidth (sizeof(NewCharType))
+#define kFilesystemLbaType (HCore::Lba)
+#define kNewFSAddressAsLba (1024)
namespace HCore {
///
@@ -211,8 +212,6 @@ class NewFilesystemHelper final {
};
} // namespace HCore
-#define kNewFSAddressAsLba 1024
-
enum {
kNewFSPartGPT,
kNewFSPartEPM,
diff --git a/Private/HALKit/AMD64/HalACPIManager.cpp b/Private/HALKit/AMD64/HalACPIManager.cpp
index db9263a1..20cbd327 100644
--- a/Private/HALKit/AMD64/HalACPIManager.cpp
+++ b/Private/HALKit/AMD64/HalACPIManager.cpp
@@ -4,7 +4,7 @@
------------------------------------------- */
-#include <HALKit/AMD64/ACPI/ACPIManager.hpp>
+#include <Drivers/ACPI/ACPIManager.hxx>
#include <HALKit/AMD64/Processor.hpp>
#include <NewKit/String.hpp>
diff --git a/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
index 98ddb646..bf122415 100644
--- a/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
+++ b/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
@@ -4,7 +4,7 @@
------------------------------------------- */
-#include <HALKit/AMD64/ACPI/ACPIManager.hpp>
+#include <Drivers/ACPI/ACPIManager.hxx>
#include <HALKit/AMD64/Processor.hpp>
///////////////////////////////////////////////////////////////////////////////////////
diff --git a/Private/KernelKit/DriveManager.hpp b/Private/KernelKit/DriveManager.hpp
index a9e26fd3..6cfb007b 100644
--- a/Private/KernelKit/DriveManager.hpp
+++ b/Private/KernelKit/DriveManager.hpp
@@ -31,13 +31,13 @@ enum {
kDriveCnt = 9,
};
-typedef Int64 DriveID;
+typedef Int64 rt_drive_id_type;
/// @brief Mounted drive traits.
struct DriveTraits final {
- char fName[kDriveNameLen]; // /System, /Boot, /USBDevice...
+ Char fName[kDriveNameLen]; // /System, /Boot, //./Devices/USB...
Int32 fKind; // fMassStorage, fFloppy, fOpticalDisc.
- DriveID fId; // Drive id.
+ rt_drive_id_type fId; // Drive id.
Int32 fFlags; // fReadOnly, fXPMDrive, fXPTDrive
//! for StorageKit.
@@ -77,6 +77,8 @@ class Mountpoint final {
DriveDevicePtr D() { return mD; }
DriveDevicePtr* GetAddressOf(int index) {
+ DbgLastError() = kErrorSuccess;
+
switch (index) {
case 0:
return &mA;
@@ -87,8 +89,9 @@ class Mountpoint final {
case 3:
return &mD;
default: {
- GetLastError() = kErrorNoSuchDisk;
+ DbgLastError() = kErrorNoSuchDisk;
kcout << "HCoreKrnl\\Mountpoint: Check HError.\n";
+
break;
}
}
diff --git a/Private/KernelKit/HError.hpp b/Private/KernelKit/HError.hpp
index c9dcc2a5..1b971e94 100644
--- a/Private/KernelKit/HError.hpp
+++ b/Private/KernelKit/HError.hpp
@@ -29,8 +29,8 @@ inline constexpr HError kErrorNoSuchDisk = 45;
Boolean ke_bug_check(void) noexcept;
} // namespace HCore
-#define IsOk(HERR) (HERR == HCore::kErrorSuccess)
-#define HasFailed(HERR) (HERR != HCore::kErrorSuccess)
-#define GetLastError() LastError
+#define DbgOk() (kLastError == HCore::kErrorSuccess)
+#define DbgFailed() (kLastError != HCore::kErrorSuccess)
+#define DbgLastError() kLastError
-inline HCore::HError LastError = 0;
+inline HCore::HError kLastError = 0;
diff --git a/Private/KernelKit/PE.hpp b/Private/KernelKit/PE.hpp
index 99d6724f..43de19e0 100644
--- a/Private/KernelKit/PE.hpp
+++ b/Private/KernelKit/PE.hpp
@@ -16,10 +16,11 @@
#include <NewKit/Defines.hpp>
+typedef HCore::UIntPtr U64;
typedef HCore::UInt32 U32;
typedef HCore::UInt16 U16;
typedef HCore::UInt8 U8;
-typedef char CHAR;
+typedef U8 BYTE;
#define kMagMz0 'M'
#define kMagMz1 'Z'
@@ -47,13 +48,12 @@ typedef struct ExecOptionalHeader final {
U16 mMagic; // 0x010b - PE32, 0x020b - PE32+ (64 bit)
U8 mMajorLinkerVersion;
U8 mMinorLinkerVersion;
- U32 mSizeOfCode;
- U32 mSizeOfInitializedData;
- U32 mSizeOfUninitializedData;
+ U64 mSizeOfCode;
+ U64 mSizeOfInitializedData;
+ U64 mSizeOfUninitializedData;
U32 mAddressOfEntryPoint;
U32 mBaseOfCode;
- U32 mBaseOfData;
- U32 mImageBase;
+ U64 mImageBase;
U32 mSectionAlignment;
U32 mFileAlignment;
U16 mMajorOperatingSystemVersion;
@@ -63,21 +63,21 @@ typedef struct ExecOptionalHeader final {
U16 mMajorSubsystemVersion;
U16 mMinorSubsystemVersion;
U32 mWin32VersionValue;
- U32 mSizeOfImage;
- U32 mSizeOfHeaders;
+ U64 mSizeOfImage;
+ U64 mSizeOfHeaders;
U32 mCheckSum;
U16 mSubsystem;
U16 mDllCharacteristics;
- U32 mSizeOfStackReserve;
- U32 mSizeOfStackCommit;
- U32 mSizeOfHeapReserve;
- U32 mSizeOfHeapCommit;
+ U64 mSizeOfStackReserve;
+ U64 mSizeOfStackCommit;
+ U64 mSizeOfHeapReserve;
+ U64 mSizeOfHeapCommit;
U32 mLoaderFlags;
U32 mNumberOfRvaAndSizes;
} ExecOptionalHeader, *ExecOptionalHeaderPtr;
typedef struct ExecSectionHeader final {
- CHAR mName[8];
+ BYTE mName[8];
U32 mVirtualSize;
U32 mVirtualAddress;
U32 mSizeOfRawData;
diff --git a/Private/KernelKit/ProcessManager.hpp b/Private/KernelKit/ProcessManager.hpp
index 092f47e7..277a2985 100644
--- a/Private/KernelKit/ProcessManager.hpp
+++ b/Private/KernelKit/ProcessManager.hpp
@@ -155,7 +155,7 @@ class Process final {
void Crash();
//! @brief Exits program.
- void Exit(Int32 exit_code = 0);
+ void Exit(Int32 exitCode = 0);
//! @brief TLS Allocate
VoidPtr New(const SizeT &sz);
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx
index e9b52bf2..fa173f25 100644
--- a/Private/NewBoot/BootKit/BootKit.hxx
+++ b/Private/NewBoot/BootKit/BootKit.hxx
@@ -42,8 +42,10 @@ typedef WideChar CharacterType;
* Writes to UEFI StdOut.
*/
class BTextWriter final {
+ BTextWriter &_Write(const Long &num);
public:
BTextWriter &Write(const Long &num);
+ BTextWriter &Write(const UChar *str);
BTextWriter &Write(const CharacterType *str);
BTextWriter &WriteCharacter(CharacterType c);
diff --git a/Private/NewBoot/CxxRuntime/unwind.cxx b/Private/NewBoot/CxxRuntime/unwind.cxx
index f679bdd5..4f8807cd 100644
--- a/Private/NewBoot/CxxRuntime/unwind.cxx
+++ b/Private/NewBoot/CxxRuntime/unwind.cxx
@@ -1,7 +1,7 @@
namespace cxxkit {
///! @brief C++ ABI unwinding
-///! finis array (r1)
-///! n of finis (r2)
+///! Fini array (r1)
+///! Numbers of Fini (r2)
extern "C" void __unwind(void (**finis)(void), int cnt) {
for (int i = 0; i < cnt; ++i) (finis[i])();
}
diff --git a/Private/NewBoot/Source/BootMain.cxx b/Private/NewBoot/Source/BootMain.cxx
index a9f3babd..53a217b6 100644
--- a/Private/NewBoot/Source/BootMain.cxx
+++ b/Private/NewBoot/Source/BootMain.cxx
@@ -10,7 +10,6 @@
#define __BOOTLOADER__ 1
#include <BootKit/BootKit.hxx>
-#include <HALKit/AMD64/ACPI/ACPI.hpp>
#include <KernelKit/MSDOS.hpp>
#include <KernelKit/PE.hpp>
#include <NewKit/Ref.hpp>
@@ -21,11 +20,17 @@
#error This CPU is unknown.
#endif // ifdef __x86_64__
+#ifndef kBootKrnlSections
+#error Please provide the amount of sections the kernel has.
+#endif // !kBootKrnlSections
+
#define kBootReadSize \
(sizeof(DosHeader) + sizeof(ExecHeader) + sizeof(ExecOptionalHeader))
EXTERN_C void Main(HEL::HandoverInformationHeader* HIH);
+typedef void (*bt_main_type)(HEL::HandoverInformationHeader* HIH);
+
EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
EfiSystemTable* SystemTable) {
InitEFI(SystemTable);
@@ -47,13 +52,13 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
.Write(SystemTable->FirmwareVendor)
.Write(L"\r\n");
- BFileReader img(L"HCOREKRNL.EXE", ImageHandle);
+ BFileReader kernelImg(L"HCOREKRNL.EXE", ImageHandle);
- img.Size(kBootReadSize);
- img.ReadAll();
+ kernelImg.Size(kBootReadSize);
+ kernelImg.ReadAll();
- if (img.Error() == BFileReader::kOperationOkay) {
- BlobType blob = (BlobType)img.Blob();
+ if (kernelImg.Error() == BFileReader::kOperationOkay) {
+ BlobType blob = (BlobType)kernelImg.Blob();
ExecHeaderPtr ptrHdr = reinterpret_cast<ExecHeaderPtr>(
HCore::rt_find_exec_header(reinterpret_cast<DosHeaderPtr>(blob)));
@@ -61,9 +66,78 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
if (ptrHdr && ptrHdr->mMachine == EFI::Platform() &&
ptrHdr->mMagic == kPeMagic) {
/// sections must be at least 3.
- if (ptrHdr->mNumberOfSections >= 3) {
+ if (ptrHdr->mNumberOfSections == kBootKrnlSections) {
ExecOptionalHeaderPtr optHdr = reinterpret_cast<ExecOptionalHeaderPtr>(
- ptrHdr + sizeof(ExecHeader));
+ (UIntPtr)&ptrHdr->mCharacteristics + 1);
+
+ BFileReader systemIni(L"KERNEL.CFG", ImageHandle);
+
+ systemIni.Size(1);
+ systemIni.ReadAll();
+
+ bt_main_type kernelMain =
+ (bt_main_type)(UIntPtr)optHdr->mAddressOfEntryPoint;
+
+ SizeT heapSize = optHdr->mSizeOfHeapReserve;
+ SizeT stackSize = optHdr->mSizeOfStackReserve;
+
+ UInt64 posSeek = 0;
+
+ /****
+ *
+ * LOAD KERNEL CODE
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * LOAD KERNEL CODE
+ */
+
+ kernelImg.File()->SetPosition(kernelImg.File(), &posSeek);
+ kernelImg.Size(kBootReadSize +
+ ptrHdr->mNumberOfSections * sizeof(ExecSectionHeader));
+
+ kernelImg.ReadAll();
+
+ writer.Write(L"HCoreLdr: Number of sections: ")
+ .Write(ptrHdr->mNumberOfSections)
+ .Write(L"\r\n");
+ writer.Write(L"HCoreLdr: Size of sections: ")
+ .Write(ptrHdr->mNumberOfSections * sizeof(ExecSectionHeader))
+ .Write(L"\r\n");
+
+ volatile ALIGN(kPTEAlign) ExecSectionHeader* blobKrnl =
+ (ExecSectionHeader*)(reinterpret_cast<DosHeaderPtr>(blob) +
+ reinterpret_cast<DosHeaderPtr>(blob)->eLfanew +
+ ptrHdr->mSizeOfOptionalHeader +
+ (sizeof(ExecHeader) +
+ sizeof(ExecOptionalHeader) + sizeof(U32)));
+
+ while (blobKrnl->mCharacteristics != 0x00000020) {
+ blobKrnl = blobKrnl + sizeof(ExecSectionHeader);
+ }
+
+ writer.Write(L"HCoreLdr: Exec Timestamp: ")
+ .Write(ptrHdr->mTimeDateStamp)
+ .Write(L"\r\n");
+
+ for (size_t i = 0; i < ptrHdr->mNumberOfSections; i++) {
+ writer.Write(L"HCoreLdr: Virtual-Size: ")
+ .Write(blobKrnl[i].mVirtualSize)
+ .Write(L"\r\n");
+ writer.Write(L"HCoreLdr: Virtual-Address: ")
+ .Write(blobKrnl[i].mVirtualAddress)
+ .Write(L"\r\n");
+ writer.Write(L"HCoreLdr: Raw-Address: ")
+ .Write(blobKrnl[i].mPointerToRawData)
+ .Write(L"\r\n");
+ writer.Write(L"HCoreLdr: Raw-Size: ")
+ .Write(blobKrnl[i].mSizeOfRawData)
+ .Write(L"\r\n");
+ }
UInt32 MapKey = 0;
UInt32* Size;
@@ -78,6 +152,12 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
L"The bootloader ran out of memory! Please check your specs.");
}
+ /****
+ *
+ * LOAD KERNEL CODE
+ *
+ */
+
*Size = sizeof(EfiMemoryDescriptor);
if (BS->AllocatePool(EfiLoaderData, sizeof(EfiMemoryDescriptor),
@@ -87,6 +167,12 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
L"The bootloader ran out of memory! Please check your specs.");
}
+ /****
+ *
+ * GET MEMORY MAP OF COMPUTER.
+ *
+ */
+
if (BS->GetMemoryMap(Size, Descriptor, &MapKey, &SzDesc, &RevDesc) !=
kEfiOk) {
EFI::RaiseHardError(
@@ -94,6 +180,10 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
L"GetMemoryMap returned a value which isn't kEfiOk!");
}
+#ifndef __DEBUG__
+ ST->ConOut->ClearScreen(ST->ConOut);
+#endif
+
HEL::HandoverInformationHeader* handoverHdrPtr = nullptr;
BS->AllocatePool(EfiLoaderData, sizeof(HEL::HandoverInformationHeader),
@@ -124,30 +214,24 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
SystemTable->FirmwareVendor,
handoverHdrPtr->f_FirmwareVendorLen);
- BFileReader systemIni(L"SYSTEM.INI", ImageHandle);
-
- systemIni.Size(1);
- systemIni.ReadAll();
-
- ST->ConOut->ClearScreen(ST->ConOut);
-
EFI::ExitBootServices(MapKey, ImageHandle);
bool isIniNotFound = (systemIni.Blob() == nullptr);
if (isIniNotFound) {
- handoverHdrPtr->f_Magic = 0x55DDFF;
+ handoverHdrPtr->f_Magic = kHandoverMagic;
handoverHdrPtr->f_Version = 0x1011;
handoverHdrPtr->f_Bootloader = 0x11; // Installer
Main(handoverHdrPtr);
-
} else {
- handoverHdrPtr->f_Magic = 0xFF55DD;
+ handoverHdrPtr->f_Magic = kHandoverMagic;
handoverHdrPtr->f_Version = 0x1011;
handoverHdrPtr->f_Bootloader = 0xDD; // System present
- // TODO: read .NewBoot section.
+ MUST_PASS(kernelMain);
+
+ kernelMain(handoverHdrPtr);
}
EFI::Stop();
diff --git a/Private/NewBoot/Source/FileReader.cxx b/Private/NewBoot/Source/FileReader.cxx
index 92b35eff..158f9ab4 100644
--- a/Private/NewBoot/Source/FileReader.cxx
+++ b/Private/NewBoot/Source/FileReader.cxx
@@ -107,14 +107,11 @@ Void BFileReader::ReadAll() {
if (this->mErrorCode != kOperationOkay) return;
if (mBlob == nullptr) {
- UInt8* blob = (UInt8*)hTransferBufferAddress;
-
- if (BS->AllocatePages(AllocateAnyPages, EfiLoaderData, 1,
- (EfiPhysicalAddress*)&blob) != kEfiOk) {
+ if (auto err = BS->AllocatePool(EfiLoaderCode, mSizeFile,
+ (VoidPtr*)&mBlob) != kEfiOk) {
+ mWriter.Write(L"*** EFI-Code: ").Write(err).Write(L" ***\r\n");
EFI::RaiseHardError(L"HCoreLdr_PageError", L"Allocation error.");
}
-
- mBlob = blob;
}
mErrorCode = kNotSupported;
diff --git a/Private/NewBoot/Source/TextWriter.cxx b/Private/NewBoot/Source/TextWriter.cxx
index 127b2293..b363d80b 100644
--- a/Private/NewBoot/Source/TextWriter.cxx
+++ b/Private/NewBoot/Source/TextWriter.cxx
@@ -28,6 +28,20 @@ BTextWriter &BTextWriter::Write(const CharacterType *str) {
return *this;
}
+BTextWriter &BTextWriter::Write(const UChar *str) {
+ if (*str == 0 || !str) return *this;
+
+ CharacterType strTmp[2];
+ strTmp[1] = 0;
+
+ for (size_t i = 0; str[i] != 0; i++) {
+ strTmp[0] = str[i];
+ ST->ConOut->OutputString(ST->ConOut, strTmp);
+ }
+
+ return *this;
+}
+
/**
@brief putc wrapper over EFI ConOut.
*/
@@ -41,10 +55,17 @@ BTextWriter &BTextWriter::WriteCharacter(CharacterType c) {
}
BTextWriter &BTextWriter::Write(const Long &x) {
+ this->Write(L"0x");
+ this->_Write(x);
+
+ return *this;
+}
+
+BTextWriter &BTextWriter::_Write(const Long &x) {
int y = x / 16;
int h = x % 16;
- if (y) this->Write(y);
+ if (y) this->_Write(y);
/* fail if the hex number is not base-16 */
if (h > 15) {
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index 40996aa4..23680c09 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -10,7 +10,7 @@ ASM=nasm
OBJ=$(wildcard *.o) $(wildcard ../../Obj/*.obj) $(wildcard HEL/AMD64/*.obj)
FLAG_ASM=-f win64
-FLAG_GNU=-fshort-wchar -D__DEBUG__ -mgeneral-regs-only -mno-red-zone -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -D__HAVE_HCORE_APIS__ -D__HCORE__ -I./ -I$(HOME)/
+FLAG_GNU=-fshort-wchar -DkBootKrnlSections=9 -D__DEBUG__ -mgeneral-regs-only -mno-red-zone -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -D__HAVE_HCORE_APIS__ -D__HCORE__ -I./ -I$(HOME)/
.PHONY: invalid-recipe
invalid-recipe:
diff --git a/Private/Root/Frameworks/.gitkeep b/Private/Root/Frameworks/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Private/Root/Frameworks/.gitkeep
diff --git a/Private/Source/ProcessManager.cxx b/Private/Source/ProcessManager.cxx
index 17bd8075..20f60c4f 100644
--- a/Private/Source/ProcessManager.cxx
+++ b/Private/Source/ProcessManager.cxx
@@ -9,11 +9,11 @@
/// @brief Process Scheduler API.
/***********************************************************************************/
-#include <KernelKit/HError.hpp>
#include <KernelKit/ProcessManager.hpp>
#include <KernelKit/SMPManager.hpp>
#include <NewKit/KernelHeap.hpp>
#include <NewKit/String.hpp>
+#include <KernelKit/HError.hpp>
///! bugs = 0
@@ -251,7 +251,7 @@ bool ProcessHelper::CanBeScheduled(Ref<Process> &process) {
}
/**
- * @brief Scheduler spin code.
+ * @brief Spin scheduler
*/
bool ProcessHelper::StartScheduling() {
if (ProcessHelper::CanBeScheduled(
diff --git a/Private/StorageKit/NVME.hpp b/Private/StorageKit/NVME.hpp
index 727a20c9..2adef888 100644
--- a/Private/StorageKit/NVME.hpp
+++ b/Private/StorageKit/NVME.hpp
@@ -40,8 +40,6 @@ class NVMEPacket {
SizeT DataSz;
UInt64 DriveID;
- Boolean ErrorSet;
- Boolean BusySet;
- Boolean ReadySet;
+ UInt8 Bits;
};
} // namespace HCore
diff --git a/Private/StorageKit/PRDT.hpp b/Private/StorageKit/PRDT.hpp
index b1127c13..a07fa6bf 100644
--- a/Private/StorageKit/PRDT.hpp
+++ b/Private/StorageKit/PRDT.hpp
@@ -3,12 +3,13 @@
Copyright Mahrouss Logic
------------------------------------------- */
+
#pragma once
#include <KernelKit/PCI/Dma.hpp>
#include <KernelKit/PCI/Iterator.hpp>
-#define PRDT_TRANSFER_SIZE (sizeof(HCore::UShort))
+#define kPrdtTransferSize (sizeof(HCore::UShort))
namespace HCore {
class PRDT final {
diff --git a/Public/Kits/SystemKit/CoreAPI.hxx b/Public/Kits/SystemKit/CoreAPI.hxx
index 05cce68d..1cd48442 100644
--- a/Public/Kits/SystemKit/CoreAPI.hxx
+++ b/Public/Kits/SystemKit/CoreAPI.hxx
@@ -1,11 +1,8 @@
-/*
- * ========================================================
- *
- * h-core
- * Copyright Mahrouss Logic, all rights reserved.
- *
- * ========================================================
- */
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
#pragma once
diff --git a/Public/Kits/SystemKit/FileAPI.hxx b/Public/Kits/SystemKit/FileAPI.hxx
index e0213c57..66ecef22 100644
--- a/Public/Kits/SystemKit/FileAPI.hxx
+++ b/Public/Kits/SystemKit/FileAPI.hxx
@@ -1,11 +1,8 @@
-/*
- * ========================================================
- *
- * h-core
- * Copyright Mahrouss Logic, all rights reserved.
- *
- * ========================================================
- */
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
#ifndef _SYSTEM_KIT_HCORE_FILE_HPP
#define _SYSTEM_KIT_HCORE_FILE_HPP
diff --git a/Public/Kits/SystemKit/HeapAPI.hxx b/Public/Kits/SystemKit/HeapAPI.hxx
index 9470de99..9391bc4f 100644
--- a/Public/Kits/SystemKit/HeapAPI.hxx
+++ b/Public/Kits/SystemKit/HeapAPI.hxx
@@ -1,11 +1,8 @@
-/*
- * ========================================================
- *
- * h-core
- * Copyright Mahrouss Logic, all rights reserved.
- *
- * ========================================================
- */
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
#pragma once
diff --git a/Public/Kits/SystemKit/ThreadAPI.hxx b/Public/Kits/SystemKit/ThreadAPI.hxx
index bbdf4779..ec15a64c 100644
--- a/Public/Kits/SystemKit/ThreadAPI.hxx
+++ b/Public/Kits/SystemKit/ThreadAPI.hxx
@@ -1,11 +1,8 @@
-/*
- * ========================================================
- *
- * h-core
- * Copyright Mahrouss Logic, all rights reserved.
- *
- * ========================================================
- */
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
//
// Created by Amlal on 1/27/24.