At one point I was crazy about creating and studying alternative operating systems. While I still find OSDev fascinating, I have moved onto other interests. This page contains links and notes from my previous studies. I also have a notebook filled with notes that I probably might maybe scan or type up one day. As a point of background, my first programming job was to convert an existing RTOS system for a custom digital board from Cosmac 1802 assembly to C and 6809 assembly. It was extremely difficult for me, but I found that I loved every moment of it. That project was of course much simpler than a general-purpose OS targeting the x86, but it stoked the embers of interest in me, and I have been fascinated with OSDev ever since.
I’ve studied most of these deeply and found them incredibly instructional.
These are not always current, but much can be learned from them all.
Interestingly, there are not that many books on developing your own operating systems. I’ve read most of those that deal with the topic directly, and some of those that touch on it only tangentially. Below are the books that I found particularly useful, relevant, and/or interesting:
I started down the path of writing an OS, aptly named FogOS written in C++. Below are some of the notes that I created (well, those I’ve been able to find).
Address Size Description --------- --------- --------------------------------- 0000 0000 1 KB Real-mode interrupt vector table 0000 0400 256 bytes ROM-BIOS data 0000 0500 62.75 KB 0001 0000 256 KB miscellaneous data 0005 0000 64 KB Kernel stack at startup 0006 0000 512 bytes Kernel IDT 0006 0200 64 KB Kernel TSS's 0007 0200 512 bytes GDT 0007 0400 63 KB 0008 0000 64 KB Kernel read-only data 0009 0000 64 KB Kernel heap 000a 0000 128 KB Video memory 000c 0000 64 KB Kernel ES 000d 0000 128 KB 000f 0000 64 KB ROM-BIOS -- 1MB -- 0010 0000 64 KB Kernel code 0010 FFF0 Max end of kernel (65,520 bytes) 0050 0000 4 MB Stack of physical memory pages 008F F000 4 KB Page table staging area 0090 0000 4 KB Kernel page directory 0090 1000 ??? Kernel page tables ???? ???? 00f0 0000 1 MB Low DMA area -- 16MB -- 0100 0000 Unlimited Available to applications
I’ve left some BIOS stuff as I found it.
My boot loader loads my kernel at 1MB physical. Given the 16-bit real-mode
nature of the boot code, it can’t load anything beyond 1MB+65,520, so for
the time being my kernel is limited to 65,520 bytes in size. Currently
it’s at 36,864 bytes. I know that one day, in the not-too-distant future,
I’ll have to do something about this. Maybe load it lower and then let it
move itself? Or break the kernel up into two files: a small one that the
boot loader loads, and that then loads the full kernel. I don’t know.
Some of these areas that I’ve reserved might not make sense. I pretty much
drew up this map before I know what I was doing (ha! I still don’t!) and
so I made room for things like TSS’s (plural) but I really won’t know what
I’ll need there until I get to processes and task switching.
I don’t do any relocations. My kernel is linked to load at 1MB and the
boot loader loads it directly there. Every time someone talks about
relocations I wonder what I’m missing. Looking forward to finding out :-)
My ideas for a microkernel. Looking back on FogOS I realize that the kernel was less interesting than the HAL. I spent a lot of time thinking about the HAL and it’s base abstractions. I actually went down the path of implementing it based on the following image:
You’ll notice that I have a crypto service all the way down in the kernel. My thinking at the time was that I could gather interesting entropy at the kernel level. I recall reading some papers about this, but their titles have long since faded. Anyway, I added at least one hook for the entropy gathering and planned for more.
Some bits of the implementation of the image above eventually booted!
And then after adding the HAL, it was still able to boot!
… and that is where I left it.
One day I shall return.