summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/Source
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-04-21 08:53:36 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-04-21 08:53:36 +0200
commitebadabf4b6ab4a08c47b098affa0de6d681b5982 (patch)
tree477087431fd2bbee9217390ab370dff30f0a2bf0 /Private/NewBoot/Source
parentbc4f32c10a34c6bded98f378004f7435deede43b (diff)
MHR-8: IMP: Implement an allocator for catalog and forks.
- Implement ke_find_free_catalog and ke_find_free_fork. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/NewBoot/Source')
-rw-r--r--Private/NewBoot/Source/BootloaderRsrc.rsrc2
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootATA.cxx14
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx10
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootMain.cxx38
4 files changed, 39 insertions, 25 deletions
diff --git a/Private/NewBoot/Source/BootloaderRsrc.rsrc b/Private/NewBoot/Source/BootloaderRsrc.rsrc
index 424d4575..e8d89e9a 100644
--- a/Private/NewBoot/Source/BootloaderRsrc.rsrc
+++ b/Private/NewBoot/Source/BootloaderRsrc.rsrc
@@ -11,7 +11,7 @@ BEGIN
BLOCK "080904E4"
BEGIN
VALUE "CompanyName", "Mahrouss-Logic"
- VALUE "FileDescription", "NewOS multi-platform bootloader."
+ VALUE "FileDescription", "New OS multi-platform bootloader."
VALUE "FileVersion", BOOTLOADER_VERSION
VALUE "InternalName", "NewBoot"
VALUE "LegalCopyright", "Copyright Mahrouss-Logic, all rights reserved."
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
index 2a2852fb..4e41ba2e 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
@@ -72,7 +72,7 @@ ATAInit_Retry:
if (statRdy & ATA_SR_ERR) {
writer.Write(
- L"NewOS: ATA: Select error, not an IDE based hard-drive.\r\n");
+ L"New Boot: ATA: Select error, not an IDE based hard-drive.\r\n");
return false;
}
@@ -108,21 +108,21 @@ ATAInit_Retry:
/* differentiate ATA, ATAPI, SATA and SATAPI */
if (cl == 0x14 && ch == 0xEB) {
- writer.Write(L"NewOS: PATAPI drive detected.\r\n");
+ writer.Write(L"New Boot: PATAPI drive detected.\r\n");
kATADeviceType = kATADevicePATA_PI;
}
if (cl == 0x69 && ch == 0x96) {
- writer.Write(L"NewOS: SATAPI drive detected.\r\n");
+ writer.Write(L"New Boot: SATAPI drive detected.\r\n");
kATADeviceType = kATADeviceSATA_PI;
}
if (cl == 0x0 && ch == 0x0) {
- writer.Write(L"NewOS: PATA drive detected.\r\n");
+ writer.Write(L"New Boot: PATA drive detected.\r\n");
kATADeviceType = kATADevicePATA;
}
if (cl == 0x3c && ch == 0xc3) {
- writer.Write(L"NewOS: SATA drive detected.\r\n");
+ writer.Write(L"New Boot: SATA drive detected.\r\n");
kATADeviceType = kATADeviceSATA;
}
@@ -159,7 +159,7 @@ Void boot_ata_read(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeUTF8* Buf,
++IndexOff;
while ((In8(ATA_COMMAND(IO))) & ATA_SR_BSY) boot_ata_wait_io(IO);
-
+
byte = In16(IO + ATA_REG_DATA);
Buf[IndexOff] = byte;
}
@@ -213,7 +213,7 @@ BootDeviceATA::BootDeviceATA() noexcept {
BTextWriter writer;
- writer.Write(L"NewOS: Drive is OnLine.\r\n");
+ writer.Write(L"New Boot: Drive is OnLine.\r\n");
}
}
/**
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx b/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx
index 6e279498..0046698c 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx
@@ -3,7 +3,7 @@
Copyright Mahrouss Logic
File: FileReader.cxx
- Purpose: NewBoot FileReader,
+ Purpose: New Boot FileReader,
Read complete file and store it in a buffer.
------------------------------------------- */
@@ -47,12 +47,12 @@ BFileReader::BFileReader(const CharacterTypeUTF16* path,
EfiGUID guidImg = EfiGUID(EFI_LOADED_IMAGE_PROTOCOL_GUID);
if (BS->HandleProtocol(ImageHandle, &guidImg, (void**)&img) != kEfiOk) {
- mWriter.Write(L"NewBoot: Fetch-Protocol: No-Such-Protocol").Write(L"\r\n");
+ mWriter.Write(L"New Boot: Fetch-Protocol: No-Such-Protocol").Write(L"\r\n");
this->mErrorCode = kNotSupported;
}
if (BS->HandleProtocol(img->DeviceHandle, &guidEfp, (void**)&efp) != kEfiOk) {
- mWriter.Write(L"NewBoot: Fetch-Protocol: No-Such-Protocol").Write(L"\r\n");
+ mWriter.Write(L"New Boot: Fetch-Protocol: No-Such-Protocol").Write(L"\r\n");
this->mErrorCode = kNotSupported;
return;
}
@@ -60,7 +60,7 @@ BFileReader::BFileReader(const CharacterTypeUTF16* path,
/// Start doing disk I/O
if (efp->OpenVolume(efp, &rootFs) != kEfiOk) {
- mWriter.Write(L"NewBoot: Fetch-Protocol: No-Such-Volume").Write(L"\r\n");
+ mWriter.Write(L"New Boot: Fetch-Protocol: No-Such-Volume").Write(L"\r\n");
this->mErrorCode = kNotSupported;
return;
}
@@ -69,7 +69,7 @@ BFileReader::BFileReader(const CharacterTypeUTF16* path,
if (rootFs->Open(rootFs, &kernelFile, mPath, kEFIFileRead, kEFIReadOnly) !=
kEfiOk) {
- mWriter.Write(L"NewBoot: Fetch-Protocol: No-Such-Path: ")
+ mWriter.Write(L"New Boot: 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
index 88d01dfc..e0d5d8c9 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
@@ -11,11 +11,9 @@
#include <KernelKit/PE.hxx>
#include <NewKit/Ref.hpp>
-#define kMaxBufSize 256
-
/** Graphics related. */
-STATIC EfiGraphicsOutputProtocol *kGop = nullptr;
+STATIC EfiGraphicsOutputProtocol* kGop = nullptr;
STATIC UInt16 kStride = 0U;
STATIC EfiGUID kGopGuid;
@@ -23,13 +21,13 @@ STATIC EfiGUID kGopGuid;
@brief Finds and stores the GOP.
*/
-STATIC Void InitGOP() noexcept {
+STATIC Void CheckAndFindFramebuffer() noexcept {
kGopGuid = EfiGUID(EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID);
kGop = nullptr;
- extern EfiBootServices *BS;
+ extern EfiBootServices* BS;
- BS->LocateProtocol(&kGopGuid, nullptr, (VoidPtr *)&kGop);
+ BS->LocateProtocol(&kGopGuid, nullptr, (VoidPtr*)&kGop);
kStride = 4;
}
@@ -45,14 +43,16 @@ STATIC Bool CheckBootDevice(BootDeviceATA& ataDev) {
/// @param SystemTable The system table of it.
/// @return
EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
- EfiSystemTable* SystemTable) {
- InitEFI(SystemTable); ///! Init the EFI library.
- InitGOP(); ///! Init the GOP.
+ EfiSystemTable* SystemTable) {
+ InitEFI(SystemTable); ///! Init the EFI library.
+ CheckAndFindFramebuffer(); ///! Init the GOP.
BTextWriter writer;
+
/// Splash screen stuff
- writer.Write(L"Mahrouss-Logic (R) NewBoot: ").Write(BVersionString::Shared());
+ writer.Write(L"Mahrouss-Logic (R) New Boot: ")
+ .Write(BVersionString::Shared());
writer.Write(L"\r\nNewBoot: Firmware Vendor: ")
.Write(SystemTable->FirmwareVendor)
@@ -69,7 +69,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
if (BS->AllocatePool(EfiLoaderData, sizeof(UInt32), (VoidPtr*)&SizePtr) !=
kEfiOk) {
- EFI::RaiseHardError(L"Bad-Alloc", L"NewBoot ran out of memory!");
+ EFI::RaiseHardError(L"Bad-Alloc", L"New Boot ran out of memory!");
}
/****
@@ -82,7 +82,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
if (BS->AllocatePool(EfiLoaderData, sizeof(EfiMemoryDescriptor),
(VoidPtr*)&Descriptor) != kEfiOk) {
- EFI::RaiseHardError(L"Bad-Alloc", L"NewBoot ran out of memory!");
+ EFI::RaiseHardError(L"Bad-Alloc", L"New Boot ran out of memory!");
}
HEL::HandoverInformationHeader* handoverHdrPtr = nullptr;
@@ -115,6 +115,20 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
handoverHdrPtr->f_GOP.f_PixelFormat = kGop->Mode->Info->PixelFormat;
handoverHdrPtr->f_GOP.f_Size = kGop->Mode->FrameBufferSize;
+ ///! Finally draw bootloader screen.
+
+ auto kHandoverHeader = handoverHdrPtr;
+
+ ToolboxInitRsrc();
+
+ ToolboxDrawZone(RGB(20, 20, 20), handoverHdrPtr->f_GOP.f_Height, handoverHdrPtr->f_GOP.f_Width, 0, 0);
+
+ ToolboxClearRsrc();
+
+ ToolboxDrawRsrc(Driver, DRIVER_HEIGHT, DRIVER_WIDTH, (handoverHdrPtr->f_GOP.f_Width - DRIVER_HEIGHT) / 2, (handoverHdrPtr->f_GOP.f_Height - DRIVER_HEIGHT) / 2);
+
+ ToolboxClearRsrc();
+
BS->AllocatePool(EfiLoaderData, sizeof(HEL::HandoverInformationHeader),
(VoidPtr*)&handoverHdrPtr);