| plan 9 kernel history: overview | file list | diff list |
1991/0115/ss/main.c (diff list | history)
| ss/main.c on 1990/1223 | ||
| 1990/1223 | #include "u.h" #include "lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" #include "ureg.h" #include "init.h" #include <libg.h> #include <gnot.h> char user[NAMELEN]; | |
| 1991/0110 | uchar *intrreg; | |
| 1990/1223 | void main(void) { int a; u = 0; memset(&edata, 0, (char*)&end-(char*)&edata); machinit(); confinit(); | |
| 1990/1226 | mmuinit(); printinit(); | |
| 1991/0112 | print("sparc plan 9\n"); | |
| 1990/1226 | trapinit(); | |
| 1990/1223 | kmapinit(); | |
| 1990/1226 | cacheinit(); | |
| 1991/0110 | intrinit(); | |
| 1990/1223 | procinit0(); pgrpinit(); chaninit(); alarminit(); chandevreset(); streaminit(); /* serviceinit(); /**/ /* filsysinit(); /**/ pageinit(); userinit(); | |
| 1990/1227 | clockinit(); | |
| 1990/1223 | schedinit(); } void | |
| 1991/0110 | intrinit(void) { KMap *k; k = kmappa(INTRREG, PTEIO); intrreg = (uchar*)k->va; } void | |
| 1990/1223 | reset(void) { delay(100); | |
| 1990/1226 | putb2(ENAB, ENABRESET); | |
| 1990/1223 | } void machinit(void) { int n; n = m->machno; memset(m, 0, sizeof(Mach)); m->machno = n; m->mmask = 1<<m->machno; #ifdef adsf m->fpstate = FPinit; fprestore(&initfp); #endif } void init0(void) { Chan *c; u->nerrlab = 0; m->proc = u->p; u->p->state = Running; u->p->mach = m; spllo(); chandevinit(); u->slash = (*devtab[0].attach)(0); u->dot = clone(u->slash, 0); | |
| 1990/1226 | touser(USTKTOP-5*BY2WD); | |
| 1990/1223 | } FPsave initfp; void userinit(void) { Proc *p; Seg *s; User *up; KMap *k; p = newproc(); p->pgrp = newpgrp(); strcpy(p->text, "*init*"); p->fpstate = FPinit; /* * Kernel Stack */ | |
| 1991/0110 | p->sched.pc = (((ulong)init0) - 8); /* 8 because of RETURN in gotolabel */ | |
| 1990/1223 | p->sched.sp = USERADDR+BY2PG-20; /* BUG */ p->upage = newpage(0, 0, USERADDR|(p->pid&0xFFFF)); /* * User */ k = kmap(p->upage); up = (User*)VA(k); up->p = p; kunmap(k); /* * User Stack */ s = &p->seg[SSEG]; s->proc = p; s->o = neworig(USTKTOP-BY2PG, 1, OWRPERM, 0); s->minva = USTKTOP-BY2PG; s->maxva = USTKTOP; /* * Text */ s = &p->seg[TSEG]; s->proc = p; s->o = neworig(UTZERO, 1, 0, 0); s->o->pte[0].page = newpage(0, 0, UTZERO); s->o->npage = 1; k = kmap(s->o->pte[0].page); memcpy((ulong*)VA(k), initcode, sizeof initcode); kunmap(k); s->minva = UTZERO; s->maxva = UTZERO+BY2PG; ready(p); } void exit(void) { int i; u = 0; splhi(); print("exiting\n"); | |
| 1991/0111 | delay(30*1000); | |
| 1990/1226 | reset(); | |
| 1990/1223 | } /* * Insert new into list after where */ void insert(List **head, List *where, List *new) { if(where == 0){ new->next = *head; *head = new; }else{ new->next = where->next; where->next = new; } } /* * Insert new into list at end */ void append(List **head, List *new) { List *where; where = *head; if(where == 0) *head = new; else{ while(where->next) where = where->next; where->next = new; } new->next = 0; } /* * Delete old from list */ void delete0(List **head, List *old) { List *l; l = *head; if(l == old){ *head = old->next; return; } while(l->next != old) l = l->next; l->next = old->next; } /* * Delete old from list. where->next is known to be old. */ void delete(List **head, List *where, List *old) { if(where == 0){ *head = old->next; return; } where->next = old->next; } Conf conf; void confinit(void) { int mul; | |
| 1990/1226 | ||
| 1990/1223 | conf.nmach = 1; if(conf.nmach > MAXMACH) panic("confinit"); | |
| 1991/0111 | conf.npage0 = (4*1024*1024)/BY2PG; /* BUG */ | |
| 1991/0115 | conf.npage1 = (4*1024*1024)/BY2PG; /* BUG */ | |
| 1990/1223 | conf.base0 = 0; | |
| 1991/0112 | conf.base1 = 32*1024*1024; | |
| 1990/1223 | conf.npage = conf.npage0+conf.npage1; | |
| 1990/1226 | conf.maxialloc = 4*1024*1024; /* BUG */ | |
| 1991/0111 | mul = 1; if(conf.npage1 > 0) mul = 2; | |
| 1990/1223 | conf.nproc = 50*mul; conf.npgrp = 12*mul; | |
| 1991/0110 | conf.npte = 1400*mul; conf.nmod = 800*mul; | |
| 1990/1223 | conf.nalarm = 1000; conf.norig = 150*mul; conf.nchan = 200*mul; conf.nenv = 100*mul; conf.nenvchar = 8000*mul; conf.npgenv = 200*mul; conf.nmtab = 50*mul; conf.nmount = 80*mul; conf.nmntdev = 10*mul; | |
| 1991/0111 | conf.nmntbuf = conf.nmntdev+6; | |
| 1990/1223 | conf.nmnthdr = 2*conf.nmntdev; conf.nstream = 40 + 32*mul; conf.nqueue = 5 * conf.nstream; conf.nblock = 24 * conf.nstream; conf.nsrv = 16*mul; /* was 32 */ conf.nbitmap = 300*mul; conf.nbitbyte = 300*1024*mul; conf.nfont = 10*mul; | |
| 1990/1231 | conf.nnoifc = 1; conf.nnoconv = 32; | |
| 1990/1223 | conf.nurp = 32; conf.nasync = 1; conf.npipe = conf.nstream/2; conf.nservice = 3*mul; /* was conf.nproc/5 */ conf.nfsyschan = 31 + conf.nchan/20; conf.copymode = 0; /* copy on write */ | |
| 1990/1231 | } /* * set up the lance */ void lancesetup(Lance *lp) { KMap *k; ushort *sp; uchar *cp; | |
| 1991/0108 | ulong pa, pte, va; int i, j; | |
| 1990/1231 | ||
| 1991/0109 | k = kmappa(ETHER, PTEIO); | |
| 1990/1231 | lp->rdp = (void*)(k->va+0); lp->rap = (void*)(k->va+2); | |
| 1991/0109 | k = kmappa(EEPROM, PTEIO); | |
| 1990/1231 | cp = (uchar*)(k->va+0x7da); for(i=0; i<6; i++) lp->ea[i] = *cp++; kunmap(k); | |
| 1991/0109 | lp->lognrrb = 5; lp->logntrb = 5; | |
| 1990/1231 | lp->nrrb = 1<<lp->lognrrb; lp->ntrb = 1<<lp->logntrb; lp->sep = 1; | |
| 1991/0109 | lp->busctl = BSWP | ACON | BCON; | |
| 1990/1231 | /* | |
| 1991/0108 | * Allocate area for lance init block and descriptor rings | |
| 1990/1231 | */ pa = (ulong)ialloc(BY2PG, 1)&~KZERO; /* one whole page */ | |
| 1991/0108 | /* map at LANCESEGM */ | |
| 1991/0109 | k = kmappa(pa, PTEMAINMEM); | |
| 1991/0108 | print("init block va %lux\n", k->va); | |
| 1990/1231 | lp->lanceram = (ushort*)k->va; lp->lm = (Lancemem*)k->va; /* | |
| 1991/0108 | * Allocate space in host memory for the io buffers. * Allocate a block and kmap it page by page. kmap's are initially * in reverse order so rearrange them. | |
| 1990/1231 | */ | |
| 1991/0108 | i = (lp->nrrb+lp->ntrb)*sizeof(Etherpkt); | |
| 1990/1231 | i = (i+(BY2PG-1))/BY2PG; | |
| 1991/0108 | print("%d lance buffers\n", i); | |
| 1990/1231 | pa = (ulong)ialloc(i*BY2PG, 1)&~KZERO; | |
| 1991/0108 | va = 0; for(j=i-1; j>=0; j--){ | |
| 1991/0109 | k = kmappa(pa+j*BY2PG, PTEMAINMEM); | |
| 1991/0108 | if(va){ if(va != k->va+BY2PG) panic("lancesetup va unordered"); va = k->va; } } /* * k->va is the base of the region */ | |
| 1990/1231 | lp->lrp = (Etherpkt*)k->va; lp->rp = (Etherpkt*)k->va; | |
| 1991/0108 | lp->ltp = lp->lrp+lp->nrrb; lp->tp = lp->rp+lp->nrrb; | |
| 1990/1223 | } /* * set up floating point for a new process */ void procsetup(Proc *p) { #ifdef asdf long fpnull; fpnull = 0; splhi(); m->fpstate = FPinit; p->fpstate = FPinit; fprestore((FPsave*)&fpnull); spllo(); #endif } /* * Save the part of the process state. */ void procsave(uchar *state, int len) { #ifdef asdf fpsave(&u->fpsave); if(u->fpsave.type){ if(u->fpsave.size > sizeof u->fpsave.junk) panic("fpsize %d max %d\n", u->fpsave.size, sizeof u->fpsave.junk); fpregsave(u->fpsave.reg); u->p->fpstate = FPactive; m->fpstate = FPdirty; } #endif } /* * Restore what procsave() saves * * Procsave() makes sure that what state points to is long enough */ void procrestore(Proc *p, uchar *state) { #ifdef asdf if(p->fpstate != m->fpstate){ if(p->fpstate == FPinit){ u->p->fpstate = FPinit; fprestore(&initfp); m->fpstate = FPinit; }else{ fpregrestore(u->fpsave.reg); fprestore(&u->fpsave); m->fpstate = FPdirty; } } #endif } | |