Daniel Hellstrom | c2f02da | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 1 | /* OpenProm defines mainly taken from linux kernel header files |
| 2 | * |
| 3 | * openprom.h: Prom structures and defines for access to the OPENBOOT |
| 4 | * prom routines and data areas. |
| 5 | * |
| 6 | * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) |
| 7 | * Copyright (C) 2007 Daniel Hellstrom (daniel@gaisler.com) |
| 8 | * |
| 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. |
| 13 | * |
| 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. |
| 18 | * |
| 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, |
| 22 | * MA 02111-1307 USA |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #ifndef __SPARC_OPENPROM_H__ |
| 27 | #define __SPARC_OPENPROM_H__ |
| 28 | |
| 29 | /* Empirical constants... */ |
| 30 | #define LINUX_OPPROM_MAGIC 0x10010407 |
| 31 | |
| 32 | #ifndef __ASSEMBLY__ |
| 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); |
| 44 | }; |
| 45 | |
| 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); |
| 51 | |
| 52 | /* To map devices into virtual I/O space. */ |
| 53 | char *(*v2_dumb_mmap) (char *virta, int which_io, unsigned paddr, |
| 54 | unsigned sz); |
| 55 | void (*v2_dumb_munmap) (char *virta, unsigned size); |
| 56 | |
| 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); |
| 62 | |
| 63 | /* Never issued (multistage load support) */ |
| 64 | void (*v2_wheee2) (void); |
| 65 | void (*v2_wheee3) (void); |
| 66 | }; |
| 67 | |
| 68 | struct linux_mlist_v0 { |
| 69 | struct linux_mlist_v0 *theres_more; |
| 70 | char *start_adr; |
| 71 | unsigned num_bytes; |
| 72 | }; |
| 73 | |
| 74 | struct linux_mem_v0 { |
| 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 */ |
| 78 | }; |
| 79 | |
| 80 | /* Arguments sent to the kernel from the boot prompt. */ |
| 81 | struct linux_arguments_v0 { |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 82 | char * const argv[8]; |
Daniel Hellstrom | c2f02da | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 83 | char args[100]; |
| 84 | char boot_dev[2]; |
| 85 | int boot_dev_ctrl; |
| 86 | int boot_dev_unit; |
| 87 | int dev_partition; |
| 88 | char *kernel_file_name; |
| 89 | void *aieee1; /* XXX */ |
| 90 | }; |
| 91 | |
| 92 | /* V2 and up boot things. */ |
| 93 | struct linux_bootargs_v2 { |
| 94 | char **bootpath; |
| 95 | char **bootargs; |
| 96 | int *fd_stdin; |
| 97 | int *fd_stdout; |
| 98 | }; |
| 99 | |
| 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; |
| 107 | |
| 108 | /* Version 0 memory descriptors. */ |
| 109 | struct linux_mem_v0 pv_v0mem; |
| 110 | |
| 111 | /* Node operations. */ |
| 112 | struct linux_nodeops *pv_nodeops; |
| 113 | |
| 114 | char **pv_bootstr; |
| 115 | struct linux_dev_v0_funcs pv_v0devops; |
| 116 | |
| 117 | char *pv_stdin; |
| 118 | char *pv_stdout; |
| 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 */ |
| 123 | |
| 124 | /* Blocking getchar/putchar. NOT REENTRANT! (grr) */ |
| 125 | int (*pv_getchar) (void); |
| 126 | void (*pv_putchar) (int ch); |
| 127 | |
| 128 | /* Non-blocking variants. */ |
| 129 | int (*pv_nbgetchar) (void); |
| 130 | int (*pv_nbputchar) (int ch); |
| 131 | |
| 132 | void (*pv_putstr) (char *str, int len); |
| 133 | |
| 134 | /* Miscellany. */ |
| 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); |
| 141 | |
| 142 | /* Evaluate a forth string, not different proto for V0 and V2->up. */ |
| 143 | union { |
| 144 | void (*v0_eval) (int len, char *str); |
| 145 | void (*v2_eval) (char *str); |
| 146 | } pv_fortheval; |
| 147 | |
| 148 | struct linux_arguments_v0 **pv_v0bootargs; |
| 149 | |
| 150 | /* Get ether address. */ |
| 151 | unsigned int (*pv_enaddr) (int d, char *enaddr); |
| 152 | |
| 153 | struct linux_bootargs_v2 pv_v2bootargs; |
| 154 | struct linux_dev_v2_funcs pv_v2devops; |
| 155 | |
| 156 | int filler[15]; |
| 157 | |
| 158 | /* This one is sun4c/sun4 only. */ |
| 159 | void (*pv_setctxt) (int ctxt, char *va, int pmeg); |
| 160 | |
| 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. :-) |
| 164 | */ |
| 165 | |
| 166 | /* v3_cpustart() will start the cpu 'whichcpu' in mmu-context |
| 167 | * 'thiscontext' executing at address 'prog_counter' |
| 168 | */ |
| 169 | int (*v3_cpustart) (unsigned int whichcpu, int ctxtbl_ptr, |
| 170 | int thiscontext, char *prog_counter); |
| 171 | |
| 172 | /* v3_cpustop() will cause cpu 'whichcpu' to stop executing |
| 173 | * until a resume cpu call is made. |
| 174 | */ |
| 175 | int (*v3_cpustop) (unsigned int whichcpu); |
| 176 | |
| 177 | /* v3_cpuidle() will idle cpu 'whichcpu' until a stop or |
| 178 | * resume cpu call is made. |
| 179 | */ |
| 180 | int (*v3_cpuidle) (unsigned int whichcpu); |
| 181 | |
| 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. |
| 185 | */ |
| 186 | int (*v3_cpuresume) (unsigned int whichcpu); |
| 187 | }; |
| 188 | |
| 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); |
| 197 | }; |
| 198 | |
| 199 | /* More fun PROM structures for device probing. */ |
| 200 | #define PROMREG_MAX 16 |
| 201 | #define PROMVADDR_MAX 16 |
| 202 | #define PROMINTR_MAX 15 |
| 203 | |
| 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? */ |
| 208 | }; |
| 209 | |
| 210 | struct linux_prom_irqs { |
| 211 | int pri; /* IRQ priority */ |
| 212 | int vector; /* This is foobar, what does it do? */ |
| 213 | }; |
| 214 | |
| 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; |
| 222 | }; |
| 223 | |
| 224 | /* Ranges and reg properties are a bit different for PCI. */ |
| 225 | struct linux_prom_pci_registers { |
| 226 | /* |
| 227 | * We don't know what information this field contain. |
| 228 | * We guess, PCI device function is in bits 15:8 |
| 229 | * So, ... |
| 230 | */ |
| 231 | unsigned int which_io; /* Let it be which_io */ |
| 232 | |
| 233 | unsigned int phys_hi; |
| 234 | unsigned int phys_lo; |
| 235 | |
| 236 | unsigned int size_hi; |
| 237 | unsigned int size_lo; |
| 238 | }; |
| 239 | |
| 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; |
| 244 | |
| 245 | unsigned int parent_phys_hi; |
| 246 | unsigned int parent_phys_lo; |
| 247 | |
| 248 | unsigned int size_hi; |
| 249 | unsigned int size_lo; |
| 250 | }; |
| 251 | |
| 252 | struct linux_prom_pci_assigned_addresses { |
| 253 | unsigned int which_io; |
| 254 | |
| 255 | unsigned int phys_hi; |
| 256 | unsigned int phys_lo; |
| 257 | |
| 258 | unsigned int size_hi; |
| 259 | unsigned int size_lo; |
| 260 | }; |
| 261 | |
| 262 | struct linux_prom_ebus_ranges { |
| 263 | unsigned int child_phys_hi; |
| 264 | unsigned int child_phys_lo; |
| 265 | |
| 266 | unsigned int parent_phys_hi; |
| 267 | unsigned int parent_phys_mid; |
| 268 | unsigned int parent_phys_lo; |
| 269 | |
| 270 | unsigned int size; |
| 271 | }; |
| 272 | |
| 273 | /* Offset into the EEPROM where the id PROM is located on the 4c */ |
| 274 | #define IDPROM_OFFSET 0x7d8 |
| 275 | |
| 276 | /* On sun4m; physical. */ |
| 277 | /* MicroSPARC(-II) does not decode 31rd bit, but it works. */ |
| 278 | #define IDPROM_OFFSET_M 0xfd8 |
| 279 | |
| 280 | struct idprom { |
| 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]; |
| 288 | }; |
| 289 | |
| 290 | extern struct idprom *idprom; |
| 291 | extern void idprom_init(void); |
| 292 | |
| 293 | #define IDPROM_SIZE (sizeof(struct idprom)) |
| 294 | |
| 295 | #endif /* !(__ASSEMBLY__) */ |
| 296 | |
| 297 | #endif |