This source file includes following definitions.
- get_options
- profile_setup
- ramdisk_start_setup
- load_ramdisk
- prompt_ramdisk
- checksetup
- calibrate_delay
- parse_options
- cpu_idle
- start_secondary
- smp_init
- smp_begin
- start_kernel
- printf
- do_rc
- do_shell
- do_linuxrc
- no_initrd
- init
1
2
3
4
5
6
7
8
9
10 #define __KERNEL_SYSCALLS__
11 #include <stdarg.h>
12
13 #include <asm/system.h>
14 #include <asm/io.h>
15
16 #include <linux/types.h>
17 #include <linux/fcntl.h>
18 #include <linux/config.h>
19 #include <linux/sched.h>
20 #include <linux/kernel.h>
21 #include <linux/tty.h>
22 #include <linux/head.h>
23 #include <linux/unistd.h>
24 #include <linux/string.h>
25 #include <linux/timer.h>
26 #include <linux/fs.h>
27 #include <linux/ctype.h>
28 #include <linux/delay.h>
29 #include <linux/utsname.h>
30 #include <linux/ioport.h>
31 #include <linux/hdreg.h>
32 #include <linux/mm.h>
33 #include <linux/major.h>
34 #include <linux/blk.h>
35 #ifdef CONFIG_APM
36 #include <linux/apm_bios.h>
37 #endif
38 #ifdef CONFIG_ROOT_NFS
39 #include <linux/nfs_fs.h>
40 #endif
41
42 #include <asm/bugs.h>
43
44 extern char _stext, _etext;
45 extern char *linux_banner;
46
47 static char printbuf[1024];
48
49 extern int console_loglevel;
50
51 static int init(void *);
52 extern int bdflush(void *);
53 extern int kswapd(void *);
54
55 extern void init_IRQ(void);
56 extern void init_modules(void);
57 extern long console_init(long, long);
58 extern long kmalloc_init(long,long);
59 extern void sock_init(void);
60 extern long pci_init(long, long);
61 extern void sysctl_init(void);
62
63 extern void swap_setup(char *str, int *ints);
64 extern void buff_setup(char *str, int *ints);
65 extern void panic_setup(char *str, int *ints);
66 extern void bmouse_setup(char *str, int *ints);
67 extern void eth_setup(char *str, int *ints);
68 extern void xd_setup(char *str, int *ints);
69 extern void floppy_setup(char *str, int *ints);
70 extern void st_setup(char *str, int *ints);
71 extern void st0x_setup(char *str, int *ints);
72 extern void advansys_setup(char *str, int *ints);
73 extern void tmc8xx_setup(char *str, int *ints);
74 extern void t128_setup(char *str, int *ints);
75 extern void pas16_setup(char *str, int *ints);
76 extern void generic_NCR5380_setup(char *str, int *intr);
77 extern void generic_NCR53C400_setup(char *str, int *intr);
78 extern void aha152x_setup(char *str, int *ints);
79 extern void aha1542_setup(char *str, int *ints);
80 extern void aic7xxx_setup(char *str, int *ints);
81 extern void AM53C974_setup(char *str, int *ints);
82 extern void BusLogic_Setup(char *str, int *ints);
83 extern void fdomain_setup(char *str, int *ints);
84 extern void NCR53c406a_setup(char *str, int *ints);
85 extern void scsi_luns_setup(char *str, int *ints);
86 extern void sound_setup(char *str, int *ints);
87 #ifdef CONFIG_CDU31A
88 extern void cdu31a_setup(char *str, int *ints);
89 #endif CONFIG_CDU31A
90 #ifdef CONFIG_MCD
91 extern void mcd_setup(char *str, int *ints);
92 #endif CONFIG_MCD
93 #ifdef CONFIG_MCDX
94 extern void mcdx_setup(char *str, int *ints);
95 #endif CONFIG_MCDX
96 #ifdef CONFIG_SBPCD
97 extern void sbpcd_setup(char *str, int *ints);
98 #endif CONFIG_SBPCD
99 #ifdef CONFIG_AZTCD
100 extern void aztcd_setup(char *str, int *ints);
101 #endif CONFIG_AZTCD
102 #ifdef CONFIG_CDU535
103 extern void sonycd535_setup(char *str, int *ints);
104 #endif CONFIG_CDU535
105 #ifdef CONFIG_GSCD
106 extern void gscd_setup(char *str, int *ints);
107 #endif CONFIG_GSCD
108 #ifdef CONFIG_CM206
109 extern void cm206_setup(char *str, int *ints);
110 #endif CONFIG_CM206
111 #ifdef CONFIG_OPTCD
112 extern void optcd_setup(char *str, int *ints);
113 #endif CONFIG_OPTCD
114 #ifdef CONFIG_SJCD
115 extern void sjcd_setup(char *str, int *ints);
116 #endif CONFIG_SJCD
117 #ifdef CONFIG_ISP16_CDI
118 extern void isp16_setup(char *str, int *ints);
119 #endif CONFIG_ISP16_CDI
120 #ifdef CONFIG_BLK_DEV_RAM
121 static void ramdisk_start_setup(char *str, int *ints);
122 static void load_ramdisk(char *str, int *ints);
123 static void prompt_ramdisk(char *str, int *ints);
124 #ifdef CONFIG_BLK_DEV_INITRD
125 static void no_initrd(char *s,int *ints);
126 #endif
127 #endif CONFIG_BLK_DEV_RAM
128 #ifdef CONFIG_ISDN_DRV_ICN
129 extern void icn_setup(char *str, int *ints);
130 #endif
131 #ifdef CONFIG_ISDN_DRV_TELES
132 extern void teles_setup(char *str, int *ints);
133 #endif
134
135 #if defined(CONFIG_SYSVIPC) || defined(CONFIG_KERNELD)
136 extern void ipc_init(void);
137 #endif
138
139
140
141
142 #define MAX_INIT_ARGS 8
143 #define MAX_INIT_ENVS 8
144
145 extern void time_init(void);
146
147 static unsigned long memory_start = 0;
148 static unsigned long memory_end = 0;
149
150 int rows, cols;
151
152 #ifdef CONFIG_BLK_DEV_RAM
153 extern int rd_doload;
154 extern int rd_prompt;
155 extern int rd_image_start;
156 #ifdef CONFIG_BLK_DEV_INITRD
157 kdev_t real_root_dev;
158 #endif
159 #endif
160
161 int root_mountflags = MS_RDONLY;
162 char *execute_command = 0;
163
164 #ifdef CONFIG_ROOT_NFS
165 char nfs_root_name[NFS_ROOT_NAME_LEN] = { NFS_ROOT };
166 char nfs_root_addrs[NFS_ROOT_ADDRS_LEN] = { "" };
167 #endif
168
169 extern void dquot_init(void);
170
171 static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
172 static char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
173
174 static char * argv_rc[] = { "/bin/sh", NULL };
175 static char * envp_rc[] = { "HOME=/", "TERM=linux", NULL };
176
177 static char * argv[] = { "-/bin/sh",NULL };
178 static char * envp[] = { "HOME=/usr/root", "TERM=linux", NULL };
179
180 char *get_options(char *str, int *ints)
181 {
182 char *cur = str;
183 int i=1;
184
185 while (cur && isdigit(*cur) && i <= 10) {
186 ints[i++] = simple_strtoul(cur,NULL,0);
187 if ((cur = strchr(cur,',')) != NULL)
188 cur++;
189 }
190 ints[0] = i-1;
191 return(cur);
192 }
193
194 static void profile_setup(char *str, int *ints)
195 {
196 if (ints[0] > 0)
197 prof_shift = (unsigned long) ints[1];
198 else
199 #ifdef CONFIG_PROFILE_SHIFT
200 prof_shift = CONFIG_PROFILE_SHIFT;
201 #else
202 prof_shift = 2;
203 #endif
204 }
205
206 struct {
207 const char *str;
208 void (*setup_func)(char *, int *);
209 } bootsetups[] = {
210 { "reserve=", reserve_setup },
211 { "profile=", profile_setup },
212 #ifdef CONFIG_BLK_DEV_RAM
213 { "ramdisk_start=", ramdisk_start_setup },
214 { "load_ramdisk=", load_ramdisk },
215 { "prompt_ramdisk=", prompt_ramdisk },
216 #ifdef CONFIG_BLK_DEV_INITRD
217 { "noinitrd", no_initrd },
218 #endif
219 #endif
220 { "swap=", swap_setup },
221 { "buff=", buff_setup },
222 { "panic=", panic_setup },
223 #ifdef CONFIG_BUGi386
224 { "no-hlt", no_halt },
225 { "no387", no_387 },
226 #endif
227 #ifdef CONFIG_INET
228 { "ether=", eth_setup },
229 #endif
230 #ifdef CONFIG_SCSI
231 { "max_scsi_luns=", scsi_luns_setup },
232 #endif
233 #ifdef CONFIG_SCSI_ADVANSYS
234 { "advansys=", advansys_setup },
235 #endif
236 #if defined(CONFIG_BLK_DEV_HD)
237 { "hd=", hd_setup },
238 #endif
239 #ifdef CONFIG_CHR_DEV_ST
240 { "st=", st_setup },
241 #endif
242 #ifdef CONFIG_BUSMOUSE
243 { "bmouse=", bmouse_setup },
244 #endif
245 #ifdef CONFIG_SCSI_SEAGATE
246 { "st0x=", st0x_setup },
247 { "tmc8xx=", tmc8xx_setup },
248 #endif
249 #ifdef CONFIG_SCSI_T128
250 { "t128=", t128_setup },
251 #endif
252 #ifdef CONFIG_SCSI_PAS16
253 { "pas16=", pas16_setup },
254 #endif
255 #ifdef CONFIG_SCSI_GENERIC_NCR5380
256 { "ncr5380=", generic_NCR5380_setup },
257 { "ncr53c400=", generic_NCR53C400_setup },
258 #endif
259 #ifdef CONFIG_SCSI_AHA152X
260 { "aha152x=", aha152x_setup},
261 #endif
262 #ifdef CONFIG_SCSI_AHA1542
263 { "aha1542=", aha1542_setup},
264 #endif
265 #ifdef CONFIG_SCSI_AIC7XXX
266 { "aic7xxx=", aic7xxx_setup},
267 #endif
268 #ifdef CONFIG_SCSI_BUSLOGIC
269 { "BusLogic=", BusLogic_Setup},
270 #endif
271 #ifdef CONFIG_SCSI_AM53C974
272 { "AM53C974=", AM53C974_setup},
273 #endif
274 #ifdef CONFIG_SCSI_NCR53C406A
275 { "ncr53c406a=", NCR53c406a_setup},
276 #endif
277 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
278 { "fdomain=", fdomain_setup},
279 #endif
280 #ifdef CONFIG_BLK_DEV_XD
281 { "xd=", xd_setup },
282 #endif
283 #ifdef CONFIG_BLK_DEV_FD
284 { "floppy=", floppy_setup },
285 #endif
286 #ifdef CONFIG_CDU31A
287 { "cdu31a=", cdu31a_setup },
288 #endif CONFIG_CDU31A
289 #ifdef CONFIG_MCD
290 { "mcd=", mcd_setup },
291 #endif CONFIG_MCD
292 #ifdef CONFIG_MCDX
293 { "mcdx=", mcdx_setup },
294 #endif CONFIG_MCDX
295 #ifdef CONFIG_SBPCD
296 { "sbpcd=", sbpcd_setup },
297 #endif CONFIG_SBPCD
298 #ifdef CONFIG_AZTCD
299 { "aztcd=", aztcd_setup },
300 #endif CONFIG_AZTCD
301 #ifdef CONFIG_CDU535
302 { "sonycd535=", sonycd535_setup },
303 #endif CONFIG_CDU535
304 #ifdef CONFIG_GSCD
305 { "gscd=", gscd_setup },
306 #endif CONFIG_GSCD
307 #ifdef CONFIG_CM206
308 { "cm206=", cm206_setup },
309 #endif CONFIG_CM206
310 #ifdef CONFIG_OPTCD
311 { "optcd=", optcd_setup },
312 #endif CONFIG_OPTCD
313 #ifdef CONFIG_SJCD
314 { "sjcd=", sjcd_setup },
315 #endif CONFIG_SJCD
316 #ifdef CONFIG_ISP16_CDI
317 { "isp16=", isp16_setup },
318 #endif CONFIG_ISP16_CDI
319 #ifdef CONFIG_SOUND
320 { "sound=", sound_setup },
321 #endif
322 #ifdef CONFIG_ISDN_DRV_ICN
323 { "icn=", icn_setup },
324 #endif
325 #ifdef CONFIG_ISDN_DRV_TELES
326 { "teles=", teles_setup },
327 #endif
328 { 0, 0 }
329 };
330
331 #ifdef CONFIG_BLK_DEV_RAM
332 static void ramdisk_start_setup(char *str, int *ints)
333 {
334 if (ints[0] > 0 && ints[1] >= 0)
335 rd_image_start = ints[1];
336 }
337
338 static void load_ramdisk(char *str, int *ints)
339 {
340 if (ints[0] > 0 && ints[1] >= 0)
341 rd_doload = ints[1] & 1;
342 }
343
344 static void prompt_ramdisk(char *str, int *ints)
345 {
346 if (ints[0] > 0 && ints[1] >= 0)
347 rd_prompt = ints[1] & 1;
348 }
349 #endif
350
351 static int checksetup(char *line)
352 {
353 int i = 0;
354 int ints[11];
355
356 #ifdef CONFIG_BLK_DEV_IDE
357
358 if (!strncmp(line,"ide",3) || (!strncmp(line,"hd",2) && line[2] != '=')) {
359 ide_setup(line);
360 return 1;
361 }
362 #endif
363 while (bootsetups[i].str) {
364 int n = strlen(bootsetups[i].str);
365 if (!strncmp(line,bootsetups[i].str,n)) {
366 bootsetups[i].setup_func(get_options(line+n,ints), ints);
367 return 1;
368 }
369 i++;
370 }
371 return 0;
372 }
373
374
375
376 unsigned long loops_per_sec = (1<<12);
377
378
379
380
381 #define LPS_PREC 8
382
383 void calibrate_delay(void)
384 {
385 int ticks;
386 int loopbit;
387 int lps_precision = LPS_PREC;
388
389 loops_per_sec = (1<<12);
390
391 printk("Calibrating delay loop.. ");
392 while (loops_per_sec <<= 1) {
393
394 ticks = jiffies;
395 while (ticks == jiffies)
396 ;
397
398 ticks = jiffies;
399 __delay(loops_per_sec);
400 ticks = jiffies - ticks;
401 if (ticks)
402 break;
403 }
404
405
406
407 loops_per_sec >>= 1;
408 loopbit = loops_per_sec;
409 while ( lps_precision-- && (loopbit >>= 1) ) {
410 loops_per_sec |= loopbit;
411 ticks = jiffies;
412 while (ticks == jiffies);
413 ticks = jiffies;
414 __delay(loops_per_sec);
415 if (jiffies != ticks)
416 loops_per_sec &= ~loopbit;
417 }
418
419
420 loops_per_sec *= HZ;
421
422 printk("ok - %lu.%02lu BogoMIPS\n",
423 (loops_per_sec+2500)/500000,
424 ((loops_per_sec+2500)/5000) % 100);
425 }
426
427
428
429
430
431
432
433
434
435
436
437 static void parse_options(char *line)
438 {
439 char *next;
440 char *devnames[] = { "nfs", "hda", "hdb", "hdc", "hdd", "sda", "sdb",
441 "sdc", "sdd", "sde", "fd", "xda", "xdb", "ram", NULL };
442 int devnums[] = { 0x0FF, 0x300, 0x340, 0x1600, 0x1640, 0x800,
443 0x810, 0x820, 0x830, 0x840, 0x200, 0xD00, 0xD40, 0x100, 0};
444 int args, envs;
445 if (!*line)
446 return;
447 args = 0;
448 envs = 1;
449 next = line;
450 while ((line = next) != NULL) {
451 if ((next = strchr(line,' ')) != NULL)
452 *next++ = 0;
453
454
455
456 if (!strncmp(line,"root=",5)) {
457 int n;
458 line += 5;
459 if (strncmp(line,"/dev/",5)) {
460 ROOT_DEV = to_kdev_t(
461 simple_strtoul(line,NULL,16));
462 continue;
463 }
464 line += 5;
465 for (n = 0 ; devnames[n] ; n++) {
466 int len = strlen(devnames[n]);
467 if (!strncmp(line,devnames[n],len)) {
468 ROOT_DEV = to_kdev_t(devnums[n]+
469 simple_strtoul(line+len,NULL,0));
470 break;
471 }
472 }
473 continue;
474 }
475 #ifdef CONFIG_ROOT_NFS
476 if (!strncmp(line, "nfsroot=", 8)) {
477 int n;
478 line += 8;
479 ROOT_DEV = MKDEV(UNNAMED_MAJOR, 255);
480 if (line[0] == '/' || (line[0] >= '0' && line[0] <= '9')) {
481 strncpy(nfs_root_name, line, sizeof(nfs_root_name));
482 nfs_root_name[sizeof(nfs_root_name)-1] = '\0';
483 continue;
484 }
485 n = strlen(line) + strlen(NFS_ROOT);
486 if (n >= sizeof(nfs_root_name))
487 line[sizeof(nfs_root_name) - strlen(NFS_ROOT) - 1] = '\0';
488 sprintf(nfs_root_name, NFS_ROOT, line);
489 continue;
490 }
491 if (!strncmp(line, "nfsaddrs=", 9)) {
492 line += 9;
493 strncpy(nfs_root_addrs, line, sizeof(nfs_root_addrs));
494 nfs_root_addrs[sizeof(nfs_root_addrs)-1] = '\0';
495 continue;
496 }
497 #endif
498 if (!strcmp(line,"ro")) {
499 root_mountflags |= MS_RDONLY;
500 continue;
501 }
502 if (!strcmp(line,"rw")) {
503 root_mountflags &= ~MS_RDONLY;
504 continue;
505 }
506 if (!strcmp(line,"debug")) {
507 console_loglevel = 10;
508 continue;
509 }
510 if (!strncmp(line,"init=",5)) {
511 line += 5;
512 execute_command = line;
513 continue;
514 }
515 if (checksetup(line))
516 continue;
517
518
519
520
521 if (strchr(line,'=')) {
522 if (envs >= MAX_INIT_ENVS)
523 break;
524 envp_init[++envs] = line;
525 } else {
526 if (args >= MAX_INIT_ARGS)
527 break;
528 argv_init[++args] = line;
529 }
530 }
531 argv_init[args+1] = NULL;
532 envp_init[envs+1] = NULL;
533 }
534
535
536 extern void setup_arch(char **, unsigned long *, unsigned long *);
537 extern void arch_syms_export(void);
538
539 #ifndef __SMP__
540
541
542
543
544
545 int cpu_idle(void *unused)
546 {
547 for(;;)
548 idle();
549 }
550
551 #else
552
553
554
555
556
557 extern int cpu_idle(void * unused);
558
559
560
561
562
563 asmlinkage void start_secondary(void)
564 {
565 trap_init();
566 init_IRQ();
567 smp_callin();
568 cpu_idle(NULL);
569 }
570
571
572
573
574
575
576
577 static void smp_init(void)
578 {
579 int i=0;
580 smp_boot_cpus();
581
582
583
584
585
586 for (i=0; i<NR_CPUS; i++)
587 {
588
589
590
591
592 if (cpu_number_map[i] > 0)
593 {
594
595
596
597
598 kernel_thread(cpu_idle, NULL, CLONE_PID);
599
600
601
602 current_set[i]=task[cpu_number_map[i]];
603 current_set[i]->processor=i;
604 }
605 }
606 }
607
608
609
610
611
612
613
614 static void smp_begin(void)
615 {
616 smp_threads_ready=1;
617 smp_commence();
618 }
619
620 #endif
621
622
623
624
625
626 asmlinkage void start_kernel(void)
627 {
628 char * command_line;
629
630
631
632
633
634 #ifdef __SMP__
635 static int first_cpu=1;
636
637 if(!first_cpu)
638 start_secondary();
639 first_cpu=0;
640
641 #endif
642
643
644
645
646 setup_arch(&command_line, &memory_start, &memory_end);
647 memory_start = paging_init(memory_start,memory_end);
648 trap_init();
649 init_IRQ();
650 sched_init();
651 time_init();
652 parse_options(command_line);
653 #ifdef CONFIG_MODULES
654 init_modules();
655 #endif
656 #ifdef CONFIG_PROFILE
657 if (!prof_shift)
658 #ifdef CONFIG_PROFILE_SHIFT
659 prof_shift = CONFIG_PROFILE_SHIFT;
660 #else
661 prof_shift = 2;
662 #endif
663 #endif
664 if (prof_shift) {
665 prof_buffer = (unsigned int *) memory_start;
666
667 prof_len = (unsigned long) &_etext - (unsigned long) &_stext;
668 prof_len >>= prof_shift;
669 memory_start += prof_len * sizeof(unsigned int);
670 }
671 memory_start = console_init(memory_start,memory_end);
672 #ifdef CONFIG_PCI
673 memory_start = pci_init(memory_start,memory_end);
674 #endif
675 memory_start = kmalloc_init(memory_start,memory_end);
676 sti();
677 calibrate_delay();
678 memory_start = inode_init(memory_start,memory_end);
679 memory_start = file_table_init(memory_start,memory_end);
680 memory_start = name_cache_init(memory_start,memory_end);
681 #ifdef CONFIG_BLK_DEV_INITRD
682 if (initrd_start && initrd_start < memory_start) {
683 printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - "
684 "disabling it.\n",initrd_start,memory_start);
685 initrd_start = 0;
686 }
687 #endif
688 mem_init(memory_start,memory_end);
689 buffer_init();
690 sock_init();
691 #if defined(CONFIG_SYSVIPC) || defined(CONFIG_KERNELD)
692 ipc_init();
693 #endif
694 #ifdef CONFIG_APM
695 apm_bios_init();
696 #endif
697 dquot_init();
698 arch_syms_export();
699 sti();
700 check_bugs();
701
702 printk(linux_banner);
703 #ifdef __SMP__
704 smp_init();
705 #endif
706 sysctl_init();
707
708
709
710
711
712 kernel_thread(init, NULL, 0);
713
714
715
716
717
718
719
720
721
722 cpu_idle(NULL);
723 }
724
725 static int printf(const char *fmt, ...)
726 {
727 va_list args;
728 int i;
729
730 va_start(args, fmt);
731 write(1,printbuf,i=vsprintf(printbuf, fmt, args));
732 va_end(args);
733 return i;
734 }
735
736 static int do_rc(void * rc)
737 {
738 close(0);
739 if (open(rc,O_RDONLY,0))
740 return -1;
741 return execve("/bin/sh", argv_rc, envp_rc);
742 }
743
744 static int do_shell(void * shell)
745 {
746 close(0);close(1);close(2);
747 setsid();
748 (void) open("/dev/tty1",O_RDWR,0);
749 (void) dup(0);
750 (void) dup(0);
751 return execve(shell, argv, envp);
752 }
753
754 #ifdef CONFIG_BLK_DEV_INITRD
755 static int do_linuxrc(void * shell)
756 {
757 static char *argv[] = { "linuxrc", NULL, };
758
759 close(0);close(1);close(2);
760 setsid();
761 (void) open("/dev/tty1",O_RDWR,0);
762 (void) dup(0);
763 (void) dup(0);
764 return execve(shell, argv, envp_init);
765 }
766
767 static void no_initrd(char *s,int *ints)
768 {
769 mount_initrd = 0;
770 }
771 #endif
772
773 static int init(void * unused)
774 {
775 int pid,i;
776 #ifdef CONFIG_BLK_DEV_INITRD
777 int real_root_mountflags;
778 #endif
779
780
781 kernel_thread(bdflush, NULL, 0);
782
783 kernel_thread(kswapd, NULL, 0);
784
785 #ifdef CONFIG_BLK_DEV_INITRD
786 real_root_dev = ROOT_DEV;
787 real_root_mountflags = root_mountflags;
788 if (initrd_start && mount_initrd) root_mountflags &= ~MS_RDONLY;
789 #endif
790 setup();
791
792 #ifdef __SMP__
793
794
795
796
797
798 smp_begin();
799 #endif
800
801 #ifdef CONFIG_UMSDOS_FS
802 {
803
804
805
806
807
808 extern struct inode *pseudo_root;
809 if (pseudo_root != NULL){
810 current->fs->root = pseudo_root;
811 current->fs->pwd = pseudo_root;
812 }
813 }
814 #endif
815
816 #ifdef CONFIG_BLK_DEV_INITRD
817 root_mountflags = real_root_mountflags;
818 if (ROOT_DEV != real_root_dev && ROOT_DEV == MKDEV(RAMDISK_MAJOR,0)) {
819 int error;
820
821 pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
822 if (pid>0)
823 while (pid != wait(&i));
824 if (real_root_dev != MKDEV(RAMDISK_MAJOR, 0)) {
825 error = change_root(real_root_dev,"/initrd");
826 if (error)
827 printk(KERN_ERR "Change root to /initrd: "
828 "error %d\n",error);
829 }
830 }
831 #endif
832
833 (void) open("/dev/tty1",O_RDWR,0);
834 (void) dup(0);
835 (void) dup(0);
836
837 if (!execute_command) {
838 execve("/etc/init",argv_init,envp_init);
839 execve("/bin/init",argv_init,envp_init);
840 execve("/sbin/init",argv_init,envp_init);
841
842
843 pid = kernel_thread(do_rc, "/etc/rc", SIGCHLD);
844 if (pid>0)
845 while (pid != wait(&i))
846 ;
847 }
848
849 while (1) {
850 pid = kernel_thread(do_shell,
851 execute_command ? execute_command : "/bin/sh",
852 SIGCHLD);
853 if (pid < 0) {
854 printf("Fork failed in init\n\r");
855 continue;
856 }
857 while (1)
858 if (pid == wait(&i))
859 break;
860 printf("\n\rchild %d died with code %04x\n\r",pid,i);
861 sync();
862 }
863 return -1;
864 }