2 #include "../port/lib.h"
16 memset(edata, 0, (ulong)end-(ulong)edata);
48 memset(m, 0, sizeof(Mach));
49 m->cputype = getpvr()>>16;
52 * For polled uart output at boot, need
53 * a default delay constant. 100000 should
54 * be enough for a while. Cpuidentify will
55 * calculate the real value later.
57 m->loopconst = 100000;
60 puthid0(gethid0() | BIT(16) | BIT(17));
71 id = "unknown PowerPC";
77 print("cpu0: %s\n", id);
88 { "ether0", "type=2114x" },
96 for(i = 0; i < nelem(plan9ini); i++)
97 if(cistrcmp(name, plan9ini[i].name) == 0)
98 return plan9ini[i].val;
105 // char **p, *q, name[KNAMELEN];
107 char buf[2*KNAMELEN];
114 * These are o.k. because rootinit is null.
115 * Then early kproc's will have a root and dot.
117 up->slash = namec("#/", Atodir, 0, 0);
118 pathclose(up->slash->path);
119 up->slash->path = newpath("/");
120 up->dot = cclone(up->slash);
125 snprint(buf, sizeof(buf), "power %s mtx", conffile);
126 ksetenv("terminal", buf, 0);
127 ksetenv("cputype", "power", 0);
129 ksetenv("service", "cpu", 0);
131 ksetenv("service", "terminal", 0);
134 for(p = confenv; *p; p++) {
135 q = strchr(p[0], '=');
141 memmove(name, p[0], n);
144 ksetenv(name, q+1, 0);
145 ksetenv(name, q+1, 1);
150 kproc("alarm", alarmkproc, 0);
151 kproc("mmusweep", mmusweep, 0);
152 touser((void*)(USTKTOP-8));
165 p->egrp = smalloc(sizeof(Egrp));
167 p->fgrp = dupfgrp(nil);
172 kstrdup(&p->text, "*init*");
173 kstrdup(&p->user, eve);
180 * N.B. The -12 for the stack pointer is important.
181 * 4 bytes for gotolabel's return PC
183 p->sched.pc = (ulong)init0;
184 p->sched.sp = (ulong)p->kstack+KSTACK-(sizeof(Sargs)+BY2WD);
189 s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG);
191 pg = newpage(1, 0, USTKTOP-BY2PG);
197 s = newseg(SG_TEXT, UTZERO, 1);
200 pg = newpage(1, 0, UTZERO);
203 k = kmap(s->map[0]->pages[0]);
204 memmove((ulong*)VA(k), initcode, sizeof initcode);
212 reboot(void*, void*, ulong)
224 * set up floating point for a new process
238 * Save the mach dependent part of the process state.
243 if(p->fpstate == FPactive){
244 if(p->state != Moribund)
246 p->fpstate = FPinactive;
256 extern ulong memsize; /* passed in from ROM monitor */
258 if(p = getconf("*kernelpercent"))
259 userpcnt = 100 - strtol(p, 0, 0);
263 pa = PGROUND(PADDR(end));
265 conf.mem[0].npage = memsize/BY2PG;
266 conf.mem[0].base = pa;
267 conf.npage = conf.mem[0].npage;
270 conf.nproc = 100 + ((conf.npage*BY2PG)/MB)*5;
273 if(conf.nproc > 2000)
276 conf.nswap = conf.nproc*80;
278 conf.copymode = 0; /* copy on write */
283 kpages = conf.npage - (conf.npage*userpcnt)/100;
286 * Hack for the big boys. Only good while physmem < 4GB.
287 * Give the kernel a max. of 16MB + enough to allocate the
289 * This is an overestimate as conf.upages < conf.npages.
290 * The patch of nimage is a band-aid, scanning the whole
291 * page list in imagereclaim just takes too long.
293 if(kpages > (16*MB + conf.npage*sizeof(Page))/BY2PG){
294 kpages = (16*MB + conf.npage*sizeof(Page))/BY2PG;
296 kpages += (conf.nproc*KSTACK)/BY2PG;
300 if(conf.npage*BY2PG < 16*MB)
305 kpages = conf.npage - (conf.npage*userpcnt)/100;
308 * Make sure terminals with low memory get at least
309 * 4MB on the first Image chunk allocation.
311 if(conf.npage*BY2PG < 16*MB)
312 imagmem->minarena = 4*1024*1024;
314 conf.upages = conf.npage - kpages;
315 conf.ialloc = (kpages/2)*BY2PG;
318 * Guess how much is taken by the large permanent
319 * datastructures. Mntcache and Mntrpc are not accounted for.
322 kpages -= conf.upages*sizeof(Page)
323 + conf.nproc*sizeof(Proc)
324 + conf.nimage*sizeof(Image)
326 + conf.nswppo*sizeof(Page*);
327 mainmem->maxsize = kpages;
330 * give terminals lots of image memory, too; the dynamic
331 * allocation will balance the load properly, hopefully.
332 * be careful with 32-bit overflow.
334 imagmem->maxsize = kpages;
337 // conf.monitor = 1; /* BUG */
341 getcfields(char* lp, char** fields, int n, char* sep)
345 for(i = 0; lp && *lp && i < n; i++){
346 while(*lp && strchr(sep, *lp) != 0)
351 while(*lp && strchr(sep, *lp) == 0){
352 if(*lp == '\\' && *(lp+1) == '\n')
362 isaconfig(char *class, int ctlrno, ISAConf *isa)
365 char cc[KNAMELEN], *p;
367 sprint(cc, "%s%d", class, ctlrno);
372 isa->nopt = tokenize(p, isa->opt, NISAOPT);
373 for(i = 0; i < isa->nopt; i++){
375 if(cistrncmp(p, "type=", 5) == 0)
377 else if(cistrncmp(p, "port=", 5) == 0)
378 isa->port = strtoul(p+5, &p, 0);
379 else if(cistrncmp(p, "irq=", 4) == 0)
380 isa->irq = strtoul(p+4, &p, 0);
381 else if(cistrncmp(p, "dma=", 4) == 0)
382 isa->dma = strtoul(p+4, &p, 0);
383 else if(cistrncmp(p, "mem=", 4) == 0)
384 isa->mem = strtoul(p+4, &p, 0);
385 else if(cistrncmp(p, "size=", 5) == 0)
386 isa->size = strtoul(p+5, &p, 0);
387 else if(cistrncmp(p, "freq=", 5) == 0)
388 isa->freq = strtoul(p+5, &p, 0);
394 cistrcmp(char *a, char *b)
402 if(ac >= 'A' && ac <= 'Z')
403 ac = 'a' + (ac - 'A');
404 if(bc >= 'A' && bc <= 'Z')
405 bc = 'a' + (bc - 'A');
416 cistrncmp(char *a, char *b, int n)
425 if(ac >= 'A' && ac <= 'Z')
426 ac = 'a' + (ac - 'A');
427 if(bc >= 'A' && bc <= 'Z')
428 bc = 'a' + (bc - 'A');
441 setupwatchpts(Proc *, Watchpt *, int n)
444 error("no watchpoints");