build.bat can create the image if missing, split the shell into native, posix and win32, clean up the build by moving executables into directories, the bootloader is no longer responsible to resolve drivers, fix ResolvePath, every process gets a copy of a module (dll), the child always inherits the cwd, fix function exports in posix, add unlink and exit to posix, add path translator to win32, first bugcheck.

This commit is contained in:
maksw committed 2026-05-13 09:24:16 +02:00
1 parent 0c7f461c6d
commit f80e66ecde
38 files changed
+1620 -462

No files matched your search

+14 -32
View File
@@ -558,8 +558,8 @@ EFI_STATUS EFIAPI UefiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable
} MODULE_LOAD_INFO;
MODULE_LOAD_INFO core[] = {
{ L"colonel.exe", "kernel.exe", NULL, KERNEL_VIRT_BASE },
{ L"hal.dll", "hal.dll", NULL, 0 /* Calculated dynamically */ },
{ L"system\\colonel.exe", "kernel.exe", NULL, KERNEL_VIRT_BASE },
{ L"system\\hal.dll", "hal.dll", NULL, 0 /* Calculated dynamically */ },
};
for (int i = 0; i < 2; i++) {
@@ -615,45 +615,27 @@ EFI_STATUS EFIAPI UefiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable
Print(L"5\n");
// Load driver .sys files.
// Load driver .sys files into raw buffers
for (int i = 0; i < ps.driverCount; i++) {
CHAR16 path[128];
UnicodeSPrint(path, sizeof(path), L"drivers\\%s", ps.drivers[i]);
UINTN imgSz;
UINT8* buf = LoadFile(path, &imgSz);
if (!buf) { Print(L"Driver not found: %s\n", ps.drivers[i]); continue; }
UINT32 stored = *(UINT32 *)(buf + *(UINT32 *)(buf + 0x3C) + 4 + 20 + 64);
UINT32 computed = ComputePeChecksum(buf, imgSz);
if (stored && computed != stored) {
Print(L"Checksum mismatch: %s\n", ps.drivers[i]);
FreePool(buf); continue;
if (!buf) {
Print(L"Driver not found: %s\n", ps.drivers[i]);
continue;
}
UINT32 peOff = *(UINT32 *)(buf + 0x3C);
UINT32 imgLen = *(UINT32 *)(buf + peOff + 4 + 20 + 56);
imgLen = (imgLen + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
EFI_PHYSICAL_ADDRESS phys;
EFI_STATUS status = LoadPeImage(buf, virtCursor, &phys);
if (EFI_ERROR(status)) {
Print(L"Driver PE load failed: %s\n", ps.drivers[i]);
FreePool(buf);
continue;
}
UINT64 virt = virtCursor;
for (UINT64 off = 0; off < imgLen; off += PAGE_SIZE)
MapPage(virt + off, phys + off, 0x03);
// Store file info for the kernel to process later
char name[32];
UnicodeStrToAsciiStrS(ps.drivers[i], name, 32);
AsciiStrCpyS(bi->Modules[bi->ModuleCount].Name, 32, name);
bi->Modules[bi->ModuleCount].VirtBase = virt;
bi->Modules[bi->ModuleCount].ImageSize = imgLen;
bi->ModuleCount++;
virtCursor = (virtCursor + imgLen + 0xFFFFF) & ~0xFFFFF;
FreePool(buf);
BOOT_MODULE* mod = &bi->Modules[bi->ModuleCount++];
AsciiStrCpyS(mod->Name, 32, name);
mod->PhysBase = (uintptr_t)buf; // Raw physical buffer from LoadFile
mod->ImageSize = (size_t)imgSz;
mod->VirtBase = 0; // Kernel will map this later
}
Print(L"6\n");