device nodes and compactflash for GoSXB

This commit is contained in:
mgcaret 2020-12-23 18:07:10 -08:00
parent 619b4ba5d3
commit 7669d292aa
3 changed files with 207 additions and 0 deletions

2
.gitignore vendored
View File

@ -19,3 +19,5 @@ cov.yml
ofw/out
platforms/GoSXB/romfs_files/bench
platforms/GoSXB/romfs_files/of.fs
compactflash.img

View File

@ -0,0 +1,95 @@
\ GoSXB board.fs
s" /" find-device
s" GoSXB" encode-string s" model" property
s" 65xSXB" encode-string s" device-type" property
s" W65C816SXB" encode-string s" compatible" property
1 encode-int s" #address-cells" property
1 encode-int s" #size-cells" property
: decode-unit 1 hex-decode-unit ;
: encode-unit 1 hex-encode-unit ;
new-device
s" cpus" device-name
1 encode-int s" #address-cells" property
0 encode-int s" #size-cells" property
: decode-unit 1 hex-decode-unit ;
: encode-unit 1 hex-encode-unit ;
new-device
0 encode-int s" reg" property
s" WDC,65C816" device-name
s" cpu" device-type
1 encode-int s" #address-cells" property
0 encode-int s" #size-cells" property
s" cpu" get-node node>path set-alias
finish-device
: open true ;
: close ;
finish-device
new-device
s" memory" 2dup device-name device-type
0 encode-int s" reg" property
1 encode-int s" #address-cells" property
1 encode-int s" #size-cells" property
: decode-unit 1 hex-decode-unit ;
: encode-unit 1 hex-encode-unit ;
0 [IF] \ takes too much memory
new-device
s" ram" device-name
0 encode-int s" reg" property
finish-device
new-device
s" mmio" device-name
1 encode-int s" #address-cells" property
8 encode-int s" #size-cells" property
: decode-unit 1 hex-decode-unit ;
: encode-unit 1 hex-encode-unit ;
7f00 encode-int s" reg" property
new-device
s" xcs" device-name
7f00 encode-int s" reg" property
finish-device
new-device
s" xcs" device-name
7f20 encode-int s" reg" property
finish-device
new-device
s" xcs" device-name
7f40 encode-int s" reg" property
finish-device
new-device
s" xcs" device-name
7f60 encode-int s" reg" property
finish-device
new-device
s" acia" device-name
7f80 encode-int s" reg" property
finish-device
new-device
s" pia" device-name
7fa0 encode-int s" reg" property
finish-device
new-device
s" via" device-name
7fc0 encode-int s" reg" property
finish-device
new-device
s" via" device-name
7fe0 encode-int s" reg" property
finish-device
finish-device
new-device
s" rom" device-name
8000 encode-int s" reg" property
finish-device
new-device
s" exp" device-name
10000 encode-int s" reg" property
finish-device
[then]
finish-device
s" /openprom" find-device
s" OF816,beta" encode-string s" model" property
device-end

View File

@ -0,0 +1,110 @@
\ CompactFlash test code
vocabulary cflash
also cflash definitions
7F60 value card-base
E0000000 value lba-select \ drive 0, LBA mode
200 value block-size
struct
1 field card>data
0 field card>features
1 field card>error
1 field card>s-count
4 field card>lba
0 field card>command
1 field card>status
drop
: ?."
ascii " parse
[: rot if type cr else 2drop then ;]
state @ if
-rot postpone sliteral compile,
else
execute
then
; immediate
: send-cmd
card-base card>command c!
;
defer init-card
: cferror ( fatal? -- f | <abort> )
card-base card>status c@ 1 and 0= if drop false exit then
card-base card>error c@ ?dup 0= if drop false exit then
." CF error: " .
03 send-cmd card-base card>error c@
." ; sense code: " . cr
if abort else true then
;
\ wait for busy (b7) to become unset
: busy-wait
card-base card>status
begin
dup c@
dup 80 and 0= if 2drop exit then
1 and if ." (!BUSY) " true cferror drop then
again
;
\ wait for drq (b3) to be asserted
: drq-wait
card-base card>status
begin
dup c@
dup 08 and if 2drop exit then
1 and if ." (DRQ) " true cferror drop then
again
;
: init-card
\ set up 8-bit mode
busy-wait 1 card-base card>features c!
busy-wait ef send-cmd
0 set-lba
;
: set-lba ( lba -- )
busy-wait
0FFFFFFF and lba-select or card-base card>lba !
;
: (read-blk-data) ( addr -- )
busy-wait drq-wait
block-size 0 do
card-base card>data c@
over i + c!
loop
drop
;
: read-block ( lba addr -- )
busy-wait
1 card-base card>s-count c!
swap set-lba
20 send-cmd (read-blk-data)
true cferror drop
;
: (identify-drive) ( addr - )
busy-wait
EC send-cmd (read-blk-data)
;
: identify-drive
init-card 200 alloc-mem >r r@ (identify-drive)
false cferror if r> free-mem ." Error identifying" cr then
r@ a + w@ 0240 <> if r> free-mem ." Unable to identify" cr exit then
r@ 36 + 28 -trailing type ." rev. " r@
r@ 2e + 8 -trailing type cr
r@ 78 + @ . ." LBAs"
r> free-mem
;
previous definitions