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 <linux/module.h>
16 #include <asm/openprom.h>
17 #include <asm/oplib.h>
18 #include <asm/system.h>
21 int prom_service_exists(const char *service_name
)
23 unsigned long args
[5];
25 args
[0] = (unsigned long) "test";
28 args
[3] = (unsigned long) service_name
;
29 args
[4] = (unsigned long) -1;
31 p1275_cmd_direct(args
);
38 void prom_sun4v_guest_soft_state(void)
40 const char *svc
= "SUNW,soft-state-supported";
41 unsigned long args
[3];
43 if (!prom_service_exists(svc
))
45 args
[0] = (unsigned long) svc
;
48 p1275_cmd_direct(args
);
51 /* Reset and reboot the machine with the command 'bcommand'. */
52 void prom_reboot(const char *bcommand
)
54 unsigned long args
[4];
56 #ifdef CONFIG_SUN_LDOMS
57 if (ldom_domaining_enabled
)
58 ldom_reboot(bcommand
);
60 args
[0] = (unsigned long) "boot";
63 args
[3] = (unsigned long) bcommand
;
65 p1275_cmd_direct(args
);
68 /* Forth evaluate the expression contained in 'fstring'. */
69 void prom_feval(const char *fstring
)
71 unsigned long args
[5];
73 if (!fstring
|| fstring
[0] == 0)
75 args
[0] = (unsigned long) "interpret";
78 args
[3] = (unsigned long) fstring
;
79 args
[4] = (unsigned long) -1;
81 p1275_cmd_direct(args
);
83 EXPORT_SYMBOL(prom_feval
);
86 extern void smp_capture(void);
87 extern void smp_release(void);
90 /* Drop into the prom, with the chance to continue with the 'go'
93 void prom_cmdline(void)
95 unsigned long args
[3];
98 local_irq_save(flags
);
104 args
[0] = (unsigned long) "enter";
108 p1275_cmd_direct(args
);
114 local_irq_restore(flags
);
117 /* Drop into the prom, but completely terminate the program.
118 * No chance of continuing.
120 void notrace
prom_halt(void)
122 unsigned long args
[3];
124 #ifdef CONFIG_SUN_LDOMS
125 if (ldom_domaining_enabled
)
129 args
[0] = (unsigned long) "exit";
132 p1275_cmd_direct(args
);
133 goto again
; /* PROM is out to get me -DaveM */
136 void prom_halt_power_off(void)
138 unsigned long args
[3];
140 #ifdef CONFIG_SUN_LDOMS
141 if (ldom_domaining_enabled
)
144 args
[0] = (unsigned long) "SUNW,power-off";
147 p1275_cmd_direct(args
);
149 /* if nothing else helps, we just halt */
153 /* Set prom sync handler to call function 'funcp'. */
154 void prom_setcallback(callback_func_t funcp
)
156 unsigned long args
[5];
159 args
[0] = (unsigned long) "set-callback";
162 args
[3] = (unsigned long) funcp
;
163 args
[4] = (unsigned long) -1;
164 p1275_cmd_direct(args
);
167 /* Get the idprom and stuff it into buffer 'idbuf'. Returns the
168 * format type. 'num_bytes' is the number of bytes that your idbuf
169 * has space for. Returns 0xff on error.
171 unsigned char prom_get_idprom(char *idbuf
, int num_bytes
)
175 len
= prom_getproplen(prom_root_node
, "idprom");
176 if ((len
>num_bytes
) || (len
== -1))
178 if (!prom_getproperty(prom_root_node
, "idprom", idbuf
, num_bytes
))
184 int prom_get_mmu_ihandle(void)
188 if (prom_mmu_ihandle_cache
!= 0)
189 return prom_mmu_ihandle_cache
;
191 node
= prom_finddevice(prom_chosen_path
);
192 ret
= prom_getint(node
, prom_mmu_name
);
193 if (ret
== -1 || ret
== 0)
194 prom_mmu_ihandle_cache
= -1;
196 prom_mmu_ihandle_cache
= ret
;
201 static int prom_get_memory_ihandle(void)
203 static int memory_ihandle_cache
;
206 if (memory_ihandle_cache
!= 0)
207 return memory_ihandle_cache
;
209 node
= prom_finddevice("/chosen");
210 ret
= prom_getint(node
, "memory");
211 if (ret
== -1 || ret
== 0)
212 memory_ihandle_cache
= -1;
214 memory_ihandle_cache
= ret
;
219 /* Load explicit I/D TLB entries. */
220 static long tlb_load(const char *type
, unsigned long index
,
221 unsigned long tte_data
, unsigned long vaddr
)
223 unsigned long args
[9];
225 args
[0] = (unsigned long) prom_callmethod_name
;
228 args
[3] = (unsigned long) type
;
229 args
[4] = (unsigned int) prom_get_mmu_ihandle();
233 args
[8] = (unsigned long) -1;
235 p1275_cmd_direct(args
);
237 return (long) args
[8];
240 long prom_itlb_load(unsigned long index
,
241 unsigned long tte_data
,
244 return tlb_load("SUNW,itlb-load", index
, tte_data
, vaddr
);
247 long prom_dtlb_load(unsigned long index
,
248 unsigned long tte_data
,
251 return tlb_load("SUNW,dtlb-load", index
, tte_data
, vaddr
);
254 int prom_map(int mode
, unsigned long size
,
255 unsigned long vaddr
, unsigned long paddr
)
257 unsigned long args
[11];
260 args
[0] = (unsigned long) prom_callmethod_name
;
263 args
[3] = (unsigned long) prom_map_name
;
264 args
[4] = (unsigned int) prom_get_mmu_ihandle();
265 args
[5] = (unsigned int) mode
;
270 args
[10] = (unsigned long) -1;
272 p1275_cmd_direct(args
);
274 ret
= (int) args
[10];
280 void prom_unmap(unsigned long size
, unsigned long vaddr
)
282 unsigned long args
[7];
284 args
[0] = (unsigned long) prom_callmethod_name
;
287 args
[3] = (unsigned long) prom_unmap_name
;
288 args
[4] = (unsigned int) prom_get_mmu_ihandle();
292 p1275_cmd_direct(args
);
295 /* Set aside physical memory which is not touched or modified
296 * across soft resets.
298 int prom_retain(const char *name
, unsigned long size
,
299 unsigned long align
, unsigned long *paddr
)
301 unsigned long args
[11];
303 args
[0] = (unsigned long) prom_callmethod_name
;
306 args
[3] = (unsigned long) "SUNW,retain";
307 args
[4] = (unsigned int) prom_get_memory_ihandle();
310 args
[7] = (unsigned long) name
;
311 args
[8] = (unsigned long) -1;
312 args
[9] = (unsigned long) -1;
313 args
[10] = (unsigned long) -1;
315 p1275_cmd_direct(args
);
318 return (int) args
[8];
320 /* Next we get "phys_high" then "phys_low". On 64-bit
321 * the phys_high cell is don't care since the phys_low
322 * cell has the full value.
329 /* Get "Unumber" string for the SIMM at the given
330 * memory address. Usually this will be of the form
331 * "Uxxxx" where xxxx is a decimal number which is
332 * etched into the motherboard next to the SIMM slot
335 int prom_getunumber(int syndrome_code
,
336 unsigned long phys_addr
,
337 char *buf
, int buflen
)
339 unsigned long args
[12];
341 args
[0] = (unsigned long) prom_callmethod_name
;
344 args
[3] = (unsigned long) "SUNW,get-unumber";
345 args
[4] = (unsigned int) prom_get_memory_ihandle();
347 args
[6] = (unsigned long) buf
;
350 args
[9] = (unsigned int) syndrome_code
;
351 args
[10] = (unsigned long) -1;
352 args
[11] = (unsigned long) -1;
354 p1275_cmd_direct(args
);
356 return (int) args
[10];
359 /* Power management extensions. */
360 void prom_sleepself(void)
362 unsigned long args
[3];
364 args
[0] = (unsigned long) "SUNW,sleep-self";
367 p1275_cmd_direct(args
);
370 int prom_sleepsystem(void)
372 unsigned long args
[4];
374 args
[0] = (unsigned long) "SUNW,sleep-system";
377 args
[3] = (unsigned long) -1;
378 p1275_cmd_direct(args
);
380 return (int) args
[3];
383 int prom_wakeupsystem(void)
385 unsigned long args
[4];
387 args
[0] = (unsigned long) "SUNW,wakeup-system";
390 args
[3] = (unsigned long) -1;
391 p1275_cmd_direct(args
);
393 return (int) args
[3];
397 void prom_startcpu(int cpunode
, unsigned long pc
, unsigned long arg
)
399 unsigned long args
[6];
401 args
[0] = (unsigned long) "SUNW,start-cpu";
404 args
[3] = (unsigned int) cpunode
;
407 p1275_cmd_direct(args
);
410 void prom_startcpu_cpuid(int cpuid
, unsigned long pc
, unsigned long arg
)
412 unsigned long args
[6];
414 args
[0] = (unsigned long) "SUNW,start-cpu-by-cpuid";
417 args
[3] = (unsigned int) cpuid
;
420 p1275_cmd_direct(args
);
423 void prom_stopcpu_cpuid(int cpuid
)
425 unsigned long args
[4];
427 args
[0] = (unsigned long) "SUNW,stop-cpu-by-cpuid";
430 args
[3] = (unsigned int) cpuid
;
431 p1275_cmd_direct(args
);
434 void prom_stopself(void)
436 unsigned long args
[3];
438 args
[0] = (unsigned long) "SUNW,stop-self";
441 p1275_cmd_direct(args
);
444 void prom_idleself(void)
446 unsigned long args
[3];
448 args
[0] = (unsigned long) "SUNW,idle-self";
451 p1275_cmd_direct(args
);
454 void prom_resumecpu(int cpunode
)
456 unsigned long args
[4];
458 args
[0] = (unsigned long) "SUNW,resume-cpu";
461 args
[3] = (unsigned int) cpunode
;
462 p1275_cmd_direct(args
);
This page took 0.099867 seconds and 6 git commands to generate.