asdf

28Sep/086

asdf-os

Hmm, I haven't updated this in a while. In this post, I thought I'd talk about "asdf-OS", a hobby operating system which I've been working on for over a year (since around May-June of 2007). My goal with this is to get something "sorta-usable", it never intends to rival Windows or something like that, lol. Before I start talking about what it can do, here's a screenshot:
asdf-OS Screenshot

asdf-OS Screenshot

So far, here's what it can do:

Hardware Support:

  • PS/2 Keyboard
  • PS/2 Mouse
  • Serial Port (mostly for debugging purposes)
  • PCI (only tested device listing so far)
  • PIT (Programmable Interval Timer - used for task scheduling)
  • ATA Hard Disk Drive (using LBA with PIO - can read and write sectors to/from the drive, parse partition table, and working on FAT32 drivers)
  • Video/screen functions with VESA/VBE
  • RTC (Real Time Clock - to get the system time from BIOS)
  • PC Speaker beeping (I was bored, lol)

Kernel/Internal Stuff:

  • Initialisation of GDT, IDT, ISRs, etc. (basic stuff needed for the OS to run)
  • Exception Handling ("RSOD")
  • System calls (used by ring3 - or usermode - programs to communicate with the kernel)
  • Multitasking! Yay. (This took a really long time to get working, but is important to any functioning modern OS)
  • Message queues for inter-process communication

Memory Management

  • Physical memory manager - keeps track of used/free pages
  • Paging! Virtual addressing is used to access memory. Each process has its own page directory, thus cannot access the memory of other processes. Also ensures protection of kernel pages from usermode processes.

Video

  • VESA Driver
  • Double-buffering (draw operations are done to a double-buffer in dynamically-allocated memory rather than writing directly to video hardware memory. This avoids flickering)
  • 800x600x32 mode by default, but can be changed to a different resolution (running 1024x768 in a VM is difficult to work with because of the screen space it takes up on my 1440x900 laptop screen)
  • Various graphics functions (ie. fillrect, drawline, fillgradient, and so on)
  • Alpha-Transparency!
  • Mouse cursor rendering
  • Bitmap drawing functions
  • Rendering of custom image format based on XPM (X PixMap), used for window title bars, close button, etc.
  • Font rendering (font data stored in a bitmap-like thing)

GUI

  • Windows and event handling based on the Windows design (using message callback procedures for each registered window-class)
  • Resizeable and moveable windows.
  • Window Controls: Button, Edit, Text.
  • Message boxes
  • Taskbar
  • "Desktop" - you can click and drag and draw rectangles just like in Windows, lol
  • Message queues for event handling in usermode

Usermode

  • Loading and running PE executables in a separate process and address space.
  • System calls communication with the OS/Kernel.
  • Libraries with C runtime stuff, memory allocation, GUI window creation / various GUI-related features.
  • Error handling! If a usermode program executes an illegal instruction (ie. divide by 0, access memory it doesn't own, etc.), only the process will be killed, the entire OS will not crash! Same as on other protected mode operating systems - if your browser crashes on Windows you don't get a BSOD.
  • Sample test usermode calculator program.

And that's about everything I can think of right now. The project is currently 12,282 lines of code in 84 files (doing a line count of all files with the extensions: c, h, asm - excludes Makefile and linker script).

asdf-OS runs fine with 16MB of RAM, but will crash with an out-of-memory error if you spawn a large number of windows and resize them to make them take up a lot of screen space. The main memory consumer in my OS is, of course, the GUI. Every window (this includes controls such as buttons) takes up height * width * 4 (* 2 if usermode). And that's an unavoidable fact of making GUIs in a 32-bit colour mode. The (bootable) kernel image fits on a 1.44MB floppy. I develop on my own Windows XP machine and run in VMWare, but I have tested it on an ancient computer in the basement and it appears to work just fine.

The only piece of software which is not my own that asdf-OS depends on is GRUB, which I use as my bootloader. It's great because it does all the necessary stuff to set up protected mode and start my kernel in protected mode. It also sets up the graphics mode that I ask for, which would otherwise be a pain in the ass to do - going back to real mode, calling the BIOS interrupts, and back to protected mode. Other than that, though, you can say this was coded "from scratch", perhaps only taking a few snippets from here and there.

I have a few screenshots that I took during the development of it at various stages. Here's what it looked like in January,  when I was working on the memory management stuff:

asdf-OS Screenshot - January 2007, text-mode

asdf-OS Screenshot - January 2007, text-mode

And here it is during GUI development (pre-transparency and after transparency):

asdf-OS Screenshot - GUI 1

asdf-OS Screenshot - GUI 1

asdf-OS Screenshot - GUI 2

asdf-OS Screenshot - GUI 2

Finally, here's a recent video demonstrating the features of usermode error handling (division by 0 exception in usermode calculator kills the process and system continues running, but division by 0 exception in kernel-mode calculator crashes the OS):

Please enable Javascript and Flash to view this Flash video.

Or view the higher resolution one here: asdf-OS Screencap on blip.tv

Edit: Thanks Frederick, I didn't know you could embed these things.

Edit 2: It's worth mentioning that lots of credit goes to Napalm for help and suggestions on various things.

  • Digg
  • Reddit
  • StumbleUpon
  • del.icio.us
  • Technorati
Comments (6) Trackbacks (0)
  1. WOW.

    I don’t understand half of the things you’ve listed, but I’m sure that many others would. So I’m going to share this on social bookmarking sites.

    Second thing: are you sure you don’t want to embed the video in your site? It’s really quite simple.
    In this case, the code would be:
    [swf http://blip.tv/play/Ac7SUgA 420 332]

  2. lolol commenthax

  3. Where do I can find more Infomations about asdf? Is there a download avaible?

  4. Simon – right now there haven’t been any public releases of asdf-OS, but perhaps that will change in the future. At this point though, I don’t know.

  5. Hi, I would like to know what emulator you are using. Video refresh seems fluid, are you using some kind of acceleration?
    Thanks,
    Gonzalo

  6. Is there anyway I could view the source code to asdf-OS? I recently got into OS development and I would love to see the source of one :)


Leave a comment


Powered by WP Hashcash

No trackbacks yet.