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