Thursday, June 8, 2017

COMBOOT serial boot loader

Contrary to what you might believe from the scarcity of updates on my blog, I have been avidly working on my operating system. I added a bytecode interpreter/VM to it so it will host completely sandboxed executables. But, I will write a separate blog post on that subject later.

What I want to write about now is my COMBOOT serial boot loader. I have a physical laptop lying around that I often use to test whether my OS still runs on physical hardware. However, the booting process is tedious: I use pxelinux to serve my kernel over PXE. First of all, the laptop's PXE ROM is slow,  and second, there is a weird bug in pxelinux regarding sizes of multiboot modules.

I have a small holiday right now, so I decided to write a replacement bootloader that should be able to load my kernel over the serial port. To my knowledge, there isn't a boot loader available that does this. The source code of the COMBOOT project can be found on my GitHub page:

Below you can see a short video of it in action:

As well as a screenshot of the bootsrv Windows application doing its thing:

Monday, May 16, 2016

ttOS R0.3

I decided that it's time for the R0.3 release. I don't feel like writing a very lengthy post today, but I want to highlight some things.

  • Multitasking
  • Logging
  • BASIC interpreter

Saturday, May 7, 2016

vhdutil - attaching/detaching VHD files using the command line

I just published a small tool to my Github account. While developing ttOS, I have been struggling to find a virtual hard disk format that:

  1. Is compatible with most x86 virtual machines
  2. Can be written to a device (USB stick, cloned to a real HDD, etc.)
  3. Is mountable in Windows, so I can include it in my build process
Turns out the best fit is the "Virtual Hard Disk" format. In Windows, it's possible to mount VHD files using the management console. But I don't want to go through all the hassle to mount it with a few mouse clicks, build the kernel, unmount it with more mouse clicks, before I can actually test it.

So I made vhdutil, which is available here:

After building, you can simply use these commands:

vhdutil.exe attach <file> to mount a VHD file.
vhdutil.exe detach <file> to unmount a VHD file.

It's licensed under the MIT license, so go right ahead and do whatever you want.

Wednesday, April 27, 2016

ttOS R0.2

The first blogpost since a month! And I have a lot to show (I think).

First, a quick round-up of the latest modifications:

  • Added views system
  • Implemented kernel service model
  • Heap locking
  • Safety checks & documentation
  • Added version numbering
Details after the break!

Tuesday, March 22, 2016

Temporarily switching to real mode to use BIOS functions

Well, I finally did it. It took me exactly two days (or 16 hours) to write a piece of code that would allow me to temporarily drop back to real mode, call some BIOS interrupts, and then go back to protected mode again. The fact that I use MSVC++ and the COFF object file format didn't actually help me, as I had to be quite inventive to work around the limitations of the COFF format.

Anyway. I have now used this technique to upgrade my console from 80x25 characters to a whopping 80x50! So one might wonder if this was worth all the time. I guess so, since I can now also switch to graphics mode, and get ACPI information, et cetera.

Look at this huge console! It seems like the VGA cursor suddenly stopped working though. I'm thinking of simply implementing my own using the underscore character, and the PIT timer.

Thursday, March 17, 2016

Syntactic sugar with C++ and more...

So in my previous blogpost I briefly spoke about switching to C++ from pure C. I really like it so far. Since the majority of code I write at work is C#, I've become very accustomed to object oriented thinking.

Currently, the driver model, device model, interrupt handling, terminal, and more have been migrated to C++. Also, I implemented a LinkedList<T> class.

Sunday, February 28, 2016

OS: Switch to C++

So yeah, it has been a while since the last update. I don't feel like writing a lengthy post like last time, so I'm just going to list the progress since the last post (on January 27th!).

  • I switched from C to C++. While writing my device driver code I noticed I was thinking object-oriented, but I could not actually code object-oriented. The source has not been fully migrated yet, as there are (of course) some problems with this. I also discovered I do not know much about the internals of C++, so it's a nice learning experience.
  • Dropped floppy support. Damn those things and damn FDCs. 
  • Added hard disk support by PIO ATA. Maybe I will switch to DMA mode some day, but for now PIO is good enough.
  • Dropped FAT12 support and switched to FAT16. Since I dropped floppy support and switching to hard disks, I did not see the point of such small partitions, and FAT12 and FAT16 are quite similar.
  • Added a VFS (Virtual File System). It's now possible to open files, print directory listings, etc. All independent of the underlying file system of course :).
  • Preliminary kernel API using soft interrupts (0x80). Had a fight with interrupt handling while in a kernel API call, only had to enable interrupts using STI... :) 
  • PCI enumeration code. Although it seems like it does not really enumerate everything, it misses the NE2000 ethernet card in Bochs. The enumeration doesn't do anything other than print it on screen yet. 
  • Various bugfixes & improvements like extending the heap stats structure.
I'm trying to implement a LinkedList<T> class. It's not exactly going according to plan...