Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __SPARC_OPENPROM_H
0003 #define __SPARC_OPENPROM_H
0004 
0005 /* openprom.h:  Prom structures and defines for access to the OPENBOOT
0006  *              prom routines and data areas.
0007  *
0008  * Copyright (C) 1995,1996 David S. Miller (davem@caip.rutgers.edu)
0009  */
0010 
0011 /* Empirical constants... */
0012 #define LINUX_OPPROM_MAGIC      0x10010407
0013 
0014 #ifndef __ASSEMBLY__
0015 #include <linux/of.h>
0016 
0017 /* V0 prom device operations. */
0018 struct linux_dev_v0_funcs {
0019     int (*v0_devopen)(char *device_str);
0020     int (*v0_devclose)(int dev_desc);
0021     int (*v0_rdblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
0022     int (*v0_wrblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
0023     int (*v0_wrnetdev)(int dev_desc, int num_bytes, char *buf);
0024     int (*v0_rdnetdev)(int dev_desc, int num_bytes, char *buf);
0025     int (*v0_rdchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
0026     int (*v0_wrchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
0027     int (*v0_seekdev)(int dev_desc, long logical_offst, int from);
0028 };
0029 
0030 /* V2 and later prom device operations. */
0031 struct linux_dev_v2_funcs {
0032     phandle (*v2_inst2pkg)(int d);  /* Convert ihandle to phandle */
0033     char * (*v2_dumb_mem_alloc)(char *va, unsigned int sz);
0034     void (*v2_dumb_mem_free)(char *va, unsigned int sz);
0035 
0036     /* To map devices into virtual I/O space. */
0037     char * (*v2_dumb_mmap)(char *virta, int which_io, unsigned int paddr, unsigned int sz);
0038     void (*v2_dumb_munmap)(char *virta, unsigned int size);
0039 
0040     int (*v2_dev_open)(char *devpath);
0041     void (*v2_dev_close)(int d);
0042     int (*v2_dev_read)(int d, char *buf, int nbytes);
0043     int (*v2_dev_write)(int d, const char *buf, int nbytes);
0044     int (*v2_dev_seek)(int d, int hi, int lo);
0045 
0046     /* Never issued (multistage load support) */
0047     void (*v2_wheee2)(void);
0048     void (*v2_wheee3)(void);
0049 };
0050 
0051 struct linux_mlist_v0 {
0052     struct linux_mlist_v0 *theres_more;
0053     unsigned int start_adr;
0054     unsigned int num_bytes;
0055 };
0056 
0057 struct linux_mem_v0 {
0058     struct linux_mlist_v0 **v0_totphys;
0059     struct linux_mlist_v0 **v0_prommap;
0060     struct linux_mlist_v0 **v0_available; /* What we can use */
0061 };
0062 
0063 /* Arguments sent to the kernel from the boot prompt. */
0064 struct linux_arguments_v0 {
0065     char *argv[8];
0066     char args[100];
0067     char boot_dev[2];
0068     int boot_dev_ctrl;
0069     int boot_dev_unit;
0070     int dev_partition;
0071     char *kernel_file_name;
0072     void *aieee1;           /* XXX */
0073 };
0074 
0075 /* V2 and up boot things. */
0076 struct linux_bootargs_v2 {
0077     char **bootpath;
0078     char **bootargs;
0079     int *fd_stdin;
0080     int *fd_stdout;
0081 };
0082 
0083 /* The top level PROM vector. */
0084 struct linux_romvec {
0085     /* Version numbers. */
0086     unsigned int pv_magic_cookie;
0087     unsigned int pv_romvers;
0088     unsigned int pv_plugin_revision;
0089     unsigned int pv_printrev;
0090 
0091     /* Version 0 memory descriptors. */
0092     struct linux_mem_v0 pv_v0mem;
0093 
0094     /* Node operations. */
0095     struct linux_nodeops *pv_nodeops;
0096 
0097     char **pv_bootstr;
0098     struct linux_dev_v0_funcs pv_v0devops;
0099 
0100     char *pv_stdin;
0101     char *pv_stdout;
0102 #define PROMDEV_KBD 0       /* input from keyboard */
0103 #define PROMDEV_SCREEN  0       /* output to screen */
0104 #define PROMDEV_TTYA    1       /* in/out to ttya */
0105 #define PROMDEV_TTYB    2       /* in/out to ttyb */
0106 
0107     /* Blocking getchar/putchar.  NOT REENTRANT! (grr) */
0108     int (*pv_getchar)(void);
0109     void (*pv_putchar)(int ch);
0110 
0111     /* Non-blocking variants. */
0112     int (*pv_nbgetchar)(void);
0113     int (*pv_nbputchar)(int ch);
0114 
0115     void (*pv_putstr)(char *str, int len);
0116 
0117     /* Miscellany. */
0118     void (*pv_reboot)(char *bootstr);
0119     void (*pv_printf)(__const__ char *fmt, ...);
0120     void (*pv_abort)(void);
0121     __volatile__ int *pv_ticks;
0122     void (*pv_halt)(void);
0123     void (**pv_synchook)(void);
0124 
0125     /* Evaluate a forth string, not different proto for V0 and V2->up. */
0126     union {
0127         void (*v0_eval)(int len, char *str);
0128         void (*v2_eval)(char *str);
0129     } pv_fortheval;
0130 
0131     struct linux_arguments_v0 **pv_v0bootargs;
0132 
0133     /* Get ether address. */
0134     unsigned int (*pv_enaddr)(int d, char *enaddr);
0135 
0136     struct linux_bootargs_v2 pv_v2bootargs;
0137     struct linux_dev_v2_funcs pv_v2devops;
0138 
0139     int filler[15];
0140 
0141     /* This one is sun4c/sun4 only. */
0142     void (*pv_setctxt)(int ctxt, char *va, int pmeg);
0143 
0144     /* Prom version 3 Multiprocessor routines. This stuff is crazy.
0145      * No joke. Calling these when there is only one cpu probably
0146      * crashes the machine, have to test this. :-)
0147      */
0148 
0149     /* v3_cpustart() will start the cpu 'whichcpu' in mmu-context
0150      * 'thiscontext' executing at address 'prog_counter'
0151      */
0152     int (*v3_cpustart)(unsigned int whichcpu, int ctxtbl_ptr,
0153                int thiscontext, char *prog_counter);
0154 
0155     /* v3_cpustop() will cause cpu 'whichcpu' to stop executing
0156      * until a resume cpu call is made.
0157      */
0158     int (*v3_cpustop)(unsigned int whichcpu);
0159 
0160     /* v3_cpuidle() will idle cpu 'whichcpu' until a stop or
0161      * resume cpu call is made.
0162      */
0163     int (*v3_cpuidle)(unsigned int whichcpu);
0164 
0165     /* v3_cpuresume() will resume processor 'whichcpu' executing
0166      * starting with whatever 'pc' and 'npc' were left at the
0167      * last 'idle' or 'stop' call.
0168      */
0169     int (*v3_cpuresume)(unsigned int whichcpu);
0170 };
0171 
0172 /* Routines for traversing the prom device tree. */
0173 struct linux_nodeops {
0174     phandle (*no_nextnode)(phandle node);
0175     phandle (*no_child)(phandle node);
0176     int (*no_proplen)(phandle node, const char *name);
0177     int (*no_getprop)(phandle node, const char *name, char *val);
0178     int (*no_setprop)(phandle node, const char *name, char *val, int len);
0179     char * (*no_nextprop)(phandle node, char *name);
0180 };
0181 
0182 /* More fun PROM structures for device probing. */
0183 #if defined(__sparc__) && defined(__arch64__)
0184 #define PROMREG_MAX     24
0185 #define PROMVADDR_MAX   16
0186 #define PROMINTR_MAX    32
0187 #else
0188 #define PROMREG_MAX     16
0189 #define PROMVADDR_MAX   16
0190 #define PROMINTR_MAX    15
0191 #endif
0192 
0193 struct linux_prom_registers {
0194     unsigned int which_io;  /* hi part of physical address */
0195     unsigned int phys_addr; /* The physical address of this register */
0196     unsigned int reg_size;  /* How many bytes does this register take up? */
0197 };
0198 
0199 struct linux_prom64_registers {
0200     unsigned long phys_addr;
0201     unsigned long reg_size;
0202 };
0203 
0204 struct linux_prom_irqs {
0205     int pri;    /* IRQ priority */
0206     int vector; /* This is foobar, what does it do? */
0207 };
0208 
0209 /* Element of the "ranges" vector */
0210 struct linux_prom_ranges {
0211     unsigned int ot_child_space;
0212     unsigned int ot_child_base;     /* Bus feels this */
0213     unsigned int ot_parent_space;
0214     unsigned int ot_parent_base;        /* CPU looks from here */
0215     unsigned int or_size;
0216 };
0217 
0218 /*
0219  * Ranges and reg properties are a bit different for PCI.
0220  */
0221 #if defined(__sparc__) && defined(__arch64__)
0222 struct linux_prom_pci_registers {
0223     unsigned int phys_hi;
0224     unsigned int phys_mid;
0225     unsigned int phys_lo;
0226 
0227     unsigned int size_hi;
0228     unsigned int size_lo;
0229 };
0230 #else
0231 struct linux_prom_pci_registers {
0232     /*
0233      * We don't know what information this field contain.
0234      * We guess, PCI device function is in bits 15:8
0235      * So, ...
0236      */
0237     unsigned int which_io;  /* Let it be which_io */
0238 
0239     unsigned int phys_hi;
0240     unsigned int phys_lo;
0241 
0242     unsigned int size_hi;
0243     unsigned int size_lo;
0244 };
0245 
0246 #endif
0247 
0248 struct linux_prom_pci_ranges {
0249     unsigned int child_phys_hi; /* Only certain bits are encoded here. */
0250     unsigned int child_phys_mid;
0251     unsigned int child_phys_lo;
0252 
0253     unsigned int parent_phys_hi;
0254     unsigned int parent_phys_lo;
0255 
0256     unsigned int size_hi;
0257     unsigned int size_lo;
0258 };
0259 
0260 struct linux_prom_pci_intmap {
0261     unsigned int phys_hi;
0262     unsigned int phys_mid;
0263     unsigned int phys_lo;
0264 
0265     unsigned int interrupt;
0266 
0267     int          cnode;
0268     unsigned int cinterrupt;
0269 };
0270 
0271 struct linux_prom_pci_intmask {
0272     unsigned int phys_hi;
0273     unsigned int phys_mid;
0274     unsigned int phys_lo;
0275     unsigned int interrupt;
0276 };
0277 
0278 #endif /* !(__ASSEMBLY__) */
0279 
0280 #endif /* !(__SPARC_OPENPROM_H) */