summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot
diff options
context:
space:
mode:
Diffstat (limited to 'Private/NewBoot')
-rw-r--r--Private/NewBoot/BootKit/BootKit.hxx2
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx54
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootMain.cxx5
3 files changed, 61 insertions, 0 deletions
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx
index 7a393e2a..bad13d85 100644
--- a/Private/NewBoot/BootKit/BootKit.hxx
+++ b/Private/NewBoot/BootKit/BootKit.hxx
@@ -204,3 +204,5 @@ class BVersionString final {
public:
static const CharacterTypeUTF16 *Shared() { return BOOTLOADER_VERSION; }
};
+
+Void boot_try_write_partition_map(const Char* namePart, SizeT namePartLength, BDeviceATA* ataInterface);
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx
index a4edfa57..6d2998f3 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx
@@ -5,3 +5,57 @@
------------------------------------------- */
#include <BootKit/BootKit.hxx>
+
+// {310E1FC7-2060-425D-BE7B-75A37CC679BC}
+STATIC const BlockGUID kEPMGuid = {
+ 0x310e1fc7,
+ 0x2060,
+ 0x425d,
+ {0xbe, 0x7b, 0x75, 0xa3, 0x7c, 0xc6, 0x79, 0xbc}};
+
+Void boot_try_write_partition_map(const Char* namePart, SizeT namePartLength,
+ BDeviceATA* ataInterface) {
+ if (namePartLength > kEPMNameLength || !namePart) return;
+ if (!ataInterface) return;
+
+ ataInterface->Leak().mBase = kEPMStartPartition;
+ ataInterface->Leak().mSize = 512;
+
+ Char buf[512] = {0};
+
+ ataInterface->Read(buf, 1);
+
+ BTextWriter writer;
+
+ writer.Write(L"NewBoot: Reading EPM boot block..\r\n");
+
+ for (SizeT i = 0; i < kEPMMagicLength; i++) {
+ if (buf[i] != kEPMMagic[i]) {
+ writer.Write(L"NewBoot: Writing EPM boot block..\r\n");
+
+ BootBlockType* bootBlock = (BootBlockType*)buf;
+
+ bootBlock->Version = kEPMHCore;
+ bootBlock->NumBlocks = kEPMMaxBlks;
+
+ for (SizeT i = 0; i < kEPMNameLength; i++) {
+ bootBlock->Magic[i] = kEPMMagic[i];
+ }
+
+ for (SizeT i = 0; i < namePartLength; i++) {
+ bootBlock->Name[i] = namePart[i];
+ }
+
+ bootBlock->SectorStart =
+ sizeof(BootBlockType) + (sizeof(PartitionBlockType) * kEPMMaxBlks);
+
+ bootBlock->SectorSz = kATASectorSize;
+
+ bootBlock->Uuid = kEPMGuid;
+
+ ataInterface->Write(buf, 1);
+
+ return;
+ }
+ }
+} \ No newline at end of file
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
index a3f82275..b4e7b56d 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
@@ -27,6 +27,11 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
InitGOP(); // Quick Toolkit for UI
BTextWriter writer;
+ BDeviceATA ataDrv;
+
+ Char namePart[kEPMNameLength] = { "NewKernel Standard System" };
+
+ boot_try_write_partition_map(namePart, kEPMNameLength, &ataDrv);
/// Splash screen stuff