1 /* $Id: oplib.h,v 1.11 1999/08/31 19:25:49 davem Exp $ 2 * oplib.h: Describes the interface and available routines in the 5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 6 * Copyright (C) 1996 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 9 #ifndef __SPARC64_OPLIB_H 10 #define __SPARC64_OPLIB_H 12 #include <asm/openprom.h> 14 /* Enumeration to describe the prom major version we have detected. */ 15 enum prom_major_version
{ 16 PROM_V0
,/* Original sun4c V0 prom */ 17 PROM_V2
,/* sun4c and early sun4m V2 prom */ 18 PROM_V3
,/* sun4m and later, up to sun4d/sun4e machines V3 */ 19 PROM_P1275
,/* IEEE compliant ISA based Sun PROM, only sun4u */ 20 PROM_AP1000
,/* actually no prom at all */ 23 externenum prom_major_version prom_vers
; 24 /* Revision, and firmware revision. */ 25 externunsigned int prom_rev
, prom_prev
; 27 /* Root node of the prom device tree, this stays constant after 28 * initialization is complete. 30 externint prom_root_node
; 32 /* PROM stdin and stdout */ 33 externint prom_stdin
, prom_stdout
; 35 /* /chosen node of the prom device tree, this stays constant after 36 * initialization is complete. 38 externint prom_chosen_node
; 40 struct linux_mlist_p1275
{ 41 struct linux_mlist_p1275
*theres_more
; 42 unsigned long start_adr
; 43 unsigned long num_bytes
; 46 struct linux_mem_p1275
{ 47 struct linux_mlist_p1275
**p1275_totphys
; 48 struct linux_mlist_p1275
**p1275_prommap
; 49 struct linux_mlist_p1275
**p1275_available
;/* What we can use */ 52 /* The functions... */ 54 /* You must call prom_init() before using any of the library services, 55 * preferably as early as possible. Pass it the romvec pointer. 57 externvoidprom_init(void*cif_handler
,void*cif_stack
); 59 /* Boot argument acquisition, returns the boot command line string. */ 60 externchar*prom_getbootargs(void); 62 /* Device utilities. */ 64 /* Device operations. */ 66 /* Open the device described by the passed string. Note, that the format 67 * of the string is different on V0 vs. V2->higher proms. The caller must 68 * know what he/she is doing! Returns the device descriptor, an int. 70 externintprom_devopen(char*device_string
); 72 /* Close a previously opened device described by the passed integer 75 externintprom_devclose(int device_handle
); 77 /* Do a seek operation on the device described by the passed integer 80 externvoidprom_seek(int device_handle
,unsigned int seek_hival
, 81 unsigned int seek_lowval
); 83 /* Machine memory configuration routine. */ 85 /* This function returns a V0 format memory descriptor table, it has three 86 * entries. One for the total amount of physical ram on the machine, one 87 * for the amount of physical ram available, and one describing the virtual 88 * areas which are allocated by the prom. So, in a sense the physical 89 * available is a calculation of the total physical minus the physical mapped 90 * by the prom with virtual mappings. 92 * These lists are returned pre-sorted, this should make your life easier 93 * since the prom itself is way too lazy to do such nice things. 95 externstruct linux_mem_p1275
*prom_meminfo(void); 97 /* Miscellaneous routines, don't really fit in any category per se. */ 99 /* Reboot the machine with the command line passed. */ 100 externvoidprom_reboot(char*boot_command
); 102 /* Evaluate the forth string passed. */ 103 externvoidprom_feval(char*forth_string
); 105 /* Enter the prom, with possibility of continuation with the 'go' 106 * command in newer proms. 108 externvoidprom_cmdline(void); 110 /* Enter the prom, with no chance of continuation for the stand-alone 113 externvoidprom_halt(void)__attribute__((noreturn
)); 115 /* Set the PROM 'sync' callback function to the passed function pointer. 116 * When the user gives the 'sync' command at the prom prompt while the 117 * kernel is still active, the prom will call this routine. 120 typedefint(*callback_func_t
)(long*cmd
); 121 externvoidprom_setcallback(callback_func_t func_ptr
); 123 /* Acquire the IDPROM of the root node in the prom device tree. This 124 * gets passed a buffer where you would like it stuffed. The return value 125 * is the format type of this idprom or 0xff on error. 127 externunsigned charprom_get_idprom(char*idp_buffer
,int idpbuf_size
); 129 /* Get the prom major version. */ 130 externintprom_version(void); 132 /* Get the prom plugin revision. */ 133 externintprom_getrev(void); 135 /* Get the prom firmware revision. */ 136 externintprom_getprev(void); 138 /* Character operations to/from the console.... */ 140 /* Non-blocking get character from console. */ 141 externintprom_nbgetchar(void); 143 /* Non-blocking put character to console. */ 144 externintprom_nbputchar(char character
); 146 /* Blocking get character from console. */ 147 externcharprom_getchar(void); 149 /* Blocking put character to console. */ 150 externvoidprom_putchar(char character
); 152 /* Prom's internal printf routine, don't use in kernel/boot code. */ 153 voidprom_printf(char*fmt
, ...); 155 /* Query for input device type */ 157 enum prom_input_device
{ 158 PROMDEV_IKBD
,/* input from keyboard */ 159 PROMDEV_ITTYA
,/* input from ttya */ 160 PROMDEV_ITTYB
,/* input from ttyb */ 164 externenum prom_input_device
prom_query_input_device(void); 166 /* Query for output device type */ 168 enum prom_output_device
{ 169 PROMDEV_OSCREEN
,/* to screen */ 170 PROMDEV_OTTYA
,/* to ttya */ 171 PROMDEV_OTTYB
,/* to ttyb */ 175 externenum prom_output_device
prom_query_output_device(void); 177 /* Multiprocessor operations... */ 179 /* Start the CPU with the given device tree node, context table, and context 180 * at the passed program counter. 182 externvoidprom_startcpu(int cpunode
,unsigned long pc
,unsigned long o0
); 184 /* Stop the current CPU. */ 185 externvoidprom_stopself(void); 187 /* Idle the current CPU. */ 188 externvoidprom_idleself(void); 190 /* Resume the CPU with the passed device tree node. */ 191 externvoidprom_resumecpu(int cpunode
); 194 /* Power management interfaces. */ 196 /* Put the current CPU to sleep. */ 197 externvoidprom_sleepself(void); 199 /* Put the entire system to sleep. */ 200 externintprom_sleepsystem(void); 202 /* Initiate a wakeup event. */ 203 externintprom_wakeupsystem(void); 205 /* MMU and memory related OBP interfaces. */ 207 /* Get unique string identifying SIMM at given physical address. */ 208 externintprom_getunumber(int syndrome_code
, 209 unsigned long phys_addr
, 210 char*buf
,int buflen
); 212 /* Retain physical memory to the caller across soft resets. */ 213 externunsigned longprom_retain(char*name
, 214 unsigned long pa_low
,unsigned long pa_high
, 215 long size
,long align
); 217 /* Load explicit I/D TLB entries into the calling processor. */ 218 externlongprom_itlb_load(unsigned long index
, 219 unsigned long tte_data
, 220 unsigned long vaddr
); 222 externlongprom_dtlb_load(unsigned long index
, 223 unsigned long tte_data
, 224 unsigned long vaddr
); 226 /* PROM device tree traversal functions... */ 228 #ifdef PROMLIB_INTERNAL 230 /* Internal version of prom_getchild. */ 231 externint__prom_getchild(int parent_node
); 233 /* Internal version of prom_getsibling. */ 234 externint__prom_getsibling(int node
); 238 /* Get the child node of the given node, or zero if no child exists. */ 239 externintprom_getchild(int parent_node
); 241 /* Get the next sibling node of the given node, or zero if no further 244 externintprom_getsibling(int node
); 246 /* Get the length, at the passed node, of the given property type. 247 * Returns -1 on error (ie. no such property at this node). 249 externintprom_getproplen(int thisnode
,char*property
); 251 /* Fetch the requested property using the given buffer. Returns 252 * the number of bytes the prom put into your buffer or -1 on error. 254 externintprom_getproperty(int thisnode
,char*property
, 255 char*prop_buffer
,int propbuf_size
); 257 /* Acquire an integer property. */ 258 externintprom_getint(int node
,char*property
); 260 /* Acquire an integer property, with a default value. */ 261 externintprom_getintdefault(int node
,char*property
,int defval
); 263 /* Acquire a boolean property, 0=FALSE 1=TRUE. */ 264 externintprom_getbool(int node
,char*prop
); 266 /* Acquire a string property, null string on error. */ 267 externvoidprom_getstring(int node
,char*prop
,char*buf
,int bufsize
); 269 /* Does the passed node have the given "name"? YES=1 NO=0 */ 270 externintprom_nodematch(int thisnode
,char*name
); 272 /* Puts in buffer a prom name in the form name@x,y or name (x for which_io 273 * and y for first regs phys address 275 externintprom_getname(int node
,char*buf
,int buflen
); 277 /* Search all siblings starting at the passed node for "name" matching 278 * the given string. Returns the node on success, zero on failure. 280 externintprom_searchsiblings(int node_start
,char*name
); 282 /* Return the first property type, as a string, for the given node. 283 * Returns a null string on error. Buffer should be at least 32B long. 285 externchar*prom_firstprop(int node
,char*buffer
); 287 /* Returns the next property after the passed property for the given 288 * node. Returns null string on failure. Buffer should be at least 32B long. 290 externchar*prom_nextprop(int node
,char*prev_property
,char*buffer
); 292 /* Returns 1 if the specified node has given property. */ 293 externintprom_node_has_property(int node
,char*property
); 295 /* Returns phandle of the path specified */ 296 externintprom_finddevice(char*name
); 298 /* Set the indicated property at the given node with the passed value. 299 * Returns the number of bytes of your value that the prom took. 301 externintprom_setprop(int node
,char*prop_name
,char*prop_value
, 304 externintprom_pathtoinode(char*path
); 305 externintprom_inst2pkg(int); 307 /* Client interface level routines. */ 308 externvoidprom_set_trap_table(unsigned long tba
); 310 /* Dorking with Bus ranges... */ 312 /* Adjust reg values with the passed ranges. */ 313 externvoidprom_adjust_regs(struct linux_prom_registers
*regp
,int nregs
, 314 struct linux_prom_ranges
*rangep
,int nranges
); 316 /* Adjust child ranges with the passed parent ranges. */ 317 externvoidprom_adjust_ranges(struct linux_prom_ranges
*cranges
,int ncranges
, 318 struct linux_prom_ranges
*pranges
,int npranges
); 320 /* Apply ranges of any prom node (and optionally parent node as well) to registers. */ 321 externvoidprom_apply_generic_ranges(int node
,int parent
, 322 struct linux_prom_registers
*sbusregs
,int nregs
); 324 externlongp1275_cmd(char*,long, ...); 328 #define P1275_SIZE(x) ((((long)((x) / 32)) << 32) | (x)) 330 #define P1275_SIZE(x) x 333 /* We support at most 16 input and 1 output argument */ 334 #define P1275_ARG_NUMBER 0 335 #define P1275_ARG_IN_STRING 1 336 #define P1275_ARG_OUT_BUF 2 337 #define P1275_ARG_OUT_32B 3 338 #define P1275_ARG_IN_FUNCTION 4 339 #define P1275_ARG_IN_BUF 5 340 #define P1275_ARG_IN_64B 6 342 #define P1275_IN(x) ((x) & 0xf) 343 #define P1275_OUT(x) (((x) << 4) & 0xf0) 344 #define P1275_INOUT(i,o) (P1275_IN(i)|P1275_OUT(o)) 345 #define P1275_ARG(n,x) ((x) << ((n)*3 + 8)) 347 #endif/* !(__SPARC64_OPLIB_H) */