diff options
| author | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-14 20:11:35 +0200 |
|---|---|---|
| committer | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-14 20:11:35 +0200 |
| commit | e05aa2145b8d0000110b93fb371ba858cb2a02bc (patch) | |
| tree | 39d68355c6afe6f1e21f87d214a5b546b4a814d9 | |
| parent | 6c51d0d2fde9b9a0201721cc625e73b585fdc479 (diff) | |
IMP: Fixes and improvements on PEF Loader, User scheduler and BMP manager.
- This covers the Memory Manager, User Scheduler Manager and Loader Manager.
- These are mostly fixes and added features.
- Such as a new symbol to get heap reserve.
META: Run format command.
Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
45 files changed, 175 insertions, 167 deletions
diff --git a/dev/DDK/KernelAlloc.c b/dev/DDK/KernelAlloc.c index 7648712d..4fad4c0c 100644 --- a/dev/DDK/KernelAlloc.c +++ b/dev/DDK/KernelAlloc.c @@ -1,17 +1,17 @@ /* ------------------------------------------- - Copyright ZKA Technologies. + Copyright ZKA Technologies. - Purpose: DDK allocator. + Purpose: DDK allocator. ------------------------------------------- */ #include <DDK/KernelStd.h> /** - \brief Allocates a new heap on the Kernel's side. - \param sz the size of the heap block. - \return the newly allocated pointer. + \brief Allocates a new heap on the Kernel's side. + \param sz the size of the heap block. + \return the newly allocated pointer. */ DK_EXTERN void* KernelAlloc(size_t sz) { @@ -24,8 +24,8 @@ DK_EXTERN void* KernelAlloc(size_t sz) } /** - \brief Frees a pointer from the heap. - \param ptr the pointer to free. + \brief Frees a pointer from the heap. + \param ptr the pointer to free. */ DK_EXTERN void KernelFree(void* ptr) { diff --git a/dev/DDK/KernelCall.c b/dev/DDK/KernelCall.c index 49bf57b5..73e9fee3 100644 --- a/dev/DDK/KernelCall.c +++ b/dev/DDK/KernelCall.c @@ -41,10 +41,10 @@ DK_EXTERN void KernelAddSyscall(const int slot, void (*slotFn)(void* a0)) /// @return Object manifest. DK_EXTERN struct DDK_OBJECT_MANIFEST* KernelGetObject(const int slot, const char* name) { - struct DDK_OBJECT_MANIFEST* manifest = (struct DDK_OBJECT_MANIFEST*)KernelCall("RtlGetObject", slot, (void*)name, 1); + struct DDK_OBJECT_MANIFEST* manifest = (struct DDK_OBJECT_MANIFEST*)KernelCall("RtlGetObject", slot, (void*)name, 1); - if (!manifest) - return nil; + if (!manifest) + return nil; return manifest; } diff --git a/dev/DDK/KernelCxxRt.cxx b/dev/DDK/KernelCxxRt.cxx index 13471a19..ffec02ca 100644 --- a/dev/DDK/KernelCxxRt.cxx +++ b/dev/DDK/KernelCxxRt.cxx @@ -1,8 +1,8 @@ /* ------------------------------------------- - Copyright ZKA Technologies. + Copyright ZKA Technologies. - Purpose: DDK C++ runtime. + Purpose: DDK C++ runtime. ------------------------------------------- */ diff --git a/dev/DDK/KernelDev.h b/dev/DDK/KernelDev.h index 17876688..bb7bdf81 100644 --- a/dev/DDK/KernelDev.h +++ b/dev/DDK/KernelDev.h @@ -15,12 +15,12 @@ struct _KERNEL_DEVICE; /// @brief Kernel Device driver. typedef struct _KERNEL_DEVICE DK_FINAL { - char d_name[255]; // the device name. Could be /./DEVICE_NAME/ + char d_name[255]; // the device name. Could be /./DEVICE_NAME/ void* (*d_read)(void* arg, int len); // read from device. void (*d_write)(void* arg, int len); - void (*d_wait)(void); // write to device. + void (*d_wait)(void); // write to device. struct _KERNEL_DEVICE* (*d_open)(const char* path); // open device. - void (*d_close)(struct _KERNEL_DEVICE* dev); // close device. + void (*d_close)(struct _KERNEL_DEVICE* dev); // close device. } KERNEL_DEVICE, *KERNEL_DEVICE_PTR; /// @brief Open a new device from path. diff --git a/dev/DDK/KernelStd.h b/dev/DDK/KernelStd.h index 4270229b..89fe786d 100644 --- a/dev/DDK/KernelStd.h +++ b/dev/DDK/KernelStd.h @@ -16,13 +16,13 @@ #define DK_EXTERN extern "C" __declspec(dllexport) #define nil nullptr #undef NULL -#define NULL 0 -#define DK_FINAL final +#define NULL 0 +#define DK_FINAL final #else #define DK_EXTERN extern __declspec(dllexport) #define nil ((void*)0) #undef NULL -#define NULL ((void*)0) +#define NULL ((void*)0) #define DK_FINAL #endif // defined(__cplusplus) diff --git a/dev/DLL/RunXPCOM/Sources/LauncherMain.cxx b/dev/DLL/RunXPCOM/Sources/LauncherMain.cxx index fd68a495..776f5c18 100644 --- a/dev/DLL/RunXPCOM/Sources/LauncherMain.cxx +++ b/dev/DLL/RunXPCOM/Sources/LauncherMain.cxx @@ -12,8 +12,8 @@ int WinMain(int argc, char* argv[]) auto mainDll = LdrOpenDLL(argv[1], argv[2]); - IUnknown* interface = (IUnknown*)LdrGetDLLProc(argv[3], mainDll); - RPCProcKind dllRpc = (RPCProcKind)LdrGetDLLProc(argv[4], mainDll); + IUnknown* interface = (IUnknown*)LdrGetDLLProc(argv[3], mainDll); + RPCProcKind dllRpc = (RPCProcKind)LdrGetDLLProc(argv[4], mainDll); if (!dllRpc) return -1; diff --git a/dev/HPFS/Sources/hpfs_main.cxx b/dev/HPFS/Sources/hpfs_main.cxx index 52ac32ab..09551ad1 100644 --- a/dev/HPFS/Sources/hpfs_main.cxx +++ b/dev/HPFS/Sources/hpfs_main.cxx @@ -13,8 +13,8 @@ /** @brief HPFS IFS main. */ HPFS_INT32 ModuleMain(HPFS_VOID) { - auto ifs_handle = KernelGetObject(0, "IFS_OBJECT"); - // TODO: Register this IFS with necessary I/O functions... + auto ifs_handle = KernelGetObject(0, "IFS_OBJECT"); + // TODO: Register this IFS with necessary I/O functions... - return 0; + return 0; } diff --git a/dev/HPFS/hpfs_specs.hxx b/dev/HPFS/hpfs_specs.hxx index 8d0536a0..4fc24c21 100644 --- a/dev/HPFS/hpfs_specs.hxx +++ b/dev/HPFS/hpfs_specs.hxx @@ -10,6 +10,6 @@ #pragma once typedef __INT32_TYPE__ HPFS_INT32; -typedef void HPFS_VOID; +typedef void HPFS_VOID; #define cHPFSVersion 0x0100 diff --git a/dev/ZBA/BootKit/Vendor/stb_image.hxx b/dev/ZBA/BootKit/Vendor/stb_image.hxx index af5f82fc..ca4576d7 100644 --- a/dev/ZBA/BootKit/Vendor/stb_image.hxx +++ b/dev/ZBA/BootKit/Vendor/stb_image.hxx @@ -659,7 +659,7 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32) == 4 ? 1 : -1]; #ifdef STBI_HAS_LROTL #define stbi_lrot(x, y) _lrotl(x, y) #else -#define stbi_lrot(x, y) (((x) << (y)) | ((x) >> (-(y)&31))) +#define stbi_lrot(x, y) (((x) << (y)) | ((x) >> (-(y) & 31))) #endif #if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) @@ -1780,7 +1780,7 @@ static stbi__uint32 stbi__get32le(stbi__context* s) } #endif -#define STBI__BYTECAST(x) ((stbi_uc)((x)&255)) // truncate int to byte without warnings +#define STBI__BYTECAST(x) ((stbi_uc)((x) & 255)) // truncate int to byte without warnings #if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) // nothing @@ -1826,7 +1826,7 @@ static unsigned char* stbi__convert_format(unsigned char* data, int img_n, int r unsigned char* src = data + j * x * img_n; unsigned char* dest = good + j * x * req_comp; -#define STBI__COMBO(a, b) ((a)*8 + (b)) +#define STBI__COMBO(a, b) ((a) * 8 + (b)) #define STBI__CASE(a, b) \ case STBI__COMBO(a, b): \ for (i = x - 1; i >= 0; --i, src += a, dest += b) @@ -1951,7 +1951,7 @@ static stbi__uint16* stbi__convert_format16(stbi__uint16* data, int img_n, int r stbi__uint16* src = data + j * x * img_n; stbi__uint16* dest = good + j * x * req_comp; -#define STBI__COMBO(a, b) ((a)*8 + (b)) +#define STBI__COMBO(a, b) ((a) * 8 + (b)) #define STBI__CASE(a, b) \ case STBI__COMBO(a, b): \ for (i = x - 1; i >= 0; --i, src += a, dest += b) @@ -2726,8 +2726,8 @@ stbi_inline static stbi_uc stbi__clamp(int x) return (stbi_uc)x; } -#define stbi__f2f(x) ((int)(((x)*4096 + 0.5))) -#define stbi__fsh(x) ((x)*4096) +#define stbi__f2f(x) ((int)(((x) * 4096 + 0.5))) +#define stbi__fsh(x) ((x) * 4096) // derived from jidctint -- DCT_ISLOW #define STBI__IDCT_1D(s0, s1, s2, s3, s4, s5, s6, s7) \ @@ -4159,7 +4159,7 @@ static stbi_uc* stbi__resample_row_generic(stbi_uc* out, stbi_uc* in_near, stbi_ // this is a reduced-precision calculation of YCbCr-to-RGB introduced // to make sure the code produces the same results in both SIMD and scalar -#define stbi__float2fixed(x) (((int)((x)*4096.0f + 0.5f)) << 8) +#define stbi__float2fixed(x) (((int)((x) * 4096.0f + 0.5f)) << 8) static void stbi__YCbCr_to_RGB_row(stbi_uc* out, const stbi_uc* y, const stbi_uc* pcb, const stbi_uc* pcr, int count, int step) { int i; @@ -4503,7 +4503,7 @@ static stbi_uc* load_jpeg_image(stbi__jpeg* z, int* out_x, int* out_y, int* comp coutput[k] = r->resample(z->img_comp[k].linebuf, y_bot ? r->line1 : r->line0, y_bot ? r->line0 : r->line1, - r->w_lores, r->hs); + r->w_lores, r->hs); if (++r->ystep >= r->vs) { r->ystep = 0; diff --git a/dev/ZBA/Sources/HEL/AMD64/BootATA.cxx b/dev/ZBA/Sources/HEL/AMD64/BootATA.cxx index 171fe371..0595f49c 100644 --- a/dev/ZBA/Sources/HEL/AMD64/BootATA.cxx +++ b/dev/ZBA/Sources/HEL/AMD64/BootATA.cxx @@ -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/ZBA/Sources/HEL/AMD64/BootFileReader.cxx b/dev/ZBA/Sources/HEL/AMD64/BootFileReader.cxx index 3c71eaab..ffbcf413 100644 --- a/dev/ZBA/Sources/HEL/AMD64/BootFileReader.cxx +++ b/dev/ZBA/Sources/HEL/AMD64/BootFileReader.cxx @@ -32,7 +32,7 @@ @brief File Reader constructor. */ Boot::BFileReader::BFileReader(const CharacterTypeUTF16* path, - EfiHandlePtr ImageHandle) + EfiHandlePtr ImageHandle) { if (path != nullptr) { diff --git a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx index 0e7a9171..5557f8dd 100644 --- a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx +++ b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx @@ -249,7 +249,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, // Provide fimware vendor name. Boot::BCopyMem(handover_hdr->f_FirmwareVendorName, SystemTable->FirmwareVendor, - handover_hdr->f_FirmwareVendorLen); + handover_hdr->f_FirmwareVendorLen); handover_hdr->f_FirmwareVendorLen = Boot::BStrLen(SystemTable->FirmwareVendor); diff --git a/dev/ZKA/FSKit/NeFS.hxx b/dev/ZKA/FSKit/NeFS.hxx index 1818eab2..442b19ce 100644 --- a/dev/ZKA/FSKit/NeFS.hxx +++ b/dev/ZKA/FSKit/NeFS.hxx @@ -52,7 +52,6 @@ default. #define kNeFSPartitionTypePage (8) #define kNeFSPartitionTypeBoot (9) - #define kNeFSCatalogKindFile (1) #define kNeFSCatalogKindDir (2) #define kNeFSCatalogKindAlias (3) @@ -71,8 +70,8 @@ default. #define kNeFSCatalogKindRLE (11) #define kNeFSCatalogKindMetaFile (12) -#define kNeFSCatalogKindTTF (13) -#define kNeFSCatalogKindRIFF (14) +#define kNeFSCatalogKindTTF (13) +#define kNeFSCatalogKindRIFF (14) #define kNeFSSeparator '\\' #define kNeFSSeparatorAlt '/' diff --git a/dev/ZKA/FirmwareKit/EFI/EFI.hxx b/dev/ZKA/FirmwareKit/EFI/EFI.hxx index be319336..76a1d933 100644 --- a/dev/ZKA/FirmwareKit/EFI/EFI.hxx +++ b/dev/ZKA/FirmwareKit/EFI/EFI.hxx @@ -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/ZKA/FirmwareKit/EPM.hxx b/dev/ZKA/FirmwareKit/EPM.hxx index 881735e0..f5a6eed2 100644 --- a/dev/ZKA/FirmwareKit/EPM.hxx +++ b/dev/ZKA/FirmwareKit/EPM.hxx @@ -111,10 +111,10 @@ struct PACKED _BOOT_BLOCK_STRUCT enum { - kEPMEmbeddedOS = 0xcf, // Embedded OS - kEPMLinux = 0x8f, // Linux on EPM - kEPMBSD = 0x9f, // Berkeley Soft. Distribution - kEPMNewOS = 0x1f, // This OS. + kEPMEmbeddedOS = 0xcf, // Embedded OS + kEPMLinux = 0x8f, // Linux on EPM + kEPMBSD = 0x9f, // Berkeley Soft. Distribution + kEPMNewOS = 0x1f, // This OS. }; typedef struct _BOOT_BLOCK_STRUCT BOOT_BLOCK_STRUCT; diff --git a/dev/ZKA/FirmwareKit/Handover.hxx b/dev/ZKA/FirmwareKit/Handover.hxx index ad8dc3bc..13c34eca 100644 --- a/dev/ZKA/FirmwareKit/Handover.hxx +++ b/dev/ZKA/FirmwareKit/Handover.hxx @@ -67,13 +67,13 @@ namespace Kernel::HEL VoidPtr f_PageStart; VoidPtr f_KernelImage; - SizeT f_KernelSz; + SizeT f_KernelSz; VoidPtr f_StartupChime; - SizeT f_ChimeSz; + SizeT f_ChimeSz; VoidPtr f_StartupImage; - SizeT f_StartupSz; + SizeT f_StartupSz; VoidPtr f_TTFallbackFont; - SizeT f_FontSz; + SizeT f_FontSz; WideChar f_FirmwareVendorName[32]; SizeT f_FirmwareVendorLen; diff --git a/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx b/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx index ce6bd42c..83fa2af3 100644 --- a/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx +++ b/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx @@ -79,11 +79,10 @@ namespace Kernel { UIntPtr* ptr_bit_set = reinterpret_cast<UIntPtr*>(base); - if (ptr_bit_set[cBitMapMagIdx] == cBitMpMagic) + if (ptr_bit_set[cBitMapMagIdx] == cBitMpMagic && + ptr_bit_set[cBitMapSizeIdx] <= size) { - if (ptr_bit_set[cBitMapSizeIdx] != 0 && - ptr_bit_set[cBitMapSizeIdx] <= size && - ptr_bit_set[cBitMapUsedIdx] == No) + if (ptr_bit_set[cBitMapUsedIdx] == No) { ptr_bit_set[cBitMapSizeIdx] = size; ptr_bit_set[cBitMapUsedIdx] = Yes; @@ -93,12 +92,11 @@ namespace Kernel return (VoidPtr)ptr_bit_set; } } - else + else if (ptr_bit_set[cBitMapMagIdx] != cBitMpMagic) { UIntPtr* ptr_bit_set = reinterpret_cast<UIntPtr*>(base_ptr); - ptr_bit_set[cBitMapMagIdx] = cBitMpMagic; - + ptr_bit_set[cBitMapMagIdx] = cBitMpMagic; ptr_bit_set[cBitMapSizeIdx] = size; ptr_bit_set[cBitMapUsedIdx] = Yes; diff --git a/dev/ZKA/HALKit/AMD64/HalCommAPI.cxx b/dev/ZKA/HALKit/AMD64/HalCommAPI.cxx index b78fd1f0..11c442b4 100644 --- a/dev/ZKA/HALKit/AMD64/HalCommAPI.cxx +++ b/dev/ZKA/HALKit/AMD64/HalCommAPI.cxx @@ -26,8 +26,8 @@ namespace Kernel::HAL /// @return Status code of page manip. EXTERN_C Int32 mm_map_page(VoidPtr virt_addr, UInt32 flags) { - ZKA_UNUSED(virt_addr); - ZKA_UNUSED(flags); + ZKA_UNUSED(virt_addr); + ZKA_UNUSED(flags); return 0; } diff --git a/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx b/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx index 1a518c5d..18302f34 100644 --- a/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx +++ b/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx @@ -148,8 +148,8 @@ namespace Kernel::HAL struct PROCESS_CONTROL_BLOCK final { HAL::StackFramePtr f_Frame; - UInt8* f_Stack; - VoidPtr f_Image; + UInt8* f_Stack; + VoidPtr f_Image; } fBlocks[kSchedProcessLimitPerTeam] = {0}; EXTERN_C HAL::StackFramePtr mp_get_current_context(Void) diff --git a/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx b/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx index bddd0eb4..44263a1c 100644 --- a/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx +++ b/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx @@ -15,7 +15,7 @@ namespace Kernel::HAL STATIC Void hal_remap_intel_pic_ctrl(Void) noexcept { - auto a1 = HAL::In8(0xa1); // save masks + auto a1 = HAL::In8(0xa1); // save masks auto a2 = HAL::In8(0xa2); HAL::Out8(0x20, 0x11); @@ -61,9 +61,9 @@ namespace Kernel::HAL Detail::kInterruptVectorTable[idt_indx].Zero = 0x0; } - idt.Base = (UIntPtr)&Detail::kInterruptVectorTable; + idt.Base = (UIntPtr)&Detail::kInterruptVectorTable; idt.Limit = sizeof(::Kernel::Detail::AMD64::InterruptDescriptorAMD64) * - (kKernelIdtSize) - 1; + (kKernelIdtSize)-1; hal_load_idt(idt); diff --git a/dev/ZKA/HALKit/AMD64/HalSchedulerCore.cxx b/dev/ZKA/HALKit/AMD64/HalSchedulerCore.cxx index 3cd07955..9dcce147 100644 --- a/dev/ZKA/HALKit/AMD64/HalSchedulerCore.cxx +++ b/dev/ZKA/HALKit/AMD64/HalSchedulerCore.cxx @@ -26,7 +26,7 @@ namespace Kernel EXTERN_C Void __zka_pure_call(void) { - asm volatile ("mov %r8, 0; mov %r9, 1; syscall"); + asm volatile("mov %r8, 0; mov %r9, 1; syscall"); } Bool hal_check_stack(HAL::StackFramePtr stack_ptr) diff --git a/dev/ZKA/HALKit/AMD64/Processor.hxx b/dev/ZKA/HALKit/AMD64/Processor.hxx index 40ea63f9..e39cac0a 100644 --- a/dev/ZKA/HALKit/AMD64/Processor.hxx +++ b/dev/ZKA/HALKit/AMD64/Processor.hxx @@ -293,4 +293,4 @@ EXTERN_C Kernel::Void hal_load_gdt(Kernel::HAL::RegisterGDT ptr); #define kKernelInterruptId 0x32 inline Kernel::VoidPtr kKernelBitMpStart = nullptr; -inline Kernel::UIntPtr kKernelBitMpSize = 0UL; +inline Kernel::UIntPtr kKernelBitMpSize = 0UL; diff --git a/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx b/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx index 9fcab945..95d73c03 100644 --- a/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx +++ b/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx @@ -26,7 +26,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 port that have been detected. diff --git a/dev/ZKA/HALKit/AMD64/Storage/ATA-PIO.cxx b/dev/ZKA/HALKit/AMD64/Storage/ATA-PIO.cxx index aa72ad56..e09a4277 100644 --- a/dev/ZKA/HALKit/AMD64/Storage/ATA-PIO.cxx +++ b/dev/ZKA/HALKit/AMD64/Storage/ATA-PIO.cxx @@ -125,7 +125,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); @@ -157,7 +157,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/ZKA/HALKit/ARM64/HalSchedulerCore.cxx b/dev/ZKA/HALKit/ARM64/HalSchedulerCore.cxx index 2c801372..7545b350 100644 --- a/dev/ZKA/HALKit/ARM64/HalSchedulerCore.cxx +++ b/dev/ZKA/HALKit/ARM64/HalSchedulerCore.cxx @@ -33,7 +33,7 @@ namespace Kernel /// Wakes up thread from the hang state. Void mp_wakeup_thread(HAL::StackFrame* stack) { - ZKA_UNUSED(stack); + ZKA_UNUSED(stack); } /// @brief makes the thread sleep on a loop. diff --git a/dev/ZKA/HALKit/ARM64/Processor.hxx b/dev/ZKA/HALKit/ARM64/Processor.hxx index 41456880..533457a9 100644 --- a/dev/ZKA/HALKit/ARM64/Processor.hxx +++ b/dev/ZKA/HALKit/ARM64/Processor.hxx @@ -43,7 +43,7 @@ namespace Kernel::HAL } // namespace Kernel::HAL inline Kernel::VoidPtr kKernelBitMpStart = nullptr; -inline Kernel::UIntPtr kKernelBitMpSize = 0UL; +inline Kernel::UIntPtr kKernelBitMpSize = 0UL; inline Kernel::VoidPtr kKernelPhysicalStart = nullptr; diff --git a/dev/ZKA/KernelKit/DebugOutput.hxx b/dev/ZKA/KernelKit/DebugOutput.hxx index 0ee04ae0..162e2ed4 100644 --- a/dev/ZKA/KernelKit/DebugOutput.hxx +++ b/dev/ZKA/KernelKit/DebugOutput.hxx @@ -190,5 +190,7 @@ namespace Kernel #undef kcout #endif // ifdef kcout -#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() +#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/HardwareThreadScheduler.hxx b/dev/ZKA/KernelKit/HardwareThreadScheduler.hxx index 302724fa..83f6ebd9 100644 --- a/dev/ZKA/KernelKit/HardwareThreadScheduler.hxx +++ b/dev/ZKA/KernelKit/HardwareThreadScheduler.hxx @@ -117,7 +117,7 @@ namespace Kernel const Bool HasMP() override { - return kHandoverHeader->f_HardwareTables.f_MultiProcessingEnabled; + return kHandoverHeader->f_HardwareTables.f_MultiProcessingEnabled; } public: diff --git a/dev/ZKA/KernelKit/Heap.hxx b/dev/ZKA/KernelKit/Heap.hxx index f9d2df06..044004dc 100644 --- a/dev/ZKA/KernelKit/Heap.hxx +++ b/dev/ZKA/KernelKit/Heap.hxx @@ -47,7 +47,6 @@ namespace Kernel /// @return status code Int32 mm_make_ke_page(VoidPtr heap_ptr); - template <typename T, typename... Args> inline T* mm_new_class(Args&&... args) { diff --git a/dev/ZKA/KernelKit/IDLLObject.hxx b/dev/ZKA/KernelKit/IDLLObject.hxx index 39580307..21c2848a 100644 --- a/dev/ZKA/KernelKit/IDLLObject.hxx +++ b/dev/ZKA/KernelKit/IDLLObject.hxx @@ -37,7 +37,6 @@ namespace Kernel 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/IPEFDLLObject.hxx b/dev/ZKA/KernelKit/IPEFDLLObject.hxx index 91e0d1ff..c41d3365 100644 --- a/dev/ZKA/KernelKit/IPEFDLLObject.hxx +++ b/dev/ZKA/KernelKit/IPEFDLLObject.hxx @@ -25,7 +25,7 @@ namespace Kernel { public: explicit IPEFDLLObject() = default; - ~IPEFDLLObject() = default; + ~IPEFDLLObject() = default; public: ZKA_COPY_DEFAULT(IPEFDLLObject); @@ -99,7 +99,7 @@ namespace Kernel typedef IPEFDLLObject* IDLL; EXTERN_C IDLL rtl_init_dll(UserProcess* header); - EXTERN_C Void rtl_fini_dll(UserProcess* header, IDLL lib, Bool* successful); + EXTERN_C Void rtl_fini_dll(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 8e51bc45..b265f738 100644 --- a/dev/ZKA/KernelKit/PCI/Dma.hxx +++ b/dev/ZKA/KernelKit/PCI/Dma.hxx @@ -52,7 +52,7 @@ namespace Kernel T* Get(const UIntPtr off = 0); public: - operator bool(); + operator bool(); bool operator!(); public: diff --git a/dev/ZKA/KernelKit/PEFCodeMgr.hxx b/dev/ZKA/KernelKit/PEFCodeMgr.hxx index c6748ba0..2b07e4f8 100644 --- a/dev/ZKA/KernelKit/PEFCodeMgr.hxx +++ b/dev/ZKA/KernelKit/PEFCodeMgr.hxx @@ -12,7 +12,7 @@ #include <NewKit/String.hxx> #include <KernelKit/FileMgr.hxx> -#define kPefApplicationMime "application/x-newos-exec" +#define kPefApplicationMime "application/vnd-zka-executable" namespace Kernel { diff --git a/dev/ZKA/NewKit/Defines.hxx b/dev/ZKA/NewKit/Defines.hxx index b77e94f3..ce767480 100644 --- a/dev/ZKA/NewKit/Defines.hxx +++ b/dev/ZKA/NewKit/Defines.hxx @@ -109,7 +109,7 @@ namespace Kernel { public: explicit IEncoderObject() = default; - virtual ~IEncoderObject() = default; + virtual ~IEncoderObject() = default; IEncoderObject& operator=(const IEncoderObject&) = default; IEncoderObject(const IEncoderObject&) = default; @@ -169,7 +169,6 @@ namespace Kernel { return false; } - }; } // namespace Kernel diff --git a/dev/ZKA/NewKit/Macros.hxx b/dev/ZKA/NewKit/Macros.hxx index 3bfe7cad..522c488c 100644 --- a/dev/ZKA/NewKit/Macros.hxx +++ b/dev/ZKA/NewKit/Macros.hxx @@ -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 @@ -94,10 +94,10 @@ #define CANT_REACH() __builtin_unreachable() #endif -#define kInvalidAddress 0xFBFBFBFBFBFBFBFB -#define kBadAddress 0x00000000000000 -#define kMaxAddr 0xFFFFFFFFFFFFFFFF -#define kPathLen 256 +#define kInvalidAddress 0xFBFBFBFBFBFBFBFB +#define kBadAddress 0x00000000000000 +#define kMaxAddr 0xFFFFFFFFFFFFFFFF +#define kPathLen 256 #define PACKED ATTRIBUTE(packed) #define NO_EXEC ATTRIBUTE(noexec) diff --git a/dev/ZKA/NewKit/PageMgr.hxx b/dev/ZKA/NewKit/PageMgr.hxx index 1f470382..4faf5c3a 100644 --- a/dev/ZKA/NewKit/PageMgr.hxx +++ b/dev/ZKA/NewKit/PageMgr.hxx @@ -32,7 +32,10 @@ namespace Kernel void NoExecute(const bool enable = false); const Bool& NoExecute(); - operator bool() { return fVirtAddr; } + operator bool() + { + return fVirtAddr; + } bool Reclaim(); bool Shareable(); diff --git a/dev/ZKA/Sources/DriveMgr.cxx b/dev/ZKA/Sources/DriveMgr.cxx index 82291ada..f6436f75 100644 --- a/dev/ZKA/Sources/DriveMgr.cxx +++ b/dev/ZKA/Sources/DriveMgr.cxx @@ -8,7 +8,6 @@ #include <KernelKit/DriveMgr.hxx> #include <NewKit/Utils.hxx> - #include <Modules/ATA/ATA.hxx> #include <Modules/AHCI/AHCI.hxx> #include <Modules/NVME/Defines.hxx> @@ -124,7 +123,7 @@ namespace Kernel trait.fInput = io_drv_unimplemented; trait.fOutput = io_drv_unimplemented; trait.fVerify = io_drv_unimplemented; - trait.fInit = io_drv_unimplemented; + trait.fInit = io_drv_unimplemented; trait.fDriveKind = ke_drv_kind; return trait; @@ -142,7 +141,7 @@ namespace Kernel trait.fInput = ke_drv_input; trait.fOutput = ke_drv_output; trait.fVerify = io_drv_unimplemented; - trait.fInit = ke_drv_init; + trait.fInit = ke_drv_init; trait.fDriveKind = ke_drv_kind; kcout << "Construct drive with success.\r"; diff --git a/dev/ZKA/Sources/FS/NeFS.cxx b/dev/ZKA/Sources/FS/NeFS.cxx index 8bd467c6..69b0c401 100644 --- a/dev/ZKA/Sources/FS/NeFS.cxx +++ b/dev/ZKA/Sources/FS/NeFS.cxx @@ -60,7 +60,7 @@ STATIC MountpointInterface sMountpointInterface; /// @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) @@ -142,10 +142,10 @@ _Output NFS_FORK_STRUCT* NeFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* catal constexpr auto cForkPadding = 4; /// this value gives us space for the data offset. - the_fork.Flags |= kNeFSFlagCreated; - the_fork.DataOffset = lba - sizeof(NFS_FORK_STRUCT); + the_fork.Flags |= kNeFSFlagCreated; + the_fork.DataOffset = lba - sizeof(NFS_FORK_STRUCT); the_fork.PreviousSibling = lbaOfPreviousFork; - the_fork.NextSibling = the_fork.DataOffset - the_fork.DataSize - sizeof(NFS_FORK_STRUCT); + the_fork.NextSibling = the_fork.DataOffset - the_fork.DataSize - sizeof(NFS_FORK_STRUCT); drv.fPacket.fLba = lba; drv.fPacket.fPacketSize = sizeof(NFS_FORK_STRUCT); @@ -172,10 +172,10 @@ _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 = sMountpointInterface.A(); + auto drv = sMountpointInterface.A(); NFS_FORK_STRUCT* the_fork = nullptr; Lba lba = isDataFork ? catalog->DataFork : catalog->ResourceFork; @@ -238,9 +238,9 @@ _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, - _Input const Int32& flags, - _Input const Int32& kind) +_Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name, + _Input const Int32& flags, + _Input const Int32& kind) { kcout << "CreateCatalog(...)\r"; @@ -650,7 +650,7 @@ bool NeFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool i rt_string_len("fs/newfs-packet")); auto startFork = (!is_rsrc_fork) ? catalog->DataFork - : catalog->ResourceFork; + : catalog->ResourceFork; NFS_FORK_STRUCT* fork_data_input = new NFS_FORK_STRUCT(); NFS_FORK_STRUCT prevFork{}; @@ -684,7 +684,7 @@ bool NeFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool i // Store the blob now. // ===================================================== // - fork_data_input->Flags |= kNeFSFlagCreated; + fork_data_input->Flags |= kNeFSFlagCreated; drive.fPacket.fPacketContent = buf; drive.fPacket.fPacketSize = kNeFSForkDataSz; @@ -722,7 +722,7 @@ bool NeFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool i /// @param catalogName the catalog name. /// @return the newly found catalog. _Output NFS_CATALOG_STRUCT* NeFSParser::FindCatalog(_Input const Char* catalogName, - Lba& out_lba) + Lba& out_lba) { kcout << "Start finding catalog...\r"; @@ -792,7 +792,7 @@ _Output NFS_CATALOG_STRUCT* NeFSParser::FindCatalog(_Input const Char* catalogNa } else { - return nullptr; + return nullptr; } } @@ -936,9 +936,9 @@ 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 Bool is_rsrc_fork, + _Input SizeT dataSz, + _Input const Char* forkName) { if (!catalog) { diff --git a/dev/ZKA/Sources/FileMgr.cxx b/dev/ZKA/Sources/FileMgr.cxx index 88e8c433..a7be26b8 100644 --- a/dev/ZKA/Sources/FileMgr.cxx +++ b/dev/ZKA/Sources/FileMgr.cxx @@ -101,10 +101,10 @@ namespace Kernel } Void NeFileSystemMgr::Write(_Input const Char* name, - _Input NodePtr node, - _Input VoidPtr data, - _Input Int32 flags, - _Input SizeT size) + _Input NodePtr node, + _Input VoidPtr data, + _Input Int32 flags, + _Input SizeT size) { if (!size || size > kNeFSForkSize) @@ -121,9 +121,9 @@ namespace Kernel } _Output VoidPtr NeFileSystemMgr::Read(_Input const Char* name, - _Input NodePtr node, - _Input Int32 flags, - _Input SizeT sz) + _Input NodePtr node, + _Input Int32 flags, + _Input SizeT sz) { if (sz > kNeFSForkSize) return nullptr; diff --git a/dev/ZKA/Sources/NeFS+IO.cxx b/dev/ZKA/Sources/NeFS+IO.cxx index a86e9c29..6c3aa6e1 100644 --- a/dev/ZKA/Sources/NeFS+IO.cxx +++ b/dev/ZKA/Sources/NeFS+IO.cxx @@ -24,7 +24,7 @@ /// Useful macros. #define NEFS_WRITE(DRV, TRAITS, MP) (MP->DRV()).fOutput(&TRAITS) -#define NEFS_READ(DRV, TRAITS, MP) (MP->DRV()).fInput(&TRAITS) +#define NEFS_READ(DRV, TRAITS, MP) (MP->DRV()).fInput(&TRAITS) using namespace Kernel; diff --git a/dev/ZKA/Sources/PEFCodeMgr.cxx b/dev/ZKA/Sources/PEFCodeMgr.cxx index c635dd69..fa9b0d93 100644 --- a/dev/ZKA/Sources/PEFCodeMgr.cxx +++ b/dev/ZKA/Sources/PEFCodeMgr.cxx @@ -15,6 +15,7 @@ /// @brief PEF stack size symbol. #define cPefStackSizeSymbol "SizeOfReserveStack" +#define cPefHeapSizeSymbol "SizeOfReserveHeap" #define cPefNameSymbol "ProgramName" namespace Kernel @@ -206,8 +207,9 @@ namespace Kernel UserProcess proc; proc.SetImageStart(errOrStart.Leak().Leak()); - proc.Kind = procKind; - proc.StackSize = *(UIntPtr*)exec.FindSymbol(cPefStackSizeSymbol, kPefData); + proc.Kind = procKind; + proc.StackSize = *(UIntPtr*)exec.FindSymbol(cPefStackSizeSymbol, kPefData); + proc.MemoryLimit = *(UIntPtr*)exec.FindSymbol(cPefHeapSizeSymbol, kPefData); rt_set_memory(proc.Name, 0, kProcessLen); @@ -235,15 +237,17 @@ namespace Kernel const Char* PEFLoader::AsString() { #ifdef __32x0__ - return "32x0 PEF format."; + return "32x0 PEF executable."; #elif defined(__64x0__) - return "64x0 PEF format."; + return "64x0 PEF executable."; #elif defined(__x86_64__) - return "x86_64 PEF format."; + return "x86_64 PEF executable."; +#elif defined(__aarch64__) + return "aarch64 PEF executable."; #elif defined(__powerpc64__) - return "POWER PEF format."; + return "POWER64 PEF executable."; #else - return "Unknown PEF format."; + return "???? PEF executable."; #endif // __32x0__ || __64x0__ || __x86_64__ || __powerpc64__ } diff --git a/dev/ZKA/Sources/ThreadLocalStorage.cxx b/dev/ZKA/Sources/ThreadLocalStorage.cxx index ed723c06..587edafd 100644 --- a/dev/ZKA/Sources/ThreadLocalStorage.cxx +++ b/dev/ZKA/Sources/ThreadLocalStorage.cxx @@ -33,8 +33,8 @@ Boolean tls_check_tib(THREAD_INFORMATION_BLOCK* the_tib) !the_tib->f_ThreadRecord) return false; - IEncoderObject encoder; - const char* tibAsBytes = encoder.AsBytes(the_tib); + IEncoderObject encoder; + const char* tibAsBytes = encoder.AsBytes(the_tib); kcout << "checking for a valid cookie inside the TIB...\r"; diff --git a/dev/ZKA/Sources/UserProcessScheduler.cxx b/dev/ZKA/Sources/UserProcessScheduler.cxx index 2d4c3836..487a2f38 100644 --- a/dev/ZKA/Sources/UserProcessScheduler.cxx +++ b/dev/ZKA/Sources/UserProcessScheduler.cxx @@ -53,10 +53,8 @@ namespace Kernel Void UserProcess::Crash() { - if (*this->Name == 0) - return; - - kcout << this->Name << ": crashed, ID = " << number(kErrorProcessFault) << endl; + if (*this->Name != 0) + kcout << this->Name << ": crashed, error id: " << number(kErrorProcessFault) << endl; this->Exit(kErrorProcessFault); } @@ -112,12 +110,13 @@ namespace Kernel } else { - auto entry = this->MemoryEntryList; + auto entry = this->MemoryEntryList; + PROCESS_MEMORY_ENTRY* prev_entry = nullptr; - while (entry->MemoryNext) + while (!entry) { - if (entry->MemoryNext) - entry = entry->MemoryNext; + prev_entry = entry; + entry = entry->MemoryNext; } entry->MemoryNext = new UserProcess::PROCESS_MEMORY_ENTRY(); @@ -137,7 +136,7 @@ namespace Kernel { auto entry = this->MemoryEntryList; - while (entry->MemoryNext) + while (entry) { if (entry->MemoryEntry == ptr) { @@ -145,7 +144,7 @@ namespace Kernel auto pd = hal_read_cr3(); hal_write_cr3(reinterpret_cast<VoidPtr>(this->MemoryPD)); - bool ret = mm_delete_ke_heap(ptr); + Bool ret = mm_delete_ke_heap(ptr); hal_write_cr3(reinterpret_cast<VoidPtr>(pd)); return ret; @@ -155,8 +154,7 @@ namespace Kernel #endif } - if (entry->MemoryNext) - entry = entry->MemoryNext; + entry = entry->MemoryNext; } return false; @@ -305,6 +303,9 @@ namespace Kernel /// @param process_id process slot inside team. /// @retval true process was removed. /// @retval false process doesn't exist in team. + + /***********************************************************************************/ + Bool UserProcessScheduler::Remove(ProcessID process_id) { // check if process is within range. @@ -317,8 +318,13 @@ namespace Kernel return true; } - /// @brief Run scheduler. - /// @return + /***********************************************************************************/ + + /// @brief Run User scheduler object. + /// @return Process executed within team. + + /***********************************************************************************/ + SizeT UserProcessScheduler::Run() noexcept { SizeT process_index = 0; //! we store this guy to tell the scheduler how many @@ -326,7 +332,7 @@ namespace Kernel for (; process_index < mTeam.AsArray().Capacity(); ++process_index) { - kcout << "Grabbing available process...\r"; + kcout << "Grabbing available process in team...\r"; auto& process = mTeam.AsArray()[process_index]; diff --git a/dev/ZKA/Sources/UserThreadScheduler.cxx b/dev/ZKA/Sources/UserThreadScheduler.cxx index 739f00ad..21514972 100644 --- a/dev/ZKA/Sources/UserThreadScheduler.cxx +++ b/dev/ZKA/Sources/UserThreadScheduler.cxx @@ -18,13 +18,13 @@ namespace Kernel { STATIC constexpr SizeT cMaxLen = 256; - Char fName[cMaxLen] = {"THREAD #0 (PROCESS 0)"}; + Char fName[cMaxLen] = {"THREAD #0 (PROCESS 0)"}; ProcessStatusKind fThreadStatus; - Int64 fThreadID; - Int64* fProcessID{nullptr}; - VoidPtr fCode{nullptr}; - VoidPtr fStack{nullptr}; - VoidPtr fData{nullptr}; + Int64 fThreadID; + Int64* fProcessID{nullptr}; + VoidPtr fCode{nullptr}; + VoidPtr fStack{nullptr}; + VoidPtr fData{nullptr}; Void Exit() noexcept { @@ -46,4 +46,4 @@ namespace Kernel return fCode; } }; -} // namespace Detail +} // namespace Kernel diff --git a/dev/ZWM/Sources/zwm_main.cxx b/dev/ZWM/Sources/zwm_main.cxx index 38d441bd..f1f7fbe7 100644 --- a/dev/ZWM/Sources/zwm_main.cxx +++ b/dev/ZWM/Sources/zwm_main.cxx @@ -10,23 +10,23 @@ #include <DDK/KernelStd.h> #include <cstdint> -static uint32_t cGPUIndexHW = 0U; -static struct DDK_OBJECT_MANIFEST* cGPUObject = nullptr; +static uint32_t cGPUIndexHW = 0U; +static struct DDK_OBJECT_MANIFEST* cGPUObject = nullptr; /** @brief ZWM main, ZWM acts a proxy to the Installed GPU Driver. */ int32_t ModuleMain(void) { - int index_gpu = 0; - struct DDK_OBJECT_MANIFEST* gpu_object = nullptr; + int index_gpu = 0; + struct DDK_OBJECT_MANIFEST* gpu_object = nullptr; - while (!gpu_object) - { - gpu_object = KernelGetObject(index_gpu, "GPU_OBJECT"); - ++index_gpu; - } + while (!gpu_object) + { + gpu_object = KernelGetObject(index_gpu, "GPU_OBJECT"); + ++index_gpu; + } - cGPUIndexHW = index_gpu; - cGPUObject = gpu_object; + cGPUIndexHW = index_gpu; + cGPUObject = gpu_object; - return 0; + return 0; } |
