xref: /openbmc/linux/arch/m68k/include/asm/openprom.h (revision 55fd7e02)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __SPARC_OPENPROM_H
3 #define __SPARC_OPENPROM_H
4 
5 /* openprom.h:  Prom structures and defines for access to the OPENBOOT
6  *              prom routines and data areas.
7  *
8  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
9  */
10 
11 
12 /* Empirical constants... */
13 #ifdef CONFIG_SUN3
14 #define KADB_DEBUGGER_BEGVM     0x0fee0000    /* There is no kadb yet but...*/
15 #define LINUX_OPPROM_BEGVM      0x0fef0000
16 #define LINUX_OPPROM_ENDVM      0x0ff10000    /* I think this is right - tm */
17 #else
18 #define KADB_DEBUGGER_BEGVM     0xffc00000    /* Where kern debugger is in virt-mem */
19 #define	LINUX_OPPROM_BEGVM	0xffd00000
20 #define	LINUX_OPPROM_ENDVM	0xfff00000
21 #define	LINUX_OPPROM_MAGIC      0x10010407
22 #endif
23 
24 #ifndef __ASSEMBLY__
25 /* V0 prom device operations. */
26 struct linux_dev_v0_funcs {
27 	int (*v0_devopen)(char *device_str);
28 	int (*v0_devclose)(int dev_desc);
29 	int (*v0_rdblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
30 	int (*v0_wrblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
31 	int (*v0_wrnetdev)(int dev_desc, int num_bytes, char *buf);
32 	int (*v0_rdnetdev)(int dev_desc, int num_bytes, char *buf);
33 	int (*v0_rdchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
34 	int (*v0_wrchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
35 	int (*v0_seekdev)(int dev_desc, long logical_offst, int from);
36 };
37 
38 /* V2 and later prom device operations. */
39 struct linux_dev_v2_funcs {
40 	int (*v2_inst2pkg)(int d);	/* Convert ihandle to phandle */
41 	char * (*v2_dumb_mem_alloc)(char *va, unsigned sz);
42 	void (*v2_dumb_mem_free)(char *va, unsigned sz);
43 
44 	/* To map devices into virtual I/O space. */
45 	char * (*v2_dumb_mmap)(char *virta, int which_io, unsigned paddr, unsigned sz);
46 	void (*v2_dumb_munmap)(char *virta, unsigned size);
47 
48 	int (*v2_dev_open)(char *devpath);
49 	void (*v2_dev_close)(int d);
50 	int (*v2_dev_read)(int d, char *buf, int nbytes);
51 	int (*v2_dev_write)(int d, char *buf, int nbytes);
52 	int (*v2_dev_seek)(int d, int hi, int lo);
53 
54 	/* Never issued (multistage load support) */
55 	void (*v2_wheee2)(void);
56 	void (*v2_wheee3)(void);
57 };
58 
59 struct linux_mlist_v0 {
60 	struct linux_mlist_v0 *theres_more;
61 	char *start_adr;
62 	unsigned num_bytes;
63 };
64 
65 struct linux_mem_v0 {
66 	struct linux_mlist_v0 **v0_totphys;
67 	struct linux_mlist_v0 **v0_prommap;
68 	struct linux_mlist_v0 **v0_available; /* What we can use */
69 };
70 
71 /* Arguments sent to the kernel from the boot prompt. */
72 struct linux_arguments_v0 {
73 	char *argv[8];
74 	char args[100];
75 	char boot_dev[2];
76 	int boot_dev_ctrl;
77 	int boot_dev_unit;
78 	int dev_partition;
79 	char *kernel_file_name;
80 	void *aieee1;           /* XXX */
81 };
82 
83 /* V2 and up boot things. */
84 struct linux_bootargs_v2 {
85 	char **bootpath;
86 	char **bootargs;
87 	int *fd_stdin;
88 	int *fd_stdout;
89 };
90 
91 #if defined(CONFIG_SUN3) || defined(CONFIG_SUN3X)
92 struct linux_romvec {
93 	char		*pv_initsp;
94 	int		(*pv_startmon)(void);
95 
96 	int		*diagberr;
97 
98 	struct linux_arguments_v0 **pv_v0bootargs;
99 	unsigned	*pv_sun3mem;
100 
101 	unsigned char	(*pv_getchar)(void);
102 	int		(*pv_putchar)(int ch);
103 	int		(*pv_nbgetchar)(void);
104 	int		(*pv_nbputchar)(int ch);
105 	unsigned char	*pv_echo;
106 	unsigned char	*pv_insource;
107 	unsigned char	*pv_outsink;
108 
109 	int		(*pv_getkey)(void);
110 	int		(*pv_initgetkey)(void);
111 	unsigned int	*pv_translation;
112 	unsigned char	*pv_keybid;
113 	int		*pv_screen_x;
114 	int		*pv_screen_y;
115 	struct keybuf	*pv_keybuf;
116 
117 	char		*pv_monid;
118 
119 	/*
120 	 * Frame buffer output and terminal emulation
121 	 */
122 
123 	int		(*pv_fbwritechar)(char);
124 	int		*pv_fbaddr;
125 	char		**pv_font;
126 	int		(*pv_fbwritestr)(char);
127 
128 	void		(*pv_reboot)(char *bootstr);
129 
130 	/*
131 	 * Line input and parsing
132 	 */
133 
134 	unsigned char	*pv_linebuf;
135 	unsigned char	**pv_lineptr;
136 	int		*pv_linesize;
137 	int		(*pv_getline)(void);
138 	unsigned char	(*pv_getnextchar)(void);
139 	unsigned char	(*pv_peeknextchar)(void);
140 	int		*pv_fbthere;
141 	int		(*pv_getnum)(void);
142 
143 	void		(*pv_printf)(const char *fmt, ...);
144 	int		(*pv_printhex)(void);
145 
146 	unsigned char	*pv_leds;
147 	int		(*pv_setleds)(void);
148 
149 	/*
150 	 * Non-maskable interrupt  (nmi) information
151 	 */
152 
153 	int		(*pv_nmiaddr)(void);
154 	int		(*pv_abortentry)(void);
155 	int		*pv_nmiclock;
156 
157 	int		*pv_fbtype;
158 
159 	/*
160 	 * Assorted other things
161 	 */
162 
163 	unsigned	pv_romvers;
164 	struct globram  *pv_globram;
165 	char		*pv_kbdzscc;
166 
167 	int		*pv_keyrinit;
168 	unsigned char	*pv_keyrtick;
169 	unsigned	*pv_memoryavail;
170 	long		*pv_resetaddr;
171 	long		*pv_resetmap;
172 
173 	void		(*pv_halt)(void);
174 	unsigned char	*pv_memorybitmap;
175 
176 #ifdef CONFIG_SUN3
177 	void		(*pv_setctxt)(int ctxt, char *va, int pmeg);
178 	void		(*pv_vector_cmd)(void);
179 	int		dummy1z;
180 	int		dummy2z;
181 	int		dummy3z;
182 	int		dummy4z;
183 #endif
184 };
185 #else
186 /* The top level PROM vector. */
187 struct linux_romvec {
188 	/* Version numbers. */
189 	unsigned int pv_magic_cookie;
190 	unsigned int pv_romvers;
191 	unsigned int pv_plugin_revision;
192 	unsigned int pv_printrev;
193 
194 	/* Version 0 memory descriptors. */
195 	struct linux_mem_v0 pv_v0mem;
196 
197 	/* Node operations. */
198 	struct linux_nodeops *pv_nodeops;
199 
200 	char **pv_bootstr;
201 	struct linux_dev_v0_funcs pv_v0devops;
202 
203 	char *pv_stdin;
204 	char *pv_stdout;
205 #define	PROMDEV_KBD	0		/* input from keyboard */
206 #define	PROMDEV_SCREEN	0		/* output to screen */
207 #define	PROMDEV_TTYA	1		/* in/out to ttya */
208 #define	PROMDEV_TTYB	2		/* in/out to ttyb */
209 
210 	/* Blocking getchar/putchar.  NOT REENTRANT! (grr) */
211 	int (*pv_getchar)(void);
212 	void (*pv_putchar)(int ch);
213 
214 	/* Non-blocking variants. */
215 	int (*pv_nbgetchar)(void);
216 	int (*pv_nbputchar)(int ch);
217 
218 	void (*pv_putstr)(char *str, int len);
219 
220 	/* Miscellany. */
221 	void (*pv_reboot)(char *bootstr);
222 	void (*pv_printf)(__const__ char *fmt, ...);
223 	void (*pv_abort)(void);
224 	__volatile__ int *pv_ticks;
225 	void (*pv_halt)(void);
226 	void (**pv_synchook)(void);
227 
228 	/* Evaluate a forth string, not different proto for V0 and V2->up. */
229 	union {
230 		void (*v0_eval)(int len, char *str);
231 		void (*v2_eval)(char *str);
232 	} pv_fortheval;
233 
234 	struct linux_arguments_v0 **pv_v0bootargs;
235 
236 	/* Get ether address. */
237 	unsigned int (*pv_enaddr)(int d, char *enaddr);
238 
239 	struct linux_bootargs_v2 pv_v2bootargs;
240 	struct linux_dev_v2_funcs pv_v2devops;
241 
242 	int filler[15];
243 
244 	/* This one is sun4c/sun4 only. */
245 	void (*pv_setctxt)(int ctxt, char *va, int pmeg);
246 
247 	/* Prom version 3 Multiprocessor routines. This stuff is crazy.
248 	 * No joke. Calling these when there is only one cpu probably
249 	 * crashes the machine, have to test this. :-)
250 	 */
251 
252 	/* v3_cpustart() will start the cpu 'whichcpu' in mmu-context
253 	 * 'thiscontext' executing at address 'prog_counter'
254 	 */
255 	int (*v3_cpustart)(unsigned int whichcpu, int ctxtbl_ptr,
256 			   int thiscontext, char *prog_counter);
257 
258 	/* v3_cpustop() will cause cpu 'whichcpu' to stop executing
259 	 * until a resume cpu call is made.
260 	 */
261 	int (*v3_cpustop)(unsigned int whichcpu);
262 
263 	/* v3_cpuidle() will idle cpu 'whichcpu' until a stop or
264 	 * resume cpu call is made.
265 	 */
266 	int (*v3_cpuidle)(unsigned int whichcpu);
267 
268 	/* v3_cpuresume() will resume processor 'whichcpu' executing
269 	 * starting with whatever 'pc' and 'npc' were left at the
270 	 * last 'idle' or 'stop' call.
271 	 */
272 	int (*v3_cpuresume)(unsigned int whichcpu);
273 };
274 #endif
275 
276 /* Routines for traversing the prom device tree. */
277 struct linux_nodeops {
278 	int (*no_nextnode)(int node);
279 	int (*no_child)(int node);
280 	int (*no_proplen)(int node, char *name);
281 	int (*no_getprop)(int node, char *name, char *val);
282 	int (*no_setprop)(int node, char *name, char *val, int len);
283 	char * (*no_nextprop)(int node, char *name);
284 };
285 
286 /* More fun PROM structures for device probing. */
287 #define PROMREG_MAX     16
288 #define PROMVADDR_MAX   16
289 #define PROMINTR_MAX    15
290 
291 struct linux_prom_registers {
292 	int which_io;         /* is this in OBIO space? */
293 	char *phys_addr;      /* The physical address of this register */
294 	int reg_size;         /* How many bytes does this register take up? */
295 };
296 
297 struct linux_prom_irqs {
298 	int pri;    /* IRQ priority */
299 	int vector; /* This is foobar, what does it do? */
300 };
301 
302 /* Element of the "ranges" vector */
303 struct linux_prom_ranges {
304 	unsigned int ot_child_space;
305 	unsigned int ot_child_base;		/* Bus feels this */
306 	unsigned int ot_parent_space;
307 	unsigned int ot_parent_base;		/* CPU looks from here */
308 	unsigned int or_size;
309 };
310 
311 #endif /* !(__ASSEMBLY__) */
312 
313 #endif /* !(__SPARC_OPENPROM_H) */
314