summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorAmlal <amlal@nekernel.org>2025-05-09 20:22:01 +0200
committerAmlal <amlal@nekernel.org>2025-05-09 20:23:52 +0200
commit1391fa1bdc1cfe864596d3120bda12590131bc62 (patch)
tree103f36459712cd3af1af8d603404684ce41718b4 /dev
parent902bafa5dc8c3ac5fcbf13a5af73e016e9c64685 (diff)
dev(kernel, tooling): better code quality inside the codebase and more checks inside the kernel, and cli.
also: - make use _NeMain for the mk_fwrk tool. Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'dev')
-rw-r--r--dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc10
-rw-r--r--dev/kernel/kernel_rsrc.rsrc2
-rw-r--r--dev/kernel/src/FS/HeFS+FileSystemParser.cc8
-rw-r--r--dev/kernel/src/UserProcessScheduler.cc5
4 files changed, 16 insertions, 9 deletions
diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
index 2b7aec14..ad4f9eeb 100644
--- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
+++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
@@ -160,10 +160,12 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz
UInt16 timeout = 0;
+ constexpr static UInt16 kTimeout = 0x7000;
+
while (slot == ~0UL) {
kout << "No free command slot found, AHCI disk is busy!\r";
- if (timeout > 0x1000) {
+ if (timeout > kTimeout) {
err_global_get() = kErrorDisk;
return;
}
@@ -183,6 +185,8 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz
volatile HbaCmdTbl* command_table =
(volatile HbaCmdTbl*) (((UInt64) command_header->Ctbau << 32) | command_header->Ctba);
+ MUST_PASS(command_table);
+
rt_set_memory((VoidPtr) command_table, 0, sizeof(HbaCmdTbl));
VoidPtr ptr = rtl_dma_alloc(size_buffer, kib_cast(4));
@@ -195,7 +199,7 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz
rtl_dma_flush(ptr, size_buffer);
- // Build the PRDT
+ // Build the PRD table.
SizeT bytes_remaining = size_buffer;
SizeT prdt_index = 0;
UIntPtr buffer_phys = (UIntPtr) ptr;
@@ -216,11 +220,13 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz
++prdt_index;
}
+ // Mark the last PRD entry, for the FIS to process the table.
command_table->Prdt[prdt_index - 1].Ie = YES;
if (bytes_remaining > 0) {
kout << "Warning: AHCI PRDT overflow, cannot map full buffer.\r";
err_global_get() = kErrorDisk;
+ rtl_dma_free(size_buffer);
return;
}
diff --git a/dev/kernel/kernel_rsrc.rsrc b/dev/kernel/kernel_rsrc.rsrc
index 69922999..b7a11036 100644
--- a/dev/kernel/kernel_rsrc.rsrc
+++ b/dev/kernel/kernel_rsrc.rsrc
@@ -8,7 +8,7 @@ BEGIN
BEGIN
BLOCK "080904E4"
BEGIN
- VALUE "CompanyName", "Amlal El Mahrouss."
+ VALUE "CompanyName", "Amlal El Mahrouss"
VALUE "FileDescription", "NeKernel"
VALUE "FileVersion", KERNEL_VERSION
VALUE "InternalName", "neoskrnl"
diff --git a/dev/kernel/src/FS/HeFS+FileSystemParser.cc b/dev/kernel/src/FS/HeFS+FileSystemParser.cc
index d66c4a53..da55432a 100644
--- a/dev/kernel/src/FS/HeFS+FileSystemParser.cc
+++ b/dev/kernel/src/FS/HeFS+FileSystemParser.cc
@@ -1037,14 +1037,14 @@ _Output Bool HeFileSystemParser::INodeManip(_Input DriveTrait* mnt, VoidPtr bloc
goto inode_manip_fail;
}
- in ? mnt->fInput(mnt->fPacket) : mnt->fOutput(mnt->fPacket);
-
- sz_out += kHeFSBlockLen;
-
if (!in) {
+ mnt->fOutput(mnt->fPacket);
delete[] nodes;
return YES;
} else {
+ mnt->fInput(mnt->fPacket);
+ sz_out += kHeFSBlockLen;
+
if (sz_out >= block_sz) {
delete[] nodes;
return YES;
diff --git a/dev/kernel/src/UserProcessScheduler.cc b/dev/kernel/src/UserProcessScheduler.cc
index dbe3882f..2082642c 100644
--- a/dev/kernel/src/UserProcessScheduler.cc
+++ b/dev/kernel/src/UserProcessScheduler.cc
@@ -3,7 +3,7 @@
Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
FILE: UserProcessScheduler.cc
- PURPOSE: Low level/Ring-3 process scheduler.
+ PURPOSE: Low-Privilege/Ring-3 process scheduler.
------------------------------------------- */
@@ -14,12 +14,13 @@
/***********************************************************************************/
#include <ArchKit/ArchKit.h>
+#include <NewKit/KString.h>
+
#include <KernelKit/HardwareThreadScheduler.h>
#include <KernelKit/IPEFDylibObject.h>
#include <KernelKit/KPC.h>
#include <KernelKit/MemoryMgr.h>
#include <KernelKit/ProcessScheduler.h>
-#include <NewKit/KString.h>
///! BUGS: 0