Changeset 9fc776c7 in mainline
- Timestamp:
- 2018-03-13T18:01:47Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- df1cbb3
- Parents:
- b127e4af
- git-author:
- Jakub Jermar <jakub@…> (2017-12-07 12:14:09)
- git-committer:
- Jakub Jermar <jakub@…> (2018-03-13 18:01:47)
- Location:
- kernel/generic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/cap/cap.h
rb127e4af r9fc776c7 64 64 struct phone; 65 65 66 struct kobject;67 66 typedef struct kobject_ops { 68 bool (*reclaim)(struct kobject *);69 67 void (*destroy)(void *); 70 68 } kobject_ops_t; -
kernel/generic/src/cap/cap.c
rb127e4af r9fc776c7 235 235 } 236 236 237 static bool cap_reclaimer(ht_link_t *link, void *arg)238 {239 cap_t **result = (cap_t **) arg;240 cap_t *cap = hash_table_get_inst(link, cap_t, caps_link);241 242 if (cap->state == CAP_STATE_PUBLISHED && cap->kobject->ops->reclaim &&243 cap->kobject->ops->reclaim(cap->kobject)) {244 kobject_t *kobj = cap_unpublish(cap->task, cap->handle,245 cap->kobject->type);246 kobject_put(kobj);247 cap_initialize(cap, cap->task, cap->handle);248 *result = cap;249 return false;250 }251 252 return true;253 }254 255 237 /** Allocate new capability 256 238 * … … 263 245 errno_t cap_alloc(task_t *task, cap_handle_t *handle) 264 246 { 265 cap_t *cap = NULL; 266 267 /* 268 * First of all, see if we can reclaim a capability. Note that this 269 * feature is only temporary and capability reclamaition will eventually 270 * be phased out. 271 */ 272 mutex_lock(&task->cap_info->lock); 273 hash_table_apply(&task->cap_info->caps, cap_reclaimer, &cap); 274 275 /* 276 * If we don't have a capability by now, try to allocate a new one. 277 */ 247 mutex_lock(&task->cap_info->lock); 248 cap_t *cap = slab_alloc(cap_cache, FRAME_ATOMIC); 278 249 if (!cap) { 279 cap = slab_alloc(cap_cache, FRAME_ATOMIC); 280 if (!cap) { 281 mutex_unlock(&task->cap_info->lock); 282 return ENOMEM; 283 } 284 uintptr_t hbase; 285 if (!ra_alloc(task->cap_info->handles, 1, 1, &hbase)) { 286 slab_free(cap_cache, cap); 287 mutex_unlock(&task->cap_info->lock); 288 return ENOMEM; 289 } 290 cap_initialize(cap, task, (cap_handle_t) hbase); 291 hash_table_insert(&task->cap_info->caps, &cap->caps_link); 292 } 250 mutex_unlock(&task->cap_info->lock); 251 return ENOMEM; 252 } 253 uintptr_t hbase; 254 if (!ra_alloc(task->cap_info->handles, 1, 1, &hbase)) { 255 slab_free(cap_cache, cap); 256 mutex_unlock(&task->cap_info->lock); 257 return ENOMEM; 258 } 259 cap_initialize(cap, task, (cap_handle_t) hbase); 260 hash_table_insert(&task->cap_info->caps, &cap->caps_link); 293 261 294 262 cap->state = CAP_STATE_ALLOCATED; -
kernel/generic/src/ipc/ipcrsc.c
rb127e4af r9fc776c7 137 137 #include <mm/slab.h> 138 138 139 static bool phone_reclaim(kobject_t *kobj)140 {141 bool gc = false;142 143 mutex_lock(&kobj->phone->lock);144 if (kobj->phone->state == IPC_PHONE_HUNGUP &&145 atomic_get(&kobj->phone->active_calls) == 0)146 gc = true;147 mutex_unlock(&kobj->phone->lock);148 149 return gc;150 }151 152 139 static void phone_destroy(void *arg) 153 140 { … … 157 144 158 145 static kobject_ops_t phone_kobject_ops = { 159 .reclaim = phone_reclaim,160 146 .destroy = phone_destroy 161 147 };
Note:
See TracChangeset
for help on using the changeset viewer.