1
2
3
4
5
6
7
8
9#include <linux/types.h>
10#include <linux/kernel.h>
11#include <linux/sched.h>
12#include <linux/module.h>
13
14#include <asm/openprom.h>
15#include <asm/oplib.h>
16#include <asm/auxio.h>
17
18extern void restore_current(void);
19
20DEFINE_SPINLOCK(prom_lock);
21
22
23void
24prom_reboot(char *bcommand)
25{
26 unsigned long flags;
27 spin_lock_irqsave(&prom_lock, flags);
28 (*(romvec->pv_reboot))(bcommand);
29
30 restore_current();
31 spin_unlock_irqrestore(&prom_lock, flags);
32}
33
34
35void
36prom_feval(char *fstring)
37{
38 unsigned long flags;
39 if(!fstring || fstring[0] == 0)
40 return;
41 spin_lock_irqsave(&prom_lock, flags);
42 if(prom_vers == PROM_V0)
43 (*(romvec->pv_fortheval.v0_eval))(strlen(fstring), fstring);
44 else
45 (*(romvec->pv_fortheval.v2_eval))(fstring);
46 restore_current();
47 spin_unlock_irqrestore(&prom_lock, flags);
48}
49EXPORT_SYMBOL(prom_feval);
50
51
52
53
54void
55prom_cmdline(void)
56{
57 unsigned long flags;
58
59 spin_lock_irqsave(&prom_lock, flags);
60 (*(romvec->pv_abort))();
61 restore_current();
62 spin_unlock_irqrestore(&prom_lock, flags);
63 set_auxio(AUXIO_LED, 0);
64}
65
66
67
68
69void __noreturn
70prom_halt(void)
71{
72 unsigned long flags;
73again:
74 spin_lock_irqsave(&prom_lock, flags);
75 (*(romvec->pv_halt))();
76
77 restore_current();
78 spin_unlock_irqrestore(&prom_lock, flags);
79 goto again;
80}
81
82typedef void (*sfunc_t)(void);
83
84
85void
86prom_setsync(sfunc_t funcp)
87{
88 if(!funcp) return;
89 *romvec->pv_synchook = funcp;
90}
91
92
93
94
95
96unsigned char
97prom_get_idprom(char *idbuf, int num_bytes)
98{
99 int len;
100
101 len = prom_getproplen(prom_root_node, "idprom");
102 if((len>num_bytes) || (len==-1)) return 0xff;
103 if(!prom_getproperty(prom_root_node, "idprom", idbuf, num_bytes))
104 return idbuf[0];
105
106 return 0xff;
107}
108
109
110int
111prom_version(void)
112{
113 return romvec->pv_romvers;
114}
115
116
117int
118prom_getrev(void)
119{
120 return prom_rev;
121}
122
123
124int
125prom_getprev(void)
126{
127 return prom_prev;
128}
129