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