Lines Matching defs:cache

4  * Module Name: utcache - local cache allocation routines
21 * PARAMETERS: cache_name - Ascii name for the cache
23 * max_depth - Maximum depth of the cache (in objects)
24 * return_cache - Where the new cache object is returned
28 * DESCRIPTION: Create a cache object
36 struct acpi_memory_list *cache;
44 /* Create the cache object */
46 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
47 if (!cache) {
51 /* Populate the cache object and return it */
53 memset(cache, 0, sizeof(struct acpi_memory_list));
54 cache->list_name = cache_name;
55 cache->object_size = object_size;
56 cache->max_depth = max_depth;
58 *return_cache = cache;
66 * PARAMETERS: cache - Handle to cache object
70 * DESCRIPTION: Free all objects within the requested cache.
74 acpi_status acpi_os_purge_cache(struct acpi_memory_list *cache)
81 if (!cache) {
90 /* Walk the list of objects in this cache */
92 while (cache->list_head) {
96 next = ACPI_GET_DESCRIPTOR_PTR(cache->list_head);
97 ACPI_FREE(cache->list_head);
99 cache->list_head = next;
100 cache->current_depth--;
111 * PARAMETERS: cache - Handle to cache object
115 * DESCRIPTION: Free all objects within the requested cache and delete the
116 * cache object.
120 acpi_status acpi_os_delete_cache(struct acpi_memory_list *cache)
126 /* Purge all objects in the cache */
128 status = acpi_os_purge_cache(cache);
133 /* Now we can delete the cache object */
135 acpi_os_free(cache);
143 * PARAMETERS: cache - Handle to cache object
148 * DESCRIPTION: Release an object to the specified cache. If cache is full,
153 acpi_status acpi_os_release_object(struct acpi_memory_list *cache, void *object)
159 if (!cache || !object) {
163 /* If cache is full, just free this object */
165 if (cache->current_depth >= cache->max_depth) {
167 ACPI_MEM_TRACKING(cache->total_freed++);
170 /* Otherwise put this object back into the cache */
180 memset(object, 0xCA, cache->object_size);
183 /* Put the object at the head of the cache list */
185 ACPI_SET_DESCRIPTOR_PTR(object, cache->list_head);
186 cache->list_head = object;
187 cache->current_depth++;
199 * PARAMETERS: cache - Handle to cache object
203 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
208 void *acpi_os_acquire_object(struct acpi_memory_list *cache)
215 if (!cache) {
224 ACPI_MEM_TRACKING(cache->requests++);
226 /* Check the cache first */
228 if (cache->list_head) {
232 object = cache->list_head;
233 cache->list_head = ACPI_GET_DESCRIPTOR_PTR(object);
235 cache->current_depth--;
237 ACPI_MEM_TRACKING(cache->hits++);
239 "%s: Object %p from %s cache\n",
241 cache->list_name));
250 memset(object, 0, cache->object_size);
252 /* The cache is empty, create a new object */
254 ACPI_MEM_TRACKING(cache->total_allocated++);
257 if ((cache->total_allocated - cache->total_freed) >
258 cache->max_occupied) {
259 cache->max_occupied =
260 cache->total_allocated - cache->total_freed;
271 object = ACPI_ALLOCATE_ZEROED(cache->object_size);