2 * Copyright (c) 1997, 1998 John S. Dyson
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice immediately at the beginning of the file, without modification,
10 * this list of conditions, and the following disclaimer.
11 * 2. Absolutely no warranty of function or purpose is made by the author
14 * $FreeBSD: src/sys/vm/vm_zone.h,v 1.13.2.2 2002/10/10 19:50:16 dillon Exp $
15 * $DragonFly: src/sys/vm/vm_zone.h,v 1.10 2008/01/21 20:21:19 nth Exp $
18 #ifndef _VM_VM_ZONE_H_
19 #define _VM_VM_ZONE_H_
21 #define ZONE_INTERRUPT 0x0001 /* If you need to allocate at int time */
22 #define ZONE_PANICFAIL 0x0002 /* panic if the zalloc fails */
23 #define ZONE_SPECIAL 0x0004 /* special vm_map_entry zone, see zget() */
24 #define ZONE_BOOT 0x0010 /* Internal flag used by zbootinit */
25 #define ZONE_USE_RESERVE 0x0020 /* use reserve memory if necessary */
26 #define ZONE_DESTROYABLE 0x0040 /* can be zdestroy()'ed */
28 #include <sys/spinlock.h>
29 #include <sys/thread.h>
33 * Zones are deprecated, use <sys/objcache.h> instead for new developments.
34 * Zones are not thread-safe; the mp lock must be held while calling
37 typedef struct vm_zone
{
38 struct spinlock zlock
; /* lock for data structure */
39 void *zitems
; /* linked list of items */
40 int zfreecnt
; /* free entries */
41 int zfreemin
; /* minimum number of free entries */
42 int znalloc
; /* number of allocations */
43 vm_offset_t zkva
; /* Base kva of zone */
44 int zpagecount
; /* Total # of allocated pages */
45 int zpagemax
; /* Max address space */
46 int zmax
; /* Max number of entries allocated */
47 int ztotal
; /* Total entries allocated now */
48 int zsize
; /* size of each entry */
49 int zalloc
; /* hint for # of pages to alloc */
50 int zflags
; /* flags for zone */
51 int zallocflag
; /* flag for allocation */
52 struct vm_object
*zobj
; /* object to hold zone */
53 char *zname
; /* name for diags */
54 LIST_ENTRY(vm_zone
) zlink
; /* link in zlist */
56 * The following fields track kmem_alloc()'ed blocks when
57 * ZONE_DESTROYABLE set and normal zone (i.e. not ZONE_INTERRUPT nor
60 vm_offset_t
*zkmvec
; /* krealloc()'ed array */
61 int zkmcur
; /* next free slot in zkmvec */
62 int zkmmax
; /* # of slots in zkmvec */
66 void zerror (int) __dead2
;
67 vm_zone_t
zinit (char *name
, int size
, int nentries
, int flags
,
69 int zinitna (vm_zone_t z
, struct vm_object
*obj
, char *name
,
70 int size
, int nentries
, int flags
, int zalloc
);
71 void * zalloc (vm_zone_t z
);
72 void zfree (vm_zone_t z
, void *item
);
73 void zbootinit (vm_zone_t z
, char *name
, int size
, void *item
,
75 void zdestroy(vm_zone_t z
);
77 #endif /* _VM_VM_ZONE_H_ */