summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA/HALKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-09-05 09:26:46 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-09-05 09:26:46 +0200
commit518e2ce29513b8d49adf73e76aaf94c4f722dfae (patch)
treec123d045f49b215220026cdc8f508f3c3da86eb1 /dev/ZKA/HALKit
parent1069f411d413e2185f6536b01b8993187056fcd8 (diff)
[ FIX ] Fixed KRNL BMP allocator, which was not working because of badly
formatted heap block. [ IMP ] Improve logger routines [ FILE ] LINE : <LINE> <MSG>. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA/HALKit')
-rw-r--r--dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx30
-rw-r--r--dev/ZKA/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx8
-rw-r--r--dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx8
-rw-r--r--dev/ZKA/HALKit/AMD64/HalKernelMain.cxx2
-rw-r--r--dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx6
-rw-r--r--dev/ZKA/HALKit/AMD64/Storage/ATA-PIO.cxx6
-rw-r--r--dev/ZKA/HALKit/ARM64/HalKernelMain.cxx2
-rw-r--r--dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx4
-rw-r--r--dev/ZKA/HALKit/AXP/CoreSyscallHandlerDEC.cpp4
9 files changed, 37 insertions, 33 deletions
diff --git a/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx b/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx
index 7bafd075..221cb044 100644
--- a/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx
@@ -37,11 +37,13 @@ namespace Kernel
{
ptr_bit_set[0] = cVMHMagic;
ptr_bit_set[1] = size;
+ ptr_bit_set[2] = __BIGGEST_ALIGNMENT__;
- kcout << "BBP: STATUS\r";
- kcout << "BBP: MAG: " << hex_number(ptr_bit_set[0]) << endl;
- kcout << "BBP: ADDRESS: " << hex_number((UIntPtr)ptr_bit_set) << endl;
- kcout << "BBP: SIZE: " << hex_number(ptr_bit_set[1]) << endl;
+ kcout << "ALLOC STATUS\r";
+ kcout << "MAG: " << hex_number(ptr_bit_set[0]) << endl;
+ kcout << "ADDRESS: " << hex_number((UIntPtr)ptr_bit_set) << endl;
+ kcout << "SIZE: " << hex_number(ptr_bit_set[1]) << endl;
+ kcout << "ALLOC STATUS\r";
if (rw)
mm_update_pte(base_ptr, eFlagsRw);
@@ -49,10 +51,10 @@ namespace Kernel
if (user)
mm_update_pte(base_ptr, eFlagsUser);
- return (VoidPtr)(&ptr_bit_set[2]);
+ return (VoidPtr)ptr_bit_set;
}
- base_ptr = reinterpret_cast<VoidPtr>(reinterpret_cast<UIntPtr>(base_ptr) + 1 + ptr_bit_set[1]);
+ base_ptr = reinterpret_cast<VoidPtr>(reinterpret_cast<UIntPtr>(base_ptr) + __BIGGEST_ALIGNMENT__ + ptr_bit_set[1]);
}
return nullptr;
@@ -71,7 +73,7 @@ namespace Kernel
ptr_new = traits.FindBitMap(kKernelVirtualStart, size, rw, user);
- return &((UIntPtr*)ptr_new)[1];
+ return ((UIntPtr*)ptr_new);
}
auto mm_free_bitmap(VoidPtr page_ptr) -> Bool
@@ -79,19 +81,21 @@ namespace Kernel
if (!page_ptr)
return false;
- UIntPtr* ptr_bit_set = reinterpret_cast<UIntPtr*>(page_ptr) - 3;
+ UIntPtr* ptr_bit_set = reinterpret_cast<UIntPtr*>(page_ptr);
if (!ptr_bit_set[0] ||
ptr_bit_set[0] != cVMHMagic)
- return false;
+ return false;
- kcout << "BBP: FREE STATUS\r";
- kcout << "BBP: MAG: " << hex_number(ptr_bit_set[0]) << endl;
- kcout << "BBP: ADDRESSS: " << hex_number((UIntPtr)ptr_bit_set) << endl;
- kcout << "BBP: SIZE: " << hex_number(ptr_bit_set[1]) << endl;
+ kcout << "FREE STATUS\r";
+ kcout << "MAG: " << hex_number(ptr_bit_set[0]) << endl;
+ kcout << "ADDRESSS: " << hex_number((UIntPtr)ptr_bit_set) << endl;
+ kcout << "SIZE: " << hex_number(ptr_bit_set[1]) << endl;
+ kcout << "FREE STATUS\r";
ptr_bit_set[0] = 0UL;
ptr_bit_set[1] = 0UL;
+ ptr_bit_set[2] = __BIGGEST_ALIGNMENT__;
return true;
}
diff --git a/dev/ZKA/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx b/dev/ZKA/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx
index 1bb54588..1be22e7d 100644
--- a/dev/ZKA/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx
@@ -63,12 +63,12 @@ EXTERN_C Kernel::Void hal_system_call_enter(Kernel::UIntPtr rcx, Kernel::UIntPtr
{
if (rcx <= (kSyscalls.Count() - 1))
{
- Kernel::kcout << "newoskrnl.exe: syscall: enter.\r";
+ kcout << "syscall: enter.\r";
if (kSyscalls[rcx].fHooked)
(kSyscalls[rcx].fProc)((Kernel::VoidPtr)rdx);
- Kernel::kcout << "newoskrnl.exe: syscall: exit.\r";
+ kcout << "syscall: exit.\r";
}
}
@@ -79,11 +79,11 @@ EXTERN_C Kernel::Void hal_kernel_call_enter(Kernel::UIntPtr rcx, Kernel::UIntPtr
{
if (rcx <= (kSyscalls.Count() - 1))
{
- Kernel::kcout << "newoskrnl.exe: kerncall: enter.\r";
+ kcout << "kerncall: enter.\r";
if (kKerncalls[rcx].fHooked)
(kKerncalls[rcx].fProc)((Kernel::VoidPtr)rdx);
- Kernel::kcout << "newoskrnl.exe: kerncall: exit.\r";
+ kcout << "kerncall: exit.\r";
}
}
diff --git a/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx b/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx
index b524b04c..f985deb7 100644
--- a/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx
@@ -191,7 +191,7 @@ namespace Kernel::HAL
cSMPInterrupt = 0;
kSMPCount = 0;
- kcout << "newoskrnl.exe: Probing MADT cores...\r";
+ kcout << "Probing MADT cores...\r";
UIntPtr madt_address = kMADTBlock->Address;
@@ -205,13 +205,13 @@ namespace Kernel::HAL
{
case 0x00: {
cSMPCores[index] = kMADTBlock->List[index].LAPIC.ProcessorID;
- kcout << "newoskrnl.exe: Core ID: " << number(cSMPCores[index]) << endl;
+ kcout << "Core ID: " << number(cSMPCores[index]) << endl;
++kSMPCount;
break;
}
case 0x05: {
madt_address = kMADTBlock->List[index].LAPIC_ADDRESS_OVERRIDE.Address;
- kcout << "newoskrnl.exe: Address: " << number(madt_address) << endl;
+ kcout << "Address: " << number(madt_address) << endl;
break;
}
}
@@ -219,7 +219,7 @@ namespace Kernel::HAL
++index;
}
- kcout << "newoskrnl.exe: # of cores: " << number(kSMPCount) << endl;
+ kcout << "# of cores: " << number(kSMPCount) << endl;
// Kernel is now SMP aware.
// That means that the scheduler is now available (on MP Kernels)
diff --git a/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx b/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
index 10916b06..79d9c097 100644
--- a/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
@@ -125,7 +125,7 @@ Kernel::Void hal_real_init(Kernel::Void) noexcept
if (kHandoverHeader->f_HardwareTables.f_MultiProcessingEnabled)
Kernel::HAL::mp_get_cores(kHandoverHeader->f_HardwareTables.f_VendorPtr);
- Kernel::kcout << "newoskrnl.exe: Creating filesystem and such.\r";
+ kcout << "Creating filesystem and such.\r";
auto fs = new Kernel::NewFilesystemMgr();
diff --git a/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx b/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx
index 889b8c39..7eaa5bbb 100644
--- a/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx
+++ b/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx
@@ -63,7 +63,7 @@ Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented)
{
if (ports_implemented)
{
- kcout << "newoskrnl.exe: Port is implemented by host.\r";
+ kcout << "Port is implemented by host.\r";
UInt8 ipm = (mem_ahci->Ports[ahci_index].Ssts >> 8) & 0x0F;
UInt8 det = mem_ahci->Ports[ahci_index].Ssts & 0x0F;
@@ -72,8 +72,8 @@ Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented)
det == cAhciPresent &&
ipm == cAhciIPMActive)
{
- kcout << "newoskrnl.exe: Found AHCI controller.\r";
- kcout << "newoskrnl.exe: Device is of SATA type.\r";
+ kcout << "Found AHCI controller.\r";
+ kcout << "Device is of SATA type.\r";
detected = true;
diff --git a/dev/ZKA/HALKit/AMD64/Storage/ATA-PIO.cxx b/dev/ZKA/HALKit/AMD64/Storage/ATA-PIO.cxx
index 052f8c64..bc1a1f22 100644
--- a/dev/ZKA/HALKit/AMD64/Storage/ATA-PIO.cxx
+++ b/dev/ZKA/HALKit/AMD64/Storage/ATA-PIO.cxx
@@ -68,7 +68,7 @@ Boolean drv_std_init(UInt16 Bus, UInt8 Drive, UInt16& OutBus, UInt8& OutMaster)
drv_std_select(IO);
- Kernel::kcout << "newoskrnl.exe: Initializing drive...\r";
+ kcout << "Initializing drive...\r";
ATAInit_Retry:
// Bus init, NEIN bit.
@@ -80,7 +80,7 @@ ATAInit_Retry:
if (statRdy & ATA_SR_ERR)
{
- Kernel::kcout << "newoskrnl.exe: Failing drive...\r";
+ kcout << "Failing drive...\r";
return false;
}
@@ -107,7 +107,7 @@ ATAInit_Retry:
OutMaster = (Bus == ATA_PRIMARY_IO) ? ATA_MASTER : ATA_SLAVE;
- Kernel::kcout << "newoskrnl.exe: Created IDE module.\r";
+ kcout << "Created IDE module.\r";
return true;
}
diff --git a/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx b/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx
index ee06c305..140c3370 100644
--- a/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx
+++ b/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx
@@ -92,7 +92,7 @@ Kernel::Void hal_real_init(Kernel::Void) noexcept
else
Kernel::HAL::mp_get_cores(nullptr);
- Kernel::kcout << "newoskrnl.exe: Creating filesystem and such.\r";
+ kcout << "Creating filesystem and such.\r";
auto fs = new Kernel::NewFilesystemMgr();
diff --git a/dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx b/dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx
index 97950a78..f1f6c718 100644
--- a/dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx
+++ b/dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx
@@ -53,13 +53,13 @@ namespace Kernel
/// @brief Enable flash memory at slot.
STATIC Void drv_enable_flash(Int32 arg)
{
- kcout << "newoskrnl.exe: Enabled FLSH hardware.\r";
+ kcout << "Enabled FLSH hardware.\r";
}
/// @brief Disable flash memory at slot.
STATIC Void drv_disable_flash(Int32 arg)
{
- kcout << "newoskrnl.exe: Disabled FLSH hardware.\r";
+ kcout << "Disabled FLSH hardware.\r";
}
} // namespace Kernel
diff --git a/dev/ZKA/HALKit/AXP/CoreSyscallHandlerDEC.cpp b/dev/ZKA/HALKit/AXP/CoreSyscallHandlerDEC.cpp
index 5f71380d..254e1ab6 100644
--- a/dev/ZKA/HALKit/AXP/CoreSyscallHandlerDEC.cpp
+++ b/dev/ZKA/HALKit/AXP/CoreSyscallHandlerDEC.cpp
@@ -14,11 +14,11 @@ EXTERN_C void rt_syscall_handle(Kernel::HAL::StackFrame* stack)
{
if (stack->Rcx <= (kSyscalls.Count() - 1))
{
- Kernel::kcout << "newoskrnl.exe: syscall: enter.\r";
+ kcout << "syscall: enter.\r";
if (kSyscalls[stack->Rcx].Leak().Leak().fHooked)
(kSyscalls[stack->Rcx].Leak().Leak().fProc)(stack);
- Kernel::kcout << "newoskrnl.exe: syscall: exit.\r";
+ kcout << "syscall: exit.\r";
}
}