summaryrefslogtreecommitdiffhomepage
path: root/dev/ZBA
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-09-05 14:42:03 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-09-05 14:42:03 +0200
commit432e68391357423914547a7b34311258d7598808 (patch)
treec2f7eeb45f99b910122257d1a9c2bcfcda4bddb3 /dev/ZBA
parent3e2b931d65582284e9716c42a902cab6d279c7f0 (diff)
[ FIX ] Fixing shortcomings of scheduler, filesystem and kernel.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZBA')
-rw-r--r--dev/ZBA/BootKit/BootKit.hxx77
-rw-r--r--dev/ZBA/Modules/SysChk/build.json2
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootMain.cxx58
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx8
4 files changed, 56 insertions, 89 deletions
diff --git a/dev/ZBA/BootKit/BootKit.hxx b/dev/ZBA/BootKit/BootKit.hxx
index 6ac87b82..3732ea8d 100644
--- a/dev/ZBA/BootKit/BootKit.hxx
+++ b/dev/ZBA/BootKit/BootKit.hxx
@@ -15,10 +15,10 @@
#include <FirmwareKit/EPM.hxx>
#include <CompilerKit/Version.hxx>
-/// include NewFS header and Support header as well.
+/// include NeFS header and Support header as well.
#include <cstring>
-#include <FSKit/NewFS.hxx>
+#include <FSKit/NeFS.hxx>
#include <BootKit/Support.hxx>
/***********************************************************************************/
@@ -193,7 +193,7 @@ public:
/// @brief File entry for **BDiskFormatFactory**.
struct BFileDescriptor final
{
- Char fFileName[kNewFSNodeNameLen];
+ Char fFileName[kNeFSNodeNameLen];
Int32 fKind;
};
@@ -219,7 +219,7 @@ public:
/// @brief check if partition is good.
Bool IsPartitionValid() noexcept
{
- fDiskDev.Leak().mBase = (kNewFSRootCatalogStartAddress);
+ fDiskDev.Leak().mBase = (kNeFSRootCatalogStartAddress);
fDiskDev.Leak().mSize = BootDev::kSectorSize;
Char buf[BootDev::kSectorSize] = {0};
@@ -230,9 +230,9 @@ public:
BTextWriter writer;
- for (SizeT indexMag = 0UL; indexMag < kNewFSIdentLen; ++indexMag)
+ for (SizeT indexMag = 0UL; indexMag < kNeFSIdentLen; ++indexMag)
{
- if (blockPart->Ident[indexMag] != kNewFSIdent[indexMag])
+ if (blockPart->Ident[indexMag] != kNeFSIdent[indexMag])
return false;
}
@@ -241,7 +241,7 @@ public:
if (blockPart->DiskSize != this->fDiskDev.GetDiskSize() ||
blockPart->DiskSize < 1 ||
blockPart->SectorSize != BootDev::kSectorSize ||
- blockPart->Version != kNewFSVersionInteger ||
+ blockPart->Version != kNeFSVersionInteger ||
blockPart->StartCatalog == 0)
{
return false;
@@ -260,7 +260,7 @@ private:
/// @brief Write all of the requested catalogs into the filesystem.
/// @param fileBlobs the blobs.
/// @param blobCount the number of blobs to write.
- /// @param partBlock the NewFS partition block.
+ /// @param partBlock the NeFS partition block.
Boolean WriteRootCatalog(BFileDescriptor* fileBlobs, SizeT blobCount, NFS_ROOT_PARTITION_BLOCK& partBlock)
{
BFileDescriptor* blob = fileBlobs;
@@ -269,14 +269,14 @@ private:
NFS_CATALOG_STRUCT catalogKind{0};
- constexpr auto cNewFSCatalogPadding = 4;
+ constexpr auto cNeFSCatalogPadding = 4;
catalogKind.PrevSibling = startLba;
- catalogKind.NextSibling = (startLba + sizeof(NFS_CATALOG_STRUCT) * cNewFSCatalogPadding);
+ catalogKind.NextSibling = (startLba + sizeof(NFS_CATALOG_STRUCT) * cNeFSCatalogPadding);
/// Fill catalog kind.
catalogKind.Kind = blob->fKind;
- catalogKind.Flags = kNewFSFlagCreated;
+ catalogKind.Flags = kNeFSFlagCreated;
--partBlock.FreeCatalog;
--partBlock.FreeSectors;
@@ -316,7 +316,7 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const Char* partName,
/// @note A catalog roughly equal to a sector.
- constexpr auto cMinimumDiskSize = 10; // at minimum.
+ constexpr auto cMinimumDiskSize = 4; // at minimum.
/// @note also look at EPM headers, for free part blocks.
@@ -325,70 +325,37 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const Char* partName,
EFI::ThrowError(L"Disk-Too-Tiny", L"Can't format a New Filesystem partition here.");
return false;
}
-
- fDiskDev.Leak().mBase = kNewFSRootCatalogStartAddress;
- fDiskDev.Leak().mSize = sectorSz;
-
+
NFS_ROOT_PARTITION_BLOCK partBlock{0};
- fDiskDev.Read((Char*)&partBlock, sizeof(NFS_ROOT_PARTITION_BLOCK));
-
- if (strncmp(kNewFSIdent, partBlock.Ident, kNewFSIdentLen) == 0 &&
- partBlock.Version != kNewFSVersionInteger)
- {
- if (partBlock.Version != 0)
- {
- BTextWriter writer;
- writer.Write(L"newosldr: Disk partition updated.\r");
-
- partBlock.Version = kNewFSVersionInteger;
-
- fDiskDev.Leak().mBase = kNewFSRootCatalogStartAddress;
- fDiskDev.Leak().mSize = sectorSz;
-
- fDiskDev.Write((Char*)&partBlock, sectorSz);
-
- return true;
- }
- }
- else if (strncmp(kNewFSIdent, partBlock.Ident, kNewFSIdentLen))
- {
- BTextWriter writer;
- writer.Write(L"newosldr: Disk partition error, not a valid one.\r");
-
- // TODO: Find a way to use EFI::Stop.
- while (1)
- ;
- }
-
- CopyMem(partBlock.Ident, kNewFSIdent, kNewFSIdentLen - 1);
+ CopyMem(partBlock.Ident, kNeFSIdent, kNeFSIdentLen - 1);
CopyMem(partBlock.PartitionName, partName, strlen(partName));
- partBlock.Version = kNewFSVersionInteger;
+ partBlock.Version = kNeFSVersionInteger;
partBlock.CatalogCount = blobCount;
- partBlock.Kind = kNewFSHardDrive;
+ partBlock.Kind = kNeFSHardDrive;
partBlock.SectorSize = sectorSz;
partBlock.FreeCatalog = fDiskDev.GetSectorsCount() / sizeof(NFS_CATALOG_STRUCT);
partBlock.SectorCount = fDiskDev.GetSectorsCount();
partBlock.FreeSectors = fDiskDev.GetSectorsCount();
- partBlock.StartCatalog = kNewFSCatalogStartAddress;
+ partBlock.StartCatalog = kNeFSCatalogStartAddress;
partBlock.DiskSize = fDiskDev.GetDiskSize();
- partBlock.Flags = kNewFSPartitionTypeBoot | kNewFSPartitionTypeStandard;
+ partBlock.Flags = kNeFSPartitionTypeBoot | kNeFSPartitionTypeStandard;
- fDiskDev.Leak().mBase = kNewFSRootCatalogStartAddress;
+ fDiskDev.Leak().mBase = kNeFSRootCatalogStartAddress;
fDiskDev.Leak().mSize = sectorSz;
fDiskDev.Write((Char*)&partBlock, sectorSz);
BOOT_BLOCK_STRUCT epmBoot{0};
- constexpr auto cFsName = "NewFS";
+ constexpr auto cFsName = "NeFS";
constexpr auto cBlockName = "ZKA:";
CopyMem(epmBoot.Fs, reinterpret_cast<VoidPtr>(const_cast<Char*>(cFsName)), StrLen(cFsName));
- epmBoot.FsVersion = kNewFSVersionInteger;
- epmBoot.LbaStart = kNewFSRootCatalogStartAddress;
+ epmBoot.FsVersion = kNeFSVersionInteger;
+ epmBoot.LbaStart = kNeFSRootCatalogStartAddress;
epmBoot.SectorSz = partBlock.SectorSize;
epmBoot.NumBlocks = partBlock.CatalogCount;
diff --git a/dev/ZBA/Modules/SysChk/build.json b/dev/ZBA/Modules/SysChk/build.json
index dac413e0..67e22955 100644
--- a/dev/ZBA/Modules/SysChk/build.json
+++ b/dev/ZBA/Modules/SysChk/build.json
@@ -11,7 +11,7 @@
"-fPIC",
"-fno-rtti",
"-fno-exceptions",
- "-Wl,--subsystem=17,--image-base,0x1000000,-e,ModuleMain"
+ "-Wl,--subsystem=17,--image-base,0x10000000,-e,ModuleMain"
],
"cpp_macros": [
"__NEWOSKRNL__",
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
index 55f10ea2..9cccc922 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
@@ -154,6 +154,27 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
handoverHdrPtr->f_HardwareTables.f_MultiProcessingEnabled = cnt_enabled > 1;
// Fill handover header now.
+ BDiskFormatFactory<BootDeviceATA> checkPart;
+
+ // ---------------------------------------------------- //
+ // The following checks for an exisiting partition
+ // inside the disk, if it doesn't have one,
+ // format the disk.
+ // ---------------------------------------------------- //
+
+ if (!checkPart.IsPartitionValid())
+ {
+ BDiskFormatFactory<BootDeviceATA>::BFileDescriptor root;
+ root.fFileName[0] = kNeFSRoot[0];
+ root.fFileName[1] = 0;
+
+ root.fKind = kNeFSCatalogKindDir;
+
+ checkPart.Format("ZKA (A:)", &root, 1);
+
+ rt_reset_hardware();
+ }
+
BS->GetMemoryMap(&SizePtr, Descriptor, &MapKey, &SzDesc, &RevDesc);
Descriptor = new EfiMemoryDescriptor[SzDesc];
@@ -193,15 +214,9 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
while (BS->AllocatePool(EfiRuntimeServicesData, kHandoverHeapSz, &handoverHdrPtr->f_BitMapStart) != kEfiOk)
;
- auto extended_heap = (VoidPtr)((UIntPtr)handoverHdrPtr->f_BitMapStart + kHandoverHeapSz);
-
- while (BS->AllocatePool(EfiRuntimeServicesData, kHandoverHeapSz, &extended_heap) != kEfiOk)
- ;
-
handoverHdrPtr->f_VirtualSize =
Descriptor[cDefaultMemoryMap].NumberOfPages; /* # of pages */
-
handoverHdrPtr->f_FirmwareCustomTables[0] = (VoidPtr)BS;
handoverHdrPtr->f_FirmwareCustomTables[1] = (VoidPtr)ST;
@@ -241,27 +256,6 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
// Assign to global 'kHandoverHeader'.
- BDiskFormatFactory<BootDeviceATA> checkPart;
-
- // ---------------------------------------------------- //
- // The following checks for an exisiting partition
- // inside the disk, if it doesn't have one,
- // format the disk.
- // ---------------------------------------------------- //
-
- if (!checkPart.IsPartitionValid())
- {
- BDiskFormatFactory<BootDeviceATA>::BFileDescriptor root;
- root.fFileName[0] = kNewFSRoot[0];
- root.fFileName[1] = 0;
-
- root.fKind = kNewFSCatalogKindDir;
-
- checkPart.Format("ZKA (A:)", &root, 1);
-
- rt_reset_hardware();
- }
-
BFileReader readerKernel(L"newoskrnl.exe", ImageHandle);
readerKernel.ReadAll(0);
@@ -293,11 +287,17 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
urbanistTTF.ReadAll(0);
if (readerSysDrv.Blob() &&
- chimeWav.Blob())
+ chimeWav.Blob() &&
+ urbanistTTF.Blob())
{
handoverHdrPtr->f_StartupChime = chimeWav.Blob();
- handoverHdrPtr->f_StartupImage = readerKernel.Blob();
+ handoverHdrPtr->f_ChimeSz = chimeWav.Size();
+ handoverHdrPtr->f_StartupImage = readerSysDrv.Blob();
+ handoverHdrPtr->f_StartupSz = readerSysDrv.Size();
+ handoverHdrPtr->f_KernelImage = readerKernel.Blob();
+ handoverHdrPtr->f_KernelSz = readerKernel.Size();
handoverHdrPtr->f_TTFallbackFont = urbanistTTF.Blob();
+ handoverHdrPtr->f_FontSz = urbanistTTF.Size();
}
else
{
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx b/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx
index 65ea3d89..467f4303 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx
@@ -25,7 +25,7 @@
*/
BTextWriter& BTextWriter::Write(const CharacterTypeUTF16* str)
{
-#ifdef __DEBUG_OUTPUT__
+#ifdef __DEBUG__
if (!str || *str == 0)
return *this;
@@ -57,7 +57,7 @@ BTextWriter& BTextWriter::Write(const CharacterTypeUTF16* str)
/// @param str the input string.
BTextWriter& BTextWriter::Write(const Char* str)
{
-#ifdef __DEBUG_OUTPUT__
+#ifdef __DEBUG__
if (!str || *str == 0)
return *this;
@@ -87,7 +87,7 @@ BTextWriter& BTextWriter::Write(const Char* str)
BTextWriter& BTextWriter::Write(const UChar* str)
{
-#ifdef __DEBUG_OUTPUT__
+#ifdef __DEBUG__
if (!str || *str == 0)
return *this;
@@ -120,7 +120,7 @@ BTextWriter& BTextWriter::Write(const UChar* str)
*/
BTextWriter& BTextWriter::WriteCharacter(CharacterTypeUTF16 c)
{
-#ifdef __DEBUG_OUTPUT__
+#ifdef __DEBUG__
EfiCharType str[2];
str[0] = c;