Lines Matching refs:cache

3  * Module Name: utcache - local cache allocation routines
55 * PARAMETERS: cache_name - Ascii name for the cache
57 * max_depth - Maximum depth of the cache (in objects)
58 * return_cache - Where the new cache object is returned
62 * DESCRIPTION: Create a cache object
70 struct acpi_memory_list *cache;
78 /* Create the cache object */
80 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
81 if (!cache) {
85 /* Populate the cache object and return it */
87 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
88 cache->list_name = cache_name;
89 cache->object_size = object_size;
90 cache->max_depth = max_depth;
92 *return_cache = cache;
100 * PARAMETERS: cache - Handle to cache object
104 * DESCRIPTION: Free all objects within the requested cache.
108 acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache)
115 if (!cache) {
124 /* Walk the list of objects in this cache */
126 while (cache->list_head) {
130 next = ACPI_GET_DESCRIPTOR_PTR(cache->list_head);
131 ACPI_FREE(cache->list_head);
133 cache->list_head = next;
134 cache->current_depth--;
145 * PARAMETERS: cache - Handle to cache object
149 * DESCRIPTION: Free all objects within the requested cache and delete the
150 * cache object.
154 acpi_status acpi_os_delete_cache(struct acpi_memory_list * cache)
160 /* Purge all objects in the cache */
162 status = acpi_os_purge_cache(cache);
167 /* Now we can delete the cache object */
169 acpi_os_free(cache);
177 * PARAMETERS: cache - Handle to cache object
182 * DESCRIPTION: Release an object to the specified cache. If cache is full,
188 acpi_os_release_object(struct acpi_memory_list * cache, void *object)
194 if (!cache || !object) {
198 /* If cache is full, just free this object */
200 if (cache->current_depth >= cache->max_depth) {
202 ACPI_MEM_TRACKING(cache->total_freed++);
205 /* Otherwise put this object back into the cache */
215 ACPI_MEMSET(object, 0xCA, cache->object_size);
218 /* Put the object at the head of the cache list */
220 ACPI_SET_DESCRIPTOR_PTR(object, cache->list_head);
221 cache->list_head = object;
222 cache->current_depth++;
234 * PARAMETERS: cache - Handle to cache object
238 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
243 void *acpi_os_acquire_object(struct acpi_memory_list *cache)
250 if (!cache) {
259 ACPI_MEM_TRACKING(cache->requests++);
261 /* Check the cache first */
263 if (cache->list_head) {
267 object = cache->list_head;
268 cache->list_head = ACPI_GET_DESCRIPTOR_PTR(object);
270 cache->current_depth--;
272 ACPI_MEM_TRACKING(cache->hits++);
274 "Object %p from %s cache\n", object,
275 cache->list_name));
284 ACPI_MEMSET(object, 0, cache->object_size);
286 /* The cache is empty, create a new object */
288 ACPI_MEM_TRACKING(cache->total_allocated++);
291 if ((cache->total_allocated - cache->total_freed) >
292 cache->max_occupied) {
293 cache->max_occupied =
294 cache->total_allocated - cache->total_freed;
305 object = ACPI_ALLOCATE_ZEROED(cache->object_size);