Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* oplib.h:  Describes the interface and available routines in the
0003  *           Linux Prom library.
0004  *
0005  * Copyright (C) 1995, 2007 David S. Miller (davem@davemloft.net)
0006  * Copyright (C) 1996 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
0007  */
0008 
0009 #ifndef __SPARC64_OPLIB_H
0010 #define __SPARC64_OPLIB_H
0011 
0012 #include <asm/openprom.h>
0013 
0014 /* OBP version string. */
0015 extern char prom_version[];
0016 
0017 /* Root node of the prom device tree, this stays constant after
0018  * initialization is complete.
0019  */
0020 extern phandle prom_root_node;
0021 
0022 /* PROM stdout */
0023 extern int prom_stdout;
0024 
0025 /* /chosen node of the prom device tree, this stays constant after
0026  * initialization is complete.
0027  */
0028 extern phandle prom_chosen_node;
0029 
0030 /* Helper values and strings in arch/sparc64/kernel/head.S */
0031 extern const char prom_peer_name[];
0032 extern const char prom_compatible_name[];
0033 extern const char prom_root_compatible[];
0034 extern const char prom_cpu_compatible[];
0035 extern const char prom_finddev_name[];
0036 extern const char prom_chosen_path[];
0037 extern const char prom_cpu_path[];
0038 extern const char prom_getprop_name[];
0039 extern const char prom_mmu_name[];
0040 extern const char prom_callmethod_name[];
0041 extern const char prom_translate_name[];
0042 extern const char prom_map_name[];
0043 extern const char prom_unmap_name[];
0044 extern int prom_mmu_ihandle_cache;
0045 extern unsigned int prom_boot_mapped_pc;
0046 extern unsigned int prom_boot_mapping_mode;
0047 extern unsigned long prom_boot_mapping_phys_high, prom_boot_mapping_phys_low;
0048 
0049 struct linux_mlist_p1275 {
0050     struct linux_mlist_p1275 *theres_more;
0051     unsigned long start_adr;
0052     unsigned long num_bytes;
0053 };
0054 
0055 struct linux_mem_p1275 {
0056     struct linux_mlist_p1275 **p1275_totphys;
0057     struct linux_mlist_p1275 **p1275_prommap;
0058     struct linux_mlist_p1275 **p1275_available; /* What we can use */
0059 };
0060 
0061 /* The functions... */
0062 
0063 /* You must call prom_init() before using any of the library services,
0064  * preferably as early as possible.  Pass it the romvec pointer.
0065  */
0066 void prom_init(void *cif_handler);
0067 void prom_init_report(void);
0068 
0069 /* Boot argument acquisition, returns the boot command line string. */
0070 char *prom_getbootargs(void);
0071 
0072 /* Miscellaneous routines, don't really fit in any category per se. */
0073 
0074 /* Reboot the machine with the command line passed. */
0075 void prom_reboot(const char *boot_command);
0076 
0077 /* Evaluate the forth string passed. */
0078 void prom_feval(const char *forth_string);
0079 
0080 /* Enter the prom, with possibility of continuation with the 'go'
0081  * command in newer proms.
0082  */
0083 void prom_cmdline(void);
0084 
0085 /* Enter the prom, with no chance of continuation for the stand-alone
0086  * which calls this.
0087  */
0088 void prom_halt(void) __attribute__ ((noreturn));
0089 
0090 /* Halt and power-off the machine. */
0091 void prom_halt_power_off(void) __attribute__ ((noreturn));
0092 
0093 /* Acquire the IDPROM of the root node in the prom device tree.  This
0094  * gets passed a buffer where you would like it stuffed.  The return value
0095  * is the format type of this idprom or 0xff on error.
0096  */
0097 unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
0098 
0099 /* Write a buffer of characters to the console. */
0100 void prom_console_write_buf(const char *buf, int len);
0101 
0102 /* Prom's internal routines, don't use in kernel/boot code. */
0103 __printf(1, 2) void prom_printf(const char *fmt, ...);
0104 void prom_write(const char *buf, unsigned int len);
0105 
0106 /* Multiprocessor operations... */
0107 #ifdef CONFIG_SMP
0108 /* Start the CPU with the given device tree node at the passed program
0109  * counter with the given arg passed in via register %o0.
0110  */
0111 void prom_startcpu(int cpunode, unsigned long pc, unsigned long arg);
0112 
0113 /* Start the CPU with the given cpu ID at the passed program
0114  * counter with the given arg passed in via register %o0.
0115  */
0116 void prom_startcpu_cpuid(int cpuid, unsigned long pc, unsigned long arg);
0117 
0118 /* Stop the CPU with the given cpu ID.  */
0119 void prom_stopcpu_cpuid(int cpuid);
0120 
0121 /* Stop the current CPU. */
0122 void prom_stopself(void);
0123 
0124 /* Idle the current CPU. */
0125 void prom_idleself(void);
0126 
0127 /* Resume the CPU with the passed device tree node. */
0128 void prom_resumecpu(int cpunode);
0129 #endif
0130 
0131 /* Power management interfaces. */
0132 
0133 /* Put the current CPU to sleep. */
0134 void prom_sleepself(void);
0135 
0136 /* Put the entire system to sleep. */
0137 int prom_sleepsystem(void);
0138 
0139 /* Initiate a wakeup event. */
0140 int prom_wakeupsystem(void);
0141 
0142 /* MMU and memory related OBP interfaces. */
0143 
0144 /* Get unique string identifying SIMM at given physical address. */
0145 int prom_getunumber(int syndrome_code,
0146             unsigned long phys_addr,
0147             char *buf, int buflen);
0148 
0149 /* Retain physical memory to the caller across soft resets. */
0150 int prom_retain(const char *name, unsigned long size,
0151         unsigned long align, unsigned long *paddr);
0152 
0153 /* Load explicit I/D TLB entries into the calling processor. */
0154 long prom_itlb_load(unsigned long index,
0155             unsigned long tte_data,
0156             unsigned long vaddr);
0157 
0158 long prom_dtlb_load(unsigned long index,
0159             unsigned long tte_data,
0160             unsigned long vaddr);
0161 
0162 /* Map/Unmap client program address ranges.  First the format of
0163  * the mapping mode argument.
0164  */
0165 #define PROM_MAP_WRITE  0x0001 /* Writable */
0166 #define PROM_MAP_READ   0x0002 /* Readable - sw */
0167 #define PROM_MAP_EXEC   0x0004 /* Executable - sw */
0168 #define PROM_MAP_LOCKED 0x0010 /* Locked, use i/dtlb load calls for this instead */
0169 #define PROM_MAP_CACHED 0x0020 /* Cacheable in both L1 and L2 caches */
0170 #define PROM_MAP_SE 0x0040 /* Side-Effects */
0171 #define PROM_MAP_GLOB   0x0080 /* Global */
0172 #define PROM_MAP_IE 0x0100 /* Invert-Endianness */
0173 #define PROM_MAP_DEFAULT (PROM_MAP_WRITE | PROM_MAP_READ | PROM_MAP_EXEC | PROM_MAP_CACHED)
0174 
0175 int prom_map(int mode, unsigned long size,
0176          unsigned long vaddr, unsigned long paddr);
0177 void prom_unmap(unsigned long size, unsigned long vaddr);
0178 
0179 
0180 /* PROM device tree traversal functions... */
0181 
0182 /* Get the child node of the given node, or zero if no child exists. */
0183 phandle prom_getchild(phandle parent_node);
0184 
0185 /* Get the next sibling node of the given node, or zero if no further
0186  * siblings exist.
0187  */
0188 phandle prom_getsibling(phandle node);
0189 
0190 /* Get the length, at the passed node, of the given property type.
0191  * Returns -1 on error (ie. no such property at this node).
0192  */
0193 int prom_getproplen(phandle thisnode, const char *property);
0194 
0195 /* Fetch the requested property using the given buffer.  Returns
0196  * the number of bytes the prom put into your buffer or -1 on error.
0197  */
0198 int prom_getproperty(phandle thisnode, const char *property,
0199              char *prop_buffer, int propbuf_size);
0200 
0201 /* Acquire an integer property. */
0202 int prom_getint(phandle node, const char *property);
0203 
0204 /* Acquire an integer property, with a default value. */
0205 int prom_getintdefault(phandle node, const char *property, int defval);
0206 
0207 /* Acquire a boolean property, 0=FALSE 1=TRUE. */
0208 int prom_getbool(phandle node, const char *prop);
0209 
0210 /* Acquire a string property, null string on error. */
0211 void prom_getstring(phandle node, const char *prop, char *buf,
0212             int bufsize);
0213 
0214 /* Does the passed node have the given "name"? YES=1 NO=0 */
0215 int prom_nodematch(phandle thisnode, const char *name);
0216 
0217 /* Search all siblings starting at the passed node for "name" matching
0218  * the given string.  Returns the node on success, zero on failure.
0219  */
0220 phandle prom_searchsiblings(phandle node_start, const char *name);
0221 
0222 /* Return the first property type, as a string, for the given node.
0223  * Returns a null string on error. Buffer should be at least 32B long.
0224  */
0225 char *prom_firstprop(phandle node, char *buffer);
0226 
0227 /* Returns the next property after the passed property for the given
0228  * node.  Returns null string on failure. Buffer should be at least 32B long.
0229  */
0230 char *prom_nextprop(phandle node, const char *prev_property, char *buf);
0231 
0232 /* Returns 1 if the specified node has given property. */
0233 int prom_node_has_property(phandle node, const char *property);
0234 
0235 /* Returns phandle of the path specified */
0236 phandle prom_finddevice(const char *name);
0237 
0238 /* Set the indicated property at the given node with the passed value.
0239  * Returns the number of bytes of your value that the prom took.
0240  */
0241 int prom_setprop(phandle node, const char *prop_name, char *prop_value,
0242          int value_size);
0243 
0244 phandle prom_inst2pkg(int);
0245 void prom_sun4v_guest_soft_state(void);
0246 
0247 int prom_ihandle2path(int handle, char *buffer, int bufsize);
0248 
0249 /* Client interface level routines. */
0250 void p1275_cmd_direct(unsigned long *);
0251 
0252 #endif /* !(__SPARC64_OPLIB_H) */