major restructuring, prepare for smp

This commit is contained in:
maksw committed 2026-05-28 18:53:37 +02:00
1 parent b3569a2b90
commit 6bff37746d
229 files changed
+1617 -1489

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
[kernel]
; bitmask: 1 = debug prints, 2 = self check
debug = 3
debug = 0
[init]
commandline = apps/shell_native.exe
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+16 -16
View File
@@ -17,9 +17,9 @@
#include <efilib.h>
#include <stdbool.h>
#include <intrin.h>
#include <boot_info.h>
#include <memory_map.h>
#include <ini_parser.h>
#include <ntlite/boot_info.h>
#include <ntlite/memory_map.h>
#include <common/ini_parser.h>
int _fltused = 0;
@@ -395,7 +395,7 @@ EFI_STATUS LoadPeImage(UINT8* rawFile, UINT64 virtDest, EFI_PHYSICAL_ADDRESS* ou
UINT8* ntHeaders = rawFile + peOff;
// Validate Signature
if (*(UINT32*)ntHeaders != 0x00004550) { Print(L"no\n"); return EFI_INVALID_PARAMETER; } // "PE\0\0"
if (*(UINT32*)ntHeaders != 0x00004550) { Print(L"Signature mismatch\n"); return EFI_INVALID_PARAMETER; } // "PE\0\0"
UINT16 sizeOfOptHeader = *(UINT16*)(ntHeaders + 20);
UINT16 numSections = *(UINT16*)(ntHeaders + 6);
@@ -581,7 +581,7 @@ EFI_STATUS EFIAPI UefiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable
return Status;
}
Print(L"1\n");
//Print(L"1\n");
// --- Parse boot.ini ---
UINTN sz;
@@ -594,7 +594,7 @@ EFI_STATUS EFIAPI UefiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable
FreePool(bootIniRaw);
}
Print(L"2\n");
//Print(L"2\n");
// --- Parse drivers/drivers.ini ---
UINT8* drvIniRaw = LoadFile(L"drivers\\drivers.ini", &sz);
@@ -605,7 +605,7 @@ EFI_STATUS EFIAPI UefiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable
FreePool(drvIniRaw);
}
Print(L"3\n");
//Print(L"3\n");
BOOT_INFO* bi = AllocateZeroPool(sizeof(BOOT_INFO));
bi->Magic = BOOT_INFO_MAGIC;
@@ -617,7 +617,7 @@ EFI_STATUS EFIAPI UefiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable
// Current mapping cursor for upper half.
UINT64 virtCursor = KERNEL_VIRT_BASE;
Print(L"4\n");
//Print(L"4\n");
// --- Load and validate PE images ---
typedef struct {
@@ -629,11 +629,11 @@ EFI_STATUS EFIAPI UefiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable
MODULE_LOAD_INFO core[] = {
{ L"system\\colonel.exe", "kernel.exe", NULL, KERNEL_VIRT_BASE },
{ L"system\\hal.dll", "hal.dll", NULL, 0 /* Calculated dynamically */ },
{ L"system\\hal.dll", "hal.dll", NULL, 0 /* Calculated dynamically */ },
};
for (int i = 0; i < 2; i++) {
Print(L"Loading %s...\n", core[i].path);
//Print(L"Loading %s...\n", core[i].path);
UINTN rawSize;
UINT8* rawBuf = LoadFile(core[i].path, &rawSize);
if (!rawBuf) {
@@ -683,7 +683,7 @@ EFI_STATUS EFIAPI UefiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable
while(true);
}
Print(L"5\n");
//Print(L"5\n");
// Load driver .sys files into raw buffers
for (int i = 0; i < ps.driverCount; i++) {
@@ -708,7 +708,7 @@ EFI_STATUS EFIAPI UefiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable
mod->VirtBase = 0; // Kernel will map this later
}
Print(L"6\n");
//Print(L"6\n");
// Query GOP FIRST, before the GetMemoryMap loop
EFI_GRAPHICS_OUTPUT_PROTOCOL* gop;
@@ -736,7 +736,7 @@ EFI_STATUS EFIAPI UefiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable
}
}
Print(L"7\n");
//Print(L"7\n");
// --- Map physical RAM as direct window AND identity map ---
UINTN mapSize = 0, descSz = 0, mapKey; UINT32 descVer;
@@ -835,7 +835,7 @@ EFI_STATUS EFIAPI UefiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable
Map4K(PHYS_MAP_BASE + phys, phys, 0x03); // Physical Window Map
}
Print(L"8\n");
//Print(L"8\n");
// --- Convert EFI memory map -> MEMORY_MAP ---
ConvertMemoryMap(&bi->MemoryMap);
@@ -880,12 +880,12 @@ EFI_STATUS EFIAPI UefiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable
}
// Print it out to verify the bootloader actually found it before launching the kernel
Print(L"Found RSDP at: 0x%llx\n", bi->RsdpPhysical);
//Print(L"Found RSDP at: 0x%llx\n", bi->RsdpPhysical);
bi->PhysicalMapBase = PHYS_MAP_BASE;
bi->Debug = (UINT32)ps.debug;
Print(L"9\n");
//Print(L"9\n");
// --- ExitBootServices ---
gBS->GetMemoryMap(&mapSize, NULL, &mapKey, &descSz, &descVer);
File renamed without changes.
File renamed without changes.
+53 -53
View File
@@ -1,53 +1,53 @@
// ini_parser.c - minimal [section] key=value parser
// Used by the bootloader to read boot.ini and drivers/drivers.ini.
// No heap; caller provides fixed-size output buffers.
#include <string.h>
#include <ini_parser.h>
static inline int IsWs(char c) { return c == ' ' || c == '\t' || c == '\r'; }
static char* TrimLeft(char* s) {
while (*s && IsWs(*s)) s++;
return s;
}
static void TrimRight(char* s) {
char* e = s + strlen(s);
while (e > s && IsWs(*(e-1))) *--e = '\0';
}
// Parse 'buf' (null-terminated) for [section] / key=value.
// Calls cb(section, key, value, userdata) for each key found.
void IniParse(char* buf, IniCallback cb, void* userdata) {
char section[64] = "";
char* line = buf;
while (*line) {
char* end = line;
while (*end && *end != '\n') end++;
char saved = *end;
*end = '\0';
char* p = TrimLeft(line);
if (*p == '[') {
p++;
char* close = strchr(p, ']');
if (close) { *close = '\0'; strncpy(section, p, 63); section[63] = '\0'; }
} else if (*p && *p != ';' && *p != '#') {
char* eq = strchr(p, '=');
if (eq) {
*eq = '\0';
char* key = p; TrimRight(key);
char* val = TrimLeft(eq + 1); TrimRight(val);
cb(section, key, val, userdata);
} else {
// Key with no value (e.g., a driver filename in drivers.ini).
TrimRight(p);
if (*p) cb(section, p, "", userdata);
}
}
*end = saved;
line = end + (*end ? 1 : 0);
}
}
// ini_parser.c - minimal [section] key=value parser
// Used by the bootloader to read boot.ini and drivers/drivers.ini.
// No heap; caller provides fixed-size output buffers.
#include <string.h>
#include <common/ini_parser.h>
static inline int IsWs(char c) { return c == ' ' || c == '\t' || c == '\r'; }
static char* TrimLeft(char* s) {
while (*s && IsWs(*s)) s++;
return s;
}
static void TrimRight(char* s) {
char* e = s + strlen(s);
while (e > s && IsWs(*(e-1))) *--e = '\0';
}
// Parse 'buf' (null-terminated) for [section] / key=value.
// Calls cb(section, key, value, userdata) for each key found.
void IniParse(char* buf, IniCallback cb, void* userdata) {
char section[64] = "";
char* line = buf;
while (*line) {
char* end = line;
while (*end && *end != '\n') end++;
char saved = *end;
*end = '\0';
char* p = TrimLeft(line);
if (*p == '[') {
p++;
char* close = strchr(p, ']');
if (close) { *close = '\0'; strncpy(section, p, 63); section[63] = '\0'; }
} else if (*p && *p != ';' && *p != '#') {
char* eq = strchr(p, '=');
if (eq) {
*eq = '\0';
char* key = p; TrimRight(key);
char* val = TrimLeft(eq + 1); TrimRight(val);
cb(section, key, val, userdata);
} else {
// Key with no value (e.g., a driver filename in drivers.ini).
TrimRight(p);
if (*p) cb(section, p, "", userdata);
}
}
*end = saved;
line = end + (*end ? 1 : 0);
}
}
View File
File renamed without changes.
+2 -2
View File
@@ -33,8 +33,8 @@
#include <stdbool.h>
#include <stdint.h>
#include "printf.h"
#include "syscall/sys_string.h"
#include <common/printf.h>
#include <ntlite/string_view.h>
// define this globally (e.g. gcc -DPRINTF_INCLUDE_CONFIG_H ...) to include the
@@ -1,9 +1,9 @@
#include <hal_api.h>
#include <ke_status.h>
#include <ke_debug.h>
KSTATUS DriverEntry(const HAL_API* hal) {
(void)hal;
DbgPrint("Test runtime driver\n");
return STATUS_SUCCESS;
}
#include <ntlite/ddi/hal_api.h>
#include <ntlite/status.h>
#include <kernel/ke_debug.h>
KSTATUS DriverEntry(const HAL_API* hal) {
(void)hal;
DbgPrint("Test runtime driver\n");
return STATUS_SUCCESS;
}
@@ -40,15 +40,15 @@
#include <stddef.h>
#include <stdbool.h>
#include <string.h>
#include <io_driver.h>
#include <hal_api.h>
#include <io_file.h>
#include <mm_virt.h>
#include <ke_debug.h>
#include <ke_irp.h>
#include <ke_semaphore.h>
#include <ke_thread.h>
#include <ke_sched.h>
#include <ntlite/ddi/io_driver.h>
#include <ntlite/ddi/hal_api.h>
#include <kernel/io_file.h>
#include <kernel/mm_virt.h>
#include <kernel/ke_debug.h>
#include <kernel/ke_irp.h>
#include <kernel/ke_semaphore.h>
#include <kernel/ke_thread.h>
#include <kernel/ke_sched.h>
// ---------------------------------------------------------------------------
// On-disk structures
File renamed without changes.
@@ -4,7 +4,7 @@
#include <stdint.h>
#include <stddef.h>
#include <ke_debug.h>
#include <kernel/ke_debug.h>
#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN 1234
File renamed without changes.
@@ -1,10 +1,10 @@
# Add these lwIP 2.2.1 files to the lwip.sys driver build.
# Include directories required:
# code/drivers/lwip/include
# code/drivers/net/lwip/include
# code/third_party/lwip/src/include
# Port glue
drivers/lwip/lwip_sys_arch.c
drivers/lwip/lwip_stack.c
drivers/net/lwip/lwip_sys_arch.c
drivers/net/lwip/lwip_stack.c
# lwIP core
third_party/lwip/src/core/init.c
@@ -5,16 +5,16 @@
#include <stdbool.h>
#include <string.h>
#include <hal_api.h>
#include <ke_status.h>
#include <ke_debug.h>
#include <ke_sched.h>
#include <ke_settings.h>
#include <ke_semaphore.h>
#include <ob_object.h>
#include <mm_virt.h>
#include <net_device.h>
#include <net_stack.h>
#include <ntlite/ddi/hal_api.h>
#include <ntlite/status.h>
#include <kernel/ke_debug.h>
#include <kernel/ke_sched.h>
#include <kernel/ke_settings.h>
#include <kernel/ke_semaphore.h>
#include <kernel/ob_object.h>
#include <kernel/mm_virt.h>
#include <ntlite/ddi/net_device.h>
#include <ntlite/ddi/net_stack.h>
#include <lwip/init.h>
#include <lwip/tcpip.h>
Loaded 100 of 229 files, more files were not shown because too many files have changed in this diff. Show more