diff --git a/src/gds/awgtpman/awg.c b/src/gds/awgtpman/awg.c index 941cc3b9b1ab56cf84f02127a687d9a137c851db..a8c642a79907818226bc2a94a5041cf1ec62fff6 100644 --- a/src/gds/awgtpman/awg.c +++ b/src/gds/awgtpman/awg.c @@ -960,7 +960,7 @@ Organization of generating waveforms: /* now start transfer */ - memcpy(target_page->buf, p->page, p->pagelen * sizeof(float)); + memcpy_to_vol(target_page->buf, p->page, p->pagelen * sizeof(float)); target_page->status = 0; } diff --git a/src/gds/awgtpman/dtt/rmapi.h b/src/gds/awgtpman/dtt/rmapi.h index bad6f01a7f1d359de74be64478e850b5d7bb9f0a..87d89c411a8698d5e339553048324988b4b952aa 100644 --- a/src/gds/awgtpman/dtt/rmapi.h +++ b/src/gds/awgtpman/dtt/rmapi.h @@ -347,6 +347,11 @@ extern "C" { int rmWrite (short ID, char *pData, int offset, int size, int flag); + + /** + * Initialize Reflective memory + */ + void initReflectiveMemory(); /*@}*/ diff --git a/src/gds/awgtpman/shared_memory.c b/src/gds/awgtpman/shared_memory.c index 876fd7f1fc09560ddc1f32be896745d5380ef283..cf60a1a490034c21912faab98511af3124ef2a06 100644 --- a/src/gds/awgtpman/shared_memory.c +++ b/src/gds/awgtpman/shared_memory.c @@ -17,8 +17,39 @@ int OpenAwgDataSharedMemory(const char *model_name) char buff[256]; strncpy(buff, model_name, sizeof(buff)); buff[sizeof(buff)-1] = 0; - strncat(buff, SHMEM_AWG_SUFFIX, sizeof(buff)); + strncat(buff, SHMEM_AWG_SUFFIX, sizeof(buff)-1); + buff[sizeof(buff)-1] = 0; shmemAwgData = (volatile AWG_DATA *)shmem_open_segment(buff, SHMEM_AWG_SIZE); AWG_DATA_INIT(shmemAwgData); return (shmemAwgData!=NULL) ? -1 : 0; -} \ No newline at end of file +} + +volatile void * memcpy_to_vol(volatile void *dest, const void *src, size_t len) +{ + // source copied from gcc memcpy + volatile char *d = dest; + const char *s = src; + while (len--) + *d++ = *s++; + return dest; +} + +void * memcpy_from_vol(void *dest, const volatile void *src, size_t len) +{ + // source copied from gcc memcpy + char *d = dest; + volatile const char *s = src; + while (len--) + *d++ = *s++; + return dest; +} + +volatile void * memcpy_vol_to_vol(volatile void *dest, const volatile void *src, size_t len) +{ + // source copied from gcc memcpy + volatile char *d = dest; + volatile const char *s = src; + while (len--) + *d++ = *s++; + return dest; +} diff --git a/src/gds/awgtpman/shared_memory.h b/src/gds/awgtpman/shared_memory.h index 8fb2fe4710a41a1c33fbc5a246a405d29b5b25cd..3315610828a4cdb3c1c507c8f6c74379a6ba3c32 100644 --- a/src/gds/awgtpman/shared_memory.h +++ b/src/gds/awgtpman/shared_memory.h @@ -32,14 +32,23 @@ int OpenAwgDataSharedMemory(const char *model_name); volatile void * memcpy_to_vol(volatile void *dest, const void *src, size_t len); /** - * - * @param dest - * @param src - * @param len - * @return + * Copy to a regular pointer from a volatile pointer. + * Works the same as memcpy() + * @param dest Destination pointer. + * @param src Source pointer. Must be volatile. + * @param len Number of bytes to copy. + * @return destination pointer. */ void * memcpy_from_vol(void *dest, const volatile void *src, size_t len); +/** + * Copy to a volatile pointer from a volatile pointer. + * Works the same as memcpy() + * @param dest The destination pointer. Must be volatile. + * @param src The source pointer. Must be volatile. + * @param len Number of bytes to copy. + * @return The destination pointer. + */ volatile void * memcpy_vol_to_vol(volatile void *dest, const volatile void *src, size_t len); diff --git a/src/gds/awgtpman/testpoint.c b/src/gds/awgtpman/testpoint.c index a6c543b7dd97834d5086eaedbd490ff6100f1a10..2642c0103041bd5cceac5467613207bbd5800de7 100644 --- a/src/gds/awgtpman/testpoint.c +++ b/src/gds/awgtpman/testpoint.c @@ -242,7 +242,7 @@ static char *versionId = "Version $Id$" ; /* make test point list */ testpoints.TP_r_len = tplen; - testpoints.TP_r_val = (testpoint_t*) tp; + testpoints.TP_r_val = (ushort *) tp; /* make client handle */ clnt = tpMakeHandle (node); @@ -406,14 +406,14 @@ static char *versionId = "Version $Id$" ; /* make test point list */ if (tp == NULL) { testpoints.TP_r_len = 1; - testpoints.TP_r_val = &all; + testpoints.TP_r_val = (ushort *)&all; } else if (tplen == 0) { return 0; } else { testpoints.TP_r_len = tplen; - testpoints.TP_r_val = (testpoint_t*) tp; + testpoints.TP_r_val = (ushort *) tp; } /* make client handle */ diff --git a/src/gds/awgtpman/testpoint_server.c b/src/gds/awgtpman/testpoint_server.c index a64e3e0b6c3e7b536b612ad9d84a39f0fa9ccaba..12b7c0acfc7166b74b53ca354277b7e81a8e80e6 100644 --- a/src/gds/awgtpman/testpoint_server.c +++ b/src/gds/awgtpman/testpoint_server.c @@ -756,7 +756,7 @@ static char *versionId = "Version $Id$" ; /* get index directly from test point client interface */ result->status = - tpGetIndexDirect (node, tpinterface, result->tp.TP_r_val, + tpGetIndexDirect (node, tpinterface, (testpoint_t *)result->tp.TP_r_val, result->tp.TP_r_len, time, epoch); if (result->status >= 0) { result->tp.TP_r_len = result->status; @@ -970,7 +970,7 @@ static char *versionId = "Version $Id$" ; while ((p != NULL) && (tp->TP_r_len < _MAX_TPNAMES)) { printf("tpName2Index checking %s\n", p); if ((gdsChannelInfo (p, &chn) == 0) && - (tpIsValid (&chn, &tp_node, tp->TP_r_val + tp->TP_r_len)) && + (tpIsValid (&chn, &tp_node, (testpoint_t *)tp->TP_r_val + tp->TP_r_len)) && (node == tp_node)) { printf ("%s is tp %i (node %i)\n", p, tp->TP_r_val[tp->TP_r_len], diff --git a/src/shmem/shmem_header.h b/src/shmem/shmem_header.h index 88f854e75053f56f599170fc42cf2bdc7aba7e23..2d7282c9019de5e65cf8fc3b9fc8284cf2f35b90 100644 --- a/src/shmem/shmem_header.h +++ b/src/shmem/shmem_header.h @@ -19,7 +19,7 @@ typedef struct SHMEM_HEADER * Pass a pointer to the header, and a version number. * Sets version number and magic bytes. */ -#define SHMEM_SET_VERSION(HEADER_PTR, ID, VERSION) { SHMEM_HEADER *_h_p_ = HEADER_PTR; \ +#define SHMEM_SET_VERSION(HEADER_PTR, ID, VERSION) { volatile SHMEM_HEADER *_h_p_ = (volatile SHMEM_HEADER *)HEADER_PTR; \ _h_p_->magic_bytes = SHMEM_HEADER_MAGIC_BYTES; \ _h_p_->struct_id = ID; \ _h_p_->version = VERSION; } @@ -29,10 +29,10 @@ typedef struct SHMEM_HEADER * Returns 0 if the structure does not start with a properly intialized * SHMEM_HEADER */ -#define SHMEM_GET_VERSION(HDR_PTR) ( (((SHMEM_HEADER *)HDR_PTR)->magic_bytes == SHMEM_HEADER_MAGIC_BYTES) \ - ? ((SHMEM_HEADER *)HDR_PTR)->version : 0 ) +#define SHMEM_GET_VERSION(HDR_PTR) ( (((volatile SHMEM_HEADER *)HDR_PTR)->magic_bytes == SHMEM_HEADER_MAGIC_BYTES) \ + ? ((volatile SHMEM_HEADER *)HDR_PTR)->version : 0 ) -#define SHMEM_GET_ID(HDR_PTR) ( (((SHMEM_HEADER *)HDR_PTR)->magic_bytes == SHMEM_HEADER_MAGIC_BYTES) \ - ? ((SHMEM_HEADER *)HDR_PTR)->struct_id : 0 ) +#define SHMEM_GET_ID(HDR_PTR) ( (((volatile SHMEM_HEADER *)HDR_PTR)->magic_bytes == SHMEM_HEADER_MAGIC_BYTES) \ + ? ((volatile SHMEM_HEADER *)HDR_PTR)->struct_id : 0 ) #endif // DAQD_TRUNK_SHMEM_HEADER_H