diff options
Diffstat (limited to 'arch/m68k/mac/debug.c')
-rw-r--r-- | arch/m68k/mac/debug.c | 331 |
1 files changed, 161 insertions, 170 deletions
diff --git a/arch/m68k/mac/debug.c b/arch/m68k/mac/debug.c index 4eeb09dc0e8f..7a5bed5bdc57 100644 --- a/arch/m68k/mac/debug.c +++ b/arch/m68k/mac/debug.c | |||
@@ -27,10 +27,6 @@ | |||
27 | #include <asm/machw.h> | 27 | #include <asm/machw.h> |
28 | #include <asm/macints.h> | 28 | #include <asm/macints.h> |
29 | 29 | ||
30 | extern char m68k_debug_device[]; | ||
31 | |||
32 | extern struct compat_bootinfo compat_boot_info; | ||
33 | |||
34 | extern unsigned long mac_videobase; | 30 | extern unsigned long mac_videobase; |
35 | extern unsigned long mac_videodepth; | 31 | extern unsigned long mac_videodepth; |
36 | extern unsigned long mac_rowbytes; | 32 | extern unsigned long mac_rowbytes; |
@@ -52,7 +48,7 @@ extern void mac_serial_print(const char *); | |||
52 | */ | 48 | */ |
53 | 49 | ||
54 | #ifdef DEBUG_SCREEN | 50 | #ifdef DEBUG_SCREEN |
55 | static int peng=0, line=0; | 51 | static int peng, line; |
56 | #endif | 52 | #endif |
57 | 53 | ||
58 | void mac_debugging_short(int pos, short num) | 54 | void mac_debugging_short(int pos, short num) |
@@ -74,15 +70,14 @@ void mac_debugging_short(int pos, short num) | |||
74 | } | 70 | } |
75 | 71 | ||
76 | /* calculate current offset */ | 72 | /* calculate current offset */ |
77 | pengoffset=(unsigned char *)(mac_videobase+(150+line*2)*mac_rowbytes) | 73 | pengoffset = (unsigned char *)mac_videobase + |
78 | +80*peng; | 74 | (150+line*2) * mac_rowbytes) + 80 * peng; |
79 | 75 | ||
80 | pptr=pengoffset; | 76 | pptr = pengoffset; |
81 | 77 | ||
82 | for(i=0;i<8*sizeof(short);i++) /* # of bits */ | 78 | for (i = 0; i < 8 * sizeof(short); i++) { /* # of bits */ |
83 | { | ||
84 | /* value mask for bit i, reverse order */ | 79 | /* value mask for bit i, reverse order */ |
85 | *pptr++ = (num & ( 1 << (8*sizeof(short)-i-1) ) ? 0xFF : 0x00); | 80 | *pptr++ = (num & (1 << (8*sizeof(short)-i-1)) ? 0xFF : 0x00); |
86 | } | 81 | } |
87 | 82 | ||
88 | peng++; | 83 | peng++; |
@@ -115,11 +110,10 @@ void mac_debugging_long(int pos, long addr) | |||
115 | pengoffset=(unsigned char *)(mac_videobase+(150+line*2)*mac_rowbytes) | 110 | pengoffset=(unsigned char *)(mac_videobase+(150+line*2)*mac_rowbytes) |
116 | +80*peng; | 111 | +80*peng; |
117 | 112 | ||
118 | pptr=pengoffset; | 113 | pptr = pengoffset; |
119 | 114 | ||
120 | for(i=0;i<8*sizeof(long);i++) /* # of bits */ | 115 | for (i = 0; i < 8 * sizeof(long); i++) { /* # of bits */ |
121 | { | 116 | *pptr++ = (addr & (1 << (8*sizeof(long)-i-1)) ? 0xFF : 0x00); |
122 | *pptr++ = (addr & ( 1 << (8*sizeof(long)-i-1) ) ? 0xFF : 0x00); | ||
123 | } | 117 | } |
124 | 118 | ||
125 | peng++; | 119 | peng++; |
@@ -136,16 +130,15 @@ void mac_debugging_long(int pos, long addr) | |||
136 | * TODO: serial debug code | 130 | * TODO: serial debug code |
137 | */ | 131 | */ |
138 | 132 | ||
139 | struct mac_SCC | 133 | struct mac_SCC { |
140 | { | 134 | u_char cha_b_ctrl; |
141 | u_char cha_b_ctrl; | 135 | u_char char_dummy1; |
142 | u_char char_dummy1; | 136 | u_char cha_a_ctrl; |
143 | u_char cha_a_ctrl; | 137 | u_char char_dummy2; |
144 | u_char char_dummy2; | 138 | u_char cha_b_data; |
145 | u_char cha_b_data; | 139 | u_char char_dummy3; |
146 | u_char char_dummy3; | 140 | u_char cha_a_data; |
147 | u_char cha_a_data; | 141 | }; |
148 | }; | ||
149 | 142 | ||
150 | # define scc (*((volatile struct mac_SCC*)mac_bi_data.sccbase)) | 143 | # define scc (*((volatile struct mac_SCC*)mac_bi_data.sccbase)) |
151 | 144 | ||
@@ -158,9 +151,9 @@ int mac_SCC_reset_done; | |||
158 | static int scc_port = -1; | 151 | static int scc_port = -1; |
159 | 152 | ||
160 | static struct console mac_console_driver = { | 153 | static struct console mac_console_driver = { |
161 | .name = "debug", | 154 | .name = "debug", |
162 | .flags = CON_PRINTBUFFER, | 155 | .flags = CON_PRINTBUFFER, |
163 | .index = -1, | 156 | .index = -1, |
164 | }; | 157 | }; |
165 | 158 | ||
166 | /* | 159 | /* |
@@ -178,8 +171,8 @@ static struct console mac_console_driver = { | |||
178 | * this driver if Mac. | 171 | * this driver if Mac. |
179 | */ | 172 | */ |
180 | 173 | ||
181 | void mac_debug_console_write (struct console *co, const char *str, | 174 | void mac_debug_console_write(struct console *co, const char *str, |
182 | unsigned int count) | 175 | unsigned int count) |
183 | { | 176 | { |
184 | mac_serial_print(str); | 177 | mac_serial_print(str); |
185 | } | 178 | } |
@@ -190,48 +183,50 @@ void mac_debug_console_write (struct console *co, const char *str, | |||
190 | 183 | ||
191 | #define uSEC 1 | 184 | #define uSEC 1 |
192 | 185 | ||
193 | static inline void mac_sccb_out (char c) | 186 | static inline void mac_sccb_out(char c) |
194 | { | 187 | { |
195 | int i; | 188 | int i; |
196 | do { | 189 | |
197 | for( i = uSEC; i > 0; --i ) | 190 | do { |
191 | for (i = uSEC; i > 0; --i) | ||
192 | barrier(); | ||
193 | } while (!(scc.cha_b_ctrl & 0x04)); /* wait for tx buf empty */ | ||
194 | for (i = uSEC; i > 0; --i) | ||
198 | barrier(); | 195 | barrier(); |
199 | } while (!(scc.cha_b_ctrl & 0x04)); /* wait for tx buf empty */ | 196 | scc.cha_b_data = c; |
200 | for( i = uSEC; i > 0; --i ) | ||
201 | barrier(); | ||
202 | scc.cha_b_data = c; | ||
203 | } | 197 | } |
204 | 198 | ||
205 | static inline void mac_scca_out (char c) | 199 | static inline void mac_scca_out(char c) |
206 | { | 200 | { |
207 | int i; | 201 | int i; |
208 | do { | 202 | |
209 | for( i = uSEC; i > 0; --i ) | 203 | do { |
204 | for (i = uSEC; i > 0; --i) | ||
205 | barrier(); | ||
206 | } while (!(scc.cha_a_ctrl & 0x04)); /* wait for tx buf empty */ | ||
207 | for (i = uSEC; i > 0; --i) | ||
210 | barrier(); | 208 | barrier(); |
211 | } while (!(scc.cha_a_ctrl & 0x04)); /* wait for tx buf empty */ | 209 | scc.cha_a_data = c; |
212 | for( i = uSEC; i > 0; --i ) | ||
213 | barrier(); | ||
214 | scc.cha_a_data = c; | ||
215 | } | 210 | } |
216 | 211 | ||
217 | void mac_sccb_console_write (struct console *co, const char *str, | 212 | void mac_sccb_console_write(struct console *co, const char *str, |
218 | unsigned int count) | 213 | unsigned int count) |
219 | { | 214 | { |
220 | while (count--) { | 215 | while (count--) { |
221 | if (*str == '\n') | 216 | if (*str == '\n') |
222 | mac_sccb_out( '\r' ); | 217 | mac_sccb_out('\r'); |
223 | mac_sccb_out( *str++ ); | 218 | mac_sccb_out(*str++); |
224 | } | 219 | } |
225 | } | 220 | } |
226 | 221 | ||
227 | void mac_scca_console_write (struct console *co, const char *str, | 222 | void mac_scca_console_write(struct console *co, const char *str, |
228 | unsigned int count) | 223 | unsigned int count) |
229 | { | 224 | { |
230 | while (count--) { | 225 | while (count--) { |
231 | if (*str == '\n') | 226 | if (*str == '\n') |
232 | mac_scca_out( '\r' ); | 227 | mac_scca_out('\r'); |
233 | mac_scca_out( *str++ ); | 228 | mac_scca_out(*str++); |
234 | } | 229 | } |
235 | } | 230 | } |
236 | 231 | ||
237 | 232 | ||
@@ -239,41 +234,41 @@ void mac_scca_console_write (struct console *co, const char *str, | |||
239 | * SCC serial ports. They're used by the debugging interface, kgdb, and the | 234 | * SCC serial ports. They're used by the debugging interface, kgdb, and the |
240 | * serial console code. */ | 235 | * serial console code. */ |
241 | #define SCCB_WRITE(reg,val) \ | 236 | #define SCCB_WRITE(reg,val) \ |
242 | do { \ | 237 | do { \ |
243 | int i; \ | 238 | int i; \ |
244 | scc.cha_b_ctrl = (reg); \ | 239 | scc.cha_b_ctrl = (reg); \ |
245 | for( i = uSEC; i > 0; --i ) \ | 240 | for (i = uSEC; i > 0; --i) \ |
246 | barrier(); \ | 241 | barrier(); \ |
247 | scc.cha_b_ctrl = (val); \ | 242 | scc.cha_b_ctrl = (val); \ |
248 | for( i = uSEC; i > 0; --i ) \ | 243 | for (i = uSEC; i > 0; --i) \ |
249 | barrier(); \ | 244 | barrier(); \ |
250 | } while(0) | 245 | } while(0) |
251 | 246 | ||
252 | #define SCCA_WRITE(reg,val) \ | 247 | #define SCCA_WRITE(reg,val) \ |
253 | do { \ | 248 | do { \ |
254 | int i; \ | 249 | int i; \ |
255 | scc.cha_a_ctrl = (reg); \ | 250 | scc.cha_a_ctrl = (reg); \ |
256 | for( i = uSEC; i > 0; --i ) \ | 251 | for (i = uSEC; i > 0; --i) \ |
257 | barrier(); \ | 252 | barrier(); \ |
258 | scc.cha_a_ctrl = (val); \ | 253 | scc.cha_a_ctrl = (val); \ |
259 | for( i = uSEC; i > 0; --i ) \ | 254 | for (i = uSEC; i > 0; --i) \ |
260 | barrier(); \ | 255 | barrier(); \ |
261 | } while(0) | 256 | } while(0) |
262 | 257 | ||
263 | /* loops_per_jiffy isn't initialized yet, so we can't use udelay(). This does a | 258 | /* loops_per_jiffy isn't initialized yet, so we can't use udelay(). This does a |
264 | * delay of ~ 60us. */ | 259 | * delay of ~ 60us. */ |
265 | /* Mac: loops_per_jiffy min. 19000 ^= .5 us; MFPDELAY was 0.6 us*/ | 260 | /* Mac: loops_per_jiffy min. 19000 ^= .5 us; MFPDELAY was 0.6 us*/ |
266 | #define LONG_DELAY() \ | 261 | #define LONG_DELAY() \ |
267 | do { \ | 262 | do { \ |
268 | int i; \ | 263 | int i; \ |
269 | for( i = 60*uSEC; i > 0; --i ) \ | 264 | for (i = 60*uSEC; i > 0; --i) \ |
270 | barrier(); \ | 265 | barrier(); \ |
271 | } while(0) | 266 | } while(0) |
272 | 267 | ||
273 | #ifndef CONFIG_SERIAL_CONSOLE | 268 | #ifndef CONFIG_SERIAL_CONSOLE |
274 | static void __init mac_init_scc_port( int cflag, int port ) | 269 | static void __init mac_init_scc_port(int cflag, int port) |
275 | #else | 270 | #else |
276 | void mac_init_scc_port( int cflag, int port ) | 271 | void mac_init_scc_port(int cflag, int port) |
277 | #endif | 272 | #endif |
278 | { | 273 | { |
279 | extern int mac_SCC_reset_done; | 274 | extern int mac_SCC_reset_done; |
@@ -292,106 +287,102 @@ void mac_init_scc_port( int cflag, int port ) | |||
292 | /* reg12 (BRG low) */ | 287 | /* reg12 (BRG low) */ |
293 | { 94, 62, 46, 22, 10, 4, 1, 0, 0 }; | 288 | { 94, 62, 46, 22, 10, 4, 1, 0, 0 }; |
294 | 289 | ||
295 | int baud = cflag & CBAUD; | 290 | int baud = cflag & CBAUD; |
296 | int clksrc, clkmode, div, reg3, reg5; | 291 | int clksrc, clkmode, div, reg3, reg5; |
297 | 292 | ||
298 | if (cflag & CBAUDEX) | 293 | if (cflag & CBAUDEX) |
299 | baud += B38400; | 294 | baud += B38400; |
300 | if (baud < B1200 || baud > B38400+2) | 295 | if (baud < B1200 || baud > B38400+2) |
301 | baud = B9600; /* use default 9600bps for non-implemented rates */ | 296 | baud = B9600; /* use default 9600bps for non-implemented rates */ |
302 | baud -= B1200; /* tables starts at 1200bps */ | 297 | baud -= B1200; /* tables starts at 1200bps */ |
303 | 298 | ||
304 | clksrc = clksrc_table[baud]; | 299 | clksrc = clksrc_table[baud]; |
305 | clkmode = clkmode_table[baud]; | 300 | clkmode = clkmode_table[baud]; |
306 | div = div_table[baud]; | 301 | div = div_table[baud]; |
307 | 302 | ||
308 | reg3 = (((cflag & CSIZE) == CS8) ? 0xc0 : 0x40); | 303 | reg3 = (((cflag & CSIZE) == CS8) ? 0xc0 : 0x40); |
309 | reg5 = (((cflag & CSIZE) == CS8) ? 0x60 : 0x20) | 0x82 /* assert DTR/RTS */; | 304 | reg5 = (((cflag & CSIZE) == CS8) ? 0x60 : 0x20) | 0x82 /* assert DTR/RTS */; |
310 | 305 | ||
311 | if (port == 1) { | 306 | if (port == 1) { |
312 | (void)scc.cha_b_ctrl; /* reset reg pointer */ | 307 | (void)scc.cha_b_ctrl; /* reset reg pointer */ |
313 | SCCB_WRITE( 9, 0xc0 ); /* reset */ | 308 | SCCB_WRITE(9, 0xc0); /* reset */ |
314 | LONG_DELAY(); /* extra delay after WR9 access */ | 309 | LONG_DELAY(); /* extra delay after WR9 access */ |
315 | SCCB_WRITE( 4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03) : 0 | | 310 | SCCB_WRITE(4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03) : 0 | |
311 | 0x04 /* 1 stopbit */ | | ||
312 | clkmode); | ||
313 | SCCB_WRITE(3, reg3); | ||
314 | SCCB_WRITE(5, reg5); | ||
315 | SCCB_WRITE(9, 0); /* no interrupts */ | ||
316 | LONG_DELAY(); /* extra delay after WR9 access */ | ||
317 | SCCB_WRITE(10, 0); /* NRZ mode */ | ||
318 | SCCB_WRITE(11, clksrc); /* main clock source */ | ||
319 | SCCB_WRITE(12, div); /* BRG value */ | ||
320 | SCCB_WRITE(13, 0); /* BRG high byte */ | ||
321 | SCCB_WRITE(14, 1); | ||
322 | SCCB_WRITE(3, reg3 | 1); | ||
323 | SCCB_WRITE(5, reg5 | 8); | ||
324 | } else if (port == 0) { | ||
325 | (void)scc.cha_a_ctrl; /* reset reg pointer */ | ||
326 | SCCA_WRITE(9, 0xc0); /* reset */ | ||
327 | LONG_DELAY(); /* extra delay after WR9 access */ | ||
328 | SCCA_WRITE(4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03) : 0 | | ||
316 | 0x04 /* 1 stopbit */ | | 329 | 0x04 /* 1 stopbit */ | |
317 | clkmode ); | 330 | clkmode); |
318 | SCCB_WRITE( 3, reg3 ); | 331 | SCCA_WRITE(3, reg3); |
319 | SCCB_WRITE( 5, reg5 ); | 332 | SCCA_WRITE(5, reg5); |
320 | SCCB_WRITE( 9, 0 ); /* no interrupts */ | 333 | SCCA_WRITE(9, 0); /* no interrupts */ |
321 | LONG_DELAY(); /* extra delay after WR9 access */ | 334 | LONG_DELAY(); /* extra delay after WR9 access */ |
322 | SCCB_WRITE( 10, 0 ); /* NRZ mode */ | 335 | SCCA_WRITE(10, 0); /* NRZ mode */ |
323 | SCCB_WRITE( 11, clksrc ); /* main clock source */ | 336 | SCCA_WRITE(11, clksrc); /* main clock source */ |
324 | SCCB_WRITE( 12, div ); /* BRG value */ | 337 | SCCA_WRITE(12, div); /* BRG value */ |
325 | SCCB_WRITE( 13, 0 ); /* BRG high byte */ | 338 | SCCA_WRITE(13, 0); /* BRG high byte */ |
326 | SCCB_WRITE( 14, 1 ); | 339 | SCCA_WRITE(14, 1); |
327 | SCCB_WRITE( 3, reg3 | 1 ); | 340 | SCCA_WRITE(3, reg3 | 1); |
328 | SCCB_WRITE( 5, reg5 | 8 ); | 341 | SCCA_WRITE(5, reg5 | 8); |
329 | } else if (port == 0) { | 342 | } |
330 | (void)scc.cha_a_ctrl; /* reset reg pointer */ | 343 | |
331 | SCCA_WRITE( 9, 0xc0 ); /* reset */ | 344 | mac_SCC_reset_done = 1; |
332 | LONG_DELAY(); /* extra delay after WR9 access */ | 345 | mac_SCC_init_done = 1; |
333 | SCCA_WRITE( 4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03) : 0 | | ||
334 | 0x04 /* 1 stopbit */ | | ||
335 | clkmode ); | ||
336 | SCCA_WRITE( 3, reg3 ); | ||
337 | SCCA_WRITE( 5, reg5 ); | ||
338 | SCCA_WRITE( 9, 0 ); /* no interrupts */ | ||
339 | LONG_DELAY(); /* extra delay after WR9 access */ | ||
340 | SCCA_WRITE( 10, 0 ); /* NRZ mode */ | ||
341 | SCCA_WRITE( 11, clksrc ); /* main clock source */ | ||
342 | SCCA_WRITE( 12, div ); /* BRG value */ | ||
343 | SCCA_WRITE( 13, 0 ); /* BRG high byte */ | ||
344 | SCCA_WRITE( 14, 1 ); | ||
345 | SCCA_WRITE( 3, reg3 | 1 ); | ||
346 | SCCA_WRITE( 5, reg5 | 8 ); | ||
347 | } | ||
348 | |||
349 | mac_SCC_reset_done = 1; | ||
350 | mac_SCC_init_done = 1; | ||
351 | } | 346 | } |
352 | #endif /* DEBUG_SERIAL */ | 347 | #endif /* DEBUG_SERIAL */ |
353 | 348 | ||
354 | void mac_init_scca_port( int cflag ) | 349 | void mac_init_scca_port(int cflag) |
355 | { | 350 | { |
356 | mac_init_scc_port(cflag, 0); | 351 | mac_init_scc_port(cflag, 0); |
357 | } | 352 | } |
358 | 353 | ||
359 | void mac_init_sccb_port( int cflag ) | 354 | void mac_init_sccb_port(int cflag) |
360 | { | 355 | { |
361 | mac_init_scc_port(cflag, 1); | 356 | mac_init_scc_port(cflag, 1); |
362 | } | 357 | } |
363 | 358 | ||
364 | void __init mac_debug_init(void) | 359 | static int __init mac_debug_setup(char *arg) |
365 | { | 360 | { |
361 | if (!MACH_IS_MAC) | ||
362 | return 0; | ||
363 | |||
366 | #ifdef DEBUG_SERIAL | 364 | #ifdef DEBUG_SERIAL |
367 | if ( !strcmp( m68k_debug_device, "ser" ) | 365 | if (!strcmp(arg, "ser") || !strcmp(arg, "ser1")) { |
368 | || !strcmp( m68k_debug_device, "ser1" )) { | 366 | /* Mac modem port */ |
369 | /* Mac modem port */ | 367 | mac_init_scc_port(B9600|CS8, 0); |
370 | mac_init_scc_port( B9600|CS8, 0 ); | 368 | mac_console_driver.write = mac_scca_console_write; |
371 | mac_console_driver.write = mac_scca_console_write; | 369 | scc_port = 0; |
372 | scc_port = 0; | 370 | } else if (!strcmp(arg, "ser2")) { |
373 | } | 371 | /* Mac printer port */ |
374 | else if (!strcmp( m68k_debug_device, "ser2" )) { | 372 | mac_init_scc_port(B9600|CS8, 1); |
375 | /* Mac printer port */ | 373 | mac_console_driver.write = mac_sccb_console_write; |
376 | mac_init_scc_port( B9600|CS8, 1 ); | 374 | scc_port = 1; |
377 | mac_console_driver.write = mac_sccb_console_write; | 375 | } |
378 | scc_port = 1; | ||
379 | } | ||
380 | #endif | 376 | #endif |
381 | #ifdef DEBUG_HEADS | 377 | #ifdef DEBUG_HEADS |
382 | if ( !strcmp( m68k_debug_device, "scn" ) | 378 | if (!strcmp(arg, "scn") || !strcmp(arg, "con")) { |
383 | || !strcmp( m68k_debug_device, "con" )) { | 379 | /* display, using head.S console routines */ |
384 | /* display, using head.S console routines */ | 380 | mac_console_driver.write = mac_debug_console_write; |
385 | mac_console_driver.write = mac_debug_console_write; | 381 | } |
386 | } | ||
387 | #endif | 382 | #endif |
388 | if (mac_console_driver.write) | 383 | if (mac_console_driver.write) |
389 | register_console(&mac_console_driver); | 384 | register_console(&mac_console_driver); |
385 | return 0; | ||
390 | } | 386 | } |
391 | 387 | ||
392 | /* | 388 | early_param("debug", mac_debug_setup); |
393 | * Local variables: | ||
394 | * c-indent-level: 4 | ||
395 | * tab-width: 8 | ||
396 | * End: | ||
397 | */ | ||