Changeset 1d1f894 in mainline for uspace/srv/hw/bus/usb/hcd/virtual/hcd.c
- Timestamp:
- 2010-11-03T15:05:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d70a463
- Parents:
- af894a21
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/bus/usb/hcd/virtual/hcd.c
raf894a21 r1d1f894 52 52 53 53 54 static dev_handle_t handle_virtual_device; 55 static dev_handle_t handle_host_driver; 56 54 57 static void client_connection(ipc_callid_t iid, ipc_call_t *icall) 55 58 { 56 59 ipcarg_t phone_hash = icall->in_phone_hash; 60 dev_handle_t handle = (dev_handle_t)IPC_GET_ARG1(*icall); 57 61 58 ipc_answer_0(iid, EOK); 59 60 while (true) { 61 ipc_callid_t callid; 62 ipc_call_t call; 63 64 callid = async_get_call(&call); 65 62 if (handle == handle_host_driver) { 66 63 /* 67 * We can do nothing until we have the callback phone. 68 * Thus, we will wait for the callback and start processing 69 * after that. 64 * We can connect host controller driver immediately. 70 65 */ 71 int method = (int) IPC_GET_METHOD(call); 72 73 if (method == IPC_M_PHONE_HUNGUP) { 74 ipc_answer_0(callid, EOK); 75 return; 76 } 77 78 if (method == IPC_M_CONNECT_TO_ME) { 79 int kind = IPC_GET_ARG1(call); 80 int callback = IPC_GET_ARG5(call); 81 66 ipc_answer_0(iid, EOK); 67 connection_handler_host(phone_hash); 68 } else if (handle == handle_virtual_device) { 69 ipc_answer_0(iid, EOK); 70 71 while (true) { 82 72 /* 83 * Determine whether host connected to us84 * or adevice.73 * We need to wait for callback request to allow 74 * connection of virtual device. 85 75 */ 86 if (kind == 0) { 76 ipc_callid_t callid; 77 ipc_call_t call; 78 79 callid = async_get_call(&call); 80 81 /* 82 * We can do nothing until we have the callback phone. 83 * Thus, we will wait for the callback and start processing 84 * after that. 85 */ 86 int method = (int) IPC_GET_METHOD(call); 87 88 if (method == IPC_M_PHONE_HUNGUP) { 87 89 ipc_answer_0(callid, EOK); 88 connection_handler_host(phone_hash, callback);89 90 return; 90 } else if (kind == 1) { 91 } 92 93 if (method == IPC_M_CONNECT_TO_ME) { 94 int callback = IPC_GET_ARG5(call); 91 95 virtdev_connection_t *dev 92 96 = virtdev_add_device(callback); … … 100 104 virtdev_destroy_device(dev); 101 105 return; 102 } else {103 ipc_answer_0(callid, EINVAL);104 ipc_hangup(callback);105 return;106 106 } 107 108 /* 109 * No other methods could be served now. 110 */ 111 dprintf_inval_call(1, call, phone_hash); 112 ipc_answer_0(callid, ENOTSUP); 107 113 } 108 114 } else { 109 115 /* 110 * No other methods could be served now. 116 * Hmmm, someone else just tried to connect to us. 117 * Kick him out ;-). 111 118 */ 112 dprintf_inval_call(1, call, phone_hash);113 ipc_answer_0(callid, ENOTSUP);119 ipc_answer_0(iid, ENOTSUP); 120 return; 114 121 } 115 122 } … … 135 142 } 136 143 137 rc = devmap_device_register(DEVMAP_PATH , NULL);144 rc = devmap_device_register(DEVMAP_PATH_HC, &handle_host_driver); 138 145 if (rc != EOK) { 139 146 printf("%s: unable to register device %s (%s).\n", 140 NAME, DEVMAP_PATH , str_error(rc));147 NAME, DEVMAP_PATH_HC, str_error(rc)); 141 148 return 1; 142 149 } 143 150 151 rc = devmap_device_register(DEVMAP_PATH_DEV, &handle_virtual_device); 152 if (rc != EOK) { 153 printf("%s: unable to register device %s (%s).\n", 154 NAME, DEVMAP_PATH_DEV, str_error(rc)); 155 return 1; 156 } 157 144 158 hub_init(); 145 159 146 printf("%s: accepting connections [devmap=%s, debug=%d].\n", NAME, 147 DEVMAP_PATH, debug_level); 160 printf("%s: accepting connections [debug=%d]\n", NAME, debug_level); 161 printf("%s: -> host controller at %s\n", NAME, DEVMAP_PATH_HC); 162 printf("%s: -> virtual hub at %s\n", NAME, DEVMAP_PATH_DEV); 163 148 164 hc_manager(); 149 165
Note:
See TracChangeset
for help on using the changeset viewer.