3 #include "../port/lib.h"
16 memset(edata, 0, (ulong)end-(ulong)edata);
47 memset(m, 0, sizeof(Mach));
48 m->cputype = getpvr()>>16;
51 * For polled uart output at boot, need
52 * a default delay constant. 100000 should
53 * be enough for a while. Cpuidentify will
54 * calculate the real value later.
56 m->loopconst = 100000;
59 puthid0(gethid0() | BIT(16) | BIT(17));
70 id = "unknown PowerPC";
76 print("cpu0: %s\n", id);
87 { "ether0", "type=2114x" },
95 for(i = 0; i < nelem(plan9ini); i++)
96 if(cistrcmp(name, plan9ini[i].name) == 0)
97 return plan9ini[i].val;
104 char buf[2*KNAMELEN];
109 snprint(buf, sizeof(buf), "power %s mtx", conffile);
110 ksetenv("terminal", buf, 0);
111 ksetenv("cputype", "power", 0);
113 ksetenv("service", "cpu", 0);
115 ksetenv("service", "terminal", 0);
118 kproc("alarm", alarmkproc, 0);
119 kproc("mmusweep", mmusweep, 0);
120 touser((void*)(USTKTOP - sizeof(Tos)));
125 reboot(void*, void*, ulong)
137 * set up floating point for a new process
151 * Save the mach dependent part of the process state.
156 if(p->fpstate == FPactive){
157 if(p->state != Moribund)
159 p->fpstate = FPinactive;
169 extern ulong memsize; /* passed in from ROM monitor */
171 if(p = getconf("*kernelpercent"))
172 userpcnt = 100 - strtol(p, 0, 0);
176 pa = PGROUND(PADDR(end));
178 conf.mem[0].npage = memsize/BY2PG;
179 conf.mem[0].base = pa;
180 conf.npage = conf.mem[0].npage;
183 conf.nproc = 100 + ((conf.npage*BY2PG)/MB)*5;
186 if(conf.nproc > 2000)
189 conf.nswap = conf.nproc*80;
191 conf.copymode = 0; /* copy on write */
196 kpages = conf.npage - (conf.npage*userpcnt)/100;
199 * Hack for the big boys. Only good while physmem < 4GB.
200 * Give the kernel a max. of 16MB + enough to allocate the
202 * This is an overestimate as conf.upages < conf.npages.
203 * The patch of nimage is a band-aid, scanning the whole
204 * page list in imagereclaim just takes too long.
206 if(kpages > (16*MB + conf.npage*sizeof(Page))/BY2PG){
207 kpages = (16*MB + conf.npage*sizeof(Page))/BY2PG;
209 kpages += (conf.nproc*KSTACK)/BY2PG;
213 if(conf.npage*BY2PG < 16*MB)
218 kpages = conf.npage - (conf.npage*userpcnt)/100;
221 * Make sure terminals with low memory get at least
222 * 4MB on the first Image chunk allocation.
224 if(conf.npage*BY2PG < 16*MB)
225 imagmem->minarena = 4*1024*1024;
227 conf.upages = conf.npage - kpages;
228 conf.ialloc = (kpages/2)*BY2PG;
231 * Guess how much is taken by the large permanent
232 * datastructures. Mntcache and Mntrpc are not accounted for.
235 kpages -= conf.upages*sizeof(Page)
236 + conf.nproc*sizeof(Proc)
237 + conf.nimage*sizeof(Image)
239 + conf.nswppo*sizeof(Page*);
240 mainmem->maxsize = kpages;
243 * give terminals lots of image memory, too; the dynamic
244 * allocation will balance the load properly, hopefully.
245 * be careful with 32-bit overflow.
247 imagmem->maxsize = kpages;
250 // conf.monitor = 1; /* BUG */
254 getcfields(char* lp, char** fields, int n, char* sep)
258 for(i = 0; lp && *lp && i < n; i++){
259 while(*lp && strchr(sep, *lp) != 0)
264 while(*lp && strchr(sep, *lp) == 0){
265 if(*lp == '\\' && *(lp+1) == '\n')
275 isaconfig(char *class, int ctlrno, ISAConf *isa)
280 snprint(cc, sizeof cc, "%s%d", class, ctlrno);
290 isa->nopt = tokenize(p, isa->opt, NISAOPT);
291 for(i = 0; i < isa->nopt; i++){
293 if(cistrncmp(p, "type=", 5) == 0)
295 else if(cistrncmp(p, "port=", 5) == 0)
296 isa->port = strtoul(p+5, &p, 0);
297 else if(cistrncmp(p, "irq=", 4) == 0)
298 isa->irq = strtoul(p+4, &p, 0);
299 else if(cistrncmp(p, "dma=", 4) == 0)
300 isa->dma = strtoul(p+4, &p, 0);
301 else if(cistrncmp(p, "mem=", 4) == 0)
302 isa->mem = strtoul(p+4, &p, 0);
303 else if(cistrncmp(p, "size=", 5) == 0)
304 isa->size = strtoul(p+5, &p, 0);
305 else if(cistrncmp(p, "freq=", 5) == 0)
306 isa->freq = strtoul(p+5, &p, 0);
312 setupwatchpts(Proc *, Watchpt *, int n)
315 error("no watchpoints");