summaryrefslogtreecommitdiffhomepage
path: root/Boot
diff options
context:
space:
mode:
Diffstat (limited to 'Boot')
-rw-r--r--Boot/BootKit/BootKit.hxx33
-rw-r--r--Boot/BootKit/Vendor/Support.hxx2
-rw-r--r--Boot/Sources/HEL/AMD64/BootMain.cxx18
3 files changed, 34 insertions, 19 deletions
diff --git a/Boot/BootKit/BootKit.hxx b/Boot/BootKit/BootKit.hxx
index 77943a10..3eeb8633 100644
--- a/Boot/BootKit/BootKit.hxx
+++ b/Boot/BootKit/BootKit.hxx
@@ -12,12 +12,13 @@
#pragma once
#include <BootKit/HW/ATA.hxx>
+#include <FirmwareKit/EPM.hxx>
#include <CompilerKit/Version.hxx>
/// include NewFS header and Support header as well.
-#include <FSKit/NewFS.hxx>
#include <cstring>
+#include <FSKit/NewFS.hxx>
#include <BootKit/Vendor/Support.hxx>
/***********************************************************************************/
@@ -215,7 +216,7 @@ public:
/// @brief check if partition is good.
Bool IsPartitionValid() noexcept
{
- fDiskDev.Leak().mBase = (kNewFSAddressAsLba);
+ fDiskDev.Leak().mBase = (kNewFSStartLba);
fDiskDev.Leak().mSize = BootDev::kSectorSize;
Char buf[BootDev::kSectorSize] = {0};
@@ -284,7 +285,7 @@ private:
EFI::ThrowError(L"Developer-Error", L"This is caused by the developer of the bootloader.");
}
- writer.Write((catalogKind->Kind == kNewFSCatalogKindFile) ? L"newosldr: Write-File: " : L"newosldr: Write-Directory: ").Write(blob->fFileName).Write(L"\r");
+ writer.Write(L"newosldr: root directory: ").Write(blob->fFileName).Write(L"\r");
memcpy(catalogKind->Name, blob->fFileName, strlen(blob->fFileName));
@@ -354,13 +355,35 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const char* partName,
/// if we can write a root catalog, then write the partition block.
if (this->WriteRootCatalog(fileBlobs, blobCount, *partBlock))
{
- fDiskDev.Leak().mBase = kNewFSAddressAsLba;
+ fDiskDev.Leak().mBase = kNewFSStartLba;
fDiskDev.Leak().mSize = sectorSz;
fDiskDev.Write(buf, sectorSz);
+ /// Reset buffer.
+ SetMem(buf, 0, sectorSz);
+
+ BootBlockType* epmBoot = (BootBlockType*)buf;
+
+ constexpr auto cFsName = "NewFS";
+
+ CopyMem(reinterpret_cast<VoidPtr>(const_cast<Char*>(cFsName)), epmBoot->Fs, StrLen(cFsName));
+
+ epmBoot->FsVersion = kNewFSVersionInteger;
+ epmBoot->LbaStart = kNewFSStartLba;
+ epmBoot->SectorSz = partBlock->SectorSize;
+ epmBoot->NumBlocks = partBlock->CatalogCount;
+
+ CopyMem(reinterpret_cast<VoidPtr>(const_cast<Char*>("BOOT:")), epmBoot->Name, StrLen("BOOT:"));
+ CopyMem(reinterpret_cast<VoidPtr>(const_cast<Char*>(kEPMMagic)), epmBoot->Magic, StrLen(kEPMMagic));
+
BTextWriter writer;
- writer.Write(L"newosldr: Write-Partition: OK.\r");
+ writer.Write(L"newosldr: wrote parition.\r");
+
+ fDiskDev.Leak().mBase = kEpmBase;
+ fDiskDev.Leak().mSize = sectorSz;
+
+ fDiskDev.Write(buf, sectorSz);
return true;
}
diff --git a/Boot/BootKit/Vendor/Support.hxx b/Boot/BootKit/Vendor/Support.hxx
index eed59424..54183558 100644
--- a/Boot/BootKit/Vendor/Support.hxx
+++ b/Boot/BootKit/Vendor/Support.hxx
@@ -9,8 +9,6 @@
/// @file Support.hxx
/// @brief Purpose of this file is to help port libs into the bootloader.
-#include <BootKit/BootKit.hxx>
-
#define cLongMax ((long)(~0UL >> 1))
#define cLongMin (~cLongMax)
diff --git a/Boot/Sources/HEL/AMD64/BootMain.cxx b/Boot/Sources/HEL/AMD64/BootMain.cxx
index 145bdadb..6591f61e 100644
--- a/Boot/Sources/HEL/AMD64/BootMain.cxx
+++ b/Boot/Sources/HEL/AMD64/BootMain.cxx
@@ -89,21 +89,15 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
/// Splash screen stuff
writer.Write(L"Zeta Electronics Corporation (R) newosldr: ")
- .Write(BVersionString::The());
+ .Write(BVersionString::The()).Write("\r");
- if (SystemTable->FirmwareVendor[0] != '\\' ||
- SystemTable->FirmwareVendor[1] != 'E' ||
- SystemTable->FirmwareVendor[2] != 'P' ||
- SystemTable->FirmwareVendor[3] != 'M')
- {
- writer.Write(L"\rnewosldr: vendor: ")
- .Write(SystemTable->FirmwareVendor)
- .Write(L" isn't supported.\r");
+#ifndef __DEBUG__
+ writer.Write(L"\rnewosldr: AMD64 is only supported in debug mode.\r");
- EFI::Stop();
+ EFI::Stop();
- CANT_REACH();
- }
+ CANT_REACH();
+#endif
UInt32* MapKey = new UInt32();
UInt32* SizePtr = new UInt32();