00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00035 #include <ipc/devman.h>
00036 #include <devman.h>
00037 #include <async.h>
00038 #include <usb/ddfiface.h>
00039 #include <usb/hc.h>
00040 #include <usb/debug.h>
00041 #include <errno.h>
00042 #include <assert.h>
00043
00045 usb_iface_t usb_iface_hub_impl = {
00046 .get_hc_handle = usb_iface_get_hc_handle_hub_impl,
00047 .get_address = usb_iface_get_address_hub_impl
00048 };
00049
00051 usb_iface_t usb_iface_hub_child_impl = {
00052 .get_hc_handle = usb_iface_get_hc_handle_hub_child_impl,
00053 .get_address = usb_iface_get_address_hub_child_impl
00054 };
00055
00056
00063 int usb_iface_get_hc_handle_hub_impl(ddf_fun_t *fun, devman_handle_t *handle)
00064 {
00065 assert(fun);
00066 return usb_hc_find(fun->handle, handle);
00067 }
00068
00076 int usb_iface_get_hc_handle_hub_child_impl(ddf_fun_t *fun,
00077 devman_handle_t *handle)
00078 {
00079 assert(fun != NULL);
00080
00081 int parent_phone = devman_parent_device_connect(fun->handle,
00082 IPC_FLAG_BLOCKING);
00083 if (parent_phone < 0) {
00084 return parent_phone;
00085 }
00086
00087 sysarg_t hc_handle;
00088 int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
00089 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &hc_handle);
00090
00091 async_hangup(parent_phone);
00092
00093 if (rc != EOK) {
00094 return rc;
00095 }
00096
00097 *handle = hc_handle;
00098
00099 return EOK;
00100 }
00101
00108 int usb_iface_get_hc_handle_hc_impl(ddf_fun_t *fun, devman_handle_t *handle)
00109 {
00110 assert(fun);
00111
00112 if (handle != NULL) {
00113 *handle = fun->handle;
00114 }
00115
00116 return EOK;
00117 }
00118
00126 int usb_iface_get_address_hub_impl(ddf_fun_t *fun, devman_handle_t handle,
00127 usb_address_t *address)
00128 {
00129 assert(fun);
00130 int parent_phone = devman_parent_device_connect(fun->handle,
00131 IPC_FLAG_BLOCKING);
00132 if (parent_phone < 0) {
00133 return parent_phone;
00134 }
00135
00136 sysarg_t addr;
00137 int rc = async_req_2_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
00138 IPC_M_USB_GET_ADDRESS, handle, &addr);
00139
00140 async_hangup(parent_phone);
00141
00142 if (rc != EOK) {
00143 return rc;
00144 }
00145
00146 if (address != NULL) {
00147 *address = (usb_address_t) addr;
00148 }
00149
00150 return EOK;
00151 }
00152
00161 int usb_iface_get_address_hub_child_impl(ddf_fun_t *fun,
00162 devman_handle_t handle, usb_address_t *address)
00163 {
00164 if (handle == 0) {
00165 handle = fun->handle;
00166 }
00167 return usb_iface_get_address_hub_impl(fun, handle, address);
00168 }
00169