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
00034 #include <assert.h>
00035 #include <async.h>
00036 #include <errno.h>
00037
00038 #include "pci_dev_iface.h"
00039 #include "ddf/driver.h"
00040
00041 static void remote_config_space_read_8(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
00042 static void remote_config_space_read_16(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
00043 static void remote_config_space_read_32(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
00044
00045 static void remote_config_space_write_8(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
00046 static void remote_config_space_write_16(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
00047 static void remote_config_space_write_32(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
00048
00050 static remote_iface_func_ptr_t remote_pci_iface_ops [] = {
00051 remote_config_space_read_8,
00052 remote_config_space_read_16,
00053 remote_config_space_read_32,
00054
00055 remote_config_space_write_8,
00056 remote_config_space_write_16,
00057 remote_config_space_write_32
00058 };
00059
00062 remote_iface_t remote_pci_iface = {
00063 .method_count = sizeof(remote_pci_iface_ops) /
00064 sizeof(remote_pci_iface_ops[0]),
00065 .methods = remote_pci_iface_ops
00066 };
00067
00068 void remote_config_space_read_8(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
00069 {
00070 assert(iface);
00071 pci_dev_iface_t *pci_iface = (pci_dev_iface_t *)iface;
00072 if (pci_iface->config_space_read_8 == NULL) {
00073 async_answer_0(callid, ENOTSUP);
00074 return;
00075 }
00076 uint32_t address = DEV_IPC_GET_ARG1(*call);
00077 uint8_t value;
00078 int ret = pci_iface->config_space_read_8(fun, address, &value);
00079 if (ret != EOK) {
00080 async_answer_0(callid, ret);
00081 } else {
00082 async_answer_1(callid, EOK, value);
00083 }
00084 }
00085
00086 void remote_config_space_read_16(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
00087 {
00088 assert(iface);
00089 pci_dev_iface_t *pci_iface = (pci_dev_iface_t *)iface;
00090 if (pci_iface->config_space_read_16 == NULL) {
00091 async_answer_0(callid, ENOTSUP);
00092 return;
00093 }
00094 uint32_t address = DEV_IPC_GET_ARG1(*call);
00095 uint16_t value;
00096 int ret = pci_iface->config_space_read_16(fun, address, &value);
00097 if (ret != EOK) {
00098 async_answer_0(callid, ret);
00099 } else {
00100 async_answer_1(callid, EOK, value);
00101 }
00102 }
00103 void remote_config_space_read_32(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
00104 {
00105 assert(iface);
00106 pci_dev_iface_t *pci_iface = (pci_dev_iface_t *)iface;
00107 if (pci_iface->config_space_read_32 == NULL) {
00108 async_answer_0(callid, ENOTSUP);
00109 return;
00110 }
00111 uint32_t address = DEV_IPC_GET_ARG1(*call);
00112 uint32_t value;
00113 int ret = pci_iface->config_space_read_32(fun, address, &value);
00114 if (ret != EOK) {
00115 async_answer_0(callid, ret);
00116 } else {
00117 async_answer_1(callid, EOK, value);
00118 }
00119 }
00120
00121 void remote_config_space_write_8(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
00122 {
00123 assert(iface);
00124 pci_dev_iface_t *pci_iface = (pci_dev_iface_t *)iface;
00125 if (pci_iface->config_space_write_8 == NULL) {
00126 async_answer_0(callid, ENOTSUP);
00127 return;
00128 }
00129 uint32_t address = DEV_IPC_GET_ARG1(*call);
00130 uint8_t value = DEV_IPC_GET_ARG2(*call);
00131 int ret = pci_iface->config_space_write_8(fun, address, value);
00132 if (ret != EOK) {
00133 async_answer_0(callid, ret);
00134 } else {
00135 async_answer_0(callid, EOK);
00136 }
00137 }
00138
00139 void remote_config_space_write_16(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
00140 {
00141 assert(iface);
00142 pci_dev_iface_t *pci_iface = (pci_dev_iface_t *)iface;
00143 if (pci_iface->config_space_write_16 == NULL) {
00144 async_answer_0(callid, ENOTSUP);
00145 return;
00146 }
00147 uint32_t address = DEV_IPC_GET_ARG1(*call);
00148 uint16_t value = DEV_IPC_GET_ARG2(*call);
00149 int ret = pci_iface->config_space_write_16(fun, address, value);
00150 if (ret != EOK) {
00151 async_answer_0(callid, ret);
00152 } else {
00153 async_answer_0(callid, EOK);
00154 }
00155 }
00156
00157 void remote_config_space_write_32(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
00158 {
00159 assert(iface);
00160 pci_dev_iface_t *pci_iface = (pci_dev_iface_t *)iface;
00161 if (pci_iface->config_space_write_32 == NULL) {
00162 async_answer_0(callid, ENOTSUP);
00163 return;
00164 }
00165 uint32_t address = DEV_IPC_GET_ARG1(*call);
00166 uint32_t value = DEV_IPC_GET_ARG2(*call);
00167 int ret = pci_iface->config_space_write_32(fun, address, value);
00168 if (ret != EOK) {
00169 async_answer_0(callid, ret);
00170 } else {
00171 async_answer_0(callid, EOK);
00172 }
00173 }
00174
00175