3 #include "../port/lib.h"
10 #include <../port/error.h>
15 * software tlb simulation
17 static Softtlb stlb[MAXMACH][STLBSIZE];
24 return (char*)arcs(0x78, name);
32 /* ipreset installs these when chandevreset runs */
33 fmtinstall('i', eipfmt);
34 fmtinstall('I', eipfmt);
35 fmtinstall('E', eipfmt);
36 fmtinstall('V', eipfmt);
37 fmtinstall('M', eipfmt);
41 ckpagemask(ulong mask, ulong size)
51 iprint("page size %ldK not supported on this cpu; "
52 "mask %#lux read back as %#lux\n", size/1024, mask, pm);
59 addmem(uintptr base, uintptr top)
70 e = PADDR(PGROUND((uintptr)end));
71 if(s < top && e > base){
79 /* exclude reserved firmware memory regions */
81 while((m = (ulong*)arcs(0x48, m)) != nil){
85 case 2: /* FreeMemory */
86 case 3: /* BadMemory */
89 if(s < top && e > base){
97 for(i=0; i<nelem(conf.mem); i++){
98 if(conf.mem[i].npage == 0){
99 conf.mem[i].base = base;
100 conf.mem[i].npage = (top - base)/BY2PG;
102 conf.npage += conf.mem[i].npage;
106 print("conf.mem[] too small\n");
110 * get memory configuration word for a bank
117 return *(ulong *)(KSEG1|MEMCFG0) >> 16;
119 return *(ulong *)(KSEG1|MEMCFG0) & 0xffff;
121 return *(ulong *)(KSEG1|MEMCFG1) >> 16;
123 return *(ulong *)(KSEG1|MEMCFG1) & 0xffff;
131 uintptr base, size, top;
136 * divide memory twixt user pages and kernel.
140 mconf = bank_conf(i);
141 if(!(mconf & 0x2000))
143 base = (mconf & 0xff) << 22;
144 size = ((mconf & 0x1f00) + 0x0100) << 14;
153 char *s = getconf("ConsoleOut");
154 return s != nil && strstr(s, "video()") != nil;
166 machinit(); /* calls clockinit */
181 ckpagemask(PGSZ, BY2PG);
190 panic("schedinit returned");
194 * initialize a processor's mach structure. each processor does this
200 extern void gevector(void); /* l.s */
201 extern void utlbmiss(void);
202 extern void vector0(void);
203 extern void vector180(void);
205 void **sbp = (void*)SPBADDR;
207 m->stb = stlb[m->machno];
209 /* install exception handlers */
210 sbp[0x18/4] = utlbmiss;
211 sbp[0x14/4] = gevector;
213 /* we could install our own vectors directly, but we'll try to play nice */
215 memmove((void*)(KSEG0+0x0), (void*)vector0, 0x80);
216 memmove((void*)(KSEG0+0x180), (void*)vector180, 0x80);
217 icflush((void*)(KSEG0+0x0), 0x80);
218 icflush((void*)(KSEG0+0x180), 0x80);
221 /* Ensure CU1 is off */
234 ksetenv("cputype", "mips", 0);
235 snprint(buf, sizeof buf, "mips %s", conffile);
236 ksetenv("terminal", buf, 0);
238 ksetenv("service", "cpu", 0);
240 ksetenv("service", "terminal", 0);
242 ksetenv("bootargs", "tcp", 0);
243 ksetenv("console", "0", 0);
246 ksetenv("usbwait", "0", 0);
247 ksetenv("nousbrc", "1", 0);
252 /* process input for arcs console */
254 kproc("arcs", arcsproc, 0);
256 kproc("alarm", alarmkproc, 0);
258 sp = (char**)(USTKTOP-sizeof(Tos) - 8 - sizeof(sp[0])*4);
259 sp[3] = sp[2] = sp[1] = nil;
260 strcpy(sp[0] = (char*)&sp[4], "boot");
269 arcs(0x18); /* reboot */
273 reboot(void *, void *, ulong)
282 postnote(up, 1, "sys: odd address", NDebug);
291 memmove(p->fpsave, &initfp, sizeof(FPsave));
300 switch(up->fpstate & ~FPillegal){
302 savefpregs(up->fpsave);
303 up->fpstate = FPinactive;
306 memmove(p->fpsave, up->fpsave, sizeof(FPsave));
307 p->fpstate = FPinactive;
315 if(p->fpstate == FPactive){
316 if(p->state != Moribund) {
317 savefpregs(p->fpsave);
318 p->fpstate = FPinactive;
339 * set up CPU's mach structure
340 * cpu0's was zeroed in l.s and our stack is in Mach, so don't zero it.
343 m->speed = 150; /* initial guess at MHz */
344 m->hz = m->speed * Mhz;
347 /* set up other configuration parameters */
353 conf.copymode = 0; /* copy on write */
355 kpages = conf.npage - (conf.npage*80)/100;
356 if(kpages > (64*MB + conf.npage*sizeof(Page))/BY2PG){
357 kpages = (64*MB + conf.npage*sizeof(Page))/BY2PG;
358 kpages += (conf.nproc*KSTACK)/BY2PG;
360 conf.upages = conf.npage - kpages;
361 conf.ialloc = (kpages/2)*BY2PG;
364 kpages -= conf.upages*sizeof(Page)
365 + conf.nproc*sizeof(Proc)
366 + conf.nimage*sizeof(Image)
368 + conf.nswppo*sizeof(Page*);
369 mainmem->maxsize = kpages;
370 imagmem->maxsize = kpages;
371 // mainmem->flags |= POOL_PARANOIA;
375 setupwatchpts(Proc *, Watchpt *, int n)
378 error("no watchpoints");
382 isaconfig(char *, int, ISAConf*)