From 7e7b05ce1712d67387a7d7c4edbb6311ba3bad98 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Thu, 10 Mar 2016 15:28:42 +1000 Subject: [PATCH] I've created an area so that we can test kernel mode code in SimH. --- src/minikern/README.md | 8 +++++ src/minikern/ttyout_test.s | 71 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 src/minikern/README.md create mode 100644 src/minikern/ttyout_test.s diff --git a/src/minikern/README.md b/src/minikern/README.md new file mode 100644 index 0000000..6e8312b --- /dev/null +++ b/src/minikern/README.md @@ -0,0 +1,8 @@ +#Readme + +This area is a place to write and try out kernel-mode test code. We can +try out drivers, test the disk routines etc. The idea is to bring pieces +of the real kernel in, test them, and keep incorporating stuff until we +reach a working kernel. + +List filenames and comments here. diff --git a/src/minikern/ttyout_test.s b/src/minikern/ttyout_test.s new file mode 100644 index 0000000..36b20a4 --- /dev/null +++ b/src/minikern/ttyout_test.s @@ -0,0 +1,71 @@ +" Code to test the teleprinter output. Some code borrowed from s7.s + +iof = 0700002 " PIC: interrupts off +ion = 0700042 " PIC: interrupts on +tsf = 0700401 " TTY: skip if flag set +tcf = 0700402 " TTY: clear flag +tls = 0700406 " TTY: load buffer, select + +. = 020 + + iof " Interrupts off, do we need this? + +1: tsf " Is the teleprinter ready to print? + jmp 1b " No, loop back + + tcf " Clear the ready flag + jms ttyrestart " Print out a character + hlt " and halt for now + + +ttyrestart: 0 + lac ttydelay " Is the ttydelay positive? + spa + jmp ttyrestart i " Yes, can't print the character yet + lac nttychar + dzm nttychar + sza + jmp 3f + isz ttydelay " Increment the tty delay towards zero + lac d2 " Why 2? + jms getchar " Get a character to print + jmp 2f " Why the jump, does getchar skip? Yes if no char +3: + tls " Send the character to the teleprinter + sad o12 + jms putcr " It's a newline, also send a CR? + sad o15 + skp " It was CR, so now insert a delay + jmp ttyrestart i " Not CR, so return from the routine + + lac ttydelay " Add 020 to the ttydelay + tad o20 + rcr " Rotate right once + cma " Invert the AC + dac ttydelay " and save back in ttydelay + jmp ttyrestart i " Now return from the routine +2: + " lac sfiles+1 + " jms wakeup + " dac sfiles+1 + jmp ttyrestart i " Now return from the routine + +getchar: 0 + lac d65 " For now, return ASCII A + isz getchar + jmp i getchar + +putcr: 0 + lac o15 + dac nttychar + cla + jmp putcr i + +d2: 2 +d65: 64 +o12: 012 +o15: 015 +o20: 020 + +ttydelay: 0 +nttychar: .=.+1