1 |
/* gxemul: $Id: arcbios_other.h,v 1.3 2005/03/05 12:34:02 debug Exp $ */ |
2 |
/* $NetBSD: arcbios.h,v 1.2 2000/01/23 21:01:50 soda Exp $ */ |
3 |
/* $OpenBSD: arcbios.h,v 1.4 1997/05/01 15:13:30 pefo Exp $ */ |
4 |
|
5 |
#ifndef ARCBIOS_OTHER_H |
6 |
#define ARCBIOS_OTHER_H |
7 |
|
8 |
/*- |
9 |
* Copyright (c) 1996 M. Warner Losh. All rights reserved. |
10 |
* |
11 |
* Redistribution and use in source and binary forms, with or without |
12 |
* modification, are permitted provided that the following conditions |
13 |
* are met: |
14 |
* 1. Redistributions of source code must retain the above copyright |
15 |
* notice, this list of conditions and the following disclaimer. |
16 |
* 2. Redistributions in binary form must reproduce the above copyright |
17 |
* notice, this list of conditions and the following disclaimer in the |
18 |
* documentation and/or other materials provided with the distribution. |
19 |
* 3. Neither the name of the University nor the names of its contributors |
20 |
* may be used to endorse or promote products derived from this software |
21 |
* without specific prior written permission. |
22 |
* |
23 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
24 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
25 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
26 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
27 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
28 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
29 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
30 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
31 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
32 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
33 |
* SUCH DAMAGE. |
34 |
*/ |
35 |
|
36 |
#include <sys/types.h> |
37 |
|
38 |
typedef struct arc_sid |
39 |
{ |
40 |
char vendor[8]; |
41 |
char prodid[8]; |
42 |
} arc_sid_t; |
43 |
|
44 |
/* struct arc_config::class */ |
45 |
#define arc_SystemClass 0 |
46 |
#define arc_ProcessorClass 1 |
47 |
#define arc_CacheClass 2 |
48 |
#define arc_AdapterClass 3 |
49 |
#define arc_ControllerClass 4 |
50 |
#define arc_PeripheralClass 5 |
51 |
#define arc_MemoryClass 6 |
52 |
|
53 |
/* struct arc_config::type */ |
54 |
#define arc_System |
55 |
|
56 |
#define arc_CentralProcessor |
57 |
#define arc_FloatingPointProcessor |
58 |
|
59 |
#define arc_PrimaryIcache |
60 |
#define arc_PrimaryDcache |
61 |
#define arc_SecondaryIcache |
62 |
#define arc_SecondaryDcache |
63 |
#define arc_SecondaryCache |
64 |
|
65 |
#define arc_EisaAdapter /* Eisa adapter */ |
66 |
#define arc_TcAdapter /* Turbochannel adapter */ |
67 |
#define arc_ScsiAdapter /* SCSI adapter */ |
68 |
#define arc_DtiAdapter /* AccessBus adapter */ |
69 |
#define arc_MultiFunctionAdapter |
70 |
|
71 |
#define arc_DiskController 0 |
72 |
#define arc_TapeController 1 |
73 |
#define arc_CdromController 2 |
74 |
#define arc_WormController 3 |
75 |
#define arc_SerialController 4 |
76 |
#define arc_NetworkController 5 |
77 |
#define arc_DisplayController 6 |
78 |
#define arc_ParallelController 7 |
79 |
#define arc_PointerController 8 |
80 |
#define arc_KeyboardController 9 |
81 |
#define arc_AudioController 10 |
82 |
#define arc_OtherController 11 /* denotes a controller not otherwise defined */ |
83 |
|
84 |
#define arc_DiskPeripheral 12 |
85 |
#define arc_FloppyDiskPeripheral 13 |
86 |
#define arc_TapePeripheral 14 |
87 |
#define arc_ModemPeripheral 15 |
88 |
#define arc_MonitorPeripheral 16 |
89 |
#define arc_PrinterPeripheral 17 |
90 |
#define arc_PointerPeripheral 18 |
91 |
#define arc_KeyboardPeripheral 19 |
92 |
#define arc_TerminalPeripheral 20 |
93 |
#define arc_OtherPeripheral 21 /* denotes a peripheral not otherwise defined */ |
94 |
#define arc_LinePeripheral 22 |
95 |
#define arc_NetworkPeripheral 23 |
96 |
|
97 |
#define arc_SystemMemory 24 |
98 |
|
99 |
/* struct arc_config::flag */ |
100 |
#define arc_PeripheralFailed 0x01 |
101 |
#define arc_PeripheralReadOnly 0x02 |
102 |
#define arc_PeripheralRemovable 0x04 |
103 |
#define arc_PeripheralConsoleIn 0x08 |
104 |
#define arc_PeripheralConsoleOut 0x10 |
105 |
#define arc_PeripheralInput 0x20 |
106 |
#define arc_PeripheralOutput 0x40 |
107 |
|
108 |
/* Wonder how this is aligned... */ |
109 |
typedef struct arc_config |
110 |
{ |
111 |
u_int32_t class; |
112 |
u_int32_t type; |
113 |
u_int32_t flags; |
114 |
u_int16_t version; |
115 |
u_int16_t revision; |
116 |
u_int32_t key; |
117 |
u_int32_t affinity_mask; |
118 |
u_int32_t config_data_len; |
119 |
u_int32_t id_len; |
120 |
char *id; |
121 |
} arc_config_t; |
122 |
|
123 |
typedef enum arc_cm_resource_type { |
124 |
arc_CmResourceTypeNull, |
125 |
arc_CmResourceTypePort, |
126 |
arc_CmResourceTypeInterrupt, |
127 |
arc_CmResourceTypeMemory, |
128 |
arc_CmResourceTypeDMA, |
129 |
arc_CmResourceTypeDeviceSpecific, |
130 |
arc_CmResourceTypeVendor, |
131 |
arc_CmResourceTypeProductName, |
132 |
arc_CmResourceTypeSerialNumber |
133 |
} arc_cm_resource_type_t; |
134 |
|
135 |
/* do not use u_int64_t to avoid alignment problem */ |
136 |
typedef struct { |
137 |
u_int32_t loword; |
138 |
u_int32_t hiword; |
139 |
} arc_paddr_t; |
140 |
|
141 |
typedef struct arc_cm_partial_resource { |
142 |
u_int8_t type; |
143 |
u_int8_t share_disposition; |
144 |
u_int16_t flags; |
145 |
|
146 |
union { |
147 |
struct { |
148 |
arc_paddr_t start; |
149 |
u_int32_t length; |
150 |
} port; |
151 |
struct { |
152 |
u_int32_t level; |
153 |
u_int32_t vector; |
154 |
u_int32_t reserved1; |
155 |
} interrupt; |
156 |
struct { |
157 |
arc_paddr_t start; |
158 |
u_int32_t length; |
159 |
} memory; |
160 |
struct { |
161 |
u_int32_t channel; |
162 |
u_int32_t port; |
163 |
u_int32_t reserved1; |
164 |
} dma; |
165 |
struct { |
166 |
u_int8_t vendor[12]; |
167 |
} vendor; |
168 |
struct { |
169 |
u_int8_t product_name[12]; |
170 |
} product_name; |
171 |
struct { |
172 |
u_int8_t serial_number[12]; |
173 |
} serial_number; |
174 |
struct { |
175 |
u_int32_t data_size; |
176 |
u_int32_t reserved1; |
177 |
u_int32_t reserved2; |
178 |
/* the data is followed */ |
179 |
} device_specific_data; |
180 |
} u; |
181 |
} arc_cm_partial_resource_t; |
182 |
|
183 |
typedef struct arc_cm_partial_resource_list { |
184 |
u_int16_t version; |
185 |
u_int16_t revision; |
186 |
u_int32_t count; |
187 |
arc_cm_partial_resource_t partial_descriptors[1]; |
188 |
} arc_cm_partial_resource_list_t; |
189 |
|
190 |
typedef enum arc_cm_share_disposition { |
191 |
arc_CmResourceShareUndetermined, |
192 |
arc_CmResourceShareDeviceExclusive, |
193 |
arc_CmResourceShareDriverExclusive, |
194 |
arc_CmResourceShareShared |
195 |
} arc_cm_share_disposition_t; |
196 |
|
197 |
/* arc_cm_partial_resource_t::flags when type == arc_CmResourceTypeInterrupt */ |
198 |
typedef enum arc_cm_flags_interrupt { |
199 |
arc_CmResourceInterruptLevelSensitive, |
200 |
arc_CmResourceInterruptLatched |
201 |
} arc_cm_flags_interrupt_t; |
202 |
|
203 |
/* arc_cm_partial_resource_t::flags when type == arc_CmResourceTypeMemory */ |
204 |
typedef enum arc_cm_flags_memory { |
205 |
arc_CmResourceMemoryReadWrite, |
206 |
arc_CmResourceMemoryReadOnly, |
207 |
arc_CmResourceMemoryWriteOnly |
208 |
} arc_cm_flags_memory_t; |
209 |
|
210 |
/* arc_cm_partial_resource_t::flags when type == arc_CmResourceTypePort */ |
211 |
typedef enum arc_cm_flags_port { |
212 |
arc_CmResourcePortMemory, |
213 |
arc_CmResourcePortIO |
214 |
} arc_cm_flags_port; |
215 |
|
216 |
typedef enum arc_status |
217 |
{ |
218 |
arc_ESUCCESS, /* Success */ |
219 |
arc_E2BIG, /* Arg list too long */ |
220 |
arc_EACCES, /* No such file or directory */ |
221 |
arc_EAGAIN, /* Try again */ |
222 |
arc_EBADF, /* Bad file number */ |
223 |
arc_EBUSY, /* Device or resource busy */ |
224 |
arc_EFAULT, /* Bad address */ |
225 |
arc_EINVAL, /* Invalid argument */ |
226 |
arc_EIO, /* I/O error */ |
227 |
arc_EISDIR, /* Is a directory */ |
228 |
arc_EMFILE, /* Too many open files */ |
229 |
arc_EMLINK, /* Too many links */ |
230 |
arc_ENAMETOOLONG, /* File name too long */ |
231 |
arc_ENODEV, /* No such device */ |
232 |
arc_ENOENT, /* No such file or directory */ |
233 |
arc_ENOEXEC, /* Exec format error */ |
234 |
arc_ENOMEM, /* Out of memory */ |
235 |
arc_ENOSPC, /* No space left on device */ |
236 |
arc_ENOTDIR, /* Not a directory */ |
237 |
arc_ENOTTY, /* Not a typewriter */ |
238 |
arc_ENXIO, /* No such device or address */ |
239 |
arc_EROFS, /* Read-only file system */ |
240 |
} arc_status_t; |
241 |
|
242 |
typedef enum { |
243 |
ExeceptionBlock, |
244 |
SystemParameterBlock, |
245 |
FreeMemory, |
246 |
BadMemory, |
247 |
LoadedProgram, |
248 |
FirmwareTemporary, |
249 |
FirmwarePermanent, |
250 |
FreeContigous |
251 |
} arc_mem_type_t; |
252 |
|
253 |
typedef struct arc_mem { |
254 |
arc_mem_type_t Type; /* Memory chunk type */ |
255 |
u_int32_t BasePage; /* Page no, first page */ |
256 |
u_int32_t PageCount; /* Number of pages */ |
257 |
} arc_mem_t; |
258 |
|
259 |
typedef caddr_t arc_time_t; /* XXX */ |
260 |
|
261 |
typedef struct arc_dsp_stat { |
262 |
u_int16_t CursorXPosition; |
263 |
u_int16_t CursorYPosition; |
264 |
u_int16_t CursorMaxXPosition; |
265 |
u_int16_t CursorMaxYPosition; |
266 |
u_int8_t ForegroundColor; |
267 |
u_int8_t BackgroundColor; |
268 |
u_int8_t HighIntensity; |
269 |
u_int8_t Underscored; |
270 |
u_int8_t ReverseVideo; |
271 |
} arc_dsp_stat_t; |
272 |
|
273 |
typedef caddr_t arc_dirent_t; /* XXX */ |
274 |
typedef u_int32_t arc_seek_mode_t; /* XXX */ |
275 |
typedef u_int32_t arc_mount_t; /* XXX */ |
276 |
|
277 |
typedef enum arc_open_mode { |
278 |
arc_OpenReadOnly, |
279 |
arc_OpenWriteOnly, |
280 |
arc_OpenReadWrite, |
281 |
arc_CreateWriteOnly, |
282 |
arc_CreateReadWrite, |
283 |
arc_SupersedeWriteOnly, |
284 |
arc_SupersedeReadWrite, |
285 |
arc_OpenDirectory, |
286 |
arc_createDirectory |
287 |
} arc_open_mode_t; |
288 |
|
289 |
typedef struct arc_calls |
290 |
{ |
291 |
arc_status_t (*load)( /* Load 1 */ |
292 |
char *, /* Image to load */ |
293 |
u_int32_t, /* top address */ |
294 |
u_int32_t *, /* Entry address */ |
295 |
u_int32_t *); /* Low address */ |
296 |
|
297 |
arc_status_t (*invoke)( /* Invoke 2 */ |
298 |
u_int32_t, /* Entry Address */ |
299 |
u_int32_t, /* Stack Address */ |
300 |
u_int32_t, /* Argc */ |
301 |
char **, /* argv */ |
302 |
char **); /* envp */ |
303 |
|
304 |
arc_status_t (*execute)( /* Execute 3 */ |
305 |
char *, /* Image path */ |
306 |
u_int32_t, /* Argc */ |
307 |
char **, /* argv */ |
308 |
char **); /* envp */ |
309 |
|
310 |
void (*halt)(void); /* Halt 4 */ |
311 |
|
312 |
void (*power_down)(void); /* PowerDown 5 */ |
313 |
|
314 |
void (*restart)(void); /* Restart 6 */ |
315 |
|
316 |
void (*reboot)(void); /* Reboot 7 */ |
317 |
|
318 |
void (*enter_interactive_mode)(void); /* EnterInteractiveMode 8 */ |
319 |
|
320 |
void (*return_from_main)(void); /* ReturnFromMain 9 */ |
321 |
|
322 |
arc_config_t *(*get_peer)( /* GetPeer 10 */ |
323 |
arc_config_t *); /* Component */ |
324 |
|
325 |
arc_config_t *(*get_child)( /* GetChild 11 */ |
326 |
arc_config_t *); /* Component */ |
327 |
|
328 |
arc_config_t *(*get_parent)( /* GetParent 12 */ |
329 |
arc_config_t *); /* Component */ |
330 |
|
331 |
arc_status_t (*get_config_data)( /* GetConfigurationData 13 */ |
332 |
caddr_t, /* Configuration Data */ |
333 |
arc_config_t *); /* Component */ |
334 |
|
335 |
arc_config_t *(*add_child)( /* AddChild 14 */ |
336 |
arc_config_t *, /* Component */ |
337 |
arc_config_t *); /* New Component */ |
338 |
|
339 |
arc_status_t (*delete_component)( /* DeleteComponent 15 */ |
340 |
arc_config_t *); /* Component */ |
341 |
|
342 |
arc_config_t *(*get_component)( /* GetComponent 16 */ |
343 |
char *); /* Path */ |
344 |
|
345 |
arc_status_t (*save_config)(void); /* SaveConfiguration 17 */ |
346 |
|
347 |
arc_sid_t *(*get_system_id)(void); /* GetSystemId 18 */ |
348 |
|
349 |
arc_mem_t *(*get_memory_descriptor)( /* GetMemoryDescriptor 19 */ |
350 |
arc_mem_t *); /* MemoryDescriptor */ |
351 |
|
352 |
void (*signal)( /* Signal 20 */ |
353 |
u_int32_t, /* Signal number */ |
354 |
/**/ caddr_t); /* Handler */ |
355 |
|
356 |
arc_time_t *(*get_time)(void); /* GetTime 21 */ |
357 |
|
358 |
u_int32_t (*get_relative_time)(void); /* GetRelativeTime 22 */ |
359 |
|
360 |
arc_status_t (*get_dir_entry)( /* GetDirectoryEntry 23 */ |
361 |
u_int32_t, /* FileId */ |
362 |
arc_dirent_t *, /* Directory entry */ |
363 |
u_int32_t, /* Length */ |
364 |
u_int32_t *); /* Count */ |
365 |
|
366 |
arc_status_t (*open)( /* Open 24 */ |
367 |
char *, /* Path */ |
368 |
arc_open_mode_t, /* Open mode */ |
369 |
u_int32_t *); /* FileId */ |
370 |
|
371 |
arc_status_t (*close)( /* Close 25 */ |
372 |
u_int32_t); /* FileId */ |
373 |
|
374 |
arc_status_t (*read)( /* Read 26 */ |
375 |
u_int32_t, /* FileId */ |
376 |
caddr_t, /* Buffer */ |
377 |
u_int32_t, /* Length */ |
378 |
u_int32_t *); /* Count */ |
379 |
|
380 |
arc_status_t (*get_read_status)( /* GetReadStatus 27 */ |
381 |
u_int32_t); /* FileId */ |
382 |
|
383 |
arc_status_t (*write)( /* Write 28 */ |
384 |
u_int32_t, /* FileId */ |
385 |
caddr_t, /* Buffer */ |
386 |
u_int32_t, /* Length */ |
387 |
u_int32_t *); /* Count */ |
388 |
|
389 |
arc_status_t (*seek)( /* Seek 29 */ |
390 |
u_int32_t, /* FileId */ |
391 |
int64_t *, /* Offset */ |
392 |
arc_seek_mode_t); /* Mode */ |
393 |
|
394 |
arc_status_t (*mount)( /* Mount 30 */ |
395 |
char *, /* Path */ |
396 |
arc_mount_t); /* Operation */ |
397 |
|
398 |
char *(*getenv)( /* GetEnvironmentVariable 31 */ |
399 |
char *); /* Variable */ |
400 |
|
401 |
arc_status_t (*putenv)( /* SetEnvironmentVariable 32 */ |
402 |
char *, /* Variable */ |
403 |
char *); /* Value */ |
404 |
|
405 |
arc_status_t (*get_file_info)(void); /* GetFileInformation 33 */ |
406 |
|
407 |
arc_status_t (*set_file_info)(void); /* SetFileInformation 34 */ |
408 |
|
409 |
void (*flush_all_caches)(void); /* FlushAllCaches 35 */ |
410 |
|
411 |
arc_status_t (*test_unicode)( /* TestUnicodeCharacter 36 */ |
412 |
u_int32_t, /* FileId */ |
413 |
u_int16_t); /* UnicodeCharacter */ |
414 |
|
415 |
arc_dsp_stat_t *(*get_display_status)( /* GetDisplayStatus 37 */ |
416 |
u_int32_t); /* FileId */ |
417 |
} arc_calls_t; |
418 |
|
419 |
#define ARC_PARAM_BLK_MAGIC 0x53435241 /* "ARCS" in little endian */ |
420 |
#define ARC_PARAM_BLK_MAGIC_BUG 0x41524353 /* This is wrong... but req */ |
421 |
|
422 |
typedef struct arc_param_blk |
423 |
{ |
424 |
u_int32_t magic; /* Magic Number */ |
425 |
u_int32_t length; /* Length of parameter block */ |
426 |
u_int16_t version; /* ?? */ |
427 |
u_int16_t revision; /* ?? */ |
428 |
/**/ caddr_t restart_block; /* ?? */ |
429 |
/**/ caddr_t debug_block; /* Debugging info -- unused */ |
430 |
/**/ caddr_t general_exp_vect; /* ?? */ |
431 |
/**/ caddr_t tlb_miss_exp_vect; /* ?? */ |
432 |
u_int32_t firmware_length; /* Size of Firmware jumptable in bytes */ |
433 |
arc_calls_t *firmware_vect; /* Firmware jumptable */ |
434 |
u_int32_t vendor_length; /* Size of Vendor specific jumptable */ |
435 |
/**/ caddr_t vendor_vect; /* Vendor specific jumptable */ |
436 |
u_int32_t adapter_count; /* ?? */ |
437 |
struct arc_adapter_param { |
438 |
u_int32_t adapter_type; /* ?? */ |
439 |
u_int32_t adapter_length; /* ?? */ |
440 |
/**/ caddr_t adapter_vect; /* ?? */ |
441 |
} adapters[1]; |
442 |
} arc_param_blk_t; |
443 |
|
444 |
#define ArcBiosBase ((arc_param_blk_t *) 0x80001000) |
445 |
#define ArcBios (ArcBiosBase->firmware_vect) |
446 |
|
447 |
#if 0 |
448 |
arc_status_t Bios_Read __P((int, void *, int, int *)); |
449 |
arc_status_t Bios_Write __P((int, void *, int, int *)); |
450 |
arc_status_t Bios_Open __P((char *, int, u_int *)); |
451 |
arc_status_t Bios_Close __P((u_int)); |
452 |
arc_mem_t *Bios_GetMemoryDescriptor __P((arc_mem_t *)); |
453 |
arc_sid_t *Bios_GetSystemId __P((void)); |
454 |
arc_config_t *Bios_GetChild __P((arc_config_t *)); |
455 |
arc_config_t *Bios_GetPeer __P((arc_config_t *)); |
456 |
int Bios_GetConfigurationData __P((void *, arc_config_t *)); |
457 |
arc_dsp_stat_t *Bios_GetDisplayStatus __P((int)); |
458 |
|
459 |
const char *const arc_strerror __P((int error)); |
460 |
|
461 |
int biosgetc __P((dev_t)); |
462 |
void biosputc __P((dev_t, int)); |
463 |
#endif |
464 |
|
465 |
#endif /* ARCBIOS_OTHER_H */ |
466 |
|