Sam Ravnborg | 7c59d28 | 2009-01-02 21:15:25 -0800 | [diff] [blame] | 1 | #ifndef __SPARC_OPENPROM_H |
| 2 | #define __SPARC_OPENPROM_H |
| 3 | |
| 4 | /* openprom.h: Prom structures and defines for access to the OPENBOOT |
| 5 | * prom routines and data areas. |
| 6 | * |
| 7 | * Copyright (C) 1995,1996 David S. Miller (davem@caip.rutgers.edu) |
| 8 | */ |
| 9 | |
| 10 | /* Empirical constants... */ |
| 11 | #define LINUX_OPPROM_MAGIC 0x10010407 |
| 12 | |
| 13 | #ifndef __ASSEMBLY__ |
Andres Salomon | 8d12556 | 2010-10-08 14:18:11 -0700 | [diff] [blame] | 14 | #include <linux/of.h> |
| 15 | |
Sam Ravnborg | 7c59d28 | 2009-01-02 21:15:25 -0800 | [diff] [blame] | 16 | /* V0 prom device operations. */ |
| 17 | struct linux_dev_v0_funcs { |
| 18 | int (*v0_devopen)(char *device_str); |
| 19 | int (*v0_devclose)(int dev_desc); |
| 20 | int (*v0_rdblkdev)(int dev_desc, int num_blks, int blk_st, char *buf); |
| 21 | int (*v0_wrblkdev)(int dev_desc, int num_blks, int blk_st, char *buf); |
| 22 | int (*v0_wrnetdev)(int dev_desc, int num_bytes, char *buf); |
| 23 | int (*v0_rdnetdev)(int dev_desc, int num_bytes, char *buf); |
| 24 | int (*v0_rdchardev)(int dev_desc, int num_bytes, int dummy, char *buf); |
| 25 | int (*v0_wrchardev)(int dev_desc, int num_bytes, int dummy, char *buf); |
| 26 | int (*v0_seekdev)(int dev_desc, long logical_offst, int from); |
| 27 | }; |
| 28 | |
| 29 | /* V2 and later prom device operations. */ |
| 30 | struct linux_dev_v2_funcs { |
Andres Salomon | 8d12556 | 2010-10-08 14:18:11 -0700 | [diff] [blame] | 31 | phandle (*v2_inst2pkg)(int d); /* Convert ihandle to phandle */ |
Sam Ravnborg | 7c59d28 | 2009-01-02 21:15:25 -0800 | [diff] [blame] | 32 | char * (*v2_dumb_mem_alloc)(char *va, unsigned sz); |
| 33 | void (*v2_dumb_mem_free)(char *va, unsigned sz); |
| 34 | |
| 35 | /* To map devices into virtual I/O space. */ |
| 36 | char * (*v2_dumb_mmap)(char *virta, int which_io, unsigned paddr, unsigned sz); |
| 37 | void (*v2_dumb_munmap)(char *virta, unsigned size); |
| 38 | |
| 39 | int (*v2_dev_open)(char *devpath); |
| 40 | void (*v2_dev_close)(int d); |
| 41 | int (*v2_dev_read)(int d, char *buf, int nbytes); |
David S. Miller | e62cac1 | 2010-11-30 14:33:29 -0800 | [diff] [blame] | 42 | int (*v2_dev_write)(int d, const char *buf, int nbytes); |
Sam Ravnborg | 7c59d28 | 2009-01-02 21:15:25 -0800 | [diff] [blame] | 43 | int (*v2_dev_seek)(int d, int hi, int lo); |
| 44 | |
| 45 | /* Never issued (multistage load support) */ |
| 46 | void (*v2_wheee2)(void); |
| 47 | void (*v2_wheee3)(void); |
| 48 | }; |
| 49 | |
| 50 | struct linux_mlist_v0 { |
| 51 | struct linux_mlist_v0 *theres_more; |
| 52 | unsigned int start_adr; |
| 53 | unsigned num_bytes; |
| 54 | }; |
| 55 | |
| 56 | struct linux_mem_v0 { |
| 57 | struct linux_mlist_v0 **v0_totphys; |
| 58 | struct linux_mlist_v0 **v0_prommap; |
| 59 | struct linux_mlist_v0 **v0_available; /* What we can use */ |
| 60 | }; |
| 61 | |
| 62 | /* Arguments sent to the kernel from the boot prompt. */ |
| 63 | struct linux_arguments_v0 { |
| 64 | char *argv[8]; |
| 65 | char args[100]; |
| 66 | char boot_dev[2]; |
| 67 | int boot_dev_ctrl; |
| 68 | int boot_dev_unit; |
| 69 | int dev_partition; |
| 70 | char *kernel_file_name; |
| 71 | void *aieee1; /* XXX */ |
| 72 | }; |
| 73 | |
| 74 | /* V2 and up boot things. */ |
| 75 | struct linux_bootargs_v2 { |
| 76 | char **bootpath; |
| 77 | char **bootargs; |
| 78 | int *fd_stdin; |
| 79 | int *fd_stdout; |
| 80 | }; |
| 81 | |
| 82 | /* The top level PROM vector. */ |
| 83 | struct linux_romvec { |
| 84 | /* Version numbers. */ |
| 85 | unsigned int pv_magic_cookie; |
| 86 | unsigned int pv_romvers; |
| 87 | unsigned int pv_plugin_revision; |
| 88 | unsigned int pv_printrev; |
| 89 | |
| 90 | /* Version 0 memory descriptors. */ |
| 91 | struct linux_mem_v0 pv_v0mem; |
| 92 | |
| 93 | /* Node operations. */ |
| 94 | struct linux_nodeops *pv_nodeops; |
| 95 | |
| 96 | char **pv_bootstr; |
| 97 | struct linux_dev_v0_funcs pv_v0devops; |
| 98 | |
| 99 | char *pv_stdin; |
| 100 | char *pv_stdout; |
| 101 | #define PROMDEV_KBD 0 /* input from keyboard */ |
| 102 | #define PROMDEV_SCREEN 0 /* output to screen */ |
| 103 | #define PROMDEV_TTYA 1 /* in/out to ttya */ |
| 104 | #define PROMDEV_TTYB 2 /* in/out to ttyb */ |
| 105 | |
| 106 | /* Blocking getchar/putchar. NOT REENTRANT! (grr) */ |
| 107 | int (*pv_getchar)(void); |
| 108 | void (*pv_putchar)(int ch); |
| 109 | |
| 110 | /* Non-blocking variants. */ |
| 111 | int (*pv_nbgetchar)(void); |
| 112 | int (*pv_nbputchar)(int ch); |
| 113 | |
| 114 | void (*pv_putstr)(char *str, int len); |
| 115 | |
| 116 | /* Miscellany. */ |
| 117 | void (*pv_reboot)(char *bootstr); |
| 118 | void (*pv_printf)(__const__ char *fmt, ...); |
| 119 | void (*pv_abort)(void); |
| 120 | __volatile__ int *pv_ticks; |
| 121 | void (*pv_halt)(void); |
| 122 | void (**pv_synchook)(void); |
| 123 | |
| 124 | /* Evaluate a forth string, not different proto for V0 and V2->up. */ |
| 125 | union { |
| 126 | void (*v0_eval)(int len, char *str); |
| 127 | void (*v2_eval)(char *str); |
| 128 | } pv_fortheval; |
| 129 | |
| 130 | struct linux_arguments_v0 **pv_v0bootargs; |
| 131 | |
| 132 | /* Get ether address. */ |
| 133 | unsigned int (*pv_enaddr)(int d, char *enaddr); |
| 134 | |
| 135 | struct linux_bootargs_v2 pv_v2bootargs; |
| 136 | struct linux_dev_v2_funcs pv_v2devops; |
| 137 | |
| 138 | int filler[15]; |
| 139 | |
| 140 | /* This one is sun4c/sun4 only. */ |
| 141 | void (*pv_setctxt)(int ctxt, char *va, int pmeg); |
| 142 | |
| 143 | /* Prom version 3 Multiprocessor routines. This stuff is crazy. |
| 144 | * No joke. Calling these when there is only one cpu probably |
| 145 | * crashes the machine, have to test this. :-) |
| 146 | */ |
| 147 | |
| 148 | /* v3_cpustart() will start the cpu 'whichcpu' in mmu-context |
| 149 | * 'thiscontext' executing at address 'prog_counter' |
| 150 | */ |
| 151 | int (*v3_cpustart)(unsigned int whichcpu, int ctxtbl_ptr, |
| 152 | int thiscontext, char *prog_counter); |
| 153 | |
| 154 | /* v3_cpustop() will cause cpu 'whichcpu' to stop executing |
| 155 | * until a resume cpu call is made. |
| 156 | */ |
| 157 | int (*v3_cpustop)(unsigned int whichcpu); |
| 158 | |
| 159 | /* v3_cpuidle() will idle cpu 'whichcpu' until a stop or |
| 160 | * resume cpu call is made. |
| 161 | */ |
| 162 | int (*v3_cpuidle)(unsigned int whichcpu); |
| 163 | |
| 164 | /* v3_cpuresume() will resume processor 'whichcpu' executing |
| 165 | * starting with whatever 'pc' and 'npc' were left at the |
| 166 | * last 'idle' or 'stop' call. |
| 167 | */ |
| 168 | int (*v3_cpuresume)(unsigned int whichcpu); |
| 169 | }; |
| 170 | |
| 171 | /* Routines for traversing the prom device tree. */ |
| 172 | struct linux_nodeops { |
Andres Salomon | 8d12556 | 2010-10-08 14:18:11 -0700 | [diff] [blame] | 173 | phandle (*no_nextnode)(phandle node); |
| 174 | phandle (*no_child)(phandle node); |
| 175 | int (*no_proplen)(phandle node, const char *name); |
| 176 | int (*no_getprop)(phandle node, const char *name, char *val); |
| 177 | int (*no_setprop)(phandle node, const char *name, char *val, int len); |
| 178 | char * (*no_nextprop)(phandle node, char *name); |
Sam Ravnborg | 7c59d28 | 2009-01-02 21:15:25 -0800 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | /* More fun PROM structures for device probing. */ |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 182 | #if defined(__sparc__) && defined(__arch64__) |
Sam Ravnborg | 7c59d28 | 2009-01-02 21:15:25 -0800 | [diff] [blame] | 183 | #define PROMREG_MAX 24 |
| 184 | #define PROMVADDR_MAX 16 |
| 185 | #define PROMINTR_MAX 32 |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 186 | #else |
Sam Ravnborg | 7c59d28 | 2009-01-02 21:15:25 -0800 | [diff] [blame] | 187 | #define PROMREG_MAX 16 |
| 188 | #define PROMVADDR_MAX 16 |
| 189 | #define PROMINTR_MAX 15 |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 190 | #endif |
Sam Ravnborg | 7c59d28 | 2009-01-02 21:15:25 -0800 | [diff] [blame] | 191 | |
| 192 | struct linux_prom_registers { |
| 193 | unsigned int which_io; /* hi part of physical address */ |
| 194 | unsigned int phys_addr; /* The physical address of this register */ |
| 195 | unsigned int reg_size; /* How many bytes does this register take up? */ |
| 196 | }; |
| 197 | |
| 198 | struct linux_prom64_registers { |
| 199 | unsigned long phys_addr; |
| 200 | unsigned long reg_size; |
| 201 | }; |
| 202 | |
| 203 | struct linux_prom_irqs { |
| 204 | int pri; /* IRQ priority */ |
| 205 | int vector; /* This is foobar, what does it do? */ |
| 206 | }; |
| 207 | |
| 208 | /* Element of the "ranges" vector */ |
| 209 | struct linux_prom_ranges { |
| 210 | unsigned int ot_child_space; |
| 211 | unsigned int ot_child_base; /* Bus feels this */ |
| 212 | unsigned int ot_parent_space; |
| 213 | unsigned int ot_parent_base; /* CPU looks from here */ |
| 214 | unsigned int or_size; |
| 215 | }; |
| 216 | |
| 217 | /* |
| 218 | * Ranges and reg properties are a bit different for PCI. |
| 219 | */ |
| 220 | #if defined(__sparc__) && defined(__arch64__) |
| 221 | struct linux_prom_pci_registers { |
| 222 | unsigned int phys_hi; |
| 223 | unsigned int phys_mid; |
| 224 | unsigned int phys_lo; |
| 225 | |
| 226 | unsigned int size_hi; |
| 227 | unsigned int size_lo; |
| 228 | }; |
| 229 | #else |
| 230 | struct linux_prom_pci_registers { |
| 231 | /* |
| 232 | * We don't know what information this field contain. |
| 233 | * We guess, PCI device function is in bits 15:8 |
| 234 | * So, ... |
| 235 | */ |
| 236 | unsigned int which_io; /* Let it be which_io */ |
| 237 | |
| 238 | unsigned int phys_hi; |
| 239 | unsigned int phys_lo; |
| 240 | |
| 241 | unsigned int size_hi; |
| 242 | unsigned int size_lo; |
| 243 | }; |
| 244 | |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 245 | #endif |
Sam Ravnborg | 7c59d28 | 2009-01-02 21:15:25 -0800 | [diff] [blame] | 246 | |
| 247 | struct linux_prom_pci_ranges { |
| 248 | unsigned int child_phys_hi; /* Only certain bits are encoded here. */ |
| 249 | unsigned int child_phys_mid; |
| 250 | unsigned int child_phys_lo; |
| 251 | |
| 252 | unsigned int parent_phys_hi; |
| 253 | unsigned int parent_phys_lo; |
| 254 | |
| 255 | unsigned int size_hi; |
| 256 | unsigned int size_lo; |
| 257 | }; |
| 258 | |
| 259 | struct linux_prom_pci_intmap { |
| 260 | unsigned int phys_hi; |
| 261 | unsigned int phys_mid; |
| 262 | unsigned int phys_lo; |
| 263 | |
| 264 | unsigned int interrupt; |
| 265 | |
| 266 | int cnode; |
| 267 | unsigned int cinterrupt; |
| 268 | }; |
| 269 | |
| 270 | struct linux_prom_pci_intmask { |
| 271 | unsigned int phys_hi; |
| 272 | unsigned int phys_mid; |
| 273 | unsigned int phys_lo; |
| 274 | unsigned int interrupt; |
| 275 | }; |
| 276 | |
| 277 | #endif /* !(__ASSEMBLY__) */ |
| 278 | |
| 279 | #endif /* !(__SPARC_OPENPROM_H) */ |