diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer new file mode 100755 index 000000000..ee2c5315d Binary files /dev/null and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv10.1.0 b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv10.1.0 deleted file mode 100755 index a96f5ec68..000000000 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv10.1.0 and /dev/null differ diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index 8893cf0c9..fc6b79ff3 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -1875,10 +1875,9 @@ int configureMAC() { calcChecksum(udp); // force FPGA writes to be aligned and in order - uint32_t words[sizeof(udp_header) / sizeof(uint32_t)]; - memcpy(words, udp, sizeof(udp_header)); - for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { - bus_w(addr + i * 2, words[i]); + if (bus_w_block(addr, udp, sizeof(udp_header), false) == FAIL) { + LOG(logERROR, ("Failed to write UDP header\n")); + return FAIL; } cleanFifos(); // FIXME: resetPerpheral() for ctb? diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv10.1.0 b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv10.1.0 index c7b451b14..7d2562a51 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv10.1.0 and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv10.1.0 differ diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv10.1.0 b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv10.1.0 index 6342bf02b..2cb626024 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv10.1.0 and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv10.1.0 differ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 36fc371bb..5206fa0d7 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -1965,9 +1965,9 @@ void setFirstUDPDestination(int value) { PKT_CONFIG_RXR_START_ID_MSK)); } -void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip, - uint64_t destmac, uint16_t destport, uint64_t sourcemac, - uint32_t sourceip, uint16_t sourceport) { +int setupHeader(int iRxEntry, int vetoInterface, uint32_t destip, + uint64_t destmac, uint16_t destport, uint64_t sourcemac, + uint32_t sourceip, uint16_t sourceport) { // start addr uint32_t addr = BASE_UDP_RAM; @@ -2011,15 +2011,15 @@ void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip, calcChecksum(udp); // force FPGA writes to be aligned and in order - uint32_t words[sizeof(udp_header) / sizeof(uint32_t)]; - memcpy(words, udp, sizeof(udp_header)); - for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { - bus_w(addr + i * sizeof(uint32_t), words[i]); + if (bus_w_block(addr, udp, sizeof(udp_header), false) == FAIL) { + LOG(logERROR, ("Failed to write UDP header\n")); + return FAIL; } if (iRxEntry < numUdpDestinations) { LOG(logINFO, ("\tIP checksum : 0x%lx\n\n", udp->ip_checksum)); } + return OK; } void calcChecksum(udp_header *udp) { @@ -2133,13 +2133,23 @@ int configureMAC() { } #endif // data - setupHeader(iRxEntry, 0, dstip, dstmac, dstport, srcmac, srcip, - srcport); + if (setupHeader(iRxEntry, 0, dstip, dstmac, dstport, srcmac, srcip, + srcport) == FAIL) { + LOG(logERROR, ("could not set udp destination IP and port for " + "data interface [entry:%d] \n", + iRxEntry)); + return FAIL; + } // veto if (i10gbe) { - setupHeader(iRxEntry, 1, dstip2, dstmac2, dstport2, srcmac2, srcip2, - srcport2); + if (setupHeader(iRxEntry, 1, dstip2, dstmac2, dstport2, srcmac2, + srcip2, srcport2) == FAIL) { + LOG(logERROR, ("could not set udp destination IP and port for " + "veto interface [entry:%d] \n", + iRxEntry)); + return FAIL; + } } } cleanFifos(); diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv10.1.0 b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv10.1.0 index b1f9bfaf2..ef2facae6 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv10.1.0 and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv10.1.0 differ diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 9d15f0fd9..916b4c942 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -1776,9 +1776,9 @@ int getPrimaryInterface() { return ((bus_r(CONFIG_REG) & CONFIG_INNR_PRIMRY_INTRFCE_MSK) ? 1 : 0); } -void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, - uint64_t destmac, uint16_t destport, uint64_t sourcemac, - uint32_t sourceip, uint16_t sourceport) { +int setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, + uint64_t destmac, uint16_t destport, uint64_t sourcemac, + uint32_t sourceip, uint16_t sourceport) { // start addr uint32_t addr = (type == INNER ? RXR_ENDPOINT_INNER_START_REG @@ -1820,15 +1820,15 @@ void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, calcChecksum(udp); // force FPGA writes to be aligned and in order - uint32_t words[sizeof(udp_header) / sizeof(uint32_t)]; - memcpy(words, udp, sizeof(udp_header)); - for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { - bus_w(addr + i * 2, words[i]); + if (bus_w_block(addr, udp, sizeof(udp_header), false) == FAIL) { + LOG(logERROR, ("Failed to write UDP header\n")); + return FAIL; } if (iRxEntry < numUdpDestinations) { LOG(logINFO, ("\tIP checksum : 0x%lx\n\n", udp->ip_checksum)); } + return OK; } void calcChecksum(udp_header *udp) { @@ -1945,21 +1945,41 @@ int configureMAC() { #endif if (numInterfaces == 2) { // bottom - setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, srcip, - srcport); + if (setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, + srcip, srcport) == FAIL) { + LOG(logERROR, ("could not set udp header for outer interface " + "[entry:%d]\n", + iRxEntry)); + return FAIL; + } // top - setupHeader(iRxEntry, INNER, dstip2, dstmac2, dstport2, srcmac2, - srcip2, srcport2); + if (setupHeader(iRxEntry, INNER, dstip2, dstmac2, dstport2, srcmac2, + srcip2, srcport2) == FAIL) { + LOG(logERROR, ("could not set udp header for inner interface " + "[entry:%d]\n", + iRxEntry)); + return FAIL; + } } // single interface else { // default if (selInterface == 0) { - setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, - srcip, srcport); + if (setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, + srcip, srcport) == FAIL) { + LOG(logERROR, ("could not set udp header for outer " + "interface [entry:%d]\n", + iRxEntry)); + return FAIL; + } } else { - setupHeader(iRxEntry, INNER, dstip, dstmac, dstport, srcmac, - srcip, srcport2); + if (setupHeader(iRxEntry, INNER, dstip, dstmac, dstport, srcmac, + srcip, srcport2) == FAIL) { + LOG(logERROR, ("could not set udp header for inner " + "interface [entry:%d]\n", + iRxEntry)); + return FAIL; + } } } } diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv10.1.0 b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv10.1.0 index 491166701..4beadb6bf 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv10.1.0 and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv10.1.0 differ diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index a21f34c20..405aa6a4c 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -1120,9 +1120,9 @@ int getPrimaryInterface() { return ((bus_r(CONFIG_REG) & CONFIG_INNR_PRIMRY_INTRFCE_MSK) ? 1 : 0); } -void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, - uint64_t destmac, uint16_t destport, uint64_t sourcemac, - uint32_t sourceip, uint16_t sourceport) { +int setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, + uint64_t destmac, uint16_t destport, uint64_t sourcemac, + uint32_t sourceip, uint16_t sourceport) { // start addr uint32_t addr = (type == INNER ? RXR_ENDPOINT_INNER_START_REG @@ -1164,15 +1164,15 @@ void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, calcChecksum(udp); // force FPGA writes to be aligned and in order - uint32_t words[sizeof(udp_header) / sizeof(uint32_t)]; - memcpy(words, udp, sizeof(udp_header)); - for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { - bus_w(addr + i * 2, words[i]); + if (bus_w_block(addr, udp, sizeof(udp_header), false) == FAIL) { + LOG(logERROR, ("Failed to write UDP header\n")); + return FAIL; } if (iRxEntry < numUdpDestinations) { LOG(logINFO, ("\tIP checksum : 0x%lx\n\n", udp->ip_checksum)); } + return OK; } void calcChecksum(udp_header *udp) { @@ -1289,21 +1289,41 @@ int configureMAC() { #endif if (numInterfaces == 2) { // bottom - setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, srcip, - srcport); + if (setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, + srcip, srcport) == FAIL) { + LOG(logERROR, ("could not set udp header for outer interface " + "[entry:%d]\n", + iRxEntry)); + return FAIL; + } // top - setupHeader(iRxEntry, INNER, dstip2, dstmac2, dstport2, srcmac2, - srcip2, srcport2); + if (setupHeader(iRxEntry, INNER, dstip2, dstmac2, dstport2, srcmac2, + srcip2, srcport2) == FAIL) { + LOG(logERROR, ("could not set udp header for inner interface " + "[entry:%d]\n", + iRxEntry)); + return FAIL; + } } // single interface else { // default if (selInterface == 0) { - setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, - srcip, srcport); + if (setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, + srcip, srcport) == FAIL) { + LOG(logERROR, ("could not set udp header for outer " + "interface [entry:%d]\n", + iRxEntry)); + return FAIL; + } } else { - setupHeader(iRxEntry, INNER, dstip, dstmac, dstport, srcmac, - srcip, srcport2); + if (setupHeader(iRxEntry, INNER, dstip, dstmac, dstport, srcmac, + srcip, srcport2) == FAIL) { + LOG(logERROR, ("could not set udp header for inner " + "interface [entry:%d]\n", + iRxEntry)); + return FAIL; + } } } } diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv10.1.0 b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv10.1.0 index a2058c933..8b5209ee8 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv10.1.0 and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv10.1.0 differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 19b3fba00..bfd69a73b 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -2044,10 +2044,9 @@ int configureMAC() { calcChecksum(udp); // force FPGA writes to be aligned and in order - uint32_t words[sizeof(udp_header) / sizeof(uint32_t)]; - memcpy(words, udp, sizeof(udp_header)); - for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { - bus_w(addr + i * sizeof(uint32_t), words[i]); + if (bus_w_block(addr, udp, sizeof(udp_header), false) == FAIL) { + LOG(logERROR, ("Failed to write UDP header\n")); + return FAIL; } if (iRxEntry < numUdpDestinations) { diff --git a/slsDetectorServers/slsDetectorServer/include/arm64.h b/slsDetectorServers/slsDetectorServer/include/arm64.h index 3cf3e5aae..b6ee6dafb 100644 --- a/slsDetectorServers/slsDetectorServer/include/arm64.h +++ b/slsDetectorServers/slsDetectorServer/include/arm64.h @@ -3,17 +3,43 @@ #pragma once #include +#include #include +/** csp0base */ void bus_w(u_int32_t offset, u_int32_t data); -void bus_w_csp1(u_int32_t offset, u_int32_t data); -void bus_w_csp2(u_int32_t offset, u_int32_t data); u_int32_t bus_r(u_int32_t offset); + +/** udp header */ +void bus_w_csp1(u_int32_t offset, u_int32_t data); u_int32_t bus_r_csp1(u_int32_t offset); + +void bus_w_csp2(u_int32_t offset, u_int32_t data); u_int32_t bus_r_csp2(u_int32_t offset); + +/** + * Write `size` bytes from `src` to the FPGA as 32-bit words, + * one at a time and in order. + * @param fixedAddress true: every word goes to `offset` (e.g. a FIFO). + * false: words go to consecutive addresses from `offset`. + * @returns OK, or FAIL if `size` is 0 or not a multiple of 4 bytes. + */ +int bus_w_block(u_int32_t offset, const void *src, size_t size, + bool fixedAddress); +int bus_r_block(u_int32_t offset, void *dest, size_t size, bool fixedAddress); + +/** + * Force FPGA writes to be aligned and in order + * by writing 32 bit words to the bus (csp1: udp header) + * @returns FAIL if size is not a non-zero multiple of sizeof(uint32_t), else OK + */ +int bus_w_csp1_block(const void *src, size_t size); + uint64_t getU64BitReg(int aLSB, int aMSB); void setU64BitReg(uint64_t value, int aLSB, int aMSB); + +/** literal register address value provided by client */ u_int32_t readRegister(u_int32_t offset); u_int32_t writeRegister(u_int32_t offset, u_int32_t data); + int mapCSP0(void); -u_int32_t *Arm_getUDPBaseAddress(); diff --git a/slsDetectorServers/slsDetectorServer/include/blackfin.h b/slsDetectorServers/slsDetectorServer/include/blackfin.h index 672f58c57..4b6b5ca07 100644 --- a/slsDetectorServers/slsDetectorServer/include/blackfin.h +++ b/slsDetectorServers/slsDetectorServer/include/blackfin.h @@ -3,6 +3,7 @@ #pragma once #include +#include #include /** enable support for ARDY signal on interface to FPGA @@ -25,100 +26,36 @@ /** I2C defines */ #define I2C_CLOCK_MHZ (131.25) -/** - * Write into a 16 bit register - * @param offset address offset - * @param data 16 bit data - */ +/* 16 bit register */ void bus_w16(u_int32_t offset, u_int16_t data); - -/** - * Read from a 16 bit register - * @param offset address offset - * @retuns 16 bit data read - */ u_int16_t bus_r16(u_int32_t offset); -/** - * Write into a 32 bit register - * @param offset address offset - * @param data 32 bit data - */ +/** 32 bit register */ void bus_w(u_int32_t offset, u_int32_t data); - -/** - * Read from a 32 bit register - * @param offset address offset - * @retuns 32 bit data read - */ u_int32_t bus_r(u_int32_t offset); /** - * Read from a 64 bit register - * @param aLSB LSB offset address - * @param aMSB MSB offset address - * @returns 64 bit data read + * Write `size` bytes from `src` to the FPGA as 32-bit words, + * one at a time and in order. + * @param fixedAddress true: every word goes to `offset` (e.g. a FIFO). + * false: words go to consecutive addresses from `offset`. + * @returns OK, or FAIL if `size` is 0 or not a multiple of 4 bytes. */ -int64_t get64BitReg(int aLSB, int aMSB); +int bus_w_block(u_int32_t offset, const void *src, size_t size, + bool fixedAddress); +int bus_r_block(u_int32_t offset, void *dest, size_t size, bool fixedAddress); -/** - * Write into a 64 bit register - * @param value 64 bit data - * @param aLSB LSB offset address - * @param aMSB MSB offset address - * @returns 64 bit data read - */ +/** legacy: to be replaced at some point (returns int64_t via tcp) */ +int64_t get64BitReg(int aLSB, int aMSB); int64_t set64BitReg(int64_t value, int aLSB, int aMSB); -/** - * Read unsigned 64 bit from a 64 bit register - * @param aLSB LSB offset address - * @param aMSB MSB offset address - * @returns unsigned 64 bit data read - */ uint64_t getU64BitReg(int aLSB, int aMSB); - -/** - * Write unsigned 64 bit into a 64 bit register - * @param value unsigned 64 bit data - * @param aLSB LSB offset address - * @param aMSB MSB offset address - */ void setU64BitReg(uint64_t value, int aLSB, int aMSB); -/** - * Read from a 32 bit register (literal register value provided by client) - * @param offset address offset - * @retuns 32 bit data read - */ +/** literal register address value provided by client */ u_int32_t readRegister(u_int32_t offset); - -/** - * Write into a 32 bit register (literal register value provided by client) - * @param offset address offset - * @param data 32 bit data - */ void writeRegister(u_int32_t offset, u_int32_t data); - -/** - * Read from a 16 bit register (literal register value provided by client) - * @param offset address offset - * @retuns 16 bit data read - */ u_int32_t readRegister16(u_int32_t offset); - -/** - * Write into a 16 bit register (literal register value provided by client) - * @param offset address offset - * @param data 16 bit data - */ void writeRegister16(u_int32_t offset, u_int32_t data); -/** - * Get base address for memory copy - */ -uint32_t *Blackfin_getBaseAddress(); -/** - * Map FPGA - */ int mapCSP0(void); diff --git a/slsDetectorServers/slsDetectorServer/include/nios.h b/slsDetectorServers/slsDetectorServer/include/nios.h index dc1ca24f4..d23862c1d 100644 --- a/slsDetectorServers/slsDetectorServer/include/nios.h +++ b/slsDetectorServers/slsDetectorServer/include/nios.h @@ -3,89 +3,36 @@ #pragma once #include +#include #include -/** - * Write into a 32 bit register for cspbase 1 - * @param offset address offset - * @param data 32 bit data - */ -void bus_w_csp1(u_int32_t offset, u_int32_t data); +/** csp0base */ +void bus_w(u_int32_t offset, u_int32_t data); +u_int32_t bus_r(u_int32_t offset); -/** - * Read from a 32 bit register for cspbase 1 - * @param offset address offset - * @retuns 32 bit data read - */ +void bus_w_csp1(u_int32_t offset, u_int32_t data); u_int32_t bus_r_csp1(u_int32_t offset); /** - * Write into a 32 bit register - * @param offset address offset - * @param data 32 bit data + * Write `size` bytes from `src` to the FPGA as 32-bit words, + * one at a time and in order. + * @param fixedAddress true: every word goes to `offset` (e.g. a FIFO). + * false: words go to consecutive addresses from `offset`. + * @returns OK, or FAIL if `size` is 0 or not a multiple of 4 bytes. */ -void bus_w(u_int32_t offset, u_int32_t data); +int bus_w_block(u_int32_t offset, const void *src, size_t size, + bool fixedAddress); +int bus_r_block(u_int32_t offset, void *dest, size_t size, bool fixedAddress); -/** - * Read from a 32 bit register - * @param offset address offset - * @retuns 32 bit data read - */ -u_int32_t bus_r(u_int32_t offset); - -/** - * Read from a 64 bit register - * @param aLSB LSB offset address - * @param aMSB MSB offset address - * @returns 64 bit data read - */ +/** legacy: to be replaced at some point (returns int64_t via tcp) */ int64_t get64BitReg(int aLSB, int aMSB); - -/** - * Write into a 64 bit register - * @param value 64 bit data - * @param aLSB LSB offset address - * @param aMSB MSB offset address - * @returns 64 bit data read - */ int64_t set64BitReg(int64_t value, int aLSB, int aMSB); -/** - * Read unsigned 64 bit from a 64 bit register - * @param aLSB LSB offset address - * @param aMSB MSB offset address - * @returns unsigned 64 bit data read - */ uint64_t getU64BitReg(int aLSB, int aMSB); - -/** - * Write unsigned 64 bit into a 64 bit register - * @param value unsigned 64 bit data - * @param aLSB LSB offset address - * @param aMSB MSB offset address - */ void setU64BitReg(uint64_t value, int aLSB, int aMSB); -/** - * Read from a 32 bit register (literal register value provided by client) - * @param offset address offset - * @retuns 32 bit data read - */ +/** literal register address value provided by client */ u_int32_t readRegister(u_int32_t offset); - -/** - * Write into a 32 bit register (literal register value provided by client) - * @param offset address offset - * @param data 32 bit data - */ void writeRegister(u_int32_t offset, u_int32_t data); -/** - * Map FPGA - */ int mapCSP0(void); - -/** - * Get Nios base address - */ -u_int32_t *Nios_getBaseAddress(); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 66e99a5af..5f1d99464 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -497,9 +497,16 @@ void setFirstUDPDestination(int value); #if defined(JUNGFRAUD) || defined(MOENCHD) void selectPrimaryInterface(int val); int getPrimaryInterface(); -void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, - uint64_t destmac, uint16_t destport, uint64_t sourcemac, - uint32_t sourceip, uint16_t sourceport); +#endif +#if defined(JUNGFRAUD) || defined(MOENCHD) +int setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, + uint64_t destmac, uint16_t destport, uint64_t sourcemac, + uint32_t sourceip, uint16_t sourceport); +#endif +#ifdef GOTTHARD2D +int setupHeader(int iRxEntry, int vetoInterface, uint32_t destip, + uint64_t destmac, uint16_t destport, uint64_t sourcemac, + uint32_t sourceip, uint16_t sourceport); #endif #if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARD2D) || \ defined(MYTHEN3D) || defined(CHIPTESTBOARDD) || \ diff --git a/slsDetectorServers/slsDetectorServer/src/arm64.c b/slsDetectorServers/slsDetectorServer/src/arm64.c index d18a56958..24726f5f5 100644 --- a/slsDetectorServers/slsDetectorServer/src/arm64.c +++ b/slsDetectorServers/slsDetectorServer/src/arm64.c @@ -8,16 +8,20 @@ #include "sls/sls_detector_defs.h" #include // open +#include // memcpy #include // mmap /* global variables */ #define CSP0 (0xB0080000) #define CSP1 (0xB0050000) // udp -#define MEM_SIZE_CSP0 (0x10000) +#define CSP2 (0xA0000000) +#define MEM_SIZE_CSP0 (0x20000) #define MEM_SIZE_CSP1 (0x2000) // smaller size for udp +#define MEM_SIZE_CSP2 (0x4000) // smaller size for udp u_int32_t *csp0base = 0; u_int32_t *csp1base = 0; +u_int32_t *csp2base = 0; void bus_w(u_int32_t offset, u_int32_t data) { volatile u_int32_t *ptr1; @@ -25,6 +29,12 @@ void bus_w(u_int32_t offset, u_int32_t data) { *ptr1 = data; } +u_int32_t bus_r(u_int32_t offset) { + volatile u_int32_t *ptr1; + ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t))); + return *ptr1; +} + void bus_w_csp1(u_int32_t offset, u_int32_t data) { volatile u_int32_t *ptr1; ptr1 = (u_int32_t *)(csp1base + offset / (sizeof(u_int32_t))); @@ -37,12 +47,67 @@ u_int32_t bus_r_csp1(u_int32_t offset) { return *ptr1; } -u_int32_t bus_r(u_int32_t offset) { +void bus_w_csp2(u_int32_t offset, u_int32_t data) { volatile u_int32_t *ptr1; - ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t))); + ptr1 = (u_int32_t *)(csp2base + offset / (sizeof(u_int32_t))); + *ptr1 = data; +} + +u_int32_t bus_r_csp2(u_int32_t offset) { + volatile u_int32_t *ptr1; + ptr1 = (u_int32_t *)(csp2base + offset / (sizeof(u_int32_t))); return *ptr1; } +int bus_w_block(u_int32_t offset, const void *src, size_t size, + bool fixedAddress) { + if (size == 0 || size % sizeof(uint32_t) != 0) { + LOG(logERROR, ("Could not write block: size %zu is not a non-zero " + "multiple of %zu\n", + size, sizeof(uint32_t))); + return FAIL; + } + const uint32_t step = fixedAddress ? 0 : sizeof(uint32_t); + uint32_t words[size / sizeof(uint32_t)]; + memcpy(words, src, size); + for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { + bus_w(offset + i * step, words[i]); + } + return OK; +} + +int bus_r_block(u_int32_t offset, void *dst, size_t size, bool fixedAddress) { + if (size == 0 || size % sizeof(uint32_t) != 0) { + LOG(logERROR, ("Could not read block: size %zu is not a non-zero " + "multiple of %zu\n", + size, sizeof(uint32_t))); + return FAIL; + } + const uint32_t step = fixedAddress ? 0 : sizeof(uint32_t); + uint32_t words[size / sizeof(uint32_t)]; + for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { + words[i] = bus_r(offset + i * step); + } + memcpy(dst, words, size); + return OK; +} + +int bus_w_csp1_block(const void *src, size_t size) { + uint32_t step = sizeof(uint32_t); + if (size == 0 || size % sizeof(uint32_t) != 0) { + LOG(logERROR, ("Could not write block: size %zu is not a non-zero " + "multiple of %zu\n", + size, sizeof(uint32_t))); + return FAIL; + } + uint32_t words[size / sizeof(uint32_t)]; + memcpy(words, src, size); + for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { + bus_w_csp1(i * step, words[i]); + } + return OK; +} + uint64_t getU64BitReg(int aLSB, int aMSB) { uint64_t retval = bus_r(aMSB); retval = (retval << 32) | bus_r(aLSB); @@ -63,12 +128,12 @@ u_int32_t writeRegister(u_int32_t offset, u_int32_t data) { int mapCSP0(void) { LOG(logINFO, ("Mapping memory\n")); - u_int32_t csps[2] = {CSP0, CSP1}; - u_int32_t **cspbases[2] = {&csp0base, &csp1base}; - u_int32_t memsize[2] = {MEM_SIZE_CSP0, MEM_SIZE_CSP1}; - char names[2][10] = {"csp0base", "csp1base"}; + u_int32_t csps[3] = {CSP0, CSP1, CSP2}; + u_int32_t **cspbases[3] = {&csp0base, &csp1base, &csp2base}; + u_int32_t memsize[3] = {MEM_SIZE_CSP0, MEM_SIZE_CSP1, MEM_SIZE_CSP2}; + char names[3][10] = {"csp0base", "csp1base", "csp2base"}; - for (int i = 0; i < 2; ++i) { + for (int i = 0; i < 3; ++i) { // if not mapped if (*cspbases[i] == 0) { LOG(logINFO, ("\tMapping memory for %s\n", names[i])); @@ -106,5 +171,3 @@ int mapCSP0(void) { } return OK; } - -u_int32_t *Arm_getUDPBaseAddress() { return csp1base; } diff --git a/slsDetectorServers/slsDetectorServer/src/blackfin.c b/slsDetectorServers/slsDetectorServer/src/blackfin.c index 06322de6d..ff0042269 100644 --- a/slsDetectorServers/slsDetectorServer/src/blackfin.c +++ b/slsDetectorServers/slsDetectorServer/src/blackfin.c @@ -8,6 +8,7 @@ #include "sls/sls_detector_defs.h" #include // open +#include //memcpy #include // mmap /* global variables */ @@ -44,6 +45,41 @@ u_int32_t bus_r(u_int32_t offset) { return *ptr1; } +int bus_w_block(u_int32_t offset, const void *src, size_t size, + bool fixedAddress) { + if (size == 0 || size % sizeof(uint32_t) != 0) { + LOG(logERROR, ("Could not write block: size %zu is not a non-zero " + "multiple of %zu\n", + size, sizeof(uint32_t))); + return FAIL; + } + const uint32_t step = fixedAddress ? 0 : (1 << MEM_MAP_SHIFT); + // low memory on blackfin, so avoid array on stack + const char *p = src; + for (size_t i = 0; i != size / sizeof(uint32_t); ++i) { + uint32_t word = 0; + memcpy(&word, p + i * sizeof(word), sizeof(word)); + bus_w(offset + i * step, word); + } + return OK; +} + +int bus_r_block(u_int32_t offset, void *dst, size_t size, bool fixedAddress) { + if (size == 0 || size % sizeof(uint32_t) != 0) { + LOG(logERROR, ("Could not read block: size %zu is not a non-zero " + "multiple of %zu\n", + size, sizeof(uint32_t))); + return FAIL; + } + const uint32_t step = fixedAddress ? 0 : (1 << MEM_MAP_SHIFT); + char *p = dst; + for (size_t i = 0; i != size / sizeof(uint32_t); ++i) { + uint32_t word = bus_r(offset + i * step); + memcpy(p + i * sizeof(word), &word, sizeof(word)); + } + return OK; +} + int64_t get64BitReg(int aLSB, int aMSB) { int64_t v64; u_int32_t vLSB, vMSB; @@ -129,5 +165,3 @@ int mapCSP0(void) { LOG(logINFO, ("Memory already mapped before\n")); return OK; } - -uint32_t *Blackfin_getBaseAddress() { return csp0base; } diff --git a/slsDetectorServers/slsDetectorServer/src/nios.c b/slsDetectorServers/slsDetectorServer/src/nios.c index 7074db54a..40a91c0c5 100644 --- a/slsDetectorServers/slsDetectorServer/src/nios.c +++ b/slsDetectorServers/slsDetectorServer/src/nios.c @@ -8,6 +8,7 @@ #include "sls/sls_detector_defs.h" #include // open +#include // memcpy #include // mmap /* global variables */ @@ -20,6 +21,18 @@ u_int32_t *csp0base = 0; u_int32_t *csp1base = 0; #define CSP1 0x18040000 +void bus_w(u_int32_t offset, u_int32_t data) { + volatile u_int32_t *ptr1; + ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t))); + *ptr1 = data; +} + +u_int32_t bus_r(u_int32_t offset) { + volatile u_int32_t *ptr1; + ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t))); + return *ptr1; +} + void bus_w_csp1(u_int32_t offset, u_int32_t data) { volatile u_int32_t *ptr1; ptr1 = (u_int32_t *)(csp1base + offset / (sizeof(u_int32_t))); @@ -32,16 +45,37 @@ u_int32_t bus_r_csp1(u_int32_t offset) { return *ptr1; } -void bus_w(u_int32_t offset, u_int32_t data) { - volatile u_int32_t *ptr1; - ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t))); - *ptr1 = data; +int bus_w_block(u_int32_t offset, const void *src, size_t size, + bool fixedAddress) { + if (size == 0 || size % sizeof(uint32_t) != 0) { + LOG(logERROR, ("Could not write block: size %zu is not a non-zero " + "multiple of %zu\n", + size, sizeof(uint32_t))); + return FAIL; + } + const uint32_t step = fixedAddress ? 0 : sizeof(uint32_t); + uint32_t words[size / sizeof(uint32_t)]; + memcpy(words, src, size); + for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { + bus_w(offset + i * step, words[i]); + } + return OK; } -u_int32_t bus_r(u_int32_t offset) { - volatile u_int32_t *ptr1; - ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t))); - return *ptr1; +int bus_r_block(u_int32_t offset, void *dst, size_t size, bool fixedAddress) { + if (size == 0 || size % sizeof(uint32_t) != 0) { + LOG(logERROR, ("Could not read block: size %zu is not a non-zero " + "multiple of %zu\n", + size, sizeof(uint32_t))); + return FAIL; + } + const uint32_t step = fixedAddress ? 0 : sizeof(uint32_t); + uint32_t words[size / sizeof(uint32_t)]; + for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { + words[i] = bus_r(offset + i * step); + } + memcpy(dst, words, size); + return OK; } int64_t get64BitReg(int aLSB, int aMSB) { @@ -124,6 +158,4 @@ int mapCSP0(void) { LOG(logINFO, ("Memory %s already mapped before\n", names[i])); } return OK; -} - -u_int32_t *Nios_getBaseAddress() { return csp0base; } +} \ No newline at end of file diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer b/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer new file mode 100755 index 000000000..8bdd16843 Binary files /dev/null and b/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer differ diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServerv10.1.0 b/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServerv10.1.0 deleted file mode 100755 index 8fb157dbe..000000000 Binary files a/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServerv10.1.0 and /dev/null differ diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c index 2ee32c9db..1b57c33f8 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c @@ -1479,10 +1479,9 @@ int configureMAC() { calcChecksum(udp); // force FPGA writes to be aligned and in order - uint32_t words[sizeof(udp_header) / sizeof(uint32_t)]; - memcpy(words, udp, sizeof(udp_header)); - for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { - bus_w_csp1(i * sizeof(uint32_t), words[i]); + if (bus_w_csp1_block(udp, sizeof(udp_header)) == FAIL) { + LOG(logERROR, ("Failed to write UDP header\n")); + return FAIL; } return OK; diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 9bfff9c20..6bc666f15 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -3,10 +3,10 @@ /** API versions */ #define APILIB "10.1.0 0x260806" #define APIRECEIVER "10.1.0 0x260806" -#define APICTB "10.1.0 0x261104" -#define APIGOTTHARD2 "10.1.0 0x261104" -#define APIMOENCH "10.1.0 0x261104" -#define APIEIGER "10.1.0 0x261028" -#define APIXILINXCTB "10.1.0 0x261104" -#define APIJUNGFRAU "10.1.0 0x261105" -#define APIMYTHEN3 "10.1.0 0x261104" +#define APICTB "10.1.0 0x261109" +#define APIGOTTHARD2 "10.1.0 0x261106" +#define APIMOENCH "10.1.0 0x261109" +#define APIEIGER "10.1.0 0x261105" +#define APIXILINXCTB "10.1.0 0x261106" +#define APIJUNGFRAU "10.1.0 0x261109" +#define APIMYTHEN3 "10.1.0 0x261106"