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>
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>
31 #include <linux/slab.h>
32 #include <linux/major.h>
33 #include <linux/blk.h>
34 #include <linux/init.h>
35 #include <linux/smp_lock.h>
37 #include <asm/system.h>
44 #include <linux/pci.h>
48 #include <linux/dio.h>
52 #include <linux/zorro.h>
56 # include <asm/mtrr.h>
60 * Versions of gcc older than that listed below may actually compile
61 * and link okay, but the end product can have subtle run time bugs.
62 * To avoid associated bogus bug reports, we flatly refuse to compile
63 * with a gcc that is known to be too old from the very beginning.
65 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
66 #error sorry, your GCC is too old. It builds incorrect kernels.
69 extern char _stext
, _etext
;
70 extern char *linux_banner
;
72 extern int console_loglevel
;
74 static int init(void *);
75 extern int bdflush(void *);
76 extern int kswapd(void *);
77 extern void kswapd_setup(void);
79 extern void init_IRQ(void);
80 extern void init_modules(void);
81 extern long console_init(long, long);
82 extern void sock_init(void);
83 extern void uidcache_init(void);
84 extern void mca_init(void);
85 extern void sbus_init(void);
86 extern void powermac_init(void);
87 extern void sysctl_init(void);
88 extern void filescache_init(void);
89 extern void signals_init(void);
91 extern void device_setup(void);
92 extern void binfmt_setup(void);
93 extern void free_initmem(void);
94 extern void filesystem_setup(void);
96 #ifdef CONFIG_ARCH_ACORN
97 extern void ecard_init(void);
100 extern void smp_setup(char *str
, int *ints
);
102 extern void ioapic_pirq_setup(char *str
, int *ints
);
104 extern void no_scroll(char *str
, int *ints
);
105 extern void kbd_reset_setup(char *str
, int *ints
);
106 extern void panic_setup(char *str
, int *ints
);
107 extern void bmouse_setup(char *str
, int *ints
);
108 extern void msmouse_setup(char *str
, int *ints
);
109 extern void console_setup(char *str
, int *ints
);
110 #ifdef CONFIG_PRINTER
111 extern void lp_setup(char *str
, int *ints
);
113 #ifdef CONFIG_JOY_AMIGA
114 extern void js_am_setup(char *str
, int *ints
);
116 #ifdef CONFIG_JOY_ANALOG
117 extern void js_an_setup(char *str
, int *ints
);
119 #ifdef CONFIG_JOY_ASSASIN
120 extern void js_as_setup(char *str
, int *ints
);
122 #ifdef CONFIG_JOY_CONSOLE
123 extern void js_console_setup(char *str
, int *ints
);
125 #ifdef CONFIG_JOY_DB9
126 extern void js_db9_setup(char *str
, int *ints
);
128 #ifdef CONFIG_JOY_TURBOGRAFX
129 extern void js_tg_setup(char *str
, int *ints
);
131 #ifdef CONFIG_JOY_LIGHTNING
132 extern void js_l4_setup(char *str
, int *ints
);
134 extern void eth_setup(char *str
, int *ints
);
135 #ifdef CONFIG_ARCNET_COM20020
136 extern void com20020_setup(char *str
, int *ints
);
138 #ifdef CONFIG_ARCNET_RIM_I
139 extern void arcrimi_setup(char *str
, int *ints
);
141 #ifdef CONFIG_ARCNET_COM90xxIO
142 extern void com90io_setup(char *str
, int *ints
);
144 #ifdef CONFIG_ARCNET_COM90xx
145 extern void com90xx_setup(char *str
, int *ints
);
148 extern void decnet_setup(char *str
, int *ints
);
150 #ifdef CONFIG_BLK_DEV_XD
151 extern void xd_setup(char *str
, int *ints
);
152 extern void xd_manual_geo_init(char *str
, int *ints
);
154 #ifdef CONFIG_BLK_DEV_IDE
155 extern void ide_setup(char *);
157 #ifdef CONFIG_PARIDE_PD
158 extern void pd_setup(char *str
, int *ints
);
160 #ifdef CONFIG_PARIDE_PF
161 extern void pf_setup(char *str
, int *ints
);
163 #ifdef CONFIG_PARIDE_PT
164 extern void pt_setup(char *str
, int *ints
);
166 #ifdef CONFIG_PARIDE_PG
167 extern void pg_setup(char *str
, int *ints
);
169 #ifdef CONFIG_PARIDE_PCD
170 extern void pcd_setup(char *str
, int *ints
);
172 extern void floppy_setup(char *str
, int *ints
);
173 extern void st_setup(char *str
, int *ints
);
174 extern void st0x_setup(char *str
, int *ints
);
175 extern void advansys_setup(char *str
, int *ints
);
176 extern void tmc8xx_setup(char *str
, int *ints
);
177 extern void t128_setup(char *str
, int *ints
);
178 extern void pas16_setup(char *str
, int *ints
);
179 extern void generic_NCR5380_setup(char *str
, int *intr
);
180 extern void generic_NCR53C400_setup(char *str
, int *intr
);
181 extern void generic_NCR53C400A_setup(char *str
, int *intr
);
182 extern void generic_DTC3181E_setup(char *str
, int *intr
);
183 extern void aha152x_setup(char *str
, int *ints
);
184 extern void aha1542_setup(char *str
, int *ints
);
185 extern void gdth_setup(char *str
, int *ints
);
186 extern void aic7xxx_setup(char *str
, int *ints
);
187 extern void AM53C974_setup(char *str
, int *ints
);
188 extern void BusLogic_Setup(char *str
, int *ints
);
189 extern void ncr53c8xx_setup(char *str
, int *ints
);
190 extern void eata2x_setup(char *str
, int *ints
);
191 extern void u14_34f_setup(char *str
, int *ints
);
192 extern void fdomain_setup(char *str
, int *ints
);
193 extern void ibmmca_scsi_setup(char *str
, int *ints
);
194 extern void in2000_setup(char *str
, int *ints
);
195 extern void NCR53c406a_setup(char *str
, int *ints
);
196 extern void wd7000_setup(char *str
, int *ints
);
197 extern void dc390_setup(char* str
, int *ints
);
198 extern void scsi_luns_setup(char *str
, int *ints
);
199 extern void scsi_logging_setup(char *str
, int *ints
);
200 extern void sound_setup(char *str
, int *ints
);
201 extern void reboot_setup(char *str
, int *ints
);
202 extern void video_setup(char *str
, int *ints
);
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 #if defined(CONFIG_SYSVIPC)
335 extern void ipc_init(void);
337 #if defined(CONFIG_QUOTA)
338 extern void dquot_init_hash(void);
341 #ifdef CONFIG_MD_BOOT
342 extern void md_setup(char *str
,int *ints
) __init
;
346 * Boot command-line arguments
348 #define MAX_INIT_ARGS 8
349 #define MAX_INIT_ENVS 8
351 extern void time_init(void);
353 static unsigned long memory_start
= 0;
354 static unsigned long memory_end
= 0;
358 #ifdef CONFIG_BLK_DEV_RAM
359 extern int rd_doload
; /* 1 = load ramdisk, 0 = don't load */
360 extern int rd_prompt
; /* 1 = prompt for ramdisk, 0 = don't prompt */
361 extern int rd_size
; /* Size of the ramdisk(s) */
362 extern int rd_image_start
; /* starting block # of image */
363 #ifdef CONFIG_BLK_DEV_INITRD
364 kdev_t real_root_dev
;
368 int root_mountflags
= MS_RDONLY
;
369 char *execute_command
= NULL
;
371 static char * argv_init
[MAX_INIT_ARGS
+2] = { "init", NULL
, };
372 static char * envp_init
[MAX_INIT_ENVS
+2] = { "HOME=/", "TERM=linux", NULL
, };
374 char *get_options(char *str
, int *ints
)
379 while (cur
&& isdigit(*cur
) && i
<= 10) {
380 ints
[i
++] = simple_strtoul(cur
,NULL
,0);
381 if ((cur
= strchr(cur
,',')) != NULL
)
388 static void __init
profile_setup(char *str
, int *ints
)
391 prof_shift
= (unsigned long) ints
[1];
397 static struct dev_name_struct
{
400 } root_dev_names
[] __initdata
= {
401 #ifdef CONFIG_ROOT_NFS
404 #ifdef CONFIG_BLK_DEV_IDE
418 #ifdef CONFIG_BLK_DEV_SD
436 #ifdef CONFIG_ATARI_ACSI
443 #ifdef CONFIG_BLK_DEV_FD
446 #ifdef CONFIG_MD_BOOT
449 #ifdef CONFIG_BLK_DEV_XD
453 #ifdef CONFIG_BLK_DEV_RAM
456 #ifdef CONFIG_BLK_DEV_SR
463 { "cdu535", 0x1800 },
464 { "sonycd", 0x1800 },
470 { "cm206cd", 0x2000 },
478 #ifdef CONFIG_BLK_DEV_PS2
482 #ifdef CONFIG_PARIDE_PD
488 #ifdef CONFIG_PARIDE_PCD
491 #ifdef CONFIG_PARIDE_PF
495 { "apblock", APBLOCK_MAJOR
<< 8},
498 { "ddv", DDV_MAJOR
<< 8},
503 kdev_t __init
name_to_kdev_t(char *line
)
506 if (strncmp(line
,"/dev/",5) == 0) {
507 struct dev_name_struct
*dev
= root_dev_names
;
510 int len
= strlen(dev
->name
);
511 if (strncmp(line
,dev
->name
,len
) == 0) {
519 return to_kdev_t(base
+ simple_strtoul(line
,NULL
,base
?10:16));
522 static void __init
root_dev_setup(char *line
, int *num
)
524 ROOT_DEV
= name_to_kdev_t(line
);
528 * List of kernel command line parameters. The first table lists parameters
529 * which are subject to values parsing (leading numbers are converted to
530 * an array of ints and chopped off the string), the second table contains
531 * the few exceptions which obey their own syntax rules.
534 struct kernel_param
{
536 void (*setup_func
)(char *, int *);
539 static struct kernel_param cooked_params
[] __initdata
= {
540 /* FIXME: make PNP just become reserve_setup */
541 #ifndef CONFIG_KERNEL_PNP_RESOURCE
542 { "reserve=", reserve_setup
},
544 { "reserve=", pnp_reserve_setup
},
546 { "profile=", profile_setup
},
548 { "nosmp", smp_setup
},
549 { "maxcpus=", smp_setup
},
551 { "pirq=", ioapic_pirq_setup
},
554 #ifdef CONFIG_BLK_DEV_RAM
555 { "ramdisk_start=", ramdisk_start_setup
},
556 { "load_ramdisk=", load_ramdisk
},
557 { "prompt_ramdisk=", prompt_ramdisk
},
558 { "ramdisk=", ramdisk_size
},
559 { "ramdisk_size=", ramdisk_size
},
560 #ifdef CONFIG_BLK_DEV_INITRD
561 { "noinitrd", no_initrd
},
565 { "video=", video_setup
},
567 { "panic=", panic_setup
},
568 { "console=", console_setup
},
569 #ifdef CONFIG_VGA_CONSOLE
570 { "no-scroll", no_scroll
},
572 #ifdef CONFIG_MDA_CONSOLE
573 { "mdacon=", mdacon_setup
},
576 { "kbd-reset", kbd_reset_setup
},
578 #ifdef CONFIG_BUGi386
579 { "no-hlt", no_halt
},
581 { "reboot=", reboot_setup
},
584 { "ether=", eth_setup
},
586 #ifdef CONFIG_ARCNET_COM20020
587 { "com20020=", com20020_setup
},
589 #ifdef CONFIG_ARCNET_RIM_I
590 { "arcrimi=", arcrimi_setup
},
592 #ifdef CONFIG_ARCNET_COM90xxIO
593 { "com90io=", com90io_setup
},
595 #ifdef CONFIG_ARCNET_COM90xx
596 { "com90xx=", com90xx_setup
},
599 { "decnet=", decnet_setup
},
601 #ifdef CONFIG_PRINTER
604 #ifdef CONFIG_JOY_AMIGA
605 { "js_am=", js_am_setup
},
607 #ifdef CONFIG_JOY_ANALOG
608 { "js_an=", js_an_setup
},
610 #ifdef CONFIG_JOY_ASSASIN
611 { "js_as=", js_as_setup
},
613 #ifdef CONFIG_JOY_CONSOLE
614 { "js_console=", js_console_setup
},
615 { "js_console2=", js_console_setup
},
616 { "js_console3=", js_console_setup
},
618 #ifdef CONFIG_JOY_DB9
619 { "js_db9=", js_db9_setup
},
620 { "js_db9_2=", js_db9_setup
},
621 { "js_db9_3=", js_db9_setup
},
623 #ifdef CONFIG_JOY_TURBOGRAFX
624 { "js_tg=", js_tg_setup
},
625 { "js_tg_2=", js_tg_setup
},
626 { "js_tg_3=", js_tg_setup
},
629 { "max_scsi_luns=", scsi_luns_setup
},
630 { "scsi_logging=", scsi_logging_setup
},
632 #ifdef CONFIG_JOY_LIGHTNING
633 { "js_l4=", js_l4_setup
},
635 #ifdef CONFIG_SCSI_ADVANSYS
636 { "advansys=", advansys_setup
},
638 #if defined(CONFIG_BLK_DEV_HD)
641 #ifdef CONFIG_CHR_DEV_ST
644 #ifdef CONFIG_BUSMOUSE
645 { "bmouse=", bmouse_setup
},
647 #ifdef CONFIG_MS_BUSMOUSE
648 { "msmouse=", msmouse_setup
},
650 #ifdef CONFIG_SCSI_SEAGATE
651 { "st0x=", st0x_setup
},
652 { "tmc8xx=", tmc8xx_setup
},
654 #ifdef CONFIG_SCSI_T128
655 { "t128=", t128_setup
},
657 #ifdef CONFIG_SCSI_PAS16
658 { "pas16=", pas16_setup
},
660 #ifdef CONFIG_SCSI_GENERIC_NCR5380
661 { "ncr5380=", generic_NCR5380_setup
},
662 { "ncr53c400=", generic_NCR53C400_setup
},
663 { "ncr53c400a=", generic_NCR53C400A_setup
},
664 { "dtc3181e=", generic_DTC3181E_setup
},
666 #ifdef CONFIG_SCSI_AHA152X
667 { "aha152x=", aha152x_setup
},
669 #ifdef CONFIG_SCSI_AHA1542
670 { "aha1542=", aha1542_setup
},
672 #ifdef CONFIG_SCSI_GDTH
673 { "gdth=", gdth_setup
},
675 #ifdef CONFIG_SCSI_AIC7XXX
676 { "aic7xxx=", aic7xxx_setup
},
678 #ifdef CONFIG_SCSI_BUSLOGIC
679 { "BusLogic=", BusLogic_Setup
},
681 #ifdef CONFIG_SCSI_NCR53C8XX
682 { "ncr53c8xx=", ncr53c8xx_setup
},
684 #ifdef CONFIG_SCSI_EATA
685 { "eata=", eata2x_setup
},
687 #ifdef CONFIG_SCSI_U14_34F
688 { "u14-34f=", u14_34f_setup
},
690 #ifdef CONFIG_SCSI_AM53C974
691 { "AM53C974=", AM53C974_setup
},
693 #ifdef CONFIG_SCSI_NCR53C406A
694 { "ncr53c406a=", NCR53c406a_setup
},
696 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
697 { "fdomain=", fdomain_setup
},
699 #ifdef CONFIG_SCSI_IN2000
700 { "in2000=", in2000_setup
},
702 #ifdef CONFIG_SCSI_7000FASST
703 { "wd7000=", wd7000_setup
},
705 #ifdef CONFIG_SCSI_IBMMCA
706 { "ibmmcascsi=", ibmmca_scsi_setup
},
708 #if defined(CONFIG_SCSI_DC390T) && ! defined(CONFIG_SCSI_DC390T_NOGENSUPP)
709 { "tmscsim=", dc390_setup
},
711 #ifdef CONFIG_BLK_DEV_XD
713 { "xd_geo=", xd_manual_geo_init
},
715 #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
716 { "floppy=", floppy_setup
},
718 #ifdef CONFIG_BLK_DEV_PS2
719 { "eda=", ed_setup
},
720 { "edb=", ed_setup
},
721 { "tp720=", tp720_setup
},
724 { "cdu31a=", cdu31a_setup
},
727 { "mcd=", mcd_setup
},
730 { "mcdx=", mcdx_setup
},
733 { "sbpcd=", sbpcd_setup
},
736 { "aztcd=", aztcd_setup
},
739 { "sonycd535=", sonycd535_setup
},
742 { "gscd=", gscd_setup
},
745 { "cm206=", cm206_setup
},
748 { "optcd=", optcd_setup
},
751 { "sjcd=", sjcd_setup
},
753 #ifdef CONFIG_ISP16_CDI
754 { "isp16=", isp16_setup
},
755 #endif CONFIG_ISP16_CDI
756 #ifdef CONFIG_SOUND_OSS
757 { "sound=", sound_setup
},
759 #ifdef CONFIG_ISDN_DRV_ICN
760 { "icn=", icn_setup
},
762 #ifdef CONFIG_ISDN_DRV_HISAX
763 { "hisax=", HiSax_setup
},
764 { "HiSax=", HiSax_setup
},
766 #ifdef CONFIG_ISDN_DRV_PCBIT
767 { "pcbit=", pcbit_setup
},
769 #ifdef CONFIG_ATARIMOUSE
770 { "atamouse=", atari_mouse_setup
},
772 #ifdef CONFIG_DMASOUND
773 { "dmasound=", dmasound_setup
},
775 #ifdef CONFIG_ATARI_SCSI
776 { "atascsi=", atari_scsi_setup
},
778 #ifdef CONFIG_STRAM_SWAP
779 { "stram_swap=", stram_swap_setup
},
781 #if defined(CONFIG_A4000T_SCSI) || defined(CONFIG_WARPENGINE_SCSI) \
782 || defined(CONFIG_A4091_SCSI) || defined(CONFIG_MVME16x_SCSI) \
783 || defined(CONFIG_BVME6000_SCSI)
784 { "53c7xx=", ncr53c7xx_setup
},
786 #if defined(CONFIG_A3000_SCSI) || defined(CONFIG_A2091_SCSI) \
787 || defined(CONFIG_GVP11_SCSI)
788 { "wd33c93=", wd33c93_setup
},
790 #if defined(CONFIG_GVP11_SCSI)
791 { "gvp11=", gvp11_setup
},
793 #ifdef CONFIG_MAC_SCSI
794 { "mac5380=", mac_scsi_setup
},
796 #ifdef CONFIG_CYCLADES
797 { "cyclades=", cy_setup
},
800 { "digi=", pcxx_setup
},
802 #ifdef CONFIG_DIGIEPCA
803 { "digiepca=", epca_setup
},
805 #ifdef CONFIG_RISCOM8
806 { "riscom8=", riscom8_setup
},
809 { "dmascc=", dmascc_setup
},
811 #ifdef CONFIG_SPECIALIX
812 { "specialix=", specialix_setup
},
814 #ifdef CONFIG_BAYCOM_PAR
815 { "baycom_par=", baycom_par_setup
},
817 #ifdef CONFIG_BAYCOM_SER_FDX
818 { "baycom_ser_fdx=", baycom_ser_fdx_setup
},
820 #ifdef CONFIG_BAYCOM_SER_HDX
821 { "baycom_ser_hdx=", baycom_ser_hdx_setup
},
823 #ifdef CONFIG_SOUNDMODEM
824 { "soundmodem=", sm_setup
},
827 { "wdt=", wdt_setup
},
829 #ifdef CONFIG_PARPORT
830 { "parport=", parport_setup
},
833 { "plip=", plip_setup
},
835 #ifdef CONFIG_HFMODEM
836 { "hfmodem=", hfmodem_setup
},
839 { "ftape=", ftape_setup
},
841 #ifdef CONFIG_MD_BOOT
844 #ifdef CONFIG_MACMOUSE
845 { "adb_buttons=", adb_mouse_setup
},
850 static struct kernel_param raw_params
[] __initdata
= {
851 { "root=", root_dev_setup
},
852 #ifdef CONFIG_ROOT_NFS
853 { "nfsroot=", nfs_root_setup
},
854 { "nfsaddrs=", ip_auto_config_setup
},
857 { "ip=", ip_auto_config_setup
},
860 { "pci=", pci_setup
},
862 #ifdef CONFIG_PARIDE_PD
865 #ifdef CONFIG_PARIDE_PCD
866 { "pcd.", pcd_setup
},
868 #ifdef CONFIG_PARIDE_PF
871 #ifdef CONFIG_PARIDE_PT
874 #ifdef CONFIG_PARIDE_PG
880 #ifdef CONFIG_BLK_DEV_RAM
881 static void __init
ramdisk_start_setup(char *str
, int *ints
)
883 if (ints
[0] > 0 && ints
[1] >= 0)
884 rd_image_start
= ints
[1];
887 static void __init
load_ramdisk(char *str
, int *ints
)
889 if (ints
[0] > 0 && ints
[1] >= 0)
890 rd_doload
= ints
[1] & 1;
893 static void __init
prompt_ramdisk(char *str
, int *ints
)
895 if (ints
[0] > 0 && ints
[1] >= 0)
896 rd_prompt
= ints
[1] & 1;
899 static void __init
ramdisk_size(char *str
, int *ints
)
901 if (ints
[0] > 0 && ints
[1] >= 0)
906 static int __init
checksetup(char *line
)
910 #ifdef CONFIG_BLK_DEV_IDE
911 /* ide driver needs the basic string, rather than pre-processed values */
912 if (!strncmp(line
,"ide",3) || (!strncmp(line
,"hd",2) && line
[2] != '=')) {
917 for (i
=0; raw_params
[i
].str
; i
++) {
918 int n
= strlen(raw_params
[i
].str
);
919 if (!strncmp(line
,raw_params
[i
].str
,n
)) {
920 raw_params
[i
].setup_func(line
+n
, NULL
);
924 for (i
=0; cooked_params
[i
].str
; i
++) {
925 int n
= strlen(cooked_params
[i
].str
);
926 if (!strncmp(line
,cooked_params
[i
].str
,n
)) {
927 cooked_params
[i
].setup_func(get_options(line
+n
, ints
), ints
);
934 /* this should be approx 2 Bo*oMips to start (note initial shift), and will
935 still work even if initially too large, it will just take slightly longer */
936 unsigned long loops_per_sec
= (1<<12);
938 /* This is the number of bits of precision for the loops_per_second. Each
939 bit takes on average 1.5/HZ seconds. This (like the original) is a little
943 void __init
calibrate_delay(void)
945 unsigned long ticks
, loopbit
;
946 int lps_precision
= LPS_PREC
;
948 loops_per_sec
= (1<<12);
950 printk("Calibrating delay loop... ");
951 while (loops_per_sec
<<= 1) {
952 /* wait for "start of" clock tick */
954 while (ticks
== jiffies
)
958 __delay(loops_per_sec
);
959 ticks
= jiffies
- ticks
;
964 /* Do a binary approximation to get loops_per_second set to equal one clock
965 (up to lps_precision bits) */
967 loopbit
= loops_per_sec
;
968 while ( lps_precision
-- && (loopbit
>>= 1) ) {
969 loops_per_sec
|= loopbit
;
971 while (ticks
== jiffies
);
973 __delay(loops_per_sec
);
974 if (jiffies
!= ticks
) /* longer than 1 tick */
975 loops_per_sec
&= ~loopbit
;
978 /* finally, adjust loops per second in terms of seconds instead of clocks */
980 /* Round the value and print it */
981 printk("%lu.%02lu BogoMIPS\n",
982 (loops_per_sec
+2500)/500000,
983 ((loops_per_sec
+2500)/5000) % 100);
987 * This is a simple kernel command line parsing function: it parses
988 * the command line, and fills in the arguments/environment to init
989 * as appropriate. Any cmd-line option is taken to be an environment
990 * variable if it contains the character '='.
992 * This routine also checks for options meant for the kernel.
993 * These options are not given to init - they are for internal kernel use only.
995 static void __init
parse_options(char *line
)
1003 envs
= 1; /* TERM is set to 'linux' by default */
1005 while ((line
= next
) != NULL
) {
1006 if ((next
= strchr(line
,' ')) != NULL
)
1009 * check for kernel options first..
1011 if (!strcmp(line
,"ro")) {
1012 root_mountflags
|= MS_RDONLY
;
1015 if (!strcmp(line
,"rw")) {
1016 root_mountflags
&= ~MS_RDONLY
;
1019 if (!strcmp(line
,"debug")) {
1020 console_loglevel
= 10;
1023 if (!strncmp(line
,"init=",5)) {
1025 execute_command
= line
;
1026 /* In case LILO is going to boot us with default command line,
1027 * it prepends "auto" before the whole cmdline which makes
1028 * the shell think it should execute a script with such name.
1029 * So we ignore all arguments entered _before_ init=... [MJ]
1034 if (checksetup(line
))
1038 * Then check if it's an environment variable or
1041 if (strchr(line
,'=')) {
1042 if (envs
>= MAX_INIT_ENVS
)
1044 envp_init
[++envs
] = line
;
1046 if (args
>= MAX_INIT_ARGS
)
1048 argv_init
[++args
] = line
;
1051 argv_init
[args
+1] = NULL
;
1052 envp_init
[envs
+1] = NULL
;
1056 extern void setup_arch(char **, unsigned long *, unsigned long *);
1061 * Uniprocessor idle thread
1064 int cpu_idle(void *unused
)
1070 #define smp_init() do { } while (0)
1075 * Multiprocessor idle thread is in arch/...
1078 extern int cpu_idle(void * unused
);
1080 /* Called by boot processor to activate the rest. */
1081 static void __init
smp_init(void)
1083 /* Get other processors into their bootup holding patterns. */
1085 smp_threads_ready
=1;
1091 extern void initialize_secondary(void);
1094 * Activate the first processor.
1097 asmlinkage
void __init
start_kernel(void)
1099 char * command_line
;
1102 static int boot_cpu
= 1;
1103 /* "current" has been set up, we need to load it now */
1105 initialize_secondary();
1110 * Interrupts are still disabled. Do necessary setups, then
1113 printk(linux_banner
);
1114 setup_arch(&command_line
, &memory_start
, &memory_end
);
1115 memory_start
= paging_init(memory_start
,memory_end
);
1120 parse_options(command_line
);
1123 * HACK ALERT! This is early. We're enabling the console before
1124 * we've done PCI setups etc, and console_init() must be aware of
1125 * this. But we do want output early, in case something goes wrong.
1127 memory_start
= console_init(memory_start
,memory_end
);
1128 #ifdef CONFIG_MODULES
1132 prof_buffer
= (unsigned int *) memory_start
;
1133 /* only text is profiled */
1134 prof_len
= (unsigned long) &_etext
- (unsigned long) &_stext
;
1135 prof_len
>>= prof_shift
;
1136 memory_start
+= prof_len
* sizeof(unsigned int);
1137 memset(prof_buffer
, 0, prof_len
* sizeof(unsigned int));
1140 memory_start
= kmem_cache_init(memory_start
, memory_end
);
1143 #ifdef CONFIG_BLK_DEV_INITRD
1144 if (initrd_start
&& !initrd_below_start_ok
&& initrd_start
< memory_start
) {
1145 printk(KERN_CRIT
"initrd overwritten (0x%08lx < 0x%08lx) - "
1146 "disabling it.\n",initrd_start
,memory_start
);
1150 mem_init(memory_start
,memory_end
);
1151 kmem_cache_sizes_init();
1152 #ifdef CONFIG_PROC_FS
1163 #if defined(CONFIG_SYSVIPC)
1166 #if defined(CONFIG_QUOTA)
1170 printk("POSIX conformance testing by UNIFIX\n");
1173 * We count on the initial thread going ok
1174 * Like idlers init is an unlocked kernel thread, which will
1175 * make syscalls (and thus be locked).
1178 kernel_thread(init
, NULL
, CLONE_FS
| CLONE_FILES
| CLONE_SIGHAND
);
1182 #ifdef CONFIG_BLK_DEV_INITRD
1183 static int do_linuxrc(void * shell
)
1185 static char *argv
[] = { "linuxrc", NULL
, };
1187 close(0);close(1);close(2);
1189 (void) open("/dev/console",O_RDWR
,0);
1192 return execve(shell
, argv
, envp_init
);
1195 static void __init
no_initrd(char *s
,int *ints
)
1201 struct task_struct
*child_reaper
= &init_task
;
1204 * Ok, the machine is now initialized. None of the devices
1205 * have been touched yet, but the CPU subsystem is up and
1206 * running, and memory and process management works.
1208 * Now we can finally start doing some real work..
1210 static void __init
do_basic_setup(void)
1212 #ifdef CONFIG_BLK_DEV_INITRD
1213 int real_root_mountflags
;
1217 * Tell the world that we're going to be the grim
1218 * reaper of innocent orphaned children.
1220 * We don't want people to have to make incorrect
1221 * assumptions about where in the task array this
1224 child_reaper
= current
;
1226 #if defined(CONFIG_MTRR) /* Do this after SMP initialization */
1228 * We should probably create some architecture-dependent "fixup after
1229 * everything is up" style function where this would belong better
1230 * than in init/main.c..
1235 #ifdef CONFIG_SYSCTL
1240 * Ok, at this point all CPU's should be initialized, so
1241 * we can start looking into devices..
1249 #if defined(CONFIG_PMAC) || defined(CONFIG_CHRP)
1255 #ifdef CONFIG_ARCH_ACORN
1265 /* Networking initialization needs a process context */
1268 /* Launch bdflush from here, instead of the old syscall way. */
1269 kernel_thread(bdflush
, NULL
, CLONE_FS
| CLONE_FILES
| CLONE_SIGHAND
);
1270 /* Start the background pageout daemon. */
1272 kernel_thread(kswapd
, NULL
, CLONE_FS
| CLONE_FILES
| CLONE_SIGHAND
);
1275 /* Start the async paging daemon. */
1277 extern int asyncd(void *);
1278 kernel_thread(asyncd
, NULL
, CLONE_FS
| CLONE_FILES
| CLONE_SIGHAND
);
1282 #ifdef CONFIG_BLK_DEV_INITRD
1284 real_root_dev
= ROOT_DEV
;
1285 real_root_mountflags
= root_mountflags
;
1286 if (initrd_start
&& mount_initrd
) root_mountflags
&= ~MS_RDONLY
;
1287 else mount_initrd
=0;
1290 /* Set up devices .. */
1293 /* .. executable formats .. */
1296 /* .. filesystems .. */
1299 /* Mount the root filesystem.. */
1302 #ifdef CONFIG_UMSDOS_FS
1305 When mounting a umsdos fs as root, we detect
1306 the pseudo_root (/linux) and initialise it here.
1307 pseudo_root is defined in fs/umsdos/inode.c
1309 extern struct inode
*pseudo_root
;
1310 if (pseudo_root
!= NULL
){
1311 current
->fs
->root
= pseudo_root
->i_sb
->s_root
;
1312 current
->fs
->pwd
= pseudo_root
->i_sb
->s_root
;
1317 #ifdef CONFIG_BLK_DEV_INITRD
1318 root_mountflags
= real_root_mountflags
;
1319 if (mount_initrd
&& ROOT_DEV
!= real_root_dev
1320 && MAJOR(ROOT_DEV
) == RAMDISK_MAJOR
&& MINOR(ROOT_DEV
) == 0) {
1324 pid
= kernel_thread(do_linuxrc
, "/linuxrc", SIGCHLD
);
1326 while (pid
!= wait(&i
));
1327 if (MAJOR(real_root_dev
) != RAMDISK_MAJOR
1328 || MINOR(real_root_dev
) != 0) {
1329 error
= change_root(real_root_dev
,"/initrd");
1331 printk(KERN_ERR
"Change root to /initrd: "
1332 "error %d\n",error
);
1338 static int init(void * unused
)
1344 * Ok, we have completed the initial bootup, and
1345 * we're essentially up and running. Get rid of the
1346 * initmem segments and start the user-mode stuff..
1351 if (open("/dev/console", O_RDWR
, 0) < 0)
1352 printk("Warning: unable to open an initial console.\n");
1358 * We try each of these until one succeeds.
1360 * The Bourne shell can be used instead of init if we are
1361 * trying to recover a really broken machine.
1364 if (execute_command
)
1365 execve(execute_command
,argv_init
,envp_init
);
1366 execve("/sbin/init",argv_init
,envp_init
);
1367 execve("/etc/init",argv_init
,envp_init
);
1368 execve("/bin/init",argv_init
,envp_init
);
1369 execve("/bin/sh",argv_init
,envp_init
);
1370 panic("No init found. Try passing init= option to kernel.");