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