Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * oplib.h:  Describes the interface and available routines in the
0004  *           Linux Prom library.
0005  *
0006  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
0007  */
0008 
0009 #ifndef __SPARC_OPLIB_H
0010 #define __SPARC_OPLIB_H
0011 
0012 #include <asm/openprom.h>
0013 #include <linux/spinlock.h>
0014 #include <linux/compiler.h>
0015 
0016 /* The master romvec pointer... */
0017 extern struct linux_romvec *romvec;
0018 
0019 /* Enumeration to describe the prom major version we have detected. */
0020 enum prom_major_version {
0021     PROM_V0,      /* Original sun4c V0 prom */
0022     PROM_V2,      /* sun4c and early sun4m V2 prom */
0023     PROM_V3,      /* sun4m and later, up to sun4d/sun4e machines V3 */
0024     PROM_P1275,   /* IEEE compliant ISA based Sun PROM, only sun4u */
0025 };
0026 
0027 extern enum prom_major_version prom_vers;
0028 /* Revision, and firmware revision. */
0029 extern unsigned int prom_rev, prom_prev;
0030 
0031 /* Root node of the prom device tree, this stays constant after
0032  * initialization is complete.
0033  */
0034 extern phandle prom_root_node;
0035 
0036 /* Pointer to prom structure containing the device tree traversal
0037  * and usage utility functions.  Only prom-lib should use these,
0038  * users use the interface defined by the library only!
0039  */
0040 extern struct linux_nodeops *prom_nodeops;
0041 
0042 /* The functions... */
0043 
0044 /* You must call prom_init() before using any of the library services,
0045  * preferably as early as possible.  Pass it the romvec pointer.
0046  */
0047 void prom_init(struct linux_romvec *rom_ptr);
0048 
0049 /* Boot argument acquisition, returns the boot command line string. */
0050 char *prom_getbootargs(void);
0051 
0052 /* Miscellaneous routines, don't really fit in any category per se. */
0053 
0054 /* Reboot the machine with the command line passed. */
0055 void prom_reboot(char *boot_command);
0056 
0057 /* Evaluate the forth string passed. */
0058 void prom_feval(char *forth_string);
0059 
0060 /* Enter the prom, with possibility of continuation with the 'go'
0061  * command in newer proms.
0062  */
0063 void prom_cmdline(void);
0064 
0065 /* Enter the prom, with no chance of continuation for the stand-alone
0066  * which calls this.
0067  */
0068 void __noreturn prom_halt(void);
0069 
0070 /* Set the PROM 'sync' callback function to the passed function pointer.
0071  * When the user gives the 'sync' command at the prom prompt while the
0072  * kernel is still active, the prom will call this routine.
0073  *
0074  * XXX The arguments are different on V0 vs. V2->higher proms, grrr! XXX
0075  */
0076 typedef void (*sync_func_t)(void);
0077 void prom_setsync(sync_func_t func_ptr);
0078 
0079 /* Acquire the IDPROM of the root node in the prom device tree.  This
0080  * gets passed a buffer where you would like it stuffed.  The return value
0081  * is the format type of this idprom or 0xff on error.
0082  */
0083 unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
0084 
0085 /* Get the prom major version. */
0086 int prom_version(void);
0087 
0088 /* Get the prom plugin revision. */
0089 int prom_getrev(void);
0090 
0091 /* Get the prom firmware revision. */
0092 int prom_getprev(void);
0093 
0094 /* Write a buffer of characters to the console. */
0095 void prom_console_write_buf(const char *buf, int len);
0096 
0097 /* Prom's internal routines, don't use in kernel/boot code. */
0098 __printf(1, 2) void prom_printf(const char *fmt, ...);
0099 void prom_write(const char *buf, unsigned int len);
0100 
0101 /* Multiprocessor operations... */
0102 
0103 /* Start the CPU with the given device tree node, context table, and context
0104  * at the passed program counter.
0105  */
0106 int prom_startcpu(int cpunode, struct linux_prom_registers *context_table,
0107           int context, char *program_counter);
0108 
0109 /* Initialize the memory lists based upon the prom version. */
0110 void prom_meminit(void);
0111 
0112 /* PROM device tree traversal functions... */
0113 
0114 /* Get the child node of the given node, or zero if no child exists. */
0115 phandle prom_getchild(phandle parent_node);
0116 
0117 /* Get the next sibling node of the given node, or zero if no further
0118  * siblings exist.
0119  */
0120 phandle prom_getsibling(phandle node);
0121 
0122 /* Get the length, at the passed node, of the given property type.
0123  * Returns -1 on error (ie. no such property at this node).
0124  */
0125 int prom_getproplen(phandle thisnode, const char *property);
0126 
0127 /* Fetch the requested property using the given buffer.  Returns
0128  * the number of bytes the prom put into your buffer or -1 on error.
0129  */
0130 int __must_check prom_getproperty(phandle thisnode, const char *property,
0131                   char *prop_buffer, int propbuf_size);
0132 
0133 /* Acquire an integer property. */
0134 int prom_getint(phandle node, char *property);
0135 
0136 /* Acquire an integer property, with a default value. */
0137 int prom_getintdefault(phandle node, char *property, int defval);
0138 
0139 /* Acquire a boolean property, 0=FALSE 1=TRUE. */
0140 int prom_getbool(phandle node, char *prop);
0141 
0142 /* Acquire a string property, null string on error. */
0143 void prom_getstring(phandle node, char *prop, char *buf, int bufsize);
0144 
0145 /* Search all siblings starting at the passed node for "name" matching
0146  * the given string.  Returns the node on success, zero on failure.
0147  */
0148 phandle prom_searchsiblings(phandle node_start, char *name);
0149 
0150 /* Returns the next property after the passed property for the given
0151  * node.  Returns null string on failure.
0152  */
0153 char *prom_nextprop(phandle node, char *prev_property, char *buffer);
0154 
0155 /* Returns phandle of the path specified */
0156 phandle prom_finddevice(char *name);
0157 
0158 /* Set the indicated property at the given node with the passed value.
0159  * Returns the number of bytes of your value that the prom took.
0160  */
0161 int prom_setprop(phandle node, const char *prop_name, char *prop_value,
0162          int value_size);
0163 
0164 phandle prom_inst2pkg(int);
0165 
0166 /* Dorking with Bus ranges... */
0167 
0168 /* Apply promlib probes OBIO ranges to registers. */
0169 void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs);
0170 
0171 /* Apply ranges of any prom node (and optionally parent node as well) to registers. */
0172 void prom_apply_generic_ranges(phandle node, phandle parent,
0173                    struct linux_prom_registers *sbusregs, int nregs);
0174 
0175 void prom_ranges_init(void);
0176 
0177 /* CPU probing helpers.  */
0178 int cpu_find_by_instance(int instance, phandle *prom_node, int *mid);
0179 int cpu_find_by_mid(int mid, phandle *prom_node);
0180 int cpu_get_hwmid(phandle prom_node);
0181 
0182 extern spinlock_t prom_lock;
0183 
0184 #endif /* !(__SPARC_OPLIB_H) */