================================ Flight of the Kestrel-2 Samuel A. Falvo II 2013-Nov-16 ================================ When We Last Saw The Kestrel-2 . . . * CPU: 16-bit S16X4 (Steamer16 superset) * Program memory: 16KB * Video: Monochrome, bitmapped graphics only * Video memory: 16KB * PS/2 keyboard interface * No subroutine call instruction! * No interrupts! * Software always ran on bare metal. ========================================================================= And now, the continuation of the Kestrel-2 Project. ========================================================================= Forth Casualty * Indirect-threaded as a means to work around lack of CALL instruction. * Tried keeping names very short to fit in available memory space. * Single dictionary chain for immediate, non-immediate words. * Over 10KB just to get line of input, parse words, and print them. * 7KB for font, console I/O alone. * 2KB for font. * Roughly 2KB for glyph painting, basic terminal emulation. * Roughly 3KB for keyboard look-up tables, driver, line editor. * Clearly not enough memory to finish compiler, editor, BLOCKs, etc. * Maybe, an OS can help by managing resources more directly? * (It seemend to work for IBM back in 1960s!) ========================================================================= Single Tasking System * A very simple operating system inspired somewhat by BOS/360, CP/M, Tripos * Kernel memory budget: 8KB. Actual memory used to date: 4.5KB * Sectors 0, 1 bootstraps kernel in sectors 2 through 15. * Filing system API supports read operations only. * Guarantees safety during OS development. * Use explicitly loaded library to write to or update files. * Single address space; no memory protection. * Prgs must free memory, unload segments before exiting. ========================================================================= STS Versions * STS V1.0 for 16KB Kestrel-2 * 16KB STILL not enough to load some programs from shell! * Both Forth and STS experience leads to one conclusion: 32KB required * STS V1.1 for 32KB Kestrel-2 ========================================================================= STS System Calls * Filesystem: open, close, read, seekblk * Memory: getmem, fremem * Programs: loadseg, unloadseg, exec, exit. (period part of name) ========================================================================= Entrypoint Vectors $0400 origin ... defer, coldstart ... defer, getmem-epv defer, relmem-epv defer, open-epv defer, close-epv defer, read-epv defer, loadseg-epv defer, unloadseg-epv defer, exec-epv ... ========================================================================= SD Card Compatibility * STS mounts SD card at boot-time only. * STS V1.1 will not reinitialize SD card after removal, insertion. * `remount' command needs to be internal to STS shell if/when implemented. * After removal, SD card access deadlocks, since SD card isn't initialized. * Treat SD card like harddrive! * Detecting SD card insertions requires interrupts. ========================================================================= Filesystem Overview * A Typical filename: SYS:prefix.prefix.name --- ------------- ---- | | | | | +--- Name of the data set. | +------------- One or more prefixes scoping the data set. +---------------------- Volume on which dataset may be found. ========================================================================= Filesystem Details (1/3) * Volume Table of Contents = flat directory. * VTOC starts on sector 16. * Typical Directory Entry (64 bytes) +-----+-------------------------------------+ | Len | Filename (1 <= length <= Len <= 47) | +-----+-----+-----+-------------------------+ | Typ | Fst | Lst | /////////////////////// | +-----+-----+-----+-------------------------+ | | | +--- Last sector of the dataset (>= Fst) +--------- First sector of the dataset ========================================================================= Filesystem Details (2/3) 0002000: 0424 4449 52cc cccc cccc cccc cccc cccc .$DIR........... 0002010: cccc cccc cccc cccc cccc cccc cccc cccc ................ 0002020: cccc cccc cccc cccc cccc cccc cccc cccc ................ 0002030: 0100 1000 1700 0000 0000 0000 0000 0000 ................ 0002040: 0857 6f72 6b44 6973 6bcc cccc cccc cccc .WorkDisk....... 0002050: cccc cccc cccc cccc cccc cccc cccc cccc ................ 0002060: cccc cccc cccc cccc cccc cccc cccc cccc ................ 0002070: 0200 0000 0000 0000 0000 0000 0000 0000 ................ . . . . . . 00021c0: 0670 7267 2e6d 32cc cccc cccc cccc cccc .prg.m2......... 00021d0: cccc cccc cccc cccc cccc cccc cccc cccc ................ 00021e0: cccc cccc cccc cccc cccc cccc cccc cccc ................ 00021f0: 0100 5800 6300 0000 0000 0000 0000 0000 ..X.c........... ========================================================================= Filesystem Details (3/3) * Prefix system inspired by OS/360. * prg.app files: programs invoked from STS shell. * lib.xxx files: libraries. * app.xxx files: data or executable files belonging to application APP. * Case sensitive! * SYS: versus VolumeName: ========================================================================= Kestrel-2 Today: Dream vs. Reality Dream -----------------------------+ Today --------------------+ | Last Year -----------+ | | | | | +------------------+-------+--------+--------+ | CPU | S16X4 | S16X4A | S16X4A | | RAM | 16KB | 32KB | 32KB | | Working OS | n/a | STS | Forth | | Interrupts | N | N | Y | | Auto Remount | n/a | N | Y | | VSYNC | N | N | Y | | Timers | N | N | Y | +------------------+-------+--------+--------+ ========================================================================= S16X4A: New Instructions * Two new instructions: * Opcode $C: LCALL (+/- 4KB from current PC; slot 1 only). * Opcode $D: ICALL (anywhere). * Both leave return address in Z on entry to subroutine. S16X4 ------S16X4A------ (6 bytes) (4 bytes) (2 bytes) +-------------+-------------+----------------+ | LI retnAddr | LI subrAddr | LCALL subrAddr | | LI subrAddr | ICALL | | | GO | | | +-------------+-------------+----------------+ ========================================================================= S16X4A: New Signals * ABORT_I signal, when asserted externally, stops CPU from updating regs. * Used by external debugging and/or memory management unit hardware. * ABORT_I also FORCES instruction fetch in next cycle, guaranteed. * MMU traps instruction PC using VPA, VDA signals. * Not used for Kestrel-2, but will be for Kestrel-3 development. ========================================================================= S16X4A: Interrupt Injection Support * S16X4(A) always qualifies each bus cycle with VDA_O, VPA_O * Assume bus control if VDA=0, VPA=1 to inject LI/ICALL to handler +-----+-----+---------------------------+ | VDA | VPA | Cycle Type | +-----+-----+---------------------------+ | 0 | 0 | Idle or internal cycle | | 0 | 1 | Instruction word fetch | | 1 | 0 | Data word access | | 1 | 1 | Instruction operand fetch | +-----+-----+---------------------------+ ========================================================================= Kestrel-2 Future Interrupt Sources * VSYNC * Raster compare * Keyboard * Programmable timers * A push-button (a la Commodore 64's RESTORE key) * SD card insertion detection ========================================================================= Future Directions * Kestrel-3 work already in flight * Change of strategy: Evolution, not Revolution * Kestrel-2 will continue to evolve too! * All new website with better curation on the way * New blog ========================================================================= Websites of Interest * http://sam-falvo.github.io * http://sam-falvo.github.io/kestrel (not yet, but eventually) * https://github.com/sam-falvo/kestrel ========================================================================= Fin * Q & A