1 /* Prom access routines for the sun3x */
3 #include <linux/types.h>
4 #include <linux/kernel.h>
6 #include <linux/console.h>
7 #include <linux/init.h>
9 #include <linux/string.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>
23 void (*sun3x_putchar)(int);
24 int (*sun3x_getchar)(void);
25 int (*sun3x_mayget)(void);
26 int (*sun3x_mayput)(int);
27 void (*sun3x_prom_reboot)(void);
28 e_vector sun3x_prom_abort;
29 struct linux_romvec *romvec;
31 /* prom vector table */
32 e_vector *sun3x_prom_vbr;
34 extern e_vector vectors[256]; /* arch/m68k/kernel/traps.c */
36 /* Handle returning to the prom */
41 /* Disable interrupts while we mess with things */
42 save_flags(flags); cli();
44 /* Restore prom vbr */
45 __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)sun3x_prom_vbr));
47 /* Restore prom NMI clock */
48 // sun3x_disable_intreg(5);
52 __asm__ volatile ("trap #14" : : );
54 /* Restore everything */
58 __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)vectors));
62 void sun3x_reboot(void)
64 /* This never returns, don't bother saving things */
67 /* Restore prom vbr */
68 __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)sun3x_prom_vbr));
70 /* Restore prom NMI clock */
75 (*romvec->pv_reboot)("vmlinux");
78 extern char m68k_debug_device[];
80 static void sun3x_prom_write(struct console *co, const char *s,
90 /* debug console - write-only */
92 static struct console sun3x_debug = {
94 sun3x_prom_write, /* write */
105 void sun3x_prom_init(void)
107 /* Read the vector table */
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;
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;
126 /* point trap #14 at abort.
127 * XXX this is futile since we restore the vbr first - oops
129 vectors[VEC_TRAP14] = sun3x_prom_abort;
131 /* If debug=prom was specified, start the debug console */
133 if (!strcmp(m68k_debug_device, "prom"))
134 register_console(&sun3x_debug);
139 /* some prom functions to export */
140 int prom_getintdefault(int node, char *property, int deflt)
145 int prom_getbool (int node, char *prop)
150 void prom_printf(char *fmt, ...)
155 void prom_halt (void)
160 /* Get the idprom and stuff it into buffer 'idbuf'. Returns the
161 * format type. 'num_bytes' is the number of bytes that your idbuf
162 * has space for. Returns 0xff on error.
165 prom_get_idprom(char *idbuf, int num_bytes)
169 /* make a copy of the idprom structure */
170 for(i = 0; i < num_bytes; i++)
171 idbuf[i] = ((char *)SUN3X_IDPROM)[i];