redo boot around an explicit system volume and fixed kernel/HAL images, redo volumes and filesystem paths around capabilities instead of drive numbers and kernel CWD state, add a capability/security model with derived and revocable handles and security contexts, add port IPC and rssrv to manage the userspace resource namespace and publish the system volume, move process, dll and path loading to userspace and add process builder syscalls, init now supervises rssrv and the session process, redo the syscall ABI around request structs and four arguments, add a volume manager and proper partition arrival/removal handling so FAT and NTFS mount dynamically, clean up the HAL/DDK boundary so drivers don't depend on HAL internals, save fpu state properly now, the serial driver doesn't hang on a missing port, fix AHCI startup races, fix timeout accounting, fix shared mmap writeback, more smoke tests

This commit is contained in:
maksw committed 2026-08-20 12:33:17 +02:00
1 parent 4add6789ba
commit f882d339fb
232 files changed
+20934 -8898

No files matched your search

+99
View File
@@ -0,0 +1,99 @@
// Shared parser for the canonical structural boot-volume selector grammar.
#include <common/boot_volume_selector.h>
#include <string.h>
// Converts one hexadecimal character without accepting non-hexadecimal text.
static bool BootVolumeHexDigit(char c, uint8_t* digitOut) {
if (!digitOut)
return false;
if (c >= '0' && c <= '9') {
*digitOut = (uint8_t)(c - '0');
return true;
}
if (c >= 'a' && c <= 'f') {
*digitOut = (uint8_t)(10 + c - 'a');
return true;
}
if (c >= 'A' && c <= 'F') {
*digitOut = (uint8_t)(10 + c - 'A');
return true;
}
return false;
}
// Parses an exact hexadecimal integer span into a 32-bit value.
static bool BootVolumeParseHex32(const char* text, size_t length, uint32_t* valueOut) {
if (!text || !valueOut || length == 0 || length > 8)
return false;
uint32_t value = 0;
for (size_t i = 0; i < length; ++i) {
uint8_t digit = 0;
if (!BootVolumeHexDigit(text[i], &digit))
return false;
value = (value << 4) | digit;
}
*valueOut = value;
return true;
}
// Parses one exact GUID hexadecimal group.
static bool BootVolumeParseGuidGroup(const char* text, size_t length, uint32_t* valueOut) {
return BootVolumeParseHex32(text, length, valueOut);
}
// Parses a canonical 8-4-4-4-12 GUID into EFI/GPT field layout.
static bool BootVolumeParseGuid(const char* text, size_t length, BOOT_VOLUME_GUID* guidOut) {
if (!text || !guidOut || length != 36 ||
text[8] != '-' || text[13] != '-' || text[18] != '-' || text[23] != '-') {
return false;
}
BOOT_VOLUME_GUID guid = {0};
uint32_t value = 0;
if (!BootVolumeParseGuidGroup(text, 8, &guid.Data1) ||
!BootVolumeParseGuidGroup(text + 9, 4, &value)) {
return false;
}
guid.Data2 = (uint16_t)value;
if (!BootVolumeParseGuidGroup(text + 14, 4, &value))
return false;
guid.Data3 = (uint16_t)value;
const size_t byteOffsets[8] = {19, 21, 24, 26, 28, 30, 32, 34};
for (size_t i = 0; i < 8; ++i) {
if (!BootVolumeParseGuidGroup(text + byteOffsets[i], 2, &value))
return false;
guid.Data4[i] = (uint8_t)value;
}
*guidOut = guid;
return true;
}
// Parses one canonical structural system-volume selector.
bool BootVolumeSelectorParse(const char* text, size_t length, BOOT_VOLUME_SELECTOR* selectorOut) {
if (!text || !selectorOut)
return false;
BOOT_VOLUME_SELECTOR selector = {0};
if (length == 14 && memcmp(text, "mbr/", 4) == 0 && text[12] == '/' &&
BootVolumeParseHex32(text + 4, 8, &selector.Identity.Mbr.DiskSignature) &&
text[13] >= '1' && text[13] <= '4') {
selector.Kind = BootVolumeSelectorMbr;
selector.Identity.Mbr.PartitionNumber = (uint32_t)(text[13] - '0');
*selectorOut = selector;
return true;
}
if (length == 40 && memcmp(text, "gpt/", 4) == 0 &&
BootVolumeParseGuid(text + 4, 36, &selector.Identity.Gpt.PartitionGuid)) {
selector.Kind = BootVolumeSelectorGpt;
*selectorOut = selector;
return true;
}
return false;
}
@@ -0,0 +1,36 @@
// Shared structural boot-volume selector declarations.
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
typedef enum BOOT_VOLUME_SELECTOR_KIND {
BootVolumeSelectorInvalid = 0,
BootVolumeSelectorMbr,
BootVolumeSelectorGpt,
} BOOT_VOLUME_SELECTOR_KIND;
typedef struct BOOT_VOLUME_GUID {
uint32_t Data1;
uint16_t Data2;
uint16_t Data3;
uint8_t Data4[8];
} BOOT_VOLUME_GUID;
typedef struct BOOT_VOLUME_SELECTOR {
BOOT_VOLUME_SELECTOR_KIND Kind;
union {
struct {
uint32_t DiskSignature;
uint32_t PartitionNumber;
} Mbr;
struct {
BOOT_VOLUME_GUID PartitionGuid;
} Gpt;
} Identity;
} BOOT_VOLUME_SELECTOR;
// Parses one canonical structural system-volume selector.
bool BootVolumeSelectorParse(const char* text, size_t length, BOOT_VOLUME_SELECTOR* selectorOut);
-6
View File
@@ -1,6 +0,0 @@
// Shared INI parser declarations for boot and kernel configuration readers.
#pragma once
typedef void (*IniCallback)(const char* section, const char* key,
const char* value, void* userdata);
void IniParse(char* buf, IniCallback cb, void* userdata);
-55
View File
@@ -1,55 +0,0 @@
// Minimal INI parser. This file accepts the small configuration dialect used by boot.ini and drivers.ini.
#include <string.h>
#include <common/ini_parser.h>
// Checks whether ws.
static inline int IsWs(char c) { return c == ' ' || c == '\t' || c == '\r'; }
// Implements the trim Left operation.
static char* TrimLeft(char* s) {
while (*s && IsWs(*s)) s++;
return s;
}
// Implements the trim Right operation.
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);
}
}
+21 -9
View File
@@ -20,15 +20,15 @@ char* strncpy(char* dest, const char* src, size_t n) {
return dest;
}
char *strstr(const char *haystack, const char *needle) {
char* strstr(const char* haystack, const char* needle) {
// An empty needle matches the beginning of haystack
if (!*needle) {
return (char *)haystack;
return (char*)haystack;
}
for (; *haystack != '\0'; haystack++) {
const char *h = haystack;
const char *n = needle;
const char* h = haystack;
const char* n = needle;
// Match as many characters as possible
while (*h != '\0' && *n != '\0' && *h == *n) {
@@ -38,7 +38,7 @@ char *strstr(const char *haystack, const char *needle) {
// If we reached the end of needle, we found a match
if (*n == '\0') {
return (char *)haystack;
return (char*)haystack;
}
}
@@ -83,13 +83,13 @@ int strcmp(const char* s1, const char* s2) {
}
// Implements the strncmp operation.
int strncmp(const char *s1, const char *s2, size_t n) {
int strncmp(const char* s1, const char* s2, size_t n) {
while (n && *s1 && (*s1 == *s2)) {
s1++;
s2++;
n--;
}
return n == 0 ? 0 : *(unsigned char *)s1 - *(unsigned char *)s2;
return n == 0 ? 0 : *(unsigned char*)s1 - *(unsigned char*)s2;
}
// Implements the stricmp operation.
@@ -109,7 +109,7 @@ size_t strlen(const char* s) {
}
// Implements the strnlen operation.
size_t strnlen(const char *s, size_t maxlen) {
size_t strnlen(const char* s, size_t maxlen) {
size_t len;
for (len = 0; len < maxlen; len++) {
if (s[len] == '\0') {
@@ -122,7 +122,7 @@ size_t strnlen(const char *s, size_t maxlen) {
// Implements the strchr operation.
char* strchr(const char* s, int c) {
while (*s) {
if (*s == (char)c) return (char *)s;
if (*s == (char)c) return (char*)s;
s++;
}
return NULL;
@@ -138,6 +138,18 @@ char* strrchr(const char* s, int c) {
return (char*)last;
}
void *memchr(const void *s, int c, size_t n) {
const unsigned char *p = s;
unsigned char ch = (unsigned char)c;
while (n--) {
if (*p == ch) {
return (void *)p;
}
p++;
}
return NULL;
}
// Implements the memset operation.
void* memset(void* dest, int c, size_t n) {
unsigned char* d = (unsigned char*)dest;