JaysOS is a "toy OS" that runs on the Gameboy Advance.
It provides preemptive threads, semaphores, condition variables, and message queues.
I've included 3 fairly lame demo "apps": a breakout game,
a version of Conway's Life, and a cpu usage displaying app.
As of 0.2, it also includes a port of the Waba VM for Java bytecodes.
Waba comes with a few interesting demo applets you can try out.
JaysOS apps interact with the world using the "UI Manager", which is in charge of
* keeping track of window sizes
* running a redraw thread
* dispatching events to message queues
There is also a "shell" app, which works over a serial connection (e.g. MBV2 cable),
and allows you to control what is going on using simple commands.
As the ARM7TDMI has no MMU, JaysOS can't provide seperate address spaces for "tasks" like
in a real OS.
Another limitation of JaysOS is the lack of proper system calls.
In most OSes, user apps communicate with the kernel through software interrupts.
Unfortunately in the GBA the BIOS traps all software interrupts and handles them itself, so
they can't be used to call into JaysOS. Apps have to call kernel functions directly.
As of version 0.2.0, there is a heap manager, but it is only used by the apps.
The kernel itself uses only statically allocated data structures.
Static memory allocation means a lot of things are fixed in JaysOS.
There is a maximum of 32 threads for instance.
None really, other than my own amusement and education.
JaysOS is not meant to be useful or to represent my idea of how a real OS should work.
Design decisions were made based on whatever I felt like having a go at that day.
Hopefully it might serve as a basic introduction to operating systems, or as a simple threading system for GBA apps, or you might even be able to use parts of it for embedded applications. I've tried to make the code as simple as possible.
Feel free to steal any bits of code that might be useful to you.
You control the apps running under JaysOS with the buttons on the front of the GBA.
The Start button pauses/unpauses apps that support pause (Life and Breakout)
The Breakout app works like you'd expect - move the bat left and right
and try to keep the ball in motion.
I haven't bothered to implement different levels, score or anything fancy.
The only control the Life app has is the A button, which can be used to restart
the simulation with a random arrangement of cells.
As you can only control one window at a time, the UI Manager has the
concept of an "active window".
The active window is the only one which receives button events.
The active window is drawn with a blue border.
You can change the active window by using the buttons on the top of the GBA marked "L" and "R".
|The Life app window is active
||The Breakout window is active
(No emulators simulate the serial port, so you will
need a real GBA for this!)
I have only tested it with the MBV2 cable, but i would imagine it works
similarly with homebrew serial cables too.
Set up your terminal software to 9600 8N1 ANSI mode.
(I've used it with minicom on linux and Zterm on MacOS X - using a keyspan USB->serial adapter)
Turn on the GBA.
If you are using the MBV2 type "C" (on your PC) a few times
while the Gameboy logo is displaying until it prints "Coded by Jeff Frohwein".
That is actually coming from the MBV2 and is nothing to do with me.
Now type "U" until you see a message welcoming you to JaysOS.
If it doesn't work try "rebooting" your GBA and trying again.
You can type "help" to get a list of recognised commands.
Currently this is
ps- list all threads running
queues- list all msg queues registered with the UI Mgr
kill <queue_name>- sends a MSG_QUIT to the specified msg queue
mem- show the heap statistics
ls- list all files in the GBFS archive
print <path_to_text_file>- dumps to the terminal the contents of the specified file
breakout- start a game of breakout
life- start Conway's Life
stats- starts an app that displays some statistics
waba <path_to_classfile>- start the Waba VM (see waba/README.jaysos)
uname- prints the version
uptime- prints the time elapsed since the GBA was switched on
You get the idea...
If you don't have a serial link, you can try running different combinations
of apps by changing which ones are started in main.c and recompiling.
Waba is an unofficial implementation of a Java VM, originally written by
Rick Wild of Wabasoft. It is small, simple and highly portable. It uses
its own class libraries which are similar to, but not compatible with,
"official" Sun standards (like J2ME).
See waba.sourceforge.net and www.wabasoft.com for more on Waba.
Waba is started from the JaysOS shell with the command "waba" followed by
the path to the main classfile (not including the ".class")
You can only have one instance of waba running at a time.
Waba can be stopped with the command:
The README tells you everything you need to know.
See the included README.