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 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
Daniel Hellstrom | c2f02da | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #ifndef __SPARC_OPENPROM_H__ |
| 13 | #define __SPARC_OPENPROM_H__ |
| 14 | |
| 15 | /* Empirical constants... */ |
| 16 | #define LINUX_OPPROM_MAGIC 0x10010407 |
| 17 | |
| 18 | #ifndef __ASSEMBLY__ |
| 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); |
| 30 | }; |
| 31 | |
| 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); |
| 37 | |
| 38 | /* To map devices into virtual I/O space. */ |
| 39 | char *(*v2_dumb_mmap) (char *virta, int which_io, unsigned paddr, |
| 40 | unsigned sz); |
| 41 | void (*v2_dumb_munmap) (char *virta, unsigned size); |
| 42 | |
| 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); |
| 48 | |
| 49 | /* Never issued (multistage load support) */ |
| 50 | void (*v2_wheee2) (void); |
| 51 | void (*v2_wheee3) (void); |
| 52 | }; |
| 53 | |
| 54 | struct linux_mlist_v0 { |
| 55 | struct linux_mlist_v0 *theres_more; |
| 56 | char *start_adr; |
| 57 | unsigned num_bytes; |
| 58 | }; |
| 59 | |
| 60 | struct linux_mem_v0 { |
| 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 */ |
| 64 | }; |
| 65 | |
| 66 | /* Arguments sent to the kernel from the boot prompt. */ |
| 67 | struct linux_arguments_v0 { |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 68 | char * const argv[8]; |
Daniel Hellstrom | c2f02da | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 69 | char args[100]; |
| 70 | char boot_dev[2]; |
| 71 | int boot_dev_ctrl; |
| 72 | int boot_dev_unit; |
| 73 | int dev_partition; |
| 74 | char *kernel_file_name; |
| 75 | void *aieee1; /* XXX */ |
| 76 | }; |
| 77 | |
| 78 | /* V2 and up boot things. */ |
| 79 | struct linux_bootargs_v2 { |
| 80 | char **bootpath; |
| 81 | char **bootargs; |
| 82 | int *fd_stdin; |
| 83 | int *fd_stdout; |
| 84 | }; |
| 85 | |
| 86 | /* The top level PROM vector. */ |
| 87 | struct linux_romvec { |
| 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; |
| 93 | |
| 94 | /* Version 0 memory descriptors. */ |
| 95 | struct linux_mem_v0 pv_v0mem; |
| 96 | |
| 97 | /* Node operations. */ |
| 98 | struct linux_nodeops *pv_nodeops; |
| 99 | |
| 100 | char **pv_bootstr; |
| 101 | struct linux_dev_v0_funcs pv_v0devops; |
| 102 | |
| 103 | char *pv_stdin; |
| 104 | char *pv_stdout; |
| 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 */ |
| 109 | |
| 110 | /* Blocking getchar/putchar. NOT REENTRANT! (grr) */ |
| 111 | int (*pv_getchar) (void); |
| 112 | void (*pv_putchar) (int ch); |
| 113 | |
| 114 | /* Non-blocking variants. */ |
| 115 | int (*pv_nbgetchar) (void); |
| 116 | int (*pv_nbputchar) (int ch); |
| 117 | |
| 118 | void (*pv_putstr) (char *str, int len); |
| 119 | |
| 120 | /* Miscellany. */ |
| 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); |
| 127 | |
| 128 | /* Evaluate a forth string, not different proto for V0 and V2->up. */ |
| 129 | union { |
| 130 | void (*v0_eval) (int len, char *str); |
| 131 | void (*v2_eval) (char *str); |
| 132 | } pv_fortheval; |
| 133 | |
| 134 | struct linux_arguments_v0 **pv_v0bootargs; |
| 135 | |
| 136 | /* Get ether address. */ |
| 137 | unsigned int (*pv_enaddr) (int d, char *enaddr); |
| 138 | |
| 139 | struct linux_bootargs_v2 pv_v2bootargs; |
| 140 | struct linux_dev_v2_funcs pv_v2devops; |
| 141 | |
| 142 | int filler[15]; |
| 143 | |
| 144 | /* This one is sun4c/sun4 only. */ |
| 145 | void (*pv_setctxt) (int ctxt, char *va, int pmeg); |
| 146 | |
| 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. :-) |
| 150 | */ |
| 151 | |
| 152 | /* v3_cpustart() will start the cpu 'whichcpu' in mmu-context |
| 153 | * 'thiscontext' executing at address 'prog_counter' |
| 154 | */ |
| 155 | int (*v3_cpustart) (unsigned int whichcpu, int ctxtbl_ptr, |
| 156 | int thiscontext, char *prog_counter); |
| 157 | |
| 158 | /* v3_cpustop() will cause cpu 'whichcpu' to stop executing |
| 159 | * until a resume cpu call is made. |
| 160 | */ |
| 161 | int (*v3_cpustop) (unsigned int whichcpu); |
| 162 | |
| 163 | /* v3_cpuidle() will idle cpu 'whichcpu' until a stop or |
| 164 | * resume cpu call is made. |
| 165 | */ |
| 166 | int (*v3_cpuidle) (unsigned int whichcpu); |
| 167 | |
| 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. |
| 171 | */ |
| 172 | int (*v3_cpuresume) (unsigned int whichcpu); |
| 173 | }; |
| 174 | |
| 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); |
| 183 | }; |
| 184 | |
| 185 | /* More fun PROM structures for device probing. */ |
| 186 | #define PROMREG_MAX 16 |
| 187 | #define PROMVADDR_MAX 16 |
| 188 | #define PROMINTR_MAX 15 |
| 189 | |
| 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? */ |
| 194 | }; |
| 195 | |
| 196 | struct linux_prom_irqs { |
| 197 | int pri; /* IRQ priority */ |
| 198 | int vector; /* This is foobar, what does it do? */ |
| 199 | }; |
| 200 | |
| 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; |
| 208 | }; |
| 209 | |
| 210 | /* Ranges and reg properties are a bit different for PCI. */ |
| 211 | struct linux_prom_pci_registers { |
| 212 | /* |
| 213 | * We don't know what information this field contain. |
| 214 | * We guess, PCI device function is in bits 15:8 |
| 215 | * So, ... |
| 216 | */ |
| 217 | unsigned int which_io; /* Let it be which_io */ |
| 218 | |
| 219 | unsigned int phys_hi; |
| 220 | unsigned int phys_lo; |
| 221 | |
| 222 | unsigned int size_hi; |
| 223 | unsigned int size_lo; |
| 224 | }; |
| 225 | |
| 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; |
| 230 | |
| 231 | unsigned int parent_phys_hi; |
| 232 | unsigned int parent_phys_lo; |
| 233 | |
| 234 | unsigned int size_hi; |
| 235 | unsigned int size_lo; |
| 236 | }; |
| 237 | |
| 238 | struct linux_prom_pci_assigned_addresses { |
| 239 | unsigned int which_io; |
| 240 | |
| 241 | unsigned int phys_hi; |
| 242 | unsigned int phys_lo; |
| 243 | |
| 244 | unsigned int size_hi; |
| 245 | unsigned int size_lo; |
| 246 | }; |
| 247 | |
| 248 | struct linux_prom_ebus_ranges { |
| 249 | unsigned int child_phys_hi; |
| 250 | unsigned int child_phys_lo; |
| 251 | |
| 252 | unsigned int parent_phys_hi; |
| 253 | unsigned int parent_phys_mid; |
| 254 | unsigned int parent_phys_lo; |
| 255 | |
| 256 | unsigned int size; |
| 257 | }; |
| 258 | |
| 259 | /* Offset into the EEPROM where the id PROM is located on the 4c */ |
| 260 | #define IDPROM_OFFSET 0x7d8 |
| 261 | |
| 262 | /* On sun4m; physical. */ |
| 263 | /* MicroSPARC(-II) does not decode 31rd bit, but it works. */ |
| 264 | #define IDPROM_OFFSET_M 0xfd8 |
| 265 | |
| 266 | struct idprom { |
| 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]; |
| 274 | }; |
| 275 | |
| 276 | extern struct idprom *idprom; |
| 277 | extern void idprom_init(void); |
| 278 | |
| 279 | #define IDPROM_SIZE (sizeof(struct idprom)) |
| 280 | |
| 281 | #endif /* !(__ASSEMBLY__) */ |
| 282 | |
| 283 | #endif |