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/head.h>
21 #include <linux/unistd.h>
22 #include <linux/string.h>
23 #include <linux/timer.h>
25 #include <linux/proc_fs.h>
26 #include <linux/ctype.h>
27 #include <linux/delay.h>
28 #include <linux/utsname.h>
29 #include <linux/ioport.h>
30 #include <linux/hdreg.h>
32 #include <linux/slab.h>
33 #include <linux/major.h>
34 #include <linux/blk.h>
35 #include <linux/init.h>
36 #ifdef CONFIG_ROOT_NFS
37 #include <linux/nfs_fs.h>
40 #include <asm/system.h>
47 #include <asm/sgialib.h>
51 * Versions of gcc older than that listed below may actually compile
52 * and link okay, but the end product can have subtle run time bugs.
53 * To avoid associated bogus bug reports, we flatly refuse to compile
54 * with a gcc that is known to be too old from the very beginning.
56 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
57 #error sorry, your GCC is too old. It builds incorrect kernels.
60 extern char _stext
, _etext
;
61 extern char *linux_banner
;
63 extern int console_loglevel
;
65 static int init(void *);
66 extern int bdflush(void *);
67 extern int kswapd(void *);
68 extern void kswapd_setup(void);
70 extern void init_IRQ(void);
71 extern void init_modules(void);
72 extern long console_init(long, long);
73 extern void sock_init(void);
74 extern void uidcache_init(void);
75 extern unsigned long pci_init(unsigned long, unsigned long);
76 extern long mca_init(long, long);
77 extern long sbus_init(long, long);
78 extern void sysctl_init(void);
79 extern void filescache_init(void);
81 extern void smp_setup(char *str
, int *ints
);
82 extern void no_scroll(char *str
, int *ints
);
83 extern void swap_setup(char *str
, int *ints
);
84 extern void buff_setup(char *str
, int *ints
);
85 extern void panic_setup(char *str
, int *ints
);
86 extern void bmouse_setup(char *str
, int *ints
);
87 extern void msmouse_setup(char *str
, int *ints
);
89 extern void lp_setup(char *str
, int *ints
);
91 extern void eth_setup(char *str
, int *ints
);
93 extern void decnet_setup(char *str
, int *ints
);
95 extern void xd_setup(char *str
, int *ints
);
96 #ifdef CONFIG_BLK_DEV_EZ
97 extern void ez_setup(char *str
, int *ints
);
99 extern void floppy_setup(char *str
, int *ints
);
100 extern void st_setup(char *str
, int *ints
);
101 extern void st0x_setup(char *str
, int *ints
);
102 extern void advansys_setup(char *str
, int *ints
);
103 extern void tmc8xx_setup(char *str
, int *ints
);
104 extern void t128_setup(char *str
, int *ints
);
105 extern void pas16_setup(char *str
, int *ints
);
106 extern void generic_NCR5380_setup(char *str
, int *intr
);
107 extern void generic_NCR53C400_setup(char *str
, int *intr
);
108 extern void aha152x_setup(char *str
, int *ints
);
109 extern void aha1542_setup(char *str
, int *ints
);
110 extern void aic7xxx_setup(char *str
, int *ints
);
111 extern void AM53C974_setup(char *str
, int *ints
);
112 extern void BusLogic_Setup(char *str
, int *ints
);
113 extern void ncr53c8xx_setup(char *str
, int *ints
);
114 extern void eata2x_setup(char *str
, int *ints
);
115 extern void u14_34f_setup(char *str
, int *ints
);
116 extern void fdomain_setup(char *str
, int *ints
);
117 extern void ibmmca_scsi_setup(char *str
, int *ints
);
118 extern void in2000_setup(char *str
, int *ints
);
119 extern void NCR53c406a_setup(char *str
, int *ints
);
120 extern void wd7000_setup(char *str
, int *ints
);
122 extern void ppa_setup(char *str
, int *ints
);
124 extern void scsi_luns_setup(char *str
, int *ints
);
125 extern void sound_setup(char *str
, int *ints
);
126 extern void reboot_setup(char *str
, int *ints
);
127 extern void video_setup(char *str
, int *ints
);
129 extern void cdu31a_setup(char *str
, int *ints
);
131 #ifdef CONFIG_BLK_DEV_PS2
132 extern void ed_setup(char *str
, int *ints
);
133 extern void tp720_setup(char *str
, int *ints
);
134 #endif CONFIG_BLK_DEV_PS2
136 extern void mcd_setup(char *str
, int *ints
);
139 extern void mcdx_setup(char *str
, int *ints
);
142 extern void sbpcd_setup(char *str
, int *ints
);
145 extern void aztcd_setup(char *str
, int *ints
);
148 extern void sonycd535_setup(char *str
, int *ints
);
151 extern void gscd_setup(char *str
, int *ints
);
154 extern void bpcd_setup(char *str
, int *ints
);
157 extern void cm206_setup(char *str
, int *ints
);
160 extern void optcd_setup(char *str
, int *ints
);
163 extern void sjcd_setup(char *str
, int *ints
);
165 #ifdef CONFIG_ISP16_CDI
166 extern void isp16_setup(char *str
, int *ints
);
167 #endif CONFIG_ISP16_CDI
168 #ifdef CONFIG_BLK_DEV_RAM
169 static void ramdisk_start_setup(char *str
, int *ints
);
170 static void load_ramdisk(char *str
, int *ints
);
171 static void prompt_ramdisk(char *str
, int *ints
);
172 static void ramdisk_size(char *str
, int *ints
);
173 #ifdef CONFIG_BLK_DEV_INITRD
174 static void no_initrd(char *s
,int *ints
);
176 #endif CONFIG_BLK_DEV_RAM
177 #ifdef CONFIG_ISDN_DRV_ICN
178 extern void icn_setup(char *str
, int *ints
);
180 #ifdef CONFIG_ISDN_DRV_HISAX
181 extern void HiSax_setup(char *str
, int *ints
);
183 #ifdef CONFIG_DIGIEPCA
184 extern void epca_setup(char *str
, int *ints
);
186 #ifdef CONFIG_ISDN_DRV_PCBIT
187 extern void pcbit_setup(char *str
, int *ints
);
190 #ifdef CONFIG_ATARIMOUSE
191 extern void atari_mouse_setup (char *str
, int *ints
);
193 #ifdef CONFIG_DMASOUND
194 extern void dmasound_setup (char *str
, int *ints
);
196 #ifdef CONFIG_ATARI_SCSI
197 extern void atari_scsi_setup (char *str
, int *ints
);
199 extern void wd33c93_setup (char *str
, int *ints
);
200 extern void gvp11_setup (char *str
, int *ints
);
201 extern void ncr53c7xx_setup (char *str
, int *ints
);
203 #ifdef CONFIG_CYCLADES
204 extern void cy_setup(char *str
, int *ints
);
207 extern void pcxx_setup(char *str
, int *ints
);
209 #ifdef CONFIG_RISCOM8
210 extern void riscom8_setup(char *str
, int *ints
);
213 extern void baycom_setup(char *str
, int *ints
);
215 #ifdef CONFIG_SOUNDMODEM
216 extern void sm_setup(char *str
, int *ints
);
219 extern void wdt_setup(char *str
, int *ints
);
221 #ifdef CONFIG_PARPORT
222 extern void parport_setup(char *str
, int *ints
);
225 extern void plip_setup(char *str
, int *ints
);
228 #if defined(CONFIG_SYSVIPC) || defined(CONFIG_KERNELD)
229 extern void ipc_init(void);
231 #ifdef CONFIG_MIPS_JAZZ
232 #include <asm/jazzdma.h>
234 #ifdef CONFIG_REMOTE_DEBUG
235 #include <asm/gdb-stub.h>
238 extern int serial_console
;
241 extern int serial_console
;
245 * Boot command-line arguments
247 #define MAX_INIT_ARGS 8
248 #define MAX_INIT_ENVS 8
250 extern void time_init(void);
252 static unsigned long memory_start
= 0;
253 static unsigned long memory_end
= 0;
257 #ifdef CONFIG_BLK_DEV_RAM
258 extern int rd_doload
; /* 1 = load ramdisk, 0 = don't load */
259 extern int rd_prompt
; /* 1 = prompt for ramdisk, 0 = don't prompt */
260 extern int rd_size
; /* Size of the ramdisk(s) */
261 extern int rd_image_start
; /* starting block # of image */
262 #ifdef CONFIG_BLK_DEV_INITRD
263 kdev_t real_root_dev
;
267 int root_mountflags
= MS_RDONLY
;
268 char *execute_command
= NULL
;
270 #ifdef CONFIG_ROOT_NFS
271 char nfs_root_name
[NFS_ROOT_NAME_LEN
] = { "default" };
272 char nfs_root_addrs
[NFS_ROOT_ADDRS_LEN
] = { "" };
275 extern void dquot_init(void);
277 static char * argv_init
[MAX_INIT_ARGS
+2] = { "init", NULL
, };
278 static char * envp_init
[MAX_INIT_ENVS
+2] = { "HOME=/", "TERM=linux", NULL
, };
280 char *get_options(char *str
, int *ints
)
285 while (cur
&& isdigit(*cur
) && i
<= 10) {
286 ints
[i
++] = simple_strtoul(cur
,NULL
,0);
287 if ((cur
= strchr(cur
,',')) != NULL
)
294 __initfunc(static void profile_setup(char *str
, int *ints
))
297 prof_shift
= (unsigned long) ints
[1];
299 #ifdef CONFIG_PROFILE_SHIFT
300 prof_shift
= CONFIG_PROFILE_SHIFT
;
308 void (*setup_func
)(char *, int *);
309 } bootsetups
[] __initdata
= {
310 { "reserve=", reserve_setup
},
311 { "profile=", profile_setup
},
313 { "nosmp", smp_setup
},
314 { "maxcpus=", smp_setup
},
316 #ifdef CONFIG_BLK_DEV_RAM
317 { "ramdisk_start=", ramdisk_start_setup
},
318 { "load_ramdisk=", load_ramdisk
},
319 { "prompt_ramdisk=", prompt_ramdisk
},
320 { "ramdisk=", ramdisk_size
},
321 { "ramdisk_size=", ramdisk_size
},
322 #ifdef CONFIG_BLK_DEV_INITRD
323 { "noinitrd", no_initrd
},
326 #if defined (CONFIG_AMIGA) || defined (CONFIG_ATARI)
327 { "video=", video_setup
},
329 { "swap=", swap_setup
},
330 { "buff=", buff_setup
},
331 { "panic=", panic_setup
},
333 { "no-scroll", no_scroll
},
335 #ifdef CONFIG_BUGi386
336 { "no-hlt", no_halt
},
338 { "reboot=", reboot_setup
},
341 { "ether=", eth_setup
},
344 { "decnet=", decnet_setup
},
346 #ifdef CONFIG_PRINTER
350 { "max_scsi_luns=", scsi_luns_setup
},
352 #ifdef CONFIG_SCSI_ADVANSYS
353 { "advansys=", advansys_setup
},
355 #if defined(CONFIG_BLK_DEV_HD)
358 #ifdef CONFIG_CHR_DEV_ST
361 #ifdef CONFIG_BUSMOUSE
362 { "bmouse=", bmouse_setup
},
364 #ifdef CONFIG_MS_BUSMOUSE
365 { "msmouse=", msmouse_setup
},
367 #ifdef CONFIG_SCSI_SEAGATE
368 { "st0x=", st0x_setup
},
369 { "tmc8xx=", tmc8xx_setup
},
371 #ifdef CONFIG_SCSI_T128
372 { "t128=", t128_setup
},
374 #ifdef CONFIG_SCSI_PAS16
375 { "pas16=", pas16_setup
},
377 #ifdef CONFIG_SCSI_GENERIC_NCR5380
378 { "ncr5380=", generic_NCR5380_setup
},
379 { "ncr53c400=", generic_NCR53C400_setup
},
381 #ifdef CONFIG_SCSI_AHA152X
382 { "aha152x=", aha152x_setup
},
384 #ifdef CONFIG_SCSI_AHA1542
385 { "aha1542=", aha1542_setup
},
387 #ifdef CONFIG_SCSI_AIC7XXX
388 { "aic7xxx=", aic7xxx_setup
},
390 #ifdef CONFIG_SCSI_BUSLOGIC
391 { "BusLogic=", BusLogic_Setup
},
393 #ifdef CONFIG_SCSI_NCR53C8XX
394 { "ncr53c8xx=", ncr53c8xx_setup
},
396 #ifdef CONFIG_SCSI_EATA
397 { "eata=", eata2x_setup
},
399 #ifdef CONFIG_SCSI_U14_34F
400 { "u14-34f=", u14_34f_setup
},
402 #ifdef CONFIG_SCSI_AM53C974
403 { "AM53C974=", AM53C974_setup
},
405 #ifdef CONFIG_SCSI_NCR53C406A
406 { "ncr53c406a=", NCR53c406a_setup
},
408 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
409 { "fdomain=", fdomain_setup
},
411 #ifdef CONFIG_SCSI_IN2000
412 { "in2000=", in2000_setup
},
414 #ifdef CONFIG_SCSI_7000FASST
415 { "wd7000=", wd7000_setup
},
417 #ifdef NOTDEF /* CONFIG_SCSI_PPA */
418 { "ppa=", ppa_setup
},
420 #ifdef CONFIG_SCSI_IBMMCA
421 { "ibmmcascsi=", ibmmca_scsi_setup
},
423 #ifdef CONFIG_BLK_DEV_XD
426 #ifdef CONFIG_BLK_DEV_EZ
429 #ifdef CONFIG_BLK_DEV_FD
430 { "floppy=", floppy_setup
},
432 #ifdef CONFIG_BLK_DEV_PS2
434 { "tp720=", tp720_setup
},
437 { "cdu31a=", cdu31a_setup
},
440 { "mcd=", mcd_setup
},
443 { "mcdx=", mcdx_setup
},
446 { "sbpcd=", sbpcd_setup
},
449 { "aztcd=", aztcd_setup
},
452 { "sonycd535=", sonycd535_setup
},
455 { "gscd=", gscd_setup
},
458 { "bpcd=", bpcd_setup
},
461 { "cm206=", cm206_setup
},
464 { "optcd=", optcd_setup
},
467 { "sjcd=", sjcd_setup
},
469 #ifdef CONFIG_ISP16_CDI
470 { "isp16=", isp16_setup
},
471 #endif CONFIG_ISP16_CDI
473 { "sound=", sound_setup
},
475 #ifdef CONFIG_ISDN_DRV_ICN
476 { "icn=", icn_setup
},
478 #ifdef CONFIG_ISDN_DRV_HISAX
479 { "hisax=", HiSax_setup
},
480 { "HiSax=", HiSax_setup
},
482 #ifdef CONFIG_ISDN_DRV_PCBIT
483 { "pcbit=", pcbit_setup
},
485 #ifdef CONFIG_ATARIMOUSE
486 { "atamouse=", atari_mouse_setup
},
488 #ifdef CONFIG_DMASOUND
489 { "dmasound=", dmasound_setup
},
491 #ifdef CONFIG_ATARI_SCSI
492 { "atascsi=", atari_scsi_setup
},
494 #if defined(CONFIG_A4000T_SCSI) || defined(CONFIG_WARPENGINE_SCSI) || defined(CONFIG_A4091_SCSI)
495 { "53c7xx=", ncr53c7xx_setup
},
497 #if defined(CONFIG_A3000_SCSI) || defined(CONFIG_A2091_SCSI) \
498 || defined(CONFIG_GVP11_SCSI) || defined(CONFIG_SCSI_SGIWD93)
499 { "wd33c93=", wd33c93_setup
},
501 #if defined(CONFIG_GVP11_SCSI)
502 { "gvp11=", gvp11_setup
},
504 #ifdef CONFIG_CYCLADES
505 { "cyclades=", cy_setup
},
508 { "digi=", pcxx_setup
},
510 #ifdef CONFIG_DIGIEPCA
511 { "digiepca=", epca_setup
},
513 #ifdef CONFIG_RISCOM8
514 { "riscom8=", riscom8_setup
},
517 { "baycom=", baycom_setup
},
519 #ifdef CONFIG_SOUNDMODEM
520 { "soundmodem=", sm_setup
},
523 { "wdt=", wdt_setup
},
525 #ifdef CONFIG_PARPORT
526 { "parport=", parport_setup
},
529 { "plip=", plip_setup
},
534 #ifdef CONFIG_BLK_DEV_RAM
535 __initfunc(static void ramdisk_start_setup(char *str
, int *ints
))
537 if (ints
[0] > 0 && ints
[1] >= 0)
538 rd_image_start
= ints
[1];
541 __initfunc(static void load_ramdisk(char *str
, int *ints
))
543 if (ints
[0] > 0 && ints
[1] >= 0)
544 rd_doload
= ints
[1] & 1;
547 __initfunc(static void prompt_ramdisk(char *str
, int *ints
))
549 if (ints
[0] > 0 && ints
[1] >= 0)
550 rd_prompt
= ints
[1] & 1;
553 __initfunc(static void ramdisk_size(char *str
, int *ints
))
555 if (ints
[0] > 0 && ints
[1] >= 0)
561 __initfunc(static int checksetup(char *line
))
566 #ifdef CONFIG_BLK_DEV_IDE
567 /* ide driver needs the basic string, rather than pre-processed values */
568 if (!strncmp(line
,"ide",3) || (!strncmp(line
,"hd",2) && line
[2] != '=')) {
573 while (bootsetups
[i
].str
) {
574 int n
= strlen(bootsetups
[i
].str
);
575 if (!strncmp(line
,bootsetups
[i
].str
,n
)) {
576 bootsetups
[i
].setup_func(get_options(line
+n
,ints
), ints
);
584 /* this should be approx 2 Bo*oMips to start (note initial shift), and will
585 still work even if initially too large, it will just take slightly longer */
586 unsigned long loops_per_sec
= (1<<12);
588 /* This is the number of bits of precision for the loops_per_second. Each
589 bit takes on average 1.5/HZ seconds. This (like the original) is a little
593 __initfunc(void calibrate_delay(void))
595 unsigned long ticks
, loopbit
;
596 int lps_precision
= LPS_PREC
;
598 loops_per_sec
= (1<<12);
600 printk("Calibrating delay loop.. ");
601 while (loops_per_sec
<<= 1) {
602 /* wait for "start of" clock tick */
604 while (ticks
== jiffies
)
608 __delay(loops_per_sec
);
609 ticks
= jiffies
- ticks
;
614 /* Do a binary approximation to get loops_per_second set to equal one clock
615 (up to lps_precision bits) */
617 loopbit
= loops_per_sec
;
618 while ( lps_precision
-- && (loopbit
>>= 1) ) {
619 loops_per_sec
|= loopbit
;
621 while (ticks
== jiffies
);
623 __delay(loops_per_sec
);
624 if (jiffies
!= ticks
) /* longer than 1 tick */
625 loops_per_sec
&= ~loopbit
;
628 /* finally, adjust loops per second in terms of seconds instead of clocks */
630 /* Round the value and print it */
631 printk("ok - %lu.%02lu BogoMIPS\n",
632 (loops_per_sec
+2500)/500000,
633 ((loops_per_sec
+2500)/5000) % 100);
636 __initfunc(static void parse_root_dev(char * line
))
639 static struct dev_name_struct
{
664 { "cdu535", 0x1800 },
666 { "cm206cd", 0x2000 },
669 { "sonycd", 0x1800 },
674 { "apblock", APBLOCK_MAJOR
<< 8},
677 { "ddv", DDV_MAJOR
<< 8},
682 if (strncmp(line
,"/dev/",5) == 0) {
683 struct dev_name_struct
*dev
= devices
;
686 int len
= strlen(dev
->name
);
687 if (strncmp(line
,dev
->name
,len
) == 0) {
695 ROOT_DEV
= to_kdev_t(base
+ simple_strtoul(line
,NULL
,base
?10:16));
699 * This is a simple kernel command line parsing function: it parses
700 * the command line, and fills in the arguments/environment to init
701 * as appropriate. Any cmd-line option is taken to be an environment
702 * variable if it contains the character '='.
705 * This routine also checks for options meant for the kernel.
706 * These options are not given to init - they are for internal kernel use only.
708 __initfunc(static void parse_options(char *line
))
716 envs
= 1; /* TERM is set to 'linux' by default */
718 while ((line
= next
) != NULL
) {
719 if ((next
= strchr(line
,' ')) != NULL
)
722 * check for kernel options first..
724 if (!strncmp(line
,"root=",5)) {
725 parse_root_dev(line
+5);
728 #ifdef CONFIG_ROOT_NFS
729 if (!strncmp(line
, "nfsroot=", 8)) {
732 ROOT_DEV
= MKDEV(UNNAMED_MAJOR
, 255);
733 if (line
[0] == '/' || line
[0] == ',' || (line
[0] >= '0' && line
[0] <= '9')) {
734 strncpy(nfs_root_name
, line
, sizeof(nfs_root_name
));
735 nfs_root_name
[sizeof(nfs_root_name
)-1] = '\0';
738 n
= strlen(line
) + strlen(NFS_ROOT
);
739 if (n
>= sizeof(nfs_root_name
))
740 line
[sizeof(nfs_root_name
) - strlen(NFS_ROOT
) - 1] = '\0';
741 sprintf(nfs_root_name
, NFS_ROOT
, line
);
744 if (!strncmp(line
, "nfsaddrs=", 9)) {
746 strncpy(nfs_root_addrs
, line
, sizeof(nfs_root_addrs
));
747 nfs_root_addrs
[sizeof(nfs_root_addrs
)-1] = '\0';
751 if (!strcmp(line
,"ro")) {
752 root_mountflags
|= MS_RDONLY
;
755 if (!strcmp(line
,"rw")) {
756 root_mountflags
&= ~MS_RDONLY
;
759 if (!strcmp(line
,"debug")) {
760 console_loglevel
= 10;
763 if (!strncmp(line
,"init=",5)) {
765 execute_command
= line
;
766 /* In case LILO is going to boot us with default command line,
767 * it prepends "auto" before the whole cmdline which makes
768 * the shell think it should execute a script with such name.
769 * So we ignore all arguments entered _before_ init=... [MJ]
774 if (checksetup(line
))
778 * Then check if it's an environment variable or
781 if (strchr(line
,'=')) {
782 if (envs
>= MAX_INIT_ENVS
)
784 envp_init
[++envs
] = line
;
786 if (args
>= MAX_INIT_ARGS
)
788 argv_init
[++args
] = line
;
791 argv_init
[args
+1] = NULL
;
792 envp_init
[envs
+1] = NULL
;
796 extern void setup_arch(char **, unsigned long *, unsigned long *);
801 * Uniprocessor idle thread
804 int cpu_idle(void *unused
)
813 * Multiprocessor idle thread is in arch/...
816 extern int cpu_idle(void * unused
);
818 /* Called by boot processor to activate the rest. */
819 __initfunc(static void smp_init(void))
821 /* Get other processors into their bootup holding patterns. */
826 * The autoprobe routines assume CPU#0 on the i386
827 * so we don't actually set the game in motion until
831 __initfunc(static void smp_begin(void))
839 extern void initialize_secondary(void);
842 * Activate the first processor.
845 __initfunc(asmlinkage
void start_kernel(void))
850 static int boot_cpu
= 1;
851 /* "current" has been set up, we need to load it now */
853 initialize_secondary();
858 * Interrupts are still disabled. Do necessary setups, then
861 setup_arch(&command_line
, &memory_start
, &memory_end
);
862 memory_start
= paging_init(memory_start
,memory_end
);
867 parse_options(command_line
);
868 #ifdef CONFIG_MODULES
871 #ifdef CONFIG_PROFILE
873 #ifdef CONFIG_PROFILE_SHIFT
874 prof_shift
= CONFIG_PROFILE_SHIFT
;
880 prof_buffer
= (unsigned int *) memory_start
;
881 /* only text is profiled */
882 prof_len
= (unsigned long) &_etext
- (unsigned long) &_stext
;
883 prof_len
>>= prof_shift
;
884 memory_start
+= prof_len
* sizeof(unsigned int);
885 memset(prof_buffer
, 0, prof_len
* sizeof(unsigned int));
888 memory_start
= sbus_init(memory_start
,memory_end
);
890 memory_start
= console_init(memory_start
,memory_end
);
891 #ifdef CONFIG_REMOTE_DEBUG
893 /* breakpoint(); */ /* execute a BREAK insn */
896 memory_start
= pci_init(memory_start
,memory_end
);
899 memory_start
= mca_init(memory_start
,memory_end
);
901 memory_start
= kmem_cache_init(memory_start
, memory_end
);
904 #ifdef CONFIG_BLK_DEV_INITRD
905 if (initrd_start
&& !initrd_below_start_ok
&& initrd_start
< memory_start
) {
906 printk(KERN_CRIT
"initrd overwritten (0x%08lx < 0x%08lx) - "
907 "disabling it.\n",initrd_start
,memory_start
);
911 mem_init(memory_start
,memory_end
);
912 kmem_cache_sizes_init();
913 #ifdef CONFIG_PROC_FS
924 #if defined(CONFIG_SYSVIPC) || defined(CONFIG_KERNELD)
931 printk(linux_banner
);
932 printk("POSIX conformance testing by UNIFIX\n");
940 * We count on the initial thread going ok
941 * Like idlers init is an unlocked kernel thread, which will
942 * make syscalls (and thus be locked).
944 kernel_thread(init
, NULL
, 0);
946 * task[0] is meant to be used as an "idle" task: it may not sleep, but
947 * it might do some general things like count free pages or it could be
948 * used to implement a reasonable LRU algorithm for the paging routines:
949 * anything that can be useful, but shouldn't take time from the real
952 * Right now task[0] just does an infinite idle loop.
957 #ifdef CONFIG_BLK_DEV_INITRD
958 static int do_linuxrc(void * shell
)
960 static char *argv
[] = { "linuxrc", NULL
, };
962 close(0);close(1);close(2);
964 (void) open("/dev/tty1",O_RDWR
,0);
967 return execve(shell
, argv
, envp_init
);
970 __initfunc(static void no_initrd(char *s
,int *ints
))
976 static int init(void * unused
)
978 #ifdef CONFIG_BLK_DEV_INITRD
979 int real_root_mountflags
;
982 /* Launch bdflush from here, instead of the old syscall way. */
983 kernel_thread(bdflush
, NULL
, 0);
984 /* Start the background pageout daemon. */
986 kernel_thread(kswapd
, NULL
, 0);
989 /* Start the async paging daemon. */
991 extern int asyncd(void *);
992 kernel_thread(asyncd
, NULL
, 0);
996 #ifdef CONFIG_BLK_DEV_INITRD
997 real_root_dev
= ROOT_DEV
;
998 real_root_mountflags
= root_mountflags
;
999 if (initrd_start
&& mount_initrd
) root_mountflags
&= ~MS_RDONLY
;
1000 else mount_initrd
=0;
1006 * With the devices probed and setup we can
1007 * now enter SMP mode.
1013 #ifdef CONFIG_UMSDOS_FS
1016 When mounting a umsdos fs as root, we detect
1017 the pseudo_root (/linux) and initialise it here.
1018 pseudo_root is defined in fs/umsdos/inode.c
1020 extern struct inode
*pseudo_root
;
1021 if (pseudo_root
!= NULL
){
1022 current
->fs
->root
= pseudo_root
;
1023 current
->fs
->pwd
= pseudo_root
;
1028 #ifdef CONFIG_BLK_DEV_INITRD
1029 root_mountflags
= real_root_mountflags
;
1030 if (mount_initrd
&& ROOT_DEV
!= real_root_dev
&& ROOT_DEV
== MKDEV(RAMDISK_MAJOR
,0)) {
1034 pid
= kernel_thread(do_linuxrc
, "/linuxrc", SIGCHLD
);
1036 while (pid
!= wait(&i
));
1037 if (real_root_dev
!= MKDEV(RAMDISK_MAJOR
, 0)) {
1038 error
= change_root(real_root_dev
,"/initrd");
1040 printk(KERN_ERR
"Change root to /initrd: "
1041 "error %d\n",error
);
1048 if (open("/dev/console",O_RDWR
,0) < 0)
1049 printk("Unable to open an initial console.\n");
1055 * We try each of these until one succeeds.
1057 * The Bourne shell can be used instead of init if we are
1058 * trying to recover a really broken machine.
1062 execve(execute_command
,argv_init
,envp_init
);
1063 execve("/sbin/init",argv_init
,envp_init
);
1064 execve("/etc/init",argv_init
,envp_init
);
1065 execve("/bin/init",argv_init
,envp_init
);
1066 execve("/bin/sh",argv_init
,envp_init
);
1067 panic("No init found. Try passing init= option to kernel.");