remote_usb.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010 Vojtech Horky
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00035 #include <async.h>
00036 #include <errno.h>
00037 
00038 #include "usb_iface.h"
00039 #include "ddf/driver.h"
00040 
00041 
00042 static void remote_usb_get_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
00043 static void remote_usb_get_interface(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
00044 static void remote_usb_get_hc_handle(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
00045 //static void remote_usb(device_t *, void *, ipc_callid_t, ipc_call_t *);
00046 
00048 static remote_iface_func_ptr_t remote_usb_iface_ops [] = {
00049         remote_usb_get_address,
00050         remote_usb_get_interface,
00051         remote_usb_get_hc_handle
00052 };
00053 
00056 remote_iface_t remote_usb_iface = {
00057         .method_count = sizeof(remote_usb_iface_ops) /
00058             sizeof(remote_usb_iface_ops[0]),
00059         .methods = remote_usb_iface_ops
00060 };
00061 
00062 
00063 void remote_usb_get_address(ddf_fun_t *fun, void *iface,
00064     ipc_callid_t callid, ipc_call_t *call)
00065 {
00066         usb_iface_t *usb_iface = (usb_iface_t *) iface;
00067 
00068         if (usb_iface->get_address == NULL) {
00069                 async_answer_0(callid, ENOTSUP);
00070                 return;
00071         }
00072 
00073         devman_handle_t handle = DEV_IPC_GET_ARG1(*call);
00074 
00075         usb_address_t address;
00076         int rc = usb_iface->get_address(fun, handle, &address);
00077         if (rc != EOK) {
00078                 async_answer_0(callid, rc);
00079         } else {
00080                 async_answer_1(callid, EOK, address);
00081         }
00082 }
00083 
00084 void remote_usb_get_interface(ddf_fun_t *fun, void *iface,
00085     ipc_callid_t callid, ipc_call_t *call)
00086 {
00087         usb_iface_t *usb_iface = (usb_iface_t *) iface;
00088 
00089         if (usb_iface->get_interface == NULL) {
00090                 async_answer_0(callid, ENOTSUP);
00091                 return;
00092         }
00093 
00094         devman_handle_t handle = DEV_IPC_GET_ARG1(*call);
00095 
00096         int iface_no;
00097         int rc = usb_iface->get_interface(fun, handle, &iface_no);
00098         if (rc != EOK) {
00099                 async_answer_0(callid, rc);
00100         } else {
00101                 async_answer_1(callid, EOK, iface_no);
00102         }
00103 }
00104 
00105 void remote_usb_get_hc_handle(ddf_fun_t *fun, void *iface,
00106     ipc_callid_t callid, ipc_call_t *call)
00107 {
00108         usb_iface_t *usb_iface = (usb_iface_t *) iface;
00109 
00110         if (usb_iface->get_hc_handle == NULL) {
00111                 async_answer_0(callid, ENOTSUP);
00112                 return;
00113         }
00114 
00115         devman_handle_t handle;
00116         int rc = usb_iface->get_hc_handle(fun, &handle);
00117         if (rc != EOK) {
00118                 async_answer_0(callid, rc);
00119         }
00120 
00121         async_answer_1(callid, EOK, (sysarg_t) handle);
00122 }
00123 
00124 
00125 

Generated on Thu Jun 2 07:45:47 2011 for HelenOS/USB by  doxygen 1.4.7