OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [before_ORP/] [uclinux/] [uClinux-2.0.x/] [init/] [main.c] - Diff between revs 199 and 582

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 199 Rev 582
Line 863... Line 863...
 */
 */
 
 
int cpu_idle(void *unused)
int cpu_idle(void *unused)
{
{
        for(;;) {
        for(;;) {
printk("%s - %s:%d \n",__FILE__,__FUNCTION__,__LINE__);
 
                idle();
                idle();
        }
        }
}
}
 
 
#else
#else
Line 957... Line 956...
        char * command_line;
        char * command_line;
 
 
/*
/*
 *      This little check will move.
 *      This little check will move.
 */
 */
 
 
#ifdef __SMP__
#ifdef __SMP__
        static int first_cpu=1;
        static int first_cpu=1;
 
 
        if(!first_cpu)
        if(!first_cpu)
                start_secondary();
                start_secondary();
Line 1030... Line 1028...
 
 
#if defined(CONFIG_MTRR) && defined(__SMP__)
#if defined(CONFIG_MTRR) && defined(__SMP__)
        init_mtrr_config();
        init_mtrr_config();
#endif
#endif
 
 
printk("main11\n");
 
        printk(linux_banner);
        printk(linux_banner);
#ifdef __SMP__
#ifdef __SMP__
        smp_init();
        smp_init();
#endif
#endif
        sysctl_init();
        sysctl_init();
Line 1042... Line 1039...
         *      We count on the initial thread going ok
         *      We count on the initial thread going ok
         *      Like idlers init is an unlocked kernel thread, which will
         *      Like idlers init is an unlocked kernel thread, which will
         *      make syscalls (and thus be locked).
         *      make syscalls (and thus be locked).
         */
         */
        kernel_thread(init, NULL, 0);
        kernel_thread(init, NULL, 0);
printk("main12 end\n");
 
/*
/*
 * task[0] is meant to be used as an "idle" task: it may not sleep, but
 * task[0] is meant to be used as an "idle" task: it may not sleep, but
 * it might do some general things like count free pages or it could be
 * it might do some general things like count free pages or it could be
 * used to implement a reasonable LRU algorithm for the paging routines:
 * used to implement a reasonable LRU algorithm for the paging routines:
 * anything that can be useful, but shouldn't take time from the real
 * anything that can be useful, but shouldn't take time from the real
Line 1078... Line 1075...
 
 
static int do_shell(void * shell)
static int do_shell(void * shell)
{
{
        close(0);close(1);close(2);
        close(0);close(1);close(2);
        setsid();
        setsid();
printk("%s - %s:%d \n",__FILE__,__FUNCTION__,__LINE__);
 
        if ((int)(open("/dev/tty1",O_RDWR,0) < 0) &&
        if ((int)(open("/dev/tty1",O_RDWR,0) < 0) &&
            (int)(open("/dev/ttyS0",O_RDWR,0) < 0))
            (int)(open("/dev/ttyS0",O_RDWR,0) < 0))
                printk("Unable to open an initial console for do_shell.\n");
                printk("Unable to open an initial console for do_shell.\n");
printk("%s - %s:%d \n",__FILE__,__FUNCTION__,__LINE__);
 
        (void) dup(0);
        (void) dup(0);
        (void) dup(0);
        (void) dup(0);
        return execve(shell, argv, envp);
        return execve(shell, argv, envp);
}
}
 
 
#ifdef CONFIG_BLK_DEV_INITRD
#ifdef CONFIG_BLK_DEV_INITRD
static int do_linuxrc(void * shell)
static int do_linuxrc(void * shell)
{
{
        static char *argv[] = { "linuxrc", NULL, };
        static char *argv[] = { "linuxrc", NULL, };
printk("do_linuxrc1\n");
 
        close(0);close(1);close(2);
        close(0);close(1);close(2);
printk("do_linuxrc2\n");
 
        setsid();
        setsid();
printk("do_linuxrc3\n");
 
        (void) open("/dev/tty1",O_RDWR,0);
        (void) open("/dev/tty1",O_RDWR,0);
printk("do_linuxrc4\n");
 
        (void) dup(0);
        (void) dup(0);
        (void) dup(0);
        (void) dup(0);
printk("do_linuxrc5\n");
 
        return execve(shell, argv, envp_init);
        return execve(shell, argv, envp_init);
}
}
 
 
static void no_initrd(char *s,int *ints)
static void no_initrd(char *s,int *ints)
{
{
Line 1113... Line 1104...
}
}
#endif
#endif
 
 
static int init(void * unused)
static int init(void * unused)
{
{
        int pid,i,fd1,fd2;
        int pid,i;
#ifdef CONFIG_BLK_DEV_INITRD
#ifdef CONFIG_BLK_DEV_INITRD
        int real_root_mountflags;
        int real_root_mountflags;
#endif
#endif
#ifdef CONFIG_COLDFIRE
#ifdef CONFIG_COLDFIRE
        extern char console_device[];
        extern char console_device[];
#endif
#endif
printk("\ninit1\n");
 
        /* Launch bdflush from here, instead of the old syscall way. */
        /* Launch bdflush from here, instead of the old syscall way. */
        kernel_thread(bdflush, NULL, 0);
        kernel_thread(bdflush, NULL, 0);
