Changeset ca07cd3 in mainline for uspace/srv
- Timestamp:
- 2010-10-25T13:23:33Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 23cb44b
- Parents:
- 355f7c2
- Location:
- uspace/srv/hw/bus/usb/hcd/virtual
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/bus/usb/hcd/virtual/conndev.c
r355f7c2 rca07cd3 42 42 #include "hub.h" 43 43 44 #define DEVICE_NAME_MAXLENGTH 32 45 46 static int get_device_name(int phone, char *buffer, size_t len) 47 { 48 ipc_call_t answer_data; 49 ipcarg_t answer_rc; 50 aid_t req; 51 int rc; 52 53 req = async_send_0(phone, 54 IPC_M_USBVIRT_GET_NAME, 55 &answer_data); 56 57 rc = async_data_read_start(phone, buffer, len); 58 if (rc != EOK) { 59 async_wait_for(req, NULL); 60 return EINVAL; 61 } 62 63 async_wait_for(req, &answer_rc); 64 rc = (int)answer_rc; 65 66 if (IPC_GET_ARG1(answer_data) < len) { 67 len = IPC_GET_ARG1(answer_data); 68 } else { 69 len--; 70 } 71 buffer[len] = 0; 72 73 return rc; 74 } 75 44 76 /** Connection handler for communcation with virtual device. 45 77 * … … 53 85 assert(dev != NULL); 54 86 55 dprintf(0, "virtual device connected through phone %#x", phone_hash); 87 char devname[DEVICE_NAME_MAXLENGTH + 1]; 88 int rc = get_device_name(dev->phone, devname, DEVICE_NAME_MAXLENGTH); 89 90 dprintf(0, "virtual device connected (phone: %#x, name: %s)", 91 phone_hash, rc == EOK ? devname : "<unknown>"); 92 56 93 57 94 while (true) { -
uspace/srv/hw/bus/usb/hcd/virtual/devices.c
r355f7c2 rca07cd3 43 43 #include <str_error.h> 44 44 45 #include <usbvirt/ids.h>46 45 #include <usbvirt/hub.h> 47 46 … … 55 54 56 55 LIST_INITIALIZE(devices); 57 58 /** Recognise device by id.59 *60 * @param id Device id.61 * @param phone Callback phone.62 */63 virtdev_connection_t *virtdev_recognise(int id, int phone)64 {65 virtdev_connection_t * dev = virtdev_add_device(phone);66 67 /*68 * We do not want to mess-up the virtdev_add_device() as69 * the id is needed only before device probing/detection70 * is implemented.71 *72 * However, that does not mean that this will happen soon.73 */74 if (dev) {75 dev->id = id;76 }77 78 return dev;79 }80 56 81 57 /** Create virtual device. -
uspace/srv/hw/bus/usb/hcd/virtual/devices.h
r355f7c2 rca07cd3 45 45 /** Phone used when sending data to device. */ 46 46 int phone; 47 /** Device id. */48 int id;49 47 /** Linked-list handle. */ 50 48 link_t link; 51 49 } virtdev_connection_t; 52 50 53 virtdev_connection_t *virtdev_recognise(int, int);54 51 virtdev_connection_t *virtdev_add_device(int); 55 52 void virtdev_destroy_device(virtdev_connection_t *); -
uspace/srv/hw/bus/usb/hcd/virtual/hc.h
r355f7c2 rca07cd3 37 37 38 38 #include <usb/hcd.h> 39 #include <usbvirt/ ids.h>39 #include <usbvirt/hub.h> 40 40 41 41 /** Callback after transaction is sent to USB. -
uspace/srv/hw/bus/usb/hcd/virtual/hcd.c
r355f7c2 rca07cd3 89 89 return; 90 90 } else if (kind == 1) { 91 int device_id = IPC_GET_ARG2(call);92 91 virtdev_connection_t *dev 93 = virtdev_ recognise(device_id,callback);92 = virtdev_add_device(callback); 94 93 if (!dev) { 95 94 ipc_answer_0(callid, EEXISTS);
Note:
See TracChangeset
for help on using the changeset viewer.
