Changeset e27595b in mainline for uspace/drv/vhc/conndev.c
- Timestamp:
- 2010-11-20T13:04:15Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0e126be7
- Parents:
- 7034be15
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/conndev.c
r7034be15 re27595b 74 74 } 75 75 76 /** Connection handler for communcation with virtual device.76 /** Default handler for IPC methods not handled by DDF. 77 77 * 78 * This function also takes care of proper phone hung-up. 79 * 80 * @param phone_hash Incoming phone hash. 81 * @param dev Virtual device handle. 78 * @param dev Device handling the call. 79 * @param icallid Call id. 80 * @param icall Call data. 82 81 */ 83 void connection_handler_device(ipcarg_t phone_hash, virtdev_connection_t *dev) 82 void default_connection_handler(device_t *dev, 83 ipc_callid_t icallid, ipc_call_t *icall) 84 84 { 85 assert(dev != NULL); 86 87 char devname[DEVICE_NAME_MAXLENGTH + 1]; 88 int rc = get_device_name(dev->phone, devname, DEVICE_NAME_MAXLENGTH); 89 90 dprintf(0, "virtual device connected (phone: %#x, name: %s)", 91 phone_hash, rc == EOK ? devname : "<unknown>"); 92 93 94 while (true) { 95 ipc_callid_t callid; 96 ipc_call_t call; 97 98 callid = async_get_call(&call); 99 100 switch (IPC_GET_METHOD(call)) { 101 case IPC_M_PHONE_HUNGUP: 102 ipc_hangup(dev->phone); 103 ipc_answer_0(callid, EOK); 104 dprintf(0, "phone%#x: device hung-up", 105 phone_hash); 106 return; 107 108 case IPC_M_CONNECT_TO_ME: 109 ipc_answer_0(callid, ELIMIT); 110 break; 111 112 default: 113 dprintf_inval_call(2, call, phone_hash); 114 ipc_answer_0(callid, EINVAL); 115 break; 85 ipcarg_t method = IPC_GET_METHOD(*icall); 86 87 if (method == IPC_M_CONNECT_TO_ME) { 88 int callback = IPC_GET_ARG5(*icall); 89 virtdev_connection_t *dev 90 = virtdev_add_device(callback); 91 if (!dev) { 92 ipc_answer_0(icallid, EEXISTS); 93 ipc_hangup(callback); 94 return; 116 95 } 96 ipc_answer_0(icallid, EOK); 97 98 char devname[DEVICE_NAME_MAXLENGTH + 1]; 99 int rc = get_device_name(callback, devname, DEVICE_NAME_MAXLENGTH); 100 101 dprintf(0, "virtual device connected (name: %s)", 102 rc == EOK ? devname : "<unknown>"); 103 104 /* FIXME: destroy the device when the client disconnects. */ 105 106 return; 117 107 } 108 109 ipc_answer_0(icallid, EINVAL); 118 110 } 111 119 112 120 113 /**
Note:
See TracChangeset
for help on using the changeset viewer.