Changeset 63d8f43 in mainline
- Timestamp:
- 2017-09-04T19:38:28Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fa32c9f
- Parents:
- 30c27e9
- Location:
- kernel/generic
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/cap/cap.h
r30c27e9 r63d8f43 38 38 #include <typedefs.h> 39 39 #include <ipc/ipc.h> 40 #include <ddi/irq.h>41 40 42 41 #define MAX_CAPS 64 … … 64 63 65 64 /* The underlying kernel object. */ 66 union { 67 phone_t phone; 68 irq_t irq; 69 }; 65 void *kobject; 70 66 } cap_t; 71 67 -
kernel/generic/src/cap/cap.c
r30c27e9 r63d8f43 102 102 assert(handle >= 0); 103 103 assert(handle < MAX_CAPS); 104 assert(task->caps[handle].type != CAP_TYPE_INVALID);104 assert(task->caps[handle].type == CAP_TYPE_ALLOCATED); 105 105 106 106 irq_spinlock_lock(&task->lock, true); -
kernel/generic/src/ipc/ipc.c
r30c27e9 r63d8f43 743 743 all_clean = true; 744 744 for_each_cap_current(cap, CAP_TYPE_PHONE) { 745 phone_t *phone = &cap->phone;745 phone_t *phone = (phone_t *) cap->kobject; 746 746 747 747 mutex_lock(&phone->lock); … … 820 820 /* Disconnect all our phones ('ipc_phone_hangup') */ 821 821 for_each_cap_current(cap, CAP_TYPE_PHONE) { 822 phone_t *phone = &cap->phone;822 phone_t *phone = (phone_t *) cap->kobject; 823 823 ipc_phone_hangup(phone); 824 824 } … … 913 913 914 914 for_each_cap(task, cap, CAP_TYPE_PHONE) { 915 phone_t *phone = &cap->phone;915 phone_t *phone = (phone_t *) cap->kobject; 916 916 917 917 if (SYNCH_FAILED(mutex_trylock(&phone->lock))) { -
kernel/generic/src/ipc/ipcrsc.c
r30c27e9 r63d8f43 135 135 #include <abi/errno.h> 136 136 #include <cap/cap.h> 137 #include <mm/slab.h> 137 138 138 139 /** Find call_t * in call table according to callid. … … 178 179 return NULL; 179 180 180 return &cap->phone;181 return (phone_t *) cap->kobject; 181 182 } 182 183 … … 190 191 assert(cap->type == CAP_TYPE_PHONE); 191 192 192 return (cap->phone.state == IPC_PHONE_HUNGUP) && 193 (atomic_get(&cap->phone.active_calls) == 0); 193 phone_t *phone = (phone_t *) cap->kobject; 194 195 return (phone->state == IPC_PHONE_HUNGUP) && 196 (atomic_get(&phone->active_calls) == 0); 194 197 } 195 198 … … 205 208 int handle = cap_alloc(task); 206 209 if (handle >= 0) { 210 phone_t *phone = malloc(sizeof(phone_t), FRAME_ATOMIC); 211 if (!phone) { 212 cap_free(TASK, handle); 213 return ENOMEM; 214 } 215 216 ipc_phone_init(phone, task); 217 phone->state = IPC_PHONE_CONNECTING; 218 207 219 irq_spinlock_lock(&task->lock, true); 208 220 cap_t *cap = cap_get(task, handle, CAP_TYPE_ALLOCATED); 209 ipc_phone_init(&cap->phone, task);210 221 cap->type = CAP_TYPE_PHONE; 222 cap->kobject = (void *) phone; 211 223 cap->can_reclaim = phone_can_reclaim; 212 cap->phone.state = IPC_PHONE_CONNECTING;213 224 irq_spinlock_unlock(&task->lock, true); 214 225 } … … 226 237 void phone_dealloc(int handle) 227 238 { 228 phone_t *phone = phone_get_current(handle); 239 irq_spinlock_lock(&TASK->lock, true); 240 cap_t *cap = cap_get_current(handle, CAP_TYPE_PHONE); 241 assert(cap); 242 cap->type = CAP_TYPE_ALLOCATED; 243 irq_spinlock_unlock(&TASK->lock, true); 244 245 phone_t *phone = (phone_t *) cap->kobject; 229 246 230 247 assert(phone); 231 248 assert(phone->state == IPC_PHONE_CONNECTING); 232 249 250 free(phone); 233 251 cap_free(TASK, handle); 234 252 } -
kernel/generic/src/ipc/irq.c
r30c27e9 r63d8f43 307 307 if (handle < 0) 308 308 return handle; 309 310 irq_t *irq = (irq_t *) malloc(sizeof(irq_t), FRAME_ATOMIC); 311 if (!irq) { 312 cap_free(TASK, handle); 313 return ENOMEM; 314 } 315 309 316 cap_t *cap = cap_get_current(handle, CAP_TYPE_ALLOCATED); 310 317 assert(cap); 311 318 312 irq_t *irq = &cap->irq;313 319 irq_initialize(irq); 314 320 irq->inr = inr; … … 321 327 irq->notif_cfg.counter = 0; 322 328 329 cap->kobject = (void *) irq; 330 323 331 /* 324 332 * Insert the IRQ structure into the uspace IRQ hash table and retype … … 359 367 irq_spinlock_unlock(&TASK->lock, true); 360 368 361 irq_t *irq = &cap->irq;369 irq_t *irq = (irq_t *) cap->kobject; 362 370 363 371 irq_spinlock_lock(&irq_uspace_hash_table_lock, true); … … 376 384 377 385 /* Free up the IRQ capability and the underlying kernel object. */ 386 free(cap->kobject); 378 387 cap_free(TASK, handle); 379 388 -
kernel/generic/src/proc/task.c
r30c27e9 r63d8f43 625 625 if (*additional) { 626 626 for_each_cap(task, cap, CAP_TYPE_PHONE) { 627 phone_t *phone = &cap->phone;627 phone_t *phone = (void *) &cap->kobject; 628 628 if (phone->callee) 629 629 printf(" %d:%p", cap->handle, phone->callee);
Note:
See TracChangeset
for help on using the changeset viewer.