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 <async.h>
00036 #include <errno.h>
00037
00038 #include "ops/hw_res.h"
00039 #include "ddf/driver.h"
00040
00041 static void remote_hw_res_get_resource_list(ddf_fun_t *, void *, ipc_callid_t,
00042 ipc_call_t *);
00043 static void remote_hw_res_enable_interrupt(ddf_fun_t *, void *, ipc_callid_t,
00044 ipc_call_t *);
00045
00046 static remote_iface_func_ptr_t remote_hw_res_iface_ops [] = {
00047 &remote_hw_res_get_resource_list,
00048 &remote_hw_res_enable_interrupt
00049 };
00050
00051 remote_iface_t remote_hw_res_iface = {
00052 .method_count = sizeof(remote_hw_res_iface_ops) /
00053 sizeof(remote_iface_func_ptr_t),
00054 .methods = remote_hw_res_iface_ops
00055 };
00056
00057 static void remote_hw_res_enable_interrupt(ddf_fun_t *fun, void *ops,
00058 ipc_callid_t callid, ipc_call_t *call)
00059 {
00060 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
00061
00062 if (hw_res_ops->enable_interrupt == NULL)
00063 async_answer_0(callid, ENOTSUP);
00064 else if (hw_res_ops->enable_interrupt(fun))
00065 async_answer_0(callid, EOK);
00066 else
00067 async_answer_0(callid, EREFUSED);
00068 }
00069
00070 static void remote_hw_res_get_resource_list(ddf_fun_t *fun, void *ops,
00071 ipc_callid_t callid, ipc_call_t *call)
00072 {
00073 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
00074
00075 if (hw_res_ops->get_resource_list == NULL) {
00076 async_answer_0(callid, ENOTSUP);
00077 return;
00078 }
00079
00080 hw_resource_list_t *hw_resources = hw_res_ops->get_resource_list(fun);
00081 if (hw_resources == NULL){
00082 async_answer_0(callid, ENOENT);
00083 return;
00084 }
00085
00086 async_answer_1(callid, EOK, hw_resources->count);
00087
00088 size_t len;
00089 if (!async_data_read_receive(&callid, &len)) {
00090
00091 return;
00092 }
00093 async_data_read_finalize(callid, hw_resources->resources, len);
00094 }
00095