Changeset 984a9ba in mainline for uspace/lib/usbvirt/src/ipc_dev.c
- Timestamp:
- 2018-07-05T09:34:09Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 63d46341
- Parents:
- 76f566d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbvirt/src/ipc_dev.c
r76f566d r984a9ba 44 44 /** Handle VHC request for device name. 45 45 * 46 * @param dev Target virtual device. 47 * @param iid Caller id. 48 * @param icall The call with the request. 49 */ 50 static void ipc_get_name(usbvirt_device_t *dev, 51 cap_call_handle_t icall_handle, ipc_call_t *icall) 46 * @param dev Target virtual device. 47 * @param icall The call with the request. 48 * 49 */ 50 static void ipc_get_name(usbvirt_device_t *dev, ipc_call_t *icall) 52 51 { 53 52 if (dev->name == NULL) { 54 async_answer_0(icall _handle, ENOENT);53 async_answer_0(icall, ENOENT); 55 54 } 56 55 57 56 size_t size = str_size(dev->name); 58 57 59 cap_call_handle_t chandle;58 ipc_call_t call; 60 59 size_t accepted_size; 61 if (!async_data_read_receive(&c handle, &accepted_size)) {62 async_answer_0(icall _handle, EINVAL);60 if (!async_data_read_receive(&call, &accepted_size)) { 61 async_answer_0(icall, EINVAL); 63 62 return; 64 63 } … … 67 66 accepted_size = size; 68 67 } 69 async_data_read_finalize( chandle, dev->name, accepted_size);70 71 async_answer_1(icall _handle, EOK, accepted_size);68 async_data_read_finalize(&call, dev->name, accepted_size); 69 70 async_answer_1(icall, EOK, accepted_size); 72 71 } 73 72 74 73 /** Handle VHC request for control read from the device. 75 74 * 76 * @param dev Target virtual device. 77 * @param iid Caller id. 78 * @param icall The call with the request. 79 */ 80 static void ipc_control_read(usbvirt_device_t *dev, 81 cap_call_handle_t icall_handle, ipc_call_t *icall) 75 * @param dev Target virtual device. 76 * @param icall The call with the request. 77 * 78 */ 79 static void ipc_control_read(usbvirt_device_t *dev, ipc_call_t *icall) 82 80 { 83 81 errno_t rc; … … 90 88 1, 1024, 0, &setup_packet_len); 91 89 if (rc != EOK) { 92 async_answer_0(icall _handle, rc);93 return; 94 } 95 96 cap_call_handle_t data_chandle;97 if (!async_data_read_receive(&data _chandle, &data_len)) {98 async_answer_0(icall _handle, EPARTY);90 async_answer_0(icall, rc); 91 return; 92 } 93 94 ipc_call_t data; 95 if (!async_data_read_receive(&data, &data_len)) { 96 async_answer_0(icall, EPARTY); 99 97 free(setup_packet); 100 98 return; … … 103 101 void *buffer = malloc(data_len); 104 102 if (buffer == NULL) { 105 async_answer_0(icall _handle, ENOMEM);103 async_answer_0(icall, ENOMEM); 106 104 free(setup_packet); 107 105 return; … … 113 111 114 112 if (rc != EOK) { 115 async_answer_0( data_chandle, rc);116 async_answer_0(icall _handle, rc);113 async_answer_0(&data, rc); 114 async_answer_0(icall, rc); 117 115 free(setup_packet); 118 116 free(buffer); … … 120 118 } 121 119 122 async_data_read_finalize( data_chandle, buffer, actual_len);123 async_answer_0(icall _handle, EOK);120 async_data_read_finalize(&data, buffer, actual_len); 121 async_answer_0(icall, EOK); 124 122 125 123 free(setup_packet); … … 129 127 /** Handle VHC request for control write to the device. 130 128 * 131 * @param dev Target virtual device. 132 * @param iid Caller id. 133 * @param icall The call with the request. 134 */ 135 static void ipc_control_write(usbvirt_device_t *dev, 136 cap_call_handle_t icall_handle, ipc_call_t *icall) 129 * @param dev Target virtual device. 130 * @param icall The call with the request. 131 * 132 */ 133 static void ipc_control_write(usbvirt_device_t *dev, ipc_call_t *icall) 137 134 { 138 135 size_t data_buffer_len = IPC_GET_ARG1(*icall); … … 146 143 1, 0, 0, &setup_packet_len); 147 144 if (rc != EOK) { 148 async_answer_0(icall _handle, rc);145 async_answer_0(icall, rc); 149 146 return; 150 147 } … … 154 151 1, 0, 0, &data_buffer_len); 155 152 if (rc != EOK) { 156 async_answer_0(icall _handle, rc);153 async_answer_0(icall, rc); 157 154 free(setup_packet); 158 155 return; … … 163 160 data_buffer, data_buffer_len); 164 161 165 async_answer_0(icall _handle, rc);162 async_answer_0(icall, rc); 166 163 167 164 free(setup_packet); … … 173 170 /** Handle VHC request for data read from the device (in transfer). 174 171 * 175 * @param dev Target virtual device.176 * @param i id Caller id.177 * @param icall The call with the request.172 * @param dev Target virtual device. 173 * @param icall The call with the request. 174 * 178 175 */ 179 176 static void ipc_data_in(usbvirt_device_t *dev, 180 usb_transfer_type_t transfer_type, 181 cap_call_handle_t icall_handle, ipc_call_t *icall) 177 usb_transfer_type_t transfer_type, ipc_call_t *icall) 182 178 { 183 179 usb_endpoint_t endpoint = IPC_GET_ARG1(*icall); … … 186 182 187 183 size_t data_len = 0; 188 cap_call_handle_t data_chandle;189 if (!async_data_read_receive(&data _chandle, &data_len)) {190 async_answer_0(icall _handle, EPARTY);184 ipc_call_t data; 185 if (!async_data_read_receive(&data, &data_len)) { 186 async_answer_0(icall, EPARTY); 191 187 return; 192 188 } … … 194 190 void *buffer = malloc(data_len); 195 191 if (buffer == NULL) { 196 async_answer_0(icall _handle, ENOMEM);192 async_answer_0(icall, ENOMEM); 197 193 return; 198 194 } … … 203 199 204 200 if (rc != EOK) { 205 async_answer_0( data_chandle, rc);206 async_answer_0(icall _handle, rc);201 async_answer_0(&data, rc); 202 async_answer_0(icall, rc); 207 203 free(buffer); 208 204 return; 209 205 } 210 206 211 async_data_read_finalize( data_chandle, buffer, actual_len);212 async_answer_0(icall _handle, EOK);207 async_data_read_finalize(&data, buffer, actual_len); 208 async_answer_0(icall, EOK); 213 209 214 210 free(buffer); … … 217 213 /** Handle VHC request for data write to the device (out transfer). 218 214 * 219 * @param dev Target virtual device.220 * @param i id Caller id.221 * @param icall The call with the request.215 * @param dev Target virtual device. 216 * @param icall The call with the request. 217 * 222 218 */ 223 219 static void ipc_data_out(usbvirt_device_t *dev, 224 usb_transfer_type_t transfer_type, 225 cap_call_handle_t icall_handle, ipc_call_t *icall) 220 usb_transfer_type_t transfer_type, ipc_call_t *icall) 226 221 { 227 222 usb_endpoint_t endpoint = IPC_GET_ARG1(*icall); … … 233 228 1, 0, 0, &data_buffer_size); 234 229 if (rc != EOK) { 235 async_answer_0(icall _handle, rc);230 async_answer_0(icall, rc); 236 231 return; 237 232 } … … 240 235 data_buffer, data_buffer_size); 241 236 242 async_answer_0(icall _handle, rc);237 async_answer_0(icall, rc); 243 238 244 239 free(data_buffer); … … 247 242 /** Handle incoming IPC call for virtual USB device. 248 243 * 249 * @param dev Target USB device. 250 * @param chandle Caller id. 244 * @param dev Target USB device. 251 245 * @param call Incoming call. 246 * 252 247 * @return Whether the call was handled. 253 * /254 bool usbvirt_ipc_handle_call(usbvirt_device_t *dev, 255 cap_call_handle_t chandle, ipc_call_t *call)248 * 249 */ 250 bool usbvirt_ipc_handle_call(usbvirt_device_t *dev, ipc_call_t *call) 256 251 { 257 252 switch (IPC_GET_IMETHOD(*call)) { 258 253 case IPC_M_USBVIRT_GET_NAME: 259 ipc_get_name(dev, c handle, call);254 ipc_get_name(dev, call); 260 255 break; 261 256 262 257 case IPC_M_USBVIRT_CONTROL_READ: 263 ipc_control_read(dev, c handle, call);258 ipc_control_read(dev, call); 264 259 break; 265 260 266 261 case IPC_M_USBVIRT_CONTROL_WRITE: 267 ipc_control_write(dev, c handle, call);262 ipc_control_write(dev, call); 268 263 break; 269 264 270 265 case IPC_M_USBVIRT_INTERRUPT_IN: 271 ipc_data_in(dev, USB_TRANSFER_INTERRUPT, c handle, call);266 ipc_data_in(dev, USB_TRANSFER_INTERRUPT, call); 272 267 break; 273 268 274 269 case IPC_M_USBVIRT_BULK_IN: 275 ipc_data_in(dev, USB_TRANSFER_BULK, c handle, call);270 ipc_data_in(dev, USB_TRANSFER_BULK, call); 276 271 break; 277 272 278 273 case IPC_M_USBVIRT_INTERRUPT_OUT: 279 ipc_data_out(dev, USB_TRANSFER_INTERRUPT, c handle, call);274 ipc_data_out(dev, USB_TRANSFER_INTERRUPT, call); 280 275 break; 281 276 282 277 case IPC_M_USBVIRT_BULK_OUT: 283 ipc_data_out(dev, USB_TRANSFER_BULK, chandle, call); 284 break; 285 278 ipc_data_out(dev, USB_TRANSFER_BULK, call); 279 break; 286 280 287 281 default:
Note:
See TracChangeset
for help on using the changeset viewer.