mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 04:48:06 +11:00
sio: new driver
This commit is contained in:
parent
7ace3032ef
commit
ddb934813e
1
blk/001
1
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
|
||||
|
5
blk/850
Normal file
5
blk/850
Normal file
@ -0,0 +1,5 @@
|
||||
Zilog SIO driver
|
||||
|
||||
Declarations at B851
|
||||
|
||||
Driver load range at B852-BXXX.
|
14
blk/851
Normal file
14
blk/851
Normal file
@ -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. )
|
15
blk/852
Normal file
15
blk/852
Normal file
@ -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,
|
14
blk/854
Normal file
14
blk/854
Normal file
@ -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!
|
||||
;
|
12
blk/855
Normal file
12
blk/855
Normal file
@ -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)
|
||||
;
|
Loading…
Reference in New Issue
Block a user