summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Private/FirmwareKit/EPM.hxx2
-rw-r--r--Private/NewBoot/Source/CDROM/INSTALLER/.gitkeep0
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootCustomPart.cxx38
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx16
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootMain.cxx8
-rw-r--r--Private/NewBoot/Source/makefile1
6 files changed, 57 insertions, 8 deletions
diff --git a/Private/FirmwareKit/EPM.hxx b/Private/FirmwareKit/EPM.hxx
index 34346a97..7dab6edc 100644
--- a/Private/FirmwareKit/EPM.hxx
+++ b/Private/FirmwareKit/EPM.hxx
@@ -101,7 +101,7 @@ typedef struct PartitionBlock PartitionBlockType;
#endif
/// partition must start after this address.
-#define kEPMStartPartition 1024
+#define kEPMStartPartitionBlk 34
/// END SPECS
diff --git a/Private/NewBoot/Source/CDROM/INSTALLER/.gitkeep b/Private/NewBoot/Source/CDROM/INSTALLER/.gitkeep
deleted file mode 100644
index e69de29b..00000000
--- a/Private/NewBoot/Source/CDROM/INSTALLER/.gitkeep
+++ /dev/null
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootCustomPart.cxx b/Private/NewBoot/Source/HEL/AMD64/BootCustomPart.cxx
new file mode 100644
index 00000000..2e811f5f
--- /dev/null
+++ b/Private/NewBoot/Source/HEL/AMD64/BootCustomPart.cxx
@@ -0,0 +1,38 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <BootKit/BootKit.hxx>
+#include <FSKit/NewFS.hxx>
+
+/// @brief Writes a NewOS partition on top of EPM
+/// @param ataInterface The drive interface.
+/// @return
+EXTERN_C Void boot_write_newos_specific_partition(BDeviceATA* ataInterface) {
+ ataInterface->Leak().mBase = 0;
+ ataInterface->Leak().mSize = 512;
+
+ Char newOSHeader[512] = {
+ /// signature of our system partition.
+ 'N', 'e', 'w', '!',
+ /// version of our os partition
+ (Char)0x10,
+
+ /// to retrieve the header size add these two fileds. (divided into parts.)
+
+ /// header size (pt 1)
+ (Char)0x100,
+ /// header size (pt 2)
+ (Char)0x100,
+ /// Reserved
+ (Char)0x00,
+ /// Current LBA.
+ (Char)0x00,
+ /// First usable LBA.
+ (Char)kEPMStartPartitionBlk,
+ };
+
+ ataInterface->Write(newOSHeader, 1);
+} \ No newline at end of file
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx
index 0d1d4086..e9bf7574 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx
@@ -7,6 +7,8 @@
#include <BootKit/BootKit.hxx>
#include <FSKit/NewFS.hxx>
+#define kSwapSize MIB(16)
+
// {310E1FC7-2060-425D-BE7B-75A37CC679BC}
STATIC const BlockGUID kEPMGuid = {
0x310e1fc7,
@@ -14,12 +16,14 @@ STATIC const BlockGUID kEPMGuid = {
0x425d,
{0xbe, 0x7b, 0x75, 0xa3, 0x7c, 0xc6, 0x79, 0xbc}};
+EXTERN_C Void boot_write_newos_specific_partition(BDeviceATA*);
+
EXTERN_C Boolean boot_write_newfs_partition(const Char* namePart, SizeT namePartLength,
BDeviceATA* ataInterface) {
if (namePartLength > kEPMNameLength || !namePart) return No;
if (!ataInterface) return No;
- ataInterface->Leak().mBase = 0;
+ ataInterface->Leak().mBase = kEPMStartPartitionBlk;
ataInterface->Leak().mSize = kATASectorSize;
Char buf[512] = {0};
@@ -37,7 +41,7 @@ EXTERN_C Boolean boot_write_newfs_partition(const Char* namePart, SizeT namePart
BootBlockType* bootBlock = (BootBlockType*)buf;
bootBlock->Version = kEPMNewOS;
- bootBlock->NumBlocks = kEPMMaxBlks;
+ bootBlock->NumBlocks = 2;
for (SizeT i = 0; i < kEPMNameLength; i++) {
bootBlock->Magic[i] = kEPMMagic[i];
@@ -73,7 +77,7 @@ EXTERN_C Boolean boot_write_newfs_partition(const Char* namePart, SizeT namePart
}
partBlock->SectorSz = kATASectorSize;
- partBlock->SectorStart = kEPMStartPartition + MIB(16);
+ partBlock->SectorStart = kEPMStartPartitionBlk + kSwapSize;
partBlock->Version = kNewFSVersionInteger;
partBlock->Kind = kNewFSPartitionTypeStandard;
partBlock->SectorEnd = 0; /// grows on the disk.
@@ -94,13 +98,15 @@ EXTERN_C Boolean boot_write_newfs_partition(const Char* namePart, SizeT namePart
}
swapBlock->SectorSz = kATASectorSize;
- swapBlock->SectorStart = kEPMStartPartition;
+ swapBlock->SectorStart = kEPMStartPartitionBlk;
swapBlock->Version = kNewFSVersionInteger;
swapBlock->Kind = kNewFSPartitionTypePage;
- swapBlock->SectorEnd = MIB(16); /// 4 MIB swap partition.
+ swapBlock->SectorEnd = kSwapSize; /// 4 MIB swap partition.
ataInterface->Write(buf, 1);
+ boot_write_newos_specific_partition(ataInterface);
+
return No;
}
}
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
index 21cc4b92..e9c900ba 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
@@ -44,12 +44,18 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
BDeviceATA ataDrv;
Boolean isIniNotFound = No;
- if (ataDrv) {
+ /// if ATA drive is initialized and EFI vendor supports an EPM scheme.
+ /// @EDK tells our OS that it supports EPM scheme as well.
+ if (ataDrv &&
+ SystemTable->FirmwareVendor[0] == '@') {
Char namePart[kEPMNameLength] = {"BootBlock"};
/// tries to read an EPM block, or writes one if it fails.
bool isIniNotFound =
boot_write_newfs_partition(namePart, kEPMNameLength, &ataDrv);
+ } else if (SystemTable->FirmwareVendor[0] != '@') {
+ writer.Write(L"This firmware can't understand NewOS, please use Mahrouss Logic products instead\r\nOur website: www.el-mahrouss-logic.com\r\n");
+ return kEfiFail;
}
/// Read Kernel blob.
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index 78d5f663..af35a110 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -37,7 +37,6 @@ 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/NEWBOOT.EFI
- $(COPY) ../../NewKernel.exe CDROM/INSTALLER/
.PHONY: compile-amd64
compile-amd64: