add CatchAllDebugBucket as a syscall for debugging, add a basic network card plus ethernet driver (wip)

This commit is contained in:
maksw committed 2026-05-20 22:21:53 +02:00
1 parent bf34d63ea3
commit 0d7f71b693
22 files changed
+2248 -25

No files matched your search

+64 -5
View File
@@ -13,6 +13,7 @@
#include <ke_irq.h>
#include <ke_dpc.h>
#include <ke_syscall.h>
#include <ethernet.h>
#include <ke_debug.h>
#include <ke_util.h>
#include <ldr_image.h>
@@ -401,10 +402,15 @@ void SystemInitThread(void* arg) {
args->hal->Screen.Clear(0x000000);
// Print memory status now that the system is fully alive
DbgPrint("Memory Status:\n");
DbgPrint(" -> Free (PMM): %.2f MB\n", (float)MmFreeFrameCount() * PAGE_SIZE / (1024.0f * 1024.0f));
DbgPrint(" -> Kernel Pool: %.2f MB\n", (float)MmGetKernelPoolUsage() / (1024.0f * 1024.0f));
DbgPrint(" -> User Heap: %.2f MB\n", (float)MmGetUserHeapUsage() / (1024.0f * 1024.0f));
DbgPrint(
"Memory Status:\n"
" -> Free (PMM): %.2f MB\n"
" -> Kernel Pool: %.2f MB\n"
" -> User Heap: %.2f MB\n",
(float)MmFreeFrameCount() * PAGE_SIZE / (1024.0f * 1024.0f),
(float)MmGetKernelPoolUsage() / (1024.0f * 1024.0f),
(float)MmGetUserHeapUsage() / (1024.0f * 1024.0f)
);
if (args->bootInfo->Debug & 2)
KiRunKernelSelfTests(args->hal);
@@ -432,6 +438,59 @@ void SystemInitThread(void* arg) {
MmFreePool(args);
}
// for debug! for science!
uint64_t KeCatchAllDebugBucket(uint64_t a0, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5) {
if (a0 == 0) {
DbgPrint(
"Memory Status:\n"
" -> Free (PMM): %.2f MB\n"
" -> Kernel Pool: %.2f MB\n"
" -> User Heap: %.2f MB\n",
(float)MmFreeFrameCount() * PAGE_SIZE / (1024.0f * 1024.0f),
(float)MmGetKernelPoolUsage() / (1024.0f * 1024.0f),
(float)MmGetUserHeapUsage() / (1024.0f * 1024.0f)
);
return 0;
}
if (a0 == 1) {
uint32_t deviceIndex = (uint32_t)a1;
uint32_t targetIp;
// Usage from shell debug mode:
// 1,0,10,0,2,2 ping 10.0.2.2 on eth0
// 1,0,167772674,0,0,0 ping packed IPv4 0x0A000202 on eth0
// 1,0,0,0,0,0 ping the default QEMU gateway 10.0.2.2
if (a2 == 0 && a3 == 0 && a4 == 0 && a5 == 0) {
targetIp = NET_IPV4_ADDR(10, 0, 2, 2);
} else if (a3 == 0 && a4 == 0 && a5 == 0 && a2 > 0xFFu) {
targetIp = (uint32_t)a2;
} else {
if (a2 > 0xFFu || a3 > 0xFFu || a4 > 0xFFu || a5 > 0xFFu) {
DbgPrint("DebugBucket[1]: invalid IPv4 octet(s): %llu.%llu.%llu.%llu\n",
a2, a3, a4, a5);
return STATUS_INVALID_PARAMETER;
}
targetIp = NET_IPV4_ADDR((uint8_t)a2, (uint8_t)a3,
(uint8_t)a4, (uint8_t)a5);
}
DbgPrint("DebugBucket[1]: ping eth%u %u.%u.%u.%u\n",
deviceIndex,
(targetIp >> 24) & 0xFFu,
(targetIp >> 16) & 0xFFu,
(targetIp >> 8) & 0xFFu,
targetIp & 0xFFu);
KSTATUS status = NetPingIpv4(deviceIndex, targetIp);
DbgPrint("DebugBucket[1]: NetPingIpv4 returned 0x%X\n", status);
return status;
}
DbgPrint("DebugBucket: unknown command %llu\n", a0);
return STATUS_INVALID_PARAMETER;
}
// ---------------------------------------------------------------------------
// Main Kernel Entry
// ---------------------------------------------------------------------------
@@ -495,7 +554,7 @@ extern void KernelMain(BOOT_INFO* bootInfo) {
HalRegisterScheduler(KeSchedulerTick);
KeSyscallSetHal(hal);
KeSyscallInit(hal, KeCatchAllDebugBucket);
//
// Dynamic Linking & Driver Execution