Changes in kernel/generic/src/cap/cap.c [82d515e9:c1f68b0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/cap/cap.c
r82d515e9 rc1f68b0 41 41 * A kernel object (kobject_t) encapsulates one of the following raw objects: 42 42 * 43 * - IPC call44 43 * - IPC phone 45 44 * - IRQ object … … 74 73 75 74 #include <cap/cap.h> 76 #include <abi/cap.h>77 75 #include <proc/task.h> 78 76 #include <synch/mutex.h> … … 83 81 #include <stdint.h> 84 82 85 #define CAPS_START (CAP_NIL + 1) 86 #define CAPS_SIZE (INT_MAX - CAPS_START) 87 #define CAPS_LAST (CAPS_SIZE - 1) 88 89 static slab_cache_t *cap_cache; 83 #define MAX_CAPS INT_MAX 84 85 static slab_cache_t *cap_slab; 90 86 91 87 static size_t caps_hash(const ht_link_t *item) … … 116 112 void caps_init(void) 117 113 { 118 cap_ cache= slab_cache_create("cap_t", sizeof(cap_t), 0, NULL,114 cap_slab = slab_cache_create("cap_t", sizeof(cap_t), 0, NULL, 119 115 NULL, 0); 120 116 } … … 133 129 if (!task->cap_info->handles) 134 130 goto error_handles; 135 if (!ra_span_add(task->cap_info->handles, CAPS_START, CAPS_SIZE))131 if (!ra_span_add(task->cap_info->handles, 0, MAX_CAPS)) 136 132 goto error_span; 137 133 if (!hash_table_create(&task->cap_info->caps, 0, 0, &caps_ops)) … … 224 220 assert(mutex_locked(&task->cap_info->lock)); 225 221 226 if ((handle < CAPS_START) || (handle > CAPS_LAST))222 if ((handle < 0) || (handle >= MAX_CAPS)) 227 223 return NULL; 228 224 ht_link_t *link = hash_table_find(&task->cap_info->caps, &handle); … … 277 273 */ 278 274 if (!cap) { 279 cap = slab_alloc(cap_ cache, FRAME_ATOMIC);275 cap = slab_alloc(cap_slab, FRAME_ATOMIC); 280 276 if (!cap) { 281 277 mutex_unlock(&task->cap_info->lock); … … 284 280 uintptr_t hbase; 285 281 if (!ra_alloc(task->cap_info->handles, 1, 1, &hbase)) { 286 slab_free(cap_ cache, cap);282 slab_free(cap_slab, cap); 287 283 mutex_unlock(&task->cap_info->lock); 288 284 return ENOMEM; … … 361 357 void cap_free(task_t *task, cap_handle_t handle) 362 358 { 363 assert(handle >= CAPS_START);364 assert(handle < = CAPS_LAST);359 assert(handle >= 0); 360 assert(handle < MAX_CAPS); 365 361 366 362 mutex_lock(&task->cap_info->lock); … … 371 367 hash_table_remove_item(&task->cap_info->caps, &cap->caps_link); 372 368 ra_free(task->cap_info->handles, handle, 1); 373 slab_free(cap_ cache, cap);369 slab_free(cap_slab, cap); 374 370 mutex_unlock(&task->cap_info->lock); 375 371 }
Note:
See TracChangeset
for help on using the changeset viewer.