Commit d6713b4091a99fa2af2fabdcd2f3fb97f32ecf2e

Authored by Roman Zippel
Committed by Linus Torvalds
1 parent f8744bc95d

m68k: early parameter support

Add early parameter support and convert current users to it.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 8 changed files with 77 additions and 106 deletions Side-by-side Diff

arch/m68k/amiga/config.c
... ... @@ -79,8 +79,6 @@
79 79  
80 80 static char amiga_model_name[13] = "Amiga ";
81 81  
82   -extern char m68k_debug_device[];
83   -
84 82 static void amiga_sched_init(irq_handler_t handler);
85 83 /* amiga specific irq functions */
86 84 extern void amiga_init_IRQ(void);
87 85  
... ... @@ -95,12 +93,10 @@
95 93 extern void amiga_mksound(unsigned int count, unsigned int ticks);
96 94 static void amiga_reset(void);
97 95 extern void amiga_init_sound(void);
98   -static void amiga_savekmsg_init(void);
99 96 static void amiga_mem_console_write(struct console *co, const char *b,
100 97 unsigned int count);
101 98 void amiga_serial_console_write(struct console *co, const char *s,
102 99 unsigned int count);
103   -static void amiga_debug_init(void);
104 100 #ifdef CONFIG_HEARTBEAT
105 101 static void amiga_heartbeat(int on);
106 102 #endif
... ... @@ -370,7 +366,6 @@
370 366 {
371 367 int i;
372 368  
373   - amiga_debug_init();
374 369 amiga_identify();
375 370  
376 371 /* Yuk, we don't have PCI memory */
... ... @@ -458,17 +453,6 @@
458 453 /* initialize chipram allocator */
459 454 amiga_chip_init();
460 455  
461   - /* debugging using chipram */
462   - if (!strcmp(m68k_debug_device, "mem")) {
463   - if (!AMIGAHW_PRESENT(CHIP_RAM))
464   - printk("Warning: no chipram present for debugging\n");
465   - else {
466   - amiga_savekmsg_init();
467   - amiga_console_driver.write = amiga_mem_console_write;
468   - register_console(&amiga_console_driver);
469   - }
470   - }
471   -
472 456 /* our beloved beeper */
473 457 if (AMIGAHW_PRESENT(AMI_AUDIO))
474 458 amiga_init_sound();
475 459  
476 460  
477 461  
... ... @@ -787,17 +771,33 @@
787 771 }
788 772 }
789 773  
790   -static void amiga_savekmsg_init(void)
  774 +static int __init amiga_savekmsg_setup(char *arg)
791 775 {
792 776 static struct resource debug_res = { .name = "Debug" };
793 777  
  778 + if (!MACH_IS_AMIGA || strcmp(arg, "mem"))
  779 + goto done;
  780 +
  781 + if (!AMIGAHW_PRESENT(CHIP_RAM)) {
  782 + printk("Warning: no chipram present for debugging\n");
  783 + goto done;
  784 + }
  785 +
794 786 savekmsg = amiga_chip_alloc_res(SAVEKMSG_MAXMEM, &debug_res);
795 787 savekmsg->magic1 = SAVEKMSG_MAGIC1;
796 788 savekmsg->magic2 = SAVEKMSG_MAGIC2;
797 789 savekmsg->magicptr = ZTWO_PADDR(savekmsg);
798 790 savekmsg->size = 0;
  791 +
  792 + amiga_console_driver.write = amiga_mem_console_write;
  793 + register_console(&amiga_console_driver);
  794 +
  795 +done:
  796 + return 0;
799 797 }
800 798  
  799 +early_param("debug", amiga_savekmsg_setup);
  800 +
801 801 static void amiga_serial_putc(char c)
802 802 {
803 803 amiga_custom.serdat = (unsigned char)c | 0x100;
804 804  
805 805  
806 806  
... ... @@ -872,14 +872,17 @@
872 872 }
873 873 #endif
874 874  
875   -static void __init amiga_debug_init(void)
  875 +static int __init amiga_debug_setup(char *arg)
