datacpy.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _PCILIB_DATACPY_H
  2. #define _PCILIB_DATACPY_H
  3. #include <stdio.h>
  4. #include <stdint.h>
  5. #include <pcilib.h>
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. /**
  10. * The collection of slow memcpy functions to move the data between BAR and system memory.
  11. * If necessary the endianess conversion is performed to ensure that the data is encoded
  12. * using the specified endianess in the BAR memory and using the native host order in the
  13. * system memory. Since endianess conversion is symmetric, it is irrelevant if we are
  14. * copying from system memory to BAR memory or vice-versa.
  15. *
  16. * The hardware may restrict access width or expose different behavior depending on the
  17. * access width. These functions access memory using the specified word width only.
  18. * 8-, 16-, 32-, and 64-bit wide access is supported.
  19. *
  20. * @param[out] dst - the destination memory region
  21. * @param[in] src - the source memory region
  22. * @param[in] access - the size of word (a single memory access) in bytes
  23. * @param[in] n - the number of words to copy (\p n * \p access bytes are copied).
  24. * @param[in] endianess - the endianess of the data words in the BAR memory
  25. * @return - `dst` or NULL on error
  26. */
  27. void *pcilib_datacpy(void * dst, void const * src, uint8_t access, size_t n, pcilib_endianess_t endianess);
  28. /**
  29. * The collection of slow memcpy functions to move the data between BAR and system memory.
  30. * If necessary the endianess conversion is performed to ensure that the data is encoded
  31. * using the specified endianess in the BAR memory and using the native host order in the
  32. * system memory. Since endianess conversion is symmetric, it is irrelevant if we are
  33. * copying from system memory to BAR memory or vice-versa.
  34. *
  35. * The hardware may restrict access width or expose different behavior depending on the
  36. * access width. This function only perform 32-bit memory accesses.
  37. *
  38. * @param[out] dst - the destination memory region
  39. * @param[in] src - the source memory region
  40. * @param[in] n - the number of 32-bit words to copy (4 * \p n bytes are copied)
  41. * @param[in] endianess - the endianess of the data words in the BAR memory
  42. * @return - `dst` or NULL on error
  43. */
  44. void *pcilib_datacpy32(void * dst, void const * src, size_t n, pcilib_endianess_t endianess);
  45. /**
  46. * The collection of slow memcpy functions to move the data between BAR and system memory.
  47. * If necessary the endianess conversion is performed to ensure that the data is encoded
  48. * using the specified endianess in the BAR memory and using the native host order in the
  49. * system memory. Since endianess conversion is symmetric, it is irrelevant if we are
  50. * copying from system memory to BAR memory or vice-versa.
  51. *
  52. * The hardware may restrict access width or expose different behavior depending on the
  53. * access width. This function only perform 64-bit memory accesses.
  54. *
  55. * @param[out] dst - the destination memory region
  56. * @param[in] src - the source memory region
  57. * @param[in] n - the number of 64-bit words to copy (8 * \p n bytes are copied)
  58. * @param[in] endianess - the endianess of the data words in the BAR memory
  59. * @return - `dst` or NULL on error
  60. */
  61. void *pcilib_datacpy64(void * dst, void const * src, size_t n, pcilib_endianess_t endianess);
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif /* _PCILIB_DATACPY_H */