Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / arcbios / arcbios.h
blobd1ade49c006437440c29121f1c0e995965571d78
1 /* $NetBSD: arcbios.h,v 1.11 2007/12/25 18:33:36 perry Exp $ */
3 /*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * The ARC BIOS (which is similar, but not 100% compatible with SGI ARCS)
34 * specification can be found at:
36 * http://www.microsoft.com/hwdev/download/respec/riscspec.zip
39 #ifndef _ARCBIOS_H_
40 #define _ARCBIOS_H_
42 #define ARCBIOS_STDIN 0
43 #define ARCBIOS_STDOUT 1
45 #define ARCBIOS_PAGESIZE 4096
47 /* ARC BIOS status codes. */
48 #define ARCBIOS_ESUCCESS 0 /* Success */
49 #define ARCBIOS_E2BIG 1 /* argument list too long */
50 #define ARCBIOS_EACCES 2 /* permission denied */
51 #define ARCBIOS_EAGAIN 3 /* resource temporarily unavailable */
52 #define ARCBIOS_EBADF 4 /* bad file number */
53 #define ARCBIOS_EBUSY 5 /* device or resource busy */
54 #define ARCBIOS_EFAULT 6 /* bad address */
55 #define ARCBIOS_EINVAL 7 /* invalid argument */
56 #define ARCBIOS_EIO 8 /* I/O error */
57 #define ARCBIOS_EISDIR 9 /* is a directory */
58 #define ARCBIOS_EMFILE 10 /* too many open files */
59 #define ARCBIOS_EMLINK 11 /* too many links */
60 #define ARCBIOS_ENAMETOOLONG 12 /* file name too long */
61 #define ARCBIOS_ENODEV 13 /* no such device */
62 #define ARCBIOS_ENOENT 14 /* no such file or directory */
63 #define ARCBIOS_ENOEXEC 15 /* exec format error */
64 #define ARCBIOS_ENOMEM 16 /* out of memory */
65 #define ARCBIOS_ENOSPC 17 /* no space left on device */
66 #define ARCBIOS_ENOTDIR 18 /* not a directory */
67 #define ARCBIOS_ENOTTY 19 /* not a typewriter */
68 #define ARCBIOS_ENXIO 20 /* media not loaded */
69 #define ARCBIOS_EROFS 21 /* read-only file system */
70 #if defined(sgimips)
71 #define ARCBIOS_EADDRNOTAVAIL 31 /* address not available */
72 #define ARCBIOS_ETIMEDOUT 32 /* operation timed out */
73 #define ARCBIOS_ECONNABORTED 33 /* connection aborted */
74 #define ARCBIOS_ENOCONNECT 34 /* not connected */
75 #endif /* sgimips */
78 * 4.2.2: System Parameter Block
80 struct arcbios_spb {
81 u_long SPBSignature;
82 u_long SPBLength;
83 uint16_t Version;
84 uint16_t Revision;
85 void *RestartBlock;
86 void *DebugBlock;
87 void *GEVector;
88 void *UTLBMissVector;
89 u_long FirmwareVectorLength;
90 void *FirmwareVector;
91 u_long PrivateVectorLength;
92 void *PrivateVector;
93 u_long AdapterCount;
94 u_long AdapterType;
95 u_long AdapterVectorLength;
96 void *AdapterVector;
99 #define ARCBIOS_SPB_SIGNATURE 0x53435241 /* A R C S */
100 #define ARCBIOS_SPB_SIGNATURE_1 0x41524353 /* S C R A */
103 * 4.2.5: System Configuration Data
105 struct arcbios_component {
106 uint32_t Class;
107 uint32_t Type;
108 uint32_t Flags;
109 uint16_t Version;
110 uint16_t Revision;
111 u_long Key;
112 u_long AffinityMask;
113 u_long ConfigurationDataSize;
114 u_long IdentifierLength;
115 char *Identifier;
119 * SGI ARCS likes to be `special', so it moved some of the class/type
120 * numbers around from the ARC standard definitions.
122 #if defined(sgimips)
123 /* Component Class */
124 #define COMPONENT_CLASS_SystemClass 0
125 #define COMPONENT_CLASS_ProcessorClass 1
126 #define COMPONENT_CLASS_CacheClass 2
127 #define COMPONENT_CLASS_MemoryClass 3
128 #define COMPONENT_CLASS_AdapterClass 4
129 #define COMPONENT_CLASS_ControllerClass 5
130 #define COMPONENT_CLASS_PeripheralClass 6
131 #else
132 /* Component Class */
133 #define COMPONENT_CLASS_SystemClass 0
134 #define COMPONENT_CLASS_ProcessorClass 1
135 #define COMPONENT_CLASS_CacheClass 2
136 #define COMPONENT_CLASS_AdapterClass 3
137 #define COMPONENT_CLASS_ControllerClass 4
138 #define COMPONENT_CLASS_PeripheralClass 5
139 #define COMPONENT_CLASS_MemoryClass 6
140 #endif
142 /* Component Types */
143 #if defined(sgimips)
144 /* System Class */
145 #define COMPONENT_TYPE_ARC 0
147 /* Processor Class */
148 #define COMPONENT_TYPE_CPU 1
149 #define COMPONENT_TYPE_FPU 2
151 /* Cache Class */
152 #define COMPONENT_TYPE_PrimaryICache 3
153 #define COMPONENT_TYPE_PrimaryDCache 4
154 #define COMPONENT_TYPE_SecondaryICache 5
155 #define COMPONENT_TYPE_SecondaryDCache 6
156 #define COMPONENT_TYPE_SecondaryCache 7
158 /* Memory Class */
159 #define COMPONENT_TYPE_MemoryUnit 8
161 /* Adapter Class */
162 #define COMPONENT_TYPE_EISAAdapter 9
163 #define COMPONENT_TYPE_TCAdapter 10
164 #define COMPONENT_TYPE_SCSIAdapter 11
165 #define COMPONENT_TYPE_DTIAdapter 12
166 #define COMPONENT_TYPE_MultiFunctionAdapter 13
168 /* Controller Class */
169 #define COMPONENT_TYPE_DiskController 14
170 #define COMPONENT_TYPE_TapeController 15
171 #define COMPONENT_TYPE_CDROMController 16
172 #define COMPONENT_TYPE_WORMController 17
173 #define COMPONENT_TYPE_SerialController 18
174 #define COMPONENT_TYPE_NetworkController 19
175 #define COMPONENT_TYPE_DisplayController 20
176 #define COMPONENT_TYPE_ParallelController 21
177 #define COMPONENT_TYPE_PointerController 22
178 #define COMPONENT_TYPE_KeyboardController 23
179 #define COMPONENT_TYPE_AudioController 24
180 #define COMPONENT_TYPE_OtherController 25
182 /* Peripheral Class */
183 #define COMPONENT_TYPE_DiskPeripheral 26
184 #define COMPONENT_TYPE_FloppyDiskPeripheral 27
185 #define COMPONENT_TYPE_TapePeripheral 28
186 #define COMPONENT_TYPE_ModemPeripheral 29
187 #define COMPONENT_TYPE_MonitorPeripheral 30
188 #define COMPONENT_TYPE_PrinterPeripheral 31
189 #define COMPONENT_TYPE_PointerPeripheral 32
190 #define COMPONENT_TYPE_KeyboardPeripheral 33
191 #define COMPONENT_TYPE_TerminalPeripheral 34
192 #define COMPONENT_TYPE_LinePeripheral 35
193 #define COMPONENT_TYPE_NetworkPeripheral 36
194 #define COMPONENT_TYPE_OtherPeripheral 37
195 #else /* not sgimips */
196 /* System Class */
197 #define COMPONENT_TYPE_ARC 0
199 /* Processor Class */
200 #define COMPONENT_TYPE_CPU 1
201 #define COMPONENT_TYPE_FPU 2
203 /* Cache Class */
204 #define COMPONENT_TYPE_PrimaryICache 3
205 #define COMPONENT_TYPE_PrimaryDCache 4
206 #define COMPONENT_TYPE_SecondaryICache 5
207 #define COMPONENT_TYPE_SecondaryDCache 6
208 #define COMPONENT_TYPE_SecondaryCache 7
210 /* Adapter Class */
211 #define COMPONENT_TYPE_EISAAdapter 8
212 #define COMPONENT_TYPE_TCAdapter 9
213 #define COMPONENT_TYPE_SCSIAdapter 10
214 #define COMPONENT_TYPE_DTIAdapter 11
215 #define COMPONENT_TYPE_MultiFunctionAdapter 12
217 /* Controller Class */
218 #define COMPONENT_TYPE_DiskController 13
219 #define COMPONENT_TYPE_TapeController 14
220 #define COMPONENT_TYPE_CDROMController 15
221 #define COMPONENT_TYPE_WORMController 16
222 #define COMPONENT_TYPE_SerialController 17
223 #define COMPONENT_TYPE_NetworkController 18
224 #define COMPONENT_TYPE_DisplayController 19
225 #define COMPONENT_TYPE_ParallelController 20
226 #define COMPONENT_TYPE_PointerController 21
227 #define COMPONENT_TYPE_KeyboardController 22
228 #define COMPONENT_TYPE_AudioController 23
229 #define COMPONENT_TYPE_OtherController 24
231 /* Peripheral Class */
232 #define COMPONENT_TYPE_DiskPeripheral 25
233 #define COMPONENT_TYPE_FloppyDiskPeripheral 26
234 #define COMPONENT_TYPE_TapePeripheral 27
235 #define COMPONENT_TYPE_ModemPeripheral 28
236 #define COMPONENT_TYPE_MonitorPeripheral 29
237 #define COMPONENT_TYPE_PrinterPeripheral 30
238 #define COMPONENT_TYPE_PointerPeripheral 31
239 #define COMPONENT_TYPE_KeyboardPeripheral 32
240 #define COMPONENT_TYPE_TerminalPeripheral 33
241 #define COMPONENT_TYPE_OtherPeripheral 34
242 #define COMPONENT_TYPE_LinePeripheral 35
243 #define COMPONENT_TYPE_NetworkPeripheral 36
245 /* Memory Class */
246 #define COMPONENT_TYPE_MemoryUnit 37
247 #endif
249 /* Component flags */
250 #define COMPONENT_FLAG_Failed 1
251 #define COMPONENT_FLAG_ReadOnly 2
252 #define COMPONENT_FLAG_Removable 4
253 #define COMPONENT_FLAG_ConsoleIn 8
254 #define COMPONENT_FLAG_ConsoleOut 16
255 #define COMPONENT_FLAG_Input 32
256 #define COMPONENT_FLAG_Output 64
258 /* Key for Cache: */
259 #define COMPONENT_KEY_Cache_CacheSize(x) \
260 (ARCBIOS_PAGESIZE << ((x) & 0xffff))
261 #define COMPONENT_KEY_Cache_LineSize(x) \
262 (1U << (((x) >> 16) & 0xff))
263 #define COMPONENT_KEY_Cache_RefillSize(x) \
264 (((x) >> 24) & 0xff)
267 * ARC system ID
269 #define ARCBIOS_SYSID_FIELDLEN 8
270 struct arcbios_sysid {
271 char VendorId[ARCBIOS_SYSID_FIELDLEN];
272 char ProductId[ARCBIOS_SYSID_FIELDLEN];
276 * ARC memory descriptor
278 struct arcbios_mem {
279 uint32_t Type;
280 u_long BasePage;
281 u_long PageCount;
284 #if defined(sgimips)
285 #define ARCBIOS_MEM_ExceptionBlock 0
286 #define ARCBIOS_MEM_SystemParameterBlock 1
287 #define ARCBIOS_MEM_FreeContiguous 2
288 #define ARCBIOS_MEM_FreeMemory 3
289 #define ARCBIOS_MEM_BadMemory 4
290 #define ARCBIOS_MEM_LoadedProgram 5
291 #define ARCBIOS_MEM_FirmwareTemporary 6
292 #define ARCBIOS_MEM_FirmwarePermanent 7
293 #elif defined(arc)
294 #define ARCBIOS_MEM_ExceptionBlock 0
295 #define ARCBIOS_MEM_SystemParameterBlock 1
296 #define ARCBIOS_MEM_FreeMemory 2
297 #define ARCBIOS_MEM_BadMemory 3
298 #define ARCBIOS_MEM_LoadedProgram 4
299 #define ARCBIOS_MEM_FirmwareTemporary 5
300 #define ARCBIOS_MEM_FirmwarePermanent 6
301 #define ARCBIOS_MEM_FreeContiguous 7
302 #endif
305 * ARC display status
307 struct arcbios_dsp_stat {
308 uint16_t CursorXPosition;
309 uint16_t CursorYPosition;
310 uint16_t CursorMaxXPosition;
311 uint16_t CursorMaxYPosition;
312 uint8_t ForegroundColor;
313 uint8_t BackgroundColor;
314 uint8_t HighIntensity;
315 uint8_t Underscored;
316 uint8_t ReverseVideo;
320 * ARC firmware vector
322 struct arcbios_fv {
323 long (*Load)(
324 char *, /* image to load */
325 u_long, /* top address */
326 u_long, /* entry address */
327 u_long *); /* low address */
329 long (*Invoke)(
330 u_long, /* entry address */
331 u_long, /* stack address */
332 u_long, /* argc */
333 char **, /* argv */
334 char **); /* envp */
336 long (*Execute)(
337 char *, /* image path */
338 u_long, /* argc */
339 char **, /* argv */
340 char **); /* envp */
342 void (*Halt)(void)
343 __dead;
345 void (*PowerDown)(void)
346 __dead;
348 void (*Restart)(void)
349 __dead;
351 void (*Reboot)(void)
352 __dead;
354 void (*EnterInteractiveMode)(void)
355 __dead;
356 #if defined(sgimips)
357 void *reserved0;
358 #else
359 void (*ReturnFromMain)(void)
360 __dead;
361 #endif
362 void *(*GetPeer)(
363 void *); /* component */
365 void *(*GetChild)(
366 void *); /* component */
368 void *(*GetParent)(
369 void *); /* component */
371 long (*GetConfigurationData)(
372 void *, /* configuration data */
373 void *); /* component */
375 void *(*AddChild)(
376 void *, /* component */
377 void *); /* new component */
379 long (*DeleteComponent)(
380 void *); /* component */
382 void *(*GetComponent)(
383 char *); /* path */
385 long (*SaveConfiguration)(void);
387 void *(*GetSystemId)(void);
389 void *(*GetMemoryDescriptor)(
390 void *); /* memory descriptor */
391 #if defined(sgimips)
392 void *reserved1;
393 #else
394 void (*Signal)(
395 u_long, /* signal number */
396 void *); /* handler */
397 #endif
398 void *(*GetTime)(void);
400 u_long (*GetRelativeTime)(void);
402 long (*GetDirectoryEntry)(
403 u_long, /* file ID */
404 void *, /* directory entry */
405 u_long, /* length */
406 u_long *); /* count */
408 long (*Open)(
409 char *, /* path */
410 u_long, /* open mode */
411 u_long *); /* file ID */
413 long (*Close)(
414 u_long); /* file ID */
416 long (*Read)(
417 u_long, /* file ID */
418 void *, /* buffer */
419 u_long, /* length */
420 u_long *); /* count */
422 long (*GetReadStatus)(
423 u_long); /* file ID */
425 long (*Write)(
426 u_long, /* file ID */
427 void *, /* buffer */
428 u_long, /* length */
429 u_long *); /* count */
431 long (*Seek)(
432 u_long, /* file ID */
433 int64_t *, /* offset */
434 u_long); /* whence */
436 long (*Mount)(
437 char *, /* path */
438 u_long); /* operation */
440 const char *(*GetEnvironmentVariable)(
441 const char *); /* variable */
443 long (*SetEnvironmentVariable)(
444 const char *, /* variable */
445 const char *); /* contents */
447 long (*GetFileInformation)(
448 u_long, /* file ID */
449 void *); /* XXX */
451 long (*SetFileInformation)(
452 u_long, /* file ID */
453 u_long, /* XXX */
454 u_long); /* XXX */
456 void (*FlushAllCaches)(void);
457 #if !defined(sgimips)
458 paddr_t (*TestUnicode)(
459 u_long, /* file ID */
460 uint16_t); /* unicode character */
462 void *(*GetDisplayStatus)(
463 u_long); /* file ID */
464 #endif
467 #endif /* _ARCBIOS_H_ */