2.2.0-final
[davej-history.git] / init / main.c
blobaea2ca978463a078a11197e165d7a484e35f6329
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/config.h>
15 #include <linux/proc_fs.h>
16 #include <linux/unistd.h>
17 #include <linux/ctype.h>
18 #include <linux/delay.h>
19 #include <linux/utsname.h>
20 #include <linux/ioport.h>
21 #include <linux/init.h>
22 #include <linux/smp_lock.h>
23 #include <linux/blk.h>
24 #include <linux/hdreg.h>
26 #include <asm/io.h>
27 #include <asm/bugs.h>
29 #ifdef CONFIG_PCI
30 #include <linux/pci.h>
31 #endif
33 #ifdef CONFIG_DIO
34 #include <linux/dio.h>
35 #endif
37 #ifdef CONFIG_ZORRO
38 #include <linux/zorro.h>
39 #endif
41 #ifdef CONFIG_MTRR
42 # include <asm/mtrr.h>
43 #endif
45 #ifdef CONFIG_APM
46 #include <linux/apm_bios.h>
47 #endif
50 * Versions of gcc older than that listed below may actually compile
51 * and link okay, but the end product can have subtle run time bugs.
52 * To avoid associated bogus bug reports, we flatly refuse to compile
53 * with a gcc that is known to be too old from the very beginning.
55 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
56 #error sorry, your GCC is too old. It builds incorrect kernels.
57 #endif
59 extern char _stext, _etext;
60 extern char *linux_banner;
62 extern int console_loglevel;
64 static int init(void *);
65 extern int bdflush(void *);
66 extern int kswapd(void *);
67 extern void kswapd_setup(void);
69 extern void init_IRQ(void);
70 extern void init_modules(void);
71 extern long console_init(long, long);
72 extern void sock_init(void);
73 extern void uidcache_init(void);
74 extern void mca_init(void);
75 extern void sbus_init(void);
76 extern void powermac_init(void);
77 extern void sysctl_init(void);
78 extern void filescache_init(void);
79 extern void signals_init(void);
81 extern void device_setup(void);
82 extern void binfmt_setup(void);
83 extern void free_initmem(void);
84 extern void filesystem_setup(void);
86 #ifdef CONFIG_ARCH_ACORN
87 extern void ecard_init(void);
88 #endif
90 extern void smp_setup(char *str, int *ints);
91 #ifdef __i386__
92 extern void ioapic_pirq_setup(char *str, int *ints);
93 extern void ioapic_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_JOY_AMIGA
105 extern void js_am_setup(char *str, int *ints);
106 #endif
107 #ifdef CONFIG_JOY_ANALOG
108 extern void js_an_setup(char *str, int *ints);
109 #endif
110 #ifdef CONFIG_JOY_ASSASIN
111 extern void js_as_setup(char *str, int *ints);
112 #endif
113 #ifdef CONFIG_JOY_CONSOLE
114 extern void js_console_setup(char *str, int *ints);
115 #endif
116 #ifdef CONFIG_JOY_DB9
117 extern void js_db9_setup(char *str, int *ints);
118 #endif
119 #ifdef CONFIG_JOY_TURBOGRAFX
120 extern void js_tg_setup(char *str, int *ints);
121 #endif
122 #ifdef CONFIG_JOY_LIGHTNING
123 extern void js_l4_setup(char *str, int *ints);
124 #endif
125 extern void eth_setup(char *str, int *ints);
126 #ifdef CONFIG_ARCNET_COM20020
127 extern void com20020_setup(char *str, int *ints);
128 #endif
129 #ifdef CONFIG_ARCNET_RIM_I
130 extern void arcrimi_setup(char *str, int *ints);
131 #endif
132 #ifdef CONFIG_ARCNET_COM90xxIO
133 extern void com90io_setup(char *str, int *ints);
134 #endif
135 #ifdef CONFIG_ARCNET_COM90xx
136 extern void com90xx_setup(char *str, int *ints);
137 #endif
138 #ifdef CONFIG_DECNET
139 extern void decnet_setup(char *str, int *ints);
140 #endif
141 #ifdef CONFIG_BLK_DEV_XD
142 extern void xd_setup(char *str, int *ints);
143 extern void xd_manual_geo_init(char *str, int *ints);
144 #endif
145 #ifdef CONFIG_BLK_DEV_IDE
146 extern void ide_setup(char *);
147 #endif
148 #ifdef CONFIG_PARIDE_PD
149 extern void pd_setup(char *str, int *ints);
150 #endif
151 #ifdef CONFIG_PARIDE_PF
152 extern void pf_setup(char *str, int *ints);
153 #endif
154 #ifdef CONFIG_PARIDE_PT
155 extern void pt_setup(char *str, int *ints);
156 #endif
157 #ifdef CONFIG_PARIDE_PG
158 extern void pg_setup(char *str, int *ints);
159 #endif
160 #ifdef CONFIG_PARIDE_PCD
161 extern void pcd_setup(char *str, int *ints);
162 #endif
163 extern void floppy_setup(char *str, int *ints);
164 extern void st_setup(char *str, int *ints);
165 extern void st0x_setup(char *str, int *ints);
166 extern void advansys_setup(char *str, int *ints);
167 extern void tmc8xx_setup(char *str, int *ints);
168 extern void t128_setup(char *str, int *ints);
169 extern void pas16_setup(char *str, int *ints);
170 extern void generic_NCR5380_setup(char *str, int *intr);
171 extern void generic_NCR53C400_setup(char *str, int *intr);
172 extern void generic_NCR53C400A_setup(char *str, int *intr);
173 extern void generic_DTC3181E_setup(char *str, int *intr);
174 extern void aha152x_setup(char *str, int *ints);
175 extern void aha1542_setup(char *str, int *ints);
176 extern void gdth_setup(char *str, int *ints);
177 extern void aic7xxx_setup(char *str, int *ints);
178 extern void AM53C974_setup(char *str, int *ints);
179 extern void BusLogic_Setup(char *str, int *ints);
180 extern void ncr53c8xx_setup(char *str, int *ints);
181 extern void eata2x_setup(char *str, int *ints);
182 extern void u14_34f_setup(char *str, int *ints);
183 extern void fdomain_setup(char *str, int *ints);
184 extern void ibmmca_scsi_setup(char *str, int *ints);
185 extern void in2000_setup(char *str, int *ints);
186 extern void NCR53c406a_setup(char *str, int *ints);
187 extern void wd7000_setup(char *str, int *ints);
188 extern void dc390_setup(char* str, int *ints);
189 extern void scsi_luns_setup(char *str, int *ints);
190 extern void scsi_logging_setup(char *str, int *ints);
191 extern void sound_setup(char *str, int *ints);
192 extern void reboot_setup(char *str, int *ints);
193 extern void video_setup(char *str, int *ints);
194 #ifdef CONFIG_CDU31A
195 extern void cdu31a_setup(char *str, int *ints);
196 #endif CONFIG_CDU31A
197 #ifdef CONFIG_BLK_DEV_PS2
198 extern void ed_setup(char *str, int *ints);
199 extern void tp720_setup(char *str, int *ints);
200 #endif CONFIG_BLK_DEV_PS2
201 #ifdef CONFIG_MCD
202 extern void mcd_setup(char *str, int *ints);
203 #endif CONFIG_MCD
204 #ifdef CONFIG_MCDX
205 extern void mcdx_setup(char *str, int *ints);
206 #endif CONFIG_MCDX
207 #ifdef CONFIG_SBPCD
208 extern void sbpcd_setup(char *str, int *ints);
209 #endif CONFIG_SBPCD
210 #ifdef CONFIG_AZTCD
211 extern void aztcd_setup(char *str, int *ints);
212 #endif CONFIG_AZTCD
213 #ifdef CONFIG_CDU535
214 extern void sonycd535_setup(char *str, int *ints);
215 #endif CONFIG_CDU535
216 #ifdef CONFIG_GSCD
217 extern void gscd_setup(char *str, int *ints);
218 #endif CONFIG_GSCD
219 #ifdef CONFIG_CM206
220 extern void cm206_setup(char *str, int *ints);
221 #endif CONFIG_CM206
222 #ifdef CONFIG_OPTCD
223 extern void optcd_setup(char *str, int *ints);
224 #endif CONFIG_OPTCD
225 #ifdef CONFIG_SJCD
226 extern void sjcd_setup(char *str, int *ints);
227 #endif CONFIG_SJCD
228 #ifdef CONFIG_ISP16_CDI
229 extern void isp16_setup(char *str, int *ints);
230 #endif CONFIG_ISP16_CDI
231 #ifdef CONFIG_BLK_DEV_RAM
232 static void ramdisk_start_setup(char *str, int *ints);
233 static void load_ramdisk(char *str, int *ints);
234 static void prompt_ramdisk(char *str, int *ints);
235 static void ramdisk_size(char *str, int *ints);
236 #ifdef CONFIG_BLK_DEV_INITRD
237 static void no_initrd(char *s,int *ints);
238 #endif
239 #endif CONFIG_BLK_DEV_RAM
240 #ifdef CONFIG_ISDN_DRV_ICN
241 extern void icn_setup(char *str, int *ints);
242 #endif
243 #ifdef CONFIG_ISDN_DRV_HISAX
244 extern void HiSax_setup(char *str, int *ints);
245 #endif
246 #ifdef CONFIG_DIGIEPCA
247 extern void epca_setup(char *str, int *ints);
248 #endif
249 #ifdef CONFIG_ISDN_DRV_PCBIT
250 extern void pcbit_setup(char *str, int *ints);
251 #endif
253 #ifdef CONFIG_ATARIMOUSE
254 extern void atari_mouse_setup (char *str, int *ints);
255 #endif
256 #ifdef CONFIG_DMASOUND
257 extern void dmasound_setup (char *str, int *ints);
258 #endif
259 #ifdef CONFIG_ATARI_SCSI
260 extern void atari_scsi_setup (char *str, int *ints);
261 #endif
262 extern void stram_swap_setup (char *str, int *ints);
263 extern void wd33c93_setup (char *str, int *ints);
264 extern void gvp11_setup (char *str, int *ints);
265 extern void ncr53c7xx_setup (char *str, int *ints);
266 #ifdef CONFIG_MAC_SCSI
267 extern void mac_scsi_setup (char *str, int *ints);
268 #endif
270 #ifdef CONFIG_CYCLADES
271 extern void cy_setup(char *str, int *ints);
272 #endif
273 #ifdef CONFIG_DIGI
274 extern void pcxx_setup(char *str, int *ints);
275 #endif
276 #ifdef CONFIG_RISCOM8
277 extern void riscom8_setup(char *str, int *ints);
278 #endif
279 #ifdef CONFIG_SPECIALIX
280 extern void specialix_setup(char *str, int *ints);
281 #endif
282 #ifdef CONFIG_DMASCC
283 extern void dmascc_setup(char *str, int *ints);
284 #endif
285 #ifdef CONFIG_BAYCOM_PAR
286 extern void baycom_par_setup(char *str, int *ints);
287 #endif
288 #ifdef CONFIG_BAYCOM_SER_FDX
289 extern void baycom_ser_fdx_setup(char *str, int *ints);
290 #endif
291 #ifdef CONFIG_BAYCOM_SER_HDX
292 extern void baycom_ser_hdx_setup(char *str, int *ints);
293 #endif
294 #ifdef CONFIG_SOUNDMODEM
295 extern void sm_setup(char *str, int *ints);
296 #endif
297 #ifdef CONFIG_ADBMOUSE
298 extern void adb_mouse_setup(char *str, int *ints);
299 #endif
300 #ifdef CONFIG_WDT
301 extern void wdt_setup(char *str, int *ints);
302 #endif
303 #ifdef CONFIG_PARPORT
304 extern void parport_setup(char *str, int *ints);
305 #endif
306 #ifdef CONFIG_PLIP
307 extern void plip_setup(char *str, int *ints);
308 #endif
309 #ifdef CONFIG_HFMODEM
310 extern void hfmodem_setup(char *str, int *ints);
311 #endif
312 #ifdef CONFIG_IP_PNP
313 extern void ip_auto_config_setup(char *str, int *ints);
314 #endif
315 #ifdef CONFIG_ROOT_NFS
316 extern void nfs_root_setup(char *str, int *ints);
317 #endif
318 #ifdef CONFIG_FTAPE
319 extern void ftape_setup(char *str, int *ints);
320 #endif
321 #ifdef CONFIG_MDA_CONSOLE
322 extern void mdacon_setup(char *str, int *ints);
323 #endif
324 #ifdef CONFIG_LTPC
325 extern void ltpc_setup(char *str, int *ints);
326 #endif
328 #if defined(CONFIG_SYSVIPC)
329 extern void ipc_init(void);
330 #endif
331 #if defined(CONFIG_QUOTA)
332 extern void dquot_init_hash(void);
333 #endif
335 #ifdef CONFIG_MD_BOOT
336 extern void md_setup(char *str,int *ints) __init;
337 #endif
340 * Boot command-line arguments
342 #define MAX_INIT_ARGS 8
343 #define MAX_INIT_ENVS 8
345 extern void time_init(void);
347 static unsigned long memory_start = 0;
348 static unsigned long memory_end = 0;
350 int rows, cols;
352 #ifdef CONFIG_BLK_DEV_RAM
353 extern int rd_doload; /* 1 = load ramdisk, 0 = don't load */
354 extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */
355 extern int rd_size; /* Size of the ramdisk(s) */
356 extern int rd_image_start; /* starting block # of image */
357 #ifdef CONFIG_BLK_DEV_INITRD
358 kdev_t real_root_dev;
359 #endif
360 #endif
362 int root_mountflags = MS_RDONLY;
363 char *execute_command = NULL;
365 static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
366 static char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
368 char *get_options(char *str, int *ints)
370 char *cur = str;
371 int i=1;
373 while (cur && (*cur=='-' || isdigit(*cur)) && i <= 10) {
374 ints[i++] = simple_strtol(cur,NULL,0);
375 if ((cur = strchr(cur,',')) != NULL)
376 cur++;
378 ints[0] = i-1;
379 return(cur);
382 static void __init profile_setup(char *str, int *ints)
384 if (ints[0] > 0)
385 prof_shift = (unsigned long) ints[1];
386 else
387 prof_shift = 2;
391 static struct dev_name_struct {
392 const char *name;
393 const int num;
394 } root_dev_names[] __initdata = {
395 #ifdef CONFIG_ROOT_NFS
396 { "nfs", 0x00ff },
397 #endif
398 #ifdef CONFIG_BLK_DEV_IDE
399 { "hda", 0x0300 },
400 { "hdb", 0x0340 },
401 { "hdc", 0x1600 },
402 { "hdd", 0x1640 },
403 { "hde", 0x2100 },
404 { "hdf", 0x2140 },
405 { "hdg", 0x2200 },
406 { "hdh", 0x2240 },
407 { "hdi", 0x3800 },
408 { "hdj", 0x3840 },
409 { "hdk", 0x3900 },
410 { "hdl", 0x3940 },
411 #endif
412 #ifdef CONFIG_BLK_DEV_SD
413 { "sda", 0x0800 },
414 { "sdb", 0x0810 },
415 { "sdc", 0x0820 },
416 { "sdd", 0x0830 },
417 { "sde", 0x0840 },
418 { "sdf", 0x0850 },
419 { "sdg", 0x0860 },
420 { "sdh", 0x0870 },
421 { "sdi", 0x0880 },
422 { "sdj", 0x0890 },
423 { "sdk", 0x08a0 },
424 { "sdl", 0x08b0 },
425 { "sdm", 0x08c0 },
426 { "sdn", 0x08d0 },
427 { "sdo", 0x08e0 },
428 { "sdp", 0x08f0 },
429 #endif
430 #ifdef CONFIG_ATARI_ACSI
431 { "ada", 0x1c00 },
432 { "adb", 0x1c10 },
433 { "adc", 0x1c20 },
434 { "add", 0x1c30 },
435 { "ade", 0x1c40 },
436 #endif
437 #ifdef CONFIG_BLK_DEV_FD
438 { "fd", 0x0200 },
439 #endif
440 #ifdef CONFIG_MD_BOOT
441 { "md", 0x0900 },
442 #endif
443 #ifdef CONFIG_BLK_DEV_XD
444 { "xda", 0x0d00 },
445 { "xdb", 0x0d40 },
446 #endif
447 #ifdef CONFIG_BLK_DEV_RAM
448 { "ram", 0x0100 },
449 #endif
450 #ifdef CONFIG_BLK_DEV_SR
451 { "scd", 0x0b00 },
452 #endif
453 #ifdef CONFIG_MCD
454 { "mcd", 0x1700 },
455 #endif
456 #ifdef CONFIG_CDU535
457 { "cdu535", 0x1800 },
458 { "sonycd", 0x1800 },
459 #endif
460 #ifdef CONFIG_AZTCD
461 { "aztcd", 0x1d00 },
462 #endif
463 #ifdef CONFIG_CM206
464 { "cm206cd", 0x2000 },
465 #endif
466 #ifdef CONFIG_GSCD
467 { "gscd", 0x1000 },
468 #endif
469 #ifdef CONFIG_SBPCD
470 { "sbpcd", 0x1900 },
471 #endif
472 #ifdef CONFIG_BLK_DEV_PS2
473 { "eda", 0x2400 },
474 { "edb", 0x2440 },
475 #endif
476 #ifdef CONFIG_PARIDE_PD
477 { "pda", 0x2d00 },
478 { "pdb", 0x2d10 },
479 { "pdc", 0x2d20 },
480 { "pdd", 0x2d30 },
481 #endif
482 #ifdef CONFIG_PARIDE_PCD
483 { "pcd", 0x2e00 },
484 #endif
485 #ifdef CONFIG_PARIDE_PF
486 { "pf", 0x2f00 },
487 #endif
488 #if CONFIG_APBLOCK
489 { "apblock", APBLOCK_MAJOR << 8},
490 #endif
491 #if CONFIG_DDV
492 { "ddv", DDV_MAJOR << 8},
493 #endif
494 { NULL, 0 }
497 kdev_t __init name_to_kdev_t(char *line)
499 int base = 0;
500 if (strncmp(line,"/dev/",5) == 0) {
501 struct dev_name_struct *dev = root_dev_names;
502 line += 5;
503 do {
504 int len = strlen(dev->name);
505 if (strncmp(line,dev->name,len) == 0) {
506 line += len;
507 base = dev->num;
508 break;
510 dev++;
511 } while (dev->name);
513 return to_kdev_t(base + simple_strtoul(line,NULL,base?10:16));
516 static void __init root_dev_setup(char *line, int *num)
518 ROOT_DEV = name_to_kdev_t(line);
522 * List of kernel command line parameters. The first table lists parameters
523 * which are subject to values parsing (leading numbers are converted to
524 * an array of ints and chopped off the string), the second table contains
525 * the few exceptions which obey their own syntax rules.
528 struct kernel_param {
529 const char *str;
530 void (*setup_func)(char *, int *);
533 static struct kernel_param cooked_params[] __initdata = {
534 /* FIXME: make PNP just become reserve_setup */
535 #ifndef CONFIG_KERNEL_PNP_RESOURCE
536 { "reserve=", reserve_setup },
537 #else
538 { "reserve=", pnp_reserve_setup },
539 #endif
540 { "profile=", profile_setup },
541 #ifdef __SMP__
542 { "nosmp", smp_setup },
543 { "maxcpus=", smp_setup },
544 #ifdef CONFIG_X86_IO_APIC
545 { "noapic", ioapic_setup },
546 { "pirq=", ioapic_pirq_setup },
547 #endif
548 #endif
549 #ifdef CONFIG_BLK_DEV_RAM
550 { "ramdisk_start=", ramdisk_start_setup },
551 { "load_ramdisk=", load_ramdisk },
552 { "prompt_ramdisk=", prompt_ramdisk },
553 { "ramdisk=", ramdisk_size },
554 { "ramdisk_size=", ramdisk_size },
555 #ifdef CONFIG_BLK_DEV_INITRD
556 { "noinitrd", no_initrd },
557 #endif
558 #endif
559 #ifdef CONFIG_FB
560 { "video=", video_setup },
561 #endif
562 { "panic=", panic_setup },
563 { "console=", console_setup },
564 #ifdef CONFIG_VGA_CONSOLE
565 { "no-scroll", no_scroll },
566 #endif
567 #ifdef CONFIG_MDA_CONSOLE
568 { "mdacon=", mdacon_setup },
569 #endif
570 #ifdef CONFIG_VT
571 { "kbd-reset", kbd_reset_setup },
572 #endif
573 #ifdef CONFIG_BUGi386
574 { "no-hlt", no_halt },
575 { "no387", no_387 },
576 { "reboot=", reboot_setup },
577 #endif
578 #ifdef CONFIG_INET
579 { "ether=", eth_setup },
580 #endif
581 #ifdef CONFIG_ARCNET_COM20020
582 { "com20020=", com20020_setup },
583 #endif
584 #ifdef CONFIG_ARCNET_RIM_I
585 { "arcrimi=", arcrimi_setup },
586 #endif
587 #ifdef CONFIG_ARCNET_COM90xxIO
588 { "com90io=", com90io_setup },
589 #endif
590 #ifdef CONFIG_ARCNET_COM90xx
591 { "com90xx=", com90xx_setup },
592 #endif
593 #ifdef CONFIG_DECNET
594 { "decnet=", decnet_setup },
595 #endif
596 #ifdef CONFIG_PRINTER
597 { "lp=", lp_setup },
598 #endif
599 #ifdef CONFIG_JOY_AMIGA
600 { "js_am=", js_am_setup },
601 #endif
602 #ifdef CONFIG_JOY_ANALOG
603 { "js_an=", js_an_setup },
604 #endif
605 #ifdef CONFIG_JOY_ASSASIN
606 { "js_as=", js_as_setup },
607 #endif
608 #ifdef CONFIG_JOY_CONSOLE
609 { "js_console=", js_console_setup },
610 { "js_console2=", js_console_setup },
611 { "js_console3=", js_console_setup },
612 #endif
613 #ifdef CONFIG_JOY_DB9
614 { "js_db9=", js_db9_setup },
615 { "js_db9_2=", js_db9_setup },
616 { "js_db9_3=", js_db9_setup },
617 #endif
618 #ifdef CONFIG_JOY_TURBOGRAFX
619 { "js_tg=", js_tg_setup },
620 { "js_tg_2=", js_tg_setup },
621 { "js_tg_3=", js_tg_setup },
622 #endif
623 #ifdef CONFIG_SCSI
624 { "max_scsi_luns=", scsi_luns_setup },
625 { "scsi_logging=", scsi_logging_setup },
626 #endif
627 #ifdef CONFIG_JOY_LIGHTNING
628 { "js_l4=", js_l4_setup },
629 #endif
630 #ifdef CONFIG_SCSI_ADVANSYS
631 { "advansys=", advansys_setup },
632 #endif
633 #if defined(CONFIG_BLK_DEV_HD)
634 { "hd=", hd_setup },
635 #endif
636 #ifdef CONFIG_CHR_DEV_ST
637 { "st=", st_setup },
638 #endif
639 #ifdef CONFIG_BUSMOUSE
640 { "bmouse=", bmouse_setup },
641 #endif
642 #ifdef CONFIG_MS_BUSMOUSE
643 { "msmouse=", msmouse_setup },
644 #endif
645 #ifdef CONFIG_SCSI_SEAGATE
646 { "st0x=", st0x_setup },
647 { "tmc8xx=", tmc8xx_setup },
648 #endif
649 #ifdef CONFIG_SCSI_T128
650 { "t128=", t128_setup },
651 #endif
652 #ifdef CONFIG_SCSI_PAS16
653 { "pas16=", pas16_setup },
654 #endif
655 #ifdef CONFIG_SCSI_GENERIC_NCR5380
656 { "ncr5380=", generic_NCR5380_setup },
657 { "ncr53c400=", generic_NCR53C400_setup },
658 { "ncr53c400a=", generic_NCR53C400A_setup },
659 { "dtc3181e=", generic_DTC3181E_setup },
660 #endif
661 #ifdef CONFIG_SCSI_AHA152X
662 { "aha152x=", aha152x_setup},
663 #endif
664 #ifdef CONFIG_SCSI_AHA1542
665 { "aha1542=", aha1542_setup},
666 #endif
667 #ifdef CONFIG_SCSI_GDTH
668 { "gdth=", gdth_setup},
669 #endif
670 #ifdef CONFIG_SCSI_AIC7XXX
671 { "aic7xxx=", aic7xxx_setup},
672 #endif
673 #ifdef CONFIG_SCSI_BUSLOGIC
674 { "BusLogic=", BusLogic_Setup},
675 #endif
676 #ifdef CONFIG_SCSI_NCR53C8XX
677 { "ncr53c8xx=", ncr53c8xx_setup},
678 #endif
679 #ifdef CONFIG_SCSI_EATA
680 { "eata=", eata2x_setup},
681 #endif
682 #ifdef CONFIG_SCSI_U14_34F
683 { "u14-34f=", u14_34f_setup},
684 #endif
685 #ifdef CONFIG_SCSI_AM53C974
686 { "AM53C974=", AM53C974_setup},
687 #endif
688 #ifdef CONFIG_SCSI_NCR53C406A
689 { "ncr53c406a=", NCR53c406a_setup},
690 #endif
691 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
692 { "fdomain=", fdomain_setup},
693 #endif
694 #ifdef CONFIG_SCSI_IN2000
695 { "in2000=", in2000_setup},
696 #endif
697 #ifdef CONFIG_SCSI_7000FASST
698 { "wd7000=", wd7000_setup},
699 #endif
700 #ifdef CONFIG_SCSI_IBMMCA
701 { "ibmmcascsi=", ibmmca_scsi_setup },
702 #endif
703 #if defined(CONFIG_SCSI_DC390T) && ! defined(CONFIG_SCSI_DC390T_NOGENSUPP)
704 { "tmscsim=", dc390_setup },
705 #endif
706 #ifdef CONFIG_BLK_DEV_XD
707 { "xd=", xd_setup },
708 { "xd_geo=", xd_manual_geo_init },
709 #endif
710 #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
711 { "floppy=", floppy_setup },
712 #endif
713 #ifdef CONFIG_BLK_DEV_PS2
714 { "eda=", ed_setup },
715 { "edb=", ed_setup },
716 { "tp720=", tp720_setup },
717 #endif
718 #ifdef CONFIG_CDU31A
719 { "cdu31a=", cdu31a_setup },
720 #endif CONFIG_CDU31A
721 #ifdef CONFIG_MCD
722 { "mcd=", mcd_setup },
723 #endif CONFIG_MCD
724 #ifdef CONFIG_MCDX
725 { "mcdx=", mcdx_setup },
726 #endif CONFIG_MCDX
727 #ifdef CONFIG_SBPCD
728 { "sbpcd=", sbpcd_setup },
729 #endif CONFIG_SBPCD
730 #ifdef CONFIG_AZTCD
731 { "aztcd=", aztcd_setup },
732 #endif CONFIG_AZTCD
733 #ifdef CONFIG_CDU535
734 { "sonycd535=", sonycd535_setup },
735 #endif CONFIG_CDU535
736 #ifdef CONFIG_GSCD
737 { "gscd=", gscd_setup },
738 #endif CONFIG_GSCD
739 #ifdef CONFIG_CM206
740 { "cm206=", cm206_setup },
741 #endif CONFIG_CM206
742 #ifdef CONFIG_OPTCD
743 { "optcd=", optcd_setup },
744 #endif CONFIG_OPTCD
745 #ifdef CONFIG_SJCD
746 { "sjcd=", sjcd_setup },
747 #endif CONFIG_SJCD
748 #ifdef CONFIG_ISP16_CDI
749 { "isp16=", isp16_setup },
750 #endif CONFIG_ISP16_CDI
751 #ifdef CONFIG_SOUND_OSS
752 { "sound=", sound_setup },
753 #endif
754 #ifdef CONFIG_ISDN_DRV_ICN
755 { "icn=", icn_setup },
756 #endif
757 #ifdef CONFIG_ISDN_DRV_HISAX
758 { "hisax=", HiSax_setup },
759 { "HiSax=", HiSax_setup },
760 #endif
761 #ifdef CONFIG_ISDN_DRV_PCBIT
762 { "pcbit=", pcbit_setup },
763 #endif
764 #ifdef CONFIG_ATARIMOUSE
765 { "atamouse=", atari_mouse_setup },
766 #endif
767 #ifdef CONFIG_DMASOUND
768 { "dmasound=", dmasound_setup },
769 #endif
770 #ifdef CONFIG_ATARI_SCSI
771 { "atascsi=", atari_scsi_setup },
772 #endif
773 #ifdef CONFIG_STRAM_SWAP
774 { "stram_swap=", stram_swap_setup },
775 #endif
776 #if defined(CONFIG_A4000T_SCSI) || defined(CONFIG_WARPENGINE_SCSI) \
777 || defined(CONFIG_A4091_SCSI) || defined(CONFIG_MVME16x_SCSI) \
778 || defined(CONFIG_BVME6000_SCSI)
779 { "53c7xx=", ncr53c7xx_setup },
780 #endif
781 #if defined(CONFIG_A3000_SCSI) || defined(CONFIG_A2091_SCSI) \
782 || defined(CONFIG_GVP11_SCSI)
783 { "wd33c93=", wd33c93_setup },
784 #endif
785 #if defined(CONFIG_GVP11_SCSI)
786 { "gvp11=", gvp11_setup },
787 #endif
788 #ifdef CONFIG_MAC_SCSI
789 { "mac5380=", mac_scsi_setup },
790 #endif
791 #ifdef CONFIG_CYCLADES
792 { "cyclades=", cy_setup },
793 #endif
794 #ifdef CONFIG_DIGI
795 { "digi=", pcxx_setup },
796 #endif
797 #ifdef CONFIG_DIGIEPCA
798 { "digiepca=", epca_setup },
799 #endif
800 #ifdef CONFIG_RISCOM8
801 { "riscom8=", riscom8_setup },
802 #endif
803 #ifdef CONFIG_DMASCC
804 { "dmascc=", dmascc_setup },
805 #endif
806 #ifdef CONFIG_SPECIALIX
807 { "specialix=", specialix_setup },
808 #endif
809 #ifdef CONFIG_BAYCOM_PAR
810 { "baycom_par=", baycom_par_setup },
811 #endif
812 #ifdef CONFIG_BAYCOM_SER_FDX
813 { "baycom_ser_fdx=", baycom_ser_fdx_setup },
814 #endif
815 #ifdef CONFIG_BAYCOM_SER_HDX
816 { "baycom_ser_hdx=", baycom_ser_hdx_setup },
817 #endif
818 #ifdef CONFIG_SOUNDMODEM
819 { "soundmodem=", sm_setup },
820 #endif
821 #ifdef CONFIG_WDT
822 { "wdt=", wdt_setup },
823 #endif
824 #ifdef CONFIG_PARPORT
825 { "parport=", parport_setup },
826 #endif
827 #ifdef CONFIG_PLIP
828 { "plip=", plip_setup },
829 #endif
830 #ifdef CONFIG_HFMODEM
831 { "hfmodem=", hfmodem_setup },
832 #endif
833 #ifdef CONFIG_FTAPE
834 { "ftape=", ftape_setup},
835 #endif
836 #ifdef CONFIG_MD_BOOT
837 { "md=", md_setup},
838 #endif
839 #ifdef CONFIG_ADBMOUSE
840 { "adb_buttons=", adb_mouse_setup },
841 #endif
842 #ifdef CONFIG_LTPC
843 { "ltpc=", ltpc_setup },
844 #endif
845 { 0, 0 }
848 static struct kernel_param raw_params[] __initdata = {
849 { "root=", root_dev_setup },
850 #ifdef CONFIG_ROOT_NFS
851 { "nfsroot=", nfs_root_setup },
852 { "nfsaddrs=", ip_auto_config_setup },
853 #endif
854 #ifdef CONFIG_IP_PNP
855 { "ip=", ip_auto_config_setup },
856 #endif
857 #ifdef CONFIG_PCI
858 { "pci=", pci_setup },
859 #endif
860 #ifdef CONFIG_PARIDE_PD
861 { "pd.", pd_setup },
862 #endif
863 #ifdef CONFIG_PARIDE_PCD
864 { "pcd.", pcd_setup },
865 #endif
866 #ifdef CONFIG_PARIDE_PF
867 { "pf.", pf_setup },
868 #endif
869 #ifdef CONFIG_PARIDE_PT
870 { "pt.", pt_setup },
871 #endif
872 #ifdef CONFIG_PARIDE_PG
873 { "pg.", pg_setup },
874 #endif
875 #ifdef CONFIG_APM
876 { "apm=", apm_setup },
877 #endif
878 { 0, 0 }
881 #ifdef CONFIG_BLK_DEV_RAM
882 static void __init ramdisk_start_setup(char *str, int *ints)
884 if (ints[0] > 0 && ints[1] >= 0)
885 rd_image_start = ints[1];
888 static void __init load_ramdisk(char *str, int *ints)
890 if (ints[0] > 0 && ints[1] >= 0)
891 rd_doload = ints[1] & 1;
894 static void __init prompt_ramdisk(char *str, int *ints)
896 if (ints[0] > 0 && ints[1] >= 0)
897 rd_prompt = ints[1] & 1;
900 static void __init ramdisk_size(char *str, int *ints)
902 if (ints[0] > 0 && ints[1] >= 0)
903 rd_size = ints[1];
905 #endif
907 static int __init checksetup(char *line)
909 int i, ints[11];
911 #ifdef CONFIG_BLK_DEV_IDE
912 /* ide driver needs the basic string, rather than pre-processed values */
913 if (!strncmp(line,"ide",3) || (!strncmp(line,"hd",2) && line[2] != '=')) {
914 ide_setup(line);
915 return 1;
917 #endif
918 for (i=0; raw_params[i].str; i++) {
919 int n = strlen(raw_params[i].str);
920 if (!strncmp(line,raw_params[i].str,n)) {
921 raw_params[i].setup_func(line+n, NULL);
922 return 1;
925 for (i=0; cooked_params[i].str; i++) {
926 int n = strlen(cooked_params[i].str);
927 if (!strncmp(line,cooked_params[i].str,n)) {
928 cooked_params[i].setup_func(get_options(line+n, ints), ints);
929 return 1;
932 return 0;
935 /* this should be approx 2 Bo*oMips to start (note initial shift), and will
936 still work even if initially too large, it will just take slightly longer */
937 unsigned long loops_per_sec = (1<<12);
939 /* This is the number of bits of precision for the loops_per_second. Each
940 bit takes on average 1.5/HZ seconds. This (like the original) is a little
941 better than 1% */
942 #define LPS_PREC 8
944 void __init calibrate_delay(void)
946 unsigned long ticks, loopbit;
947 int lps_precision = LPS_PREC;
949 loops_per_sec = (1<<12);
951 printk("Calibrating delay loop... ");
952 while (loops_per_sec <<= 1) {
953 /* wait for "start of" clock tick */
954 ticks = jiffies;
955 while (ticks == jiffies)
956 /* nothing */;
957 /* Go .. */
958 ticks = jiffies;
959 __delay(loops_per_sec);
960 ticks = jiffies - ticks;
961 if (ticks)
962 break;
965 /* Do a binary approximation to get loops_per_second set to equal one clock
966 (up to lps_precision bits) */
967 loops_per_sec >>= 1;
968 loopbit = loops_per_sec;
969 while ( lps_precision-- && (loopbit >>= 1) ) {
970 loops_per_sec |= loopbit;
971 ticks = jiffies;
972 while (ticks == jiffies);
973 ticks = jiffies;
974 __delay(loops_per_sec);
975 if (jiffies != ticks) /* longer than 1 tick */
976 loops_per_sec &= ~loopbit;
979 /* finally, adjust loops per second in terms of seconds instead of clocks */
980 loops_per_sec *= HZ;
981 /* Round the value and print it */
982 printk("%lu.%02lu BogoMIPS\n",
983 (loops_per_sec+2500)/500000,
984 ((loops_per_sec+2500)/5000) % 100);
988 * This is a simple kernel command line parsing function: it parses
989 * the command line, and fills in the arguments/environment to init
990 * as appropriate. Any cmd-line option is taken to be an environment
991 * variable if it contains the character '='.
993 * This routine also checks for options meant for the kernel.
994 * These options are not given to init - they are for internal kernel use only.
996 static void __init parse_options(char *line)
998 char *next;
999 int args, envs;
1001 if (!*line)
1002 return;
1003 args = 0;
1004 envs = 1; /* TERM is set to 'linux' by default */
1005 next = line;
1006 while ((line = next) != NULL) {
1007 if ((next = strchr(line,' ')) != NULL)
1008 *next++ = 0;
1010 * check for kernel options first..
1012 if (!strcmp(line,"ro")) {
1013 root_mountflags |= MS_RDONLY;
1014 continue;
1016 if (!strcmp(line,"rw")) {
1017 root_mountflags &= ~MS_RDONLY;
1018 continue;
1020 if (!strcmp(line,"debug")) {
1021 console_loglevel = 10;
1022 continue;
1024 if (!strncmp(line,"init=",5)) {
1025 line += 5;
1026 execute_command = line;
1027 /* In case LILO is going to boot us with default command line,
1028 * it prepends "auto" before the whole cmdline which makes
1029 * the shell think it should execute a script with such name.
1030 * So we ignore all arguments entered _before_ init=... [MJ]
1032 args = 0;
1033 continue;
1035 if (checksetup(line))
1036 continue;
1039 * Then check if it's an environment variable or
1040 * an option.
1042 if (strchr(line,'=')) {
1043 if (envs >= MAX_INIT_ENVS)
1044 break;
1045 envp_init[++envs] = line;
1046 } else {
1047 if (args >= MAX_INIT_ARGS)
1048 break;
1049 argv_init[++args] = line;
1052 argv_init[args+1] = NULL;
1053 envp_init[envs+1] = NULL;
1057 extern void setup_arch(char **, unsigned long *, unsigned long *);
1059 #ifndef __SMP__
1062 * Uniprocessor idle thread
1065 int cpu_idle(void *unused)
1067 for(;;)
1068 idle();
1071 #define smp_init() do { } while (0)
1073 #else
1076 * Multiprocessor idle thread is in arch/...
1079 extern int cpu_idle(void * unused);
1081 /* Called by boot processor to activate the rest. */
1082 static void __init smp_init(void)
1084 /* Get other processors into their bootup holding patterns. */
1085 smp_boot_cpus();
1086 smp_threads_ready=1;
1087 smp_commence();
1090 #endif
1092 extern void initialize_secondary(void);
1095 * Activate the first processor.
1098 asmlinkage void __init start_kernel(void)
1100 char * command_line;
1102 #ifdef __SMP__
1103 static int boot_cpu = 1;
1104 /* "current" has been set up, we need to load it now */
1105 if (!boot_cpu)
1106 initialize_secondary();
1107 boot_cpu = 0;
1108 #endif
1111 * Interrupts are still disabled. Do necessary setups, then
1112 * enable them
1114 printk(linux_banner);
1115 setup_arch(&command_line, &memory_start, &memory_end);
1116 memory_start = paging_init(memory_start,memory_end);
1117 trap_init();
1118 init_IRQ();
1119 sched_init();
1120 time_init();
1121 parse_options(command_line);
1124 * HACK ALERT! This is early. We're enabling the console before
1125 * we've done PCI setups etc, and console_init() must be aware of
1126 * this. But we do want output early, in case something goes wrong.
1128 memory_start = console_init(memory_start,memory_end);
1129 #ifdef CONFIG_MODULES
1130 init_modules();
1131 #endif
1132 if (prof_shift) {
1133 prof_buffer = (unsigned int *) memory_start;
1134 /* only text is profiled */
1135 prof_len = (unsigned long) &_etext - (unsigned long) &_stext;
1136 prof_len >>= prof_shift;
1137 memory_start += prof_len * sizeof(unsigned int);
1138 memset(prof_buffer, 0, prof_len * sizeof(unsigned int));
1141 memory_start = kmem_cache_init(memory_start, memory_end);
1142 sti();
1143 calibrate_delay();
1144 #ifdef CONFIG_BLK_DEV_INITRD
1145 if (initrd_start && !initrd_below_start_ok && initrd_start < memory_start) {
1146 printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - "
1147 "disabling it.\n",initrd_start,memory_start);
1148 initrd_start = 0;
1150 #endif
1151 mem_init(memory_start,memory_end);
1152 kmem_cache_sizes_init();
1153 #ifdef CONFIG_PROC_FS
1154 proc_root_init();
1155 #endif
1156 uidcache_init();
1157 filescache_init();
1158 dcache_init();
1159 vma_init();
1160 buffer_init();
1161 signals_init();
1162 inode_init();
1163 file_table_init();
1164 #if defined(CONFIG_SYSVIPC)
1165 ipc_init();
1166 #endif
1167 #if defined(CONFIG_QUOTA)
1168 dquot_init_hash();
1169 #endif
1170 check_bugs();
1171 printk("POSIX conformance testing by UNIFIX\n");
1174 * We count on the initial thread going ok
1175 * Like idlers init is an unlocked kernel thread, which will
1176 * make syscalls (and thus be locked).
1178 smp_init();
1179 kernel_thread(init, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1180 current->need_resched = 1;
1181 cpu_idle(NULL);
1184 #ifdef CONFIG_BLK_DEV_INITRD
1185 static int do_linuxrc(void * shell)
1187 static char *argv[] = { "linuxrc", NULL, };
1189 close(0);close(1);close(2);
1190 setsid();
1191 (void) open("/dev/console",O_RDWR,0);
1192 (void) dup(0);
1193 (void) dup(0);
1194 return execve(shell, argv, envp_init);
1197 static void __init no_initrd(char *s,int *ints)
1199 mount_initrd = 0;
1201 #endif
1203 struct task_struct *child_reaper = &init_task;
1206 * Ok, the machine is now initialized. None of the devices
1207 * have been touched yet, but the CPU subsystem is up and
1208 * running, and memory and process management works.
1210 * Now we can finally start doing some real work..
1212 static void __init do_basic_setup(void)
1214 #ifdef CONFIG_BLK_DEV_INITRD
1215 int real_root_mountflags;
1216 #endif
1219 * Tell the world that we're going to be the grim
1220 * reaper of innocent orphaned children.
1222 * We don't want people to have to make incorrect
1223 * assumptions about where in the task array this
1224 * can be found.
1226 child_reaper = current;
1228 #if defined(CONFIG_MTRR) /* Do this after SMP initialization */
1230 * We should probably create some architecture-dependent "fixup after
1231 * everything is up" style function where this would belong better
1232 * than in init/main.c..
1234 mtrr_init();
1235 #endif
1237 #ifdef CONFIG_SYSCTL
1238 sysctl_init();
1239 #endif
1242 * Ok, at this point all CPU's should be initialized, so
1243 * we can start looking into devices..
1245 #ifdef CONFIG_PCI
1246 pci_init();
1247 #endif
1248 #ifdef CONFIG_SBUS
1249 sbus_init();
1250 #endif
1251 #if defined(CONFIG_PPC)
1252 powermac_init();
1253 #endif
1254 #ifdef CONFIG_MCA
1255 mca_init();
1256 #endif
1257 #ifdef CONFIG_ARCH_ACORN
1258 ecard_init();
1259 #endif
1260 #ifdef CONFIG_ZORRO
1261 zorro_init();
1262 #endif
1263 #ifdef CONFIG_DIO
1264 dio_init();
1265 #endif
1267 /* Networking initialization needs a process context */
1268 sock_init();
1270 /* Launch bdflush from here, instead of the old syscall way. */
1271 kernel_thread(bdflush, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1272 /* Start the background pageout daemon. */
1273 kswapd_setup();
1274 kernel_thread(kswapd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1276 #if CONFIG_AP1000
1277 /* Start the async paging daemon. */
1279 extern int asyncd(void *);
1280 kernel_thread(asyncd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1282 #endif
1284 #ifdef CONFIG_BLK_DEV_INITRD
1286 real_root_dev = ROOT_DEV;
1287 real_root_mountflags = root_mountflags;
1288 if (initrd_start && mount_initrd) root_mountflags &= ~MS_RDONLY;
1289 else mount_initrd =0;
1290 #endif
1292 /* Set up devices .. */
1293 device_setup();
1295 /* .. executable formats .. */
1296 binfmt_setup();
1298 /* .. filesystems .. */
1299 filesystem_setup();
1301 /* Mount the root filesystem.. */
1302 mount_root();
1304 #ifdef CONFIG_UMSDOS_FS
1307 When mounting a umsdos fs as root, we detect
1308 the pseudo_root (/linux) and initialise it here.
1309 pseudo_root is defined in fs/umsdos/inode.c
1311 extern struct inode *pseudo_root;
1312 if (pseudo_root != NULL){
1313 current->fs->root = pseudo_root->i_sb->s_root;
1314 current->fs->pwd = pseudo_root->i_sb->s_root;
1317 #endif
1319 #ifdef CONFIG_BLK_DEV_INITRD
1320 root_mountflags = real_root_mountflags;
1321 if (mount_initrd && ROOT_DEV != real_root_dev
1322 && MAJOR(ROOT_DEV) == RAMDISK_MAJOR && MINOR(ROOT_DEV) == 0) {
1323 int error;
1324 int i, pid;
1326 pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
1327 if (pid>0)
1328 while (pid != wait(&i));
1329 if (MAJOR(real_root_dev) != RAMDISK_MAJOR
1330 || MINOR(real_root_dev) != 0) {
1331 error = change_root(real_root_dev,"/initrd");
1332 if (error)
1333 printk(KERN_ERR "Change root to /initrd: "
1334 "error %d\n",error);
1337 #endif
1340 static int init(void * unused)
1342 lock_kernel();
1343 do_basic_setup();
1346 * Ok, we have completed the initial bootup, and
1347 * we're essentially up and running. Get rid of the
1348 * initmem segments and start the user-mode stuff..
1350 free_initmem();
1351 unlock_kernel();
1353 if (open("/dev/console", O_RDWR, 0) < 0)
1354 printk("Warning: unable to open an initial console.\n");
1356 (void) dup(0);
1357 (void) dup(0);
1360 * We try each of these until one succeeds.
1362 * The Bourne shell can be used instead of init if we are
1363 * trying to recover a really broken machine.
1366 if (execute_command)
1367 execve(execute_command,argv_init,envp_init);
1368 execve("/sbin/init",argv_init,envp_init);
1369 execve("/etc/init",argv_init,envp_init);
1370 execve("/bin/init",argv_init,envp_init);
1371 execve("/bin/sh",argv_init,envp_init);
1372 panic("No init found. Try passing init= option to kernel.");