diff options
Diffstat (limited to 'arch/ppc/xmon/start.c')
-rw-r--r-- | arch/ppc/xmon/start.c | 184 |
1 files changed, 4 insertions, 180 deletions
diff --git a/arch/ppc/xmon/start.c b/arch/ppc/xmon/start.c index 4344cbe9b5c5..ff86b2d814cb 100644 --- a/arch/ppc/xmon/start.c +++ b/arch/ppc/xmon/start.c | |||
@@ -6,16 +6,11 @@ | |||
6 | #include <asm/machdep.h> | 6 | #include <asm/machdep.h> |
7 | #include <asm/io.h> | 7 | #include <asm/io.h> |
8 | #include <asm/page.h> | 8 | #include <asm/page.h> |
9 | #include <linux/adb.h> | ||
10 | #include <linux/pmu.h> | ||
11 | #include <linux/cuda.h> | ||
12 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
13 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
14 | #include <linux/sysrq.h> | 11 | #include <linux/sysrq.h> |
15 | #include <linux/bitops.h> | 12 | #include <linux/bitops.h> |
16 | #include <asm/xmon.h> | 13 | #include <asm/xmon.h> |
17 | #include <asm/prom.h> | ||
18 | #include <asm/bootx.h> | ||
19 | #include <asm/machdep.h> | 14 | #include <asm/machdep.h> |
20 | #include <asm/errno.h> | 15 | #include <asm/errno.h> |
21 | #include <asm/processor.h> | 16 | #include <asm/processor.h> |
@@ -26,9 +21,7 @@ static volatile unsigned char *sccc, *sccd; | |||
26 | unsigned int TXRDY, RXRDY, DLAB; | 21 | unsigned int TXRDY, RXRDY, DLAB; |
27 | static int xmon_expect(const char *str, unsigned int timeout); | 22 | static int xmon_expect(const char *str, unsigned int timeout); |
28 | 23 | ||
29 | static int use_screen; | ||
30 | static int via_modem; | 24 | static int via_modem; |
31 | static int xmon_use_sccb; | ||
32 | 25 | ||
33 | #define TB_SPEED 25000000 | 26 | #define TB_SPEED 25000000 |
34 | 27 | ||
@@ -46,47 +39,6 @@ void buf_access(void) | |||
46 | sccd[3] &= ~DLAB; /* reset DLAB */ | 39 | sccd[3] &= ~DLAB; /* reset DLAB */ |
47 | } | 40 | } |
48 | 41 | ||
49 | extern int adb_init(void); | ||
50 | |||
51 | #ifdef CONFIG_PPC_CHRP | ||
52 | /* | ||
53 | * This looks in the "ranges" property for the primary PCI host bridge | ||
54 | * to find the physical address of the start of PCI/ISA I/O space. | ||
55 | * It is basically a cut-down version of pci_process_bridge_OF_ranges. | ||
56 | */ | ||
57 | static unsigned long chrp_find_phys_io_base(void) | ||
58 | { | ||
59 | struct device_node *node; | ||
60 | unsigned int *ranges; | ||
61 | unsigned long base = CHRP_ISA_IO_BASE; | ||
62 | int rlen = 0; | ||
63 | int np; | ||
64 | |||
65 | node = find_devices("isa"); | ||
66 | if (node != NULL) { | ||
67 | node = node->parent; | ||
68 | if (node == NULL || node->type == NULL | ||
69 | || strcmp(node->type, "pci") != 0) | ||
70 | node = NULL; | ||
71 | } | ||
72 | if (node == NULL) | ||
73 | node = find_devices("pci"); | ||
74 | if (node == NULL) | ||
75 | return base; | ||
76 | |||
77 | ranges = (unsigned int *) get_property(node, "ranges", &rlen); | ||
78 | np = prom_n_addr_cells(node) + 5; | ||
79 | while ((rlen -= np * sizeof(unsigned int)) >= 0) { | ||
80 | if ((ranges[0] >> 24) == 1 && ranges[2] == 0) { | ||
81 | /* I/O space starting at 0, grab the phys base */ | ||
82 | base = ranges[np - 3]; | ||
83 | break; | ||
84 | } | ||
85 | ranges += np; | ||
86 | } | ||
87 | return base; | ||
88 | } | ||
89 | #endif /* CONFIG_PPC_CHRP */ | ||
90 | 42 | ||
91 | #ifdef CONFIG_MAGIC_SYSRQ | 43 | #ifdef CONFIG_MAGIC_SYSRQ |
92 | static void sysrq_handle_xmon(int key, struct pt_regs *regs, | 44 | static void sysrq_handle_xmon(int key, struct pt_regs *regs, |
@@ -109,22 +61,6 @@ xmon_map_scc(void) | |||
109 | #ifdef CONFIG_PPC_MULTIPLATFORM | 61 | #ifdef CONFIG_PPC_MULTIPLATFORM |
110 | volatile unsigned char *base; | 62 | volatile unsigned char *base; |
111 | 63 | ||
112 | #ifdef CONFIG_PPC_CHRP | ||
113 | base = (volatile unsigned char *) isa_io_base; | ||
114 | if (_machine == _MACH_chrp) | ||
115 | base = (volatile unsigned char *) | ||
116 | ioremap(chrp_find_phys_io_base(), 0x1000); | ||
117 | |||
118 | sccc = base + 0x3fd; | ||
119 | sccd = base + 0x3f8; | ||
120 | if (xmon_use_sccb) { | ||
121 | sccc -= 0x100; | ||
122 | sccd -= 0x100; | ||
123 | } | ||
124 | TXRDY = 0x20; | ||
125 | RXRDY = 1; | ||
126 | DLAB = 0x80; | ||
127 | #endif /* CONFIG_PPC_CHRP */ | ||
128 | #elif defined(CONFIG_GEMINI) | 64 | #elif defined(CONFIG_GEMINI) |
129 | /* should already be mapped by the kernel boot */ | 65 | /* should already be mapped by the kernel boot */ |
130 | sccc = (volatile unsigned char *) 0xffeffb0d; | 66 | sccc = (volatile unsigned char *) 0xffeffb0d; |
@@ -143,22 +79,9 @@ xmon_map_scc(void) | |||
143 | register_sysrq_key('x', &sysrq_xmon_op); | 79 | register_sysrq_key('x', &sysrq_xmon_op); |
144 | } | 80 | } |
145 | 81 | ||
146 | static int scc_initialized = 0; | 82 | static int scc_initialized; |
147 | 83 | ||
148 | void xmon_init_scc(void); | 84 | void xmon_init_scc(void); |
149 | extern void cuda_poll(void); | ||
150 | |||
151 | static inline void do_poll_adb(void) | ||
152 | { | ||
153 | #ifdef CONFIG_ADB_PMU | ||
154 | if (sys_ctrler == SYS_CTRLER_PMU) | ||
155 | pmu_poll_adb(); | ||
156 | #endif /* CONFIG_ADB_PMU */ | ||
157 | #ifdef CONFIG_ADB_CUDA | ||
158 | if (sys_ctrler == SYS_CTRLER_CUDA) | ||
159 | cuda_poll(); | ||
160 | #endif /* CONFIG_ADB_CUDA */ | ||
161 | } | ||
162 | 85 | ||
163 | int | 86 | int |
164 | xmon_write(void *handle, void *ptr, int nb) | 87 | xmon_write(void *handle, void *ptr, int nb) |
@@ -176,20 +99,12 @@ xmon_write(void *handle, void *ptr, int nb) | |||
176 | break; | 99 | break; |
177 | #endif | 100 | #endif |
178 | 101 | ||
179 | #ifdef CONFIG_BOOTX_TEXT | ||
180 | if (use_screen) { | ||
181 | /* write it on the screen */ | ||
182 | for (i = 0; i < nb; ++i) | ||
183 | btext_drawchar(*p++); | ||
184 | goto out; | ||
185 | } | ||
186 | #endif | ||
187 | if (!scc_initialized) | 102 | if (!scc_initialized) |
188 | xmon_init_scc(); | 103 | xmon_init_scc(); |
189 | ct = 0; | 104 | ct = 0; |
190 | for (i = 0; i < nb; ++i) { | 105 | for (i = 0; i < nb; ++i) { |
191 | while ((*sccc & TXRDY) == 0) | 106 | while ((*sccc & TXRDY) == 0) |
192 | do_poll_adb(); | 107 | ; |
193 | c = p[i]; | 108 | c = p[i]; |
194 | if (c == '\n' && !ct) { | 109 | if (c == '\n' && !ct) { |
195 | c = '\r'; | 110 | c = '\r'; |
@@ -203,7 +118,6 @@ xmon_write(void *handle, void *ptr, int nb) | |||
203 | eieio(); | 118 | eieio(); |
204 | } | 119 | } |
205 | 120 | ||
206 | out: | ||
207 | #ifdef CONFIG_SMP | 121 | #ifdef CONFIG_SMP |
208 | if (!locked) | 122 | if (!locked) |
209 | clear_bit(0, &xmon_write_lock); | 123 | clear_bit(0, &xmon_write_lock); |
@@ -212,65 +126,7 @@ xmon_write(void *handle, void *ptr, int nb) | |||
212 | } | 126 | } |
213 | 127 | ||
214 | int xmon_wants_key; | 128 | int xmon_wants_key; |
215 | int xmon_adb_keycode; | ||
216 | |||
217 | #ifdef CONFIG_BOOTX_TEXT | ||
218 | static int xmon_adb_shiftstate; | ||
219 | |||
220 | static unsigned char xmon_keytab[128] = | ||
221 | "asdfhgzxcv\000bqwer" /* 0x00 - 0x0f */ | ||
222 | "yt123465=97-80]o" /* 0x10 - 0x1f */ | ||
223 | "u[ip\rlj'k;\\,/nm." /* 0x20 - 0x2f */ | ||
224 | "\t `\177\0\033\0\0\0\0\0\0\0\0\0\0" /* 0x30 - 0x3f */ | ||
225 | "\0.\0*\0+\0\0\0\0\0/\r\0-\0" /* 0x40 - 0x4f */ | ||
226 | "\0\0000123456789\0\0\0"; /* 0x50 - 0x5f */ | ||
227 | |||
228 | static unsigned char xmon_shift_keytab[128] = | ||
229 | "ASDFHGZXCV\000BQWER" /* 0x00 - 0x0f */ | ||
230 | "YT!@#$^%+(&_*)}O" /* 0x10 - 0x1f */ | ||
231 | "U{IP\rLJ\"K:|<?NM>" /* 0x20 - 0x2f */ | ||
232 | "\t ~\177\0\033\0\0\0\0\0\0\0\0\0\0" /* 0x30 - 0x3f */ | ||
233 | "\0.\0*\0+\0\0\0\0\0/\r\0-\0" /* 0x40 - 0x4f */ | ||
234 | "\0\0000123456789\0\0\0"; /* 0x50 - 0x5f */ | ||
235 | |||
236 | static int | ||
237 | xmon_get_adb_key(void) | ||
238 | { | ||
239 | int k, t, on; | ||
240 | 129 | ||
241 | xmon_wants_key = 1; | ||
242 | for (;;) { | ||
243 | xmon_adb_keycode = -1; | ||
244 | t = 0; | ||
245 | on = 0; | ||
246 | do { | ||
247 | if (--t < 0) { | ||
248 | on = 1 - on; | ||
249 | btext_drawchar(on? 0xdb: 0x20); | ||
250 | btext_drawchar('\b'); | ||
251 | t = 200000; | ||
252 | } | ||
253 | do_poll_adb(); | ||
254 | } while (xmon_adb_keycode == -1); | ||
255 | k = xmon_adb_keycode; | ||
256 | if (on) | ||
257 | btext_drawstring(" \b"); | ||
258 | |||
259 | /* test for shift keys */ | ||
260 | if ((k & 0x7f) == 0x38 || (k & 0x7f) == 0x7b) { | ||
261 | xmon_adb_shiftstate = (k & 0x80) == 0; | ||
262 | continue; | ||
263 | } | ||
264 | if (k >= 0x80) | ||
265 | continue; /* ignore up transitions */ | ||
266 | k = (xmon_adb_shiftstate? xmon_shift_keytab: xmon_keytab)[k]; | ||
267 | if (k != 0) | ||
268 | break; | ||
269 | } | ||
270 | xmon_wants_key = 0; | ||
271 | return k; | ||
272 | } | ||
273 | #endif /* CONFIG_BOOTX_TEXT */ | ||
274 | 130 | ||
275 | int | 131 | int |
276 | xmon_read(void *handle, void *ptr, int nb) | 132 | xmon_read(void *handle, void *ptr, int nb) |
@@ -278,18 +134,11 @@ xmon_read(void *handle, void *ptr, int nb) | |||
278 | char *p = ptr; | 134 | char *p = ptr; |
279 | int i; | 135 | int i; |
280 | 136 | ||
281 | #ifdef CONFIG_BOOTX_TEXT | ||
282 | if (use_screen) { | ||
283 | for (i = 0; i < nb; ++i) | ||
284 | *p++ = xmon_get_adb_key(); | ||
285 | return i; | ||
286 | } | ||
287 | #endif | ||
288 | if (!scc_initialized) | 137 | if (!scc_initialized) |
289 | xmon_init_scc(); | 138 | xmon_init_scc(); |
290 | for (i = 0; i < nb; ++i) { | 139 | for (i = 0; i < nb; ++i) { |
291 | while ((*sccc & RXRDY) == 0) | 140 | while ((*sccc & RXRDY) == 0) |
292 | do_poll_adb(); | 141 | ; |
293 | buf_access(); | 142 | buf_access(); |
294 | *p++ = *sccd; | 143 | *p++ = *sccd; |
295 | } | 144 | } |
@@ -300,7 +149,7 @@ int | |||
300 | xmon_read_poll(void) | 149 | xmon_read_poll(void) |
301 | { | 150 | { |
302 | if ((*sccc & RXRDY) == 0) { | 151 | if ((*sccc & RXRDY) == 0) { |
303 | do_poll_adb(); | 152 | ; |
304 | return -1; | 153 | return -1; |
305 | } | 154 | } |
306 | buf_access(); | 155 | buf_access(); |
@@ -310,15 +159,6 @@ xmon_read_poll(void) | |||
310 | void | 159 | void |
311 | xmon_init_scc(void) | 160 | xmon_init_scc(void) |
312 | { | 161 | { |
313 | if ( _machine == _MACH_chrp ) | ||
314 | { | ||
315 | sccd[3] = 0x83; eieio(); /* LCR = 8N1 + DLAB */ | ||
316 | sccd[0] = 12; eieio(); /* DLL = 9600 baud */ | ||
317 | sccd[1] = 0; eieio(); | ||
318 | sccd[2] = 0; eieio(); /* FCR = 0 */ | ||
319 | sccd[3] = 3; eieio(); /* LCR = 8N1 */ | ||
320 | sccd[1] = 0; eieio(); /* IER = 0 */ | ||
321 | } | ||
322 | scc_initialized = 1; | 162 | scc_initialized = 1; |
323 | if (via_modem) { | 163 | if (via_modem) { |
324 | for (;;) { | 164 | for (;;) { |
@@ -334,22 +174,6 @@ xmon_init_scc(void) | |||
334 | } | 174 | } |
335 | } | 175 | } |
336 | 176 | ||
337 | #if 0 | ||
338 | extern int (*prom_entry)(void *); | ||
339 | |||
340 | int | ||
341 | xmon_exit(void) | ||
342 | { | ||
343 | struct prom_args { | ||
344 | char *service; | ||
345 | } args; | ||
346 | |||
347 | for (;;) { | ||
348 | args.service = "exit"; | ||
349 | (*prom_entry)(&args); | ||
350 | } | ||
351 | } | ||
352 | #endif | ||
353 | 177 | ||
354 | void *xmon_stdin; | 178 | void *xmon_stdin; |
355 | void *xmon_stdout; | 179 | void *xmon_stdout; |