Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
SqueakNOS
Last updated at 1:54 pm UTC on 22 August 2011
bronz2009.jpg

''Operating System: An operating system is a collection of things that don't fit into a language. There shouldn't be one.'' – Dan Ingalls, in an article in Byte Magazine, 1981.


SqueakNOS running on VMWare 19-May-2006
SqueakNOS scanning the PCI bus and showing Mac Address of NIC





This page isn't changed any more, we have moved to blogspot so follow this link: http://squeaknos.blogspot.com


SqueakNOS

We want to get rid of the operating system under Squeak. For this we know we will need to implement lots of low level things, we are not afraid, but we want to take a little different approach: Implement the bare minimum as native code (a mix of assembly and C), and then do everything else in Squeak. The people originally in the group only knew low level PC stuff, so we started with this, however there is already people participating that want to give Apple/PowerPC a try!

There are two incarnations of SqueakNOS, one was pretty much abandoned in 2001, and had support for 640x480x1 or 640x480x4, keyboard, mouse, serial port and a pseudo file system over serial port, although some of this features never saw the light. In May 2006 we restarted SqueakNOS, and a new version was released in May 16th, with support for 1024x768x32, and bare IRQ handling.

The SqueakNOS development is planned in different phases and small steps, as of May 20th, the first 2 are accomplished and the 3rd is almost ready. There is a lot of people willing to contribute, and there's certainly space for everybody, however we believe the first 3 phases must be ready so it's easy to contribute.

Download

Get latest .iso image (containing everything you need to boot and recompile) from SourceForge's mirrors.

Other pages

Mailing list

We've put up a mailing list to talk SqueakNOS, join in, or just drop an email there.

Current Status...

