int xmerge(void *vp, void *vq) { Xhdr *p, *q; p = (Xhdr*)(((ulong)vp - offsetof(Xhdr, data[0]))); q = (Xhdr*)(((ulong)vq - offsetof(Xhdr, data[0]))); if(p->magix != Magichole || q->magix != Magichole) { int i; ulong *wd; void *badp; xsummary(); badp = (p->magix != Magichole? p: q); wd = (ulong *)badp - 12; for (i = 24; i-- > 0; ) { print("%#p: %lux", wd, *wd); if (wd == badp) print(" <-"); print("\n"); wd++; } panic("xmerge(%#p, %#p) bad magic %#lux, %#lux", vp, vq, p->magix, q->magix); } if((uchar*)p+p->size == (uchar*)q) { p->size += q->size; return 1; } return 0; }
void xfree(void *p) { Xhdr *x; x = UINT2PTR((PTR2UINT(p) - offsetof(Xhdr, data[0]))); if(x->magix != Magichole) { xsummary(); panic("xfree(%#p) %#ux != %#lux", p, Magichole, x->magix); } xhole(PADDR(x), x->size); }
void xfree(void *p) { Xhdr *x; x = (Xhdr*)((ulong)p - datoff); if(x->magix != Magichole) { xsummary(); panic("xfree(0x%lux) 0x%lux!=0x%lux", p, (ulong)Magichole, x->magix); } xhole(PADDR(x), x->size); }
void xfree(void *p) { Xhdr *x; x = (Xhdr*)((ulong)p - offsetof(Xhdr, data[0])); if(x->magix != Magichole) { xsummary(); panic("xfree(%#p) %#ux != %#lux", p, Magichole, x->magix); } xhole(PADDR((uintptr)x), x->size); }
void xinit(void) { int i, n, upages, kpages; ulong maxkpa; Confmem *m; Pallocmem *pm; Hole *h, *eh; eh = &xlists.hole[Nhole-1]; for(h = xlists.hole; h < eh; h++) h->link = h+1; xlists.flist = xlists.hole; upages = conf.upages; kpages = conf.npage - upages; pm = palloc.mem; maxkpa = -KZERO; for(i=0; i<nelem(conf.mem); i++){ m = &conf.mem[i]; n = m->npage; if(n > kpages) n = kpages; if(m->base >= maxkpa) n = 0; else if(n > 0 && m->base+n*PGSZ >= maxkpa) n = (maxkpa - m->base)/PGSZ; /* first give to kernel */ if(n > 0){ m->kbase = PTR2UINT(KADDR(m->base)); m->klimit = PTR2UINT(KADDR(m->base+n*PGSZ)); xhole(m->base, n*PGSZ); kpages -= n; } /* if anything left over, give to user */ if(n < m->npage){ if(pm >= palloc.mem+nelem(palloc.mem)){ print("xinit: losing %lud pages\n", m->npage-n); continue; } pm->base = m->base+n*PGSZ; pm->npage = m->npage - n; pm++; } } xsummary(); }
void xinit(void) { int i, n, upages, kpages; ulong maxpages; Confmem *m; Pallocmem *pm; Hole *h, *eh; eh = &xlists.hole[Nhole-1]; for(h = xlists.hole; h < eh; h++) h->link = h+1; xlists.flist = xlists.hole; upages = conf.upages; kpages = conf.npage - upages; pm = palloc.mem; for(i=0; i<nelem(conf.mem); i++){ m = &conf.mem[i]; n = m->npage; if(n > kpages) n = kpages; /* don't try to use non-KADDR-able memory for kernel */ maxpages = cankaddr(m->base)/BY2PG; if(n > maxpages) n = maxpages; /* first give to kernel */ if(n > 0){ m->kbase = (ulong)KADDR(m->base); m->klimit = (ulong)KADDR(m->base+n*BY2PG); xhole(m->base, n*BY2PG); kpages -= n; } /* if anything left over, give to user */ if(n < m->npage){ if(pm >= palloc.mem+nelem(palloc.mem)){ print("xinit: losing %lud pages\n", m->npage-n); continue; } pm->base = m->base+n*BY2PG; pm->npage = m->npage - n; pm++; } } xsummary(); }
void procinit0(void) /* bad planning - clashes with devproc.c */ { Proc *p; int i; p = xalloc(conf.nproc*sizeof(Proc)); if(p == nil){ xsummary(); panic("cannot allocate %lud procs (%ludMB)", conf.nproc, conf.nproc*sizeof(Proc)/(1024*1024)); } procalloc.arena = p; procalloc.free = p; for(i=0; i<conf.nproc-1; i++, p++) p->qnext = p+1; p->qnext = nil; }
int xmerge(void *vp, void *vq) { Xhdr *p, *q; p = UINT2PTR((PTR2UINT(vp) - offsetof(Xhdr, data[0]))); q = UINT2PTR((PTR2UINT(vq) - offsetof(Xhdr, data[0]))); if(p->magix != Magichole || q->magix != Magichole) { xsummary(); panic("xmerge(%#p, %#p) bad magic %#lux, %#lux\n", vp, vq, p->magix, q->magix); } if((uchar*)p+p->size == (uchar*)q) { p->size += q->size; return 1; } return 0; }
Block* allocb(int size) { Block *b; /* * Check in a process and wait until successful. * Can still error out of here, though. */ if(up == nil) panic("allocb without up: %luX\n", getcallerpc(&size)); if((b = _allocb(size)) == nil){ xsummary(); mallocsummary(); panic("allocb: no memory for %d bytes\n", size); } setmalloctag(b, getcallerpc(&size)); return b; }
static void echo(char *buf, int n) { static int ctrlt, pid; char *e, *p; if (n == 0) return; e = buf + n; for (p = buf; p < e; p++) { switch (*p) { #if 0 case 0x10: /* ^P */ if (cpuserver && !kbd.ctlpoff) { active.exiting = 1; return; } break; #endif case 0x14: /* ^T */ ctrlt++; if (ctrlt > 2) ctrlt = 2; continue; } if (ctrlt != 2) continue; /* ^T escapes */ ctrlt = 0; switch (*p) { #if 0 case 'S': { int8_t x = 0; disable_irqsave(&x); dumpstack(); procdump(); enable_irqsave(&x); return; } #endif case 's': dumpstack(); return; #if 0 case 'x': xsummary(); ixsummary(); mallocsummary(); memorysummary(); pagersummary(); return; case 'd': if (consdebug == NULL) consdebug = rdb; else consdebug = NULL; printd("consdebug now %#p\n", consdebug); return; case 'D': if (consdebug == NULL) consdebug = rdb; consdebug(); return; case 'p': x = spllo(); procdump(); splx(x); return; case 'q': scheddump(); return; case 'k': killbig("^t ^t k"); return; #endif case 'r': exit(0); return; } } qproduce(kbdq, buf, n); if (kbd.raw) return; kmesgputs(buf, n); if (screenputs != NULL) echoscreen(buf, n); if (serialoq) echoserialoq(buf, n); }
static void ixprt() { xsummary(); ixsummary(); }
void echo(char *buf, int n) { static int ctrlt; int x; char *e, *p; if(n == 0) return; e = buf+n; for(p = buf; p < e; p++){ switch(*p){ case 0x10: /* ^P */ if(cpuserver && !kbd.ctlpoff){ active.exiting = 1; return; } break; case 0x14: /* ^T */ ctrlt++; if(ctrlt > 2) ctrlt = 2; continue; } if(ctrlt != 2) continue; /* ^T escapes */ ctrlt = 0; switch(*p){ case 'S': x = splhi(); dumpstack(); procdump(); splx(x); return; case 's': dumpstack(); return; case 'x': xsummary(); ixsummary(); mallocsummary(); // memorysummary(); pagersummary(); return; case 'd': if(consdebug == nil) consdebug = rdb; else consdebug = nil; print("consdebug now 0x%p\n", consdebug); return; case 'D': if(consdebug == nil) consdebug = rdb; consdebug(); return; case 'p': x = spllo(); procdump(); splx(x); return; case 'q': scheddump(); return; case 'k': killbig("^t ^t k"); return; case 'r': exit(0); return; } } qproduce(kbdq, buf, n); if(kbd.raw) return; kmesgputs(buf, n); if(screenputs != nil) echoscreen(buf, n); uartecho(buf, n); // Plan 9 VX }