Chatomari/SMILE, my old toy OS project

Created 19 May Modified 9 Aug

Kids are stupid, and I surely was.
Back in high school, some part of my underdeveloped brain thought it would have been cool to make my life miserable and learn C++ by writing my own operating system.
Because, sure. Why not?

Impressively, it was not a failure, and it forced me to improve my English quick, as it is not like there were many resources about OsDev in Italian.
I don’t have physical access to the source code. It is still inside the ancient IDE hard drive of the PC I used back in the day.
And even so, it would be a mess to navigate; you know, old, oldold & new folders nested in an endless tree, as this all predates any understanding of mine about what code revisioning was.
But I have some surviving screenshots as a clear display of my troubled years.

Please, notice that most of them had to be rescaled, as the old textual VGA modes had resolutions which were unlike the aspect ratio of common displays.

Smile (V2)

My very first experiments were never made public, so those are probably gone for good. These are the very first screenshot I was able to find.

Loading drivers & hardware checks

Its very limited TUI windows

This version run in 32bit protected mode.
It had a very rudimentary system to dynamically load drivers (which were bundled in its image), and supported basic hardware, like the PIC, PS/2 keyboard & mouse, PC speaker, VGA and VESA modes.
It also had support for an old dot matrix printer connected via parallel port.

Smile (V3)

V3 was largely derivative from V2, and was mostly me experimenting with graphical modes, text rendering and other edgy effect. It also introduced a first “usable” command line interface.

The OS loading... and meeting and expected exceptions

The command line once loaded in

Smile Boot Loader (V1)

A little after Smile V3, I decided that I had enough about my lack of a proper bootloader… so I wrote one. Mostly.
I took the code of a different project and basically rewrote most, but it was very helpful to bootstrap from a piece of software already working.
I am quite proud of this one, as it contains one of the very first pieces of code written by my little brother while I was forcing him to learn C++ with me 1 😁.

The bootloader worked in 16bit real mode, It had:

  • Support for FAT12 and FAT16 on top of BIOS interrupt driver access
  • customizable bitmap fonts loaded at startup. Yeah, some of my typographic choices were quite questionable I guess…
  • a scripting language also available before booting, a bit like GRUB exposing the same functionalities of the selectable profiles
  • dumping files, fs navigation etc…
  • handling multiple nested options in the menu
  • some resident service which could be called back from the loaded kernel, offering some services even after the loader finished its job
  • setting up a video mode

For this one I was able to find files.
They are not images ready to use, and they require ancient windows to prepare a floppy… but I mean if anyone is crazy enough they should be working.

  • the older v0.89. There is some really cringe content inside, but hey not gonna change that.
  • a patch to jump to v1.27. One just has to replace the file with the same name from the floppy.

I am 90% confident this was not the final version for SBL, as I recall a v1.45, but that was probably never released to the public.

Smile (V4)

Smile V4 was a total rewrite of my kernel and OS. Now that I had a decent bootloader I was able to offload there a lot of code used by the early boot stages, and this prompted me to do everything from scratch, ditching the old compiler and build system I was using.

This is also as far as I ever got with a home-brew OS in terms of features:

  • Basic support for SMP, basically multicore support.
  • Runtime hot-reloading of drivers.
  • Unreal mode2 bridge. Basically the kernel had a syscall which could go back to unreal mode to perform tasks needing BIOS interrupts and jump again to protected mode.
  • A very basic PCI stub capable of seeing devices on the bus.
  • Multiple virtual consoles, each running one process at a time, but that could be suspended while switching. Virtual pre-emptive scheduler based on the same method to switch context.
  • Support for serial and printers (well just my own) via parallel port.
  • Loader for executable files (not elf)

The initial console where drivers and background applications were being loaded.

The error console

The debug console

An application loaded and running in one of the consoles

Smile Boot Loader (V2)

This is the very last tail of my osdev journey. It was in the transition period as I started university, and with very little time spent back home.
The new code base of Smile 4 so was much better compared to anything I ever wrote before, so I decided to refresh my bootloader next.
In retrospective this was a very odd project, and probably less useful to anyone.

  • It fully works in unreal mode2.
  • It has support for loading or downloading files via serial, so I was able to remote boot applications from my workstation.
  • It has an embedded text editor and a BASIC interpreter (written as a separate application)
  • It uses my own filesystem format because… I don’t remember why. I guess I just wanted my own filesystem.
  • More powerful scripting tools compared to SBL 1, to configure how to set up and run applications.
  • Its own multi-task system, you could run multiple plugins by switching context before jumping to a kernel.

Since the autoexec.bat is missing from disk, it tries to load a file from serial.

The BLUE screen of death

The help screen with the hat guy.

Example of its command line interface.

SBL2 had a public build. Once uncompressed, it is just a disk image, so it is very easy to run and test:

qemu-system-i386 -m 64M -fda final2.img -boot a -vga std

Sadly it is not bundled with my custom BASIC plugin; also, from what I recall, this was not the very last version of SBL 2, we had a gamma 4 and work was started on gamma 5 before I stopped.

Conclusion

I’ll be honest, this was very bitter-sweet to write. None of these project was technically remarkable or even useful to anyone.
At the same time, it has been a journey which spanned from late 2007 to some indefinite point of 2012 in which I learned a lot.
When I started I was barely able to write any C++ code or to put together a coherent web-page.

By the end of it, I cannot even remember how many rewrites my website had (most of which UI/UX crimes, but you know… experimentation), and I had a working kernel able to do things.
Not useful things, mind you, but things nonetheless.
And that is probably one of the most empowering feelings which always makes me enjoy programming.


  1. For anyone who’s asking, it is the logic to show folder, before that only files could be navigated from a flat root in its UI. ↩︎

  2. Unreal mode is a special, not documented mode where part of the processor is configured as a legacy real mode device, but some elements of the 32bit modes have been set. Basically, it allows addressing 32bit of memory from 16bit code thanks to some trickery, while keeping compatibility with BIOS interrupts. ↩︎ ↩︎