/* * bauble: a tiny room-based messaging system. * * zone.h: header information for zoned virtual memory * * virtual memory is implemented as a series of chunks, 64 bytes each, * with a header-block that's a bitmap of all the addressable virtual * memory (bits set represent used blocks.) Used blocks have a 4-byte * header on them that gives the number of chunks that are allocated * in that block, plus a magic number for vfree() validation. vmalloc * scans the bitmap to find enough contiguous chunks to give back, so * no other header information is needed. */ #ifndef _ZONE_H #define _ZONE_H #include /* for CHAR_BITS definition */ #define ZSIZE 64 /* memory chunksize */ #define ZMAP 512 /* # words in zonemap */ #define ZTOC (ZMAP*sizeof(zonemap[0])) /* # bytes in swapfile*/ #define SZONES (ZTOC*CHAR_BIT) /* # zones in zonemap */ #define SBITS (CHAR_BIT*sizeof(zonemap[0])) /* # bits per short */ extern unsigned short zonemap[ZMAP]; /* bitmap of allocated/free memory */ typedef struct { /* zone header block */ short z_magic; /* magic number (0x42) */ short z_segs; /* # blocks occupied by used zone */ } zoneheader; #define Z_MAGIC 0x42 /* magic number for zone headers */ /* a couple of semi-handy macros */ #define Zbit(x) (1<<(x%SBITS)) #define Zvalid(x) ((x%ZSIZE) == sizeof(zoneheader)) #define Zisfree(x) ((zonemap[x/SBITS] & Zbit(x)) == 0) #define Zfree(x) (zonemap[x/SBITS] &= ~Zbit(x)) #define Zalloc(x) (zonemap[x/SBITS] |= Zbit(x)) extern int swapdev; /* the vm swapfile */ #endif /*_ZONE_H*/