2 * allocate Blocks from uncached memory
5 #include "../port/lib.h"
13 Hdrspc = 64, /* leave room for high-level headers */
14 Bdead = 0x51494F42, /* "QIOB" */
29 if((b = ucalloc(sizeof(Block)+size+Hdrspc)) == nil)
37 /* align start of data portion by rounding up */
39 addr = ROUND(addr + sizeof(Block), BLOCKALIGN);
40 b->base = (uchar*)addr;
42 /* align end of data portion by rounding down */
43 b->lim = (uchar*)b + msize(b);
44 addr = (uintptr)b->lim;
45 addr &= ~(BLOCKALIGN-1);
46 b->lim = (uchar*)addr;
48 /* leave sluff at beginning for added headers */
49 b->rp = b->lim - ROUND(size, BLOCKALIGN);
63 * Check in a process and wait until successful.
64 * Can still error out of here, though.
67 panic("ucallocb without up: %#p", getcallerpc(&size));
68 if((b = _ucallocb(size)) == nil)
69 panic("ucallocb: no memory for %d bytes", size);
70 setmalloctag(b, getcallerpc(&size));
79 static int m1, m2, mp;
81 if((b = _ucallocb(size)) == nil){
82 if(0 && (m2++%10000)==0){
84 panic("uciallocb: out of memory");
85 iprint("uciallocb: no memory %lud/%lud\n",
86 ucialloc.bytes, conf.ialloc);
90 setmalloctag(b, getcallerpc(&size));
94 ucialloc.bytes += b->lim - b->base;
103 void *dead = (void*)Bdead;
109 * drivers which perform non cache coherent DMA manage their own buffer
110 * pool of uncached buffers and provide their own free routine.
116 if(b->flag & BINTR) {
118 ucialloc.bytes -= b->lim - b->base;
122 /* poison the block in case someone is still holding onto it */