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 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #ifndef __SPARC_OPENPROM_H__
27 #define __SPARC_OPENPROM_H__
29 /* Empirical constants... */
30 #define LINUX_OPPROM_MAGIC 0x10010407
33 /* V0 prom device operations. */
34 struct linux_dev_v0_funcs {
35 int (*v0_devopen) (char *device_str);
36 int (*v0_devclose) (int dev_desc);
37 int (*v0_rdblkdev) (int dev_desc, int num_blks, int blk_st, char *buf);
38 int (*v0_wrblkdev) (int dev_desc, int num_blks, int blk_st, char *buf);
39 int (*v0_wrnetdev) (int dev_desc, int num_bytes, char *buf);
40 int (*v0_rdnetdev) (int dev_desc, int num_bytes, char *buf);
41 int (*v0_rdchardev) (int dev_desc, int num_bytes, int dummy, char *buf);
42 int (*v0_wrchardev) (int dev_desc, int num_bytes, int dummy, char *buf);
43 int (*v0_seekdev) (int dev_desc, long logical_offst, int from);
46 /* V2 and later prom device operations. */
47 struct linux_dev_v2_funcs {
48 int (*v2_inst2pkg) (int d); /* Convert ihandle to phandle */
49 char *(*v2_dumb_mem_alloc) (char *va, unsigned sz);
50 void (*v2_dumb_mem_free) (char *va, unsigned sz);
52 /* To map devices into virtual I/O space. */
53 char *(*v2_dumb_mmap) (char *virta, int which_io, unsigned paddr,
55 void (*v2_dumb_munmap) (char *virta, unsigned size);
57 int (*v2_dev_open) (char *devpath);
58 void (*v2_dev_close) (int d);
59 int (*v2_dev_read) (int d, char *buf, int nbytes);
60 int (*v2_dev_write) (int d, char *buf, int nbytes);
61 int (*v2_dev_seek) (int d, int hi, int lo);
63 /* Never issued (multistage load support) */
64 void (*v2_wheee2) (void);
65 void (*v2_wheee3) (void);
68 struct linux_mlist_v0 {
69 struct linux_mlist_v0 *theres_more;
75 struct linux_mlist_v0 **v0_totphys;
76 struct linux_mlist_v0 **v0_prommap;
77 struct linux_mlist_v0 **v0_available; /* What we can use */
80 /* Arguments sent to the kernel from the boot prompt. */
81 struct linux_arguments_v0 {
88 char *kernel_file_name;
89 void *aieee1; /* XXX */
92 /* V2 and up boot things. */
93 struct linux_bootargs_v2 {
100 /* The top level PROM vector. */
101 struct linux_romvec {
102 /* Version numbers. */
103 unsigned int pv_magic_cookie;
104 unsigned int pv_romvers;
105 unsigned int pv_plugin_revision;
106 unsigned int pv_printrev;
108 /* Version 0 memory descriptors. */
109 struct linux_mem_v0 pv_v0mem;
111 /* Node operations. */
112 struct linux_nodeops *pv_nodeops;
115 struct linux_dev_v0_funcs pv_v0devops;
119 #define PROMDEV_KBD 0 /* input from keyboard */
120 #define PROMDEV_SCREEN 0 /* output to screen */
121 #define PROMDEV_TTYA 1 /* in/out to ttya */
122 #define PROMDEV_TTYB 2 /* in/out to ttyb */
124 /* Blocking getchar/putchar. NOT REENTRANT! (grr) */
125 int (*pv_getchar) (void);
126 void (*pv_putchar) (int ch);
128 /* Non-blocking variants. */
129 int (*pv_nbgetchar) (void);
130 int (*pv_nbputchar) (int ch);
132 void (*pv_putstr) (char *str, int len);
135 void (*pv_reboot) (char *bootstr);
136 void (*pv_printf) (__const__ char *fmt, ...);
137 void (*pv_abort) (void);
138 __volatile__ int *pv_ticks;
139 void (*pv_halt) (void);
140 void (**pv_synchook) (void);
142 /* Evaluate a forth string, not different proto for V0 and V2->up. */
144 void (*v0_eval) (int len, char *str);
145 void (*v2_eval) (char *str);
148 struct linux_arguments_v0 **pv_v0bootargs;
150 /* Get ether address. */
151 unsigned int (*pv_enaddr) (int d, char *enaddr);
153 struct linux_bootargs_v2 pv_v2bootargs;
154 struct linux_dev_v2_funcs pv_v2devops;
158 /* This one is sun4c/sun4 only. */
159 void (*pv_setctxt) (int ctxt, char *va, int pmeg);
161 /* Prom version 3 Multiprocessor routines. This stuff is crazy.
162 * No joke. Calling these when there is only one cpu probably
163 * crashes the machine, have to test this. :-)
166 /* v3_cpustart() will start the cpu 'whichcpu' in mmu-context
167 * 'thiscontext' executing at address 'prog_counter'
169 int (*v3_cpustart) (unsigned int whichcpu, int ctxtbl_ptr,
170 int thiscontext, char *prog_counter);
172 /* v3_cpustop() will cause cpu 'whichcpu' to stop executing
173 * until a resume cpu call is made.
175 int (*v3_cpustop) (unsigned int whichcpu);
177 /* v3_cpuidle() will idle cpu 'whichcpu' until a stop or
178 * resume cpu call is made.
180 int (*v3_cpuidle) (unsigned int whichcpu);
182 /* v3_cpuresume() will resume processor 'whichcpu' executing
183 * starting with whatever 'pc' and 'npc' were left at the
184 * last 'idle' or 'stop' call.
186 int (*v3_cpuresume) (unsigned int whichcpu);
189 /* Routines for traversing the prom device tree. */
190 struct linux_nodeops {
191 int (*no_nextnode) (int node);
192 int (*no_child) (int node);
193 int (*no_proplen) (int node, char *name);
194 int (*no_getprop) (int node, char *name, char *val);
195 int (*no_setprop) (int node, char *name, char *val, int len);
196 char *(*no_nextprop) (int node, char *name);
199 /* More fun PROM structures for device probing. */
200 #define PROMREG_MAX 16
201 #define PROMVADDR_MAX 16
202 #define PROMINTR_MAX 15
204 struct linux_prom_registers {
205 unsigned int which_io; /* is this in OBIO space? */
206 unsigned int phys_addr; /* The physical address of this register */
207 unsigned int reg_size; /* How many bytes does this register take up? */
210 struct linux_prom_irqs {
211 int pri; /* IRQ priority */
212 int vector; /* This is foobar, what does it do? */
215 /* Element of the "ranges" vector */
216 struct linux_prom_ranges {
217 unsigned int ot_child_space;
218 unsigned int ot_child_base; /* Bus feels this */
219 unsigned int ot_parent_space;
220 unsigned int ot_parent_base; /* CPU looks from here */
221 unsigned int or_size;
224 /* Ranges and reg properties are a bit different for PCI. */
225 struct linux_prom_pci_registers {
227 * We don't know what information this field contain.
228 * We guess, PCI device function is in bits 15:8
231 unsigned int which_io; /* Let it be which_io */
233 unsigned int phys_hi;
234 unsigned int phys_lo;
236 unsigned int size_hi;
237 unsigned int size_lo;
240 struct linux_prom_pci_ranges {
241 unsigned int child_phys_hi; /* Only certain bits are encoded here. */
242 unsigned int child_phys_mid;
243 unsigned int child_phys_lo;
245 unsigned int parent_phys_hi;
246 unsigned int parent_phys_lo;
248 unsigned int size_hi;
249 unsigned int size_lo;
252 struct linux_prom_pci_assigned_addresses {
253 unsigned int which_io;
255 unsigned int phys_hi;
256 unsigned int phys_lo;
258 unsigned int size_hi;
259 unsigned int size_lo;
262 struct linux_prom_ebus_ranges {
263 unsigned int child_phys_hi;
264 unsigned int child_phys_lo;
266 unsigned int parent_phys_hi;
267 unsigned int parent_phys_mid;
268 unsigned int parent_phys_lo;
273 /* Offset into the EEPROM where the id PROM is located on the 4c */
274 #define IDPROM_OFFSET 0x7d8
276 /* On sun4m; physical. */
277 /* MicroSPARC(-II) does not decode 31rd bit, but it works. */
278 #define IDPROM_OFFSET_M 0xfd8
281 unsigned char id_format; /* Format identifier (always 0x01) */
282 unsigned char id_machtype; /* Machine type */
283 unsigned char id_ethaddr[6]; /* Hardware ethernet address */
284 long id_date; /* Date of manufacture */
285 unsigned int id_sernum:24; /* Unique serial number */
286 unsigned char id_cksum; /* Checksum - xor of the data bytes */
287 unsigned char reserved[16];
290 extern struct idprom *idprom;
291 extern void idprom_init(void);
293 #define IDPROM_SIZE (sizeof(struct idprom))
295 #endif /* !(__ASSEMBLY__) */