1 /* OpenProm defines mainly taken from linux kernel header files
3 * openprom.h: Prom structures and defines for access to the OPENBOOT
4 * prom routines and data areas.
6 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
7 * Copyright (C) 2007 Daniel Hellstrom (daniel@gaisler.com)
9 * SPDX-License-Identifier: GPL-2.0+
12 #ifndef __SPARC_OPENPROM_H__
13 #define __SPARC_OPENPROM_H__
15 /* Empirical constants... */
16 #define LINUX_OPPROM_MAGIC 0x10010407
19 /* V0 prom device operations. */
20 struct linux_dev_v0_funcs {
21 int (*v0_devopen) (char *device_str);
22 int (*v0_devclose) (int dev_desc);
23 int (*v0_rdblkdev) (int dev_desc, int num_blks, int blk_st, char *buf);
24 int (*v0_wrblkdev) (int dev_desc, int num_blks, int blk_st, char *buf);
25 int (*v0_wrnetdev) (int dev_desc, int num_bytes, char *buf);
26 int (*v0_rdnetdev) (int dev_desc, int num_bytes, char *buf);
27 int (*v0_rdchardev) (int dev_desc, int num_bytes, int dummy, char *buf);
28 int (*v0_wrchardev) (int dev_desc, int num_bytes, int dummy, char *buf);
29 int (*v0_seekdev) (int dev_desc, long logical_offst, int from);
32 /* V2 and later prom device operations. */
33 struct linux_dev_v2_funcs {
34 int (*v2_inst2pkg) (int d); /* Convert ihandle to phandle */
35 char *(*v2_dumb_mem_alloc) (char *va, unsigned sz);
36 void (*v2_dumb_mem_free) (char *va, unsigned sz);
38 /* To map devices into virtual I/O space. */
39 char *(*v2_dumb_mmap) (char *virta, int which_io, unsigned paddr,
41 void (*v2_dumb_munmap) (char *virta, unsigned size);
43 int (*v2_dev_open) (char *devpath);
44 void (*v2_dev_close) (int d);
45 int (*v2_dev_read) (int d, char *buf, int nbytes);
46 int (*v2_dev_write) (int d, char *buf, int nbytes);
47 int (*v2_dev_seek) (int d, int hi, int lo);
49 /* Never issued (multistage load support) */
50 void (*v2_wheee2) (void);
51 void (*v2_wheee3) (void);
54 struct linux_mlist_v0 {
55 struct linux_mlist_v0 *theres_more;
61 struct linux_mlist_v0 **v0_totphys;
62 struct linux_mlist_v0 **v0_prommap;
63 struct linux_mlist_v0 **v0_available; /* What we can use */
66 /* Arguments sent to the kernel from the boot prompt. */
67 struct linux_arguments_v0 {
74 char *kernel_file_name;
75 void *aieee1; /* XXX */
78 /* V2 and up boot things. */
79 struct linux_bootargs_v2 {
86 /* The top level PROM vector. */
88 /* Version numbers. */
89 unsigned int pv_magic_cookie;
90 unsigned int pv_romvers;
91 unsigned int pv_plugin_revision;
92 unsigned int pv_printrev;
94 /* Version 0 memory descriptors. */
95 struct linux_mem_v0 pv_v0mem;
97 /* Node operations. */
98 struct linux_nodeops *pv_nodeops;
101 struct linux_dev_v0_funcs pv_v0devops;
105 #define PROMDEV_KBD 0 /* input from keyboard */
106 #define PROMDEV_SCREEN 0 /* output to screen */
107 #define PROMDEV_TTYA 1 /* in/out to ttya */
108 #define PROMDEV_TTYB 2 /* in/out to ttyb */
110 /* Blocking getchar/putchar. NOT REENTRANT! (grr) */
111 int (*pv_getchar) (void);
112 void (*pv_putchar) (int ch);
114 /* Non-blocking variants. */
115 int (*pv_nbgetchar) (void);
116 int (*pv_nbputchar) (int ch);
118 void (*pv_putstr) (char *str, int len);
121 void (*pv_reboot) (char *bootstr);
122 void (*pv_printf) (__const__ char *fmt, ...);
123 void (*pv_abort) (void);
124 __volatile__ int *pv_ticks;
125 void (*pv_halt) (void);
126 void (**pv_synchook) (void);
128 /* Evaluate a forth string, not different proto for V0 and V2->up. */
130 void (*v0_eval) (int len, char *str);
131 void (*v2_eval) (char *str);
134 struct linux_arguments_v0 **pv_v0bootargs;
136 /* Get ether address. */
137 unsigned int (*pv_enaddr) (int d, char *enaddr);
139 struct linux_bootargs_v2 pv_v2bootargs;
140 struct linux_dev_v2_funcs pv_v2devops;
144 /* This one is sun4c/sun4 only. */
145 void (*pv_setctxt) (int ctxt, char *va, int pmeg);
147 /* Prom version 3 Multiprocessor routines. This stuff is crazy.
148 * No joke. Calling these when there is only one cpu probably
149 * crashes the machine, have to test this. :-)
152 /* v3_cpustart() will start the cpu 'whichcpu' in mmu-context
153 * 'thiscontext' executing at address 'prog_counter'
155 int (*v3_cpustart) (unsigned int whichcpu, int ctxtbl_ptr,
156 int thiscontext, char *prog_counter);
158 /* v3_cpustop() will cause cpu 'whichcpu' to stop executing
159 * until a resume cpu call is made.
161 int (*v3_cpustop) (unsigned int whichcpu);
163 /* v3_cpuidle() will idle cpu 'whichcpu' until a stop or
164 * resume cpu call is made.
166 int (*v3_cpuidle) (unsigned int whichcpu);
168 /* v3_cpuresume() will resume processor 'whichcpu' executing
169 * starting with whatever 'pc' and 'npc' were left at the
170 * last 'idle' or 'stop' call.
172 int (*v3_cpuresume) (unsigned int whichcpu);
175 /* Routines for traversing the prom device tree. */
176 struct linux_nodeops {
177 int (*no_nextnode) (int node);
178 int (*no_child) (int node);
179 int (*no_proplen) (int node, char *name);
180 int (*no_getprop) (int node, char *name, char *val);
181 int (*no_setprop) (int node, char *name, char *val, int len);
182 char *(*no_nextprop) (int node, char *name);
185 /* More fun PROM structures for device probing. */
186 #define PROMREG_MAX 16
187 #define PROMVADDR_MAX 16
188 #define PROMINTR_MAX 15
190 struct linux_prom_registers {
191 unsigned int which_io; /* is this in OBIO space? */
192 unsigned int phys_addr; /* The physical address of this register */
193 unsigned int reg_size; /* How many bytes does this register take up? */
196 struct linux_prom_irqs {
197 int pri; /* IRQ priority */
198 int vector; /* This is foobar, what does it do? */
201 /* Element of the "ranges" vector */
202 struct linux_prom_ranges {
203 unsigned int ot_child_space;
204 unsigned int ot_child_base; /* Bus feels this */
205 unsigned int ot_parent_space;
206 unsigned int ot_parent_base; /* CPU looks from here */
207 unsigned int or_size;
210 /* Ranges and reg properties are a bit different for PCI. */
211 struct linux_prom_pci_registers {
213 * We don't know what information this field contain.
214 * We guess, PCI device function is in bits 15:8
217 unsigned int which_io; /* Let it be which_io */
219 unsigned int phys_hi;
220 unsigned int phys_lo;
222 unsigned int size_hi;
223 unsigned int size_lo;
226 struct linux_prom_pci_ranges {
227 unsigned int child_phys_hi; /* Only certain bits are encoded here. */
228 unsigned int child_phys_mid;
229 unsigned int child_phys_lo;
231 unsigned int parent_phys_hi;
232 unsigned int parent_phys_lo;
234 unsigned int size_hi;
235 unsigned int size_lo;
238 struct linux_prom_pci_assigned_addresses {
239 unsigned int which_io;
241 unsigned int phys_hi;
242 unsigned int phys_lo;
244 unsigned int size_hi;
245 unsigned int size_lo;
248 struct linux_prom_ebus_ranges {
249 unsigned int child_phys_hi;
250 unsigned int child_phys_lo;
252 unsigned int parent_phys_hi;
253 unsigned int parent_phys_mid;
254 unsigned int parent_phys_lo;
259 /* Offset into the EEPROM where the id PROM is located on the 4c */
260 #define IDPROM_OFFSET 0x7d8
262 /* On sun4m; physical. */
263 /* MicroSPARC(-II) does not decode 31rd bit, but it works. */
264 #define IDPROM_OFFSET_M 0xfd8
267 unsigned char id_format; /* Format identifier (always 0x01) */
268 unsigned char id_machtype; /* Machine type */
269 unsigned char id_ethaddr[6]; /* Hardware ethernet address */
270 long id_date; /* Date of manufacture */
271 unsigned int id_sernum:24; /* Unique serial number */
272 unsigned char id_cksum; /* Checksum - xor of the data bytes */
273 unsigned char reserved[16];
276 extern struct idprom *idprom;
277 extern void idprom_init(void);
279 #define IDPROM_SIZE (sizeof(struct idprom))
281 #endif /* !(__ASSEMBLY__) */