Changeset aab02fb in mainline
- Timestamp:
- 2010-10-26T22:21:45Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- efedee77
- Parents:
- fa2a361
- Location:
- uspace
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbvirt/Makefile
rfa2a361 raab02fb 36 36 callback.c \ 37 37 ctrlpipe.c \ 38 debug.c \ 38 39 main.c \ 39 40 stdreq.c \ -
uspace/lib/usbvirt/ctrlpipe.c
rfa2a361 raab02fb 45 45 ((value & GET_MIDBITS_MASK(size, shift)) >> shift) 46 46 47 usb_address_t dev_new_address = -1; 47 48 static const char *str_request_type(int type) 49 { 50 switch (type) { 51 case REQUEST_TYPE_STANDARD: 52 return "standard"; 53 case REQUEST_TYPE_CLASS: 54 return "class"; 55 default: 56 return "unknown"; 57 } 58 } 48 59 49 60 /** Tell request type. … … 59 70 int control_pipe(usbvirt_device_t *device, usbvirt_control_transfer_t *transfer) 60 71 { 72 device->lib_debug(device, 1, USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO, 73 "op on control pipe zero (request_size=%u)", transfer->request_size); 74 61 75 if (transfer->request_size < sizeof(usb_device_request_setup_packet_t)) { 62 76 return ENOMEM; … … 69 83 70 84 int rc = EOK; 85 86 device->lib_debug(device, 2, USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO, 87 "request type: %s", str_request_type(type)); 71 88 72 89 switch (type) { … … 97 114 98 115 device->new_address = -1; 116 117 device->lib_debug(device, 2, USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO, 118 "device address changed to %d (state %s)", 119 device->address, str_device_state(device->state)); 99 120 } 100 121 -
uspace/lib/usbvirt/device.h
rfa2a361 raab02fb 145 145 } usbvirt_control_transfer_t; 146 146 147 typedef enum { 148 USBVIRT_DEBUGTAG_BASE = 1, 149 USBVIRT_DEBUGTAG_TRANSACTION = 2, 150 USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO = 4, 151 USBVIRT_DEBUGTAG_ALL = 255 152 } usbvirt_debug_tags_t; 153 147 154 /** Virtual USB device. */ 148 155 struct usbvirt_device { … … 186 193 /** State information on control-transfer endpoints. */ 187 194 usbvirt_control_transfer_t current_control_transfers[USB11_ENDPOINT_MAX]; 195 196 /* User debugging. */ 197 198 /** Debug print. */ 199 void (*debug)(usbvirt_device_t *dev, int level, uint8_t tag, 200 const char *format, ...); 201 202 /** Current debug level. */ 203 int debug_level; 204 205 /** Bitmap of currently enabled tags. */ 206 uint8_t debug_enabled_tags; 207 208 /* Library debugging. */ 209 210 /** Debug print. */ 211 void (*lib_debug)(usbvirt_device_t *dev, int level, uint8_t tag, 212 const char *format, ...); 213 214 /** Current debug level. */ 215 int lib_debug_level; 216 217 /** Bitmap of currently enabled tags. */ 218 uint8_t lib_debug_enabled_tags; 188 219 }; 189 220 -
uspace/lib/usbvirt/main.c
rfa2a361 raab02fb 124 124 dev->control_transfer_reply = control_transfer_reply; 125 125 126 dev->debug = user_debug; 127 dev->lib_debug = lib_debug; 128 126 129 dev->state = USBVIRT_STATE_DEFAULT; 127 130 dev->address = 0; -
uspace/lib/usbvirt/private.h
rfa2a361 raab02fb 66 66 void *buffer, size_t size, size_t *data_size); 67 67 68 69 void user_debug(usbvirt_device_t *device, int level, uint8_t tag, 70 const char *format, ...); 71 void lib_debug(usbvirt_device_t *device, int level, uint8_t tag, 72 const char *format, ...); 73 74 static inline const char *str_device_state(usbvirt_device_state_t state) 75 { 76 switch (state) { 77 case USBVIRT_STATE_DEFAULT: 78 return "default"; 79 case USBVIRT_STATE_ADDRESS: 80 return "address"; 81 case USBVIRT_STATE_CONFIGURED: 82 return "configured"; 83 default: 84 return "unknown"; 85 } 86 } 87 68 88 #endif 69 89 /** -
uspace/lib/usbvirt/stdreq.c
rfa2a361 raab02fb 187 187 usb_device_request_setup_packet_t *request, uint8_t *data) 188 188 { 189 device->lib_debug(device, 3, USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO, 190 "handling standard request %d", request->request); 191 189 192 HANDLE_REQUEST(request, data, USB_DEVREQ_GET_DESCRIPTOR, 190 193 device, on_get_descriptor, -
uspace/lib/usbvirt/transaction.c
rfa2a361 raab02fb 67 67 void *buffer, size_t size) 68 68 { 69 device->lib_debug(device, 1, USBVIRT_DEBUGTAG_TRANSACTION, 70 "setup transaction: endpoint=%d, size=%u", endpoint, size); 71 69 72 usbvirt_control_transfer_t *transfer = &device->current_control_transfers[endpoint]; 70 73 … … 97 100 void *buffer, size_t size) 98 101 { 102 device->lib_debug(device, 1, USBVIRT_DEBUGTAG_TRANSACTION, 103 "out transaction: endpoint=%d, size=%u", endpoint, size); 104 99 105 /* 100 106 * First check whether it is a transaction over control pipe. … … 151 157 void *buffer, size_t size, size_t *data_size) 152 158 { 159 device->lib_debug(device, 1, USBVIRT_DEBUGTAG_TRANSACTION, 160 "in transaction: endpoint=%d, size=%u", endpoint, size); 161 153 162 /* 154 163 * First check whether it is a transaction over control pipe. -
uspace/srv/hw/bus/usb/hcd/virtual/hub.c
rfa2a361 raab02fb 141 141 .ops = &hub_ops, 142 142 .descriptors = &descriptors, 143 .lib_debug_level = 4, 144 .lib_debug_enabled_tags = USBVIRT_DEBUGTAG_ALL 143 145 }; 144 146
Note:
See TracChangeset
for help on using the changeset viewer.