summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dev/ZBA/BootKit/BootKit.hxx58
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/Support.cxx2
-rw-r--r--dev/ZKA/FSKit/NewFS.hxx4
-rw-r--r--dev/ZKA/Sources/DLLMain.cxx4
-rw-r--r--dev/ZKA/Sources/FS/NewFS.cxx22
-rw-r--r--doc/NewFS.pdfbin0 -> 13654 bytes
6 files changed, 61 insertions, 29 deletions
diff --git a/dev/ZBA/BootKit/BootKit.hxx b/dev/ZBA/BootKit/BootKit.hxx
index 59b222c9..1d0dca94 100644
--- a/dev/ZBA/BootKit/BootKit.hxx
+++ b/dev/ZBA/BootKit/BootKit.hxx
@@ -271,8 +271,8 @@ private:
constexpr auto cNewFSCatalogPadding = 4;
- catalogKind.PrevSibling = startLba;
- catalogKind.NextSibling = (startLba + sizeof(NFS_CATALOG_STRUCT) * cNewFSCatalogPadding);
+ catalogKind.PrevSibling = startLba;
+ catalogKind.NextSibling = (startLba + sizeof(NFS_CATALOG_STRUCT) * cNewFSCatalogPadding);
/// Fill catalog kind.
catalogKind.Kind = blob->fKind;
@@ -313,10 +313,6 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const Char* partName,
/// convert the sector into something that the disk understands.
SizeT sectorSz = BootDev::kSectorSize;
- NFS_ROOT_PARTITION_BLOCK partBlock{0};
-
- CopyMem(partBlock.Ident, kNewFSIdent, kNewFSIdentLen - 1);
- CopyMem(partBlock.PartitionName, partName, strlen(partName));
/// @note A catalog roughly equal to a sector.
@@ -330,16 +326,50 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const Char* partName,
return false;
}
- partBlock.Version = kNewFSVersionInteger;
+ 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)
+ {
+ 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.PartitionName, partName, strlen(partName));
+
+ partBlock.Version = kNewFSVersionInteger;
partBlock.CatalogCount = blobCount;
- partBlock.Kind = kNewFSHardDrive;
- partBlock.SectorSize = sectorSz;
- partBlock.FreeCatalog = fDiskDev.GetSectorsCount() / sizeof(NFS_CATALOG_STRUCT);
- partBlock.SectorCount = fDiskDev.GetSectorsCount();
- partBlock.FreeSectors = fDiskDev.GetSectorsCount();
+ partBlock.Kind = kNewFSHardDrive;
+ partBlock.SectorSize = sectorSz;
+ partBlock.FreeCatalog = fDiskDev.GetSectorsCount() / sizeof(NFS_CATALOG_STRUCT);
+ partBlock.SectorCount = fDiskDev.GetSectorsCount();
+ partBlock.FreeSectors = fDiskDev.GetSectorsCount();
partBlock.StartCatalog = kNewFSCatalogStartAddress;
- partBlock.DiskSize = fDiskDev.GetDiskSize();
- partBlock.Flags |= kNewFSPartitionTypeBoot | kNewFSPartitionTypeStandard;
+ partBlock.DiskSize = fDiskDev.GetDiskSize();
+ partBlock.Flags = kNewFSPartitionTypeBoot | kNewFSPartitionTypeStandard;
fDiskDev.Leak().mBase = kNewFSRootCatalogStartAddress;
fDiskDev.Leak().mSize = sectorSz;
diff --git a/dev/ZBA/Sources/HEL/AMD64/Support.cxx b/dev/ZBA/Sources/HEL/AMD64/Support.cxx
index 667bbfda..aa93318b 100644
--- a/dev/ZBA/Sources/HEL/AMD64/Support.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/Support.cxx
@@ -71,7 +71,7 @@ EXTERN_C int strcmp(const char* whatToCheck, const char* whatToCheckRight)
++len;
}
- return whatToCheck[len] == whatToCheckRight[len] ? 0 : len;
+ return len;
}
/// @brief somthing specific to the Microsoft's ABI, When the stack grows too big.
diff --git a/dev/ZKA/FSKit/NewFS.hxx b/dev/ZKA/FSKit/NewFS.hxx
index 4912c96e..c3ae7091 100644
--- a/dev/ZKA/FSKit/NewFS.hxx
+++ b/dev/ZKA/FSKit/NewFS.hxx
@@ -39,8 +39,8 @@ default.
#define kNewFSMetaFilePrefix '$'
-#define kNewFSVersionInteger (0x0127)
-#define kNewFSVerionString "1.27"
+#define kNewFSVersionInteger (0x0128)
+#define kNewFSVerionString "1.28"
/// @brief Standard fork types.
#define kNewFSDataFork "main_data"
diff --git a/dev/ZKA/Sources/DLLMain.cxx b/dev/ZKA/Sources/DLLMain.cxx
index a82d0b97..8562ba09 100644
--- a/dev/ZKA/Sources/DLLMain.cxx
+++ b/dev/ZKA/Sources/DLLMain.cxx
@@ -90,7 +90,7 @@ namespace Kernel::Detail
kNewFSCatalogKindDir);
CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.dll: Catalog directory has been created: ", 10 + (10 * (dirIndx + 1)), 10, RGB(0, 0, 0));
- CG::CGDrawStringToWnd(cKernelWnd, catalogDir->Name, 10 + (10 * (dirIndx + 1)), 10 + (FONT_SIZE_X * rt_string_len("newoskrnl.dll: Catalog has been created: ")), RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, catalogDir->Name, 10 + (10 * (dirIndx + 1)), 10 + (FONT_SIZE_X * rt_string_len("newoskrnl.dll: Catalog directory has been created: ")), RGB(0, 0, 0));
delete catalogDir;
}
@@ -211,7 +211,7 @@ EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void)
CG::CGDrawStringToWnd(cKernelWnd, kSysDrv, 20, 10 + (FONT_SIZE_X * Kernel::rt_string_len("newoskrnl.dll: Missing catalog: ")), RGB(0, 0, 0));
}
- CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.dll: Starting the scheduler...", 30, 10, RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.dll: Starting ZKA...", 30, 10, RGB(0, 0, 0));
while (Yes)
{
diff --git a/dev/ZKA/Sources/FS/NewFS.cxx b/dev/ZKA/Sources/FS/NewFS.cxx
index cdf9d6a4..5406f91c 100644
--- a/dev/ZKA/Sources/FS/NewFS.cxx
+++ b/dev/ZKA/Sources/FS/NewFS.cxx
@@ -63,7 +63,7 @@ _Output NFS_FORK_STRUCT* NewFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* cata
_Input NFS_FORK_STRUCT& theFork)
{
if (catalog && theFork.ForkName[0] != 0 &&
- theFork.DataSize <= kNewFSForkSz)
+ theFork.DataSize <= kNewFSForkSz)
{
Lba lba = (theFork.Kind == kNewFSDataForkKind) ? catalog->DataFork
: catalog->ResourceFork;
@@ -381,7 +381,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
}
// ========================== //
- // allocate catalog now...
+ // Allocate catalog now...
// ========================== //
if ((nextSibling->Flags & kNewFSFlagCreated) == 0)
{
@@ -406,10 +406,13 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
catalogChild->DataFork = partBlock->DiskSize - start_free;
catalogChild->ResourceFork = catalogChild->DataFork;
- catalogChild->NextSibling =
- start_free + (sizeof(NFS_CATALOG_STRUCT) * cNewFSCatalogPadding);
-
- // write the new catalog.
+ // Write the new catalog next sibling, if we don't know this parent. //
+ // This is necessary, so that we don't have to get another lba to allocate. //
+ if (!StringBuilder::Equals(parentName, nextSibling->Name))
+ {
+ catalogChild->NextSibling =
+ start_free + (sizeof(NFS_CATALOG_STRUCT) * cNewFSCatalogPadding);
+ }
drive.fPacket.fPacketContent = catalogChild;
drive.fPacket.fPacketSize = sizeof(NFS_CATALOG_STRUCT);
@@ -417,7 +420,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
drive.fOutput(&drive.fPacket);
- // get newfs part block.
+ // Get NewFS partition's block.
drive.fPacket.fPacketContent = sectorBufPartBlock;
drive.fPacket.fPacketSize = kNewFSSectorSz;
@@ -425,10 +428,9 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
drive.fInput(&drive.fPacket);
- partBlock->SectorCount -= 1;
+ partBlock->FreeSectors -= 1;
partBlock->CatalogCount += 1;
partBlock->FreeCatalog -= 1;
- partBlock->FreeCatalog = catalogChild->NextSibling;
drive.fOutput(&drive.fPacket);
@@ -904,8 +906,8 @@ Boolean NewFSParser::RemoveCatalog(_Input const Char* catalogName)
NFS_ROOT_PARTITION_BLOCK* partBlock =
reinterpret_cast<NFS_ROOT_PARTITION_BLOCK*>(partitionBlockBuf);
- ++partBlock->FreeCatalog;
--partBlock->CatalogCount;
+ ++partBlock->FreeSectors;
drive.fOutput(&drive.fPacket);
diff --git a/doc/NewFS.pdf b/doc/NewFS.pdf
new file mode 100644
index 00000000..a2193504
--- /dev/null
+++ b/doc/NewFS.pdf
Binary files differ