summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/Source
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-18 12:35:19 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-18 12:39:24 +0100
commit4c714f2c24c5df78bae2f35c42c73107de4c8c71 (patch)
treeb36d2498b8387909dac45c98097b8169636ad25a /Private/NewBoot/Source
parenta4bfc396a78ddd553de519ab927d8479d0c3c45d (diff)
unstable, unrelated: See below.
- :boom: Breaking changes in System.Core.dll - Framebuffer, moved operator bool into c++ source file. - Remove zlib in favor of our own Zip API. Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Private/NewBoot/Source')
-rw-r--r--Private/NewBoot/Source/BootMain.cxx220
-rw-r--r--Private/NewBoot/Source/BootString.cxx (renamed from Private/NewBoot/Source/String.cxx)0
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootAHCI.cxx (renamed from Private/NewBoot/Source/HEL/AMD64/AMD64-AHCI.cxx)0
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootATA.cxx (renamed from Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx)18
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx (renamed from Private/NewBoot/Source/FileReader.cxx)12
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootMain.cxx167
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootTextWriter.cxx (renamed from Private/NewBoot/Source/TextWriter.cxx)0
-rw-r--r--Private/NewBoot/Source/makefile23
8 files changed, 195 insertions, 245 deletions
diff --git a/Private/NewBoot/Source/BootMain.cxx b/Private/NewBoot/Source/BootMain.cxx
deleted file mode 100644
index c0412797..00000000
--- a/Private/NewBoot/Source/BootMain.cxx
+++ /dev/null
@@ -1,220 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
-------------------------------------------- */
-
-#include <BootKit/BootKit.hxx>
-#include <KernelKit/MSDOS.hpp>
-#include <KernelKit/PE.hpp>
-#include <NewKit/Ref.hpp>
-
-#ifdef __x86_64__
-#include <HALKit/AMD64/HalPageAlloc.hpp>
-#else
-#error This CPU is unknown.
-#endif // ifdef __x86_64__
-
-#ifndef kBootKrnlSections
-#error [NewBoot/HCoreLdr] 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); // Init the efi library.
- InitGOP(); // Quick Toolkit for UI
-
- BTextWriter writer;
-
- /// Splash screen stuff
-
- writer.Write(L"MahroussLogic (R) HCoreLdr: ")
- .Write(BVersionString::Shared()).Write(L"\r\n");
-
- const char strDate[] = __DATE__;
-
- writer.Write(L"HCoreLdr: Build: ");
-
- for (auto& ch : strDate) writer.WriteCharacter(ch);
-
- writer.Write(L"\r\nHCoreLdr: Firmware Vendor: ")
- .Write(SystemTable->FirmwareVendor)
- .Write(L"\r\n");
-
- /// Read Kernel blob.
-
- BFileReader kernelImg(L"HCOREKRNL.EXE", ImageHandle);
-
- kernelImg.Size(kBootReadSize);
- kernelImg.ReadAll();
-
- if (kernelImg.Error() == BFileReader::kOperationOkay) {
- BlobType blob = (BlobType)kernelImg.Blob();
-
- ExecHeaderPtr ptrHdr = reinterpret_cast<ExecHeaderPtr>(
- HCore::rt_find_exec_header(reinterpret_cast<DosHeaderPtr>(blob)));
-
- if (ptrHdr && ptrHdr->mMachine == EFI::Platform() &&
- ptrHdr->mMagic == kPeMagic) {
- /// sections must be at least 3.
- if (ptrHdr->mNumberOfSections == kBootKrnlSections) {
- ExecOptionalHeaderPtr optHdr = reinterpret_cast<ExecOptionalHeaderPtr>(
- (UIntPtr)&ptrHdr->mCharacteristics + 1);
-
- // first check for kernel.cfg inside ESP/EPM.
- 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 sections here
-
- 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");
-
- ExecSectionHeader* blobKrnl =
- (ExecSectionHeader*)(&optHdr + sizeof(ExecOptionalHeader) + sizeof(UInt32));
-
- for (size_t i = 0; i < ptrHdr->mNumberOfSections; i++) {
- // TODO: parse PE information here.
- }
-
- UInt32 MapKey = 0;
- UInt32* Size;
- EfiMemoryDescriptor* Descriptor;
- UInt32 SzDesc = 0;
- UInt32 RevDesc = 0;
-
- if (BS->AllocatePool(EfiLoaderData, sizeof(UInt32), (VoidPtr*)&Size) !=
- kEfiOk) {
- EFI::RaiseHardError(
- L"HCoreLdr-BadAlloc",
- L"The bootloader ran out of memory! Please check your specs.");
- }
-
- /****
- *
- * Load kernel into memory.
- *
- */
-
- *Size = sizeof(EfiMemoryDescriptor);
-
- if (BS->AllocatePool(EfiLoaderData, sizeof(EfiMemoryDescriptor),
- (VoidPtr*)&Descriptor) != kEfiOk) {
- EFI::RaiseHardError(
- L"HCoreLdr-BadAlloc",
- L"The bootloader ran out of memory! Please check your specs.");
- }
-
- /****
- *
- * Get machine memory map.
- *
- */
-
- if (BS->GetMemoryMap(Size, Descriptor, &MapKey, &SzDesc, &RevDesc) !=
- kEfiOk) {
- EFI::RaiseHardError(
- L"HCoreLdr-GetMemoryMap",
- 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),
- (VoidPtr*)&handoverHdrPtr);
-
- handoverHdrPtr->f_GOP.f_The = kGop->Mode->FrameBufferBase;
- handoverHdrPtr->f_GOP.f_Width = kGop->Mode->Info->VerticalResolution;
- handoverHdrPtr->f_GOP.f_Height = kGop->Mode->Info->HorizontalResolution;
- handoverHdrPtr->f_GOP.f_PixelPerLine =
- kGop->Mode->Info->PixelsPerScanLine;
- handoverHdrPtr->f_GOP.f_PixelFormat = kGop->Mode->Info->PixelFormat;
- handoverHdrPtr->f_GOP.f_Size = kGop->Mode->FrameBufferSize;
-
- handoverHdrPtr->f_PhysicalStart =
- reinterpret_cast<voidPtr>(Descriptor->PhysicalStart);
- handoverHdrPtr->f_PhysicalSize = Descriptor->NumberOfPages;
-
- handoverHdrPtr->f_VirtualStart =
- reinterpret_cast<voidPtr>(Descriptor->VirtualStart);
-
- handoverHdrPtr->f_VirtualSize =
- Descriptor->NumberOfPages; /* # of pages */
-
- handoverHdrPtr->f_FirmwareVendorLen =
- BStrLen(SystemTable->FirmwareVendor);
-
- BCopyMem(handoverHdrPtr->f_FirmwareVendorName,
- SystemTable->FirmwareVendor,
- handoverHdrPtr->f_FirmwareVendorLen);
-
- handoverHdrPtr->f_HardwareTables.f_VendorTables = ST->ConfigurationTable->VendorTable;
-
- EFI::ExitBootServices(MapKey, ImageHandle);
-
- bool isIniNotFound = (systemIni.Blob() == nullptr);
-
- if (isIniNotFound) {
- handoverHdrPtr->f_Magic = kHandoverMagic;
- handoverHdrPtr->f_Version = 0x1011;
- handoverHdrPtr->f_Bootloader = 0x11; // Installer
-
- Main(handoverHdrPtr);
- } else {
- handoverHdrPtr->f_Magic = kHandoverMagic;
- handoverHdrPtr->f_Version = 0x1011;
- handoverHdrPtr->f_Bootloader = 0xDD; // System present
-
- MUST_PASS(kernelMain);
-
- kernelMain(handoverHdrPtr);
- }
-
- EFI::Stop();
-
- return kEfiOk;
- } else {
- writer.Write(L"HCoreLdr: Error-Code: HLDR-0001\r\n");
- }
- } else {
- writer.Write(L"HCoreLdr: Error-Code: HLDR-0002\r\n");
- }
- } else {
- writer.Write(L"HCoreLdr: Error-Code: HLDR-0003\r\n");
- }
-
- EFI::Stop();
-
- return kEfiFail;
-}
diff --git a/Private/NewBoot/Source/String.cxx b/Private/NewBoot/Source/BootString.cxx
index 9fbe1a11..9fbe1a11 100644
--- a/Private/NewBoot/Source/String.cxx
+++ b/Private/NewBoot/Source/BootString.cxx
diff --git a/Private/NewBoot/Source/HEL/AMD64/AMD64-AHCI.cxx b/Private/NewBoot/Source/HEL/AMD64/BootAHCI.cxx
index be7010a8..be7010a8 100644
--- a/Private/NewBoot/Source/HEL/AMD64/AMD64-AHCI.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootAHCI.cxx
diff --git a/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
index fc09a3a7..21f3f256 100644
--- a/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
@@ -72,7 +72,7 @@ ATAInit_Retry:
if (statRdy & ATA_SR_ERR) {
writer.Write(
- L"HCoreLdr: ATA: Select error, not an IDE based hard-drive.\r\n");
+ L"NewBoot: ATA: Select error, not an IDE based hard-drive.\r\n");
return false;
}
@@ -90,7 +90,7 @@ ATAInit_Retry:
kATAData[indexData] = In16(IO + ATA_REG_DATA);
}
- writer.Write(L"HCoreLdr: Model: ");
+ writer.Write(L"NewBoot: Model: ");
for (SizeT indexData = 0; indexData < kATADataLen; indexData += 1) {
writer.WriteCharacter(kATAData[indexData + ATA_IDENT_MODEL + 1])
@@ -114,21 +114,21 @@ ATAInit_Retry:
/* differentiate ATA, ATAPI, SATA and SATAPI */
if (cl == 0x14 && ch == 0xEB) {
- writer.Write(L"HCoreLdr: PATAPI drive detected.\r\n");
+ writer.Write(L"NewBoot: PATAPI drive detected.\r\n");
kATADeviceType = kATADevicePATA_PI;
}
if (cl == 0x69 && ch == 0x96) {
- writer.Write(L"HCoreLdr: SATAPI drive detected.\r\n");
+ writer.Write(L"NewBoot: SATAPI drive detected.\r\n");
kATADeviceType = kATADeviceSATA_PI;
}
if (cl == 0 && ch == 0) {
- writer.Write(L"HCoreLdr: PATA drive detected.\r\n");
+ writer.Write(L"NewBoot: PATA drive detected.\r\n");
kATADeviceType = kATADevicePATA;
}
if (cl == 0x3c && ch == 0xc3) {
- writer.Write(L"HCoreLdr: SATA drive detected.\r\n");
+ writer.Write(L"NewBoot: SATA drive detected.\r\n");
kATADeviceType = kATADeviceSATA;
}
@@ -206,7 +206,7 @@ BDeviceATA::BDeviceATA() noexcept {
kATADetected = true;
BTextWriter writer;
- writer.Write(L"HCoreLdr: Driver: OnLine.\r\n");
+ writer.Write(L"NewBoot: Driver: OnLine.\r\n");
}
}
/**
@@ -271,6 +271,6 @@ BDeviceATA& BDeviceATA::Write(CharacterType* Buf, const SizeT& SectorSz) {
/**
* @brief ATA Config getter.
- * @return BDeviceATA::ATATraits& the drive config.
+ * @return BDeviceATA::ATATrait& the drive config.
*/
-BDeviceATA::ATATraits& BDeviceATA::Leak() { return mTraits; }
+BDeviceATA::ATATrait& BDeviceATA::Leak() { return mTrait; }
diff --git a/Private/NewBoot/Source/FileReader.cxx b/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx
index f24329e8..8418fd4c 100644
--- a/Private/NewBoot/Source/FileReader.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx
@@ -6,10 +6,6 @@
Purpose: NewBoot FileReader,
Read complete file and store it in a buffer.
- Revision History:
-
- Fix stupid implementation for a more smarter one.
-
------------------------------------------- */
#include <BootKit/BootKit.hxx>
@@ -50,12 +46,12 @@ BFileReader::BFileReader(const CharacterType* path, EfiHandlePtr ImageHandle) {
EfiGUID guidImg = EfiGUID(EFI_LOADED_IMAGE_PROTOCOL_GUID);
if (BS->HandleProtocol(ImageHandle, &guidImg, (void**)&img) != kEfiOk) {
- mWriter.Write(L"HCoreLdr: Fetch-Protocol: No-Such-Protocol").Write(L"\r\n");
+ mWriter.Write(L"NewBoot: Fetch-Protocol: No-Such-Protocol").Write(L"\r\n");
this->mErrorCode = kNotSupported;
}
if (BS->HandleProtocol(img->DeviceHandle, &guidEfp, (void**)&efp) != kEfiOk) {
- mWriter.Write(L"HCoreLdr: Fetch-Protocol: No-Such-Protocol").Write(L"\r\n");
+ mWriter.Write(L"NewBoot: Fetch-Protocol: No-Such-Protocol").Write(L"\r\n");
this->mErrorCode = kNotSupported;
return;
}
@@ -63,7 +59,7 @@ BFileReader::BFileReader(const CharacterType* path, EfiHandlePtr ImageHandle) {
/// Start doing disk I/O
if (efp->OpenVolume(efp, &rootFs) != kEfiOk) {
- mWriter.Write(L"HCoreLdr: Fetch-Protocol: No-Such-Volume").Write(L"\r\n");
+ mWriter.Write(L"NewBoot: Fetch-Protocol: No-Such-Volume").Write(L"\r\n");
this->mErrorCode = kNotSupported;
return;
}
@@ -72,7 +68,7 @@ BFileReader::BFileReader(const CharacterType* path, EfiHandlePtr ImageHandle) {
if (rootFs->Open(rootFs, &kernelFile, mPath, kEFIFileRead, kEFIReadOnly) !=
kEfiOk) {
- mWriter.Write(L"HCoreLdr: Fetch-Protocol: No-Such-Path: ")
+ mWriter.Write(L"NewBoot: Fetch-Protocol: No-Such-Path: ")
.Write(mPath)
.Write(L"\r\n");
this->mErrorCode = kNotSupported;
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
new file mode 100644
index 00000000..cfd58516
--- /dev/null
+++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
@@ -0,0 +1,167 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <BootKit/BootKit.hxx>
+#include <KernelKit/MSDOS.hpp>
+#include <KernelKit/PE.hpp>
+#include <NewKit/Ref.hpp>
+
+#ifdef __x86_64__
+#include <HALKit/AMD64/HalPageAlloc.hpp>
+#else
+#error This CPU is unknown.
+#endif // ifdef __x86_64__
+
+#ifndef kBootKrnlSections
+#error[NewBoot/NewBoot] 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); // Init the efi library.
+ InitGOP(); // Quick Toolkit for UI
+
+ BTextWriter writer;
+
+ /// Splash screen stuff
+
+ writer.Write(L"MahroussLogic (R) NewBoot: ")
+ .Write(BVersionString::Shared())
+ .Write(L"\r\n");
+
+ const char strDate[] = __DATE__;
+
+ writer.Write(L"NewBoot: Build: ");
+
+ for (auto& ch : strDate) writer.WriteCharacter(ch);
+
+ writer.Write(L"\r\nHCoreLdr: Firmware Vendor: ")
+ .Write(SystemTable->FirmwareVendor)
+ .Write(L"\r\n");
+
+ /// Read Kernel blob.
+
+ BFileReader kernelImg(L".HCORE", ImageHandle);
+
+ kernelImg.Size(kBootReadSize + sizeof(ExecSectionHeader) * kBootKrnlSections);
+ kernelImg.ReadAll();
+
+ if (kernelImg.Error() == BFileReader::kOperationOkay) {
+ // first check for kernel.cfg inside ESP/EPM.
+ BFileReader systemManifest(L".MANIFEST", ImageHandle);
+
+ systemManifest.Size(1);
+ systemManifest.ReadAll();
+
+ UInt32 MapKey = 0;
+ UInt32* Size;
+ EfiMemoryDescriptor* Descriptor;
+ UInt32 SzDesc = 0;
+ UInt32 RevDesc = 0;
+
+ if (BS->AllocatePool(EfiLoaderData, sizeof(UInt32), (VoidPtr*)&Size) !=
+ kEfiOk) {
+ EFI::RaiseHardError(
+ L"NewBoot-BadAlloc",
+ L"NewBoot ran out of memory! Please check your specs.");
+ }
+
+ /****
+ *
+ * Load kernel into memory.
+ *
+ */
+
+ *Size = sizeof(EfiMemoryDescriptor);
+
+ if (BS->AllocatePool(EfiLoaderData, sizeof(EfiMemoryDescriptor),
+ (VoidPtr*)&Descriptor) != kEfiOk) {
+ EFI::RaiseHardError(
+ L"NewBoot-BadAlloc",
+ L"NewBoot ran out of memory! Please check your specs.");
+ }
+
+ /****
+ *
+ * Get machine memory map.
+ *
+ */
+
+ if (BS->GetMemoryMap(Size, Descriptor, &MapKey, &SzDesc, &RevDesc) !=
+ kEfiOk) {
+ EFI::RaiseHardError(L"NewBoot-GetMemoryMap",
+ 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),
+ (VoidPtr*)&handoverHdrPtr);
+
+ handoverHdrPtr->f_GOP.f_The = kGop->Mode->FrameBufferBase;
+ handoverHdrPtr->f_GOP.f_Width = kGop->Mode->Info->VerticalResolution;
+ handoverHdrPtr->f_GOP.f_Height = kGop->Mode->Info->HorizontalResolution;
+ handoverHdrPtr->f_GOP.f_PixelPerLine = kGop->Mode->Info->PixelsPerScanLine;
+ handoverHdrPtr->f_GOP.f_PixelFormat = kGop->Mode->Info->PixelFormat;
+ handoverHdrPtr->f_GOP.f_Size = kGop->Mode->FrameBufferSize;
+
+ handoverHdrPtr->f_PhysicalStart =
+ reinterpret_cast<voidPtr>(Descriptor->PhysicalStart);
+ handoverHdrPtr->f_PhysicalSize = Descriptor->NumberOfPages;
+
+ handoverHdrPtr->f_VirtualStart =
+ reinterpret_cast<voidPtr>(Descriptor->VirtualStart);
+
+ handoverHdrPtr->f_VirtualSize = Descriptor->NumberOfPages; /* # of pages */
+
+ handoverHdrPtr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor);
+
+ BCopyMem(handoverHdrPtr->f_FirmwareVendorName, SystemTable->FirmwareVendor,
+ handoverHdrPtr->f_FirmwareVendorLen);
+
+ handoverHdrPtr->f_HardwareTables.f_VendorTables =
+ ST->ConfigurationTable->VendorTable;
+
+ EFI::ExitBootServices(MapKey, ImageHandle);
+
+ bool isIniNotFound = (systemManifest.Blob() == nullptr);
+
+ if (isIniNotFound) {
+ handoverHdrPtr->f_Magic = kHandoverMagic;
+ handoverHdrPtr->f_Version = 0x1011;
+ handoverHdrPtr->f_Bootloader = 0x11; // Installer
+
+ Main(handoverHdrPtr);
+ } else {
+ handoverHdrPtr->f_Magic = kHandoverMagic;
+ handoverHdrPtr->f_Version = 0x1011;
+ handoverHdrPtr->f_Bootloader = 0xDD; // System present
+
+ Main(handoverHdrPtr);
+ }
+
+ EFI::Stop();
+
+ return kEfiOk;
+ } else {
+ writer.Write(L"NewBoot: Error-Code: HLDR-0003\r\n");
+ }
+
+ EFI::Stop();
+
+ return kEfiFail;
+}
diff --git a/Private/NewBoot/Source/TextWriter.cxx b/Private/NewBoot/Source/HEL/AMD64/BootTextWriter.cxx
index b363d80b..b363d80b 100644
--- a/Private/NewBoot/Source/TextWriter.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootTextWriter.cxx
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index eaaac592..801e7699 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -6,6 +6,10 @@
CC_GNU=x86_64-w64-mingw32-g++
LD_GNU=x86_64-w64-mingw32-ld
+ADD_FILE=touch
+COPY=cp
+HTTP_GET=wget
+
ifeq ($(shell uname), Darwin)
EMU=qemu-system-x86_64
else
@@ -26,12 +30,15 @@ invalid-recipe:
@echo "invalid-recipe: Use make bootloader-<arch> all instead."
.PHONY: bootloader-amd64
-bootloader-amd64:
- $(CC_GNU) $(FLAG_GNU) HEL/AMD64/*.cxx *.cxx
- $(LD_GNU) $(OBJ) $(LD_FLAGS) -o HCoreLdr.exe
- cp HCoreLdr.exe CDROM/EFI/BOOT/BOOTX64.EFI
- cp HCoreLdr.exe CDROM/EFI/BOOT/HCORELDR.EFI
- cp ../../HCoreKrnl.exe CDROM/HCOREKRNL.EXE
+bootloader-amd64: compile-amd64
+ $(LD_GNU) $(OBJ) $(LD_FLAGS) -o NewBoot.exe
+ $(COPY) NewBoot.exe CDROM/EFI/BOOT/BOOTX64.EFI
+ $(COPY) NewBoot.exe CDROM/EFI/BOOT/HCORELDR.EFI
+ $(ADD_FILE) CDROM/.HCORE
+
+.PHONY: compile-amd64
+compile-amd64:
+ $(CC_GNU) $(FLAG_GNU) $(wildcard HEL/AMD64/*.cxx) $(wildcard *.cxx)
.PHONY: run-efi-amd64
run-efi-amd64:
@@ -39,8 +46,8 @@ run-efi-amd64:
.PHONY: download-edk
download-edk:
- wget https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd
+ $(HTTP_GET) https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd
.PHONY: clean
clean:
- $(REM) $(REM_FLAG) $(OBJ) HCoreLdr.exe HCoreKrnl.exe OVMF.fd
+ $(REM) $(REM_FLAG) $(OBJ) NewBoot.exe HCoreKrnl.exe OVMF.fd