MAXI09OS

Summary

MAXI09OS is an operating system for my MAXI09 8 bit 6809 SBC. It is very much a work in progress. It is not another of those cut-down Unix available for the 6809, but rather it borrows ideas from a few different OSes and implements some of my own. The principle reason this thing exists is for the fun in writing it, and as a means to learn about the mechanics of writing an 8 bit OS.

Rough list of features

  • Simple single-link list based dynamic memory allocator
  • Objects are stored in a double-linked list, which uses the same dummy link in the list header as AmigaOS for speed
    • Currently object types include tasks and open devices
  • Preemptive task switching, simple round robin
    • Idle task that currently toggles the LED attached to DISCo allowing the CPU to be monitored (in a crude fashion)
  • Device driver model for IO abstraction
    • Calls for open, close, read, write and control
  • Interrupt usage is currently limited to UART (and console) port RX and the timer
  • Signal/Wait mechanism borrowed from AmigaOS but 8 bit signals
  • Drivers for…
    • SC16C654 QUAD UART
    • V9958 text-mode console, with 6 virtual consoles
      • Terminal emulation is completely trivial and limited to CR, LF and FF
    • Non repeating or repeating timer
    • Digital Joystick ports
      • Transition based; signal on joystick movement
    • IDE block device
      • Including identity and MBR reading control commands
    • Minixfs file (read only)
    • Low-level SPI host within DISCo
    • DISCo’s LED
  • Debug monitor handler on “break” signal
    • Low level memory operations
    • Show task list and details on a task
    • Exercise drivers by opening them and performing operations
  • Startings of a simple command Shell
    • Implemented as a resident task
    • Run on two of the virtual terminals and a UART port
    • List directories (list)
      • With long mode (-l)
    • Type a file (type)
    • Change directory (cd)
    • Run an external file as a subroutine
      • Date set and get with RTC
      • Various test programs
      • Run Snake!
    • Transfer binary file from host machine over UART and run it as a subroutine

Features TODO

  • Drivers for…
    • 6522 parallel printer port
    • OPL2 (no idea how that will work yet)
  • Better terminal emulation in console driver
  • Write support for the Minix FS layer
  • More Shell commands
    • Configure keyboard controller (key repeat rate, etc)
    • Copy file
    • Create directory
    • Etc..
  • Command redirection so files can be printed
  • Maybe write a basic full screen editor

Source code modules

The source is currently held on github. I’m rather fond of the asxxxx assembler, so use that. The source code makes fairly heavy use of macros for things like a debug API and defining structures and their offsets in a fairly nice way.

The source is arranged in the following tree:

  • drivers/ : Drivers follow a common template, described below.
    • uart.asm : UART driver
    • shared/ : Some drivers (eg. console and uart) share low level code held here
    • fs/ : Drivers which are interfaces to filesystems.
    • console/ : Because it is large, the console driver is held in a directory.
  • executive/ : The “core”
    • lists.asm : Functions for manipulating doubly linked lists, which include a dummy node in the head as an optimisation, borrowing from AmigaOS.
    • memory.asm : The memoryalloc and memoryfree subroutines here.
    • tasks.asm : Routines for creating, destroying, signalling, and related subroutines go here. The main ticker handler lives here, as well as the schedular.
    • tickeer.asm : This contains the init subroutine for the timer, which involves configuring the needed 6522 registers, configuring the internet route, and setting the ISR address.
  • fs/ : Contains higher level routes for each of the supported filesysems (which is currently only MinixFS)
    • minix.asm : Contains routines to mount a MinixFS block device and extract the needed information from the superblock, as well as routines to read inodes.
  • include/ : Various include files used by different modules.
    • ascii.inc : Contains constants for the low byte (0 to 31) control codes, and MAXI09OS-specific codes in high positions for things like function keys etc. A special byte sequence represents the break signal, etc. UTF-8 can go to hell.
    • debug.inc : Debug macros for outputting strings, with register contents, to the debug UART port.
    • hardware.inc : Contains constants for register addresses and the values used for registers. This is a constant WIP and, in general, this file is only added to as values are needed.
    • minix.inc : Contains structure definitions for various Minix on-disk structures, as well as constants.
    • scancodes.inc : Scancode constants for non printable keys. This should be extended to every key on the keyboard, though currently only a few key scancodes values are needed.
    • system.inc : The “main” include file, that defines the key system structures (tasks and open devices). This file should probably be broken down into headers for the various modules, instead of lumping them together. Also contains some generic macros for manipulating the Condition Code register (enabling/disabling interrupts etc). The global debug build flags are set here.
    • v99lowlevel.inc : Macros for manipulating the V9958.
    • version.inc : Contains a single constant: the build number. This is output by init when it starts.