2019-02-20 13:16:57 +01:00
|
|
|
# x86 Device Drivers
|
|
|
|
|
|
|
|
This exposes the low level port I/O device to RETRO. These
|
|
|
|
will be used in the implementation of the device drivers.
|
|
|
|
|
|
|
|
~~~
|
|
|
|
{{
|
|
|
|
'io:X86 var
|
|
|
|
:identify
|
|
|
|
@io:X86 n:zero? [
|
|
|
|
#2000 io:scan-for dup n:negative?
|
|
|
|
[ drop 'IO_DEVICE_TYPE_2000_NOT_FOUND s:put nl ]
|
|
|
|
[ !io:X86 ] choose ] if ;
|
|
|
|
---reveal---
|
|
|
|
:io:x86 identify @io:X86 io:invoke ;
|
|
|
|
}}
|
|
|
|
~~~
|
|
|
|
|
|
|
|
# I/O Ports
|
|
|
|
|
|
|
|
~~~
|
|
|
|
:pio:in-byte (p-n) #0 io:x86 ;
|
|
|
|
:pio:out-byte (vp-) #1 io:x86 ;
|
2019-02-20 20:19:31 +01:00
|
|
|
:pio:in-word (p-n) #6 io:x86 ;
|
|
|
|
:pio:out-word (vp-) #7 io:x86 ;
|
2019-02-20 13:16:57 +01:00
|
|
|
~~~
|
|
|
|
|
|
|
|
# Access to Physical RAM
|
|
|
|
|
|
|
|
~~~
|
|
|
|
:ram:store (va-) #2 io:x86 ;
|
|
|
|
:ram:fetch (a-v) #3 io:x86 ;
|
|
|
|
:ram:store-byte (va-) #4 io:x86 ;
|
|
|
|
:ram:fetch-byte (a-v) #5 io:x86 ;
|
|
|
|
~~~
|
|
|
|
|
|
|
|
# Hexadecimal
|
|
|
|
|
|
|
|
Since most resources list the values and ports in hex, I
|
|
|
|
am defining a prefix to be used. This will allow for hex
|
|
|
|
values to be specified like `0xC3`. They must be caps, and
|
|
|
|
negative values are not supported.
|
|
|
|
|
|
|
|
~~~
|
|
|
|
{{
|
2019-06-06 13:15:27 +02:00
|
|
|
:hex (s-n)
|
|
|
|
dup fetch $- eq? [ n:inc #-1 ] [ #0 ] choose swap
|
|
|
|
#0 swap [ '0123456789ABCDEF swap s:index-of + #16 * ] s:for-each
|
|
|
|
#16 / swap 0; * ;
|
2019-02-20 13:16:57 +01:00
|
|
|
---reveal---
|
2019-06-06 13:15:27 +02:00
|
|
|
:prefix:0 (s-...)
|
|
|
|
dup n:dec d:lookup n:-zero?
|
|
|
|
[ n:dec d:lookup [ d:xt fetch ] [ d:class fetch ] bi call ] if;
|
|
|
|
n:inc hex class:data ; immediate
|
2019-02-20 13:16:57 +01:00
|
|
|
}}
|
|
|
|
~~~
|