/*------------------------------------------------------------------------
 *  sysinit  --  initialize all Xinu data structeres and devices
 *------------------------------------------------------------------------
 */
LOCAL int sysinit()
{
	int	i,j;
	struct	pentry	*pptr;
	struct	sentry	*sptr;
	struct	mblock	*mptr;

	numproc = 0;			/* initialize system variables */
	nextproc = NPROC-1;
	nextsem = NSEM-1;
	nextqueue = NPROC;		/* q[0..NPROC-1] are processes */

	/* initialize free memory list */
	/* PC version has to pre-allocate 640K-1024K "hole" */
	if (maxaddr+1 > (char *)HOLESTART) {
		memlist.mnext = mptr = (struct mblock *) roundmb(&end);
		mptr->mnext = (struct mblock *)HOLEEND;
		mptr->mlen = (int) truncew(((unsigned) HOLESTART -
	     		 (unsigned)&end));
        mptr->mlen -= 4;

		mptr = (struct mblock *) HOLEEND;
		mptr->mnext = 0;
		mptr->mlen = (int) truncew((unsigned)maxaddr - HOLEEND -
	      		NULLSTK);
	} else {
		/* initialize free memory list */
		memlist.mnext = mptr = (struct mblock *) roundmb(&end);
		mptr->mnext = 0;
		mptr->mlen = (int) truncew((unsigned)maxaddr - (int)&end -
			NULLSTK);
	}
	

	for (i=0 ; i<NPROC ; i++)	/* initialize process table */
		proctab[i].pstate = PRFREE;

	pptr = &proctab[NULLPROC];	/* initialize null process entry */
	pptr->pstate = PRCURR;
	for (j=0; j<7; j++)
		pptr->pname[j] = "prnull"[j];
	pptr->plimit = (WORD)(maxaddr + 1) - NULLSTK;
	pptr->pbase = (WORD) maxaddr - 3;
	pptr->pesp = pptr->pbase-4;	/* for stkchk; rewritten before used */
	*( (int *)pptr->pbase ) = MAGIC;
	pptr->paddr = (WORD) nulluser;
	pptr->pargs = 0;
	pptr->pprio = 0;
	currpid = NULLPROC;

	for (i=0 ; i<NSEM ; i++) {	/* initialize semaphores */
		(sptr = &semaph[i])->sstate = SFREE;
		sptr->sqtail = 1 + (sptr->sqhead = newqueue());
	}

	rdytail = 1 + (rdyhead=newqueue());/* initialize ready list */

#ifdef	MEMMARK
	_mkinit();			/* initialize memory marking */
#endif

#ifdef	RTCLOCK
	clkinit();			/* initialize r.t.clock	*/
#endif

	pci_init();	/* PCI */

	mon_init();	/* init monitor */
//	ripinit();

#ifdef NDEVS
	for (i=0 ; i<NDEVS ; i++ ) {	    
	    init_dev(i);
	}
#endif
	buf_init();
	return(OK);
}
Beispiel #2
0
/*------------------------------------------------------------------------
 *  sysinit  --  initialize all Xinu data structeres and devices
 *------------------------------------------------------------------------
 */
