3 #include "../port/lib.h"
12 typedef struct Plan9ini Plan9ini;
20 Plan9ini plan9ini[MAXCONF];
27 static void plan9iniinit(void);
34 id = "unknown PowerPC";
57 print("cpu0: %s, rev 0x%lux, cpu hz %lld, bus hz %ld\n",
58 cpuid(), getpvr()&0xffff, m->cpuhz, m->bushz);
64 memset(edata, 0, (ulong)end-(ulong)edata);
79 print("\nPlan 9 from Bell Labs\n");
98 for(i = 0; i < nconf; i++)
99 if(cistrcmp(name, plan9ini[i].name) == 0)
100 return plan9ini[i].val;
109 char *cp, line[MAXCONF], *p, *q;
112 * parse configuration args from dos file plan9.ini
116 for(i = 0; i < MAXCONF; i++){
118 * Strip out '\r', change '\t' -> ' ', test for 0xff which is end of file
121 for(q = cp; c = (uchar)*q; q++){
126 if(c == 0xff || c == '\n')
133 if(*line != '#' && (cp = strchr(line, '='))){
135 kstrdup(&plan9ini[nconf].name, line);
136 kstrdup(&plan9ini[nconf].val, cp);
149 char buf[2*KNAMELEN];
155 snprint(buf, sizeof(buf), "power %s mtx", conffile);
156 ksetenv("terminal", buf, 0);
157 ksetenv("cputype", "power", 0);
159 ksetenv("service", "cpu", 0);
161 ksetenv("service", "terminal", 0);
163 for(i = 0; i < nconf; i++){
164 if(plan9ini[i].name[0] != '*')
165 ksetenv(plan9ini[i].name, plan9ini[i].val, 0);
166 ksetenv(plan9ini[i].name, plan9ini[i].val, 1);
170 kproc("alarm", alarmkproc, 0);
171 kproc("mmusweep", mmusweep, 0);
172 touser((void*)(USTKTOP - sizeof(Tos)));
183 * set up floating point for a new process
191 p->pcycles = -p->kentry;
197 p->kentry = up->kentry;
198 p->pcycles = -p->kentry;
214 * Save the mach dependent part of the process state.
224 if(p->fpstate == FPactive){
225 if(p->state != Moribund)
227 p->fpstate = FPinactive;
237 /* passed in from ROM monitor: */
239 if(p = getconf("service")){
240 if(strcmp(p, "cpu") == 0)
242 else if(strcmp(p,"terminal") == 0)
246 if(p = getconf("*kernelpercent"))
247 userpcnt = 100 - strtol(p, 0, 0);
251 pa = PGROUND(PADDR(end));
253 /* Blast Board specific */
254 conf.mem[0].npage = (MEM1SIZE - pa)/BY2PG;
255 conf.mem[0].base = pa;
257 conf.mem[1].npage = MEM2SIZE/BY2PG;
258 conf.mem[1].base = MEM2BASE;
260 conf.npage = conf.mem[0].npage + conf.mem[1].npage;
263 conf.nproc = 100 + ((conf.npage*BY2PG)/MB)*5;
266 if(conf.nproc > 2000)
269 conf.nswap = conf.nproc*80;
271 conf.copymode = 0; /* copy on write */
276 kpages = conf.npage - (conf.npage*userpcnt)/100;
279 * Hack for the big boys. Only good while physmem < 4GB.
280 * Give the kernel a max. of 16MB + enough to allocate the
282 * This is an overestimate as conf.upages < conf.npages.
283 * The patch of nimage is a band-aid, scanning the whole
284 * page list in imagereclaim just takes too long.
286 if(kpages > (16*MB + conf.npage*sizeof(Page))/BY2PG){
287 kpages = (16*MB + conf.npage*sizeof(Page))/BY2PG;
289 kpages += (conf.nproc*KSTACK)/BY2PG;
293 if(conf.npage*BY2PG < 16*MB)
298 kpages = conf.npage - (conf.npage*userpcnt)/100;
301 * Make sure terminals with low memory get at least
302 * 4MB on the first Image chunk allocation.
304 if(conf.npage*BY2PG < 16*MB)
305 imagmem->minarena = 4*1024*1024;
307 conf.upages = conf.npage - kpages;
308 conf.ialloc = (kpages/2)*BY2PG;
311 * Guess how much is taken by the large permanent
312 * datastructures. Mntcache and Mntrpc are not accounted for.
315 kpages -= conf.upages*sizeof(Page)
316 + conf.nproc*sizeof(Proc)
317 + conf.nimage*sizeof(Image)
319 + conf.nswppo*sizeof(Page*);
320 mainmem->maxsize = kpages;
323 * give terminals lots of image memory, too; the dynamic
324 * allocation will balance the load properly, hopefully.
325 * be careful with 32-bit overflow.
327 imagmem->maxsize = kpages;
332 getcfields(char* lp, char** fields, int n, char* sep)
336 for(i = 0; lp && *lp && i < n; i++){
337 while(*lp && strchr(sep, *lp) != 0)
342 while(*lp && strchr(sep, *lp) == 0){
343 if(*lp == '\\' && *(lp+1) == '\n')
353 isaconfig(char *class, int ctlrno, ISAConf *isa)
356 char cc[KNAMELEN], *p;
358 sprint(cc, "%s%d", class, ctlrno);
363 isa->nopt = tokenize(p, isa->opt, NISAOPT);
364 for(i = 0; i < isa->nopt; i++){
366 if(cistrncmp(p, "type=", 5) == 0)
368 else if(cistrncmp(p, "port=", 5) == 0)
369 isa->port = strtoul(p+5, &p, 0);
370 else if(cistrncmp(p, "irq=", 4) == 0)
371 isa->irq = strtoul(p+4, &p, 0);
372 else if(cistrncmp(p, "dma=", 4) == 0)
373 isa->dma = strtoul(p+4, &p, 0);
374 else if(cistrncmp(p, "mem=", 4) == 0)
375 isa->mem = strtoul(p+4, &p, 0);
376 else if(cistrncmp(p, "size=", 5) == 0)
377 isa->size = strtoul(p+5, &p, 0);
378 else if(cistrncmp(p, "freq=", 5) == 0)
379 isa->freq = strtoul(p+5, &p, 0);
385 setupwatchpts(Proc *, Watchpt *, int n)
388 error("no watchpoints");