Ok. I didn't make 2.4.0 in 2000. Tough. I tried, but we had some
[davej-history.git] / arch / sparc / prom / misc.c
blob86ce399101986f8fb936108fc7308e69ee566286
1 /* $Id: misc.c,v 1.18 2000/08/26 02:38:03 anton Exp $
2 * misc.c: Miscellaneous prom functions that don't belong
3 * anywhere else.
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */
8 #include <linux/config.h>
9 #include <linux/types.h>
10 #include <linux/kernel.h>
11 #include <linux/sched.h>
12 #include <asm/openprom.h>
13 #include <asm/oplib.h>
14 #include <asm/auxio.h>
16 extern void restore_current(void);
18 spinlock_t prom_lock = SPIN_LOCK_UNLOCKED;
20 /* Reset and reboot the machine with the command 'bcommand'. */
21 void
22 prom_reboot(char *bcommand)
24 unsigned long flags;
25 spin_lock_irqsave(&prom_lock, flags);
26 (*(romvec->pv_reboot))(bcommand);
27 /* Never get here. */
28 restore_current();
29 spin_unlock_irqrestore(&prom_lock, flags);
32 /* Forth evaluate the expression contained in 'fstring'. */
33 void
34 prom_feval(char *fstring)
36 unsigned long flags;
37 if(!fstring || fstring[0] == 0)
38 return;
39 spin_lock_irqsave(&prom_lock, flags);
40 if(prom_vers == PROM_V0)
41 (*(romvec->pv_fortheval.v0_eval))(strlen(fstring), fstring);
42 else
43 (*(romvec->pv_fortheval.v2_eval))(fstring);
44 restore_current();
45 spin_unlock_irqrestore(&prom_lock, flags);
48 /* We want to do this more nicely some day. */
49 #ifdef CONFIG_SUN_CONSOLE
50 extern void (*prom_palette)(int);
51 extern int serial_console;
52 #endif
54 /* Drop into the prom, with the chance to continue with the 'go'
55 * prom command.
57 void
58 prom_cmdline(void)
60 extern void kernel_enter_debugger(void);
61 extern void install_obp_ticker(void);
62 extern void install_linux_ticker(void);
63 unsigned long flags;
65 kernel_enter_debugger();
66 #ifdef CONFIG_SUN_CONSOLE
67 if(!serial_console && prom_palette)
68 prom_palette (1);
69 #endif
70 install_obp_ticker();
71 spin_lock_irqsave(&prom_lock, flags);
72 (*(romvec->pv_abort))();
73 restore_current();
74 spin_unlock_irqrestore(&prom_lock, flags);
75 install_linux_ticker();
76 #ifdef CONFIG_SUN_AUXIO
77 TURN_ON_LED;
78 #endif
79 #ifdef CONFIG_SUN_CONSOLE
80 if(!serial_console && prom_palette)
81 prom_palette (0);
82 #endif
85 /* Drop into the prom, but completely terminate the program.
86 * No chance of continuing.
88 void
89 prom_halt(void)
91 unsigned long flags;
92 again:
93 spin_lock_irqsave(&prom_lock, flags);
94 (*(romvec->pv_halt))();
95 /* Never get here. */
96 restore_current();
97 spin_unlock_irqrestore(&prom_lock, flags);
98 goto again; /* PROM is out to get me -DaveM */
101 typedef void (*sfunc_t)(void);
103 /* Set prom sync handler to call function 'funcp'. */
104 void
105 prom_setsync(sfunc_t funcp)
107 if(!funcp) return;
108 *romvec->pv_synchook = funcp;
111 /* Get the idprom and stuff it into buffer 'idbuf'. Returns the
112 * format type. 'num_bytes' is the number of bytes that your idbuf
113 * has space for. Returns 0xff on error.
115 unsigned char
116 prom_get_idprom(char *idbuf, int num_bytes)
118 int len;
120 len = prom_getproplen(prom_root_node, "idprom");
121 if((len>num_bytes) || (len==-1)) return 0xff;
122 if(!prom_getproperty(prom_root_node, "idprom", idbuf, num_bytes))
123 return idbuf[0];
125 return 0xff;
128 /* Get the major prom version number. */
130 prom_version(void)
132 return romvec->pv_romvers;
135 /* Get the prom plugin-revision. */
137 prom_getrev(void)
139 return prom_rev;
142 /* Get the prom firmware print revision. */
144 prom_getprev(void)
146 return prom_prev;