/*
* Called to allocate permanent data structures
* Alignment is in number of bytes. It pertains both to the start and
* end of the allocated memory.
*/
void*
ialloc(ulong n, int align)
{
Mbank *mbp;
ulong p;
int m;
iunlock(&mconf);
for(mbp = mconf.bank; mbp < &mconf.bank[mconf.nbank]; mbp++)
print("bank[%ld]: base 0x%8.8lux, limit 0x%8.8lux\n",
mbp - mconf.bank, mbp->base, mbp->limit);
panic("ialloc(0x%lux, 0x%lx): out of memory\n", n, align);
return 0;
}
/*
* allocate rest of mem
* for io buffers.
*/
#define HWIDTH 8 /* buffers per hash */
void
iobufinit(void)
{
long m;
int i;
Iobuf *p, *q;
Hiob *hp;
Mbank *mbp;
wlock(&mainlock); /* init */
wunlock(&mainlock);
m = 0;
for(mbp = mconf.bank; mbp < &mconf.bank[mconf.nbank]; mbp++) {
m += mbp->limit - mbp->base;
}
m -= conf.sparemem;
/*
* Make sure that no more of bank[0] can be used:
* 'check' will do an ialloc(0, 1) to find the base of
* sparemem.
*/
mconf.bank[0].base = mconf.bank[0].limit+1;
i = 0;
for(mbp = mconf.bank; mbp < &mconf.bank[mconf.nbank]; mbp++)
i += mbp->limit - mbp->base;
print(" mem left = %d\n", i);
print(" out of = %ld\n", conf.mem);
}