diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2015-11-17 18:23:48 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2015-11-17 18:23:48 +0100 |
commit | 52e32b2c9f0e5ac7cfb31fd2306e6536340955e1 (patch) | |
tree | 720e376325d14f6713df434e031c503ba8f33c1e /pcilib/memcpy.c | |
parent | 2455a677448e0e0c17d7193bf405b734b758811b (diff) | |
download | pcitool-52e32b2c9f0e5ac7cfb31fd2306e6536340955e1.tar.gz pcitool-52e32b2c9f0e5ac7cfb31fd2306e6536340955e1.tar.bz2 pcitool-52e32b2c9f0e5ac7cfb31fd2306e6536340955e1.tar.xz pcitool-52e32b2c9f0e5ac7cfb31fd2306e6536340955e1.zip |
Support for 64-bit registes
Diffstat (limited to 'pcilib/memcpy.c')
-rw-r--r-- | pcilib/memcpy.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/pcilib/memcpy.c b/pcilib/memcpy.c new file mode 100644 index 0000000..149d1fd --- /dev/null +++ b/pcilib/memcpy.c @@ -0,0 +1,66 @@ +#define _POSIX_C_SOURCE 200112L +#define _GNU_SOURCE + +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <stdint.h> +#include <assert.h> +#include <ctype.h> +#include <time.h> +#include <sched.h> +#include <arpa/inet.h> +#include <sys/time.h> + +#include "pci.h" +#include "tools.h" +#include "error.h" + +void *pcilib_memcpy8(void * dst, void const * src, size_t len) { + int i; + for (i = 0; i < len; i++) ((char*)dst)[i] = ((char*)src)[i]; + return dst; +} + +void *pcilib_memcpy32(void * dst, void const * src, size_t len) { + uint32_t * plDst = (uint32_t *) dst; + uint32_t const * plSrc = (uint32_t const *) src; + + while (len >= 4) { +// *plDst = ntohl(*plSrc); + *plDst = *plSrc; + plSrc++; + plDst++; + len -= 4; + } + + char * pcDst = (char *) plDst; + char const * pcSrc = (char const *) plSrc; + + while (len--) { + *pcDst++ = *pcSrc++; + } + + return (dst); +} + + +void *pcilib_memcpy64(void * dst, void const * src, size_t len) { + uint64_t * plDst = (uint64_t *) dst; + uint64_t const * plSrc = (uint64_t const *) src; + + while (len >= 8) { + *plDst++ = *plSrc++; + len -= 8; + } + + char * pcDst = (char *) plDst; + char const * pcSrc = (char const *) plSrc; + + while (len--) { + *pcDst++ = *pcSrc++; + } + + return (dst); +} + |