xref: /netbsd/sys/arch/arc/arc/arcbios.h (revision cc2d9d22)
1 /*	$NetBSD: arcbios.h,v 1.11 2017/06/22 16:46:53 flxd Exp $	*/
2 /*	$OpenBSD: arcbios.h,v 1.1 1998/01/29 15:06:22 pefo Exp $	*/
3 
4 /*-
5  * Copyright (c) 1996 M. Warner Losh.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31 
32 #include <sys/types.h>
33 
34 typedef struct arc_sid
35 {
36 	char vendor[8];
37 	char prodid[8];
38 } arc_sid_t;
39 
40 typedef enum arc_config_class
41 {
42 	arc_SystemClass,
43 	arc_ProcessorClass,
44 	arc_CacheClass,
45 	arc_AdapterClass,
46 	arc_ControllerClass,
47 	arc_PeripheralClass,
48 	arc_MemoryClass
49 } arc_config_class_t;
50 
51 typedef enum arc_config_type
52 {
53 	arc_System,
54 
55 	arc_CentralProcessor,
56 	arc_FloatingPointProcessor,
57 
58 	arc_PrimaryIcache,
59 	arc_PrimaryDcache,
60 	arc_SecondaryIcache,
61 	arc_SecondaryDcache,
62 	arc_SecondaryCache,
63 
64 	arc_EisaAdapter,		/* Eisa adapter         */
65 	arc_TcAdapter,			/* TURBOchannel adapter */
66 	arc_ScsiAdapter,		/* SCSI adapter         */
67 	arc_DtiAdapter,			/* AccessBus adapter    */
68 	arc_MultiFunctionAdapter,
69 
70 	arc_DiskController,
71 	arc_TapeController,
72 	arc_CdromController,
73 	arc_WormController,
74 	arc_SerialController,
75 	arc_NetworkController,
76 	arc_DisplayController,
77 	arc_ParallelController,
78 	arc_PointerController,
79 	arc_KeyboardController,
80 	arc_AudioController,
81 	arc_OtherController,		/* denotes a controller not otherwise defined */
82 
83 	arc_DiskPeripheral,
84 	arc_FloppyDiskPeripheral,
85 	arc_TapePeripheral,
86 	arc_ModemPeripheral,
87 	arc_MonitorPeripheral,
88 	arc_PrinterPeripheral,
89 	arc_PointerPeripheral,
90 	arc_KeyboardPeripheral,
91 	arc_TerminalPeripheral,
92 	arc_OtherPeripheral,		/* denotes a peripheral not otherwise defined   */
93 	arc_LinePeripheral,
94 	arc_NetworkPeripheral,
95 
96 	arc_SystemMemory
97 } arc_config_type_t;
98 
99 typedef u_char arc_dev_flags_t;
100 
101 /* Wonder how this is aligned... */
102 typedef struct arc_config
103 {
104 	arc_config_class_t	class;		/* Likely these three all */
105 	arc_config_type_t	type;		/* need to be uchar to make */
106 	arc_dev_flags_t		flags;		/* the alignment right */
107 	uint16_t		version;
108 	uint16_t		revision;
109 	uint32_t		key;
110 	uint32_t		affinity_mask;
111 	uint32_t		config_data_len;
112 	uint32_t		id_len;
113 	char 			*id;
114 } arc_config_t;
115 
116 typedef enum arc_status
117 {
118 	arc_ESUCCESS,			/* Success                   */
119 	arc_E2BIG,			/* Arg list too long         */
120 	arc_EACCES,			/* No such file or directory */
121 	arc_EAGAIN,			/* Try again                 */
122 	arc_EBADF,			/* Bad file number           */
123 	arc_EBUSY,			/* Device or resource busy   */
124 	arc_EFAULT,			/* Bad address               */
125 	arc_EINVAL,			/* Invalid argument          */
126 	arc_EIO,			/* I/O error                 */
127 	arc_EISDIR,			/* Is a directory            */
128 	arc_EMFILE,			/* Too many open files       */
129 	arc_EMLINK,			/* Too many links            */
130 	arc_ENAMETOOLONG,		/* File name too long        */
131 	arc_ENODEV,			/* No such device            */
132 	arc_ENOENT,			/* No such file or directory */
133 	arc_ENOEXEC,			/* Exec format error         */
134 	arc_ENOMEM,			/* Out of memory             */
135 	arc_ENOSPC,			/* No space left on device   */
136 	arc_ENOTDIR,			/* Not a directory           */
137 	arc_ENOTTY,			/* Not a typewriter          */
138 	arc_ENXIO,			/* No such device or address */
139 	arc_EROFS,			/* Read-only file system     */
140 } arc_status_t;
141 
142 #ifdef arc
143 typedef enum {
144 	ExeceptionBlock,
145 	SystemParameterBlock,
146 	FreeMemory,
147 	BadMemory,
148 	LoadedProgram,
149 	FirmwareTemporary,
150 	FirmwarePermanent,
151 	FreeContigous
152 } MEMORYTYPE;
153 #endif
154 #ifdef sgi /* note: SGI's systems have different order of types. */
155   typedef enum {
156 	ExeceptionBlock,
157 	SystemParameterBlock,
158 	FreeContigous,
159 	FreeMemory,
160 	BadMemory,
161 	LoadedProgram,
162 	FirmwareTemporary,
163 	FirmwarePermanent,
164   } MEMORYTYPE;
165 #endif
166 
167 typedef struct arc_mem {
168 	MEMORYTYPE	Type;		/* Memory chunk type */
169 	uint32_t	BasePage;	/* Page no, first page */
170 	uint32_t	PageCount;	/* Number of pages */
171 } arc_mem_t;
172 
173 typedef void *arc_time_t; /* XXX */
174 
175 typedef struct arc_dsp_stat {
176 	uint16_t	CursorXPosition;
177 	uint16_t	CursorYPosition;
178 	uint16_t	CursorMaxXPosition;
179 	uint16_t	CursorMaxYPosition;
180 	u_char		ForegroundColor;
181 	u_char		BackgroundColor;
182 	u_char		HighIntensity;
183 	u_char		Underscored;
184 	u_char		ReverseVideo;
185 } arc_dsp_stat_t;
186 
187 typedef void *arc_dirent_t; /* XXX */
188 typedef uint32_t arc_open_mode_t; /* XXX */
189 typedef uint32_t arc_seek_mode_t; /* XXX */
190 typedef uint32_t arc_mount_t; /* XXX */
191 
192 typedef struct arc_calls
193 {
194 	arc_status_t (*load)(		/* Load 1 */
195 		char *,			/* Image to load */
196 		uint32_t,		/* top address */
197 		uint32_t *,		/* Entry address */
198 		uint32_t *);		/* Low address */
199 
200 	arc_status_t (*invoke)(		/* Invoke 2 */
201 		uint32_t,		/* Entry Address */
202 		uint32_t,		/* Stack Address */
203 		uint32_t,		/* Argc */
204 		char **,		/* argv */
205 		char **);		/* envp */
206 
207 	arc_status_t (*execute)(	/* Execute 3 */
208 		char *,			/* Image path */
209 		uint32_t,		/* Argc */
210 		char **,		/* argv */
211 		char **);		/* envp */
212 
213 	void (*halt)(void)
214 	    __attribute__((__noreturn__));	/* Halt 4 */
215 
216 	void (*power_down)(void)
217 	    __attribute__((__noreturn__));	/* PowerDown 5 */
218 
219 	void (*restart)(void)
220 	    __attribute__((__noreturn__));	/* Restart 6 */
221 
222 	void (*reboot)(void)
223 	    __attribute__((__noreturn__));	/* Reboot 7 */
224 
225 	void (*enter_interactive_mode)(void)
226 	    __attribute__((__noreturn__));	/* EnterInteractiveMode 8 */
227 
228 	void (*return_from_main)(void)
229 	    __attribute__((__noreturn__));	/* ReturnFromMain 9 */
230 
231 	arc_config_t *(*get_peer)(	/* GetPeer 10 */
232 		arc_config_t *); 	/* Component */
233 
234 	arc_config_t *(*get_child)(	/* GetChild 11 */
235 		arc_config_t *);	/* Component */
236 
237 	arc_config_t *(*get_parent)(	/* GetParent 12 */
238 		arc_config_t *);	/* Component */
239 
240 	arc_status_t (*get_config_data)( /* GetConfigurationData 13 */
241 		void *,		/* Configuration Data */
242 		arc_config_t *);	/* Component */
243 
244 	arc_config_t *(*add_child)(	/* AddChild 14 */
245 		arc_config_t *,		/* Component */
246 		arc_config_t *);	/* New Component */
247 
248 	arc_status_t (*delete_component)( /* DeleteComponent 15 */
249 		arc_config_t *);	/* Component */
250 
251 	arc_config_t *(*get_component)( /* GetComponent 16 */
252 		char *);		/* Path */
253 
254 	arc_status_t (*save_config)(void); /* SaveConfiguration 17 */
255 
256 	arc_sid_t *(*get_system_id)(void); /* GetSystemId 18 */
257 
258 	arc_mem_t *(*get_memory_descriptor)( /* GetMemoryDescriptor 19 */
259 		arc_mem_t *);		/* MemoryDescriptor */
260 
261 #ifdef arc
262 	void (*signal)(			/* Signal 20 */
263 		uint32_t,		/* Signal number */
264 /**/		void *);		/* Handler */
265 #endif
266 #ifdef sgi
267 	void *unused;
268 #endif
269 
270 	arc_time_t *(*get_time)(void);	/* GetTime 21 */
271 
272 	uint32_t (*get_relative_time)(void); /* GetRelativeTime 22 */
273 
274 	arc_status_t (*get_dir_entry)(	/* GetDirectoryEntry 23 */
275 		uint32_t,		/* FileId */
276 		arc_dirent_t *,		/* Directory entry */
277 		uint32_t,		/* Length */
278 		uint32_t *);		/* Count */
279 
280 	arc_status_t (*open)(		/* Open 24 */
281 		char *,			/* Path */
282 		arc_open_mode_t,	/* Open mode */
283 		uint32_t *);		/* FileId */
284 
285 	arc_status_t (*close)(		/* Close 25 */
286 		uint32_t);		/* FileId */
287 
288 	arc_status_t (*read)(		/* Read 26 */
289 		uint32_t,		/* FileId */
290 		void *,		/* Buffer */
291 		uint32_t,		/* Length */
292 		uint32_t *);		/* Count */
293 
294 	arc_status_t (*get_read_status)( /* GetReadStatus 27 */
295 		uint32_t);		/* FileId */
296 
297 	arc_status_t (*write)(		/* Write 28 */
298 		uint32_t,		/* FileId */
299 		void *,		/* Buffer */
300 		uint32_t,		/* Length */
301 		uint32_t *);		/* Count */
302 
303 	arc_status_t (*seek)(		/* Seek 29 */
304 		uint32_t,		/* FileId */
305 		int64_t *,		/* Offset */
306 		arc_seek_mode_t); 	/* Mode */
307 
308 	arc_status_t (*mount)(		/* Mount 30 */
309 		char *,			/* Path */
310 		arc_mount_t);		/* Operation */
311 
312 	const char *(*getenv)(		/* GetEnvironmentVariable 31 */
313 		const char *);		/* Variable */
314 
315 	arc_status_t (*putenv)(		/* SetEnvironmentVariable 32 */
316 		char *,			/* Variable */
317 		char *);		/* Value */
318 
319 	arc_status_t (*get_file_info)(void);	/* GetFileInformation 33 */
320 
321 	arc_status_t (*set_file_info)(void);	/* SetFileInformation 34 */
322 
323 	void (*flush_all_caches)(void);	/* FlushAllCaches 35 */
324 
325 	/* note: the followings don't exist on SGI */
326 #ifdef arc
327 	arc_status_t (*test_unicode)(	/* TestUnicodeCharacter 36 */
328 		uint32_t,		/* FileId */
329 		uint16_t);		/* UnicodeCharacter */
330 
331 	arc_dsp_stat_t *(*get_display_status)( /* GetDisplayStatus 37 */
332 		uint32_t);		/* FileId */
333 #endif
334 } arc_calls_t;
335 
336 #define ARC_PARAM_BLK_MAGIC	0x53435241
337 #define ARC_PARAM_BLK_MAGIC_BUG	0x41524353	/* This is wrong... but req */
338 
339 typedef struct arc_param_blk
340 {
341 	uint32_t	magic;		/* Magic Number */
342 	uint32_t	length;		/* Length of parameter block */
343 	uint16_t	version;	/* ?? */
344 	uint16_t	revision;	/* ?? */
345 /**/	void *		restart_block;	/* ?? */
346 /**/	void *		debug_block;	/* Debugging info -- unused */
347 /**/	void *		general_exp_vect; /* ?? */
348 /**/	void *		tlb_miss_exp_vect; /* ?? */
349 	uint32_t	firmware_length; /* Size of Firmware jumptable in bytes */
350 	arc_calls_t	*firmware_vect;	/* Firmware jumptable */
351 	uint32_t	vendor_length;	/* Size of Vendor specific jumptable */
352 /**/	void *		vendor_vect;	/* Vendor specific jumptable */
353 	uint32_t	adapter_count;	/* ?? */
354 	uint32_t	adapter0_type;	/* ?? */
355 	uint32_t	adapter0_length; /* ?? */
356 /**/	void *		adapter0_vect;	/* ?? */
357 } arc_param_blk_t;
358 
359 #define ArcBiosBase ((arc_param_blk_t *) 0x80001000)
360 #define ArcBios (ArcBiosBase->firmware_vect)
361 
362 /*
363  * All functions except bios_ident() should be called only if
364  *	bios_ident() returns >= 0.
365  */
366 int bios_ident(void);
367 void bios_init_console(void);
368 int bios_configure_memory(int *, phys_ram_seg_t *, int *);
369 void bios_save_info(void);
370 #ifdef arc
371 void bios_display_info(int *, int *, int *, int *);
372 #endif
373 
374 extern char arc_vendor_id[sizeof(((arc_sid_t *)0)->vendor) + 1];
375 extern unsigned char arc_product_id[sizeof(((arc_sid_t *)0)->prodid)];
376 extern char arc_id[64 + 1];
377 extern char arc_displayc_id[64 + 1];
378 extern arc_dsp_stat_t arc_displayinfo;
379 extern int arc_cpu_l2cache_size;
380