Changeset 3f74275 in mainline for kernel/generic/src/ipc/ipcrsc.c


Ignore:
Timestamp:
2017-08-20T16:45:01Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e68765e
Parents:
e7ac23d0
Message:

Fix terminology around capabilities, capability handles and kernel objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/ipcrsc.c

    re7ac23d0 r3f74275  
    133133#include <assert.h>
    134134#include <abi/errno.h>
    135 #include <kobject/kobject.h>
     135#include <cap/cap.h>
    136136
    137137/** Find call_t * in call table according to callid.
     
    163163}
    164164
    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.
    169169 *
    170170 * @return  Address of the phone kernel object.
     
    172172 *
    173173 */
    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)
     174phone_t *phone_get(task_t *task, int handle)
     175{
     176        cap_t *cap = cap_get(task, handle, CAP_TYPE_PHONE);
     177        if (!cap)
    178178                return NULL;
    179179       
    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
     183phone_t *phone_get_current(int handle)
     184{
     185        return phone_get(TASK, handle);
     186}
     187
     188static 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);
    194194}
    195195
     
    198198 * @param task  Task for which to allocate a new phone.
    199199 *
    200  * @return  New phone capability.
     200 * @return  New phone capability handle.
    201201 * @return  Negative error code if a new capability cannot be allocated.
    202202 */
    203203int phone_alloc(task_t *task)
    204204{
    205         int cap = kobject_alloc(task);
    206         if (cap >= 0) {
     205        int handle = cap_alloc(task);
     206        if (handle >= 0) {
    207207                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;
    213213                irq_spinlock_unlock(&task->lock, true);
    214214        }
    215215       
    216         return cap;
     216        return handle;
    217217}
    218218
     
    221221 * All already sent messages will be correctly processed.
    222222 *
    223  * @param phoneid Phone handle 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 */
     226void phone_dealloc(int handle)
     227{
     228        phone_t *phone = phone_get_current(handle);
    229229       
    230230        assert(phone);
    231231        assert(phone->state == IPC_PHONE_CONNECTING);
    232232
    233         kobject_free(TASK, cap);
     233        cap_free(TASK, handle);
    234234}
    235235
    236236/** Connect phone to a given answerbox.
    237237 *
    238  * @param cap  Phone capability to 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.
    241241 *
    242242 * The procedure _enforces_ that the user first marks the phone busy (e.g. via
     
    245245 *
    246246 */
    247 bool phone_connect(int cap, answerbox_t *box)
    248 {
    249         phone_t *phone = phone_get_current(cap);
     247bool phone_connect(int handle, answerbox_t *box)
     248{
     249        phone_t *phone = phone_get_current(handle);
    250250       
    251251        assert(phone);
Note: See TracChangeset for help on using the changeset viewer.