Changes in / [071a1ddb:0722869] in mainline
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/ipc/kbox.h
r071a1ddb r0722869 50 50 } kbox_t; 51 51 52 extern int ipc_connect_kbox(task_id_t );52 extern int ipc_connect_kbox(task_id_t, cap_handle_t *); 53 53 extern void ipc_kbox_cleanup(void); 54 54 -
kernel/generic/include/ipc/sysipc.h
r071a1ddb r0722869 59 59 extern sysarg_t sys_ipc_irq_unsubscribe(sysarg_t); 60 60 61 #ifdef __32_BITS__ 62 63 extern sysarg_t sys_ipc_connect_kbox(sysarg64_t *); 64 65 #endif /* __32_BITS__ */ 66 67 #ifdef __64_BITS__ 68 69 extern sysarg_t sys_ipc_connect_kbox(sysarg_t); 70 71 #endif /* __64_BITS__ */ 61 extern sysarg_t sys_ipc_connect_kbox(task_id_t *, cap_handle_t *); 72 62 73 63 #endif -
kernel/generic/src/ipc/kbox.c
r071a1ddb r0722869 206 206 * cleanup code. 207 207 * 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 */ 212 int ipc_connect_kbox(task_id_t taskid, cap_handle_t *out_phone) 212 213 { 213 214 irq_spinlock_lock(&tasks_lock, true); … … 231 232 } 232 233 233 if (task->kb.finished != false) {234 if (task->kb.finished) { 234 235 mutex_unlock(&task->kb.cleanup_lock); 235 236 return EINVAL; 236 237 } 237 238 239 /* Create a kbox thread if necessary. */ 240 if (task->kb.thread == NULL) { 241 thread_t *kb_thread = thread_create(kbox_thread_proc, NULL, task, 242 THREAD_FLAG_NONE, "kbox"); 243 244 if (!kb_thread) { 245 mutex_unlock(&task->kb.cleanup_lock); 246 return ENOMEM; 247 } 248 249 task->kb.thread = kb_thread; 250 thread_ready(kb_thread); 251 } 252 253 /* Allocate a new phone. */ 238 254 cap_handle_t phone_handle = phone_alloc(TASK); 239 255 if (phone_handle < 0) { … … 248 264 (void) ipc_phone_connect(phone_obj->phone, &task->kb.box); 249 265 250 if (task->kb.thread != NULL) {251 mutex_unlock(&task->kb.cleanup_lock);252 return phone_handle;253 }254 255 /* Create a kbox thread */256 thread_t *kb_thread = thread_create(kbox_thread_proc, NULL, task,257 THREAD_FLAG_NONE, "kbox");258 if (!kb_thread) {259 mutex_unlock(&task->kb.cleanup_lock);260 return ENOMEM;261 }262 263 task->kb.thread = kb_thread;264 thread_ready(kb_thread);265 266 266 mutex_unlock(&task->kb.cleanup_lock); 267 268 return phone_handle;267 *out_phone = phone_handle; 268 return EOK; 269 269 } 270 270 -
kernel/generic/src/ipc/sysipc.c
r071a1ddb r0722869 897 897 } 898 898 899 #ifdef __32_BITS__ 900 901 /** Syscall connect to a task by ID (32 bits) 902 * 903 * @return Phone id on success, or negative error code. 904 * 905 */ 906 sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid) 899 /** Syscall connect to a task by ID 900 * 901 * @return Error code. 902 * 903 */ 904 sysarg_t sys_ipc_connect_kbox(task_id_t *uspace_taskid, cap_handle_t *uspace_phone) 907 905 { 908 906 #ifdef CONFIG_UDEBUG 909 sysarg64_t taskid; 910 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); 907 task_id_t taskid; 908 cap_handle_t phone; 909 910 int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(task_id_t)); 911 if (rc == EOK) { 912 rc = ipc_connect_kbox((task_id_t) taskid, &phone); 913 } 914 915 if (rc == EOK) { 916 rc = copy_to_uspace(uspace_phone, &phone, sizeof(cap_handle_t)); 917 if (rc != EOK) { 918 // Clean up the phone on failure. 919 sys_ipc_hangup(phone); 920 } 921 } 922 923 return (sysarg_t) rc; 915 924 #else 916 925 return (sysarg_t) ENOTSUP; … … 918 927 } 919 928 920 #endif /* __32_BITS__ */921 922 #ifdef __64_BITS__923 924 /** Syscall connect to a task by ID (64 bits)925 *926 * @return Phone id on success, or negative error code.927 *928 */929 sysarg_t sys_ipc_connect_kbox(sysarg_t taskid)930 {931 #ifdef CONFIG_UDEBUG932 return ipc_connect_kbox((task_id_t) taskid);933 #else934 return (sysarg_t) ENOTSUP;935 #endif936 }937 938 #endif /* __64_BITS__ */939 940 929 /** @} 941 930 */ -
uspace/lib/c/generic/async.c
r071a1ddb r0722869 2398 2398 } 2399 2399 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; 2403 2404 free(sess); 2404 2405 return NULL; -
uspace/lib/c/generic/ipc.c
r071a1ddb r0722869 377 377 * 378 378 */ 379 int ipc_connect_kbox(task_id_t id) 380 { 381 #ifdef __32_BITS__ 382 sysarg64_t arg = (sysarg64_t) id; 383 return __SYSCALL1(SYS_IPC_CONNECT_KBOX, (sysarg_t) &arg); 384 #endif 385 386 #ifdef __64_BITS__ 387 return __SYSCALL1(SYS_IPC_CONNECT_KBOX, (sysarg_t) id); 388 #endif 379 int ipc_connect_kbox(task_id_t id, cap_handle_t *phone) 380 { 381 return __SYSCALL2(SYS_IPC_CONNECT_KBOX, (sysarg_t) &id, (sysarg_t) phone); 389 382 } 390 383 -
uspace/lib/c/include/ipc/ipc.h
r071a1ddb r0722869 122 122 sysarg_t, sysarg_t, sysarg_t, sysarg_t, unsigned int); 123 123 124 extern int ipc_connect_kbox(task_id_t );124 extern int ipc_connect_kbox(task_id_t, cap_handle_t *); 125 125 126 126 #endif
Note:
See TracChangeset
for help on using the changeset viewer.