KernelMain reports more details about memory usage, LdrResolveImports catches kernel32, user32, ole32 and winmm and redirects them to win32.
This commit is contained in:
1 parent
129be91e15
commit
c13dd99150
7 files changed
+116
-1190
No files matched your search
@@ -0,0 +1,86 @@
|
||||
# an x86-64 kernel
|
||||
|
||||
boots. runs processes. doesn't crash (usually).
|
||||
|
||||
## what is it?
|
||||
|
||||
a 64-bit operating system kernel written from scratch.
|
||||
UEFI bootloader, physical and virtual memory managers, preemptive scheduler, HAL, VFS, PE loader, partial Win32 layer.
|
||||
it boots into a shell.
|
||||
~20k lines of code.
|
||||
|
||||
## features
|
||||
|
||||
- UEFI bootloader with PE loading and base relocation
|
||||
- physical memory manager (frame stack, O(1) alloc/free)
|
||||
- virtual memory manager with kernel pool
|
||||
- HAL (screen, keyboard, timer, disk, PCI, APIC)
|
||||
- preemptive scheduler with priority levels
|
||||
- processes and threads
|
||||
- VFS with FAT32 driver (read-only)
|
||||
- drive-letter paths (`0:\apps\shell.exe`)
|
||||
- INI-based boot and driver configuration
|
||||
- partial Win32 layer (kernel32 and user32, far from finished)
|
||||
- PE import resolution and dynamic driver loading
|
||||
|
||||
## how 2 build
|
||||
|
||||
* open vs x64 build tools
|
||||
* cd into this directory
|
||||
* `build.bat`
|
||||
* open `run.bat`/`rund.bat`
|
||||
* replace `\\.\PhysicalDrive7` with your thumbdrive partition
|
||||
* `run.bat`/`rund.bat`
|
||||
* enjoy
|
||||
|
||||
## driver model
|
||||
|
||||
drivers are PE32+ `.sys` files with an entry point preferably named DriverEntry accepting a constant pointer to HAL_API.
|
||||
|
||||
drivers to be loaded have their path stored in `drivers.ini`, split into essential for boot (loaded by bootloader) and not required for boot (loaded by kernel).
|
||||
|
||||
a disk driver fills in a `DISK_DRIVER` vtable and calls `IoRegisterDisk(index, &driver)`.
|
||||
a filesystem driver fills in an `IO_FILESYSTEM` vtable and calls `IoRegisterFilesystem(index, &fs, &vol)`.
|
||||
|
||||
## how it boots
|
||||
|
||||
1. UEFI loads `boot.ini`, reads `drivers.ini`
|
||||
2. bootloader maps kernel, HAL, and boot drivers into the upper half
|
||||
3. direct physical window at `0xFFFF880000000000`
|
||||
4. jumps to `KernelMain`
|
||||
5. PMM, VMM, GDT, IDT, HAL, IRQs, scheduler
|
||||
6. loads runtime drivers from disk
|
||||
7. launches `shell.exe`
|
||||
|
||||
## paths
|
||||
|
||||
```
|
||||
"apps\shell.exe" -> drive 0
|
||||
"0:\apps\shell.exe" -> drive 0
|
||||
"2:\data\config.ini" -> drive 2
|
||||
```
|
||||
|
||||
drives 0–7. a drive only works if a filesystem registered on it.
|
||||
|
||||
## faq
|
||||
|
||||
Q: Why?
|
||||
A: Why not.
|
||||
|
||||
Q: Does it run Doom?
|
||||
A: Not yet.
|
||||
|
||||
Q: Is the Win32 layer real?
|
||||
A: Real enough to load binaries that expect it. Not real enough to run Notepad.
|
||||
|
||||
Q: Is the scheduler preemptive?
|
||||
A: Yes.
|
||||
|
||||
Q: Will it corrupt my data?
|
||||
A: How would it? It's read-only.
|
||||
|
||||
Q: Is this finished?
|
||||
A: Not in the slightest.
|
||||
|
||||
Q: Can I use this in production?
|
||||
A: Don't.
|
||||
Reference in new issue
Block a user