Changeset 47e3a8e in mainline for uspace/lib/usbvirt
- Timestamp:
- 2010-10-15T16:32:57Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 186d630
- Parents:
- 73301a0
- Location:
- uspace/lib/usbvirt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbvirt/device.h
r73301a0 r47e3a8e 106 106 } usbvirt_descriptors_t; 107 107 108 /** Possible states of virtual USB device. 109 * Notice that these are not 1:1 mappings to those in USB specification. 110 */ 111 typedef enum { 112 USBVIRT_STATE_DEFAULT, 113 USBVIRT_STATE_ADDRESS, 114 USBVIRT_STATE_CONFIGURED 115 } usbvirt_device_state_t; 108 116 117 /** Virtual USB device. */ 109 118 typedef struct usbvirt_device { 110 119 /** Callback device operations. */ … … 126 135 usbvirt_descriptors_t *descriptors; 127 136 137 /** Current device state. */ 138 usbvirt_device_state_t state; 139 /** Device address. */ 140 usb_address_t address; 128 141 129 142 /* Private attributes. */ -
uspace/lib/usbvirt/main.c
r73301a0 r47e3a8e 50 50 static void handle_data_to_device(ipc_callid_t iid, ipc_call_t icall) 51 51 { 52 usb_endpoint_t endpoint = IPC_GET_ARG1(icall); 52 usb_address_t address = IPC_GET_ARG1(icall); 53 usb_endpoint_t endpoint = IPC_GET_ARG2(icall); 54 55 if (address != device->address) { 56 ipc_answer_0(iid, EADDRNOTAVAIL); 57 return; 58 } 53 59 54 60 size_t len; … … 95 101 } 96 102 103 static void device_init(usbvirt_device_t *dev) 104 { 105 dev->send_data = usbvirt_data_to_host; 106 dev->state = USBVIRT_STATE_DEFAULT; 107 dev->address = 0; 108 } 109 97 110 int usbvirt_data_to_host(struct usbvirt_device *dev, 98 111 usb_endpoint_t endpoint, void *buffer, size_t size) … … 112 125 int rc; 113 126 114 req = async_send_ 1(phone,127 req = async_send_2(phone, 115 128 IPC_M_USBVIRT_DATA_FROM_DEVICE, 129 dev->address, 116 130 endpoint, 117 131 &answer_data); … … 174 188 175 189 dev->vhcd_phone_ = hcd_phone; 176 dev ->send_data = usbvirt_data_to_host;190 device_init(dev); 177 191 178 192 device = dev; -
uspace/lib/usbvirt/stdreq.c
r73301a0 r47e3a8e 118 118 119 119 /* 120 * TODO: inform the HC that device has new address assigned. 120 * TODO: handle when this request is invalid (e.g. 121 * setting address when in configured state). 121 122 */ 123 if (new_address == 0) { 124 device->state = USBVIRT_STATE_DEFAULT; 125 } else { 126 device->state = USBVIRT_STATE_ADDRESS; 127 } 128 129 device->address = new_address; 130 122 131 return EOK; 123 132 }
Note:
See TracChangeset
for help on using the changeset viewer.