Changeset 3f74275 in mainline for kernel/generic/src/ipc/ipcrsc.c
- Timestamp:
- 2017-08-20T16:45:01Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e68765e
- Parents:
- e7ac23d0
- File:
-
- 1 edited
-
kernel/generic/src/ipc/ipcrsc.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/ipcrsc.c
re7ac23d0 r3f74275 133 133 #include <assert.h> 134 134 #include <abi/errno.h> 135 #include < kobject/kobject.h>135 #include <cap/cap.h> 136 136 137 137 /** Find call_t * in call table according to callid. … … 163 163 } 164 164 165 /** Get phone from the current task by capability .166 * 167 * @param cap Phone capability.168 * @param phone Place to store pointer to phone.165 /** Get phone from the current task by capability handle. 166 * 167 * @param handle Phone capability handle. 168 * @param phone Place to store pointer to phone. 169 169 * 170 170 * @return Address of the phone kernel object. … … 172 172 * 173 173 */ 174 phone_t *phone_get(task_t *task, int cap)175 { 176 kobject_t *kobj = kobject_get(task, cap, KOBJECT_TYPE_PHONE);177 if (! kobj)174 phone_t *phone_get(task_t *task, int handle) 175 { 176 cap_t *cap = cap_get(task, handle, CAP_TYPE_PHONE); 177 if (!cap) 178 178 return NULL; 179 179 180 return & kobj->phone;181 } 182 183 phone_t *phone_get_current(int cap)184 { 185 return phone_get(TASK, cap);186 } 187 188 static bool phone_can_reclaim( kobject_t *kobj)189 { 190 assert( kobj->type == KOBJECT_TYPE_PHONE);191 192 return ( kobj->phone.state == IPC_PHONE_HUNGUP) &&193 (atomic_get(& kobj->phone.active_calls) == 0);180 return &cap->phone; 181 } 182 183 phone_t *phone_get_current(int handle) 184 { 185 return phone_get(TASK, handle); 186 } 187 188 static bool phone_can_reclaim(cap_t *cap) 189 { 190 assert(cap->type == CAP_TYPE_PHONE); 191 192 return (cap->phone.state == IPC_PHONE_HUNGUP) && 193 (atomic_get(&cap->phone.active_calls) == 0); 194 194 } 195 195 … … 198 198 * @param task Task for which to allocate a new phone. 199 199 * 200 * @return New phone capability .200 * @return New phone capability handle. 201 201 * @return Negative error code if a new capability cannot be allocated. 202 202 */ 203 203 int phone_alloc(task_t *task) 204 204 { 205 int cap = kobject_alloc(task);206 if ( cap>= 0) {205 int handle = cap_alloc(task); 206 if (handle >= 0) { 207 207 irq_spinlock_lock(&task->lock, true); 208 kobject_t *kobj = &task->kobject[cap];209 ipc_phone_init(& kobj->phone, task);210 kobj->type = KOBJECT_TYPE_PHONE;211 kobj->can_reclaim = phone_can_reclaim;212 kobj->phone.state = IPC_PHONE_CONNECTING;208 cap_t *cap = &task->caps[handle]; 209 ipc_phone_init(&cap->phone, task); 210 cap->type = CAP_TYPE_PHONE; 211 cap->can_reclaim = phone_can_reclaim; 212 cap->phone.state = IPC_PHONE_CONNECTING; 213 213 irq_spinlock_unlock(&task->lock, true); 214 214 } 215 215 216 return cap;216 return handle; 217 217 } 218 218 … … 221 221 * All already sent messages will be correctly processed. 222 222 * 223 * @param phoneid Phonehandle of the phone to be freed.224 * 225 */ 226 void phone_dealloc(int cap)227 { 228 phone_t *phone = phone_get_current( cap);223 * @param handle Phone capability handle of the phone to be freed. 224 * 225 */ 226 void phone_dealloc(int handle) 227 { 228 phone_t *phone = phone_get_current(handle); 229 229 230 230 assert(phone); 231 231 assert(phone->state == IPC_PHONE_CONNECTING); 232 232 233 kobject_free(TASK, cap);233 cap_free(TASK, handle); 234 234 } 235 235 236 236 /** Connect phone to a given answerbox. 237 237 * 238 * @param cap Phone capabilityto be connected.239 * @param box Answerbox to which to connect the phone capability.240 * @return True if the phone was connected, false otherwise.238 * @param handle Capability handle of the phone to be connected. 239 * @param box Answerbox to which to connect the phone. 240 * @return True if the phone was connected, false otherwise. 241 241 * 242 242 * The procedure _enforces_ that the user first marks the phone busy (e.g. via … … 245 245 * 246 246 */ 247 bool phone_connect(int cap, answerbox_t *box)248 { 249 phone_t *phone = phone_get_current( cap);247 bool phone_connect(int handle, answerbox_t *box) 248 { 249 phone_t *phone = phone_get_current(handle); 250 250 251 251 assert(phone);
Note:
See TracChangeset
for help on using the changeset viewer.
