31 #ifndef LIBSWITCHTEC_MMAP_GAS_H 
   32 #define LIBSWITCHTEC_MMAP_GAS_H 
   39 #define __force __attribute__((force)) 
   44 #include "../switchtec_priv.h" 
   46 static void mmap_memcpy_to_gas(
struct switchtec_dev *dev, 
void __gas *dest,
 
   47                    const void *src, 
size_t n)
 
   49     memcpy((
void __force *)dest, src, n);
 
   52 static void mmap_memcpy_from_gas(
struct switchtec_dev *dev, 
void *dest,
 
   53                  const void __gas *src, 
size_t n)
 
   55     memcpy(dest, (
void __force *)src, n);
 
   58 static ssize_t mmap_write_from_gas(
struct switchtec_dev *dev, 
int fd,
 
   59                    const void __gas *src, 
size_t n)
 
   61     return write(fd, (
void __force *)src, n);
 
   64 #define create_gas_read(type, suffix) \ 
   65     static type mmap_gas_read ## suffix(struct switchtec_dev *dev, \ 
   68         type *safe_addr = (type __force *)addr; \ 
   69         asm volatile("": : :"memory"); \ 
   73 #define create_gas_write(type, suffix) \ 
   74     static void mmap_gas_write ## suffix(struct switchtec_dev *dev, \ 
   75                          type val, type __gas *addr) \ 
   77         type *safe_addr = (type __force *)addr; \ 
   78         asm volatile("": : :"memory"); \ 
   82 create_gas_read(uint8_t, 8);
 
   83 create_gas_read(uint16_t, 16);
 
   84 create_gas_read(uint32_t, 32);
 
   85 create_gas_read(uint64_t, 64);
 
   87 create_gas_write(uint8_t, 8);
 
   88 create_gas_write(uint16_t, 16);
 
   89 create_gas_write(uint32_t, 32);
 
   90 create_gas_write(uint64_t, 64);