Import 2.1.118
[davej-history.git] / init / main.c
blob4b37834628b539f46d67f20fdddf661f77382e3d
1 /*
2 * linux/init/main.c
4 * Copyright (C) 1991, 1992 Linus Torvalds
6 * GK 2/5/95 - Changed to support mounting root fs via NFS
7 * Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96
8 * Moan early if gcc is old, avoiding bogus kernels - Paul Gortmaker, May '96
9 * Simplified starting of init: Michael A. Griffith <grif@acm.org>
12 #define __KERNEL_SYSCALLS__
14 #include <linux/types.h>
15 #include <linux/fcntl.h>
16 #include <linux/config.h>
17 #include <linux/sched.h>
18 #include <linux/kernel.h>
19 #include <linux/tty.h>
20 #include <linux/head.h>
21 #include <linux/unistd.h>
22 #include <linux/string.h>
23 #include <linux/timer.h>
24 #include <linux/fs.h>
25 #include <linux/proc_fs.h>
26 #include <linux/ctype.h>
27 #include <linux/delay.h>
28 #include <linux/utsname.h>
29 #include <linux/ioport.h>
30 #include <linux/hdreg.h>
31 #include <linux/mm.h>
32 #include <linux/slab.h>
33 #include <linux/major.h>
34 #include <linux/blk.h>
35 #include <linux/init.h>
37 #include <asm/system.h>
38 #include <asm/io.h>
39 #include <asm/bugs.h>
41 #include <stdarg.h>
43 #ifdef CONFIG_PCI
44 #include <linux/pci.h>
45 #endif
47 #ifdef CONFIG_DIO
48 #include <linux/dio.h>
49 #endif
51 #ifdef CONFIG_MTRR
52 # include <asm/mtrr.h>
53 #endif
56 * Versions of gcc older than that listed below may actually compile
57 * and link okay, but the end product can have subtle run time bugs.
58 * To avoid associated bogus bug reports, we flatly refuse to compile
59 * with a gcc that is known to be too old from the very beginning.
61 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
62 #error sorry, your GCC is too old. It builds incorrect kernels.
63 #endif
65 extern char _stext, _etext;
66 extern char *linux_banner;
68 extern int console_loglevel;
70 static int init(void *);
71 extern int bdflush(void *);
72 extern int kswapd(void *);
73 extern void kswapd_setup(void);
75 extern void init_IRQ(void);
76 extern void init_modules(void);
77 extern long console_init(long, long);
78 extern void sock_init(void);
79 extern void uidcache_init(void);
80 extern void mca_init(void);
81 extern long sbus_init(long, long);
82 extern long powermac_init(unsigned long, unsigned long);
83 extern void sysctl_init(void);
84 extern void filescache_init(void);
85 extern void signals_init(void);
87 #ifdef CONFIG_ARCH_ACORN
88 extern void ecard_init(void);
89 #endif
91 extern void smp_setup(char *str, int *ints);
92 #ifdef __i386__
93 extern void ioapic_pirq_setup(char *str, int *ints);
94 #endif
95 extern void no_scroll(char *str, int *ints);
96 extern void kbd_reset_setup(char *str, int *ints);
97 extern void panic_setup(char *str, int *ints);
98 extern void bmouse_setup(char *str, int *ints);
99 extern void msmouse_setup(char *str, int *ints);
100 extern void console_setup(char *str, int *ints);
101 #ifdef CONFIG_PRINTER
102 extern void lp_setup(char *str, int *ints);
103 #endif
104 #ifdef CONFIG_JOYSTICK
105 extern void js_setup(char *str, int *ints);
106 #endif
107 extern void eth_setup(char *str, int *ints);
108 #ifdef CONFIG_ARCNET_COM20020
109 extern void com20020_setup(char *str, int *ints);
110 #endif
111 #ifdef CONFIG_ARCNET_RIM_I
112 extern void arcrimi_setup(char *str, int *ints);
113 #endif
114 #ifdef CONFIG_ARCNET_COM90xxIO
115 extern void com90io_setup(char *str, int *ints);
116 #endif
117 #ifdef CONFIG_ARCNET_COM90xx
118 extern void com90xx_setup(char *str, int *ints);
119 #endif
120 #ifdef CONFIG_DECNET
121 extern void decnet_setup(char *str, int *ints);
122 #endif
123 #ifdef CONFIG_BLK_DEV_XD
124 extern void xd_setup(char *str, int *ints);
125 extern void xd_manual_geo_init(char *str, int *ints);
126 #endif
127 #ifdef CONFIG_BLK_DEV_IDE
128 extern void ide_setup(char *);
129 #endif
130 #ifdef CONFIG_PARIDE_PD
131 extern void pd_setup(char *str, int *ints);
132 #endif
133 #ifdef CONFIG_PARIDE_PF
134 extern void pf_setup(char *str, int *ints);
135 #endif
136 #ifdef CONFIG_PARIDE_PT
137 extern void pt_setup(char *str, int *ints);
138 #endif
139 #ifdef CONFIG_PARIDE_PG
140 extern void pg_setup(char *str, int *ints);
141 #endif
142 #ifdef CONFIG_PARIDE_PCD
143 extern void pcd_setup(char *str, int *ints);
144 #endif
145 extern void floppy_setup(char *str, int *ints);
146 extern void st_setup(char *str, int *ints);
147 extern void st0x_setup(char *str, int *ints);
148 extern void advansys_setup(char *str, int *ints);
149 extern void tmc8xx_setup(char *str, int *ints);
150 extern void t128_setup(char *str, int *ints);
151 extern void pas16_setup(char *str, int *ints);
152 extern void generic_NCR5380_setup(char *str, int *intr);
153 extern void generic_NCR53C400_setup(char *str, int *intr);
154 extern void generic_NCR53C400A_setup(char *str, int *intr);
155 extern void generic_DTC3181E_setup(char *str, int *intr);
156 extern void aha152x_setup(char *str, int *ints);
157 extern void aha1542_setup(char *str, int *ints);
158 extern void gdth_setup(char *str, int *ints);
159 extern void aic7xxx_setup(char *str, int *ints);
160 extern void AM53C974_setup(char *str, int *ints);
161 extern void BusLogic_Setup(char *str, int *ints);
162 extern void ncr53c8xx_setup(char *str, int *ints);
163 extern void eata2x_setup(char *str, int *ints);
164 extern void u14_34f_setup(char *str, int *ints);
165 extern void fdomain_setup(char *str, int *ints);
166 extern void ibmmca_scsi_setup(char *str, int *ints);
167 extern void in2000_setup(char *str, int *ints);
168 extern void NCR53c406a_setup(char *str, int *ints);
169 extern void wd7000_setup(char *str, int *ints);
170 extern void scsi_luns_setup(char *str, int *ints);
171 extern void scsi_logging_setup(char *str, int *ints);
172 extern void sound_setup(char *str, int *ints);
173 extern void reboot_setup(char *str, int *ints);
174 extern void video_setup(char *str, int *ints);
175 #ifdef CONFIG_CDU31A
176 extern void cdu31a_setup(char *str, int *ints);
177 #endif CONFIG_CDU31A
178 #ifdef CONFIG_BLK_DEV_PS2
179 extern void ed_setup(char *str, int *ints);
180 extern void tp720_setup(char *str, int *ints);
181 #endif CONFIG_BLK_DEV_PS2
182 #ifdef CONFIG_MCD
183 extern void mcd_setup(char *str, int *ints);
184 #endif CONFIG_MCD
185 #ifdef CONFIG_MCDX
186 extern void mcdx_setup(char *str, int *ints);
187 #endif CONFIG_MCDX
188 #ifdef CONFIG_SBPCD
189 extern void sbpcd_setup(char *str, int *ints);
190 #endif CONFIG_SBPCD
191 #ifdef CONFIG_AZTCD
192 extern void aztcd_setup(char *str, int *ints);
193 #endif CONFIG_AZTCD
194 #ifdef CONFIG_CDU535
195 extern void sonycd535_setup(char *str, int *ints);
196 #endif CONFIG_CDU535
197 #ifdef CONFIG_GSCD
198 extern void gscd_setup(char *str, int *ints);
199 #endif CONFIG_GSCD
200 #ifdef CONFIG_CM206
201 extern void cm206_setup(char *str, int *ints);
202 #endif CONFIG_CM206
203 #ifdef CONFIG_OPTCD
204 extern void optcd_setup(char *str, int *ints);
205 #endif CONFIG_OPTCD
206 #ifdef CONFIG_SJCD
207 extern void sjcd_setup(char *str, int *ints);
208 #endif CONFIG_SJCD
209 #ifdef CONFIG_ISP16_CDI
210 extern void isp16_setup(char *str, int *ints);
211 #endif CONFIG_ISP16_CDI
212 #ifdef CONFIG_BLK_DEV_RAM
213 static void ramdisk_start_setup(char *str, int *ints);
214 static void load_ramdisk(char *str, int *ints);
215 static void prompt_ramdisk(char *str, int *ints);
216 static void ramdisk_size(char *str, int *ints);
217 #ifdef CONFIG_BLK_DEV_INITRD
218 static void no_initrd(char *s,int *ints);
219 #endif
220 #endif CONFIG_BLK_DEV_RAM
221 #ifdef CONFIG_ISDN_DRV_ICN
222 extern void icn_setup(char *str, int *ints);
223 #endif
224 #ifdef CONFIG_ISDN_DRV_HISAX
225 extern void HiSax_setup(char *str, int *ints);
226 #endif
227 #ifdef CONFIG_DIGIEPCA
228 extern void epca_setup(char *str, int *ints);
229 #endif
230 #ifdef CONFIG_ISDN_DRV_PCBIT
231 extern void pcbit_setup(char *str, int *ints);
232 #endif
234 #ifdef CONFIG_ATARIMOUSE
235 extern void atari_mouse_setup (char *str, int *ints);
236 #endif
237 #ifdef CONFIG_DMASOUND
238 extern void dmasound_setup (char *str, int *ints);
239 #endif
240 #ifdef CONFIG_ATARI_SCSI
241 extern void atari_scsi_setup (char *str, int *ints);
242 #endif
243 extern void stram_swap_setup (char *str, int *ints);
244 extern void wd33c93_setup (char *str, int *ints);
245 extern void gvp11_setup (char *str, int *ints);
246 extern void ncr53c7xx_setup (char *str, int *ints);
247 #ifdef CONFIG_MAC_SCSI
248 extern void mac_scsi_setup (char *str, int *ints);
249 #endif
251 #ifdef CONFIG_CYCLADES
252 extern void cy_setup(char *str, int *ints);
253 #endif
254 #ifdef CONFIG_DIGI
255 extern void pcxx_setup(char *str, int *ints);
256 #endif
257 #ifdef CONFIG_RISCOM8
258 extern void riscom8_setup(char *str, int *ints);
259 #endif
260 #ifdef CONFIG_SPECIALIX
261 extern void specialix_setup(char *str, int *ints);
262 #endif
263 #ifdef CONFIG_DMASCC
264 extern void dmascc_setup(char *str, int *ints);
265 #endif
266 #ifdef CONFIG_BAYCOM_PAR
267 extern void baycom_par_setup(char *str, int *ints);
268 #endif
269 #ifdef CONFIG_BAYCOM_SER_FDX
270 extern void baycom_ser_fdx_setup(char *str, int *ints);
271 #endif
272 #ifdef CONFIG_BAYCOM_SER_HDX
273 extern void baycom_ser_hdx_setup(char *str, int *ints);
274 #endif
275 #ifdef CONFIG_SOUNDMODEM
276 extern void sm_setup(char *str, int *ints);
277 #endif
278 #ifdef CONFIG_PMAC_CONSOLE
279 extern void pmac_cons_setup(char *str, int *ints);
280 extern void pmac_vmode_setup(char *str, int *ints);
281 #endif
282 #ifdef CONFIG_WDT
283 extern void wdt_setup(char *str, int *ints);
284 #endif
285 #ifdef CONFIG_PARPORT
286 extern void parport_setup(char *str, int *ints);
287 #endif
288 #ifdef CONFIG_PLIP
289 extern void plip_setup(char *str, int *ints);
290 #endif
291 #ifdef CONFIG_HFMODEM
292 extern void hfmodem_setup(char *str, int *ints);
293 #endif
294 #ifdef CONFIG_IP_PNP
295 extern void ip_auto_config_setup(char *str, int *ints);
296 #endif
297 #ifdef CONFIG_ROOT_NFS
298 extern void nfs_root_setup(char *str, int *ints);
299 #endif
300 #ifdef CONFIG_FTAPE
301 extern void ftape_setup(char *str, int *ints);
302 #endif
304 #if defined(CONFIG_SYSVIPC)
305 extern void ipc_init(void);
306 #endif
307 #if defined(CONFIG_QUOTA)
308 extern void dquot_init_hash(void);
309 #endif
311 #ifdef CONFIG_MD_BOOT
312 extern void md_setup(char *str,int *ints) __init;
313 #endif
315 #ifdef __sparc__
316 extern int serial_console;
317 #endif
320 * Boot command-line arguments
322 #define MAX_INIT_ARGS 8
323 #define MAX_INIT_ENVS 8
325 extern void time_init(void);
327 static unsigned long memory_start = 0;
328 static unsigned long memory_end = 0;
330 int rows, cols;
332 #ifdef CONFIG_BLK_DEV_RAM
333 extern int rd_doload; /* 1 = load ramdisk, 0 = don't load */
334 extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */
335 extern int rd_size; /* Size of the ramdisk(s) */
336 extern int rd_image_start; /* starting block # of image */
337 #ifdef CONFIG_BLK_DEV_INITRD
338 kdev_t real_root_dev;
339 #endif
340 #endif
342 int root_mountflags = MS_RDONLY;
343 char *execute_command = NULL;
345 static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
346 static char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
348 char *get_options(char *str, int *ints)
350 char *cur = str;
351 int i=1;
353 while (cur && isdigit(*cur) && i <= 10) {
354 ints[i++] = simple_strtoul(cur,NULL,0);
355 if ((cur = strchr(cur,',')) != NULL)
356 cur++;
358 ints[0] = i-1;
359 return(cur);
362 static void __init profile_setup(char *str, int *ints)
364 if (ints[0] > 0)
365 prof_shift = (unsigned long) ints[1];
366 else
367 prof_shift = 2;
371 static struct dev_name_struct {
372 const char *name;
373 const int num;
374 } root_dev_names[] __initdata = {
375 #ifdef CONFIG_ROOT_NFS
376 { "nfs", 0x00ff },
377 #endif
378 #ifdef CONFIG_BLK_DEV_IDE
379 { "hda", 0x0300 },
380 { "hdb", 0x0340 },
381 { "hdc", 0x1600 },
382 { "hdd", 0x1640 },
383 { "hde", 0x2100 },
384 { "hdf", 0x2140 },
385 { "hdg", 0x2200 },
386 { "hdh", 0x2240 },
387 #endif
388 #ifdef CONFIG_BLK_DEV_SD
389 { "sda", 0x0800 },
390 { "sdb", 0x0810 },
391 { "sdc", 0x0820 },
392 { "sdd", 0x0830 },
393 { "sde", 0x0840 },
394 { "sdf", 0x0850 },
395 { "sdg", 0x0860 },
396 { "sdh", 0x0870 },
397 { "sdi", 0x0880 },
398 { "sdj", 0x0890 },
399 { "sdk", 0x08a0 },
400 { "sdl", 0x08b0 },
401 { "sdm", 0x08c0 },
402 { "sdn", 0x08d0 },
403 { "sdo", 0x08e0 },
404 { "sdp", 0x08f0 },
405 #endif
406 #ifdef CONFIG_ATARI_ACSI
407 { "ada", 0x1c00 },
408 { "adb", 0x1c10 },
409 { "adc", 0x1c20 },
410 { "add", 0x1c30 },
411 { "ade", 0x1c40 },
412 #endif
413 #ifdef CONFIG_BLK_DEV_FD
414 { "fd", 0x0200 },
415 #endif
416 #ifdef CONFIG_MD_BOOT
417 { "md", 0x0900 },
418 #endif
419 #ifdef CONFIG_BLK_DEV_XD
420 { "xda", 0x0d00 },
421 { "xdb", 0x0d40 },
422 #endif
423 #ifdef CONFIG_BLK_DEV_RAM
424 { "ram", 0x0100 },
425 #endif
426 #ifdef CONFIG_BLK_DEV_SR
427 { "scd", 0x0b00 },
428 #endif
429 #ifdef CONFIG_MCD
430 { "mcd", 0x1700 },
431 #endif
432 #ifdef CONFIG_CDU535
433 { "cdu535", 0x1800 },
434 { "sonycd", 0x1800 },
435 #endif
436 #ifdef CONFIG_AZTCD
437 { "aztcd", 0x1d00 },
438 #endif
439 #ifdef CONFIG_CM206
440 { "cm206cd", 0x2000 },
441 #endif
442 #ifdef CONFIG_GSCD
443 { "gscd", 0x1000 },
444 #endif
445 #ifdef CONFIG_SBPCD
446 { "sbpcd", 0x1900 },
447 #endif
448 #ifdef CONFIG_BLK_DEV_PS2
449 { "eda", 0x2400 },
450 #endif
451 #ifdef CONFIG_PARIDE_PD
452 { "pda", 0x2d00 },
453 { "pdb", 0x2d10 },
454 { "pdc", 0x2d20 },
455 { "pdd", 0x2d30 },
456 #endif
457 #ifdef CONFIG_PARIDE_PCD
458 { "pcd", 0x2e00 },
459 #endif
460 #ifdef CONFIG_PARIDE_PF
461 { "pf", 0x2f00 },
462 #endif
463 #if CONFIG_APBLOCK
464 { "apblock", APBLOCK_MAJOR << 8},
465 #endif
466 #if CONFIG_DDV
467 { "ddv", DDV_MAJOR << 8},
468 #endif
469 { NULL, 0 }
472 kdev_t __init name_to_kdev_t(char *line)
474 int base = 0;
475 if (strncmp(line,"/dev/",5) == 0) {
476 struct dev_name_struct *dev = root_dev_names;
477 line += 5;
478 do {
479 int len = strlen(dev->name);
480 if (strncmp(line,dev->name,len) == 0) {
481 line += len;
482 base = dev->num;
483 break;
485 dev++;
486 } while (dev->name);
488 return to_kdev_t(base + simple_strtoul(line,NULL,base?10:16));
491 static void __init root_dev_setup(char *line, int *num)
493 ROOT_DEV = name_to_kdev_t(line);
497 * List of kernel command line parameters. The first table lists parameters
498 * which are subject to values parsing (leading numbers are converted to
499 * an array of ints and chopped off the string), the second table contains
500 * the few exceptions which obey their own syntax rules.
503 struct kernel_param {
504 const char *str;
505 void (*setup_func)(char *, int *);
508 static struct kernel_param cooked_params[] __initdata = {
509 /* FIXME: make PNP just become reserve_setup */
510 #ifndef CONFIG_KERNEL_PNP_RESOURCE
511 { "reserve=", reserve_setup },
512 #else
513 { "reserve=", pnp_reserve_setup },
514 #endif
515 { "profile=", profile_setup },
516 #ifdef __SMP__
517 { "nosmp", smp_setup },
518 { "maxcpus=", smp_setup },
519 #ifdef __i386__
520 { "pirq=", ioapic_pirq_setup },
521 #endif
522 #endif
523 #ifdef CONFIG_BLK_DEV_RAM
524 { "ramdisk_start=", ramdisk_start_setup },
525 { "load_ramdisk=", load_ramdisk },
526 { "prompt_ramdisk=", prompt_ramdisk },
527 { "ramdisk=", ramdisk_size },
528 { "ramdisk_size=", ramdisk_size },
529 #ifdef CONFIG_BLK_DEV_INITRD
530 { "noinitrd", no_initrd },
531 #endif
532 #endif
533 #ifdef CONFIG_FB
534 { "video=", video_setup },
535 #endif
536 { "panic=", panic_setup },
537 { "console=", console_setup },
538 #ifdef CONFIG_VT
539 #ifdef CONFIG_VGA_CONSOLE
540 { "no-scroll", no_scroll },
541 #endif
542 { "kbd-reset", kbd_reset_setup },
543 #endif
544 #ifdef CONFIG_BUGi386
545 { "no-hlt", no_halt },
546 { "no387", no_387 },
547 { "reboot=", reboot_setup },
548 #endif
549 #ifdef CONFIG_INET
550 { "ether=", eth_setup },
551 #endif
552 #ifdef CONFIG_ARCNET_COM20020
553 { "com20020=", com20020_setup },
554 #endif
555 #ifdef CONFIG_ARCNET_RIM_I
556 { "arcrimi=", arcrimi_setup },
557 #endif
558 #ifdef CONFIG_ARCNET_COM90xxIO
559 { "com90io=", com90io_setup },
560 #endif
561 #ifdef CONFIG_ARCNET_COM90xx
562 { "com90xx=", com90xx_setup },
563 #endif
564 #ifdef CONFIG_DECNET
565 { "decnet=", decnet_setup },
566 #endif
567 #ifdef CONFIG_PRINTER
568 { "lp=", lp_setup },
569 #endif
570 #ifdef CONFIG_JOYSTICK
571 { "js=", js_setup },
572 #endif
573 #ifdef CONFIG_SCSI
574 { "max_scsi_luns=", scsi_luns_setup },
575 { "scsi_logging=", scsi_logging_setup },
576 #endif
577 #ifdef CONFIG_SCSI_ADVANSYS
578 { "advansys=", advansys_setup },
579 #endif
580 #if defined(CONFIG_BLK_DEV_HD)
581 { "hd=", hd_setup },
582 #endif
583 #ifdef CONFIG_CHR_DEV_ST
584 { "st=", st_setup },
585 #endif
586 #ifdef CONFIG_BUSMOUSE
587 { "bmouse=", bmouse_setup },
588 #endif
589 #ifdef CONFIG_MS_BUSMOUSE
590 { "msmouse=", msmouse_setup },
591 #endif
592 #ifdef CONFIG_SCSI_SEAGATE
593 { "st0x=", st0x_setup },
594 { "tmc8xx=", tmc8xx_setup },
595 #endif
596 #ifdef CONFIG_SCSI_T128
597 { "t128=", t128_setup },
598 #endif
599 #ifdef CONFIG_SCSI_PAS16
600 { "pas16=", pas16_setup },
601 #endif
602 #ifdef CONFIG_SCSI_GENERIC_NCR5380
603 { "ncr5380=", generic_NCR5380_setup },
604 { "ncr53c400=", generic_NCR53C400_setup },
605 { "ncr53c400a=", generic_NCR53C400A_setup },
606 { "dtc3181e=", generic_DTC3181E_setup },
607 #endif
608 #ifdef CONFIG_SCSI_AHA152X
609 { "aha152x=", aha152x_setup},
610 #endif
611 #ifdef CONFIG_SCSI_AHA1542
612 { "aha1542=", aha1542_setup},
613 #endif
614 #ifdef CONFIG_SCSI_GDTH
615 { "gdth=", gdth_setup},
616 #endif
617 #ifdef CONFIG_SCSI_AIC7XXX
618 { "aic7xxx=", aic7xxx_setup},
619 #endif
620 #ifdef CONFIG_SCSI_BUSLOGIC
621 { "BusLogic=", BusLogic_Setup},
622 #endif
623 #ifdef CONFIG_SCSI_NCR53C8XX
624 { "ncr53c8xx=", ncr53c8xx_setup},
625 #endif
626 #ifdef CONFIG_SCSI_EATA
627 { "eata=", eata2x_setup},
628 #endif
629 #ifdef CONFIG_SCSI_U14_34F
630 { "u14-34f=", u14_34f_setup},
631 #endif
632 #ifdef CONFIG_SCSI_AM53C974
633 { "AM53C974=", AM53C974_setup},
634 #endif
635 #ifdef CONFIG_SCSI_NCR53C406A
636 { "ncr53c406a=", NCR53c406a_setup},
637 #endif
638 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
639 { "fdomain=", fdomain_setup},
640 #endif
641 #ifdef CONFIG_SCSI_IN2000
642 { "in2000=", in2000_setup},
643 #endif
644 #ifdef CONFIG_SCSI_7000FASST
645 { "wd7000=", wd7000_setup},
646 #endif
647 #ifdef CONFIG_SCSI_IBMMCA
648 { "ibmmcascsi=", ibmmca_scsi_setup },
649 #endif
650 #ifdef CONFIG_BLK_DEV_XD
651 { "xd=", xd_setup },
652 { "xd_geo=", xd_manual_geo_init },
653 #endif
654 #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
655 { "floppy=", floppy_setup },
656 #endif
657 #ifdef CONFIG_BLK_DEV_PS2
658 { "ed=", ed_setup },
659 { "tp720=", tp720_setup },
660 #endif
661 #ifdef CONFIG_CDU31A
662 { "cdu31a=", cdu31a_setup },
663 #endif CONFIG_CDU31A
664 #ifdef CONFIG_MCD
665 { "mcd=", mcd_setup },
666 #endif CONFIG_MCD
667 #ifdef CONFIG_MCDX
668 { "mcdx=", mcdx_setup },
669 #endif CONFIG_MCDX
670 #ifdef CONFIG_SBPCD
671 { "sbpcd=", sbpcd_setup },
672 #endif CONFIG_SBPCD
673 #ifdef CONFIG_AZTCD
674 { "aztcd=", aztcd_setup },
675 #endif CONFIG_AZTCD
676 #ifdef CONFIG_CDU535
677 { "sonycd535=", sonycd535_setup },
678 #endif CONFIG_CDU535
679 #ifdef CONFIG_GSCD
680 { "gscd=", gscd_setup },
681 #endif CONFIG_GSCD
682 #ifdef CONFIG_CM206
683 { "cm206=", cm206_setup },
684 #endif CONFIG_CM206
685 #ifdef CONFIG_OPTCD
686 { "optcd=", optcd_setup },
687 #endif CONFIG_OPTCD
688 #ifdef CONFIG_SJCD
689 { "sjcd=", sjcd_setup },
690 #endif CONFIG_SJCD
691 #ifdef CONFIG_ISP16_CDI
692 { "isp16=", isp16_setup },
693 #endif CONFIG_ISP16_CDI
694 #ifdef CONFIG_SOUND_OSS
695 { "sound=", sound_setup },
696 #endif
697 #ifdef CONFIG_ISDN_DRV_ICN
698 { "icn=", icn_setup },
699 #endif
700 #ifdef CONFIG_ISDN_DRV_HISAX
701 { "hisax=", HiSax_setup },
702 { "HiSax=", HiSax_setup },
703 #endif
704 #ifdef CONFIG_ISDN_DRV_PCBIT
705 { "pcbit=", pcbit_setup },
706 #endif
707 #ifdef CONFIG_ATARIMOUSE
708 { "atamouse=", atari_mouse_setup },
709 #endif
710 #ifdef CONFIG_DMASOUND
711 { "dmasound=", dmasound_setup },
712 #endif
713 #ifdef CONFIG_ATARI_SCSI
714 { "atascsi=", atari_scsi_setup },
715 #endif
716 #ifdef CONFIG_STRAM_SWAP
717 { "stram_swap=", stram_swap_setup },
718 #endif
719 #if defined(CONFIG_A4000T_SCSI) || defined(CONFIG_WARPENGINE_SCSI) \
720 || defined(CONFIG_A4091_SCSI) || defined(CONFIG_MVME16x_SCSI) \
721 || defined(CONFIG_BVME6000_SCSI)
722 { "53c7xx=", ncr53c7xx_setup },
723 #endif
724 #if defined(CONFIG_A3000_SCSI) || defined(CONFIG_A2091_SCSI) \
725 || defined(CONFIG_GVP11_SCSI)
726 { "wd33c93=", wd33c93_setup },
727 #endif
728 #if defined(CONFIG_GVP11_SCSI)
729 { "gvp11=", gvp11_setup },
730 #endif
731 #ifdef CONFIG_MAC_SCSI
732 { "mac5380=", mac_scsi_setup },
733 #endif
734 #ifdef CONFIG_CYCLADES
735 { "cyclades=", cy_setup },
736 #endif
737 #ifdef CONFIG_DIGI
738 { "digi=", pcxx_setup },
739 #endif
740 #ifdef CONFIG_DIGIEPCA
741 { "digiepca=", epca_setup },
742 #endif
743 #ifdef CONFIG_RISCOM8
744 { "riscom8=", riscom8_setup },
745 #endif
746 #ifdef CONFIG_DMASCC
747 { "dmascc=", dmascc_setup },
748 #endif
749 #ifdef CONFIG_SPECIALIX
750 { "specialix=", specialix_setup },
751 #endif
752 #ifdef CONFIG_BAYCOM_PAR
753 { "baycom_par=", baycom_par_setup },
754 #endif
755 #ifdef CONFIG_BAYCOM_SER_FDX
756 { "baycom_ser_fdx=", baycom_ser_fdx_setup },
757 #endif
758 #ifdef CONFIG_BAYCOM_SER_HDX
759 { "baycom_ser_hdx=", baycom_ser_hdx_setup },
760 #endif
761 #ifdef CONFIG_SOUNDMODEM
762 { "soundmodem=", sm_setup },
763 #endif
764 #ifdef CONFIG_WDT
765 { "wdt=", wdt_setup },
766 #endif
767 #ifdef CONFIG_PARPORT
768 { "parport=", parport_setup },
769 #endif
770 #ifdef CONFIG_PLIP
771 { "plip=", plip_setup },
772 #endif
773 #ifdef CONFIG_HFMODEM
774 { "hfmodem=", hfmodem_setup },
775 #endif
776 #ifdef CONFIG_FTAPE
777 { "ftape=", ftape_setup},
778 #endif
779 #ifdef CONFIG_MD_BOOT
780 { "md=", md_setup},
781 #endif
782 #ifdef CONFIG_MACMOUSE
783 { "adb_buttons=", adb_mouse_setup },
784 #endif
785 { 0, 0 }
788 static struct kernel_param raw_params[] __initdata = {
789 { "root=", root_dev_setup },
790 #ifdef CONFIG_ROOT_NFS
791 { "nfsroot=", nfs_root_setup },
792 { "nfsaddrs=", ip_auto_config_setup },
793 #endif
794 #ifdef CONFIG_IP_PNP
795 { "ip=", ip_auto_config_setup },
796 #endif
797 #ifdef CONFIG_PCI
798 { "pci=", pci_setup },
799 #endif
800 #ifdef CONFIG_PARIDE_PD
801 { "pd.", pd_setup },
802 #endif
803 #ifdef CONFIG_PARIDE_PCD
804 { "pcd.", pcd_setup },
805 #endif
806 #ifdef CONFIG_PARIDE_PF
807 { "pf.", pf_setup },
808 #endif
809 #ifdef CONFIG_PARIDE_PT
810 { "pt.", pt_setup },
811 #endif
812 #ifdef CONFIG_PARIDE_PG
813 { "pg.", pg_setup },
814 #endif
815 { 0, 0 }
818 #ifdef CONFIG_BLK_DEV_RAM
819 static void __init ramdisk_start_setup(char *str, int *ints)
821 if (ints[0] > 0 && ints[1] >= 0)
822 rd_image_start = ints[1];
825 static void __init load_ramdisk(char *str, int *ints)
827 if (ints[0] > 0 && ints[1] >= 0)
828 rd_doload = ints[1] & 1;
831 static void __init prompt_ramdisk(char *str, int *ints)
833 if (ints[0] > 0 && ints[1] >= 0)
834 rd_prompt = ints[1] & 1;
837 static void __init ramdisk_size(char *str, int *ints)
839 if (ints[0] > 0 && ints[1] >= 0)
840 rd_size = ints[1];
842 #endif
844 static int __init checksetup(char *line)
846 int i, ints[11];
848 #ifdef CONFIG_BLK_DEV_IDE
849 /* ide driver needs the basic string, rather than pre-processed values */
850 if (!strncmp(line,"ide",3) || (!strncmp(line,"hd",2) && line[2] != '=')) {
851 ide_setup(line);
852 return 1;
854 #endif
855 for (i=0; raw_params[i].str; i++) {
856 int n = strlen(raw_params[i].str);
857 if (!strncmp(line,raw_params[i].str,n)) {
858 raw_params[i].setup_func(line+n, NULL);
859 return 1;
862 for (i=0; cooked_params[i].str; i++) {
863 int n = strlen(cooked_params[i].str);
864 if (!strncmp(line,cooked_params[i].str,n)) {
865 cooked_params[i].setup_func(get_options(line+n, ints), ints);
866 return 1;
869 return 0;
872 /* this should be approx 2 Bo*oMips to start (note initial shift), and will
873 still work even if initially too large, it will just take slightly longer */
874 unsigned long loops_per_sec = (1<<12);
876 /* This is the number of bits of precision for the loops_per_second. Each
877 bit takes on average 1.5/HZ seconds. This (like the original) is a little
878 better than 1% */
879 #define LPS_PREC 8
881 void __init calibrate_delay(void)
883 unsigned long ticks, loopbit;
884 int lps_precision = LPS_PREC;
886 loops_per_sec = (1<<12);
888 printk("Calibrating delay loop... ");
889 while (loops_per_sec <<= 1) {
890 /* wait for "start of" clock tick */
891 ticks = jiffies;
892 while (ticks == jiffies)
893 /* nothing */;
894 /* Go .. */
895 ticks = jiffies;
896 __delay(loops_per_sec);
897 ticks = jiffies - ticks;
898 if (ticks)
899 break;
902 /* Do a binary approximation to get loops_per_second set to equal one clock
903 (up to lps_precision bits) */
904 loops_per_sec >>= 1;
905 loopbit = loops_per_sec;
906 while ( lps_precision-- && (loopbit >>= 1) ) {
907 loops_per_sec |= loopbit;
908 ticks = jiffies;
909 while (ticks == jiffies);
910 ticks = jiffies;
911 __delay(loops_per_sec);
912 if (jiffies != ticks) /* longer than 1 tick */
913 loops_per_sec &= ~loopbit;
916 /* finally, adjust loops per second in terms of seconds instead of clocks */
917 loops_per_sec *= HZ;
918 /* Round the value and print it */
919 printk("%lu.%02lu BogoMIPS\n",
920 (loops_per_sec+2500)/500000,
921 ((loops_per_sec+2500)/5000) % 100);
925 * This is a simple kernel command line parsing function: it parses
926 * the command line, and fills in the arguments/environment to init
927 * as appropriate. Any cmd-line option is taken to be an environment
928 * variable if it contains the character '='.
930 * This routine also checks for options meant for the kernel.
931 * These options are not given to init - they are for internal kernel use only.
933 static void __init parse_options(char *line)
935 char *next;
936 int args, envs;
938 if (!*line)
939 return;
940 args = 0;
941 envs = 1; /* TERM is set to 'linux' by default */
942 next = line;
943 while ((line = next) != NULL) {
944 if ((next = strchr(line,' ')) != NULL)
945 *next++ = 0;
947 * check for kernel options first..
949 if (!strcmp(line,"ro")) {
950 root_mountflags |= MS_RDONLY;
951 continue;
953 if (!strcmp(line,"rw")) {
954 root_mountflags &= ~MS_RDONLY;
955 continue;
957 if (!strcmp(line,"debug")) {
958 console_loglevel = 10;
959 continue;
961 if (!strncmp(line,"init=",5)) {
962 line += 5;
963 execute_command = line;
964 /* In case LILO is going to boot us with default command line,
965 * it prepends "auto" before the whole cmdline which makes
966 * the shell think it should execute a script with such name.
967 * So we ignore all arguments entered _before_ init=... [MJ]
969 args = 0;
970 continue;
972 if (checksetup(line))
973 continue;
976 * Then check if it's an environment variable or
977 * an option.
979 if (strchr(line,'=')) {
980 if (envs >= MAX_INIT_ENVS)
981 break;
982 envp_init[++envs] = line;
983 } else {
984 if (args >= MAX_INIT_ARGS)
985 break;
986 argv_init[++args] = line;
989 argv_init[args+1] = NULL;
990 envp_init[envs+1] = NULL;
994 extern void setup_arch(char **, unsigned long *, unsigned long *);
996 #ifndef __SMP__
999 * Uniprocessor idle thread
1002 int cpu_idle(void *unused)
1004 for(;;)
1005 idle();
1008 #else
1011 * Multiprocessor idle thread is in arch/...
1014 extern int cpu_idle(void * unused);
1016 /* Called by boot processor to activate the rest. */
1017 static void __init smp_init(void)
1019 /* Get other processors into their bootup holding patterns. */
1020 smp_boot_cpus();
1024 * The autoprobe routines assume CPU#0 on the i386
1025 * so we don't actually set the game in motion until
1026 * they are finished.
1029 static void __init smp_begin(void)
1031 smp_threads_ready=1;
1032 smp_commence();
1035 #endif
1037 extern void initialize_secondary(void);
1040 * Activate the first processor.
1043 asmlinkage void __init start_kernel(void)
1045 char * command_line;
1047 #ifdef __SMP__
1048 static int boot_cpu = 1;
1049 /* "current" has been set up, we need to load it now */
1050 if (!boot_cpu)
1051 initialize_secondary();
1052 boot_cpu = 0;
1053 #endif
1056 * Interrupts are still disabled. Do necessary setups, then
1057 * enable them
1059 printk(linux_banner);
1060 setup_arch(&command_line, &memory_start, &memory_end);
1061 memory_start = paging_init(memory_start,memory_end);
1062 trap_init();
1063 init_IRQ();
1064 sched_init();
1065 time_init();
1066 parse_options(command_line);
1069 * HACK ALERT! This is early. We're enabling the console before
1070 * we've done PCI setups etc, and console_init() must be aware of
1071 * this. But we do want output early, in case something goes wrong.
1073 memory_start = console_init(memory_start,memory_end);
1074 #ifdef CONFIG_MODULES
1075 init_modules();
1076 #endif
1077 if (prof_shift) {
1078 prof_buffer = (unsigned int *) memory_start;
1079 /* only text is profiled */
1080 prof_len = (unsigned long) &_etext - (unsigned long) &_stext;
1081 prof_len >>= prof_shift;
1082 memory_start += prof_len * sizeof(unsigned int);
1083 memset(prof_buffer, 0, prof_len * sizeof(unsigned int));
1086 memory_start = kmem_cache_init(memory_start, memory_end);
1087 sti();
1088 calibrate_delay();
1089 #ifdef CONFIG_BLK_DEV_INITRD
1090 if (initrd_start && !initrd_below_start_ok && initrd_start < memory_start) {
1091 printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - "
1092 "disabling it.\n",initrd_start,memory_start);
1093 initrd_start = 0;
1095 #endif
1096 mem_init(memory_start,memory_end);
1097 kmem_cache_sizes_init();
1098 #ifdef CONFIG_PROC_FS
1099 proc_root_init();
1100 #endif
1101 uidcache_init();
1102 filescache_init();
1103 dcache_init();
1104 vma_init();
1105 buffer_init();
1106 signals_init();
1107 inode_init();
1108 file_table_init();
1109 #if defined(CONFIG_SYSVIPC)
1110 ipc_init();
1111 #endif
1112 #if defined(CONFIG_QUOTA)
1113 dquot_init_hash();
1114 #endif
1115 printk("POSIX conformance testing by UNIFIX\n");
1117 #ifdef __SMP__
1118 smp_init();
1119 #endif
1121 check_bugs();
1123 #if defined(CONFIG_MTRR) /* Do this after SMP initialization */
1125 * We should probably create some architecture-dependent "fixup after
1126 * everything is up" style function where this would belong better
1127 * than in init/main.c..
1129 mtrr_init ();
1130 #endif
1132 sock_init();
1133 #ifdef CONFIG_SYSCTL
1134 sysctl_init();
1135 #endif
1136 #ifdef CONFIG_DIO
1137 dio_init();
1138 #endif
1141 * Ok, at this point all CPU's should be initialized, so
1142 * we can start looking into devices..
1144 #ifdef CONFIG_PCI
1145 pci_init();
1146 #endif
1147 #ifdef CONFIG_SBUS
1148 sbus_init();
1149 #endif
1150 #if defined(CONFIG_PMAC) || defined(CONFIG_CHRP)
1151 powermac_init();
1152 #endif
1153 #ifdef CONFIG_MCA
1154 mca_init();
1155 #endif
1156 #ifdef CONFIG_ARCH_ACORN
1157 ecard_init();
1158 #endif
1161 * We count on the initial thread going ok
1162 * Like idlers init is an unlocked kernel thread, which will
1163 * make syscalls (and thus be locked).
1165 kernel_thread(init, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1167 * task[0] is meant to be used as an "idle" task: it may not sleep, but
1168 * it might do some general things like count free pages or it could be
1169 * used to implement a reasonable LRU algorithm for the paging routines:
1170 * anything that can be useful, but shouldn't take time from the real
1171 * processes.
1173 * Right now task[0] just does an infinite idle loop.
1175 cpu_idle(NULL);
1178 #ifdef CONFIG_BLK_DEV_INITRD
1179 static int do_linuxrc(void * shell)
1181 static char *argv[] = { "linuxrc", NULL, };
1183 close(0);close(1);close(2);
1184 setsid();
1185 (void) open("/dev/console",O_RDWR,0);
1186 (void) dup(0);
1187 (void) dup(0);
1188 return execve(shell, argv, envp_init);
1191 static void __init no_initrd(char *s,int *ints)
1193 mount_initrd = 0;
1195 #endif
1197 static int init(void * unused)
1199 #ifdef CONFIG_BLK_DEV_INITRD
1200 int real_root_mountflags;
1201 #endif
1203 /* Launch bdflush from here, instead of the old syscall way. */
1204 kernel_thread(bdflush, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1205 /* Start the background pageout daemon. */
1206 kswapd_setup();
1207 kernel_thread(kswapd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1209 #if CONFIG_AP1000
1210 /* Start the async paging daemon. */
1212 extern int asyncd(void *);
1213 kernel_thread(asyncd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1215 #endif
1217 #ifdef CONFIG_BLK_DEV_INITRD
1218 real_root_dev = ROOT_DEV;
1219 real_root_mountflags = root_mountflags;
1220 if (initrd_start && mount_initrd) root_mountflags &= ~MS_RDONLY;
1221 else mount_initrd =0;
1222 #endif
1223 setup(0);
1225 #ifdef __SMP__
1227 * With the devices probed and setup we can
1228 * now enter SMP mode.
1231 smp_begin();
1232 #endif
1234 #ifdef CONFIG_UMSDOS_FS
1237 When mounting a umsdos fs as root, we detect
1238 the pseudo_root (/linux) and initialise it here.
1239 pseudo_root is defined in fs/umsdos/inode.c
1241 extern struct inode *pseudo_root;
1242 if (pseudo_root != NULL){
1243 current->fs->root = pseudo_root;
1244 current->fs->pwd = pseudo_root;
1247 #endif
1249 #ifdef CONFIG_BLK_DEV_INITRD
1250 root_mountflags = real_root_mountflags;
1251 if (mount_initrd && ROOT_DEV != real_root_dev
1252 && MAJOR(ROOT_DEV) == RAMDISK_MAJOR && MINOR(ROOT_DEV) == 0) {
1253 int error;
1254 int i, pid;
1256 pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
1257 if (pid>0)
1258 while (pid != wait(&i));
1259 if (MAJOR(real_root_dev) != RAMDISK_MAJOR
1260 || MINOR(real_root_dev) != 0) {
1261 error = change_root(real_root_dev,"/initrd");
1262 if (error)
1263 printk(KERN_ERR "Change root to /initrd: "
1264 "error %d\n",error);
1267 #endif
1269 setup(1);
1271 if (open("/dev/console", O_RDWR, 0) < 0)
1272 printk("Warning: unable to open an initial console.\n");
1274 (void) dup(0);
1275 (void) dup(0);
1278 * We try each of these until one succeeds.
1280 * The Bourne shell can be used instead of init if we are
1281 * trying to recover a really broken machine.
1284 if (execute_command)
1285 execve(execute_command,argv_init,envp_init);
1286 execve("/sbin/init",argv_init,envp_init);
1287 execve("/etc/init",argv_init,envp_init);
1288 execve("/bin/init",argv_init,envp_init);
1289 execve("/bin/sh",argv_init,envp_init);
1290 panic("No init found. Try passing init= option to kernel.");