LOCAL	sysinit()
{

	int i,j,len;
	struct pentry *pptr;	 /* null process entry */
	struct sentry *sptr;
	struct mblock *volatile mptr;

	numproc = 0;			/* initialize system variables */
	nextproc = NPROC-1;
	nextsem = NSEM-1;
	nextqueue = NPROC;		/* q[0..NPROC-1] are processes */

	memlist.mnext = mptr =		/* initialize free memory list */
	    (struct mblock *volatile) roundmb(__malloc_heap_start);
	mptr->mnext = (struct mblock *)NULL;
	mptr->mlen = len = (int) truncmb(RAMEND - NULLSTK - (unsigned)&__bss_end);
	__malloc_heap_start = (char *)mptr;
	__malloc_heap_end = __malloc_heap_start + len;
	kprintf_P(PSTR("Heap: %p of length %d\n"), mptr, len);
	
	for (i=0 ; i<NPROC ; i++)	/* initialize process table */
		proctab[i].pstate = PRFREE;

	/* initialize null process entry */
	pptr = &proctab[NULLPROC];
	pptr->pstate = PRCURR;
	for (j=0; j<6; j++)
		pptr->pname[j] = "nullp"[j];

	pptr->plimit = (unsigned char *)(RAMEND + 1) - NULLSTK;
	pptr->pbase = (unsigned char *) RAMEND;
	*pptr->pbase = (unsigned char)MAGIC; 	/* clobbers return, but proc 0 doesn't return */
	pptr->paddr = (int *) main;
	pptr->pargs = 0;
	pptr->pprio = 0;
	pptr->pregs[SSP_L] = lobyte((unsigned int)pptr->plimit);	/* for error checking */
	pptr->pregs[SSP_H] = hibyte((unsigned int)pptr->plimit);	/* for error checking */
	currpid = NULLPROC;

	for (i=0 ; i<NSEM ; i++) {	/* initialize semaphores */
		(sptr = &semaph[i])->sstate = SFREE;
		sptr->sqtail = 1 + (sptr->sqhead = newqueue());
	}

	rdytail = 1 + (rdyhead=newqueue());	/* initialize ready list */

	
#ifdef	MEMMARK
	kprintf("Memory marking\n");
	_mkinit();			/* initialize memory marking */
#else
	kprintf("Pool init\n");
	poolinit();			/* explicitly */
	pinit(MAXMSGS);
#endif

#ifdef	RTCLOCK
	kprintf("init RTC\n");
	clkinit();			/* initialize r.t.clock	*/
#endif

#ifdef NDEVS
	for ( i=0 ; i<NDEVS ; i++ ) {
		if (i>0) kprintf("init dev %d\n", i);
	    init(i);
	}
#endif

#ifdef	NNETS
//	kprintf("net init\n");
	netinit();
#endif

	return (OK);
}
Beispiel #3
0
//------------------------------------------------------------------------
//  sysinit  --  initialize all Xinu data structures and devices
//------------------------------------------------------------------------
static int
sysinit(void)
{
	static int (*nulluserp)() = &nulluser;
	static uword *nulluserpp = (uword *)&nulluserp;

	struct pentry *pptr;
	struct mblock *mptr;

	// initialize system variables
	numproc = 0;
	nextproc = NPROC - 1;
	nextsem = NSEM - 1;
	nextqueue = NPROC;	// q[0..NPROC-1] are processes

	// initialize free memory list
	memlist.mnext = mptr = (struct mblock *)roundew(&end);
	mptr->mnext = (struct mblock *)NULL;
	mptr->mlen = (uword)truncew((uintptr_t)maxaddr - NULLSTK - (uintptr_t)&end);

	// initialize process table
	for (int k = 0; k < NPROC; k++)
		proctab[k].pstate = PRFREE;

	// initialize null process entry
	pptr = &proctab[NULLPROC];
	pptr->pstate = PRCURR;
	pptr->pprio = 0;
	strlcpy(pptr->pname, "prnull", PNMLEN);
	pptr->plimit = ((char *)maxaddr) - NULLSTK - sizeof(uword);
	pptr->pbase = (char *)maxaddr;
	*((uword *)pptr->pbase) = MAGIC;
	pptr->paddr = (char *)(*nulluserpp);
	pptr->phasmsg = FALSE;
	pptr->pargs = 0;
	currpid = NULLPROC;

	// initialize semaphores
	for (int k = 0; k < NSEM; k++) {
		struct sentry *sptr = &semaph[k];
		sptr->sstate = SFREE;
		sptr->sqtail = 1 + (sptr->sqhead = newqueue());
	}

	// initialize ready list
	rdyhead = newqueue();
	rdytail = 1 + rdyhead;

	// initialize memory marking
	_mkinit();

	// initialize r.t.clock
	clkinit();

	// initialize disk buffers
	dskdbp = mkpool(DBUFSIZ, NDBUFF);
	dskrbp = mkpool(DREQSIZ, NDREQ);

	// initialize devices
	for (int k = 0; k < NDEVS; k++)
		init(k);

	return OK;
}
Beispiel #4
0
/*------------------------------------------------------------------------
 *  sysinit  --  initialize all Xinu data structeres and devices
 *------------------------------------------------------------------------
 */
