9 * Called to allocate permanent data structures
10 * Alignment is in number of bytes. It pertains both to the start and
11 * end of the allocated memory.
14 ialloc(ulong n, int align)
16 void *p = mallocalign(n, align, 0, 0);
19 panic("ialloc: out of memory");
29 for(mbp = mconf.bank; mbp < &mconf.bank[mconf.nbank]; mbp++)
30 print("bank[%ld]: base 0x%8.8lux, limit 0x%8.8lux (%.0fMB)\n",
31 mbp - mconf.bank, mbp->base, mbp->limit,
32 (mbp->limit - mbp->base)/(double)MB);
36 cmd_memory(int, char *[])
41 enum { HWIDTH = 8 }; /* buffers per hash */
44 * allocate rest of mem
57 wlock(&mainlock); /* init */
62 for(mbp = mconf.bank; mbp < &mconf.bank[mconf.nbank]; mbp++)
63 m += mbp->limit - mbp->base;
65 niob = m / (sizeof(Iobuf) + RBUFSIZE + sizeof(Hiob)/HWIDTH);
66 nhiob = niob / HWIDTH;
69 print("\t%ld buffers; %ld hashes\n", niob, nhiob);
70 hiob = ialloc(nhiob * sizeof(Hiob), 0);
72 for(i=0; i<nhiob; i++) {
77 p = ialloc(niob * sizeof(Iobuf), 0);
78 xiop = ialloc(niob * RBUFSIZE, 0);
80 for(i=0; i < niob; i++) {
100 // p->xiobuf = ialloc(RBUFSIZE, RBUFSIZE);
102 p->iobuf = (char*)-1;
108 * Make sure that no more of bank[0] can be used.
110 mconf.bank[0].base = mconf.bank[0].limit;
113 for(mbp = mconf.bank; mbp < &mconf.bank[mconf.nbank]; mbp++)
114 i += mbp->limit - mbp->base;
115 print("\tmem left = %,d, out of %,ld\n", i, conf.mem);
116 /* paranoia: add this command as late as is easy */
117 cmd_install("memory", "-- print ranges of memory banks", cmd_memory);
123 return p->iobuf = p->xiobuf;
129 p->iobuf = (char*)-1;