876 876 {
877   - if (!strcmp(m68k_debug_device, "ser" )) {
  877 + if (MACH_IS_AMIGA && !strcmp(arg, "ser")) {
878 878 /* no initialization required (?) */
879 879 amiga_console_driver.write = amiga_serial_console_write;
880 880 register_console(&amiga_console_driver);
881 881 }
  882 + return 0;
882 883 }
  884 +
  885 +early_param("debug", amiga_debug_setup);
883 886  
884 887 #ifdef CONFIG_HEARTBEAT
885 888 static void amiga_heartbeat(int on)
arch/m68k/atari/config.c
... ... @@ -69,10 +69,7 @@
69 69 extern int atari_mste_set_clock_mmss (unsigned long);
70 70 extern int atari_tt_set_clock_mmss (unsigned long);
71 71  
72   -/* atari specific debug functions (in debug.c) */
73   -extern void atari_debug_init(void);
74 72  
75   -
76 73 /* ++roman: This is a more elaborate test for an SCC chip, since the plain
77 74 * Medusa board generates DTACK at the SCC's standard addresses, but a SCC
78 75 * board in the Medusa is possible. Also, the addresses where the ST_ESCC
79 76  
80 77  
81 78  
... ... @@ -137,15 +134,18 @@
137 134  
138 135  
139 136 /* Parse the Atari-specific switches= option. */
140   -void __init atari_switches_setup(const char *str, unsigned len)
  137 +static int __init atari_switches_setup(char *str)
141 138 {
142   - char switches[len+1];
  139 + char switches[strlen(str) + 1];
143 140 char *p;
144 141 int ovsc_shift;
145 142 char *args = switches;
146 143  
  144 + if (!MACH_IS_ATARI)
  145 + return 0;
  146 +
147 147 /* copy string to local array, strsep works destructively... */
148   - strlcpy(switches, str, sizeof(switches));
  148 + strcpy(switches, str);
149 149 atari_switches = 0;
150 150  
151 151 /* parse the options */
152 152  
153 153  
... ... @@ -170,9 +170,12 @@
170 170 atari_switches |= ATARI_SWITCH_SND7 << ovsc_shift;
171 171 }
172 172 }
  173 + return 0;
173 174 }
174 175  
  176 +early_param("switches", atari_switches_setup);
175 177  
  178 +
176 179 /*
177 180 * Setup the Atari configuration info
178 181 */
... ... @@ -182,8 +185,6 @@
182 185 unsigned short tos_version;
183 186  
184 187 memset(&atari_hw_present, 0, sizeof(atari_hw_present));
185   -
186   - atari_debug_init();
187 188  
188 189 /* Change size of I/O space from 64KB to 4GB. */
189 190 ioport_resource.end = 0xFFFFFFFF;
arch/m68k/atari/debug.c
... ... @@ -19,8 +19,6 @@
19 19 #include <asm/atarihw.h>
20 20 #include <asm/atariints.h>
21 21  
22   -extern char m68k_debug_device[];
23   -
24 22 /* Flag that Modem1 port is already initialized and used */
25 23 int atari_MFP_init_done;
26 24 /* Flag that Modem1 port is already initialized and used */
27 25  
28 26  
29 27  
30 28  
31 29  
32 30  
... ... @@ -305,26 +303,28 @@
305 303 ACIA_RHTID : ACIA_RLTID);
306 304 }
307 305  
308   -void __init atari_debug_init(void)
  306 +static int __init atari_debug_setup(char *arg)
