The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Yabin Cui | aed3c61 | 2015-09-22 15:52:57 -0700 | [diff] [blame] | 17 | #define TRACE_TAG USB |
Dan Albert | 3313426 | 2015-03-19 15:21:08 -0700 | [diff] [blame] | 18 | |
| 19 | #include "sysdeps.h" |
| 20 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 21 | #include <dirent.h> |
| 22 | #include <errno.h> |
Dan Albert | 7664901 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 23 | #include <linux/usb/ch9.h> |
| 24 | #include <linux/usb/functionfs.h> |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| 28 | #include <sys/ioctl.h> |
Jerry Zhang | ecee434 | 2017-07-18 14:07:57 -0700 | [diff] [blame] | 29 | #include <sys/mman.h> |
Dan Albert | 7664901 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 30 | #include <sys/types.h> |
| 31 | #include <unistd.h> |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 32 | |
Josh Gao | ae72b5a | 2015-12-17 13:45:18 -0800 | [diff] [blame] | 33 | #include <algorithm> |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 34 | #include <atomic> |
Elliott Hughes | dbe91ee | 2016-11-15 12:37:32 -0800 | [diff] [blame] | 35 | #include <chrono> |
Josh Gao | 0cd3ae1 | 2016-09-21 12:37:10 -0700 | [diff] [blame] | 36 | #include <condition_variable> |
| 37 | #include <mutex> |
Elliott Hughes | dbe91ee | 2016-11-15 12:37:32 -0800 | [diff] [blame] | 38 | #include <thread> |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 39 | |
| 40 | #include <android-base/logging.h> |
Elliott Hughes | ffdec18 | 2016-09-23 15:40:03 -0700 | [diff] [blame] | 41 | #include <android-base/properties.h> |
Josh Gao | ae72b5a | 2015-12-17 13:45:18 -0800 | [diff] [blame] | 42 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 43 | #include "adb.h" |
Josh Gao | 44c688c | 2017-01-11 17:37:35 -0800 | [diff] [blame] | 44 | #include "daemon/usb.h" |
Dan Albert | 7664901 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 45 | #include "transport.h" |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 46 | |
Elliott Hughes | dbe91ee | 2016-11-15 12:37:32 -0800 | [diff] [blame] | 47 | using namespace std::chrono_literals; |
| 48 | |
Josh Gao | 44c688c | 2017-01-11 17:37:35 -0800 | [diff] [blame] | 49 | #define MAX_PACKET_SIZE_FS 64 |
| 50 | #define MAX_PACKET_SIZE_HS 512 |
| 51 | #define MAX_PACKET_SIZE_SS 1024 |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 52 | |
Jerry Zhang | 55205a5 | 2017-01-04 12:34:38 -0800 | [diff] [blame] | 53 | #define USB_FFS_BULK_SIZE 16384 |
Josh Gao | ae72b5a | 2015-12-17 13:45:18 -0800 | [diff] [blame] | 54 | |
Jerry Zhang | ecee434 | 2017-07-18 14:07:57 -0700 | [diff] [blame] | 55 | // Number of buffers needed to fit MAX_PAYLOAD, with an extra for ZLPs. |
| 56 | #define USB_FFS_NUM_BUFS ((MAX_PAYLOAD / USB_FFS_BULK_SIZE) + 1) |
| 57 | |
Josh Gao | 44c688c | 2017-01-11 17:37:35 -0800 | [diff] [blame] | 58 | #define cpu_to_le16(x) htole16(x) |
| 59 | #define cpu_to_le32(x) htole32(x) |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 60 | |
Jerry Zhang | 55205a5 | 2017-01-04 12:34:38 -0800 | [diff] [blame] | 61 | #define FUNCTIONFS_ENDPOINT_ALLOC _IOR('g', 231, __u32) |
| 62 | |
Jerry Zhang | 40a8778 | 2017-04-27 15:00:13 -0700 | [diff] [blame] | 63 | static constexpr size_t ENDPOINT_ALLOC_RETRIES = 10; |
Jerry Zhang | 55205a5 | 2017-01-04 12:34:38 -0800 | [diff] [blame] | 64 | |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 65 | static int dummy_fd = -1; |
| 66 | |
Badhri Jagan Sridharan | ab3446d | 2014-10-27 18:26:17 -0700 | [diff] [blame] | 67 | struct func_desc { |
| 68 | struct usb_interface_descriptor intf; |
| 69 | struct usb_endpoint_descriptor_no_audio source; |
| 70 | struct usb_endpoint_descriptor_no_audio sink; |
| 71 | } __attribute__((packed)); |
| 72 | |
Jack Pham | a190c80 | 2015-06-02 10:36:43 -0700 | [diff] [blame] | 73 | struct ss_func_desc { |
| 74 | struct usb_interface_descriptor intf; |
| 75 | struct usb_endpoint_descriptor_no_audio source; |
| 76 | struct usb_ss_ep_comp_descriptor source_comp; |
| 77 | struct usb_endpoint_descriptor_no_audio sink; |
| 78 | struct usb_ss_ep_comp_descriptor sink_comp; |
| 79 | } __attribute__((packed)); |
| 80 | |
Badhri Jagan Sridharan | ab3446d | 2014-10-27 18:26:17 -0700 | [diff] [blame] | 81 | struct desc_v1 { |
| 82 | struct usb_functionfs_descs_head_v1 { |
| 83 | __le32 magic; |
| 84 | __le32 length; |
| 85 | __le32 fs_count; |
| 86 | __le32 hs_count; |
| 87 | } __attribute__((packed)) header; |
| 88 | struct func_desc fs_descs, hs_descs; |
| 89 | } __attribute__((packed)); |
| 90 | |
| 91 | struct desc_v2 { |
Christopher Ferris | c49f51c | 2015-01-23 17:09:56 -0800 | [diff] [blame] | 92 | struct usb_functionfs_descs_head_v2 header; |
| 93 | // The rest of the structure depends on the flags in the header. |
| 94 | __le32 fs_count; |
| 95 | __le32 hs_count; |
Jack Pham | a190c80 | 2015-06-02 10:36:43 -0700 | [diff] [blame] | 96 | __le32 ss_count; |
Badhri Jagan Sridharan | ca2a0bd | 2015-10-05 13:04:03 -0700 | [diff] [blame] | 97 | __le32 os_count; |
Badhri Jagan Sridharan | ab3446d | 2014-10-27 18:26:17 -0700 | [diff] [blame] | 98 | struct func_desc fs_descs, hs_descs; |
Jack Pham | a190c80 | 2015-06-02 10:36:43 -0700 | [diff] [blame] | 99 | struct ss_func_desc ss_descs; |
Badhri Jagan Sridharan | ca2a0bd | 2015-10-05 13:04:03 -0700 | [diff] [blame] | 100 | struct usb_os_desc_header os_header; |
| 101 | struct usb_ext_compat_desc os_desc; |
Badhri Jagan Sridharan | ab3446d | 2014-10-27 18:26:17 -0700 | [diff] [blame] | 102 | } __attribute__((packed)); |
| 103 | |
Elliott Hughes | 3edd54b | 2015-05-05 18:26:10 -0700 | [diff] [blame] | 104 | static struct func_desc fs_descriptors = { |
Badhri Jagan Sridharan | ab3446d | 2014-10-27 18:26:17 -0700 | [diff] [blame] | 105 | .intf = { |
| 106 | .bLength = sizeof(fs_descriptors.intf), |
| 107 | .bDescriptorType = USB_DT_INTERFACE, |
| 108 | .bInterfaceNumber = 0, |
| 109 | .bNumEndpoints = 2, |
| 110 | .bInterfaceClass = ADB_CLASS, |
| 111 | .bInterfaceSubClass = ADB_SUBCLASS, |
| 112 | .bInterfaceProtocol = ADB_PROTOCOL, |
| 113 | .iInterface = 1, /* first string from the provided table */ |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 114 | }, |
Badhri Jagan Sridharan | ab3446d | 2014-10-27 18:26:17 -0700 | [diff] [blame] | 115 | .source = { |
| 116 | .bLength = sizeof(fs_descriptors.source), |
| 117 | .bDescriptorType = USB_DT_ENDPOINT, |
| 118 | .bEndpointAddress = 1 | USB_DIR_OUT, |
| 119 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
| 120 | .wMaxPacketSize = MAX_PACKET_SIZE_FS, |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 121 | }, |
Badhri Jagan Sridharan | ab3446d | 2014-10-27 18:26:17 -0700 | [diff] [blame] | 122 | .sink = { |
| 123 | .bLength = sizeof(fs_descriptors.sink), |
| 124 | .bDescriptorType = USB_DT_ENDPOINT, |
| 125 | .bEndpointAddress = 2 | USB_DIR_IN, |
| 126 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
| 127 | .wMaxPacketSize = MAX_PACKET_SIZE_FS, |
| 128 | }, |
| 129 | }; |
| 130 | |
Elliott Hughes | 3edd54b | 2015-05-05 18:26:10 -0700 | [diff] [blame] | 131 | static struct func_desc hs_descriptors = { |
Badhri Jagan Sridharan | ab3446d | 2014-10-27 18:26:17 -0700 | [diff] [blame] | 132 | .intf = { |
| 133 | .bLength = sizeof(hs_descriptors.intf), |
| 134 | .bDescriptorType = USB_DT_INTERFACE, |
| 135 | .bInterfaceNumber = 0, |
| 136 | .bNumEndpoints = 2, |
| 137 | .bInterfaceClass = ADB_CLASS, |
| 138 | .bInterfaceSubClass = ADB_SUBCLASS, |
| 139 | .bInterfaceProtocol = ADB_PROTOCOL, |
| 140 | .iInterface = 1, /* first string from the provided table */ |
| 141 | }, |
| 142 | .source = { |
| 143 | .bLength = sizeof(hs_descriptors.source), |
| 144 | .bDescriptorType = USB_DT_ENDPOINT, |
| 145 | .bEndpointAddress = 1 | USB_DIR_OUT, |
| 146 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
| 147 | .wMaxPacketSize = MAX_PACKET_SIZE_HS, |
| 148 | }, |
| 149 | .sink = { |
| 150 | .bLength = sizeof(hs_descriptors.sink), |
| 151 | .bDescriptorType = USB_DT_ENDPOINT, |
| 152 | .bEndpointAddress = 2 | USB_DIR_IN, |
| 153 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
| 154 | .wMaxPacketSize = MAX_PACKET_SIZE_HS, |
Zhuang Jin Can | d6ee9f2 | 2014-09-02 13:04:44 +0800 | [diff] [blame] | 155 | }, |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 156 | }; |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 157 | |
Jack Pham | a190c80 | 2015-06-02 10:36:43 -0700 | [diff] [blame] | 158 | static struct ss_func_desc ss_descriptors = { |
| 159 | .intf = { |
| 160 | .bLength = sizeof(ss_descriptors.intf), |
| 161 | .bDescriptorType = USB_DT_INTERFACE, |
| 162 | .bInterfaceNumber = 0, |
| 163 | .bNumEndpoints = 2, |
| 164 | .bInterfaceClass = ADB_CLASS, |
| 165 | .bInterfaceSubClass = ADB_SUBCLASS, |
| 166 | .bInterfaceProtocol = ADB_PROTOCOL, |
| 167 | .iInterface = 1, /* first string from the provided table */ |
| 168 | }, |
| 169 | .source = { |
| 170 | .bLength = sizeof(ss_descriptors.source), |
| 171 | .bDescriptorType = USB_DT_ENDPOINT, |
| 172 | .bEndpointAddress = 1 | USB_DIR_OUT, |
| 173 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
| 174 | .wMaxPacketSize = MAX_PACKET_SIZE_SS, |
| 175 | }, |
| 176 | .source_comp = { |
| 177 | .bLength = sizeof(ss_descriptors.source_comp), |
| 178 | .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, |
Jerry Zhang | b5a34a2 | 2017-02-10 17:43:00 -0800 | [diff] [blame] | 179 | .bMaxBurst = 4, |
Jack Pham | a190c80 | 2015-06-02 10:36:43 -0700 | [diff] [blame] | 180 | }, |
| 181 | .sink = { |
| 182 | .bLength = sizeof(ss_descriptors.sink), |
| 183 | .bDescriptorType = USB_DT_ENDPOINT, |
| 184 | .bEndpointAddress = 2 | USB_DIR_IN, |
| 185 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
| 186 | .wMaxPacketSize = MAX_PACKET_SIZE_SS, |
| 187 | }, |
| 188 | .sink_comp = { |
| 189 | .bLength = sizeof(ss_descriptors.sink_comp), |
| 190 | .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, |
Jerry Zhang | b5a34a2 | 2017-02-10 17:43:00 -0800 | [diff] [blame] | 191 | .bMaxBurst = 4, |
Jack Pham | a190c80 | 2015-06-02 10:36:43 -0700 | [diff] [blame] | 192 | }, |
| 193 | }; |
| 194 | |
Badhri Jagan Sridharan | ca2a0bd | 2015-10-05 13:04:03 -0700 | [diff] [blame] | 195 | struct usb_ext_compat_desc os_desc_compat = { |
| 196 | .bFirstInterfaceNumber = 0, |
| 197 | .Reserved1 = cpu_to_le32(1), |
| 198 | .CompatibleID = {0}, |
| 199 | .SubCompatibleID = {0}, |
| 200 | .Reserved2 = {0}, |
| 201 | }; |
| 202 | |
| 203 | static struct usb_os_desc_header os_desc_header = { |
| 204 | .interface = cpu_to_le32(1), |
| 205 | .dwLength = cpu_to_le32(sizeof(os_desc_header) + sizeof(os_desc_compat)), |
| 206 | .bcdVersion = cpu_to_le32(1), |
| 207 | .wIndex = cpu_to_le32(4), |
| 208 | .bCount = cpu_to_le32(1), |
| 209 | .Reserved = cpu_to_le32(0), |
| 210 | }; |
| 211 | |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 212 | #define STR_INTERFACE_ "ADB Interface" |
| 213 | |
| 214 | static const struct { |
| 215 | struct usb_functionfs_strings_head header; |
| 216 | struct { |
| 217 | __le16 code; |
| 218 | const char str1[sizeof(STR_INTERFACE_)]; |
| 219 | } __attribute__((packed)) lang0; |
| 220 | } __attribute__((packed)) strings = { |
| 221 | .header = { |
| 222 | .magic = cpu_to_le32(FUNCTIONFS_STRINGS_MAGIC), |
| 223 | .length = cpu_to_le32(sizeof(strings)), |
| 224 | .str_count = cpu_to_le32(1), |
| 225 | .lang_count = cpu_to_le32(1), |
| 226 | }, |
| 227 | .lang0 = { |
| 228 | cpu_to_le16(0x0409), /* en-us */ |
| 229 | STR_INTERFACE_, |
| 230 | }, |
| 231 | }; |
| 232 | |
Jerry Zhang | ecee434 | 2017-07-18 14:07:57 -0700 | [diff] [blame] | 233 | static void aio_block_init(aio_block* aiob) { |
| 234 | aiob->iocb.resize(USB_FFS_NUM_BUFS); |
| 235 | aiob->iocbs.resize(USB_FFS_NUM_BUFS); |
| 236 | aiob->events.resize(USB_FFS_NUM_BUFS); |
| 237 | aiob->num_submitted = 0; |
| 238 | for (unsigned i = 0; i < USB_FFS_NUM_BUFS; i++) { |
| 239 | aiob->iocbs[i] = &aiob->iocb[i]; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | static int getMaxPacketSize(int ffs_fd) { |
| 244 | usb_endpoint_descriptor desc; |
| 245 | if (ioctl(ffs_fd, FUNCTIONFS_ENDPOINT_DESC, reinterpret_cast<unsigned long>(&desc))) { |
| 246 | D("[ could not get endpoint descriptor! (%d) ]", errno); |
| 247 | return MAX_PACKET_SIZE_HS; |
| 248 | } else { |
| 249 | return desc.wMaxPacketSize; |
| 250 | } |
| 251 | } |
| 252 | |
Josh Gao | 44c688c | 2017-01-11 17:37:35 -0800 | [diff] [blame] | 253 | bool init_functionfs(struct usb_handle* h) { |
Josh Gao | 184f571 | 2017-07-26 11:06:55 -0700 | [diff] [blame] | 254 | LOG(INFO) << "initializing functionfs"; |
| 255 | |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 256 | ssize_t ret; |
Badhri Jagan Sridharan | ab3446d | 2014-10-27 18:26:17 -0700 | [diff] [blame] | 257 | struct desc_v1 v1_descriptor; |
| 258 | struct desc_v2 v2_descriptor; |
Jerry Zhang | 55205a5 | 2017-01-04 12:34:38 -0800 | [diff] [blame] | 259 | size_t retries = 0; |
Badhri Jagan Sridharan | ab3446d | 2014-10-27 18:26:17 -0700 | [diff] [blame] | 260 | |
| 261 | v2_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2); |
| 262 | v2_descriptor.header.length = cpu_to_le32(sizeof(v2_descriptor)); |
Jack Pham | a190c80 | 2015-06-02 10:36:43 -0700 | [diff] [blame] | 263 | v2_descriptor.header.flags = FUNCTIONFS_HAS_FS_DESC | FUNCTIONFS_HAS_HS_DESC | |
Badhri Jagan Sridharan | ca2a0bd | 2015-10-05 13:04:03 -0700 | [diff] [blame] | 264 | FUNCTIONFS_HAS_SS_DESC | FUNCTIONFS_HAS_MS_OS_DESC; |
Christopher Ferris | c49f51c | 2015-01-23 17:09:56 -0800 | [diff] [blame] | 265 | v2_descriptor.fs_count = 3; |
| 266 | v2_descriptor.hs_count = 3; |
Jack Pham | a190c80 | 2015-06-02 10:36:43 -0700 | [diff] [blame] | 267 | v2_descriptor.ss_count = 5; |
Badhri Jagan Sridharan | ca2a0bd | 2015-10-05 13:04:03 -0700 | [diff] [blame] | 268 | v2_descriptor.os_count = 1; |
Badhri Jagan Sridharan | ab3446d | 2014-10-27 18:26:17 -0700 | [diff] [blame] | 269 | v2_descriptor.fs_descs = fs_descriptors; |
| 270 | v2_descriptor.hs_descs = hs_descriptors; |
Jack Pham | a190c80 | 2015-06-02 10:36:43 -0700 | [diff] [blame] | 271 | v2_descriptor.ss_descs = ss_descriptors; |
Badhri Jagan Sridharan | ca2a0bd | 2015-10-05 13:04:03 -0700 | [diff] [blame] | 272 | v2_descriptor.os_header = os_desc_header; |
| 273 | v2_descriptor.os_desc = os_desc_compat; |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 274 | |
Siqi Lin | 8c40762 | 2016-05-26 13:04:52 -0700 | [diff] [blame] | 275 | if (h->control < 0) { // might have already done this before |
Josh Gao | 184f571 | 2017-07-26 11:06:55 -0700 | [diff] [blame] | 276 | LOG(INFO) << "opening control endpoint " << USB_FFS_ADB_EP0; |
Siqi Lin | 8c40762 | 2016-05-26 13:04:52 -0700 | [diff] [blame] | 277 | h->control = adb_open(USB_FFS_ADB_EP0, O_RDWR); |
| 278 | if (h->control < 0) { |
Josh Gao | 184f571 | 2017-07-26 11:06:55 -0700 | [diff] [blame] | 279 | PLOG(ERROR) << "cannot open control endpoint " << USB_FFS_ADB_EP0; |
Jack Pham | 4cbf1d8 | 2013-12-23 17:46:10 -0800 | [diff] [blame] | 280 | goto err; |
| 281 | } |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 282 | |
Siqi Lin | 8c40762 | 2016-05-26 13:04:52 -0700 | [diff] [blame] | 283 | ret = adb_write(h->control, &v2_descriptor, sizeof(v2_descriptor)); |
| 284 | if (ret < 0) { |
| 285 | v1_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC); |
| 286 | v1_descriptor.header.length = cpu_to_le32(sizeof(v1_descriptor)); |
| 287 | v1_descriptor.header.fs_count = 3; |
| 288 | v1_descriptor.header.hs_count = 3; |
| 289 | v1_descriptor.fs_descs = fs_descriptors; |
| 290 | v1_descriptor.hs_descs = hs_descriptors; |
| 291 | D("[ %s: Switching to V1_descriptor format errno=%d ]", USB_FFS_ADB_EP0, errno); |
| 292 | ret = adb_write(h->control, &v1_descriptor, sizeof(v1_descriptor)); |
| 293 | if (ret < 0) { |
| 294 | D("[ %s: write descriptors failed: errno=%d ]", USB_FFS_ADB_EP0, errno); |
| 295 | goto err; |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | ret = adb_write(h->control, &strings, sizeof(strings)); |
| 300 | if (ret < 0) { |
| 301 | D("[ %s: writing strings failed: errno=%d]", USB_FFS_ADB_EP0, errno); |
| 302 | goto err; |
| 303 | } |
Badhri Jagan Sridharan | 43fd1a4 | 2017-03-07 17:30:03 -0800 | [diff] [blame] | 304 | //Signal only when writing the descriptors to ffs |
| 305 | android::base::SetProperty("sys.usb.ffs.ready", "1"); |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | h->bulk_out = adb_open(USB_FFS_ADB_OUT, O_RDWR); |
| 309 | if (h->bulk_out < 0) { |
Josh Gao | 184f571 | 2017-07-26 11:06:55 -0700 | [diff] [blame] | 310 | PLOG(ERROR) << "cannot open bulk-out endpoint " << USB_FFS_ADB_OUT; |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 311 | goto err; |
| 312 | } |
| 313 | |
| 314 | h->bulk_in = adb_open(USB_FFS_ADB_IN, O_RDWR); |
| 315 | if (h->bulk_in < 0) { |
Josh Gao | 184f571 | 2017-07-26 11:06:55 -0700 | [diff] [blame] | 316 | PLOG(ERROR) << "cannot open bulk-in endpoint " << USB_FFS_ADB_IN; |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 317 | goto err; |
| 318 | } |
| 319 | |
Jerry Zhang | c3d4e72 | 2018-02-12 16:15:50 -0800 | [diff] [blame] | 320 | memset(&h->read_aiob.ctx, 0, sizeof(h->read_aiob.ctx)); |
| 321 | memset(&h->write_aiob.ctx, 0, sizeof(h->write_aiob.ctx)); |
Jerry Zhang | ecee434 | 2017-07-18 14:07:57 -0700 | [diff] [blame] | 322 | if (io_setup(USB_FFS_NUM_BUFS, &h->read_aiob.ctx) || |
| 323 | io_setup(USB_FFS_NUM_BUFS, &h->write_aiob.ctx)) { |
| 324 | D("[ aio: got error on io_setup (%d) ]", errno); |
| 325 | } |
| 326 | |
| 327 | h->read_aiob.fd = h->bulk_out; |
| 328 | h->write_aiob.fd = h->bulk_in; |
| 329 | |
Jerry Zhang | 55205a5 | 2017-01-04 12:34:38 -0800 | [diff] [blame] | 330 | h->max_rw = MAX_PAYLOAD; |
| 331 | while (h->max_rw >= USB_FFS_BULK_SIZE && retries < ENDPOINT_ALLOC_RETRIES) { |
| 332 | int ret_in = ioctl(h->bulk_in, FUNCTIONFS_ENDPOINT_ALLOC, static_cast<__u32>(h->max_rw)); |
| 333 | int errno_in = errno; |
| 334 | int ret_out = ioctl(h->bulk_out, FUNCTIONFS_ENDPOINT_ALLOC, static_cast<__u32>(h->max_rw)); |
| 335 | int errno_out = errno; |
| 336 | |
| 337 | if (ret_in || ret_out) { |
| 338 | if (errno_in == ENODEV || errno_out == ENODEV) { |
| 339 | std::this_thread::sleep_for(100ms); |
| 340 | retries += 1; |
| 341 | continue; |
| 342 | } |
| 343 | h->max_rw /= 2; |
| 344 | } else { |
| 345 | return true; |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | D("[ adb: cannot call endpoint alloc: errno=%d ]", errno); |
| 350 | // Kernel pre-allocation could have failed for recoverable reasons. |
| 351 | // Continue running with a safe max rw size. |
Jerry Zhang | f3fb7de | 2017-02-21 14:37:07 -0800 | [diff] [blame] | 352 | h->max_rw = USB_FFS_BULK_SIZE; |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 353 | return true; |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 354 | |
| 355 | err: |
| 356 | if (h->bulk_in > 0) { |
| 357 | adb_close(h->bulk_in); |
| 358 | h->bulk_in = -1; |
| 359 | } |
| 360 | if (h->bulk_out > 0) { |
| 361 | adb_close(h->bulk_out); |
| 362 | h->bulk_out = -1; |
| 363 | } |
| 364 | if (h->control > 0) { |
| 365 | adb_close(h->control); |
| 366 | h->control = -1; |
| 367 | } |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 368 | return false; |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 369 | } |
| 370 | |
Josh Gao | d9db09c | 2016-02-12 14:31:15 -0800 | [diff] [blame] | 371 | static void usb_ffs_open_thread(void* x) { |
Josh Gao | 183b73e | 2017-01-11 14:39:19 -0800 | [diff] [blame] | 372 | struct usb_handle* usb = (struct usb_handle*)x; |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 373 | |
Siva Velusamy | 49ee7cf | 2015-08-28 16:37:29 -0700 | [diff] [blame] | 374 | adb_thread_setname("usb ffs open"); |
| 375 | |
Elliott Hughes | a7090b9 | 2015-04-17 17:03:59 -0700 | [diff] [blame] | 376 | while (true) { |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 377 | // wait until the USB device needs opening |
Josh Gao | 0cd3ae1 | 2016-09-21 12:37:10 -0700 | [diff] [blame] | 378 | std::unique_lock<std::mutex> lock(usb->lock); |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 379 | while (!usb->open_new_connection) { |
Josh Gao | 0cd3ae1 | 2016-09-21 12:37:10 -0700 | [diff] [blame] | 380 | usb->notify.wait(lock); |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 381 | } |
| 382 | usb->open_new_connection = false; |
Josh Gao | 0cd3ae1 | 2016-09-21 12:37:10 -0700 | [diff] [blame] | 383 | lock.unlock(); |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 384 | |
Elliott Hughes | a7090b9 | 2015-04-17 17:03:59 -0700 | [diff] [blame] | 385 | while (true) { |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 386 | if (init_functionfs(usb)) { |
Josh Gao | 184f571 | 2017-07-26 11:06:55 -0700 | [diff] [blame] | 387 | LOG(INFO) << "functionfs successfully initialized"; |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 388 | break; |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 389 | } |
Elliott Hughes | dbe91ee | 2016-11-15 12:37:32 -0800 | [diff] [blame] | 390 | std::this_thread::sleep_for(1s); |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 391 | } |
| 392 | |
Josh Gao | 184f571 | 2017-07-26 11:06:55 -0700 | [diff] [blame] | 393 | LOG(INFO) << "registering usb transport"; |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 394 | register_usb_transport(usb, 0, 0, 1); |
| 395 | } |
| 396 | |
| 397 | // never gets here |
Josh Gao | d9db09c | 2016-02-12 14:31:15 -0800 | [diff] [blame] | 398 | abort(); |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 399 | } |
| 400 | |
Josh Gao | 6b531c4 | 2015-12-02 17:30:58 -0800 | [diff] [blame] | 401 | static int usb_ffs_write(usb_handle* h, const void* data, int len) { |
Yabin Cui | 7a3f8d6 | 2015-09-02 17:44:28 -0700 | [diff] [blame] | 402 | D("about to write (fd=%d, len=%d)", h->bulk_in, len); |
Josh Gao | 6b531c4 | 2015-12-02 17:30:58 -0800 | [diff] [blame] | 403 | |
Josh Gao | 6b531c4 | 2015-12-02 17:30:58 -0800 | [diff] [blame] | 404 | const char* buf = static_cast<const char*>(data); |
| 405 | while (len > 0) { |
Jerry Zhang | 55205a5 | 2017-01-04 12:34:38 -0800 | [diff] [blame] | 406 | int write_len = std::min(h->max_rw, len); |
Josh Gao | 6b531c4 | 2015-12-02 17:30:58 -0800 | [diff] [blame] | 407 | int n = adb_write(h->bulk_in, buf, write_len); |
| 408 | if (n < 0) { |
| 409 | D("ERROR: fd = %d, n = %d: %s", h->bulk_in, n, strerror(errno)); |
| 410 | return -1; |
| 411 | } |
| 412 | buf += n; |
| 413 | len -= n; |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 414 | } |
Josh Gao | 6b531c4 | 2015-12-02 17:30:58 -0800 | [diff] [blame] | 415 | |
Yabin Cui | 7a3f8d6 | 2015-09-02 17:44:28 -0700 | [diff] [blame] | 416 | D("[ done fd=%d ]", h->bulk_in); |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 417 | return 0; |
| 418 | } |
| 419 | |
Josh Gao | 6b531c4 | 2015-12-02 17:30:58 -0800 | [diff] [blame] | 420 | static int usb_ffs_read(usb_handle* h, void* data, int len) { |
| 421 | D("about to read (fd=%d, len=%d)", h->bulk_out, len); |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 422 | |
Josh Gao | 6b531c4 | 2015-12-02 17:30:58 -0800 | [diff] [blame] | 423 | char* buf = static_cast<char*>(data); |
| 424 | while (len > 0) { |
Jerry Zhang | 55205a5 | 2017-01-04 12:34:38 -0800 | [diff] [blame] | 425 | int read_len = std::min(h->max_rw, len); |
Josh Gao | 0b19540 | 2015-12-16 11:00:08 -0800 | [diff] [blame] | 426 | int n = adb_read(h->bulk_out, buf, read_len); |
Josh Gao | 6b531c4 | 2015-12-02 17:30:58 -0800 | [diff] [blame] | 427 | if (n < 0) { |
| 428 | D("ERROR: fd = %d, n = %d: %s", h->bulk_out, n, strerror(errno)); |
Elliott Hughes | 8fcd8bc | 2015-08-25 10:59:45 -0700 | [diff] [blame] | 429 | return -1; |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 430 | } |
Josh Gao | 6b531c4 | 2015-12-02 17:30:58 -0800 | [diff] [blame] | 431 | buf += n; |
| 432 | len -= n; |
Elliott Hughes | 8fcd8bc | 2015-08-25 10:59:45 -0700 | [diff] [blame] | 433 | } |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 434 | |
Yabin Cui | 7a3f8d6 | 2015-09-02 17:44:28 -0700 | [diff] [blame] | 435 | D("[ done fd=%d ]", h->bulk_out); |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 436 | return 0; |
| 437 | } |
| 438 | |
Jerry Zhang | ecee434 | 2017-07-18 14:07:57 -0700 | [diff] [blame] | 439 | static int usb_ffs_do_aio(usb_handle* h, const void* data, int len, bool read) { |
| 440 | aio_block* aiob = read ? &h->read_aiob : &h->write_aiob; |
| 441 | bool zero_packet = false; |
| 442 | |
| 443 | int num_bufs = len / USB_FFS_BULK_SIZE + (len % USB_FFS_BULK_SIZE == 0 ? 0 : 1); |
| 444 | const char* cur_data = reinterpret_cast<const char*>(data); |
| 445 | int packet_size = getMaxPacketSize(aiob->fd); |
| 446 | |
| 447 | if (posix_madvise(const_cast<void*>(data), len, POSIX_MADV_SEQUENTIAL | POSIX_MADV_WILLNEED) < |
| 448 | 0) { |
| 449 | D("[ Failed to madvise: %d ]", errno); |
| 450 | } |
| 451 | |
| 452 | for (int i = 0; i < num_bufs; i++) { |
| 453 | int buf_len = std::min(len, USB_FFS_BULK_SIZE); |
| 454 | io_prep(&aiob->iocb[i], aiob->fd, cur_data, buf_len, 0, read); |
| 455 | |
| 456 | len -= buf_len; |
| 457 | cur_data += buf_len; |
| 458 | |
| 459 | if (len == 0 && buf_len % packet_size == 0 && read) { |
| 460 | // adb does not expect the device to send a zero packet after data transfer, |
| 461 | // but the host *does* send a zero packet for the device to read. |
| 462 | zero_packet = true; |
| 463 | } |
| 464 | } |
| 465 | if (zero_packet) { |
| 466 | io_prep(&aiob->iocb[num_bufs], aiob->fd, reinterpret_cast<const void*>(cur_data), |
| 467 | packet_size, 0, read); |
| 468 | num_bufs += 1; |
| 469 | } |
| 470 | |
| 471 | if (io_submit(aiob->ctx, num_bufs, aiob->iocbs.data()) < num_bufs) { |
| 472 | D("[ aio: got error submitting %s (%d) ]", read ? "read" : "write", errno); |
| 473 | return -1; |
| 474 | } |
| 475 | if (TEMP_FAILURE_RETRY( |
| 476 | io_getevents(aiob->ctx, num_bufs, num_bufs, aiob->events.data(), nullptr)) < num_bufs) { |
| 477 | D("[ aio: got error waiting %s (%d) ]", read ? "read" : "write", errno); |
| 478 | return -1; |
| 479 | } |
| 480 | for (int i = 0; i < num_bufs; i++) { |
| 481 | if (aiob->events[i].res < 0) { |
| 482 | errno = aiob->events[i].res; |
| 483 | D("[ aio: got error event on %s (%d) ]", read ? "read" : "write", errno); |
| 484 | return -1; |
| 485 | } |
| 486 | } |
| 487 | return 0; |
| 488 | } |
| 489 | |
| 490 | static int usb_ffs_aio_read(usb_handle* h, void* data, int len) { |
| 491 | return usb_ffs_do_aio(h, data, len, true); |
| 492 | } |
| 493 | |
| 494 | static int usb_ffs_aio_write(usb_handle* h, const void* data, int len) { |
| 495 | return usb_ffs_do_aio(h, data, len, false); |
| 496 | } |
| 497 | |
Josh Gao | 183b73e | 2017-01-11 14:39:19 -0800 | [diff] [blame] | 498 | static void usb_ffs_kick(usb_handle* h) { |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 499 | int err; |
| 500 | |
| 501 | err = ioctl(h->bulk_in, FUNCTIONFS_CLEAR_HALT); |
Yabin Cui | aed3c61 | 2015-09-22 15:52:57 -0700 | [diff] [blame] | 502 | if (err < 0) { |
Yabin Cui | 7a3f8d6 | 2015-09-02 17:44:28 -0700 | [diff] [blame] | 503 | D("[ kick: source (fd=%d) clear halt failed (%d) ]", h->bulk_in, errno); |
Yabin Cui | aed3c61 | 2015-09-22 15:52:57 -0700 | [diff] [blame] | 504 | } |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 505 | |
| 506 | err = ioctl(h->bulk_out, FUNCTIONFS_CLEAR_HALT); |
Yabin Cui | aed3c61 | 2015-09-22 15:52:57 -0700 | [diff] [blame] | 507 | if (err < 0) { |
Yabin Cui | 7a3f8d6 | 2015-09-02 17:44:28 -0700 | [diff] [blame] | 508 | D("[ kick: sink (fd=%d) clear halt failed (%d) ]", h->bulk_out, errno); |
Yabin Cui | aed3c61 | 2015-09-22 15:52:57 -0700 | [diff] [blame] | 509 | } |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 510 | |
Jack Pham | 4cbf1d8 | 2013-12-23 17:46:10 -0800 | [diff] [blame] | 511 | // don't close ep0 here, since we may not need to reinitialize it with |
| 512 | // the same descriptors again. if however ep1/ep2 fail to re-open in |
| 513 | // init_functionfs, only then would we close and open ep0 again. |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 514 | // Ditto the comment in usb_adb_kick. |
| 515 | h->kicked = true; |
| 516 | TEMP_FAILURE_RETRY(dup2(dummy_fd, h->bulk_out)); |
| 517 | TEMP_FAILURE_RETRY(dup2(dummy_fd, h->bulk_in)); |
| 518 | } |
| 519 | |
Josh Gao | 183b73e | 2017-01-11 14:39:19 -0800 | [diff] [blame] | 520 | static void usb_ffs_close(usb_handle* h) { |
Josh Gao | 184f571 | 2017-07-26 11:06:55 -0700 | [diff] [blame] | 521 | LOG(INFO) << "closing functionfs transport"; |
| 522 | |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 523 | h->kicked = false; |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 524 | adb_close(h->bulk_out); |
| 525 | adb_close(h->bulk_in); |
Jerry Zhang | ecee434 | 2017-07-18 14:07:57 -0700 | [diff] [blame] | 526 | io_destroy(h->read_aiob.ctx); |
| 527 | io_destroy(h->write_aiob.ctx); |
| 528 | |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 529 | // Notify usb_adb_open_thread to open a new connection. |
Josh Gao | 0cd3ae1 | 2016-09-21 12:37:10 -0700 | [diff] [blame] | 530 | h->lock.lock(); |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 531 | h->open_new_connection = true; |
Josh Gao | 0cd3ae1 | 2016-09-21 12:37:10 -0700 | [diff] [blame] | 532 | h->lock.unlock(); |
| 533 | h->notify.notify_one(); |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 534 | } |
| 535 | |
Josh Gao | 183b73e | 2017-01-11 14:39:19 -0800 | [diff] [blame] | 536 | static void usb_ffs_init() { |
Yabin Cui | 7a3f8d6 | 2015-09-02 17:44:28 -0700 | [diff] [blame] | 537 | D("[ usb_init - using FunctionFS ]"); |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 538 | |
Josh Gao | 0cd3ae1 | 2016-09-21 12:37:10 -0700 | [diff] [blame] | 539 | usb_handle* h = new usb_handle(); |
Elliott Hughes | dc3b459 | 2015-04-21 19:39:52 -0700 | [diff] [blame] | 540 | |
Jerry Zhang | ecee434 | 2017-07-18 14:07:57 -0700 | [diff] [blame] | 541 | if (android::base::GetBoolProperty("sys.usb.ffs.aio_compat", false)) { |
| 542 | // Devices on older kernels (< 3.18) will not have aio support for ffs |
| 543 | // unless backported. Fall back on the non-aio functions instead. |
| 544 | h->write = usb_ffs_write; |
| 545 | h->read = usb_ffs_read; |
| 546 | } else { |
| 547 | h->write = usb_ffs_aio_write; |
| 548 | h->read = usb_ffs_aio_read; |
| 549 | aio_block_init(&h->read_aiob); |
| 550 | aio_block_init(&h->write_aiob); |
| 551 | } |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 552 | h->kick = usb_ffs_kick; |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 553 | h->close = usb_ffs_close; |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 554 | |
Yabin Cui | 7a3f8d6 | 2015-09-02 17:44:28 -0700 | [diff] [blame] | 555 | D("[ usb_init - starting thread ]"); |
Josh Gao | e1dacfc | 2017-04-12 17:00:49 -0700 | [diff] [blame] | 556 | std::thread(usb_ffs_open_thread, h).detach(); |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 557 | } |
| 558 | |
Josh Gao | 183b73e | 2017-01-11 14:39:19 -0800 | [diff] [blame] | 559 | void usb_init() { |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 560 | dummy_fd = adb_open("/dev/null", O_WRONLY); |
| 561 | CHECK_NE(dummy_fd, -1); |
Josh Gao | 183b73e | 2017-01-11 14:39:19 -0800 | [diff] [blame] | 562 | usb_ffs_init(); |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 563 | } |
| 564 | |
Josh Gao | 183b73e | 2017-01-11 14:39:19 -0800 | [diff] [blame] | 565 | int usb_write(usb_handle* h, const void* data, int len) { |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 566 | return h->write(h, data, len); |
| 567 | } |
| 568 | |
Josh Gao | 183b73e | 2017-01-11 14:39:19 -0800 | [diff] [blame] | 569 | int usb_read(usb_handle* h, void* data, int len) { |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 570 | return h->read(h, data, len); |
| 571 | } |
Josh Gao | 0cd3ae1 | 2016-09-21 12:37:10 -0700 | [diff] [blame] | 572 | |
Josh Gao | 183b73e | 2017-01-11 14:39:19 -0800 | [diff] [blame] | 573 | int usb_close(usb_handle* h) { |
Yabin Cui | 9b53e4c | 2016-04-05 14:51:52 -0700 | [diff] [blame] | 574 | h->close(h); |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 575 | return 0; |
| 576 | } |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 577 | |
Josh Gao | 183b73e | 2017-01-11 14:39:19 -0800 | [diff] [blame] | 578 | void usb_kick(usb_handle* h) { |
Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 579 | h->kick(h); |
| 580 | } |