25 #ifndef LIBSWITCHTEC_GAS_MRPC_H 26 #define LIBSWITCHTEC_GAS_MRPC_H 28 #include <switchtec/mrpc.h> 31 #include <switchtec/endian.h> 36 uint8_t data[MRPC_MAX_DATA_LEN - 2 *
sizeof(uint32_t)];
45 const void *src,
size_t n);
47 const void __gas *src,
size_t n);
49 const void __gas *src,
size_t n);
52 static inline uint8_t le8toh(uint8_t x) {
return x; }
53 static inline uint8_t htole8(uint8_t x) {
return x; }
55 #define create_mrpc_gas_read(type, suffix) \ 56 static inline int gas_mrpc_read ## suffix(struct switchtec_dev *dev, \ 61 ret = gas_mrpc_memcpy_from_gas(dev, data, addr, \ 63 *data = le##suffix##toh(*data); \ 67 #define create_mrpc_gas_write(type, suffix) \ 68 static inline void gas_mrpc_write ## suffix(struct switchtec_dev *dev, \ 69 type val, type __gas *addr) \ 71 val = htole##suffix (val); \ 72 gas_mrpc_memcpy_to_gas(dev, addr, &val, sizeof(val)); \ 75 create_mrpc_gas_read(uint8_t, 8);
76 create_mrpc_gas_read(uint16_t, 16);
77 create_mrpc_gas_read(uint32_t, 32);
78 create_mrpc_gas_read(uint64_t, 64);
80 create_mrpc_gas_write(uint8_t, 8);
81 create_mrpc_gas_write(uint16_t, 16);
82 create_mrpc_gas_write(uint32_t, 32);
83 create_mrpc_gas_write(uint64_t, 64);
85 #undef create_mrpc_gas_read 86 #undef create_mrpc_gas_write int gas_mrpc_memcpy_from_gas(struct switchtec_dev *dev, void *dest, const void __gas *src, size_t n)
Copy data from the GAS using MRPC commands.
ssize_t gas_mrpc_write_from_gas(struct switchtec_dev *dev, int fd, const void __gas *src, size_t n)
Call write() with data from the GAS using an MRPC command.
void gas_mrpc_memcpy_to_gas(struct switchtec_dev *dev, void __gas *dest, const void *src, size_t n)
Copy data to the GAS using MRPC commands.