Initial revision
[AROS-Contrib.git] / development / compilers / freepascal / rtl / aros / configregs.pas
blob5d10d774616d14b2cc29310e312095d7ccc82d86
2 This file is part of the Free Pascal run time library.
4 A file in Amiga system run time library.
5 Copyright (c) 1998 by Nils Sjoholm
6 member of the Amiga RTL development team.
8 See the file COPYING.FPC, included in this distribution,
9 for details about the copyright.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 **********************************************************************}
17 unit configregs;
19 INTERFACE
21 uses exec;
24 ** AutoConfig (tm) boards each contain a 32 byte "ExpansionRom" area that is
25 ** read by the system software at configuration time. Configuration of each
26 ** board starts when the ConfigIn* signal is passed from the previous board
27 ** (or from the system for the first board). Each board will present it's
28 ** ExpansionRom structure at location $00E80000 to be read by the system.
29 ** This file defines the appearance of the ExpansionRom area.
31 ** Expansion boards are actually organized such that only one nybble per
32 ** 16 bit word contains valid information. The low nybbles of each
33 ** word are combined to fill the structure below. (This table is structured
34 ** as LOGICAL information. This means that it never corresponds exactly
35 ** with a physical implementation.)
37 ** The ExpansionRom space is further split into two regions: The first 16
38 ** bytes are read-only. Except for the er_type field, this area is inverted
39 ** by the system software when read in. The second 16 bytes contain the
40 ** control portion, where all read/write registers are located.
42 ** The system builds one "ConfigDev" structure for each board found. The
43 ** list of boards can be examined using the expansion.library/FindConfigDev
44 ** function.
46 ** A special "hacker" Manufacturer ID number is reserved for test use:
47 ** 2011 ($7DB). When inverted this will look like $F824.
50 Type
52 pExpansionRom = ^tExpansionRom;
53 tExpansionRom = record
54 er_Type : Byte;
55 er_Product : Byte;
56 er_Flags : Byte;
57 er_Reserved03 : Byte;
58 er_Manufacturer : Word;
59 er_SerialNumber : ULONG;
60 er_InitDiagVec : Word;
61 er_Reserved0c : Byte;
62 er_Reserved0d : Byte;
63 er_Reserved0e : Byte;
64 er_Reserved0f : Byte;
65 end;
68 ** Note that use of the ec_BaseAddress register is tricky. The system
69 ** will actually write twice. First the low order nybble is written
70 ** to the ec_BaseAddress register+2 (D15-D12). Then the entire byte is
71 ** written to ec_BaseAddress (D15-D8). This allows writing of a byte-wide
72 ** address to nybble size registers.
75 pExpansionControl = ^tExpansionControl;
76 tExpansionControl = record
77 ec_Interrupt : Byte; { interrupt control register }
78 ec_Reserved11 : Byte;
79 ec_BaseAddress : Byte; { set new config address }
80 ec_Shutup : Byte; { don't respond, pass config out }
81 ec_Reserved14 : Byte;
82 ec_Reserved15 : Byte;
83 ec_Reserved16 : Byte;
84 ec_Reserved17 : Byte;
85 ec_Reserved18 : Byte;
86 ec_Reserved19 : Byte;
87 ec_Reserved1a : Byte;
88 ec_Reserved1b : Byte;
89 ec_Reserved1c : Byte;
90 ec_Reserved1d : Byte;
91 ec_Reserved1e : Byte;
92 ec_Reserved1f : Byte;
93 end;
96 ** many of the constants below consist of a triplet of equivalent
97 ** definitions: xxMASK is a bit mask of those bits that matter.
98 ** xxBIT is the starting bit number of the field. xxSIZE is the
99 ** number of bits that make up the definition. This method is
100 ** used when the field is larger than one bit.
102 ** If the field is only one bit wide then the xxB_xx and xxF_xx convention
103 ** is used (xxB_xx is the bit number, and xxF_xx is mask of the bit).
106 Const
108 { manifest constants }
110 E_SLOTSIZE = $10000;
111 E_SLOTMASK = -1;
112 E_SLOTSHIFT = 16;
114 { these define the two free regions of Zorro memory space.
115 ** THESE MAY WELL CHANGE FOR FUTURE PRODUCTS!
118 E_EXPANSIONBASE = $e80000;
119 EZ3_EXPANSIONBASE = $ff000000; { Zorro III config address }
120 E_EXPANSIONSIZE = $080000;
121 E_EXPANSIONSLOTS = 8;
123 E_MEMORYBASE = $200000;
124 E_MEMORYSIZE = $800000;
125 E_MEMORYSLOTS = 128;
127 EZ3_CONFIGAREA = $40000000; { Zorro III space }
128 EZ3_CONFIGAREAEND = $7FFFFFFF; { Zorro III space }
129 EZ3_SIZEGRANULARITY = $00080000; { 512K increments }
133 { *** er_Type definitions (ttldcmmm) **************************************}
135 { er_Type board type bits -- the OS ignores "old style" boards }
136 ERT_TYPEMASK = $c0; {Bits 7-6 }
137 ERT_TYPEBIT = 6 ;
138 ERT_TYPESIZE = 2 ;
139 ERT_NEWBOARD = $c0;
140 ERT_ZORROII = ERT_NEWBOARD;
141 ERT_ZORROIII = $80;
143 { other bits defined in er_Type }
144 ERTB_MEMLIST = 5; { Link RAM into free memory list }
145 ERTB_DIAGVALID = 4; { ROM vector is valid }
146 ERTB_CHAINEDCONFIG = 3; { Next config is part of the same card }
148 ERTF_MEMLIST = 32;
149 ERTF_DIAGVALID = 16;
150 ERTF_CHAINEDCONFIG = 8;
152 { er_Type field memory size bits }
153 ERT_MEMMASK = $07; {Bits 2-0 }
154 ERT_MEMBIT = 0 ;
155 ERT_MEMSIZE = 3 ;
159 { *** er_Flags byte -- for those things that didn't fit into the type byte ***}
160 { *** the hardware stores this byte in inverted form ***}
161 ERFF_MEMSPACE = 128; { Wants to be in 8 meg space. }
162 ERFB_MEMSPACE = 7; { (NOT IMPLEMENTED) }
164 ERFF_NOSHUTUP = 64; { Board can't be shut up }
165 ERFB_NOSHUTUP = 6;
167 ERFF_EXTENDED = 32; { Zorro III: Use extended size table }
168 ERFB_EXTENDED = 5; { for bits 0-2 of er_Type }
169 { Zorro II : Must be 0 }
171 ERFF_ZORRO_III = 16; { Zorro III: must be 1 }
172 ERFB_ZORRO_III = 4; { Zorro II : must be 0 }
174 ERT_Z3_SSMASK = $0F; { Bits 3-0. Zorro III Sub-Size. How }
175 ERT_Z3_SSBIT = 0; { much space the card actually uses }
176 ERT_Z3_SSSIZE = 4; { (regardless of config granularity) }
177 { Zorro II : must be 0 }
180 { ec_Interrupt register (unused) *******************************************}
181 ECIB_INTENA = 1;
182 ECIB_RESET = 3;
183 ECIB_INT2PEND = 4;
184 ECIB_INT6PEND = 5;
185 ECIB_INT7PEND = 6;
186 ECIB_INTERRUPTING = 7;
188 ECIF_INTENA = 2;
189 ECIF_RESET = 8;
190 ECIF_INT2PEND = 16;
191 ECIF_INT6PEND = 32;
192 ECIF_INT7PEND = 64;
193 ECIF_INTERRUPTING = 128;
196 {**************************************************************************
198 ** these are the specifications for the diagnostic area. If the Diagnostic
199 ** Address Valid bit is set in the Board Type byte (the first byte in
200 ** expansion space) then the Diag Init vector contains a valid offset.
202 ** The Diag Init vector is actually a word offset from the base of the
203 ** board. The resulting address points to the base of the DiagArea
204 ** structure. The structure may be physically implemented either four,
205 ** eight, or sixteen bits wide. The code will be copied out into
206 ** ram first before being called.
208 ** The da_Size field, and both code offsets (da_DiagPoint and da_BootPoint)
209 ** are offsets from the diag area AFTER it has been copied into ram, and
210 ** "de-nibbleized" (if needed). Inotherwords, the size is the size of
211 ** the actual information, not how much address space is required to
212 ** store it.
214 ** All bits are encoded with uninverted logic (e.g. 5 volts on the bus
215 ** is a logic one).
217 ** If your board is to make use of the boot facility then it must leave
218 ** its config area available even after it has been configured. Your
219 ** boot vector will be called AFTER your board's final address has been
220 ** set.
222 ***************************************************************************}
224 Type
226 pDiagArea = ^tDiagArea;
227 tDiagArea = record
228 da_Config : Byte; { see below for definitions }
229 da_Flags : Byte; { see below for definitions }
230 da_Size : Word; { the size (in bytes) of the total diag area }
231 da_DiagPoint : Word; { where to start for diagnostics, or zero }
232 da_BootPoint : Word; { where to start for booting }
233 da_Name : Word; { offset in diag area where a string }
234 { identifier can be found (or zero if no }
235 { identifier is present). }
237 da_Reserved01 : Word; { two words of reserved data. must be zero. }
238 da_Reserved02 : Word;
239 end;
241 Const
243 { da_Config definitions }
245 DAC_BUSWIDTH = $C0; { two bits for bus width }
246 DAC_NIBBLEWIDE = $00;
247 DAC_BYTEWIDE = $40;
248 DAC_WORDWIDE = $80;
250 DAC_BOOTTIME = $30; { two bits for when to boot }
251 DAC_NEVER = $00; { obvious }
252 DAC_CONFIGTIME = $10; { call da_BootPoint when first configing the }
253 { the device }
254 DAC_BINDTIME = $20; { run when binding drivers to boards }
257 ** These are the calling conventions for Diag or Boot area
259 ** A7 -- points to at least 2K of stack
260 ** A6 -- ExecBase
261 ** A5 -- ExpansionBase
262 ** A3 -- your board's ConfigDev structure
263 ** A2 -- Base of diag/init area that was copied
264 ** A0 -- Base of your board
266 ** Your board should return a value in D0. If this value is NULL, then
267 ** the diag/init area that was copied in will be returned to the free
268 ** memory pool.
271 IMPLEMENTATION
273 end.