diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-04-27 22:10:15 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-04-27 22:10:15 +0200 |
| commit | dd6568c64e440fe9d8c75539165377ddbbca3e2c (patch) | |
| tree | a37e126238a4908100b3aaf701c27d183fe68a63 /Private/NewBoot | |
| parent | 86a2d7327f84519f525d66a7745554b41dddeb93 (diff) | |
MHR-18: A lot of patches and fixes, big improvements as well.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/NewBoot')
| -rw-r--r-- | Private/NewBoot/BootKit/BootKit.hxx | 30 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootATA.cxx | 2 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootMain.cxx | 21 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootPlatform.cxx | 2 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/New+Delete.cxx | 2 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/Support.cxx | 2 |
6 files changed, 23 insertions, 36 deletions
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx index a1eb9d76..4b9eecfd 100644 --- a/Private/NewBoot/BootKit/BootKit.hxx +++ b/Private/NewBoot/BootKit/BootKit.hxx @@ -38,9 +38,6 @@ class BFileReader; class BFileRunner; class BVersionString; -///! @note This address is reserved to NewKernel. -#define kBootVirtualAddress (0xfffffff80000000) - using namespace NewOS; typedef Char *PEFImagePtr; @@ -264,8 +261,12 @@ private: if (blobCounter > blobCount) break; ++blobCounter; - NewCatalog* catalogKind = new NewCatalog(); - memset(catalogKind, 0, sizeof(NewCatalog)); + Char bufCatalog[sizeof(NewCatalog)] = { 0 }; + Char bufFork[sizeof(NewFork)] = { 0 }; + + NewCatalog* catalogKind = (NewCatalog*)bufFork; + + catalogKind->PrevSibling = startLba; /// Fill catalog kind. catalogKind->Kind = blob->fKind; @@ -277,8 +278,7 @@ private: catalogKind->ResourceFork = (startLba + sizeof(NewCatalog)); } - NewFork* forkKind = new NewFork(); - memset(forkKind, 0, sizeof(NewFork)); + NewFork* forkKind = (NewFork*)bufFork; memcpy(forkKind->Name, blob->fForkName, strlen(blob->fForkName)); forkKind->Kind = (forkKind->Name[0] == kNewFSDataFork[0]) ? kNewFSDataForkKind : kNewFSRsrcForkKind; @@ -322,13 +322,8 @@ private: catalogKind->Kind = blob->fKind; catalogKind->Flags |= kNewFSFlagCreated; - Lba catalogLba = (sizeof(NewCatalog) - startLba); - //// Now write catalog as well.. - catalogKind->PrevSibling = startLba; - catalogKind->NextSibling = (sizeof(NewCatalog) + blob->fBlobSz); - /// this mime only applies to file. if (catalogKind->Kind == kNewFSCatalogKindFile) { memcpy(catalogKind->Mime, kBKBootFileMime, strlen(kBKBootFileMime)); @@ -338,6 +333,8 @@ private: memcpy(catalogKind->Name, blob->fFileName, strlen(blob->fFileName)); + catalogKind->NextSibling = startLba + (sizeof(NewCatalog) + sizeof(NewFork) + blob->fBlobSz); + fDiskDev.Leak().mBase = startLba; fDiskDev.Leak().mSize = sizeof(NewCatalog); @@ -348,9 +345,6 @@ private: --partBlock.FreeCatalog; --partBlock.FreeSectors; - delete forkKind; - delete catalogKind; - blob = blob->fNext; } @@ -387,14 +381,14 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const char* partName, partBlock->CatalogCount = blobCount; partBlock->Kind = kNewFSHardDrive; partBlock->SectorSize = sectorSz; - partBlock->FreeCatalog = fDiskDev.GetSectorsCount() - partBlock->CatalogCount; + partBlock->FreeCatalog = fDiskDev.GetSectorsCount(); partBlock->SectorCount = fDiskDev.GetSectorsCount(); - partBlock->FreeSectors = fDiskDev.GetSectorsCount() - partBlock->CatalogCount; + partBlock->FreeSectors = fDiskDev.GetSectorsCount(); partBlock->StartCatalog = kNewFSCatalogStartAddress; partBlock->DiskSize = fDiskDev.GetDiskSize(); if (this->FormatCatalog(fileBlobs, blobCount, *partBlock)) { - fDiskDev.Leak().mBase = (kNewFSAddressAsLba); + fDiskDev.Leak().mBase = kNewFSAddressAsLba; fDiskDev.Leak().mSize = sectorSz; fDiskDev.Write(buf, sectorSz); diff --git a/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx index 8ab7dc20..5be1e977 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx @@ -88,7 +88,7 @@ ATAInit_Retry: boot_ata_wait_io(IO); for (SizeT indexData = 0ul; indexData < kATADataLen; ++indexData) { - kATAData[indexData] = In8(IO + ATA_REG_DATA); + kATAData[indexData] = In16(IO + ATA_REG_DATA); } OutBus = diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx index 226d5bff..36dc47d3 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx @@ -12,6 +12,7 @@ #include <NewKit/Macros.hpp> #include <BootKit/BootKit.hxx> #include <NewKit/Ref.hpp> +#include <FirmwareKit/Handover.hxx> #include <cstring> /// make the compiler shut up. @@ -21,13 +22,11 @@ /** Graphics related. */ -EXTERN_C Void hal_init_platform(HEL::HandoverInformationHeader* HIH); - STATIC EfiGraphicsOutputProtocol* kGop = nullptr; STATIC UInt16 kStride = 0U; STATIC EfiGUID kGopGuid; -EXTERN_C Void rt_jump_to_address(VoidPtr blob); +EXTERN_C Void hal_init_platform(HEL::HandoverInformationHeader* HIH); /** @brief Finds and stores the GOP. @@ -66,7 +65,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, writer.Write(L"Mahrouss-Logic (R) New Boot: ") .Write(BVersionString::Shared()); - writer.Write(L"\r\nNewBoot: Firmware Vendor: ") + writer.Write(L"\r\nNew Boot: Firmware Vendor: ") .Write(SystemTable->FirmwareVendor) .Write(L"\r\n"); @@ -76,6 +75,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, UInt32* SzDesc = new UInt32(); UInt32* RevDesc = new UInt32(); + *MapKey = 0; *SizePtr = sizeof(EfiMemoryDescriptor); HEL::HandoverInformationHeader* handoverHdrPtr = new HEL::HandoverInformationHeader(); @@ -125,19 +125,12 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, ToolboxClearRsrc(); - EfiPhysicalAddress* whereAddress = - reinterpret_cast<EfiPhysicalAddress*>(kBootVirtualAddress); - BS->GetMemoryMap(SizePtr, Descriptor, MapKey, SzDesc, RevDesc); handoverHdrPtr->f_PhysicalStart = (VoidPtr)Descriptor->PhysicalStart; - handoverHdrPtr->f_FirmwareSpecific[0] = Descriptor->Attribute; - handoverHdrPtr->f_FirmwareSpecific[1] = Descriptor->Kind; - - - BS->AllocatePages(EfiAllocateType::AllocateAnyPages, - EfiMemoryType::EfiConventionalMemory, 1, whereAddress); + handoverHdrPtr->f_FirmwareSpecific[HEL::kHandoverSpecificAttrib] = Descriptor->Attribute; + handoverHdrPtr->f_FirmwareSpecific[HEL::kHandoverSpecificKind] = Descriptor->Kind; handoverHdrPtr->f_VirtualStart = (VoidPtr)Descriptor->VirtualStart; handoverHdrPtr->f_VirtualSize = Descriptor->NumberOfPages; /* # of pages */ @@ -231,7 +224,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, EFI::ExitBootServices(*MapKey, ImageHandle); - hal_init_platform(kHandoverHeader); + hal_init_platform(handoverHdrPtr); EFI::Stop(); diff --git a/Private/NewBoot/Source/HEL/AMD64/BootPlatform.cxx b/Private/NewBoot/Source/HEL/AMD64/BootPlatform.cxx index 2ac90dd8..fa735142 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootPlatform.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootPlatform.cxx @@ -9,7 +9,7 @@ #include <BootKit/BootKit.hxx> #include "HALKit/AMD64/Processor.hpp" -#if 0 +#ifdef __STANDALONE__ EXTERN_C void rt_hlt() { asm volatile("hlt"); } diff --git a/Private/NewBoot/Source/HEL/AMD64/New+Delete.cxx b/Private/NewBoot/Source/HEL/AMD64/New+Delete.cxx index 909ccca6..8d811bd9 100644 --- a/Private/NewBoot/Source/HEL/AMD64/New+Delete.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/New+Delete.cxx @@ -9,7 +9,7 @@ #include <BootKit/BootKit.hxx> #include <cstddef> /* Since we're using GCC for this EFI program. */ -#if 0 +#ifdef __STANDALONE__ /// @brief Allocates a new object. /// @param sz the size. diff --git a/Private/NewBoot/Source/HEL/AMD64/Support.cxx b/Private/NewBoot/Source/HEL/AMD64/Support.cxx index a8e2c275..686f4811 100644 --- a/Private/NewBoot/Source/HEL/AMD64/Support.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/Support.cxx @@ -8,7 +8,7 @@ #include <FirmwareKit/Handover.hxx> #include <BootKit/Vendor/Support.hxx> -#if 0 +#ifdef __STANDALONE__ /// @brief memset definition in C++. /// @param dst destination pointer. |
