A hobby x86 monolithic OS written in C
This is an attempt of me to learn about osdev
- PS/2 keyboard driver
- ATA PIO mode
- FAT32 filesystem support
- basic VESA driver (i think)
- A GCC cross compiler. although a preinstalled GCC on linux will compile it just fine, the osdev wiki said we should use a cross compiler to avoid any unexpected errors.
- if you are lazy to install one, use
make all NO_CROSS_COMPILER=1
to compile using linux GCC (please do not report any errors if you use this option) - if you use a cross compiler then please check and correct the
CROSS_COMPILER_LOC
in the second line ofMakefile
- if you are lazy to install one, use
- nasm
- dosfstools
- grub (and xorriso to gen iso image)
- qemu
# build
chmod +x script/*.sh
make all
# run
./script/run.sh # or make run
# make iso
./script/geniso.sh
# editing the disk files
./script/mount-device.sh
cd mnt/
## do some stuffs here
./script/umount-device.sh # you also want to run this if you ever encountered errors like disk image is in use or whatever
# if you want to copy some files/dirs and dont want to run mount-device and then umount-device
./script/cpyfile.sh file/or/directory/in/somewhere ./mnt/some/DIRECTORY/in/the/disk
Files and directories in fsfiles/
will be automatically copied into the disk image after running make all
.
Note that scripts in script/
will need sudo privilege to setup loopback device for the hard disk image.
You can either make an iso ./script/geniso.sh
and burn it to an usb or use sudo dd if=disk.img of=/dev/sdX && sync
to burn the disk to an usb to run the OS. Note that ISO 9660 FS and usb driver are not implemented so the OS will perform filesystem commands on whatever partitions with FAT32 fs it found so just dont perform fs command and you will be fine.
Note
I am not responsible for any damage caused to your machine by the OS. Try this with your own risk!
- basic bootloader
- load the kernel
- 2-stage bootloader
- print some text in the kernel
- switch to GRUB
- load GDT in the kernel
- load IDT in the kernel
- handle exception interrupt
- handle interrupts send by PIC
- load kernel with ELF binary instead of flat binary
- support multiboot
- higher half kernel
- PS/2 keyboard driver
- get key scancode
- translate scancode to keycode
- LED indicating
- PIT
- generate ticks
- PC speaker (beep beep boop boop)
- memory manager
- physical memory manager: bitmap allocator
- virtual memory manager
- the heap: first-fit allocator
- ATA
- PIO mode
- CMOS and RTC: get datetime
- APCI
- APIC
- HPET
- PS/2 mouse driver
- VESA
- plot pixel
- render psf fonts
- USB
- sound
- im not gonna touch networking
- MBR support
- GPT support
- FAT32 fs
- detect
- list
- make dir
- remove dir
- touch files
- read
- write file
- move
- copy
- ext2 fs
- vfs
- TSS setup
- enter usermode
- syscall
- putchar
- current time
- read file
- write file
- process manager
- multitasking
- load and run ELF file
- ATA PIO mode initialization some time failed (very rare): address mark not found
print_debug
gives gliberrish result if put in many formats- processes not giving control back properly
Note that anything related to osdev are on the osdev wiki
- https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf
- http://www.osdever.net/bkerndev/Docs/gettingstarted.htm
- http://www.brokenthorn.com/Resources/OSDevIndex.html
- https://web.archive.org/web/20160313134414/http://www.jamesmolloy.co.uk/tutorial_html/index.html
- https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html
- https://www.gnu.org/software/grub/manual/multiboot/multiboot.html
- https://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/fatgen103.doc
- http://www.skyfree.org/linux/references/ELF_Format.pdf