]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/sparc64/prom/misc.c
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>
18 int prom_service_exists(const char *service_name
)
20 int err
= p1275_cmd("test", P1275_ARG(0, P1275_ARG_IN_STRING
) |
21 P1275_INOUT(1, 1), service_name
);
28 void prom_sun4v_guest_soft_state(void)
30 const char *svc
= "SUNW,soft-state-supported";
32 if (!prom_service_exists(svc
))
34 p1275_cmd(svc
, P1275_INOUT(0, 0));
37 /* Reset and reboot the machine with the command 'bcommand'. */
38 void prom_reboot(const char *bcommand
)
40 p1275_cmd("boot", P1275_ARG(0, P1275_ARG_IN_STRING
) |
41 P1275_INOUT(1, 0), bcommand
);
44 /* Forth evaluate the expression contained in 'fstring'. */
45 void prom_feval(const char *fstring
)
47 if (!fstring
|| fstring
[0] == 0)
49 p1275_cmd("interpret", P1275_ARG(0, P1275_ARG_IN_STRING
) |
50 P1275_INOUT(1, 1), fstring
);
53 /* We want to do this more nicely some day. */
54 extern void (*prom_palette
)(int);
57 extern void smp_capture(void);
58 extern void smp_release(void);
61 /* Drop into the prom, with the chance to continue with the 'go'
64 void prom_cmdline(void)
68 local_irq_save(flags
);
70 if (!serial_console
&& prom_palette
)
77 p1275_cmd("enter", P1275_INOUT(0, 0));
83 if (!serial_console
&& prom_palette
)
86 local_irq_restore(flags
);
89 /* Drop into the prom, but completely terminate the program.
90 * No chance of continuing.
95 p1275_cmd("exit", P1275_INOUT(0, 0));
96 goto again
; /* PROM is out to get me -DaveM */
99 void prom_halt_power_off(void)
101 p1275_cmd("SUNW,power-off", P1275_INOUT(0, 0));
103 /* if nothing else helps, we just halt */
107 /* Set prom sync handler to call function 'funcp'. */
108 void prom_setcallback(callback_func_t funcp
)
112 p1275_cmd("set-callback", P1275_ARG(0, P1275_ARG_IN_FUNCTION
) |
113 P1275_INOUT(1, 1), funcp
);
116 /* Get the idprom and stuff it into buffer 'idbuf'. Returns the
117 * format type. 'num_bytes' is the number of bytes that your idbuf
118 * has space for. Returns 0xff on error.
120 unsigned char prom_get_idprom(char *idbuf
, int num_bytes
)
124 len
= prom_getproplen(prom_root_node
, "idprom");
125 if ((len
>num_bytes
) || (len
== -1))
127 if (!prom_getproperty(prom_root_node
, "idprom", idbuf
, num_bytes
))
133 /* Install Linux trap table so PROM uses that instead of its own. */
134 void prom_set_trap_table(unsigned long tba
)
136 p1275_cmd("SUNW,set-trap-table",
137 (P1275_ARG(0, P1275_ARG_IN_64B
) |
138 P1275_INOUT(1, 0)), tba
);
141 void prom_set_trap_table_sun4v(unsigned long tba
, unsigned long mmfsa
)
143 p1275_cmd("SUNW,set-trap-table",
144 (P1275_ARG(0, P1275_ARG_IN_64B
) |
145 P1275_ARG(1, P1275_ARG_IN_64B
) |
146 P1275_INOUT(2, 0)), tba
, mmfsa
);
149 int prom_get_mmu_ihandle(void)
153 if (prom_mmu_ihandle_cache
!= 0)
154 return prom_mmu_ihandle_cache
;
156 node
= prom_finddevice(prom_chosen_path
);
157 ret
= prom_getint(node
, prom_mmu_name
);
158 if (ret
== -1 || ret
== 0)
159 prom_mmu_ihandle_cache
= -1;
161 prom_mmu_ihandle_cache
= ret
;
166 static int prom_get_memory_ihandle(void)
168 static int memory_ihandle_cache
;
171 if (memory_ihandle_cache
!= 0)
172 return memory_ihandle_cache
;
174 node
= prom_finddevice("/chosen");
175 ret
= prom_getint(node
, "memory");
176 if (ret
== -1 || ret
== 0)
177 memory_ihandle_cache
= -1;
179 memory_ihandle_cache
= ret
;
184 /* Load explicit I/D TLB entries. */
185 long prom_itlb_load(unsigned long index
,
186 unsigned long tte_data
,
189 return p1275_cmd(prom_callmethod_name
,
190 (P1275_ARG(0, P1275_ARG_IN_STRING
) |
191 P1275_ARG(2, P1275_ARG_IN_64B
) |
192 P1275_ARG(3, P1275_ARG_IN_64B
) |
195 prom_get_mmu_ihandle(),
196 /* And then our actual args are pushed backwards. */
202 long prom_dtlb_load(unsigned long index
,
203 unsigned long tte_data
,
206 return p1275_cmd(prom_callmethod_name
,
207 (P1275_ARG(0, P1275_ARG_IN_STRING
) |
208 P1275_ARG(2, P1275_ARG_IN_64B
) |
209 P1275_ARG(3, P1275_ARG_IN_64B
) |
212 prom_get_mmu_ihandle(),
213 /* And then our actual args are pushed backwards. */
219 int prom_map(int mode
, unsigned long size
,
220 unsigned long vaddr
, unsigned long paddr
)
222 int ret
= p1275_cmd(prom_callmethod_name
,
223 (P1275_ARG(0, P1275_ARG_IN_STRING
) |
224 P1275_ARG(3, P1275_ARG_IN_64B
) |
225 P1275_ARG(4, P1275_ARG_IN_64B
) |
226 P1275_ARG(6, P1275_ARG_IN_64B
) |
229 prom_get_mmu_ihandle(),
241 void prom_unmap(unsigned long size
, unsigned long vaddr
)
243 p1275_cmd(prom_callmethod_name
,
244 (P1275_ARG(0, P1275_ARG_IN_STRING
) |
245 P1275_ARG(2, P1275_ARG_IN_64B
) |
246 P1275_ARG(3, P1275_ARG_IN_64B
) |
249 prom_get_mmu_ihandle(),
254 /* Set aside physical memory which is not touched or modified
255 * across soft resets.
257 unsigned long prom_retain(const char *name
,
258 unsigned long pa_low
, unsigned long pa_high
,
259 long size
, long align
)
261 /* XXX I don't think we return multiple values correctly.
262 * XXX OBP supposedly returns pa_low/pa_high here, how does
266 /* If align is zero, the pa_low/pa_high args are passed,
270 return p1275_cmd("SUNW,retain",
271 (P1275_ARG(0, P1275_ARG_IN_BUF
) | P1275_INOUT(5, 2)),
272 name
, pa_low
, pa_high
, size
, align
);
274 return p1275_cmd("SUNW,retain",
275 (P1275_ARG(0, P1275_ARG_IN_BUF
) | P1275_INOUT(3, 2)),
279 /* Get "Unumber" string for the SIMM at the given
280 * memory address. Usually this will be of the form
281 * "Uxxxx" where xxxx is a decimal number which is
282 * etched into the motherboard next to the SIMM slot
285 int prom_getunumber(int syndrome_code
,
286 unsigned long phys_addr
,
287 char *buf
, int buflen
)
289 return p1275_cmd(prom_callmethod_name
,
290 (P1275_ARG(0, P1275_ARG_IN_STRING
) |
291 P1275_ARG(3, P1275_ARG_OUT_BUF
) |
292 P1275_ARG(6, P1275_ARG_IN_64B
) |
294 "SUNW,get-unumber", prom_get_memory_ihandle(),
295 buflen
, buf
, P1275_SIZE(buflen
),
296 0, phys_addr
, syndrome_code
);
299 /* Power management extensions. */
300 void prom_sleepself(void)
302 p1275_cmd("SUNW,sleep-self", P1275_INOUT(0, 0));
305 int prom_sleepsystem(void)
307 return p1275_cmd("SUNW,sleep-system", P1275_INOUT(0, 1));
310 int prom_wakeupsystem(void)
312 return p1275_cmd("SUNW,wakeup-system", P1275_INOUT(0, 1));
316 void prom_startcpu(int cpunode
, unsigned long pc
, unsigned long arg
)
318 p1275_cmd("SUNW,start-cpu", P1275_INOUT(3, 0), cpunode
, pc
, arg
);
321 void prom_startcpu_cpuid(int cpuid
, unsigned long pc
, unsigned long arg
)
323 p1275_cmd("SUNW,start-cpu-by-cpuid", P1275_INOUT(3, 0),
327 void prom_stopcpu_cpuid(int cpuid
)
329 p1275_cmd("SUNW,stop-cpu-by-cpuid", P1275_INOUT(1, 0),
333 void prom_stopself(void)
335 p1275_cmd("SUNW,stop-self", P1275_INOUT(0, 0));
338 void prom_idleself(void)
340 p1275_cmd("SUNW,idle-self", P1275_INOUT(0, 0));
343 void prom_resumecpu(int cpunode
)
345 p1275_cmd("SUNW,resume-cpu", P1275_INOUT(1, 0), cpunode
);