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>
26 #include <linux/iobuf.h>
32 #include <linux/pci.h>
36 #include <linux/dio.h>
40 #include <linux/zorro.h>
44 # include <asm/mtrr.h>
48 #include <linux/apm_bios.h>
52 extern void nubus_init(void);
56 * Versions of gcc older than that listed below may actually compile
57 * and link okay, but the end product can have subtle run time bugs.
58 * To avoid associated bogus bug reports, we flatly refuse to compile
59 * with a gcc that is known to be too old from the very beginning.
61 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
62 #error sorry, your GCC is too old. It builds incorrect kernels.
65 extern char _stext
, _etext
;
66 extern char *linux_banner
;
68 extern int console_loglevel
;
70 static int init(void *);
71 extern int bdflush(void *);
72 extern int kswapd(void *);
73 extern void kswapd_setup(void);
75 extern void init_IRQ(void);
76 extern void init_modules(void);
77 extern long console_init(long, long);
78 extern void sock_init(void);
79 extern void fork_init(unsigned long);
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
);
336 #ifdef CONFIG_BLK_CPQ_DA
337 extern void cpqarray_setup(char *str
, int *ints
);
340 #if defined(CONFIG_SYSVIPC)
341 extern void ipc_init(void);
343 #if defined(CONFIG_QUOTA)
344 extern void dquot_init_hash(void);
347 #ifdef CONFIG_MD_BOOT
348 extern void md_setup(char *str
,int *ints
) __init
;
352 * Boot command-line arguments
354 #define MAX_INIT_ARGS 8
355 #define MAX_INIT_ENVS 8
357 extern void time_init(void);
359 static unsigned long memory_start
= 0;
360 static unsigned long memory_end
= 0;
364 #ifdef CONFIG_BLK_DEV_RAM
365 extern int rd_doload
; /* 1 = load ramdisk, 0 = don't load 2 = dual disk */
366 extern int rd_prompt
; /* 1 = prompt for ramdisk, 0 = don't prompt */
367 extern int rd_size
; /* Size of the ramdisk(s) */
368 extern int rd_image_start
; /* starting block # of image */
369 #ifdef CONFIG_BLK_DEV_INITRD
370 kdev_t real_root_dev
;
374 int root_mountflags
= MS_RDONLY
;
375 char *execute_command
= NULL
;
377 static char * argv_init
[MAX_INIT_ARGS
+2] = { "init", NULL
, };
378 static char * envp_init
[MAX_INIT_ENVS
+2] = { "HOME=/", "TERM=linux", NULL
, };
380 char *get_options(char *str
, int *ints
)
385 while (cur
&& (*cur
=='-' || isdigit(*cur
)) && i
<= 10) {
386 ints
[i
++] = simple_strtol(cur
,NULL
,0);
387 if ((cur
= strchr(cur
,',')) != NULL
)
394 static void __init
profile_setup(char *str
, int *ints
)
397 prof_shift
= (unsigned long) ints
[1];
403 static struct dev_name_struct
{
406 } root_dev_names
[] __initdata
= {
407 #ifdef CONFIG_ROOT_NFS
410 #ifdef CONFIG_BLK_DEV_IDE
428 #ifdef CONFIG_BLK_DEV_SD
446 #ifdef CONFIG_ATARI_ACSI
453 #ifdef CONFIG_BLK_DEV_FD
456 #ifdef CONFIG_MD_BOOT
459 #ifdef CONFIG_BLK_DEV_XD
463 #ifdef CONFIG_BLK_DEV_RAM
466 #ifdef CONFIG_BLK_DEV_SR
473 { "cdu535", 0x1800 },
474 { "sonycd", 0x1800 },
480 { "cm206cd", 0x2000 },
488 #ifdef CONFIG_BLK_DEV_PS2
492 #ifdef CONFIG_PARIDE_PD
498 #ifdef CONFIG_PARIDE_PCD
501 #ifdef CONFIG_PARIDE_PF
505 { "apblock", APBLOCK_MAJOR
<< 8},
508 { "ddv", DDV_MAJOR
<< 8},
513 kdev_t __init
name_to_kdev_t(char *line
)
516 if (strncmp(line
,"/dev/",5) == 0) {
517 struct dev_name_struct
*dev
= root_dev_names
;
520 int len
= strlen(dev
->name
);
521 if (strncmp(line
,dev
->name
,len
) == 0) {
529 return to_kdev_t(base
+ simple_strtoul(line
,NULL
,base
?10:16));
532 static void __init
root_dev_setup(char *line
, int *num
)
534 ROOT_DEV
= name_to_kdev_t(line
);
538 * List of kernel command line parameters. The first table lists parameters
539 * which are subject to values parsing (leading numbers are converted to
540 * an array of ints and chopped off the string), the second table contains
541 * the few exceptions which obey their own syntax rules.
544 struct kernel_param
{
546 void (*setup_func
)(char *, int *);
549 static struct kernel_param cooked_params
[] __initdata
= {
550 /* FIXME: make PNP just become reserve_setup */
551 #ifndef CONFIG_KERNEL_PNP_RESOURCE
552 { "reserve=", reserve_setup
},
554 { "reserve=", pnp_reserve_setup
},
556 { "profile=", profile_setup
},
558 { "nosmp", smp_setup
},
559 { "maxcpus=", smp_setup
},
560 #ifdef CONFIG_X86_IO_APIC
561 { "noapic", ioapic_setup
},
562 { "pirq=", ioapic_pirq_setup
},
565 #ifdef CONFIG_BLK_DEV_RAM
566 { "ramdisk_start=", ramdisk_start_setup
},
567 { "load_ramdisk=", load_ramdisk
},
568 { "prompt_ramdisk=", prompt_ramdisk
},
569 { "ramdisk=", ramdisk_size
},
570 { "ramdisk_size=", ramdisk_size
},
571 #ifdef CONFIG_BLK_DEV_INITRD
572 { "noinitrd", no_initrd
},
576 { "video=", video_setup
},
578 { "panic=", panic_setup
},
579 { "console=", console_setup
},
580 #ifdef CONFIG_VGA_CONSOLE
581 { "no-scroll", no_scroll
},
583 #ifdef CONFIG_MDA_CONSOLE
584 { "mdacon=", mdacon_setup
},
587 { "kbd-reset", kbd_reset_setup
},
589 #ifdef CONFIG_BUGi386
590 { "no-hlt", no_halt
},
592 { "reboot=", reboot_setup
},
593 { "mca-pentium", mca_pentium
},
596 { "ether=", eth_setup
},
598 #ifdef CONFIG_ARCNET_COM20020
599 { "com20020=", com20020_setup
},
601 #ifdef CONFIG_ARCNET_RIM_I
602 { "arcrimi=", arcrimi_setup
},
604 #ifdef CONFIG_ARCNET_COM90xxIO
605 { "com90io=", com90io_setup
},
607 #ifdef CONFIG_ARCNET_COM90xx
608 { "com90xx=", com90xx_setup
},
611 { "decnet=", decnet_setup
},
613 #ifdef CONFIG_PRINTER
616 #ifdef CONFIG_JOY_AMIGA
617 { "js_am=", js_am_setup
},
619 #ifdef CONFIG_JOY_ANALOG
620 { "js_an=", js_an_setup
},
622 #ifdef CONFIG_JOY_ASSASIN
623 { "js_as=", js_as_setup
},
625 #ifdef CONFIG_JOY_CONSOLE
626 { "js_console=", js_console_setup
},
627 { "js_console2=", js_console_setup
},
628 { "js_console3=", js_console_setup
},
630 #ifdef CONFIG_JOY_DB9
631 { "js_db9=", js_db9_setup
},
632 { "js_db9_2=", js_db9_setup
},
633 { "js_db9_3=", js_db9_setup
},
635 #ifdef CONFIG_JOY_TURBOGRAFX
636 { "js_tg=", js_tg_setup
},
637 { "js_tg_2=", js_tg_setup
},
638 { "js_tg_3=", js_tg_setup
},
641 { "max_scsi_luns=", scsi_luns_setup
},
642 { "scsi_logging=", scsi_logging_setup
},
644 #ifdef CONFIG_JOY_LIGHTNING
645 { "js_l4=", js_l4_setup
},
647 #ifdef CONFIG_SCSI_ADVANSYS
648 { "advansys=", advansys_setup
},
650 #if defined(CONFIG_BLK_DEV_HD)
653 #ifdef CONFIG_CHR_DEV_ST
656 #ifdef CONFIG_BUSMOUSE
657 { "bmouse=", bmouse_setup
},
659 #ifdef CONFIG_MS_BUSMOUSE
660 { "msmouse=", msmouse_setup
},
662 #ifdef CONFIG_SCSI_SEAGATE
663 { "st0x=", st0x_setup
},
664 { "tmc8xx=", tmc8xx_setup
},
666 #ifdef CONFIG_SCSI_T128
667 { "t128=", t128_setup
},
669 #ifdef CONFIG_SCSI_PAS16
670 { "pas16=", pas16_setup
},
672 #ifdef CONFIG_SCSI_GENERIC_NCR5380
673 { "ncr5380=", generic_NCR5380_setup
},
674 { "ncr53c400=", generic_NCR53C400_setup
},
675 { "ncr53c400a=", generic_NCR53C400A_setup
},
676 { "dtc3181e=", generic_DTC3181E_setup
},
678 #ifdef CONFIG_SCSI_AHA152X
679 { "aha152x=", aha152x_setup
},
681 #ifdef CONFIG_SCSI_AHA1542
682 { "aha1542=", aha1542_setup
},
684 #ifdef CONFIG_SCSI_GDTH
685 { "gdth=", gdth_setup
},
687 #ifdef CONFIG_SCSI_AIC7XXX
688 { "aic7xxx=", aic7xxx_setup
},
690 #ifdef CONFIG_SCSI_BUSLOGIC
691 { "BusLogic=", BusLogic_Setup
},
693 #ifdef CONFIG_SCSI_NCR53C8XX
694 { "ncr53c8xx=", ncr53c8xx_setup
},
696 #ifdef CONFIG_SCSI_SYM53C8XX
697 { "sym53c8xx=", sym53c8xx_setup
},
699 #ifdef CONFIG_SCSI_EATA
700 { "eata=", eata2x_setup
},
702 #ifdef CONFIG_SCSI_U14_34F
703 { "u14-34f=", u14_34f_setup
},
705 #ifdef CONFIG_SCSI_AM53C974
706 { "AM53C974=", AM53C974_setup
},
708 #ifdef CONFIG_SCSI_NCR53C406A
709 { "ncr53c406a=", NCR53c406a_setup
},
711 #ifdef CONFIG_SCSI_SYM53C416
712 { "sym53c416=", sym53c416_setup
},
714 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
715 { "fdomain=", fdomain_setup
},
717 #ifdef CONFIG_SCSI_IN2000
718 { "in2000=", in2000_setup
},
720 #ifdef CONFIG_SCSI_7000FASST
721 { "wd7000=", wd7000_setup
},
723 #ifdef CONFIG_SCSI_IBMMCA
724 { "ibmmcascsi=", ibmmca_scsi_setup
},
726 #ifdef CONFIG_SCSI_FD_MCS
727 { "fd_mcs=", fd_mcs_setup
},
729 #if defined(CONFIG_SCSI_DC390T) && ! defined(CONFIG_SCSI_DC390T_NOGENSUPP)
730 { "tmscsim=", dc390_setup
},
732 #ifdef CONFIG_BLK_DEV_XD
734 { "xd_geo=", xd_manual_geo_init
},
736 #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
737 { "floppy=", floppy_setup
},
739 #ifdef CONFIG_BLK_DEV_PS2
740 { "eda=", ed_setup
},
741 { "edb=", ed_setup
},
742 { "tp720=", tp720_setup
},
745 { "cdu31a=", cdu31a_setup
},
748 { "mcd=", mcd_setup
},
751 { "mcdx=", mcdx_setup
},
754 { "sbpcd=", sbpcd_setup
},
757 { "aztcd=", aztcd_setup
},
760 { "sonycd535=", sonycd535_setup
},
763 { "gscd=", gscd_setup
},
766 { "cm206=", cm206_setup
},
769 { "optcd=", optcd_setup
},
772 { "sjcd=", sjcd_setup
},
774 #ifdef CONFIG_ISP16_CDI
775 { "isp16=", isp16_setup
},
776 #endif CONFIG_ISP16_CDI
777 #ifdef CONFIG_SOUND_OSS
778 { "sound=", sound_setup
},
780 #ifdef CONFIG_ISDN_DRV_ICN
781 { "icn=", icn_setup
},
783 #ifdef CONFIG_ISDN_DRV_HISAX
784 { "hisax=", HiSax_setup
},
785 { "HiSax=", HiSax_setup
},
787 #ifdef CONFIG_ISDN_DRV_PCBIT
788 { "pcbit=", pcbit_setup
},
790 #ifdef CONFIG_ATARIMOUSE
791 { "atamouse=", atari_mouse_setup
},
793 #ifdef CONFIG_DMASOUND
794 { "dmasound=", dmasound_setup
},
796 #ifdef CONFIG_ATARI_SCSI
797 { "atascsi=", atari_scsi_setup
},
799 #ifdef CONFIG_STRAM_SWAP
800 { "stram_swap=", stram_swap_setup
},
802 #if defined(CONFIG_A4000T_SCSI) || defined(CONFIG_WARPENGINE_SCSI) \
803 || defined(CONFIG_A4091_SCSI) || defined(CONFIG_MVME16x_SCSI) \
804 || defined(CONFIG_BVME6000_SCSI) \
805 || defined(CONFIG_BLZ603EPLUS_SCSI)
806 { "53c7xx=", ncr53c7xx_setup
},
808 #if defined(CONFIG_A3000_SCSI) || defined(CONFIG_A2091_SCSI) \
809 || defined(CONFIG_GVP11_SCSI)
810 { "wd33c93=", wd33c93_setup
},
812 #if defined(CONFIG_GVP11_SCSI)
813 { "gvp11=", gvp11_setup
},
815 #ifdef CONFIG_MAC_SCSI
816 { "mac5380=", mac_scsi_setup
},
818 #ifdef CONFIG_CYCLADES
819 { "cyclades=", cy_setup
},
822 { "digi=", pcxx_setup
},
824 #ifdef CONFIG_DIGIEPCA
825 { "digiepca=", epca_setup
},
827 #ifdef CONFIG_RISCOM8
828 { "riscom8=", riscom8_setup
},
831 { "dmascc=", dmascc_setup
},
833 #ifdef CONFIG_SPECIALIX
834 { "specialix=", specialix_setup
},
836 #ifdef CONFIG_BAYCOM_PAR
837 { "baycom_par=", baycom_par_setup
},
839 #ifdef CONFIG_BAYCOM_SER_FDX
840 { "baycom_ser_fdx=", baycom_ser_fdx_setup
},
842 #ifdef CONFIG_BAYCOM_SER_HDX
843 { "baycom_ser_hdx=", baycom_ser_hdx_setup
},
845 #ifdef CONFIG_SOUNDMODEM
846 { "soundmodem=", sm_setup
},
849 { "wdt=", wdt_setup
},
851 #ifdef CONFIG_PARPORT
852 { "parport=", parport_setup
},
855 { "plip=", plip_setup
},
857 #ifdef CONFIG_HFMODEM
858 { "hfmodem=", hfmodem_setup
},
861 { "ftape=", ftape_setup
},
863 #ifdef CONFIG_MD_BOOT
866 #ifdef CONFIG_ADBMOUSE
867 { "adb_buttons=", adb_mouse_setup
},
870 { "ltpc=", ltpc_setup
},
872 #ifdef CONFIG_BLK_CPQ_DA
873 { "smart2=", cpqarray_setup
},
878 static struct kernel_param raw_params
[] __initdata
= {
879 { "root=", root_dev_setup
},
880 #ifdef CONFIG_ROOT_NFS
881 { "nfsroot=", nfs_root_setup
},
882 { "nfsaddrs=", ip_auto_config_setup
},
885 { "ip=", ip_auto_config_setup
},
888 { "pci=", pci_setup
},
890 #ifdef CONFIG_PARIDE_PD
893 #ifdef CONFIG_PARIDE_PCD
894 { "pcd.", pcd_setup
},
896 #ifdef CONFIG_PARIDE_PF
899 #ifdef CONFIG_PARIDE_PT
902 #ifdef CONFIG_PARIDE_PG
906 { "apm=", apm_setup
},
911 #ifdef CONFIG_BLK_DEV_RAM
912 static void __init
ramdisk_start_setup(char *str
, int *ints
)
914 if (ints
[0] > 0 && ints
[1] >= 0)
915 rd_image_start
= ints
[1];
918 static void __init
load_ramdisk(char *str
, int *ints
)
920 if (ints
[0] > 0 && ints
[1] >= 0)
921 rd_doload
= ints
[1] & 3;
924 static void __init
prompt_ramdisk(char *str
, int *ints
)
926 if (ints
[0] > 0 && ints
[1] >= 0)
927 rd_prompt
= ints
[1] & 1;
930 static void __init
ramdisk_size(char *str
, int *ints
)
932 if (ints
[0] > 0 && ints
[1] >= 0)
937 static int __init
checksetup(char *line
)
941 #ifdef CONFIG_BLK_DEV_IDE
942 /* ide driver needs the basic string, rather than pre-processed values */
943 if (!strncmp(line
,"ide",3) ||
944 #ifdef CONFIG_BLK_DEV_VIA82C586
945 !strncmp(line
,"splitfifo",9) ||
946 #endif /* CONFIG_BLK_DEV_VIA82C586 */
947 (!strncmp(line
,"hd",2) && line
[2] != '=')) {
952 for (i
=0; raw_params
[i
].str
; i
++) {
953 int n
= strlen(raw_params
[i
].str
);
954 if (!strncmp(line
,raw_params
[i
].str
,n
)) {
955 raw_params
[i
].setup_func(line
+n
, NULL
);
959 for (i
=0; cooked_params
[i
].str
; i
++) {
960 int n
= strlen(cooked_params
[i
].str
);
961 if (!strncmp(line
,cooked_params
[i
].str
,n
)) {
962 cooked_params
[i
].setup_func(get_options(line
+n
, ints
), ints
);
969 /* this should be approx 2 Bo*oMips to start (note initial shift), and will
970 still work even if initially too large, it will just take slightly longer */
971 unsigned long loops_per_sec
= (1<<12);
973 /* This is the number of bits of precision for the loops_per_second. Each
974 bit takes on average 1.5/HZ seconds. This (like the original) is a little
978 void __init
calibrate_delay(void)
980 unsigned long ticks
, loopbit
;
981 int lps_precision
= LPS_PREC
;
983 loops_per_sec
= (1<<12);
985 printk("Calibrating delay loop... ");
986 while (loops_per_sec
<<= 1) {
987 /* wait for "start of" clock tick */
989 while (ticks
== jiffies
)
993 __delay(loops_per_sec
);
994 ticks
= jiffies
- ticks
;
999 /* Do a binary approximation to get loops_per_second set to equal one clock
1000 (up to lps_precision bits) */
1001 loops_per_sec
>>= 1;
1002 loopbit
= loops_per_sec
;
1003 while ( lps_precision
-- && (loopbit
>>= 1) ) {
1004 loops_per_sec
|= loopbit
;
1006 while (ticks
== jiffies
);
1008 __delay(loops_per_sec
);
1009 if (jiffies
!= ticks
) /* longer than 1 tick */
1010 loops_per_sec
&= ~loopbit
;
1013 /* finally, adjust loops per second in terms of seconds instead of clocks */
1014 loops_per_sec
*= HZ
;
1015 /* Round the value and print it */
1016 printk("%lu.%02lu BogoMIPS\n",
1017 (loops_per_sec
+2500)/500000,
1018 ((loops_per_sec
+2500)/5000) % 100);
1022 * This is a simple kernel command line parsing function: it parses
1023 * the command line, and fills in the arguments/environment to init
1024 * as appropriate. Any cmd-line option is taken to be an environment
1025 * variable if it contains the character '='.
1027 * This routine also checks for options meant for the kernel.
1028 * These options are not given to init - they are for internal kernel use only.
1030 static void __init
parse_options(char *line
)
1038 envs
= 1; /* TERM is set to 'linux' by default */
1040 while ((line
= next
) != NULL
) {
1041 if ((next
= strchr(line
,' ')) != NULL
)
1044 * check for kernel options first..
1046 if (!strcmp(line
,"ro")) {
1047 root_mountflags
|= MS_RDONLY
;
1050 if (!strcmp(line
,"rw")) {
1051 root_mountflags
&= ~MS_RDONLY
;
1054 if (!strcmp(line
,"debug")) {
1055 console_loglevel
= 10;
1058 if (!strncmp(line
,"init=",5)) {
1060 execute_command
= line
;
1061 /* In case LILO is going to boot us with default command line,
1062 * it prepends "auto" before the whole cmdline which makes
1063 * the shell think it should execute a script with such name.
1064 * So we ignore all arguments entered _before_ init=... [MJ]
1069 if (checksetup(line
))
1073 * Then check if it's an environment variable or
1076 if (strchr(line
,'=')) {
1077 if (envs
>= MAX_INIT_ENVS
)
1079 envp_init
[++envs
] = line
;
1081 if (args
>= MAX_INIT_ARGS
)
1083 argv_init
[++args
] = line
;
1086 argv_init
[args
+1] = NULL
;
1087 envp_init
[envs
+1] = NULL
;
1091 extern void setup_arch(char **, unsigned long *, unsigned long *);
1092 extern int cpu_idle(void * unused
);
1096 #define smp_init() do { } while (0)
1100 /* Called by boot processor to activate the rest. */
1101 static void __init
smp_init(void)
1103 /* Get other processors into their bootup holding patterns. */
1105 smp_threads_ready
=1;
1111 extern void initialize_secondary(void);
1114 * Activate the first processor.
1117 asmlinkage
void __init
start_kernel(void)
1119 char * command_line
;
1122 static int boot_cpu
= 1;
1123 /* "current" has been set up, we need to load it now */
1125 initialize_secondary();
1130 * Interrupts are still disabled. Do necessary setups, then
1134 printk(linux_banner
);
1135 setup_arch(&command_line
, &memory_start
, &memory_end
);
1136 memory_start
= paging_init(memory_start
,memory_end
);
1141 parse_options(command_line
);
1144 * HACK ALERT! This is early. We're enabling the console before
1145 * we've done PCI setups etc, and console_init() must be aware of
1146 * this. But we do want output early, in case something goes wrong.
1148 memory_start
= console_init(memory_start
,memory_end
);
1149 #ifdef CONFIG_MODULES
1153 prof_buffer
= (unsigned int *) memory_start
;
1154 /* only text is profiled */
1155 prof_len
= (unsigned long) &_etext
- (unsigned long) &_stext
;
1156 prof_len
>>= prof_shift
;
1157 memory_start
+= prof_len
* sizeof(unsigned int);
1158 memset(prof_buffer
, 0, prof_len
* sizeof(unsigned int));
1161 memory_start
= kmem_cache_init(memory_start
, memory_end
);
1164 #ifdef CONFIG_BLK_DEV_INITRD
1165 if (initrd_start
&& !initrd_below_start_ok
&& initrd_start
< memory_start
) {
1166 printk(KERN_CRIT
"initrd overwritten (0x%08lx < 0x%08lx) - "
1167 "disabling it.\n",initrd_start
,memory_start
);
1171 mem_init(memory_start
,memory_end
);
1172 kmem_cache_sizes_init();
1173 #ifdef CONFIG_PROC_FS
1176 fork_init(memory_end
-memory_start
);
1180 buffer_init(memory_end
-memory_start
);
1181 page_cache_init(memory_end
-memory_start
);
1186 #if defined(CONFIG_SYSVIPC)
1189 #if defined(CONFIG_QUOTA)
1193 printk("POSIX conformance testing by UNIFIX\n");
1196 * We count on the initial thread going ok
1197 * Like idlers init is an unlocked kernel thread, which will
1198 * make syscalls (and thus be locked).
1201 kernel_thread(init
, NULL
, CLONE_FS
| CLONE_FILES
| CLONE_SIGHAND
);
1203 current
->need_resched
= 1;
1207 #ifdef CONFIG_BLK_DEV_INITRD
1208 static int do_linuxrc(void * shell
)
1210 static char *argv
[] = { "linuxrc", NULL
, };
1212 close(0);close(1);close(2);
1214 (void) open("/dev/console",O_RDWR
,0);
1217 return execve(shell
, argv
, envp_init
);
1220 static void __init
no_initrd(char *s
,int *ints
)
1226 struct task_struct
*child_reaper
= &init_task
;
1229 * Ok, the machine is now initialized. None of the devices
1230 * have been touched yet, but the CPU subsystem is up and
1231 * running, and memory and process management works.
1233 * Now we can finally start doing some real work..
1235 static void __init
do_basic_setup(void)
1237 #ifdef CONFIG_BLK_DEV_INITRD
1238 int real_root_mountflags
;
1242 * Tell the world that we're going to be the grim
1243 * reaper of innocent orphaned children.
1245 * We don't want people to have to make incorrect
1246 * assumptions about where in the task array this
1249 child_reaper
= current
;
1251 #if defined(CONFIG_MTRR) /* Do this after SMP initialization */
1253 * We should probably create some architecture-dependent "fixup after
1254 * everything is up" style function where this would belong better
1255 * than in init/main.c..
1260 #ifdef CONFIG_SYSCTL
1265 * Ok, at this point all CPU's should be initialized, so
1266 * we can start looking into devices..
1274 #if defined(CONFIG_PPC)
1280 #ifdef CONFIG_ARCH_ACORN
1296 /* Networking initialization needs a process context */
1299 /* Launch bdflush from here, instead of the old syscall way. */
1300 kernel_thread(bdflush
, NULL
, CLONE_FS
| CLONE_FILES
| CLONE_SIGHAND
);
1301 /* Start the background pageout daemon. */
1303 kernel_thread(kswapd
, NULL
, CLONE_FS
| CLONE_FILES
| CLONE_SIGHAND
);
1306 /* Start the async paging daemon. */
1308 extern int asyncd(void *);
1309 kernel_thread(asyncd
, NULL
, CLONE_FS
| CLONE_FILES
| CLONE_SIGHAND
);
1313 #ifdef CONFIG_BLK_DEV_INITRD
1315 real_root_dev
= ROOT_DEV
;
1316 real_root_mountflags
= root_mountflags
;
1317 if (initrd_start
&& mount_initrd
) root_mountflags
&= ~MS_RDONLY
;
1318 else mount_initrd
=0;
1321 /* Set up devices .. */
1324 /* .. executable formats .. */
1327 /* .. filesystems .. */
1330 /* Mount the root filesystem.. */
1333 #ifdef CONFIG_BLK_DEV_INITRD
1334 root_mountflags
= real_root_mountflags
;
1335 if (mount_initrd
&& ROOT_DEV
!= real_root_dev
1336 && MAJOR(ROOT_DEV
) == RAMDISK_MAJOR
&& MINOR(ROOT_DEV
) == 0) {
1340 pid
= kernel_thread(do_linuxrc
, "/linuxrc", SIGCHLD
);
1342 while (pid
!= wait(&i
));
1343 if (MAJOR(real_root_dev
) != RAMDISK_MAJOR
1344 || MINOR(real_root_dev
) != 0) {
1345 error
= change_root(real_root_dev
,"/initrd");
1347 printk(KERN_ERR
"Change root to /initrd: "
1348 "error %d\n",error
);
1354 static int init(void * unused
)
1360 * Ok, we have completed the initial bootup, and
1361 * we're essentially up and running. Get rid of the
1362 * initmem segments and start the user-mode stuff..
1367 if (open("/dev/console", O_RDWR
, 0) < 0)
1368 printk("Warning: unable to open an initial console.\n");
1374 * We try each of these until one succeeds.
1376 * The Bourne shell can be used instead of init if we are
1377 * trying to recover a really broken machine.
1380 if (execute_command
)
1381 execve(execute_command
,argv_init
,envp_init
);
1382 execve("/sbin/init",argv_init
,envp_init
);
1383 execve("/etc/init",argv_init
,envp_init
);
1384 execve("/bin/init",argv_init
,envp_init
);
1385 execve("/bin/sh",argv_init
,envp_init
);
1386 panic("No init found. Try passing init= option to kernel.");