diff options
Diffstat (limited to 'src')
47 files changed, 222 insertions, 240 deletions
diff --git a/src/boot/BootKit/BootKit.h b/src/boot/BootKit/BootKit.h index fa10e6cf..4296ebcb 100644 --- a/src/boot/BootKit/BootKit.h +++ b/src/boot/BootKit/BootKit.h @@ -290,16 +290,16 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const Char* part_name) { CopyMem(gpt_part->Signature, reinterpret_cast<VoidPtr>(const_cast<Char*>(kMagicGPT)), StrLen(kMagicGPT)); - gpt_part->Revision = 0x00010000; + gpt_part->Revision = 0x00010000; gpt_part->HeaderSize = sizeof(GPT_PARTITION_TABLE); gpt_part->CRC32 = 0x00000000; - gpt_part->Reserved1 = 0x00000000; - gpt_part->LBAHeader = 0x00000000; - gpt_part->LBAAltHeader = 0x00000000; + gpt_part->Reserved1 = 0x00000000; + gpt_part->LBAHeader = 0x00000000; + gpt_part->LBAAltHeader = 0x00000000; gpt_part->FirstGPTEntry = 0x00000000; - gpt_part->LastGPTEntry = 0x00000000; + gpt_part->LastGPTEntry = 0x00000000; gpt_part->Guid.Data1 = 0x00000000; gpt_part->Guid.Data2 = 0x0000; @@ -309,10 +309,10 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const Char* part_name) { gpt_part->Revision = 0x00010000; - gpt_part->StartingLBA = 0x00000000; + gpt_part->StartingLBA = 0x00000000; gpt_part->NumPartitionEntries = 0x00000000; - gpt_part->SizeOfEntries = 0x00000000; - gpt_part->CRC32PartEntry = 0x00000000; + gpt_part->SizeOfEntries = 0x00000000; + gpt_part->CRC32PartEntry = 0x00000000; SetMem(gpt_part->Reserved2, 0, kSectorAlignGPT_PartTbl); diff --git a/src/boot/modules/BootNet/BootNet.cc b/src/boot/modules/BootNet/BootNet.cc index 4a08cb51..8b0112c5 100644 --- a/src/boot/modules/BootNet/BootNet.cc +++ b/src/boot/modules/BootNet/BootNet.cc @@ -7,8 +7,8 @@ #include <FirmwareKit/EFI/API.h> #include <modules/BootNet/BootNet.h> -STATIC EFI_GUID kEfiSimpleProtoGUID = EFI_SIMPLE_NETWORK_PROTOCOL_GUID; -STATIC EFI_SIMPLE_NETWORK_PROTOCOL* kEfiProtocol = nullptr; +STATIC EFI_GUID kEfiSimpleProtoGUID = EFI_SIMPLE_NETWORK_PROTOCOL_GUID; +STATIC EFI_SIMPLE_NETWORK_PROTOCOL* kEfiProtocol = nullptr; STATIC Void bootnet_read_ip_packet(BOOTNET_INTERNET_HEADER inet, BOOTNET_INTERNET_HEADER** inet_out); diff --git a/src/boot/src/HEL/AMD64/BootATA.cc b/src/boot/src/HEL/AMD64/BootATA.cc index 3826ea41..423f4437 100644 --- a/src/boot/src/HEL/AMD64/BootATA.cc +++ b/src/boot/src/HEL/AMD64/BootATA.cc @@ -75,8 +75,7 @@ ATAInit_Retry: /// fetch serial info /// model, speed, number of sectors... - while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ)) - ; + while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ)); for (SizeT indexData = 0ul; indexData < kATADataLen; ++indexData) { kATAData[indexData] = rt_in16(IO + ATA_REG_DATA); @@ -102,15 +101,14 @@ Void boot_ata_read(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeASCII* Buf, rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz) / SectorSz)); - rt_out8(IO + ATA_REG_LBA0, (Lba) &0xFF); + rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF); rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8); rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16); rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24); rt_out8(IO + ATA_REG_COMMAND, ATA_CMD_READ_PIO); - while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ)) - ; + while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ)); for (SizeT IndexOff = 0; IndexOff < Size; IndexOff += 2) { boot_ata_wait_io(IO); @@ -136,15 +134,14 @@ Void boot_ata_write(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeASCII* Buf rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + (SectorSz)) / SectorSz)); - rt_out8(IO + ATA_REG_LBA0, (Lba) &0xFF); + rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF); rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8); rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16); rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24); rt_out8(IO + ATA_REG_COMMAND, ATA_CMD_WRITE_PIO); - while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ)) - ; + while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ)); for (SizeT IndexOff = 0; IndexOff < Size; IndexOff += 2) { boot_ata_wait_io(IO); diff --git a/src/boot/src/HEL/ARM64/BootPlatform.cc b/src/boot/src/HEL/ARM64/BootPlatform.cc index 612fe62c..8e45fa60 100644 --- a/src/boot/src/HEL/ARM64/BootPlatform.cc +++ b/src/boot/src/HEL/ARM64/BootPlatform.cc @@ -11,8 +11,7 @@ using namespace Boot; EXTERN_C void rt_halt() { - while (Yes) - ; + while (Yes); } EXTERN_C void rt_cli() {} diff --git a/src/boot/src/New+Delete.cc b/src/boot/src/New+Delete.cc index 99a31166..20965cbe 100644 --- a/src/boot/src/New+Delete.cc +++ b/src/boot/src/New+Delete.cc @@ -15,8 +15,7 @@ void* operator new(size_t sz) { void* buf = nullptr; - while (BS->AllocatePool(EfiMemoryType::EfiLoaderData, sz, &buf) != kEfiOk) - ; + while (BS->AllocatePool(EfiMemoryType::EfiLoaderData, sz, &buf) != kEfiOk); return buf; } diff --git a/src/kernel/CompilerKit/Version.h b/src/kernel/CompilerKit/Version.h index 808968d5..53c2e4a1 100644 --- a/src/kernel/CompilerKit/Version.h +++ b/src/kernel/CompilerKit/Version.h @@ -5,10 +5,10 @@ #ifndef COMPILERKIT_VERSION_H #define COMPILERKIT_VERSION_H -#define BOOTLOADER_VERSION "v0.1.21-bootz" -#define KERNEL_VERSION "v0.1.21-krnl" +#define BOOTLOADER_VERSION "v0.1.3-bootz" +#define KERNEL_VERSION "v0.1.3-krnl" -#define BOOTLOADER_VERSION_BCD (0x01021) -#define KERNEL_VERSION_BCD (0x01021) +#define BOOTLOADER_VERSION_BCD (0x0103) +#define KERNEL_VERSION_BCD (0x0103) #endif diff --git a/src/kernel/FSKit/Ext2+IFS.h b/src/kernel/FSKit/Ext2+IFS.h index edefc978..242db5f9 100644 --- a/src/kernel/FSKit/Ext2+IFS.h +++ b/src/kernel/FSKit/Ext2+IFS.h @@ -31,7 +31,7 @@ class Ext2Context final { } } - Ext2Context(const Ext2Context&) = delete; + Ext2Context(const Ext2Context&) = delete; Ext2Context& operator=(const Ext2Context&) = delete; Ext2Context(Ext2Context&& other) : drive(other.drive), superblock(other.superblock) { diff --git a/src/kernel/FSKit/OpenHeFS.h b/src/kernel/FSKit/OpenHeFS.h index 81e8add2..7b4da7c5 100644 --- a/src/kernel/FSKit/OpenHeFS.h +++ b/src/kernel/FSKit/OpenHeFS.h @@ -266,7 +266,7 @@ inline UInt32 hefs_hour_get(ATime raw_atime) { /// @return the minute value. /// @note The minute is stored in the lower 8 bits of the ATime value. inline UInt32 hefs_minute_get(ATime raw_atime) { - return (raw_atime) &0xFF; + return (raw_atime) & 0xFF; } inline constexpr UInt32 kOpenHeFSBaseYear = 1970; @@ -386,10 +386,10 @@ class HeFileSystemParser final { ~HeFileSystemParser() = default; public: - HeFileSystemParser(const HeFileSystemParser&) = delete; + HeFileSystemParser(const HeFileSystemParser&) = delete; HeFileSystemParser& operator=(const HeFileSystemParser&) = delete; - HeFileSystemParser(HeFileSystemParser&&) = delete; + HeFileSystemParser(HeFileSystemParser&&) = delete; HeFileSystemParser& operator=(HeFileSystemParser&&) = delete; public: diff --git a/src/kernel/FirmwareKit/EFI/EFI.h b/src/kernel/FirmwareKit/EFI/EFI.h index 2418f20c..912be6eb 100644 --- a/src/kernel/FirmwareKit/EFI/EFI.h +++ b/src/kernel/FirmwareKit/EFI/EFI.h @@ -55,7 +55,7 @@ typedef Char16 EfiChar16Type; /// @brief Core Handle Kind /// Self is like NT's Win32 HANDLE type. typedef struct EfiHandle { -} * EfiHandlePtr; +}* EfiHandlePtr; /* UEFI uses wide characters by default. */ typedef WideChar EfiCharType; @@ -237,64 +237,42 @@ typedef struct EfiTableHeader { UInt32 Reserved; } EfiTableHeader; -#define EFI_ACPI_TABLE_PROTOCOL_GUID \ - { \ - 0xffe06bdd, 0x6107, 0x46a6, { 0x7b, 0xb2, 0x5a, 0x9c, 0x7e, 0xc5, 0x27, 0x5c } \ - } +#define EFI_ACPI_TABLE_PROTOCOL_GUID \ + {0xffe06bdd, 0x6107, 0x46a6, {0x7b, 0xb2, 0x5a, 0x9c, 0x7e, 0xc5, 0x27, 0x5c}} -#define EFI_LOAD_FILE_PROTOCOL_GUID \ - { \ - 0x56EC3091, 0x954C, 0x11d2, { 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ - } +#define EFI_LOAD_FILE_PROTOCOL_GUID \ + {0x56EC3091, 0x954C, 0x11d2, {0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}} -#define EFI_LOAD_FILE2_PROTOCOL_GUID \ - { \ - 0x4006c0c1, 0xfcb3, 0x403e, { 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d } \ - } +#define EFI_LOAD_FILE2_PROTOCOL_GUID \ + {0x4006c0c1, 0xfcb3, 0x403e, {0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d}} -#define EFI_LOADED_IMAGE_PROTOCOL_GUID \ - { \ - 0x5B1B31A1, 0x9562, 0x11d2, { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } \ - } +#define EFI_LOADED_IMAGE_PROTOCOL_GUID \ + {0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B}} -#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \ - { \ - 0x9042a9de, 0x23dc, 0x4a38, { 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a } \ - } +#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \ + {0x9042a9de, 0x23dc, 0x4a38, {0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a}} -#define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \ - { \ - 0xA19832B9, 0xAC25, 0x11D3, { 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ - } +#define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \ + {0xA19832B9, 0xAC25, 0x11D3, {0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d}} #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000 -#define EFI_IP4_PROTOCOL_GUID \ - { \ - 0x41d94cd2, 0x35b6, 0x455a, { 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } \ - } +#define EFI_IP4_PROTOCOL_GUID \ + {0x41d94cd2, 0x35b6, 0x455a, {0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd}} #define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000 -#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \ - { \ - 0x0964e5b22, 0x6459, 0x11d2, { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ - } +#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \ + {0x0964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}} -#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \ - { \ - 0xbc62157e, 0x3e33, 0x4fec, { 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf } \ - } +#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \ + {0xbc62157e, 0x3e33, 0x4fec, {0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf}} -#define EFI_DEVICE_PATH_PROTOCOL_GUID \ - { \ - 0x9576e91, 0x6d3f, 0x11d2, { 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ - } +#define EFI_DEVICE_PATH_PROTOCOL_GUID \ + {0x9576e91, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b}} -#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \ - { \ - 0x0964e5b22, 0x6459, 0x11d2, { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ - } +#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \ + {0x0964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}} typedef UInt64(EfiImageUnload)(EfiHandlePtr ImageHandle); @@ -349,17 +327,17 @@ typedef struct { typedef EFI_STATUS(EFIAPI* EFI_SIMPLE_NETWORK_TRANSMIT)(IN EFI_SIMPLE_NETWORK_PROTOCOL* This, IN UInt32 HeaderSize, IN UInt32 BufferSize, - IN Void* Buffer, - IN EfiMacAddress* SrcAddr OPTIONAL, + IN Void* Buffer, + IN EfiMacAddress* SrcAddr OPTIONAL, IN EfiMacAddress* DestAddr OPTIONAL, - IN UInt16* Protocol OPTIONAL); + IN UInt16* Protocol OPTIONAL); typedef EFI_STATUS(EFIAPI* EFI_SIMPLE_NETWORK_RECEIVE)(IN EFI_SIMPLE_NETWORK_PROTOCOL* This, - OUT UInt32* HeaderSize OPTIONAL, + OUT UInt32* HeaderSize OPTIONAL, IN OUT UInt32* BufferSize, OUT Void* Buffer, - OUT EfiMacAddress* SrcAddr OPTIONAL, + OUT EfiMacAddress* SrcAddr OPTIONAL, OUT EfiMacAddress* DestAddr OPTIONAL, - OUT UInt16* Protocol OPTIONAL); + OUT UInt16* Protocol OPTIONAL); typedef struct EFI_SIMPLE_NETWORK_PROTOCOL { UInt64 Revision; @@ -504,10 +482,8 @@ typedef struct EFI_GUID EFI_FINAL { * Protocol stuff... */ -#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \ - { \ - 0x387477c1, 0x69c7, 0x11d2, { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ - } +#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \ + {0x387477c1, 0x69c7, 0x11d2, {0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}} /** some helpers */ #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 @@ -605,7 +581,7 @@ typedef struct { } EfiInputKey; typedef EfiStatusType(EFI_API* EfiInputReadKey)(IN EfiSimpleTextInputProtocol* This, - OUT EfiInputKey* Key); + OUT EfiInputKey* Key); typedef EfiStatusType(EFI_API* EfiInputReset)(IN EfiSimpleTextInputProtocol* This, IN Boolean ExtendedChk); @@ -663,7 +639,7 @@ typedef struct EfiSystemTable { struct { EFI_GUID VendorGUID; VoidPtr VendorTable; - } * ConfigurationTable; + }* ConfigurationTable; } EfiSystemTable; #define kEfiOk 0 @@ -724,10 +700,8 @@ enum { #define EFI_EXTRA_DESCRIPTOR_SIZE 8 -#define EFI_MP_SERVICES_PROTOCOL_GUID \ - { \ - 0x3fdda605, 0xa76e, 0x4f46, { 0xad, 0x29, 0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08 } \ - } +#define EFI_MP_SERVICES_PROTOCOL_GUID \ + {0x3fdda605, 0xa76e, 0x4f46, {0xad, 0x29, 0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08}} #define PROCESSOR_AS_BSP_BIT 0x00000001 #define PROCESSOR_ENABLED_BIT 0x00000002 @@ -823,10 +797,8 @@ typedef struct EfiTime { UInt8 Pad2; } EfiTime; -#define EFI_FILE_INFO_GUID \ - { \ - 0x09576e92, 0x6d3f, 0x11d2, { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ - } +#define EFI_FILE_INFO_GUID \ + {0x09576e92, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}} struct EfiFileInfo EFI_FINAL { /// @brief Structure size. @@ -894,8 +866,8 @@ typedef EfiStatusType EFI_API (*EfiMpServicesStartupThisAP)( IN Void* ProcedureArgument OPTIONAL, OUT Boolean* Finished OPTIONAL); typedef EfiStatusType EFI_API (*EfiMpServicesDisableThisAP)(IN struct _EfiMpServicesProtocol* Self, - IN UInt32 ProcessorNumber, - IN Boolean EnableAP, + IN UInt32 ProcessorNumber, + IN Boolean EnableAP, IN UInt32* HealthFlag OPTIONAL); typedef EfiStatusType EFI_API (*EfiMpServicesWhoAmI)(IN struct _EfiMpServicesProtocol* Self, diff --git a/src/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc b/src/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc index e977912f..34c2c6a0 100644 --- a/src/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc +++ b/src/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc @@ -65,8 +65,7 @@ EXTERN_C void idt_handle_scheduler(Kernel::UIntPtr rsp) { hal_idt_send_eoi(32); - while (kIsRunning) - ; + while (kIsRunning); kIsRunning = YES; diff --git a/src/kernel/HALKit/AMD64/HalKernelMain.cc b/src/kernel/HALKit/AMD64/HalKernelMain.cc index cdf593cb..0179732f 100644 --- a/src/kernel/HALKit/AMD64/HalKernelMain.cc +++ b/src/kernel/HALKit/AMD64/HalKernelMain.cc @@ -157,7 +157,6 @@ EXTERN_C Kernel::Void hal_real_init(Kernel::Void) { HAL::IDTLoader idt_loader; idt_loader.Load(idt_reg); - while (YES) - ; + while (YES); } #endif // ifndef __NE_MODULAR_KERNEL_COMPONENTS__ diff --git a/src/kernel/HALKit/AMD64/Paging.h b/src/kernel/HALKit/AMD64/Paging.h index 96f87973..41543f5d 100644 --- a/src/kernel/HALKit/AMD64/Paging.h +++ b/src/kernel/HALKit/AMD64/Paging.h @@ -56,7 +56,9 @@ namespace Detail { kPageEnable = 31, }; - inline UInt8 control_register_cast(ControlRegisterBits reg) { return static_cast<UInt8>(reg); } + inline UInt8 control_register_cast(ControlRegisterBits reg) { + return static_cast<UInt8>(reg); + } } // namespace Detail auto mm_alloc_bitmap(Boolean wr, Boolean user, SizeT size, Bool is_page, SizeT pad = 0) -> VoidPtr; diff --git a/src/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/src/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index c4fdf56f..456b6a2a 100644 --- a/src/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/src/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -281,8 +281,7 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz goto ahci_io_end; } else { kout << "ahci: Disk still busy after command completion!\r"; - while (kSATAHba->Ports[kSATAIndex].Tfd & (kSATASRBsy | kSATASRDrq)) - ; + while (kSATAHba->Ports[kSATAIndex].Tfd & (kSATASRBsy | kSATASRDrq)); } ahci_io_end: @@ -295,13 +294,15 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz @brief Gets the number of sectors inside the drive. @return Sector size in bytes. */ -STATIC ATTRIBUTE(unused) SizeT drv_get_sector_count_ahci() { +STATIC ATTRIBUTE(unused) +SizeT drv_get_sector_count_ahci() { return kSATASectorCount; } /// @brief Get the drive size. /// @return Disk size in bytes. -STATIC ATTRIBUTE(unused) SizeT drv_get_size_ahci() { +STATIC ATTRIBUTE(unused) +SizeT drv_get_size_ahci() { return drv_std_get_sector_count() * kAHCISectorSize; } diff --git a/src/kernel/HALKit/AMD64/Storage/DMA+Generic.cc b/src/kernel/HALKit/AMD64/Storage/DMA+Generic.cc index a258bf3a..8bf7b161 100644 --- a/src/kernel/HALKit/AMD64/Storage/DMA+Generic.cc +++ b/src/kernel/HALKit/AMD64/Storage/DMA+Generic.cc @@ -92,7 +92,7 @@ Void drv_std_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorSz rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz - 1) / SectorSz)); - rt_out8(IO + ATA_REG_LBA0, (Lba) &0xFF); + rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF); rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8); rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16); rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24); @@ -110,8 +110,7 @@ Void drv_std_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorSz rt_out8(kATADevice.Bar(0x20) + 0x00, 0x09); // Start DMA engine - while (rt_in8(kATADevice.Bar(0x20) + ATA_REG_STATUS) & 0x01) - ; + while (rt_in8(kATADevice.Bar(0x20) + ATA_REG_STATUS) & 0x01); rt_out8(kATADevice.Bar(0x20) + 0x00, 0x00); // Stop DMA engine @@ -134,7 +133,7 @@ Void drv_std_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorS rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + (SectorSz - 1)) / SectorSz)); - rt_out8(IO + ATA_REG_LBA0, (Lba) &0xFF); + rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF); rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8); rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16); rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24); @@ -150,8 +149,7 @@ Void drv_std_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorS rt_out8(IO + 0x00, 0x09); // Start DMA engine - while (rt_in8(kATADevice.Bar(0x20) + ATA_REG_STATUS) & 0x01) - ; + while (rt_in8(kATADevice.Bar(0x20) + ATA_REG_STATUS) & 0x01); rt_out8(kATADevice.Bar(0x20) + 0x00, 0x00); // Stop DMA engine diff --git a/src/kernel/HALKit/AMD64/Storage/PIO+Generic.cc b/src/kernel/HALKit/AMD64/Storage/PIO+Generic.cc index 6f5ebb66..19497b5f 100644 --- a/src/kernel/HALKit/AMD64/Storage/PIO+Generic.cc +++ b/src/kernel/HALKit/AMD64/Storage/PIO+Generic.cc @@ -70,8 +70,7 @@ ATAInit_Retry: rt_out8(OutBus + ATA_REG_COMMAND, ATA_CMD_IDENTIFY); - while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ)) - ; + while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ)); /// fetch serial info /// model, speed, number of sectors... @@ -104,15 +103,14 @@ Void drv_pio_std_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT Sect rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz) / SectorSz)); - rt_out8(IO + ATA_REG_LBA0, (Lba) &0xFF); + rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF); rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8); rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16); rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24); rt_out8(IO + ATA_REG_COMMAND, ATA_CMD_READ_PIO); - while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ)) - ; + while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ)); for (SizeT IndexOff = 0; IndexOff < Size; IndexOff += 2) { drv_pio_std_wait_io(IO); @@ -136,15 +134,14 @@ Void drv_pio_std_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT Sec rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz) / SectorSz)); - rt_out8(IO + ATA_REG_LBA0, (Lba) &0xFF); + rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF); rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8); rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16); rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24); rt_out8(IO + ATA_REG_COMMAND, ATA_CMD_WRITE_PIO); - while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ)) - ; + while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ)); for (SizeT IndexOff = 0; IndexOff < Size; IndexOff += 2) { drv_pio_std_wait_io(IO); diff --git a/src/kernel/HALKit/ARM64/HalCoreInterruptHandler.cc b/src/kernel/HALKit/ARM64/HalCoreInterruptHandler.cc index 1fadcec3..7ee4a69c 100644 --- a/src/kernel/HALKit/ARM64/HalCoreInterruptHandler.cc +++ b/src/kernel/HALKit/ARM64/HalCoreInterruptHandler.cc @@ -54,8 +54,7 @@ EXTERN_C void int_handle_scheduler(Kernel::UIntPtr rsp) { hal_int_send_eoi(32); - while (kIsRunning) - ; + while (kIsRunning); kIsRunning = YES; diff --git a/src/kernel/HALKit/ARM64/HalKernelMain.cc b/src/kernel/HALKit/ARM64/HalKernelMain.cc index 9d2b21d7..3a6e4085 100644 --- a/src/kernel/HALKit/ARM64/HalKernelMain.cc +++ b/src/kernel/HALKit/ARM64/HalKernelMain.cc @@ -55,7 +55,6 @@ EXTERN_C void hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) { Kernel::mp_init_cores(); - while (YES) - ; + while (YES); } #endif diff --git a/src/kernel/HALKit/ARM64/Paging.h b/src/kernel/HALKit/ARM64/Paging.h index e5487e22..8dedf65f 100644 --- a/src/kernel/HALKit/ARM64/Paging.h +++ b/src/kernel/HALKit/ARM64/Paging.h @@ -40,14 +40,10 @@ /// Long format address range -#define cPageMAll \ - { 0b000, 0b000 } -#define cPageMToMax(M) \ - { M, 0b000 } -#define cPageMaxToM(M) \ - { 0b000, M } -#define cPageMToN(M, N) \ - { M, N } +#define cPageMAll {0b000, 0b000} +#define cPageMToMax(M) {M, 0b000} +#define cPageMaxToM(M) {0b000, M} +#define cPageMToN(M, N) {M, N} namespace Kernel::HAL { struct PACKED PTE_4KB final { @@ -85,7 +81,9 @@ namespace Detail { PageEnable = 31, }; - inline UInt8 control_register_cast(ControlRegisterBits reg) { return static_cast<UInt8>(reg); } + inline UInt8 control_register_cast(ControlRegisterBits reg) { + return static_cast<UInt8>(reg); + } } // namespace Detail struct PDE_4KB final { diff --git a/src/kernel/HALKit/POWER/HalApplicationProcessor.cc b/src/kernel/HALKit/POWER/HalApplicationProcessor.cc index 63292418..64333086 100644 --- a/src/kernel/HALKit/POWER/HalApplicationProcessor.cc +++ b/src/kernel/HALKit/POWER/HalApplicationProcessor.cc @@ -10,8 +10,7 @@ namespace Kernel::Detail { STATIC void mp_hang_fn(void) { - while (YES) - ; + while (YES); } } // namespace Kernel::Detail diff --git a/src/kernel/HALKit/RISCV/HalApplicationProcessor.cc b/src/kernel/HALKit/RISCV/HalApplicationProcessor.cc index 6c882acf..68242f97 100644 --- a/src/kernel/HALKit/RISCV/HalApplicationProcessor.cc +++ b/src/kernel/HALKit/RISCV/HalApplicationProcessor.cc @@ -11,8 +11,7 @@ using namespace Kernel; namespace Kernel { namespace Detail { STATIC void mp_hang_fn(void) { - while (YES) - ; + while (YES); } } // namespace Detail diff --git a/src/kernel/KernelKit/CoreProcessScheduler.h b/src/kernel/KernelKit/CoreProcessScheduler.h index c87e4cec..a6f817f7 100644 --- a/src/kernel/KernelKit/CoreProcessScheduler.h +++ b/src/kernel/KernelKit/CoreProcessScheduler.h @@ -59,19 +59,11 @@ struct ProcessHeapTree { TreeKind Color{TreeKind::kBlackTreeKind}; - struct ProcessHeapTree<T>* Parent { - nullptr - }; - struct ProcessHeapTree<T>* Child { - nullptr - }; - - struct ProcessHeapTree<T>* Prev { - nullptr - }; - struct ProcessHeapTree<T>* Next { - nullptr - }; + struct ProcessHeapTree<T>* Parent{nullptr}; + struct ProcessHeapTree<T>* Child{nullptr}; + + struct ProcessHeapTree<T>* Prev{nullptr}; + struct ProcessHeapTree<T>* Next{nullptr}; }; template <typename T> @@ -86,21 +78,13 @@ struct ProcessFileTree { TreeKind Color{TreeKind::kBlackTreeKind}; - struct ProcessFileTree<T>* Parent { - nullptr - }; + struct ProcessFileTree<T>* Parent{nullptr}; - struct ProcessFileTree<T>* Child { - nullptr - }; + struct ProcessFileTree<T>* Child{nullptr}; - struct ProcessFileTree<T>* Prev { - nullptr - }; + struct ProcessFileTree<T>* Prev{nullptr}; - struct ProcessFileTree<T>* Next { - nullptr - }; + struct ProcessFileTree<T>* Next{nullptr}; }; template <typename T> @@ -121,21 +105,13 @@ struct ProcessSpecialTree { TreeKind Color{TreeKind::kBlackTreeKind}; - struct ProcessSpecialTree<T>* Parent { - nullptr - }; + struct ProcessSpecialTree<T>* Parent{nullptr}; - struct ProcessSpecialTree<T>* Child { - nullptr - }; + struct ProcessSpecialTree<T>* Child{nullptr}; - struct ProcessSpecialTree<T>* Prev { - nullptr - }; + struct ProcessSpecialTree<T>* Prev{nullptr}; - struct ProcessSpecialTree<T>* Next { - nullptr - }; + struct ProcessSpecialTree<T>* Next{nullptr}; }; /***********************************************************************************/ diff --git a/src/kernel/KernelKit/DriveMgr.h b/src/kernel/KernelKit/DriveMgr.h index ad17c5a6..5c13460b 100644 --- a/src/kernel/KernelKit/DriveMgr.h +++ b/src/kernel/KernelKit/DriveMgr.h @@ -72,7 +72,7 @@ struct DriveTrait final { Void (*fOutput)(DrivePacket& packet){nullptr}; Void (*fVerify)(DrivePacket& packet){nullptr}; Void (*fInit)(DrivePacket& packet){nullptr}; - const Char* (*fProtocol)(Void){nullptr}; + const Char* (*fProtocol)(Void) {nullptr}; }; namespace Probe { diff --git a/src/kernel/KernelKit/HardwareThreadScheduler.h b/src/kernel/KernelKit/HardwareThreadScheduler.h index ec03d7c2..6813fcfe 100644 --- a/src/kernel/KernelKit/HardwareThreadScheduler.h +++ b/src/kernel/KernelKit/HardwareThreadScheduler.h @@ -63,10 +63,10 @@ class HardwareThread final { BOOL IsWakeup(); public: - HAL::StackFramePtr StackFrame(); + HAL::StackFramePtr StackFrame(); _Output const ThreadKind& Kind(); BOOL IsBusy(); - _Output const ThreadID& ID(); + _Output const ThreadID& ID(); private: HAL::StackFramePtr fStack{}; @@ -101,7 +101,7 @@ class HardwareThreadScheduler final : public ISchedulable { public: Ref<HardwareThread*> operator[](SizeT idx); bool operator!(); - operator bool(); + operator bool(); Bool IsUser() override { return Yes; } diff --git a/src/kernel/KernelKit/ILoader.h b/src/kernel/KernelKit/ILoader.h index 786cf3ee..8399e1ea 100644 --- a/src/kernel/KernelKit/ILoader.h +++ b/src/kernel/KernelKit/ILoader.h @@ -22,9 +22,9 @@ class ILoader { public: virtual _Output ErrorOr<VoidPtr> GetBlob() { return ErrorOr<VoidPtr>{}; } - virtual _Output const Char* AsString() { return ""; } - virtual _Output const Char* MIME() { return ""; } - virtual _Output const Char* Path() { return ""; } + virtual _Output const Char* AsString() { return ""; } + virtual _Output const Char* MIME() { return ""; } + virtual _Output const Char* Path() { return ""; } virtual _Output ErrorOr<VoidPtr> FindStart() { return ErrorOr<VoidPtr>{}; } virtual _Output ErrorOr<VoidPtr> FindSymbol(_Input const Char*, _Input Int32) { return ErrorOr<VoidPtr>{}; diff --git a/src/kernel/KernelKit/PCI/DMA.h b/src/kernel/KernelKit/PCI/DMA.h index 11b044cd..38854f31 100644 --- a/src/kernel/KernelKit/PCI/DMA.h +++ b/src/kernel/KernelKit/PCI/DMA.h @@ -46,7 +46,7 @@ class DMAWrapper final { T* Get(UIntPtr off = 0); public: - operator bool(); + operator bool(); bool operator!(); public: diff --git a/src/kernel/NeKit/Config.h b/src/kernel/NeKit/Config.h index a9ba8b8a..c012e008 100644 --- a/src/kernel/NeKit/Config.h +++ b/src/kernel/NeKit/Config.h @@ -16,7 +16,7 @@ #define NE_ICODEC \ final: \ - public \ + public \ ::Kernel::ICodec /// @brief The **NeKernel** namespace. @@ -112,12 +112,12 @@ inline Args&& move(Args&& arg) { template <class Type> concept IsSerializable = requires() { - {Type::kValue}; + { Type::kValue }; }; template <class Type> concept IsNotSerializable = requires() { - {!Type::kValue}; + { !Type::kValue }; }; /// @brief Encoding interface, used as a proxy to convert T to Char* diff --git a/src/kernel/NeKit/Macros.h b/src/kernel/NeKit/Macros.h index 3a6e26fa..c0fc57f4 100644 --- a/src/kernel/NeKit/Macros.h +++ b/src/kernel/NeKit/Macros.h @@ -15,7 +15,7 @@ #endif #ifndef kib_cast -#define kib_cast(X) (Kernel::UInt64)((X) *1024) +#define kib_cast(X) (Kernel::UInt64)((X) * 1024) #endif #ifndef MIB @@ -116,7 +116,7 @@ #define NE_UNUSED(X) ((Kernel::Void) X) #ifndef RGB -#define RGB(R, G, B) ((Kernel::UInt32)((0xFF << 24) | ((R) << 16) | ((G) << 8) | (B))) +#define RGB(R, G, B) ((Kernel::UInt32) ((0xFF << 24) | ((R) << 16) | ((G) << 8) | (B))) #endif // !RGB #ifdef __NE_AMD64__ diff --git a/src/kernel/NeKit/Ref.h b/src/kernel/NeKit/Ref.h index 2c669611..42e6d4ce 100644 --- a/src/kernel/NeKit/Ref.h +++ b/src/kernel/NeKit/Ref.h @@ -13,9 +13,8 @@ #include <NeKit/Vettable.h> namespace Kernel { -/// =========================================================== /// -/// @brief Reference wrapper class. /// -/// =========================================================== /// + +/// @brief Reference wrapper class. template <typename T> class Ref final { public: @@ -67,6 +66,7 @@ class Ref final { Type fClass; }; +/// @brief Non Nullable Reference class. template <typename T> class NonNullRef final { public: @@ -93,6 +93,7 @@ class NonNullRef final { using RefAny = Ref<Any>; using NonNullRefAny = NonNullRef<Any>; + } // namespace Kernel #endif // ifndef _NEKIT_REF_H_ diff --git a/src/kernel/NeKit/Utils.h b/src/kernel/NeKit/Utils.h index 8ee1371b..e28e23eb 100644 --- a/src/kernel/NeKit/Utils.h +++ b/src/kernel/NeKit/Utils.h @@ -54,9 +54,9 @@ inline constexpr SizeT oe_string_len(const CharType* str) { if (!str) return 0; #if __cplusplus == 202302L - if - consteval { return ARRAY_SIZE(str); } - else { + if consteval { + return ARRAY_SIZE(str); + } else { SizeT len{0}; while (str[len] != 0) ++len; return len; diff --git a/src/kernel/NeKit/Vettable.h b/src/kernel/NeKit/Vettable.h index f2056d27..5c2fd211 100644 --- a/src/kernel/NeKit/Vettable.h +++ b/src/kernel/NeKit/Vettable.h @@ -11,11 +11,14 @@ #define NE_VETTABLE static constexpr BOOL kVettable = YES #define NE_NON_VETTABLE static constexpr BOOL kVettable = NO +#define NE_UN_VETTABLE static constexpr BOOL kUnvettable = YES + namespace Kernel { template <class Type> -concept IsVettable = requires(Type) { - (Type::kVettable); -}; +concept IsVettable = requires(Type) { (Type::kVettable); }; + +template <class Type> +concept IsUnVettable = requires(Type) { (Type::kUnvettable); }; } // namespace Kernel #endif // !__NE_KIT_VETTABLE_H__ diff --git a/src/kernel/src/AsciiUtils.cc b/src/kernel/src/AsciiUtils.cc index e7eb8cd6..08d6464b 100644 --- a/src/kernel/src/AsciiUtils.cc +++ b/src/kernel/src/AsciiUtils.cc @@ -70,8 +70,7 @@ Void rt_zero_memory(voidPtr pointer, Size len) { #ifdef __NE_ENFORCE_DEPRECATED_WARNINGS [[deprecated("Use rt_set_memory_safe instead")]] #endif -voidPtr -rt_set_memory(voidPtr src, UInt32 value, Size len) { +voidPtr rt_set_memory(voidPtr src, UInt32 value, Size len) { if (!src) return nullptr; auto p = reinterpret_cast<UInt8*>(src); UInt8 v = static_cast<UInt8>(value & 0xFF); diff --git a/src/kernel/src/BitMapMgr.cc b/src/kernel/src/BitMapMgr.cc index c00c71ae..1aee57b6 100644 --- a/src/kernel/src/BitMapMgr.cc +++ b/src/kernel/src/BitMapMgr.cc @@ -155,7 +155,9 @@ namespace HAL { STATIC Detail::IBitMapProxy kBitMapMgr; - auto mm_is_bitmap(VoidPtr ptr) -> BOOL { return kBitMapMgr.IsBitMap(ptr); } + auto mm_is_bitmap(VoidPtr ptr) -> BOOL { + return kBitMapMgr.IsBitMap(ptr); + } /***********************************************************************************/ /// @brief Allocate a new page to be used by the OS. diff --git a/src/kernel/src/FS/NeFS+FileSystemParser.cc b/src/kernel/src/FS/NeFS+FileSystemParser.cc index 208a5563..cdbb92b1 100644 --- a/src/kernel/src/FS/NeFS+FileSystemParser.cc +++ b/src/kernel/src/FS/NeFS+FileSystemParser.cc @@ -152,8 +152,8 @@ _Output BOOL NeFileSystemParser::CreateFork(_Input NEFS_FORK_STRUCT& the_fork) { /// @return the newly found fork. /***********************************************************************************/ _Output NEFS_FORK_STRUCT* NeFileSystemParser::FindFork(_Input NEFS_CATALOG_STRUCT* catalog, - _Input const Char* name, - _Input Boolean is_data) { + _Input const Char* name, + _Input Boolean is_data) { if (!catalog || !name) return nullptr; auto& drive = kMountpoint.A(); @@ -215,7 +215,7 @@ _Output NEFS_CATALOG_STRUCT* NeFileSystemParser::CreateCatalog(_Input const Char /// @param kind the catalog kind. /// @return catalog pointer. /***********************************************************************************/ -_Output NEFS_CATALOG_STRUCT* NeFileSystemParser::CreateCatalog(_Input const Char* name, +_Output NEFS_CATALOG_STRUCT* NeFileSystemParser::CreateCatalog(_Input const Char* name, _Input const Int32& flags, _Input const Int32& kind) { kout << "CreateCatalog(*...*)\r"; diff --git a/src/kernel/src/IndexableProperty.cc b/src/kernel/src/IndexableProperty.cc index b3828e48..49063950 100644 --- a/src/kernel/src/IndexableProperty.cc +++ b/src/kernel/src/IndexableProperty.cc @@ -16,13 +16,21 @@ namespace Kernel { namespace Indexer { - Index& IndexableProperty::Leak() { return fIndex; } + Index& IndexableProperty::Leak() { + return fIndex; + } - Void IndexableProperty::AddFlag(UInt16 flag) { fFlags |= flag; } + Void IndexableProperty::AddFlag(UInt16 flag) { + fFlags |= flag; + } - Void IndexableProperty::RemoveFlag(UInt16 flag) { fFlags &= ~(flag); } + Void IndexableProperty::RemoveFlag(UInt16 flag) { + fFlags &= ~(flag); + } - UInt16 IndexableProperty::HasFlag(UInt16 flag) { return fFlags & flag; } + UInt16 IndexableProperty::HasFlag(UInt16 flag) { + return fFlags & flag; + } /// @brief Index a file into the indexer instance. /// @param filename filesystem path to access. diff --git a/src/kernel/src/PE32CodeMgr.cc b/src/kernel/src/PE32CodeMgr.cc index 940abd11..2bb8d941 100644 --- a/src/kernel/src/PE32CodeMgr.cc +++ b/src/kernel/src/PE32CodeMgr.cc @@ -18,6 +18,7 @@ #define kPeImageStart "__ImageStart" namespace Kernel { + namespace Detail { /***********************************************************************************/ /// @brief Get the PE32+ platform signature according to the compiled architecture. @@ -241,11 +242,10 @@ namespace Utils { if (errOrStart.Error() != kErrorSuccess) return kSchedInvalidPID; - ErrorOrAny symname = exec.FindSymbol(kPeImageStart, 0); + ErrorOrAny symname = exec.FindSymbol(kPeNameSymbol, 0); - if (!symname.Leak().Leak()) { - symname = ErrorOr<VoidPtr>{(VoidPtr) rt_alloc_string("USER_PROCESS_PE32+")}; - } + if (!symname.Leak().Leak()) + symname = ErrorOr<VoidPtr>{(VoidPtr) rt_alloc_string(kPeImageStart)}; if (!symname.Leak().Leak()) return kSchedInvalidPID; @@ -283,4 +283,5 @@ namespace Utils { return id; } } // namespace Utils + } // namespace Kernel
\ No newline at end of file diff --git a/src/kernel/src/PEFCodeMgr.cc b/src/kernel/src/PEFCodeMgr.cc index a9c26d9f..82d90ec1 100644 --- a/src/kernel/src/PEFCodeMgr.cc +++ b/src/kernel/src/PEFCodeMgr.cc @@ -21,8 +21,10 @@ #define kPefStackSizeSymbol "__PEFSizeOfReserveStack" #define kPefHeapSizeSymbol "__PEFSizeOfReserveHeap" #define kPefNameSymbol "__PEFProgramName" +#define kPefImageStart "__ImageStart" namespace Kernel { + namespace Detail { /***********************************************************************************/ /// @brief Get the PEF platform signature according to the compiled architecture. @@ -298,11 +300,10 @@ ProcessID rtl_create_user_process(PEFLoader& exec, if (errOrStart.Error() != kErrorSuccess) return kSchedInvalidPID; - auto symname = exec.FindSymbol(kPefNameSymbol, kPefData); + auto symname = exec.FindSymbol(kPefNameSymbol, kPefCode); - if (!symname.Leak().Leak()) { - symname = ErrorOr<VoidPtr>{(VoidPtr) rt_alloc_string("USER_PROCESS_PEF")}; - } + if (!symname.Leak().Leak()) + symname = ErrorOr<VoidPtr>{(VoidPtr) rt_alloc_string(kPefImageStart)}; if (!symname.Leak().Leak()) return kSchedInvalidPID; @@ -338,4 +339,5 @@ ProcessID rtl_create_user_process(PEFLoader& exec, return id; } + } // namespace Kernel diff --git a/src/kernel/src/ThreadLocalStorage.cc b/src/kernel/src/ThreadLocalStorage.cc index aad7b9a5..7168c749 100644 --- a/src/kernel/src/ThreadLocalStorage.cc +++ b/src/kernel/src/ThreadLocalStorage.cc @@ -15,7 +15,7 @@ /***********************************************************************************/ namespace Kernel { - + /** * @brief Checks for cookie inside the TIB. * @param tib_ptr the TIB to check. diff --git a/src/kernel/src/UserMgr+User.cc b/src/kernel/src/UserMgr+User.cc index 66b1d3ec..9c6eda0e 100644 --- a/src/kernel/src/UserMgr+User.cc +++ b/src/kernel/src/UserMgr+User.cc @@ -1,4 +1,4 @@ -// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org) +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/nekernel-org/nekernel @@ -15,6 +15,7 @@ /// @brief Multi-user support. namespace Kernel { + namespace Detail { //////////////////////////////////////////////////////////// /// \brief Constructs a password by hashing the password. @@ -22,11 +23,11 @@ namespace Detail { /// \return the hashed password //////////////////////////////////////////////////////////// STATIC UInt64 user_fnv_generator(const Char* password, User* user) { + kout << "user_fnv_generator: Try hashing user password...\r"; + if (!password || !user) return 0; if (*password == 0) return 0; - kout << "user_fnv_generator: Hashing user password...\r"; - const UInt64 kFnvOffsetBasis = 0xcbf29ce484222325ULL; const UInt64 kFnvPrime = 0x100000001b3ULL; @@ -117,4 +118,5 @@ Bool User::IsStdUser() { Bool User::IsSuperUser() { return this->Ring() == UserRingKind::kRingSuperUser; } + } // namespace Kernel diff --git a/src/kernel/src/UserProcessScheduler.cc b/src/kernel/src/UserProcessScheduler.cc index 3b9e1a0f..de6e959f 100644 --- a/src/kernel/src/UserProcessScheduler.cc +++ b/src/kernel/src/UserProcessScheduler.cc @@ -111,7 +111,7 @@ ErrorOr<VoidPtr> UserProcess::New(SizeT sz, SizeT pad_amount) { hal_write_cr3(vm_register); #else - auto ptr = mm_alloc_ptr(sz, Yes, Yes, pad_amount); + auto ptr = mm_alloc_ptr(sz, Yes, Yes, pad_amount); #endif if (!this->HeapTree) { diff --git a/src/launch/src/AppMain.cc b/src/launch/src/Main.cc index bb38c773..bb38c773 100644 --- a/src/launch/src/AppMain.cc +++ b/src/launch/src/Main.cc diff --git a/src/libDDK/DriverKit/c++/checksum.h b/src/libDDK/DriverKit/c++/checksum.h index 34a49675..4cc87423 100644 --- a/src/libDDK/DriverKit/c++/checksum.h +++ b/src/libDDK/DriverKit/c++/checksum.h @@ -1,10 +1,39 @@ -// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org) +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/nekernel-org/nekernel #ifndef DRIVERKIT_CHECKSUM_H #define DRIVERKIT_CHECKSUM_H -/// @todo Driver checksum +#include <DriverKit/c++/driver_base.h> + +namespace Kernel::DDK { + +using IndexableBlob = Char*; + +/// @note This uses the FNV 64-bit variant. +/// @brief Performs a checksum computation for a memory region. +inline UInt64 rtl_checksum(const IndexableBlob path) { + if (!path || *path == 0) return 0; + + const UInt64 kFNVSeed = 0xcbf29ce484222325ULL; + const UInt64 kFNVPrime = 0x100000001b3ULL; + + UInt64 hash = kFNVSeed; + + IndexableBlob path_ = path; + + while (*path_) { + hash ^= (Char) (*path_++); + hash *= kFNVPrime; + } + + return hash; +} + +using Blob = VoidPtr; + +} + #endif diff --git a/src/libDDK/DriverKit/c++/ddk.h b/src/libDDK/DriverKit/c++/ddk.h index f9b6b8d1..857a65a7 100644 --- a/src/libDDK/DriverKit/c++/ddk.h +++ b/src/libDDK/DriverKit/c++/ddk.h @@ -1,11 +1,11 @@ -// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org) +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/nekernel-org/nekernel #ifndef DRIVERKIT_DDK_H #define DRIVERKIT_DDK_H -#include <DriverKit/c++/checksum.h> #include <DriverKit/c++/driver_base.h> +#include <DriverKit/c++/checksum.h> #endif diff --git a/src/libDDK/DriverKit/c++/driver_base.h b/src/libDDK/DriverKit/c++/driver_base.h index e5147b77..82e5bd44 100644 --- a/src/libDDK/DriverKit/c++/driver_base.h +++ b/src/libDDK/DriverKit/c++/driver_base.h @@ -5,11 +5,12 @@ #ifndef DRIVERKIT_DRIVER_BASE_H #define DRIVERKIT_DRIVER_BASE_H +#include <CompilerKit/CompilerKit.h> #include <libDDK/DriverKit/macros.h> #define DDK_DRIVER_IMPL \ final: \ - public \ + public \ ::Kernel::DDK::IDriverBase /// @author Amlal El Mahrouss @@ -38,7 +39,7 @@ class IDriverBase { /// @author @amlel-el-mahrouss template <typename Driver> concept IsValidDriver = requires(Driver drv) { - {drv.IsActive() && drv.Type() > kInvalidType}; + { drv.IsActive() && drv.Type() > kInvalidType }; }; } // namespace Kernel::DDK diff --git a/src/libDDK/DriverKit/ddk.h b/src/libDDK/DriverKit/ddk.h index fa6a90ed..2ff2db9e 100644 --- a/src/libDDK/DriverKit/ddk.h +++ b/src/libDDK/DriverKit/ddk.h @@ -10,11 +10,18 @@ struct DDK_STATUS_STRUCT; struct DDK_OBJECT_MANIFEST; +typedef void* ptr_t; + +typedef ptr_t addr_t; + +typedef ptr_t vaddr_t; +typedef ptr_t paddr_t; + /// \brief Object handle manifest. struct DDK_OBJECT_MANIFEST DDK_FINAL { char* p_name; int32_t p_kind; - void* p_object; + ptr_t p_object; }; /// \brief DDK status ping structure. @@ -25,13 +32,6 @@ struct DDK_STATUS_STRUCT DDK_FINAL { struct DDK_OBJECT_MANIFEST* s_object; }; -typedef void* ptr_t; - -typedef ptr_t addr_t; - -typedef ptr_t vaddr_t; -typedef ptr_t paddr_t; - /// @brief Call Kernel procedure. /// @param name the procedure name. /// @param cnt number of elements in **dat** diff --git a/src/libDDK/src/ddk_kernel_call.c b/src/libDDK/src/ddk_kernel_call.c index d69b1f59..2c75ee07 100644 --- a/src/libDDK/src/ddk_kernel_call.c +++ b/src/libDDK/src/ddk_kernel_call.c @@ -13,7 +13,7 @@ /// @brief this is an internal call, do not use it. DDK_EXTERN ATTRIBUTE(naked) /* */ - ptr_t __ke_call_dispatch(const int32_t name, int32_t cnt, void* data, size_t sz); +ptr_t __ke_call_dispatch(const int32_t name, int32_t cnt, void* data, size_t sz); /// @brief This function hashes the path into a FNV symbol. /// @param path the path to hash. @@ -51,7 +51,7 @@ DDK_EXTERN void* ke_call_dispatch(const char* name, int32_t cnt, void* data, siz /// @param slot system call slot /// @param slotFn, syscall slot. DDK_EXTERN void ke_set_syscall(const int slot, void (*slotFn)(void* a0)) { - ke_call_dispatch("ke_set_syscall", slot, slotFn, 1); + ke_call_dispatch("ke_set_syscall", slot, (ptr_t)slotFn, 1); } /// @brief Get a Kernel object. @@ -72,6 +72,7 @@ DDK_EXTERN struct DDK_OBJECT_MANIFEST* ke_get_obj(const int slot, const char* na /// @param name the object's name. /// @param ddk_pr pointer to a object's DDK_OBJECT_MANIFEST. /// @return property's object. -DDK_EXTERN void* ke_set_obj(const int slot, const struct DDK_OBJECT_MANIFEST* ddk_pr) { - return ke_call_dispatch("cfkit_set_kobj", slot, (void*) ddk_pr, 1); +DDK_EXTERN void* ke_set_obj(const int slot, const struct DDK_OBJECT_MANIFEST* ddk_ptr) { + if (ddk_ptr == nil) return nil; + return ke_call_dispatch("cfkit_set_kobj", slot, (void*) ddk_ptr, 1); } diff --git a/src/libMsg/MsgKit/Server.h b/src/libMsg/MsgKit/Server.h index af235d29..189715df 100644 --- a/src/libMsg/MsgKit/Server.h +++ b/src/libMsg/MsgKit/Server.h @@ -1,4 +1,4 @@ -// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org) +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/nekernel-org/nekernel @@ -6,7 +6,7 @@ #define MSGKIT_SERVER_H #ifdef __cplusplus -#include <public/frameworks/CoreFoundation.fwrk/headers/String.h> +#include <CoreFoundation.fwrk/headers/String.h> #else #include <libSystem/SystemKit/System.h> #endif diff --git a/src/libSystem/SystemKit/Macros.h b/src/libSystem/SystemKit/Macros.h index b349387f..cd337f26 100644 --- a/src/libSystem/SystemKit/Macros.h +++ b/src/libSystem/SystemKit/Macros.h @@ -90,7 +90,7 @@ typedef nullPtr NullPtr; #endif #ifndef kib_cast -#define kib_cast(X) (UInt64)((X) *1024) +#define kib_cast(X) (UInt64)((X) * 1024) #endif #ifndef MIB |
