<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>asdf &#187; osdev</title>
	<atom:link href="http://asdf.personallog.org/tag/osdev/feed/" rel="self" type="application/rss+xml" />
	<link>http://asdf.personallog.org</link>
	<description>...</description>
	<lastBuildDate>Fri, 10 Jul 2009 21:59:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>asdf-os</title>
		<link>http://asdf.personallog.org/2008/09/28/asdf-os/</link>
		<comments>http://asdf.personallog.org/2008/09/28/asdf-os/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 16:03:31 +0000</pubDate>
		<dc:creator>asdf</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[asdf-os]]></category>
		<category><![CDATA[osdev]]></category>

		<guid isPermaLink="false">http://asdf.personallog.org/?p=35</guid>
		<description><![CDATA[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. [...]]]></description>
			<content:encoded><![CDATA[<div class="mceTemp">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:</div>
<div class="wp-caption alignnone" style="width: 170px"><a title="asdf-OS Screenshot" href="http://i159.photobucket.com/albums/t141/sovietweasel/asdfos-gui8.jpg" target="_blank"><img src="http://i159.photobucket.com/albums/t141/sovietweasel/th_asdfos-gui8.jpg" alt="asdf-OS Screenshot" width="160" height="120" /></a><p class="wp-caption-text">asdf-OS Screenshot</p></div>
<p><span id="more-35"></span></p>
<p>So far, here's what it can do:</p>
<p><strong>Hardware Support:</strong></p>
<ul>
<li>PS/2 Keyboard</li>
<li>PS/2 Mouse</li>
<li>Serial Port (mostly for debugging purposes)</li>
<li>PCI (only tested device listing so far)</li>
<li>PIT (Programmable Interval Timer - used for task scheduling)</li>
<li>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)</li>
<li>Video/screen functions with VESA/VBE</li>
<li>RTC (Real Time Clock - to get the system time from BIOS)</li>
<li>PC Speaker beeping (I was bored, lol)</li>
</ul>
<p><strong>Kernel/Internal Stuff:</strong></p>
<ul>
<li>Initialisation of GDT, IDT, ISRs, etc. (basic stuff needed for the OS to run)</li>
<li>Exception Handling ("RSOD")</li>
<li>System calls (used by ring3 - or usermode - programs to communicate with the kernel)</li>
<li><strong>Multitasking!</strong> Yay. (This took a really long time to get working, but is important to any functioning modern OS)</li>
<li>Message queues for inter-process communication</li>
</ul>
<p><strong>Memory Management</strong></p>
<ul>
<li>Physical memory manager - keeps track of used/free pages</li>
<li><strong>Paging!</strong> 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.</li>
</ul>
<p><strong>Video</strong></p>
<ul>
<li>VESA Driver</li>
<li>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)</li>
<li>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)</li>
<li>Various graphics functions (ie. fillrect, drawline, fillgradient, and so on)</li>
<li>Alpha-Transparency!</li>
<li>Mouse cursor rendering</li>
<li>Bitmap drawing functions</li>
<li>Rendering of custom image format based on XPM (X PixMap), used for window title bars, close button, etc.</li>
<li>Font rendering (font data stored in a bitmap-like thing)</li>
</ul>
<p><strong>GUI</strong></p>
<ul>
<li>Windows and event handling based on the Windows design (using message callback procedures for each registered window-class)</li>
<li>Resizeable and moveable windows.</li>
<li>Window Controls: Button, Edit, Text.</li>
<li>Message boxes</li>
<li>Taskbar</li>
<li>"Desktop" - you can click and drag and draw rectangles just like in Windows, lol</li>
<li>Message queues for event handling in usermode</li>
</ul>
<p><strong>Usermode</strong></p>
<ul>
<li>Loading and running PE executables in a separate process and address space.</li>
<li>System calls communication with the OS/Kernel.</li>
<li>Libraries with C runtime stuff, memory allocation, GUI window creation / various GUI-related features.</li>
<li><strong>Error handling! </strong>If a usermode program executes an illegal instruction (ie. divide by 0, access memory it doesn't own, etc.), only the <em>process</em> 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.</li>
<li>Sample test usermode calculator program.</li>
</ul>
<p>And that's about everything I can think of right now. The project is currently <strong>12,282</strong> lines of code in <strong>84</strong> files (doing a line count of all files with the extensions: c, h, asm - excludes Makefile and linker script).</p>
<p>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 <strong>height </strong>* <strong>width </strong>* <strong>4 </strong>(* 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.</p>
<p>The only piece of software which is <em>not</em> 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.</p>
<p>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:</p>
<div class="wp-caption alignnone" style="width: 170px"><a title="asdf-OS Screenshot - January 2007, text-mode" href="http://i159.photobucket.com/albums/t141/sovietweasel/asdfos-pmm2.png" target="_blank"><img src="http://i159.photobucket.com/albums/t141/sovietweasel/th_asdfos-pmm2.png" alt="asdf-OS Screenshot - January 2007, text-mode" width="160" height="95" /></a><p class="wp-caption-text">asdf-OS Screenshot - January 2007, text-mode</p></div>
<p>And here it is during GUI development (pre-transparency and after transparency):<br />
<a title="asdf-OS Screenshot - January 2007, text-mode" href="http://i159.photobucket.com/albums/t141/sovietweasel/asdfos-pmm2.png" target="_blank"><br />
</a></p>
<div class="modcaption" style="margin: 5px auto">
<div class="wp-caption alignnone" style="width: 170px"><a title="asdf-OS Screenshot - GUI 1" href="http://i159.photobucket.com/albums/t141/sovietweasel/asdfos-gui2.png" target="_blank"><img src="http://i159.photobucket.com/albums/t141/sovietweasel/th_asdfos-gui2.png" alt="asdf-OS Screenshot - GUI 1" width="160" height="125" /></a><p class="wp-caption-text">asdf-OS Screenshot - GUI 1</p></div>
<div class="wp-caption alignnone" style="width: 170px"><a title="asdf-OS Screenshot - GUI 2" href="http://i159.photobucket.com/albums/t141/sovietweasel/asdfos-gui4.png" target="_blank"><img src="http://i159.photobucket.com/albums/t141/sovietweasel/th_asdfos-gui4.png" alt="asdf-OS Screenshot - GUI 2" width="160" height="127" /></a><p class="wp-caption-text">asdf-OS Screenshot - GUI 2</p></div>
</div>
<p style="text-align: left">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):</p>
<p><a href="http://asdf.personallog.org/2008/09/28/asdf-os/"><em>Click here to view the embedded video.</em></a></p>
<p>Or view the higher resolution one here: <a href="http://weasel707.blip.tv/file/1282160/">asdf-OS Screencap on blip.tv</a></p>
<p>Edit: Thanks Frederick, I didn't know you could embed these things.</p>
<p>Edit 2: It's worth mentioning that lots of credit goes to <a href="http://www.rohitab.com/discuss/index.php?showuser=3860">Napalm</a> for help and suggestions on various things.</p>
]]></content:encoded>
			<wfw:commentRss>http://asdf.personallog.org/2008/09/28/asdf-os/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
