Changeset b61d47d in mainline
- Timestamp:
- 2007-12-02T20:00:14Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 90c35436
- Parents:
- 8df2eab
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/ipc/ipc.h
r8df2eab rb61d47d 139 139 * indicating that it wants to be connected to some 140 140 * service 141 * - arg1/2 are user specified, arg3contains141 * - arg1/2/3 are user specified, arg5 contains 142 142 * address of the phone that should be connected 143 143 * (TODO: it leaks to userspace) -
kernel/generic/include/ipc/sysipc.h
r8df2eab rb61d47d 53 53 int nonblocking); 54 54 unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid, 55 unative_t method, unative_t arg1, int mode);55 unative_t method, unative_t arg1, unative_t arg2, int mode); 56 56 unative_t sys_ipc_hangup(int phoneid); 57 57 unative_t sys_ipc_register_irq(inr_t inr, devno_t devno, unative_t method, -
kernel/generic/src/ipc/sysipc.c
r8df2eab rb61d47d 192 192 /* If the users accepted call, connect */ 193 193 if (!IPC_GET_RETVAL(answer->data)) { 194 ipc_phone_connect((phone_t *) IPC_GET_ARG 3(*olddata),194 ipc_phone_connect((phone_t *) IPC_GET_ARG5(*olddata), 195 195 &TASK->answerbox); 196 196 } … … 271 271 return ELIMIT; 272 272 /* Set arg3 for server */ 273 IPC_SET_ARG 3(call->data, (unative_t) &TASK->phones[newphid]);273 IPC_SET_ARG5(call->data, (unative_t) &TASK->phones[newphid]); 274 274 call->flags |= IPC_CALL_CONN_ME_TO; 275 275 call->priv = newphid; … … 319 319 phone_dealloc(call->priv); 320 320 else 321 IPC_SET_ARG 3(call->data, call->priv);321 IPC_SET_ARG5(call->data, call->priv); 322 322 } 323 323 } … … 553 553 */ 554 554 unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid, 555 unative_t method, unative_t arg1, int mode)555 unative_t method, unative_t arg1, unative_t arg2, int mode) 556 556 { 557 557 call_t *call; … … 578 578 /* 579 579 * Userspace is not allowed to change method of system methods on 580 * forward, allow changing ARG1 and ARG2 by means of method and arg1. 580 * forward, allow changing ARG1, ARG2 and ARG3 by means of method, 581 * arg1 and arg2. 581 582 * If the method is immutable, don't change anything. 582 583 */ … … 584 585 if (method_is_system(IPC_GET_METHOD(call->data))) { 585 586 if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_TO_ME) 586 phone_dealloc(IPC_GET_ARG 3(call->data));587 phone_dealloc(IPC_GET_ARG5(call->data)); 587 588 588 589 IPC_SET_ARG1(call->data, method); 589 590 IPC_SET_ARG2(call->data, arg1); 591 IPC_SET_ARG3(call->data, arg2); 590 592 } else { 591 593 IPC_SET_METHOD(call->data, method); 592 594 IPC_SET_ARG1(call->data, arg1); 595 IPC_SET_ARG2(call->data, arg2); 593 596 } 594 597 } -
uspace/app/tester/devmap/devmap1.c
r8df2eab rb61d47d 36 36 #include "../tester.h" 37 37 38 #include <time.h> 39 40 #define TEST_DEVICE1 "TestDevice1" 41 #define TEST_DEVICE2 "TestDevice2" 42 43 /** Handle requests from clients 44 * 45 */ 46 static void driver_client_connection(ipc_callid_t iid, ipc_call_t *icall) 47 { 48 ipc_callid_t callid; 49 ipc_call_t call; 50 int retval; 51 52 printf("connected: method=%u arg1=%u, arg2=%u arg3=%u.\n", IPC_GET_METHOD(*icall), 53 IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall), IPC_GET_ARG3(*icall)); 54 55 printf("driver_client_connection.\n"); 56 ipc_answer_0(iid, EOK); 57 58 /* Ignore parameters, the connection is already opened */ 59 while (1) { 60 callid = async_get_call(&call); 61 retval = EOK; 62 printf("method=%u arg1=%u, arg2=%u arg3=%u.\n", IPC_GET_METHOD(call), 63 IPC_GET_ARG1(call), IPC_GET_ARG2(call), IPC_GET_ARG3(call)); 64 switch (IPC_GET_METHOD(call)) { 65 case IPC_M_PHONE_HUNGUP: 66 /* TODO: Handle hangup */ 67 return; 68 default: 69 printf("Unknown device method %u.\n", IPC_GET_METHOD(call)); 70 retval = ENOENT; 71 } 72 ipc_answer_0(callid, retval); 73 } 74 return; 75 } 76 77 static int device_client_fibril(void *arg) 78 { 79 int handle; 80 int device_phone; 81 82 handle = (int)arg; 83 84 device_phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, \ 85 DEVMAP_CONNECT_TO_DEVICE, handle); 86 87 if (device_phone < 0) { 88 printf("Failed to connect to devmap as client (handle = %u).\n", 89 handle); 90 return -1; 91 } 92 /* 93 * device_phone = (int) IPC_GET_ARG3(answer); 94 */ 95 printf("Connected to device.\n"); 96 ipc_call_sync_1_0(device_phone, 1024, 1025); 97 /* 98 * ipc_hangup(device_phone); 99 */ 100 ipc_hangup(device_phone); 101 102 return EOK; 103 } 104 105 /** Communication test with device. 106 * @param handle handle to tested instance. 107 */ 108 static int device_client(int handle) 109 { 110 /* fid_t fid; 111 ipc_call_t call; 112 ipc_callid_t callid; 113 114 fid = fibril_create(device_client_fibril, (void *)handle); 115 fibril_add_ready(fid); 116 117 */ 118 return EOK; 119 } 120 121 /** 122 * 123 */ 38 124 static int driver_register(char *name) 39 125 { 40 i nt retval;126 ipcarg_t retval; 41 127 aid_t req; 42 128 ipc_call_t answer; … … 44 130 ipcarg_t callback_phonehash; 45 131 46 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, DEVMAP_DRIVER); 132 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, 133 DEVMAP_DRIVER, 0); 47 134 48 135 while (phone < 0) { 49 136 usleep(100000); 50 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, DEVMAP_DRIVER); 137 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, 138 DEVMAP_DRIVER, 0); 51 139 } 52 140 53 141 req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer); 54 142 55 retval = ipc_data_send(phone, (char *)name, strlen(name) );143 retval = ipc_data_send(phone, (char *)name, strlen(name) + 1); 56 144 57 145 if (retval != EOK) { … … 60 148 } 61 149 150 async_set_client_connection(driver_client_connection); 151 62 152 ipc_connect_to_me(phone, 0, 0, &callback_phonehash); 63 64 async_wait_for(req, NULL); 153 /* 154 if (NULL == async_new_connection(callback_phonehash, 0, NULL, 155 driver_client_connection)) { 156 printf("Failed to create new fibril.\n"); 157 async_wait_for(req, NULL); 158 return -1; 159 } 160 */ 161 async_wait_for(req, &retval); 65 162 printf("Driver '%s' registered.\n", name); 66 163 … … 68 165 } 69 166 70 static int device_ register(int driver_phone, char *name, int *handle)167 static int device_get_handle(int driver_phone, char *name, int *handle) 71 168 { 72 169 ipcarg_t retval; … … 74 171 ipc_call_t answer; 75 172 173 req = async_send_2(driver_phone, DEVMAP_DEVICE_GET_HANDLE, 0, 0, &answer); 174 175 retval = ipc_data_send(driver_phone, name, strlen(name) + 1); 176 177 if (retval != EOK) { 178 printf("Failed to send device name '%s'.\n", name); 179 async_wait_for(req, NULL); 180 return retval; 181 } 182 183 async_wait_for(req, &retval); 184 185 if (NULL != handle) { 186 *handle = -1; 187 } 188 189 if (EOK == retval) { 190 191 if (NULL != handle) { 192 *handle = (int) IPC_GET_ARG1(answer); 193 } 194 printf("Device '%s' has handle %u.\n", name, (int) IPC_GET_ARG1(answer)); 195 } else { 196 printf("Failed to get handle for device '%s'.\n", name); 197 } 198 199 return retval; 200 } 201 202 /** Register new device. 203 * @param driver_phone 204 * @param name Device name. 205 * @param handle Output variable. Handle to the created instance of device. 206 */ 207 static int device_register(int driver_phone, char *name, int *handle) 208 { 209 ipcarg_t retval; 210 aid_t req; 211 ipc_call_t answer; 212 76 213 req = async_send_2(driver_phone, DEVMAP_DEVICE_REGISTER, 0, 0, &answer); 77 214 78 retval = ipc_data_send(driver_phone, (char *)name, strlen(name) );215 retval = ipc_data_send(driver_phone, (char *)name, strlen(name) + 1); 79 216 80 217 if (retval != EOK) { … … 111 248 int dev2_handle; 112 249 int dev3_handle; 250 int handle; 113 251 114 252 /* Register new driver */ … … 120 258 121 259 /* Register new device dev1*/ 122 if (EOK != device_register(driver_phone, "TestDevice1", &dev1_handle)) {260 if (EOK != device_register(driver_phone, TEST_DEVICE1, &dev1_handle)) { 123 261 ipc_hangup(driver_phone); 124 262 return "Error: cannot register device.\n"; 125 263 } 126 127 /* TODO: get handle for dev1*/ 128 129 /* TODO: get handle for dev2 (Should fail unless device is already 264 265 /* Get handle for dev2 (Should fail unless device is already 130 266 * registered by someone else) 131 267 */ 268 if (EOK == device_get_handle(driver_phone, TEST_DEVICE2, &handle)) { 269 ipc_hangup(driver_phone); 270 return "Error: got handle for dev2 before it was registered.\n"; 271 } 132 272 133 273 /* Register new device dev2*/ 134 if (EOK != device_register(driver_phone, "TestDevice2", &dev2_handle)) {274 if (EOK != device_register(driver_phone, TEST_DEVICE2, &dev2_handle)) { 135 275 ipc_hangup(driver_phone); 136 276 return "Error: cannot register device dev2.\n"; 137 277 } 138 278 139 140 279 /* Register again device dev1 */ 141 if (EOK == device_register(driver_phone, "TestDevice1", &dev3_handle)) {280 if (EOK == device_register(driver_phone, TEST_DEVICE1, &dev3_handle)) { 142 281 return "Error: dev1 registered twice.\n"; 143 282 } 144 283 145 /* TODO: get handle for dev2 */ 146 147 /* TODO: */ 284 /* Get handle for dev1*/ 285 if (EOK != device_get_handle(driver_phone, TEST_DEVICE1, &handle)) { 286 ipc_hangup(driver_phone); 287 return "Error: cannot get handle for 'DEVMAP_DEVICE1'.\n"; 288 } 289 290 if (handle != dev1_handle) { 291 ipc_hangup(driver_phone); 292 return "Error: cannot get handle for 'DEVMAP_DEVICE1'.\n"; 293 } 294 295 if (EOK != device_client(dev1_handle)) { 296 ipc_hangup(driver_phone); 297 return "Error: failed client test for 'DEVMAP_DEVICE1'.\n"; 298 } 299 300 /* TODO: */ 148 301 149 302 ipc_hangup(driver_phone); -
uspace/app/tester/ipc/connect.c
r8df2eab rb61d47d 47 47 48 48 printf("Connecting to %d..", svc); 49 phid = ipc_connect_me_to(PHONE_NS, svc, 0 );49 phid = ipc_connect_me_to(PHONE_NS, svc, 0, 0); 50 50 if (phid > 0) { 51 51 printf("phoneid: %d\n", phid); -
uspace/lib/libc/generic/async.c
r8df2eab rb61d47d 539 539 case IPC_M_CONNECT_ME_TO: 540 540 /* Open new connection with fibril etc. */ 541 async_new_connection(IPC_GET_ARG 3(*call), callid, call,541 async_new_connection(IPC_GET_ARG5(*call), callid, call, 542 542 client_connection); 543 543 return; -
uspace/lib/libc/generic/io/stream.c
r8df2eab rb61d47d 97 97 if (console_phone < 0) { 98 98 while ((console_phone = ipc_connect_me_to(PHONE_NS, 99 SERVICE_CONSOLE, 0 )) < 0) {99 SERVICE_CONSOLE, 0, 0)) < 0) { 100 100 usleep(10000); 101 101 } … … 116 116 if (console_phone < 0) { 117 117 while ((console_phone = ipc_connect_me_to(PHONE_NS, 118 SERVICE_CONSOLE, 0 )) < 0) {118 SERVICE_CONSOLE, 0, 0)) < 0) { 119 119 usleep(10000); 120 120 } -
uspace/lib/libc/generic/ipc.c
r8df2eab rb61d47d 588 588 * @param arg1 User defined argument. 589 589 * @param arg2 User defined argument. 590 * @param arg3 User defined argument. 590 591 * 591 592 * @return New phone handle on success or a negative error code. 592 593 */ 593 int ipc_connect_me_to(int phoneid, int arg1, int arg2 )594 int ipc_connect_me_to(int phoneid, int arg1, int arg2, int arg3) 594 595 { 595 596 ipcarg_t newphid; 596 597 int res; 597 598 598 res = ipc_call_sync_ 2_3(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, NULL,599 599 res = ipc_call_sync_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, 600 NULL, NULL, NULL, NULL, &newphid); 600 601 if (res) 601 602 return res; … … 647 648 * @param method New method for the forwarded call. 648 649 * @param arg1 New value of the first argument for the forwarded call. 650 * @param arg2 New value of the second argument for the forwarded call. 649 651 * @param mode Flags specifying mode of the forward operation. 650 652 * … … 652 654 * 653 655 * For non-system methods, the old method and arg1 are rewritten by the new 654 * values. For system methods, the new method and arg1 are written to the old655 * arg1 and arg2, respectivelly. Calls with immutable methods are forwarded656 * verbatim.656 * values. For system methods, the new method, arg1 and arg2 are written 657 * to the old arg1, arg2 and arg3, respectivelly. Calls with immutable 658 * methods are forwarded verbatim. 657 659 */ 658 660 int ipc_forward_fast(ipc_callid_t callid, int phoneid, int method, 659 ipcarg_t arg1, i nt mode)660 { 661 return __SYSCALL 5(SYS_IPC_FORWARD_FAST, callid, phoneid, method, arg1,662 661 ipcarg_t arg1, ipcarg_t arg2, int mode) 662 { 663 return __SYSCALL6(SYS_IPC_FORWARD_FAST, callid, phoneid, method, arg1, 664 arg2, mode); 663 665 } 664 666 -
uspace/lib/libc/include/ipc/ipc.h
r8df2eab rb61d47d 254 254 255 255 extern int ipc_connect_to_me(int phoneid, int arg1, int arg2, ipcarg_t *phone); 256 extern int ipc_connect_me_to(int phoneid, int arg1, int arg2 );256 extern int ipc_connect_me_to(int phoneid, int arg1, int arg2, int arg3); 257 257 extern int ipc_hangup(int phoneid); 258 258 extern int ipc_register_irq(int inr, int devno, int method, irq_code_t *code); 259 259 extern int ipc_unregister_irq(int inr, int devno); 260 260 extern int ipc_forward_fast(ipc_callid_t callid, int phoneid, int method, 261 ipcarg_t arg1, i nt mode);261 ipcarg_t arg1, ipcarg_t arg2, int mode); 262 262 extern int ipc_data_send(int phoneid, void *src, size_t size); 263 263 extern int ipc_data_receive(ipc_callid_t *callid, void **dst, size_t *size); -
uspace/srv/console/console.c
r8df2eab rb61d47d 483 483 /* Connect to keyboard driver */ 484 484 485 kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0 );485 kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0, 0); 486 486 while (kbd_phone < 0) { 487 487 usleep(10000); 488 kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0 );488 kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0, 0); 489 489 } 490 490 … … 495 495 /* Connect to framebuffer driver */ 496 496 497 fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0 );497 fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0, 0); 498 498 while (fb_info.phone < 0) { 499 499 usleep(10000); 500 fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0 );500 fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0, 0); 501 501 } 502 502 -
uspace/srv/devmap/devmap.c
r8df2eab rb61d47d 449 449 * Find device driver owning requested device and forward 450 450 * the message to it. 451 *452 *453 451 */ 454 452 static void devmap_forward(ipc_callid_t callid, ipc_call_t *call) … … 460 458 * Get handle from request 461 459 */ 462 handle = IPC_GET_ARG 1(*call);460 handle = IPC_GET_ARG2(*call); 463 461 dev = devmap_device_find_handle(handle); 464 462 … … 470 468 } 471 469 472 /* FIXME: is this correct method how to pass argument on forwarding ?*/473 470 ipc_forward_fast(callid, dev->driver->phone, (ipcarg_t)(dev->handle), 474 0, IPC_FF_NONE);471 IPC_GET_ARG3(*call), 0, IPC_FF_NONE); 475 472 return; 476 473 } … … 670 667 continue; /* Exit thread */ 671 668 672 case DEVMAP_DEVICE_CONNECT_ME_TO:673 /* Connect client to selected device */674 printf("DEVMAP: connect to device %d.\n",675 IPC_GET_ARG1(call));676 devmap_forward(callid, &call);677 break;678 679 669 case DEVMAP_DEVICE_GET_HANDLE: 680 670 devmap_get_handle(callid, &call); … … 710 700 devmap_connection_client(iid, icall); 711 701 break; 702 case DEVMAP_CONNECT_TO_DEVICE: 703 /* Connect client to selected device */ 704 printf("DEVMAP: connect to device %d.\n", 705 IPC_GET_ARG2(*icall)); 706 devmap_forward(iid, icall); 707 break; 712 708 default: 713 709 ipc_answer_0(iid, ENOENT); /* No such interface */ -
uspace/srv/devmap/devmap.h
r8df2eab rb61d47d 42 42 DEVMAP_DRIVER_REGISTER = IPC_FIRST_USER_METHOD, 43 43 DEVMAP_DRIVER_UNREGISTER, 44 DEVMAP_DEVICE_CONNECT_ME_TO,45 44 DEVMAP_DEVICE_REGISTER, 46 45 DEVMAP_DEVICE_UNREGISTER, … … 83 82 } devmap_device_t; 84 83 85 /** Interface provided by DevMap. 86 * 84 /** Interface provided by devmap. 85 * Every process that connects to devmap must ask one of following 86 * interfaces otherwise connection will be refused. 87 87 */ 88 88 typedef enum { 89 DEVMAP_DRIVER = 1, 90 DEVMAP_CLIENT 89 /** Connect as device driver */ 90 DEVMAP_DRIVER = 1, 91 /** Connect as client */ 92 DEVMAP_CLIENT, 93 /** Create new connection to instance of device that 94 * is specified by second argument of call. */ 95 DEVMAP_CONNECT_TO_DEVICE 91 96 } devmap_interface_t; 92 97 -
uspace/srv/fs/fat/fat.c
r8df2eab rb61d47d 127 127 printf("FAT: HelenOS FAT file system server.\n"); 128 128 129 vfs_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VFS, 0 );129 vfs_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VFS, 0, 0); 130 130 while (vfs_phone < EOK) { 131 131 usleep(10000); 132 vfs_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VFS, 0 );132 vfs_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VFS, 0, 0); 133 133 } 134 134 -
uspace/srv/ns/ns.c
r8df2eab rb61d47d 213 213 } 214 214 hs = hash_table_get_instance(hlp, hashed_service_t, link); 215 return ipc_forward_fast(callid, hs->phone, IPC_GET_ARG2(*call), 0,216 215 return ipc_forward_fast(callid, hs->phone, IPC_GET_ARG2(*call), 216 IPC_GET_ARG3(*call), 0, IPC_FF_NONE); 217 217 } 218 218 -
uspace/srv/vfs/vfs_read.c
r8df2eab rb61d47d 97 97 */ 98 98 ipc_forward_fast(callid, fs_phone, IPC_GET_METHOD(call), 99 IPC_GET_ARG1(call), IPC_FF_ROUTE_FROM_ME);99 IPC_GET_ARG1(call), 0, IPC_FF_ROUTE_FROM_ME); 100 100 101 101 vfs_release_phone(fs_phone);
Note:
See TracChangeset
for help on using the changeset viewer.