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/string.h>
18 #include <linux/ctype.h>
19 #include <linux/delay.h>
20 #include <linux/utsname.h>
21 #include <linux/ioport.h>
22 #include <linux/init.h>
23 #include <linux/smp_lock.h>
24 #include <linux/blk.h>
25 #include <linux/hdreg.h>
31 #include <linux/pci.h>
35 #include <linux/dio.h>
39 #include <linux/zorro.h>
43 # include <asm/mtrr.h>
47 #include <linux/apm_bios.h>
51 extern void nubus_init(void);
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.
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 int kpiod(void *);
73 extern void kswapd_setup(void);
75 extern void init_IRQ(void);
76 extern void init_modules(void);
77 extern long console_init(long, long);
78 extern void sock_init(void);
79 extern void uidcache_init(void);
80 extern void mca_init(void);
81 extern void sbus_init(void);
82 extern void ppc_init(void);
83 extern void sysctl_init(void);
84 extern void filescache_init(void);
85 extern void signals_init(void);
87 extern void device_setup(void);
88 extern void binfmt_setup(void);
89 extern void free_initmem(void);
90 extern void filesystem_setup(void);
92 #ifdef CONFIG_ARCH_ACORN
93 extern void ecard_init(void);
96 extern void smp_setup(char *str
, int *ints
);
98 extern void ioapic_pirq_setup(char *str
, int *ints
);
99 extern void ioapic_setup(char *str
, int *ints
);
101 extern void no_scroll(char *str
, int *ints
);
102 extern void kbd_reset_setup(char *str
, int *ints
);
103 extern void panic_setup(char *str
, int *ints
);
104 extern void bmouse_setup(char *str
, int *ints
);
105 extern void msmouse_setup(char *str
, int *ints
);
106 extern void console_setup(char *str
, int *ints
);
107 #ifdef CONFIG_PRINTER
108 extern void lp_setup(char *str
, int *ints
);
110 #ifdef CONFIG_JOY_AMIGA
111 extern void js_am_setup(char *str
, int *ints
);
113 #ifdef CONFIG_JOY_ANALOG
114 extern void js_an_setup(char *str
, int *ints
);
116 #ifdef CONFIG_JOY_ASSASIN
117 extern void js_as_setup(char *str
, int *ints
);
119 #ifdef CONFIG_JOY_CONSOLE
120 extern void js_console_setup(char *str
, int *ints
);
122 #ifdef CONFIG_JOY_DB9
123 extern void js_db9_setup(char *str
, int *ints
);
125 #ifdef CONFIG_JOY_TURBOGRAFX
126 extern void js_tg_setup(char *str
, int *ints
);
128 #ifdef CONFIG_JOY_LIGHTNING
129 extern void js_l4_setup(char *str
, int *ints
);
131 extern void eth_setup(char *str
, int *ints
);
132 #ifdef CONFIG_ARCNET_COM20020
133 extern void com20020_setup(char *str
, int *ints
);
135 #ifdef CONFIG_ARCNET_RIM_I
136 extern void arcrimi_setup(char *str
, int *ints
);
138 #ifdef CONFIG_ARCNET_COM90xxIO
139 extern void com90io_setup(char *str
, int *ints
);
141 #ifdef CONFIG_ARCNET_COM90xx
142 extern void com90xx_setup(char *str
, int *ints
);
145 extern void decnet_setup(char *str
, int *ints
);
147 #ifdef CONFIG_BLK_DEV_XD
148 extern void xd_setup(char *str
, int *ints
);
149 extern void xd_manual_geo_init(char *str
, int *ints
);
151 #ifdef CONFIG_BLK_DEV_IDE
152 extern void ide_setup(char *);
154 #ifdef CONFIG_PARIDE_PD
155 extern void pd_setup(char *str
, int *ints
);
157 #ifdef CONFIG_PARIDE_PF
158 extern void pf_setup(char *str
, int *ints
);
160 #ifdef CONFIG_PARIDE_PT
161 extern void pt_setup(char *str
, int *ints
);
163 #ifdef CONFIG_PARIDE_PG
164 extern void pg_setup(char *str
, int *ints
);
166 #ifdef CONFIG_PARIDE_PCD
167 extern void pcd_setup(char *str
, int *ints
);
169 extern void floppy_setup(char *str
, int *ints
);
170 extern void st_setup(char *str
, int *ints
);
171 extern void st0x_setup(char *str
, int *ints
);
172 extern void advansys_setup(char *str
, int *ints
);
173 extern void tmc8xx_setup(char *str
, int *ints
);
174 extern void t128_setup(char *str
, int *ints
);
175 extern void pas16_setup(char *str
, int *ints
);
176 extern void generic_NCR5380_setup(char *str
, int *intr
);
177 extern void generic_NCR53C400_setup(char *str
, int *intr
);
178 extern void generic_NCR53C400A_setup(char *str
, int *intr
);
179 extern void generic_DTC3181E_setup(char *str
, int *intr
);
180 extern void aha152x_setup(char *str
, int *ints
);
181 extern void aha1542_setup(char *str
, int *ints
);
182 extern void gdth_setup(char *str
, int *ints
);
183 extern void aic7xxx_setup(char *str
, int *ints
);
184 extern void AM53C974_setup(char *str
, int *ints
);
185 extern void BusLogic_Setup(char *str
, int *ints
);
186 extern void ncr53c8xx_setup(char *str
, int *ints
);
187 extern void sym53c8xx_setup(char *str
, int *ints
);
188 extern void eata2x_setup(char *str
, int *ints
);
189 extern void u14_34f_setup(char *str
, int *ints
);
190 extern void fdomain_setup(char *str
, int *ints
);
191 extern void ibmmca_scsi_setup(char *str
, int *ints
);
192 extern void fd_mcs_setup(char *str
, int *ints
);
193 extern void in2000_setup(char *str
, int *ints
);
194 extern void NCR53c406a_setup(char *str
, int *ints
);
195 extern void sym53c416_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
);
204 extern void cdu31a_setup(char *str
, int *ints
);
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
211 extern void mcd_setup(char *str
, int *ints
);
214 extern void mcdx_setup(char *str
, int *ints
);
217 extern void sbpcd_setup(char *str
, int *ints
);
220 extern void aztcd_setup(char *str
, int *ints
);
223 extern void sonycd535_setup(char *str
, int *ints
);
226 extern void gscd_setup(char *str
, int *ints
);
229 extern void cm206_setup(char *str
, int *ints
);
232 extern void optcd_setup(char *str
, int *ints
);
235 extern void sjcd_setup(char *str
, int *ints
);
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
);
248 #endif CONFIG_BLK_DEV_RAM
249 #ifdef CONFIG_ISDN_DRV_ICN
250 extern void icn_setup(char *str
, int *ints
);
252 #ifdef CONFIG_ISDN_DRV_HISAX
253 extern void HiSax_setup(char *str
, int *ints
);
255 #ifdef CONFIG_DIGIEPCA
256 extern void epca_setup(char *str
, int *ints
);
258 #ifdef CONFIG_ISDN_DRV_PCBIT
259 extern void pcbit_setup(char *str
, int *ints
);
262 #ifdef CONFIG_ATARIMOUSE
263 extern void atari_mouse_setup (char *str
, int *ints
);
265 #ifdef CONFIG_DMASOUND
266 extern void dmasound_setup (char *str
, int *ints
);
268 #ifdef CONFIG_ATARI_SCSI
269 extern void atari_scsi_setup (char *str
, int *ints
);
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
);
279 #ifdef CONFIG_CYCLADES
280 extern void cy_setup(char *str
, int *ints
);
283 extern void pcxx_setup(char *str
, int *ints
);
285 #ifdef CONFIG_RISCOM8
286 extern void riscom8_setup(char *str
, int *ints
);
288 #ifdef CONFIG_SPECIALIX
289 extern void specialix_setup(char *str
, int *ints
);
292 extern void dmascc_setup(char *str
, int *ints
);
294 #ifdef CONFIG_BAYCOM_PAR
295 extern void baycom_par_setup(char *str
, int *ints
);
297 #ifdef CONFIG_BAYCOM_SER_FDX
298 extern void baycom_ser_fdx_setup(char *str
, int *ints
);
300 #ifdef CONFIG_BAYCOM_SER_HDX
301 extern void baycom_ser_hdx_setup(char *str
, int *ints
);
303 #ifdef CONFIG_SOUNDMODEM
304 extern void sm_setup(char *str
, int *ints
);
306 #ifdef CONFIG_ADBMOUSE
307 extern void adb_mouse_setup(char *str
, int *ints
);
310 extern void wdt_setup(char *str
, int *ints
);
312 #ifdef CONFIG_PARPORT
313 extern void parport_setup(char *str
, int *ints
);
316 extern void plip_setup(char *str
, int *ints
);
318 #ifdef CONFIG_HFMODEM
319 extern void hfmodem_setup(char *str
, int *ints
);
322 extern void ip_auto_config_setup(char *str
, int *ints
);
324 #ifdef CONFIG_ROOT_NFS
325 extern void nfs_root_setup(char *str
, int *ints
);
328 extern void ftape_setup(char *str
, int *ints
);
330 #ifdef CONFIG_MDA_CONSOLE
331 extern void mdacon_setup(char *str
, int *ints
);
334 extern void ltpc_setup(char *str
, int *ints
);
337 #if defined(CONFIG_SYSVIPC)
338 extern void ipc_init(void);
340 #if defined(CONFIG_QUOTA)
341 extern void dquot_init_hash(void);
344 #ifdef CONFIG_MD_BOOT
345 extern void md_setup(char *str
,int *ints
) __init
;
349 * Boot command-line arguments
351 #define MAX_INIT_ARGS 8
352 #define MAX_INIT_ENVS 8
354 extern void time_init(void);
356 static unsigned long memory_start
= 0;
357 static unsigned long memory_end
= 0;
361 #ifdef CONFIG_BLK_DEV_RAM
362 extern int rd_doload
; /* 1 = load ramdisk, 0 = don't load 2 = dual disk */
363 extern int rd_prompt
; /* 1 = prompt for ramdisk, 0 = don't prompt */
364 extern int rd_size
; /* Size of the ramdisk(s) */
365 extern int rd_image_start
; /* starting block # of image */
366 #ifdef CONFIG_BLK_DEV_INITRD
367 kdev_t real_root_dev
;
371 int root_mountflags
= MS_RDONLY
;
372 char *execute_command
= NULL
;
374 static char * argv_init
[MAX_INIT_ARGS
+2] = { "init", NULL
, };
375 static char * envp_init
[MAX_INIT_ENVS
+2] = { "HOME=/", "TERM=linux", NULL
, };
377 char *get_options(char *str
, int *ints
)
382 while (cur
&& (*cur
=='-' || isdigit(*cur
)) && i
<= 10) {
383 ints
[i
++] = simple_strtol(cur
,NULL
,0);
384 if ((cur
= strchr(cur
,',')) != NULL
)
391 static void __init
profile_setup(char *str
, int *ints
)
394 prof_shift
= (unsigned long) ints
[1];
400 static struct dev_name_struct
{
403 } root_dev_names
[] __initdata
= {
404 #ifdef CONFIG_ROOT_NFS
407 #ifdef CONFIG_BLK_DEV_IDE
425 #ifdef CONFIG_BLK_DEV_SD
443 #ifdef CONFIG_ATARI_ACSI
450 #ifdef CONFIG_BLK_DEV_FD
453 #ifdef CONFIG_MD_BOOT
456 #ifdef CONFIG_BLK_DEV_XD
460 #ifdef CONFIG_BLK_DEV_RAM
463 #ifdef CONFIG_BLK_DEV_SR
470 { "cdu535", 0x1800 },
471 { "sonycd", 0x1800 },
477 { "cm206cd", 0x2000 },
485 #ifdef CONFIG_BLK_DEV_PS2
489 #ifdef CONFIG_PARIDE_PD
495 #ifdef CONFIG_PARIDE_PCD
498 #ifdef CONFIG_PARIDE_PF
502 { "apblock", APBLOCK_MAJOR
<< 8},
505 { "ddv", DDV_MAJOR
<< 8},
510 kdev_t __init
name_to_kdev_t(char *line
)
513 if (strncmp(line
,"/dev/",5) == 0) {
514 struct dev_name_struct
*dev
= root_dev_names
;
517 int len
= strlen(dev
->name
);
518 if (strncmp(line
,dev
->name
,len
) == 0) {
526 return to_kdev_t(base
+ simple_strtoul(line
,NULL
,base
?10:16));
529 static void __init
root_dev_setup(char *line
, int *num
)
531 ROOT_DEV
= name_to_kdev_t(line
);
535 * List of kernel command line parameters. The first table lists parameters
536 * which are subject to values parsing (leading numbers are converted to
537 * an array of ints and chopped off the string), the second table contains
538 * the few exceptions which obey their own syntax rules.
541 struct kernel_param
{
543 void (*setup_func
)(char *, int *);
546 static struct kernel_param cooked_params
[] __initdata
= {
547 /* FIXME: make PNP just become reserve_setup */
548 #ifndef CONFIG_KERNEL_PNP_RESOURCE
549 { "reserve=", reserve_setup
},
551 { "reserve=", pnp_reserve_setup
},
553 { "profile=", profile_setup
},
555 { "nosmp", smp_setup
},
556 { "maxcpus=", smp_setup
},
557 #ifdef CONFIG_X86_IO_APIC
558 { "noapic", ioapic_setup
},
559 { "pirq=", ioapic_pirq_setup
},
562 #ifdef CONFIG_BLK_DEV_RAM
563 { "ramdisk_start=", ramdisk_start_setup
},
564 { "load_ramdisk=", load_ramdisk
},
565 { "prompt_ramdisk=", prompt_ramdisk
},
566 { "ramdisk=", ramdisk_size
},
567 { "ramdisk_size=", ramdisk_size
},
568 #ifdef CONFIG_BLK_DEV_INITRD
569 { "noinitrd", no_initrd
},
573 { "video=", video_setup
},
575 { "panic=", panic_setup
},
576 { "console=", console_setup
},
577 #ifdef CONFIG_VGA_CONSOLE
578 { "no-scroll", no_scroll
},
580 #ifdef CONFIG_MDA_CONSOLE
581 { "mdacon=", mdacon_setup
},
584 { "kbd-reset", kbd_reset_setup
},
586 #ifdef CONFIG_BUGi386
587 { "no-hlt", no_halt
},
589 { "reboot=", reboot_setup
},
590 { "mca-pentium", mca_pentium
},
593 { "ether=", eth_setup
},
595 #ifdef CONFIG_ARCNET_COM20020
596 { "com20020=", com20020_setup
},
598 #ifdef CONFIG_ARCNET_RIM_I
599 { "arcrimi=", arcrimi_setup
},
601 #ifdef CONFIG_ARCNET_COM90xxIO
602 { "com90io=", com90io_setup
},
604 #ifdef CONFIG_ARCNET_COM90xx
605 { "com90xx=", com90xx_setup
},
608 { "decnet=", decnet_setup
},
610 #ifdef CONFIG_PRINTER
613 #ifdef CONFIG_JOY_AMIGA
614 { "js_am=", js_am_setup
},
616 #ifdef CONFIG_JOY_ANALOG
617 { "js_an=", js_an_setup
},
619 #ifdef CONFIG_JOY_ASSASIN
620 { "js_as=", js_as_setup
},
622 #ifdef CONFIG_JOY_CONSOLE
623 { "js_console=", js_console_setup
},
624 { "js_console2=", js_console_setup
},
625 { "js_console3=", js_console_setup
},
627 #ifdef CONFIG_JOY_DB9
628 { "js_db9=", js_db9_setup
},
629 { "js_db9_2=", js_db9_setup
},
630 { "js_db9_3=", js_db9_setup
},
632 #ifdef CONFIG_JOY_TURBOGRAFX
633 { "js_tg=", js_tg_setup
},
634 { "js_tg_2=", js_tg_setup
},
635 { "js_tg_3=", js_tg_setup
},
638 { "max_scsi_luns=", scsi_luns_setup
},
639 { "scsi_logging=", scsi_logging_setup
},
641 #ifdef CONFIG_JOY_LIGHTNING
642 { "js_l4=", js_l4_setup
},
644 #ifdef CONFIG_SCSI_ADVANSYS
645 { "advansys=", advansys_setup
},
647 #if defined(CONFIG_BLK_DEV_HD)
650 #ifdef CONFIG_CHR_DEV_ST
653 #ifdef CONFIG_BUSMOUSE
654 { "bmouse=", bmouse_setup
},
656 #ifdef CONFIG_MS_BUSMOUSE
657 { "msmouse=", msmouse_setup
},
659 #ifdef CONFIG_SCSI_SEAGATE
660 { "st0x=", st0x_setup
},
661 { "tmc8xx=", tmc8xx_setup
},
663 #ifdef CONFIG_SCSI_T128
664 { "t128=", t128_setup
},
666 #ifdef CONFIG_SCSI_PAS16
667 { "pas16=", pas16_setup
},
669 #ifdef CONFIG_SCSI_GENERIC_NCR5380
670 { "ncr5380=", generic_NCR5380_setup
},
671 { "ncr53c400=", generic_NCR53C400_setup
},
672 { "ncr53c400a=", generic_NCR53C400A_setup
},
673 { "dtc3181e=", generic_DTC3181E_setup
},
675 #ifdef CONFIG_SCSI_AHA152X
676 { "aha152x=", aha152x_setup
},
678 #ifdef CONFIG_SCSI_AHA1542
679 { "aha1542=", aha1542_setup
},
681 #ifdef CONFIG_SCSI_GDTH
682 { "gdth=", gdth_setup
},
684 #ifdef CONFIG_SCSI_AIC7XXX
685 { "aic7xxx=", aic7xxx_setup
},
687 #ifdef CONFIG_SCSI_BUSLOGIC
688 { "BusLogic=", BusLogic_Setup
},
690 #ifdef CONFIG_SCSI_NCR53C8XX
691 { "ncr53c8xx=", ncr53c8xx_setup
},
693 #ifdef CONFIG_SCSI_SYM53C8XX
694 { "sym53c8xx=", sym53c8xx_setup
},
696 #ifdef CONFIG_SCSI_EATA
697 { "eata=", eata2x_setup
},
699 #ifdef CONFIG_SCSI_U14_34F
700 { "u14-34f=", u14_34f_setup
},
702 #ifdef CONFIG_SCSI_AM53C974
703 { "AM53C974=", AM53C974_setup
},
705 #ifdef CONFIG_SCSI_NCR53C406A
706 { "ncr53c406a=", NCR53c406a_setup
},
708 #ifdef CONFIG_SCSI_SYM53C416
709 { "sym53c416=", sym53c416_setup
},
711 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
712 { "fdomain=", fdomain_setup
},
714 #ifdef CONFIG_SCSI_IN2000
715 { "in2000=", in2000_setup
},
717 #ifdef CONFIG_SCSI_7000FASST
718 { "wd7000=", wd7000_setup
},
720 #ifdef CONFIG_SCSI_IBMMCA
721 { "ibmmcascsi=", ibmmca_scsi_setup
},
723 #ifdef CONFIG_SCSI_FD_MCS
724 { "fd_mcs=", fd_mcs_setup
},
726 #if defined(CONFIG_SCSI_DC390T) && ! defined(CONFIG_SCSI_DC390T_NOGENSUPP)
727 { "tmscsim=", dc390_setup
},
729 #ifdef CONFIG_BLK_DEV_XD
731 { "xd_geo=", xd_manual_geo_init
},
733 #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
734 { "floppy=", floppy_setup
},
736 #ifdef CONFIG_BLK_DEV_PS2
737 { "eda=", ed_setup
},
738 { "edb=", ed_setup
},
739 { "tp720=", tp720_setup
},
742 { "cdu31a=", cdu31a_setup
},
745 { "mcd=", mcd_setup
},
748 { "mcdx=", mcdx_setup
},
751 { "sbpcd=", sbpcd_setup
},
754 { "aztcd=", aztcd_setup
},
757 { "sonycd535=", sonycd535_setup
},
760 { "gscd=", gscd_setup
},
763 { "cm206=", cm206_setup
},
766 { "optcd=", optcd_setup
},
769 { "sjcd=", sjcd_setup
},
771 #ifdef CONFIG_ISP16_CDI
772 { "isp16=", isp16_setup
},
773 #endif CONFIG_ISP16_CDI
774 #ifdef CONFIG_SOUND_OSS
775 { "sound=", sound_setup
},
777 #ifdef CONFIG_ISDN_DRV_ICN
778 { "icn=", icn_setup
},
780 #ifdef CONFIG_ISDN_DRV_HISAX
781 { "hisax=", HiSax_setup
},
782 { "HiSax=", HiSax_setup
},
784 #ifdef CONFIG_ISDN_DRV_PCBIT
785 { "pcbit=", pcbit_setup
},
787 #ifdef CONFIG_ATARIMOUSE
788 { "atamouse=", atari_mouse_setup
},
790 #ifdef CONFIG_DMASOUND
791 { "dmasound=", dmasound_setup
},
793 #ifdef CONFIG_ATARI_SCSI
794 { "atascsi=", atari_scsi_setup
},
796 #ifdef CONFIG_STRAM_SWAP
797 { "stram_swap=", stram_swap_setup
},
799 #if defined(CONFIG_A4000T_SCSI) || defined(CONFIG_WARPENGINE_SCSI) \
800 || defined(CONFIG_A4091_SCSI) || defined(CONFIG_MVME16x_SCSI) \
801 || defined(CONFIG_BVME6000_SCSI) \
802 || defined(CONFIG_BLZ603EPLUS_SCSI)
803 { "53c7xx=", ncr53c7xx_setup
},
805 #if defined(CONFIG_A3000_SCSI) || defined(CONFIG_A2091_SCSI) \
806 || defined(CONFIG_GVP11_SCSI)
807 { "wd33c93=", wd33c93_setup
},
809 #if defined(CONFIG_GVP11_SCSI)
810 { "gvp11=", gvp11_setup
},
812 #ifdef CONFIG_MAC_SCSI
813 { "mac5380=", mac_scsi_setup
},
815 #ifdef CONFIG_CYCLADES
816 { "cyclades=", cy_setup
},
819 { "digi=", pcxx_setup
},
821 #ifdef CONFIG_DIGIEPCA
822 { "digiepca=", epca_setup
},
824 #ifdef CONFIG_RISCOM8
825 { "riscom8=", riscom8_setup
},
828 { "dmascc=", dmascc_setup
},
830 #ifdef CONFIG_SPECIALIX
831 { "specialix=", specialix_setup
},
833 #ifdef CONFIG_BAYCOM_PAR
834 { "baycom_par=", baycom_par_setup
},
836 #ifdef CONFIG_BAYCOM_SER_FDX
837 { "baycom_ser_fdx=", baycom_ser_fdx_setup
},
839 #ifdef CONFIG_BAYCOM_SER_HDX
840 { "baycom_ser_hdx=", baycom_ser_hdx_setup
},
842 #ifdef CONFIG_SOUNDMODEM
843 { "soundmodem=", sm_setup
},
846 { "wdt=", wdt_setup
},
848 #ifdef CONFIG_PARPORT
849 { "parport=", parport_setup
},
852 { "plip=", plip_setup
},
854 #ifdef CONFIG_HFMODEM
855 { "hfmodem=", hfmodem_setup
},
858 { "ftape=", ftape_setup
},
860 #ifdef CONFIG_MD_BOOT
863 #ifdef CONFIG_ADBMOUSE
864 { "adb_buttons=", adb_mouse_setup
},
867 { "ltpc=", ltpc_setup
},
872 static struct kernel_param raw_params
[] __initdata
= {
873 { "root=", root_dev_setup
},
874 #ifdef CONFIG_ROOT_NFS
875 { "nfsroot=", nfs_root_setup
},
876 { "nfsaddrs=", ip_auto_config_setup
},
879 { "ip=", ip_auto_config_setup
},
882 { "pci=", pci_setup
},
884 #ifdef CONFIG_PARIDE_PD
887 #ifdef CONFIG_PARIDE_PCD
888 { "pcd.", pcd_setup
},
890 #ifdef CONFIG_PARIDE_PF
893 #ifdef CONFIG_PARIDE_PT
896 #ifdef CONFIG_PARIDE_PG
900 { "apm=", apm_setup
},
905 #ifdef CONFIG_BLK_DEV_RAM
906 static void __init
ramdisk_start_setup(char *str
, int *ints
)
908 if (ints
[0] > 0 && ints
[1] >= 0)
909 rd_image_start
= ints
[1];
912 static void __init
load_ramdisk(char *str
, int *ints
)
914 if (ints
[0] > 0 && ints
[1] >= 0)
915 rd_doload
= ints
[1] & 3;
918 static void __init
prompt_ramdisk(char *str
, int *ints
)
920 if (ints
[0] > 0 && ints
[1] >= 0)
921 rd_prompt
= ints
[1] & 1;
924 static void __init
ramdisk_size(char *str
, int *ints
)
926 if (ints
[0] > 0 && ints
[1] >= 0)
931 static int __init
checksetup(char *line
)
935 #ifdef CONFIG_BLK_DEV_IDE
936 /* ide driver needs the basic string, rather than pre-processed values */
937 if (!strncmp(line
,"ide",3) ||
938 #ifdef CONFIG_BLK_DEV_VIA82C586
939 !strncmp(line
,"splitfifo",9) ||
940 #endif /* CONFIG_BLK_DEV_VIA82C586 */
941 (!strncmp(line
,"hd",2) && line
[2] != '=')) {
946 for (i
=0; raw_params
[i
].str
; i
++) {
947 int n
= strlen(raw_params
[i
].str
);
948 if (!strncmp(line
,raw_params
[i
].str
,n
)) {
949 raw_params
[i
].setup_func(line
+n
, NULL
);
953 for (i
=0; cooked_params
[i
].str
; i
++) {
954 int n
= strlen(cooked_params
[i
].str
);
955 if (!strncmp(line
,cooked_params
[i
].str
,n
)) {
956 cooked_params
[i
].setup_func(get_options(line
+n
, ints
), ints
);
963 /* this should be approx 2 Bo*oMips to start (note initial shift), and will
964 still work even if initially too large, it will just take slightly longer */
965 unsigned long loops_per_sec
= (1<<12);
967 /* This is the number of bits of precision for the loops_per_second. Each
968 bit takes on average 1.5/HZ seconds. This (like the original) is a little
972 void __init
calibrate_delay(void)
974 unsigned long ticks
, loopbit
;
975 int lps_precision
= LPS_PREC
;
977 loops_per_sec
= (1<<12);
979 printk("Calibrating delay loop... ");
980 while (loops_per_sec
<<= 1) {
981 /* wait for "start of" clock tick */
983 while (ticks
== jiffies
)
987 __delay(loops_per_sec
);
988 ticks
= jiffies
- ticks
;
993 /* Do a binary approximation to get loops_per_second set to equal one clock
994 (up to lps_precision bits) */
996 loopbit
= loops_per_sec
;
997 while ( lps_precision
-- && (loopbit
>>= 1) ) {
998 loops_per_sec
|= loopbit
;
1000 while (ticks
== jiffies
);
1002 __delay(loops_per_sec
);
1003 if (jiffies
!= ticks
) /* longer than 1 tick */
1004 loops_per_sec
&= ~loopbit
;
1007 /* finally, adjust loops per second in terms of seconds instead of clocks */
1008 loops_per_sec
*= HZ
;
1009 /* Round the value and print it */
1010 printk("%lu.%02lu BogoMIPS\n",
1011 (loops_per_sec
+2500)/500000,
1012 ((loops_per_sec
+2500)/5000) % 100);
1016 * This is a simple kernel command line parsing function: it parses
1017 * the command line, and fills in the arguments/environment to init
1018 * as appropriate. Any cmd-line option is taken to be an environment
1019 * variable if it contains the character '='.
1021 * This routine also checks for options meant for the kernel.
1022 * These options are not given to init - they are for internal kernel use only.
1024 static void __init
parse_options(char *line
)
1032 envs
= 1; /* TERM is set to 'linux' by default */
1034 while ((line
= next
) != NULL
) {
1035 if ((next
= strchr(line
,' ')) != NULL
)
1038 * check for kernel options first..
1040 if (!strcmp(line
,"ro")) {
1041 root_mountflags
|= MS_RDONLY
;
1044 if (!strcmp(line
,"rw")) {
1045 root_mountflags
&= ~MS_RDONLY
;
1048 if (!strcmp(line
,"debug")) {
1049 console_loglevel
= 10;
1052 if (!strncmp(line
,"init=",5)) {
1054 execute_command
= line
;
1055 /* In case LILO is going to boot us with default command line,
1056 * it prepends "auto" before the whole cmdline which makes
1057 * the shell think it should execute a script with such name.
1058 * So we ignore all arguments entered _before_ init=... [MJ]
1063 if (checksetup(line
))
1067 * Then check if it's an environment variable or
1070 if (strchr(line
,'=')) {
1071 if (envs
>= MAX_INIT_ENVS
)
1073 envp_init
[++envs
] = line
;
1075 if (args
>= MAX_INIT_ARGS
)
1077 argv_init
[++args
] = line
;
1080 argv_init
[args
+1] = NULL
;
1081 envp_init
[envs
+1] = NULL
;
1085 extern void setup_arch(char **, unsigned long *, unsigned long *);
1090 * Uniprocessor idle thread
1093 int cpu_idle(void *unused
)
1099 #define smp_init() do { } while (0)
1104 * Multiprocessor idle thread is in arch/...
1107 extern int cpu_idle(void * unused
);
1109 /* Called by boot processor to activate the rest. */
1110 static void __init
smp_init(void)
1112 /* Get other processors into their bootup holding patterns. */
1114 smp_threads_ready
=1;
1120 extern void initialize_secondary(void);
1123 * Activate the first processor.
1126 asmlinkage
void __init
start_kernel(void)
1128 char * command_line
;
1131 static int boot_cpu
= 1;
1132 /* "current" has been set up, we need to load it now */
1134 initialize_secondary();
1139 * Interrupts are still disabled. Do necessary setups, then
1142 printk(linux_banner
);
1143 setup_arch(&command_line
, &memory_start
, &memory_end
);
1144 memory_start
= paging_init(memory_start
,memory_end
);
1149 parse_options(command_line
);
1152 * HACK ALERT! This is early. We're enabling the console before
1153 * we've done PCI setups etc, and console_init() must be aware of
1154 * this. But we do want output early, in case something goes wrong.
1156 memory_start
= console_init(memory_start
,memory_end
);
1157 #ifdef CONFIG_MODULES
1161 prof_buffer
= (unsigned int *) memory_start
;
1162 /* only text is profiled */
1163 prof_len
= (unsigned long) &_etext
- (unsigned long) &_stext
;
1164 prof_len
>>= prof_shift
;
1165 memory_start
+= prof_len
* sizeof(unsigned int);
1166 memset(prof_buffer
, 0, prof_len
* sizeof(unsigned int));
1169 memory_start
= kmem_cache_init(memory_start
, memory_end
);
1172 #ifdef CONFIG_BLK_DEV_INITRD
1173 if (initrd_start
&& !initrd_below_start_ok
&& initrd_start
< memory_start
) {
1174 printk(KERN_CRIT
"initrd overwritten (0x%08lx < 0x%08lx) - "
1175 "disabling it.\n",initrd_start
,memory_start
);
1179 mem_init(memory_start
,memory_end
);
1180 kmem_cache_sizes_init();
1181 #ifdef CONFIG_PROC_FS
1188 buffer_init(memory_end
-memory_start
);
1192 #if defined(CONFIG_SYSVIPC)
1195 #if defined(CONFIG_QUOTA)
1199 printk("POSIX conformance testing by UNIFIX\n");
1202 * We count on the initial thread going ok
1203 * Like idlers init is an unlocked kernel thread, which will
1204 * make syscalls (and thus be locked).
1207 kernel_thread(init
, NULL
, CLONE_FS
| CLONE_FILES
| CLONE_SIGHAND
);
1208 current
->need_resched
= 1;
1212 #ifdef CONFIG_BLK_DEV_INITRD
1213 static int do_linuxrc(void * shell
)
1215 static char *argv
[] = { "linuxrc", NULL
, };
1217 close(0);close(1);close(2);
1219 (void) open("/dev/console",O_RDWR
,0);
1222 return execve(shell
, argv
, envp_init
);
1225 static void __init
no_initrd(char *s
,int *ints
)
1231 struct task_struct
*child_reaper
= &init_task
;
1234 * Ok, the machine is now initialized. None of the devices
1235 * have been touched yet, but the CPU subsystem is up and
1236 * running, and memory and process management works.
1238 * Now we can finally start doing some real work..
1240 static void __init
do_basic_setup(void)
1242 #ifdef CONFIG_BLK_DEV_INITRD
1243 int real_root_mountflags
;
1247 * Tell the world that we're going to be the grim
1248 * reaper of innocent orphaned children.
1250 * We don't want people to have to make incorrect
1251 * assumptions about where in the task array this
1254 child_reaper
= current
;
1256 #if defined(CONFIG_MTRR) /* Do this after SMP initialization */
1258 * We should probably create some architecture-dependent "fixup after
1259 * everything is up" style function where this would belong better
1260 * than in init/main.c..
1265 #ifdef CONFIG_SYSCTL
1270 * Ok, at this point all CPU's should be initialized, so
1271 * we can start looking into devices..
1279 #if defined(CONFIG_PPC)
1285 #ifdef CONFIG_ARCH_ACORN
1298 /* Networking initialization needs a process context */
1301 /* Launch bdflush from here, instead of the old syscall way. */
1302 kernel_thread(bdflush
, NULL
, CLONE_FS
| CLONE_FILES
| CLONE_SIGHAND
);
1303 /* Start the background pageout daemon. */
1305 kernel_thread(kpiod
, NULL
, CLONE_FS
| CLONE_FILES
| CLONE_SIGHAND
);
1306 kernel_thread(kswapd
, NULL
, CLONE_FS
| CLONE_FILES
| CLONE_SIGHAND
);
1309 /* Start the async paging daemon. */
1311 extern int asyncd(void *);
1312 kernel_thread(asyncd
, NULL
, CLONE_FS
| CLONE_FILES
| CLONE_SIGHAND
);
1316 #ifdef CONFIG_BLK_DEV_INITRD
1318 real_root_dev
= ROOT_DEV
;
1319 real_root_mountflags
= root_mountflags
;
1320 if (initrd_start
&& mount_initrd
) root_mountflags
&= ~MS_RDONLY
;
1321 else mount_initrd
=0;
1324 /* Set up devices .. */
1327 /* .. executable formats .. */
1330 /* .. filesystems .. */
1333 /* Mount the root filesystem.. */
1336 #ifdef CONFIG_BLK_DEV_INITRD
1337 root_mountflags
= real_root_mountflags
;
1338 if (mount_initrd
&& ROOT_DEV
!= real_root_dev
1339 && MAJOR(ROOT_DEV
) == RAMDISK_MAJOR
&& MINOR(ROOT_DEV
) == 0) {
1343 pid
= kernel_thread(do_linuxrc
, "/linuxrc", SIGCHLD
);
1345 while (pid
!= wait(&i
));
1346 if (MAJOR(real_root_dev
) != RAMDISK_MAJOR
1347 || MINOR(real_root_dev
) != 0) {
1348 error
= change_root(real_root_dev
,"/initrd");
1350 printk(KERN_ERR
"Change root to /initrd: "
1351 "error %d\n",error
);
1357 static int init(void * unused
)
1363 * Ok, we have completed the initial bootup, and
1364 * we're essentially up and running. Get rid of the
1365 * initmem segments and start the user-mode stuff..
1370 if (open("/dev/console", O_RDWR
, 0) < 0)
1371 printk("Warning: unable to open an initial console.\n");
1377 * We try each of these until one succeeds.
1379 * The Bourne shell can be used instead of init if we are
1380 * trying to recover a really broken machine.
1383 if (execute_command
)
1384 execve(execute_command
,argv_init
,envp_init
);
1385 execve("/sbin/init",argv_init
,envp_init
);
1386 execve("/etc/init",argv_init
,envp_init
);
1387 execve("/bin/init",argv_init
,envp_init
);
1388 execve("/bin/sh",argv_init
,envp_init
);
1389 panic("No init found. Try passing init= option to kernel.");