LOCAL
sysinit()
{
	static	long	currsp;
	int	i,j;
	struct	pentry	*pptr;
	struct	sentry	*sptr;
	struct	mblock	*mptr;

	numproc = 0;			/* initialize system variables */
	nextproc = NPROC-1;
	nextsem = NSEM-1;
	nextqueue = NPROC;		/* q[0..NPROC-1] are processes */

#ifdef X__COM32__
	puts_com32("sysinit()\n");
#endif
	
#ifdef __COM32__
	/* initialize free memory list */
	kprintf("com32topmem %d\n", (unsigned long) com32topmem);
	com32topmem = com32topmem - 1024*64; /* !!! we need some space fort this code */
	maxaddr =  (char*) com32topmem;
	kprintf("maxaddr     %d\n", (unsigned long) maxaddr);
	memlist.mnext = mptr = (struct mblock *) roundmb(&end);
	mptr->mnext = 0;
	mptr->mlen = (int) truncew((unsigned)maxaddr - (int)&end -
			NULLSTK);
#else
	/* initialize free memory list */
	/* PC version has to pre-allocate 640K-1024K "hole" */
	if (maxaddr+1 > HOLESTART) {
		memlist.mnext = mptr = (struct mblock *) roundmb(&end);
		mptr->mnext = (struct mblock *)HOLEEND;
		mptr->mlen = (int) truncew((unsigned) HOLESTART -
	     		 (unsigned)&end - 4);

		mptr = (struct mblock *) HOLEEND;
		mptr->mnext = 0;
		mptr->mlen = (int) truncew(maxaddr - HOLEEND - NULLSTK);
	} else {
		/* initialize free memory list */
		memlist.mnext = mptr = (struct mblock *) roundmb(&end);
		mptr->mnext = 0;
		mptr->mlen = (int) truncew((unsigned)maxaddr - (int)&end -
			NULLSTK);
	}
#endif
	
#ifdef X__COM32__
	puts_com32("sysinit() free memory list done\n");
#endif
	
	for (i=0 ; i<NPROC ; i++)	/* initialize process table */
		proctab[i].pstate = PRFREE;

#ifdef X__COM32__
	puts_com32("sysinit() proctab done\n");
#endif
	
	pptr = &proctab[NULLPROC];	/* initialize null process entry */
	pptr->pstate = PRCURR;
	for (j=0; j<7; j++)
		pptr->pname[j] = "prnull"[j];
	pptr->plimit = (WORD)(maxaddr + 1) - NULLSTK;
	pptr->pbase = (WORD) maxaddr - 3;
	pptr->pesp = pptr->pbase-4;	/* for stkchk; rewritten before used */
	*( (int *)pptr->pbase ) = MAGIC;
	pptr->paddr = (WORD) nulluser;
	pptr->pargs = 0;
	pptr->pprio = 0;
	currpid = NULLPROC;

	for (i=0 ; i<NSEM ; i++) {	/* initialize semaphores */
		(sptr = &semaph[i])->sstate = SFREE;
		sptr->sqtail = 1 + (sptr->sqhead = newqueue());
	}

	rdytail = 1 + (rdyhead=newqueue());/* initialize ready list */

#ifdef X__COM32__
	puts_com32("sysinit() semaphores done\n");
#endif
	
#ifdef	MEMMARK
	_mkinit();			/* initialize memory marking */
#ifdef __COM32__
	puts_com32("sysinit()  memory marking done\n");
#endif
#endif

#ifdef	RTCLOCK
	clkinit();			/* initialize r.t.clock	*/
#ifdef __COM32__
	puts_com32("sysinit() rtc done\n");
#endif
#endif

#ifdef NDEVS
	for ( i=0 ; i<NDEVS ; i++ ) {
	    init(i);
	}
#ifdef __COM32__
	puts_com32("sysinit() devs done\n");
#endif	
#endif

#ifdef	NNETS
	netinit();
#ifdef __COM32__
	puts_com32("sysinit() netinit() done\n");
#endif
#endif

	return(OK);
}
Beispiel #5
0
/*------------------------------------------------------------------------
 *  sysinit  --  initialize all Xinu data structeres and devices
 *------------------------------------------------------------------------
 */
