summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/Source
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-04-04 19:46:31 +0200
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-04-04 19:46:31 +0200
commita45872967f07906297782cd04223706cfc326219 (patch)
treef48d43749e4a1536d34e6c7dbb5b25defb8656fa /Private/NewBoot/Source
parentc33efb3e8a31435b37ed2c55375eec80c9b23155 (diff)
NewBoot: Major bootloader improvements, use __EFI_x86_64__ on EFI platforms, add common device class.
Meta: Upate specs and kernel-design. Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Private/NewBoot/Source')
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootAHCI.cxx2
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootATA.cxx2
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx16
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootMain.cxx2
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/New+Delete.cxx33
-rw-r--r--Private/NewBoot/Source/makefile6
6 files changed, 49 insertions, 12 deletions
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootAHCI.cxx b/Private/NewBoot/Source/HEL/AMD64/BootAHCI.cxx
index be7010a8..d736ac59 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootAHCI.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootAHCI.cxx
@@ -15,4 +15,4 @@
*
*/
-#include <BootKit/Arch/SATA.hxx>
+#include <BootKit/HW/SATA.hxx>
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
index 3f309f31..2a2852fb 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
@@ -15,7 +15,7 @@
*
*/
-#include <BootKit/Arch/ATA.hxx>
+#include <BootKit/HW/ATA.hxx>
#include <BootKit/BootKit.hxx>
/// bugs: 0
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx
index e767cb2d..cca9a6ca 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx
@@ -19,19 +19,19 @@ STATIC const BlockGUID kEPMGuid = {
/// @brief Write epm partition to disk.
/// @param namePart partition name
/// @param namePartLength length of name
-/// @param ataInterface disk interface, here ATA.
+/// @param bootDev disk interface.
/// @return
EXTERN_C Boolean boot_write_epm_partition(const Char* namePart, SizeT namePartLength,
- BootDeviceATA* ataInterface) {
+ BootDevice* bootDev) {
if (namePartLength > kEPMNameLength || !namePart) return No;
- if (!ataInterface) return No;
+ if (!bootDev) return No;
- ataInterface->Leak().mBase = kEPMStartPartitionBlk;
- ataInterface->Leak().mSize = kATASectorSize;
+ bootDev->Leak().mBase = kEPMStartPartitionBlk;
+ bootDev->Leak().mSize = kATASectorSize;
- Char buf[512] = {0};
+ Char buf[kATASectorSize] = {0};
- ataInterface->Read(buf, 1);
+ bootDev->Read(buf, 1);
BTextWriter writer;
@@ -106,7 +106,7 @@ EXTERN_C Boolean boot_write_epm_partition(const Char* namePart, SizeT namePartLe
swapBlock->Kind = kNewFSPartitionTypePage;
swapBlock->LbaEnd = kSwapSize; /// 4 MIB swap partition.
- ataInterface->Write(buf, 1);
+ bootDev->Write(buf, 1);
return No;
}
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
index f4eaee33..f2d893c2 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
@@ -173,7 +173,7 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
handoverHdrPtr->f_Magic = kHandoverMagic;
handoverHdrPtr->f_Version = kHandoverVersion;
- writer.Write(L"NewOS: Running NewOS...\r\n");
+ writer.Write(L"NewOS: Starting kernel...\r\n");
EFI::ExitBootServices(MapKey, ImageHandle);
diff --git a/Private/NewBoot/Source/HEL/AMD64/New+Delete.cxx b/Private/NewBoot/Source/HEL/AMD64/New+Delete.cxx
new file mode 100644
index 00000000..af7f2f00
--- /dev/null
+++ b/Private/NewBoot/Source/HEL/AMD64/New+Delete.cxx
@@ -0,0 +1,33 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <BootKit/BootKit.hxx>
+
+/// @brief Allocates a new object.
+/// @param sz the size.
+/// @return
+void* operator new(size_t sz)
+{
+ void* buf = nullptr;
+ BS->AllocatePool(EfiMemoryType::EfiLoaderData, sz, &buf);
+
+ return buf;
+}
+
+/// @brief Deletes the object.
+/// @param buf the object.
+void operator delete(void* buf)
+{
+ BS->FreePool(buf);
+}
+
+/// @brief Deletes the object (array specific).
+/// @param buf the object.
+/// @param size it's size.
+void operator delete(void* buf, size_t size)
+{
+ BS->FreePool(buf);
+} \ No newline at end of file
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index b9413bb4..4f076580 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -26,7 +26,7 @@ REM=rm
REM_FLAG=-f
FLAG_ASM=-f win64
-FLAG_GNU=-fshort-wchar -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./
+FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./
.PHONY: invalid-recipe
invalid-recipe:
@@ -38,6 +38,10 @@ all: compile-amd64
$(COPY) NewBoot.exe CDROM/EFI/BOOT/BOOTX64.EFI
$(COPY) NewBoot.exe CDROM/EFI/BOOT/NEWBOOT.EFI
+ifneq ($(DEBUG_SUPPORT), )
+DEBUG = -D__DEBUG__
+endif
+
.PHONY: compile-amd64
compile-amd64:
windres BootloaderRsrc.rsrc -O coff -o BootloaderRsrc.o