aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/sun3/prom
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/m68k/sun3/prom
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/m68k/sun3/prom')
-rw-r--r--arch/m68k/sun3/prom/Makefile7
-rw-r--r--arch/m68k/sun3/prom/console.c174
-rw-r--r--arch/m68k/sun3/prom/init.c89
-rw-r--r--arch/m68k/sun3/prom/misc.c94
-rw-r--r--arch/m68k/sun3/prom/printf.c61
5 files changed, 425 insertions, 0 deletions
diff --git a/arch/m68k/sun3/prom/Makefile b/arch/m68k/sun3/prom/Makefile
new file mode 100644
index 000000000000..6e48ae2a7175
--- /dev/null
+++ b/arch/m68k/sun3/prom/Makefile
@@ -0,0 +1,7 @@
1# $Id: Makefile,v 1.5 1995/11/25 00:59:48 davem Exp $
2# Makefile for the Sun Boot PROM interface library under
3# Linux.
4#
5
6obj-y := init.o console.o printf.o misc.o
7#bootstr.o init.o misc.o segment.o console.o printf.o
diff --git a/arch/m68k/sun3/prom/console.c b/arch/m68k/sun3/prom/console.c
new file mode 100644
index 000000000000..52c1427863de
--- /dev/null
+++ b/arch/m68k/sun3/prom/console.c
@@ -0,0 +1,174 @@
1/* $Id: console.c,v 1.10 1996/12/18 06:46:54 tridge Exp $
2 * console.c: Routines that deal with sending and receiving IO
3 * to/from the current console device using the PROM.
4 *
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */
7
8#include <linux/types.h>
9#include <linux/kernel.h>
10#include <linux/sched.h>
11#include <asm/openprom.h>
12#include <asm/oplib.h>
13#include <asm/system.h>
14#include <linux/string.h>
15
16/* Non blocking get character from console input device, returns -1
17 * if no input was taken. This can be used for polling.
18 */
19int
20prom_nbgetchar(void)
21{
22 int i = -1;
23 unsigned long flags;
24
25 local_irq_save(flags);
26 i = (*(romvec->pv_nbgetchar))();
27 local_irq_restore(flags);
28 return i; /* Ugh, we could spin forever on unsupported proms ;( */
29}
30
31/* Non blocking put character to console device, returns -1 if
32 * unsuccessful.
33 */
34int
35prom_nbputchar(char c)
36{
37 unsigned long flags;
38 int i = -1;
39
40 local_irq_save(flags);
41 i = (*(romvec->pv_nbputchar))(c);
42 local_irq_restore(flags);
43 return i; /* Ugh, we could spin forever on unsupported proms ;( */
44}
45
46/* Blocking version of get character routine above. */
47char
48prom_getchar(void)
49{
50 int character;
51 while((character = prom_nbgetchar()) == -1) ;
52 return (char) character;
53}
54
55/* Blocking version of put character routine above. */
56void
57prom_putchar(char c)
58{
59 while(prom_nbputchar(c) == -1) ;
60 return;
61}
62
63/* Query for input device type */
64#if 0
65enum prom_input_device
66prom_query_input_device()
67{
68 unsigned long flags;
69 int st_p;
70 char propb[64];
71 char *p;
72
73 switch(prom_vers) {
74 case PROM_V0:
75 case PROM_V2:
76 default:
77 switch(*romvec->pv_stdin) {
78 case PROMDEV_KBD: return PROMDEV_IKBD;
79 case PROMDEV_TTYA: return PROMDEV_ITTYA;
80 case PROMDEV_TTYB: return PROMDEV_ITTYB;
81 default:
82 return PROMDEV_I_UNK;
83 };
84 case PROM_V3:
85 case PROM_P1275:
86 local_irq_save(flags);
87 st_p = (*romvec->pv_v2devops.v2_inst2pkg)(*romvec->pv_v2bootargs.fd_stdin);
88 __asm__ __volatile__("ld [%0], %%g6\n\t" : :
89 "r" (&current_set[smp_processor_id()]) :
90 "memory");
91 local_irq_restore(flags);
92 if(prom_node_has_property(st_p, "keyboard"))
93 return PROMDEV_IKBD;
94 prom_getproperty(st_p, "device_type", propb, sizeof(propb));
95 if(strncmp(propb, "serial", sizeof("serial")))
96 return PROMDEV_I_UNK;
97 prom_getproperty(prom_root_node, "stdin-path", propb, sizeof(propb));
98 p = propb;
99 while(*p) p++; p -= 2;
100 if(p[0] == ':') {
101 if(p[1] == 'a')
102 return PROMDEV_ITTYA;
103 else if(p[1] == 'b')
104 return PROMDEV_ITTYB;
105 }
106 return PROMDEV_I_UNK;
107 case PROM_AP1000:
108 return PROMDEV_I_UNK;
109 };
110}
111#endif
112
113/* Query for output device type */
114
115#if 0
116enum prom_output_device
117prom_query_output_device()
118{
119 unsigned long flags;
120 int st_p;
121 char propb[64];
122 char *p;
123 int propl;
124
125 switch(prom_vers) {
126 case PROM_V0:
127 switch(*romvec->pv_stdin) {
128 case PROMDEV_SCREEN: return PROMDEV_OSCREEN;
129 case PROMDEV_TTYA: return PROMDEV_OTTYA;
130 case PROMDEV_TTYB: return PROMDEV_OTTYB;
131 };
132 break;
133 case PROM_V2:
134 case PROM_V3:
135 case PROM_P1275:
136 local_irq_save(flags);
137 st_p = (*romvec->pv_v2devops.v2_inst2pkg)(*romvec->pv_v2bootargs.fd_stdout);
138 __asm__ __volatile__("ld [%0], %%g6\n\t" : :
139 "r" (&current_set[smp_processor_id()]) :
140 "memory");
141 local_irq_restore(flags);
142 propl = prom_getproperty(st_p, "device_type", propb, sizeof(propb));
143 if (propl >= 0 && propl == sizeof("display") &&
144 strncmp("display", propb, sizeof("display")) == 0)
145 {
146 return PROMDEV_OSCREEN;
147 }
148 if(prom_vers == PROM_V3) {
149 if(strncmp("serial", propb, sizeof("serial")))
150 return PROMDEV_O_UNK;
151 prom_getproperty(prom_root_node, "stdout-path", propb, sizeof(propb));
152 p = propb;
153 while(*p) p++; p -= 2;
154 if(p[0]==':') {
155 if(p[1] == 'a')
156 return PROMDEV_OTTYA;
157 else if(p[1] == 'b')
158 return PROMDEV_OTTYB;
159 }
160 return PROMDEV_O_UNK;
161 } else {
162 /* This works on SS-2 (an early OpenFirmware) still. */
163 switch(*romvec->pv_stdin) {
164 case PROMDEV_TTYA: return PROMDEV_OTTYA;
165 case PROMDEV_TTYB: return PROMDEV_OTTYB;
166 };
167 }
168 break;
169 case PROM_AP1000:
170 return PROMDEV_I_UNK;
171 };
172 return PROMDEV_O_UNK;
173}
174#endif
diff --git a/arch/m68k/sun3/prom/init.c b/arch/m68k/sun3/prom/init.c
new file mode 100644
index 000000000000..2e6ae56aec12
--- /dev/null
+++ b/arch/m68k/sun3/prom/init.c
@@ -0,0 +1,89 @@
1/* $Id: init.c,v 1.9 1996/12/18 06:46:55 tridge Exp $
2 * init.c: Initialize internal variables used by the PROM
3 * library functions.
4 *
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */
7
8#include <linux/config.h>
9#include <linux/kernel.h>
10#include <linux/init.h>
11
12#include <asm/openprom.h>
13#include <asm/oplib.h>
14
15struct linux_romvec *romvec;
16enum prom_major_version prom_vers;
17unsigned int prom_rev, prom_prev;
18
19/* The root node of the prom device tree. */
20int prom_root_node;
21
22/* Pointer to the device tree operations structure. */
23struct linux_nodeops *prom_nodeops;
24
25/* You must call prom_init() before you attempt to use any of the
26 * routines in the prom library. It returns 0 on success, 1 on
27 * failure. It gets passed the pointer to the PROM vector.
28 */
29
30extern void prom_meminit(void);
31extern void prom_ranges_init(void);
32
33void __init prom_init(struct linux_romvec *rp)
34{
35#ifdef CONFIG_AP1000
36 extern struct linux_romvec *ap_prom_init(void);
37 rp = ap_prom_init();
38#endif
39
40 romvec = rp;
41#ifndef CONFIG_SUN3
42 switch(romvec->pv_romvers) {
43 case 0:
44 prom_vers = PROM_V0;
45 break;
46 case 2:
47 prom_vers = PROM_V2;
48 break;
49 case 3:
50 prom_vers = PROM_V3;
51 break;
52 case 4:
53 prom_vers = PROM_P1275;
54 prom_printf("PROMLIB: Sun IEEE Prom not supported yet\n");
55 prom_halt();
56 break;
57 case 42: /* why not :-) */
58 prom_vers = PROM_AP1000;
59 break;
60
61 default:
62 prom_printf("PROMLIB: Bad PROM version %d\n",
63 romvec->pv_romvers);
64 prom_halt();
65 break;
66 };
67
68 prom_rev = romvec->pv_plugin_revision;
69 prom_prev = romvec->pv_printrev;
70 prom_nodeops = romvec->pv_nodeops;
71
72 prom_root_node = prom_getsibling(0);
73 if((prom_root_node == 0) || (prom_root_node == -1))
74 prom_halt();
75
76 if((((unsigned long) prom_nodeops) == 0) ||
77 (((unsigned long) prom_nodeops) == -1))
78 prom_halt();
79
80 prom_meminit();
81
82 prom_ranges_init();
83#endif
84// printk("PROMLIB: Sun Boot Prom Version %d Revision %d\n",
85// romvec->pv_romvers, prom_rev);
86
87 /* Initialization successful. */
88 return;
89}
diff --git a/arch/m68k/sun3/prom/misc.c b/arch/m68k/sun3/prom/misc.c
new file mode 100644
index 000000000000..b88716f2c68c
--- /dev/null
+++ b/arch/m68k/sun3/prom/misc.c
@@ -0,0 +1,94 @@
1/* $Id: misc.c,v 1.15 1997/05/14 20:45:00 davem Exp $
2 * misc.c: Miscellaneous prom functions that don't belong
3 * anywhere else.
4 *
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */
7
8#include <linux/types.h>
9#include <linux/kernel.h>
10#include <linux/sched.h>
11#include <asm/sun3-head.h>
12#include <asm/idprom.h>
13#include <asm/openprom.h>
14#include <asm/oplib.h>
15#include <asm/movs.h>
16
17/* Reset and reboot the machine with the command 'bcommand'. */
18void
19prom_reboot(char *bcommand)
20{
21 unsigned long flags;
22 local_irq_save(flags);
23 (*(romvec->pv_reboot))(bcommand);
24 local_irq_restore(flags);
25}
26
27/* Drop into the prom, with the chance to continue with the 'go'
28 * prom command.
29 */
30void
31prom_cmdline(void)
32{
33}
34
35/* Drop into the prom, but completely terminate the program.
36 * No chance of continuing.
37 */
38void
39prom_halt(void)
40{
41 unsigned long flags;
42again:
43 local_irq_save(flags);
44 (*(romvec->pv_halt))();
45 local_irq_restore(flags);
46 goto again; /* PROM is out to get me -DaveM */
47}
48
49typedef void (*sfunc_t)(void);
50
51/* Get the idprom and stuff it into buffer 'idbuf'. Returns the
52 * format type. 'num_bytes' is the number of bytes that your idbuf
53 * has space for. Returns 0xff on error.
54 */
55unsigned char
56prom_get_idprom(char *idbuf, int num_bytes)
57{
58 int i, oldsfc;
59 GET_SFC(oldsfc);
60 SET_SFC(FC_CONTROL);
61 for(i=0;i<num_bytes; i++)
62 {
63 /* There is a problem with the GET_CONTROL_BYTE
64 macro; defining the extra variable
65 gets around it.
66 */
67 int c;
68 GET_CONTROL_BYTE(SUN3_IDPROM_BASE + i, c);
69 idbuf[i] = c;
70 }
71 SET_SFC(oldsfc);
72 return idbuf[0];
73}
74
75/* Get the major prom version number. */
76int
77prom_version(void)
78{
79 return romvec->pv_romvers;
80}
81
82/* Get the prom plugin-revision. */
83int
84prom_getrev(void)
85{
86 return prom_rev;
87}
88
89/* Get the prom firmware print revision. */
90int
91prom_getprev(void)
92{
93 return prom_prev;
94}
diff --git a/arch/m68k/sun3/prom/printf.c b/arch/m68k/sun3/prom/printf.c
new file mode 100644
index 000000000000..e6ee1006344e
--- /dev/null
+++ b/arch/m68k/sun3/prom/printf.c
@@ -0,0 +1,61 @@
1/* $Id: printf.c,v 1.5 1996/04/04 16:31:07 tridge Exp $
2 * printf.c: Internal prom library printf facility.
3 *
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7/* This routine is internal to the prom library, no one else should know
8 * about or use it! It's simple and smelly anyway....
9 */
10
11#include <linux/config.h>
12#include <linux/kernel.h>
13
14#include <asm/openprom.h>
15#include <asm/oplib.h>
16
17#ifdef CONFIG_KGDB
18extern int kgdb_initialized;
19#endif
20
21static char ppbuf[1024];
22
23void
24prom_printf(char *fmt, ...)
25{
26 va_list args;
27 char ch, *bptr;
28 int i;
29
30 va_start(args, fmt);
31
32#ifdef CONFIG_KGDB
33 ppbuf[0] = 'O';
34 i = vsprintf(ppbuf + 1, fmt, args) + 1;
35#else
36 i = vsprintf(ppbuf, fmt, args);
37#endif
38
39 bptr = ppbuf;
40
41#ifdef CONFIG_AP1000
42 ap_write(1,bptr,strlen(bptr));
43#else
44
45#ifdef CONFIG_KGDB
46 if (kgdb_initialized) {
47 printk("kgdb_initialized = %d\n", kgdb_initialized);
48 putpacket(bptr, 1);
49 } else
50#else
51 while((ch = *(bptr++)) != 0) {
52 if(ch == '\n')
53 prom_putchar('\r');
54
55 prom_putchar(ch);
56 }
57#endif
58#endif
59 va_end(args);
60 return;
61}