Annotation of XNU/osfmk/kern/zalloc.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /*
        !            23:  * @OSF_COPYRIGHT@
        !            24:  */
        !            25: /* 
        !            26:  * Mach Operating System
        !            27:  * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
        !            28:  * All Rights Reserved.
        !            29:  * 
        !            30:  * Permission to use, copy, modify and distribute this software and its
        !            31:  * documentation is hereby granted, provided that both the copyright
        !            32:  * notice and this permission notice appear in all copies of the
        !            33:  * software, derivative works or modified versions, and any portions
        !            34:  * thereof, and that both notices appear in supporting documentation.
        !            35:  * 
        !            36:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            37:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            38:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            39:  * 
        !            40:  * Carnegie Mellon requests users of this software to return to
        !            41:  * 
        !            42:  *  Software Distribution Coordinator  or  [email protected]
        !            43:  *  School of Computer Science
        !            44:  *  Carnegie Mellon University
        !            45:  *  Pittsburgh PA 15213-3890
        !            46:  * 
        !            47:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            48:  * the rights to redistribute these changes.
        !            49:  */
        !            50: /*
        !            51:  */
        !            52: /*
        !            53:  *     File:   zalloc.h
        !            54:  *     Author: Avadis Tevanian, Jr.
        !            55:  *     Date:    1985
        !            56:  *
        !            57:  */
        !            58: 
        !            59: #ifndef        _KERN_ZALLOC_H_
        !            60: #define _KERN_ZALLOC_H_
        !            61: 
        !            62: #include <mach/machine/vm_types.h>
        !            63: #include <kern/kern_types.h>
        !            64: 
        !            65: #ifdef MACH_KERNEL_PRIVATE
        !            66: #include <zone_debug.h>
        !            67: #include <mach_kdb.h>
        !            68: #include <kern/lock.h>
        !            69: #include <kern/queue.h>
        !            70: 
        !            71: /*
        !            72:  *     A zone is a collection of fixed size blocks for which there
        !            73:  *     is fast allocation/deallocation access.  Kernel routines can
        !            74:  *     use zones to manage data structures dynamically, creating a zone
        !            75:  *     for each type of data structure to be managed.
        !            76:  *
        !            77:  */
        !            78: 
        !            79: struct zone {
        !            80:        int             count;          /* Number of elements used now */
        !            81:        vm_offset_t     free_elements;
        !            82:        vm_size_t       cur_size;       /* current memory utilization */
        !            83:        vm_size_t       max_size;       /* how large can this zone grow */
        !            84:        vm_size_t       elem_size;      /* size of an element */
        !            85:        vm_size_t       alloc_size;     /* size used for more memory */
        !            86:        char            *zone_name;     /* a name for the zone */
        !            87:        unsigned int
        !            88:        /* boolean_t */ exhaustible :1, /* (F) merely return if empty? */
        !            89:        /* boolean_t */ collectable :1, /* (F) garbage collect empty pages */
        !            90:        /* boolean_t */ expandable :1,  /* (T) expand zone (with message)? */
        !            91:        /* boolean_t */ allows_foreign :1,/* (F) allow non-zalloc space */
        !            92:        /* boolean_t */ doing_alloc :1, /* is zone expanding now? */
        !            93:        /* boolean_t */ waiting :1;     /* is thread waiting for expansion? */
        !            94:        struct zone *   next_zone;      /* Link for all-zones list */
        !            95: #if    ZONE_DEBUG
        !            96:        queue_head_t    active_zones;   /* active elements */
        !            97: #endif /* ZONE_DEBUG */
        !            98:        decl_simple_lock_data(,lock)            /* generic lock */
        !            99: };
        !           100: 
        !           101: 
        !           102: extern void            zone_gc(void);
        !           103: extern void            consider_zone_gc(void);
        !           104: 
        !           105: /* Steal memory for zone module */
        !           106: extern void            zone_steal_memory(void);
        !           107: 
        !           108: /* Bootstrap zone module (create zone zone) */
        !           109: extern void            zone_bootstrap(void);
        !           110: 
        !           111: /* Init zone module */
        !           112: extern void            zone_init(vm_size_t);
        !           113: 
        !           114: #endif /* ! MACH_KERNEL_PRIVATE */
        !           115: 
        !           116: 
        !           117: /* Allocate from zone */
        !           118: extern vm_offset_t     zalloc(
        !           119:                                zone_t          zone);
        !           120: 
        !           121: /* Get from zone free list */
        !           122: extern vm_offset_t     zget(
        !           123:                                zone_t          zone);
        !           124: 
        !           125: /* Create zone */
        !           126: extern zone_t          zinit(
        !           127:                                vm_size_t       size,           /* the size of an element */
        !           128:                                vm_size_t       max,            /* maximum memory to use */
        !           129:                                vm_size_t       alloc,          /* allocation size */
        !           130:                                char            *name);         /* a name for the zone */
        !           131: 
        !           132: /* Free zone element */
        !           133: extern void            zfree(
        !           134:                                zone_t          zone,
        !           135:                                vm_offset_t     elem);
        !           136: 
        !           137: /* Fill zone with memory */
        !           138: extern void            zcram(
        !           139:                                zone_t          zone,
        !           140:                                vm_offset_t     newmem,
        !           141:                                vm_size_t       size);
        !           142: 
        !           143: /* Initially fill zone with specified number of elements */
        !           144: extern int             zfill(
        !           145:                                zone_t          zone,
        !           146:                                int             nelem);
        !           147: /* Change zone parameters */
        !           148: extern void            zone_change(
        !           149:                                zone_t          zone,
        !           150:                                unsigned int    item,
        !           151:                                boolean_t       value);
        !           152: 
        !           153: /* Preallocate space for zone from zone map */
        !           154: extern void            zprealloc(
        !           155:                                zone_t          zone,
        !           156:                                vm_size_t       size);
        !           157: 
        !           158: /*
        !           159:  * zone_free_count returns a hint as to the current number of free elements
        !           160:  * in the zone.  By the time it returns, it may no longer be true (a new
        !           161:  * element might have been added, or an element removed).
        !           162:  * This routine may be used in conjunction with zcram and a lock to regulate
        !           163:  * adding memory to a non-expandable zone.
        !           164:  */
        !           165: extern integer_t              zone_free_count(zone_t zone);
        !           166: 
        !           167: /*
        !           168:  * Item definitions for zone_change:
        !           169:  */
        !           170: #define Z_EXHAUST      1       /* Make zone exhaustible        */
        !           171: #define Z_COLLECT      2       /* Make zone collectable        */
        !           172: #define Z_EXPAND       3       /* Make zone expandable         */
        !           173: #define        Z_FOREIGN       4       /* Allow collectable zone to contain foreign */
        !           174:                                /* (not allocated via zalloc) elements. */
        !           175: #ifdef MACH_KERNEL_PRIVATE
        !           176: #if    ZONE_DEBUG
        !           177: #if    MACH_KDB
        !           178: extern vm_offset_t     next_element(
        !           179:                                zone_t          z,
        !           180:                                vm_offset_t     elt);
        !           181: 
        !           182: extern vm_offset_t     first_element(
        !           183:                                zone_t          z);
        !           184: #endif /* MACH_KDB */
        !           185: extern void            zone_debug_enable(
        !           186:                                zone_t          z);
        !           187: 
        !           188: extern void            zone_debug_disable(
        !           189:                                zone_t          z);
        !           190: #endif /* ZONE_DEBUG */
        !           191: #endif MACH_KERNEL_PRIVATE
        !           192: 
        !           193: #endif /* _KERN_ZALLOC_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.