1
2
3#include <linux/types.h>
4#include <linux/kernel.h>
5#include <linux/tty.h>
6#include <linux/console.h>
7#include <linux/init.h>
8#include <linux/mm.h>
9#include <linux/string.h>
10
11#include <asm/page.h>
12#include <asm/pgtable.h>
13#include <asm/bootinfo.h>
14#include <asm/setup.h>
15#include <asm/traps.h>
16#include <asm/sun3xprom.h>
17#include <asm/idprom.h>
18#include <asm/segment.h>
19#include <asm/sun3ints.h>
20#include <asm/openprom.h>
21#include <asm/machines.h>
22
23void (*sun3x_putchar)(int);
24int (*sun3x_getchar)(void);
25int (*sun3x_mayget)(void);
26int (*sun3x_mayput)(int);
27void (*sun3x_prom_reboot)(void);
28e_vector sun3x_prom_abort;
29struct linux_romvec *romvec;
30
31
32e_vector *sun3x_prom_vbr;
33
34extern e_vector vectors[256];
35
36
37void sun3x_halt(void)
38{
39 unsigned long flags;
40
41
42 save_flags(flags); cli();
43
44
45 __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)sun3x_prom_vbr));
46
47
48
49 sun3_enable_irq(7);
50
51
52 __asm__ volatile ("trap #14" : : );
53
54
55 sun3_disable_irq(7);
56 sun3_enable_irq(5);
57
58 __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)vectors));
59 restore_flags(flags);
60}
61
62void sun3x_reboot(void)
63{
64
65 cli();
66
67
68 __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)sun3x_prom_vbr));
69
70
71 sun3_disable_irq(5);
72 sun3_enable_irq(7);
73
74
75 (*romvec->pv_reboot)("vmlinux");
76}
77
78extern char m68k_debug_device[];
79
80static void sun3x_prom_write(struct console *co, const char *s,
81 unsigned int count)
82{
83 while (count--) {
84 if (*s == '\n')
85 sun3x_putchar('\r');
86 sun3x_putchar(*s++);
87 }
88}
89
90
91
92static struct console sun3x_debug = {
93 "debug",
94 sun3x_prom_write,
95 NULL,
96 NULL,
97 NULL,
98 NULL,
99 CON_PRINTBUFFER,
100 -1,
101 0,
102 NULL
103};
104
105void sun3x_prom_init(void)
106{
107
108
109 sun3x_putchar = *(void (**)(int)) (SUN3X_P_PUTCHAR);
110 sun3x_getchar = *(int (**)(void)) (SUN3X_P_GETCHAR);
111 sun3x_mayget = *(int (**)(void)) (SUN3X_P_MAYGET);
112 sun3x_mayput = *(int (**)(int)) (SUN3X_P_MAYPUT);
113 sun3x_prom_reboot = *(void (**)(void)) (SUN3X_P_REBOOT);
114 sun3x_prom_abort = *(e_vector *) (SUN3X_P_ABORT);
115 romvec = (struct linux_romvec *)SUN3X_PROM_BASE;
116
117 idprom_init();
118
119 if(!((idprom->id_machtype & SM_ARCH_MASK) == SM_SUN3X)) {
120 printk("Warning: machine reports strange type %02x\n",
121 idprom->id_machtype);
122 printk("Pretending it's a 3/80, but very afraid...\n");
123 idprom->id_machtype = SM_SUN3X | SM_3_80;
124 }
125
126
127
128
129 vectors[VEC_TRAP14] = sun3x_prom_abort;
130
131
132
133 if (!strcmp(m68k_debug_device, "prom"))
134 register_console(&sun3x_debug);
135
136
137}
138
139
140int prom_getintdefault(int node, char *property, int deflt)
141{
142 return deflt;
143}
144
145int prom_getbool (int node, char *prop)
146{
147 return 1;
148}
149
150void prom_printf(char *fmt, ...)
151{
152
153}
154
155void prom_halt (void)
156{
157 sun3x_halt();
158}
159
160
161
162
163
164unsigned char
165prom_get_idprom(char *idbuf, int num_bytes)
166{
167 int i;
168
169
170 for(i = 0; i < num_bytes; i++)
171 idbuf[i] = ((char *)SUN3X_IDPROM)[i];
172
173 return idbuf[0];
174}
175