Changeset 1b973dc in mainline for uspace/lib/drv
- Timestamp:
- 2013-12-31T21:41:45Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1bb9833
- Parents:
- 4c14b88 (diff), 8a84484 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib/drv
- Files:
-
- 25 edited
- 18 moved
-
Makefile (modified) (1 diff)
-
generic/dev_iface.c (modified) (2 diffs)
-
generic/driver.c (modified) (3 diffs)
-
generic/interrupt.c (modified) (4 diffs)
-
generic/private/remote_ahci.h (moved) (moved from uspace/lib/drv/include/remote_ahci.h )
-
generic/private/remote_audio_mixer.h (moved) (moved from uspace/lib/drv/include/remote_audio_mixer.h )
-
generic/private/remote_audio_pcm.h (moved) (moved from uspace/lib/drv/include/remote_audio_pcm.h )
-
generic/private/remote_battery_dev.h (moved) (moved from uspace/lib/drv/include/remote_battery_dev.h )
-
generic/private/remote_char_dev.h (moved) (moved from uspace/lib/drv/include/remote_char_dev.h )
-
generic/private/remote_clock_dev.h (moved) (moved from uspace/lib/drv/include/remote_clock_dev.h )
-
generic/private/remote_graph_dev.h (moved) (moved from uspace/lib/drv/include/remote_graph_dev.h )
-
generic/private/remote_hw_res.h (moved) (moved from uspace/lib/drv/include/remote_hw_res.h )
-
generic/private/remote_nic.h (moved) (moved from uspace/lib/drv/include/remote_nic.h )
-
generic/private/remote_pci.h (moved) (moved from uspace/lib/drv/include/remote_pci.h )
-
generic/private/remote_pio_window.h (moved) (moved from uspace/lib/drv/include/remote_pio_window.h )
-
generic/private/remote_usb.h (moved) (moved from uspace/lib/drv/include/remote_usb.h )
-
generic/private/remote_usbhc.h (moved) (moved from uspace/lib/drv/include/remote_usbhc.h )
-
generic/private/remote_usbhid.h (moved) (moved from uspace/lib/drv/include/remote_usbhid.h )
-
generic/remote_ahci.c (modified) (5 diffs)
-
generic/remote_audio_mixer.c (modified) (3 diffs)
-
generic/remote_audio_pcm.c (modified) (3 diffs)
-
generic/remote_battery_dev.c (modified) (3 diffs)
-
generic/remote_char_dev.c (modified) (3 diffs)
-
generic/remote_clock_dev.c (modified) (3 diffs)
-
generic/remote_graph_dev.c (modified) (1 diff)
-
generic/remote_hw_res.c (modified) (3 diffs)
-
generic/remote_nic.c (modified) (3 diffs)
-
generic/remote_pci.c (modified) (2 diffs)
-
generic/remote_pio_window.c (modified) (2 diffs)
-
generic/remote_usb.c (modified) (2 diffs)
-
generic/remote_usbhc.c (modified) (3 diffs)
-
generic/remote_usbhid.c (modified) (2 diffs)
-
include/ahci_iface.h (modified) (1 diff)
-
include/battery_iface.h (moved) (moved from uspace/lib/c/include/device/battery_dev.h ) (1 diff)
-
include/char_dev_iface.h (moved) (moved from uspace/lib/c/include/device/char_dev.h ) (1 diff)
-
include/ddf/driver.h (modified) (1 diff)
-
include/ddf/interrupt.h (modified) (1 diff)
-
include/dev_iface.h (modified) (1 diff)
-
include/graph_iface.h (moved) (moved from uspace/lib/c/include/device/graph_dev.h ) (1 diff)
-
include/nic_iface.h (moved) (moved from uspace/lib/c/include/device/nic.h ) (2 diffs)
-
include/ops/battery_dev.h (modified) (1 diff)
-
include/pci_dev_iface.h (modified) (1 diff)
-
include/usbhid_iface.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/Makefile
r4c14b88 r1b973dc 29 29 30 30 USPACE_PREFIX = ../.. 31 EXTRA_CFLAGS = -Iinclude -I$(LIBUSB_PREFIX)/include -I$(LIBPCM_PREFIX)/include 31 EXTRA_CFLAGS = \ 32 -Iinclude \ 33 -Igeneric/private \ 34 -I$(LIBUSB_PREFIX)/include \ 35 -I$(LIBPCM_PREFIX)/include 32 36 LIBRARY = libdrv 33 37 -
uspace/lib/drv/generic/dev_iface.c
r4c14b88 r1b973dc 69 69 [CLOCK_DEV_IFACE] = &remote_clock_dev_iface, 70 70 [BATTERY_DEV_IFACE] = &remote_battery_dev_iface, 71 [AHCI_DEV_IFACE] = &remote_ahci_iface 71 [AHCI_DEV_IFACE] = &remote_ahci_iface, 72 72 } 73 73 }; 74 74 75 remote_iface_t *get_remote_iface(int idx)75 const remote_iface_t *get_remote_iface(int idx) 76 76 { 77 77 assert(is_valid_iface_idx(idx)); … … 80 80 81 81 remote_iface_func_ptr_t 82 get_remote_method( remote_iface_t *rem_iface, sysarg_t iface_method_idx)82 get_remote_method(const remote_iface_t *rem_iface, sysarg_t iface_method_idx) 83 83 { 84 84 if (iface_method_idx >= rem_iface->method_count) -
uspace/lib/drv/generic/driver.c
r4c14b88 r1b973dc 63 63 64 64 /** Driver structure */ 65 static driver_t *driver;65 static const driver_t *driver; 66 66 67 67 /** Devices */ … … 413 413 * handling ("remote interface"). 414 414 */ 415 remote_iface_t *rem_iface = get_remote_iface(iface_idx);415 const remote_iface_t *rem_iface = get_remote_iface(iface_idx); 416 416 assert(rem_iface != NULL); 417 417 … … 957 957 } 958 958 959 int ddf_driver_main( driver_t *drv)959 int ddf_driver_main(const driver_t *drv) 960 960 { 961 961 /* -
uspace/lib/drv/generic/interrupt.c
r4c14b88 r1b973dc 39 39 #include <errno.h> 40 40 #include <sys/types.h> 41 #include <macros.h> 41 42 42 43 #include "ddf/interrupt.h" … … 55 56 static interrupt_context_t *find_interrupt_context( 56 57 interrupt_context_list_t *list, ddf_dev_t *dev, int irq); 57 int register_interrupt_handler(ddf_dev_t *dev, int irq,58 interrupt_handler_t *handler, irq_code_t *pseudocode);59 int unregister_interrupt_handler(ddf_dev_t *dev, int irq);60 58 61 59 /** Interrupts */ … … 68 66 }; 69 67 70 static irq_code_t default_pseudocode = {68 static const irq_code_t default_pseudocode = { 71 69 0, 72 70 NULL, 73 sizeof(default_cmds) / sizeof(irq_cmd_t),71 ARRAY_SIZE(default_cmds), 74 72 default_cmds 75 73 }; … … 169 167 170 168 int register_interrupt_handler(ddf_dev_t *dev, int irq, 171 interrupt_handler_t *handler, irq_code_t *pseudocode)169 interrupt_handler_t *handler, const irq_code_t *pseudocode) 172 170 { 173 171 interrupt_context_t *ctx = create_interrupt_context(); -
uspace/lib/drv/generic/remote_ahci.c
r4c14b88 r1b973dc 33 33 */ 34 34 35 #include <as.h> 35 36 #include <async.h> 37 #include <devman.h> 36 38 #include <errno.h> 37 39 #include <stdio.h> 40 #include <macros.h> 38 41 #include "ahci_iface.h" 39 42 #include "ddf/driver.h" … … 47 50 } ahci_iface_funcs_t; 48 51 52 #define MAX_NAME_LENGTH 1024 53 49 54 #define LO(ptr) \ 50 55 ((uint32_t) (((uint64_t) ((uintptr_t) (ptr))) & 0xffffffff)) … … 53 58 ((uint32_t) (((uint64_t) ((uintptr_t) (ptr))) >> 32)) 54 59 60 async_sess_t* ahci_get_sess(devman_handle_t funh, char **name) 61 { 62 // FIXME: Use a better way than substring match 63 64 *name = NULL; 65 66 char devn[MAX_NAME_LENGTH]; 67 int rc = devman_fun_get_name(funh, devn, MAX_NAME_LENGTH); 68 if (rc != EOK) 69 return NULL; 70 71 size_t devn_size = str_size(devn); 72 73 if ((devn_size > 5) && (str_lcmp(devn, "ahci_", 5) == 0)) { 74 async_sess_t *sess = devman_device_connect(EXCHANGE_PARALLEL, 75 funh, IPC_FLAG_BLOCKING); 76 77 if (sess) { 78 *name = str_dup(devn); 79 return sess; 80 } 81 } 82 83 return NULL; 84 } 85 86 int ahci_get_sata_device_name(async_sess_t *sess, size_t sata_dev_name_length, 87 char *sata_dev_name) 88 { 89 async_exch_t *exch = async_exchange_begin(sess); 90 if (!exch) 91 return EINVAL; 92 93 aid_t req = async_send_2(exch, DEV_IFACE_ID(AHCI_DEV_IFACE), 94 IPC_M_AHCI_GET_SATA_DEVICE_NAME, sata_dev_name_length, NULL); 95 96 async_data_read_start(exch, sata_dev_name, sata_dev_name_length); 97 98 sysarg_t rc; 99 async_wait_for(req, &rc); 100 101 return rc; 102 } 103 104 int ahci_get_num_blocks(async_sess_t *sess, uint64_t *blocks) 105 { 106 async_exch_t *exch = async_exchange_begin(sess); 107 if (!exch) 108 return EINVAL; 109 110 sysarg_t blocks_hi; 111 sysarg_t blocks_lo; 112 int rc = async_req_1_2(exch, DEV_IFACE_ID(AHCI_DEV_IFACE), 113 IPC_M_AHCI_GET_NUM_BLOCKS, &blocks_hi, &blocks_lo); 114 115 async_exchange_end(exch); 116 117 if (rc == EOK) { 118 *blocks = (((uint64_t) blocks_hi) << 32) 119 | (((uint64_t) blocks_lo) & 0xffffffff); 120 } 121 122 return rc; 123 } 124 125 int ahci_get_block_size(async_sess_t *sess, size_t *blocks_size) 126 { 127 async_exch_t *exch = async_exchange_begin(sess); 128 if (!exch) 129 return EINVAL; 130 131 sysarg_t bs; 132 int rc = async_req_1_1(exch, DEV_IFACE_ID(AHCI_DEV_IFACE), 133 IPC_M_AHCI_GET_BLOCK_SIZE, &bs); 134 135 async_exchange_end(exch); 136 137 if (rc == EOK) 138 *blocks_size = (size_t) bs; 139 140 return rc; 141 } 142 143 int ahci_read_blocks(async_sess_t *sess, uint64_t blocknum, size_t count, 144 void *buf) 145 { 146 async_exch_t *exch = async_exchange_begin(sess); 147 if (!exch) 148 return EINVAL; 149 150 aid_t req; 151 req = async_send_4(exch, DEV_IFACE_ID(AHCI_DEV_IFACE), 152 IPC_M_AHCI_READ_BLOCKS, HI(blocknum), LO(blocknum), count, NULL); 153 154 async_share_out_start(exch, buf, AS_AREA_READ | AS_AREA_WRITE); 155 156 async_exchange_end(exch); 157 158 sysarg_t rc; 159 async_wait_for(req, &rc); 160 161 return rc; 162 } 163 164 int ahci_write_blocks(async_sess_t *sess, uint64_t blocknum, size_t count, 165 void* buf) 166 { 167 async_exch_t *exch = async_exchange_begin(sess); 168 if (!exch) 169 return EINVAL; 170 171 aid_t req = async_send_4(exch, DEV_IFACE_ID(AHCI_DEV_IFACE), 172 IPC_M_AHCI_WRITE_BLOCKS, HI(blocknum), LO(blocknum), count, NULL); 173 174 async_share_out_start(exch, buf, AS_AREA_READ | AS_AREA_WRITE); 175 176 async_exchange_end(exch); 177 178 sysarg_t rc; 179 async_wait_for(req, &rc); 180 181 return rc; 182 } 183 55 184 static void remote_ahci_get_sata_device_name(ddf_fun_t *, void *, ipc_callid_t, 56 185 ipc_call_t *); … … 65 194 66 195 /** Remote AHCI interface operations. */ 67 static remote_iface_func_ptr_t remote_ahci_iface_ops [] = {196 static const remote_iface_func_ptr_t remote_ahci_iface_ops [] = { 68 197 [IPC_M_AHCI_GET_SATA_DEVICE_NAME] = remote_ahci_get_sata_device_name, 69 198 [IPC_M_AHCI_GET_NUM_BLOCKS] = remote_ahci_get_num_blocks, … … 75 204 /** Remote AHCI interface structure. 76 205 */ 77 remote_iface_t remote_ahci_iface = { 78 .method_count = sizeof(remote_ahci_iface_ops) / 79 sizeof(remote_ahci_iface_ops[0]), 206 const remote_iface_t remote_ahci_iface = { 207 .method_count = ARRAY_SIZE(remote_ahci_iface_ops), 80 208 .methods = remote_ahci_iface_ops 81 209 }; -
uspace/lib/drv/generic/remote_audio_mixer.c
r4c14b88 r1b973dc 37 37 #include <assert.h> 38 38 #include <str.h> 39 #include <macros.h> 39 40 40 41 #include "audio_mixer_iface.h" … … 204 205 205 206 /** Remote audio mixer interface operations. */ 206 static remote_iface_func_ptr_t remote_audio_mixer_iface_ops[] = {207 static const remote_iface_func_ptr_t remote_audio_mixer_iface_ops[] = { 207 208 [IPC_M_AUDIO_MIXER_GET_INFO] = remote_audio_mixer_get_info, 208 209 [IPC_M_AUDIO_MIXER_GET_ITEM_INFO] = remote_audio_mixer_get_item_info, … … 212 213 213 214 /** Remote audio mixer interface structure. */ 214 remote_iface_t remote_audio_mixer_iface = { 215 .method_count = sizeof(remote_audio_mixer_iface_ops) / 216 sizeof(remote_audio_mixer_iface_ops[0]), 215 const remote_iface_t remote_audio_mixer_iface = { 216 .method_count = ARRAY_SIZE(remote_audio_mixer_iface_ops), 217 217 .methods = remote_audio_mixer_iface_ops 218 218 }; -
uspace/lib/drv/generic/remote_audio_pcm.c
r4c14b88 r1b973dc 38 38 #include <macros.h> 39 39 #include <str.h> 40 #include <as.h>41 40 #include <sys/mman.h> 42 41 … … 611 610 612 611 /** Remote audio pcm buffer interface operations. */ 613 static remote_iface_func_ptr_t remote_audio_pcm_iface_ops[] = {612 static const remote_iface_func_ptr_t remote_audio_pcm_iface_ops[] = { 614 613 [IPC_M_AUDIO_PCM_GET_INFO_STR] = remote_audio_pcm_get_info_str, 615 614 [IPC_M_AUDIO_PCM_QUERY_CAPS] = remote_audio_pcm_query_caps, … … 627 626 628 627 /** Remote audio mixer interface structure. */ 629 remote_iface_t remote_audio_pcm_iface = { 630 .method_count = sizeof(remote_audio_pcm_iface_ops) / 631 sizeof(remote_audio_pcm_iface_ops[0]), 628 const remote_iface_t remote_audio_pcm_iface = { 629 .method_count = ARRAY_SIZE(remote_audio_pcm_iface_ops), 632 630 .methods = remote_audio_pcm_iface_ops 633 631 }; -
uspace/lib/drv/generic/remote_battery_dev.c
r4c14b88 r1b973dc 36 36 #include <errno.h> 37 37 #include <ops/battery_dev.h> 38 #include < device/battery_dev.h>38 #include <battery_iface.h> 39 39 #include <ddf/driver.h> 40 #include <macros.h> 41 42 /** Read the current battery status from the device 43 * 44 * @param sess Session of the device 45 * @param status Current status of the battery 46 * 47 * @return EOK on success or a negative error code 48 */ 49 int 50 battery_status_get(async_sess_t *sess, battery_status_t *batt_status) 51 { 52 sysarg_t status; 53 54 async_exch_t *exch = async_exchange_begin(sess); 55 56 int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE), 57 BATTERY_STATUS_GET, &status); 58 59 async_exchange_end(exch); 60 61 if (rc == EOK) 62 *batt_status = (battery_status_t) status; 63 64 return rc; 65 } 66 67 /** Read the current battery charge level from the device 68 * 69 * @param sess Session of the device 70 * @param level Battery charge level (0 - 100) 71 * 72 * @return EOK on success or a negative error code 73 */ 74 int 75 battery_charge_level_get(async_sess_t *sess, int *level) 76 { 77 sysarg_t charge_level; 78 79 async_exch_t *exch = async_exchange_begin(sess); 80 81 int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE), 82 BATTERY_CHARGE_LEVEL_GET, &charge_level); 83 84 async_exchange_end(exch); 85 86 if (rc == EOK) 87 *level = (int) charge_level; 88 89 return rc; 90 } 40 91 41 92 static void remote_battery_status_get(ddf_fun_t *, void *, ipc_callid_t, … … 45 96 46 97 /** Remote battery interface operations */ 47 static remote_iface_func_ptr_t remote_battery_dev_iface_ops[] = {48 &remote_battery_status_get,49 &remote_battery_charge_level_get,98 static const remote_iface_func_ptr_t remote_battery_dev_iface_ops[] = { 99 [BATTERY_STATUS_GET] = remote_battery_status_get, 100 [BATTERY_CHARGE_LEVEL_GET] = remote_battery_charge_level_get, 50 101 }; 51 102 … … 56 107 * 57 108 */ 58 remote_iface_t remote_battery_dev_iface = { 59 .method_count = sizeof(remote_battery_dev_iface_ops) / 60 sizeof(remote_iface_func_ptr_t), 109 const remote_iface_t remote_battery_dev_iface = { 110 .method_count = ARRAY_SIZE(remote_battery_dev_iface_ops), 61 111 .methods = remote_battery_dev_iface_ops, 62 112 }; -
uspace/lib/drv/generic/remote_char_dev.c
r4c14b88 r1b973dc 35 35 #include <async.h> 36 36 #include <errno.h> 37 #include <macros.h> 37 38 38 39 #include "ops/char_dev.h" 40 #include "char_dev_iface.h" 39 41 #include "ddf/driver.h" 40 42 41 43 #define MAX_CHAR_RW_COUNT 256 44 45 /** Read to or write from device. 46 * 47 * Helper function to read to or write from a device 48 * using its character interface. 49 * 50 * @param sess Session to the device. 51 * @param buf Buffer for the data read from or written to the device. 52 * @param size Maximum size of data (in bytes) to be read or written. 53 * @param read Read from the device if true, write to it otherwise. 54 * 55 * @return Non-negative number of bytes actually read from or 56 * written to the device on success, negative error number 57 * otherwise. 58 * 59 */ 60 static ssize_t char_dev_rw(async_sess_t *sess, void *buf, size_t size, bool read) 61 { 62 ipc_call_t answer; 63 aid_t req; 64 int ret; 65 66 async_exch_t *exch = async_exchange_begin(sess); 67 68 if (read) { 69 req = async_send_1(exch, DEV_IFACE_ID(CHAR_DEV_IFACE), 70 CHAR_DEV_READ, &answer); 71 ret = async_data_read_start(exch, buf, size); 72 } else { 73 req = async_send_1(exch, DEV_IFACE_ID(CHAR_DEV_IFACE), 74 CHAR_DEV_WRITE, &answer); 75 ret = async_data_write_start(exch, buf, size); 76 } 77 78 async_exchange_end(exch); 79 80 sysarg_t rc; 81 if (ret != EOK) { 82 async_wait_for(req, &rc); 83 if (rc == EOK) 84 return (ssize_t) ret; 85 86 return (ssize_t) rc; 87 } 88 89 async_wait_for(req, &rc); 90 91 ret = (int) rc; 92 if (ret != EOK) 93 return (ssize_t) ret; 94 95 return (ssize_t) IPC_GET_ARG1(answer); 96 } 97 98 /** Read from character device. 99 * 100 * @param sess Session to the device. 101 * @param buf Output buffer for the data read from the device. 102 * @param size Maximum size (in bytes) of the data to be read. 103 * 104 * @return Non-negative number of bytes actually read from the 105 * device on success, negative error number otherwise. 106 * 107 */ 108 ssize_t char_dev_read(async_sess_t *sess, void *buf, size_t size) 109 { 110 return char_dev_rw(sess, buf, size, true); 111 } 112 113 /** Write to character device. 114 * 115 * @param sess Session to the device. 116 * @param buf Input buffer containg the data to be written to the 117 * device. 118 * @param size Maximum size (in bytes) of the data to be written. 119 * 120 * @return Non-negative number of bytes actually written to the 121 * device on success, negative error number otherwise. 122 * 123 */ 124 ssize_t char_dev_write(async_sess_t *sess, void *buf, size_t size) 125 { 126 return char_dev_rw(sess, buf, size, false); 127 } 42 128 43 129 static void remote_char_read(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 45 131 46 132 /** Remote character interface operations. */ 47 static remote_iface_func_ptr_t remote_char_dev_iface_ops[] = {48 &remote_char_read,49 &remote_char_write133 static const remote_iface_func_ptr_t remote_char_dev_iface_ops[] = { 134 [CHAR_DEV_READ] = remote_char_read, 135 [CHAR_DEV_WRITE] = remote_char_write 50 136 }; 51 137 … … 55 141 * character interface. 56 142 */ 57 remote_iface_t remote_char_dev_iface = { 58 .method_count = sizeof(remote_char_dev_iface_ops) / 59 sizeof(remote_iface_func_ptr_t), 143 const remote_iface_t remote_char_dev_iface = { 144 .method_count = ARRAY_SIZE(remote_char_dev_iface_ops), 60 145 .methods = remote_char_dev_iface_ops 61 146 }; -
uspace/lib/drv/generic/remote_clock_dev.c
r4c14b88 r1b973dc 36 36 #include <errno.h> 37 37 #include <time.h> 38 #include <macros.h> 39 #include <device/clock_dev.h> 38 40 39 41 #include <ops/clock_dev.h> … … 46 48 47 49 /** Remote clock interface operations */ 48 static remote_iface_func_ptr_t remote_clock_dev_iface_ops[] = {49 &remote_clock_time_get,50 &remote_clock_time_set,50 static const remote_iface_func_ptr_t remote_clock_dev_iface_ops[] = { 51 [CLOCK_DEV_TIME_GET] = remote_clock_time_get, 52 [CLOCK_DEV_TIME_SET] = remote_clock_time_set, 51 53 }; 52 54 … … 56 58 * addressed by the clock interface. 57 59 */ 58 remote_iface_t remote_clock_dev_iface = { 59 .method_count = sizeof(remote_clock_dev_iface_ops) / 60 sizeof(remote_iface_func_ptr_t), 60 const remote_iface_t remote_clock_dev_iface = { 61 .method_count = ARRAY_SIZE(remote_clock_dev_iface_ops), 61 62 .methods = remote_clock_dev_iface_ops, 62 63 }; -
uspace/lib/drv/generic/remote_graph_dev.c
r4c14b88 r1b973dc 35 35 #include <errno.h> 36 36 #include <async.h> 37 #include <macros.h> 37 38 38 39 #include "ops/graph_dev.h" 40 #include "graph_iface.h" 39 41 #include "ddf/driver.h" 42 43 typedef enum { 44 GRAPH_DEV_CONNECT = 0 45 } graph_dev_method_t; 46 47 int graph_dev_connect(async_sess_t *sess) 48 { 49 async_exch_t *exch = async_exchange_begin(sess); 50 int ret = async_req_1_0(exch, DEV_IFACE_ID(GRAPH_DEV_IFACE), GRAPH_DEV_CONNECT); 51 async_exchange_end(exch); 52 53 return ret; 54 } 40 55 41 56 static void remote_graph_connect(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 42 57 43 static remote_iface_func_ptr_t remote_graph_dev_iface_ops[] = {44 &remote_graph_connect58 static const remote_iface_func_ptr_t remote_graph_dev_iface_ops[] = { 59 [GRAPH_DEV_CONNECT] = remote_graph_connect 45 60 }; 46 61 47 remote_iface_t remote_graph_dev_iface = { 48 .method_count = sizeof(remote_graph_dev_iface_ops) / 49 sizeof(remote_iface_func_ptr_t), 62 const remote_iface_t remote_graph_dev_iface = { 63 .method_count = ARRAY_SIZE(remote_graph_dev_iface_ops), 50 64 .methods = remote_graph_dev_iface_ops 51 65 }; -
uspace/lib/drv/generic/remote_hw_res.c
r4c14b88 r1b973dc 36 36 #include <async.h> 37 37 #include <errno.h> 38 #include <macros.h> 38 39 39 40 #include "ops/hw_res.h" … … 49 50 ipc_call_t *); 50 51 51 static remote_iface_func_ptr_t remote_hw_res_iface_ops [] = {52 static const remote_iface_func_ptr_t remote_hw_res_iface_ops [] = { 52 53 [HW_RES_GET_RESOURCE_LIST] = &remote_hw_res_get_resource_list, 53 54 [HW_RES_ENABLE_INTERRUPT] = &remote_hw_res_enable_interrupt, … … 56 57 }; 57 58 58 remote_iface_t remote_hw_res_iface = { 59 .method_count = sizeof(remote_hw_res_iface_ops) / 60 sizeof(remote_iface_func_ptr_t), 59 const remote_iface_t remote_hw_res_iface = { 60 .method_count = ARRAY_SIZE(remote_hw_res_iface_ops), 61 61 .methods = remote_hw_res_iface_ops 62 62 }; -
uspace/lib/drv/generic/remote_nic.c
r4c14b88 r1b973dc 40 40 #include <ipc/services.h> 41 41 #include <sys/time.h> 42 #include <macros.h> 43 42 44 #include "ops/nic.h" 45 #include "nic_iface.h" 46 47 typedef enum { 48 NIC_SEND_MESSAGE = 0, 49 NIC_CALLBACK_CREATE, 50 NIC_GET_STATE, 51 NIC_SET_STATE, 52 NIC_GET_ADDRESS, 53 NIC_SET_ADDRESS, 54 NIC_GET_STATS, 55 NIC_GET_DEVICE_INFO, 56 NIC_GET_CABLE_STATE, 57 NIC_GET_OPERATION_MODE, 58 NIC_SET_OPERATION_MODE, 59 NIC_AUTONEG_ENABLE, 60 NIC_AUTONEG_DISABLE, 61 NIC_AUTONEG_PROBE, 62 NIC_AUTONEG_RESTART, 63 NIC_GET_PAUSE, 64 NIC_SET_PAUSE, 65 NIC_UNICAST_GET_MODE, 66 NIC_UNICAST_SET_MODE, 67 NIC_MULTICAST_GET_MODE, 68 NIC_MULTICAST_SET_MODE, 69 NIC_BROADCAST_GET_MODE, 70 NIC_BROADCAST_SET_MODE, 71 NIC_DEFECTIVE_GET_MODE, 72 NIC_DEFECTIVE_SET_MODE, 73 NIC_BLOCKED_SOURCES_GET, 74 NIC_BLOCKED_SOURCES_SET, 75 NIC_VLAN_GET_MASK, 76 NIC_VLAN_SET_MASK, 77 NIC_VLAN_SET_TAG, 78 NIC_WOL_VIRTUE_ADD, 79 NIC_WOL_VIRTUE_REMOVE, 80 NIC_WOL_VIRTUE_PROBE, 81 NIC_WOL_VIRTUE_LIST, 82 NIC_WOL_VIRTUE_GET_CAPS, 83 NIC_WOL_LOAD_INFO, 84 NIC_OFFLOAD_PROBE, 85 NIC_OFFLOAD_SET, 86 NIC_POLL_GET_MODE, 87 NIC_POLL_SET_MODE, 88 NIC_POLL_NOW 89 } nic_funcs_t; 90 91 /** Send frame from NIC 92 * 93 * @param[in] dev_sess 94 * @param[in] data Frame data 95 * @param[in] size Frame size in bytes 96 * 97 * @return EOK If the operation was successfully completed 98 * 99 */ 100 int nic_send_frame(async_sess_t *dev_sess, void *data, size_t size) 101 { 102 async_exch_t *exch = async_exchange_begin(dev_sess); 103 104 ipc_call_t answer; 105 aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 106 NIC_SEND_MESSAGE, &answer); 107 sysarg_t retval = async_data_write_start(exch, data, size); 108 109 async_exchange_end(exch); 110 111 if (retval != EOK) { 112 async_forget(req); 113 return retval; 114 } 115 116 async_wait_for(req, &retval); 117 return retval; 118 } 119 120 /** Create callback connection from NIC service 121 * 122 * @param[in] dev_sess 123 * @param[in] device_id 124 * 125 * @return EOK If the operation was successfully completed 126 * 127 */ 128 int nic_callback_create(async_sess_t *dev_sess, async_client_conn_t cfun, 129 void *carg) 130 { 131 ipc_call_t answer; 132 int rc; 133 sysarg_t retval; 134 135 async_exch_t *exch = async_exchange_begin(dev_sess); 136 aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 137 NIC_CALLBACK_CREATE, &answer); 138 139 rc = async_connect_to_me(exch, 0, 0, 0, cfun, carg); 140 if (rc != EOK) { 141 async_forget(req); 142 return rc; 143 } 144 async_exchange_end(exch); 145 146 async_wait_for(req, &retval); 147 return (int) retval; 148 } 149 150 /** Get the current state of the device 151 * 152 * @param[in] dev_sess 153 * @param[out] state Current state 154 * 155 * @return EOK If the operation was successfully completed 156 * 157 */ 158 int nic_get_state(async_sess_t *dev_sess, nic_device_state_t *state) 159 { 160 assert(state); 161 162 sysarg_t _state; 163 164 async_exch_t *exch = async_exchange_begin(dev_sess); 165 int rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 166 NIC_GET_STATE, &_state); 167 async_exchange_end(exch); 168 169 *state = (nic_device_state_t) _state; 170 171 return rc; 172 } 173 174 /** Request the device to change its state 175 * 176 * @param[in] dev_sess 177 * @param[in] state New state 178 * 179 * @return EOK If the operation was successfully completed 180 * 181 */ 182 int nic_set_state(async_sess_t *dev_sess, nic_device_state_t state) 183 { 184 async_exch_t *exch = async_exchange_begin(dev_sess); 185 int rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 186 NIC_SET_STATE, state); 187 async_exchange_end(exch); 188 189 return rc; 190 } 191 192 /** Request the MAC address of the device 193 * 194 * @param[in] dev_sess 195 * @param[out] address Structure with buffer for the address 196 * 197 * @return EOK If the operation was successfully completed 198 * 199 */ 200 int nic_get_address(async_sess_t *dev_sess, nic_address_t *address) 201 { 202 assert(address); 203 204 async_exch_t *exch = async_exchange_begin(dev_sess); 205 aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 206 NIC_GET_ADDRESS, NULL); 207 int rc = async_data_read_start(exch, address, sizeof(nic_address_t)); 208 async_exchange_end(exch); 209 210 sysarg_t res; 211 async_wait_for(aid, &res); 212 213 if (rc != EOK) 214 return rc; 215 216 return (int) res; 217 } 218 219 /** Set the address of the device (e.g. MAC on Ethernet) 220 * 221 * @param[in] dev_sess 222 * @param[in] address Pointer to the address 223 * 224 * @return EOK If the operation was successfully completed 225 * 226 */ 227 int nic_set_address(async_sess_t *dev_sess, const nic_address_t *address) 228 { 229 assert(address); 230 231 async_exch_t *exch = async_exchange_begin(dev_sess); 232 aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 233 NIC_SET_ADDRESS, NULL); 234 int rc = async_data_write_start(exch, address, sizeof(nic_address_t)); 235 async_exchange_end(exch); 236 237 sysarg_t res; 238 async_wait_for(aid, &res); 239 240 if (rc != EOK) 241 return rc; 242 243 return (int) res; 244 } 245 246 /** Request statistic data about NIC operation. 247 * 248 * @param[in] dev_sess 249 * @param[out] stats Structure with the statistics 250 * 251 * @return EOK If the operation was successfully completed 252 * 253 */ 254 int nic_get_stats(async_sess_t *dev_sess, nic_device_stats_t *stats) 255 { 256 assert(stats); 257 258 async_exch_t *exch = async_exchange_begin(dev_sess); 259 260 int rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 261 NIC_GET_STATS); 262 if (rc != EOK) { 263 async_exchange_end(exch); 264 return rc; 265 } 266 267 rc = async_data_read_start(exch, stats, sizeof(nic_device_stats_t)); 268 269 async_exchange_end(exch); 270 271 return rc; 272 } 273 274 /** Request information about the device. 275 * 276 * @see nic_device_info_t 277 * 278 * @param[in] dev_sess 279 * @param[out] device_info Information about the device 280 * 281 * @return EOK If the operation was successfully completed 282 * 283 */ 284 int nic_get_device_info(async_sess_t *dev_sess, nic_device_info_t *device_info) 285 { 286 assert(device_info); 287 288 async_exch_t *exch = async_exchange_begin(dev_sess); 289 290 int rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 291 NIC_GET_DEVICE_INFO); 292 if (rc != EOK) { 293 async_exchange_end(exch); 294 return rc; 295 } 296 297 rc = async_data_read_start(exch, device_info, sizeof(nic_device_info_t)); 298 299 async_exchange_end(exch); 300 301 return rc; 302 } 303 304 /** Request status of the cable (plugged/unplugged) 305 * 306 * @param[in] dev_sess 307 * @param[out] cable_state Current cable state 308 * 309 * @return EOK If the operation was successfully completed 310 * 311 */ 312 int nic_get_cable_state(async_sess_t *dev_sess, nic_cable_state_t *cable_state) 313 { 314 assert(cable_state); 315 316 sysarg_t _cable_state; 317 318 async_exch_t *exch = async_exchange_begin(dev_sess); 319 int rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 320 NIC_GET_CABLE_STATE, &_cable_state); 321 async_exchange_end(exch); 322 323 *cable_state = (nic_cable_state_t) _cable_state; 324 325 return rc; 326 } 327 328 /** Request current operation mode. 329 * 330 * @param[in] dev_sess 331 * @param[out] speed Current operation speed in Mbps. Can be NULL. 332 * @param[out] duplex Full duplex/half duplex. Can be NULL. 333 * @param[out] role Master/slave/auto. Can be NULL. 334 * 335 * @return EOK If the operation was successfully completed 336 * 337 */ 338 int nic_get_operation_mode(async_sess_t *dev_sess, int *speed, 339 nic_channel_mode_t *duplex, nic_role_t *role) 340 { 341 sysarg_t _speed; 342 sysarg_t _duplex; 343 sysarg_t _role; 344 345 async_exch_t *exch = async_exchange_begin(dev_sess); 346 int rc = async_req_1_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 347 NIC_GET_OPERATION_MODE, &_speed, &_duplex, &_role); 348 async_exchange_end(exch); 349 350 if (speed) 351 *speed = (int) _speed; 352 353 if (duplex) 354 *duplex = (nic_channel_mode_t) _duplex; 355 356 if (role) 357 *role = (nic_role_t) _role; 358 359 return rc; 360 } 361 362 /** Set current operation mode. 363 * 364 * If the NIC has auto-negotiation enabled, this command 365 * disables auto-negotiation and sets the operation mode. 366 * 367 * @param[in] dev_sess 368 * @param[in] speed Operation speed in Mbps 369 * @param[in] duplex Full duplex/half duplex 370 * @param[in] role Master/slave/auto (e.g. in Gbit Ethernet] 371 * 372 * @return EOK If the operation was successfully completed 373 * 374 */ 375 int nic_set_operation_mode(async_sess_t *dev_sess, int speed, 376 nic_channel_mode_t duplex, nic_role_t role) 377 { 378 async_exch_t *exch = async_exchange_begin(dev_sess); 379 int rc = async_req_4_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 380 NIC_SET_OPERATION_MODE, (sysarg_t) speed, (sysarg_t) duplex, 381 (sysarg_t) role); 382 async_exchange_end(exch); 383 384 return rc; 385 } 386 387 /** Enable auto-negotiation. 388 * 389 * The advertisement argument can only limit some modes, 390 * it can never force the NIC to advertise unsupported modes. 391 * 392 * The allowed modes are defined in "nic/eth_phys.h" in the C library. 393 * 394 * @param[in] dev_sess 395 * @param[in] advertisement Allowed advertised modes. Use 0 for all modes. 396 * 397 * @return EOK If the operation was successfully completed 398 * 399 */ 400 int nic_autoneg_enable(async_sess_t *dev_sess, uint32_t advertisement) 401 { 402 async_exch_t *exch = async_exchange_begin(dev_sess); 403 int rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 404 NIC_AUTONEG_ENABLE, (sysarg_t) advertisement); 405 async_exchange_end(exch); 406 407 return rc; 408 } 409 410 /** Disable auto-negotiation. 411 * 412 * @param[in] dev_sess 413 * 414 * @return EOK If the operation was successfully completed 415 * 416 */ 417 int nic_autoneg_disable(async_sess_t *dev_sess) 418 { 419 async_exch_t *exch = async_exchange_begin(dev_sess); 420 int rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 421 NIC_AUTONEG_DISABLE); 422 async_exchange_end(exch); 423 424 return rc; 425 } 426 427 /** Probe current state of auto-negotiation. 428 * 429 * Modes are defined in the "nic/eth_phys.h" in the C library. 430 * 431 * @param[in] dev_sess 432 * @param[out] our_advertisement Modes advertised by this NIC. 433 * Can be NULL. 434 * @param[out] their_advertisement Modes advertised by the other side. 435 * Can be NULL. 436 * @param[out] result General state of auto-negotiation. 437 * Can be NULL. 438 * @param[out] their_result State of other side auto-negotiation. 439 * Can be NULL. 440 * 441 * @return EOK If the operation was successfully completed 442 * 443 */ 444 int nic_autoneg_probe(async_sess_t *dev_sess, uint32_t *our_advertisement, 445 uint32_t *their_advertisement, nic_result_t *result, 446 nic_result_t *their_result) 447 { 448 sysarg_t _our_advertisement; 449 sysarg_t _their_advertisement; 450 sysarg_t _result; 451 sysarg_t _their_result; 452 453 async_exch_t *exch = async_exchange_begin(dev_sess); 454 int rc = async_req_1_4(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 455 NIC_AUTONEG_PROBE, &_our_advertisement, &_their_advertisement, 456 &_result, &_their_result); 457 async_exchange_end(exch); 458 459 if (our_advertisement) 460 *our_advertisement = (uint32_t) _our_advertisement; 461 462 if (*their_advertisement) 463 *their_advertisement = (uint32_t) _their_advertisement; 464 465 if (result) 466 *result = (nic_result_t) _result; 467 468 if (their_result) 469 *their_result = (nic_result_t) _their_result; 470 471 return rc; 472 } 473 474 /** Restart the auto-negotiation process. 475 * 476 * @param[in] dev_sess 477 * 478 * @return EOK If the operation was successfully completed 479 * 480 */ 481 int nic_autoneg_restart(async_sess_t *dev_sess) 482 { 483 async_exch_t *exch = async_exchange_begin(dev_sess); 484 int rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 485 NIC_AUTONEG_RESTART); 486 async_exchange_end(exch); 487 488 return rc; 489 } 490 491 /** Query party's sending and reception of the PAUSE frame. 492 * 493 * @param[in] dev_sess 494 * @param[out] we_send This NIC sends the PAUSE frame (true/false) 495 * @param[out] we_receive This NIC receives the PAUSE frame (true/false) 496 * @param[out] pause The time set to transmitted PAUSE frames. 497 * 498 * @return EOK If the operation was successfully completed 499 * 500 */ 501 int nic_get_pause(async_sess_t *dev_sess, nic_result_t *we_send, 502 nic_result_t *we_receive, uint16_t *pause) 503 { 504 sysarg_t _we_send; 505 sysarg_t _we_receive; 506 sysarg_t _pause; 507 508 async_exch_t *exch = async_exchange_begin(dev_sess); 509 int rc = async_req_1_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 510 NIC_GET_PAUSE, &_we_send, &_we_receive, &_pause); 511 async_exchange_end(exch); 512 513 if (we_send) 514 *we_send = _we_send; 515 516 if (we_receive) 517 *we_receive = _we_receive; 518 519 if (pause) 520 *pause = _pause; 521 522 return rc; 523 } 524 525 /** Control sending and reception of the PAUSE frame. 526 * 527 * @param[in] dev_sess 528 * @param[in] allow_send Allow sending the PAUSE frame (true/false) 529 * @param[in] allow_receive Allow reception of the PAUSE frame (true/false) 530 * @param[in] pause Pause length in 512 bit units written 531 * to transmitted frames. The value 0 means 532 * auto value (the best). If the requested 533 * time cannot be set the driver is allowed 534 * to set the nearest supported value. 535 * 536 * @return EOK If the operation was successfully completed 537 * 538 */ 539 int nic_set_pause(async_sess_t *dev_sess, int allow_send, int allow_receive, 540 uint16_t pause) 541 { 542 async_exch_t *exch = async_exchange_begin(dev_sess); 543 int rc = async_req_4_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 544 NIC_SET_PAUSE, allow_send, allow_receive, pause); 545 async_exchange_end(exch); 546 547 return rc; 548 } 549 550 /** Retrieve current settings of unicast frames reception. 551 * 552 * Note: In case of mode != NIC_UNICAST_LIST the contents of 553 * address_list and address_count are undefined. 554 * 555 * @param[in] dev_sess 556 * @param[out] mode Current operation mode 557 * @param[in] max_count Maximal number of addresses that could 558 * be written into the list buffer. 559 * @param[out] address_list Buffer for the list (array). Can be NULL. 560 * @param[out] address_count Number of addresses in the list before 561 * possible truncation due to the max_count. 562 * 563 * @return EOK If the operation was successfully completed 564 * 565 */ 566 int nic_unicast_get_mode(async_sess_t *dev_sess, nic_unicast_mode_t *mode, 567 size_t max_count, nic_address_t *address_list, size_t *address_count) 568 { 569 assert(mode); 570 571 sysarg_t _mode; 572 sysarg_t _address_count; 573 574 if (!address_list) 575 max_count = 0; 576 577 async_exch_t *exch = async_exchange_begin(dev_sess); 578 579 int rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 580 NIC_UNICAST_GET_MODE, max_count, &_mode, &_address_count); 581 if (rc != EOK) { 582 async_exchange_end(exch); 583 return rc; 584 } 585 586 *mode = (nic_unicast_mode_t) _mode; 587 if (address_count) 588 *address_count = (size_t) _address_count; 589 590 if ((max_count) && (_address_count)) 591 rc = async_data_read_start(exch, address_list, 592 max_count * sizeof(nic_address_t)); 593 594 async_exchange_end(exch); 595 596 return rc; 597 } 598 599 /** Set which unicast frames are received. 600 * 601 * @param[in] dev_sess 602 * @param[in] mode Current operation mode 603 * @param[in] address_list The list of addresses. Can be NULL. 604 * @param[in] address_count Number of addresses in the list. 605 * 606 * @return EOK If the operation was successfully completed 607 * 608 */ 609 int nic_unicast_set_mode(async_sess_t *dev_sess, nic_unicast_mode_t mode, 610 const nic_address_t *address_list, size_t address_count) 611 { 612 if (address_list == NULL) 613 address_count = 0; 614 615 async_exch_t *exch = async_exchange_begin(dev_sess); 616 617 aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 618 NIC_UNICAST_SET_MODE, (sysarg_t) mode, address_count, NULL); 619 620 int rc; 621 if (address_count) 622 rc = async_data_write_start(exch, address_list, 623 address_count * sizeof(nic_address_t)); 624 else 625 rc = EOK; 626 627 async_exchange_end(exch); 628 629 sysarg_t res; 630 async_wait_for(message_id, &res); 631 632 if (rc != EOK) 633 return rc; 634 635 return (int) res; 636 } 637 638 /** Retrieve current settings of multicast frames reception. 639 * 640 * Note: In case of mode != NIC_MULTICAST_LIST the contents of 641 * address_list and address_count are undefined. 642 * 643 * @param[in] dev_sess 644 * @param[out] mode Current operation mode 645 * @param[in] max_count Maximal number of addresses that could 646 * be written into the list buffer. 647 * @param[out] address_list Buffer for the list (array). Can be NULL. 648 * @param[out] address_count Number of addresses in the list before 649 * possible truncation due to the max_count. 650 * Can be NULL. 651 * 652 * @return EOK If the operation was successfully completed 653 * 654 */ 655 int nic_multicast_get_mode(async_sess_t *dev_sess, nic_multicast_mode_t *mode, 656 size_t max_count, nic_address_t *address_list, size_t *address_count) 657 { 658 assert(mode); 659 660 sysarg_t _mode; 661 662 if (!address_list) 663 max_count = 0; 664 665 async_exch_t *exch = async_exchange_begin(dev_sess); 666 667 sysarg_t ac; 668 int rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 669 NIC_MULTICAST_GET_MODE, max_count, &_mode, &ac); 670 if (rc != EOK) { 671 async_exchange_end(exch); 672 return rc; 673 } 674 675 *mode = (nic_multicast_mode_t) _mode; 676 if (address_count) 677 *address_count = (size_t) ac; 678 679 if ((max_count) && (ac)) 680 rc = async_data_read_start(exch, address_list, 681 max_count * sizeof(nic_address_t)); 682 683 async_exchange_end(exch); 684 return rc; 685 } 686 687 /** Set which multicast frames are received. 688 * 689 * @param[in] dev_sess 690 * @param[in] mode Current operation mode 691 * @param[in] address_list The list of addresses. Can be NULL. 692 * @param[in] address_count Number of addresses in the list. 693 * 694 * @return EOK If the operation was successfully completed 695 * 696 */ 697 int nic_multicast_set_mode(async_sess_t *dev_sess, nic_multicast_mode_t mode, 698 const nic_address_t *address_list, size_t address_count) 699 { 700 if (address_list == NULL) 701 address_count = 0; 702 703 async_exch_t *exch = async_exchange_begin(dev_sess); 704 705 aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 706 NIC_MULTICAST_SET_MODE, (sysarg_t) mode, address_count, NULL); 707 708 int rc; 709 if (address_count) 710 rc = async_data_write_start(exch, address_list, 711 address_count * sizeof(nic_address_t)); 712 else 713 rc = EOK; 714 715 async_exchange_end(exch); 716 717 sysarg_t res; 718 async_wait_for(message_id, &res); 719 720 if (rc != EOK) 721 return rc; 722 723 return (int) res; 724 } 725 726 /** Determine if broadcast packets are received. 727 * 728 * @param[in] dev_sess 729 * @param[out] mode Current operation mode 730 * 731 * @return EOK If the operation was successfully completed 732 * 733 */ 734 int nic_broadcast_get_mode(async_sess_t *dev_sess, nic_broadcast_mode_t *mode) 735 { 736 assert(mode); 737 738 sysarg_t _mode; 739 740 async_exch_t *exch = async_exchange_begin(dev_sess); 741 int rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 742 NIC_BROADCAST_GET_MODE, &_mode); 743 async_exchange_end(exch); 744 745 *mode = (nic_broadcast_mode_t) _mode; 746 747 return rc; 748 } 749 750 /** Set whether broadcast packets are received. 751 * 752 * @param[in] dev_sess 753 * @param[in] mode Current operation mode 754 * 755 * @return EOK If the operation was successfully completed 756 * 757 */ 758 int nic_broadcast_set_mode(async_sess_t *dev_sess, nic_broadcast_mode_t mode) 759 { 760 async_exch_t *exch = async_exchange_begin(dev_sess); 761 int rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 762 NIC_BROADCAST_SET_MODE, mode); 763 async_exchange_end(exch); 764 765 return rc; 766 } 767 768 /** Determine if defective (erroneous) packets are received. 769 * 770 * @param[in] dev_sess 771 * @param[out] mode Bitmask specifying allowed errors 772 * 773 * @return EOK If the operation was successfully completed 774 * 775 */ 776 int nic_defective_get_mode(async_sess_t *dev_sess, uint32_t *mode) 777 { 778 assert(mode); 779 780 sysarg_t _mode; 781 782 async_exch_t *exch = async_exchange_begin(dev_sess); 783 int rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 784 NIC_DEFECTIVE_GET_MODE, &_mode); 785 async_exchange_end(exch); 786 787 *mode = (uint32_t) _mode; 788 789 return rc; 790 } 791 792 /** Set whether defective (erroneous) packets are received. 793 * 794 * @param[in] dev_sess 795 * @param[out] mode Bitmask specifying allowed errors 796 * 797 * @return EOK If the operation was successfully completed 798 * 799 */ 800 int nic_defective_set_mode(async_sess_t *dev_sess, uint32_t mode) 801 { 802 async_exch_t *exch = async_exchange_begin(dev_sess); 803 int rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 804 NIC_DEFECTIVE_SET_MODE, mode); 805 async_exchange_end(exch); 806 807 return rc; 808 } 809 810 /** Retrieve the currently blocked source MAC addresses. 811 * 812 * @param[in] dev_sess 813 * @param[in] max_count Maximal number of addresses that could 814 * be written into the list buffer. 815 * @param[out] address_list Buffer for the list (array). Can be NULL. 816 * @param[out] address_count Number of addresses in the list before 817 * possible truncation due to the max_count. 818 * 819 * @return EOK If the operation was successfully completed 820 * 821 */ 822 int nic_blocked_sources_get(async_sess_t *dev_sess, size_t max_count, 823 nic_address_t *address_list, size_t *address_count) 824 { 825 if (!address_list) 826 max_count = 0; 827 828 async_exch_t *exch = async_exchange_begin(dev_sess); 829 830 sysarg_t ac; 831 int rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 832 NIC_BLOCKED_SOURCES_GET, max_count, &ac); 833 if (rc != EOK) { 834 async_exchange_end(exch); 835 return rc; 836 } 837 838 if (address_count) 839 *address_count = (size_t) ac; 840 841 if ((max_count) && (ac)) 842 rc = async_data_read_start(exch, address_list, 843 max_count * sizeof(nic_address_t)); 844 845 async_exchange_end(exch); 846 return rc; 847 } 848 849 /** Set which source MACs are blocked 850 * 851 * @param[in] dev_sess 852 * @param[in] address_list The list of addresses. Can be NULL. 853 * @param[in] address_count Number of addresses in the list. 854 * 855 * @return EOK If the operation was successfully completed 856 * 857 */ 858 int nic_blocked_sources_set(async_sess_t *dev_sess, 859 const nic_address_t *address_list, size_t address_count) 860 { 861 if (address_list == NULL) 862 address_count = 0; 863 864 async_exch_t *exch = async_exchange_begin(dev_sess); 865 866 aid_t message_id = async_send_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 867 NIC_BLOCKED_SOURCES_SET, address_count, NULL); 868 869 int rc; 870 if (address_count) 871 rc = async_data_write_start(exch, address_list, 872 address_count * sizeof(nic_address_t)); 873 else 874 rc = EOK; 875 876 async_exchange_end(exch); 877 878 sysarg_t res; 879 async_wait_for(message_id, &res); 880 881 if (rc != EOK) 882 return rc; 883 884 return (int) res; 885 } 886 887 /** Request current VLAN filtering mask. 888 * 889 * @param[in] dev_sess 890 * @param[out] stats Structure with the statistics 891 * 892 * @return EOK If the operation was successfully completed 893 * 894 */ 895 int nic_vlan_get_mask(async_sess_t *dev_sess, nic_vlan_mask_t *mask) 896 { 897 assert(mask); 898 899 async_exch_t *exch = async_exchange_begin(dev_sess); 900 int rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 901 NIC_VLAN_GET_MASK); 902 if (rc != EOK) { 903 async_exchange_end(exch); 904 return rc; 905 } 906 907 rc = async_data_read_start(exch, mask, sizeof(nic_vlan_mask_t)); 908 async_exchange_end(exch); 909 910 return rc; 911 } 912 913 /** Set the mask used for VLAN filtering. 914 * 915 * If NULL, VLAN filtering is disabled. 916 * 917 * @param[in] dev_sess 918 * @param[in] mask Pointer to mask structure or NULL to disable. 919 * 920 * @return EOK If the operation was successfully completed 921 * 922 */ 923 int nic_vlan_set_mask(async_sess_t *dev_sess, const nic_vlan_mask_t *mask) 924 { 925 async_exch_t *exch = async_exchange_begin(dev_sess); 926 927 aid_t message_id = async_send_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 928 NIC_VLAN_SET_MASK, mask != NULL, NULL); 929 930 int rc; 931 if (mask != NULL) 932 rc = async_data_write_start(exch, mask, sizeof(nic_vlan_mask_t)); 933 else 934 rc = EOK; 935 936 async_exchange_end(exch); 937 938 sysarg_t res; 939 async_wait_for(message_id, &res); 940 941 if (rc != EOK) 942 return rc; 943 944 return (int) res; 945 } 946 947 /** Set VLAN (802.1q) tag. 948 * 949 * Set whether the tag is to be signaled in offload info and 950 * if the tag should be stripped from received frames and added 951 * to sent frames automatically. Not every combination of add 952 * and strip must be supported. 953 * 954 * @param[in] dev_sess 955 * @param[in] tag VLAN priority (top 3 bits) and 956 * the VLAN tag (bottom 12 bits) 957 * @param[in] add Add the VLAN tag automatically (boolean) 958 * @param[in] strip Strip the VLAN tag automatically (boolean) 959 * 960 * @return EOK If the operation was successfully completed 961 * 962 */ 963 int nic_vlan_set_tag(async_sess_t *dev_sess, uint16_t tag, bool add, bool strip) 964 { 965 async_exch_t *exch = async_exchange_begin(dev_sess); 966 int rc = async_req_4_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 967 NIC_VLAN_SET_TAG, (sysarg_t) tag, (sysarg_t) add, (sysarg_t) strip); 968 async_exchange_end(exch); 969 970 return rc; 971 } 972 973 /** Add new Wake-On-LAN virtue. 974 * 975 * @param[in] dev_sess 976 * @param[in] type Type of the virtue 977 * @param[in] data Data required for this virtue 978 * (depends on type) 979 * @param[in] length Length of the data 980 * @param[out] id Identifier of the new virtue 981 * 982 * @return EOK If the operation was successfully completed 983 * 984 */ 985 int nic_wol_virtue_add(async_sess_t *dev_sess, nic_wv_type_t type, 986 const void *data, size_t length, nic_wv_id_t *id) 987 { 988 assert(id); 989 990 bool send_data = ((data != NULL) && (length != 0)); 991 async_exch_t *exch = async_exchange_begin(dev_sess); 992 993 ipc_call_t result; 994 aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 995 NIC_WOL_VIRTUE_ADD, (sysarg_t) type, send_data, &result); 996 997 sysarg_t res; 998 if (send_data) { 999 int rc = async_data_write_start(exch, data, length); 1000 if (rc != EOK) { 1001 async_exchange_end(exch); 1002 async_wait_for(message_id, &res); 1003 return rc; 1004 } 1005 } 1006 1007 async_exchange_end(exch); 1008 async_wait_for(message_id, &res); 1009 1010 *id = IPC_GET_ARG1(result); 1011 return (int) res; 1012 } 1013 1014 /** Remove Wake-On-LAN virtue. 1015 * 1016 * @param[in] dev_sess 1017 * @param[in] id Virtue identifier 1018 * 1019 * @return EOK If the operation was successfully completed 1020 * 1021 */ 1022 int nic_wol_virtue_remove(async_sess_t *dev_sess, nic_wv_id_t id) 1023 { 1024 async_exch_t *exch = async_exchange_begin(dev_sess); 1025 int rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1026 NIC_WOL_VIRTUE_REMOVE, (sysarg_t) id); 1027 async_exchange_end(exch); 1028 1029 return rc; 1030 } 1031 1032 /** Get information about virtue. 1033 * 1034 * @param[in] dev_sess 1035 * @param[in] id Virtue identifier 1036 * @param[out] type Type of the filter. Can be NULL. 1037 * @param[out] max_length Size of the data buffer. 1038 * @param[out] data Buffer for data used when the 1039 * virtue was created. Can be NULL. 1040 * @param[out] length Length of the data. Can be NULL. 1041 * 1042 * @return EOK If the operation was successfully completed 1043 * 1044 */ 1045 int nic_wol_virtue_probe(async_sess_t *dev_sess, nic_wv_id_t id, 1046 nic_wv_type_t *type, size_t max_length, void *data, size_t *length) 1047 { 1048 sysarg_t _type; 1049 sysarg_t _length; 1050 1051 if (data == NULL) 1052 max_length = 0; 1053 1054 async_exch_t *exch = async_exchange_begin(dev_sess); 1055 1056 int rc = async_req_3_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1057 NIC_WOL_VIRTUE_PROBE, (sysarg_t) id, max_length, 1058 &_type, &_length); 1059 if (rc != EOK) { 1060 async_exchange_end(exch); 1061 return rc; 1062 } 1063 1064 if (type) 1065 *type = _type; 1066 1067 if (length) 1068 *length = _length; 1069 1070 if ((max_length) && (_length != 0)) 1071 rc = async_data_read_start(exch, data, max_length); 1072 1073 async_exchange_end(exch); 1074 return rc; 1075 } 1076 1077 /** Get a list of all virtues of the specified type. 1078 * 1079 * When NIC_WV_NONE is specified as the virtue type the function 1080 * lists virtues of all types. 1081 * 1082 * @param[in] dev_sess 1083 * @param[in] type Type of the virtues 1084 * @param[in] max_count Maximum number of ids that can be 1085 * written into the list buffer. 1086 * @param[out] id_list Buffer for to the list of virtue ids. 1087 * Can be NULL. 1088 * @param[out] id_count Number of virtue identifiers in the list 1089 * before possible truncation due to the 1090 * max_count. Can be NULL. 1091 * 1092 * @return EOK If the operation was successfully completed 1093 * 1094 */ 1095 int nic_wol_virtue_list(async_sess_t *dev_sess, nic_wv_type_t type, 1096 size_t max_count, nic_wv_id_t *id_list, size_t *id_count) 1097 { 1098 if (id_list == NULL) 1099 max_count = 0; 1100 1101 async_exch_t *exch = async_exchange_begin(dev_sess); 1102 1103 sysarg_t count; 1104 int rc = async_req_3_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1105 NIC_WOL_VIRTUE_LIST, (sysarg_t) type, max_count, &count); 1106 1107 if (id_count) 1108 *id_count = (size_t) count; 1109 1110 if ((rc != EOK) || (!max_count)) { 1111 async_exchange_end(exch); 1112 return rc; 1113 } 1114 1115 rc = async_data_read_start(exch, id_list, 1116 max_count * sizeof(nic_wv_id_t)); 1117 1118 async_exchange_end(exch); 1119 return rc; 1120 } 1121 1122 /** Get number of virtues that can be enabled yet. 1123 * 1124 * Count: < 0 => Virtue of this type can be never used 1125 * = 0 => No more virtues can be enabled 1126 * > 0 => #count virtues can be enabled yet 1127 * 1128 * @param[in] dev_sess 1129 * @param[in] type Virtue type 1130 * @param[out] count Number of virtues 1131 * 1132 * @return EOK If the operation was successfully completed 1133 * 1134 */ 1135 int nic_wol_virtue_get_caps(async_sess_t *dev_sess, nic_wv_type_t type, 1136 int *count) 1137 { 1138 assert(count); 1139 1140 sysarg_t _count; 1141 1142 async_exch_t *exch = async_exchange_begin(dev_sess); 1143 int rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1144 NIC_WOL_VIRTUE_GET_CAPS, (sysarg_t) type, &_count); 1145 async_exchange_end(exch); 1146 1147 *count = (int) _count; 1148 return rc; 1149 } 1150 1151 /** Load the frame that issued the wakeup. 1152 * 1153 * The NIC can support only matched_type, only part of the frame 1154 * can be available or not at all. Sometimes even the type can be 1155 * uncertain -- in this case the matched_type contains NIC_WV_NONE. 1156 * 1157 * Frame_length can be greater than max_length, but at most max_length 1158 * bytes will be copied into the frame buffer. 1159 * 1160 * Note: Only the type of the filter can be detected, not the concrete 1161 * filter, because the driver is probably not running when the wakeup 1162 * is issued. 1163 * 1164 * @param[in] dev_sess 1165 * @param[out] matched_type Type of the filter that issued wakeup. 1166 * @param[in] max_length Size of the buffer 1167 * @param[out] frame Buffer for the frame. Can be NULL. 1168 * @param[out] frame_length Length of the stored frame. Can be NULL. 1169 * 1170 * @return EOK If the operation was successfully completed 1171 * 1172 */ 1173 int nic_wol_load_info(async_sess_t *dev_sess, nic_wv_type_t *matched_type, 1174 size_t max_length, uint8_t *frame, size_t *frame_length) 1175 { 1176 assert(matched_type); 1177 1178 sysarg_t _matched_type; 1179 sysarg_t _frame_length; 1180 1181 if (frame == NULL) 1182 max_length = 0; 1183 1184 async_exch_t *exch = async_exchange_begin(dev_sess); 1185 1186 int rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1187 NIC_WOL_LOAD_INFO, max_length, &_matched_type, &_frame_length); 1188 if (rc != EOK) { 1189 async_exchange_end(exch); 1190 return rc; 1191 } 1192 1193 *matched_type = (nic_wv_type_t) _matched_type; 1194 if (frame_length) 1195 *frame_length = (size_t) _frame_length; 1196 1197 if ((max_length != 0) && (_frame_length != 0)) 1198 rc = async_data_read_start(exch, frame, max_length); 1199 1200 async_exchange_end(exch); 1201 return rc; 1202 } 1203 1204 /** Probe supported options and current setting of offload computations 1205 * 1206 * @param[in] dev_sess 1207 * @param[out] supported Supported offload options 1208 * @param[out] active Currently active offload options 1209 * 1210 * @return EOK If the operation was successfully completed 1211 * 1212 */ 1213 int nic_offload_probe(async_sess_t *dev_sess, uint32_t *supported, 1214 uint32_t *active) 1215 { 1216 assert(supported); 1217 assert(active); 1218 1219 sysarg_t _supported; 1220 sysarg_t _active; 1221 1222 async_exch_t *exch = async_exchange_begin(dev_sess); 1223 int rc = async_req_1_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1224 NIC_OFFLOAD_PROBE, &_supported, &_active); 1225 async_exchange_end(exch); 1226 1227 *supported = (uint32_t) _supported; 1228 *active = (uint32_t) _active; 1229 return rc; 1230 } 1231 1232 /** Set which offload computations can be performed on the NIC. 1233 * 1234 * @param[in] dev_sess 1235 * @param[in] mask Mask for the options (only those set here will be set) 1236 * @param[in] active Which options should be enabled and which disabled 1237 * 1238 * @return EOK If the operation was successfully completed 1239 * 1240 */ 1241 int nic_offload_set(async_sess_t *dev_sess, uint32_t mask, uint32_t active) 1242 { 1243 async_exch_t *exch = async_exchange_begin(dev_sess); 1244 int rc = async_req_3_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1245 NIC_AUTONEG_RESTART, (sysarg_t) mask, (sysarg_t) active); 1246 async_exchange_end(exch); 1247 1248 return rc; 1249 } 1250 1251 /** Query the current interrupt/poll mode of the NIC 1252 * 1253 * @param[in] dev_sess 1254 * @param[out] mode Current poll mode 1255 * @param[out] period Period used in periodic polling. 1256 * Can be NULL. 1257 * 1258 * @return EOK If the operation was successfully completed 1259 * 1260 */ 1261 int nic_poll_get_mode(async_sess_t *dev_sess, nic_poll_mode_t *mode, 1262 struct timeval *period) 1263 { 1264 assert(mode); 1265 1266 sysarg_t _mode; 1267 1268 async_exch_t *exch = async_exchange_begin(dev_sess); 1269 1270 int rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1271 NIC_POLL_GET_MODE, period != NULL, &_mode); 1272 if (rc != EOK) { 1273 async_exchange_end(exch); 1274 return rc; 1275 } 1276 1277 *mode = (nic_poll_mode_t) _mode; 1278 1279 if (period != NULL) 1280 rc = async_data_read_start(exch, period, sizeof(struct timeval)); 1281 1282 async_exchange_end(exch); 1283 return rc; 1284 } 1285 1286 /** Set the interrupt/poll mode of the NIC. 1287 * 1288 * @param[in] dev_sess 1289 * @param[in] mode New poll mode 1290 * @param[in] period Period used in periodic polling. Can be NULL. 1291 * 1292 * @return EOK If the operation was successfully completed 1293 * 1294 */ 1295 int nic_poll_set_mode(async_sess_t *dev_sess, nic_poll_mode_t mode, 1296 const struct timeval *period) 1297 { 1298 async_exch_t *exch = async_exchange_begin(dev_sess); 1299 1300 aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1301 NIC_POLL_SET_MODE, (sysarg_t) mode, period != NULL, NULL); 1302 1303 int rc; 1304 if (period) 1305 rc = async_data_write_start(exch, period, sizeof(struct timeval)); 1306 else 1307 rc = EOK; 1308 1309 async_exchange_end(exch); 1310 1311 sysarg_t res; 1312 async_wait_for(message_id, &res); 1313 1314 if (rc != EOK) 1315 return rc; 1316 1317 return (int) res; 1318 } 1319 1320 /** Request the driver to poll the NIC. 1321 * 1322 * @param[in] dev_sess 1323 * 1324 * @return EOK If the operation was successfully completed 1325 * 1326 */ 1327 int nic_poll_now(async_sess_t *dev_sess) 1328 { 1329 async_exch_t *exch = async_exchange_begin(dev_sess); 1330 int rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), NIC_POLL_NOW); 1331 async_exchange_end(exch); 1332 1333 return rc; 1334 } 43 1335 44 1336 static void remote_nic_send_frame(ddf_fun_t *dev, void *iface, … … 1198 2490 * 1199 2491 */ 1200 static remote_iface_func_ptr_t remote_nic_iface_ops[] = {1201 &remote_nic_send_frame,1202 &remote_nic_callback_create,1203 &remote_nic_get_state,1204 &remote_nic_set_state,1205 &remote_nic_get_address,1206 &remote_nic_set_address,1207 &remote_nic_get_stats,1208 &remote_nic_get_device_info,1209 &remote_nic_get_cable_state,1210 &remote_nic_get_operation_mode,1211 &remote_nic_set_operation_mode,1212 &remote_nic_autoneg_enable,1213 &remote_nic_autoneg_disable,1214 &remote_nic_autoneg_probe,1215 &remote_nic_autoneg_restart,1216 &remote_nic_get_pause,1217 &remote_nic_set_pause,1218 &remote_nic_unicast_get_mode,1219 &remote_nic_unicast_set_mode,1220 &remote_nic_multicast_get_mode,1221 &remote_nic_multicast_set_mode,1222 &remote_nic_broadcast_get_mode,1223 &remote_nic_broadcast_set_mode,1224 &remote_nic_defective_get_mode,1225 &remote_nic_defective_set_mode,1226 &remote_nic_blocked_sources_get,1227 &remote_nic_blocked_sources_set,1228 &remote_nic_vlan_get_mask,1229 &remote_nic_vlan_set_mask,1230 &remote_nic_vlan_set_tag,1231 &remote_nic_wol_virtue_add,1232 &remote_nic_wol_virtue_remove,1233 &remote_nic_wol_virtue_probe,1234 &remote_nic_wol_virtue_list,1235 &remote_nic_wol_virtue_get_caps,1236 &remote_nic_wol_load_info,1237 &remote_nic_offload_probe,1238 &remote_nic_offload_set,1239 &remote_nic_poll_get_mode,1240 &remote_nic_poll_set_mode,1241 &remote_nic_poll_now2492 static const remote_iface_func_ptr_t remote_nic_iface_ops[] = { 2493 [NIC_SEND_MESSAGE] = remote_nic_send_frame, 2494 [NIC_CALLBACK_CREATE] = remote_nic_callback_create, 2495 [NIC_GET_STATE] = remote_nic_get_state, 2496 [NIC_SET_STATE] = remote_nic_set_state, 2497 [NIC_GET_ADDRESS] = remote_nic_get_address, 2498 [NIC_SET_ADDRESS] = remote_nic_set_address, 2499 [NIC_GET_STATS] = remote_nic_get_stats, 2500 [NIC_GET_DEVICE_INFO] = remote_nic_get_device_info, 2501 [NIC_GET_CABLE_STATE] = remote_nic_get_cable_state, 2502 [NIC_GET_OPERATION_MODE] = remote_nic_get_operation_mode, 2503 [NIC_SET_OPERATION_MODE] = remote_nic_set_operation_mode, 2504 [NIC_AUTONEG_ENABLE] = remote_nic_autoneg_enable, 2505 [NIC_AUTONEG_DISABLE] = remote_nic_autoneg_disable, 2506 [NIC_AUTONEG_PROBE] = remote_nic_autoneg_probe, 2507 [NIC_AUTONEG_RESTART] = remote_nic_autoneg_restart, 2508 [NIC_GET_PAUSE] = remote_nic_get_pause, 2509 [NIC_SET_PAUSE] = remote_nic_set_pause, 2510 [NIC_UNICAST_GET_MODE] = remote_nic_unicast_get_mode, 2511 [NIC_UNICAST_SET_MODE] = remote_nic_unicast_set_mode, 2512 [NIC_MULTICAST_GET_MODE] = remote_nic_multicast_get_mode, 2513 [NIC_MULTICAST_SET_MODE] = remote_nic_multicast_set_mode, 2514 [NIC_BROADCAST_GET_MODE] = remote_nic_broadcast_get_mode, 2515 [NIC_BROADCAST_SET_MODE] = remote_nic_broadcast_set_mode, 2516 [NIC_DEFECTIVE_GET_MODE] = remote_nic_defective_get_mode, 2517 [NIC_DEFECTIVE_SET_MODE] = remote_nic_defective_set_mode, 2518 [NIC_BLOCKED_SOURCES_GET] = remote_nic_blocked_sources_get, 2519 [NIC_BLOCKED_SOURCES_SET] = remote_nic_blocked_sources_set, 2520 [NIC_VLAN_GET_MASK] = remote_nic_vlan_get_mask, 2521 [NIC_VLAN_SET_MASK] = remote_nic_vlan_set_mask, 2522 [NIC_VLAN_SET_TAG] = remote_nic_vlan_set_tag, 2523 [NIC_WOL_VIRTUE_ADD] = remote_nic_wol_virtue_add, 2524 [NIC_WOL_VIRTUE_REMOVE] = remote_nic_wol_virtue_remove, 2525 [NIC_WOL_VIRTUE_PROBE] = remote_nic_wol_virtue_probe, 2526 [NIC_WOL_VIRTUE_LIST] = remote_nic_wol_virtue_list, 2527 [NIC_WOL_VIRTUE_GET_CAPS] = remote_nic_wol_virtue_get_caps, 2528 [NIC_WOL_LOAD_INFO] = remote_nic_wol_load_info, 2529 [NIC_OFFLOAD_PROBE] = remote_nic_offload_probe, 2530 [NIC_OFFLOAD_SET] = remote_nic_offload_set, 2531 [NIC_POLL_GET_MODE] = remote_nic_poll_get_mode, 2532 [NIC_POLL_SET_MODE] = remote_nic_poll_set_mode, 2533 [NIC_POLL_NOW] = remote_nic_poll_now 1242 2534 }; 1243 2535 … … 1248 2540 * 1249 2541 */ 1250 remote_iface_t remote_nic_iface = { 1251 .method_count = sizeof(remote_nic_iface_ops) / 1252 sizeof(remote_iface_func_ptr_t), 2542 const remote_iface_t remote_nic_iface = { 2543 .method_count = ARRAY_SIZE(remote_nic_iface_ops), 1253 2544 .methods = remote_nic_iface_ops 1254 2545 }; -
uspace/lib/drv/generic/remote_pci.c
r4c14b88 r1b973dc 36 36 #include <async.h> 37 37 #include <errno.h> 38 #include <macros.h> 38 39 39 40 #include "pci_dev_iface.h" 40 41 #include "ddf/driver.h" 42 43 typedef enum { 44 IPC_M_CONFIG_SPACE_READ_8, 45 IPC_M_CONFIG_SPACE_READ_16, 46 IPC_M_CONFIG_SPACE_READ_32, 47 48 IPC_M_CONFIG_SPACE_WRITE_8, 49 IPC_M_CONFIG_SPACE_WRITE_16, 50 IPC_M_CONFIG_SPACE_WRITE_32 51 } pci_dev_iface_funcs_t; 52 53 int pci_config_space_read_8(async_sess_t *sess, uint32_t address, uint8_t *val) 54 { 55 sysarg_t res = 0; 56 57 async_exch_t *exch = async_exchange_begin(sess); 58 int rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE), 59 IPC_M_CONFIG_SPACE_READ_8, address, &res); 60 async_exchange_end(exch); 61 62 *val = (uint8_t) res; 63 return rc; 64 } 65 66 int pci_config_space_read_16(async_sess_t *sess, uint32_t address, 67 uint16_t *val) 68 { 69 sysarg_t res = 0; 70 71 async_exch_t *exch = async_exchange_begin(sess); 72 int rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE), 73 IPC_M_CONFIG_SPACE_READ_16, address, &res); 74 async_exchange_end(exch); 75 76 *val = (uint16_t) res; 77 return rc; 78 } 79 80 int pci_config_space_read_32(async_sess_t *sess, uint32_t address, 81 uint32_t *val) 82 { 83 sysarg_t res = 0; 84 85 async_exch_t *exch = async_exchange_begin(sess); 86 int rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE), 87 IPC_M_CONFIG_SPACE_READ_32, address, &res); 88 async_exchange_end(exch); 89 90 *val = (uint32_t) res; 91 return rc; 92 } 93 94 int pci_config_space_write_8(async_sess_t *sess, uint32_t address, uint8_t val) 95 { 96 async_exch_t *exch = async_exchange_begin(sess); 97 int rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE), 98 IPC_M_CONFIG_SPACE_WRITE_8, address, val); 99 async_exchange_end(exch); 100 101 return rc; 102 } 103 104 int pci_config_space_write_16(async_sess_t *sess, uint32_t address, 105 uint16_t val) 106 { 107 async_exch_t *exch = async_exchange_begin(sess); 108 int rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE), 109 IPC_M_CONFIG_SPACE_WRITE_16, address, val); 110 async_exchange_end(exch); 111 112 return rc; 113 } 114 115 int pci_config_space_write_32(async_sess_t *sess, uint32_t address, 116 uint32_t val) 117 { 118 async_exch_t *exch = async_exchange_begin(sess); 119 int rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE), 120 IPC_M_CONFIG_SPACE_WRITE_32, address, val); 121 async_exchange_end(exch); 122 123 return rc; 124 } 41 125 42 126 static void remote_config_space_read_8(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 49 133 50 134 /** Remote USB interface operations. */ 51 static remote_iface_func_ptr_t remote_pci_iface_ops [] = {52 remote_config_space_read_8,53 remote_config_space_read_16,54 remote_config_space_read_32,55 56 remote_config_space_write_8,57 remote_config_space_write_16,58 remote_config_space_write_32135 static const remote_iface_func_ptr_t remote_pci_iface_ops [] = { 136 [IPC_M_CONFIG_SPACE_READ_8] = remote_config_space_read_8, 137 [IPC_M_CONFIG_SPACE_READ_16] = remote_config_space_read_16, 138 [IPC_M_CONFIG_SPACE_READ_32] = remote_config_space_read_32, 139 140 [IPC_M_CONFIG_SPACE_WRITE_8] = remote_config_space_write_8, 141 [IPC_M_CONFIG_SPACE_WRITE_16] = remote_config_space_write_16, 142 [IPC_M_CONFIG_SPACE_WRITE_32] = remote_config_space_write_32 59 143 }; 60 144 61 145 /** Remote USB interface structure. 62 146 */ 63 remote_iface_t remote_pci_iface = { 64 .method_count = sizeof(remote_pci_iface_ops) / 65 sizeof(remote_pci_iface_ops[0]), 147 const remote_iface_t remote_pci_iface = { 148 .method_count = ARRAY_SIZE(remote_pci_iface_ops), 66 149 .methods = remote_pci_iface_ops 67 150 }; -
uspace/lib/drv/generic/remote_pio_window.c
r4c14b88 r1b973dc 35 35 #include <async.h> 36 36 #include <errno.h> 37 #include <macros.h> 37 38 38 39 #include "ops/pio_window.h" … … 42 43 ipc_call_t *); 43 44 44 static remote_iface_func_ptr_t remote_pio_window_iface_ops [] = {45 static const remote_iface_func_ptr_t remote_pio_window_iface_ops [] = { 45 46 [PIO_WINDOW_GET] = &remote_pio_window_get 46 47 }; 47 48 48 remote_iface_t remote_pio_window_iface = { 49 .method_count = sizeof(remote_pio_window_iface_ops) / 50 sizeof(remote_iface_func_ptr_t), 49 const remote_iface_t remote_pio_window_iface = { 50 .method_count = ARRAY_SIZE(remote_pio_window_iface_ops), 51 51 .methods = remote_pio_window_iface_ops 52 52 }; -
uspace/lib/drv/generic/remote_usb.c
r4c14b88 r1b973dc 281 281 282 282 /** Remote USB interface operations. */ 283 static remote_iface_func_ptr_t remote_usb_iface_ops [] = {283 static const remote_iface_func_ptr_t remote_usb_iface_ops [] = { 284 284 [IPC_M_USB_GET_MY_INTERFACE] = remote_usb_get_my_interface, 285 285 [IPC_M_USB_GET_MY_DEVICE_HANDLE] = remote_usb_get_my_device_handle, … … 296 296 /** Remote USB interface structure. 297 297 */ 298 remote_iface_t remote_usb_iface = {298 const remote_iface_t remote_usb_iface = { 299 299 .method_count = ARRAY_SIZE(remote_usb_iface_ops), 300 300 .methods = remote_usb_iface_ops, -
uspace/lib/drv/generic/remote_usbhc.c
r4c14b88 r1b973dc 37 37 #include <errno.h> 38 38 #include <assert.h> 39 #include <macros.h> 39 40 40 41 #include "usbhc_iface.h" … … 191 192 192 193 /** Remote USB host controller interface operations. */ 193 static remote_iface_func_ptr_t remote_usbhc_iface_ops[] = {194 static const remote_iface_func_ptr_t remote_usbhc_iface_ops[] = { 194 195 [IPC_M_USBHC_READ] = remote_usbhc_read, 195 196 [IPC_M_USBHC_WRITE] = remote_usbhc_write, … … 198 199 /** Remote USB host controller interface structure. 199 200 */ 200 remote_iface_t remote_usbhc_iface = { 201 .method_count = sizeof(remote_usbhc_iface_ops) / 202 sizeof(remote_usbhc_iface_ops[0]), 201 const remote_iface_t remote_usbhc_iface = { 202 .method_count = ARRAY_SIZE(remote_usbhc_iface_ops), 203 203 .methods = remote_usbhc_iface_ops 204 204 }; -
uspace/lib/drv/generic/remote_usbhid.c
r4c14b88 r1b973dc 37 37 #include <assert.h> 38 38 #include <stdio.h> 39 #include <macros.h> 39 40 40 41 #include "usbhid_iface.h" 41 42 #include "ddf/driver.h" 43 44 /** IPC methods for USB HID device interface. */ 45 typedef enum { 46 /** Get number of events reported in single burst. 47 * Parameters: none 48 * Answer: 49 * - Size of one report in bytes. 50 */ 51 IPC_M_USBHID_GET_EVENT_LENGTH, 52 /** Get single event from the HID device. 53 * The word single refers to set of individual events that were 54 * available at particular point in time. 55 * Parameters: 56 * - flags 57 * The call is followed by data read expecting two concatenated 58 * arrays. 59 * Answer: 60 * - EOK - events returned 61 * - EAGAIN - no event ready (only in non-blocking mode) 62 * 63 * It is okay if the client requests less data. Extra data must 64 * be truncated by the driver. 65 * 66 * @todo Change this comment. 67 */ 68 IPC_M_USBHID_GET_EVENT, 69 70 /** Get the size of the report descriptor from the HID device. 71 * 72 * Parameters: 73 * - none 74 * Answer: 75 * - EOK - method is implemented (expected always) 76 * Parameters of the answer: 77 * - Size of the report in bytes. 78 */ 79 IPC_M_USBHID_GET_REPORT_DESCRIPTOR_LENGTH, 80 81 /** Get the report descriptor from the HID device. 82 * 83 * Parameters: 84 * - none 85 * The call is followed by data read expecting the descriptor itself. 86 * Answer: 87 * - EOK - report descriptor returned. 88 */ 89 IPC_M_USBHID_GET_REPORT_DESCRIPTOR 90 } usbhid_iface_funcs_t; 91 92 /** Ask for event array length. 93 * 94 * @param dev_sess Session to DDF device providing USB HID interface. 95 * 96 * @return Number of usages returned or negative error code. 97 * 98 */ 99 int usbhid_dev_get_event_length(async_sess_t *dev_sess, size_t *size) 100 { 101 if (!dev_sess) 102 return EINVAL; 103 104 async_exch_t *exch = async_exchange_begin(dev_sess); 105 106 sysarg_t len; 107 int rc = async_req_1_1(exch, DEV_IFACE_ID(USBHID_DEV_IFACE), 108 IPC_M_USBHID_GET_EVENT_LENGTH, &len); 109 110 async_exchange_end(exch); 111 112 if (rc == EOK) { 113 if (size != NULL) 114 *size = (size_t) len; 115 } 116 117 return rc; 118 } 119 120 /** Request for next event from HID device. 121 * 122 * @param[in] dev_sess Session to DDF device providing USB HID interface. 123 * @param[out] usage_pages Where to store usage pages. 124 * @param[out] usages Where to store usages (actual data). 125 * @param[in] usage_count Length of @p usage_pages and @p usages buffer 126 * (in items, not bytes). 127 * @param[out] actual_usage_count Number of usages actually returned by the 128 * device driver. 129 * @param[in] flags Flags (see USBHID_IFACE_FLAG_*). 130 * 131 * @return Error code. 132 * 133 */ 134 int usbhid_dev_get_event(async_sess_t *dev_sess, uint8_t *buf, 135 size_t size, size_t *actual_size, int *event_nr, unsigned int flags) 136 { 137 if (!dev_sess) 138 return EINVAL; 139 140 if (buf == NULL) 141 return ENOMEM; 142 143 if (size == 0) 144 return EINVAL; 145 146 size_t buffer_size = size; 147 uint8_t *buffer = malloc(buffer_size); 148 if (buffer == NULL) 149 return ENOMEM; 150 151 async_exch_t *exch = async_exchange_begin(dev_sess); 152 153 ipc_call_t opening_request_call; 154 aid_t opening_request = async_send_2(exch, 155 DEV_IFACE_ID(USBHID_DEV_IFACE), IPC_M_USBHID_GET_EVENT, 156 flags, &opening_request_call); 157 158 if (opening_request == 0) { 159 async_exchange_end(exch); 160 free(buffer); 161 return ENOMEM; 162 } 163 164 ipc_call_t data_request_call; 165 aid_t data_request = async_data_read(exch, buffer, buffer_size, 166 &data_request_call); 167 168 async_exchange_end(exch); 169 170 if (data_request == 0) { 171 async_forget(opening_request); 172 free(buffer); 173 return ENOMEM; 174 } 175 176 sysarg_t data_request_rc; 177 sysarg_t opening_request_rc; 178 async_wait_for(data_request, &data_request_rc); 179 async_wait_for(opening_request, &opening_request_rc); 180 181 if (data_request_rc != EOK) { 182 /* Prefer return code of the opening request. */ 183 if (opening_request_rc != EOK) 184 return (int) opening_request_rc; 185 else 186 return (int) data_request_rc; 187 } 188 189 if (opening_request_rc != EOK) 190 return (int) opening_request_rc; 191 192 size_t act_size = IPC_GET_ARG2(data_request_call); 193 194 /* Copy the individual items. */ 195 memcpy(buf, buffer, act_size); 196 197 if (actual_size != NULL) 198 *actual_size = act_size; 199 200 if (event_nr != NULL) 201 *event_nr = IPC_GET_ARG1(opening_request_call); 202 203 return EOK; 204 } 205 206 int usbhid_dev_get_report_descriptor_length(async_sess_t *dev_sess, 207 size_t *size) 208 { 209 if (!dev_sess) 210 return EINVAL; 211 212 async_exch_t *exch = async_exchange_begin(dev_sess); 213 214 sysarg_t arg_size; 215 int rc = async_req_1_1(exch, DEV_IFACE_ID(USBHID_DEV_IFACE), 216 IPC_M_USBHID_GET_REPORT_DESCRIPTOR_LENGTH, &arg_size); 217 218 async_exchange_end(exch); 219 220 if (rc == EOK) { 221 if (size != NULL) 222 *size = (size_t) arg_size; 223 } 224 225 return rc; 226 } 227 228 int usbhid_dev_get_report_descriptor(async_sess_t *dev_sess, uint8_t *buf, 229 size_t size, size_t *actual_size) 230 { 231 if (!dev_sess) 232 return EINVAL; 233 234 if (buf == NULL) 235 return ENOMEM; 236 237 if (size == 0) 238 return EINVAL; 239 240 async_exch_t *exch = async_exchange_begin(dev_sess); 241 242 aid_t opening_request = async_send_1(exch, 243 DEV_IFACE_ID(USBHID_DEV_IFACE), IPC_M_USBHID_GET_REPORT_DESCRIPTOR, 244 NULL); 245 if (opening_request == 0) { 246 async_exchange_end(exch); 247 return ENOMEM; 248 } 249 250 ipc_call_t data_request_call; 251 aid_t data_request = async_data_read(exch, buf, size, 252 &data_request_call); 253 254 async_exchange_end(exch); 255 256 if (data_request == 0) { 257 async_forget(opening_request); 258 return ENOMEM; 259 } 260 261 sysarg_t data_request_rc; 262 sysarg_t opening_request_rc; 263 async_wait_for(data_request, &data_request_rc); 264 async_wait_for(opening_request, &opening_request_rc); 265 266 if (data_request_rc != EOK) { 267 /* Prefer return code of the opening request. */ 268 if (opening_request_rc != EOK) 269 return (int) opening_request_rc; 270 else 271 return (int) data_request_rc; 272 } 273 274 if (opening_request_rc != EOK) 275 return (int) opening_request_rc; 276 277 size_t act_size = IPC_GET_ARG2(data_request_call); 278 279 if (actual_size != NULL) 280 *actual_size = act_size; 281 282 return EOK; 283 } 42 284 43 285 static void remote_usbhid_get_event_length(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 48 290 49 291 /** Remote USB HID interface operations. */ 50 static remote_iface_func_ptr_t remote_usbhid_iface_ops [] = { 51 remote_usbhid_get_event_length, 52 remote_usbhid_get_event, 53 remote_usbhid_get_report_descriptor_length, 54 remote_usbhid_get_report_descriptor 292 static const remote_iface_func_ptr_t remote_usbhid_iface_ops [] = { 293 [IPC_M_USBHID_GET_EVENT_LENGTH] = remote_usbhid_get_event_length, 294 [IPC_M_USBHID_GET_EVENT] = remote_usbhid_get_event, 295 [IPC_M_USBHID_GET_REPORT_DESCRIPTOR_LENGTH] = 296 remote_usbhid_get_report_descriptor_length, 297 [IPC_M_USBHID_GET_REPORT_DESCRIPTOR] = remote_usbhid_get_report_descriptor 55 298 }; 56 299 57 300 /** Remote USB HID interface structure. 58 301 */ 59 remote_iface_t remote_usbhid_iface = { 60 .method_count = sizeof(remote_usbhid_iface_ops) / 61 sizeof(remote_usbhid_iface_ops[0]), 302 const remote_iface_t remote_usbhid_iface = { 303 .method_count = ARRAY_SIZE(remote_usbhid_iface_ops), 62 304 .methods = remote_usbhid_iface_ops 63 305 }; -
uspace/lib/drv/include/ahci_iface.h
r4c14b88 r1b973dc 41 41 #include <async.h> 42 42 43 extern async_sess_t* ahci_get_sess(devman_handle_t, char **); 44 45 extern int ahci_get_sata_device_name(async_sess_t *, size_t, char *); 46 extern int ahci_get_num_blocks(async_sess_t *, uint64_t *); 47 extern int ahci_get_block_size(async_sess_t *, size_t *); 48 extern int ahci_read_blocks(async_sess_t *, uint64_t, size_t, void *); 49 extern int ahci_write_blocks(async_sess_t *, uint64_t, size_t, void *); 50 43 51 /** AHCI device communication interface. */ 44 52 typedef struct { -
uspace/lib/drv/include/battery_iface.h
r4c14b88 r1b973dc 33 33 */ 34 34 35 #ifndef LIB C_DEVICE_BATTERY_DEV_H_36 #define LIB C_DEVICE_BATTERY_DEV_H_35 #ifndef LIBDRV_BATTERY_IFACE_H_ 36 #define LIBDRV_BATTERY_IFACE_H_ 37 37 38 38 #include <async.h> -
uspace/lib/drv/include/char_dev_iface.h
r4c14b88 r1b973dc 33 33 */ 34 34 35 #ifndef LIB C_DEVICE_CHAR_DEV_H_36 #define LIB C_DEVICE_CHAR_DEV_H_35 #ifndef LIBDRV_CHAR_DEV_IFACE_H_ 36 #define LIBDRV_CHAR_DEV_IFACE_H_ 37 37 38 38 #include <async.h> -
uspace/lib/drv/include/ddf/driver.h
r4c14b88 r1b973dc 116 116 #endif 117 117 118 extern int ddf_driver_main( driver_t *);118 extern int ddf_driver_main(const driver_t *); 119 119 120 120 extern void *ddf_dev_data_alloc(ddf_dev_t *, size_t); -
uspace/lib/drv/include/ddf/interrupt.h
r4c14b88 r1b973dc 67 67 extern void interrupt_init(void); 68 68 extern int register_interrupt_handler(ddf_dev_t *, int, interrupt_handler_t *, 69 irq_code_t *);69 const irq_code_t *); 70 70 extern int unregister_interrupt_handler(ddf_dev_t *, int); 71 71 -
uspace/lib/drv/include/dev_iface.h
r4c14b88 r1b973dc 55 55 56 56 typedef struct { 57 size_t method_count;58 remote_iface_func_ptr_t *methods;57 const size_t method_count; 58 const remote_iface_func_ptr_t *methods; 59 59 } remote_iface_t; 60 60 61 61 typedef struct { 62 remote_iface_t *ifaces[DEV_IFACE_COUNT];62 const remote_iface_t *ifaces[DEV_IFACE_COUNT]; 63 63 } iface_dipatch_table_t; 64 64 65 extern remote_iface_t *get_remote_iface(int);66 extern remote_iface_func_ptr_t get_remote_method( remote_iface_t *, sysarg_t);65 extern const remote_iface_t *get_remote_iface(int); 66 extern remote_iface_func_ptr_t get_remote_method(const remote_iface_t *, sysarg_t); 67 67 68 68 -
uspace/lib/drv/include/graph_iface.h
r4c14b88 r1b973dc 38 38 #include <async.h> 39 39 40 typedef enum {41 GRAPH_DEV_CONNECT = 042 } graph_dev_method_t;43 44 40 extern int graph_dev_connect(async_sess_t *); 45 41 -
uspace/lib/drv/include/nic_iface.h
r4c14b88 r1b973dc 33 33 */ 34 34 35 #ifndef LIB C_DEVICE_NIC_H_36 #define LIB C_DEVICE_NIC_H_35 #ifndef LIBDRV_NIC_IFACE_H_ 36 #define LIBDRV_NIC_IFACE_H_ 37 37 38 38 #include <async.h> … … 40 40 #include <ipc/common.h> 41 41 42 typedef enum {43 NIC_SEND_MESSAGE = 0,44 NIC_CALLBACK_CREATE,45 NIC_GET_STATE,46 NIC_SET_STATE,47 NIC_GET_ADDRESS,48 NIC_SET_ADDRESS,49 NIC_GET_STATS,50 NIC_GET_DEVICE_INFO,51 NIC_GET_CABLE_STATE,52 NIC_GET_OPERATION_MODE,53 NIC_SET_OPERATION_MODE,54 NIC_AUTONEG_ENABLE,55 NIC_AUTONEG_DISABLE,56 NIC_AUTONEG_PROBE,57 NIC_AUTONEG_RESTART,58 NIC_GET_PAUSE,59 NIC_SET_PAUSE,60 NIC_UNICAST_GET_MODE,61 NIC_UNICAST_SET_MODE,62 NIC_MULTICAST_GET_MODE,63 NIC_MULTICAST_SET_MODE,64 NIC_BROADCAST_GET_MODE,65 NIC_BROADCAST_SET_MODE,66 NIC_DEFECTIVE_GET_MODE,67 NIC_DEFECTIVE_SET_MODE,68 NIC_BLOCKED_SOURCES_GET,69 NIC_BLOCKED_SOURCES_SET,70 NIC_VLAN_GET_MASK,71 NIC_VLAN_SET_MASK,72 NIC_VLAN_SET_TAG,73 NIC_WOL_VIRTUE_ADD,74 NIC_WOL_VIRTUE_REMOVE,75 NIC_WOL_VIRTUE_PROBE,76 NIC_WOL_VIRTUE_LIST,77 NIC_WOL_VIRTUE_GET_CAPS,78 NIC_WOL_LOAD_INFO,79 NIC_OFFLOAD_PROBE,80 NIC_OFFLOAD_SET,81 NIC_POLL_GET_MODE,82 NIC_POLL_SET_MODE,83 NIC_POLL_NOW84 } nic_funcs_t;85 42 86 43 typedef enum { -
uspace/lib/drv/include/ops/battery_dev.h
r4c14b88 r1b973dc 37 37 38 38 #include "../ddf/driver.h" 39 #include " device/battery_dev.h"39 #include "battery_iface.h" 40 40 41 41 typedef struct { -
uspace/lib/drv/include/pci_dev_iface.h
r4c14b88 r1b973dc 40 40 #include "ddf/driver.h" 41 41 42 typedef enum { 43 IPC_M_CONFIG_SPACE_READ_8, 44 IPC_M_CONFIG_SPACE_READ_16, 45 IPC_M_CONFIG_SPACE_READ_32, 42 #define PCI_DEVICE_ID 0x02 46 43 47 IPC_M_CONFIG_SPACE_WRITE_8, 48 IPC_M_CONFIG_SPACE_WRITE_16, 49 IPC_M_CONFIG_SPACE_WRITE_32 50 } pci_dev_iface_funcs_t; 44 extern int pci_config_space_read_8(async_sess_t *, uint32_t, uint8_t *); 45 extern int pci_config_space_read_16(async_sess_t *, uint32_t, uint16_t *); 46 extern int pci_config_space_read_32(async_sess_t *, uint32_t, uint32_t *); 47 48 extern int pci_config_space_write_8(async_sess_t *, uint32_t, uint8_t); 49 extern int pci_config_space_write_16(async_sess_t *, uint32_t, uint16_t); 50 extern int pci_config_space_write_32(async_sess_t *, uint32_t, uint32_t); 51 51 52 52 /** PCI device communication interface. */ -
uspace/lib/drv/include/usbhid_iface.h
r4c14b88 r1b973dc 40 40 #include <usb/usb.h> 41 41 42 /** IPC methods for USB HID device interface. */ 43 typedef enum { 44 /** Get number of events reported in single burst. 45 * Parameters: none 46 * Answer: 47 * - Size of one report in bytes. 48 */ 49 IPC_M_USBHID_GET_EVENT_LENGTH, 50 /** Get single event from the HID device. 51 * The word single refers to set of individual events that were 52 * available at particular point in time. 53 * Parameters: 54 * - flags 55 * The call is followed by data read expecting two concatenated 56 * arrays. 57 * Answer: 58 * - EOK - events returned 59 * - EAGAIN - no event ready (only in non-blocking mode) 60 * 61 * It is okay if the client requests less data. Extra data must 62 * be truncated by the driver. 63 * 64 * @todo Change this comment. 65 */ 66 IPC_M_USBHID_GET_EVENT, 67 68 /** Get the size of the report descriptor from the HID device. 69 * 70 * Parameters: 71 * - none 72 * Answer: 73 * - EOK - method is implemented (expected always) 74 * Parameters of the answer: 75 * - Size of the report in bytes. 76 */ 77 IPC_M_USBHID_GET_REPORT_DESCRIPTOR_LENGTH, 78 79 /** Get the report descriptor from the HID device. 80 * 81 * Parameters: 82 * - none 83 * The call is followed by data read expecting the descriptor itself. 84 * Answer: 85 * - EOK - report descriptor returned. 86 */ 87 IPC_M_USBHID_GET_REPORT_DESCRIPTOR 88 } usbhid_iface_funcs_t; 89 90 /** USB HID interface flag - return immediately if no data are available. */ 91 #define USBHID_IFACE_FLAG_NON_BLOCKING (1 << 0) 42 extern int usbhid_dev_get_event_length(async_sess_t *, size_t *); 43 extern int usbhid_dev_get_event(async_sess_t *, uint8_t *, size_t, size_t *, 44 int *, unsigned int); 45 extern int usbhid_dev_get_report_descriptor_length(async_sess_t *, size_t *); 46 extern int usbhid_dev_get_report_descriptor(async_sess_t *, uint8_t *, size_t, 47 size_t *); 92 48 93 49 /** USB HID device communication interface. */
Note:
See TracChangeset
for help on using the changeset viewer.
