Changes in uspace/lib/drv/generic/remote_usb.c [56bdd9a4:27ed734c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usb.c
r56bdd9a4 r27ed734c 1 1 /* 2 2 * Copyright (c) 2010 Vojtech Horky 3 * Copyright (c) 2011 Jan Vesely4 3 * All rights reserved. 5 4 * … … 40 39 #include "ddf/driver.h" 41 40 42 typedef enum {43 IPC_M_USB_GET_MY_ADDRESS,44 IPC_M_USB_GET_MY_INTERFACE,45 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE,46 } usb_iface_funcs_t;47 48 /** Tell USB address assigned to device.49 * @param exch Vaid IPC exchange50 * @param address Pointer to address storage place.51 * @return Error code.52 *53 * Exch param is an open communication to device implementing usb_iface.54 */55 int usb_get_my_address(async_exch_t *exch, usb_address_t *address)56 {57 if (!exch)58 return EINVAL;59 sysarg_t addr;60 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),61 IPC_M_USB_GET_MY_ADDRESS, &addr);62 63 if (ret == EOK && address != NULL)64 *address = (usb_address_t) addr;65 return ret;66 }67 /*----------------------------------------------------------------------------*/68 /** Tell interface number given device can use.69 * @param[in] exch IPC communication exchange70 * @param[in] handle Id of the device71 * @param[out] usb_iface Assigned USB interface72 * @return Error code.73 */74 int usb_get_my_interface(async_exch_t *exch, int *usb_iface)75 {76 if (!exch)77 return EINVAL;78 sysarg_t iface_no;79 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),80 IPC_M_USB_GET_MY_INTERFACE, &iface_no);81 if (ret == EOK && usb_iface)82 *usb_iface = (int)iface_no;83 return ret;84 }85 /*----------------------------------------------------------------------------*/86 /** Tell devman handle of device host controller.87 * @param[in] exch IPC communication exchange88 * @param[out] hc_handle devman handle of the HC used by the target device.89 * @return Error code.90 */91 int usb_get_hc_handle(async_exch_t *exch, devman_handle_t *hc_handle)92 {93 if (!exch)94 return EINVAL;95 devman_handle_t h;96 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),97 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);98 if (ret == EOK && hc_handle)99 *hc_handle = (devman_handle_t)h;100 return ret;101 }102 103 41 104 42 static void remote_usb_get_my_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 105 static void remote_usb_get_ my_interface(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);43 static void remote_usb_get_interface(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 106 44 static void remote_usb_get_hc_handle(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 45 //static void remote_usb(device_t *, void *, ipc_callid_t, ipc_call_t *); 107 46 108 47 /** Remote USB interface operations. */ 109 48 static remote_iface_func_ptr_t remote_usb_iface_ops [] = { 110 49 [IPC_M_USB_GET_MY_ADDRESS] = remote_usb_get_my_address, 111 [IPC_M_USB_GET_ MY_INTERFACE] = remote_usb_get_my_interface,50 [IPC_M_USB_GET_INTERFACE] = remote_usb_get_interface, 112 51 [IPC_M_USB_GET_HOST_CONTROLLER_HANDLE] = remote_usb_get_hc_handle, 113 52 }; … … 121 60 }; 122 61 123 /*----------------------------------------------------------------------------*/ 62 124 63 void remote_usb_get_my_address(ddf_fun_t *fun, void *iface, 125 64 ipc_callid_t callid, ipc_call_t *call) 126 65 { 127 constusb_iface_t *usb_iface = (usb_iface_t *) iface;66 usb_iface_t *usb_iface = (usb_iface_t *) iface; 128 67 129 68 if (usb_iface->get_my_address == NULL) { … … 133 72 134 73 usb_address_t address; 135 const int ret= usb_iface->get_my_address(fun, &address);136 if (r et!= EOK) {137 async_answer_0(callid, r et);74 int rc = usb_iface->get_my_address(fun, &address); 75 if (rc != EOK) { 76 async_answer_0(callid, rc); 138 77 } else { 139 78 async_answer_1(callid, EOK, address); 140 79 } 141 80 } 142 /*----------------------------------------------------------------------------*/ 143 void remote_usb_get_ my_interface(ddf_fun_t *fun, void *iface,81 82 void remote_usb_get_interface(ddf_fun_t *fun, void *iface, 144 83 ipc_callid_t callid, ipc_call_t *call) 145 84 { 146 constusb_iface_t *usb_iface = (usb_iface_t *) iface;85 usb_iface_t *usb_iface = (usb_iface_t *) iface; 147 86 148 if (usb_iface->get_ my_interface == NULL) {87 if (usb_iface->get_interface == NULL) { 149 88 async_answer_0(callid, ENOTSUP); 150 89 return; 151 90 } 152 91 92 devman_handle_t handle = DEV_IPC_GET_ARG1(*call); 93 153 94 int iface_no; 154 const int ret = usb_iface->get_my_interface(fun, &iface_no);155 if (r et!= EOK) {156 async_answer_0(callid, r et);95 int rc = usb_iface->get_interface(fun, handle, &iface_no); 96 if (rc != EOK) { 97 async_answer_0(callid, rc); 157 98 } else { 158 99 async_answer_1(callid, EOK, iface_no); 159 100 } 160 101 } 161 /*----------------------------------------------------------------------------*/ 102 162 103 void remote_usb_get_hc_handle(ddf_fun_t *fun, void *iface, 163 104 ipc_callid_t callid, ipc_call_t *call) 164 105 { 165 constusb_iface_t *usb_iface = (usb_iface_t *) iface;106 usb_iface_t *usb_iface = (usb_iface_t *) iface; 166 107 167 108 if (usb_iface->get_hc_handle == NULL) { … … 171 112 172 113 devman_handle_t handle; 173 const int ret= usb_iface->get_hc_handle(fun, &handle);174 if (r et!= EOK) {175 async_answer_0(callid, r et);114 int rc = usb_iface->get_hc_handle(fun, &handle); 115 if (rc != EOK) { 116 async_answer_0(callid, rc); 176 117 } 177 118 178 119 async_answer_1(callid, EOK, (sysarg_t) handle); 179 120 } 121 122 123 180 124 /** 181 125 * @}
Note:
See TracChangeset
for help on using the changeset viewer.