Operating System
Memory Layout
Addresses | Name | Description |
---|---|---|
0x0000-0x1000 | ROM | Bootloader, some OS-provided routines |
0x1000-0x1200 | Interrupt_Vectors (iv) | Interrupt handler jump table |
0x1200-0x2000 | OS_VAR(bss) | Reserved for OS variables |
↓ 0x2000 | USER | User space for program code and global variables |
↑ 0xffff | STACK | Stack 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
Code | Name | Description |
---|---|---|
0x00 | RST | Resets the Computer |
0x01 | ACK | Interrupt code for the Arduino to acknowledge a received byte |
0x42 | SEND | Interrupt code for the Arduino to signal that a byte is ready for CPU consumption |
0x43 | EOF | Interrupt 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
).
OS-provided Routines
Label | Arguments | Description |
---|---|---|
wait_io_ack | none | Waits for an ACK interrupt |
putc | char: acc | Prints a character from acc to the Arduino console |
puts | char*: pi | Prints a null terminated string that starts at the address stored in pi |
Device Driver
Arduino Communication
For hardware see Arduino Interface.
Communication sequence:
SaarCPU | Arduino |
---|---|
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:
Code | Name | Parameter | Description |
---|---|---|---|
0x01 | REQ_EXE | none | Start loading the user program |
0x02 | PRINTC | char c | Prints a character to the Arduino serial connection |