Operating System
The Búri Operating System lives in ROM in the top 8KB of memory. (See the memory map for the full details.) The source code is available in the Búri repository. It is the first code which is run on reset. The OS at the moment is fairly simplistic.
Booting
On reset, the processor vectors to the code in reset.s. The OS then performs the following tasks:
- Disable interrupts.
- Make sure that binary-mode arithmetic is enabled.
- Clear page zero (sets all bytes to 0x00).
- Initialise the OS vector table.
- Enable interrupts.
- Jump to the initialisation routine.
At this point the processor is sanely bootstrapped. The initialisation routine in init.s takes over to bring up the computer. It does the following:
- Configure the serial adapter, if present.
- Clear the terminal.
- Write the “welcome” banner.
- Enter the command-line loop.
Vectors
The OS provides some basic routines such as “output a byte” (putc
) and
“block and read a byte” (getc
). These routines are vectored through a table
starting at $0200. For example, when calling putc
, the OS will call the
little-endian 16-bit address stored at $0200. Code wishing to “patch” this
routine can replace this address with a pointer to their own code. This is how
the LCD display driver was developed.
Command line
The init function then runs an endless loop of reading a line of input via readln and executing it via the functions in the cli directory. The OS command table is at the start of ROM and is searched for commands. At a later date I intend to vector this as well to allow for commands to be soft-loaded into the OS.
Builtin commands
echo
*echo <arg1> <arg2> <arg3>
Prints arg1
through arg3
to the output. Mostly used to test the CLI
parsing routines.
call
*call <addr>
Takes a hexadecimal address <addr>
and jumps to it via JSR
. When the
code calls RTS
, control returns to the OS.
dump
*dump <addr> [<length>]
Provides a hes-dump of memory starting from hexadecimal address <addr>
. If
<length>
is present, it is a hexadecimal number giving the number of bytes
to dump. If omitted, a single page of 256 bytes is assumed.
reset
*reset
Jumps to the OS reset vector. A software equivalent of pressing the reset button. In later OS revisions I plan to make this “soft” reset detectably different from a hard reset and make a warm reset different from a cold boot.
peek
*peek <addr>
Display the hexadecimal representation of the byte at hexadecimal address
<addr>
in memory.
poke
*poke <addr> <value>
Set the byte at hexadecimal address <addr>
to the hexadecimal byte
<value>
.
xrecv
*xrecv <addr>
Begin receiving data via the XMODEM protocol and write it starting from
hexadecimal address <addr>
. This is the current method by which most data is
uploaded onto Búri.