arcbios.h revision 1.1 1 /* $NetBSD: arcbios.h,v 1.1 2001/07/08 19:58:02 thorpej Exp $ */
2
3 /*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * The ARC BIOS (which is similar, but not 100% compatible with SGI ARCS)
41 * specification can be found at:
42 *
43 * http://www.microsoft.com/hwdev/download/respec/riscspec.zip
44 */
45
46 #define ARCBIOS_STDIN 0
47 #define ARCBIOS_STDOUT 1
48
49 #define ARCBIOS_PAGESIZE 4096
50
51 /* ARC BIOS status codes. */
52 #define ARCBIOS_ESUCCESS 0 /* Success */
53 #define ARCBIOS_E2BIG 1 /* argument list too long */
54 #define ARCBIOS_EACCES 2 /* permission denied */
55 #define ARCBIOS_EAGAIN 3 /* resource temporarily unavailable */
56 #define ARCBIOS_EBADF 4 /* bad file number */
57 #define ARCBIOS_EBUSY 5 /* device or resource busy */
58 #define ARCBIOS_EFAULT 6 /* bad address */
59 #define ARCBIOS_EINVAL 7 /* invalid argument */
60 #define ARCBIOS_EIO 8 /* I/O error */
61 #define ARCBIOS_EISDIR 9 /* is a directory */
62 #define ARCBIOS_EMFILE 10 /* too many open files */
63 #define ARCBIOS_EMLINK 11 /* too many links */
64 #define ARCBIOS_ENAMETOOLONG 12 /* file name too long */
65 #define ARCBIOS_ENODEV 13 /* no such device */
66 #define ARCBIOS_ENOENT 14 /* no such file or directory */
67 #define ARCBIOS_ENOEXEC 15 /* exec format error */
68 #define ARCBIOS_ENOMEM 16 /* out of memory */
69 #define ARCBIOS_ENOSPC 17 /* no space left on device */
70 #define ARCBIOS_ENOTDIR 18 /* not a directory */
71 #define ARCBIOS_ENOTTY 19 /* not a typewriter */
72 #define ARCBIOS_ENXIO 20 /* media not loaded */
73 #define ARCBIOS_EROFS 21 /* read-only file system */
74 #if defined(sgimips)
75 #define ARCBIOS_EADDRNOTAVAIL 31 /* address not available */
76 #define ARCBIOS_ETIMEDOUT 32 /* operation timed out */
77 #define ARCBIOS_ECONNABORTED 33 /* connection aborted */
78 #define ARCBIOS_ENOCONNECT 34 /* not connected */
79 #endif /* sgimips */
80
81 /*
82 * 4.2.2: System Parameter Block
83 */
84 struct arcbios_spb {
85 uint32_t SPBSignature;
86 uint32_t SPBLength;
87 uint16_t Version;
88 uint16_t Revision;
89 void *RestartBlock;
90 void *DebugBlock;
91 void *GEVector;
92 void *UTLBMissVector;
93 uint32_t FirmwareVectorLength;
94 void *FirmwareVector;
95 uint32_t PrivateVectorLength;
96 void *PrivateVector;
97 uint32_t AdapterCount;
98 uint32_t AdapterType;
99 uint32_t AdapterVectorLength;
100 void *AdapterVector;
101 };
102
103 #define ARCBIOS_SPB_SIGNATURE 0x53435241 /* A R C S */
104 #define ARCBIOS_SPB_SIGNATURE_1 0x41524353 /* S C R A */
105
106 /*
107 * 4.2.5: System Configuration Data
108 */
109 struct arcbios_component {
110 uint32_t Class;
111 uint32_t Type;
112 uint32_t Flags;
113 uint16_t Version;
114 uint16_t Revision;
115 uint32_t Key;
116 uint32_t AffinityMask;
117 uint32_t ConfigurationDataSize;
118 uint32_t IdentifierLength;
119 char *Identifier;
120 };
121
122 /* Component Class */
123 #define COMPONENT_CLASS_SystemClass 0
124 #define COMPONENT_CLASS_ProcessorClass 1
125 #define COMPONENT_CLASS_CacheClass 2
126 #define COMPONENT_CLASS_AdapterClass 3
127 #define COMPONENT_CLASS_ControllerClass 4
128 #define COMPONENT_CLASS_PeripheralClass 5
129 #define COMPONENT_CLASS_MemoryClass 6
130
131 /* System Class */
132 #define COMPONENT_TYPE_ARC 0
133
134 /* Processor Class */
135 #define COMPONENT_TYPE_CPU 1
136 #define COMPONENT_TYPE_FPU 2
137
138 /* Cache Class */
139 #define COMPONENT_TYPE_PrimaryICache 3
140 #define COMPONENT_TYPE_PrimaryDCache 4
141 #define COMPONENT_TYPE_SecondaryICache 5
142 #define COMPONENT_TYPE_SecondaryDCache 6
143 #define COMPONENT_TYPE_SecondaryCache 7
144
145 /* Adapter Class */
146 #define COMPONENT_TYPE_EISAAdapter 8
147 #define COMPONENT_TYPE_TCAdapter 9
148 #define COMPONENT_TYPE_SCSIAdapter 10
149 #define COMPONENT_TYPE_DTIAdapter 11
150 #define COMPONENT_TYPE_MultiFunctionAdapter 12
151
152 /* Controller Class */
153 #define COMPONENT_TYPE_DiskController 13
154 #define COMPONENT_TYPE_TapeController 14
155 #define COMPONENT_TYPE_CDROMController 15
156 #define COMPONENT_TYPE_WORMController 16
157 #define COMPONENT_TYPE_SerialController 17
158 #define COMPONENT_TYPE_NetworkController 18
159 #define COMPONENT_TYPE_DisplayController 19
160 #define COMPONENT_TYPE_ParallelController 20
161 #define COMPONENT_TYPE_PointerController 21
162 #define COMPONENT_TYPE_KeyboardController 22
163 #define COMPONENT_TYPE_AudioController 23
164 #define COMPONENT_TYPE_OtherController 24
165
166 /* Peripheral Class */
167 #define COMPONENT_TYPE_DiskPeripheral 25
168 #define COMPONENT_TYPE_FloppyDiskPeripheral 26
169 #define COMPONENT_TYPE_TapePeripheral 27
170 #define COMPONENT_TYPE_ModemPeripheral 28
171 #define COMPONENT_TYPE_MonitorPeripheral 29
172 #define COMPONENT_TYPE_PrinterPeripheral 30
173 #define COMPONENT_TYPE_PointerPeripheral 31
174 #define COMPONENT_TYPE_KeyboardPeripheral 32
175 #define COMPONENT_TYPE_TerminalPeripheral 33
176 #define COMPONENT_TYPE_OtherPeripheral 34
177 #define COMPONENT_TYPE_LinePeripheral 35
178 #define COMPONENT_TYPE_NetworkPeripheral 36
179
180 /* Memory Class */
181 #define COMPONENT_TYPE_MemoryUnit 37
182
183 /* Component flags */
184 #define COMPONENT_FLAG_Failed 1
185 #define COMPONENT_FLAG_ReadOnly 2
186 #define COMPONENT_FLAG_Removable 4
187 #define COMPONENT_FLAG_ConsoleIn 8
188 #define COMPONENT_FLAG_ConsoleOut 16
189 #define COMPONENT_FLAG_Input 32
190 #define COMPONENT_FLAG_Output 64
191
192 /* Key for Cache: */
193 #define COMPONENT_KEY_Cache_CacheSize(x) \
194 (ARCBIOS_PAGESIZE << ((x) & 0xffff))
195 #define COMPONENT_KEY_Cache_LineSize(x) \
196 (1U << (((x) >> 16) & 0xff))
197 #define COMPONENT_KEY_Cache_RefillSize(x) \
198 (((x) >> 24) & 0xff)
199
200 /*
201 * ARC system ID
202 */
203 struct arcbios_sysid {
204 char Vendor[8];
205 char Serial[8];
206 };
207
208 /*
209 * ARC memory descriptor
210 */
211 struct arcbios_mem {
212 uint32_t Type;
213 uint32_t BasePage;
214 uint32_t PageCount;
215 };
216
217 #if defined(sgimips)
218 #define ARCBIOS_MEM_ExecptionBlock 0
219 #define ARCBIOS_MEM_SystemParameterBlock 1
220 #define ARCBIOS_MEM_FreeContiguous 2
221 #define ARCBIOS_MEM_FreeMemory 3
222 #define ARCBIOS_MEM_BadMemory 4
223 #define ARCBIOS_MEM_LoadedProgram 5
224 #define ARCBIOS_MEM_FirmwareTemporary 6
225 #define ARCBIOS_MEM_FirmwarePermanent 7
226 #elif defined(arc)
227 #define ARCBIOS_MEM_ExceptionBlock 0
228 #define ARCBIOS_MEM_SystemParameterBlock 1
229 #define ARCBIOS_MEM_FreeMemory 2
230 #define ARCBIOS_MEM_BadMemory 3
231 #define ARCBIOS_MEM_LoadedProgram 4
232 #define ARCBIOS_MEM_FirmwareTemporary 5
233 #define ARCBIOS_MEM_FirmwarePermanent 6
234 #define ARCBIOS_MEM_FreeContiguous 7
235 #endif
236
237 /*
238 * ARC display status
239 */
240 struct arcbios_dsp_stat {
241 uint16_t CursorXPosition;
242 uint16_t CursorYPosition;
243 uint16_t CursorMaxXPosition;
244 uint16_t CursorMaxYPosition;
245 uint8_t ForegroundColor;
246 uint8_t BackgroundColor;
247 uint8_t HighIntensity;
248 uint8_t Underscored;
249 uint8_t ReverseVideo;
250 };
251
252 /*
253 * ARC firmware vector
254 */
255 struct arcbios_fv {
256 uint32_t (*Load)(
257 char *, /* image to load */
258 uint32_t, /* top address */
259 uint32_t, /* entry address */
260 uint32_t *); /* low address */
261
262 uint32_t (*Invoke)(
263 uint32_t, /* entry address */
264 uint32_t, /* stack address */
265 uint32_t, /* argc */
266 char **, /* argv */
267 char **); /* envp */
268
269 uint32_t (*Execute)(
270 char *, /* image path */
271 uint32_t, /* argc */
272 char **, /* argv */
273 char **); /* envp */
274
275 void (*Halt)(void)
276 __attribute__((__noreturn__));
277
278 void (*PowerDown)(void)
279 __attribute__((__noreturn__));
280
281 void (*Restart)(void)
282 __attribute__((__noreturn__));
283
284 void (*Reboot)(void)
285 __attribute__((__noreturn__));
286
287 void (*EnterInteractiveMode)(void)
288 __attribute__((__noreturn__));
289 #if defined(sgimips)
290 void *reserved0;
291 #else
292 void (*ReturnFromMain)(void)
293 __attribute__((__noreturn__));
294 #endif
295 void *(*GetPeer)(
296 void *); /* component */
297
298 void *(*GetChild)(
299 void *); /* component */
300
301 void *(*GetParent)(
302 void *); /* component */
303
304 uint32_t (*GetConfigurationData)(
305 void *, /* configuration data */
306 void *); /* component */
307
308 void *(*AddChild)(
309 void *, /* component */
310 void *); /* new component */
311
312 uint32_t (*DeleteComponent)(
313 void *); /* component */
314
315 uint32_t (*GetComponent)(
316 char *); /* path */
317
318 uint32_t (*SaveConfiguration)(void);
319
320 void *(*GetSystemId)(void);
321
322 void *(*GetMemoryDescriptor)(
323 void *); /* memory descriptor */
324 #if defined(sgimips)
325 void *reserved1;
326 #else
327 void (*Signal)(
328 uint32_t, /* signal number */
329 void *); /* handler */
330 #endif
331 void *(*GetTime)(void);
332
333 uint32_t (*GetRelativeTime)(void);
334
335 uint32_t (*GetDirectoryEntry)(
336 uint32_t, /* file ID */
337 void *, /* directory entry */
338 uint32_t, /* length */
339 uint32_t *); /* count */
340
341 uint32_t (*Open)(
342 char *, /* path */
343 uint32_t, /* open mode */
344 uint32_t *); /* file ID */
345
346 uint32_t (*Close)(
347 uint32_t); /* file ID */
348
349 uint32_t (*Read)(
350 uint32_t, /* file ID */
351 void *, /* buffer */
352 uint32_t, /* length */
353 uint32_t *); /* count */
354
355 uint32_t (*GetReadStatus)(
356 uint32_t); /* file ID */
357
358 uint32_t (*Write)(
359 uint32_t, /* file ID */
360 void *, /* buffer */
361 uint32_t, /* length */
362 uint32_t *); /* count */
363
364 uint32_t (*Seek)(
365 uint32_t, /* file ID */
366 int64_t *, /* offset */
367 uint32_t); /* whence */
368
369 uint32_t (*Mount)(
370 char *, /* path */
371 uint32_t); /* operation */
372
373 char *(*GetEnvironmentVariable)(
374 char *); /* variable */
375
376 uint32_t (*SetEnvironmentVariable)(
377 char *, /* variable */
378 char *); /* contents */
379
380 uint32_t (*GetFileInformation)(
381 uint32_t, /* file ID */
382 void *); /* XXX */
383
384 uint32_t (*SetFileInformation)(
385 uint32_t, /* file ID */
386 uint32_t, /* XXX */
387 uint32_t); /* XXX */
388
389 void (*FlushAllCaches)(void);
390 #if !defined(sgimips)
391 uint32_t (*TestUnicode)(
392 uint32_t, /* file ID */
393 uint16_t); /* unicode character */
394
395 void *(*GetDisplayStatus)(
396 uint32_t); /* file ID */
397 #endif
398 };
399