91 lines
2.4 KiB
Markdown
91 lines
2.4 KiB
Markdown
# NT-Lite -- an x86-64 kernel
|
||
|
||
Boots. Runs processes. Mimics Windows to some extent.
|
||
|
||
## 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 C and assembly.
|
||
|
||
## features
|
||
|
||
- UEFI bootloader
|
||
- physical memory manager
|
||
- virtual memory manager with kernel pool
|
||
- HAL (screen, keyboard, timer, disk, PCI, APIC)
|
||
- preemptive scheduler with priority levels
|
||
- processes and threads
|
||
- VFS
|
||
- drive-letter paths (`0:\apps\shell.exe`)
|
||
- INI-based boot and driver configuration
|
||
- partial Win32 layer (kernel32 and user32, far from finished but capable of running simple apps)
|
||
- 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.
|
||
|
||
## screenshots
|
||
|
||

|
||
|
||
## 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: As much as it will ever be.
|
||
|
||
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.
|