erm... we used to have a page with rss feeds and everything at people.squeakfoundation.org, but it doesn't exist anymore. Hopefully we'll get it back somewhere :-(

Plan

Phase 1: Make it boot

Make it boot and start intepreting the .iamge with text output for tracing and debugging. [Done]
The old SqueakNOS used a custom made mutant boot loader, borned from mixing LILO, the Linux kernel boot loader, and our dirty fingers. We had quite a few problems with it, and it was really complicated to put the needed environment to compile it. So we chose to replace it for something better and more modern: GRUB.

We first thought on GRUB because it, of course, handles all initialization, switches to flat 4G mode can load huge kerneles in high memory, and also has support for modules loading (module and modulenounzip GRUB commands). We wanted to detach the native part and the Squeak .image, which were glued in a single file in the old SqueakNOS, making it easier for Squeakers to touch the .image without having to set up the compiling environment. [done]

We needed to implement the switch to graphics mode before starting jumping to the interprenter. In the old SqueakNOS we did it from real mode (that's why we had so pour video support). But this time GRUB gave us control already in protected mode, so we couldn't just call the right INT. Luckily, GRUB already has the roots for supporting graphic video mode selection, and although it is not usuable in the standard GRUB distro, we could solve the problem quite easily, by copying the testvbe command into the setvbe command, and removing erverything after the command switches the video mode. We latter found out that the video memory address changes from box to box, so we also hacked the vbeprobe command to show the video memory address. [Done]

We also learned that GRUB supports part of the multiboot protocol and is able to load ELF binaries, this led us reduce the amount of assembly code to barely around 20 line. It's not that we are afraid of assembly, but if multiboot was supported in some other platform (Apple/PowerPC), porting SqueakNOS' kernel should be really easy. [Never tried]

At this point we had GRUB loading the kernel and loading the .image all in memory, we had some glue code to make the .image look like a file so Squeak's intepreter could start interpreting it. We coded console text output support, hacked some debugging messages in the interpreter loop, some stack traces here and there and figured out what Plugins needed to be compiled for Squeak to start up: we finally managed to make the interpreter loop run loose. [Done]

Phase 2: Make it breath

Add graphics mode support, and native IRQ setup and handling [Done]
After the nice suprise that GRUB had graphic mode switching almost ready to be used, we jumped into making it work for us, and we chose a graphic mode that is really nice AND maps 1 to 1 from Squeak's representation to video RAM: 1024x768x32 bits is our choice although any 32 bits mode would suit the needs. Hacking a ioShowDisplay() that works was easy: it's no more than a bounded memcpy(). With this we got some grphic output in SqueakNOS' screen!. [Done]

With the old SqueakNOS we had some problems at this point, mainly because Squeak does not refresh the screen upon entering, so this time we solved it really fast, by doing a "self currentWorld fullRepaintNeeded" after a small Delay, and voila! Squeak's full screen was shown! [Done]

Now we were facing the most delicate part: making IRQs properly work. Subtasks: set a void handler for every IRQ and enable IRQs (see that it doesn't halt). Add an infinite loop handler for the keyboard IRQ (see that it hangs on a keypress). Set a visible handler for the timer interrupt (see that it draws something on the screen... you can still see it in the upper right corner of SqueakNOS). Finally change all void handlers for code that will trigger a Squeak Semaphore and exit, also add the primitive to register the Semaphores (see that it doesn't hang, then see that the Semaphore gets triggered from inside Squeak). At last, loop waiting on the semaphore for keyboard's IRQ, read keyboard's port, and signla IRQ end all from inside Squeak. [Done]

SqueakNOS IRQ Handling
Squeak VM lets you signal Squeak Semaphores from the native world by calling signalSemaphoreWithIndex(). We want to serve IRQs from Squeak, using interpreted code, not native code. We seriously think that with hardware close to 1000 times faster than 20 years go we should be able to do it without any problems. Of course we cannot set the native IRQs handlers to jump to Squeak code, so our idea is to have a different Semaphore for every IRQ and have a Squeak Process with highIOPriority blocking on the Semaphore.

The code inside Squeak, taken from InterruptRequestDispatcher>>installOn: looks like:
installOn: aComputer
	self registerSemaphore.
	process := [
		[
			semaphore wait.
			self handleOn: aComputer.
			aComputer interruptController signalEndOfInterrupt: interruptNumber.
		] repeat
	] fork priority: Processor highIOPriority.
	aComputer interruptController enableIRQ: interruptNumber

And the native code to signal the Semaphore, taken from ints.h, is similar to:
	void irq_1_handler();
	asmlinkage void ISR_1() {
		if (0!=IRQSemaphores[number])
		  signalSemaphoreWithIndex(IRQSemaphores[number]);
	}

	asm(
	    ".text"			
	    ".align 16"
	    "irq_1_handler:"
	    "pusha"
	    "call ISR_1"
	    "popa"			
	    "iret"			
	)

There is an interesting detail in all this: the software interrupt ending (IRET) and the hardware IRQ ending (outb(0x20,0x20)) are detached in SqueakNOS, were they are almost always done at the same time in every other code we saw. This gives a really desirable result: The IRET lets the software continue, going back to the interpreter and letting the Process waiting on the Semaphore be rescheduled, however, the hardware part (Interrupt Controller) still thinks the IRQ has not been served yet, and will wait until the Squeak side of the handler (shown above) signals the end of the interrupt (aComputer interruptController signalEndOfInterrupt: interruptNumber.

We seriously believe that with computers close to 1000 times faster than 20 years ago this should be ok, however we are not sure yet if it may bring any problems latter, and we are open, although reluctant, to the possibility of coding some glue code, or even complete "device drivers" natively (or hopefully using Exupery). Probably for sound and video I/O, we'll see.

We were successfully using the very same scheme in the old SqueakNOS, so we just ported it to the new code base.

So, in short, IRQ handling [Done]

Phase 3: Give it awareness

Make Keyboard and Mouse work. This will let us code SqueakNOS from within SqueakNOS. [Done]
If we do this, we'll want to be able to save the changes, so we'll need some persistency. Our idea (taken, again, from the old SqueakNOS), is to implement serial port support [Done], and some type of File System over it.[Kind of Done]

Phase 4: Help it grow

Start codding a few HardwareDevices as model, specially some Network card support [Not started yet]
Code PCI Bus handler. [Done]
Code Network support.
Code CMOS support (hardware clock for example).[Parts Done]

Phase 5: Let it be

What to do

Ufff! There are tons of things to do. You can pick any to do :-)
Some in particular no order:

Ideas


Possible problems

Bug reports

Known to work on