Changeset 569a51a in mainline


Ignore:
Timestamp:
2017-12-08T21:17:27Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0016674
Parents:
071a1ddb
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-07 16:35:29)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-08 21:17:27)
Message:

Return phone handle in SYS_IPC_CONNECT_KBOX separately from error code.

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ipc/kbox.h

    r071a1ddb r569a51a  
    5050} kbox_t;
    5151
    52 extern int ipc_connect_kbox(task_id_t);
     52extern int ipc_connect_kbox(task_id_t, cap_handle_t *);
    5353extern void ipc_kbox_cleanup(void);
    5454
  • kernel/generic/include/ipc/sysipc.h

    r071a1ddb r569a51a  
    6161#ifdef __32_BITS__
    6262
    63 extern sysarg_t sys_ipc_connect_kbox(sysarg64_t *);
     63extern sysarg_t sys_ipc_connect_kbox(sysarg64_t *, cap_handle_t *);
    6464
    6565#endif  /* __32_BITS__ */
     
    6767#ifdef __64_BITS__
    6868
    69 extern sysarg_t sys_ipc_connect_kbox(sysarg_t);
     69extern sysarg_t sys_ipc_connect_kbox(sysarg_t, cap_handle_t *);
    7070
    7171#endif  /* __64_BITS__ */
  • kernel/generic/src/ipc/kbox.c

    r071a1ddb r569a51a  
    206206 * cleanup code.
    207207 *
    208  * @return Phone capability handle on success, or negative error code.
    209  *
    210  */
    211 int ipc_connect_kbox(task_id_t taskid)
     208 * @param[out] out_phone  Phone capability handle on success.
     209 * @return Error code.
     210 *
     211 */
     212int ipc_connect_kbox(task_id_t taskid, cap_handle_t *out_phone)
    212213{
    213214        irq_spinlock_lock(&tasks_lock, true);
     
    250251        if (task->kb.thread != NULL) {
    251252                mutex_unlock(&task->kb.cleanup_lock);
    252                 return phone_handle;
     253                *out_phone = phone_handle;
     254                return EOK;
    253255        }
    254256       
     
    257259            THREAD_FLAG_NONE, "kbox");
    258260        if (!kb_thread) {
     261                // FIXME: Shouldn't we clean up phone_handle?
    259262                mutex_unlock(&task->kb.cleanup_lock);
    260263                return ENOMEM;
     
    266269        mutex_unlock(&task->kb.cleanup_lock);
    267270       
    268         return phone_handle;
     271        *out_phone = phone_handle;
     272        return EOK;
    269273}
    270274
  • kernel/generic/src/ipc/sysipc.c

    r071a1ddb r569a51a  
    901901/** Syscall connect to a task by ID (32 bits)
    902902 *
    903  * @return Phone id on success, or negative error code.
    904  *
    905  */
    906 sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid)
     903 * @return Error code.
     904 *
     905 */
     906sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid, cap_handle_t *uspace_phone)
    907907{
    908908#ifdef CONFIG_UDEBUG
    909909        sysarg64_t taskid;
     910        cap_handle_t phone;
    910911        int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(sysarg64_t));
    911         if (rc != 0)
    912                 return (sysarg_t) rc;
    913        
    914         return ipc_connect_kbox((task_id_t) taskid);
     912        if (rc == EOK) {
     913                rc = ipc_connect_kbox((task_id_t) taskid, &phone);
     914        }
     915        if (rc == EOK) {
     916                rc = copy_to_uspace(uspace_phone, &phone, sizeof(cap_handle_t));
     917                // FIXME: Clean up phone on failure.
     918        }
     919       
     920        return (sysarg_t) rc;
    915921#else
    916922        return (sysarg_t) ENOTSUP;
     
    924930/** Syscall connect to a task by ID (64 bits)
    925931 *
    926  * @return Phone id on success, or negative error code.
    927  *
    928  */
    929 sysarg_t sys_ipc_connect_kbox(sysarg_t taskid)
     932 * @return Error code.
     933 *
     934 */
     935sysarg_t sys_ipc_connect_kbox(sysarg_t taskid, cap_handle_t *uspace_phone)
    930936{
    931937#ifdef CONFIG_UDEBUG
    932         return ipc_connect_kbox((task_id_t) taskid);
     938        cap_handle_t phone;
     939        int rc = ipc_connect_kbox((task_id_t) taskid, &phone);
     940        if (rc == EOK) {
     941                rc = copy_to_uspace(uspace_phone, &phone, sizeof(cap_handle_t));
     942        }
     943        return (sysarg_t) rc;
    933944#else
    934945        return (sysarg_t) ENOTSUP;
  • uspace/lib/c/generic/async.c

    r071a1ddb r569a51a  
    23982398        }
    23992399       
    2400         int phone = ipc_connect_kbox(id);
    2401         if (phone < 0) {
    2402                 errno = phone;
     2400        cap_handle_t phone;
     2401        int rc = ipc_connect_kbox(id, &phone);
     2402        if (rc != EOK) {
     2403                errno = rc;
    24032404                free(sess);
    24042405                return NULL;
  • uspace/lib/c/generic/ipc.c

    r071a1ddb r569a51a  
    377377 *
    378378 */
    379 int ipc_connect_kbox(task_id_t id)
     379int ipc_connect_kbox(task_id_t id, cap_handle_t *phone)
    380380{
    381381#ifdef __32_BITS__
    382382        sysarg64_t arg = (sysarg64_t) id;
    383         return __SYSCALL1(SYS_IPC_CONNECT_KBOX, (sysarg_t) &arg);
     383        return __SYSCALL2(SYS_IPC_CONNECT_KBOX, (sysarg_t) &arg, (sysarg_t) phone);
    384384#endif
    385        
    386385#ifdef __64_BITS__
    387         return __SYSCALL1(SYS_IPC_CONNECT_KBOX, (sysarg_t) id);
     386        return __SYSCALL2(SYS_IPC_CONNECT_KBOX, (sysarg_t) id, (sysarg_t) phone);
    388387#endif
    389388}
  • uspace/lib/c/include/ipc/ipc.h

    r071a1ddb r569a51a  
    122122    sysarg_t, sysarg_t, sysarg_t, sysarg_t, unsigned int);
    123123
    124 extern int ipc_connect_kbox(task_id_t);
     124extern int ipc_connect_kbox(task_id_t, cap_handle_t *);
    125125
    126126#endif
Note: See TracChangeset for help on using the changeset viewer.