README
1Welcome to the OpenBIOS tokenizer Toke.
2
3This README provides you with a short description of the tokenizer and
4of how to use it.
5
6---------------------------------------------------------------------
7
8Table of contents:
9
101. What is the OpenBIOS tokenizer?
112. What is required to build the OpenBIOS tokenizer?
123. How to use the OpenBIOS tokenizer
134. Toke's Special Features not described in IEEE 1275-1994
145. Text Strings
156. Contact
16
17---------------------------------------------------------------------
18
191. What is the OpenBIOS tokenizer?
20
21 toke is a GPLed FCode tokenizer. It can tokenize (assemble) fcode
22 source to bytecode files as described by the IEEE 1275-1994 standard.
23
24 This program is compliant to IEEE 1275-1994.
25
26 Bytecode files normally contain Open Firmware drivers or other
27 packages for use with an Open Firmware compliant system.
28
29
302. What is required to build the OpenBIOS tokenizer?
31
32 toke should build with any ANSI compliant C compiler.
33
34 For building toke on certain platforms you might have to adjust the
35 Makefile. If so, please contact Stefan Reinauer <stepan@openbios.org>
36
37 Build toke by just enter "make". To clean up an existing build,
38 use "make clean" or "make distclean"
39
40
413. How to use the OpenBIOS tokenizer
42
43 tokenize an fcode source file with
44 toke [-v|--verbose] [-i|--ignore-errors] <file.4th> [<file2.4th>]
45
46 Get help with:
47 toke [-h|--help]
48
49 The file extension will be changed to .fc. If no file extension
50 exists, .fc will be appended. If -i is specified, toke continues
51 on errors, producing invalid fcode binaries.
52
53
544. Toke's Special Features not described in IEEE 1275-1994
55
56 In addition to the standard Open Firmware words, some additional
57 commands have been added to make life easier and for compatibility
58 to other, mostly commercial, fcode tokenizers. These are:
59
604.1 NEXT-FCODE
61
62 In tokenizer[ .. ]tokenizer context there is an additional control
63 word besides emit-byte: next-fcode. It sets the increasing fcode
64 number used to emit new fcode words to the specified value. Thus
65 allowing sparse fcode numbering and overwriting previously defined
66 fcode words.
67
68 This could look like:
69 -------------------------------------------
70 \ next emitted fcode is 0x053, 2dup.
71 tokenizer[ 053 next-fcode ]tokenizer
72 \ now define the word.
73 : 2dup over over ;
74 -------------------------------------------
75
76 Note: Toke is capable of creating fcode files that implement words
77 defined by the IEEE 1275-1994 standard itself. This is not necessarily
78 supported by every Open Firmware implementation.
79
80
814.2 FCODE-VERSION2
82
83 This word generates an FCode header using START1. It should be used
84 with FCODE-END.
85
86
874.3 FCODE-END
88
89 This word creates an END0 FCode and fixes up the FCode header
90 information. Use this with FCODE-VERSION2
91
92
934.4 PCI-HEADER
94
95 This word creates a PCI option ROM header. PCI-HEADER expects 3
96 values on the top of the stack when it is invoked: Vendor#, Device#
97 and Class-Code.
98
99 These values are used for the according fields in the PCI Data
100 structure that is emitted by PCI-HEADER. To include these values
101 put them on the stack with TOKENIZER[ and ]TOKENIZER.
102
103
1044.5 PCI-END / PCI-HEADER-END
105
106 This word completes the PCI header created by PCI-HEADER. It fills out
107 the image to a multiple of 512 bytes, and sets the missing values in
108 the PCI header (image-length, revision).
109
110 Example:
111 HEX
112 TOKENIZER[ 1234 5678 ABCDEF ]TOKENIZER
113 PCI-HEADER \ generate PCI option rom header
114 FCODE-VERSION2 \ generate FCode header (within PCI image)
115 ...
116 ...
117 FCODE-END \ terminate FCode in image
118 PCI-END \ complete the PCI header and image.
119
120
1214.6 PCI-REVISION / SET-REV-LEVEL
122
123 Use this word to change the revision field of the PCI header. Like
124 PCI-HEADER, PCI-REVISION takes it's value from the stack. You can
125 write: TOKENIZER[ 23 ]TOKENIZER PCI-REVISION
126
127
1284.7 NOT-LAST-IMAGE
129
130 Normally Toke assumes that a PCI image generated by PCI-HEADER is
131 the only ROM image in the (EEP)ROM it will be written to. With
132 NOT-LAST-IMAGE Toke sets a flag in the PCI header that other images
133 will follow in the same ROM.
134
135
1364.8 FCODE-DATE
137
138 FCODE-DATE creates an FCode string that contains the date of the
139 tokenization. This string could be used to create a device tree
140 property that can be inspected by drivers, etc. to check when the
141 image was created. The format of the string emitted by FCODE-DATE
142 is MM/DD.YYYY
143
144
1454.9 FCODE-TIME
146
147 FCODE-TIME creates an FCode string that contains the time of the
148 tokenization. This string could be used to create a device tree
149 property that can be inspected by drivers, etc. to check when the
150 image was created. The format of the string emitted by FCODE-TIME
151 is HH:MM:SS
152
153
1544.10 ENCODE-FILE
155
156 encode a binary file. Use as: encode-file filename
157
158
1595. Text Strings
160
161 From "Writing FCode":
162 Escape Sequences in Text Strings
163
164 -----------------------------------------------------------
165 Syntax Function
166 -----------------------------------------------------------
167 "" quote (")
168 "n newline
169 "r carriage return
170 "t tab
171 "f formfeed
172 "l linefeed
173 "b backspace
174 "! bell
175 "^x control x, where x is any printable
176 character
177 "(hh hh) Sequence of bytes, one byte for each pair
178 of hex digits hh . Non-hex characters will
179 be ignored
180
181 " followed by any other printable character not mentioned
182 above is equivalent to that character.
183
184 "( means to start parsing pairs of hexadecimal digits as
185 one or more 8-bit characters in the range 0x00 through
186 0xFF, delimited by a trailing ) and ignoring
187 non-hexadecimal digits between pairs of hexadecimal
188 digits. Both uppercase and lowercase hexadecimal digits are
189 recognized. Since non-hex characters (such as space or
190 comma) are ignored between "( and ), these characters make
191 useful delimiters. (The "makearray" tool can be used in
192 conjunction with this syntax to easily incorporate large
193 binary data fields into any FCode Program.)
194
195 Any characters thus recognized are appended to any previous
196 text in the string being assembled. After the ) is
197 recognized, text assembly continues until a trailing
198 "<whitespace>.
199
200 For example:
201
202 " This is "(01 32,8e)abc"nA test! "!"! abcd""hijk"^bl"
203 ^^^^^^^^ ^ ^ ^ ^ ^
204 3 bytes newline 2 bells " control b
205
2066. Contact
207
208 Ideas, bug reports, patches, contributions are welcome.
209
210 Stefan Reinauer <stepan@openbios.org>
211
212
213