diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-26 05:37:44 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-26 05:37:44 +0100 |
| commit | 0d6df50e386dae373c654522d241330a8a42412b (patch) | |
| tree | 004fba8b1bd513154cb925450c76ae1e011b86f8 | |
| parent | 1cd930c0c72f215101300dfcc5860800a474362d (diff) | |
NewBoot: Fully Implemented an EPM drive, needs now to write the layout
found inside Private/Rooot inside the epm.img, so that the user can
install it.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
| -rw-r--r-- | Private/FSKit/NewFS.hxx | 6 | ||||
| -rw-r--r-- | Private/FirmwareKit/EPM.hxx | 1 | ||||
| -rw-r--r-- | Private/KernelKit/HError.hpp | 1 | ||||
| -rw-r--r-- | Private/NewBoot/BootKit/BootKit.hxx | 2 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx | 50 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootMain.cxx | 2 | ||||
| -rw-r--r-- | Public/Developer/System.Core/Headers/File.hxx | 32 |
7 files changed, 74 insertions, 20 deletions
diff --git a/Private/FSKit/NewFS.hxx b/Private/FSKit/NewFS.hxx index b82bde9e..8e306180 100644 --- a/Private/FSKit/NewFS.hxx +++ b/Private/FSKit/NewFS.hxx @@ -54,6 +54,10 @@ #define kNewFSCatalogKindPage 8 +#define kNewFSPartitionTypeStandard 7 +#define kNewFSPartitionTypePage 8 +#define kNewFSPartitionTypeBoot 9 + #define kNewFSCatalogKindDevice 9 #define kNewFSCatalogKindLock 10 @@ -182,7 +186,7 @@ class NewFSParser { HCORE_COPY_DEFAULT(NewFSParser); public: - virtual _Output NewFork* ForkFrom(NewCatalog& catalog, const Int64& id) = 0; + virtual _Output NewFork* GetForkFrom(NewCatalog& catalog, const Char* name) = 0; virtual _Output NewCatalog* FindCatalog(const char* catalogName) = 0; diff --git a/Private/FirmwareKit/EPM.hxx b/Private/FirmwareKit/EPM.hxx index 97ff8a57..0746a050 100644 --- a/Private/FirmwareKit/EPM.hxx +++ b/Private/FirmwareKit/EPM.hxx @@ -96,6 +96,7 @@ typedef struct PartitionBlock PartitionBlockType; #define kEPMMagic kEPMMagicError #endif +/// partition must start after this address. #define kEPMStartPartition 1024 /// END SPECS diff --git a/Private/KernelKit/HError.hpp b/Private/KernelKit/HError.hpp index af498520..4b943296 100644 --- a/Private/KernelKit/HError.hpp +++ b/Private/KernelKit/HError.hpp @@ -30,6 +30,7 @@ inline constexpr HError kErrorFileExists = 46; inline constexpr HError kErrorFormatFailed = 47; inline constexpr HError kErrorNetworkTimeout = 48; inline constexpr HError kErrorInternal = 49; +inline constexpr HError kErrorForkAlreadyExists = 50; inline constexpr HError kErrorUnimplemented = 0; Boolean ke_bug_check(void) noexcept; diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx index 7012767c..dbdbb072 100644 --- a/Private/NewBoot/BootKit/BootKit.hxx +++ b/Private/NewBoot/BootKit/BootKit.hxx @@ -205,4 +205,4 @@ class BVersionString final { static const CharacterTypeUTF16 *Shared() { return BOOTLOADER_VERSION; } }; -Void boot_try_read_partition_map(const Char* namePart, SizeT namePartLength, BDeviceATA* ataInterface); +Void boot_write_newfs_partition(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 da28a3f3..d59adc48 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx @@ -5,6 +5,7 @@ ------------------------------------------- */ #include <BootKit/BootKit.hxx> +#include <FSKit/NewFS.hxx> // {310E1FC7-2060-425D-BE7B-75A37CC679BC} STATIC const BlockGUID kEPMGuid = { @@ -13,8 +14,8 @@ STATIC const BlockGUID kEPMGuid = { 0x425d, {0xbe, 0x7b, 0x75, 0xa3, 0x7c, 0xc6, 0x79, 0xbc}}; -Void boot_try_read_partition_map(const Char* namePart, SizeT namePartLength, - BDeviceATA* ataInterface) { +Void boot_write_newfs_partition(const Char* namePart, SizeT namePartLength, + BDeviceATA* ataInterface) { if (namePartLength > kEPMNameLength || !namePart) return; if (!ataInterface) return; @@ -53,6 +54,51 @@ Void boot_try_read_partition_map(const Char* namePart, SizeT namePartLength, bootBlock->Uuid = kEPMGuid; + PartitionBlock* partBlock = (PartitionBlock*)(buf + sizeof(BootBlock)); + + char* fsName = "NewFS"; + int fsNameLength = 6; + + for (SizeT i = 0; i < fsNameLength; i++) { + partBlock->Fs[i] = fsName[i]; + } + + partBlock->Magic = kEPMHCore; + + char* partName = "System HD"; + int partNameLength = 10; + + for (SizeT i = 0; i < partNameLength; i++) { + partBlock->Name[i] = partName[i]; + } + + partBlock->SectorSz = kATASectorSize; + partBlock->SectorStart = kEPMStartPartition + MIB(4); + partBlock->Version = kNewFSVersionInteger; + partBlock->Type = kNewFSPartitionTypeStandard; + partBlock->SectorEnd = 0; /// grows on the disk. + + PartitionBlock* swapBlock = (PartitionBlock*)(buf + sizeof(BootBlock) + sizeof(PartitionBlock)); + + for (SizeT i = 0; i < fsNameLength; i++) { + swapBlock->Fs[i] = fsName[i]; + } + + swapBlock->Magic = kEPMHCore; + + partName = "Swap HD"; + partNameLength = 8; + + for (SizeT i = 0; i < partNameLength; i++) { + swapBlock->Name[i] = partName[i]; + } + + swapBlock->SectorSz = kATASectorSize; + swapBlock->SectorStart = kEPMStartPartition; + swapBlock->Version = kNewFSVersionInteger; + swapBlock->Type = kNewFSPartitionTypeBoot; + swapBlock->SectorEnd = MIB(4); /// 4 MIB swap partition. + ataInterface->Write(buf, 1); return; diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx index 21481f85..3766e23f 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx @@ -49,7 +49,7 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, Char namePart[kEPMNameLength] = { "BootBlock" }; /// tries to read an EPM block, or writes one if it fails. - boot_try_read_partition_map(namePart, kEPMNameLength, &ataDrv); + boot_write_newfs_partition(namePart, kEPMNameLength, &ataDrv); } /// Read Kernel blob. diff --git a/Public/Developer/System.Core/Headers/File.hxx b/Public/Developer/System.Core/Headers/File.hxx index f76dbb60..3d3abf13 100644 --- a/Public/Developer/System.Core/Headers/File.hxx +++ b/Public/Developer/System.Core/Headers/File.hxx @@ -48,38 +48,40 @@ class FileInterface final { CA_COPY_DEFAULT(FileInterface); public: - PtrVoidType Read(UIntPtrType off, SizeType sz) { + PtrVoidType ReadFork(const CharacterTypeUTF8* name, UIntPtrType off, SizeType sz) { return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle, - 2, off, sz); + 2, name, off, sz); } - PtrVoidType Read(SizeType sz) { + PtrVoidType ReadFork(const CharacterTypeUTF8* name, SizeType sz) { return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle, - 3, sz); + name, 3, sz); } - void Write(PtrVoidType buf, UIntPtrType off, SizeType sz) { - kApplicationObject->Invoke(kApplicationObject, mHandle, 4, buf, off, sz); + void WriteFork(const CharacterTypeUTF8* name, PtrVoidType buf, UIntPtrType off, SizeType sz) { + kApplicationObject->Invoke(kApplicationObject, mHandle, 4, name, buf, off, sz); } - void Write(PtrVoidType buf, SizeType sz) { - kApplicationObject->Invoke(kApplicationObject, mHandle, 5, buf, sz); + void WriteFork(const CharacterTypeUTF8* name, PtrVoidType buf, SizeType sz) { + kApplicationObject->Invoke(kApplicationObject, mHandle, 5, name, buf, sz); } - void Seek(UIntPtrType off) { - kApplicationObject->Invoke(kApplicationObject, mHandle, 5); + void SeekFork(const CharacterTypeUTF8* name) { + kApplicationObject->Invoke(kApplicationObject, mHandle, 6, name); } - void Rewind() { kApplicationObject->Invoke(kApplicationObject, mHandle, 6); } + void RewindFork() { kApplicationObject->Invoke(kApplicationObject, mHandle, 7); } public: - const char *MIME() { + const CharacterTypeUTF8 *MIME() { return (const char *)kApplicationObject->Invoke(kApplicationObject, mHandle, - 7); + 8); } - void MIME(const char *mime) { - kApplicationObject->Invoke(kApplicationObject, mHandle, 8, mime); + void MIME(const CharacterTypeUTF8 *mime) { + CA_MUST_PASS(mime); + + kApplicationObject->Invoke(kApplicationObject, mHandle, 9, mime); } private: |