LOCAL
sysinit()
{
	static	long	currsp;
	int	i,j, avail;
	struct	pentry	*pptr;
	struct	sentry	*sptr;
	struct	mblock	*mptr;
	SYSCALL pfintr();

	/*********************/
	set_evec(14, pfintr);

	pptr = &proctab[NULLPROC]; /* initialize null process entry */
	/*********************/
	

	numproc = 0;			/* initialize system variables */
	nextproc = NPROC-1;
	nextsem = NSEM-1;
	nextqueue = NPROC;		/* q[0..NPROC-1] are processes */

	/* initialize free memory list */
	/* PC version has to pre-allocate 640K-1024K "hole" */
	if (maxaddr+1 > HOLESTART) {
		memlist.mnext = mptr = (struct mblock *) roundmb(&end);
		mptr->mnext = (struct mblock *)HOLEEND;
		mptr->mlen = (int) truncew(((unsigned) HOLESTART -
	     		 (unsigned)&end));
        mptr->mlen -= 4;

		mptr = (struct mblock *) HOLEEND;
		mptr->mnext = 0;
		mptr->mlen = (int) truncew((unsigned)maxaddr - HOLEEND -
	      		NULLSTK);
/*
		mptr->mlen = (int) truncew((unsigned)maxaddr - (4096 - 1024 ) *  4096 - HOLEEND - NULLSTK);
*/
	} else {
		/* initialize free memory list */
		memlist.mnext = mptr = (struct mblock *) roundmb(&end);
		mptr->mnext = 0;
		mptr->mlen = (int) truncew((unsigned)maxaddr - (int)&end -
			NULLSTK);
	}
	

	for (i=0 ; i<NPROC ; i++)	/* initialize process table */
		proctab[i].pstate = PRFREE;


#ifdef	MEMMARK
	_mkinit();			/* initialize memory marking */
#endif

#ifdef	RTCLOCK
	clkinit();			/* initialize r.t.clock	*/
#endif

	mon_init();     /* init monitor */

#ifdef NDEVS
	for (i=0 ; i<NDEVS ; i++ ) {	    
	    init_dev(i);
	}
#endif

	pptr = &proctab[NULLPROC];	/* initialize null process entry */
	pptr->pstate = PRCURR;
	for (j=0; j<7; j++)
		pptr->pname[j] = "prnull"[j];
	pptr->plimit = (WORD)(maxaddr + 1) - NULLSTK;
	pptr->pbase = (WORD) maxaddr - 3;
/*
	pptr->plimit = (WORD)(maxaddr + 1) - NULLSTK - (4096 - 1024 )*4096;
	pptr->pbase = (WORD) maxaddr - 3 - (4096-1024)*4096;
*/
	pptr->pesp = pptr->pbase-4;	/* for stkchk; rewritten before used */
	*( (int *)pptr->pbase ) = MAGIC;
	pptr->paddr = (WORD) nulluser;
	pptr->pargs = 0;
	pptr->pprio = 0;
	currpid = NULLPROC;
	
	
	for (i=0 ; i<NSEM ; i++) {	/* initialize semaphores */
		(sptr = &semaph[i])->sstate = SFREE;
		sptr->sqtail = 1 + (sptr->sqhead = newqueue());
	}

	rdytail = 1 + (rdyhead=newqueue());/* initialize ready list */

	init_bsm();
	init_frm();

	kprintf("initialize page tables for null process\n");
	init_glb_pgs(glb_pg_tbl_frm_mapping);
	// init pg dir for proc 0
	frame_t *pg_dir = get_free_frame();
	init_pg_dir(pg_dir, NULLPROC);
	pptr->pdbr = pg_dir->frm_num;
	pptr->pd = pg_dir;
	return(OK);
}