1 /* $Id: misc.c,v 1.20 2001/09/21 03:17:07 kanoj Exp $
2 * misc.c: Miscellaneous prom functions that don't belong
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
9 #include <linux/types.h>
10 #include <linux/kernel.h>
11 #include <linux/sched.h>
12 #include <linux/interrupt.h>
13 #include <linux/delay.h>
14 #include <asm/openprom.h>
15 #include <asm/oplib.h>
16 #include <asm/system.h>
19 int prom_service_exists(const char *service_name
)
21 int err
= p1275_cmd("test", P1275_ARG(0, P1275_ARG_IN_STRING
) |
22 P1275_INOUT(1, 1), service_name
);
29 void prom_sun4v_guest_soft_state(void)
31 const char *svc
= "SUNW,soft-state-supported";
33 if (!prom_service_exists(svc
))
35 p1275_cmd(svc
, P1275_INOUT(0, 0));
38 /* Reset and reboot the machine with the command 'bcommand'. */
39 void prom_reboot(const char *bcommand
)
41 #ifdef CONFIG_SUN_LDOMS
42 if (ldom_domaining_enabled
)
43 ldom_reboot(bcommand
);
45 p1275_cmd("boot", P1275_ARG(0, P1275_ARG_IN_STRING
) |
46 P1275_INOUT(1, 0), bcommand
);
49 /* Forth evaluate the expression contained in 'fstring'. */
50 void prom_feval(const char *fstring
)
52 if (!fstring
|| fstring
[0] == 0)
54 p1275_cmd("interpret", P1275_ARG(0, P1275_ARG_IN_STRING
) |
55 P1275_INOUT(1, 1), fstring
);
58 <<<<<<< HEAD
:arch
/sparc64
/prom
/misc
.c
59 /* We want to do this more nicely some day. */
60 extern void (*prom_palette
)(int);
63 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/sparc64
/prom
/misc
.c
65 extern void smp_capture(void);
66 extern void smp_release(void);
69 /* Drop into the prom, with the chance to continue with the 'go'
72 void prom_cmdline(void)
76 local_irq_save(flags
);
78 <<<<<<< HEAD
:arch
/sparc64
/prom
/misc
.c
83 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/sparc64
/prom
/misc
.c
88 p1275_cmd("enter", P1275_INOUT(0, 0));
94 <<<<<<< HEAD
:arch
/sparc64
/prom
/misc
.c
99 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/sparc64
/prom
/misc
.c
100 local_irq_restore(flags
);
103 /* Drop into the prom, but completely terminate the program.
104 * No chance of continuing.
108 #ifdef CONFIG_SUN_LDOMS
109 if (ldom_domaining_enabled
)
113 p1275_cmd("exit", P1275_INOUT(0, 0));
114 goto again
; /* PROM is out to get me -DaveM */
117 void prom_halt_power_off(void)
119 #ifdef CONFIG_SUN_LDOMS
120 if (ldom_domaining_enabled
)
123 p1275_cmd("SUNW,power-off", P1275_INOUT(0, 0));
125 /* if nothing else helps, we just halt */
129 /* Set prom sync handler to call function 'funcp'. */
130 void prom_setcallback(callback_func_t funcp
)
134 p1275_cmd("set-callback", P1275_ARG(0, P1275_ARG_IN_FUNCTION
) |
135 P1275_INOUT(1, 1), funcp
);
138 /* Get the idprom and stuff it into buffer 'idbuf'. Returns the
139 * format type. 'num_bytes' is the number of bytes that your idbuf
140 * has space for. Returns 0xff on error.
142 unsigned char prom_get_idprom(char *idbuf
, int num_bytes
)
146 len
= prom_getproplen(prom_root_node
, "idprom");
147 if ((len
>num_bytes
) || (len
== -1))
149 if (!prom_getproperty(prom_root_node
, "idprom", idbuf
, num_bytes
))
155 int prom_get_mmu_ihandle(void)
159 if (prom_mmu_ihandle_cache
!= 0)
160 return prom_mmu_ihandle_cache
;
162 node
= prom_finddevice(prom_chosen_path
);
163 ret
= prom_getint(node
, prom_mmu_name
);
164 if (ret
== -1 || ret
== 0)
165 prom_mmu_ihandle_cache
= -1;
167 prom_mmu_ihandle_cache
= ret
;
172 static int prom_get_memory_ihandle(void)
174 static int memory_ihandle_cache
;
177 if (memory_ihandle_cache
!= 0)
178 return memory_ihandle_cache
;
180 node
= prom_finddevice("/chosen");
181 ret
= prom_getint(node
, "memory");
182 if (ret
== -1 || ret
== 0)
183 memory_ihandle_cache
= -1;
185 memory_ihandle_cache
= ret
;
190 /* Load explicit I/D TLB entries. */
191 long prom_itlb_load(unsigned long index
,
192 unsigned long tte_data
,
195 return p1275_cmd(prom_callmethod_name
,
196 (P1275_ARG(0, P1275_ARG_IN_STRING
) |
197 P1275_ARG(2, P1275_ARG_IN_64B
) |
198 P1275_ARG(3, P1275_ARG_IN_64B
) |
201 prom_get_mmu_ihandle(),
202 /* And then our actual args are pushed backwards. */
208 long prom_dtlb_load(unsigned long index
,
209 unsigned long tte_data
,
212 return p1275_cmd(prom_callmethod_name
,
213 (P1275_ARG(0, P1275_ARG_IN_STRING
) |
214 P1275_ARG(2, P1275_ARG_IN_64B
) |
215 P1275_ARG(3, P1275_ARG_IN_64B
) |
218 prom_get_mmu_ihandle(),
219 /* And then our actual args are pushed backwards. */
225 int prom_map(int mode
, unsigned long size
,
226 unsigned long vaddr
, unsigned long paddr
)
228 int ret
= p1275_cmd(prom_callmethod_name
,
229 (P1275_ARG(0, P1275_ARG_IN_STRING
) |
230 P1275_ARG(3, P1275_ARG_IN_64B
) |
231 P1275_ARG(4, P1275_ARG_IN_64B
) |
232 P1275_ARG(6, P1275_ARG_IN_64B
) |
235 prom_get_mmu_ihandle(),
247 void prom_unmap(unsigned long size
, unsigned long vaddr
)
249 p1275_cmd(prom_callmethod_name
,
250 (P1275_ARG(0, P1275_ARG_IN_STRING
) |
251 P1275_ARG(2, P1275_ARG_IN_64B
) |
252 P1275_ARG(3, P1275_ARG_IN_64B
) |
255 prom_get_mmu_ihandle(),
260 /* Set aside physical memory which is not touched or modified
261 * across soft resets.
263 unsigned long prom_retain(const char *name
,
264 unsigned long pa_low
, unsigned long pa_high
,
265 long size
, long align
)
267 /* XXX I don't think we return multiple values correctly.
268 * XXX OBP supposedly returns pa_low/pa_high here, how does
272 /* If align is zero, the pa_low/pa_high args are passed,
276 return p1275_cmd("SUNW,retain",
277 (P1275_ARG(0, P1275_ARG_IN_BUF
) | P1275_INOUT(5, 2)),
278 name
, pa_low
, pa_high
, size
, align
);
280 return p1275_cmd("SUNW,retain",
281 (P1275_ARG(0, P1275_ARG_IN_BUF
) | P1275_INOUT(3, 2)),
285 /* Get "Unumber" string for the SIMM at the given
286 * memory address. Usually this will be of the form
287 * "Uxxxx" where xxxx is a decimal number which is
288 * etched into the motherboard next to the SIMM slot
291 int prom_getunumber(int syndrome_code
,
292 unsigned long phys_addr
,
293 char *buf
, int buflen
)
295 return p1275_cmd(prom_callmethod_name
,
296 (P1275_ARG(0, P1275_ARG_IN_STRING
) |
297 P1275_ARG(3, P1275_ARG_OUT_BUF
) |
298 P1275_ARG(6, P1275_ARG_IN_64B
) |
300 "SUNW,get-unumber", prom_get_memory_ihandle(),
301 buflen
, buf
, P1275_SIZE(buflen
),
302 0, phys_addr
, syndrome_code
);
305 /* Power management extensions. */
306 void prom_sleepself(void)
308 p1275_cmd("SUNW,sleep-self", P1275_INOUT(0, 0));
311 int prom_sleepsystem(void)
313 return p1275_cmd("SUNW,sleep-system", P1275_INOUT(0, 1));
316 int prom_wakeupsystem(void)
318 return p1275_cmd("SUNW,wakeup-system", P1275_INOUT(0, 1));
322 void prom_startcpu(int cpunode
, unsigned long pc
, unsigned long arg
)
324 p1275_cmd("SUNW,start-cpu", P1275_INOUT(3, 0), cpunode
, pc
, arg
);
327 void prom_startcpu_cpuid(int cpuid
, unsigned long pc
, unsigned long arg
)
329 p1275_cmd("SUNW,start-cpu-by-cpuid", P1275_INOUT(3, 0),
333 void prom_stopcpu_cpuid(int cpuid
)
335 p1275_cmd("SUNW,stop-cpu-by-cpuid", P1275_INOUT(1, 0),
339 void prom_stopself(void)
341 p1275_cmd("SUNW,stop-self", P1275_INOUT(0, 0));
344 void prom_idleself(void)
346 p1275_cmd("SUNW,idle-self", P1275_INOUT(0, 0));
349 void prom_resumecpu(int cpunode
)
351 p1275_cmd("SUNW,resume-cpu", P1275_INOUT(1, 0), cpunode
);