Changeset 984a9ba in mainline for uspace/lib/drv/generic/remote_hw_res.c
- Timestamp:
- 2018-07-05T09:34:09Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 63d46341
- Parents:
- 76f566d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_hw_res.c
r76f566d r984a9ba 41 41 #include "ddf/driver.h" 42 42 43 static void remote_hw_res_get_resource_list(ddf_fun_t *, void *, cap_call_handle_t, 44 ipc_call_t *); 45 static void remote_hw_res_enable_interrupt(ddf_fun_t *, void *, cap_call_handle_t, 46 ipc_call_t *); 47 static void remote_hw_res_disable_interrupt(ddf_fun_t *, void *, cap_call_handle_t, 48 ipc_call_t *); 49 static void remote_hw_res_clear_interrupt(ddf_fun_t *, void *, cap_call_handle_t, 50 ipc_call_t *); 51 static void remote_hw_res_dma_channel_setup(ddf_fun_t *, void *, cap_call_handle_t, 52 ipc_call_t *); 53 static void remote_hw_res_dma_channel_remain(ddf_fun_t *, void *, cap_call_handle_t, 54 ipc_call_t *); 43 static void remote_hw_res_get_resource_list(ddf_fun_t *, void *, ipc_call_t *); 44 static void remote_hw_res_enable_interrupt(ddf_fun_t *, void *, ipc_call_t *); 45 static void remote_hw_res_disable_interrupt(ddf_fun_t *, void *, ipc_call_t *); 46 static void remote_hw_res_clear_interrupt(ddf_fun_t *, void *, ipc_call_t *); 47 static void remote_hw_res_dma_channel_setup(ddf_fun_t *, void *, ipc_call_t *); 48 static void remote_hw_res_dma_channel_remain(ddf_fun_t *, void *, ipc_call_t *); 55 49 56 50 static const remote_iface_func_ptr_t remote_hw_res_iface_ops [] = { … … 69 63 70 64 static void remote_hw_res_enable_interrupt(ddf_fun_t *fun, void *ops, 71 cap_call_handle_t chandle,ipc_call_t *call)65 ipc_call_t *call) 72 66 { 73 67 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops; 74 68 75 69 if (hw_res_ops->enable_interrupt == NULL) { 76 async_answer_0(c handle, ENOTSUP);70 async_answer_0(call, ENOTSUP); 77 71 return; 78 72 } … … 80 74 const int irq = DEV_IPC_GET_ARG1(*call); 81 75 const errno_t ret = hw_res_ops->enable_interrupt(fun, irq); 82 async_answer_0(c handle, ret);76 async_answer_0(call, ret); 83 77 } 84 78 85 79 static void remote_hw_res_disable_interrupt(ddf_fun_t *fun, void *ops, 86 cap_call_handle_t chandle,ipc_call_t *call)80 ipc_call_t *call) 87 81 { 88 82 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops; 89 83 90 84 if (hw_res_ops->disable_interrupt == NULL) { 91 async_answer_0(c handle, ENOTSUP);85 async_answer_0(call, ENOTSUP); 92 86 return; 93 87 } … … 95 89 const int irq = DEV_IPC_GET_ARG1(*call); 96 90 const errno_t ret = hw_res_ops->disable_interrupt(fun, irq); 97 async_answer_0(c handle, ret);91 async_answer_0(call, ret); 98 92 } 99 93 100 94 static void remote_hw_res_clear_interrupt(ddf_fun_t *fun, void *ops, 101 cap_call_handle_t chandle,ipc_call_t *call)95 ipc_call_t *call) 102 96 { 103 97 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops; 104 98 105 99 if (hw_res_ops->clear_interrupt == NULL) { 106 async_answer_0(c handle, ENOTSUP);100 async_answer_0(call, ENOTSUP); 107 101 return; 108 102 } … … 110 104 const int irq = DEV_IPC_GET_ARG1(*call); 111 105 const errno_t ret = hw_res_ops->enable_interrupt(fun, irq); 112 async_answer_0(c handle, ret);106 async_answer_0(call, ret); 113 107 } 114 108 115 109 static void remote_hw_res_get_resource_list(ddf_fun_t *fun, void *ops, 116 cap_call_handle_t chandle,ipc_call_t *call)110 ipc_call_t *call) 117 111 { 118 112 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops; 119 113 120 114 if (hw_res_ops->get_resource_list == NULL) { 121 async_answer_0(c handle, ENOTSUP);115 async_answer_0(call, ENOTSUP); 122 116 return; 123 117 } … … 125 119 hw_resource_list_t *hw_resources = hw_res_ops->get_resource_list(fun); 126 120 if (hw_resources == NULL) { 127 async_answer_0(c handle, ENOENT);121 async_answer_0(call, ENOENT); 128 122 return; 129 123 } 130 124 131 async_answer_1(c handle, EOK, hw_resources->count);125 async_answer_1(call, EOK, hw_resources->count); 132 126 127 ipc_call_t data; 133 128 size_t len; 134 if (!async_data_read_receive(& chandle, &len)) {129 if (!async_data_read_receive(&data, &len)) { 135 130 /* Protocol error - the recipient is not accepting data */ 136 131 return; 137 132 } 138 async_data_read_finalize(chandle, hw_resources->resources, len); 133 134 async_data_read_finalize(&data, hw_resources->resources, len); 139 135 } 140 136 141 137 static void remote_hw_res_dma_channel_setup(ddf_fun_t *fun, void *ops, 142 cap_call_handle_t chandle,ipc_call_t *call)138 ipc_call_t *call) 143 139 { 144 140 hw_res_ops_t *hw_res_ops = ops; 145 141 146 142 if (hw_res_ops->dma_channel_setup == NULL) { 147 async_answer_0(c handle, ENOTSUP);143 async_answer_0(call, ENOTSUP); 148 144 return; 149 145 } 146 150 147 const unsigned channel = DEV_IPC_GET_ARG1(*call) & 0xffff; 151 148 const uint8_t mode = DEV_IPC_GET_ARG1(*call) >> 16; … … 155 152 const errno_t ret = hw_res_ops->dma_channel_setup( 156 153 fun, channel, address, size, mode); 157 async_answer_0(c handle, ret);154 async_answer_0(call, ret); 158 155 } 159 156 160 157 static void remote_hw_res_dma_channel_remain(ddf_fun_t *fun, void *ops, 161 cap_call_handle_t chandle,ipc_call_t *call)158 ipc_call_t *call) 162 159 { 163 160 hw_res_ops_t *hw_res_ops = ops; 164 161 165 162 if (hw_res_ops->dma_channel_setup == NULL) { 166 async_answer_0(c handle, ENOTSUP);163 async_answer_0(call, ENOTSUP); 167 164 return; 168 165 } 166 169 167 const unsigned channel = DEV_IPC_GET_ARG1(*call); 170 168 size_t remain = 0; 171 169 const errno_t ret = hw_res_ops->dma_channel_remain(fun, channel, &remain); 172 async_answer_1(c handle, ret, remain);170 async_answer_1(call, ret, remain); 173 171 } 172 174 173 /** 175 174 * @}
Note:
See TracChangeset
for help on using the changeset viewer.