2 #include "../port/lib.h"
13 typedef struct Plan9ini Plan9ini;
21 Plan9ini plan9ini[MAXCONF];
28 static void plan9iniinit(void);
35 id = "unknown PowerPC";
58 print("cpu0: %s, rev 0x%lux, cpu hz %lld, bus hz %ld\n",
59 cpuid(), getpvr()&0xffff, m->cpuhz, m->bushz);
65 memset(edata, 0, (ulong)end-(ulong)edata);
80 print("\nPlan 9 from Bell Labs\n");
99 for(i = 0; i < nconf; i++)
100 if(cistrcmp(name, plan9ini[i].name) == 0)
101 return plan9ini[i].val;
110 char *cp, line[MAXCONF], *p, *q;
113 * parse configuration args from dos file plan9.ini
117 for(i = 0; i < MAXCONF; i++){
119 * Strip out '\r', change '\t' -> ' ', test for 0xff which is end of file
122 for(q = cp; c = (uchar)*q; q++){
127 if(c == 0xff || c == '\n')
134 if(*line != '#' && (cp = strchr(line, '='))){
136 kstrdup(&plan9ini[nconf].name, line);
137 kstrdup(&plan9ini[nconf].val, cp);
150 // char **p, *q, name[KNAMELEN];
152 char buf[2*KNAMELEN];
158 * These are o.k. because rootinit is null.
159 * Then early kproc's will have a root and dot.
161 up->slash = namec("#/", Atodir, 0, 0);
162 pathclose(up->slash->path);
163 up->slash->path = newpath("/");
164 up->dot = cclone(up->slash);
169 snprint(buf, sizeof(buf), "power %s mtx", conffile);
170 ksetenv("terminal", buf, 0);
171 ksetenv("cputype", "power", 0);
173 ksetenv("service", "cpu", 0);
175 ksetenv("service", "terminal", 0);
177 for(i = 0; i < nconf; i++){
178 if(plan9ini[i].name[0] != '*')
179 ksetenv(plan9ini[i].name, plan9ini[i].val, 0);
180 ksetenv(plan9ini[i].name, plan9ini[i].val, 1);
184 kproc("alarm", alarmkproc, 0);
185 kproc("mmusweep", mmusweep, 0);
186 touser((void*)(USTKTOP-sizeof(Tos)));
199 p->egrp = smalloc(sizeof(Egrp));
201 p->fgrp = dupfgrp(nil);
206 kstrdup(&p->text, "*init*");
207 kstrdup(&p->user, eve);
214 * N.B. The -12 for the stack pointer is important.
215 * 4 bytes for gotolabel's return PC
217 p->sched.pc = (ulong)init0;
218 p->sched.sp = (ulong)p->kstack+KSTACK-(sizeof(Sargs)+BY2WD);
223 s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG);
225 pg = newpage(1, 0, USTKTOP-BY2PG);
231 s = newseg(SG_TEXT, UTZERO, 1);
234 pg = newpage(1, 0, UTZERO);
237 k = kmap(s->map[0]->pages[0]);
238 memmove((ulong*)VA(k), initcode, sizeof initcode);
252 * set up floating point for a new process
260 p->pcycles = -p->kentry;
266 p->kentry = up->kentry;
267 p->pcycles = -p->kentry;
283 * Save the mach dependent part of the process state.
293 if(p->fpstate == FPactive){
294 if(p->state != Moribund)
296 p->fpstate = FPinactive;
306 /* passed in from ROM monitor: */
308 if(p = getconf("service")){
309 if(strcmp(p, "cpu") == 0)
311 else if(strcmp(p,"terminal") == 0)
315 if(p = getconf("*kernelpercent"))
316 userpcnt = 100 - strtol(p, 0, 0);
320 pa = PGROUND(PADDR(end));
322 /* Blast Board specific */
323 conf.mem[0].npage = (MEM1SIZE - pa)/BY2PG;
324 conf.mem[0].base = pa;
326 conf.mem[1].npage = MEM2SIZE/BY2PG;
327 conf.mem[1].base = MEM2BASE;
329 conf.npage = conf.mem[0].npage + conf.mem[1].npage;
332 conf.nproc = 100 + ((conf.npage*BY2PG)/MB)*5;
335 if(conf.nproc > 2000)
338 conf.nswap = conf.nproc*80;
340 conf.copymode = 0; /* copy on write */
345 kpages = conf.npage - (conf.npage*userpcnt)/100;
348 * Hack for the big boys. Only good while physmem < 4GB.
349 * Give the kernel a max. of 16MB + enough to allocate the
351 * This is an overestimate as conf.upages < conf.npages.
352 * The patch of nimage is a band-aid, scanning the whole
353 * page list in imagereclaim just takes too long.
355 if(kpages > (16*MB + conf.npage*sizeof(Page))/BY2PG){
356 kpages = (16*MB + conf.npage*sizeof(Page))/BY2PG;
358 kpages += (conf.nproc*KSTACK)/BY2PG;
362 if(conf.npage*BY2PG < 16*MB)
367 kpages = conf.npage - (conf.npage*userpcnt)/100;
370 * Make sure terminals with low memory get at least
371 * 4MB on the first Image chunk allocation.
373 if(conf.npage*BY2PG < 16*MB)
374 imagmem->minarena = 4*1024*1024;
376 conf.upages = conf.npage - kpages;
377 conf.ialloc = (kpages/2)*BY2PG;
380 * Guess how much is taken by the large permanent
381 * datastructures. Mntcache and Mntrpc are not accounted for.
384 kpages -= conf.upages*sizeof(Page)
385 + conf.nproc*sizeof(Proc)
386 + conf.nimage*sizeof(Image)
388 + conf.nswppo*sizeof(Page*);
389 mainmem->maxsize = kpages;
392 * give terminals lots of image memory, too; the dynamic
393 * allocation will balance the load properly, hopefully.
394 * be careful with 32-bit overflow.
396 imagmem->maxsize = kpages;
401 getcfields(char* lp, char** fields, int n, char* sep)
405 for(i = 0; lp && *lp && i < n; i++){
406 while(*lp && strchr(sep, *lp) != 0)
411 while(*lp && strchr(sep, *lp) == 0){
412 if(*lp == '\\' && *(lp+1) == '\n')
422 isaconfig(char *class, int ctlrno, ISAConf *isa)
425 char cc[KNAMELEN], *p;
427 sprint(cc, "%s%d", class, ctlrno);
432 isa->nopt = tokenize(p, isa->opt, NISAOPT);
433 for(i = 0; i < isa->nopt; i++){
435 if(cistrncmp(p, "type=", 5) == 0)
437 else if(cistrncmp(p, "port=", 5) == 0)
438 isa->port = strtoul(p+5, &p, 0);
439 else if(cistrncmp(p, "irq=", 4) == 0)
440 isa->irq = strtoul(p+4, &p, 0);
441 else if(cistrncmp(p, "dma=", 4) == 0)
442 isa->dma = strtoul(p+4, &p, 0);
443 else if(cistrncmp(p, "mem=", 4) == 0)
444 isa->mem = strtoul(p+4, &p, 0);
445 else if(cistrncmp(p, "size=", 5) == 0)
446 isa->size = strtoul(p+5, &p, 0);
447 else if(cistrncmp(p, "freq=", 5) == 0)
448 isa->freq = strtoul(p+5, &p, 0);
454 cistrcmp(char *a, char *b)
462 if(ac >= 'A' && ac <= 'Z')
463 ac = 'a' + (ac - 'A');
464 if(bc >= 'A' && bc <= 'Z')
465 bc = 'a' + (bc - 'A');
476 cistrncmp(char *a, char *b, int n)
485 if(ac >= 'A' && ac <= 'Z')
486 ac = 'a' + (ac - 'A');
487 if(bc >= 'A' && bc <= 'Z')
488 bc = 'a' + (bc - 'A');
501 setupwatchpts(Proc *, Watchpt *, int n)
504 error("no watchpoints");