diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2015-11-20 18:26:29 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2015-11-20 18:26:29 +0100 |
commit | bba9c619c79175b58359116b52a889e30a632d07 (patch) | |
tree | 6da3898d50880e96f2afa5d5139bd16263fccf42 /pcilib/memcpy.c | |
parent | fe5bca8604e8c381d3fe2cce3073dd6602d016d1 (diff) | |
download | pcitool-bba9c619c79175b58359116b52a889e30a632d07.tar.gz pcitool-bba9c619c79175b58359116b52a889e30a632d07.tar.bz2 pcitool-bba9c619c79175b58359116b52a889e30a632d07.tar.xz pcitool-bba9c619c79175b58359116b52a889e30a632d07.zip |
64-bit access to BAR memory
Diffstat (limited to 'pcilib/memcpy.c')
-rw-r--r-- | pcilib/memcpy.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pcilib/memcpy.c b/pcilib/memcpy.c index 149d1fd..dd55037 100644 --- a/pcilib/memcpy.c +++ b/pcilib/memcpy.c @@ -64,3 +64,19 @@ void *pcilib_memcpy64(void * dst, void const * src, size_t len) { return (dst); } +typedef void* (*pcilib_memcpy_routine_t)(void * dst, void const *src, size_t bytes); +static pcilib_memcpy_routine_t pcilib_memcpy_routines[4] = { + pcilib_memcpy8, NULL, pcilib_memcpy32, pcilib_memcpy64 +}; + +void *pcilib_memcpy(void * dst, void const * src, uint8_t access, size_t n) { + size_t pos = 0, size = n * access; + pcilib_memcpy_routine_t routine; + + assert((access)&&(access <= 8)); + + while (access >>= 1) ++pos; + routine = pcilib_memcpy_routines[pos]; + + return routine(dst, src, size); +} |