TravorOS - Developing with Simplification
This is the first Operating System I created. It's written in two languages: C language and Assembly.
This project has been activated since December 15, 2017
Table of Contents
Write text to VGA
CPU Interrupt (IDT, ISRs, IRQs, etc.)
Read character from PS/2 Keyboard
Read string from PS/2 Keyboard
Virtual Memory (Paging, Frames, etc.)
Page Frame Allocation and De-allocation
Dynamic Memory Allocation (liballoc)
Get CPU Information
Real-Time Clock: So we can know when the movie starts
Kernel Stack Trace
Hard Disk Driver
Floppy Disk Driver
Graphical User Interface
This OS uses a 2-staged bootloader. In case the second stage is when we entered Protected Mode and calls kernel.
The first 512 bytes of my floppy image contains the Boot Sector which does a lot of stuff that Protected Mode cannot do. (e.g. Loading stuff from disk). Then it jumps to the second stage loaded at
0x7E00 (just after the boot sector).
This stage loads the GDT and enters Protected Mode, then it copies the kernel loaded by boot sector at
0x100000 (1 MB). At last jump!
The size of the kernel is always growing, but I can't always increase the sectors to load. As a solution. I decide to use GRUB. The kernel is stored as an ELF image (
kernel.img) in a CD which uses
ISO 9660 as its file system. GRUB also supports multiboot, so my Operating System can work together with others (Windows, Linux, etc.).
We entered protected mode which means we don't have access to BIOS functions. So, this kernel needs to re-implement those functions for controlling the hardware.
Now, I have re-implemented standard devices: screen and keyboard. In the further development. I am going to implement disk driver.
This Operating System uses both segmentation and paging to provide memory protection. In my Global Descriptor Table, I put 5 segment descriptors:
Code Segment for kernel: The segment where my kernel code belongs to
Data Segment for kernel: The segment where my kernel global variables belong to
Code Segment for user: Currently not using
Data Segment for user: Same as 4
I also enable paging. Now I intentionally maped the fourth page in the first page table to
read-only, so you can generate a Page Fault by executing entering
bsod in my OS's command line.
Page Frame Allocator
This kernel provides a Page Frame Allocator, so the memory management will be more convenient and I will be easier to approach multitasking.
As JamesM's Tutorial suggests, I will use a bitset to determine whether a frame is free or not.
1: Allocated 0: Free v v frame_bitset: 11110111110101111101111111 ^ get_free_frame()
Dynamic Memory Allocation
I have currently implemented a placement malloc without free because all variables used by kernel never need to be freed until powers off.
Heap Allocation ----------------------------------------------- Allocated | Memory | Free.......until the end of memory | -----------------------------------------------
Because I am lazy, I port a 3rd party memory allocator called
liballoc which only required few functions in my OS.
This project uses GNU Make to build. So, the way to build is to type
make, if any problems occur during the build, type
make dep before
make. Open an issue if still stuck.
If you are not using Linux or WSL (Windows Subsystem for Linux), you will need to download a cross compiler from here. Then modify