Written using C and Assembly. GCC is used as C compiler, NASM is used as assembler.
Kernel uses Multiboot 2 specification and GRUB 2 as bootloader.
This kernel for now works only in CSM(compatibility support mode) since it uses deprecated VGA 80x25 text mode (because its easy to get up and running). Main branch has been tested on real hardware.
2. All available ram is identity mapped into kernel space (just like Linux does).
3. Kernel heap is based on Doug Lea's malloc for glibc, though is heavily simplified.
4. Since in x64 segmentation is deprecated, but identity segments are still required, GDT is set up to bare minimum.
//======================================================================================= // Start addr | Offset | End addr | Description //======================================================================================= // | | | // 0000000000000000 | 0 | 00007fffffffffff | user-space virtual memory //__________________|__________|__________________|______________________________________ // | | | // 0000800000000000 | +128 TB | ffff7fffffffffff | non-canonical virtual memory //__________________|__________|__________________|______________________________________ // | // | Kernel-space virtual memory //________________________________________________|______________________________________ // | | | // ffff800000000000 | -128 TB | ffff87ffffffffff | Kernel code // ffff888000000000 | -119.5TB | ffffc87fffffffff | Direct mapping of all physical memory // ffffc88000000000 | -55.5 TB | | Kernel heap //__________________|__________|__________________|______________________________________
What is implemented:
- identity segmentation
- basic irq handling, PIC set up
- multiboot info provided by bootloader parsing
- timer set up
- physical memory management
- virtual memory management
- basic atomic operations, spin lock support
- kernel heap (kmalloc, kmalloc_aligned, krealloc, kfree)
- vga text console
- synchronization primitives: spinlocks, mutexes, semaphores, conditional variables
- preemptive multithreading
- userspace (ring 3) threads
- initial support for syscalls (via "int 0x80" for x86-64)
- subset of posix signals
TBD:
- group threads to form processes, ring 0/3 <- currently working on this part
- parse elf files to run processes
- syscall interface and basic unix syscalls implementation
- modern graphics interface support to get rid of CSM
- interface for drivers
- simple hdd driver, virtual file system
- SMP(simultaneous multi-processing) support
- compile portable std lib for C for kernel
- port Doom :D
To build and run in QEMU:
- Clone git repository.
- Change
CROSS_COMPILE
prefix in Makefile to your toolchain prefix. - Run
make all
from root repository directory. build_output
folder now containssos.iso
file.- Run
make run
to run on QEMU emulator.
To make bootable flash drive, after step 4:
- Run
lsblk
and get name of your flashdrive (for examplesdb
) - Unmount all partitions of selected flashdrive with
sudo umount
(for examplesudo umount /dev/sdb1 /dev/sdb2 /dev/sdb3 /dev/sdb4
). - Copy iso image of kernel with
dd
(for examplesudo dd if=build_output/sos.iso of=/dev/sdb && sync
)