Skip to main content

Operating System

Memory Layout

AddressesNameDescription
0x0000-0x1000ROMBootloader, some OS-provided routines
0x1000-0x1200Interrupt_Vectors (iv)Interrupt handler jump table
0x1200-0x2000OS_VAR(bss)Reserved for OS variables
↓ 0x2000USERUser space for program code and global variables
↑ 0xffffSTACKStack used by OS and user code
Bootloader Bugs

The current bootloader implementation determines the interrupt table entry address with a add acc, acc instruction. This overflows for interrupts with code > 0x80, and thus aliases high interrupt codes with the lower table entries.

Interrupt codes

CodeNameDescription
0x00RSTResets the Computer
0x01ACKInterrupt code for the Arduino to acknowledge a received byte
0x42SENDInterrupt code for the Arduino to signal that a byte is ready for CPU consumption
0x43EOFInterrupt code for the Arduino to signal that a requested byte sequence is complete
Work in Progress

TODO add Timer and PS/2 Interrupts

Bootloader

The Bootloader allows loading in executables from an Arduino and running them. It requests them by sending the Arduino the REQ_EXE command. The Arduino then sends the executable byte by byte and the Bootloader copies them into the beginning of the user space. Once the whole program has been transferred, the Arduino sends an EOF interrupt and the bootloader calls to the beginning of user space (0x2000).

Bootloader code

OS-provided Routines

LabelArgumentsDescription
wait_io_acknoneWaits for an ACK interrupt
putcchar: accPrints a character from acc to the Arduino console
putschar*: piPrints a null terminated string that starts at the address stored in pi

Device Driver

Arduino Communication

For hardware see Arduino Interface.

Communication sequence:

SaarCPUArduino
write command code
send ACK interrupt
send command paramenter
send ACK interrupt
...
write response to device register
send interrupt to signal that data is available

Command codes:

CodeNameParameterDescription
0x01REQ_EXEnoneStart loading the user program
0x02PRINTCchar cPrints a character to the Arduino serial connection