printk("\ninit2\n");
 
        /* Start the background pageout daemon. */
        /* Start the background pageout daemon. */
#ifndef NO_MM
#ifndef NO_MM
        kswapd_setup();
        kswapd_setup();
        kernel_thread(kswapd, NULL, 0);
        kernel_thread(kswapd, NULL, 0);
#endif /* !NO_MM */
#endif /* !NO_MM */
Line 1178... Line 1167...
 
 
#ifdef CONFIG_BLK_DEV_INITRD
#ifdef CONFIG_BLK_DEV_INITRD
        root_mountflags = real_root_mountflags;
        root_mountflags = real_root_mountflags;
        if (mount_initrd && ROOT_DEV != real_root_dev && ROOT_DEV == MKDEV(RAMDISK_MAJOR,0)) {
        if (mount_initrd && ROOT_DEV != real_root_dev && ROOT_DEV == MKDEV(RAMDISK_MAJOR,0)) {
                int error;
                int error;
/* SIMON */
 
printk("init3\n");
 
        if ((open("/dev/tty1",O_RDWR,0) < 0) &&
        if ((open("/dev/tty1",O_RDWR,0) < 0) &&
            (open("/dev/ttyS0",O_RDWR,0) < 0))
            (open("/dev/ttyS0",O_RDWR,0) < 0))
                printk("Unable to open an initial console.\n");
                printk("Unable to open an initial console.\n");
 
 
printk("init4\n");
 
 
 
                pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
                pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
printk("init5\n");
 
                if (pid>0)
                if (pid>0)
                        while (pid != wait(&i));
                        while (pid != wait(&i));
printk("init6\n");
 
                if (real_root_dev != MKDEV(RAMDISK_MAJOR, 0)) {
                if (real_root_dev != MKDEV(RAMDISK_MAJOR, 0)) {
                        error = change_root(real_root_dev,"/initrd");
                        error = change_root(real_root_dev,"/initrd");
                        if (error)
                        if (error)
                                printk(KERN_ERR "Change root to /initrd: "
                                printk(KERN_ERR "Change root to /initrd: "
                                    "error %d\n",error);
                                    "error %d\n",error);
                }
                }
        }
        }
#endif
#endif
 
 
printk("init7\n");
 
        /*
        /*
         *      This keeps serial console MUCH cleaner, but does assume
         *      This keeps serial console MUCH cleaner, but does assume
         *      the console driver checks there really is a video device
         *      the console driver checks there really is a video device
         *      attached (Sparc effectively does).
         *      attached (Sparc effectively does).
         */
         */
#ifdef CONFIG_COLDFIRE
#ifdef CONFIG_COLDFIRE
        if (console_device[0] && (open(console_device,O_RDWR,0) >= 0)) {
        if (console_device[0] && (open(console_device,O_RDWR,0) >= 0)) {
                /* Nothing */;
                /* Nothing */;
        } else
        } else
#endif /* CONFIG_COLDFIRE */
#endif /* CONFIG_COLDFIRE */
/*      if ((open("/dev/tty1",O_RDWR,0) < 0) &&
        if ((open("/dev/tty1",O_RDWR,0) < 0) &&
            (open("/dev/ttyS0",O_RDWR,0) < 0))
            (open("/dev/ttyS0",O_RDWR,0) < 0))
                printk("Unable to open an initial console.\n");
                printk("Unable to open an initial console.\n");
*/
 
fd1 = open("/dev/tty",O_RDWR,0);
 
printk("open /dev/tty fd = %x\n", fd1);
 
write(fd1, (void *)"Hello world 1!", 13);
 
 
 
fd2 = open("/dev/ttyS0",O_RDWR,0);
 
printk("open /dev/ttyS0 fd = %x\n", fd2);
 
/*write(fd2, (void *)"Hello world 2!", 13);
 
*/
 
printk("init8\n");
 
 
 
        (void) dup(0);
        (void) dup(0);
        (void) dup(0);
        (void) dup(0);
 
 
printk("init9\n");
 
 
 
        printf("Executing sash\n");
        printf("Executing sash\n");
 
 
        execve("/bin/sash",argv_init,envp_init);
        execve("/bin/sash",argv_init,envp_init);
 
 
printk("init10\n");
 
 
 
        if (!execute_command) {
        if (!execute_command) {
                execve("/etc/init",argv_init,envp_init);
                execve("/etc/init",argv_init,envp_init);
                execve("/bin/init",argv_init,envp_init);
                execve("/bin/init",argv_init,envp_init);
                execve("/sbin/init",argv_init,envp_init);
                execve("/sbin/init",argv_init,envp_init);
                /* if this fails, fall through to original stuff */
                /* if this fails, fall through to original stuff */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.