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