/* * this assumes that if a bank is not empty, * its first slot is filled. * * ../port/alloc.c and ../port/page.c * need to be changed to support more than two banks. */ void scanbank(ulong base, uchar *mempres, int n) { int i; ulong addr, npg; npg = 0; for(i=0; i<n; i++){ mempres[i] = 0; addr = base + i*MB; if(!probemem(addr)) break; if(addr != base) { /* check for mirrors */ putphys(addr, addr); if(getphys(base) == addr) break; } mempres[i] = 1; npg += MB/BY2PG; } if(npg){ if(conf.npage0 == 0){ conf.base0 = base; conf.npage0 = npg; }else if(conf.npage1 < npg){ conf.base1 = base; conf.npage1 = npg; } } }
/* * we assume that the kernel is at the beginning of one of the * contiguous chunks of memory. */ void confinit(void) { int i, j; ulong addr; ulong ktop; /* find first two contiguous sections of available memory */ addr = PHYSDRAM0; for(i=0; i<nelem(conf.mem); i++){ conf.mem[i].base = addr; conf.mem[i].limit = addr; } for(j=0; j<nelem(conf.mem); j++){ conf.mem[j].base = addr; conf.mem[j].limit = addr; for(i = 0; i < 512; i++){ if(probemem(addr) == 0) break; addr += OneMeg; } for(; i < 512; i++){ if(probemem(addr) < 0) break; addr += OneMeg; conf.mem[j].limit = addr; } } conf.npage = 0; for(i=0; i<nelem(conf.mem); i++){ /* take kernel out of allocatable space */ ktop = PGROUND((ulong)end); if(ktop >= conf.mem[i].base && ktop <= conf.mem[i].limit) conf.mem[i].base = ktop; /* zero memory */ memset((void*)conf.mem[i].base, 0, conf.mem[i].limit - conf.mem[i].base); conf.mem[i].npage = (conf.mem[i].limit - conf.mem[i].base)/BY2PG; conf.npage += conf.mem[i].npage; } if(conf.npage > 16*MB/BY2PG){ conf.upages = (conf.npage*60)/100; imagmem->minarena = 4*1024*1024; }else conf.upages = (conf.npage*40)/100; conf.ialloc = ((conf.npage-conf.upages)/2)*BY2PG; /* only one processor */ conf.nmach = 1; /* set up other configuration parameters */ conf.nproc = 100; conf.nswap = conf.npage*3; conf.nswppo = 4096; conf.nimage = 200; conf.monitor = 1; conf.copymode = 0; /* copy on write */ }
void confinit(void) { ulong i; ulong ktop; conf.monitor = 0; conf.nmach = 1; if(conf.nmach > MAXMACH) panic("confinit"); /* fetch ID prom */ physcopyin(&idprom, NVR_PHYS+IDOFF, sizeof(idprom)); if(idprom.format!=1 || (idprom.type&0xF0)!=0x80) *(ulong*)~0 = 0; /* not a new generation sparc; die! */ for(sparam = sysparam; sparam->id; sparam++) if(sparam->id == idprom.type) break; /* First entry in the table is the default */ if(sparam->id == 0) sparam = sysparam; conf.ss2 = sparam->ss2; conf.vacsize = sparam->vacsize; conf.vaclinesize = sparam->vacline; conf.ncontext = sparam->ncontext; conf.ss2cachebug = sparam->cachebug; for(i=0; i<sparam->nbank; i++) if(probemem(i*sparam->banksize*MB)) scanbank(i*sparam->banksize*MB, mempres, sparam->banksize); bank[0] = conf.npage0*BY2PG/MB; bank[1] = conf.npage1*BY2PG/MB; if(bank[1] == 0){ /* * This split of memory into 2 banks fools the allocator into * allocating low memory pages from bank 0 for the ethernet * since it has only a 24bit address *counter. * NB. Suns must have at LEAST 8Mbytes. */ conf.npage1 = conf.npage0 - (8*MB)/BY2PG; conf.base1 = conf.base0 + 8*MB; conf.npage0 = (8*MB)/BY2PG; bank[1] = bank[0]-8; bank[0] = 8; } conf.npage = conf.npage0+conf.npage1; ktop = PGROUND((ulong)end); ktop = PADDR(ktop); conf.npage0 -= ktop/BY2PG; conf.base0 += ktop; conf.nproc = 100 + ((conf.npage*BY2PG)/MB)*5; conf.copymode = 0; /* copy on write */ conf.arp = 32; conf.ialloc = (((conf.npage*(100-sparam->pcnt))/100)/2)*BY2PG; eve = strdup("inferno"); #ifdef notdef /* XXX - Eric - Autoconfigure memory */ /* XXX - Tad: 8 eigths, total... */ mainmem->maxsize = (conf.npage*BY2PG)/8; heapmem->maxsize = ((conf.npage*BY2PG)*5)/8; imagmem->maxsize = ((conf.npage*BY2PG)*2)/8; #endif }