309 307 {
310   - if (!strcmp(m68k_debug_device, "ser")) {
  308 + if (!MACH_IS_ATARI)
  309 + return 0;
  310 +
  311 + if (!strcmp(arg, "ser"))
311 312 /* defaults to ser2 for a Falcon and ser1 otherwise */
312   - strcpy(m68k_debug_device, MACH_IS_FALCON ? "ser2" : "ser1");
313   - }
  313 + arg = MACH_IS_FALCON ? "ser2" : "ser1";
314 314  
315   - if (!strcmp(m68k_debug_device, "ser1")) {
  315 + if (!strcmp(arg, "ser1")) {
316 316 /* ST-MFP Modem1 serial port */
317 317 atari_init_mfp_port(B9600|CS8);
318 318 atari_console_driver.write = atari_mfp_console_write;
319   - } else if (!strcmp(m68k_debug_device, "ser2")) {
  319 + } else if (!strcmp(arg, "ser2")) {
320 320 /* SCC Modem2 serial port */
321 321 atari_init_scc_port(B9600|CS8);
322 322 atari_console_driver.write = atari_scc_console_write;
323   - } else if (!strcmp(m68k_debug_device, "midi")) {
  323 + } else if (!strcmp(arg, "midi")) {
324 324 /* MIDI port */
325 325 atari_init_midi_port(B9600|CS8);
326 326 atari_console_driver.write = atari_midi_console_write;
327   - } else if (!strcmp(m68k_debug_device, "par")) {
  327 + } else if (!strcmp(arg, "par")) {
328 328 /* parallel printer */
329 329 atari_turnoff_irq(IRQ_MFP_BUSY); /* avoid ints */
330 330 sound_ym.rd_data_reg_sel = 7; /* select mixer control */
331 331  
... ... @@ -337,5 +337,9 @@
337 337 }
338 338 if (atari_console_driver.write)
339 339 register_console(&atari_console_driver);
  340 +
  341 + return 0;
340 342 }
  343 +
  344 +early_param("debug", atari_debug_setup);
arch/m68k/kernel/setup.c
... ... @@ -71,9 +71,6 @@
71 71  
72 72 static char m68k_command_line[CL_SIZE];
73 73  
74   -char m68k_debug_device[6] = "";
75   -EXPORT_SYMBOL(m68k_debug_device);
76   -
77 74 void (*mach_sched_init) (irq_handler_t handler) __initdata = NULL;
78 75 /* machine dependent irq functions */
79 76 void (*mach_init_IRQ) (void) __initdata = NULL;
... ... @@ -215,7 +212,6 @@
215 212 unsigned long endmem, startmem;
216 213 #endif
217 214 int i;
218   - char *p, *q;
219 215  
220 216 /* The bootinfo is located right after the kernel bss */
221 217 m68k_parse_bootinfo((const struct bi_record *)&_end);
... ... @@ -258,40 +254,7 @@
258 254 *cmdline_p = m68k_command_line;
259 255 memcpy(boot_command_line, *cmdline_p, CL_SIZE);
260 256  
261   - /* Parse the command line for arch-specific options.
262   - * For the m68k, this is currently only "debug=xxx" to enable printing
263   - * certain kernel messages to some machine-specific device.
264   - */
265   - for (p = *cmdline_p; p && *p;) {
266   - i = 0;
267   - if (!strncmp(p, "debug=", 6)) {
268   - strlcpy(m68k_debug_device, p+6, sizeof(m68k_debug_device));
269   - q = strchr(m68k_debug_device, ' ');
270   - if (q)
271   - *q = 0;
272   - i = 1;
273   - }
274   -#ifdef CONFIG_ATARI
275   - /* This option must be parsed very early */
276   - if (!strncmp(p, "switches=", 9)) {
277   - extern void atari_switches_setup(const char *, int);
278   - q = strchr(p + 9, ' ');
279   - atari_switches_setup(p + 9, q ? (q - (p + 9)) : strlen(p + 9));
280   - i = 1;
281   - }
282   -#endif
283   -
284   - if (i) {
285   - /* option processed, delete it */
286   - if ((q = strchr(p, ' ')))
287   - strcpy(p, q + 1);
288   - else
289   - *p = 0;
290   - } else {
291   - if ((p = strchr(p, ' ')))
292   - ++p;
293   - }
294   - }
  257 + parse_early_param();
295 258  
296 259 #ifdef CONFIG_DUMMY_CONSOLE
297 260 conswitchp = &dummy_con;
arch/m68k/mac/config.c
... ... @@ -82,10 +82,6 @@
82 82  
83 83 extern void nubus_sweep_video(void);
84 84  
85   -/* Mac specific debug functions (in debug.c) */
86   -extern void mac_debug_init(void);
87   -extern void mac_debugging_long(int, long);
88   -
89 85 static void mac_get_model(char *str);
90 86  
91 87 static void mac_sched_init(irq_handler_t vector)
... ... @@ -180,9 +176,6 @@
180 176 mach_halt = mac_poweroff;
181 177 mach_power_off = mac_poweroff;
182 178 mach_max_dma_address = 0xffffffff;
183   -#if 0
184   - mach_debug_init = mac_debug_init;
185   -#endif
186 179 #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
187 180 mach_beep = mac_mksound;
188 181 #endif
... ... @@ -802,7 +795,6 @@
802 795 /* the serial ports set to "Faster" mode in MacOS. */
803 796  
804 797 iop_preinit();
805   - mac_debug_init();
806 798  
807 799 printk(KERN_INFO "Detected Macintosh model: %d \n", model);
808 800  
arch/m68k/mac/debug.c
... ... @@ -27,10 +27,6 @@
27 27 #include <asm/machw.h>
28 28 #include <asm/macints.h>
29 29  
30   -extern char m68k_debug_device[];
31   -
32   -extern struct compat_bootinfo compat_boot_info;
33   -
34 30 extern unsigned long mac_videobase;
35 31 extern unsigned long mac_videodepth;
36 32 extern unsigned long mac_rowbytes;
37 33  
38 34  
39 35  
... ... @@ -360,16 +356,18 @@
360 356 mac_init_scc_port(cflag, 1);
361 357 }
362 358  
363   -void __init mac_debug_init(void)
  359 +static int __init mac_debug_setup(char *arg)
