From ddb934813e9682d69161c80bf3fa3b9d1dce0f58 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sat, 15 Aug 2020 09:44:19 -0400 Subject: [PATCH] sio: new driver --- blk/001 | 1 + blk/850 | 5 +++++ blk/851 | 14 ++++++++++++++ blk/852 | 15 +++++++++++++++ blk/854 | 14 ++++++++++++++ blk/855 | 12 ++++++++++++ 6 files changed, 61 insertions(+) create mode 100644 blk/850 create mode 100644 blk/851 create mode 100644 blk/852 create mode 100644 blk/854 create mode 100644 blk/855 diff --git a/blk/001 b/blk/001 index c3b0e68..5e258be 100644 --- a/blk/001 +++ b/blk/001 @@ -11,3 +11,4 @@ MASTER INDEX 620 Sega Master System Recipe 650 AVR assembler 730 8086 assembler 800 8086 boot code 830 PC/AT recipe +850 Zilog SIO driver diff --git a/blk/850 b/blk/850 new file mode 100644 index 0000000..676548c --- /dev/null +++ b/blk/850 @@ -0,0 +1,5 @@ +Zilog SIO driver + +Declarations at B851 + +Driver load range at B852-BXXX. diff --git a/blk/851 b/blk/851 new file mode 100644 index 0000000..523a4f7 --- /dev/null +++ b/blk/851 @@ -0,0 +1,14 @@ +0x80 CONSTANT SIO_ACTL 0x81 CONSTANT SIO_ADATA +0x82 CONSTANT SIO_BCTL 0x83 CONSTANT SIO_BDATA +0x20 CONSTANT SIO_BUFSZ ( SZ-1 must be a mask ) +( Address in memory that can be used variables shared + with SIO native words. 4 bytes used. ) +CREATE SIO_MEM SYSVARS 0x70 + , +( Points to SIO buf ) +: SIO( SIO_MEM @ 2+ ; +( Read buf idx Pre-inc ) +: SIOR> SIO_MEM @ ; +( Write buf idx Post-inc ) +: SIOW> SIO_MEM @ 1+ ; +( This means that if W> == R>, buffer is full. + If R>+1 == W>, buffer is empty. ) diff --git a/blk/852 b/blk/852 new file mode 100644 index 0000000..7b6fcf8 --- /dev/null +++ b/blk/852 @@ -0,0 +1,15 @@ +( INT handler. Set RST 38 jump ) PC ORG @ 0x39 + ! +AF PUSH, BEGIN, +SIO_ACTL INAi, ( RR0 ) 0x01 ANDi, ( is recv buf full? ) +IFZ, ( nope, exit ) A 0x20 ( CMD 4 ) LDri, SIO_ACTL OUTiA, + AF POP, EI, RETI, THEN, +HL PUSH, +HL SIOW> LDdi, A (HL) LDrr, +HL DECd, (HL) CPr, ( W> == R> ? ) +IFNZ, ( buffer not full ) + ( get wr ptr ) HL SIO( LDd(i), + L ADDr, IFC, H INCr, THEN, L A LDrr, + ( fetch/write ) SIO_ADATA INAi, (HL) A LDrr, + ( advance W> ) SIOW> LDA(i), A INCr, + SIO_BUFSZ 1- ANDi, SIOW> LD(i)A, +THEN, HL POP, JR, AGAIN, diff --git a/blk/854 b/blk/854 new file mode 100644 index 0000000..2175d30 --- /dev/null +++ b/blk/854 @@ -0,0 +1,14 @@ +: (key) + ( inc then fetch ) + [ SIOR> LITN ] C@ 1+ [ SIO_BUFSZ 1- LITN ] AND + ( As long as R> == W>-1, it means that buffer is empty ) + BEGIN DUP [ SIOW> LITN ] C@ = NOT UNTIL + DUP [ SIO( LITN ] @ + C@ ( ridx c ) + SWAP [ SIOR> LITN ] C! ( c ) +; +: (emit) + ( As long at CTL bit 2 is low, we are transmitting. wait ) + BEGIN [ SIO_ACTL LITN ] PC@ 0x04 AND UNTIL + ( The way is clear, go! ) + [ SIO_ADATA LITN ] PC! +; diff --git a/blk/855 b/blk/855 new file mode 100644 index 0000000..b1e6616 --- /dev/null +++ b/blk/855 @@ -0,0 +1,12 @@ +: _ [ SIO_ACTL LITN ] PC! ; +: SIO$ + H@ [ SIO( LITN ] ! 0 [ SIOR> LITN ] C! + 1 [ SIOW> LITN ] C! ( write index starts one pos later ) + [ SIO_BUFSZ LITN ] ALLOT + 0x18 _ ( CMD3 ) + 0x24 _ ( CMD2/PTR4 ) 0b11000100 _ ( WR4/64x/1stop/nopar ) + 0x03 _ ( PTR3 ) 0b11000001 _ ( WR3/RXen/8char ) + 0x05 _ ( PTR5 ) 0b11001000 _ ( WR5/TXen/8char ) + 0x21 _ ( CMD2/PTR1 ) 0b00011000 _ ( WR1/Rx INT all chars ) + (im1) +;