Writing FCode 3.x Programs
|
|
Writing FCode 3.x Programs
806-1379-10
Figures
Tables
Preface
1. SBus Cards and FCode
FCode PROM Format
Interpreting FCode
Device Identification
Creating and Executing FCode Definitions
2. PCI FCode Information
PCI FCode PROM Header Format
The PCI Expansion PROM Header Format
PCI Expansion PROM Data Structure Format
Format of Physical Address in reg Property
CPU PROM-Generated Properties
Adding a PCI Header to a PROM
3. Elements of FCode Programming
Colon Definitions
Stack Operations
Programming Style
Commenting Code
Coding Style
Definition Length
Stack Comments
A Minimal FCode Program
FCode Classes
Primitive FCode Functions
System FCode Functions
Interface FCode Functions
Local FCode Functions
4. Debugging and Testing FCode Programs
Packaging PCI FCode
System Flags and FCode Debugging
FCode Source
Tokenizing FCode Source
FCode Binary Format
Testing FCode Programs on the Target Machine
Configuring the Target Machine
Setting Appropriate Configuration Parameters
Modifying the Expansion Bus Probe Sequence
Getting to the Forth Monitor
Using the Command Line Editor of the Forth Monitor
Using the Forth Monitor to Test FCode Programs
Using dload to Load From Ethernet
Using dlbin to Load From Serial Port A
Using boot to Load From Hard Disk, Diskette, or Ethernet
Using dl to Load Forth Over Serial Port A
Using the Forth Monitor to Interpret an FCode Program
Using the Forth Monitor to Browse a Device Node
Using the Forth Monitor to Test a Device Driver
Device Node Methods
Testing FCode Programs in Source Form
Producing an FCode PROM
Exercising an Installed FCode PROM
Debugging Errors Generated by select-dev
5. Helpful Testing and Debugging Hints
Accessing a PCI Device's Configuration Space Registers
Base Address Register Setting
System Cache Line Size
Sun Ultra 30 UPA/PCI-Related Nodes
Finding and Using Physical Addresses
Controlling PCI Slot Probing on an Ultra 30 UPA/PCI System
Using 3.x Tokenizer and 3.x CPU PROMs
PCI Device Configuration Register Access
Boot Software Roles
Enabling Access to a PCI Device's Memory Space Locations
Expansion FCode PROM
Packaging Error With Ethernet FCode
6. Packages
Package Descriptions
Package Instances
Package Data
Static and Instance-Specific Methods
Execution Tokens
Intra-Package Calling Methods
Accessing Other Packages With phandle and ihandle
Inter-Package Calling Methods
execute-device-method and apply
Plug-in Device Drivers
Common Package Methods
Basic Methods
open
close
Recommended Methods
reset
selftest
Package Data Definitions
Instance Arguments and Parameters
Package Addresses
Package Mappings
The nvramrc Facility
Modifying Package Properties
Standard Support Packages
Sun Disk Label Support Package
TFTP Booting Support Package
Deblocker Support Package
7. Properties
Standard FCode Properties
Standard Property Names
Display Device Properties
Network Device Properties
Memory Device Properties
General Properties for Parent Nodes
Properties for PCI Parent Nodes
Properties for PCI Child Nodes
Detailed Descriptions of Standard Properties
#address-cells
#size-cells
address
address-bits
alternate-reg
assigned-addresses
available
big-endian-aperture
bus-range
character-set
class-code
compatible
depth
device-id
device_type
devsel-speed
existing
fast-back-to-back
has-fcode
height
interrupts
linebytes
little-endian-aperture
local-mac-address
mac-address
max-frame-size
max-latency
min-grant
model
name
page-size
power-consumption
ranges
reg
revision-id
slot-names
status
translations
vendor-id
width
Manipulating Properties
Property Creation and Modification
Property Values
Property Encoding
Property Retrieval
Property Decoding
Property-Specific FCodes
8. Block and Byte Devices
Block Devices
Byte Devices
Required Methods
block-size ( -- block-len )
load ( addr -- size )
max-transfer ( -- max-len )
read ( addr len -- actual )
read-blocks ( addr block# #blocks -- #read )
seek ( poslow poshigh -- status ) for block; seek ( offset file# -- error? ) for byte
write ( addr len -- actual )
write-blocks ( addr block# #blocks -- #written )
Required Properties
Device Driver Examples
Simple Block Device Driver
Extended Block Device Driver
Complete Block and Byte Device Driver
9. Display Devices
Required Methods
Required Properties
Device Driver Examples
Extended Display Device Driver
Complete Display Device Drive
10. Memory-Mapped Buses
Required Methods
decode-unit ( addr len -- phys.lo ... phys.hi )
dma-alloc ( size -- virt )
dma-free ( virt size -- )
dma-map-in ( virt size cacheable? -- devaddr )
dma-map-out ( virt devaddr size -- )
dma-sync ( virt devaddr size -- )
probe-self ( arg-addr arg-len reg- addr reg-len fcode-addr fcode-len -- )
map-in ( phys.lo ... phys.hi size -- virt )
map-out ( virt size -- )
SBus Addressing
SBus Required Properties
Device Driver Examples
Basic Hierarchical Device Driver
Extended Hierarchical Device Driver
Complete Hierarchical Device Driver
11. Network Devices
Required Methods
load ( addr -- len )
read ( addr len -- actual )
write ( addr len -- actual )
Required Device Properties
Optional Device Properties
Device Driver Examples
Simple Network Device Example
Sample Driver With Test and Debugging Methods
Bootable Network Device Driver Example
12. Serial Devices
Required Methods
install-abort ( -- )
read ( addr len -- actual )
remove-abort ( -- )
write ( addr len -- actual )
Required Properties
Device Driver Examples
Simple Serial FCode Program
Extended Serial FCode Program
Complete Serial FCode Program
13. PCI FCode Driver Example
14. FCode Dictionary
Special Characters
!
"
#
#>
'
(
(.)
*
*/
+
+!
,
-
.
."
.(
/
:
;
<
<#
<<
<=
<>
=
>
>=
>>
?
@
[
[']
\
]
Numerical Characters
0
0<
0<=
0<>
0=
0>
0>=
1
1+
1-
-1
2
2!
2*
2+
2-
2/
2@
3
A Words
>>a
abort
abs
accept
again
alarm
alias
align
aligned
alloc-mem
allot
and
ascii
B Words
b(")
b(')
b(:)
b(;)
base
b(constant)
b(create)
b(defer)
b(do)
b(?do)
because
begin
behavior
bell
b(endcase)
b(endof)
between
b(field)
bl
blank
b(leave)
blink-screen
b(lit)
bljoin
b(loop)
b(+loop)
b(<mark)
>body
b(of)
bounds
branch
branch
b(>resolve)
bs
b(to)
buffer:
buffer:)
b(value)
b(variable)
bwjoin
bxjoin
byte-load
C Words
c!
c,
/c
/c*
c@
ca+
ca1+
$call-method
call-package
$call-parent
carret
Xcase
catch
cell+
cells
char-height
chars
char-width
child
close-package
cmove>
column#
#columns
comp
compile,
[compile]
constant
control
count
cpeek
cpoke
cr
(cr
create
D Words
d#
d+
d-
.d
decimal
decode-bytes
decode-int
decode-phys
decode-string
default-font
defer
delete-characters
delete-lines
delete-property
depth
device-name
diagnostic-mode?
digit
do
?do
draw-character
draw-logo
drop
2drop
3drop
dup
2dup
3dup
?dup
E Words
else
emit
emit-byte
encode+
encode-bytes
encode-int
encode-phys
encode-string
end0
end1
endcase
endof
erase
erase-screen
eval
evaluate
execute
exit
expect
external
external-token
F Words
false
fb1-blink-screen
fb1-delete-characters
fb1-draw-character
fb1-draw-logo
fb1-erase-screen
fb1-insert-characters
fb1-insert-lines
fb1-install
fb1-invert-screen
fb1-reset-screen
fb1-slide-up
fb1-toggle-cursor
fb8-blink-screen
fb8-delete-characters
fb8-delete-lines
fb8-draw-character
fb8-draw-logo
fb8-erase-screen
fb8-insert-characters
fb8-insert-lines
fb8-install
fb8-invert-screen
fb8-reset-screen
fb8-toggle-cursor
fcode-revision
fcode-version1
fcode-version2
ferror
field
fill
$find
find-method
find-package
finish-device
fload
>font
fontbytes
frame-buffer-adr
free-mem
free-virtual
G Words
get-inherited-property
get-msecs
get-my-property
get-package-property
get-token
H Words
h# number
.h
headerless
headers
here
hex
hold
I Words
i
if
ihandle>phandle
insert-characters
insert-lines
instance
inverse?
inverse-screen?
invert
invert-screen
is-stack
is-install
is-remove
is-selftest
(is-user-word)
J - L Words
j
key
key?
l!
l,
l@
/l
/l*
<l@
la+
la1+
lbflip
lbflips
lbsplit
lcc
leave
?leave
left-parse-string
line#
#line
linefeed
#lines
loop
+loop
lpeek
lpoke
lshift
lwflip
lwflips
lwsplit
lxjoin
M Words
mac-address
map-low
mask
max
memory-test-suite
min
mod
*/mod
/mod
model
move
ms
my-address
my-args
my-parent
my-self
my-space
my-unit
N Words
/n
/n*
na+
na1+
name
named-token
negate
new-device
new-token
next-property
nip
noop
not
$number
O Words
of
off
offset16
on
open-package
$open-package
or
#out
over
2over
P Words
pack
parse-2int
peer
pick
property
R Words
r>
r@
.r
>r
rb!
rb@
reg
repeat
reset-screen
rl!
rl@
roll
rot
-rot
2rot
rshift
rw!
rw@
rx@
rx!
S Words
s"
s.
#s
.s
sbus-intr>cpu
screen-height
screen-width
set-args
set-font
set-token
sign
space
spaces
span
start0
start1
start2
start4
state
struct
suspend-fcode
swap
2swap
T Words
then
throw
to
toggle-cursor
tokenizer[
]tokenizer
true
tuck
type
U Words
u#
u#>
u#s
u.
u<
u<=
u>
u>=
(u.)
u2/
um*
um/mod
u/mod
unloop
until
upc
u.r
user-abort
V Words
value
variable
version1
versionx?
W Words
w!
w,
w@
/w
/w*
<w@
wa+
wa1+
wbflip
wbflips
wbsplit
while
window-left
window-top
within
wljoin
wpeek
wpoke
wxjoin
X Words
x,
x@
x!
/x
xa+
xa1+
xbflip
xbflips
xbsplit
xlflip
xlflips
xlsplit
xor
xwflip
xwflips
xwsplit
A. FCode Reference
FCodes by Function
FCodes by Byte Value
FCodes by Name
B. FCode Memory Allocation
C. Forth Coding Style
Typographic Conventions
Use of Spaces
if...then...else
do...loop
begin...while...repeat
begin...until...again
Block Comments
Stack Comments
Return Stack Comments
Numbers
D. Differences Between FCode 2.x and FCode 3.x
Index
Writing FCode 3.x Programs
|
806-1379-10
|
|
Copyright © 2004, Sun Microsystems, Inc. All Rights Reserved.