diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-11 16:48:02 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-11 16:49:12 +0200 |
| commit | da0e83c01161d0c216f3831d5be21df728691c64 (patch) | |
| tree | 126ca82341e40fd8481b21966320fdf10c3f0266 /dev/kernel/HALKit | |
| parent | f775566da3cf4f8e3ffd4ca6dfe0a3c7776c3b35 (diff) | |
feat(kernel/hefs): Fixed the shortcomings and issues of HeFS.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/HALKit')
| -rw-r--r-- | dev/kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc | 3 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/HalDebugOutput.cc | 46 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/HalKernelMain.cc | 3 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Paging.h | 4 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc | 6 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc | 10 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc | 4 | ||||
| -rw-r--r-- | dev/kernel/HALKit/ARM64/HalApplicationProcessor.cc | 3 | ||||
| -rw-r--r-- | dev/kernel/HALKit/ARM64/HalKernelMain.cc | 3 | ||||
| -rw-r--r-- | dev/kernel/HALKit/ARM64/HalPagingMgrARM64.cc | 3 | ||||
| -rw-r--r-- | dev/kernel/HALKit/ARM64/Paging.h | 4 | ||||
| -rw-r--r-- | dev/kernel/HALKit/POWER/HalApplicationProcessor.cc | 3 | ||||
| -rw-r--r-- | dev/kernel/HALKit/RISCV/HalApplicationProcessor.cc | 3 |
13 files changed, 65 insertions, 30 deletions
diff --git a/dev/kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc b/dev/kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc index 641fb8e4..84c35615 100644 --- a/dev/kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc +++ b/dev/kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc @@ -128,7 +128,8 @@ EXTERN_C Kernel::Void idt_handle_breakpoint(Kernel::UIntPtr rip) { if (process.Leak().Status != Kernel::ProcessStatusKind::kRunning) { Kernel::kout << "Kernel: SIGTRAP\r"; - while (YES); + while (YES) + ; } kIsScheduling = NO; diff --git a/dev/kernel/HALKit/AMD64/HalDebugOutput.cc b/dev/kernel/HALKit/AMD64/HalDebugOutput.cc index bd8fe734..5d14f214 100644 --- a/dev/kernel/HALKit/AMD64/HalDebugOutput.cc +++ b/dev/kernel/HALKit/AMD64/HalDebugOutput.cc @@ -57,6 +57,8 @@ namespace Detail { TerminalDevice::~TerminalDevice() = default; +STATIC SizeT kX = kFontSizeX, kY = kFontSizeY; + EXTERN_C void ke_utf_io_write(IDeviceObject<const Utf8Char*>* obj, const Utf8Char* bytes) { NE_UNUSED(bytes); NE_UNUSED(obj); @@ -76,11 +78,36 @@ EXTERN_C void ke_utf_io_write(IDeviceObject<const Utf8Char*>* obj, const Utf8Cha index = 0; len = urt_string_len(bytes); + Char tmp_str[2]; + while (index < len) { if (bytes[index] == '\r') HAL::rt_out8(Detail::kPort, '\r'); HAL::rt_out8(Detail::kPort, bytes[index] == '\r' ? '\n' : bytes[index]); + tmp_str[0] = (bytes[index] > 127) ? '?' : bytes[index]; + tmp_str[1] = 0; + + fb_render_string(tmp_str, kY, kX, RGB(0xff, 0xff, 0xff)); + + if (bytes[index] == '\r') { + kY += kFontSizeY; + kX = kFontSizeX; + } + + kX += kFontSizeX; + + if (kX > kHandoverHeader->f_GOP.f_Width) { + kX = kFontSizeX; + } + + if (kY > kHandoverHeader->f_GOP.f_Height) { + kY = kFontSizeY; + + FBDrawInRegion(fb_get_clear_clr(), FB::FBAccessibilty::Height(), FB::FBAccessibilty::Width(), + 0, 0); + } + ++index; } @@ -107,32 +134,31 @@ EXTERN_C void ke_io_write(IDeviceObject<const Char*>* obj, const Char* bytes) { index = 0; len = rt_string_len(bytes); - STATIC SizeT x = kFontSizeX, y = kFontSizeY; + Char tmp_str[2]; while (index < len) { if (bytes[index] == '\r') HAL::rt_out8(Detail::kPort, '\r'); HAL::rt_out8(Detail::kPort, bytes[index] == '\r' ? '\n' : bytes[index]); - char tmp_str[2]; tmp_str[0] = bytes[index]; tmp_str[1] = 0; - fb_render_string(tmp_str, y, x, RGB(0xff, 0xff, 0xff)); + fb_render_string(tmp_str, kY, kX, RGB(0xff, 0xff, 0xff)); if (bytes[index] == '\r') { - y += kFontSizeY; - x = kFontSizeX; + kY += kFontSizeY; + kX = kFontSizeX; } - x += kFontSizeX; + kX += kFontSizeX; - if (x > kHandoverHeader->f_GOP.f_Width) { - x = kFontSizeX; + if (kX > kHandoverHeader->f_GOP.f_Width) { + kX = kFontSizeX; } - if (y > kHandoverHeader->f_GOP.f_Height) { - y = kFontSizeY; + if (kY > kHandoverHeader->f_GOP.f_Height) { + kY = kFontSizeY; FBDrawInRegion(fb_get_clear_clr(), FB::FBAccessibilty::Height(), FB::FBAccessibilty::Width(), 0, 0); diff --git a/dev/kernel/HALKit/AMD64/HalKernelMain.cc b/dev/kernel/HALKit/AMD64/HalKernelMain.cc index f41979bb..2747439a 100644 --- a/dev/kernel/HALKit/AMD64/HalKernelMain.cc +++ b/dev/kernel/HALKit/AMD64/HalKernelMain.cc @@ -146,7 +146,8 @@ EXTERN_C Kernel::Void hal_real_init(Kernel::Void) noexcept { kTeams[team_index].Id() = team_index; - while (!UserProcessScheduler::The().SwitchTeam(kTeams[team_index])); + while (!UserProcessScheduler::The().SwitchTeam(kTeams[team_index])) + ; timer.Wait(); diff --git a/dev/kernel/HALKit/AMD64/Paging.h b/dev/kernel/HALKit/AMD64/Paging.h index 3c7107bc..cfba232c 100644 --- a/dev/kernel/HALKit/AMD64/Paging.h +++ b/dev/kernel/HALKit/AMD64/Paging.h @@ -55,9 +55,7 @@ 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 auto mm_alloc_bitmap(Boolean wr, Boolean user, SizeT size, Bool is_page, SizeT pad = 0) -> VoidPtr; diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index 42242dbe..a3079e0c 100644 --- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -265,6 +265,9 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz if (timeout > kTimeout) { kout << "Disk hangup!\r"; kSATAHba->Ports[kSATAIndex].Ci = 0; + err_global_get() = kErrorDiskIsCorrupted; + rtl_dma_free(size_buffer); + return; } @@ -293,7 +296,8 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz goto ahci_io_end; } else { kout << "Warning: Disk still busy after command completion!\r"; - while (kSATAHba->Ports[kSATAIndex].Tfd & (kSATASRBsy | kSATASRDrq)); + while (kSATAHba->Ports[kSATAIndex].Tfd & (kSATASRBsy | kSATASRDrq)) + ; } ahci_io_end: diff --git a/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc index 4688203f..39efb7d3 100644 --- a/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc @@ -105,7 +105,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); @@ -123,7 +123,8 @@ 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 @@ -146,7 +147,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); @@ -162,7 +163,8 @@ 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/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc index b22330e4..aec21ee4 100644 --- a/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc @@ -118,7 +118,7 @@ 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); @@ -143,7 +143,7 @@ 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); diff --git a/dev/kernel/HALKit/ARM64/HalApplicationProcessor.cc b/dev/kernel/HALKit/ARM64/HalApplicationProcessor.cc index 14af1a16..7e55aa07 100644 --- a/dev/kernel/HALKit/ARM64/HalApplicationProcessor.cc +++ b/dev/kernel/HALKit/ARM64/HalApplicationProcessor.cc @@ -39,7 +39,8 @@ namespace Detail { STATIC BOOL kGICEnabled = NO;
STATIC void mp_hang_fn(void) {
- while (YES);
+ while (YES)
+ ;
dbg_break_point();
}
diff --git a/dev/kernel/HALKit/ARM64/HalKernelMain.cc b/dev/kernel/HALKit/ARM64/HalKernelMain.cc index 3e6701ea..bf5849ef 100644 --- a/dev/kernel/HALKit/ARM64/HalKernelMain.cc +++ b/dev/kernel/HALKit/ARM64/HalKernelMain.cc @@ -62,7 +62,8 @@ EXTERN_C void hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) { team_index = 0U; } - while (!UserProcessScheduler::The().SwitchTeam(kTeams[team_index])); + while (!UserProcessScheduler::The().SwitchTeam(kTeams[team_index])) + ; timer.Wait(); diff --git a/dev/kernel/HALKit/ARM64/HalPagingMgrARM64.cc b/dev/kernel/HALKit/ARM64/HalPagingMgrARM64.cc index 9fcee573..e0b67489 100644 --- a/dev/kernel/HALKit/ARM64/HalPagingMgrARM64.cc +++ b/dev/kernel/HALKit/ARM64/HalPagingMgrARM64.cc @@ -46,7 +46,8 @@ EXTERN_C Int32 mm_map_page(VoidPtr virtual_address, VoidPtr physical_address, UI NE_PAGE_STORE& page_store = NE_PAGE_STORE::The(); - while (page_store.fStoreOp); + while (page_store.fStoreOp) + ; page_store.fStoreOp = Yes; diff --git a/dev/kernel/HALKit/ARM64/Paging.h b/dev/kernel/HALKit/ARM64/Paging.h index e23c0538..2eb02bc1 100644 --- a/dev/kernel/HALKit/ARM64/Paging.h +++ b/dev/kernel/HALKit/ARM64/Paging.h @@ -84,9 +84,7 @@ 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/dev/kernel/HALKit/POWER/HalApplicationProcessor.cc b/dev/kernel/HALKit/POWER/HalApplicationProcessor.cc index eb44b72b..617b3dda 100644 --- a/dev/kernel/HALKit/POWER/HalApplicationProcessor.cc +++ b/dev/kernel/HALKit/POWER/HalApplicationProcessor.cc @@ -10,7 +10,8 @@ namespace Kernel::Detail { STATIC void mp_hang_fn(void) { - while (YES); + while (YES) + ; } } // namespace Kernel::Detail diff --git a/dev/kernel/HALKit/RISCV/HalApplicationProcessor.cc b/dev/kernel/HALKit/RISCV/HalApplicationProcessor.cc index 548167a4..80162b81 100644 --- a/dev/kernel/HALKit/RISCV/HalApplicationProcessor.cc +++ b/dev/kernel/HALKit/RISCV/HalApplicationProcessor.cc @@ -13,7 +13,8 @@ using namespace Kernel; namespace Kernel {
namespace Detail {
STATIC void mp_hang_fn(void) {
- while (YES);
+ while (YES)
+ ;
}
} // namespace Detail
|
