예제 #1
0
파일: mp.c 프로젝트: Earnestly/plan9
static void
squidboy(Apic* apic)
{
//	iprint("Hello Squidboy\n");

	machinit();
	fpsavealloc();
	mmuinit();

	cpuidentify();
	cpuidprint();
	checkmtrr();

	apic->online = 1;
	coherence();

	lapicinit(apic);
	lapiconline();
	syncclock();
	timersinit();

	fpoff();

	lock(&active);
	active.machs |= 1<<m->machno;
	unlock(&active);

	while(!active.thunderbirdsarego)
		microdelay(100);

	schedinit();
}
예제 #2
0
파일: mp.c 프로젝트: 8l/inferno
static void
squidboy(Apic* apic)
{
//	iprint("Hello Squidboy\n");

	machinit();
	mmuinit();

	cpuidentify();
	cpuidprint();
	checkmtrr();

	lock(&mprdthilock);
	mprdthi |= (1<<apic->apicno)<<24;
	unlock(&mprdthilock);

	lapicinit(apic);
	lapiconline();
	syncclock();
	timersinit();

	fpoff();

	lock(&active);
	active.machs |= 1<<m->machno;
	unlock(&active);

	while(!active.thunderbirdsarego)
		microdelay(100);

	schedinit();
}
예제 #3
0
void
main(void)
{
	cgapost(0);
	mach0init();
	options();
	ioinit();
	i8250console();
	quotefmtinstall();
	screeninit();

	print("\nPlan 9\n");

	trapinit0();
	mmuinit0();

	kbdinit();
	i8253init();
	cpuidentify();
	meminit();
	confinit();
	archinit();
	if(!isa20on())
		panic("bootstrap didn't leave a20 address line enabled");
	xinit();
	if(i8237alloc != nil)
		i8237alloc();
	trapinit();
	printinit();
	cpuidprint();
	mmuinit();
	fpsavealloc();
	if(arch->intrinit)	/* launches other processors on an mp */
		arch->intrinit();
	timersinit();
	mathinit();
	kbdenable();
	if(arch->clockenable)
		arch->clockenable();
	procinit0();
	initseg();
	if(delaylink){
		bootlinks();
		pcimatch(0, 0, 0);
	}else
		links();
	conf.monitor = 1;
	chandevreset();
	cgapost(0xcd);

	pageinit();
	i8253link();
	swapinit();
	userinit();
	active.thunderbirdsarego = 1;

	cgapost(0x99);
	schedinit();
}
예제 #4
0
/*
 * Initialization code.
 * Called from cold start routine as
 * soon as a stack and segmentation
 * have been established.
 * Functions:
 *  clear and free user core
 *  turn on clock
 *  hand craft 0th process
 *  call all initialization routines
 *  fork - process 0 to schedule
 *       - process 1 execute bootstrap
 */
