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>
48 * Versions of gcc older than that listed below may actually compile
49 * and link okay, but the end product can have subtle run time bugs.
50 * To avoid associated bogus bug reports, we flatly refuse to compile
51 * with a gcc that is known to be too old from the very beginning.
53 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
54 #error sorry, your GCC is too old. It builds incorrect kernels.
57 extern char _stext
, _etext
;
58 extern char *linux_banner
;
60 extern int console_loglevel
;
62 static int init(void *);
63 extern int bdflush(void *);
64 extern int kswapd(void *);
66 extern void init_IRQ(void);
67 extern void init_modules(void);
68 extern long console_init(long, long);
69 extern void sock_init(void);
70 extern void uidcache_init(void);
71 extern unsigned long pci_init(unsigned long, unsigned long);
72 extern long mca_init(long, long);
73 extern long sbus_init(long, long);
74 extern void sysctl_init(void);
76 extern void smp_setup(char *str
, int *ints
);
77 extern void no_scroll(char *str
, int *ints
);
78 extern void swap_setup(char *str
, int *ints
);
79 extern void buff_setup(char *str
, int *ints
);
80 extern void panic_setup(char *str
, int *ints
);
81 extern void bmouse_setup(char *str
, int *ints
);
82 extern void msmouse_setup(char *str
, int *ints
);
84 extern void lp_setup(char *str
, int *ints
);
86 extern void eth_setup(char *str
, int *ints
);
87 extern void xd_setup(char *str
, int *ints
);
88 #ifdef CONFIG_BLK_DEV_EZ
89 extern void ez_setup(char *str
, int *ints
);
91 extern void floppy_setup(char *str
, int *ints
);
92 extern void st_setup(char *str
, int *ints
);
93 extern void st0x_setup(char *str
, int *ints
);
94 extern void advansys_setup(char *str
, int *ints
);
95 extern void tmc8xx_setup(char *str
, int *ints
);
96 extern void t128_setup(char *str
, int *ints
);
97 extern void pas16_setup(char *str
, int *ints
);
98 extern void generic_NCR5380_setup(char *str
, int *intr
);
99 extern void generic_NCR53C400_setup(char *str
, int *intr
);
100 extern void aha152x_setup(char *str
, int *ints
);
101 extern void aha1542_setup(char *str
, int *ints
);
102 extern void aic7xxx_setup(char *str
, int *ints
);
103 extern void AM53C974_setup(char *str
, int *ints
);
104 extern void BusLogic_Setup(char *str
, int *ints
);
105 extern void ncr53c8xx_setup(char *str
, int *ints
);
106 extern void eata2x_setup(char *str
, int *ints
);
107 extern void u14_34f_setup(char *str
, int *ints
);
108 extern void fdomain_setup(char *str
, int *ints
);
109 extern void ibmmca_scsi_setup(char *str
, int *ints
);
110 extern void in2000_setup(char *str
, int *ints
);
111 extern void NCR53c406a_setup(char *str
, int *ints
);
112 extern void wd7000_setup(char *str
, int *ints
);
114 extern void ppa_setup(char *str
, int *ints
);
116 extern void scsi_luns_setup(char *str
, int *ints
);
117 extern void sound_setup(char *str
, int *ints
);
118 extern void reboot_setup(char *str
, int *ints
);
119 extern void video_setup(char *str
, int *ints
);
121 extern void cdu31a_setup(char *str
, int *ints
);
123 #ifdef CONFIG_BLK_DEV_PS2
124 extern void ed_setup(char *str
, int *ints
);
125 extern void tp720_setup(char *str
, int *ints
);
126 #endif CONFIG_BLK_DEV_PS2
128 extern void mcd_setup(char *str
, int *ints
);
131 extern void mcdx_setup(char *str
, int *ints
);
134 extern void sbpcd_setup(char *str
, int *ints
);
137 extern void aztcd_setup(char *str
, int *ints
);
140 extern void sonycd535_setup(char *str
, int *ints
);
143 extern void gscd_setup(char *str
, int *ints
);
146 extern void bpcd_setup(char *str
, int *ints
);
149 extern void cm206_setup(char *str
, int *ints
);
152 extern void optcd_setup(char *str
, int *ints
);
155 extern void sjcd_setup(char *str
, int *ints
);
157 #ifdef CONFIG_ISP16_CDI
158 extern void isp16_setup(char *str
, int *ints
);
159 #endif CONFIG_ISP16_CDI
160 #ifdef CONFIG_BLK_DEV_RAM
161 static void ramdisk_start_setup(char *str
, int *ints
);
162 static void load_ramdisk(char *str
, int *ints
);
163 static void prompt_ramdisk(char *str
, int *ints
);
164 static void ramdisk_size(char *str
, int *ints
);
165 #ifdef CONFIG_BLK_DEV_INITRD
166 static void no_initrd(char *s
,int *ints
);
168 #endif CONFIG_BLK_DEV_RAM
169 #ifdef CONFIG_ISDN_DRV_ICN
170 extern void icn_setup(char *str
, int *ints
);
172 #ifdef CONFIG_ISDN_DRV_HISAX
173 extern void HiSax_setup(char *str
, int *ints
);
175 #ifdef CONFIG_DIGIEPCA
176 extern void epca_setup(char *str
, int *ints
);
178 #ifdef CONFIG_ISDN_DRV_PCBIT
179 extern void pcbit_setup(char *str
, int *ints
);
182 #ifdef CONFIG_ATARIMOUSE
183 extern void atari_mouse_setup (char *str
, int *ints
);
185 #ifdef CONFIG_DMASOUND
186 extern void dmasound_setup (char *str
, int *ints
);
188 #ifdef CONFIG_ATARI_SCSI
189 extern void atari_scsi_setup (char *str
, int *ints
);
191 extern void wd33c93_setup (char *str
, int *ints
);
192 extern void gvp11_setup (char *str
, int *ints
);
193 extern void ncr53c7xx_setup (char *str
, int *ints
);
195 #ifdef CONFIG_CYCLADES
196 extern void cy_setup(char *str
, int *ints
);
199 extern void pcxx_setup(char *str
, int *ints
);
201 #ifdef CONFIG_RISCOM8
202 extern void riscom8_setup(char *str
, int *ints
);
205 extern void baycom_setup(char *str
, int *ints
);
207 #ifdef CONFIG_SOUNDMODEM
208 extern void sm_setup(char *str
, int *ints
);
211 extern void wdt_setup(char *str
, int *ints
);
213 #ifdef CONFIG_PNP_PARPORT
214 extern void parport_setup(char *str
, int *ints
);
217 extern void plip_setup(char *str
, int *ints
);
220 #if defined(CONFIG_SYSVIPC) || defined(CONFIG_KERNELD)
221 extern void ipc_init(void);
225 extern int serial_console
;
229 * Boot command-line arguments
231 #define MAX_INIT_ARGS 8
232 #define MAX_INIT_ENVS 8
234 extern void time_init(void);
236 static unsigned long memory_start
= 0;
237 static unsigned long memory_end
= 0;
241 #ifdef CONFIG_BLK_DEV_RAM
242 extern int rd_doload
; /* 1 = load ramdisk, 0 = don't load */
243 extern int rd_prompt
; /* 1 = prompt for ramdisk, 0 = don't prompt */
244 extern int rd_size
; /* Size of the ramdisk(s) */
245 extern int rd_image_start
; /* starting block # of image */
246 #ifdef CONFIG_BLK_DEV_INITRD
247 kdev_t real_root_dev
;
251 int root_mountflags
= MS_RDONLY
;
252 char *execute_command
= NULL
;
254 #ifdef CONFIG_ROOT_NFS
255 char nfs_root_name
[NFS_ROOT_NAME_LEN
] = { "default" };
256 char nfs_root_addrs
[NFS_ROOT_ADDRS_LEN
] = { "" };
259 extern void dquot_init(void);
261 static char * argv_init
[MAX_INIT_ARGS
+2] = { "init", NULL
, };
262 static char * envp_init
[MAX_INIT_ENVS
+2] = { "HOME=/", "TERM=linux", NULL
, };
264 char *get_options(char *str
, int *ints
)
269 while (cur
&& isdigit(*cur
) && i
<= 10) {
270 ints
[i
++] = simple_strtoul(cur
,NULL
,0);
271 if ((cur
= strchr(cur
,',')) != NULL
)
278 __initfunc(static void profile_setup(char *str
, int *ints
))
281 prof_shift
= (unsigned long) ints
[1];
283 #ifdef CONFIG_PROFILE_SHIFT
284 prof_shift
= CONFIG_PROFILE_SHIFT
;
292 void (*setup_func
)(char *, int *);
293 } bootsetups
[] __initdata
= {
294 { "reserve=", reserve_setup
},
295 { "profile=", profile_setup
},
297 { "nosmp", smp_setup
},
298 { "maxcpus=", smp_setup
},
300 #ifdef CONFIG_BLK_DEV_RAM
301 { "ramdisk_start=", ramdisk_start_setup
},
302 { "load_ramdisk=", load_ramdisk
},
303 { "prompt_ramdisk=", prompt_ramdisk
},
304 { "ramdisk=", ramdisk_size
},
305 { "ramdisk_size=", ramdisk_size
},
306 #ifdef CONFIG_BLK_DEV_INITRD
307 { "noinitrd", no_initrd
},
310 #if defined (CONFIG_AMIGA) || defined (CONFIG_ATARI)
311 { "video=", video_setup
},
313 { "swap=", swap_setup
},
314 { "buff=", buff_setup
},
315 { "panic=", panic_setup
},
317 { "no-scroll", no_scroll
},
319 #ifdef CONFIG_BUGi386
320 { "no-hlt", no_halt
},
322 { "reboot=", reboot_setup
},
325 { "ether=", eth_setup
},
327 #ifdef CONFIG_PRINTER
331 { "max_scsi_luns=", scsi_luns_setup
},
333 #ifdef CONFIG_SCSI_ADVANSYS
334 { "advansys=", advansys_setup
},
336 #if defined(CONFIG_BLK_DEV_HD)
339 #ifdef CONFIG_CHR_DEV_ST
342 #ifdef CONFIG_BUSMOUSE
343 { "bmouse=", bmouse_setup
},
345 #ifdef CONFIG_MS_BUSMOUSE
346 { "msmouse=", msmouse_setup
},
348 #ifdef CONFIG_SCSI_SEAGATE
349 { "st0x=", st0x_setup
},
350 { "tmc8xx=", tmc8xx_setup
},
352 #ifdef CONFIG_SCSI_T128
353 { "t128=", t128_setup
},
355 #ifdef CONFIG_SCSI_PAS16
356 { "pas16=", pas16_setup
},
358 #ifdef CONFIG_SCSI_GENERIC_NCR5380
359 { "ncr5380=", generic_NCR5380_setup
},
360 { "ncr53c400=", generic_NCR53C400_setup
},
362 #ifdef CONFIG_SCSI_AHA152X
363 { "aha152x=", aha152x_setup
},
365 #ifdef CONFIG_SCSI_AHA1542
366 { "aha1542=", aha1542_setup
},
368 #ifdef CONFIG_SCSI_AIC7XXX
369 { "aic7xxx=", aic7xxx_setup
},
371 #ifdef CONFIG_SCSI_BUSLOGIC
372 { "BusLogic=", BusLogic_Setup
},
374 #ifdef CONFIG_SCSI_NCR53C8XX
375 { "ncr53c8xx=", ncr53c8xx_setup
},
377 #ifdef CONFIG_SCSI_EATA
378 { "eata=", eata2x_setup
},
380 #ifdef CONFIG_SCSI_U14_34F
381 { "u14-34f=", u14_34f_setup
},
383 #ifdef CONFIG_SCSI_AM53C974
384 { "AM53C974=", AM53C974_setup
},
386 #ifdef CONFIG_SCSI_NCR53C406A
387 { "ncr53c406a=", NCR53c406a_setup
},
389 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
390 { "fdomain=", fdomain_setup
},
392 #ifdef CONFIG_SCSI_IN2000
393 { "in2000=", in2000_setup
},
395 #ifdef CONFIG_SCSI_7000FASST
396 { "wd7000=", wd7000_setup
},
398 #ifdef NOTDEF /* CONFIG_SCSI_PPA */
399 { "ppa=", ppa_setup
},
401 #ifdef CONFIG_SCSI_IBMMCA
402 { "ibmmcascsi=", ibmmca_scsi_setup
},
404 #ifdef CONFIG_BLK_DEV_XD
407 #ifdef CONFIG_BLK_DEV_EZ
410 #ifdef CONFIG_BLK_DEV_FD
411 { "floppy=", floppy_setup
},
413 #ifdef CONFIG_BLK_DEV_PS2
415 { "tp720=", tp720_setup
},
418 { "cdu31a=", cdu31a_setup
},
421 { "mcd=", mcd_setup
},
424 { "mcdx=", mcdx_setup
},
427 { "sbpcd=", sbpcd_setup
},
430 { "aztcd=", aztcd_setup
},
433 { "sonycd535=", sonycd535_setup
},
436 { "gscd=", gscd_setup
},
439 { "bpcd=", bpcd_setup
},
442 { "cm206=", cm206_setup
},
445 { "optcd=", optcd_setup
},
448 { "sjcd=", sjcd_setup
},
450 #ifdef CONFIG_ISP16_CDI
451 { "isp16=", isp16_setup
},
452 #endif CONFIG_ISP16_CDI
454 { "sound=", sound_setup
},
456 #ifdef CONFIG_ISDN_DRV_ICN
457 { "icn=", icn_setup
},
459 #ifdef CONFIG_ISDN_DRV_HISAX
460 { "hisax=", HiSax_setup
},
461 { "HiSax=", HiSax_setup
},
463 #ifdef CONFIG_ISDN_DRV_PCBIT
464 { "pcbit=", pcbit_setup
},
466 #ifdef CONFIG_ATARIMOUSE
467 { "atamouse=", atari_mouse_setup
},
469 #ifdef CONFIG_DMASOUND
470 { "dmasound=", dmasound_setup
},
472 #ifdef CONFIG_ATARI_SCSI
473 { "atascsi=", atari_scsi_setup
},
475 #if defined(CONFIG_A4000T_SCSI) || defined(CONFIG_WARPENGINE_SCSI) || defined(CONFIG_A4091_SCSI)
476 { "53c7xx=", ncr53c7xx_setup
},
478 #if defined(CONFIG_A3000_SCSI) || defined(CONFIG_A2091_SCSI) \
479 || defined(CONFIG_GVP11_SCSI)
480 { "wd33c93=", wd33c93_setup
},
482 #if defined(CONFIG_GVP11_SCSI)
483 { "gvp11=", gvp11_setup
},
485 #ifdef CONFIG_CYCLADES
486 { "cyclades=", cy_setup
},
489 { "digi=", pcxx_setup
},
491 #ifdef CONFIG_DIGIEPCA
492 { "digiepca=", epca_setup
},
494 #ifdef CONFIG_RISCOM8
495 { "riscom8=", riscom8_setup
},
498 { "baycom=", baycom_setup
},
500 #ifdef CONFIG_SOUNDMODEM
501 { "soundmodem=", sm_setup
},
504 { "wdt=", wdt_setup
},
506 #ifdef CONFIG_PNP_PARPORT
507 { "parport=", parport_setup
},
510 { "plip=", plip_setup
},
515 #ifdef CONFIG_BLK_DEV_RAM
516 __initfunc(static void ramdisk_start_setup(char *str
, int *ints
))
518 if (ints
[0] > 0 && ints
[1] >= 0)
519 rd_image_start
= ints
[1];
522 __initfunc(static void load_ramdisk(char *str
, int *ints
))
524 if (ints
[0] > 0 && ints
[1] >= 0)
525 rd_doload
= ints
[1] & 1;
528 __initfunc(static void prompt_ramdisk(char *str
, int *ints
))
530 if (ints
[0] > 0 && ints
[1] >= 0)
531 rd_prompt
= ints
[1] & 1;
534 __initfunc(static void ramdisk_size(char *str
, int *ints
))
536 if (ints
[0] > 0 && ints
[1] >= 0)
542 __initfunc(static int checksetup(char *line
))
547 #ifdef CONFIG_BLK_DEV_IDE
548 /* ide driver needs the basic string, rather than pre-processed values */
549 if (!strncmp(line
,"ide",3) || (!strncmp(line
,"hd",2) && line
[2] != '=')) {
554 while (bootsetups
[i
].str
) {
555 int n
= strlen(bootsetups
[i
].str
);
556 if (!strncmp(line
,bootsetups
[i
].str
,n
)) {
557 bootsetups
[i
].setup_func(get_options(line
+n
,ints
), ints
);
565 /* this should be approx 2 Bo*oMips to start (note initial shift), and will
566 still work even if initially too large, it will just take slightly longer */
567 unsigned long loops_per_sec
= (1<<12);
569 /* This is the number of bits of precision for the loops_per_second. Each
570 bit takes on average 1.5/HZ seconds. This (like the original) is a little
574 __initfunc(void calibrate_delay(void))
576 unsigned long ticks
, loopbit
;
577 int lps_precision
= LPS_PREC
;
579 loops_per_sec
= (1<<12);
581 printk("Calibrating delay loop.. ");
582 while (loops_per_sec
<<= 1) {
583 /* wait for "start of" clock tick */
585 while (ticks
== jiffies
)
589 __delay(loops_per_sec
);
590 ticks
= jiffies
- ticks
;
595 /* Do a binary approximation to get loops_per_second set to equal one clock
596 (up to lps_precision bits) */
598 loopbit
= loops_per_sec
;
599 while ( lps_precision
-- && (loopbit
>>= 1) ) {
600 loops_per_sec
|= loopbit
;
602 while (ticks
== jiffies
);
604 __delay(loops_per_sec
);
605 if (jiffies
!= ticks
) /* longer than 1 tick */
606 loops_per_sec
&= ~loopbit
;
609 /* finally, adjust loops per second in terms of seconds instead of clocks */
611 /* Round the value and print it */
612 printk("ok - %lu.%02lu BogoMIPS\n",
613 (loops_per_sec
+2500)/500000,
614 ((loops_per_sec
+2500)/5000) % 100);
617 __initfunc(static void parse_root_dev(char * line
))
620 static struct dev_name_struct
{
645 { "cdu535", 0x1800 },
647 { "cm206cd", 0x2000 },
650 { "sonycd", 0x1800 },
655 { "apblock", APBLOCK_MAJOR
<< 8},
658 { "ddv", DDV_MAJOR
<< 8},
663 if (strncmp(line
,"/dev/",5) == 0) {
664 struct dev_name_struct
*dev
= devices
;
667 int len
= strlen(dev
->name
);
668 if (strncmp(line
,dev
->name
,len
) == 0) {
676 ROOT_DEV
= to_kdev_t(base
+ simple_strtoul(line
,NULL
,base
?10:16));
680 * This is a simple kernel command line parsing function: it parses
681 * the command line, and fills in the arguments/environment to init
682 * as appropriate. Any cmd-line option is taken to be an environment
683 * variable if it contains the character '='.
686 * This routine also checks for options meant for the kernel.
687 * These options are not given to init - they are for internal kernel use only.
689 __initfunc(static void parse_options(char *line
))
697 envs
= 1; /* TERM is set to 'linux' by default */
699 while ((line
= next
) != NULL
) {
700 if ((next
= strchr(line
,' ')) != NULL
)
703 * check for kernel options first..
705 if (!strncmp(line
,"root=",5)) {
706 parse_root_dev(line
+5);
709 #ifdef CONFIG_ROOT_NFS
710 if (!strncmp(line
, "nfsroot=", 8)) {
713 ROOT_DEV
= MKDEV(UNNAMED_MAJOR
, 255);
714 if (line
[0] == '/' || line
[0] == ',' || (line
[0] >= '0' && line
[0] <= '9')) {
715 strncpy(nfs_root_name
, line
, sizeof(nfs_root_name
));
716 nfs_root_name
[sizeof(nfs_root_name
)-1] = '\0';
719 n
= strlen(line
) + strlen(NFS_ROOT
);
720 if (n
>= sizeof(nfs_root_name
))
721 line
[sizeof(nfs_root_name
) - strlen(NFS_ROOT
) - 1] = '\0';
722 sprintf(nfs_root_name
, NFS_ROOT
, line
);
725 if (!strncmp(line
, "nfsaddrs=", 9)) {
727 strncpy(nfs_root_addrs
, line
, sizeof(nfs_root_addrs
));
728 nfs_root_addrs
[sizeof(nfs_root_addrs
)-1] = '\0';
732 if (!strcmp(line
,"ro")) {
733 root_mountflags
|= MS_RDONLY
;
736 if (!strcmp(line
,"rw")) {
737 root_mountflags
&= ~MS_RDONLY
;
740 if (!strcmp(line
,"debug")) {
741 console_loglevel
= 10;
744 if (!strncmp(line
,"init=",5)) {
746 execute_command
= line
;
749 if (checksetup(line
))
753 * Then check if it's an environment variable or
756 if (strchr(line
,'=')) {
757 if (envs
>= MAX_INIT_ENVS
)
759 envp_init
[++envs
] = line
;
761 if (args
>= MAX_INIT_ARGS
)
763 argv_init
[++args
] = line
;
766 argv_init
[args
+1] = NULL
;
767 envp_init
[envs
+1] = NULL
;
771 extern void setup_arch(char **, unsigned long *, unsigned long *);
776 * Uniprocessor idle thread
779 int cpu_idle(void *unused
)
788 * Multiprocessor idle thread is in arch/...
791 extern int cpu_idle(void * unused
);
793 /* Called by boot processor to activate the rest. */
794 __initfunc(static void smp_init(void))
796 /* Get other processors into their bootup holding patterns. */
801 * The autoprobe routines assume CPU#0 on the i386
802 * so we don't actually set the game in motion until
806 __initfunc(static void smp_begin(void))
814 extern void initialize_secondary(void);
817 * Activate the first processor.
820 __initfunc(asmlinkage
void start_kernel(void))
825 static int boot_cpu
= 1;
826 /* "current" has been set up, we need to load it now */
828 initialize_secondary();
833 * Interrupts are still disabled. Do necessary setups, then
836 setup_arch(&command_line
, &memory_start
, &memory_end
);
837 memory_start
= paging_init(memory_start
,memory_end
);
842 parse_options(command_line
);
843 #ifdef CONFIG_MODULES
846 #ifdef CONFIG_PROFILE
848 #ifdef CONFIG_PROFILE_SHIFT
849 prof_shift
= CONFIG_PROFILE_SHIFT
;
855 prof_buffer
= (unsigned int *) memory_start
;
856 /* only text is profiled */
857 prof_len
= (unsigned long) &_etext
- (unsigned long) &_stext
;
858 prof_len
>>= prof_shift
;
859 memory_start
+= prof_len
* sizeof(unsigned int);
860 memset(prof_buffer
, 0, prof_len
* sizeof(unsigned int));
863 memory_start
= sbus_init(memory_start
,memory_end
);
865 memory_start
= console_init(memory_start
,memory_end
);
867 memory_start
= pci_init(memory_start
,memory_end
);
870 memory_start
= mca_init(memory_start
,memory_end
);
872 memory_start
= kmem_cache_init(memory_start
, memory_end
);
875 memory_start
= name_cache_init(memory_start
,memory_end
);
876 #ifdef CONFIG_BLK_DEV_INITRD
877 if (initrd_start
&& !initrd_below_start_ok
&& initrd_start
< memory_start
) {
878 printk(KERN_CRIT
"initrd overwritten (0x%08lx < 0x%08lx) - "
879 "disabling it.\n",initrd_start
,memory_start
);
883 mem_init(memory_start
,memory_end
);
884 kmem_cache_sizes_init();
885 #ifdef CONFIG_PROC_FS
894 #if defined(CONFIG_SYSVIPC) || defined(CONFIG_KERNELD)
901 printk(linux_banner
);
902 printk("POSIX conformance testing by UNIFIX\n");
910 * We count on the initial thread going ok
911 * Like idlers init is an unlocked kernel thread, which will
912 * make syscalls (and thus be locked).
914 kernel_thread(init
, NULL
, 0);
916 * task[0] is meant to be used as an "idle" task: it may not sleep, but
917 * it might do some general things like count free pages or it could be
918 * used to implement a reasonable LRU algorithm for the paging routines:
919 * anything that can be useful, but shouldn't take time from the real
922 * Right now task[0] just does an infinite idle loop.
927 #ifdef CONFIG_BLK_DEV_INITRD
928 static int do_linuxrc(void * shell
)
930 static char *argv
[] = { "linuxrc", NULL
, };
932 close(0);close(1);close(2);
934 (void) open("/dev/tty1",O_RDWR
,0);
937 return execve(shell
, argv
, envp_init
);
940 __initfunc(static void no_initrd(char *s
,int *ints
))
946 static int init(void * unused
)
948 #ifdef CONFIG_BLK_DEV_INITRD
949 int real_root_mountflags
;
952 /* Launch bdflush from here, instead of the old syscall way. */
953 kernel_thread(bdflush
, NULL
, 0);
954 /* Start the background pageout daemon. */
955 kernel_thread(kswapd
, NULL
, 0);
958 /* Start the async paging daemon. */
960 extern int asyncd(void *);
961 kernel_thread(asyncd
, NULL
, 0);
965 #ifdef CONFIG_BLK_DEV_INITRD
966 real_root_dev
= ROOT_DEV
;
967 real_root_mountflags
= root_mountflags
;
968 if (initrd_start
&& mount_initrd
) root_mountflags
&= ~MS_RDONLY
;
969 else mount_initrd
=0;
975 * With the devices probed and setup we can
976 * now enter SMP mode.
982 #ifdef CONFIG_UMSDOS_FS
985 When mounting a umsdos fs as root, we detect
986 the pseudo_root (/linux) and initialise it here.
987 pseudo_root is defined in fs/umsdos/inode.c
989 extern struct inode
*pseudo_root
;
990 if (pseudo_root
!= NULL
){
991 current
->fs
->root
= pseudo_root
;
992 current
->fs
->pwd
= pseudo_root
;
997 #ifdef CONFIG_BLK_DEV_INITRD
998 root_mountflags
= real_root_mountflags
;
999 if (mount_initrd
&& ROOT_DEV
!= real_root_dev
&& ROOT_DEV
== MKDEV(RAMDISK_MAJOR
,0)) {
1003 pid
= kernel_thread(do_linuxrc
, "/linuxrc", SIGCHLD
);
1005 while (pid
!= wait(&i
));
1006 if (real_root_dev
!= MKDEV(RAMDISK_MAJOR
, 0)) {
1007 error
= change_root(real_root_dev
,"/initrd");
1009 printk(KERN_ERR
"Change root to /initrd: "
1010 "error %d\n",error
);
1017 if (open("/dev/console",O_RDWR
,0) < 0)
1018 printk("Unable to open an initial console.\n");
1024 * We try each of these until one succeeds.
1026 * The Bourne shell can be used instead of init if we are
1027 * trying to recover a really broken machine.
1031 execve(execute_command
,argv_init
,envp_init
);
1032 execve("/sbin/init",argv_init
,envp_init
);
1033 execve("/etc/init",argv_init
,envp_init
);
1034 execve("/bin/init",argv_init
,envp_init
);
1035 execve("/bin/sh",argv_init
,envp_init
);
1036 panic("No init found. Try passing init= option to kernel.");