summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal <amlalelmahrouss@icloud.com>2024-09-05 19:13:02 +0000
committerAmlal <amlalelmahrouss@icloud.com>2024-09-05 19:13:02 +0000
commit621e814da6d5005ade8a1fe3f378a363db559cf7 (patch)
tree438f1337c0eb2ae83cf3d409c29848d396be08b2
parentcc9ce57cac59bd443e2319e3b8f427172b93f7da (diff)
parent3b60a1e87ab02a1b72d8bb9f7392780899d5a0d7 (diff)
Merged in major-refactor (pull request #19)
Major refactor
-rw-r--r--.vscode/c_cpp_properties.json4
-rw-r--r--dev/DLL/EncryptFS/EncryptFS.hxx2
-rw-r--r--dev/HPFS/.gitignore3
-rw-r--r--dev/HPFS/Sources/IFSMain.rs12
-rw-r--r--dev/HPFS/X64/EBS.asm29
-rw-r--r--dev/HPFS/hpfs.json11
-rw-r--r--dev/INST/.keepme (renamed from dev/INSTALL/.keepme)0
-rw-r--r--dev/INST/ReadMe.txt (renamed from dev/INSTALL/ReadMe.txt)0
-rw-r--r--dev/INST/X64/InstallAPI.asm (renamed from dev/INSTALL/X64/InstallAPI.asm)0
-rw-r--r--dev/ZBA/BootKit/BootKit.hxx81
-rw-r--r--dev/ZBA/Modules/NetBoot/build.json2
-rw-r--r--dev/ZBA/Modules/SysChk/Module.cxx2
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootAPI.S (renamed from dev/ZBA/Sources/HEL/AMD64/BootJump.S)6
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootMain.cxx93
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx9
-rw-r--r--dev/ZBA/Sources/Thread.cxx2
-rw-r--r--dev/ZBA/amd64-efi.make4
-rw-r--r--dev/ZKA/ArchKit/ArchKit.hxx2
-rw-r--r--dev/ZKA/Docs/SPECIFICATION.md2
-rw-r--r--dev/ZKA/FSKit/HPFS.hxx (renamed from dev/ZKA/FSKit/FAT32.hxx)4
-rw-r--r--dev/ZKA/FSKit/IndexableProperty.hxx2
-rw-r--r--dev/ZKA/FSKit/NeFS.hxx (renamed from dev/ZKA/FSKit/NewFS.hxx)159
-rw-r--r--dev/ZKA/FirmwareKit/EPM.hxx2
-rw-r--r--dev/ZKA/FirmwareKit/Handover.hxx15
-rw-r--r--dev/ZKA/HALKit/AMD64/HalAPICMgr.cxx (renamed from dev/ZKA/HALKit/AMD64/HalAPIC.cxx)0
-rw-r--r--dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx103
-rw-r--r--dev/ZKA/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx22
-rw-r--r--dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx14
-rw-r--r--dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx20
-rw-r--r--dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm18
-rw-r--r--dev/ZKA/HALKit/AMD64/HalKernelMain.cxx29
-rw-r--r--dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm41
-rw-r--r--dev/ZKA/HALKit/AMD64/HalPageAlloc.cxx149
-rw-r--r--dev/ZKA/HALKit/AMD64/HalPageAlloc.hxx4
-rw-r--r--dev/ZKA/HALKit/AMD64/HalProcessor.cxx31
-rw-r--r--dev/ZKA/HALKit/AMD64/Processor.hxx28
-rw-r--r--dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx6
-rw-r--r--dev/ZKA/HALKit/AMD64/Storage/ATA-PIO.cxx6
-rw-r--r--dev/ZKA/HALKit/ARM64/HalKernelMain.cxx16
-rw-r--r--dev/ZKA/HALKit/ARM64/HalPageAlloc.hxx2
-rw-r--r--dev/ZKA/HALKit/ARM64/Processor.hxx1
-rw-r--r--dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx4
-rw-r--r--dev/ZKA/HALKit/AXP/CoreSyscallHandlerDEC.cpp4
-rw-r--r--dev/ZKA/HALKit/POWER/HalHardware.cxx19
-rw-r--r--dev/ZKA/KernelKit/CodeMgr.hxx (renamed from dev/ZKA/KernelKit/CodeManager.hxx)10
-rw-r--r--dev/ZKA/KernelKit/DebugOutput.hxx24
-rw-r--r--dev/ZKA/KernelKit/DeviceMgr.hxx (renamed from dev/ZKA/KernelKit/DeviceManager.hxx)6
-rw-r--r--dev/ZKA/KernelKit/DriveMgr.hxx (renamed from dev/ZKA/KernelKit/DriveManager.hxx)6
-rw-r--r--dev/ZKA/KernelKit/FileMgr.hxx (renamed from dev/ZKA/KernelKit/FileManager.hxx)50
-rw-r--r--dev/ZKA/KernelKit/HardwareThreadScheduler.hxx (renamed from dev/ZKA/KernelKit/MP.hxx)2
-rw-r--r--dev/ZKA/KernelKit/Heap.hxx8
-rw-r--r--dev/ZKA/KernelKit/IDLLObject.hxx (renamed from dev/ZKA/KernelKit/DLLInterface.hxx)13
-rw-r--r--dev/ZKA/KernelKit/IPEFDLLObject.hxx (renamed from dev/ZKA/KernelKit/PEFDLLInterface.hxx)18
-rw-r--r--dev/ZKA/KernelKit/PCI/Dma.hxx2
-rw-r--r--dev/ZKA/KernelKit/PECodeMgr.hxx (renamed from dev/ZKA/KernelKit/PECodeManager.hxx)4
-rw-r--r--dev/ZKA/KernelKit/PEFCodeMgr.hxx (renamed from dev/ZKA/KernelKit/PEFCodeManager.hxx)8
-rw-r--r--dev/ZKA/KernelKit/UserProcessScheduler.hxx47
-rw-r--r--dev/ZKA/NetworkKit/NetworkDevice.hxx2
-rw-r--r--dev/ZKA/NetworkKit/NetworkDevice.inl4
-rw-r--r--dev/ZKA/NewKit/KernelCheck.hxx3
-rw-r--r--dev/ZKA/NewKit/Macros.hxx23
-rw-r--r--dev/ZKA/NewKit/PageAllocator.hxx3
-rw-r--r--dev/ZKA/NewKit/PageMgr.hxx (renamed from dev/ZKA/NewKit/PageManager.hxx)22
-rw-r--r--dev/ZKA/NewKit/Pmm.hxx8
-rw-r--r--dev/ZKA/NewKit/Ref.hxx2
-rw-r--r--dev/ZKA/Sources/CodeMgr.cxx (renamed from dev/ZKA/Sources/CodeManager.cxx)4
-rw-r--r--dev/ZKA/Sources/CxxAbi-AMD64.cxx2
-rw-r--r--dev/ZKA/Sources/CxxAbi-ARM64.cxx2
-rw-r--r--dev/ZKA/Sources/DLLMain.cxx111
-rw-r--r--dev/ZKA/Sources/DeviceMgr.cxx (renamed from dev/ZKA/Sources/DeviceManager.cxx)2
-rw-r--r--dev/ZKA/Sources/DriveMgr.cxx (renamed from dev/ZKA/Sources/DriveManager.cxx)16
-rw-r--r--dev/ZKA/Sources/FS/FAT32.cxx4
-rw-r--r--dev/ZKA/Sources/FS/NeFS.cxx (renamed from dev/ZKA/Sources/FS/NewFS.cxx)295
-rw-r--r--dev/ZKA/Sources/FileMgr.cxx (renamed from dev/ZKA/Sources/FileManager.cxx)46
-rw-r--r--dev/ZKA/Sources/Framebuffer.cxx2
-rw-r--r--dev/ZKA/Sources/HardwareThreadScheduler.cxx (renamed from dev/ZKA/Sources/MP.cxx)41
-rw-r--r--dev/ZKA/Sources/Heap.cxx117
-rw-r--r--dev/ZKA/Sources/IDLLObject.cxx (renamed from dev/ZKA/Sources/DLLInterface.cxx)2
-rw-r--r--dev/ZKA/Sources/IPEFDLLObject.cxx (renamed from dev/ZKA/Sources/PEFDLLInterface.cxx)10
-rw-r--r--dev/ZKA/Sources/IndexableProperty.cxx2
-rw-r--r--dev/ZKA/Sources/KernelCheck.cxx20
-rw-r--r--dev/ZKA/Sources/NeFS+FileMgr.cxx (renamed from dev/ZKA/Sources/NewFS+FileManager.cxx)43
-rw-r--r--dev/ZKA/Sources/NeFS+IO.cxx (renamed from dev/ZKA/Sources/NewFS+IO.cxx)46
-rw-r--r--dev/ZKA/Sources/NewFS+Journal.cxx22
-rw-r--r--dev/ZKA/Sources/PEFCodeMgr.cxx (renamed from dev/ZKA/Sources/PEFCodeManager.cxx)4
-rw-r--r--dev/ZKA/Sources/PageAllocator.cxx13
-rw-r--r--dev/ZKA/Sources/PageMgr.cxx (renamed from dev/ZKA/Sources/PageManager.cxx)34
-rw-r--r--dev/ZKA/Sources/Pmm.cxx14
-rw-r--r--dev/ZKA/Sources/Storage/ATADeviceInterface.cxx4
-rw-r--r--dev/ZKA/Sources/ThreadLocalStorage.cxx10
-rw-r--r--dev/ZKA/Sources/User.cxx5
-rw-r--r--dev/ZKA/Sources/UserProcessScheduler.cxx215
-rw-r--r--dev/ZKA/Sources/UserProcessTeam.cxx (renamed from dev/ZKA/Sources/ProcessTeam.cxx)0
-rw-r--r--dev/ZKA/Sources/compile_flags.txt2
-rw-r--r--dev/ZKA/StorageKit/AHCI.hxx4
-rw-r--r--dev/ZKA/StorageKit/ATA.hxx4
-rw-r--r--dev/ZKA/StorageKit/NVME.hxx4
-rw-r--r--dev/ZKA/amd64-efi.make4
-rw-r--r--dev/ZKA/arm64-efi.make2
-rw-r--r--doc/NeFS.pdf (renamed from doc/NewFS.pdf)bin13654 -> 13654 bytes
100 files changed, 1100 insertions, 1234 deletions
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
index 5c0ed4d2..6a8b4dfb 100644
--- a/.vscode/c_cpp_properties.json
+++ b/.vscode/c_cpp_properties.json
@@ -12,7 +12,7 @@
"__NEWOSKRNL__",
"Z_PREFIX",
"__HAVE_ZKA_APIS__",
- "__FSKIT_USE_NEWFS__",
+ "__FSKIT_USE_NEFS__",
"__EFI_x86_64__",
"__ATA_PIO__",
"__ZKA_AMD64__",
@@ -35,7 +35,7 @@
"__NEWOSKRNL__",
"Z_PREFIX",
"__HAVE_ZKA_APIS__",
- "__FSKIT_USE_NEWFS__",
+ "__FSKIT_USE_NEFS__",
"__EFI_x86_64__",
"__ATA_PIO__",
"__ZKA_AMD64__",
diff --git a/dev/DLL/EncryptFS/EncryptFS.hxx b/dev/DLL/EncryptFS/EncryptFS.hxx
index 4dfafe7c..368df9ae 100644
--- a/dev/DLL/EncryptFS/EncryptFS.hxx
+++ b/dev/DLL/EncryptFS/EncryptFS.hxx
@@ -13,7 +13,7 @@
#pragma once
-#include <FSKit/NewFS.hxx>
+#include <FSKit/NeFS.hxx>
namespace EncryptFS
{
diff --git a/dev/HPFS/.gitignore b/dev/HPFS/.gitignore
new file mode 100644
index 00000000..6f675898
--- /dev/null
+++ b/dev/HPFS/.gitignore
@@ -0,0 +1,3 @@
+*.sys
+*.exe
+*.dll \ No newline at end of file
diff --git a/dev/HPFS/Sources/IFSMain.rs b/dev/HPFS/Sources/IFSMain.rs
new file mode 100644
index 00000000..5a49585a
--- /dev/null
+++ b/dev/HPFS/Sources/IFSMain.rs
@@ -0,0 +1,12 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+ FILE: IFSMain.rs
+ PURPOSE: HPFS IFS.
+
+------------------------------------------- */
+
+fn IFSStart() {
+
+} \ No newline at end of file
diff --git a/dev/HPFS/X64/EBS.asm b/dev/HPFS/X64/EBS.asm
index c1d87ab5..3c55825b 100644
--- a/dev/HPFS/X64/EBS.asm
+++ b/dev/HPFS/X64/EBS.asm
@@ -1,25 +1,28 @@
;; FILE: EBS.asm
-;; PURPOSE: EXPLICIT BOOT SECTOR OF HPFS.
+;; PURPOSE: EXPLICIT BOOT SECTOR STRUCTURE (HPFS RELATED).
;; AUTHOR: AMLAL EL MAHROUSS
-;; THIS IS PART OF THE HPFS FOR AMD64 FILESYSTEM PACKAGE.
[bits 64]
-;; WRITE THIS A BLOB TO THEN DUMP INTO DISK.
+;; DUMP THIS BLOB TO DISK, WHEN FORMATTING THE SSD.
HPFS_EBS_HEADER:
- db " HPFS", 0 ;; MAGIC NUMBER OF FILESYSTEM
- db 1 ;; VERSION
+ db "HPFS ", 0 ;; MAGIC NUMBER OF FILESYSTEM
+ dq 0 ;; RESERVED 4
+ dw 1 ;; VERSION
dw 0 ;; PARTITION TYPE
+ dq 0 ;; RESERVED 3
dw 0 ;; DISK TYPE (INVALID = 0, CDROM = 1, SSD = 2, USB = 3)
dw 0 ;; CHECKSUM OF PARTITION
dw 0 ;; IS IT LOCKED? (DISK ENCRYPTION ON?)
dq 0 ;; SECTOR COUNT
- dw 512 ;; SECTOR SZ
- dq 0 ;; KERNEL FILE RECORD LBA
- dq 0 ;; KERNEL FILE RECORD SIZE
-;; READ LAST, WHEN KERNEL LBA IS READ.
-HPFS_EBS_JUMP_FIELD:
- nop
- nop
- jmp 0x4000000 ;; OS JUMP FIELD, OS SHOULD BE AT THAT LOCATION \ No newline at end of file
+ dq 0 ;; RESERVED 2
+ dq 512 ;; SECTOR SZ
+ dq 0 ;; DISK SIZE
+ dq 0 ;; RESERVED 1
+ dq 0 ;; LOCKER ON?
+ dq 0 ;; PARTITION MAP TYPE (GPT, MBR, EPM)
+ dq 0 ;; MASTER FILE TABLE
+ dq 0 ;; MASTER TRACE TABLE
+ dq 0 ;; MASTER DIRECTORY TABLE
+ dw 0xFFFF ;; END OF HEADER WORD \ No newline at end of file
diff --git a/dev/HPFS/hpfs.json b/dev/HPFS/hpfs.json
new file mode 100644
index 00000000..3a13297b
--- /dev/null
+++ b/dev/HPFS/hpfs.json
@@ -0,0 +1,11 @@
+{
+ "compiler_path": "rustc",
+ "compiler_std": "",
+ "sources_path": ["Sources/*.rs"],
+ "output_name": "hpfs.sys",
+ "compiler_flags": [
+ ],
+ "cpp_macros": [
+ ]
+ }
+ \ No newline at end of file
diff --git a/dev/INSTALL/.keepme b/dev/INST/.keepme
index e69de29b..e69de29b 100644
--- a/dev/INSTALL/.keepme
+++ b/dev/INST/.keepme
diff --git a/dev/INSTALL/ReadMe.txt b/dev/INST/ReadMe.txt
index d1a3953b..d1a3953b 100644
--- a/dev/INSTALL/ReadMe.txt
+++ b/dev/INST/ReadMe.txt
diff --git a/dev/INSTALL/X64/InstallAPI.asm b/dev/INST/X64/InstallAPI.asm
index 61c712d0..61c712d0 100644
--- a/dev/INSTALL/X64/InstallAPI.asm
+++ b/dev/INST/X64/InstallAPI.asm
diff --git a/dev/ZBA/BootKit/BootKit.hxx b/dev/ZBA/BootKit/BootKit.hxx
index 6ac87b82..3f7b0a96 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,18 +230,18 @@ 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;
}
- writer.Write(L"newosldr: Disk size: ").Write(this->fDiskDev.GetDiskSize()).Write(L"\r");
+ writer.Write(L"newosldr: Disk is ").Write(GIB(this->fDiskDev.GetDiskSize())).Write(L" GB.\r");
if (blockPart->DiskSize != this->fDiskDev.GetDiskSize() ||
blockPart->DiskSize < 1 ||
blockPart->SectorSize != BootDev::kSectorSize ||
- blockPart->Version != kNewFSVersionInteger ||
+ blockPart->Version != kNeFSVersionInteger ||
blockPart->StartCatalog == 0)
{
return false;
@@ -251,7 +251,7 @@ public:
return false;
}
- writer.Write(L"newosldr: Partition name: ").Write(blockPart->PartitionName).Write(L" is healthy.\r");
+ writer.Write(L"newosldr: Partition: ").Write(blockPart->PartitionName).Write(L" is healthy.\r");
return true;
}
@@ -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/NetBoot/build.json b/dev/ZBA/Modules/NetBoot/build.json
index 78336241..c24966d9 100644
--- a/dev/ZBA/Modules/NetBoot/build.json
+++ b/dev/ZBA/Modules/NetBoot/build.json
@@ -11,7 +11,7 @@
"-fPIC",
"-fno-rtti",
"-fno-exceptions",
- "-Wl,--subsystem=17,--image-base 0x10000000"
+ "-Wl,--subsystem=17,--image-base,0x1000000"
],
"cpp_macros": [
"__NEWOSKRNL__",
diff --git a/dev/ZBA/Modules/SysChk/Module.cxx b/dev/ZBA/Modules/SysChk/Module.cxx
index 9bc3425c..7bf7fb62 100644
--- a/dev/ZBA/Modules/SysChk/Module.cxx
+++ b/dev/ZBA/Modules/SysChk/Module.cxx
@@ -15,7 +15,7 @@ EXTERN_C Int32 ModuleMain(Kernel::HEL::HandoverInformationHeader* Handover)
cST->ConOut->ClearScreen(cST->ConOut);
- cST->ConOut->OutputString(cST->ConOut, L"SYSCHK: CHECKING FOR VALID NEWFS OR EXT4 PARTITIONS...\r\n");
+ cST->ConOut->OutputString(cST->ConOut, L"SYSCHK: CHECKING FOR VALID NEWFS OR HPFS PARTITIONS...\r\n");
cST->ConOut->OutputString(cST->ConOut, L"SYSCHK: GOOD TO GO!\r\n");
return kEfiOk;
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootJump.S b/dev/ZBA/Sources/HEL/AMD64/BootAPI.S
index d8e09d4e..e391351d 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootJump.S
+++ b/dev/ZBA/Sources/HEL/AMD64/BootAPI.S
@@ -39,3 +39,9 @@ wait_gate2:
mov cr4,rax
reset_wait:
jmp reset_wait
+
+.global write_cr3
+
+write_cr3:
+ mov cr3, rcx
+ ret \ No newline at end of file
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
index 576ada08..9cccc922 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
@@ -79,6 +79,8 @@ STATIC Bool CheckBootDevice(BootDeviceATA& ataDev)
return true;
}
+EXTERN_C Void write_cr3(VoidPtr new_cr3);
+
/// @brief Main EFI entrypoint.
/// @param ImageHandle Handle of this image.
/// @param SystemTable The system table of it.
@@ -152,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];
@@ -186,52 +209,14 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
handoverHdrPtr->f_FirmwareSpecific[HEL::kHandoverSpecificMemoryEfi] =
(UIntPtr)Descriptor;
- handoverHdrPtr->f_VirtualStart =
- (VoidPtr)Descriptor[cDefaultMemoryMap].VirtualStart;
+ handoverHdrPtr->f_BitMapStart = 0;
- handoverHdrPtr->f_HeapStart = 0;
-
- while (BS->AllocatePool(EfiLoaderData, kHandoverHeapSz, &handoverHdrPtr->f_HeapStart) != kEfiOk)
+ while (BS->AllocatePool(EfiRuntimeServicesData, kHandoverHeapSz, &handoverHdrPtr->f_BitMapStart) != kEfiOk)
;
handoverHdrPtr->f_VirtualSize =
Descriptor[cDefaultMemoryMap].NumberOfPages; /* # of pages */
- handoverHdrPtr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor);
-
- handoverHdrPtr->f_Magic = kHandoverMagic;
- handoverHdrPtr->f_Version = kHandoverVersion;
-
- // Provide fimware vendor name.
-
- BCopyMem(handoverHdrPtr->f_FirmwareVendorName, SystemTable->FirmwareVendor,
- handoverHdrPtr->f_FirmwareVendorLen);
-
- handoverHdrPtr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor);
-
- // Assign to global 'kHandoverHeader'.
-
- BDiskFormatFactory<BootDeviceATA> checkPart;
-
- 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();
- }
-
- // ---------------------------------------------------- //
- // The following checks for an exisiting partition
- // inside the disk, if it doesn't have one,
- // format the disk.
- // ---------------------------------------------------- //
-
handoverHdrPtr->f_FirmwareCustomTables[0] = (VoidPtr)BS;
handoverHdrPtr->f_FirmwareCustomTables[1] = (VoidPtr)ST;
@@ -247,7 +232,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
if (readerSysChk.Blob())
{
loaderSysChk = new Boot::BThread(readerSysChk.Blob());
- loaderSysChk->SetName("64-bit System Check DLL.");
+ loaderSysChk->SetName("System Check SYS.");
}
loaderSysChk->Start(handoverHdrPtr);
@@ -257,6 +242,20 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
handoverHdrPtr->f_FirmwareCustomTables[0] = nullptr;
handoverHdrPtr->f_FirmwareCustomTables[1] = nullptr;
+ handoverHdrPtr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor);
+
+ handoverHdrPtr->f_Magic = kHandoverMagic;
+ handoverHdrPtr->f_Version = kHandoverVersion;
+
+ // Provide fimware vendor name.
+
+ BCopyMem(handoverHdrPtr->f_FirmwareVendorName, SystemTable->FirmwareVendor,
+ handoverHdrPtr->f_FirmwareVendorLen);
+
+ handoverHdrPtr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor);
+
+ // Assign to global 'kHandoverHeader'.
+
BFileReader readerKernel(L"newoskrnl.exe", ImageHandle);
readerKernel.ReadAll(0);
@@ -270,7 +269,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
if (readerKernel.Blob())
{
loader = new Boot::BThread(readerKernel.Blob());
- loader->SetName("64-bit Kernel DLL.");
+ loader->SetName("64-Bit Kernel EXE.");
handoverHdrPtr->f_KernelImage = readerKernel.Blob();
}
@@ -288,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 467f4303..d43be468 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx
@@ -134,7 +134,6 @@ BTextWriter& BTextWriter::WriteCharacter(CharacterTypeUTF16 c)
BTextWriter& BTextWriter::Write(const Long& x)
{
#ifdef __DEBUG__
- this->Write(L"0x");
this->_Write(x);
#endif // ifdef __DEBUG__
@@ -145,14 +144,14 @@ BTextWriter& BTextWriter::Write(const Long& x)
BTextWriter& BTextWriter::_Write(const Long& x)
{
#ifdef __DEBUG__
- UInt64 y = (x > 0 ? x : -x) / 16;
- UInt64 h = (x > 0 ? x : -x) % 16;
+ UInt64 y = (x > 0 ? x : -x) / 10;
+ UInt64 h = (x > 0 ? x : -x) % 10;
if (y)
this->_Write(y);
/* fail if the hex number is not base-16 */
- if (h > 15)
+ if (h > 10)
{
this->WriteCharacter('?');
return *this;
@@ -161,7 +160,7 @@ BTextWriter& BTextWriter::_Write(const Long& x)
if (y < 0)
y = -y;
- const char cNumbers[17] = "0123456789ABCDEF";
+ const char cNumbers[] = "0123456789";
this->WriteCharacter(cNumbers[h]);
#endif // ifdef __DEBUG__
diff --git a/dev/ZBA/Sources/Thread.cxx b/dev/ZBA/Sources/Thread.cxx
index 1ea83618..13b02b92 100644
--- a/dev/ZBA/Sources/Thread.cxx
+++ b/dev/ZBA/Sources/Thread.cxx
@@ -165,7 +165,7 @@ namespace Boot
err_fn(handover);
}
- rt_jump_to_address(fStartAddress, handover);
+ reinterpret_cast<HEL::HandoverProc>(fStartAddress)(handover);
}
const Char* BThread::GetName()
diff --git a/dev/ZBA/amd64-efi.make b/dev/ZBA/amd64-efi.make
index d75f2aaf..1f8bf1b1 100644
--- a/dev/ZBA/amd64-efi.make
+++ b/dev/ZBA/amd64-efi.make
@@ -29,14 +29,14 @@ IMG=epm-master-1.img
IMG_2=epm-slave.img
IMG_3=epm-master-2.img
-EMU_FLAGS=-net none -m 8G -M q35 -cpu qemu64 \
+EMU_FLAGS=-net none -m 8G -M q35 \
-bios $(BIOS) -device piix3-ide,id=ide \
-drive id=disk,file=$(IMG),format=raw,if=none \
-device ide-hd,drive=disk,bus=ide.0 -drive \
file=fat:rw:Sources/Root/,index=2,format=raw \
-drive id=disk_2,file=$(IMG_2),if=none \
-device ahci,id=ahci \
- -device ide-hd,drive=disk_2,bus=ahci.0 -d int
+ -device ide-hd,drive=disk_2,bus=ahci.0 -serial stdio -no-reboot
LD_FLAGS=-e Main --subsystem=10
diff --git a/dev/ZKA/ArchKit/ArchKit.hxx b/dev/ZKA/ArchKit/ArchKit.hxx
index 60a2b2ec..fc2d7d33 100644
--- a/dev/ZKA/ArchKit/ArchKit.hxx
+++ b/dev/ZKA/ArchKit/ArchKit.hxx
@@ -109,4 +109,4 @@ inline Kernel::Array<HAL_SYSCALL_RECORD,
EXTERN_C Kernel::HAL::StackFramePtr mp_get_current_context();
EXTERN_C Kernel::Void mp_do_context_switch_pre(Kernel::Void);
/// @note The context gives out the return address in return register.
-EXTERN_C Kernel::UIntPtr mp_do_context_switch(Kernel::VoidPtr image, Kernel::UInt8* stack_ptr, Kernel::HAL::StackFramePtr stackPtr);
+EXTERN_C Kernel::Void mp_do_context_switch(Kernel::VoidPtr image, Kernel::UInt8* stack_ptr, Kernel::HAL::StackFramePtr stackPtr);
diff --git a/dev/ZKA/Docs/SPECIFICATION.md b/dev/ZKA/Docs/SPECIFICATION.md
index d39a95d3..c38fa122 100644
--- a/dev/ZKA/Docs/SPECIFICATION.md
+++ b/dev/ZKA/Docs/SPECIFICATION.md
@@ -19,7 +19,7 @@
- Separation of Files/Devices.
- Networking.
- Hardware Abstraction Layer.
-- Native Filesystem support (NewFS, FAT32 and ffs2).
+- Native Filesystem support (NeFS, FAT32 and ffs2).
- Program Loaders interfaces.
- TLS (Thread Local Storage) support.
- Semaphore, Locks, Timers.
diff --git a/dev/ZKA/FSKit/FAT32.hxx b/dev/ZKA/FSKit/HPFS.hxx
index 04fa0c6d..6f5ff3f4 100644
--- a/dev/ZKA/FSKit/FAT32.hxx
+++ b/dev/ZKA/FSKit/HPFS.hxx
@@ -8,5 +8,5 @@
#include <NewKit/Defines.hxx>
-/// @file FAT32.hxx
-/// @brief FAT32 support. \ No newline at end of file
+/// @file HPFS.hxx
+/// @brief HPFS support. \ No newline at end of file
diff --git a/dev/ZKA/FSKit/IndexableProperty.hxx b/dev/ZKA/FSKit/IndexableProperty.hxx
index 652e0e74..56e5de1c 100644
--- a/dev/ZKA/FSKit/IndexableProperty.hxx
+++ b/dev/ZKA/FSKit/IndexableProperty.hxx
@@ -8,7 +8,7 @@
#include <CFKit/Property.hxx>
#include <CompilerKit/CompilerKit.hxx>
-#include <KernelKit/DriveManager.hxx>
+#include <KernelKit/DriveMgr.hxx>
#define kIndexerNodeNameLength 255
#define kIndexerClaimed 0xCF
diff --git a/dev/ZKA/FSKit/NewFS.hxx b/dev/ZKA/FSKit/NeFS.hxx
index c5ada14b..2bf17863 100644
--- a/dev/ZKA/FSKit/NewFS.hxx
+++ b/dev/ZKA/FSKit/NeFS.hxx
@@ -2,14 +2,14 @@
Copyright ZKA Technologies.
- File: NewFS.hxx
- Purpose:
+ FILE: NeFS.hxx
+ PURPOSE: NeFS (New FileSystem) support, can be used with kernel, HPFS is preferred.
Revision History:
?/?/?: Added file (amlel)
12/02/24: Add UUID macro for EPM and GPT partition schemes.
- 3/16/24: Add mandatory sector size, kNewFSSectorSz is set to 2048 by
+ 3/16/24: Add mandatory sector size, kNeFSSectorSz is set to 2048 by
default.
------------------------------------------- */
@@ -18,7 +18,7 @@ default.
#include <CompilerKit/CompilerKit.hxx>
#include <HintKit/CompilerHint.hxx>
-#include <KernelKit/DriveManager.hxx>
+#include <KernelKit/DriveMgr.hxx>
#include <NewKit/Defines.hxx>
/**
@@ -26,68 +26,69 @@ default.
@author Amlal EL Mahrouss
*/
-#define kNewFSInvalidFork (-1)
-#define kNewFSInvalidCatalog (-1)
-#define kNewFSNodeNameLen (256)
+#define kNeFSInvalidFork (-1)
+#define kNeFSInvalidCatalog (-1)
+#define kNeFSNodeNameLen (256)
-#define kNewFSSectorSz (512)
-#define kNewFSForkSz (8192)
+#define kNeFSSectorSz (512)
+#define kNeFSForkDataSz (kib_cast(8))
-#define kNewFSIdentLen (8)
-#define kNewFSIdent " NewFS"
-#define kNewFSPadLen (400)
+#define kNeFSIdentLen (8)
+#define kNeFSIdent " NeFS"
+#define kNeFSPadLen (392)
-#define kNewFSMetaFilePrefix '$'
+#define kNeFSMetaFilePrefix '$'
-#define kNewFSVersionInteger (0x0128)
-#define kNewFSVerionString "1.28"
+#define kNeFSVersionInteger (0x0128)
+#define kNeFSVerionString "1.28"
/// @brief Standard fork types.
-#define kNewFSDataFork "main_data"
-#define kNewFSResourceFork "main_rsrc"
+#define kNeFSDataFork "main_data"
+#define kNeFSResourceFork "main_rsrc"
-#define kNewFSCatalogKindFile (1)
-#define kNewFSCatalogKindDir (2)
-#define kNewFSCatalogKindAlias (3)
+#define kNeFSCatalogKindFile (1)
+#define kNeFSCatalogKindDir (2)
+#define kNeFSCatalogKindAlias (3)
-#define kNewFSForkSize (512)
+#define kNeFSForkSize (512)
//! shared between network or
//! other filesystems. Export forks as .zip when copying.
-#define kNewFSCatalogKindShared (4)
+#define kNeFSCatalogKindShared (4)
-#define kNewFSCatalogKindResource (5)
-#define kNewFSCatalogKindExecutable (6)
+#define kNeFSCatalogKindResource (5)
+#define kNeFSCatalogKindExecutable (6)
-#define kNewFSCatalogKindPage (8)
+#define kNeFSCatalogKindPage (8)
-#define kNewFSPartitionTypeStandard (7)
-#define kNewFSPartitionTypePage (8)
-#define kNewFSPartitionTypeBoot (9)
+#define kNeFSPartitionTypeStandard (7)
+#define kNeFSPartitionTypePage (8)
+#define kNeFSPartitionTypeBoot (9)
-#define kNewFSCatalogKindDevice (9)
-#define kNewFSCatalogKindLock (10)
+#define kNeFSCatalogKindDevice (9)
+#define kNeFSCatalogKindLock (10)
-#define kNewFSCatalogKindRLE (11)
+#define kNeFSCatalogKindRLE (11)
+#define kNeFSCatalogKindMetaFile (12)
+#define kNeFSCatalogKindTTF (13)
+#define kNeFSCatalogKindRIFF (14)
-#define kNewFSCatalogKindMetaFile (12)
+#define kNeFSSeparator '\\'
+#define kNeFSSeparatorAlt '/'
-#define kNewFSSeparator '\\'
-#define kNewFSSeparatorAlt '/'
+#define kNeFSUpDir ".."
+#define kNeFSRoot "\\"
+#define kNeFSRootAlt "/"
-#define kNewFSUpDir ".."
-#define kNewFSRoot "\\"
-#define kNewFSRootAlt "/"
+#define kNeFSLF '\r'
+#define kNeFSEOF (-1)
-#define kNewFSLF '\r'
-#define kNewFSEOF (-1)
-
-#define kNewFSBitWidth (sizeof(Kernel::Char))
-#define kNewFSLbaType (Kernel::Lba)
+#define kNeFSBitWidth (sizeof(Kernel::Char))
+#define kNeFSLbaType (Kernel::Lba)
/// Start After the PM headers, pad 1024 bytes.
-#define kNewFSRootCatalogStartAddress (1024)
-#define kNewFSCatalogStartAddress ((2048) + sizeof(NFS_ROOT_PARTITION_BLOCK))
+#define kNeFSRootCatalogStartAddress (1024)
+#define kNeFSCatalogStartAddress ((2048) + sizeof(NFS_ROOT_PARTITION_BLOCK))
#define kResourceTypeDialog (10)
#define kResourceTypeString (11)
@@ -96,13 +97,13 @@ default.
#define kConfigLen (64)
#define kPartLen (32)
-#define kNewFSFlagDeleted (70)
-#define kNewFSFlagUnallocated (0)
-#define kNewFSFlagCreated (71)
+#define kNeFSFlagDeleted (70)
+#define kNeFSFlagUnallocated (0)
+#define kNeFSFlagCreated (71)
-#define kNewFSMimeNameLen (200)
+#define kNeFSMimeNameLen (200)
-#define kNewFSForkNameLen (200U)
+#define kNeFSForkNameLen (200U)
struct NFS_CATALOG_STRUCT;
struct NFS_FORK_STRUCT;
@@ -110,21 +111,21 @@ struct NFS_ROOT_PARTITION_BLOCK;
enum
{
- kNewFSHardDrive = 0xC0, // Hard Drive
- kNewFSSolidStateDrive = 0xC1, // Solid State Drive
- kNewFSOpticalDrive = 0x0C, // Blu-Ray/DVD
- kNewFSMassStorageDevice = 0xCC, // USB
- kNewFSScsi = 0xC4, // SCSI Hard Drive
- kNewFSFlashDrive = 0xC6,
- kNewFSUnknown = 0xFF, // Unknown device.
- kNewFSDriveCount = 7,
+ kNeFSHardDrive = 0xC0, // Hard Drive
+ kNeFSSolidStateDrive = 0xC1, // Solid State Drive
+ kNeFSOpticalDrive = 0x0C, // Blu-Ray/DVD
+ kNeFSMassStorageDevice = 0xCC, // USB
+ kNeFSScsi = 0xC4, // SCSI Hard Drive
+ kNeFSFlashDrive = 0xC6,
+ kNeFSUnknown = 0xFF, // Unknown device.
+ kNeFSDriveCount = 7,
};
/// @brief Catalog type.
struct PACKED NFS_CATALOG_STRUCT final
{
- Kernel::Char Name[kNewFSNodeNameLen];
- Kernel::Char Mime[kNewFSMimeNameLen];
+ Kernel::Char Name[kNeFSNodeNameLen];
+ Kernel::Char Mime[kNeFSMimeNameLen];
/// Catalog status flag.
Kernel::UInt16 Flags;
@@ -152,8 +153,8 @@ struct PACKED NFS_CATALOG_STRUCT final
/// whereas the data fork is reserved for file data.
struct PACKED NFS_FORK_STRUCT final
{
- Kernel::Char ForkName[kNewFSForkNameLen];
- Kernel::Char CatalogName[kNewFSNodeNameLen];
+ Kernel::Char ForkName[kNeFSForkNameLen];
+ Kernel::Char CatalogName[kNeFSNodeNameLen];
Kernel::Int32 Flags;
Kernel::Int32 Kind;
@@ -172,7 +173,7 @@ struct PACKED NFS_FORK_STRUCT final
/// @brief Partition block type
struct PACKED NFS_ROOT_PARTITION_BLOCK final
{
- Kernel::Char Ident[kNewFSIdentLen];
+ Kernel::Char Ident[kNeFSIdentLen];
Kernel::Char PartitionName[kPartLen];
Kernel::Int32 Flags;
@@ -193,41 +194,41 @@ struct PACKED NFS_ROOT_PARTITION_BLOCK final
Kernel::Lba EpmBlock;
- Kernel::Char Pad[kNewFSPadLen - sizeof(Kernel::Lba)];
+ Kernel::Char Pad[kNeFSPadLen];
};
namespace Kernel
{
enum
{
- kNewFSSubDriveA,
- kNewFSSubDriveB,
- kNewFSSubDriveC,
- kNewFSSubDriveD,
- kNewFSSubDriveInvalid,
- kNewFSSubDriveCount,
+ kNeFSSubDriveA,
+ kNeFSSubDriveB,
+ kNeFSSubDriveC,
+ kNeFSSubDriveD,
+ kNeFSSubDriveInvalid,
+ kNeFSSubDriveCount,
};
/// \brief Resource fork kind.
enum
{
- kNewFSRsrcForkKind = 0,
- kNewFSDataForkKind = 1
+ kNeFSRsrcForkKind = 0,
+ kNeFSDataForkKind = 1
};
///
- /// \name NewFSParser
- /// \brief NewFS parser class. (catalog creation, remove removal, root,
+ /// \name NeFSParser
+ /// \brief NeFS parser class. (catalog creation, remove removal, root,
/// forks...) Designed like the DOM, detects the filesystem automatically.
///
- class NewFSParser final
+ class NeFSParser final
{
public:
- explicit NewFSParser() = default;
- ~NewFSParser() = default;
+ explicit NeFSParser() = default;
+ ~NeFSParser() = default;
public:
- ZKA_COPY_DEFAULT(NewFSParser);
+ ZKA_COPY_DEFAULT(NeFSParser);
public:
/// @brief Creates a new fork inside the New filesystem partition.
@@ -278,13 +279,13 @@ namespace Kernel
bool CloseCatalog(_InOut NFS_CATALOG_STRUCT* catalog);
- /// @brief Make a EPM+NewFS drive out of the disk.
+ /// @brief Make a EPM+NeFS drive out of the disk.
/// @param drive The drive to write on.
/// @return If it was sucessful, see ErrLocal().
bool Format(_Input _Output DriveTrait* drive, _Input const Lba endLba, _Input const Int32 flags, const Char* part_name);
public:
- Int32 fDriveIndex{kNewFSSubDriveA};
+ Int32 fDriveIndex{kNeFSSubDriveA};
};
///
diff --git a/dev/ZKA/FirmwareKit/EPM.hxx b/dev/ZKA/FirmwareKit/EPM.hxx
index 0de288be..18f8558d 100644
--- a/dev/ZKA/FirmwareKit/EPM.hxx
+++ b/dev/ZKA/FirmwareKit/EPM.hxx
@@ -102,7 +102,7 @@ struct PACKED _BOOT_BLOCK_STRUCT
Kernel::Int64 LbaEnd; // addition of lba_start to get the end of partition.
Kernel::Int16 Kind;
Kernel::Int32 FsVersion;
- Kernel::Char Fs[kEPMFilesystemLength]; /* NewFS, ffs2... */
+ Kernel::Char Fs[kEPMFilesystemLength]; /* NeFS, ffs2... */
Kernel::Char Reserved[401]; // to fill a full sector.
};
diff --git a/dev/ZKA/FirmwareKit/Handover.hxx b/dev/ZKA/FirmwareKit/Handover.hxx
index 46fca139..b4558560 100644
--- a/dev/ZKA/FirmwareKit/Handover.hxx
+++ b/dev/ZKA/FirmwareKit/Handover.hxx
@@ -24,13 +24,7 @@
#define kHandoverMagic 0xBADCC
#define kHandoverVersion 0x114
-#define kHandoverMaxCmdLine 8
-
-#define kHandoverBetterEFI "ZKA_EFI"
-#define kHandoverBetterEFI_U L"ZKA_EFI"
-
-#define kHandoverHeapSz gib_cast(2)
-
+#define kHandoverHeapSz gib_cast(3)
#define kHandoverStructSz sizeof(HEL::HandoverInformationHeader)
namespace Kernel::HEL
@@ -62,15 +56,18 @@ namespace Kernel::HEL
UInt64 f_Magic;
UInt64 f_Version;
- VoidPtr f_VirtualStart;
+ VoidPtr f_BitMapStart;
SizeT f_VirtualSize;
VoidPtr f_PhysicalStart;
- VoidPtr f_HeapStart;
VoidPtr f_KernelImage;
+ SizeT f_KernelSz;
VoidPtr f_StartupChime;
+ SizeT f_ChimeSz;
VoidPtr f_StartupImage;
+ SizeT f_StartupSz;
VoidPtr f_TTFallbackFont;
+ SizeT f_FontSz;
WideChar f_FirmwareVendorName[32];
SizeT f_FirmwareVendorLen;
diff --git a/dev/ZKA/HALKit/AMD64/HalAPIC.cxx b/dev/ZKA/HALKit/AMD64/HalAPICMgr.cxx
index caa2ce0b..caa2ce0b 100644
--- a/dev/ZKA/HALKit/AMD64/HalAPIC.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalAPICMgr.cxx
diff --git a/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx b/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx
new file mode 100644
index 00000000..221cb044
--- /dev/null
+++ b/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx
@@ -0,0 +1,103 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#include <ArchKit/ArchKit.hxx>
+
+#define cVMHMagic ((Kernel::UIntPtr)0x10210)
+
+#ifdef __ZKA_AMD64__
+#include <HALKit/AMD64/HalPageAlloc.hxx>
+#elif defined(__ZKA_ARM64__)
+#include <HALKit/ARM64/HalPageAlloc.hxx>
+#endif
+
+#include <NewKit/Defines.hxx>
+#include <NewKit/KernelCheck.hxx>
+
+namespace Kernel
+{
+ namespace HAL
+ {
+ namespace Detail
+ {
+ struct AllocatorTraits final
+ {
+ /// @brief Iterate over availables pages for a free one.
+ /// @return The new address which was found.
+ VoidPtr FindBitMap(VoidPtr base_ptr, SizeT size, Bool rw, Bool user) noexcept
+ {
+ while (base_ptr && size)
+ {
+ UIntPtr* ptr_bit_set = reinterpret_cast<UIntPtr*>(base_ptr);
+
+ if (ptr_bit_set[0] != cVMHMagic)
+ {
+ ptr_bit_set[0] = cVMHMagic;
+ ptr_bit_set[1] = size;
+ ptr_bit_set[2] = __BIGGEST_ALIGNMENT__;
+
+ kcout << "ALLOC STATUS\r";
+ kcout << "MAG: " << hex_number(ptr_bit_set[0]) << endl;
+ kcout << "ADDRESS: " << hex_number((UIntPtr)ptr_bit_set) << endl;
+ kcout << "SIZE: " << hex_number(ptr_bit_set[1]) << endl;
+ kcout << "ALLOC STATUS\r";
+
+ if (rw)
+ mm_update_pte(base_ptr, eFlagsRw);
+
+ if (user)
+ mm_update_pte(base_ptr, eFlagsUser);
+
+ return (VoidPtr)ptr_bit_set;
+ }
+
+ base_ptr = reinterpret_cast<VoidPtr>(reinterpret_cast<UIntPtr>(base_ptr) + __BIGGEST_ALIGNMENT__ + ptr_bit_set[1]);
+ }
+
+ return nullptr;
+ }
+ };
+ } // namespace Detail
+
+ /// @brief Allocate a new page to be used by the OS.
+ /// @param rw read/write bit.
+ /// @param user user bit.
+ /// @return
+ auto mm_alloc_bitmap(Boolean rw, Boolean user, SizeT size) -> VoidPtr
+ {
+ VoidPtr ptr_new = nullptr;
+ Detail::AllocatorTraits traits;
+
+ ptr_new = traits.FindBitMap(kKernelVirtualStart, size, rw, user);
+
+ return ((UIntPtr*)ptr_new);
+ }
+
+ auto mm_free_bitmap(VoidPtr page_ptr) -> Bool
+ {
+ if (!page_ptr)
+ return false;
+
+ UIntPtr* ptr_bit_set = reinterpret_cast<UIntPtr*>(page_ptr);
+
+ if (!ptr_bit_set[0] ||
+ ptr_bit_set[0] != cVMHMagic)
+ return false;
+
+ kcout << "FREE STATUS\r";
+ kcout << "MAG: " << hex_number(ptr_bit_set[0]) << endl;
+ kcout << "ADDRESSS: " << hex_number((UIntPtr)ptr_bit_set) << endl;
+ kcout << "SIZE: " << hex_number(ptr_bit_set[1]) << endl;
+ kcout << "FREE STATUS\r";
+
+ ptr_bit_set[0] = 0UL;
+ ptr_bit_set[1] = 0UL;
+ ptr_bit_set[2] = __BIGGEST_ALIGNMENT__;
+
+ return true;
+ }
+ } // namespace HAL
+} // namespace Kernel
diff --git a/dev/ZKA/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx b/dev/ZKA/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx
index 611ec596..b49a688f 100644
--- a/dev/ZKA/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx
@@ -13,6 +13,9 @@
EXTERN_C void idt_handle_gpf(Kernel::UIntPtr rsp)
{
Kernel::UserProcessScheduler::The().CurrentProcess().Leak().Crash();
+
+ Kernel::UserProcessHelper::StartScheduling();
+ Kernel::ke_stop(RUNTIME_CHECK_PROCESS);
}
/// @brief Handle page fault.
@@ -20,14 +23,23 @@ EXTERN_C void idt_handle_gpf(Kernel::UIntPtr rsp)
EXTERN_C void idt_handle_pf(Kernel::UIntPtr rsp)
{
Kernel::UserProcessScheduler::The().CurrentProcess().Leak().Crash();
+
+ Kernel::UserProcessHelper::StartScheduling();
Kernel::ke_stop(RUNTIME_CHECK_PROCESS);
}
+EXTERN_C void idt_handle_scheduler(Kernel::UIntPtr rsp)
+{
+ Kernel::UserProcessHelper::StartScheduling();
+}
+
/// @brief Handle math fault.
/// @param rsp
EXTERN_C void idt_handle_math(Kernel::UIntPtr rsp)
{
Kernel::UserProcessScheduler::The().CurrentProcess().Leak().Crash();
+
+ Kernel::UserProcessHelper::StartScheduling();
Kernel::ke_stop(RUNTIME_CHECK_PROCESS);
}
@@ -44,6 +56,8 @@ EXTERN_C void idt_handle_generic(Kernel::UIntPtr rsp)
EXTERN_C void idt_handle_ud(Kernel::UIntPtr rsp)
{
Kernel::UserProcessScheduler::The().CurrentProcess().Leak().Crash();
+
+ Kernel::UserProcessHelper::StartScheduling();
Kernel::ke_stop(RUNTIME_CHECK_PROCESS);
}
@@ -54,12 +68,12 @@ EXTERN_C Kernel::Void hal_system_call_enter(Kernel::UIntPtr rcx, Kernel::UIntPtr
{
if (rcx <= (kSyscalls.Count() - 1))
{
- Kernel::kcout << "newoskrnl.exe: syscall: enter.\r";
+ kcout << "syscall: enter.\r";
if (kSyscalls[rcx].fHooked)
(kSyscalls[rcx].fProc)((Kernel::VoidPtr)rdx);
- Kernel::kcout << "newoskrnl.exe: syscall: exit.\r";
+ kcout << "syscall: exit.\r";
}
}
@@ -70,11 +84,11 @@ EXTERN_C Kernel::Void hal_kernel_call_enter(Kernel::UIntPtr rcx, Kernel::UIntPtr
{
if (rcx <= (kSyscalls.Count() - 1))
{
- Kernel::kcout << "newoskrnl.exe: kerncall: enter.\r";
+ kcout << "kerncall: enter.\r";
if (kKerncalls[rcx].fHooked)
(kKerncalls[rcx].fProc)((Kernel::VoidPtr)rdx);
- Kernel::kcout << "newoskrnl.exe: kerncall: exit.\r";
+ kcout << "kerncall: exit.\r";
}
}
diff --git a/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx b/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx
index 2e76d73a..5f6c0552 100644
--- a/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx
@@ -16,7 +16,7 @@
// Needed for SMP. //
#include <FirmwareKit/EFI.hxx>
-#include <KernelKit/MP.hxx>
+#include <KernelKit/HardwareThreadScheduler.hxx>
#define kApicSignature "APIC"
@@ -160,10 +160,10 @@ namespace Kernel::HAL
{
fBlocks[UserProcessScheduler::The().CurrentProcess().Leak().ProcessId % kSchedProcessLimitPerTeam].f_Process = &UserProcessScheduler::The().CurrentProcess().Leak();
- return true;
+ return Yes;
}
- return false;
+ return No;
}
/***********************************************************************************/
@@ -191,7 +191,7 @@ namespace Kernel::HAL
cSMPInterrupt = 0;
kSMPCount = 0;
- kcout << "newoskrnl.exe: Probing MADT cores...\r";
+ kcout << "Probing MADT cores...\r";
UIntPtr madt_address = kMADTBlock->Address;
@@ -205,13 +205,13 @@ namespace Kernel::HAL
{
case 0x00: {
cSMPCores[index] = kMADTBlock->List[index].LAPIC.ProcessorID;
- kcout << "newoskrnl.exe: Core ID: " << number(cSMPCores[index]) << endl;
+ kcout << "Core ID: " << number(cSMPCores[index]) << endl;
++kSMPCount;
break;
}
case 0x05: {
madt_address = kMADTBlock->List[index].LAPIC_ADDRESS_OVERRIDE.Address;
- kcout << "newoskrnl.exe: Address: " << number(madt_address) << endl;
+ kcout << "Address: " << number(madt_address) << endl;
break;
}
}
@@ -219,7 +219,7 @@ namespace Kernel::HAL
++index;
}
- kcout << "newoskrnl.exe: # of cores: " << number(kSMPCount) << endl;
+ kcout << "# of cores: " << number(kSMPCount) << endl;
// Kernel is now SMP aware.
// That means that the scheduler is now available (on MP Kernels)
diff --git a/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx b/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx
index 4474295f..54b62b80 100644
--- a/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx
@@ -15,12 +15,15 @@ namespace Kernel::HAL
STATIC Void hal_remap_intel_pic_ctrl(Void) noexcept
{
- // Remap PIC.
+ auto a1 = HAL::In8(0xa1); // save masks
+ auto a2 = HAL::In8(0xa2);
+
HAL::Out8(0x20, 0x11);
+
HAL::Out8(0xA0, 0x11);
- HAL::Out8(0x21, 40);
- HAL::Out8(0xA1, 32);
+ HAL::Out8(0x21, 32);
+ HAL::Out8(0xA1, 40);
HAL::Out8(0x21, 4);
HAL::Out8(0xA1, 2);
@@ -28,8 +31,8 @@ namespace Kernel::HAL
HAL::Out8(0x21, 0x01);
HAL::Out8(0xA1, 0x01);
- HAL::Out8(0x21, 0xFD);
- HAL::Out8(0xA1, 0xFF);
+ HAL::Out8(0x21, a2);
+ HAL::Out8(0xA1, a1);
}
} // namespace Detail
@@ -47,8 +50,6 @@ namespace Kernel::HAL
for (UInt16 idt_indx = 0; idt_indx < 12; ++idt_indx)
{
- MUST_PASS(ptr_ivt[idt_indx]);
-
Detail::kInterruptVectorTable[idt_indx].Selector = kGdtKernelCodeSelector;
Detail::kInterruptVectorTable[idt_indx].Ist = 0;
Detail::kInterruptVectorTable[idt_indx].TypeAttributes = kTrapGate;
@@ -62,8 +63,6 @@ namespace Kernel::HAL
for (UInt16 idt_indx = 13; idt_indx < kKernelIdtSize; ++idt_indx)
{
- MUST_PASS(ptr_ivt[idt_indx]);
-
Detail::kInterruptVectorTable[idt_indx].Selector = kGdtKernelCodeSelector;
Detail::kInterruptVectorTable[idt_indx].Ist = 0;
Detail::kInterruptVectorTable[idt_indx].TypeAttributes = kInterruptGate;
@@ -77,7 +76,8 @@ namespace Kernel::HAL
hal_load_idt(idt);
- Detail::hal_remap_intel_pic_ctrl();
+ HAL::Out8(0xA1, 0xFF);
+ HAL::Out8(0x21, 0xFF);
}
void GDTLoader::Load(Ref<RegisterGDT>& gdt)
diff --git a/dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm b/dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm
index d59cc197..6abd28c9 100644
--- a/dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm
+++ b/dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm
@@ -141,12 +141,7 @@ IntNormal 38
IntNormal 39
IntNormal 40
-extern mp_system_call_handler
-
-__ZKA_INT_41:
- cmp rcx, 0
- jne mp_system_call_handler
- iretq
+IntNormal 41
IntNormal 42
IntNormal 43
@@ -222,17 +217,18 @@ section .text
hal_load_gdt:
lgdt [rcx]
- push 0x08
- lea rax, [rel rt_reload_segments]
- push rax
+ cli
+ push 8
+ push hal_reload_segments
o64 retf
-rt_reload_segments:
- mov ax, 0x10
+hal_reload_segments:
+ mov ax, 16
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
+ sti
ret
global hal_load_idt
diff --git a/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx b/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
index 34398871..79d9c097 100644
--- a/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
@@ -7,14 +7,14 @@
#include <ArchKit/ArchKit.hxx>
#include <Modules/CoreCG/FbRenderer.hxx>
#include <FirmwareKit/Handover.hxx>
-#include <KernelKit/FileManager.hxx>
+#include <KernelKit/FileMgr.hxx>
#include <KernelKit/Framebuffer.hxx>
#include <KernelKit/Heap.hxx>
-#include <KernelKit/PEFCodeManager.hxx>
+#include <KernelKit/PEFCodeMgr.hxx>
#include <KernelKit/UserProcessScheduler.hxx>
#include <NewKit/Json.hxx>
#include <Modules/CoreCG/Accessibility.hxx>
-#include <KernelKit/CodeManager.hxx>
+#include <KernelKit/CodeMgr.hxx>
#include <Modules/ACPI/ACPIFactoryInterface.hxx>
#include <NetworkKit/IPC.hxx>
#include <CFKit/Property.hxx>
@@ -56,7 +56,6 @@ namespace Kernel::HAL
Kernel::Property cKernelVersion;
Kernel::User cUserSuper{Kernel::RingKind::kRingSuperUser, kSuperUser};
-EXTERN Kernel::Boolean kAllocationInProgress;
EXTERN_C Kernel::VoidPtr kInterruptVectorTable[];
Kernel::Void hal_real_init(Kernel::Void) noexcept;
@@ -65,14 +64,14 @@ EXTERN_C void hal_user_code_start(void);
EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void);
/* GDT, mostly descriptors for user and kernel segments. */
-STATIC Kernel::HAL::Detail::ZKA_GDT_ENTRY cGdt[6] = {
+STATIC Kernel::HAL::Detail::ZKA_GDT_ENTRY ALIGN(0x1000) cGdt[6] = {
{.fLimitLow = 0, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0x00, .fFlags = 0x00, .fBaseHigh = 0}, // Null entry
{.fLimitLow = 0xFFFF, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0x9A, .fFlags = 0xA0, .fBaseHigh = 0}, // Kernel code
{.fLimitLow = 0xFFFF, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0x92, .fFlags = 0xA0, .fBaseHigh = 0}, // Kernel data
- {.fLimitLow = 0xFFFF, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0xFA, .fFlags = 0xA0, .fBaseHigh = 0}, // User code
- {.fLimitLow = 0xFFFF, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0xF2, .fFlags = 0xA0, .fBaseHigh = 0}, // User data
- // reserve them for later.
{.fLimitLow = 0, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0x00, .fFlags = 0x00, .fBaseHigh = 0},
+ {.fLimitLow = 0xFFFF, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0x9A, .fFlags = 0xA0, .fBaseHigh = 0}, // User code
+ {.fLimitLow = 0xFFFF, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0x92, .fFlags = 0xA0, .fBaseHigh = 0}, // User data
+ // reserve them for later.
};
EXTERN_C void hal_init_platform(
@@ -93,17 +92,12 @@ EXTERN_C void hal_init_platform(
Kernel::Void hal_real_init(Kernel::Void) noexcept
{
- // reset kAllocationInProgress field to zero.
- kAllocationInProgress = false;
-
- kKernelVMHStart = kHandoverHeader->f_HeapStart;
-
// get page size.
kKernelVirtualSize = kHandoverHeader->f_VirtualSize;
// get virtual address start (for the heap)
kKernelVirtualStart = reinterpret_cast<Kernel::VoidPtr>(
- reinterpret_cast<Kernel::UIntPtr>(kHandoverHeader->f_VirtualStart));
+ reinterpret_cast<Kernel::UIntPtr>(kHandoverHeader->f_BitMapStart));
// get physical address start.
kKernelPhysicalStart = reinterpret_cast<Kernel::VoidPtr>(
@@ -131,14 +125,13 @@ Kernel::Void hal_real_init(Kernel::Void) noexcept
if (kHandoverHeader->f_HardwareTables.f_MultiProcessingEnabled)
Kernel::HAL::mp_get_cores(kHandoverHeader->f_HardwareTables.f_VendorPtr);
- Kernel::kcout << "newoskrnl.exe: Creating filesystem and such.\r";
+ kcout << "Creating filesystem and such.\r";
- auto fs = new Kernel::NewFilesystemManager();
+ auto fs = new Kernel::NewFilesystemMgr();
MUST_PASS(fs);
- MUST_PASS(fs->GetParser());
- Kernel::NewFilesystemManager::Mount(fs);
+ Kernel::NewFilesystemMgr::Mount(fs);
const auto cPassword = "ZKA_KERNEL_AUTHORITY";
diff --git a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
index dc534589..c26a346f 100644
--- a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
+++ b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
@@ -21,23 +21,25 @@ section .text
;; rcx: code ptr.
;; rdx: stack ptr.
mp_do_context_switch:
- mov rsp, rdx
- mov rbp, rsp
+ mov fs, rcx
+ mov gs, rdx
mov r9, [r8 + (8 * 2)]
mov r10, [r8 + (8 * 3)]
- mov fs, [r8 + (8 * 4)]
+
mov r12, [r8 + (8 * 5)]
mov r13, [r8 + (8 * 6)]
mov r14, [r8 + (8 * 7)]
mov r15, [r8 + (8 * 8)]
- mov gs, [r8 + (8 * 9)]
- mov r8, [r8]
-
- mov rax, rcx
+ mov r11, gs
+ mov r12, fs
mov r11, 0x202
+ mov fs, [r8 + (8 * 4)]
+ mov gs, [r8 + (8 * 9)]
+ mov r8, [r8]
+
o64 sysret
;; @brief Gets the current stack frame.
@@ -49,8 +51,6 @@ extern hal_system_call_enter
global mp_system_call_handler
mp_system_call_handler:
- swapgs
-
push r8
push r9
push r10
@@ -61,26 +61,29 @@ mp_system_call_handler:
pop r9
pop r8
- swapgs
- sti
-
o64 sysret
mp_do_context_switch_pre:
+ xor rdx, rdx
+ mov rax, 0x202
+ mov rcx, 0xc0000084
+ wrmsr
+
+ mov rdx, mp_system_call_handler
+ shr rdx, 32
+ mov rcx, 0xc0000082
+ wrmsr
+
+ ; Enable SCE that enables sysret and syscall
+ mov rcx, 0xc0000082
+ wrmsr
mov rcx, 0xc0000080
rdmsr
or eax, 1
wrmsr
-
mov rcx, 0xc0000081
rdmsr
- mov rax, 0x00000000
mov edx, 0x00180008
wrmsr
- mov rcx, 0xc0000082
- mov rax, mp_system_call_handler
- mov rdx, 0x0
- wrmsr
-
ret
diff --git a/dev/ZKA/HALKit/AMD64/HalPageAlloc.cxx b/dev/ZKA/HALKit/AMD64/HalPageAlloc.cxx
deleted file mode 100644
index 28b5f9be..00000000
--- a/dev/ZKA/HALKit/AMD64/HalPageAlloc.cxx
+++ /dev/null
@@ -1,149 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#include <ArchKit/ArchKit.hxx>
-
-#define cVMHMagic (0xDEEFD00D)
-#define cPaddingVMH (16)
-
-#ifdef __ZKA_AMD64__
-#include <HALKit/AMD64/HalPageAlloc.hxx>
-#elif defined(__ZKA_ARM64__)
-#include <HALKit/ARM64/HalPageAlloc.hxx>
-#endif
-
-#include <NewKit/Defines.hxx>
-#include <NewKit/KernelCheck.hxx>
-
-Kernel::Boolean kAllocationInProgress = false;
-
-namespace Kernel
-{
- namespace HAL
- {
- namespace Detail
- {
- struct VIRTUAL_MEMORY_HEADER
- {
- UInt32 Magic;
- Boolean Present : 1;
- Boolean ReadWrite : 1;
- Boolean User : 1;
- SizeT Size;
- };
-
- struct VirtualMemoryHeaderTraits final
- {
- /// @brief Get next header.
- /// @param current
- /// @return
- VIRTUAL_MEMORY_HEADER* Next(VIRTUAL_MEMORY_HEADER* current)
- {
- if (current->Magic != cVMHMagic)
- return current;
-
- return current + sizeof(VIRTUAL_MEMORY_HEADER) + current->Size;
- }
-
- /// @brief Get previous header.
- /// @param current
- /// @return
- VIRTUAL_MEMORY_HEADER* Prev(VIRTUAL_MEMORY_HEADER* current)
- {
- if (current->Magic != cVMHMagic)
- return current;
-
- return current - sizeof(VIRTUAL_MEMORY_HEADER) - current->Size;
- }
- };
- } // namespace Detail
-
- /// @brief Allocates a new page of memory.
- /// @param sz the size of it.
- /// @param rw read/write flag.
- /// @param user user flag.
- /// @return the page table of it.
- STATIC auto hal_try_alloc_new_page(Boolean rw, Boolean user, SizeT size) -> VoidPtr
- {
- if (kAllocationInProgress)
- return nullptr;
-
- kAllocationInProgress = true;
-
- //! fetch from the start.
- Detail::VIRTUAL_MEMORY_HEADER* vmh_header = reinterpret_cast<Detail::VIRTUAL_MEMORY_HEADER*>(kKernelVMHStart);
- Detail::VirtualMemoryHeaderTraits traits;
-
- while (vmh_header->Present &&
- vmh_header->Magic == cVMHMagic)
- {
- vmh_header = traits.Next(vmh_header);
-
- if (vmh_header == reinterpret_cast<VoidPtr>(kBadPtr))
- {
- ke_stop(RUNTIME_CHECK_POINTER);
- return nullptr;
- }
- }
-
- vmh_header->Magic = cVMHMagic;
- vmh_header->Present = true;
- vmh_header->ReadWrite = rw;
- vmh_header->User = user;
- vmh_header->Size = size;
-
- kAllocationInProgress = false;
-
- VoidPtr result = reinterpret_cast<VoidPtr>(vmh_header + sizeof(Detail::VIRTUAL_MEMORY_HEADER));
-
- mm_update_pte(result, (rw ? eFlagsRw : 0));
- mm_update_pte(result, (user ? eFlagsUser : 0));
-
- return result;
- }
-
- /// @brief Allocate a new page to be used by the OS.
- /// @param rw read/write bit.
- /// @param user user bit.
- /// @return
- auto hal_alloc_page(Boolean rw, Boolean user, SizeT size) -> VoidPtr
- {
- kcout << "PageAlloc: Waiting now...";
-
- // Wait for a ongoing allocation to complete.
- while (kAllocationInProgress)
- {
- (Void)0;
- }
-
- kcout << ", done waiting, allocating...\r";
-
- if (size == 0)
- ++size;
-
- // Now allocate the page.
- return hal_try_alloc_new_page(rw, user, size);
- }
-
- auto hal_free_page(VoidPtr page_ptr) -> Bool
- {
- if (!page_ptr)
- return false;
-
- Detail::VIRTUAL_MEMORY_HEADER* result = reinterpret_cast<Detail::VIRTUAL_MEMORY_HEADER*>((UIntPtr)page_ptr - sizeof(Detail::VIRTUAL_MEMORY_HEADER));
-
- if (result->Magic != cVMHMagic)
- return false;
-
- if (result->Present != true)
- return true;
-
- result->Present = false;
-
- return true;
- }
- } // namespace HAL
-} // namespace Kernel
diff --git a/dev/ZKA/HALKit/AMD64/HalPageAlloc.hxx b/dev/ZKA/HALKit/AMD64/HalPageAlloc.hxx
index aadabd9c..8eb85e78 100644
--- a/dev/ZKA/HALKit/AMD64/HalPageAlloc.hxx
+++ b/dev/ZKA/HALKit/AMD64/HalPageAlloc.hxx
@@ -87,8 +87,8 @@ namespace Kernel::HAL
ZKA_PTE ALIGN(kPTEAlign) Pte[kPTEMax];
};
- auto hal_alloc_page(Boolean rw, Boolean user, SizeT size) -> VoidPtr;
- auto hal_free_page(VoidPtr page_ptr) -> Bool;
+ auto mm_alloc_bitmap(Boolean rw, Boolean user, SizeT size) -> VoidPtr;
+ auto mm_free_bitmap(VoidPtr page_ptr) -> Bool;
} // namespace Kernel::HAL
namespace Kernel
diff --git a/dev/ZKA/HALKit/AMD64/HalProcessor.cxx b/dev/ZKA/HALKit/AMD64/HalProcessor.cxx
index 407b7e51..3c34ab68 100644
--- a/dev/ZKA/HALKit/AMD64/HalProcessor.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalProcessor.cxx
@@ -27,32 +27,37 @@ namespace Kernel::HAL
// Access PML4 entry
volatile UInt64* pml4_entry = (volatile UInt64*)(((UInt64)pml4_base) + pml4_idx * sizeof(UIntPtr));
- UInt64 pdpt_base = *pml4_entry & ~0xFFF; // Remove flags (assuming 4KB pages)
+ UInt64 pdpt_base = *pml4_entry & ~0xFFF; // Remove flags (assuming 4KB pages)
// Access PDPT entry
volatile UInt64* pdpt_entry = (volatile UInt64*)(((UInt64)pdpt_base) + pdpt_idx * sizeof(UIntPtr));
- UInt64 pd_base = *pdpt_entry & ~0xFFF; // Remove flags
+ UInt64 pd_base = *pdpt_entry & ~0xFFF; // Remove flags
+ // Now PD
volatile UInt64* pd_entry = (volatile UInt64*)(((UInt64)pd_base) + pd_idx * sizeof(UIntPtr));
UInt64 pt_base = *pd_entry & ~0xFFF; // Remove flags
+ // And then PTE
volatile UInt64* page_addr = (volatile UInt64*)(((UInt64)pt_base) + (pte_idx * sizeof(UIntPtr)));
- if (page_addr)
- {
- if (flags & eFlagsPresent)
- *page_addr |= 0x01; // present bit
+ if (flags & eFlagsPresent)
+ *page_addr |= 0x01; // present bit
+ else if (flags & ~eFlagsPresent)
+ *page_addr &= 0x01; // present bit
- if (flags & eFlagsRw)
- *page_addr |= 0x02;
+ if (flags & eFlagsRw)
+ *page_addr |= 0x02;
+ else if (flags & ~eFlagsRw)
+ *page_addr &= 0x02; // present bit
- if (flags & eFlagsUser)
- *page_addr |= 0x02;
+ if (flags & eFlagsUser)
+ *page_addr |= 0x04;
+ else if (flags & ~eFlagsUser)
+ *page_addr &= 0x04; // present bit
- return Yes;
- }
+ hal_write_cr3((UIntPtr)pml4_base);
- return No;
+ return 0;
}
Void Out8(UInt16 port, UInt8 value)
diff --git a/dev/ZKA/HALKit/AMD64/Processor.hxx b/dev/ZKA/HALKit/AMD64/Processor.hxx
index a80e13cb..0636c291 100644
--- a/dev/ZKA/HALKit/AMD64/Processor.hxx
+++ b/dev/ZKA/HALKit/AMD64/Processor.hxx
@@ -56,11 +56,10 @@ namespace Kernel::HAL
/// @brief Virtual memory flags.
enum
{
- eFlagsPresent,
- eFlagsUser,
- eFlagsRw,
- eFlagsExecDisable,
- eFlagsCount,
+ eFlagsPresent = 0x01,
+ eFlagsRw = 0x02,
+ eFlagsUser = 0x04,
+ eFlagsCount = 0x3,
};
/// @brief Updates a PTE from pd_base.
@@ -102,15 +101,15 @@ namespace Kernel::HAL
/// @brief Stack frame (as retrieved from assembly.)
struct PACKED StackFrame final
{
- UIntPtr R8{0};
- UIntPtr R9{0};
- UIntPtr R10{0};
- UIntPtr FS{0};
- UIntPtr R12{0};
- UIntPtr R13{0};
- UIntPtr R14{0};
- UIntPtr R15{0};
- UIntPtr GS{0};
+ RawRegister R8{0};
+ RawRegister R9{0};
+ RawRegister R10{0};
+ RawRegister FS{0};
+ RawRegister R12{0};
+ RawRegister R13{0};
+ RawRegister R14{0};
+ RawRegister R15{0};
+ RawRegister GS{0};
};
typedef StackFrame* StackFramePtr;
@@ -293,7 +292,6 @@ EXTERN_C Kernel::Void hal_load_gdt(Kernel::HAL::RegisterGDT ptr);
#define kKernelIdtSize 0x100
#define kKernelInterruptId 0x32
-inline Kernel::VoidPtr kKernelVMHStart = nullptr;
inline Kernel::VoidPtr kKernelVirtualStart = nullptr;
inline Kernel::UIntPtr kKernelVirtualSize = 0UL;
diff --git a/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx b/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx
index 889b8c39..7eaa5bbb 100644
--- a/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx
+++ b/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx
@@ -63,7 +63,7 @@ Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented)
{
if (ports_implemented)
{
- kcout << "newoskrnl.exe: Port is implemented by host.\r";
+ kcout << "Port is implemented by host.\r";
UInt8 ipm = (mem_ahci->Ports[ahci_index].Ssts >> 8) & 0x0F;
UInt8 det = mem_ahci->Ports[ahci_index].Ssts & 0x0F;
@@ -72,8 +72,8 @@ Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented)
det == cAhciPresent &&
ipm == cAhciIPMActive)
{
- kcout << "newoskrnl.exe: Found AHCI controller.\r";
- kcout << "newoskrnl.exe: Device is of SATA type.\r";
+ kcout << "Found AHCI controller.\r";
+ kcout << "Device is of SATA type.\r";
detected = true;
diff --git a/dev/ZKA/HALKit/AMD64/Storage/ATA-PIO.cxx b/dev/ZKA/HALKit/AMD64/Storage/ATA-PIO.cxx
index 996b93ee..bc1a1f22 100644
--- a/dev/ZKA/HALKit/AMD64/Storage/ATA-PIO.cxx
+++ b/dev/ZKA/HALKit/AMD64/Storage/ATA-PIO.cxx
@@ -68,7 +68,7 @@ Boolean drv_std_init(UInt16 Bus, UInt8 Drive, UInt16& OutBus, UInt8& OutMaster)
drv_std_select(IO);
- Kernel::kcout << "newoskrnl.exe: Initializing drive...\r";
+ kcout << "Initializing drive...\r";
ATAInit_Retry:
// Bus init, NEIN bit.
@@ -80,7 +80,7 @@ ATAInit_Retry:
if (statRdy & ATA_SR_ERR)
{
- Kernel::kcout << "newoskrnl.exe: Failing drive...\r";
+ kcout << "Failing drive...\r";
return false;
}
@@ -107,7 +107,7 @@ ATAInit_Retry:
OutMaster = (Bus == ATA_PRIMARY_IO) ? ATA_MASTER : ATA_SLAVE;
- Kernel::kcout << "newoskrnl.exe: Create ATA module.\r";
+ kcout << "Created IDE module.\r";
return true;
}
diff --git a/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx b/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx
index 52e4f1ee..140c3370 100644
--- a/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx
+++ b/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx
@@ -7,14 +7,14 @@
#include <ArchKit/ArchKit.hxx>
#include <Modules/CoreCG/FbRenderer.hxx>
#include <FirmwareKit/Handover.hxx>
-#include <KernelKit/FileManager.hxx>
+#include <KernelKit/FileMgr.hxx>
#include <KernelKit/Framebuffer.hxx>
#include <KernelKit/Heap.hxx>
-#include <KernelKit/PEFCodeManager.hxx>
+#include <KernelKit/PEFCodeMgr.hxx>
#include <KernelKit/UserProcessScheduler.hxx>
#include <NewKit/Json.hxx>
#include <Modules/CoreCG/Accessibility.hxx>
-#include <KernelKit/CodeManager.hxx>
+#include <KernelKit/CodeMgr.hxx>
#include <Modules/ACPI/ACPIFactoryInterface.hxx>
#include <NetworkKit/IPC.hxx>
#include <CFKit/Property.hxx>
@@ -76,14 +76,12 @@ Kernel::Void hal_real_init(Kernel::Void) noexcept
// reset kAllocationInProgress field to zero.
kAllocationInProgress = false;
- kKernelVMHStart = kHandoverHeader->f_HeapStart;
-
// get page size.
kKernelVirtualSize = kHandoverHeader->f_VirtualSize;
// get virtual address start (for the heap)
kKernelVirtualStart = reinterpret_cast<Kernel::VoidPtr>(
- reinterpret_cast<Kernel::UIntPtr>(kHandoverHeader->f_VirtualStart));
+ reinterpret_cast<Kernel::UIntPtr>(kHandoverHeader->f_BitMapStart));
// get physical address start.
kKernelPhysicalStart = reinterpret_cast<Kernel::VoidPtr>(
@@ -94,14 +92,14 @@ Kernel::Void hal_real_init(Kernel::Void) noexcept
else
Kernel::HAL::mp_get_cores(nullptr);
- Kernel::kcout << "newoskrnl.exe: Creating filesystem and such.\r";
+ kcout << "Creating filesystem and such.\r";
- auto fs = new Kernel::NewFilesystemManager();
+ auto fs = new Kernel::NewFilesystemMgr();
MUST_PASS(fs);
MUST_PASS(fs->GetParser());
- Kernel::NewFilesystemManager::Mount(fs);
+ Kernel::NewFilesystemMgr::Mount(fs);
const auto cPassword = "ZKA_KERNEL_AUTHORITY";
diff --git a/dev/ZKA/HALKit/ARM64/HalPageAlloc.hxx b/dev/ZKA/HALKit/ARM64/HalPageAlloc.hxx
index ef3b6db1..ab77f1d0 100644
--- a/dev/ZKA/HALKit/ARM64/HalPageAlloc.hxx
+++ b/dev/ZKA/HALKit/ARM64/HalPageAlloc.hxx
@@ -96,7 +96,7 @@ namespace Kernel::HAL
LongDescLevel3 ALIGN(kPTEAlign) Pte[kPTEMax];
};
- VoidPtr hal_alloc_page(Boolean rw, Boolean user, SizeT size);
+ VoidPtr mm_alloc_bitmap(Boolean rw, Boolean user, SizeT size);
} // namespace Kernel::HAL
namespace Kernel
diff --git a/dev/ZKA/HALKit/ARM64/Processor.hxx b/dev/ZKA/HALKit/ARM64/Processor.hxx
index 1880d36c..ad2bdc7b 100644
--- a/dev/ZKA/HALKit/ARM64/Processor.hxx
+++ b/dev/ZKA/HALKit/ARM64/Processor.hxx
@@ -42,7 +42,6 @@ namespace Kernel::HAL
typedef StackFrame* StackFramePtr;
} // namespace Kernel::HAL
-inline Kernel::VoidPtr kKernelVMHStart = nullptr;
inline Kernel::VoidPtr kKernelVirtualStart = nullptr;
inline Kernel::UIntPtr kKernelVirtualSize = 0UL;
diff --git a/dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx b/dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx
index 97950a78..f1f6c718 100644
--- a/dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx
+++ b/dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx
@@ -53,13 +53,13 @@ namespace Kernel
/// @brief Enable flash memory at slot.
STATIC Void drv_enable_flash(Int32 arg)
{
- kcout << "newoskrnl.exe: Enabled FLSH hardware.\r";
+ kcout << "Enabled FLSH hardware.\r";
}
/// @brief Disable flash memory at slot.
STATIC Void drv_disable_flash(Int32 arg)
{
- kcout << "newoskrnl.exe: Disabled FLSH hardware.\r";
+ kcout << "Disabled FLSH hardware.\r";
}
} // namespace Kernel
diff --git a/dev/ZKA/HALKit/AXP/CoreSyscallHandlerDEC.cpp b/dev/ZKA/HALKit/AXP/CoreSyscallHandlerDEC.cpp
index 5f71380d..254e1ab6 100644
--- a/dev/ZKA/HALKit/AXP/CoreSyscallHandlerDEC.cpp
+++ b/dev/ZKA/HALKit/AXP/CoreSyscallHandlerDEC.cpp
@@ -14,11 +14,11 @@ EXTERN_C void rt_syscall_handle(Kernel::HAL::StackFrame* stack)
{
if (stack->Rcx <= (kSyscalls.Count() - 1))
{
- Kernel::kcout << "newoskrnl.exe: syscall: enter.\r";
+ kcout << "syscall: enter.\r";
if (kSyscalls[stack->Rcx].Leak().Leak().fHooked)
(kSyscalls[stack->Rcx].Leak().Leak().fProc)(stack);
- Kernel::kcout << "newoskrnl.exe: syscall: exit.\r";
+ kcout << "syscall: exit.\r";
}
}
diff --git a/dev/ZKA/HALKit/POWER/HalHardware.cxx b/dev/ZKA/HALKit/POWER/HalHardware.cxx
deleted file mode 100644
index 9fb841c8..00000000
--- a/dev/ZKA/HALKit/POWER/HalHardware.cxx
+++ /dev/null
@@ -1,19 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#include <HALKit/POWER/Processor.hxx>
-#include <KernelKit/DebugOutput.hxx>
-
-namespace Kernel
-{
- namespace HAL
- {
- UIntPtr hal_alloc_page(bool rw, bool user)
- {
- return 0;
- }
- } // namespace HAL
-} // namespace Kernel
diff --git a/dev/ZKA/KernelKit/CodeManager.hxx b/dev/ZKA/KernelKit/CodeMgr.hxx
index ef9d18f4..c8f9cca9 100644
--- a/dev/ZKA/KernelKit/CodeManager.hxx
+++ b/dev/ZKA/KernelKit/CodeMgr.hxx
@@ -2,8 +2,8 @@
Copyright ZKA Technologies.
- File: CodeManager.hpp
- Purpose: Code Manager and Shared Objects.
+ File: CodeMgr.hpp
+ Purpose: Code Mgr and Shared Objects.
Revision History:
@@ -14,9 +14,9 @@
#pragma once
-#include <KernelKit/PECodeManager.hxx>
-#include <KernelKit/PEFCodeManager.hxx>
-#include <KernelKit/PEFDLLInterface.hxx>
+#include <KernelKit/PECodeMgr.hxx>
+#include <KernelKit/PEFCodeMgr.hxx>
+#include <KernelKit/IPEFDLLObject.hxx>
namespace Kernel
{
diff --git a/dev/ZKA/KernelKit/DebugOutput.hxx b/dev/ZKA/KernelKit/DebugOutput.hxx
index fcf18bff..70f920d1 100644
--- a/dev/ZKA/KernelKit/DebugOutput.hxx
+++ b/dev/ZKA/KernelKit/DebugOutput.hxx
@@ -6,7 +6,7 @@
#pragma once
-#include <KernelKit/DeviceManager.hxx>
+#include <KernelKit/DeviceMgr.hxx>
#include <CompilerKit/CompilerKit.hxx>
#include <NewKit/OwnPtr.hxx>
#include <NewKit/Stream.hxx>
@@ -59,21 +59,24 @@ namespace Kernel
inline TerminalDevice end_line()
{
TerminalDevice selfTerm = TerminalDevice::The();
- selfTerm << "\r";
+
+ selfTerm.operator<<("\r");
return selfTerm;
}
inline TerminalDevice carriage_return()
{
TerminalDevice selfTerm = TerminalDevice::The();
- selfTerm << "\r";
+
+ selfTerm.operator<<("\r");
return selfTerm;
}
inline TerminalDevice tabulate()
{
TerminalDevice selfTerm = TerminalDevice::The();
- selfTerm << "\t";
+
+ selfTerm.operator<<("\t");
return selfTerm;
}
@@ -81,7 +84,8 @@ namespace Kernel
inline TerminalDevice bell()
{
TerminalDevice selfTerm = TerminalDevice::The();
- selfTerm << "\a";
+
+ selfTerm.operator<<("\a");
return selfTerm;
}
@@ -111,7 +115,7 @@ namespace Kernel
buf[0] = cNumbers[h];
buf[1] = 0;
- term << buf;
+ term.operator<<(buf);
return term;
}
@@ -139,7 +143,7 @@ namespace Kernel
buf[0] = cNumbers[h];
buf[1] = 0;
- term << buf;
+ term.operator<<(buf);
return term;
}
} // namespace Detail
@@ -148,7 +152,7 @@ namespace Kernel
{
TerminalDevice selfTerm = TerminalDevice::The();
- selfTerm << "0x";
+ selfTerm.operator<<("0x");
Detail::_write_number_hex(x, selfTerm);
return selfTerm;
@@ -186,5 +190,5 @@ namespace Kernel
#undef kcout
#endif // ifdef kcout
-#define kcout TerminalDevice::The()
-#define endl kcout << Kernel::end_line()
+#define kcout (Kernel::TerminalDevice::The() << "\e[0;31m [ " << __FILE__ << ": LINE: " << Kernel::number(__LINE__)); (Kernel::TerminalDevice::The() << " ] \e[0m" << ": ")
+#define endl Kernel::TerminalDevice::The() << Kernel::end_line()
diff --git a/dev/ZKA/KernelKit/DeviceManager.hxx b/dev/ZKA/KernelKit/DeviceMgr.hxx
index 5164ae28..473af601 100644
--- a/dev/ZKA/KernelKit/DeviceManager.hxx
+++ b/dev/ZKA/KernelKit/DeviceMgr.hxx
@@ -14,13 +14,15 @@
#pragma once
-/* Kernel device interface manager. */
-/* @file KernelKit/DeviceManager.hpp */
+/* Device manager. */
+/* @file KernelKit/DeviceMgr.hpp */
/* @brief Device abstraction and I/O buffer. */
#include <NewKit/ErrorOr.hxx>
#include <NewKit/Ref.hxx>
+#define cDevicePath "\\Mount\\"
+
// Last Rev
// Wed, Apr 3, 2024 9:09:41 AM
diff --git a/dev/ZKA/KernelKit/DriveManager.hxx b/dev/ZKA/KernelKit/DriveMgr.hxx
index 96fbd95d..8cec098c 100644
--- a/dev/ZKA/KernelKit/DriveManager.hxx
+++ b/dev/ZKA/KernelKit/DriveMgr.hxx
@@ -10,12 +10,12 @@
#include <KernelKit/UserProcessScheduler.hxx>
#include <CompilerKit/CompilerKit.hxx>
#include <KernelKit/DebugOutput.hxx>
-#include <KernelKit/DeviceManager.hxx>
+#include <KernelKit/DeviceMgr.hxx>
#include <KernelKit/LPC.hxx>
#include <NewKit/Defines.hxx>
#include <NewKit/String.hxx>
-#define kDriveManagerCount (4U)
+#define kDriveMgrCount (4U)
#define kDriveInvalidID (-1)
#define kDriveNameLen (32)
@@ -116,7 +116,7 @@ namespace Kernel
return &mD;
default: {
ErrLocal() = kErrorNoSuchDisk;
- kcout << "newoskrnl.exe: No such disk.\n";
+ kcout << "No such disk.\n";
break;
}
diff --git a/dev/ZKA/KernelKit/FileManager.hxx b/dev/ZKA/KernelKit/FileMgr.hxx
index 05f74a63..86eade6a 100644
--- a/dev/ZKA/KernelKit/FileManager.hxx
+++ b/dev/ZKA/KernelKit/FileMgr.hxx
@@ -2,7 +2,7 @@
Copyright ZKA Technologies.
- File: FileManager.hxx
+ File: FileMgr.hxx
Purpose: Kernel file manager.
------------------------------------------- */
@@ -12,16 +12,16 @@
Revision History:
31/01/24: Update documentation (amlel)
- 05/07/24: NewFS support, and fork support, updated constants and specs
+ 05/07/24: NeFS support, and fork support, updated constants and specs
as well.
------------------------------------------- */
#pragma once
-#ifdef __FSKIT_USE_NEWFS__
-#include <FSKit/NewFS.hxx>
-#endif // __FSKIT_USE_NEWFS__
+#ifdef __FSKIT_USE_NEFS__
+#include <FSKit/NeFS.hxx>
+#endif // __FSKIT_USE_NEFS__
#include <CompilerKit/CompilerKit.hxx>
#include <HintKit/CompilerHint.hxx>
@@ -71,31 +71,31 @@ namespace Kernel
typedef VoidPtr NodePtr;
/**
- @brief Filesystem Manager Interface class
+ @brief Filesystem Mgr Interface class
@brief Used to provide common I/O for a specific filesystem.
*/
- class FilesystemManagerInterface
+ class FilesystemMgrInterface
{
public:
- explicit FilesystemManagerInterface() = default;
- virtual ~FilesystemManagerInterface() = default;
+ explicit FilesystemMgrInterface() = default;
+ virtual ~FilesystemMgrInterface() = default;
public:
- ZKA_COPY_DEFAULT(FilesystemManagerInterface);
+ ZKA_COPY_DEFAULT(FilesystemMgrInterface);
public:
/// @brief Mounts a new filesystem into an active state.
/// @param interface the filesystem interface
/// @return
- static bool Mount(FilesystemManagerInterface* interface);
+ static bool Mount(FilesystemMgrInterface* interface);
/// @brief Unmounts the active filesystem
/// @return
- static FilesystemManagerInterface* Unmount();
+ static FilesystemMgrInterface* Unmount();
/// @brief Getter, gets the active filesystem.
/// @return
- static FilesystemManagerInterface* GetMounted();
+ static FilesystemMgrInterface* GetMounted();
public:
virtual NodePtr Create(_Input const Char* path) = 0;
@@ -135,19 +135,19 @@ namespace Kernel
virtual bool Rewind(_Input NodePtr node) = 0;
};
-#ifdef __FSKIT_USE_NEWFS__
+#ifdef __FSKIT_USE_NEFS__
/**
- * @brief Based of FilesystemManagerInterface, takes care of managing NewFS
+ * @brief Based of FilesystemMgrInterface, takes care of managing NeFS
* disks.
*/
- class NewFilesystemManager final : public FilesystemManagerInterface
+ class NewFilesystemMgr final : public FilesystemMgrInterface
{
public:
- explicit NewFilesystemManager();
- ~NewFilesystemManager() override;
+ explicit NewFilesystemMgr();
+ ~NewFilesystemMgr() override;
public:
- ZKA_COPY_DEFAULT(NewFilesystemManager);
+ ZKA_COPY_DEFAULT(NewFilesystemMgr);
public:
NodePtr Create(const Char* path) override;
@@ -176,15 +176,15 @@ namespace Kernel
_Input SizeT sz) override;
public:
- /// @brief Get NewFS parser class.
+ /// @brief Get NeFS parser class.
/// @return The filesystem parser class.
- NewFSParser* GetParser() noexcept;
+ NeFSParser* GetParser() noexcept;
private:
- NewFSParser* fImpl{nullptr};
+ NeFSParser* fImpl{nullptr};
};
-#endif // ifdef __FSKIT_USE_NEWFS__
+#endif // ifdef __FSKIT_USE_NEFS__
/**
* Usable FileStream
@@ -192,7 +192,7 @@ namespace Kernel
* @tparam FSClass Filesystem contract who takes care of it.
*/
template <typename Encoding = Char,
- typename FSClass = FilesystemManagerInterface>
+ typename FSClass = FilesystemMgrInterface>
class FileStream final
{
public:
@@ -408,7 +408,7 @@ namespace Kernel
}
}
- kcout << "newoskrnl.exe: new file: " << path << ".\r";
+ kcout << "new file: " << path << ".\r";
}
/// @brief destructor
diff --git a/dev/ZKA/KernelKit/MP.hxx b/dev/ZKA/KernelKit/HardwareThreadScheduler.hxx
index 51f3472a..cf5d6754 100644
--- a/dev/ZKA/KernelKit/MP.hxx
+++ b/dev/ZKA/KernelKit/HardwareThreadScheduler.hxx
@@ -103,7 +103,7 @@ namespace Kernel
operator bool() noexcept;
public:
- /// @brief Shared instance of the MP Manager.
+ /// @brief Shared instance of the MP Mgr.
/// @return the reference to the mp manager class.
STATIC HardwareThreadScheduler& The();
diff --git a/dev/ZKA/KernelKit/Heap.hxx b/dev/ZKA/KernelKit/Heap.hxx
index 65b71774..27c79c83 100644
--- a/dev/ZKA/KernelKit/Heap.hxx
+++ b/dev/ZKA/KernelKit/Heap.hxx
@@ -30,10 +30,10 @@ namespace Kernel
/// @return if it exists.
Boolean mm_is_valid_heap(VoidPtr heap_ptr);
- /// @brief allocate chunk of memory.
- /// @param sz size of pointer
- /// @param rw read write (true to enable it)
- /// @param user is it accesible by user processes?
+ /// @brief Allocate chunk of memory.
+ /// @param sz Size of pointer
+ /// @param rw Read Write bit.
+ /// @param user User enable bit.
/// @return The newly allocated pointer.
VoidPtr mm_new_ke_heap(const SizeT sz, const Bool rw, const Bool user);
diff --git a/dev/ZKA/KernelKit/DLLInterface.hxx b/dev/ZKA/KernelKit/IDLLObject.hxx
index 370363b7..39580307 100644
--- a/dev/ZKA/KernelKit/DLLInterface.hxx
+++ b/dev/ZKA/KernelKit/IDLLObject.hxx
@@ -13,11 +13,11 @@
namespace Kernel
{
- class DLLInterface
+ class IDLLObject
{
public:
- explicit DLLInterface() = default;
- virtual ~DLLInterface() = default;
+ explicit IDLLObject() = default;
+ virtual ~IDLLObject() = default;
struct DLL_TRAITS final
{
@@ -30,13 +30,14 @@ namespace Kernel
}
};
- ZKA_COPY_DEFAULT(DLLInterface);
+ ZKA_COPY_DEFAULT(IDLLObject);
virtual DLL_TRAITS** GetAddressOf() = 0;
virtual DLL_TRAITS* Get() = 0;
- virtual void Mount(DLL_TRAITS* to_mount) = 0;
- virtual void Unmount() = 0;
+ virtual Void Mount(DLL_TRAITS* to_mount) = 0;
+ virtual Void Unmount() = 0;
+
};
/// @brief Pure implementation, missing method/function handler.
diff --git a/dev/ZKA/KernelKit/PEFDLLInterface.hxx b/dev/ZKA/KernelKit/IPEFDLLObject.hxx
index ef1a844f..013173d1 100644
--- a/dev/ZKA/KernelKit/PEFDLLInterface.hxx
+++ b/dev/ZKA/KernelKit/IPEFDLLObject.hxx
@@ -11,9 +11,9 @@
#define __KERNELKIT_SHARED_OBJECT_HXX__
#include <KernelKit/PEF.hxx>
-#include <KernelKit/PEFCodeManager.hxx>
#include <NewKit/Defines.hxx>
-#include <KernelKit/DLLInterface.hxx>
+#include <KernelKit/PEFCodeMgr.hxx>
+#include <KernelKit/IDLLObject.hxx>
namespace Kernel
{
@@ -21,14 +21,14 @@ namespace Kernel
* @brief Shared Library class
* Load library from this class
*/
- class PEFDLLInterface final : public DLLInterface
+ class IPEFDLLObject final : public IDLLObject
{
public:
- explicit PEFDLLInterface() = default;
- ~PEFDLLInterface() = default;
+ explicit IPEFDLLObject() = default;
+ ~IPEFDLLObject() = default;
public:
- ZKA_COPY_DEFAULT(PEFDLLInterface);
+ ZKA_COPY_DEFAULT(IPEFDLLObject);
private:
DLL_TRAITS* fMounted{nullptr};
@@ -96,10 +96,10 @@ namespace Kernel
PEFLoader* fLoader{nullptr};
};
- typedef PEFDLLInterface* DLLInterfacePtr;
+ typedef IPEFDLLObject* IDLL;
- EXTERN_C DLLInterfacePtr rtl_init_shared_object(UserProcess* header);
- EXTERN_C Void rtl_fini_shared_object(UserProcess* header, DLLInterfacePtr lib, Bool* successful);
+ EXTERN_C IDLL rtl_init_shared_object(UserProcess* header);
+ EXTERN_C Void rtl_fini_shared_object(UserProcess* header, IDLL lib, Bool* successful);
} // namespace Kernel
#endif /* ifndef __KERNELKIT_SHARED_OBJECT_HXX__ */
diff --git a/dev/ZKA/KernelKit/PCI/Dma.hxx b/dev/ZKA/KernelKit/PCI/Dma.hxx
index 43df13f0..8e51bc45 100644
--- a/dev/ZKA/KernelKit/PCI/Dma.hxx
+++ b/dev/ZKA/KernelKit/PCI/Dma.hxx
@@ -6,7 +6,7 @@
#pragma once
-#include <KernelKit/DeviceManager.hxx>
+#include <KernelKit/DeviceMgr.hxx>
#include <KernelKit/PCI/Device.hxx>
#include <NewKit/Array.hxx>
#include <NewKit/OwnPtr.hxx>
diff --git a/dev/ZKA/KernelKit/PECodeManager.hxx b/dev/ZKA/KernelKit/PECodeMgr.hxx
index f42c7c21..7b84fbc1 100644
--- a/dev/ZKA/KernelKit/PECodeManager.hxx
+++ b/dev/ZKA/KernelKit/PECodeMgr.hxx
@@ -2,8 +2,8 @@
Copyright ZKA Technologies.
- File: PECodeManager.hxx
- Purpose: PE32+ Code Manager and Shared Objects.
+ File: PECodeMgr.hxx
+ Purpose: PE32+ Code Mgr and Shared Objects.
Revision History:
diff --git a/dev/ZKA/KernelKit/PEFCodeManager.hxx b/dev/ZKA/KernelKit/PEFCodeMgr.hxx
index dd6daca5..c2938fae 100644
--- a/dev/ZKA/KernelKit/PEFCodeManager.hxx
+++ b/dev/ZKA/KernelKit/PEFCodeMgr.hxx
@@ -10,7 +10,7 @@
#include <KernelKit/PEF.hxx>
#include <NewKit/ErrorOr.hxx>
#include <NewKit/String.hxx>
-#include <KernelKit/FileManager.hxx>
+#include <KernelKit/FileMgr.hxx>
#define kPefApplicationMime "application/x-newos-exec"
@@ -46,11 +46,11 @@ namespace Kernel
bool IsLoaded() noexcept;
private:
-#ifdef __FSKIT_USE_NEWFS__
- OwnPtr<FileStream<Char, NewFilesystemManager>> fFile;
+#ifdef __FSKIT_USE_NEFS__
+ OwnPtr<FileStream<Char, NewFilesystemMgr>> fFile;
#else
OwnPtr<FileStream<Char>> fFile;
-#endif // __FSKIT_USE_NEWFS__
+#endif // __FSKIT_USE_NEFS__
Ref<StringView> fPath;
VoidPtr fCachedBlob;
diff --git a/dev/ZKA/KernelKit/UserProcessScheduler.hxx b/dev/ZKA/KernelKit/UserProcessScheduler.hxx
index 809dbb7f..9585da29 100644
--- a/dev/ZKA/KernelKit/UserProcessScheduler.hxx
+++ b/dev/ZKA/KernelKit/UserProcessScheduler.hxx
@@ -14,7 +14,6 @@
#define kSchedMinMicroTime (AffinityKind::kStandard)
#define kSchedInvalidPID (-1)
-#define kSchedMaxStackSz (4096) /* Max stack sz */
#define kSchedProcessLimitPerTeam (16U)
////////////////////////////////////////////////////
@@ -28,7 +27,7 @@ namespace Kernel
//! @note Forward declarations.
class UserProcess;
- class PEFDLLInterface;
+ class IPEFDLLObject;
class UserProcessTeam;
class UserProcessScheduler;
class UserProcessHelper;
@@ -53,12 +52,12 @@ namespace Kernel
//! to run.
enum class AffinityKind : Int32
{
- kRealTime = 0500,
- kVeryHigh = 2500,
- kHigh = 2000,
- kStandard = 1500,
- kLowUsage = 1000,
- kVeryLowUsage = 5000,
+ kRealTime = 500,
+ kVeryHigh = 250,
+ kHigh = 200,
+ kStandard = 1000,
+ kLowUsage = 1500,
+ kVeryLowUsage = 2000,
};
// operator overloading.
@@ -147,24 +146,33 @@ namespace Kernel
User* Owner{nullptr};
HAL::StackFramePtr StackFrame{nullptr};
AffinityKind Affinity{AffinityKind::kStandard};
- ProcessStatusKind Status{ProcessStatusKind::kDead};
+ ProcessStatusKind Status{ProcessStatusKind::kDead};
UInt8* StackReserve{nullptr};
// Memory, images pointers.
- HeapPtrKind HeapCursor{nullptr};
ImagePtr Image{nullptr};
- HeapPtrKind HeapPtr{nullptr};
SizeT StackSize{mib_cast(8)};
- // shared library handle, reserved for kDLLKind types of executables only.
- PEFDLLInterface* DLLPtr{nullptr};
- UserProcess* Parent{nullptr};
+ //! @brief Shared library handle, reserved for kDLLKind types of executables only.
+ IPEFDLLObject* DLLPtr{nullptr};
+
+ /// @brief Parent process, reserved for threads only.
+ UserProcess* Parent{nullptr};
// Memory usage.
- SizeT UsedMemory{0};
- SizeT FreeMemory{0};
- SizeT SizeMemory{gib_cast(4)};
+ SizeT MemoryCursor{0};
+ SizeT MemoryLimit{gib_cast(128)};
+
+ struct PROCESS_MEMORY_ENTRY
+ {
+ VoidPtr MemoryEntry;
+
+ struct PROCESS_MEMORY_ENTRY *MemoryPrev;
+ struct PROCESS_MEMORY_ENTRY *MemoryNext;
+ } * MemoryEntryList{nullptr};
+
+ SizeT MemoryPD{0};
enum
{
@@ -212,9 +220,9 @@ namespace Kernel
//! @return Int32 local error code.
Int32& GetLocalCode() noexcept;
- const User* GetOwner() noexcept;
+ const User* GetOwner() noexcept;
const ProcessStatusKind& GetStatus() noexcept;
- const AffinityKind& GetAffinity() noexcept;
+ const AffinityKind& GetAffinity() noexcept;
private:
UInt32 fLastExitCode{0};
@@ -290,6 +298,7 @@ namespace Kernel
STATIC bool CanBeScheduled(UserProcess& process);
STATIC PID& TheCurrentPID();
STATIC SizeT StartScheduling();
+ STATIC Void Init();
};
const UInt32& sched_get_exit_code(void) noexcept;
diff --git a/dev/ZKA/NetworkKit/NetworkDevice.hxx b/dev/ZKA/NetworkKit/NetworkDevice.hxx
index c307a433..ed575e3e 100644
--- a/dev/ZKA/NetworkKit/NetworkDevice.hxx
+++ b/dev/ZKA/NetworkKit/NetworkDevice.hxx
@@ -7,7 +7,7 @@
#ifndef __INC_NETWORK_DEVICE_HPP__
#define __INC_NETWORK_DEVICE_HPP__
-#include <KernelKit/DeviceManager.hxx>
+#include <KernelKit/DeviceMgr.hxx>
#include <NetworkKit/IP.hxx>
/// @note Can either work with: Ethernet, GPRS, WiFi
diff --git a/dev/ZKA/NetworkKit/NetworkDevice.inl b/dev/ZKA/NetworkKit/NetworkDevice.inl
index 0ae5d9c6..4bc2a153 100644
--- a/dev/ZKA/NetworkKit/NetworkDevice.inl
+++ b/dev/ZKA/NetworkKit/NetworkDevice.inl
@@ -15,7 +15,7 @@ namespace Kernel
void (*on_cleanup)(void))
: DeviceInterface<NetworkDeviceCommand>(out, in), fCleanup(on_cleanup)
{
- kcout << "newoskrnl.exe: NetworkDevice initialized.\r";
+ kcout << "NetworkDevice initialized.\r";
MUST_PASS(out && in && on_cleanup);
}
@@ -24,7 +24,7 @@ namespace Kernel
{
MUST_PASS(fCleanup);
- kcout << "newoskrnl.exe: NetworkDevice cleanup.\r";
+ kcout << "NetworkDevice cleanup.\r";
if (fCleanup)
fCleanup();
diff --git a/dev/ZKA/NewKit/KernelCheck.hxx b/dev/ZKA/NewKit/KernelCheck.hxx
index 58a76acb..8797ff86 100644
--- a/dev/ZKA/NewKit/KernelCheck.hxx
+++ b/dev/ZKA/NewKit/KernelCheck.hxx
@@ -20,7 +20,7 @@ namespace Kernel
Kernel::ke_runtime_check(EXPR, FILE, STRINGIFY(LINE))
#ifdef __DEBUG__
-#define MUST_PASS(EXPR) __MUST_PASS(EXPR, __FILE__, __LINE__)
+#define MUST_PASS(EXPR) __MUST_PASS((EXPR), __FILE__, __LINE__)
#define assert(EXPR) MUST_PASS(EXPR, RUNTIME_CHECK_EXPRESSION)
#else
#define MUST_PASS(EXPR) (Kernel::Void)(EXPR)
@@ -43,6 +43,7 @@ enum RUNTIME_CHECK
RUNTIME_CHECK_BOOTSTRAP,
RUNTIME_CHECK_UNEXCPECTED,
RUNTIME_CHECK_FILESYSTEM,
+ RUNTIME_CHECK_VIRTUAL_OUT_OF_MEM,
RUNTIME_CHECK_COUNT,
};
diff --git a/dev/ZKA/NewKit/Macros.hxx b/dev/ZKA/NewKit/Macros.hxx
index 153b8c45..b20ddb8a 100644
--- a/dev/ZKA/NewKit/Macros.hxx
+++ b/dev/ZKA/NewKit/Macros.hxx
@@ -7,31 +7,31 @@
#pragma once
#ifndef KIB
-#define KIB(X) ((X) / 1024)
+#define KIB(X) (Kernel::UInt64)((X) / 1024)
#endif
#ifndef kib_cast
-#define kib_cast(X) ((X)*1024)
+#define kib_cast(X) (Kernel::UInt64)((X)*1024)
#endif
#ifndef MIB
-#define MIB(X) ((Kernel::UInt64)KIB(X) / 1024)
+#define MIB(X) (Kernel::UInt64)((Kernel::UInt64)KIB(X) / 1024)
#endif
#ifndef mib_cast
-#define mib_cast(X) ((Kernel::UInt64)kib_cast(X) * 1024)
+#define mib_cast(X) (Kernel::UInt64)((Kernel::UInt64)kib_cast(X) * 1024)
#endif
#ifndef GIB
-#define GIB(X) ((Kernel::UInt64)MIB(X) / 1024)
+#define GIB(X) (Kernel::UInt64)((Kernel::UInt64)MIB(X) / 1024)
#endif
#ifndef gib_cast
-#define gib_cast(X) ((Kernel::UInt64)mib_cast(X) * 1024)
+#define gib_cast(X) (Kernel::UInt64)((Kernel::UInt64)mib_cast(X) * 1024)
#endif
#ifndef TIB
-#define TIB(X) ((Kernel::UInt64)GIB(X) / 1024)
+#define TIB(X) (Kernel::UInt64)((Kernel::UInt64)GIB(X) / 1024)
#endif
#ifndef tib_cast
@@ -94,7 +94,7 @@
#define CANT_REACH() __builtin_unreachable()
#endif
-#define kBadPtr 0xFBFBFBFBFBFBFBFB
+#define kInvalidAddress 0xFBFBFBFBFBFBFBFB
#define kBadAddress 0x00000000000000
#define kMaxAddr 0xFFFFFFFFFFFFFFFF
#define kPathLen 255
@@ -119,3 +119,10 @@
/// @brief The main system driver.
#define kSysDrv "\\System\\startup.sys"
+
+/// @brief The main font file.
+#define kSysTTF "\\System\\urbanist.ttf"
+
+/// @brief The main kernel file.
+#define kSysChime "\\System\\startup.wav"
+
diff --git a/dev/ZKA/NewKit/PageAllocator.hxx b/dev/ZKA/NewKit/PageAllocator.hxx
index b485e722..5b19c0c2 100644
--- a/dev/ZKA/NewKit/PageAllocator.hxx
+++ b/dev/ZKA/NewKit/PageAllocator.hxx
@@ -7,13 +7,12 @@
#pragma once
#include <NewKit/Defines.hxx>
-#include <NewKit/PageManager.hxx>
+#include <NewKit/PageMgr.hxx>
namespace Kernel
{
namespace Detail
{
- VoidPtr create_page_wrapper(Boolean rw, Boolean user, SizeT pageSz);
void exec_disable(UIntPtr addr);
bool page_disable(UIntPtr addr);
} // namespace Detail
diff --git a/dev/ZKA/NewKit/PageManager.hxx b/dev/ZKA/NewKit/PageMgr.hxx
index 249c0cc9..1f6b5021 100644
--- a/dev/ZKA/NewKit/PageManager.hxx
+++ b/dev/ZKA/NewKit/PageMgr.hxx
@@ -15,7 +15,7 @@
namespace Kernel
{
- class PageManager;
+ class PageMgr;
class PTEWrapper final
{
@@ -31,7 +31,9 @@ namespace Kernel
const UIntPtr VirtualAddress();
void NoExecute(const bool enable = false);
- const bool& NoExecute();
+ const Bool& NoExecute();
+
+ operator bool() { return fVirtAddr; }
bool Reclaim();
bool Shareable();
@@ -50,25 +52,25 @@ namespace Kernel
Boolean fAccessed;
private:
- friend class PageManager;
+ friend class PageMgr;
friend class Pmm;
};
- struct PageManager final
+ struct PageMgr final
{
public:
- PageManager() = default;
- ~PageManager() = default;
+ PageMgr() = default;
+ ~PageMgr() = default;
- PageManager& operator=(const PageManager&) = default;
- PageManager(const PageManager&) = default;
+ PageMgr& operator=(const PageMgr&) = default;
+ PageMgr(const PageMgr&) = default;
public:
PTEWrapper Request(Boolean Rw, Boolean User, Boolean ExecDisable, SizeT Sz);
- bool Free(Ref<PTEWrapper*>& wrapper);
+ bool Free(Ref<PTEWrapper>& wrapper);
private:
- void FlushTLB(UIntPtr VirtAddr);
+ void FlushTLB();
private:
friend PTEWrapper;
diff --git a/dev/ZKA/NewKit/Pmm.hxx b/dev/ZKA/NewKit/Pmm.hxx
index 111b3044..cdf498d9 100644
--- a/dev/ZKA/NewKit/Pmm.hxx
+++ b/dev/ZKA/NewKit/Pmm.hxx
@@ -7,7 +7,7 @@
#pragma once
-#include <NewKit/PageManager.hxx>
+#include <NewKit/PageMgr.hxx>
#include <NewKit/Ref.hxx>
namespace Kernel
@@ -33,12 +33,12 @@ namespace Kernel
Boolean ToggleShare(Ref<PTEWrapper> refPage, Boolean enable = true);
/// @brief Get the page manager of this.
- Ref<PageManager>& Leak()
+ Ref<PageMgr>& Leak()
{
- return fPageManager;
+ return fPageMgr;
}
private:
- Ref<PageManager> fPageManager;
+ Ref<PageMgr> fPageMgr;
};
} // namespace Kernel
diff --git a/dev/ZKA/NewKit/Ref.hxx b/dev/ZKA/NewKit/Ref.hxx
index 977c353a..7f5167c2 100644
--- a/dev/ZKA/NewKit/Ref.hxx
+++ b/dev/ZKA/NewKit/Ref.hxx
@@ -84,7 +84,7 @@ namespace Kernel
NonNullRef(T* ref)
: fRef(ref, true)
{
- MUST_PASS(ref != nullptr);
+ MUST_PASS(ref);
}
Ref<T>& operator->()
diff --git a/dev/ZKA/Sources/CodeManager.cxx b/dev/ZKA/Sources/CodeMgr.cxx
index 7e180ac0..1d4f4a6e 100644
--- a/dev/ZKA/Sources/CodeManager.cxx
+++ b/dev/ZKA/Sources/CodeMgr.cxx
@@ -5,7 +5,7 @@
------------------------------------------- */
#include <NewKit/Utils.hxx>
-#include <KernelKit/CodeManager.hxx>
+#include <KernelKit/CodeMgr.hxx>
#include <KernelKit/UserProcessScheduler.hxx>
namespace Kernel
@@ -23,7 +23,7 @@ namespace Kernel
proc.SetImageStart(reinterpret_cast<VoidPtr>(main));
proc.Kind = UserProcess::kExeKind;
- proc.StackSize = kib_cast(8);
+ proc.StackSize = mib_cast(4);
rt_copy_memory((VoidPtr)processName, proc.Name, rt_string_len(processName));
diff --git a/dev/ZKA/Sources/CxxAbi-AMD64.cxx b/dev/ZKA/Sources/CxxAbi-AMD64.cxx
index 0b26e9da..908e26f4 100644
--- a/dev/ZKA/Sources/CxxAbi-AMD64.cxx
+++ b/dev/ZKA/Sources/CxxAbi-AMD64.cxx
@@ -19,7 +19,7 @@ Kernel::UIntPtr __dso_handle;
EXTERN_C void __cxa_pure_virtual()
{
- Kernel::kcout << "newoskrnl.exe: C++ placeholder method.\n";
+ kcout << "C++ placeholder method.\n";
}
EXTERN_C void ___chkstk_ms(void)
diff --git a/dev/ZKA/Sources/CxxAbi-ARM64.cxx b/dev/ZKA/Sources/CxxAbi-ARM64.cxx
index c11baf72..679be041 100644
--- a/dev/ZKA/Sources/CxxAbi-ARM64.cxx
+++ b/dev/ZKA/Sources/CxxAbi-ARM64.cxx
@@ -68,7 +68,7 @@ EXTERN_C void __cdecl _Init_thread_footer(int* const pOnce) noexcept
EXTERN_C void _purecall()
{
- Kernel::kcout << "newoskrnl.exe: C++ placeholder method.\n";
+ kcout << "C++ placeholder method.\n";
}
#endif // ifdef __ZKA_ARM64__
diff --git a/dev/ZKA/Sources/DLLMain.cxx b/dev/ZKA/Sources/DLLMain.cxx
index 934f418c..2aed9bf7 100644
--- a/dev/ZKA/Sources/DLLMain.cxx
+++ b/dev/ZKA/Sources/DLLMain.cxx
@@ -11,18 +11,18 @@
#include <ArchKit/ArchKit.hxx>
#include <CompilerKit/Detail.hxx>
#include <FirmwareKit/Handover.hxx>
-#include <KernelKit/FileManager.hxx>
+#include <KernelKit/FileMgr.hxx>
#include <KernelKit/Framebuffer.hxx>
#include <KernelKit/Heap.hxx>
#include <KernelKit/PEF.hxx>
-#include <KernelKit/PEFCodeManager.hxx>
+#include <KernelKit/PEFCodeMgr.hxx>
#include <KernelKit/UserProcessScheduler.hxx>
#include <NewKit/Json.hxx>
#include <NewKit/KernelCheck.hxx>
#include <NewKit/String.hxx>
#include <NewKit/Utils.hxx>
-#include <KernelKit/PEFCodeManager.hxx>
-#include <KernelKit/CodeManager.hxx>
+#include <KernelKit/PEFCodeMgr.hxx>
+#include <KernelKit/CodeMgr.hxx>
#include <CFKit/Property.hxx>
#include <Modules/CoreCG/WindowRenderer.hxx>
#include <KernelKit/Timer.hxx>
@@ -44,25 +44,25 @@ namespace Kernel::Detail
/// @brief Filesystem auto formatter, additional checks are also done by the class.
class FilesystemInstaller final
{
- Kernel::NewFilesystemManager* fNewFS{nullptr};
+ Kernel::NewFilesystemMgr* fNeFS{nullptr};
public:
/// @brief wizard constructor.
explicit FilesystemInstaller()
{
- if (Kernel::FilesystemManagerInterface::GetMounted())
+ if (Kernel::FilesystemMgrInterface::GetMounted())
{
- CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.exe: NewFS IFS already mounted by HAL (A:)", 10, 10, RGB(0, 0, 0));
- fNewFS = reinterpret_cast<Kernel::NewFilesystemManager*>(Kernel::FilesystemManagerInterface::GetMounted());
+ CG::CGDrawStringToWnd(cKernelWnd, "NeFS IFS already mounted by HAL (A:)", 10, 10, RGB(0, 0, 0));
+ fNeFS = reinterpret_cast<Kernel::NewFilesystemMgr*>(Kernel::FilesystemMgrInterface::GetMounted());
}
else
{
- // Mounts a NewFS from main drive.
- fNewFS = new Kernel::NewFilesystemManager();
+ // Mounts a NeFS from main drive.
+ fNeFS = new Kernel::NewFilesystemMgr();
- Kernel::FilesystemManagerInterface::Mount(fNewFS);
+ Kernel::FilesystemMgrInterface::Mount(fNeFS);
- CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.exe: Mounted NewFS IFS (A:)", 10, 10, RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, "Mounted NeFS IFS (A:)", 10, 10, RGB(0, 0, 0));
}
const Kernel::SizeT cDirCount = 7UL;
@@ -71,93 +71,50 @@ namespace Kernel::Detail
"\\Boot\\", "\\System\\", "\\Support\\", "\\Applications\\",
"\\Users\\", "\\Library\\", "\\Mount\\"};
- if (fNewFS->GetParser())
+ if (fNeFS->GetParser())
{
for (Kernel::SizeT dirIndx = 0UL; dirIndx < cDirCount; ++dirIndx)
{
- auto catalogDir = fNewFS->GetParser()->GetCatalog(cDirStr[dirIndx]);
+ auto catalogDir = fNeFS->GetParser()->GetCatalog(cDirStr[dirIndx]);
if (catalogDir)
{
- CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.exe: Catalog directory already exists: ", 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.exe: Catalog directory already exists: ")), RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, "Directory already exists: ", 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("Directory already exists: ")), RGB(0, 0, 0));
delete catalogDir;
continue;
}
- catalogDir = fNewFS->GetParser()->CreateCatalog(cDirStr[dirIndx], 0,
- kNewFSCatalogKindDir);
+ catalogDir = fNeFS->GetParser()->CreateCatalog(cDirStr[dirIndx], 0,
+ kNeFSCatalogKindDir);
- CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.exe: 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.exe: Catalog directory has been created: ")), RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, "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("Directory has been created: ")), RGB(0, 0, 0));
delete catalogDir;
}
}
-
- NFS_CATALOG_STRUCT* catalogDisk =
- this->fNewFS->GetParser()->GetCatalog(kSysPage);
- const Kernel::Char* cSrcName = "8K_SYS_PAGE_KERNEL";
-
- if (catalogDisk)
- {
- CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.exe: Catalog swap file already exists: ", 10 + (10 * (cDirCount + 1)), 10, RGB(0, 0, 0));
- CG::CGDrawStringToWnd(cKernelWnd, kSysPage, 10 + (10 * (cDirCount + 1)), 10 + (FONT_SIZE_X * rt_string_len("newoskrnl.exe: Catalog swap file already exists: ")), RGB(0, 0, 0));
-
- delete catalogDisk;
- }
- else
- {
- CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.exe: Catalog swap file created: ", 10 + (10 * (cDirCount + 1)), 10, RGB(0, 0, 0));
- CG::CGDrawStringToWnd(cKernelWnd, kSysPage, 10 + (10 * (cDirCount + 1)), 10 + (FONT_SIZE_X * rt_string_len("newoskrnl.exe: Catalog swap file created: ")), RGB(0, 0, 0));
-
- catalogDisk =
- (NFS_CATALOG_STRUCT*)this->Leak()->CreateSwapFile(kSysPage);
-
- NFS_FORK_STRUCT theDiskFork{0};
-
- Kernel::rt_copy_memory((Kernel::VoidPtr)(cSrcName), theDiskFork.ForkName,
- Kernel::rt_string_len(cSrcName));
-
- Kernel::rt_copy_memory((Kernel::VoidPtr)(catalogDisk->Name),
- theDiskFork.CatalogName,
- Kernel::rt_string_len(catalogDisk->Name));
-
- Kernel::Size sz_hdr = kNewFSForkSz;
-
- theDiskFork.DataSize = sz_hdr;
- theDiskFork.ResourceId = kNewFSCatalogKindExecutable | kNewFSCatalogKindPage;
- theDiskFork.ResourceKind = Kernel::kNewFSDataForkKind;
- theDiskFork.Kind = Kernel::kNewFSDataForkKind;
-
- fNewFS->GetParser()->CreateFork(catalogDisk, theDiskFork);
-
- delete catalogDisk;
- }
}
~FilesystemInstaller() = default;
ZKA_COPY_DEFAULT(FilesystemInstaller);
- /// @brief Grab the disk's NewFS reference.
- /// @return NewFilesystemManager the filesystem interface
- Kernel::NewFilesystemManager* Leak()
+ /// @brief Grab the disk's NeFS reference.
+ /// @return NewFilesystemMgr the filesystem interface
+ Kernel::NewFilesystemMgr* Leak()
{
- return fNewFS;
+ return fNeFS;
}
};
} // namespace Kernel::Detail
-namespace Kernel
+EXTERN_C ATTRIBUTE(naked) Kernel::Void HangCPU(Kernel::Void)
{
- EXTERN UserProcessScheduler* cProcessScheduler;
-} // namespace Kernel
-
-EXTERN_C Kernel::Void HangCPU(Kernel::Void)
-{
- while (1);
+ while (Yes)
+ {
+ }
}
/// @brief Application entrypoint.
@@ -186,14 +143,12 @@ EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void)
CG::CGDrawWindowList(&cKernelWnd, 1);
- CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.exe: Running System Component: ", 10, 10, RGB(0, 0, 0));
- CG::CGDrawStringToWnd(cKernelWnd, kSysDrv, 10, 10 + (FONT_SIZE_X * Kernel::rt_string_len("newoskrnl.exe: Running System Component: ")), RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, "Running System Component: ", 10, 10, RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, kSysDrv, 10, 10 + (FONT_SIZE_X * Kernel::rt_string_len("Running System Component: ")), RGB(0, 0, 0));
- /// @note BThread doesn't parse the symbols so doesn't nullify them, .bss is though.
- Kernel::cProcessScheduler = nullptr;
- Kernel::UserProcessHelper::StartScheduling();
+ CG::CGDrawStringToWnd(cKernelWnd, "Starting ZKA System...", 20, 10, RGB(0, 0, 0));
- CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.exe: Starting ZKA System...", 20, 10, RGB(0, 0, 0));
+ Kernel::UserProcessHelper::Init();
Kernel::sched_execute_thread(HangCPU, "HANG TEST");
@@ -201,6 +156,4 @@ EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void)
{
Kernel::UserProcessHelper::StartScheduling();
}
-
- Kernel::ke_stop(RUNTIME_CHECK_BOOTSTRAP);
}
diff --git a/dev/ZKA/Sources/DeviceManager.cxx b/dev/ZKA/Sources/DeviceMgr.cxx
index 229e0fb7..70d01984 100644
--- a/dev/ZKA/Sources/DeviceManager.cxx
+++ b/dev/ZKA/Sources/DeviceMgr.cxx
@@ -4,4 +4,4 @@
------------------------------------------- */
-#include <KernelKit/DeviceManager.hxx>
+#include <KernelKit/DeviceMgr.hxx>
diff --git a/dev/ZKA/Sources/DriveManager.cxx b/dev/ZKA/Sources/DriveMgr.cxx
index 84c9870f..5d0f7fc3 100644
--- a/dev/ZKA/Sources/DriveManager.cxx
+++ b/dev/ZKA/Sources/DriveMgr.cxx
@@ -5,18 +5,21 @@
------------------------------------------- */
#include <KernelKit/DebugOutput.hxx>
-#include <KernelKit/DriveManager.hxx>
+#include <KernelKit/DriveMgr.hxx>
+#include <NewKit/Utils.hxx>
+
+
#include <Modules/ATA/ATA.hxx>
#include <Modules/AHCI/AHCI.hxx>
-#include <NewKit/Utils.hxx>
+#include <Modules/NVME/Defines.hxx>
-/// @file DriveManager.cxx
+/// @file DriveMgr.cxx
/// @brief Kernel drive manager.
namespace Kernel
{
- static UInt16 kATAIO = 0U;
- static UInt8 kATAMaster = 0U;
+ STATIC UInt16 kATAIO = 0U;
+ STATIC UInt8 kATAMaster = 0U;
/// @brief reads from an ATA drive.
/// @param pckt
@@ -106,6 +109,7 @@ namespace Kernel
/// @return
Void io_drv_unimplemented(DriveTrait::DrivePacket* pckt)
{
+ ZKA_UNUSED(pckt);
}
/// @brief Makes a new drive.
@@ -139,7 +143,7 @@ namespace Kernel
trait.fVerify = ke_drv_check_disk;
trait.fDriveKind = io_drive_kind;
- kcout << "newoskrnl.exe: Construct drive with success.\r";
+ kcout << "Construct drive with success.\r";
return trait;
}
diff --git a/dev/ZKA/Sources/FS/FAT32.cxx b/dev/ZKA/Sources/FS/FAT32.cxx
index 1f5e194b..9e22e2a8 100644
--- a/dev/ZKA/Sources/FS/FAT32.cxx
+++ b/dev/ZKA/Sources/FS/FAT32.cxx
@@ -4,9 +4,9 @@
------------------------------------------- */
-#ifdef __FSKIT_INCLUDES_FAT32__
+#ifdef __FSKIT_INCLUDES_HPFS__
#include <FirmwareKit/GPT.hxx>
#include <FirmwareKit/EPM.hxx>
-#endif // ifdef __FSKIT_INCLUDES_FAT32__
+#endif // ifdef __FSKIT_INCLUDES_HPFS__
diff --git a/dev/ZKA/Sources/FS/NewFS.cxx b/dev/ZKA/Sources/FS/NeFS.cxx
index bf55a56f..68078ec3 100644
--- a/dev/ZKA/Sources/FS/NewFS.cxx
+++ b/dev/ZKA/Sources/FS/NeFS.cxx
@@ -4,12 +4,12 @@
------------------------------------------- */
-#ifdef __FSKIT_USE_NEWFS__
+#ifdef __FSKIT_USE_NEFS__
#include <Modules/AHCI/AHCI.hxx>
#include <Modules/ATA/ATA.hxx>
#include <Modules/Flash/Flash.hxx>
-#include <FSKit/NewFS.hxx>
+#include <FSKit/NeFS.hxx>
#include <KernelKit/LPC.hxx>
#include <NewKit/Crc32.hxx>
#include <NewKit/KernelCheck.hxx>
@@ -59,17 +59,18 @@ STATIC MountpointInterface sMountpointInterface;
/// @param theFork the fork itself.
/// @return the fork
/***********************************************************************************/
-_Output NFS_FORK_STRUCT* NewFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* catalog,
+_Output NFS_FORK_STRUCT* NeFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* catalog,
_Input NFS_FORK_STRUCT& theFork)
{
- if (catalog && theFork.ForkName[0] != 0)
+ if (catalog && theFork.ForkName[0] != 0 &&
+ theFork.DataSize <= kNeFSForkDataSz)
{
- Lba lba = (theFork.Kind == kNewFSDataForkKind) ? catalog->DataFork
+ Lba lba = (theFork.Kind == kNeFSDataForkKind) ? catalog->DataFork
: catalog->ResourceFork;
- kcout << "newoskrnl.exe: fork lba: " << hex_number(lba) << endl;
+ kcout << "fork lba: " << hex_number(lba) << endl;
- if (lba <= kNewFSCatalogStartAddress)
+ if (lba <= kNeFSCatalogStartAddress)
return nullptr;
auto drv = sMountpointInterface.A();
@@ -85,7 +86,7 @@ _Output NFS_FORK_STRUCT* NewFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* cata
/// do not check for anything. Loop until we get what we want, that is a free fork zone.
while (true)
{
- if (lba <= kNewFSCatalogStartAddress)
+ if (lba <= kNeFSCatalogStartAddress)
break;
drv.fPacket.fLba = lba;
@@ -96,22 +97,22 @@ _Output NFS_FORK_STRUCT* NewFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* cata
if (curFork.NextSibling > kBadAddress)
{
- kcout << "newoskrnl.exe: bad fork: " << hex_number(curFork.NextSibling) << endl;
+ kcout << "bad fork: " << hex_number(curFork.NextSibling) << endl;
break;
}
- kcout << "newoskrnl.exe: next fork: " << hex_number(curFork.NextSibling) << endl;
+ kcout << "next fork: " << hex_number(curFork.NextSibling) << endl;
- if (curFork.Flags == kNewFSFlagCreated)
+ if (curFork.Flags == kNeFSFlagCreated)
{
- kcout << "newoskrnl.exe: fork already exists.\r";
+ kcout << "fork already exists.\r";
/// sanity check.
if (StringBuilder::Equals(curFork.ForkName, theFork.ForkName) &&
StringBuilder::Equals(curFork.CatalogName, catalog->Name))
return nullptr;
- kcout << "newoskrnl.exe: next fork: " << hex_number(curFork.NextSibling) << endl;
+ kcout << "next fork: " << hex_number(curFork.NextSibling) << endl;
lbaOfPreviousFork = lba;
lba = curFork.NextSibling;
@@ -122,7 +123,7 @@ _Output NFS_FORK_STRUCT* NewFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* cata
{
/// This is a check that we have, in order to link the previous fork
/// entry.
- if (lba >= kNewFSCatalogStartAddress)
+ if (lba >= kNeFSCatalogStartAddress)
{
drv.fPacket.fLba = lbaOfPreviousFork;
drv.fPacket.fPacketSize = sizeof(NFS_FORK_STRUCT);
@@ -141,10 +142,10 @@ _Output NFS_FORK_STRUCT* NewFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* cata
constexpr auto cForkPadding =
4; /// this value gives us space for the data offset.
- theFork.Flags = kNewFSFlagCreated;
- theFork.DataOffset = lba - sizeof(NFS_FORK_STRUCT) * cForkPadding;
+ theFork.Flags = kNeFSFlagCreated;
+ theFork.DataOffset = lba - sizeof(NFS_FORK_STRUCT) - theFork.DataSize;
theFork.PreviousSibling = lbaOfPreviousFork;
- theFork.NextSibling = theFork.DataOffset - theFork.DataSize;
+ theFork.NextSibling = theFork.DataOffset + sizeof(NFS_FORK_STRUCT) + theFork.DataSize;
drv.fPacket.fLba = lba;
drv.fPacket.fPacketSize = sizeof(NFS_FORK_STRUCT);
@@ -153,10 +154,10 @@ _Output NFS_FORK_STRUCT* NewFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* cata
drv.fOutput(&drv.fPacket);
/// log what we have now.
- kcout << "newoskrnl.exe: Wrote fork data at: " << hex_number(theFork.DataOffset)
+ kcout << "Wrote fork data at: " << hex_number(theFork.DataOffset)
<< endl;
- kcout << "newoskrnl.exe: Wrote fork at: " << hex_number(lba) << endl;
+ kcout << "Wrote fork at: " << hex_number(lba) << endl;
return &theFork;
}
@@ -170,7 +171,7 @@ _Output NFS_FORK_STRUCT* NewFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* cata
/// @param name the fork name.
/// @return the fork.
/***********************************************************************************/
-_Output NFS_FORK_STRUCT* NewFSParser::FindFork(_Input NFS_CATALOG_STRUCT* catalog,
+_Output NFS_FORK_STRUCT* NeFSParser::FindFork(_Input NFS_CATALOG_STRUCT* catalog,
_Input const Char* name,
Boolean isDataFork)
{
@@ -225,9 +226,9 @@ _Output NFS_FORK_STRUCT* NewFSParser::FindFork(_Input NFS_CATALOG_STRUCT* catalo
/// @param name
/// @return catalog pointer.
/***********************************************************************************/
-_Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name)
+_Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name)
{
- return this->CreateCatalog(name, 0, kNewFSCatalogKindFile);
+ return this->CreateCatalog(name, 0, kNeFSCatalogKindFile);
}
/***********************************************************************************/
@@ -237,23 +238,23 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name)
/// @param kind the catalog kind.
/// @return catalog pointer.
/***********************************************************************************/
-_Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
+_Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name,
_Input const Int32& flags,
_Input const Int32& kind)
{
- kcout << "newoskrnl.exe: CreateCatalog(...)\r";
+ kcout << "CreateCatalog(...)\r";
Lba out_lba = 0UL;
- kcout << "newoskrnl.exe: Checking for extension...\r";
+ kcout << "Checking for extension...\r";
/// a directory should have a slash in the end.
- if (kind == kNewFSCatalogKindDir &&
+ if (kind == kNeFSCatalogKindDir &&
name[rt_string_len(name) - 1] != NewFilesystemHelper::Separator())
return nullptr;
/// a file shouldn't have a slash in the end.
- if (kind != kNewFSCatalogKindDir &&
+ if (kind != kNeFSCatalogKindDir &&
name[rt_string_len(name) - 1] == NewFilesystemHelper::Separator())
return nullptr;
@@ -261,13 +262,13 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
if (catalog_copy)
{
- kcout << "newoskrnl.exe: Catalog already exists: " << name << ".\r";
+ kcout << "Catalog already exists: " << name << ".\r";
ErrLocal() = kErrorFileExists;
return catalog_copy;
}
- Char parentName[kNewFSNodeNameLen] = {0};
+ Char parentName[kNeFSNodeNameLen] = {0};
for (SizeT indexName = 0UL; indexName < rt_string_len(name); ++indexName)
{
@@ -276,7 +277,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
if (*parentName == 0)
{
- kcout << "newoskrnl.exe: Parent name is NUL.\r";
+ kcout << "Parent name is NUL.\r";
ErrLocal() = kErrorFileNotFound;
return nullptr;
}
@@ -306,29 +307,29 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
auto drive = sMountpointInterface.A();
- if (catalog && catalog->Kind == kNewFSCatalogKindFile)
+ if (catalog && catalog->Kind == kNeFSCatalogKindFile)
{
- kcout << "newoskrnl.exe: Parent name is file.\r";
+ kcout << "Parent name is file.\r";
delete catalog;
return nullptr;
}
else if (!catalog)
{
- Char sectorBufPartBlock[kNewFSSectorSz] = {0};
+ Char sectorBufPartBlock[kNeFSSectorSz] = {0};
drive.fPacket.fPacketContent = sectorBufPartBlock;
- drive.fPacket.fPacketSize = kNewFSSectorSz;
- drive.fPacket.fLba = kNewFSRootCatalogStartAddress;
+ drive.fPacket.fPacketSize = kNeFSSectorSz;
+ drive.fPacket.fLba = kNeFSRootCatalogStartAddress;
drive.fInput(&drive.fPacket);
- constexpr auto cNewFSCatalogPadding = 4;
+ constexpr auto cNeFSCatalogPadding = 4;
NFS_ROOT_PARTITION_BLOCK* partBlock = (NFS_ROOT_PARTITION_BLOCK*)sectorBufPartBlock;
out_lba = partBlock->StartCatalog;
}
- constexpr SizeT cDefaultForkSize = kNewFSForkSize;
+ constexpr SizeT cDefaultForkSize = kNeFSForkSize;
NFS_CATALOG_STRUCT* catalogChild = new NFS_CATALOG_STRUCT();
@@ -340,12 +341,12 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
catalogChild->NextSibling = out_lba;
catalogChild->PrevSibling = out_lba;
catalogChild->Kind = kind;
- catalogChild->Flags = kNewFSFlagCreated | flagsList;
+ catalogChild->Flags = kNeFSFlagCreated | flagsList;
rt_copy_memory((VoidPtr)name, (VoidPtr)catalogChild->Name,
rt_string_len(name));
- UInt16 catalogBuf[kNewFSSectorSz] = {0};
+ UInt16 catalogBuf[kNeFSSectorSz] = {0};
Lba start_free = out_lba;
@@ -353,7 +354,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
rt_string_len("fs/newfs-packet"));
drive.fPacket.fPacketContent = catalogBuf;
- drive.fPacket.fPacketSize = kNewFSSectorSz;
+ drive.fPacket.fPacketSize = kNeFSSectorSz;
drive.fPacket.fLba = start_free;
drive.fInput(&drive.fPacket);
@@ -371,7 +372,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
{
nextSibling = reinterpret_cast<NFS_CATALOG_STRUCT*>(catalogBuf);
- if (start_free <= kNewFSRootCatalogStartAddress)
+ if (start_free <= kNeFSRootCatalogStartAddress)
{
delete catalogChild;
delete catalog;
@@ -382,17 +383,17 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
// ========================== //
// Allocate catalog now...
// ========================== //
- if ((nextSibling->Flags & kNewFSFlagCreated) == 0)
+ if ((nextSibling->Flags & kNeFSFlagCreated) == 0)
{
- Char sectorBufPartBlock[kNewFSSectorSz] = {0};
+ Char sectorBufPartBlock[kNeFSSectorSz] = {0};
drive.fPacket.fPacketContent = sectorBufPartBlock;
- drive.fPacket.fPacketSize = kNewFSSectorSz;
- drive.fPacket.fLba = kNewFSRootCatalogStartAddress;
+ drive.fPacket.fPacketSize = kNeFSSectorSz;
+ drive.fPacket.fLba = kNeFSRootCatalogStartAddress;
drive.fInput(&drive.fPacket);
- constexpr auto cNewFSCatalogPadding = 4;
+ constexpr auto cNeFSCatalogPadding = 4;
NFS_ROOT_PARTITION_BLOCK* partBlock = (NFS_ROOT_PARTITION_BLOCK*)sectorBufPartBlock;
@@ -410,7 +411,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
if (!StringBuilder::Equals(parentName, nextSibling->Name))
{
catalogChild->NextSibling =
- start_free + (sizeof(NFS_CATALOG_STRUCT) * cNewFSCatalogPadding);
+ start_free + (sizeof(NFS_CATALOG_STRUCT) * cNeFSCatalogPadding);
}
drive.fPacket.fPacketContent = catalogChild;
@@ -419,11 +420,11 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
drive.fOutput(&drive.fPacket);
- // Get NewFS partition's block.
+ // Get NeFS partition's block.
drive.fPacket.fPacketContent = sectorBufPartBlock;
- drive.fPacket.fPacketSize = kNewFSSectorSz;
- drive.fPacket.fLba = kNewFSRootCatalogStartAddress;
+ drive.fPacket.fPacketSize = kNeFSSectorSz;
+ drive.fPacket.fLba = kNeFSRootCatalogStartAddress;
drive.fInput(&drive.fPacket);
@@ -433,27 +434,27 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
drive.fOutput(&drive.fPacket);
- kcout << "newoskrnl.exe: Create new catalog, status: "
+ kcout << "Create new catalog, status: "
<< hex_number(catalogChild->Flags) << endl;
- kcout << "newoskrnl.exe: Create new catalog, name: " << catalogChild->Name
+ kcout << "Create new catalog, name: " << catalogChild->Name
<< endl;
delete catalog;
return catalogChild;
}
- else if ((nextSibling->Flags & kNewFSFlagCreated) &&
+ else if ((nextSibling->Flags & kNeFSFlagCreated) &&
StringBuilder::Equals(nextSibling->Name, name))
{
return nextSibling;
}
- constexpr auto cNewFSCatalogPadding = 4;
+ constexpr auto cNeFSCatalogPadding = 4;
//// @note that's how we find the next catalog in the partition block.
- start_free = start_free + (sizeof(NFS_CATALOG_STRUCT) * cNewFSCatalogPadding);
+ start_free = start_free + (sizeof(NFS_CATALOG_STRUCT) * cNeFSCatalogPadding);
drive.fPacket.fPacketContent = catalogBuf;
- drive.fPacket.fPacketSize = kNewFSSectorSz;
+ drive.fPacket.fPacketSize = kNeFSSectorSz;
drive.fPacket.fLba = start_free;
drive.fInput(&drive.fPacket);
@@ -463,10 +464,10 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
return nullptr;
}
-/// @brief Make a EPM+NewFS drive out of the disk.
+/// @brief Make a EPM+NeFS drive out of the disk.
/// @param drive The drive to write on.
/// @return If it was sucessful, see ErrLocal().
-bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endLba, _Input const Int32 flags, const Char* part_name)
+bool NeFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endLba, _Input const Int32 flags, const Char* part_name)
{
if (*part_name == 0 ||
endLba == 0)
@@ -485,40 +486,40 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL
return false;
}
- Char fs_buf[kNewFSSectorSz] = {0};
+ Char fs_buf[kNeFSSectorSz] = {0};
- Lba start = kNewFSRootCatalogStartAddress;
+ Lba start = kNeFSRootCatalogStartAddress;
drive->fPacket.fPacketContent = fs_buf;
- drive->fPacket.fPacketSize = kNewFSSectorSz;
+ drive->fPacket.fPacketSize = kNeFSSectorSz;
drive->fPacket.fLba = start;
drive->fInput(&drive->fPacket);
- if (flags & kNewFSPartitionTypeBoot)
+ if (flags & kNeFSPartitionTypeBoot)
{
// make it bootable when needed.
- Char bufEpmHdr[kNewFSSectorSz] = {0};
+ Char bufEpmHdr[kNeFSSectorSz] = {0};
BOOT_BLOCK_STRUCT* epmBoot = (BOOT_BLOCK_STRUCT*)bufEpmHdr;
// EPM header.
- constexpr auto cFsName = "NewFS";
+ constexpr auto cFsName = "NeFS";
constexpr auto cBlockName = "ZKA:";
rt_copy_memory(reinterpret_cast<VoidPtr>(const_cast<Char*>(cFsName)), epmBoot->Fs, rt_string_len(cFsName));
- epmBoot->FsVersion = kNewFSVersionInteger;
+ epmBoot->FsVersion = kNeFSVersionInteger;
epmBoot->LbaStart = start;
- epmBoot->SectorSz = kNewFSSectorSz;
+ epmBoot->SectorSz = kNeFSSectorSz;
rt_copy_memory(reinterpret_cast<VoidPtr>(const_cast<Char*>(cBlockName)), epmBoot->Name, rt_string_len(cBlockName));
rt_copy_memory(reinterpret_cast<VoidPtr>(const_cast<Char*>(kEPMMagic)), epmBoot->Magic, rt_string_len(kEPMMagic));
Lba outEpmLba = kEpmBase;
- Char buf[kNewFSSectorSz];
+ Char buf[kNeFSSectorSz];
Lba prevStart = 0;
SizeT cnt = 0;
@@ -526,7 +527,7 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL
while (drive->fPacket.fPacketGood)
{
drive->fPacket.fPacketContent = buf;
- drive->fPacket.fPacketSize = kNewFSSectorSz;
+ drive->fPacket.fPacketSize = kNeFSSectorSz;
drive->fPacket.fLba = outEpmLba;
drive->fInput(&drive->fPacket);
@@ -542,7 +543,7 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL
epmBoot->NumBlocks = cnt;
drive->fPacket.fPacketContent = bufEpmHdr;
- drive->fPacket.fPacketSize = kNewFSSectorSz;
+ drive->fPacket.fPacketSize = kNeFSSectorSz;
drive->fPacket.fLba = outEpmLba;
drive->fOutput(&drive->fPacket);
@@ -566,16 +567,16 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL
// check for an empty partition here.
if (partBlock->PartitionName[0] == 0 &&
- rt_string_cmp(partBlock->Ident, kNewFSIdent, kNewFSIdentLen))
+ rt_string_cmp(partBlock->Ident, kNeFSIdent, kNeFSIdentLen))
{
// partition is free and valid.
- partBlock->Version = kNewFSVersionInteger;
+ partBlock->Version = kNeFSVersionInteger;
const auto cUntitledHD = part_name;
- rt_copy_memory((VoidPtr)kNewFSIdent, (VoidPtr)partBlock->Ident,
- kNewFSIdentLen);
+ rt_copy_memory((VoidPtr)kNeFSIdent, (VoidPtr)partBlock->Ident,
+ kNeFSIdentLen);
rt_copy_memory((VoidPtr)cUntitledHD, (VoidPtr)partBlock->PartitionName,
rt_string_len(cUntitledHD));
@@ -585,41 +586,41 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL
SizeT sectorCount = drv_std_get_sector_count();
SizeT diskSize = drv_std_get_drv_size();
- partBlock->Kind = kNewFSPartitionTypeStandard;
- partBlock->StartCatalog = kNewFSCatalogStartAddress;
- partBlock->Flags = kNewFSPartitionTypeStandard;
+ partBlock->Kind = kNeFSPartitionTypeStandard;
+ partBlock->StartCatalog = kNeFSCatalogStartAddress;
+ partBlock->Flags = kNeFSPartitionTypeStandard;
partBlock->CatalogCount = sectorCount / sizeof(NFS_CATALOG_STRUCT);
partBlock->SectorCount = sectorCount;
partBlock->DiskSize = diskSize;
partBlock->FreeCatalog = sectorCount / sizeof(NFS_CATALOG_STRUCT);
drive->fPacket.fPacketContent = fs_buf;
- drive->fPacket.fPacketSize = kNewFSSectorSz;
- drive->fPacket.fLba = kNewFSRootCatalogStartAddress;
+ drive->fPacket.fPacketSize = kNeFSSectorSz;
+ drive->fPacket.fLba = kNeFSRootCatalogStartAddress;
drive->fOutput(&drive->fPacket);
- kcout << "newoskrnl.exe: drive kind: " << drive->fDriveKind() << endl;
+ kcout << "drive kind: " << drive->fDriveKind() << endl;
- kcout << "newoskrnl.exe: partition name: " << partBlock->PartitionName << endl;
- kcout << "newoskrnl.exe: start: " << hex_number(partBlock->StartCatalog) << endl;
- kcout << "newoskrnl.exe: number of catalogs: " << hex_number(partBlock->CatalogCount) << endl;
- kcout << "newoskrnl.exe: free catalog: " << hex_number(partBlock->FreeCatalog) << endl;
- kcout << "newoskrnl.exe: free sectors: " << hex_number(partBlock->FreeSectors) << endl;
- kcout << "newoskrnl.exe: sector size: " << hex_number(partBlock->SectorSize) << endl;
+ kcout << "partition name: " << partBlock->PartitionName << endl;
+ kcout << "start: " << hex_number(partBlock->StartCatalog) << endl;
+ kcout << "number of catalogs: " << hex_number(partBlock->CatalogCount) << endl;
+ kcout << "free catalog: " << hex_number(partBlock->FreeCatalog) << endl;
+ kcout << "free sectors: " << hex_number(partBlock->FreeSectors) << endl;
+ kcout << "sector size: " << hex_number(partBlock->SectorSize) << endl;
// write the root catalog.
- this->CreateCatalog(kNewFSRoot, 0, kNewFSCatalogKindDir);
+ this->CreateCatalog(kNeFSRoot, 0, kNeFSCatalogKindDir);
return true;
}
- kcout << "newoskrnl.exe: partition block already exists.\r";
+ kcout << "partition block already exists.\r";
start += partBlock->DiskSize;
drive->fPacket.fPacketContent = fs_buf;
- drive->fPacket.fPacketSize = kNewFSSectorSz;
+ drive->fPacket.fPacketSize = kNeFSSectorSz;
drive->fPacket.fLba = start;
drive->fInput(&drive->fPacket);
@@ -632,8 +633,15 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL
/// @param catalog the catalog itself
/// @param data the data.
/// @return if the catalog w rote the contents successfully.
-bool NewFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool isRsrcFork, _Input VoidPtr data, _Input SizeT sizeOfData, _Input const Char* forkName)
+bool NeFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool isRsrcFork, _Input VoidPtr data, _Input SizeT sizeOfData, _Input const Char* forkName)
{
+ if (sizeOfData > kNeFSForkDataSz ||
+ sizeOfData == 0)
+ return No;
+
+ auto buf = new UInt8[kNeFSForkDataSz];
+ rt_copy_memory(data, buf, sizeOfData);
+
auto drive = sMountpointInterface.A();
rt_copy_memory((VoidPtr) "fs/newfs-packet", drive.fPacket.fPacketMime,
@@ -646,7 +654,7 @@ bool NewFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool
NFS_FORK_STRUCT prevFork{};
// sanity check of the fork position as the condition to run the loop.
- while (startFork >= kNewFSCatalogStartAddress)
+ while (startFork >= kNeFSCatalogStartAddress)
{
drive.fPacket.fPacketContent = forkDataIn;
drive.fPacket.fPacketSize = sizeof(NFS_FORK_STRUCT);
@@ -655,50 +663,43 @@ bool NewFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool
drive.fInput(&drive.fPacket);
// check the fork, if it's position is valid.
- if (forkDataIn->DataOffset <= kNewFSCatalogStartAddress)
+ if (forkDataIn->DataOffset <= kNeFSCatalogStartAddress)
{
ErrLocal() = kErrorDiskIsCorrupted;
- kcout << "newoskrnl.exe: Invalid fork offset.\r";
+ kcout << "Invalid fork offset.\r";
return false;
}
- if (forkDataIn->Flags != kNewFSFlagUnallocated &&
- forkDataIn->Flags != kNewFSFlagDeleted &&
+ if (forkDataIn->Flags != kNeFSFlagUnallocated &&
+ forkDataIn->Flags != kNeFSFlagDeleted &&
StringBuilder::Equals(forkDataIn->ForkName, forkName) &&
- StringBuilder::Equals(forkDataIn->CatalogName, catalog->Name))
+ StringBuilder::Equals(forkDataIn->CatalogName, catalog->Name) &&
+ forkDataIn->DataSize == sizeOfData)
{
// ===================================================== //
- // Store size of blob now.
+ // Store the blob now.
// ===================================================== //
- if (forkDataIn->DataSize < sizeOfData &&
- forkDataIn->DataSize < 1)
- {
- startFork = forkDataIn->NextSibling;
- continue;
- }
-
- forkDataIn->Flags = kNewFSFlagCreated;
- forkDataIn->DataOffset = startFork + sizeof(NFS_FORK_STRUCT);
- forkDataIn->DataSize = sizeOfData;
+ forkDataIn->Flags = kNeFSFlagCreated;
- drive.fPacket.fPacketContent = data;
- drive.fPacket.fPacketSize = sizeOfData;
- drive.fPacket.fLba = startFork + sizeof(NFS_FORK_STRUCT);
+ drive.fPacket.fPacketContent = buf;
+ drive.fPacket.fPacketSize = kNeFSForkDataSz;
+ drive.fPacket.fLba = forkDataIn->DataOffset;
- kcout << "newoskrnl.exe: data offset: " << hex_number(forkDataIn->DataOffset) << endl;
+ kcout << "data offset: " << hex_number(forkDataIn->DataOffset) << endl;
drive.fOutput(&drive.fPacket);
- drive.fPacket.fPacketContent = &forkDataIn;
+ drive.fPacket.fPacketContent = forkDataIn;
drive.fPacket.fPacketSize = sizeof(NFS_FORK_STRUCT);
- drive.fPacket.fLba = startFork;
+ drive.fPacket.fLba = startFork - sizeof(NFS_FORK_STRUCT);
drive.fOutput(&drive.fPacket);
- kcout << "newoskrnl.exe: wrote fork at offset: " << hex_number(forkDataIn->DataOffset) << endl;
+ kcout << "wrote fork at offset: " << hex_number(forkDataIn->DataOffset) << endl;
+ kcout << "wrote fork at offset: " << hex_number(startFork - sizeof(NFS_FORK_STRUCT)) << endl;
delete catalog;
@@ -718,10 +719,10 @@ bool NewFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool
/// @brief
/// @param catalogName the catalog name.
/// @return the newly found catalog.
-_Output NFS_CATALOG_STRUCT* NewFSParser::FindCatalog(_Input const Char* catalogName,
+_Output NFS_CATALOG_STRUCT* NeFSParser::FindCatalog(_Input const Char* catalogName,
Lba& out_lba)
{
- kcout << "newoskrnl.exe: start finding catalog...\r";
+ kcout << "start finding catalog...\r";
NFS_ROOT_PARTITION_BLOCK fs_buf{0};
auto drive = sMountpointInterface.A();
@@ -731,7 +732,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::FindCatalog(_Input const Char* catalogN
drive.fPacket.fPacketContent = &fs_buf;
drive.fPacket.fPacketSize = sizeof(NFS_ROOT_PARTITION_BLOCK);
- drive.fPacket.fLba = kNewFSRootCatalogStartAddress;
+ drive.fPacket.fLba = kNeFSRootCatalogStartAddress;
drive.fInput(&drive.fPacket);
@@ -752,7 +753,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::FindCatalog(_Input const Char* catalogN
if (!StringBuilder::Equals(catalogName, NewFilesystemHelper::Root()))
{
- Char parentName[kNewFSNodeNameLen] = {0};
+ Char parentName[kNeFSNodeNameLen] = {0};
for (SizeT indexFill = 0; indexFill < rt_string_len(catalogName); ++indexFill)
{
@@ -789,9 +790,9 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::FindCatalog(_Input const Char* catalogN
}
}
- kcout << "newoskrnl.exe: fetching catalog...\r";
+ kcout << "fetching catalog...\r";
-NewFSSearchThroughCatalogList:
+NeFSSearchThroughCatalogList:
while (drive.fPacket.fPacketGood)
{
drive.fPacket.fLba = startCatalogList;
@@ -805,25 +806,25 @@ NewFSSearchThroughCatalogList:
if (StringBuilder::Equals(catalogName, catalog->Name))
{
/// ignore unallocated catalog, break
- if (!(catalog->Flags & kNewFSFlagCreated))
+ if (!(catalog->Flags & kNeFSFlagCreated))
{
- goto NewFSContinueSearch;
+ goto NeFSContinueSearch;
}
NFS_CATALOG_STRUCT* catalogPtr = new NFS_CATALOG_STRUCT();
rt_copy_memory(catalog, catalogPtr, sizeof(NFS_CATALOG_STRUCT));
- kcout << "newoskrnl.exe: found catalog at: " << hex_number(startCatalogList) << endl;
- kcout << "newoskrnl.exe: found catalog at: " << catalog->Name << endl;
+ kcout << "found catalog at: " << hex_number(startCatalogList) << endl;
+ kcout << "found catalog at: " << catalog->Name << endl;
out_lba = startCatalogList;
return catalogPtr;
}
- NewFSContinueSearch:
+ NeFSContinueSearch:
startCatalogList = catalog->NextSibling;
- if (startCatalogList <= kNewFSRootCatalogStartAddress)
+ if (startCatalogList <= kNeFSRootCatalogStartAddress)
break;
}
@@ -832,7 +833,7 @@ NewFSSearchThroughCatalogList:
localSearchFirst = false;
startCatalogList = cCtartCatalogList;
- goto NewFSSearchThroughCatalogList;
+ goto NeFSSearchThroughCatalogList;
}
out_lba = 0UL;
@@ -842,7 +843,7 @@ NewFSSearchThroughCatalogList:
/// @brief Get catalog from filesystem.
/// @param name the catalog's name/
/// @return
-_Output NFS_CATALOG_STRUCT* NewFSParser::GetCatalog(_Input const Char* name)
+_Output NFS_CATALOG_STRUCT* NeFSParser::GetCatalog(_Input const Char* name)
{
Lba unused = 0;
return this->FindCatalog(name, unused);
@@ -851,7 +852,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::GetCatalog(_Input const Char* name)
/// @brief Closes a catalog, (frees it).
/// @param catalog the catalog to close.
/// @return
-Boolean NewFSParser::CloseCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog)
+Boolean NeFSParser::CloseCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog)
{
if (!catalog)
return false;
@@ -865,7 +866,7 @@ Boolean NewFSParser::CloseCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog)
/// @brief Mark catalog as removed.
/// @param catalog The catalog structure.
/// @return if the catalog was removed or not.
-Boolean NewFSParser::RemoveCatalog(_Input const Char* catalogName)
+Boolean NeFSParser::RemoveCatalog(_Input const Char* catalogName)
{
if (!catalogName ||
StringBuilder::Equals(catalogName, NewFilesystemHelper::Root()))
@@ -877,10 +878,10 @@ Boolean NewFSParser::RemoveCatalog(_Input const Char* catalogName)
Lba out_lba = 0;
auto catalog = this->FindCatalog(catalogName, out_lba);
- if (out_lba >= kNewFSCatalogStartAddress ||
- catalog->Flags == kNewFSFlagCreated)
+ if (out_lba >= kNeFSCatalogStartAddress ||
+ catalog->Flags == kNeFSFlagCreated)
{
- catalog->Flags = kNewFSFlagDeleted;
+ catalog->Flags = kNeFSFlagDeleted;
auto drive = sMountpointInterface.A();
@@ -896,7 +897,7 @@ Boolean NewFSParser::RemoveCatalog(_Input const Char* catalogName)
Char partitionBlockBuf[sizeof(NFS_ROOT_PARTITION_BLOCK)] = {0};
- drive.fPacket.fLba = kNewFSRootCatalogStartAddress;
+ drive.fPacket.fLba = kNeFSRootCatalogStartAddress;
drive.fPacket.fPacketContent = partitionBlockBuf;
drive.fPacket.fPacketSize = sizeof(NFS_ROOT_PARTITION_BLOCK);
@@ -928,7 +929,7 @@ Boolean NewFSParser::RemoveCatalog(_Input const Char* catalogName)
/// @return
/***********************************************************************************/
-VoidPtr NewFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
+VoidPtr NeFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
_Input Bool isRsrcFork,
_Input SizeT dataSz,
_Input const Char* forkName)
@@ -939,12 +940,12 @@ VoidPtr NewFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
return nullptr;
}
- constexpr auto cNewFSCatalogPadding = 4;
+ constexpr auto cNeFSCatalogPadding = 4;
Lba dataForkLba = (!isRsrcFork) ? catalog->DataFork : catalog->ResourceFork;
Size dataForkSize = (!isRsrcFork) ? catalog->DataForkSize : catalog->ResourceForkSize;
- kcout << "newoskrnl.exe: catalog " << catalog->Name
+ kcout << "catalog " << catalog->Name
<< ", fork: " << hex_number(dataForkLba) << endl;
NFS_FORK_STRUCT* fs_buf = new NFS_FORK_STRUCT();
@@ -955,7 +956,7 @@ VoidPtr NewFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
NFS_FORK_STRUCT* fs_fork_data = nullptr;
- while (dataForkLba > kNewFSCatalogStartAddress)
+ while (dataForkLba > kNeFSCatalogStartAddress)
{
drive.fPacket.fLba = dataForkLba;
drive.fPacket.fPacketSize = sizeof(NFS_FORK_STRUCT);
@@ -965,8 +966,8 @@ VoidPtr NewFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
fs_fork_data = fs_buf;
- kcout << "newoskrnl.exe: ForkName: " << fs_fork_data->ForkName << endl;
- kcout << "newoskrnl.exe: CatalogName: " << fs_fork_data->CatalogName << endl;
+ kcout << "ForkName: " << fs_fork_data->ForkName << endl;
+ kcout << "CatalogName: " << fs_fork_data->CatalogName << endl;
if (StringBuilder::Equals(forkName, fs_fork_data->ForkName) &&
StringBuilder::Equals(catalog->Name, fs_fork_data->CatalogName))
@@ -975,7 +976,7 @@ VoidPtr NewFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
dataForkLba = fs_fork_data->NextSibling;
}
- if (dataForkLba < kNewFSCatalogStartAddress)
+ if (dataForkLba < kNeFSCatalogStartAddress)
{
delete[] fs_buf;
return nullptr;
@@ -991,7 +992,7 @@ VoidPtr NewFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
/// @return if the seeking was successful.
/***********************************************************************************/
-bool NewFSParser::Seek(_Input _Output NFS_CATALOG_STRUCT* catalog, SizeT off)
+bool NeFSParser::Seek(_Input _Output NFS_CATALOG_STRUCT* catalog, SizeT off)
{
if (!catalog)
{
@@ -1009,7 +1010,7 @@ bool NewFSParser::Seek(_Input _Output NFS_CATALOG_STRUCT* catalog, SizeT off)
/// @return The position on the file.
/***********************************************************************************/
-SizeT NewFSParser::Tell(_Input _Output NFS_CATALOG_STRUCT* catalog)
+SizeT NeFSParser::Tell(_Input _Output NFS_CATALOG_STRUCT* catalog)
{
if (!catalog)
{
@@ -1024,25 +1025,25 @@ SizeT NewFSParser::Tell(_Input _Output NFS_CATALOG_STRUCT* catalog)
namespace Kernel::Detail
{
/***********************************************************************************/
- /// @brief Construct NewFS drives.
+ /// @brief Construct NeFS drives.
/***********************************************************************************/
Boolean fs_init_newfs(Void) noexcept
{
- kcout << "newoskrnl.exe: Creating drives...\r";
+ kcout << "Creating drives...\r";
sMountpointInterface.A() = io_construct_main_drive();
sMountpointInterface.B() = io_construct_drive();
sMountpointInterface.C() = io_construct_drive();
sMountpointInterface.D() = io_construct_drive();
- kcout << "newoskrnl.exe: Testing main drive...\r";
+ kcout << "Testing A:\r";
sMountpointInterface.A().fVerify(&sMountpointInterface.A().fPacket);
- kcout << "newoskrnl.exe: Testing main drive [ OK ]...\r";
+ kcout << "Testing A: [ OK ]\r";
return true;
}
} // namespace Kernel::Detail
-#endif // ifdef __FSKIT_USE_NEWFS__
+#endif // ifdef __FSKIT_USE_NEFS__
diff --git a/dev/ZKA/Sources/FileManager.cxx b/dev/ZKA/Sources/FileMgr.cxx
index 8c8fb83a..3e3977ab 100644
--- a/dev/ZKA/Sources/FileManager.cxx
+++ b/dev/ZKA/Sources/FileMgr.cxx
@@ -4,7 +4,7 @@
------------------------------------------- */
-#include <KernelKit/FileManager.hxx>
+#include <KernelKit/FileMgr.hxx>
#include <NewKit/Utils.hxx>
/// BUGS: 0
@@ -12,18 +12,18 @@
namespace Kernel
{
- STATIC FilesystemManagerInterface* kMounted = nullptr;
+ STATIC FilesystemMgrInterface* kMounted = nullptr;
- /// @brief FilesystemManager getter.
+ /// @brief FilesystemMgr getter.
/// @return The mounted filesystem.
- _Output FilesystemManagerInterface* FilesystemManagerInterface::GetMounted()
+ _Output FilesystemMgrInterface* FilesystemMgrInterface::GetMounted()
{
return kMounted;
}
/// @brief Unmount filesystem.
/// @return The unmounted filesystem.
- _Output FilesystemManagerInterface* FilesystemManagerInterface::Unmount()
+ _Output FilesystemMgrInterface* FilesystemMgrInterface::Unmount()
{
if (kMounted)
{
@@ -39,7 +39,7 @@ namespace Kernel
/// @brief Mount filesystem.
/// @param mount_ptr The filesystem to mount.
/// @return if it succeeded true, otherwise false.
- bool FilesystemManagerInterface::Mount(_Input FilesystemManagerInterface* mount_ptr)
+ bool FilesystemMgrInterface::Mount(_Input FilesystemMgrInterface* mount_ptr)
{
if (mount_ptr != nullptr)
{
@@ -50,12 +50,12 @@ namespace Kernel
return false;
}
-#ifdef __FSKIT_USE_NEWFS__
+#ifdef __FSKIT_USE_NEFS__
/// @brief Opens a new file.
/// @param path
/// @param r
/// @return
- _Output NodePtr NewFilesystemManager::Open(_Input const Char* path, _Input const Char* r)
+ _Output NodePtr NewFilesystemMgr::Open(_Input const Char* path, _Input const Char* r)
{
if (!path || *path == 0)
return nullptr;
@@ -73,14 +73,14 @@ namespace Kernel
/// @param data the data.
/// @param flags the size.
/// @return
- Void NewFilesystemManager::Write(_Input NodePtr node, _Input VoidPtr data, _Input Int32 flags, _Input SizeT size)
+ Void NewFilesystemMgr::Write(_Input NodePtr node, _Input VoidPtr data, _Input Int32 flags, _Input SizeT size)
{
if (!node)
return;
if (!size)
return;
- constexpr auto cDataForkName = kNewFSDataFork;
+ constexpr auto cDataForkName = kNeFSDataFork;
this->Write(cDataForkName, node, data, flags, size);
}
@@ -89,25 +89,25 @@ namespace Kernel
/// @param flags the flags with it.
/// @param sz the size to read.
/// @return
- _Output VoidPtr NewFilesystemManager::Read(_Input NodePtr node, _Input Int32 flags, _Input SizeT size)
+ _Output VoidPtr NewFilesystemMgr::Read(_Input NodePtr node, _Input Int32 flags, _Input SizeT size)
{
if (!node)
return nullptr;
if (!size)
return nullptr;
- constexpr auto cDataForkName = kNewFSDataFork;
+ constexpr auto cDataForkName = kNeFSDataFork;
return this->Read(cDataForkName, node, flags, size);
}
- Void NewFilesystemManager::Write(_Input const Char* name,
+ Void NewFilesystemMgr::Write(_Input const Char* name,
_Input NodePtr node,
_Input VoidPtr data,
_Input Int32 flags,
_Input SizeT size)
{
if (!size ||
- size > kNewFSForkSize)
+ size > kNeFSForkSize)
return;
if (!data)
@@ -115,17 +115,17 @@ namespace Kernel
ZKA_UNUSED(flags);
- if ((reinterpret_cast<NFS_CATALOG_STRUCT*>(node))->Kind == kNewFSCatalogKindFile)
+ if ((reinterpret_cast<NFS_CATALOG_STRUCT*>(node))->Kind == kNeFSCatalogKindFile)
fImpl->WriteCatalog(reinterpret_cast<NFS_CATALOG_STRUCT*>(node), (flags & cFileFlagRsrc ? true : false), data, size,
name);
}
- _Output VoidPtr NewFilesystemManager::Read(_Input const Char* name,
+ _Output VoidPtr NewFilesystemMgr::Read(_Input const Char* name,
_Input NodePtr node,
_Input Int32 flags,
_Input SizeT sz)
{
- if (sz > kNewFSForkSize)
+ if (sz > kNeFSForkSize)
return nullptr;
if (!sz)
@@ -133,7 +133,7 @@ namespace Kernel
ZKA_UNUSED(flags);
- if ((reinterpret_cast<NFS_CATALOG_STRUCT*>(node))->Kind == kNewFSCatalogKindFile)
+ if ((reinterpret_cast<NFS_CATALOG_STRUCT*>(node))->Kind == kNeFSCatalogKindFile)
return fImpl->ReadCatalog(reinterpret_cast<NFS_CATALOG_STRUCT*>(node), (flags & cFileFlagRsrc ? true : false), sz,
name);
@@ -146,7 +146,7 @@ namespace Kernel
/// @retval true always returns false, this is unimplemented.
/// @retval false always returns this, it is unimplemented.
- _Output Bool NewFilesystemManager::Seek(NodePtr node, SizeT off)
+ _Output Bool NewFilesystemMgr::Seek(NodePtr node, SizeT off)
{
if (!node || off == 0)
return false;
@@ -159,7 +159,7 @@ namespace Kernel
/// @retval true always returns false, this is unimplemented.
/// @retval false always returns this, it is unimplemented.
- _Output SizeT NewFilesystemManager::Tell(NodePtr node)
+ _Output SizeT NewFilesystemMgr::Tell(NodePtr node)
{
if (!node)
return kNPos;
@@ -172,7 +172,7 @@ namespace Kernel
/// @retval true always returns false, this is unimplemented.
/// @retval false always returns this, it is unimplemented.
- _Output Bool NewFilesystemManager::Rewind(NodePtr node)
+ _Output Bool NewFilesystemMgr::Rewind(NodePtr node)
{
if (!node)
return false;
@@ -182,9 +182,9 @@ namespace Kernel
/// @brief Returns the filesystem parser.
/// @return the Filesystem parser class.
- _Output NewFSParser* NewFilesystemManager::GetParser() noexcept
+ _Output NeFSParser* NewFilesystemMgr::GetParser() noexcept
{
return fImpl;
}
-#endif // __FSKIT_USE_NEWFS__
+#endif // __FSKIT_USE_NEFS__
} // namespace Kernel
diff --git a/dev/ZKA/Sources/Framebuffer.cxx b/dev/ZKA/Sources/Framebuffer.cxx
index 76fe7172..3794e458 100644
--- a/dev/ZKA/Sources/Framebuffer.cxx
+++ b/dev/ZKA/Sources/Framebuffer.cxx
@@ -44,7 +44,7 @@ namespace Kernel
{
return fFrameBufferAddr.Leak()->fBase != 0 &&
fColour != FramebufferColorKind::INVALID &&
- fFrameBufferAddr.Leak()->fBase != kBadPtr;
+ fFrameBufferAddr.Leak()->fBase != kInvalidAddress;
}
/// @brief Set color kind of framebuffer.
diff --git a/dev/ZKA/Sources/MP.cxx b/dev/ZKA/Sources/HardwareThreadScheduler.cxx
index b3b62609..b130ef63 100644
--- a/dev/ZKA/Sources/MP.cxx
+++ b/dev/ZKA/Sources/HardwareThreadScheduler.cxx
@@ -6,7 +6,7 @@
#include <ArchKit/ArchKit.hxx>
#include <KernelKit/UserProcessScheduler.hxx>
-#include <KernelKit/MP.hxx>
+#include <KernelKit/HardwareThreadScheduler.hxx>
#include <CFKit/Property.hxx>
///! BUGS: 0
@@ -17,12 +17,6 @@
namespace Kernel
{
- /***********************************************************************************/
- /// @brief MP object container property.
- /***********************************************************************************/
-
- Property cSMPCoreName;
-
///! A HardwareThread class takes care of it's owned hardware thread.
///! It has a stack for it's core.
@@ -96,19 +90,26 @@ namespace Kernel
!stack_ptr)
return false;
+ if (this->IsBusy())
+ return false;
+
fStack = frame;
if (kHandoverHeader->f_HardwareTables.f_MultiProcessingEnabled)
{
- return mp_register_process(fStack);
- }
-
- //! SMP is disabled here.
+ this->Busy(true);
+ Bool ret = mp_register_process(fStack);
+ this->Busy(true);
- mp_do_context_switch_pre();
- mp_do_context_switch(image, stack_ptr, fStack);
-
- return true;
+ return ret;
+ }
+ else
+ {
+ mp_do_context_switch_pre();
+ mp_do_context_switch(image, stack_ptr, fStack);
+
+ return true;
+ }
}
///! @brief Tells if processor is waked up.
@@ -123,15 +124,7 @@ namespace Kernel
///! @brief Constructor and destructors.
///! @brief Default constructor.
- HardwareThreadScheduler::HardwareThreadScheduler()
- {
- kcout << "newoskrnl.exe: initializing HardwareThreadScheduler." << endl;
-
- cSMPCoreName.GetKey() += "Property\\MPClass";
- cSMPCoreName.GetValue() = (PropertyId)this;
-
- kcout << "newoskrnl.exe: initialized HardwareThreadScheduler." << endl;
- }
+ HardwareThreadScheduler::HardwareThreadScheduler() = default;
///! @brief Default destructor.
HardwareThreadScheduler::~HardwareThreadScheduler() = default;
diff --git a/dev/ZKA/Sources/Heap.cxx b/dev/ZKA/Sources/Heap.cxx
index bd7e299b..1f9af6a2 100644
--- a/dev/ZKA/Sources/Heap.cxx
+++ b/dev/ZKA/Sources/Heap.cxx
@@ -8,7 +8,7 @@
#include <KernelKit/LPC.hxx>
#include <KernelKit/Heap.hxx>
#include <NewKit/Crc32.hxx>
-#include <NewKit/PageManager.hxx>
+#include <NewKit/PageMgr.hxx>
//! @file KernelHeap.cxx
//! @brief Kernel heap allocator.
@@ -19,8 +19,8 @@
namespace Kernel
{
SizeT kHeapCount = 0UL;
- PageManager kHeapPageManager;
- Bool kOperationInProgress = No;
+ PageMgr kHeapPageMgr;
+ Bool kHeapLock = No;
/// @brief Contains data structures and algorithms for the heap.
namespace Detail
@@ -52,43 +52,43 @@ namespace Kernel
Void mm_alloc_init_timeout(Void) noexcept
{
- kOperationInProgress = Yes;
+ kHeapLock = Yes;
}
Void mm_alloc_fini_timeout(Void) noexcept
{
- kOperationInProgress = No;
+ kHeapLock = No;
}
} // namespace Detail
Detail::HEAP_INFORMATION_BLOCK_PTR kLatestAllocation = nullptr;
- /// @brief Declare a new size for allocatedPtr.
- /// @param allocatedPtr the pointer.
+ /// @brief Declare a new size for ptr_heap.
+ /// @param ptr_heap the pointer.
/// @return
- voidPtr mm_realloc_ke_heap(voidPtr allocatedPtr, SizeT newSz)
+ voidPtr mm_realloc_ke_heap(voidPtr ptr_heap, SizeT new_sz)
{
- if (!allocatedPtr || newSz < 1)
+ if (!ptr_heap || new_sz < 1)
return nullptr;
- Detail::HEAP_INFORMATION_BLOCK_PTR heapInfoBlk =
+ Detail::HEAP_INFORMATION_BLOCK_PTR heap_blk =
reinterpret_cast<Detail::HEAP_INFORMATION_BLOCK_PTR>(
- (UIntPtr)allocatedPtr - sizeof(Detail::HEAP_INFORMATION_BLOCK));
+ (UIntPtr)ptr_heap - sizeof(Detail::HEAP_INFORMATION_BLOCK));
- heapInfoBlk->fHeapSize = newSz;
+ heap_blk->fHeapSize = new_sz;
- if (heapInfoBlk->fCRC32 > 0)
+ if (heap_blk->fCRC32 > 0)
{
- MUST_PASS(mm_protect_ke_heap(allocatedPtr));
+ MUST_PASS(mm_protect_ke_heap(ptr_heap));
}
- return allocatedPtr;
+ return ptr_heap;
}
- /// @brief allocate chunk of memory.
- /// @param sz size of pointer
- /// @param rw read write (true to enable it)
- /// @param user is it accesible by user processes?
+ /// @brief Allocate chunk of memory.
+ /// @param sz Size of pointer
+ /// @param rw Read Write bit.
+ /// @param user User enable bit.
/// @return The newly allocated pointer.
VoidPtr mm_new_ke_heap(const SizeT sz, const bool rw, const bool user)
{
@@ -97,30 +97,31 @@ namespace Kernel
auto szFix = sz;
if (szFix == 0)
- ++szFix;
+ return nullptr;
- auto wrapper = kHeapPageManager.Request(rw, user, false, szFix);
+ auto wrapper = kHeapPageMgr.Request(rw, user, No, szFix);
Detail::HEAP_INFORMATION_BLOCK_PTR heap_info_ptr =
reinterpret_cast<Detail::HEAP_INFORMATION_BLOCK_PTR>(
- wrapper.VirtualAddress());
+ wrapper.VirtualAddress() + sizeof(Detail::HEAP_INFORMATION_BLOCK));
heap_info_ptr->fHeapSize = szFix;
- heap_info_ptr->fMagic = kKernelHeapMagic;
- heap_info_ptr->fCRC32 = 0U; // dont fill it for now.
- heap_info_ptr->fHeapPtr = wrapper.VirtualAddress() + sizeof(Detail::HEAP_INFORMATION_BLOCK);
- heap_info_ptr->fPage = 0UL;
- heap_info_ptr->fUser = user;
- heap_info_ptr->fPresent = true;
+ heap_info_ptr->fMagic = kKernelHeapMagic;
+ heap_info_ptr->fCRC32 = No; // dont fill it for now.
+ heap_info_ptr->fHeapPtr = reinterpret_cast<UIntPtr>(heap_info_ptr) + sizeof(Detail::HEAP_INFORMATION_BLOCK);
+ heap_info_ptr->fPage = No;
+ heap_info_ptr->fUser = user;
+ heap_info_ptr->fPresent = Yes;
++kHeapCount;
+ auto result = reinterpret_cast<VoidPtr>(heap_info_ptr->fHeapPtr);
+
kLatestAllocation = heap_info_ptr;
Detail::mm_alloc_fini_timeout();
- return reinterpret_cast<VoidPtr>(heap_info_ptr +
- sizeof(Detail::HEAP_INFORMATION_BLOCK));
+ return result;
}
/// @brief Makes a page heap.
@@ -132,16 +133,16 @@ namespace Kernel
return -kErrorInternal;
if (((IntPtr)heap_ptr - sizeof(Detail::HEAP_INFORMATION_BLOCK)) <= 0)
return -kErrorInternal;
- if (((IntPtr)heap_ptr - kBadPtr) < 0)
+ if (((IntPtr)heap_ptr - kInvalidAddress) < 0)
return -kErrorInternal;
Detail::mm_alloc_init_timeout();
- Detail::HEAP_INFORMATION_BLOCK_PTR heapInfoBlk =
+ Detail::HEAP_INFORMATION_BLOCK_PTR heap_blk =
reinterpret_cast<Detail::HEAP_INFORMATION_BLOCK_PTR>(
(UIntPtr)heap_ptr - sizeof(Detail::HEAP_INFORMATION_BLOCK));
- heapInfoBlk->fPage = true;
+ heap_blk->fPage = true;
Detail::mm_alloc_fini_timeout();
@@ -155,48 +156,50 @@ namespace Kernel
{
if (kHeapCount < 1)
return -kErrorInternal;
- if (((IntPtr)heap_ptr - sizeof(Detail::HEAP_INFORMATION_BLOCK)) <= 0)
- return -kErrorInternal;
- if (((IntPtr)heap_ptr - kBadPtr) < 0)
- return -kErrorInternal;
+
+ if (!heap_ptr)
+ return -kErrorInvalidData;
Detail::mm_alloc_init_timeout();
- Detail::HEAP_INFORMATION_BLOCK_PTR heapInfoBlk =
+ Detail::HEAP_INFORMATION_BLOCK_PTR heap_blk =
reinterpret_cast<Detail::HEAP_INFORMATION_BLOCK_PTR>(
(UIntPtr)heap_ptr - sizeof(Detail::HEAP_INFORMATION_BLOCK));
- if (heapInfoBlk && heapInfoBlk->fMagic == kKernelHeapMagic)
+ if (heap_blk && heap_blk->fMagic == kKernelHeapMagic)
{
- if (!heapInfoBlk->fPresent)
+
+ if (!heap_blk->fPresent)
{
Detail::mm_alloc_fini_timeout();
return -kErrorHeapNotPresent;
}
- if (heapInfoBlk->fCRC32 != 0)
+ if (heap_blk->fCRC32 != 0)
{
- if (heapInfoBlk->fCRC32 !=
- ke_calculate_crc32((Char*)heapInfoBlk->fHeapPtr,
- heapInfoBlk->fHeapSize))
+ if (heap_blk->fCRC32 !=
+ ke_calculate_crc32((Char*)heap_blk->fHeapPtr,
+ heap_blk->fHeapSize))
{
- if (!heapInfoBlk->fUser)
+ if (!heap_blk->fUser)
{
ke_stop(RUNTIME_CHECK_POINTER);
}
}
}
- heapInfoBlk->fHeapSize = 0UL;
- heapInfoBlk->fPresent = false;
- heapInfoBlk->fHeapPtr = 0;
- heapInfoBlk->fCRC32 = 0;
- heapInfoBlk->fMagic = 0;
+ heap_blk->fHeapSize = 0UL;
+ heap_blk->fPresent = No;
+ heap_blk->fHeapPtr = 0;
+ heap_blk->fCRC32 = 0;
+ heap_blk->fMagic = 0;
+
+ PTEWrapper pageWrapper(false, false, false, reinterpret_cast<UIntPtr>(heap_blk) - sizeof(Detail::HEAP_INFORMATION_BLOCK));
+ Ref<PTEWrapper> pteAddress{pageWrapper};
- PTEWrapper pageWrapper(false, false, false, reinterpret_cast<UIntPtr>(heapInfoBlk));
- Ref<PTEWrapper*> pteAddress{&pageWrapper};
+ kcout << "Freeing pointer address: " << hex_number(reinterpret_cast<UIntPtr>(heap_blk) - sizeof(Detail::HEAP_INFORMATION_BLOCK)) << endl;
- kHeapPageManager.Free(pteAddress);
+ kHeapPageMgr.Free(pteAddress);
--kHeapCount;
@@ -238,14 +241,14 @@ namespace Kernel
{
if (heap_ptr)
{
- Detail::HEAP_INFORMATION_BLOCK_PTR heapInfoBlk =
+ Detail::HEAP_INFORMATION_BLOCK_PTR heap_blk =
reinterpret_cast<Detail::HEAP_INFORMATION_BLOCK_PTR>(
(UIntPtr)heap_ptr - sizeof(Detail::HEAP_INFORMATION_BLOCK));
- if (heapInfoBlk->fPresent && kKernelHeapMagic == heapInfoBlk->fMagic)
+ if (heap_blk->fPresent && kKernelHeapMagic == heap_blk->fMagic)
{
- heapInfoBlk->fCRC32 =
- ke_calculate_crc32((Char*)heapInfoBlk->fHeapPtr, heapInfoBlk->fHeapSize);
+ heap_blk->fCRC32 =
+ ke_calculate_crc32((Char*)heap_blk->fHeapPtr, heap_blk->fHeapSize);
return true;
}
diff --git a/dev/ZKA/Sources/DLLInterface.cxx b/dev/ZKA/Sources/IDLLObject.cxx
index c18f2f00..b6b6a348 100644
--- a/dev/ZKA/Sources/DLLInterface.cxx
+++ b/dev/ZKA/Sources/IDLLObject.cxx
@@ -7,7 +7,7 @@
* ========================================================
*/
-#include <KernelKit/DLLInterface.hxx>
+#include <KernelKit/IDLLObject.hxx>
#include <KernelKit/DebugOutput.hxx>
#include <KernelKit/UserProcessScheduler.hxx>
diff --git a/dev/ZKA/Sources/PEFDLLInterface.cxx b/dev/ZKA/Sources/IPEFDLLObject.cxx
index 70c68783..913912a4 100644
--- a/dev/ZKA/Sources/PEFDLLInterface.cxx
+++ b/dev/ZKA/Sources/IPEFDLLObject.cxx
@@ -9,7 +9,7 @@
#include <KernelKit/DebugOutput.hxx>
#include <KernelKit/PEF.hxx>
-#include <KernelKit/PEFDLLInterface.hxx>
+#include <KernelKit/IPEFDLLObject.hxx>
#include <KernelKit/UserProcessScheduler.hxx>
#include <KernelKit/ThreadLocalStorage.hxx>
#include <NewKit/Defines.hxx>
@@ -37,9 +37,9 @@ using namespace Kernel;
/** @brief Library initializer. */
/***********************************************************************************/
-EXTERN_C DLLInterfacePtr rtl_init_shared_object(UserProcess* header)
+EXTERN_C IDLL rtl_init_shared_object(UserProcess* header)
{
- DLLInterfacePtr sharedObj = tls_new_class<PEFDLLInterface>();
+ IDLL sharedObj = tls_new_class<IPEFDLLObject>();
if (!sharedObj)
{
@@ -48,7 +48,7 @@ EXTERN_C DLLInterfacePtr rtl_init_shared_object(UserProcess* header)
return nullptr;
}
- sharedObj->Mount(tls_new_class<PEFDLLInterface::DLL_TRAITS>());
+ sharedObj->Mount(tls_new_class<IPEFDLLObject::DLL_TRAITS>());
if (!sharedObj->Get())
{
@@ -80,7 +80,7 @@ EXTERN_C DLLInterfacePtr rtl_init_shared_object(UserProcess* header)
/** @param successful Reports if successful or not. */
/***********************************************************************************/
-EXTERN_C Void rtl_fini_shared_object(UserProcess* header, DLLInterfacePtr lib, Bool* successful)
+EXTERN_C Void rtl_fini_shared_object(UserProcess* header, IDLL lib, Bool* successful)
{
MUST_PASS(successful);
diff --git a/dev/ZKA/Sources/IndexableProperty.cxx b/dev/ZKA/Sources/IndexableProperty.cxx
index 84aabc6b..a5f1bc0b 100644
--- a/dev/ZKA/Sources/IndexableProperty.cxx
+++ b/dev/ZKA/Sources/IndexableProperty.cxx
@@ -52,7 +52,7 @@ namespace Kernel
indexer.AddFlag(kIndexerClaimed);
rt_copy_memory((VoidPtr)indexer.Leak().Path, (VoidPtr)filename, filenameLen);
- kcout << "newoskrnl.exe: filesystem: index new file: " << filename << endl;
+ kcout << "filesystem: index new file: " << filename << endl;
}
}
} // namespace Indexer
diff --git a/dev/ZKA/Sources/KernelCheck.cxx b/dev/ZKA/Sources/KernelCheck.cxx
index a05c265a..acc01dec 100644
--- a/dev/ZKA/Sources/KernelCheck.cxx
+++ b/dev/ZKA/Sources/KernelCheck.cxx
@@ -56,6 +56,7 @@ namespace Kernel
{
case RUNTIME_CHECK_PROCESS: {
CGDrawString("0x00000008 No more processes to run, this is because that ZKA ran out of processes.", start_y, x, panicTxt);
+ RecoveryFactory::Recover();
break;
}
case RUNTIME_CHECK_ACPI: {
@@ -98,11 +99,16 @@ namespace Kernel
RecoveryFactory::Recover();
break;
case RUNTIME_CHECK_UNEXCPECTED: {
- CGDrawString("0x0000000B Catasrophic Kernel failure.", start_y, x, panicTxt);
+ CGDrawString("0x0000000B Unexpected Kernel failure.", start_y, x, panicTxt);
+ break;
+ }
+ case RUNTIME_CHECK_VIRTUAL_OUT_OF_MEM: {
+ CGDrawString("0x10000001 Out of Virtual Memory. (Catastrophic Failure)", start_y, x, panicTxt);
+ RecoveryFactory::Recover();
break;
}
case RUNTIME_CHECK_FAILED: {
- CGDrawString("0x10000001 Assertion failed.", start_y, x, panicTxt);
+ CGDrawString("0x10000001 Kernel Check.", start_y, x, panicTxt);
RecoveryFactory::Recover();
break;
}
@@ -120,13 +126,6 @@ namespace Kernel
Void RecoveryFactory::Recover() noexcept
{
- const auto cMaxSeconds = Seconds(4);
-
- HardwareTimer timer(cMaxSeconds);
- timer.Wait();
-
- kcout << "newoskrnl.exe: Shutting down computer...\r";
-
PowerFactoryInterface power(nullptr);
power.Shutdown();
}
@@ -135,6 +134,9 @@ namespace Kernel
{
if (!expr)
{
+ kcout << "FAILED: FILE: " << file << endl;
+ kcout << "FAILED: LINE: " << line << endl;
+
ke_stop(RUNTIME_CHECK_FAILED); // Runtime Check failed
}
}
diff --git a/dev/ZKA/Sources/NewFS+FileManager.cxx b/dev/ZKA/Sources/NeFS+FileMgr.cxx
index 98e0e3af..b3ad381f 100644
--- a/dev/ZKA/Sources/NewFS+FileManager.cxx
+++ b/dev/ZKA/Sources/NeFS+FileMgr.cxx
@@ -4,28 +4,29 @@
------------------------------------------- */
-#include <KernelKit/FileManager.hxx>
+#include <KernelKit/FileMgr.hxx>
#include <KernelKit/Heap.hxx>
-#ifdef __FSKIT_USE_NEWFS__
+#ifdef __FSKIT_USE_NEFS__
-/// @brief NewFS File manager.
+/// @brief NeFS File manager.
/// BUGS: 0
namespace Kernel
{
/// @brief C++ constructor
- NewFilesystemManager::NewFilesystemManager()
+ NewFilesystemMgr::NewFilesystemMgr()
{
MUST_PASS(Detail::fs_init_newfs());
- fImpl = new NewFSParser();
+ fImpl = new NeFSParser();
+ MUST_PASS(fImpl);
- kcout << "newoskrnl.exe: We are done here... (NewFilesystemManager).\r";
+ kcout << "We are done here... (NewFilesystemMgr).\r";
}
- NewFilesystemManager::~NewFilesystemManager()
+ NewFilesystemMgr::~NewFilesystemMgr()
{
- kcout << "newoskrnl.exe: Destroying it...\r";
+ kcout << "Destroying it...\r";
if (fImpl)
{
@@ -36,7 +37,7 @@ namespace Kernel
/// @brief Removes a node from the filesystem.
/// @param fileName The filename
/// @return If it was deleted or not.
- bool NewFilesystemManager::Remove(const Char* fileName)
+ bool NewFilesystemMgr::Remove(const Char* fileName)
{
if (fileName == nullptr || *fileName == 0)
return false;
@@ -47,7 +48,7 @@ namespace Kernel
/// @brief Creates a node with the specified.
/// @param path The filename path.
/// @return The Node pointer.
- NodePtr NewFilesystemManager::Create(const Char* path)
+ NodePtr NewFilesystemMgr::Create(const Char* path)
{
return node_cast(fImpl->CreateCatalog(path));
}
@@ -55,54 +56,54 @@ namespace Kernel
/// @brief Creates a node with is a directory.
/// @param path The filename path.
/// @return The Node pointer.
- NodePtr NewFilesystemManager::CreateDirectory(const Char* path)
+ NodePtr NewFilesystemMgr::CreateDirectory(const Char* path)
{
- return node_cast(fImpl->CreateCatalog(path, 0, kNewFSCatalogKindDir));
+ return node_cast(fImpl->CreateCatalog(path, 0, kNeFSCatalogKindDir));
}
/// @brief Creates a node with is a alias.
/// @param path The filename path.
/// @return The Node pointer.
- NodePtr NewFilesystemManager::CreateAlias(const Char* path)
+ NodePtr NewFilesystemMgr::CreateAlias(const Char* path)
{
- return node_cast(fImpl->CreateCatalog(path, 0, kNewFSCatalogKindAlias));
+ return node_cast(fImpl->CreateCatalog(path, 0, kNeFSCatalogKindAlias));
}
/// @brief Creates a node with is a page file.
/// @param path The filename path.
/// @return The Node pointer.
- NodePtr NewFilesystemManager::CreateSwapFile(const Char* path)
+ NodePtr NewFilesystemMgr::CreateSwapFile(const Char* path)
{
- return node_cast(fImpl->CreateCatalog(path, 0, kNewFSCatalogKindPage));
+ return node_cast(fImpl->CreateCatalog(path, 0, kNeFSCatalogKindPage));
}
/// @brief Gets the root directory.
/// @return
const Char* NewFilesystemHelper::Root()
{
- return kNewFSRoot;
+ return kNeFSRoot;
}
/// @brief Gets the up-dir directory.
/// @return
const Char* NewFilesystemHelper::UpDir()
{
- return kNewFSUpDir;
+ return kNeFSUpDir;
}
/// @brief Gets the separator character.
/// @return
const Char NewFilesystemHelper::Separator()
{
- return kNewFSSeparator;
+ return kNeFSSeparator;
}
/// @brief Gets the metafile character.
/// @return
const Char NewFilesystemHelper::MetaFile()
{
- return kNewFSMetaFilePrefix;
+ return kNeFSMetaFilePrefix;
}
} // namespace Kernel
-#endif // ifdef __FSKIT_USE_NEWFS__
+#endif // ifdef __FSKIT_USE_NEFS__
diff --git a/dev/ZKA/Sources/NewFS+IO.cxx b/dev/ZKA/Sources/NeFS+IO.cxx
index ddcecde4..a86e9c29 100644
--- a/dev/ZKA/Sources/NewFS+IO.cxx
+++ b/dev/ZKA/Sources/NeFS+IO.cxx
@@ -4,12 +4,12 @@
------------------------------------------- */
-#include <KernelKit/DriveManager.hxx>
-#include <KernelKit/FileManager.hxx>
+#include <KernelKit/DriveMgr.hxx>
+#include <KernelKit/FileMgr.hxx>
/*************************************************************
*
- * File: NewFS+IO.cxx
+ * File: NeFS+IO.cxx
* Purpose: Filesystem to mountpoint interface.
* Date: 3/26/24
*
@@ -17,14 +17,14 @@
*
*************************************************************/
-#ifdef __FSKIT_USE_NEWFS__
+#ifdef __FSKIT_USE_NEFS__
#include <FirmwareKit/EPM.hxx>
/// Useful macros.
-#define NEWFS_WRITE(DRV, TRAITS, MP) (MP->DRV()).fOutput(&TRAITS)
-#define NEWFS_READ(DRV, TRAITS, MP) (MP->DRV()).fInput(&TRAITS)
+#define NEFS_WRITE(DRV, TRAITS, MP) (MP->DRV()).fOutput(&TRAITS)
+#define NEFS_READ(DRV, TRAITS, MP) (MP->DRV()).fInput(&TRAITS)
using namespace Kernel;
@@ -42,20 +42,20 @@ Int32 fs_newfs_read(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvInd
switch (DrvIndex)
{
- case kNewFSSubDriveA: {
- NEWFS_READ(A, DrvTrait.fPacket, Mnt);
+ case kNeFSSubDriveA: {
+ NEFS_READ(A, DrvTrait.fPacket, Mnt);
break;
}
- case kNewFSSubDriveB: {
- NEWFS_READ(B, DrvTrait.fPacket, Mnt);
+ case kNeFSSubDriveB: {
+ NEFS_READ(B, DrvTrait.fPacket, Mnt);
break;
}
- case kNewFSSubDriveC: {
- NEWFS_READ(C, DrvTrait.fPacket, Mnt);
+ case kNeFSSubDriveC: {
+ NEFS_READ(C, DrvTrait.fPacket, Mnt);
break;
}
- case kNewFSSubDriveD: {
- NEWFS_READ(D, DrvTrait.fPacket, Mnt);
+ case kNeFSSubDriveD: {
+ NEFS_READ(D, DrvTrait.fPacket, Mnt);
break;
}
}
@@ -77,20 +77,20 @@ Int32 fs_newfs_write(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvIn
switch (DrvIndex)
{
- case kNewFSSubDriveA: {
- NEWFS_WRITE(A, DrvTrait.fPacket, Mnt);
+ case kNeFSSubDriveA: {
+ NEFS_WRITE(A, DrvTrait.fPacket, Mnt);
break;
}
- case kNewFSSubDriveB: {
- NEWFS_WRITE(B, DrvTrait.fPacket, Mnt);
+ case kNeFSSubDriveB: {
+ NEFS_WRITE(B, DrvTrait.fPacket, Mnt);
break;
}
- case kNewFSSubDriveC: {
- NEWFS_WRITE(C, DrvTrait.fPacket, Mnt);
+ case kNeFSSubDriveC: {
+ NEFS_WRITE(C, DrvTrait.fPacket, Mnt);
break;
}
- case kNewFSSubDriveD: {
- NEWFS_WRITE(D, DrvTrait.fPacket, Mnt);
+ case kNeFSSubDriveD: {
+ NEFS_WRITE(D, DrvTrait.fPacket, Mnt);
break;
}
}
@@ -98,4 +98,4 @@ Int32 fs_newfs_write(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvIn
return DrvTrait.fPacket.fPacketGood;
}
-#endif // ifdef __FSKIT_USE_NEWFS__
+#endif // ifdef __FSKIT_USE_NEFS__
diff --git a/dev/ZKA/Sources/NewFS+Journal.cxx b/dev/ZKA/Sources/NewFS+Journal.cxx
deleted file mode 100644
index 6504b2bc..00000000
--- a/dev/ZKA/Sources/NewFS+Journal.cxx
+++ /dev/null
@@ -1,22 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#include <KernelKit/DebugOutput.hxx>
-#include <KernelKit/FileManager.hxx>
-
-#ifdef __FSKIT_USE_NEWFS__
-
-///! BUGS: 0
-///! @file NewFS+Journal.cxx
-///! @brief Journaling for NewFS.
-
-namespace Kernel::Journal
-{
-} // namespace Kernel::Journal
-
-using namespace Kernel;
-
-#endif // ifdef __FSKIT_USE_NEWFS__
diff --git a/dev/ZKA/Sources/PEFCodeManager.cxx b/dev/ZKA/Sources/PEFCodeMgr.cxx
index 526312e0..feafc35c 100644
--- a/dev/ZKA/Sources/PEFCodeManager.cxx
+++ b/dev/ZKA/Sources/PEFCodeMgr.cxx
@@ -6,7 +6,7 @@
#include <KernelKit/DebugOutput.hxx>
#include <KernelKit/Heap.hxx>
-#include <KernelKit/PEFCodeManager.hxx>
+#include <KernelKit/PEFCodeMgr.hxx>
#include <KernelKit/UserProcessScheduler.hxx>
#include <NewKit/Defines.hxx>
#include <NewKit/KernelCheck.hxx>
@@ -87,7 +87,7 @@ namespace Kernel
if (fCachedBlob)
mm_delete_ke_heap(fCachedBlob);
- kcout << "CodeManagerPEF: Warning: Executable format error!\r";
+ kcout << "CodeMgrPEF: Warning: Executable format error!\r";
fCachedBlob = nullptr;
}
diff --git a/dev/ZKA/Sources/PageAllocator.cxx b/dev/ZKA/Sources/PageAllocator.cxx
index dec6c470..e68d0659 100644
--- a/dev/ZKA/Sources/PageAllocator.cxx
+++ b/dev/ZKA/Sources/PageAllocator.cxx
@@ -11,19 +11,6 @@
/// @brief Internal namespace, used internally by Kernel.
namespace Kernel::Detail
{
- VoidPtr create_page_wrapper(Boolean rw, Boolean user, SizeT pageSz)
- {
- auto addr = HAL::hal_alloc_page(rw, user, pageSz);
-
- if (addr == kBadAddress)
- {
- kcout << "[create_page_wrapper] kBadAddress returned\n";
- ke_stop(RUNTIME_CHECK_POINTER);
- }
-
- return addr;
- }
-
void exec_disable(UIntPtr VirtualAddr)
{
#ifdef __ZKA_SUPPORT_NX__
diff --git a/dev/ZKA/Sources/PageManager.cxx b/dev/ZKA/Sources/PageMgr.cxx
index d14130ff..78b279f3 100644
--- a/dev/ZKA/Sources/PageManager.cxx
+++ b/dev/ZKA/Sources/PageMgr.cxx
@@ -5,7 +5,7 @@
------------------------------------------- */
#include <KernelKit/DebugOutput.hxx>
-#include <NewKit/PageManager.hxx>
+#include <NewKit/PageMgr.hxx>
#ifdef __ZKA_AMD64__
#include <HALKit/AMD64/HalPageAlloc.hxx>
@@ -35,11 +35,8 @@ namespace Kernel
/// @brief Flush virtual address.
/// @param VirtAddr
- Void PageManager::FlushTLB(UIntPtr VirtAddr)
+ Void PageMgr::FlushTLB()
{
- if (VirtAddr == kBadAddress)
- return;
-
hal_flush_tlb();
}
@@ -61,34 +58,23 @@ namespace Kernel
/// @param User user mode?
/// @param ExecDisable disable execution on page?
/// @return
- PTEWrapper PageManager::Request(Boolean Rw, Boolean User, Boolean ExecDisable, SizeT Sz)
+ PTEWrapper PageMgr::Request(Boolean Rw, Boolean User, Boolean ExecDisable, SizeT Sz)
{
// Store PTE wrapper right after PTE.
- VoidPtr ptr = Kernel::HAL::hal_alloc_page(Rw, User, Sz);
-
- if (ptr == kBadAddress)
- {
- kcout << "[create_page_wrapper] kBadAddress returned\n";
- ke_stop(RUNTIME_CHECK_POINTER);
- }
+ VoidPtr ptr = Kernel::HAL::mm_alloc_bitmap(Rw, User, Sz);
return PTEWrapper{Rw, User, ExecDisable, reinterpret_cast<UIntPtr>(ptr)};
}
- /// @brief Disable PTE.
+ /// @brief Disable BitMap.
/// @param wrapper the wrapper.
- /// @return
- bool PageManager::Free(Ref<PTEWrapper*>& wrapper)
+ /// @return If the page bitmap was cleared or not.
+ Bool PageMgr::Free(Ref<PTEWrapper>& wrapper)
{
- if (wrapper)
- {
- if (!Kernel::HAL::hal_free_page((VoidPtr)wrapper->VirtualAddress()))
- return false;
+ if (!Kernel::HAL::mm_free_bitmap((VoidPtr)wrapper.Leak().VirtualAddress()))
+ return false;
- return true;
- }
-
- return false;
+ return true;
}
/// @brief Virtual PTE address.
diff --git a/dev/ZKA/Sources/Pmm.cxx b/dev/ZKA/Sources/Pmm.cxx
index b0855281..58335a2b 100644
--- a/dev/ZKA/Sources/Pmm.cxx
+++ b/dev/ZKA/Sources/Pmm.cxx
@@ -19,9 +19,9 @@ namespace Kernel
{
/// @brief Pmm constructor.
Pmm::Pmm()
- : fPageManager()
+ : fPageMgr()
{
- kcout << "[PMM] Allocate PageMemoryManager";
+ kcout << "[PMM] Allocate PageMemoryMgr";
}
Pmm::~Pmm() = default;
@@ -31,17 +31,15 @@ namespace Kernel
/// @param readWrite is it r/w?
Ref<PTEWrapper> Pmm::RequestPage(Boolean user, Boolean readWrite)
{
- PTEWrapper pt = fPageManager.Leak().Request(user, readWrite, false, kPTESize);
+ PTEWrapper pt = fPageMgr.Leak().Request(user, readWrite, false, kPTESize);
if (pt.fPresent)
{
- kcout << "[PMM]: Allocation was successful.\r";
- return Ref<PTEWrapper>(pt);
+ kcout << "[PMM]: Allocation failed.\r";
+ return {};
}
- kcout << "[PMM]: Allocation failed.\r";
-
- return {};
+ return Ref<PTEWrapper>(pt);
}
Boolean Pmm::FreePage(Ref<PTEWrapper> PageRef)
diff --git a/dev/ZKA/Sources/Storage/ATADeviceInterface.cxx b/dev/ZKA/Sources/Storage/ATADeviceInterface.cxx
index 183481e1..97d2e2e4 100644
--- a/dev/ZKA/Sources/Storage/ATADeviceInterface.cxx
+++ b/dev/ZKA/Sources/Storage/ATADeviceInterface.cxx
@@ -43,7 +43,7 @@ ATADeviceInterface& ATADeviceInterface::operator<<(MountpointInterface* Data)
if (!Data)
return *this;
- for (SizeT driveCount = 0; driveCount < kDriveManagerCount; ++driveCount)
+ for (SizeT driveCount = 0; driveCount < kDriveMgrCount; ++driveCount)
{
auto interface = Data->GetAddressOf(driveCount);
if ((interface) && rt_string_cmp((interface)->fDriveKind(), "ATA-", 5) == 0)
@@ -69,7 +69,7 @@ ATADeviceInterface& ATADeviceInterface::operator>>(MountpointInterface* Data)
if (!Data)
return *this;
- for (SizeT driveCount = 0; driveCount < kDriveManagerCount; ++driveCount)
+ for (SizeT driveCount = 0; driveCount < kDriveMgrCount; ++driveCount)
{
auto interface = Data->GetAddressOf(driveCount);
if ((interface) && rt_string_cmp((interface)->fDriveKind(), "ATA-", 5) == 0)
diff --git a/dev/ZKA/Sources/ThreadLocalStorage.cxx b/dev/ZKA/Sources/ThreadLocalStorage.cxx
index f4794bdd..35f2dbcd 100644
--- a/dev/ZKA/Sources/ThreadLocalStorage.cxx
+++ b/dev/ZKA/Sources/ThreadLocalStorage.cxx
@@ -21,7 +21,7 @@
using namespace Kernel;
-namespace Detail
+namespace Kernel::Detail
{
/// \brief UserProcess thread information header.
struct THREAD_HEADER_BLOCK final
@@ -72,7 +72,7 @@ Boolean tls_check_tib(THREAD_INFORMATION_BLOCK* the_tib)
Encoder encoder;
const char* tibAsBytes = encoder.AsBytes(the_tib);
- kcout << "newoskrnl.exe: checking for a valid cookie inside the TIB...\r";
+ kcout << "checking for a valid cookie inside the TIB...\r";
return tibAsBytes[0] == kCookieMag0 && tibAsBytes[1] == kCookieMag1 &&
tibAsBytes[2] == kCookieMag2;
@@ -87,7 +87,7 @@ EXTERN_C Bool tls_check_syscall_impl(Kernel::VoidPtr tib_ptr) noexcept
{
if (!tib_ptr)
{
- kcout << "newoskrnl.exe: failing because of an invalid TIB...\r";
+ kcout << "failing because of an invalid TIB...\r";
return false;
}
@@ -95,10 +95,10 @@ EXTERN_C Bool tls_check_syscall_impl(Kernel::VoidPtr tib_ptr) noexcept
if (!tls_check_tib(tib_struct))
{
- kcout << "newoskrnl.exe: crashing because of an invalid TIB...\r";
+ kcout << "crashing because of an invalid TIB...\r";
return false;
}
- kcout << "newoskrnl.exe: Verification succeeded! staying alive...\r";
+ kcout << "Verification succeeded! staying alive...\r";
return true;
}
diff --git a/dev/ZKA/Sources/User.cxx b/dev/ZKA/Sources/User.cxx
index 5a4c2335..066a3e06 100644
--- a/dev/ZKA/Sources/User.cxx
+++ b/dev/ZKA/Sources/User.cxx
@@ -13,7 +13,7 @@
#include <KernelKit/LPC.hxx>
#include <KernelKit/User.hxx>
#include <NewKit/KernelCheck.hxx>
-#include <KernelKit/FileManager.hxx>
+#include <KernelKit/FileMgr.hxx>
#include <KernelKit/UserProcessScheduler.hxx>
#include <KernelKit/Heap.hxx>
@@ -77,7 +77,6 @@ namespace Kernel
SizeT len = rt_string_len(password_to_fill);
Char* password = new Char[len];
-
MUST_PASS(password);
// fill data first, generate hash.
@@ -100,7 +99,7 @@ namespace Kernel
delete[] password;
password = nullptr;
- kcout << "newoskrnl.exe: Saved password...\r";
+ kcout << "Saved password...\r";
return true;
}
diff --git a/dev/ZKA/Sources/UserProcessScheduler.cxx b/dev/ZKA/Sources/UserProcessScheduler.cxx
index dc142b18..8c46b1cf 100644
--- a/dev/ZKA/Sources/UserProcessScheduler.cxx
+++ b/dev/ZKA/Sources/UserProcessScheduler.cxx
@@ -2,16 +2,19 @@
Copyright ZKA Technologies.
+ FILE: UserProcessScheduler.cxx
+ PURPOSE: User sided process scheduler.
+
------------------------------------------- */
/***********************************************************************************/
/// @file UserProcessScheduler.cxx
-/// @brief User UserProcess scheduler.
+/// @brief User Process scheduler.
/***********************************************************************************/
#include <KernelKit/UserProcessScheduler.hxx>
-#include <KernelKit/PEFDLLInterface.hxx>
-#include <KernelKit/MP.hxx>
+#include <KernelKit/IPEFDLLObject.hxx>
+#include <KernelKit/HardwareThreadScheduler.hxx>
#include <KernelKit/Heap.hxx>
#include <NewKit/String.hxx>
#include <KernelKit/LPC.hxx>
@@ -19,7 +22,7 @@
///! BUGS: 0
/***********************************************************************************/
-/* TODO: Document more the Kernel, sdk and kits. */
+/** TODO: Document the Kernel, SDK and kits. */
/***********************************************************************************/
namespace Kernel
@@ -28,10 +31,10 @@ namespace Kernel
/// @brief Exit Code global variable.
/***********************************************************************************/
- UInt32 cLastExitCode = 0U;
+ STATIC UInt32 cLastExitCode = 0U;
/***********************************************************************************/
- /// @brief UserProcess scheduler instance.
+ /// @brief User Process scheduler global object.
/***********************************************************************************/
UserProcessScheduler* cProcessScheduler = nullptr;
@@ -53,11 +56,9 @@ namespace Kernel
if (this->Name == 0)
return;
- kcout << this->Name << ": crashed. (id = " << number(kErrorProcessFault) << endl;
+ kcout << this->Name << ": crashed, ID = " << number(kErrorProcessFault) << endl;
this->Exit(kErrorProcessFault);
-
- UserProcessHelper::StartScheduling();
}
/// @brief Gets the local last exit code.
@@ -85,27 +86,45 @@ namespace Kernel
/***********************************************************************************/
+ /** @brief Add pointer to entry. */
VoidPtr UserProcess::New(const SizeT& sz)
{
- if (this->HeapCursor)
+#ifdef __ZKA_AMD64__
+ auto pd = hal_read_cr3();
+ hal_write_cr3(this->MemoryPD);
+
+ auto ptr = mm_new_ke_heap(sz, Yes, Yes);
+
+ hal_write_cr3(reinterpret_cast<UIntPtr>(pd));
+#else
+ auto ptr = mm_new_ke_heap(sz, Yes, Yes);
+#endif
+
+ if (!this->MemoryEntryList)
{
- if (this->FreeMemory < 1)
- {
- ErrLocal() = kErrorHeapOutOfMemory;
+ this->MemoryEntryList = new UserProcess::PROCESS_MEMORY_ENTRY();
+ this->MemoryEntryList->MemoryEntry = ptr;
- /* We're going out of memory! crash... */
- this->Crash();
+ this->MemoryEntryList->MemoryPrev = nullptr;
+ this->MemoryEntryList->MemoryNext = nullptr;
- return nullptr;
- }
+ return ptr;
+ }
+ else
+ {
+ auto entry = this->MemoryEntryList;
- this->HeapCursor = reinterpret_cast<VoidPtr>((UIntPtr)this->HeapCursor + (sizeof(sz)));
- VoidPtr cursor = this->HeapCursor;
+ while (entry->MemoryNext)
+ {
+ if (entry->MemoryNext)
+ entry = entry->MemoryNext;
+ }
- ++this->UsedMemory;
- --this->FreeMemory;
+ entry->MemoryNext = new UserProcess::PROCESS_MEMORY_ENTRY();
+ entry->MemoryNext->MemoryEntry = ptr;
- return cursor;
+ entry->MemoryNext->MemoryPrev = entry;
+ entry->MemoryNext->MemoryNext = nullptr;
}
return nullptr;
@@ -113,39 +132,31 @@ namespace Kernel
/***********************************************************************************/
- /* @brief checks if runtime pointer is in region. */
- bool rt_is_in_pool(VoidPtr pool_ptr, VoidPtr pool, const SizeT& pool_ptr_cur_sz, const SizeT& pool_ptr_used_sz)
- {
- if (pool == nullptr ||
- pool_ptr == nullptr)
- return false;
-
- UIntPtr* uint_pool_ptr = (UIntPtr*)pool_ptr;
- UIntPtr* uint_pool = (UIntPtr*)pool;
-
- return (UIntPtr)&uint_pool > (UIntPtr)&uint_pool_ptr &&
- pool_ptr_cur_sz > pool_ptr_used_sz;
- }
-
- /* @brief free pointer from usage. */
+ /** @brief Free pointer from usage. */
Boolean UserProcess::Delete(VoidPtr ptr, const SizeT& sz)
{
- if (sz < 1 || this->HeapCursor == this->HeapPtr)
- return false;
-
- // also check for the amount of allocations we've done so far.
- if (this->UsedMemory < 1)
- return false;
+ auto entry = this->MemoryEntryList;
- if (rt_is_in_pool(ptr, this->HeapCursor, this->UsedMemory, this->FreeMemory))
+ while (entry->MemoryNext)
{
- this->HeapCursor = (VoidPtr)((UIntPtr)this->HeapCursor - (sizeof(sz)));
- rt_zero_memory(ptr, sz);
+ if (entry->MemoryEntry == ptr)
+ {
+#ifdef __ZKA_AMD64__
+ auto pd = hal_read_cr3();
+ hal_write_cr3(this->MemoryPD);
+
+ bool ret = mm_delete_ke_heap(ptr);
+ hal_write_cr3(reinterpret_cast<UIntPtr>(pd));
- ++this->FreeMemory;
- --this->UsedMemory;
+ return ret;
+#else
+ bool ret = mm_delete_ke_heap(ptr);
+ return ret;
+#endif
+ }
- return true;
+ if (entry->MemoryNext)
+ entry = entry->MemoryNext;
}
return false;
@@ -185,7 +196,7 @@ namespace Kernel
void UserProcess::Exit(const Int32& exit_code)
{
this->Status = ProcessStatusKind::kDead;
-
+
fLastExitCode = exit_code;
cLastExitCode = exit_code;
@@ -213,7 +224,8 @@ namespace Kernel
if (this->StackReserve)
delete[] this->StackReserve;
- cProcessScheduler->Remove(this->ProcessId);
+ if (this->ProcessId > 0)
+ UserProcessScheduler::The().Remove(this->ProcessId);
}
/// @brief Add process to list.
@@ -221,46 +233,34 @@ namespace Kernel
/// @return the process index inside the team.
SizeT UserProcessScheduler::Add(UserProcess& process)
{
- if (!process.Image)
- {
- return -kErrorInvalidData;
- }
+#ifdef __ZKA_AMD64__
+ process.MemoryPD = reinterpret_cast<UIntPtr>(hal_read_cr3());
+#endif // __ZKA_AMD64__
- kcout << "UserProcessScheduler: Adding process to team...\r";
+ process.StackFrame = (HAL::StackFrame*)process.New(sizeof(HAL::StackFrame));
- // Create heap according to type of process.
- if (process.Kind == UserProcess::kExeKind)
- {
- process.HeapPtr = mm_new_ke_heap(process.SizeMemory, true, true);
- }
- else if (process.Kind == UserProcess::kDLLKind)
+ if (!process.StackFrame)
{
- process.DLLPtr = rtl_init_shared_object(&process);
- process.HeapPtr = mm_new_ke_heap(process.SizeMemory, true, true);
- }
- else
- {
- // Something went wrong, do not continue, process may be incorrect.
process.Crash();
return -kErrorProcessFault;
}
- process.StackFrame = new HAL::StackFrame();
-
- MUST_PASS(process.StackFrame);
+ // Create heap according to type of process.
+ if (process.Kind == UserProcess::kDLLKind)
+ {
+ process.DLLPtr = rtl_init_shared_object(&process);
+ }
if (process.Image)
{
// get preferred stack size by app.
const auto cMaxStackSize = process.StackSize;
+ process.StackReserve = (UInt8*)process.New(sizeof(UInt8) * cMaxStackSize);
- process.StackReserve = (UInt8*)mm_new_ke_heap(cMaxStackSize, Yes, Yes);
-
- // if stack pointer isn't valid.
- if (!process.StackReserve)
+ if (process.StackReserve)
{
- process.StackReserve = (UInt8*)mm_new_ke_heap(kSchedMaxStackSz, Yes, Yes);
- kcout << "newoskrnl.exe: Use fallback reserve size.\r";
+ process.Crash();
+ return -kErrorProcessFault;
}
}
else
@@ -272,18 +272,16 @@ namespace Kernel
}
}
- process.Status = ProcessStatusKind::kStarting;
-
+ process.Status = ProcessStatusKind::kStarting;
process.ProcessId = mTeam.mProcessAmount;
++mTeam.mProcessAmount;
- process.HeapCursor = process.HeapPtr;
+ while (1)
+ ;
mTeam.AsArray()[process.ProcessId] = process;
- kcout << "UserProcessScheduler: Adding process to team [ OK ]...\r";
-
return process.ProcessId;
}
@@ -298,22 +296,16 @@ namespace Kernel
/***********************************************************************************/
/// @brief Remove process from list.
- /// @param processSlot process slot inside team.
+ /// @param process_id process slot inside team.
/// @retval true process was removed.
/// @retval false process doesn't exist in team.
- Bool UserProcessScheduler::Remove(ProcessID processSlot)
+ Bool UserProcessScheduler::Remove(ProcessID process_id)
{
// check if process is within range.
- if (processSlot > mTeam.AsArray().Count())
+ if (process_id > mTeam.AsArray().Count())
return false;
- // also check if the process isn't a dummy one.
- if (mTeam.AsArray()[processSlot].Image == nullptr)
- return false;
-
- kcout << "UserProcessScheduler: Removing process...\r";
-
- mTeam.AsArray()[processSlot].Status = ProcessStatusKind::kDead;
+ mTeam.AsArray()[process_id].Status = ProcessStatusKind::kDead;
--mTeam.mProcessAmount;
return true;
@@ -334,7 +326,7 @@ namespace Kernel
if (UserProcessHelper::CanBeScheduled(process))
{
// set the current process.
- mTeam.AsRef() = process;
+ mTeam.AsRef() = mTeam.AsArray()[process.ProcessId];
process.PTime = static_cast<Int32>(process.Affinity);
@@ -342,7 +334,7 @@ namespace Kernel
// tell helper to find a core to schedule on.
if (!UserProcessHelper::Switch(process.Image, &process.StackReserve[process.StackSize], process.StackFrame,
- process.ProcessId))
+ process.ProcessId))
{
process.Crash();
continue;
@@ -386,6 +378,16 @@ namespace Kernel
return cProcessScheduler->CurrentProcess().Leak().ProcessId;
}
+ Void UserProcessHelper::Init()
+ {
+ if (mm_is_valid_heap(cProcessScheduler))
+ delete cProcessScheduler;
+
+ cProcessScheduler = nullptr;
+ cProcessScheduler = new UserProcessScheduler();
+ MUST_PASS(cProcessScheduler);
+ }
+
/// @brief Check if process can be schedulded.
/// @param process the process reference.
/// @retval true can be schedulded.
@@ -401,7 +403,7 @@ namespace Kernel
if (auto start = process.DLLPtr->Load<VoidPtr>(kPefStart, rt_string_len(kPefStart), kPefCode);
start)
{
- process.Image = start;
+ process.Image = start;
}
}
@@ -414,14 +416,6 @@ namespace Kernel
SizeT UserProcessHelper::StartScheduling()
{
- if (!cProcessScheduler)
- {
- cProcessScheduler = new UserProcessScheduler();
- MUST_PASS(cProcessScheduler);
-
- kcout << "newoskrnl.exe: Team capacity: " << number(cProcessScheduler->CurrentTeam().AsArray().Capacity()) << endl;
- }
-
SizeT ret = cProcessScheduler->Run();
return ret;
}
@@ -437,8 +431,6 @@ namespace Kernel
if (!stack || !frame_ptr || !image_ptr || new_pid < 0)
return false;
- kcout << "newoskrnl.exe: Finding hardware thread...\r";
-
for (SizeT index = 0UL; index < HardwareThreadScheduler::The().Count(); ++index)
{
if (HardwareThreadScheduler::The()[index].Leak()->Kind() == kInvalidHart)
@@ -452,17 +444,16 @@ namespace Kernel
HardwareThreadScheduler::The()[index].Leak()->Kind() !=
ThreadKind::kHartSystemReserved)
{
- HardwareThreadScheduler::The()[index].Leak()->Busy(true);
-
+ PID prev_pid = UserProcessHelper::TheCurrentPID();
UserProcessHelper::TheCurrentPID() = new_pid;
- kcout << "newoskrnl.exe: Found hardware thread...\r";
-
bool ret = HardwareThreadScheduler::The()[index].Leak()->Switch(image_ptr, stack, frame_ptr);
- HardwareThreadScheduler::The()[index].Leak()->Busy(false);
-
- return ret;
+ if (!ret)
+ {
+ UserProcessHelper::TheCurrentPID() = prev_pid;
+ continue;
+ }
}
}
diff --git a/dev/ZKA/Sources/ProcessTeam.cxx b/dev/ZKA/Sources/UserProcessTeam.cxx
index bb5726f7..bb5726f7 100644
--- a/dev/ZKA/Sources/ProcessTeam.cxx
+++ b/dev/ZKA/Sources/UserProcessTeam.cxx
diff --git a/dev/ZKA/Sources/compile_flags.txt b/dev/ZKA/Sources/compile_flags.txt
index 33aadad4..a22ed881 100644
--- a/dev/ZKA/Sources/compile_flags.txt
+++ b/dev/ZKA/Sources/compile_flags.txt
@@ -3,5 +3,5 @@
-std=c++20
-I../
-I$(HOME)/
--D__FSKIT_USE_NEWFS__
+-D__FSKIT_USE_NEFS__
-D__ZKA_AMD64__
diff --git a/dev/ZKA/StorageKit/AHCI.hxx b/dev/ZKA/StorageKit/AHCI.hxx
index 3e9567a5..f3d771c9 100644
--- a/dev/ZKA/StorageKit/AHCI.hxx
+++ b/dev/ZKA/StorageKit/AHCI.hxx
@@ -6,8 +6,8 @@
#pragma once
-#include <KernelKit/DeviceManager.hxx>
-#include <KernelKit/DriveManager.hxx>
+#include <KernelKit/DeviceMgr.hxx>
+#include <KernelKit/DriveMgr.hxx>
#include <NewKit/OwnPtr.hxx>
namespace Kernel
diff --git a/dev/ZKA/StorageKit/ATA.hxx b/dev/ZKA/StorageKit/ATA.hxx
index be3e4a21..e954b0e7 100644
--- a/dev/ZKA/StorageKit/ATA.hxx
+++ b/dev/ZKA/StorageKit/ATA.hxx
@@ -6,8 +6,8 @@
#pragma once
-#include <KernelKit/DeviceManager.hxx>
-#include <KernelKit/DriveManager.hxx>
+#include <KernelKit/DeviceMgr.hxx>
+#include <KernelKit/DriveMgr.hxx>
#include <NewKit/OwnPtr.hxx>
#include <NewKit/Utils.hxx>
diff --git a/dev/ZKA/StorageKit/NVME.hxx b/dev/ZKA/StorageKit/NVME.hxx
index c0231f57..45d00c0c 100644
--- a/dev/ZKA/StorageKit/NVME.hxx
+++ b/dev/ZKA/StorageKit/NVME.hxx
@@ -6,8 +6,8 @@
#pragma once
-#include <KernelKit/DeviceManager.hxx>
-#include <KernelKit/DriveManager.hxx>
+#include <KernelKit/DeviceMgr.hxx>
+#include <KernelKit/DriveMgr.hxx>
#include <NewKit/OwnPtr.hxx>
namespace Kernel
diff --git a/dev/ZKA/amd64-efi.make b/dev/ZKA/amd64-efi.make
index 02224e93..00c2664e 100644
--- a/dev/ZKA/amd64-efi.make
+++ b/dev/ZKA/amd64-efi.make
@@ -6,7 +6,7 @@
CC = x86_64-w64-mingw32-g++
LD = x86_64-w64-mingw32-ld
CCFLAGS = -fshort-wchar -c -D__ZKA_AMD64__ -mno-red-zone -fno-rtti -fno-exceptions \
- -std=c++20 -D__ZKA_SUPPORT_NX__ -I../Vendor -D__FSKIT_USE_NEWFS__ \
+ -std=c++20 -D__ZKA_SUPPORT_NX__ -I../Vendor -D__FSKIT_USE_NEFS__ \
-D__NEWOSKRNL__ -D__HAVE_ZKA_APIS__ -D__FREESTANDING__ -D__ZKA__ -I./ -I../ -I../ZBA
ASM = nasm
@@ -38,7 +38,7 @@ ASMFLAGS = -f win64
LDFLAGS = -e hal_init_platform --subsystem=17 --image-base 0x10000000
LDOBJ = Objects/*.obj
-# This file is the Kernel, responsible of task management and memory.
+# This file is the Kernel, responsible of task, memory, driver, sci, disk and device management.
KERNEL = newoskrnl.exe
.PHONY: error
diff --git a/dev/ZKA/arm64-efi.make b/dev/ZKA/arm64-efi.make
index 65f3a0ae..a801ed3e 100644
--- a/dev/ZKA/arm64-efi.make
+++ b/dev/ZKA/arm64-efi.make
@@ -7,7 +7,7 @@ CC = clang++
LD = lld-link
CCFLAGS = -fshort-wchar -c -ffreestanding -MMD -mno-red-zone -D__ZKA_ARM64__ -fno-rtti -fno-exceptions -I./ \
-target aarch64-unknown-windows \
- -std=c++20 -D__FSKIT_USE_NEWFS__ -D__ZETA_MACHINE__ -D__NEWOSKRNL__ -D__HAVE_ZKA_APIS__ -D__ZKA__ -I../
+ -std=c++20 -D__FSKIT_USE_NEFS__ -D__ZETA_MACHINE__ -D__NEWOSKRNL__ -D__HAVE_ZKA_APIS__ -D__ZKA__ -I../
ASM = clang++
diff --git a/doc/NewFS.pdf b/doc/NeFS.pdf
index a2193504..a2193504 100644
--- a/doc/NewFS.pdf
+++ b/doc/NeFS.pdf
Binary files differ