int
main()
{
    register struct proc *p;
    register int i;
    register struct fs *fs = NULL;
    char inbuf[4];
    char inch;
    int s __attribute__((unused));

    startup();
    printf ("\n%s", version);
    cpuidentify();
    cnidentify();

    /*
     * Set up system process 0 (swapper).
     */
    p = &proc[0];
    p->p_addr = (size_t) &u;
    p->p_stat = SRUN;
    p->p_flag |= SLOAD | SSYS;
    p->p_nice = NZERO;

    u.u_procp = p;          /* init user structure */
    u.u_cmask = CMASK;
    u.u_lastfile = -1;
    for (i = 1; i < NGROUPS; i++)
        u.u_groups[i] = NOGROUP;
    for (i = 0; i < sizeof(u.u_rlimit)/sizeof(u.u_rlimit[0]); i++)
        u.u_rlimit[i].rlim_cur = u.u_rlimit[i].rlim_max =
            RLIM_INFINITY;

    /* Initialize signal state for process 0 */
    siginit (p);

    /*
     * Initialize tables, protocols, and set up well-known inodes.
     */
#ifdef LOG_ENABLED
    loginit();
#endif
    coutinit();
    cinit();
    pqinit();
    ihinit();
    bhinit();
    binit();
    nchinit();
    clkstart();
    s = spl0();
    rdisk_init();

    pipedev = rootdev = get_boot_device();
    swapdev = get_swap_device();

    /* Mount a root filesystem. */
    for (;;) {
        if(rootdev!=-1)
        {
            fs = mountfs (rootdev, (boothowto & RB_RDONLY) ? MNT_RDONLY : 0,
                (struct inode*) 0);
        }
        if (fs)
            break;
        printf ("No root filesystem available!\n");
//      rdisk_list_partitions(RDISK_FS);
retry:
        printf ("Please enter device to boot from (press ? to list): ");
        inch=0;
        inbuf[0] = inbuf[1] = inbuf[2] = inbuf[3] = 0;
        while((inch=cngetc()) != '\r')
        {
            switch(inch)
            {
                case '?':
                    printf("?\n");
                    rdisk_list_partitions(RDISK_FS);
                    printf ("Please enter device to boot from (press ? to list): ");
                    break;
                default:
                    printf("%c",inch);
                    inbuf[0] = inbuf[1];
                    inbuf[1] = inbuf[2];
                    inbuf[2] = inbuf[3];
                    inbuf[3] = inch;
                    break;
            }
        }

        inch = 0;
        if(inbuf[0]=='r' && inbuf[1]=='d')
        {
            if(inbuf[2]>='0' && inbuf[2] < '0'+rdisk_num_disks())
            {
                if(inbuf[3]>='a' && inbuf[3]<='d')
                {
                    rootdev=makedev(inbuf[2]-'0',inbuf[3]-'a'+1);
                    inch = 1;
                }
            }
        } else if(inbuf[1]=='r' && inbuf[2]=='d') {
            if(inbuf[3]>='0' && inbuf[3] < '0'+rdisk_num_disks())
            {
                rootdev=makedev(inbuf[3]-'0',0);
                inch = 1;
            }
        } else if(inbuf[3] == 0) {
            inch = 1;
        }
        if(inch==0)
        {
            printf("\nUnknown device.\n\n");
            goto retry;
        }
        printf ("\n\n");
    }
    printf ("phys mem  = %u kbytes\n", physmem / 1024);
    printf ("user mem  = %u kbytes\n", MAXMEM / 1024);
    if(minor(rootdev)==0)
    {
        printf ("root dev  = rd%d (%d,%d)\n",
            major(rootdev),
            major(rootdev), minor(rootdev)
        );
    } else {
        printf ("root dev  = rd%d%c (%d,%d)\n",
            major(rootdev), 'a'+minor(rootdev)-1,
            major(rootdev), minor(rootdev)
        );
    }

    printf ("root size = %u kbytes\n", fs->fs_fsize * DEV_BSIZE / 1024);
    mount[0].m_inodp = (struct inode*) 1;   /* XXX */
    mount_updname (fs, "/", "root", 1, 4);
    time.tv_sec = fs->fs_time;
    boottime = time;

    /* Find a swap file. */
    swapstart = 1;
    while(swapdev == -1)
    {
        printf("Please enter swap device (press ? to list): ");
        inbuf[0] = inbuf[1] = inbuf[2] = inbuf[3] = 0;
        while((inch = cngetc())!='\r')
        {
            switch(inch)
            {
                case '?':
                    printf("?\n");
                    rdisk_list_partitions(RDISK_SWAP);
                    printf("Please enter swap device (press ? to list): ");
                    break;
                default:
                    printf("%c",inch);
                    inbuf[0] = inbuf[1];
                    inbuf[1] = inbuf[2];
                    inbuf[2] = inbuf[3];
                    inbuf[3] = inch;
                    break;
            }
        }
        inch = 0;
        if(inbuf[0]=='r' && inbuf[1]=='d')
        {
            if(inbuf[2]>='0' && inbuf[2] < '0'+rdisk_num_disks())
            {
                if(inbuf[3]>='a' && inbuf[3]<='d')
                {
                    swapdev=makedev(inbuf[2]-'0',inbuf[3]-'a'+1);
                    inch = 1;
                }
            }
        } else if(inbuf[1]=='r' && inbuf[2]=='d') {
            if(inbuf[3]>='0' && inbuf[3] < '0'+rdisk_num_disks())
            {
                swapdev=makedev(inbuf[3]-'0',0);
                inch = 1;
            }
        }

        if(minor(swapdev)!=0)
        {
            if(partition_type(swapdev)!=RDISK_SWAP)
            {
                printf("\nNot a swap partition!\n\n");
                swapdev=-1;
            }
        }
    }
    nswap = rdsize(swapdev);

    if(minor(swapdev)==0)
    {
        printf ("swap dev  = rd%d (%d,%d)\n",
            major(swapdev),
            major(swapdev), minor(swapdev)
        );
    } else {
        printf ("swap dev  = rd%d%c (%d,%d)\n",
            major(swapdev), 'a'+minor(swapdev)-1,
            major(swapdev), minor(swapdev)
        );
    }
    (*bdevsw[major(swapdev)].d_open)(swapdev, FREAD|FWRITE, S_IFBLK);
    printf ("swap size = %u kbytes\n", nswap * DEV_BSIZE / 1024);
    if (nswap <= 0)
        panic ("zero swap size");   /* don't want to panic, but what ? */
    mfree (swapmap, nswap, swapstart);

    /* Kick off timeout driven events by calling first time. */
    schedcpu (0);

    /* Set up the root file system. */
    rootdir = iget (rootdev, &mount[0].m_filsys, (ino_t) ROOTINO);
    iunlock (rootdir);
    u.u_cdir = iget (rootdev, &mount[0].m_filsys, (ino_t) ROOTINO);
    iunlock (u.u_cdir);
    u.u_rdir = NULL;

    /*
     * Make init process.
     */
    if (newproc (0) == 0) {
        /* Parent process with pid 0: swapper.
         * No return from sched. */
        sched();
    }
    /* Child process with pid 1: init. */
    s = splhigh();
    p = u.u_procp;
    p->p_dsize = icodeend - icode;
    p->p_daddr = USER_DATA_START;
    p->p_ssize = 1024;              /* one kbyte of stack */
    p->p_saddr = USER_DATA_END - 1024;
    bcopy ((caddr_t) icode, (caddr_t) USER_DATA_START, icodeend - icode);
    /*
     * return goes to location 0 of user init code
     * just copied out.
     */
    return 0;
}
예제 #5
0
void
main(void)
{
	Proc *savup;
	static ulong vfy = Datamagic;
	static char novga[] = "\nno vga; serial console only\n";

	savup = up;
	up = nil;
	/* m has been set by l32v.s */

	/*
	 * disable address wraps at 1MB boundaries.
	 * if we're 9boot, ldecomp.s already did this.
	 */
	a20init();

	mach0init();
//	options();		/* we don't get options passed to us */
	ioinit();
	/* we later call i8250console after plan9.ini has been read */
	i8250config("0");	/* configure serial port 0 with defaults */
	quotefmtinstall();
 	fmtinstall('i', eipfmt);
 	fmtinstall('I', eipfmt);
 	fmtinstall('E', eipfmt);
 	fmtinstall('V', eipfmt);
 	fmtinstall('M', eipfmt);
	screeninit();			/* cga setup */
	cgapost(0xc);

	trapinit0();
	mmuinit0();

	kbdinit();
	i8253init();
	cpuidentify();
	readlsconf();
	meminit();
	confinit();
	archinit();
	xinit();
	if(i8237alloc != nil)
		i8237alloc();		/* dma (for floppy) init */
	trapinit();
	printinit();
	sanity();
	cgapost(1);

	/*
	 * soekris servers have no built-in video but each has a serial port.
	 * they must see serial output, if any, before cga output because
	 * otherwise the soekris bios will translate cga output to serial
	 * output, which will garble serial console output.
	 */
	pcimatch(nil, 0, 0);		/* force scan of pci table */
	if (!pcivga) {
		screenputs = nil;
		uartputs(novga, sizeof novga - 1);
	}
	print(" %s\n\n", hellomsg);

	if (vfy != Datamagic)
		panic("data segment incorrectly aligned or loaded");
	if (savup)
		print("up was non-nil (%#p) upon entry to main; bss wasn't zeroed!\n",
			savup);

//	xsummary();
	cpuidprint();
	mmuinit();
	if(arch->intrinit)	/* launches other processors on an mp */
		arch->intrinit();
	timersinit();
	mathinit();
	kbdenable();
	/*
	 * 9loadusb runs much faster if we don't use the clock.
	 * perhaps we're competing with the bios for the use of it?
	 */
	if(!noclock && arch->clockenable)
		arch->clockenable();
	procinit0();
	initseg();
	if(delaylink){
		bootlinks();
		pcimatch(0, 0, 0);
	}else
		links();
	conf.monitor = 1;
	cgapost(0xcd);
	chandevreset();
	cgapost(2);
	pageinit();	/* must follow xinit, and conf.mem must be populated */
	i8253link();
	userinit();

	active.thunderbirdsarego = 1;
	cgapost(0xb0);
	schedinit();
}