364 360 {
  361 + if (!MACH_IS_MAC)
  362 + return 0;
  363 +
365 364 #ifdef DEBUG_SERIAL
366   - if (!strcmp(m68k_debug_device, "ser") ||
367   - !strcmp(m68k_debug_device, "ser1")) {
  365 + if (!strcmp(arg, "ser") || !strcmp(arg, "ser1")) {
368 366 /* Mac modem port */
369 367 mac_init_scc_port(B9600|CS8, 0);
370 368 mac_console_driver.write = mac_scca_console_write;
371 369 scc_port = 0;
372   - } else if (!strcmp(m68k_debug_device, "ser2")) {
  370 + } else if (!strcmp(arg, "ser2")) {
373 371 /* Mac printer port */
374 372 mac_init_scc_port(B9600|CS8, 1);
375 373 mac_console_driver.write = mac_sccb_console_write;
376 374  
377 375  
... ... @@ -377,13 +375,15 @@
377 375 }
378 376 #endif
379 377 #ifdef DEBUG_HEADS
380   - if (!strcmp(m68k_debug_device, "scn") ||
381   - !strcmp(m68k_debug_device, "con")) {
  378 + if (!strcmp(arg, "scn") || !strcmp(arg, "con")) {
382 379 /* display, using head.S console routines */
383 380 mac_console_driver.write = mac_debug_console_write;
384 381 }
385 382 #endif
386 383 if (mac_console_driver.write)
387 384 register_console(&mac_console_driver);
  385 + return 0;
388 386 }
  387 +
  388 +early_param("debug", mac_debug_setup);
arch/m68k/q40/config.c
... ... @@ -54,7 +54,6 @@
54 54  
55 55 extern void q40_mksound(unsigned int /*freq*/, unsigned int /*ticks*/);
56 56  
57   -extern char m68k_debug_device[];
58 57 static void q40_mem_console_write(struct console *co, const char *b,
59 58 unsigned int count);
60 59  
... ... @@ -62,6 +61,7 @@
62 61  
63 62 static struct console q40_console_driver = {
64 63 .name = "debug",
  64 + .write = q40_mem_console_write,
65 65 .flags = CON_PRINTBUFFER,
66 66 .index = -1,
67 67 };
... ... @@ -85,6 +85,19 @@
85 85 }
86 86 }
87 87  
  88 +static int __init q40_debug_setup(char *arg)
  89 +{
  90 + /* useful for early debugging stages - writes kernel messages into SRAM */
  91 + if (MACH_IS_Q40 && !strncmp(arg, "mem", 3)) {
  92 + /*printk("using NVRAM debug, q40_mem_cptr=%p\n",q40_mem_cptr);*/
  93 + _cpleft = 2000 - ((long)q40_mem_cptr-0xff020000) / 4;
  94 + register_console(&q40_console_driver);
  95 + }
  96 + return 0;
  97 +}
  98 +
  99 +early_param("debug", q40_debug_setup);
  100 +
88 101 #if 0
89 102 void printq40(char *str)
90 103 {
... ... @@ -194,14 +207,6 @@
194 207 * all physical RAM fits into the boundary - otherwise
195 208 * allocator may play costly and useless tricks */
196 209 mach_max_dma_address = 1024*1024*1024;
197   -
198   - /* useful for early debugging stages - writes kernel messages into SRAM */
199   - if (!strncmp( m68k_debug_device,"mem", 3)) {
200   - /*printk("using NVRAM debug, q40_mem_cptr=%p\n",q40_mem_cptr);*/
201   - _cpleft = 2000 - ((long)q40_mem_cptr-0xff020000) / 4;
202   - q40_console_driver.write = q40_mem_console_write;
203   - register_console(&q40_console_driver);
204   - }
205 210 }
206 211  
207 212  
arch/m68k/sun3x/prom.c
... ... @@ -73,8 +73,6 @@
73 73 (*romvec->pv_reboot)("vmlinux");
74 74 }
75 75  
76   -extern char m68k_debug_device[];
77   -
78 76 static void sun3x_prom_write(struct console *co, const char *s,
79 77 unsigned int count)
80 78 {
81 79  
82 80  
83 81  
84 82  
... ... @@ -119,12 +117,17 @@
119 117 * XXX this is futile since we restore the vbr first - oops
120 118 */
121 119 vectors[VEC_TRAP14] = sun3x_prom_abort;
  120 +}
122 121  
  122 +static int __init sun3x_debug_setup(char *arg)
  123 +{
123 124 /* If debug=prom was specified, start the debug console */
124   -
125   - if (!strcmp(m68k_debug_device, "prom"))
  125 + if (MACH_IS_SUN3X && !strcmp(arg, "prom"))
126 126 register_console(&sun3x_debug);
  127 + return 0;
127 128 }
  129 +
  130 +early_param("debug", sun3x_debug_setup);
128 131  
129 132 /* some prom functions to export */
130 133 int prom_getintdefault(int node, char *property, int deflt)