summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
Diffstat (limited to 'dev')
-rw-r--r--dev/ZBAKit/src/HEL/AMD64/BootATA.cc4
-rw-r--r--dev/ZKAKit/FSKit/NeFS.h12
-rw-r--r--dev/ZKAKit/FirmwareKit/EFI/EFI.h22
-rw-r--r--dev/ZKAKit/HALKit/AMD64/HalDescriptorLoader.cc2
-rw-r--r--dev/ZKAKit/HALKit/AMD64/HalKernelMain.cc14
-rw-r--r--dev/ZKAKit/HALKit/AMD64/Storage/AHCI.cc2
-rw-r--r--dev/ZKAKit/HALKit/AMD64/Storage/ATA-PIO.cc4
-rw-r--r--dev/ZKAKit/HALKit/ARM64/Storage/HalFlash.cc10
-rw-r--r--dev/ZKAKit/KernelKit/HardwareThreadScheduler.h6
-rw-r--r--dev/ZKAKit/KernelKit/PCI/DMA.h2
-rw-r--r--dev/ZKAKit/KernelKit/PEFCodeMgr.h2
-rw-r--r--dev/ZKAKit/KernelKit/User.h1
-rw-r--r--dev/ZKAKit/KernelKit/UserProcessScheduler.h14
-rw-r--r--dev/ZKAKit/NewKit/Json.h12
-rw-r--r--dev/ZKAKit/NewKit/Macros.h2
-rw-r--r--dev/ZKAKit/src/CodeMgr.cc21
-rw-r--r--dev/ZKAKit/src/FS/NeFS.cc10
-rw-r--r--dev/ZKAKit/src/HardwareThreadScheduler.cc2
-rw-r--r--dev/ZKAKit/src/PEFCodeMgr.cc34
-rw-r--r--dev/ZKAKit/src/Stop.cc4
-rw-r--r--dev/ZKAKit/src/User.cc16
-rw-r--r--dev/ZKAKit/src/UserProcessScheduler.cc54
-rw-r--r--dev/ZKAKit/src/Utils.cc5
23 files changed, 146 insertions, 109 deletions
diff --git a/dev/ZBAKit/src/HEL/AMD64/BootATA.cc b/dev/ZBAKit/src/HEL/AMD64/BootATA.cc
index 69ebdbe9..ca883935 100644
--- a/dev/ZBAKit/src/HEL/AMD64/BootATA.cc
+++ b/dev/ZBAKit/src/HEL/AMD64/BootATA.cc
@@ -124,7 +124,7 @@ Void boot_ata_read(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeUTF8* Buf,
Out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz) / SectorSz));
- Out8(IO + ATA_REG_LBA0, (Lba) & 0xFF);
+ Out8(IO + ATA_REG_LBA0, (Lba)&0xFF);
Out8(IO + ATA_REG_LBA1, (Lba) >> 8);
Out8(IO + ATA_REG_LBA2, (Lba) >> 16);
Out8(IO + ATA_REG_LBA3, (Lba) >> 24);
@@ -154,7 +154,7 @@ Void boot_ata_write(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeUTF8* Buf,
Out8(IO + ATA_REG_SEC_COUNT0, ((Size + (SectorSz)) / SectorSz));
- Out8(IO + ATA_REG_LBA0, (Lba) & 0xFF);
+ Out8(IO + ATA_REG_LBA0, (Lba)&0xFF);
Out8(IO + ATA_REG_LBA1, (Lba) >> 8);
Out8(IO + ATA_REG_LBA2, (Lba) >> 16);
Out8(IO + ATA_REG_LBA3, (Lba) >> 24);
diff --git a/dev/ZKAKit/FSKit/NeFS.h b/dev/ZKAKit/FSKit/NeFS.h
index dbe892e3..3d2f4a46 100644
--- a/dev/ZKAKit/FSKit/NeFS.h
+++ b/dev/ZKAKit/FSKit/NeFS.h
@@ -239,15 +239,15 @@ namespace Kernel
/// @param theFork the fork itself.
/// @return the fork
_Output NFS_FORK_STRUCT* CreateFork(_Input NFS_CATALOG_STRUCT* catalog,
- _Input NFS_FORK_STRUCT& theFork);
+ _Input NFS_FORK_STRUCT& theFork);
/// @brief Find fork inside New filesystem.
/// @param catalog the catalog.
/// @param name the fork name.
/// @return the fork.
_Output NFS_FORK_STRUCT* FindFork(_Input NFS_CATALOG_STRUCT* catalog,
- _Input const Char* name,
- Boolean dataOrRsrc);
+ _Input const Char* name,
+ Boolean dataOrRsrc);
_Output Void RemoveFork(_Input NFS_FORK_STRUCT* fork);
@@ -257,7 +257,7 @@ namespace Kernel
_Output NFS_CATALOG_STRUCT* GetCatalog(_Input const Char* name);
- _Output NFS_CATALOG_STRUCT* CreateCatalog(_Input const Char* name,
+ _Output NFS_CATALOG_STRUCT* CreateCatalog(_Input const Char* name,
_Input const Int32& flags,
_Input const Int32& kind);
@@ -267,12 +267,12 @@ namespace Kernel
_Input Bool isRsrcFork,
_Input VoidPtr data,
_Input SizeT sizeOfData,
- _Input const Char* forkName);
+ _Input const Char* forkName);
VoidPtr ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
_Input Bool isRsrcFork,
_Input SizeT dataSz,
- _Input const Char* forkName);
+ _Input const Char* forkName);
bool Seek(_Input _Output NFS_CATALOG_STRUCT* catalog, SizeT off);
diff --git a/dev/ZKAKit/FirmwareKit/EFI/EFI.h b/dev/ZKAKit/FirmwareKit/EFI/EFI.h
index bedf5131..98942e4e 100644
--- a/dev/ZKAKit/FirmwareKit/EFI/EFI.h
+++ b/dev/ZKAKit/FirmwareKit/EFI/EFI.h
@@ -50,7 +50,7 @@ typedef UInt64 EfiStatusType;
/// This is like NT's Win32 HANDLE type.
typedef struct EfiHandle
{
-}* EfiHandlePtr;
+} * EfiHandlePtr;
/* UEFI uses wide characters by default. */
typedef WideChar EfiCharType;
@@ -593,7 +593,7 @@ typedef struct EfiSystemTable
{
EfiGUID VendorGUID;
VoidPtr VendorTable;
- }* ConfigurationTable;
+ } * ConfigurationTable;
} EfiSystemTable;
#define kEfiOk 0
@@ -823,11 +823,11 @@ typedef struct _EfiProcessorInformation
typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS)(
IN struct _EfiMpServicesProtocol* Self,
- OUT UInt32* NumberOfProcessors,
- OUT UInt32* NumberOfEnabledProcessors);
+ OUT UInt32* NumberOfProcessors,
+ OUT UInt32* NumberOfEnabledProcessors);
typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_GET_PROCESSOR_INFO)(
- IN struct _EfiMpServicesProtocol* Self,
+ IN struct _EfiMpServicesProtocol* Self,
IN UInt32* ProcessorNumber,
OUT struct _EfiProcessorInformation* NumberOfEnabledProcessors);
@@ -842,8 +842,8 @@ typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_STARTUP_ALL_APS)(
IN Boolean SingleThread,
IN VoidPtr WaitEvent OPTIONAL, // EFI_EVENT first, but unused here.
IN UInt32 TimeoutInMicroSeconds,
- IN Void* ProcedureArgument OPTIONAL,
- OUT UInt32** FailedCpuList OPTIONAL);
+ IN Void* ProcedureArgument OPTIONAL,
+ OUT UInt32** FailedCpuList OPTIONAL);
typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_SWITCH_BSP)(
IN struct _EfiMpServicesProtocol* This,
@@ -856,18 +856,18 @@ typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_STARTUP_THIS_AP)(
IN UInt32 ProcessorNumber,
IN VoidPtr WaitEvent OPTIONAL,
IN UInt32 TimeoutInMicroseconds,
- IN Void* ProcedureArgument OPTIONAL,
- OUT Boolean* Finished OPTIONAL);
+ IN Void* ProcedureArgument OPTIONAL,
+ OUT Boolean* Finished OPTIONAL);
typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_ENABLEDISABLEAP)(
IN struct _EfiMpServicesProtocol* This,
IN UInt32 ProcessorNumber,
IN Boolean EnableAP,
- IN UInt32* HealthFlag OPTIONAL);
+ IN UInt32* HealthFlag OPTIONAL);
typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_WHOAMI)(
IN struct _EfiMpServicesProtocol* This,
- OUT UInt32* ProcessorNumber);
+ OUT UInt32* ProcessorNumber);
typedef struct _EfiMpServicesProtocol
{
diff --git a/dev/ZKAKit/HALKit/AMD64/HalDescriptorLoader.cc b/dev/ZKAKit/HALKit/AMD64/HalDescriptorLoader.cc
index f28d23a5..b04fb0b0 100644
--- a/dev/ZKAKit/HALKit/AMD64/HalDescriptorLoader.cc
+++ b/dev/ZKAKit/HALKit/AMD64/HalDescriptorLoader.cc
@@ -7,7 +7,7 @@
#include <ArchKit/ArchKit.h>
#include <HALKit/AMD64/Processor.h>
-#define kPITDefaultTicks (100U)
+#define kPITDefaultTicks (1000U)
namespace Kernel::HAL
{
diff --git a/dev/ZKAKit/HALKit/AMD64/HalKernelMain.cc b/dev/ZKAKit/HALKit/AMD64/HalKernelMain.cc
index 14cf4dae..05ace369 100644
--- a/dev/ZKAKit/HALKit/AMD64/HalKernelMain.cc
+++ b/dev/ZKAKit/HALKit/AMD64/HalKernelMain.cc
@@ -24,8 +24,10 @@ STATIC Kernel::Void hal_init_cxx_ctors()
{
for (Kernel::SizeT index = 0UL; __CTOR_LIST__[index] != __DTOR_LIST__[0]; ++index)
{
- Kernel::MainKind ctor = (Kernel::MainKind)__CTOR_LIST__[index];
- ctor();
+ Kernel::MainKind constructor_cxx = (Kernel::MainKind)__CTOR_LIST__[index];
+ constructor_cxx();
+
+ kcout << "Called constrcutor.\r";
}
}
@@ -84,6 +86,14 @@ EXTERN_C Kernel::Void hal_real_init(Kernel::Void) noexcept
/* Initialize filesystem. */
Kernel::NeFileSystemMgr::Mount(new Kernel::NeFileSystemMgr());
+ Kernel::rtl_create_process([]() -> void {
+ while (Yes)
+ {
+ kcout << "Hello.\r";
+ }
+ },
+ "RtlProcess");
+
/* Start any cores. */
if (kHandoverHeader->f_HardwareTables.f_MultiProcessingEnabled)
Kernel::HAL::mp_get_cores(kHandoverHeader->f_HardwareTables.f_VendorPtr);
diff --git a/dev/ZKAKit/HALKit/AMD64/Storage/AHCI.cc b/dev/ZKAKit/HALKit/AMD64/Storage/AHCI.cc
index b4d72267..52603f51 100644
--- a/dev/ZKAKit/HALKit/AMD64/Storage/AHCI.cc
+++ b/dev/ZKAKit/HALKit/AMD64/Storage/AHCI.cc
@@ -31,7 +31,7 @@ enum
};
STATIC Kernel::PCI::Device kAhciDevice;
-STATIC HbaPort* kAhciPort = nullptr;
+STATIC HbaPort* kAhciPort = nullptr;
/// @brief Initializes an AHCI disk.
/// @param PortsImplemented the amount of kAhciPort that have been detected.
diff --git a/dev/ZKAKit/HALKit/AMD64/Storage/ATA-PIO.cc b/dev/ZKAKit/HALKit/AMD64/Storage/ATA-PIO.cc
index 8ddeeeb4..811c9033 100644
--- a/dev/ZKAKit/HALKit/AMD64/Storage/ATA-PIO.cc
+++ b/dev/ZKAKit/HALKit/AMD64/Storage/ATA-PIO.cc
@@ -123,7 +123,7 @@ Void drv_std_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorSz
Out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz) / SectorSz));
- Out8(IO + ATA_REG_LBA0, (Lba) & 0xFF);
+ Out8(IO + ATA_REG_LBA0, (Lba)&0xFF);
Out8(IO + ATA_REG_LBA1, (Lba) >> 8);
Out8(IO + ATA_REG_LBA2, (Lba) >> 16);
Out8(IO + ATA_REG_LBA3, (Lba) >> 24);
@@ -155,7 +155,7 @@ Void drv_std_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorS
Out8(IO + ATA_REG_SEC_COUNT0, ((Size + (SectorSz)) / SectorSz));
- Out8(IO + ATA_REG_LBA0, (Lba) & 0xFF);
+ Out8(IO + ATA_REG_LBA0, (Lba)&0xFF);
Out8(IO + ATA_REG_LBA1, (Lba) >> 8);
Out8(IO + ATA_REG_LBA2, (Lba) >> 16);
Out8(IO + ATA_REG_LBA3, (Lba) >> 24);
diff --git a/dev/ZKAKit/HALKit/ARM64/Storage/HalFlash.cc b/dev/ZKAKit/HALKit/ARM64/Storage/HalFlash.cc
index 7204f7ae..e7aca8f6 100644
--- a/dev/ZKAKit/HALKit/ARM64/Storage/HalFlash.cc
+++ b/dev/ZKAKit/HALKit/ARM64/Storage/HalFlash.cc
@@ -12,7 +12,7 @@
#ifdef __USE_MBCI_FLASH__
-#define cMaxFlash (4U)
+#define kMaxFlash (4U)
namespace Kernel
{
@@ -21,8 +21,8 @@ namespace Kernel
constexpr auto kFlashBridgeRevision = 1;
STATIC const Boolean kFlashEnabled = No;
- STATIC SizeT kFlashSize[cMaxFlash] = {};
- STATIC SizeT kFlashSectorSz[cMaxFlash] = {};
+ STATIC SizeT kFlashSize[kMaxFlash] = {};
+ STATIC SizeT kFlashSectorSz[kMaxFlash] = {};
/// @brief Enable flash memory builtin.
STATIC Void drv_enable_flash(Int32 slot);
@@ -34,7 +34,7 @@ namespace Kernel
/// @return drive sector count.
SizeT drv_get_sector_count(Int32 slot)
{
- if (slot > cMaxFlash)
+ if (slot > kMaxFlash)
return 0;
return kFlashSectorSz[slot];
@@ -44,7 +44,7 @@ namespace Kernel
/// @return drive size
SizeT drv_get_size(Int32 slot)
{
- if (slot > cMaxFlash)
+ if (slot > kMaxFlash)
return 0;
return kFlashSize[slot];
diff --git a/dev/ZKAKit/KernelKit/HardwareThreadScheduler.h b/dev/ZKAKit/KernelKit/HardwareThreadScheduler.h
index bd669018..5ea7553f 100644
--- a/dev/ZKAKit/KernelKit/HardwareThreadScheduler.h
+++ b/dev/ZKAKit/KernelKit/HardwareThreadScheduler.h
@@ -14,7 +14,7 @@
/// @note Last Rev Sun 28 Jul CET 2024
/// @note Last Rev Thu, Aug 1, 2024 9:07:38 AM
-#define cMaxHartInsideSched (8U)
+#define kMaxHartInsideSched (8U)
namespace Kernel
{
@@ -105,7 +105,7 @@ namespace Kernel
public:
Ref<HardwareThread*> operator[](const SizeT& idx);
bool operator!() noexcept;
- operator bool() noexcept;
+ operator bool() noexcept;
const Bool IsUser() override
{
@@ -133,7 +133,7 @@ namespace Kernel
SizeT Count() noexcept;
private:
- Array<HardwareThread, cMaxHartInsideSched> fThreadList;
+ Array<HardwareThread, kMaxHartInsideSched> fThreadList;
ThreadID fCurrentThread{0};
};
diff --git a/dev/ZKAKit/KernelKit/PCI/DMA.h b/dev/ZKAKit/KernelKit/PCI/DMA.h
index 2d71e0d6..89e38cb9 100644
--- a/dev/ZKAKit/KernelKit/PCI/DMA.h
+++ b/dev/ZKAKit/KernelKit/PCI/DMA.h
@@ -52,7 +52,7 @@ namespace Kernel
T* Get(const UIntPtr off = 0);
public:
- operator bool();
+ operator bool();
bool operator!();
public:
diff --git a/dev/ZKAKit/KernelKit/PEFCodeMgr.h b/dev/ZKAKit/KernelKit/PEFCodeMgr.h
index 568b77da..6887f521 100644
--- a/dev/ZKAKit/KernelKit/PEFCodeMgr.h
+++ b/dev/ZKAKit/KernelKit/PEFCodeMgr.h
@@ -60,7 +60,7 @@ namespace Kernel
namespace Utils
{
- ProcessID execute_from_image(PEFLoader& exec, const Int32& procKind) noexcept;
+ ProcessID rtl_create_process(PEFLoader& exec, const Int32& procKind) noexcept;
} // namespace Utils
} // namespace Kernel
diff --git a/dev/ZKAKit/KernelKit/User.h b/dev/ZKAKit/KernelKit/User.h
index ebb8cee2..48475b2e 100644
--- a/dev/ZKAKit/KernelKit/User.h
+++ b/dev/ZKAKit/KernelKit/User.h
@@ -27,6 +27,7 @@ namespace Kernel
enum class UserRingKind
{
+ kRingInvalid = 0,
kRingStdUser = 1,
kRingSuperUser = 2,
kRingGuestUser = 5,
diff --git a/dev/ZKAKit/KernelKit/UserProcessScheduler.h b/dev/ZKAKit/KernelKit/UserProcessScheduler.h
index 3ec92e8c..9880b565 100644
--- a/dev/ZKAKit/KernelKit/UserProcessScheduler.h
+++ b/dev/ZKAKit/KernelKit/UserProcessScheduler.h
@@ -122,8 +122,7 @@ namespace Kernel
};
// Helper types.
- using ImagePtr = VoidPtr;
- using HeapPtrKind = VoidPtr;
+ using ImagePtr = VoidPtr;
/// @name UserProcess
/// @brief User process header.
@@ -131,7 +130,7 @@ namespace Kernel
class UserProcess final
{
public:
- explicit UserProcess(VoidPtr startImage = nullptr);
+ UserProcess(VoidPtr start_image = nullptr);
~UserProcess();
public:
@@ -241,7 +240,6 @@ namespace Kernel
public:
Array<UserProcess, kSchedProcessLimitPerTeam> mProcessList;
Ref<UserProcess> mCurrentProcess;
- SizeT mProcessAmount{0};
ProcessID mTeamId{0};
};
@@ -259,7 +257,7 @@ namespace Kernel
ZKA_COPY_DEFAULT(UserProcessScheduler)
- operator bool();
+ operator bool();
bool operator!();
public:
@@ -281,7 +279,7 @@ namespace Kernel
STATIC UserProcessScheduler& The();
private:
- UserProcessTeam mTeam;
+ UserProcessTeam mTeam{};
};
/*
@@ -291,8 +289,8 @@ namespace Kernel
class UserProcessHelper final
{
public:
- STATIC bool Switch(VoidPtr image_ptr, UInt8* stack_ptr, HAL::StackFramePtr frame_ptr, const PID& new_pid);
- STATIC bool CanBeScheduled(const UserProcess& process);
+ STATIC bool Switch(VoidPtr image_ptr, UInt8* stack_ptr, HAL::StackFramePtr frame_ptr, const PID& new_pid);
+ STATIC bool CanBeScheduled(const UserProcess& process);
STATIC PID& TheCurrentPID();
STATIC SizeT StartScheduling();
};
diff --git a/dev/ZKAKit/NewKit/Json.h b/dev/ZKAKit/NewKit/Json.h
index 05b24808..5a9676dd 100644
--- a/dev/ZKAKit/NewKit/Json.h
+++ b/dev/ZKAKit/NewKit/Json.h
@@ -15,9 +15,9 @@
#include <NewKit/KString.h>
#include <NewKit/Utils.h>
-#define cMaxJsonPath 4096
-#define cJSONLen 32
-#define cJSONNull "null"
+#define kMaxJsonPath 4096
+#define kJSONLen 32
+#define kJSONNull "null"
namespace Kernel
{
@@ -27,9 +27,9 @@ namespace Kernel
public:
explicit JSON()
{
- auto len = cJSONLen;
+ auto len = kJSONLen;
KString key = KString(len);
- key += cJSONNull;
+ key += kJSONNull;
this->AsKey() = key;
this->AsValue() = key;
@@ -97,7 +97,7 @@ namespace Kernel
SizeT key_len = 0;
SizeT value_len = 0;
- JSON type(cMaxJsonPath, cMaxJsonPath);
+ JSON type(kMaxJsonPath, kMaxJsonPath);
for (SizeT i = 1; i < len; ++i)
{
diff --git a/dev/ZKAKit/NewKit/Macros.h b/dev/ZKAKit/NewKit/Macros.h
index 4d19416a..7041741b 100644
--- a/dev/ZKAKit/NewKit/Macros.h
+++ b/dev/ZKAKit/NewKit/Macros.h
@@ -11,7 +11,7 @@
#endif
#ifndef kib_cast
-#define kib_cast(X) (Kernel::UInt64)((X) * 1024)
+#define kib_cast(X) (Kernel::UInt64)((X)*1024)
#endif
#ifndef MIB
diff --git a/dev/ZKAKit/src/CodeMgr.cc b/dev/ZKAKit/src/CodeMgr.cc
index b71f49d3..4031736a 100644
--- a/dev/ZKAKit/src/CodeMgr.cc
+++ b/dev/ZKAKit/src/CodeMgr.cc
@@ -16,18 +16,25 @@ namespace Kernel
/// @return if the process was started or not.
ProcessID rtl_create_process(MainKind main, const Char* process_name) noexcept
{
+ kcout << "Validating process...\r";
+
if (!main)
return No;
- UserProcess proc;
+ UserProcess* proc = new UserProcess{reinterpret_cast<VoidPtr>(main)};
+
+ kcout << "Setting-up process...\r";
+
+ proc->Kind = UserProcess::kExectuableKind;
+ proc->StackSize = kib_cast(8);
+ proc->PTime = 0UL;
+
+ rt_copy_memory((VoidPtr)process_name, proc->Name, rt_string_len(process_name));
- proc.Image = reinterpret_cast<VoidPtr>(main);
- proc.Kind = UserProcess::kExectuableKind;
- proc.StackSize = kib_cast(32);
+ ProcessID id = UserProcessScheduler::The().Add(*proc);
- rt_set_memory(proc.Name, 0, kProcessLen);
- rt_copy_memory((VoidPtr)process_name, proc.Name, rt_string_len(process_name));
+ delete proc;
- return UserProcessScheduler::The().Add(proc);
+ return id;
}
} // namespace Kernel
diff --git a/dev/ZKAKit/src/FS/NeFS.cc b/dev/ZKAKit/src/FS/NeFS.cc
index 652f41e3..bd93332a 100644
--- a/dev/ZKAKit/src/FS/NeFS.cc
+++ b/dev/ZKAKit/src/FS/NeFS.cc
@@ -61,7 +61,7 @@ STATIC MountpointInterface kDiskMountpoint;
/// @return the fork
/***********************************************************************************/
_Output NFS_FORK_STRUCT* NeFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* catalog,
- _Input NFS_FORK_STRUCT& the_fork)
+ _Input NFS_FORK_STRUCT& the_fork)
{
if (catalog && the_fork.ForkName[0] != 0 &&
the_fork.DataSize <= kNeFSForkDataSz)
@@ -170,8 +170,8 @@ _Output NFS_FORK_STRUCT* NeFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* catal
/// @return the fork.
/***********************************************************************************/
_Output NFS_FORK_STRUCT* NeFSParser::FindFork(_Input NFS_CATALOG_STRUCT* catalog,
- _Input const Char* name,
- Boolean isDataFork)
+ _Input const Char* name,
+ Boolean isDataFork)
{
auto drv = kDiskMountpoint.A();
NFS_FORK_STRUCT* the_fork = nullptr;
@@ -236,7 +236,7 @@ _Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name)
/// @param kind the catalog kind.
/// @return catalog pointer.
/***********************************************************************************/
-_Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name,
+_Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name,
_Input const Int32& flags,
_Input const Int32& kind)
{
@@ -936,7 +936,7 @@ Boolean NeFSParser::RemoveCatalog(_Input const Char* catalogName)
VoidPtr NeFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
_Input Bool is_rsrc_fork,
_Input SizeT dataSz,
- _Input const Char* forkName)
+ _Input const Char* forkName)
{
if (!catalog)
{
diff --git a/dev/ZKAKit/src/HardwareThreadScheduler.cc b/dev/ZKAKit/src/HardwareThreadScheduler.cc
index 5c5b8f15..84f870d0 100644
--- a/dev/ZKAKit/src/HardwareThreadScheduler.cc
+++ b/dev/ZKAKit/src/HardwareThreadScheduler.cc
@@ -162,7 +162,7 @@ namespace Kernel
fThreadList[idx].fKind = kHartBoot;
}
}
- else if (idx >= cMaxHartInsideSched)
+ else if (idx >= kMaxHartInsideSched)
{
static HardwareThread* fakeThread = nullptr;
return {fakeThread};
diff --git a/dev/ZKAKit/src/PEFCodeMgr.cc b/dev/ZKAKit/src/PEFCodeMgr.cc
index 2aba5fbf..a2b3482a 100644
--- a/dev/ZKAKit/src/PEFCodeMgr.cc
+++ b/dev/ZKAKit/src/PEFCodeMgr.cc
@@ -14,9 +14,9 @@
#include <NewKit/KString.h>
/// @brief PEF stack size symbol.
-#define cPefStackSizeSymbol "SizeOfReserveStack"
-#define cPefHeapSizeSymbol "SizeOfReserveHeap"
-#define cPefNameSymbol "ProgramName"
+#define kPefStackSizeSymbol "SizeOfReserveStack"
+#define kPefHeapSizeSymbol "SizeOfReserveHeap"
+#define kPefNameSymbol "ProgramName"
namespace Kernel
{
@@ -58,9 +58,9 @@ namespace Kernel
fFile.New(const_cast<Char*>(path), kRestrictRB);
fPath = StringBuilder::Construct(path).Leak();
- auto cPefHeader = "PEF_CONTAINER";
+ auto kPefHeader = "PEF_CONTAINER";
- fCachedBlob = fFile->Read(cPefHeader);
+ fCachedBlob = fFile->Read(kPefHeader);
PEFContainer* container = reinterpret_cast<PEFContainer*>(fCachedBlob);
@@ -228,32 +228,32 @@ namespace Kernel
namespace Utils
{
- ProcessID execute_from_image(PEFLoader& exec, const Int32& procKind) noexcept
+ ProcessID rtl_create_process(PEFLoader& exec, const Int32& procKind) noexcept
{
auto errOrStart = exec.FindStart();
if (errOrStart.Error() != kErrorSuccess)
return No;
- UserProcess proc{};
+ UserProcess* proc = new UserProcess{errOrStart.Leak().Leak()};
- proc.Image = errOrStart.Leak().Leak();
- proc.Kind = procKind;
- proc.StackSize = *(UIntPtr*)exec.FindSymbol(cPefStackSizeSymbol, kPefData);
- proc.MemoryLimit = *(UIntPtr*)exec.FindSymbol(cPefHeapSizeSymbol, kPefData);
+ proc->Kind = procKind;
+ proc->StackSize = *(UIntPtr*)exec.FindSymbol(kPefStackSizeSymbol, kPefData);
+ proc->MemoryLimit = *(UIntPtr*)exec.FindSymbol(kPefHeapSizeSymbol, kPefData);
+ proc->PTime = 0UL;
- rt_set_memory(proc.Name, 0, kProcessLen);
+ rt_set_memory(proc->Name, 0, kProcessLen);
- if (exec.FindSymbol(cPefNameSymbol, kPefData))
- rt_copy_memory(exec.FindSymbol(cPefNameSymbol, kPefData), proc.Name, rt_string_len((Char*)exec.FindSymbol(cPefNameSymbol, kPefData)));
+ if (exec.FindSymbol(kPefNameSymbol, kPefData))
+ rt_copy_memory(exec.FindSymbol(kPefNameSymbol, kPefData), proc->Name, rt_string_len((Char*)exec.FindSymbol(kPefNameSymbol, kPefData)));
- if (!proc.StackSize)
+ if (!proc->StackSize)
{
const auto cDefaultStackSizeMib = 8;
- proc.StackSize = mib_cast(cDefaultStackSizeMib);
+ proc->StackSize = mib_cast(cDefaultStackSizeMib);
}
- return UserProcessScheduler::The().Add(proc);
+ return UserProcessScheduler::The().Add(*proc);
}
} // namespace Utils
} // namespace Kernel
diff --git a/dev/ZKAKit/src/Stop.cc b/dev/ZKAKit/src/Stop.cc
index ce904988..122b4489 100644
--- a/dev/ZKAKit/src/Stop.cc
+++ b/dev/ZKAKit/src/Stop.cc
@@ -21,7 +21,7 @@
namespace Kernel
{
- void ke_stop(const Kernel::Int& id)
+ Void ke_stop(const Kernel::Int& id)
{
CGInit();
@@ -46,7 +46,7 @@ namespace Kernel
switch (id)
{
case RUNTIME_CHECK_PROCESS: {
- CGDrawString("0x00000008 Process check error.", start_y, x, panic_text);
+ CGDrawString("0x00000008 Invalid process behavior, aborting.", start_y, x, panic_text);
break;
}
case RUNTIME_CHECK_ACPI: {
diff --git a/dev/ZKAKit/src/User.cc b/dev/ZKAKit/src/User.cc
index ef35d2f4..68bb2641 100644
--- a/dev/ZKAKit/src/User.cc
+++ b/dev/ZKAKit/src/User.cc
@@ -34,7 +34,7 @@ namespace Kernel
if (!password || !user)
return 1;
- kcout << "Hashing password...\r";
+ kcout << "Hashing user password...\r";
for (Size i_pass = 0; i_pass < length; ++i_pass)
{
@@ -46,12 +46,13 @@ namespace Kernel
password[i_pass] = cur_chr | (user->IsStdUser() ? kStdUserType : kSuperUserType);
}
- kcout << "Done hashing password!\r";
+ kcout << "Done hashing user password!\r";
return 0;
}
} // namespace Detail
+ /// @brief User ring constructor.
User::User(const Int32& sel, const Char* userName)
: fRing((UserRingKind)sel)
{
@@ -59,12 +60,14 @@ namespace Kernel
rt_copy_memory((VoidPtr)userName, this->fUserName, rt_string_len(userName));
}
+ /// @brief User ring constructor.
User::User(const UserRingKind& ringKind, const Char* userName)
: fRing(ringKind)
{
rt_copy_memory((VoidPtr)userName, this->fUserName, rt_string_len(userName));
}
+ /// @brief User destructor class.
User::~User() = default;
Bool User::Save(const UserPublicKey password_to_fill) noexcept
@@ -130,7 +133,14 @@ namespace Kernel
kcout << "Validating hashed passwords...\r";
// now check if the password matches.
- return rt_string_cmp(password, this->fUserToken, rt_string_len(this->fUserToken)) == 0;
+ if (rt_string_cmp(password, this->fUserToken, rt_string_len(this->fUserToken)) == 0)
+ {
+ kcout << "Password is valid.\r";
+ return Yes;
+ }
+
+ kcout << "Password isn't valid.\r";
+ return No;
}
Bool User::operator==(const User& lhs)
diff --git a/dev/ZKAKit/src/UserProcessScheduler.cc b/dev/ZKAKit/src/UserProcessScheduler.cc
index b2fed635..67eac095 100644
--- a/dev/ZKAKit/src/UserProcessScheduler.cc
+++ b/dev/ZKAKit/src/UserProcessScheduler.cc
@@ -32,7 +32,7 @@ namespace Kernel
/// @brief Exit Code global variable.
/***********************************************************************************/
- STATIC UInt32 kLastExitCode = 0U;
+ UInt32 kLastExitCode = 0U;
/***********************************************************************************/
/// @brief User Process scheduler global and external reference of thread scheduler.
@@ -61,14 +61,7 @@ namespace Kernel
Void UserProcess::Crash()
{
- if (this->Status != ProcessStatusKind::kRunning)
- return;
-
- if (*this->Name != 0)
- {
- kcout << this->Name << ": crashed, error id: " << number(kErrorProcessFault) << endl;
- }
-
+ kcout << this->Name << ": crashed, error id: " << number(kErrorProcessFault) << endl;
this->Exit(kErrorProcessFault);
}
@@ -78,7 +71,7 @@ namespace Kernel
UserProcess::operator bool()
{
- return this->Status != ProcessStatusKind::kDead;
+ return this->Status == ProcessStatusKind::kRunning && this->Image != nullptr;
}
/***********************************************************************************/
@@ -319,13 +312,25 @@ namespace Kernel
SizeT UserProcessScheduler::Add(UserProcess process)
{
- if (mTeam.mProcessAmount > kSchedProcessLimitPerTeam)
+ kcout << "Creating process: " << process.Name << ", prevous process count: " << number(mTeam.mProcessList.Count()) << endl;
+
+ if (mTeam.mProcessList.Count() >= kSchedProcessLimitPerTeam)
return kErrorInvalidData;
+ kcout << "Create vm_register of: " << process.Name << endl;
+
#ifdef __ZKA_AMD64__
process.VMRegister = reinterpret_cast<UIntPtr>(mm_new_heap(sizeof(PDE), No, Yes));
+
+ if (!process.VMRegister)
+ {
+ process.Crash();
+ return kErrorProcessFault;
+ }
#endif // __ZKA_AMD64__
+ kcout << "Create stack_frame of: " << process.Name << endl;
+
process.StackFrame = reinterpret_cast<HAL::StackFramePtr>(mm_new_heap(sizeof(HAL::StackFrame), Yes, Yes));
if (!process.StackFrame)
@@ -334,18 +339,24 @@ namespace Kernel
return kErrorProcessFault;
}
+ kcout << "Create delegate if DLL for: " << process.Name << endl;
+
// Create heap according to type of process.
if (process.Kind == UserProcess::kExectuableDLLKind)
{
process.PefDLLDelegate = rtl_init_dll(&process);
}
+ kcout << "Validate image of: " << process.Name << endl;
+
if (!process.Image)
{
process.Crash();
return kErrorProcessFault;
}
+ kcout << "Validate stack reserve of: " << process.Name << endl;
+
// Get preferred stack size by app.
const auto kMaxStackSize = process.StackSize;
process.StackReserve = reinterpret_cast<UInt8*>(mm_new_heap(sizeof(UInt8) * kMaxStackSize, Yes, Yes));
@@ -356,13 +367,13 @@ namespace Kernel
return kErrorProcessFault;
}
- ++mTeam.mProcessAmount;
-
- process.ProcessId = mTeam.mProcessAmount;
- process.Status = ProcessStatusKind::kStarting;
+ process.ProcessId = 0UL;
+ process.Status = ProcessStatusKind::kRunning;
mTeam.AsArray()[process.ProcessId] = process;
+ kcout << "Create process: " << process.Name << endl;
+
return process.ProcessId;
}
@@ -372,6 +383,7 @@ namespace Kernel
UserProcessScheduler& UserProcessScheduler::The()
{
+ kcout << "Return user scheduler object.\r";
return kProcessScheduler;
}
@@ -387,11 +399,10 @@ namespace Kernel
const Bool UserProcessScheduler::Remove(ProcessID process_id)
{
// check if process is within range.
- if (process_id > mTeam.mProcessAmount)
+ if (process_id > mTeam.mProcessList.Count())
return No;
mTeam.AsArray()[process_id].Status = ProcessStatusKind::kDead;
- --mTeam.mProcessAmount;
return Yes;
}
@@ -424,13 +435,13 @@ namespace Kernel
SizeT process_index = 0; //! we store this guy to tell the scheduler how many
//! things we have scheduled.
- if (mTeam.mProcessAmount == 0)
+ if (mTeam.mProcessList.Empty())
{
kcout << "UserProcessScheduler::Run(): This team doesn't have any process!\r";
return 0;
}
- kcout << "UserProcessScheduler::Run(): This team has process # " << number(mTeam.mProcessAmount) << endl;
+ kcout << "UserProcessScheduler::Run(): This team has a process capacity of: " << number(mTeam.mProcessList.Capacity()) << endl;
for (; process_index < mTeam.AsArray().Capacity(); ++process_index)
{
@@ -441,9 +452,6 @@ namespace Kernel
{
process.PTime = static_cast<Int32>(process.Affinity);
- UserProcessScheduler::The().GetCurrentProcess().Leak().Status = ProcessStatusKind::kFrozen;
- UserProcessScheduler::The().GetCurrentProcess() = process;
-
kcout << "Switch to '" << process.Name << "'.\r";
// Set current process header.
@@ -463,8 +471,6 @@ namespace Kernel
}
}
- kcout << "Scheduled Process Count: " << number(process_index) << endl;
-
return process_index;
}
diff --git a/dev/ZKAKit/src/Utils.cc b/dev/ZKAKit/src/Utils.cc
index a3343527..f6564f38 100644
--- a/dev/ZKAKit/src/Utils.cc
+++ b/dev/ZKAKit/src/Utils.cc
@@ -210,3 +210,8 @@ namespace Kernel
return str;
}
} // namespace Kernel
+
+EXTERN_C void* memset(void* dst, char c, Kernel::Size len)
+{
+ return Kernel::rt_set_memory(dst, c, len);
+}