From 140abc51f92bcac40d143ae5c2b2f9382dbe820a Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Fri, 11 Sep 2020 09:45:20 -0300 Subject: [PATCH 01/40] src/apps: add DKMS package dependency to halscd package --- src/apps/halcsd/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apps/halcsd/CMakeLists.txt b/src/apps/halcsd/CMakeLists.txt index fcaa73bd..154497ea 100644 --- a/src/apps/halcsd/CMakeLists.txt +++ b/src/apps/halcsd/CMakeLists.txt @@ -474,12 +474,12 @@ if(ENABLE_CPACK) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) # we also depend on malamute >= 1.0, but this has not been packaged into the official # repositories yet - set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsodium-dev (>= 1.0.8), libzmq3-dev (>= 4.2.5), libczmq-dev (>= 4.0.2)") + set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsodium-dev (>= 1.0.8), libzmq3-dev (>= 4.2.5), libczmq-dev (>= 4.0.2), dkms") set(CPACK_RPM_PACKAGE_AUTOREQ no) set(CPACK_RPM_PACKAGE_AUTOPROV yes) # we also depend on malamute >= 1.0, but this has not been packaged into the official # repositories yet - set(CPACK_RPM_PACKAGE_REQUIRE "libsodium-devel >= 1.0.8, zeromq-devel >= 4.2.5, czmq-devel >= 4.0.2") + set(CPACK_RPM_PACKAGE_REQUIRE "libsodium-devel >= 1.0.8, zeromq-devel >= 4.2.5, czmq-devel >= 4.0.2, dkms") set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /lib /usr/etc From 9fb56526e263894c46cc1268d48e0d8c3e0d79ab Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Tue, 26 Jan 2021 14:21:27 -0300 Subject: [PATCH 02/40] src/apps: add fofb-ctrl* to automatic run script --- .../init-generic/share/halcs/scripts/run-fpga-program.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/apps/halcs_generic_udev/init-generic/share/halcs/scripts/run-fpga-program.sh b/src/apps/halcs_generic_udev/init-generic/share/halcs/scripts/run-fpga-program.sh index 773e3511..7729638a 100755 --- a/src/apps/halcs_generic_udev/init-generic/share/halcs/scripts/run-fpga-program.sh +++ b/src/apps/halcs_generic_udev/init-generic/share/halcs/scripts/run-fpga-program.sh @@ -37,6 +37,15 @@ for i in $(seq 1 "${#HALCS_IDXS[@]}"); do START_PROGRAM="/usr/bin/systemctl --no-block start halcs-ioc@${HALCS_IDXS[$prog_inst]}.target" ;; + afc_fofb_ctrl*) + # Only start HALCSs for even-numbered instances, as there is no device for odd-numbered instances + if [ $((prog_inst%2)) -eq 0 ]; then + START_PROGRAM="/usr/bin/systemctl --no-block start halcs-be@${HALCS_IDXS[$prog_inst]}.service" + else + START_PROGRAM="" + fi + ;; + afc-tim*) # Only start IOCs for even-numbered instances, as there is no device for odd-numbered instances if [ $((prog_inst%2)) -eq 0 ]; then From af68b25ef2d2accacbe072699d7ab90693142af2 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Tue, 26 Jan 2021 17:07:55 -0300 Subject: [PATCH 03/40] include/hw: add FOFB CC register definitions --- include/hw/__wb_fofb_cc_regs.h | 34 +++++++++++++ include/hw/wb_fofb_cc_regs.h | 87 ++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 include/hw/__wb_fofb_cc_regs.h create mode 100644 include/hw/wb_fofb_cc_regs.h diff --git a/include/hw/__wb_fofb_cc_regs.h b/include/hw/__wb_fofb_cc_regs.h new file mode 100644 index 00000000..986e4cec --- /dev/null +++ b/include/hw/__wb_fofb_cc_regs.h @@ -0,0 +1,34 @@ +#ifndef __CHEBY__FOFB_CC_REGS__H__ +#define __CHEBY__FOFB_CC_REGS__H__ +#define FOFB_CC_REGS_SIZE 16384 /* 0x4000 = 16KB */ + +/* FOFB CC configuration register */ +#define FOFB_CC_REGS_CFG_VAL 0x0UL +#define FOFB_CC_REGS_CFG_VAL_ACT_PART 0x1UL +#define FOFB_CC_REGS_CFG_VAL_UNUSED 0x2UL +#define FOFB_CC_REGS_CFG_VAL_ERR_CLR 0x4UL +#define FOFB_CC_REGS_CFG_VAL_CC_ENABLE 0x8UL +#define FOFB_CC_REGS_CFG_VAL_TFS_OVERRIDE 0x10UL + +/* FOFB CC RAM for register map */ +#define FOFB_CC_REGS_RAM_REG 0x2000UL +#define FOFB_CC_REGS_RAM_REG_SIZE 4 /* 0x4 */ + +/* None */ +#define FOFB_CC_REGS_RAM_REG_DATA 0x0UL + +struct fofb_cc_regs { + /* [0x0]: REG (rw) FOFB CC configuration register */ + uint32_t cfg_val; + + /* padding to: 2048 words */ + uint32_t __padding_0[2047]; + + /* [0x2000]: MEMORY FOFB CC RAM for register map */ + struct ram_reg { + /* [0x0]: REG (rw) (no description) */ + uint32_t data; + } ram_reg[2048]; +}; + +#endif /* __CHEBY__FOFB_CC_REGS__H__ */ diff --git a/include/hw/wb_fofb_cc_regs.h b/include/hw/wb_fofb_cc_regs.h new file mode 100644 index 00000000..ca0a03ea --- /dev/null +++ b/include/hw/wb_fofb_cc_regs.h @@ -0,0 +1,87 @@ +#ifndef __WB_FOFB_CC_REGS_H__ +#define __WB_FOFB_CC_REGS_H__ + +#include "__wb_fofb_cc_regs.h" + +#ifdef __KERNEL__ +#include +#else +#include +#endif + +#if defined( __GNUC__) +#define PACKED __attribute__ ((packed)) +#else +#error "Unsupported compiler?" +#endif + +#ifndef __WBGEN2_MACROS_DEFINED__ +#define __WBGEN2_MACROS_DEFINED__ +#define WBGEN2_GEN_MASK(offset, size) (((1<<(size))-1) << (offset)) +#define WBGEN2_GEN_WRITE(value, offset, size) (((value) & ((1<<(size))-1)) << (offset)) +#define WBGEN2_GEN_READ(reg, offset, size) (((reg) >> (offset)) & ((1<<(size))-1)) +#define WBGEN2_SIGN_EXTEND(value, bits) (((value) & (1< Date: Wed, 27 Jan 2021 09:10:58 -0300 Subject: [PATCH 04/40] include/hw: fix register name from "REGS" to "REG" as per convention --- include/hw/wb_fofb_cc_regs.h | 98 ++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/include/hw/wb_fofb_cc_regs.h b/include/hw/wb_fofb_cc_regs.h index ca0a03ea..56d02180 100644 --- a/include/hw/wb_fofb_cc_regs.h +++ b/include/hw/wb_fofb_cc_regs.h @@ -29,59 +29,59 @@ #define FOFB_CC_REGS_CTL_OFFS (0x0 << 10) -#define FOFB_CC_REGS_RAM_BPM_ID ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x00) -#define FOFB_CC_REGS_RAM_TIME_FRAME_LEN ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x04) -#define FOFB_CC_REGS_RAM_MGT_POWERDOWN ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x08) -#define FOFB_CC_REGS_RAM_MGT_LOOPBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x0C) -#define FOFB_CC_REGS_RAM_TIME_FRAME_DLY ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x10) -#define FOFB_CC_REGS_RAM_GOLDEN_ORB_X ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x14) -#define FOFB_CC_REGS_RAM_GOLDEN_ORB_Y ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x18) -#define FOFB_CC_REGS_RAM_CUST_FEATURE ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x1C) -#define FOFB_CC_REGS_RAM_RXPOLARITY ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x20) -#define FOFB_CC_REGS_RAM_PAYLOADSEL ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x24) -#define FOFB_CC_REGS_RAM_FOFBDATASEL ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x28) +#define FOFB_CC_REG_RAM_BPM_ID ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x00) +#define FOFB_CC_REG_RAM_TIME_FRAME_LEN ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x04) +#define FOFB_CC_REG_RAM_MGT_POWERDOWN ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x08) +#define FOFB_CC_REG_RAM_MGT_LOOPBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x0C) +#define FOFB_CC_REG_RAM_TIME_FRAME_DLY ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x10) +#define FOFB_CC_REG_RAM_GOLDEN_ORB_X ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x14) +#define FOFB_CC_REG_RAM_GOLDEN_ORB_Y ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x18) +#define FOFB_CC_REG_RAM_CUST_FEATURE ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x1C) +#define FOFB_CC_REG_RAM_RXPOLARITY ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x20) +#define FOFB_CC_REG_RAM_PAYLOADSEL ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x24) +#define FOFB_CC_REG_RAM_FOFBDATASEL ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x28) /* RAM-based registers. Read from Bus, Write from Device */ #define FOFB_CC_REGS_STA_OFFS (0x3 << 10) -#define FOFB_CC_REGS_CMD_FIRMWARE_VER ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x3FC) -#define FOFB_CC_REGS_CMD_SYS_STATUS ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x00) -#define FOFB_CC_REGS_CMD_LINK_PARTNER_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x04) -#define FOFB_CC_REGS_CMD_LINK_PARTNER_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x08) -#define FOFB_CC_REGS_CMD_LINK_PARTNER_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x0C) -#define FOFB_CC_REGS_CMD_LINK_PARTNER_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x10) -#define FOFB_CC_REGS_CMD_LINK_UP ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x14) -#define FOFB_CC_REGS_CMD_TIME_FRAME_COUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x18) -#define FOFB_CC_REGS_CMD_HARD_ERR_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x1C) -#define FOFB_CC_REGS_CMD_HARD_ERR_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x20) -#define FOFB_CC_REGS_CMD_HARD_ERR_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x24) -#define FOFB_CC_REGS_CMD_HARD_ERR_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x28) -#define FOFB_CC_REGS_CMD_SOFT_ERR_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x2C) -#define FOFB_CC_REGS_CMD_SOFT_ERR_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x30) -#define FOFB_CC_REGS_CMD_SOFT_ERR_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x34) -#define FOFB_CC_REGS_CMD_SOFT_ERR_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x38) -#define FOFB_CC_REGS_CMD_FRAME_ERR_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x3C) -#define FOFB_CC_REGS_CMD_FRAME_ERR_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x40) -#define FOFB_CC_REGS_CMD_FRAME_ERR_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x44) -#define FOFB_CC_REGS_CMD_FRAME_ERR_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x48) -#define FOFB_CC_REGS_CMD_RX_PCK_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x4C) -#define FOFB_CC_REGS_CMD_RX_PCK_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x50) -#define FOFB_CC_REGS_CMD_RX_PCK_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x54) -#define FOFB_CC_REGS_CMD_RX_PCK_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x58) -#define FOFB_CC_REGS_CMD_TX_PCK_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x5C) -#define FOFB_CC_REGS_CMD_TX_PCK_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x60) -#define FOFB_CC_REGS_CMD_TX_PCK_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x64) -#define FOFB_CC_REGS_CMD_TX_PCK_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x68) -#define FOFB_CC_REGS_CMD_FOD_PROCESS_TIME ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x6C) -#define FOFB_CC_REGS_CMD_BPM_COUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x70) -#define FOFB_CC_REGS_CMD_BPM_ID_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x74) -#define FOFB_CC_REGS_CMD_TF_LENGTH_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x78) -#define FOFB_CC_REGS_CMD_POWERDOWN_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x7C) -#define FOFB_CC_REGS_CMD_LOOPBACK_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x80) -#define FOFB_CC_REGS_CMD_FAIVAL_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x84) -#define FOFB_CC_REGS_CMD_FEATURE_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x88) -#define FOFB_CC_REGS_CMD_RX_MAXCOUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x8C) -#define FOFB_CC_REGS_CMD_TX_MAXCOUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x90) +#define FOFB_CC_REG_CMD_FIRMWARE_VER ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x3FC) +#define FOFB_CC_REG_CMD_SYS_STATUS ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x00) +#define FOFB_CC_REG_CMD_LINK_PARTNER_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x04) +#define FOFB_CC_REG_CMD_LINK_PARTNER_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x08) +#define FOFB_CC_REG_CMD_LINK_PARTNER_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x0C) +#define FOFB_CC_REG_CMD_LINK_PARTNER_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x10) +#define FOFB_CC_REG_CMD_LINK_UP ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x14) +#define FOFB_CC_REG_CMD_TIME_FRAME_COUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x18) +#define FOFB_CC_REG_CMD_HARD_ERR_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x1C) +#define FOFB_CC_REG_CMD_HARD_ERR_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x20) +#define FOFB_CC_REG_CMD_HARD_ERR_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x24) +#define FOFB_CC_REG_CMD_HARD_ERR_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x28) +#define FOFB_CC_REG_CMD_SOFT_ERR_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x2C) +#define FOFB_CC_REG_CMD_SOFT_ERR_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x30) +#define FOFB_CC_REG_CMD_SOFT_ERR_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x34) +#define FOFB_CC_REG_CMD_SOFT_ERR_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x38) +#define FOFB_CC_REG_CMD_FRAME_ERR_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x3C) +#define FOFB_CC_REG_CMD_FRAME_ERR_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x40) +#define FOFB_CC_REG_CMD_FRAME_ERR_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x44) +#define FOFB_CC_REG_CMD_FRAME_ERR_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x48) +#define FOFB_CC_REG_CMD_RX_PCK_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x4C) +#define FOFB_CC_REG_CMD_RX_PCK_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x50) +#define FOFB_CC_REG_CMD_RX_PCK_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x54) +#define FOFB_CC_REG_CMD_RX_PCK_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x58) +#define FOFB_CC_REG_CMD_TX_PCK_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x5C) +#define FOFB_CC_REG_CMD_TX_PCK_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x60) +#define FOFB_CC_REG_CMD_TX_PCK_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x64) +#define FOFB_CC_REG_CMD_TX_PCK_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x68) +#define FOFB_CC_REG_CMD_FOD_PROCESS_TIME ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x6C) +#define FOFB_CC_REG_CMD_BPM_COUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x70) +#define FOFB_CC_REG_CMD_BPM_ID_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x74) +#define FOFB_CC_REG_CMD_TF_LENGTH_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x78) +#define FOFB_CC_REG_CMD_POWERDOWN_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x7C) +#define FOFB_CC_REG_CMD_LOOPBACK_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x80) +#define FOFB_CC_REG_CMD_FAIVAL_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x84) +#define FOFB_CC_REG_CMD_FEATURE_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x88) +#define FOFB_CC_REG_CMD_RX_MAXCOUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x8C) +#define FOFB_CC_REG_CMD_TX_MAXCOUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x90) #endif /* __WB_FOFB_CC_REGS_H__ */ From 26f146e5a13aa7403b61665f9097ea35d64a5dab Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Wed, 27 Jan 2021 09:14:32 -0300 Subject: [PATCH 05/40] include/hw: fix removing bloated "RAM"/"REG" from definitions --- include/hw/wb_fofb_cc_regs.h | 98 ++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/include/hw/wb_fofb_cc_regs.h b/include/hw/wb_fofb_cc_regs.h index 56d02180..32ae4741 100644 --- a/include/hw/wb_fofb_cc_regs.h +++ b/include/hw/wb_fofb_cc_regs.h @@ -29,59 +29,59 @@ #define FOFB_CC_REGS_CTL_OFFS (0x0 << 10) -#define FOFB_CC_REG_RAM_BPM_ID ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x00) -#define FOFB_CC_REG_RAM_TIME_FRAME_LEN ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x04) -#define FOFB_CC_REG_RAM_MGT_POWERDOWN ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x08) -#define FOFB_CC_REG_RAM_MGT_LOOPBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x0C) -#define FOFB_CC_REG_RAM_TIME_FRAME_DLY ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x10) -#define FOFB_CC_REG_RAM_GOLDEN_ORB_X ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x14) -#define FOFB_CC_REG_RAM_GOLDEN_ORB_Y ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x18) -#define FOFB_CC_REG_RAM_CUST_FEATURE ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x1C) -#define FOFB_CC_REG_RAM_RXPOLARITY ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x20) -#define FOFB_CC_REG_RAM_PAYLOADSEL ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x24) -#define FOFB_CC_REG_RAM_FOFBDATASEL ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x28) +#define FOFB_CC_REG_BPM_ID ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x00) +#define FOFB_CC_REG_TIME_FRAME_LEN ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x04) +#define FOFB_CC_REG_MGT_POWERDOWN ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x08) +#define FOFB_CC_REG_MGT_LOOPBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x0C) +#define FOFB_CC_REG_TIME_FRAME_DLY ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x10) +#define FOFB_CC_REG_GOLDEN_ORB_X ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x14) +#define FOFB_CC_REG_GOLDEN_ORB_Y ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x18) +#define FOFB_CC_REG_CUST_FEATURE ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x1C) +#define FOFB_CC_REG_RXPOLARITY ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x20) +#define FOFB_CC_REG_PAYLOADSEL ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x24) +#define FOFB_CC_REG_FOFBDATASEL ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_CTL_OFFS) + 0x28) /* RAM-based registers. Read from Bus, Write from Device */ #define FOFB_CC_REGS_STA_OFFS (0x3 << 10) -#define FOFB_CC_REG_CMD_FIRMWARE_VER ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x3FC) -#define FOFB_CC_REG_CMD_SYS_STATUS ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x00) -#define FOFB_CC_REG_CMD_LINK_PARTNER_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x04) -#define FOFB_CC_REG_CMD_LINK_PARTNER_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x08) -#define FOFB_CC_REG_CMD_LINK_PARTNER_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x0C) -#define FOFB_CC_REG_CMD_LINK_PARTNER_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x10) -#define FOFB_CC_REG_CMD_LINK_UP ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x14) -#define FOFB_CC_REG_CMD_TIME_FRAME_COUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x18) -#define FOFB_CC_REG_CMD_HARD_ERR_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x1C) -#define FOFB_CC_REG_CMD_HARD_ERR_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x20) -#define FOFB_CC_REG_CMD_HARD_ERR_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x24) -#define FOFB_CC_REG_CMD_HARD_ERR_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x28) -#define FOFB_CC_REG_CMD_SOFT_ERR_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x2C) -#define FOFB_CC_REG_CMD_SOFT_ERR_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x30) -#define FOFB_CC_REG_CMD_SOFT_ERR_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x34) -#define FOFB_CC_REG_CMD_SOFT_ERR_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x38) -#define FOFB_CC_REG_CMD_FRAME_ERR_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x3C) -#define FOFB_CC_REG_CMD_FRAME_ERR_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x40) -#define FOFB_CC_REG_CMD_FRAME_ERR_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x44) -#define FOFB_CC_REG_CMD_FRAME_ERR_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x48) -#define FOFB_CC_REG_CMD_RX_PCK_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x4C) -#define FOFB_CC_REG_CMD_RX_PCK_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x50) -#define FOFB_CC_REG_CMD_RX_PCK_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x54) -#define FOFB_CC_REG_CMD_RX_PCK_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x58) -#define FOFB_CC_REG_CMD_TX_PCK_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x5C) -#define FOFB_CC_REG_CMD_TX_PCK_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x60) -#define FOFB_CC_REG_CMD_TX_PCK_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x64) -#define FOFB_CC_REG_CMD_TX_PCK_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x68) -#define FOFB_CC_REG_CMD_FOD_PROCESS_TIME ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x6C) -#define FOFB_CC_REG_CMD_BPM_COUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x70) -#define FOFB_CC_REG_CMD_BPM_ID_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x74) -#define FOFB_CC_REG_CMD_TF_LENGTH_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x78) -#define FOFB_CC_REG_CMD_POWERDOWN_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x7C) -#define FOFB_CC_REG_CMD_LOOPBACK_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x80) -#define FOFB_CC_REG_CMD_FAIVAL_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x84) -#define FOFB_CC_REG_CMD_FEATURE_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x88) -#define FOFB_CC_REG_CMD_RX_MAXCOUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x8C) -#define FOFB_CC_REG_CMD_TX_MAXCOUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x90) +#define FOFB_CC_REG_FIRMWARE_VER ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x3FC) +#define FOFB_CC_REG_SYS_STATUS ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x00) +#define FOFB_CC_REG_LINK_PARTNER_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x04) +#define FOFB_CC_REG_LINK_PARTNER_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x08) +#define FOFB_CC_REG_LINK_PARTNER_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x0C) +#define FOFB_CC_REG_LINK_PARTNER_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x10) +#define FOFB_CC_REG_LINK_UP ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x14) +#define FOFB_CC_REG_TIME_FRAME_COUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x18) +#define FOFB_CC_REG_HARD_ERR_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x1C) +#define FOFB_CC_REG_HARD_ERR_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x20) +#define FOFB_CC_REG_HARD_ERR_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x24) +#define FOFB_CC_REG_HARD_ERR_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x28) +#define FOFB_CC_REG_SOFT_ERR_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x2C) +#define FOFB_CC_REG_SOFT_ERR_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x30) +#define FOFB_CC_REG_SOFT_ERR_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x34) +#define FOFB_CC_REG_SOFT_ERR_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x38) +#define FOFB_CC_REG_FRAME_ERR_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x3C) +#define FOFB_CC_REG_FRAME_ERR_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x40) +#define FOFB_CC_REG_FRAME_ERR_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x44) +#define FOFB_CC_REG_FRAME_ERR_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x48) +#define FOFB_CC_REG_RX_PCK_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x4C) +#define FOFB_CC_REG_RX_PCK_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x50) +#define FOFB_CC_REG_RX_PCK_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x54) +#define FOFB_CC_REG_RX_PCK_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x58) +#define FOFB_CC_REG_TX_PCK_CNT_1 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x5C) +#define FOFB_CC_REG_TX_PCK_CNT_2 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x60) +#define FOFB_CC_REG_TX_PCK_CNT_3 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x64) +#define FOFB_CC_REG_TX_PCK_CNT_4 ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x68) +#define FOFB_CC_REG_FOD_PROCESS_TIME ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x6C) +#define FOFB_CC_REG_BPM_COUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x70) +#define FOFB_CC_REG_BPM_ID_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x74) +#define FOFB_CC_REG_TF_LENGTH_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x78) +#define FOFB_CC_REG_POWERDOWN_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x7C) +#define FOFB_CC_REG_LOOPBACK_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x80) +#define FOFB_CC_REG_FAIVAL_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x84) +#define FOFB_CC_REG_FEATURE_RDBACK ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x88) +#define FOFB_CC_REG_RX_MAXCOUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x8C) +#define FOFB_CC_REG_TX_MAXCOUNT ((FOFB_CC_REGS_RAM_START | FOFB_CC_REGS_STA_OFFS) + 0x90) #endif /* __WB_FOFB_CC_REGS_H__ */ From 9349c55323abadd09cbce73b2ac7babef6119f9a Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Wed, 27 Jan 2021 14:38:51 -0300 Subject: [PATCH 06/40] msg: remove bogus opcode bounds checking Any 32-bit opcode is fine. We don't need to limit ourselves by that "200" limit. --- include/msg.h | 2 -- src/msg/msg.c | 3 --- 2 files changed, 5 deletions(-) diff --git a/include/msg.h b/include/msg.h index 716219c4..f6126d45 100644 --- a/include/msg.h +++ b/include/msg.h @@ -13,8 +13,6 @@ extern "C" { #endif #define MSG_OPCODE_SIZE (sizeof (uint32_t)) -/* Arbitrary number*/ -#define MSG_OPCODE_MAX 200 /* We add more message types here */ typedef enum { diff --git a/src/msg/msg.c b/src/msg/msg.c index 5ab05da7..7d0a52ac 100644 --- a/src/msg/msg.c +++ b/src/msg/msg.c @@ -289,13 +289,10 @@ static msg_err_e _msg_gen_get_opcode (zmsg_t *zmq_msg, uint32_t *opcode) MSG_ERR_WRONG_ARGS); *opcode = *(uint32_t *) zframe_data (opcode_frm); - ASSERT_TEST(*opcode < MSG_OPCODE_MAX, "Invalid opcode received", - err_invalid_opcode, MSG_ERR_WRONG_ARGS); zframe_destroy (&opcode_frm); return err; -err_invalid_opcode: err_wrong_opcode_size: zframe_destroy (&opcode_frm); err_null_opcode: From 83ef9168a96e616b768465ba55f37a357b5d1b8f Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Wed, 27 Jan 2021 15:01:36 -0300 Subject: [PATCH 07/40] hw/wb_fofb_cc_regs.h: add fai_cfg_val register definitions --- include/hw/wb_fofb_cc_regs.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/hw/wb_fofb_cc_regs.h b/include/hw/wb_fofb_cc_regs.h index 32ae4741..5a777fc5 100644 --- a/include/hw/wb_fofb_cc_regs.h +++ b/include/hw/wb_fofb_cc_regs.h @@ -23,6 +23,17 @@ #define WBGEN2_SIGN_EXTEND(value, bits) (((value) & (1< Date: Wed, 27 Jan 2021 15:02:37 -0300 Subject: [PATCH 08/40] sm_io/modules: add fofb_ctrl SMIO module --- src/sm_io/modules/fofb_ctrl/CMakeLists.txt | 131 ++++ src/sm_io/modules/fofb_ctrl/fofb_ctrl.mk | 5 + .../modules/fofb_ctrl/sm_io_fofb_ctrl_codes.h | 127 ++++ .../modules/fofb_ctrl/sm_io_fofb_ctrl_core.c | 64 ++ .../modules/fofb_ctrl/sm_io_fofb_ctrl_core.h | 22 + .../fofb_ctrl/sm_io_fofb_ctrl_defaults.c | 84 +++ .../fofb_ctrl/sm_io_fofb_ctrl_defaults.h | 20 + .../modules/fofb_ctrl/sm_io_fofb_ctrl_exp.c | 696 ++++++++++++++++++ .../modules/fofb_ctrl/sm_io_fofb_ctrl_exp.h | 18 + src/sm_io/modules/modules.mk | 6 +- 10 files changed, 1171 insertions(+), 2 deletions(-) create mode 100644 src/sm_io/modules/fofb_ctrl/CMakeLists.txt create mode 100644 src/sm_io/modules/fofb_ctrl/fofb_ctrl.mk create mode 100644 src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_codes.h create mode 100644 src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_core.c create mode 100644 src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_core.h create mode 100644 src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_defaults.c create mode 100644 src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_defaults.h create mode 100644 src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_exp.c create mode 100644 src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_exp.h diff --git a/src/sm_io/modules/fofb_ctrl/CMakeLists.txt b/src/sm_io/modules/fofb_ctrl/CMakeLists.txt new file mode 100644 index 00000000..9e6f3325 --- /dev/null +++ b/src/sm_io/modules/fofb_ctrl/CMakeLists.txt @@ -0,0 +1,131 @@ +######################################################################## +# Library setup +######################################################################## + +# library basename +set (sm_io_module_fofb_ctrl_OUTPUT_BASENAME "sm_io_module_fofb_ctrl" + CACHE STRING + "Output sm_io_module_fofb_ctrl library base name" +) + +######################################################################### +# XXX dependency +######################################################################### + +# list(APPEND sm_io_module_fofb_ctrl_LIBRARIES XXX) + +######################################################################## +# Library compile options +######################################################################## + +######################################################################## +# Sources/Headers definitions +######################################################################## + +####################################### +# Our sources +####################################### + +# Source files + +set(sm_io_module_fofb_ctrl_sources + ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_fofb_ctrl_core.c + ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_fofb_ctrl_exp.c + ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_fofb_ctrl_defaults.c +) + +# for IDE project generation +source_group("Source Files" FILES + ${sm_io_module_fofb_ctrl_sources} +) + +# Header files +list(APPEND sm_io_module_fofb_ctrl_other_search_dirs "") + +####################################### +# SMIO header definitions +####################################### + +set(sm_io_module_fofb_ctrl_public_headers + ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_fofb_ctrl_core.h + ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_fofb_ctrl_exp.h + ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_fofb_ctrl_defaults.h + ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_fofb_ctrl_codes.h +) + +# Get directory names only +list(APPEND sm_io_module_fofb_ctrl_search_dirs "") + +foreach(search_dir_header ${sm_io_module_fofb_ctrl_public_headers}) + get_filename_component(search_dir + ${search_dir_header} + DIRECTORY + ) + + list(APPEND sm_io_module_fofb_ctrl_search_dirs ${search_dir}) +endforeach() + +# remove, well, duplicates ... +list(REMOVE_DUPLICATES sm_io_module_fofb_ctrl_search_dirs) + +# append to global search list +list(APPEND sm_io_module_fofb_ctrl_other_search_dirs ${sm_io_module_fofb_ctrl_search_dirs}) + +####################################### +# HEADER Grouping +####################################### + +# for IDE project generation +source_group("Header Files" FILES + ${sm_io_module_fofb_ctrl_public_headers} +) + +######################################################################## +# Library declaration +######################################################################## + +# build static library +add_library(sm_io_module_fofb_ctrl STATIC + ${sm_io_module_fofb_ctrl_sources} + ${sm_io_module_fofb_ctrl_public_headers} +) + +set_target_properties(sm_io_module_fofb_ctrl PROPERTIES + PUBLIC_HEADER "${sm_io_module_fofb_ctrl_public_headers}" + OUTPUT_NAME "${sm_io_module_fofb_ctrl_OUTPUT_BASENAME}" + PREFIX "lib") + +# sm_io_module_fofb_ctrl_other_search_dirs is in quotes as this is a list +# and the first element would be concatenated with the previous +# generator expression. +target_include_directories(sm_io_module_fofb_ctrl + PRIVATE + "$" + $ + $ +) + +# set debug posfix in case of debug builds +set_target_properties(sm_io_module_fofb_ctrl PROPERTIES + DEBUG_POSTFIX + ${CMAKE_DEBUG_POSTFIX} + POSITION_INDEPENDENT_CODE + ON +) + +# set compiler flags +target_link_libraries(sm_io_module_fofb_ctrl + PRIVATE + sm_io_compiler_flags +) + +######################################################################## +# Library dependencies +######################################################################## + +# set depedency to targets +target_link_libraries(sm_io_module_fofb_ctrl + PRIVATE + ${sm_io_module_fofb_ctrl_LIBRARIES} + ${halcs_LIBRARIES} +) diff --git a/src/sm_io/modules/fofb_ctrl/fofb_ctrl.mk b/src/sm_io/modules/fofb_ctrl/fofb_ctrl.mk new file mode 100644 index 00000000..34b5e723 --- /dev/null +++ b/src/sm_io/modules/fofb_ctrl/fofb_ctrl.mk @@ -0,0 +1,5 @@ +sm_io_fofb_ctrl_DIR = $(sm_io_modules_DIR)/fofb_ctrl + +sm_io_fofb_ctrl_OBJS = $(sm_io_fofb_ctrl_DIR)/sm_io_fofb_ctrl_core.o \ + $(sm_io_fofb_ctrl_DIR)/sm_io_fofb_ctrl_exp.o \ + $(sm_io_fofb_ctrl_DIR)/sm_io_fofb_ctrl_defaults.o diff --git a/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_codes.h b/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_codes.h new file mode 100644 index 00000000..13cb5660 --- /dev/null +++ b/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_codes.h @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#ifndef _SM_IO_FOFB_CTRL_CODES_H_ +#define _SM_IO_FOFB_CTRL_CODES_H_ + +/* Messaging OPCODES */ +#define FOFB_CTRL_OPCODE_TYPE uint32_t +#define FOFB_CTRL_OPCODE_SIZE (sizeof (FOFB_CTRL_OPCODE_TYPE)) + +/* Regular registers */ +#define FOFB_CTRL_OPCODE_SET_GET_ACT_PART 0 +#define FOFB_CTRL_NAME_SET_GET_ACT_PART "fofb_ctrl_set_get_act_part" +#define FOFB_CTRL_OPCODE_SET_GET_ERR_CLR 1 +#define FOFB_CTRL_NAME_SET_GET_ERR_CLR "fofb_ctrl_set_get_err_clr" +#define FOFB_CTRL_OPCODE_SET_GET_CC_ENABLE 2 +#define FOFB_CTRL_NAME_SET_GET_CC_ENABLE "fofb_ctrl_set_get_cc_enable" +#define FOFB_CTRL_OPCODE_SET_GET_TFS_OVERRIDE 3 +#define FOFB_CTRL_NAME_SET_GET_TFS_OVERRIDE "fofb_ctrl_set_get_tfs_override" + +/* RAM-based register */ +#define FOFB_CTRL_OPCODE_SET_GET_BPM_ID 200 +#define FOFB_CTRL_NAME_SET_GET_BPM_ID "fofb_ctrl_set_get_bpm_id" +#define FOFB_CTRL_OPCODE_SET_GET_TIME_FRAME_LEN 201 +#define FOFB_CTRL_NAME_SET_GET_TIME_FRAME_LEN "fofb_ctrl_set_get_time_frame_len" +#define FOFB_CTRL_OPCODE_SET_GET_MGT_POWERDOWN 202 +#define FOFB_CTRL_NAME_SET_GET_MGT_POWERDOWN "fofb_ctrl_set_get_mgt_powerdown" +#define FOFB_CTRL_OPCODE_SET_GET_MGT_LOOPBACK 203 +#define FOFB_CTRL_NAME_SET_GET_MGT_LOOPBACK "fofb_ctrl_set_get_mgt_loopback" +#define FOFB_CTRL_OPCODE_SET_GET_TIME_FRAME_DLY 204 +#define FOFB_CTRL_NAME_SET_GET_TIME_FRAME_DLY "fofb_ctrl_set_get_time_frame_dly" +#define FOFB_CTRL_OPCODE_SET_GET_GOLDEN_ORB_X 205 +#define FOFB_CTRL_NAME_SET_GET_GOLDEN_ORB_X "fofb_ctrl_set_get_golden_orb_x" +#define FOFB_CTRL_OPCODE_SET_GET_GOLDEN_ORB_Y 206 +#define FOFB_CTRL_NAME_SET_GET_GOLDEN_ORB_Y "fofb_ctrl_set_get_golden_orb_y" +#define FOFB_CTRL_OPCODE_SET_GET_CUST_FEATURE 207 +#define FOFB_CTRL_NAME_SET_GET_CUST_FEATURE "fofb_ctrl_set_get_cust_feature" +#define FOFB_CTRL_OPCODE_SET_GET_RX_POLARITY 208 +#define FOFB_CTRL_NAME_SET_GET_RX_POLARITY "fofb_ctrl_set_get_rx_polarity" +#define FOFB_CTRL_OPCODE_SET_GET_PAYLOADSEL 209 +#define FOFB_CTRL_NAME_SET_GET_PAYLOADSEL "fofb_ctrl_set_get_payloadsel" +#define FOFB_CTRL_OPCODE_SET_GET_FOFBDATASEL 210 +#define FOFB_CTRL_NAME_SET_GET_FOFBDATASEL "fofb_ctrl_set_get_fofbdatasel" +#define FOFB_CTRL_OPCODE_SET_GET_FIRMWARE_VER 211 +#define FOFB_CTRL_NAME_SET_GET_FIRMWARE_VER "fofb_ctrl_set_get_firmware_ver" +#define FOFB_CTRL_OPCODE_SET_GET_SYS_STATUS 212 +#define FOFB_CTRL_NAME_SET_GET_SYS_STATUS "fofb_ctrl_set_get_sys_status" +#define FOFB_CTRL_OPCODE_SET_GET_LINK_PARTNER_1 213 +#define FOFB_CTRL_NAME_SET_GET_LINK_PARTNER_1 "fofb_ctrl_set_get_link_partner_1" +#define FOFB_CTRL_OPCODE_SET_GET_LINK_PARTNER_2 214 +#define FOFB_CTRL_NAME_SET_GET_LINK_PARTNER_2 "fofb_ctrl_set_get_link_partner_2" +#define FOFB_CTRL_OPCODE_SET_GET_LINK_PARTNER_3 215 +#define FOFB_CTRL_NAME_SET_GET_LINK_PARTNER_3 "fofb_ctrl_set_get_link_partner_3" +#define FOFB_CTRL_OPCODE_SET_GET_LINK_PARTNER_4 216 +#define FOFB_CTRL_NAME_SET_GET_LINK_PARTNER_4 "fofb_ctrl_set_get_link_partner_4" +#define FOFB_CTRL_OPCODE_SET_GET_LINK_UP 217 +#define FOFB_CTRL_NAME_SET_GET_LINK_UP "fofb_ctrl_set_get_link_up" +#define FOFB_CTRL_OPCODE_SET_GET_TIME_FRAME_COUNT 218 +#define FOFB_CTRL_NAME_SET_GET_TIME_FRAME_COUNT "fofb_ctrl_set_get_time_frame_count" +#define FOFB_CTRL_OPCODE_SET_GET_HARD_ERR_CNT_1 219 +#define FOFB_CTRL_NAME_SET_GET_HARD_ERR_CNT_1 "fofb_ctrl_set_get_hard_err_cnt_1" +#define FOFB_CTRL_OPCODE_SET_GET_HARD_ERR_CNT_2 220 +#define FOFB_CTRL_NAME_SET_GET_HARD_ERR_CNT_2 "fofb_ctrl_set_get_hard_err_cnt_2" +#define FOFB_CTRL_OPCODE_SET_GET_HARD_ERR_CNT_3 221 +#define FOFB_CTRL_NAME_SET_GET_HARD_ERR_CNT_3 "fofb_ctrl_set_get_hard_err_cnt_3" +#define FOFB_CTRL_OPCODE_SET_GET_HARD_ERR_CNT_4 222 +#define FOFB_CTRL_NAME_SET_GET_HARD_ERR_CNT_4 "fofb_ctrl_set_get_hard_err_cnt_4" +#define FOFB_CTRL_OPCODE_SET_GET_SOFT_ERR_CNT_1 223 +#define FOFB_CTRL_NAME_SET_GET_SOFT_ERR_CNT_1 "fofb_ctrl_set_get_soft_err_cnt_1" +#define FOFB_CTRL_OPCODE_SET_GET_SOFT_ERR_CNT_2 224 +#define FOFB_CTRL_NAME_SET_GET_SOFT_ERR_CNT_2 "fofb_ctrl_set_get_soft_err_cnt_2" +#define FOFB_CTRL_OPCODE_SET_GET_SOFT_ERR_CNT_3 225 +#define FOFB_CTRL_NAME_SET_GET_SOFT_ERR_CNT_3 "fofb_ctrl_set_get_soft_err_cnt_3" +#define FOFB_CTRL_OPCODE_SET_GET_SOFT_ERR_CNT_4 226 +#define FOFB_CTRL_NAME_SET_GET_SOFT_ERR_CNT_4 "fofb_ctrl_set_get_soft_err_cnt_4" +#define FOFB_CTRL_OPCODE_SET_GET_FRAME_ERR_CNT_1 227 +#define FOFB_CTRL_NAME_SET_GET_FRAME_ERR_CNT_1 "fofb_ctrl_set_get_frame_err_cnt_1" +#define FOFB_CTRL_OPCODE_SET_GET_FRAME_ERR_CNT_2 228 +#define FOFB_CTRL_NAME_SET_GET_FRAME_ERR_CNT_2 "fofb_ctrl_set_get_frame_err_cnt_2" +#define FOFB_CTRL_OPCODE_SET_GET_FRAME_ERR_CNT_3 229 +#define FOFB_CTRL_NAME_SET_GET_FRAME_ERR_CNT_3 "fofb_ctrl_set_get_frame_err_cnt_3" +#define FOFB_CTRL_OPCODE_SET_GET_FRAME_ERR_CNT_4 230 +#define FOFB_CTRL_NAME_SET_GET_FRAME_ERR_CNT_4 "fofb_ctrl_set_get_frame_err_cnt_4" +#define FOFB_CTRL_OPCODE_SET_GET_RX_PCK_CNT_1 235 +#define FOFB_CTRL_NAME_SET_GET_RX_PCK_CNT_1 "fofb_ctrl_set_get_rx_pck_cnt_1" +#define FOFB_CTRL_OPCODE_SET_GET_RX_PCK_CNT_2 236 +#define FOFB_CTRL_NAME_SET_GET_RX_PCK_CNT_2 "fofb_ctrl_set_get_rx_pck_cnt_2" +#define FOFB_CTRL_OPCODE_SET_GET_RX_PCK_CNT_3 237 +#define FOFB_CTRL_NAME_SET_GET_RX_PCK_CNT_3 "fofb_ctrl_set_get_rx_pck_cnt_3" +#define FOFB_CTRL_OPCODE_SET_GET_RX_PCK_CNT_4 238 +#define FOFB_CTRL_NAME_SET_GET_RX_PCK_CNT_4 "fofb_ctrl_set_get_rx_pck_cnt_4" +#define FOFB_CTRL_OPCODE_SET_GET_TX_PCK_CNT_1 239 +#define FOFB_CTRL_NAME_SET_GET_TX_PCK_CNT_1 "fofb_ctrl_set_get_tx_pck_cnt_1" +#define FOFB_CTRL_OPCODE_SET_GET_TX_PCK_CNT_2 240 +#define FOFB_CTRL_NAME_SET_GET_TX_PCK_CNT_2 "fofb_ctrl_set_get_tx_pck_cnt_2" +#define FOFB_CTRL_OPCODE_SET_GET_TX_PCK_CNT_3 241 +#define FOFB_CTRL_NAME_SET_GET_TX_PCK_CNT_3 "fofb_ctrl_set_get_tx_pck_cnt_3" +#define FOFB_CTRL_OPCODE_SET_GET_TX_PCK_CNT_4 242 +#define FOFB_CTRL_NAME_SET_GET_TX_PCK_CNT_4 "fofb_ctrl_set_get_tx_pck_cnt_4" +#define FOFB_CTRL_OPCODE_SET_GET_FOD_PROCESS_TIME 243 +#define FOFB_CTRL_NAME_SET_GET_FOD_PROCESS_TIME "fofb_ctrl_set_get_fod_process_time" +#define FOFB_CTRL_OPCODE_SET_GET_BPM_COUNT 244 +#define FOFB_CTRL_NAME_SET_GET_BPM_COUNT "fofb_ctrl_set_get_bpm_count" +#define FOFB_CTRL_OPCODE_SET_GET_BPM_ID_RDBACK 245 +#define FOFB_CTRL_NAME_SET_GET_BPM_ID_RDBACK "fofb_ctrl_set_get_bpm_id_rdback" +#define FOFB_CTRL_OPCODE_SET_GET_TF_LENGTH_RDBACK 246 +#define FOFB_CTRL_NAME_SET_GET_TF_LENGTH_RDBACK "fofb_ctrl_set_get_tf_length_rdback" +#define FOFB_CTRL_OPCODE_SET_GET_POWERDOWN_RDBACK 247 +#define FOFB_CTRL_NAME_SET_GET_POWERDOWN_RDBACK "fofb_ctrl_set_get_powerdown_rdback" +#define FOFB_CTRL_OPCODE_SET_GET_LOOPBACK_RDBACK 248 +#define FOFB_CTRL_NAME_SET_GET_LOOPBACK_RDBACK "fofb_ctrl_set_get_loopback_rdback" +#define FOFB_CTRL_OPCODE_SET_GET_FAIVAL_RDBACK 249 +#define FOFB_CTRL_NAME_SET_GET_FAIVAL_RDBACK "fofb_ctrl_set_get_faival_rdback" +#define FOFB_CTRL_OPCODE_END 250 + +/* Messaging Reply OPCODES */ +#define FOFB_CTRL_REPLY_TYPE uint32_t +#define FOFB_CTRL_REPLY_SIZE (sizeof (FOFB_CTRL_REPLY_TYPE)) + +#define FOFB_CTRL_OK 0 /* Operation was successful */ +#define FOFB_CTRL_ERR 1 /* Generic error */ + +#endif diff --git a/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_core.c b/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_core.c new file mode 100644 index 00000000..cf9106d5 --- /dev/null +++ b/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_core.c @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#include "halcs_server.h" +/* Private headers */ +#include "sm_io_fofb_ctrl_defaults.h" +#include "sm_io_fofb_ctrl_core.h" + +/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */ +#ifdef ASSERT_TEST +#undef ASSERT_TEST +#endif +#define ASSERT_TEST(test_boolean, err_str, err_goto_label, /* err_core */ ...) \ + ASSERT_HAL_TEST(test_boolean, SM_IO, "[sm_io_fofb_ctrl_core]", \ + err_str, err_goto_label, /* err_core */ __VA_ARGS__) + +#ifdef ASSERT_ALLOC +#undef ASSERT_ALLOC +#endif +#define ASSERT_ALLOC(ptr, err_goto_label, /* err_core */ ...) \ + ASSERT_HAL_ALLOC(ptr, SM_IO, "[sm_io_fofb_ctrl_core]", \ + smio_err_str(SMIO_ERR_ALLOC), \ + err_goto_label, /* err_core */ __VA_ARGS__) + +#ifdef CHECK_ERR +#undef CHECK_ERR +#endif +#define CHECK_ERR(err, err_type) \ + CHECK_HAL_ERR(err, SM_IO, "[sm_io_fofb_ctrl_core]", \ + smio_err_str (err_type)) + +/* Creates a new instance of Device Information */ +smio_fofb_ctrl_t * smio_fofb_ctrl_new (smio_t *parent) +{ + UNUSED(parent); + + smio_fofb_ctrl_t *self = (smio_fofb_ctrl_t *) zmalloc (sizeof *self); + ASSERT_ALLOC(self, err_self_alloc); + + return self; + +err_self_alloc: + return NULL; +} + +/* Destroy an instance of the Device Information */ +smio_err_e smio_fofb_ctrl_destroy (smio_fofb_ctrl_t **self_p) +{ + assert (self_p); + + if (*self_p) { + smio_fofb_ctrl_t *self = *self_p; + + free (self); + *self_p = NULL; + } + + return SMIO_SUCCESS; +} + diff --git a/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_core.h b/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_core.h new file mode 100644 index 00000000..de85d65b --- /dev/null +++ b/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_core.h @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2031 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. +*/ + +#ifndef _SM_IO_FOFB_CTRL_CORE_H_ +#define _SM_IO_FOFB_CTRL_CORE_H_ + +typedef struct { + const uint32_t example; +} smio_fofb_ctrl_t; + +/***************** Our methods *****************/ + +/* Creates a new instance of the smio realization */ +smio_fofb_ctrl_t * smio_fofb_ctrl_new (smio_t *parent); +/* Destroys the smio realization */ +smio_err_e smio_fofb_ctrl_destroy (smio_fofb_ctrl_t **self_p); + +#endif diff --git a/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_defaults.c b/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_defaults.c new file mode 100644 index 00000000..7df16bb6 --- /dev/null +++ b/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_defaults.c @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#include "halcs_server.h" +/* Private headers */ +#include "sm_io_fofb_ctrl_defaults.h" + +/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */ +#ifdef ASSERT_TEST +#undef ASSERT_TEST +#endif +#define ASSERT_TEST(test_boolean, err_str, err_goto_label, /* err_core */ ...) \ + ASSERT_HAL_TEST(test_boolean, SM_IO, "[sm_io:fofb_ctrl_defaults]", \ + err_str, err_goto_label, /* err_core */ __VA_ARGS__) + +#ifdef ASSERT_ALLOC +#undef ASSERT_ALLOC +#endif +#define ASSERT_ALLOC(ptr, err_goto_label, /* err_core */ ...) \ + ASSERT_HAL_ALLOC(ptr, SM_IO, "[sm_io:fofb_ctrl_defaults]", \ + smio_err_str(SMIO_ERR_ALLOC), \ + err_goto_label, /* err_core */ __VA_ARGS__) + +#ifdef CHECK_ERR +#undef CHECK_ERR +#endif +#define CHECK_ERR(err, err_type) \ + CHECK_HAL_ERR(err, SM_IO, "[sm_io:fofb_ctrl_defaults]", \ + smio_err_str (err_type)) + +#define SMIO_FOFB_CTRL_LIBHALCSCLIENT_LOG_MODE "a" + +/* We use the actual libclient to send and configure our default values, + * maintaining internal consistency. So, in fact, we are sending ourselves + * a message containing the default values. Because of this approach, we + * only get to default our values when the functions are already exported + * to the broker, which happens on a late stage. This could cause a fast + * client to get an inconsistent state from our server */ +/* TODO: Avoid exporting the functions before we have initialized + * our server with the default values */ +smio_err_e fofb_ctrl_config_defaults (char *broker_endp, char *service, + const char *log_file_name) +{ + UNUSED(log_file_name); + DBE_DEBUG (DBG_SM_IO | DBG_LVL_INFO, "[sm_io:fofb_ctrl_defaults] Configuring SMIO " + "FOFB_CTRL with default values ...\n"); + halcs_client_err_e client_err = HALCS_CLIENT_SUCCESS; + smio_err_e err = SMIO_SUCCESS; + + halcs_client_t *config_client = halcs_client_new_log_mode (broker_endp, 0, + log_file_name, SMIO_FOFB_CTRL_LIBHALCSCLIENT_LOG_MODE); + ASSERT_ALLOC(config_client, err_alloc_client); + + client_err = halcs_set_fofb_ctrl_time_frame_len (config_client, service, FOFB_CTRL_DFLT_TIME_FRAME_LEN); + ASSERT_TEST(client_err == HALCS_CLIENT_SUCCESS, "Could not set TIME FRAME LEN", + err_param_set, SMIO_ERR_CONFIG_DFLT); + + client_err = halcs_set_fofb_ctrl_time_frame_dly (config_client, service, FOFB_CTRL_DFLT_TIME_FRAME_DLY); + ASSERT_TEST(client_err == HALCS_CLIENT_SUCCESS, "Could not set TIME FRAME DLY", + err_param_set, SMIO_ERR_CONFIG_DFLT); + + client_err = halcs_set_fofb_ctrl_bpm_id (config_client, service, FOFB_CTRL_DFLT_BPM_ID); + ASSERT_TEST(client_err == HALCS_CLIENT_SUCCESS, "Could not set BPM ID", + err_param_set, SMIO_ERR_CONFIG_DFLT); + + client_err = halcs_set_fofb_ctrl_cc_enable (config_client, service, FOFB_CTRL_DFLT_CC_ENABLE); + ASSERT_TEST(client_err == HALCS_CLIENT_SUCCESS, "Could not set CC ENABLE", + err_param_set, SMIO_ERR_CONFIG_DFLT); + + client_err = halcs_set_fofb_ctrl_act_part (config_client, service, 0x1); + ASSERT_TEST(client_err == HALCS_CLIENT_SUCCESS, "Could not set ACT PART value", + err_param_set, SMIO_ERR_CONFIG_DFLT); + +err_param_set: + halcs_client_destroy (&config_client); +err_alloc_client: + DBE_DEBUG (DBG_SM_IO | DBG_LVL_INFO, "[sm_io:fofb_ctrl_defaults] Exiting Config thread %s\n", + service); + return err; +} diff --git a/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_defaults.h b/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_defaults.h new file mode 100644 index 00000000..95762205 --- /dev/null +++ b/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_defaults.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#ifndef _FOFB_CTRL_DEFAULTS_H_ +#define _FOFB_CTRL_DEFAULTS_H_ + +#define FOFB_CTRL_DFLT_CC_ENABLE 0x1 /* Enabled */ +#define FOFB_CTRL_DFLT_TIME_FRAME_LEN 0x1D4C /* */ +#define FOFB_CTRL_DFLT_TIME_FRAME_DLY 0 /* */ +#define FOFB_CTRL_DFLT_BPM_ID 0xFFFFFFFF /* MAX ID. Must be changed before operation */ + +smio_err_e fofb_ctrl_config_defaults (char *broker_endp, char *service, + const char *log_file_name); + +#endif + diff --git a/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_exp.c b/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_exp.c new file mode 100644 index 00000000..d4b28685 --- /dev/null +++ b/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_exp.c @@ -0,0 +1,696 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#include "halcs_server.h" +/* Private headers */ +#include "sm_io_fofb_ctrl_codes.h" +#include "sm_io_fofb_ctrl_defaults.h" +#include "sm_io_fofb_ctrl_exports.h" +#include "sm_io_fofb_ctrl_core.h" +#include "sm_io_fofb_ctrl_exp.h" +#include "hw/wb_fofb_cc_regs.h" + +/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */ +#ifdef ASSERT_TEST +#undef ASSERT_TEST +#endif +#define ASSERT_TEST(test_boolean, err_str, err_goto_label, /* err_core */ ...) \ + ASSERT_HAL_TEST(test_boolean, SM_IO, "[sm_io:fofb_ctrl_exp]", \ + err_str, err_goto_label, /* err_core */ __VA_ARGS__) + +#ifdef ASSERT_ALLOC +#undef ASSERT_ALLOC +#endif +#define ASSERT_ALLOC(ptr, err_goto_label, /* err_core */ ...) \ + ASSERT_HAL_ALLOC(ptr, SM_IO, "[sm_io:fofb_ctrl_exp]", \ + smio_err_str(SMIO_ERR_ALLOC), \ + err_goto_label, /* err_core */ __VA_ARGS__) + +#ifdef CHECK_ERR +#undef CHECK_ERR +#endif +#define CHECK_ERR(err, err_type) \ + CHECK_HAL_ERR(err, SM_IO, "[sm_io:fofb_ctrl_exp]", \ + smio_err_str (err_type)) + +/******************************************************************/ +/***************** Specific FOFB_CTRL Operations *****************/ +/******************************************************************/ + +/* Regular registers */ + +#define FOFB_CC_ACT_PART_MIN 0 +#define FOFB_CC_ACT_PART_MAX 1 +RW_PARAM_FUNC(fofb_ctrl, act_part) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, CFG_VAL, ACT_PART, SINGLE_BIT_PARAM, + FOFB_CC_ACT_PART_MIN, FOFB_CC_ACT_PART_MAX, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_ERR_CLR_MIN 0 +#define FOFB_CC_ERR_CLR_MAX 1 +RW_PARAM_FUNC(fofb_ctrl, err_clr) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, CFG_VAL, ERR_CLR, SINGLE_BIT_PARAM, + FOFB_CC_ERR_CLR_MIN, FOFB_CC_ERR_CLR_MAX, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_CC_ENABLE_MIN 0 +#define FOFB_CC_CC_ENABLE_MAX 1 +RW_PARAM_FUNC(fofb_ctrl, cc_enable) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, CFG_VAL, CC_ENABLE, SINGLE_BIT_PARAM, + FOFB_CC_CC_ENABLE_MIN, FOFB_CC_CC_ENABLE_MAX, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_TFS_OVERRIDE_MIN 0 +#define FOFB_CC_TFS_OVERRIDE_MAX 1 +RW_PARAM_FUNC(fofb_ctrl, tfs_override) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, CFG_VAL, TFS_OVERRIDE, SINGLE_BIT_PARAM, + FOFB_CC_TFS_OVERRIDE_MIN, FOFB_CC_TFS_OVERRIDE_MAX, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +/* Read/Write registers. Read/Write from bus, read from device */ + +#define FOFB_CC_BPM_ID_R(val) (val) +#define FOFB_CC_BPM_ID_W(val) (val) +#define FOFB_CC_BPM_ID_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, bpm_id) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, BPM_ID, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_TIME_FRAME_LEN_R(val) (val) +#define FOFB_CC_TIME_FRAME_LEN_W(val) (val) +#define FOFB_CC_TIME_FRAME_LEN_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, time_frame_len) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, TIME_FRAME_LEN, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_MGT_POWERDOWN_R(val) (val) +#define FOFB_CC_MGT_POWERDOWN_W(val) (val) +#define FOFB_CC_MGT_POWERDOWN_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, mgt_powerdown) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, MGT_POWERDOWN, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_MGT_LOOPBACK_R(val) (val) +#define FOFB_CC_MGT_LOOPBACK_W(val) (val) +#define FOFB_CC_MGT_LOOPBACK_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, mgt_loopback) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, MGT_LOOPBACK, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_TIME_FRAME_DLY_R(val) (val) +#define FOFB_CC_TIME_FRAME_DLY_W(val) (val) +#define FOFB_CC_TIME_FRAME_DLY_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, time_frame_dly) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, TIME_FRAME_DLY, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_GOLDEN_ORB_X_R(val) (val) +#define FOFB_CC_GOLDEN_ORB_X_W(val) (val) +#define FOFB_CC_GOLDEN_ORB_X_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, golden_orb_x) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, GOLDEN_ORB_X, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_GOLDEN_ORB_Y_R(val) (val) +#define FOFB_CC_GOLDEN_ORB_Y_W(val) (val) +#define FOFB_CC_GOLDEN_ORB_Y_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, golden_orb_y) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, GOLDEN_ORB_Y, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_CUST_FEATURE_R(val) (val) +#define FOFB_CC_CUST_FEATURE_W(val) (val) +#define FOFB_CC_CUST_FEATURE_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, cust_feature) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, CUST_FEATURE, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_RXPOLARITY_R(val) (val) +#define FOFB_CC_RXPOLARITY_W(val) (val) +#define FOFB_CC_RXPOLARITY_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, rx_polarity) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, RXPOLARITY, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_PAYLOADSEL_R(val) (val) +#define FOFB_CC_PAYLOADSEL_W(val) (val) +#define FOFB_CC_PAYLOADSEL_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, payloadsel) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, PAYLOADSEL, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_FOFBDATASEL_R(val) (val) +#define FOFB_CC_FOFBDATASEL_W(val) (val) +#define FOFB_CC_FOFBDATASEL_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, fofbdatasel) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, FOFBDATASEL, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +/* Read-Only registers. Read from bus, write from device */ + +#define FOFB_CC_FIRMWARE_VER_R(val) (val) +#define FOFB_CC_FIRMWARE_VER_W(val) (val) +#define FOFB_CC_FIRMWARE_VER_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, firmware_ver) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, FIRMWARE_VER, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_SYS_STATUS_R(val) (val) +#define FOFB_CC_SYS_STATUS_W(val) (val) +#define FOFB_CC_SYS_STATUS_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, sys_status) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, SYS_STATUS, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_LINK_PARTNER_1_R(val) (val) +#define FOFB_CC_LINK_PARTNER_1_W(val) (val) +#define FOFB_CC_LINK_PARTNER_1_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, link_partner_1) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, LINK_PARTNER_1, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_LINK_PARTNER_2_R(val) (val) +#define FOFB_CC_LINK_PARTNER_2_W(val) (val) +#define FOFB_CC_LINK_PARTNER_2_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, link_partner_2) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, LINK_PARTNER_2, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_LINK_PARTNER_3_R(val) (val) +#define FOFB_CC_LINK_PARTNER_3_W(val) (val) +#define FOFB_CC_LINK_PARTNER_3_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, link_partner_3) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, LINK_PARTNER_3, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_LINK_PARTNER_4_R(val) (val) +#define FOFB_CC_LINK_PARTNER_4_W(val) (val) +#define FOFB_CC_LINK_PARTNER_4_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, link_partner_4) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, LINK_PARTNER_4, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_LINK_UP_R(val) (val) +#define FOFB_CC_LINK_UP_W(val) (val) +#define FOFB_CC_LINK_UP_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, link_up) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, LINK_UP, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_TIME_FRAME_COUNT_R(val) (val) +#define FOFB_CC_TIME_FRAME_COUNT_W(val) (val) +#define FOFB_CC_TIME_FRAME_COUNT_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, time_frame_count) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, TIME_FRAME_COUNT, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_HARD_ERR_CNT_1_R(val) (val) +#define FOFB_CC_HARD_ERR_CNT_1_W(val) (val) +#define FOFB_CC_HARD_ERR_CNT_1_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, hard_err_cnt_1) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, HARD_ERR_CNT_1, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_HARD_ERR_CNT_2_R(val) (val) +#define FOFB_CC_HARD_ERR_CNT_2_W(val) (val) +#define FOFB_CC_HARD_ERR_CNT_2_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, hard_err_cnt_2) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, HARD_ERR_CNT_2, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_HARD_ERR_CNT_3_R(val) (val) +#define FOFB_CC_HARD_ERR_CNT_3_W(val) (val) +#define FOFB_CC_HARD_ERR_CNT_3_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, hard_err_cnt_3) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, HARD_ERR_CNT_3, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_HARD_ERR_CNT_4_R(val) (val) +#define FOFB_CC_HARD_ERR_CNT_4_W(val) (val) +#define FOFB_CC_HARD_ERR_CNT_4_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, hard_err_cnt_4) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, HARD_ERR_CNT_4, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_SOFT_ERR_CNT_1_R(val) (val) +#define FOFB_CC_SOFT_ERR_CNT_1_W(val) (val) +#define FOFB_CC_SOFT_ERR_CNT_1_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, soft_err_cnt_1) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, SOFT_ERR_CNT_1, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_SOFT_ERR_CNT_2_R(val) (val) +#define FOFB_CC_SOFT_ERR_CNT_2_W(val) (val) +#define FOFB_CC_SOFT_ERR_CNT_2_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, soft_err_cnt_2) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, SOFT_ERR_CNT_2, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_SOFT_ERR_CNT_3_R(val) (val) +#define FOFB_CC_SOFT_ERR_CNT_3_W(val) (val) +#define FOFB_CC_SOFT_ERR_CNT_3_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, soft_err_cnt_3) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, SOFT_ERR_CNT_3, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_SOFT_ERR_CNT_4_R(val) (val) +#define FOFB_CC_SOFT_ERR_CNT_4_W(val) (val) +#define FOFB_CC_SOFT_ERR_CNT_4_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, soft_err_cnt_4) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, SOFT_ERR_CNT_4, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_FRAME_ERR_CNT_1_R(val) (val) +#define FOFB_CC_FRAME_ERR_CNT_1_W(val) (val) +#define FOFB_CC_FRAME_ERR_CNT_1_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, frame_err_cnt_1) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, FRAME_ERR_CNT_1, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_FRAME_ERR_CNT_2_R(val) (val) +#define FOFB_CC_FRAME_ERR_CNT_2_W(val) (val) +#define FOFB_CC_FRAME_ERR_CNT_2_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, frame_err_cnt_2) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, FRAME_ERR_CNT_2, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_FRAME_ERR_CNT_3_R(val) (val) +#define FOFB_CC_FRAME_ERR_CNT_3_W(val) (val) +#define FOFB_CC_FRAME_ERR_CNT_3_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, frame_err_cnt_3) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, FRAME_ERR_CNT_3, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_FRAME_ERR_CNT_4_R(val) (val) +#define FOFB_CC_FRAME_ERR_CNT_4_W(val) (val) +#define FOFB_CC_FRAME_ERR_CNT_4_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, frame_err_cnt_4) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, FRAME_ERR_CNT_4, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_RX_PCK_CNT_1_R(val) (val) +#define FOFB_CC_RX_PCK_CNT_1_W(val) (val) +#define FOFB_CC_RX_PCK_CNT_1_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, rx_pck_cnt_1) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, RX_PCK_CNT_1, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_RX_PCK_CNT_2_R(val) (val) +#define FOFB_CC_RX_PCK_CNT_2_W(val) (val) +#define FOFB_CC_RX_PCK_CNT_2_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, rx_pck_cnt_2) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, RX_PCK_CNT_2, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_RX_PCK_CNT_3_R(val) (val) +#define FOFB_CC_RX_PCK_CNT_3_W(val) (val) +#define FOFB_CC_RX_PCK_CNT_3_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, rx_pck_cnt_3) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, RX_PCK_CNT_3, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_RX_PCK_CNT_4_R(val) (val) +#define FOFB_CC_RX_PCK_CNT_4_W(val) (val) +#define FOFB_CC_RX_PCK_CNT_4_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, rx_pck_cnt_4) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, RX_PCK_CNT_4, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_TX_PCK_CNT_1_R(val) (val) +#define FOFB_CC_TX_PCK_CNT_1_W(val) (val) +#define FOFB_CC_TX_PCK_CNT_1_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, tx_pck_cnt_1) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, TX_PCK_CNT_1, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_TX_PCK_CNT_2_R(val) (val) +#define FOFB_CC_TX_PCK_CNT_2_W(val) (val) +#define FOFB_CC_TX_PCK_CNT_2_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, tx_pck_cnt_2) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, TX_PCK_CNT_2, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_TX_PCK_CNT_3_R(val) (val) +#define FOFB_CC_TX_PCK_CNT_3_W(val) (val) +#define FOFB_CC_TX_PCK_CNT_3_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, tx_pck_cnt_3) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, TX_PCK_CNT_3, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_TX_PCK_CNT_4_R(val) (val) +#define FOFB_CC_TX_PCK_CNT_4_W(val) (val) +#define FOFB_CC_TX_PCK_CNT_4_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, tx_pck_cnt_4) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, TX_PCK_CNT_4, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_FOD_PROCESS_TIME_R(val) (val) +#define FOFB_CC_FOD_PROCESS_TIME_W(val) (val) +#define FOFB_CC_FOD_PROCESS_TIME_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, fod_process_time) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, FOD_PROCESS_TIME, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_BPM_COUNT_R(val) (val) +#define FOFB_CC_BPM_COUNT_W(val) (val) +#define FOFB_CC_BPM_COUNT_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, bpm_count) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, BPM_COUNT, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_BPM_ID_RDBACK_R(val) (val) +#define FOFB_CC_BPM_ID_RDBACK_W(val) (val) +#define FOFB_CC_BPM_ID_RDBACK_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, bpm_id_rdback) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, BPM_ID_RDBACK, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_TF_LENGTH_RDBACK_R(val) (val) +#define FOFB_CC_TF_LENGTH_RDBACK_W(val) (val) +#define FOFB_CC_TF_LENGTH_RDBACK_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, tf_length_rdback) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, TF_LENGTH_RDBACK, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_POWERDOWN_RDBACK_R(val) (val) +#define FOFB_CC_POWERDOWN_RDBACK_W(val) (val) +#define FOFB_CC_POWERDOWN_RDBACK_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, powerdown_rdback) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, POWERDOWN_RDBACK, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_LOOPBACK_RDBACK_R(val) (val) +#define FOFB_CC_LOOPBACK_RDBACK_W(val) (val) +#define FOFB_CC_LOOPBACK_RDBACK_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, loopback_rdback) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, LOOPBACK_RDBACK, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define FOFB_CC_FAIVAL_RDBACK_R(val) (val) +#define FOFB_CC_FAIVAL_RDBACK_W(val) (val) +#define FOFB_CC_FAIVAL_RDBACK_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(fofb_ctrl, faival_rdback) { + SET_GET_PARAM(fofb_ctrl, 0x0, FOFB_CC, FAIVAL_RDBACK, /* No field */, + MULT_BIT_PARAM, /* No minimum check*/, /* No maximum check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +/* Exported function pointers */ +const disp_table_func_fp fofb_ctrl_exp_fp [] = { + RW_PARAM_FUNC_NAME(fofb_ctrl, act_part), + RW_PARAM_FUNC_NAME(fofb_ctrl, err_clr), + RW_PARAM_FUNC_NAME(fofb_ctrl, cc_enable), + RW_PARAM_FUNC_NAME(fofb_ctrl, tfs_override), + RW_PARAM_FUNC_NAME(fofb_ctrl, bpm_id), + RW_PARAM_FUNC_NAME(fofb_ctrl, time_frame_len), + RW_PARAM_FUNC_NAME(fofb_ctrl, mgt_powerdown), + RW_PARAM_FUNC_NAME(fofb_ctrl, mgt_loopback), + RW_PARAM_FUNC_NAME(fofb_ctrl, time_frame_dly), + RW_PARAM_FUNC_NAME(fofb_ctrl, golden_orb_x), + RW_PARAM_FUNC_NAME(fofb_ctrl, golden_orb_y), + RW_PARAM_FUNC_NAME(fofb_ctrl, cust_feature), + RW_PARAM_FUNC_NAME(fofb_ctrl, rx_polarity), + RW_PARAM_FUNC_NAME(fofb_ctrl, payloadsel), + RW_PARAM_FUNC_NAME(fofb_ctrl, fofbdatasel), + RW_PARAM_FUNC_NAME(fofb_ctrl, firmware_ver), + RW_PARAM_FUNC_NAME(fofb_ctrl, sys_status), + RW_PARAM_FUNC_NAME(fofb_ctrl, link_partner_1), + RW_PARAM_FUNC_NAME(fofb_ctrl, link_partner_2), + RW_PARAM_FUNC_NAME(fofb_ctrl, link_partner_3), + RW_PARAM_FUNC_NAME(fofb_ctrl, link_partner_4), + RW_PARAM_FUNC_NAME(fofb_ctrl, link_up), + RW_PARAM_FUNC_NAME(fofb_ctrl, time_frame_count), + RW_PARAM_FUNC_NAME(fofb_ctrl, hard_err_cnt_1), + RW_PARAM_FUNC_NAME(fofb_ctrl, hard_err_cnt_2), + RW_PARAM_FUNC_NAME(fofb_ctrl, hard_err_cnt_3), + RW_PARAM_FUNC_NAME(fofb_ctrl, hard_err_cnt_4), + RW_PARAM_FUNC_NAME(fofb_ctrl, soft_err_cnt_1), + RW_PARAM_FUNC_NAME(fofb_ctrl, soft_err_cnt_2), + RW_PARAM_FUNC_NAME(fofb_ctrl, soft_err_cnt_3), + RW_PARAM_FUNC_NAME(fofb_ctrl, soft_err_cnt_4), + RW_PARAM_FUNC_NAME(fofb_ctrl, frame_err_cnt_1), + RW_PARAM_FUNC_NAME(fofb_ctrl, frame_err_cnt_2), + RW_PARAM_FUNC_NAME(fofb_ctrl, frame_err_cnt_3), + RW_PARAM_FUNC_NAME(fofb_ctrl, frame_err_cnt_4), + RW_PARAM_FUNC_NAME(fofb_ctrl, rx_pck_cnt_1), + RW_PARAM_FUNC_NAME(fofb_ctrl, rx_pck_cnt_2), + RW_PARAM_FUNC_NAME(fofb_ctrl, rx_pck_cnt_3), + RW_PARAM_FUNC_NAME(fofb_ctrl, rx_pck_cnt_4), + RW_PARAM_FUNC_NAME(fofb_ctrl, tx_pck_cnt_1), + RW_PARAM_FUNC_NAME(fofb_ctrl, tx_pck_cnt_2), + RW_PARAM_FUNC_NAME(fofb_ctrl, tx_pck_cnt_3), + RW_PARAM_FUNC_NAME(fofb_ctrl, tx_pck_cnt_4), + RW_PARAM_FUNC_NAME(fofb_ctrl, fod_process_time), + RW_PARAM_FUNC_NAME(fofb_ctrl, bpm_count), + RW_PARAM_FUNC_NAME(fofb_ctrl, bpm_id_rdback), + RW_PARAM_FUNC_NAME(fofb_ctrl, tf_length_rdback), + RW_PARAM_FUNC_NAME(fofb_ctrl, powerdown_rdback), + RW_PARAM_FUNC_NAME(fofb_ctrl, loopback_rdback), + RW_PARAM_FUNC_NAME(fofb_ctrl, faival_rdback), + NULL +}; + +/************************************************************/ +/***************** Export methods functions *****************/ +/************************************************************/ + +static smio_err_e _fofb_ctrl_do_op (void *owner, void *msg); + +/* Attach an instance of sm_io to dev_io function pointer */ +smio_err_e fofb_ctrl_attach (smio_t *self, void *args) +{ + UNUSED(self); + UNUSED(args); + return SMIO_ERR_FUNC_NOT_IMPL; +} + +/* Deattach an instance of sm_io to dev_io function pointer */ +smio_err_e fofb_ctrl_deattach (smio_t *self) +{ + UNUSED(self); + return SMIO_ERR_FUNC_NOT_IMPL; +} + +/* Export (register) sm_io to handle operations function pointer */ +smio_err_e fofb_ctrl_export_ops (smio_t *self, + const disp_op_t **smio_exp_ops) +{ + UNUSED(self); + UNUSED(smio_exp_ops); + return SMIO_ERR_FUNC_NOT_IMPL; +} + +/* Unexport (unregister) sm_io to handle operations function pointer */ +smio_err_e fofb_ctrl_unexport_ops (smio_t *self) +{ + UNUSED(self); + return SMIO_ERR_FUNC_NOT_IMPL; +} + +/* Generic wrapper for receiving opcodes and arguments to specific funtions function pointer */ +/* FIXME: Code repetition! _devio_do_smio_op () function does almost the same!!! */ +smio_err_e _fofb_ctrl_do_op (void *owner, void *msg) +{ + UNUSED(owner); + UNUSED(msg); + return SMIO_ERR_FUNC_NOT_IMPL; +} + +smio_err_e fofb_ctrl_do_op (void *self, void *msg) +{ + return _fofb_ctrl_do_op (self, msg); +} + +const smio_ops_t fofb_ctrl_ops = { + .attach = &fofb_ctrl_attach, /* Attach sm_io instance to dev_io */ + .deattach = &fofb_ctrl_deattach, /* Deattach sm_io instance to dev_io */ + .export_ops = &fofb_ctrl_export_ops, /* Export sm_io operations to dev_io */ + .unexport_ops = &fofb_ctrl_unexport_ops, /* Unexport sm_io operations to dev_io */ + .do_op = &fofb_ctrl_do_op /* Generic wrapper for handling specific operations */ +}; + +/************************************************************/ +/****************** Bootstrap Operations ********************/ +/************************************************************/ + +smio_err_e fofb_ctrl_init (smio_t * self) +{ + DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fofb_ctrl_exp] Initializing fofb_ctrl\n"); + + smio_err_e err = SMIO_SUCCESS; + + err = smio_set_id (self, FOFB_CTRL_SDB_DEVID); + ASSERT_TEST(err == SMIO_SUCCESS, "Could not set SMIO id", err_set_id); + err = smio_set_name (self, FOFB_CTRL_SDB_NAME); + ASSERT_TEST(err == SMIO_SUCCESS, "Could not set SMIO name", err_set_name); + + /* Set SMIO ops pointers */ + err = smio_set_ops (self, &fofb_ctrl_ops); + ASSERT_TEST(err == SMIO_SUCCESS, "Could not set SMIO operations", + err_smio_set_ops); + err = smio_set_thsafe_client_ops (self, &smio_thsafe_client_zmq_ops); + ASSERT_TEST(err == SMIO_SUCCESS, "Could not set SMIO thsafe operations", + err_smio_set_thsafe_ops); + + /* disp_op_t structure is const and all of the functions performing on it + * obviously receives a const argument, but here (and only on the SMIO + * initialization) we need to make an exception if we want to keep the + * functions' description and the function pointers separate */ + err = smio_init_exp_ops (self, (disp_op_t **) fofb_ctrl_exp_ops, fofb_ctrl_exp_fp); + ASSERT_TEST(err == SMIO_SUCCESS, "Could not fill SMIO " + "function descriptors with the callbacks", err_fill_desc); + + err = smio_set_exp_ops (self, fofb_ctrl_exp_ops); + ASSERT_TEST(err == SMIO_SUCCESS, "Could not set SMIO exported operations", + err_smio_set_exp_ops); + + /* Initialize specific structure */ + smio_fofb_ctrl_t *smio_handler = smio_fofb_ctrl_new (self); + ASSERT_ALLOC(smio_handler, err_smio_handler_alloc, SMIO_ERR_ALLOC); + err = smio_set_handler (self, smio_handler); + ASSERT_TEST(err == SMIO_SUCCESS, "Could not set SMIO handler", + err_smio_set_handler); + + return err; + +err_smio_set_handler: + smio_fofb_ctrl_destroy (&smio_handler); +err_smio_handler_alloc: + smio_set_exp_ops (self, NULL); +err_smio_set_exp_ops: +err_fill_desc: + smio_set_thsafe_client_ops (self, NULL); +err_smio_set_thsafe_ops: + smio_set_ops (self, NULL); +err_smio_set_ops: +err_set_name: +err_set_id: + return err; +} + +/* Destroy sm_io instance of fofb_ctrl */ +smio_err_e fofb_ctrl_shutdown (smio_t *self) +{ + DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fofb_ctrl_exp] Shutting down fofb_ctrl\n"); + + smio_err_e err = SMIO_SUCCESS; + smio_fofb_ctrl_t *fofb_ctrl = smio_get_handler (self); + ASSERT_TEST(fofb_ctrl != NULL, "Could not get FOFB_CTRL handler", + err_fofb_ctrl_handler, SMIO_ERR_ALLOC /* FIXME: improve return code */); + + /* Destroy SMIO instance */ + smio_fofb_ctrl_destroy (&fofb_ctrl); + /* Nullify operation pointers */ + smio_set_exp_ops (self, NULL); + smio_set_thsafe_client_ops (self, NULL); + smio_set_ops (self, NULL); + +err_fofb_ctrl_handler: + return err; +} + +const smio_bootstrap_ops_t fofb_ctrl_bootstrap_ops = { + .init = &fofb_ctrl_init, + .shutdown = &fofb_ctrl_shutdown, + .config_defaults = &fofb_ctrl_config_defaults +}; + +SMIO_MOD_DECLARE(FOFB_CTRL_SDB_DEVID, FOFB_CTRL_SDB_NAME, fofb_ctrl_bootstrap_ops) diff --git a/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_exp.h b/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_exp.h new file mode 100644 index 00000000..47e04b67 --- /dev/null +++ b/src/sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_exp.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#ifndef _FOFB_CTRL_H_ +#define _FOFB_CTRL_H_ + +/* Known modules IDs (from SDB records defined in FPGA) */ +#define FOFB_CTRL_SDB_DEVID 0x4a1df147 +#define FOFB_CTRL_SDB_NAME "FOFB_CTRL" + +extern const smio_bootstrap_ops_t fofb_ctrl_bootstrap_ops; + +#endif + diff --git a/src/sm_io/modules/modules.mk b/src/sm_io/modules/modules.mk index 4c632f93..70c55afa 100644 --- a/src/sm_io/modules/modules.mk +++ b/src/sm_io/modules/modules.mk @@ -18,7 +18,8 @@ include $(sm_io_modules_DIR)/fmc130m_4ch/fmc130m_4ch.mk \ $(sm_io_modules_DIR)/afc_mgmt/afc_mgmt.mk \ $(sm_io_modules_DIR)/tim_rcv/tim_rcv.mk \ $(sm_io_modules_DIR)/rffe_scpi/rffe_scpi.mk \ - $(sm_io_modules_DIR)/orbit_intlk/orbit_intlk.mk + $(sm_io_modules_DIR)/orbit_intlk/orbit_intlk.mk \ + $(sm_io_modules_DIR)/fofb_ctrl/fofb_ctrl.mk sm_io_modules_OBJS = $(sm_io_fmc130m_4ch_OBJS) \ $(sm_io_fmc250m_4ch_OBJS) \ @@ -38,4 +39,5 @@ sm_io_modules_OBJS = $(sm_io_fmc130m_4ch_OBJS) \ $(sm_io_afc_mgmt_OBJS) \ $(sm_io_tim_rcv_OBJS) \ $(sm_io_rffe_scpi_OBJS) \ - $(sm_io_orbit_intlk_OBJS) + $(sm_io_orbit_intlk_OBJS) \ + $(sm_io_fofb_ctrl_OBJS) From 065b47b3e9a59d81732fc3b00275c9c3907c82bd Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Wed, 27 Jan 2021 15:02:59 -0300 Subject: [PATCH 09/40] sm_io/modules: add fofb_ctrl SMIO_TABLE module --- src/sm_io_table/CMakeLists.txt | 2 + .../modules/fofb_ctrl/fofb_ctrl.mk | 3 + .../fofb_ctrl/sm_io_fofb_ctrl_exports.c | 665 ++++++++++++++++++ .../fofb_ctrl/sm_io_fofb_ctrl_exports.h | 66 ++ src/sm_io_table/modules/modules.mk | 6 +- src/sm_io_table/sm_io_codes.c | 1 + src/sm_io_table/sm_io_codes.h | 2 + 7 files changed, 743 insertions(+), 2 deletions(-) create mode 100644 src/sm_io_table/modules/fofb_ctrl/fofb_ctrl.mk create mode 100644 src/sm_io_table/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.c create mode 100644 src/sm_io_table/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.h diff --git a/src/sm_io_table/CMakeLists.txt b/src/sm_io_table/CMakeLists.txt index 74462eed..cfc2232a 100644 --- a/src/sm_io_table/CMakeLists.txt +++ b/src/sm_io_table/CMakeLists.txt @@ -52,6 +52,7 @@ set(sm_io_table_sources ${CMAKE_CURRENT_SOURCE_DIR}/modules/afc_mgmt/sm_io_afc_mgmt_exports.c ${CMAKE_CURRENT_SOURCE_DIR}/modules/tim_rcv/sm_io_tim_rcv_exports.c ${CMAKE_CURRENT_SOURCE_DIR}/modules/orbit_intlk/sm_io_orbit_intlk_exports.c + ${CMAKE_CURRENT_SOURCE_DIR}/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.c ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_codes.c ) @@ -88,6 +89,7 @@ set(sm_io_table_public_headers ${CMAKE_CURRENT_SOURCE_DIR}/modules/afc_mgmt/sm_io_afc_mgmt_exports.h ${CMAKE_CURRENT_SOURCE_DIR}/modules/tim_rcv/sm_io_tim_rcv_exports.h ${CMAKE_CURRENT_SOURCE_DIR}/modules/orbit_intlk/sm_io_orbit_intlk_exports.h + ${CMAKE_CURRENT_SOURCE_DIR}/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.h ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_codes.h ) diff --git a/src/sm_io_table/modules/fofb_ctrl/fofb_ctrl.mk b/src/sm_io_table/modules/fofb_ctrl/fofb_ctrl.mk new file mode 100644 index 00000000..a878fd3c --- /dev/null +++ b/src/sm_io_table/modules/fofb_ctrl/fofb_ctrl.mk @@ -0,0 +1,3 @@ +sm_io_table_fofb_ctrl_DIR = $(sm_io_table_modules_DIR)/fofb_ctrl + +sm_io_table_fofb_ctrl_OBJS = $(sm_io_table_fofb_ctrl_DIR)/sm_io_fofb_ctrl_exports.o diff --git a/src/sm_io_table/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.c b/src/sm_io_table/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.c new file mode 100644 index 00000000..ddbd2506 --- /dev/null +++ b/src/sm_io_table/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.c @@ -0,0 +1,665 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#include "sm_io_exports_helper.h" +#include "sm_io_codes.h" + +/* Description SMIO FOFB_CTRL functions */ +disp_op_t fofb_ctrl_set_get_act_part_exp = { + .name = FOFB_CTRL_NAME_SET_GET_ACT_PART, + .opcode = FOFB_CTRL_OPCODE_SET_GET_ACT_PART, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_err_clr_exp = { + .name = FOFB_CTRL_NAME_SET_GET_ERR_CLR, + .opcode = FOFB_CTRL_OPCODE_SET_GET_ERR_CLR, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_cc_enable_exp = { + .name = FOFB_CTRL_NAME_SET_GET_CC_ENABLE, + .opcode = FOFB_CTRL_OPCODE_SET_GET_CC_ENABLE, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_tfs_override_exp = { + .name = FOFB_CTRL_NAME_SET_GET_TFS_OVERRIDE, + .opcode = FOFB_CTRL_OPCODE_SET_GET_TFS_OVERRIDE, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_bpm_id_exp = { + .name = FOFB_CTRL_NAME_SET_GET_BPM_ID, + .opcode = FOFB_CTRL_OPCODE_SET_GET_BPM_ID, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_time_frame_len_exp = { + .name = FOFB_CTRL_NAME_SET_GET_TIME_FRAME_LEN, + .opcode = FOFB_CTRL_OPCODE_SET_GET_TIME_FRAME_LEN, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_mgt_powerdown_exp = { + .name = FOFB_CTRL_NAME_SET_GET_MGT_POWERDOWN, + .opcode = FOFB_CTRL_OPCODE_SET_GET_MGT_POWERDOWN, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_mgt_loopback_exp = { + .name = FOFB_CTRL_NAME_SET_GET_MGT_LOOPBACK, + .opcode = FOFB_CTRL_OPCODE_SET_GET_MGT_LOOPBACK, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_time_frame_dly_exp = { + .name = FOFB_CTRL_NAME_SET_GET_TIME_FRAME_DLY, + .opcode = FOFB_CTRL_OPCODE_SET_GET_TIME_FRAME_DLY, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_golden_orb_x_exp = { + .name = FOFB_CTRL_NAME_SET_GET_GOLDEN_ORB_X, + .opcode = FOFB_CTRL_OPCODE_SET_GET_GOLDEN_ORB_X, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_golden_orb_y_exp = { + .name = FOFB_CTRL_NAME_SET_GET_GOLDEN_ORB_Y, + .opcode = FOFB_CTRL_OPCODE_SET_GET_GOLDEN_ORB_Y, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_cust_feature_exp = { + .name = FOFB_CTRL_NAME_SET_GET_CUST_FEATURE, + .opcode = FOFB_CTRL_OPCODE_SET_GET_CUST_FEATURE, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_rx_polarity_exp = { + .name = FOFB_CTRL_NAME_SET_GET_RX_POLARITY, + .opcode = FOFB_CTRL_OPCODE_SET_GET_RX_POLARITY, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_payloadsel_exp = { + .name = FOFB_CTRL_NAME_SET_GET_PAYLOADSEL, + .opcode = FOFB_CTRL_OPCODE_SET_GET_PAYLOADSEL, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_fofbdatasel_exp = { + .name = FOFB_CTRL_NAME_SET_GET_FOFBDATASEL, + .opcode = FOFB_CTRL_OPCODE_SET_GET_FOFBDATASEL, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_firmware_ver_exp = { + .name = FOFB_CTRL_NAME_SET_GET_FIRMWARE_VER, + .opcode = FOFB_CTRL_OPCODE_SET_GET_FIRMWARE_VER, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_sys_status_exp = { + .name = FOFB_CTRL_NAME_SET_GET_SYS_STATUS, + .opcode = FOFB_CTRL_OPCODE_SET_GET_SYS_STATUS, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_link_partner_1_exp = { + .name = FOFB_CTRL_NAME_SET_GET_LINK_PARTNER_1, + .opcode = FOFB_CTRL_OPCODE_SET_GET_LINK_PARTNER_1, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_link_partner_2_exp = { + .name = FOFB_CTRL_NAME_SET_GET_LINK_PARTNER_2, + .opcode = FOFB_CTRL_OPCODE_SET_GET_LINK_PARTNER_2, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_link_partner_3_exp = { + .name = FOFB_CTRL_NAME_SET_GET_LINK_PARTNER_3, + .opcode = FOFB_CTRL_OPCODE_SET_GET_LINK_PARTNER_3, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_link_partner_4_exp = { + .name = FOFB_CTRL_NAME_SET_GET_LINK_PARTNER_4, + .opcode = FOFB_CTRL_OPCODE_SET_GET_LINK_PARTNER_4, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_link_up_exp = { + .name = FOFB_CTRL_NAME_SET_GET_LINK_UP, + .opcode = FOFB_CTRL_OPCODE_SET_GET_LINK_UP, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_time_frame_count_exp = { + .name = FOFB_CTRL_NAME_SET_GET_TIME_FRAME_COUNT, + .opcode = FOFB_CTRL_OPCODE_SET_GET_TIME_FRAME_COUNT, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_hard_err_cnt_1_exp = { + .name = FOFB_CTRL_NAME_SET_GET_HARD_ERR_CNT_1, + .opcode = FOFB_CTRL_OPCODE_SET_GET_HARD_ERR_CNT_1, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_hard_err_cnt_2_exp = { + .name = FOFB_CTRL_NAME_SET_GET_HARD_ERR_CNT_2, + .opcode = FOFB_CTRL_OPCODE_SET_GET_HARD_ERR_CNT_2, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_hard_err_cnt_3_exp = { + .name = FOFB_CTRL_NAME_SET_GET_HARD_ERR_CNT_3, + .opcode = FOFB_CTRL_OPCODE_SET_GET_HARD_ERR_CNT_3, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_hard_err_cnt_4_exp = { + .name = FOFB_CTRL_NAME_SET_GET_HARD_ERR_CNT_4, + .opcode = FOFB_CTRL_OPCODE_SET_GET_HARD_ERR_CNT_4, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_soft_err_cnt_1_exp = { + .name = FOFB_CTRL_NAME_SET_GET_SOFT_ERR_CNT_1, + .opcode = FOFB_CTRL_OPCODE_SET_GET_SOFT_ERR_CNT_1, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_soft_err_cnt_2_exp = { + .name = FOFB_CTRL_NAME_SET_GET_SOFT_ERR_CNT_2, + .opcode = FOFB_CTRL_OPCODE_SET_GET_SOFT_ERR_CNT_2, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_soft_err_cnt_3_exp = { + .name = FOFB_CTRL_NAME_SET_GET_SOFT_ERR_CNT_3, + .opcode = FOFB_CTRL_OPCODE_SET_GET_SOFT_ERR_CNT_3, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_soft_err_cnt_4_exp = { + .name = FOFB_CTRL_NAME_SET_GET_SOFT_ERR_CNT_4, + .opcode = FOFB_CTRL_OPCODE_SET_GET_SOFT_ERR_CNT_4, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_frame_err_cnt_1_exp = { + .name = FOFB_CTRL_NAME_SET_GET_FRAME_ERR_CNT_1, + .opcode = FOFB_CTRL_OPCODE_SET_GET_FRAME_ERR_CNT_1, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_frame_err_cnt_2_exp = { + .name = FOFB_CTRL_NAME_SET_GET_FRAME_ERR_CNT_2, + .opcode = FOFB_CTRL_OPCODE_SET_GET_FRAME_ERR_CNT_2, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_frame_err_cnt_3_exp = { + .name = FOFB_CTRL_NAME_SET_GET_FRAME_ERR_CNT_3, + .opcode = FOFB_CTRL_OPCODE_SET_GET_FRAME_ERR_CNT_3, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_frame_err_cnt_4_exp = { + .name = FOFB_CTRL_NAME_SET_GET_FRAME_ERR_CNT_4, + .opcode = FOFB_CTRL_OPCODE_SET_GET_FRAME_ERR_CNT_4, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_rx_pck_cnt_1_exp = { + .name = FOFB_CTRL_NAME_SET_GET_RX_PCK_CNT_1, + .opcode = FOFB_CTRL_OPCODE_SET_GET_RX_PCK_CNT_1, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_rx_pck_cnt_2_exp = { + .name = FOFB_CTRL_NAME_SET_GET_RX_PCK_CNT_2, + .opcode = FOFB_CTRL_OPCODE_SET_GET_RX_PCK_CNT_2, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_rx_pck_cnt_3_exp = { + .name = FOFB_CTRL_NAME_SET_GET_RX_PCK_CNT_3, + .opcode = FOFB_CTRL_OPCODE_SET_GET_RX_PCK_CNT_3, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_rx_pck_cnt_4_exp = { + .name = FOFB_CTRL_NAME_SET_GET_RX_PCK_CNT_4, + .opcode = FOFB_CTRL_OPCODE_SET_GET_RX_PCK_CNT_4, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_tx_pck_cnt_1_exp = { + .name = FOFB_CTRL_NAME_SET_GET_TX_PCK_CNT_1, + .opcode = FOFB_CTRL_OPCODE_SET_GET_TX_PCK_CNT_1, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_tx_pck_cnt_2_exp = { + .name = FOFB_CTRL_NAME_SET_GET_TX_PCK_CNT_2, + .opcode = FOFB_CTRL_OPCODE_SET_GET_TX_PCK_CNT_2, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_tx_pck_cnt_3_exp = { + .name = FOFB_CTRL_NAME_SET_GET_TX_PCK_CNT_3, + .opcode = FOFB_CTRL_OPCODE_SET_GET_TX_PCK_CNT_3, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_tx_pck_cnt_4_exp = { + .name = FOFB_CTRL_NAME_SET_GET_TX_PCK_CNT_4, + .opcode = FOFB_CTRL_OPCODE_SET_GET_TX_PCK_CNT_4, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_fod_process_time_exp = { + .name = FOFB_CTRL_NAME_SET_GET_FOD_PROCESS_TIME, + .opcode = FOFB_CTRL_OPCODE_SET_GET_FOD_PROCESS_TIME, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_bpm_count_exp = { + .name = FOFB_CTRL_NAME_SET_GET_BPM_COUNT, + .opcode = FOFB_CTRL_OPCODE_SET_GET_BPM_COUNT, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_bpm_id_rdback_exp = { + .name = FOFB_CTRL_NAME_SET_GET_BPM_ID_RDBACK, + .opcode = FOFB_CTRL_OPCODE_SET_GET_BPM_ID_RDBACK, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_tf_length_rdback_exp = { + .name = FOFB_CTRL_NAME_SET_GET_TF_LENGTH_RDBACK, + .opcode = FOFB_CTRL_OPCODE_SET_GET_TF_LENGTH_RDBACK, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_powerdown_rdback_exp = { + .name = FOFB_CTRL_NAME_SET_GET_POWERDOWN_RDBACK, + .opcode = FOFB_CTRL_OPCODE_SET_GET_POWERDOWN_RDBACK, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_loopback_rdback_exp = { + .name = FOFB_CTRL_NAME_SET_GET_LOOPBACK_RDBACK, + .opcode = FOFB_CTRL_OPCODE_SET_GET_LOOPBACK_RDBACK, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t fofb_ctrl_set_get_faival_rdback_exp = { + .name = FOFB_CTRL_NAME_SET_GET_FAIVAL_RDBACK, + .opcode = FOFB_CTRL_OPCODE_SET_GET_FAIVAL_RDBACK, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +/* Exported function description */ +const disp_op_t *fofb_ctrl_exp_ops [] = { + &fofb_ctrl_set_get_act_part_exp, + &fofb_ctrl_set_get_err_clr_exp, + &fofb_ctrl_set_get_cc_enable_exp, + &fofb_ctrl_set_get_tfs_override_exp, + &fofb_ctrl_set_get_bpm_id_exp, + &fofb_ctrl_set_get_time_frame_len_exp, + &fofb_ctrl_set_get_mgt_powerdown_exp, + &fofb_ctrl_set_get_mgt_loopback_exp, + &fofb_ctrl_set_get_time_frame_dly_exp, + &fofb_ctrl_set_get_golden_orb_x_exp, + &fofb_ctrl_set_get_golden_orb_y_exp, + &fofb_ctrl_set_get_cust_feature_exp, + &fofb_ctrl_set_get_rx_polarity_exp, + &fofb_ctrl_set_get_payloadsel_exp, + &fofb_ctrl_set_get_fofbdatasel_exp, + &fofb_ctrl_set_get_firmware_ver_exp, + &fofb_ctrl_set_get_sys_status_exp, + &fofb_ctrl_set_get_link_partner_1_exp, + &fofb_ctrl_set_get_link_partner_2_exp, + &fofb_ctrl_set_get_link_partner_3_exp, + &fofb_ctrl_set_get_link_partner_4_exp, + &fofb_ctrl_set_get_link_up_exp, + &fofb_ctrl_set_get_time_frame_count_exp, + &fofb_ctrl_set_get_hard_err_cnt_1_exp, + &fofb_ctrl_set_get_hard_err_cnt_2_exp, + &fofb_ctrl_set_get_hard_err_cnt_3_exp, + &fofb_ctrl_set_get_hard_err_cnt_4_exp, + &fofb_ctrl_set_get_soft_err_cnt_1_exp, + &fofb_ctrl_set_get_soft_err_cnt_2_exp, + &fofb_ctrl_set_get_soft_err_cnt_3_exp, + &fofb_ctrl_set_get_soft_err_cnt_4_exp, + &fofb_ctrl_set_get_frame_err_cnt_1_exp, + &fofb_ctrl_set_get_frame_err_cnt_2_exp, + &fofb_ctrl_set_get_frame_err_cnt_3_exp, + &fofb_ctrl_set_get_frame_err_cnt_4_exp, + &fofb_ctrl_set_get_rx_pck_cnt_1_exp, + &fofb_ctrl_set_get_rx_pck_cnt_2_exp, + &fofb_ctrl_set_get_rx_pck_cnt_3_exp, + &fofb_ctrl_set_get_rx_pck_cnt_4_exp, + &fofb_ctrl_set_get_tx_pck_cnt_1_exp, + &fofb_ctrl_set_get_tx_pck_cnt_2_exp, + &fofb_ctrl_set_get_tx_pck_cnt_3_exp, + &fofb_ctrl_set_get_tx_pck_cnt_4_exp, + &fofb_ctrl_set_get_fod_process_time_exp, + &fofb_ctrl_set_get_bpm_count_exp, + &fofb_ctrl_set_get_bpm_id_rdback_exp, + &fofb_ctrl_set_get_tf_length_rdback_exp, + &fofb_ctrl_set_get_powerdown_rdback_exp, + &fofb_ctrl_set_get_loopback_rdback_exp, + &fofb_ctrl_set_get_faival_rdback_exp, + NULL +}; diff --git a/src/sm_io_table/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.h b/src/sm_io_table/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.h new file mode 100644 index 00000000..3b1f0fca --- /dev/null +++ b/src/sm_io_table/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#ifndef _SM_IO_FOFB_CTRL_EXPORTS_H_ +#define _SM_IO_FOFB_CTRL_EXPORTS_H_ + +#include "disptable.h" + +extern disp_op_t fofb_ctrl_set_get_act_part_exp; +extern disp_op_t fofb_ctrl_set_get_err_clr_exp; +extern disp_op_t fofb_ctrl_set_get_cc_enable_exp; +extern disp_op_t fofb_ctrl_set_get_tfs_override_exp; +extern disp_op_t fofb_ctrl_set_get_bpm_id_exp; +extern disp_op_t fofb_ctrl_set_get_time_frame_len_exp; +extern disp_op_t fofb_ctrl_set_get_mgt_powerdown_exp; +extern disp_op_t fofb_ctrl_set_get_mgt_loopback_exp; +extern disp_op_t fofb_ctrl_set_get_time_frame_dly_exp; +extern disp_op_t fofb_ctrl_set_get_golden_orb_x_exp; +extern disp_op_t fofb_ctrl_set_get_golden_orb_y_exp; +extern disp_op_t fofb_ctrl_set_get_cust_feature_exp; +extern disp_op_t fofb_ctrl_set_get_rx_polarity_exp; +extern disp_op_t fofb_ctrl_set_get_payloadsel_exp; +extern disp_op_t fofb_ctrl_set_get_fofbdatasel_exp; +extern disp_op_t fofb_ctrl_set_get_firmware_ver_exp; +extern disp_op_t fofb_ctrl_set_get_sys_status_exp; +extern disp_op_t fofb_ctrl_set_get_link_partner_1_exp; +extern disp_op_t fofb_ctrl_set_get_link_partner_2_exp; +extern disp_op_t fofb_ctrl_set_get_link_partner_3_exp; +extern disp_op_t fofb_ctrl_set_get_link_partner_4_exp; +extern disp_op_t fofb_ctrl_set_get_link_up_exp; +extern disp_op_t fofb_ctrl_set_get_time_frame_count_exp; +extern disp_op_t fofb_ctrl_set_get_hard_err_cnt_1_exp; +extern disp_op_t fofb_ctrl_set_get_hard_err_cnt_2_exp; +extern disp_op_t fofb_ctrl_set_get_hard_err_cnt_3_exp; +extern disp_op_t fofb_ctrl_set_get_hard_err_cnt_4_exp; +extern disp_op_t fofb_ctrl_set_get_soft_err_cnt_1_exp; +extern disp_op_t fofb_ctrl_set_get_soft_err_cnt_2_exp; +extern disp_op_t fofb_ctrl_set_get_soft_err_cnt_3_exp; +extern disp_op_t fofb_ctrl_set_get_soft_err_cnt_4_exp; +extern disp_op_t fofb_ctrl_set_get_frame_err_cnt_1_exp; +extern disp_op_t fofb_ctrl_set_get_frame_err_cnt_2_exp; +extern disp_op_t fofb_ctrl_set_get_frame_err_cnt_3_exp; +extern disp_op_t fofb_ctrl_set_get_frame_err_cnt_4_exp; +extern disp_op_t fofb_ctrl_set_get_rx_pck_cnt_1_exp; +extern disp_op_t fofb_ctrl_set_get_rx_pck_cnt_2_exp; +extern disp_op_t fofb_ctrl_set_get_rx_pck_cnt_3_exp; +extern disp_op_t fofb_ctrl_set_get_rx_pck_cnt_4_exp; +extern disp_op_t fofb_ctrl_set_get_tx_pck_cnt_1_exp; +extern disp_op_t fofb_ctrl_set_get_tx_pck_cnt_2_exp; +extern disp_op_t fofb_ctrl_set_get_tx_pck_cnt_3_exp; +extern disp_op_t fofb_ctrl_set_get_tx_pck_cnt_4_exp; +extern disp_op_t fofb_ctrl_set_get_fod_process_time_exp; +extern disp_op_t fofb_ctrl_set_get_bpm_count_exp; +extern disp_op_t fofb_ctrl_set_get_bpm_id_rdback_exp; +extern disp_op_t fofb_ctrl_set_get_tf_length_rdback_exp; +extern disp_op_t fofb_ctrl_set_get_powerdown_rdback_exp; +extern disp_op_t fofb_ctrl_set_get_loopback_rdback_exp; +extern disp_op_t fofb_ctrl_set_get_faival_rdback_exp; + +extern const disp_op_t *fofb_ctrl_exp_ops []; + +#endif diff --git a/src/sm_io_table/modules/modules.mk b/src/sm_io_table/modules/modules.mk index 48d498e7..8fd93191 100644 --- a/src/sm_io_table/modules/modules.mk +++ b/src/sm_io_table/modules/modules.mk @@ -18,7 +18,8 @@ include $(sm_io_table_modules_DIR)/fmc130m_4ch/fmc130m_4ch.mk \ $(sm_io_table_modules_DIR)/afc_mgmt/afc_mgmt.mk \ $(sm_io_table_modules_DIR)/tim_rcv/tim_rcv.mk \ $(sm_io_table_modules_DIR)/rffe_scpi/rffe_scpi.mk \ - $(sm_io_table_modules_DIR)/orbit_intlk/orbit_intlk.mk + $(sm_io_table_modules_DIR)/orbit_intlk/orbit_intlk.mk \ + $(sm_io_table_modules_DIR)/fofb_ctrl/fofb_ctrl.mk sm_io_table_modules_OBJS = $(sm_io_table_fmc130m_4ch_OBJS) \ $(sm_io_table_fmc250m_4ch_OBJS) \ @@ -38,4 +39,5 @@ sm_io_table_modules_OBJS = $(sm_io_table_fmc130m_4ch_OBJS) \ $(sm_io_table_afc_mgmt_OBJS) \ $(sm_io_table_tim_rcv_OBJS) \ $(sm_io_table_rffe_scpi_OBJS) \ - $(sm_io_table_orbit_intlk_OBJS) + $(sm_io_table_orbit_intlk_OBJS) \ + $(sm_io_table_fofb_ctrl_OBJS) diff --git a/src/sm_io_table/sm_io_codes.c b/src/sm_io_table/sm_io_codes.c index bdeaed22..f9ff0518 100644 --- a/src/sm_io_table/sm_io_codes.c +++ b/src/sm_io_table/sm_io_codes.c @@ -27,6 +27,7 @@ const disp_op_t **smio_exp_ops [] = { afc_mgmt_exp_ops, tim_rcv_exp_ops, orbit_intlk_exp_ops, + fofb_ctrl_exp_ops, NULL }; diff --git a/src/sm_io_table/sm_io_codes.h b/src/sm_io_table/sm_io_codes.h index 63302906..02cdb071 100644 --- a/src/sm_io_table/sm_io_codes.h +++ b/src/sm_io_table/sm_io_codes.h @@ -45,6 +45,7 @@ typedef struct _smio_rffe_version_t smio_rffe_version_t; #include "sm_io_afc_mgmt_codes.h" #include "sm_io_tim_rcv_codes.h" #include "sm_io_orbit_intlk_codes.h" +#include "sm_io_fofb_ctrl_codes.h" /* Include all function descriptors */ #include "sm_io_fmc130m_4ch_exports.h" @@ -66,6 +67,7 @@ typedef struct _smio_rffe_version_t smio_rffe_version_t; #include "sm_io_afc_mgmt_exports.h" #include "sm_io_tim_rcv_exports.h" #include "sm_io_orbit_intlk_exports.h" +#include "sm_io_fofb_ctrl_exports.h" /* Merge all function descriptors in a single structure */ extern const disp_op_t **smio_exp_ops []; From 64f6f856fe82caaf9e995015df9d261ff1197cd9 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Wed, 27 Jan 2021 15:03:11 -0300 Subject: [PATCH 10/40] src/client: add fofb_ctrl client functions --- src/client/CMakeLists.txt | 3 + src/client/include/halcs_client_core.h | 334 +++++++++++++++++++++++++ src/client/src/halcs_client_core.c | 328 ++++++++++++++++++++++++ 3 files changed, 665 insertions(+) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 37ef1634..c12c1b40 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -287,6 +287,7 @@ set(halcsclient_smio_table_sources ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/afc_mgmt/sm_io_afc_mgmt_exports.c ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/tim_rcv/sm_io_tim_rcv_exports.c ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/orbit_intlk/sm_io_orbit_intlk_exports.c + ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.c ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/sm_io_codes.c ) @@ -343,6 +344,7 @@ set(halcsclient_smio_public_headers ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io/modules/afc_mgmt/sm_io_afc_mgmt_codes.h ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io/modules/tim_rcv/sm_io_tim_rcv_codes.h ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io/modules/orbit_intlk/sm_io_orbit_intlk_codes.h + ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_codes.h ) # Get directory names only @@ -394,6 +396,7 @@ set(halcsclient_smio_table_public_headers ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/afc_mgmt/sm_io_afc_mgmt_exports.h ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/tim_rcv/sm_io_tim_rcv_exports.h ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/orbit_intlk/sm_io_orbit_intlk_exports.h + ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.h ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/sm_io_codes.h ) diff --git a/src/client/include/halcs_client_core.h b/src/client/include/halcs_client_core.h index f8405349..fb5bc176 100644 --- a/src/client/include/halcs_client_core.h +++ b/src/client/include/halcs_client_core.h @@ -2112,6 +2112,340 @@ halcs_client_err_e halcs_set_orbit_intlk_ang_min_y (halcs_client_t *self, char * halcs_client_err_e halcs_get_orbit_intlk_ang_min_y (halcs_client_t *self, char *service, int32_t *orbit_intlk_ang_min_y); +/********************** FOFB CTRL Functions ********************/ + +/* FOFB Controller act_part function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_act_part (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_act_part); +halcs_client_err_e halcs_get_fofb_ctrl_act_part (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_act_part); + +/* FOFB Controller err_clr function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_err_clr (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_err_clr); +halcs_client_err_e halcs_get_fofb_ctrl_err_clr (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_err_clr); + +/* FOFB Controller cc_enable function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_cc_enable (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_cc_enable); +halcs_client_err_e halcs_get_fofb_ctrl_cc_enable (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_cc_enable); + +/* FOFB Controller tfs_override function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_tfs_override (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_tfs_override); +halcs_client_err_e halcs_get_fofb_ctrl_tfs_override (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_tfs_override); + +/* FOFB Controller bpm_id function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_bpm_id (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_bpm_id); +halcs_client_err_e halcs_get_fofb_ctrl_bpm_id (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_bpm_id); + +/* FOFB Controller time_frame_len function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_time_frame_len (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_time_frame_len); +halcs_client_err_e halcs_get_fofb_ctrl_time_frame_len (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_time_frame_len); + +/* FOFB Controller mgt_powerdown function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_mgt_powerdown (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_mgt_powerdown); +halcs_client_err_e halcs_get_fofb_ctrl_mgt_powerdown (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_mgt_powerdown); + +/* FOFB Controller mgt_loopback function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_mgt_loopback (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_mgt_loopback); +halcs_client_err_e halcs_get_fofb_ctrl_mgt_loopback (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_mgt_loopback); + +/* FOFB Controller time_frame_dly function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_time_frame_dly (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_time_frame_dly); +halcs_client_err_e halcs_get_fofb_ctrl_time_frame_dly (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_time_frame_dly); + +/* FOFB Controller golden_orb_x function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_golden_orb_x (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_golden_orb_x); +halcs_client_err_e halcs_get_fofb_ctrl_golden_orb_x (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_golden_orb_x); + +/* FOFB Controller golden_orb_y function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_golden_orb_y (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_golden_orb_y); +halcs_client_err_e halcs_get_fofb_ctrl_golden_orb_y (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_golden_orb_y); + +/* FOFB Controller cust_feature function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_cust_feature (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_cust_feature); +halcs_client_err_e halcs_get_fofb_ctrl_cust_feature (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_cust_feature); + +/* FOFB Controller rx_polarity function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_rx_polarity (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_rx_polarity); +halcs_client_err_e halcs_get_fofb_ctrl_rx_polarity (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_rx_polarity); + +/* FOFB Controller payloadsel function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_payloadsel (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_payloadsel); +halcs_client_err_e halcs_get_fofb_ctrl_payloadsel (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_payloadsel); + +/* FOFB Controller fofbdatasel function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_fofb_ctrl_fofbdatasel (halcs_client_t *self, char *service, + uint32_t fofb_ctrl_fofbdatasel); +halcs_client_err_e halcs_get_fofb_ctrl_fofbdatasel (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_fofbdatasel); + +/* Status only functions */ + +/* FOFB Controller firmware_ver function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_firmware_ver (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_firmware_ver); + +/* FOFB Controller sys_status function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_sys_status (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_sys_status); + +/* FOFB Controller link_partner_1 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_link_partner_1 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_link_partner_1); + +/* FOFB Controller link_partner_2 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_link_partner_2 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_link_partner_2); + +/* FOFB Controller link_partner_3 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_link_partner_3 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_link_partner_3); + +/* FOFB Controller link_partner_4 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_link_partner_4 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_link_partner_4); + +/* FOFB Controller link_up function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_link_up (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_link_up); + +/* FOFB Controller time_frame_count function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_time_frame_count (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_time_frame_count); + +/* FOFB Controller hard_err_cnt_1 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_hard_err_cnt_1 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_hard_err_cnt_1); + +/* FOFB Controller hard_err_cnt_2 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_hard_err_cnt_2 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_hard_err_cnt_2); + +/* FOFB Controller hard_err_cnt_3 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_hard_err_cnt_3 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_hard_err_cnt_3); + +/* FOFB Controller hard_err_cnt_4 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_hard_err_cnt_4 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_hard_err_cnt_4); + +/* FOFB Controller soft_err_cnt_1 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_soft_err_cnt_1 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_soft_err_cnt_1); + +/* FOFB Controller soft_err_cnt_2 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_soft_err_cnt_2 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_soft_err_cnt_2); + +/* FOFB Controller soft_err_cnt_3 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_soft_err_cnt_3 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_soft_err_cnt_3); + +/* FOFB Controller soft_err_cnt_4 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_soft_err_cnt_4 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_soft_err_cnt_4); + +/* FOFB Controller frame_err_cnt_1 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_frame_err_cnt_1 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_frame_err_cnt_1); + +/* FOFB Controller frame_err_cnt_2 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_frame_err_cnt_2 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_frame_err_cnt_2); + +/* FOFB Controller frame_err_cnt_3 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_frame_err_cnt_3 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_frame_err_cnt_3); + +/* FOFB Controller frame_err_cnt_4 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_frame_err_cnt_4 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_frame_err_cnt_4); + +/* FOFB Controller rx_pck_cnt_1 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_rx_pck_cnt_1 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_rx_pck_cnt_1); + +/* FOFB Controller rx_pck_cnt_2 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_rx_pck_cnt_2 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_rx_pck_cnt_2); + +/* FOFB Controller rx_pck_cnt_3 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_rx_pck_cnt_3 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_rx_pck_cnt_3); + +/* FOFB Controller rx_pck_cnt_4 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_rx_pck_cnt_4 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_rx_pck_cnt_4); + +/* FOFB Controller tx_pck_cnt_1 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_tx_pck_cnt_1 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_tx_pck_cnt_1); + +/* FOFB Controller tx_pck_cnt_2 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_tx_pck_cnt_2 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_tx_pck_cnt_2); + +/* FOFB Controller tx_pck_cnt_3 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_tx_pck_cnt_3 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_tx_pck_cnt_3); + +/* FOFB Controller tx_pck_cnt_4 function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_tx_pck_cnt_4 (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_tx_pck_cnt_4); + +/* FOFB Controller fod_process_time function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_fod_process_time (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_fod_process_time); + +/* FOFB Controller bpm_count function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_bpm_count (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_bpm_count); + +/* FOFB Controller bpm_id_rdback function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_bpm_id_rdback (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_bpm_id_rdback); + +/* FOFB Controller tf_length_rdback function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_tf_length_rdback (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_tf_length_rdback); + +/* FOFB Controller powerdown_rdback function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_powerdown_rdback (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_powerdown_rdback); + +/* FOFB Controller loopback_rdback function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_loopback_rdback (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_loopback_rdback); + +/* FOFB Controller faival_rdback function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_fofb_ctrl_faival_rdback (halcs_client_t *self, char *service, + uint32_t *fofb_ctrl_faival_rdback); + #ifdef __cplusplus } #endif diff --git a/src/client/src/halcs_client_core.c b/src/client/src/halcs_client_core.c index 965f0ff1..2046e18c 100644 --- a/src/client/src/halcs_client_core.c +++ b/src/client/src/halcs_client_core.c @@ -3649,3 +3649,331 @@ PARAM_FUNC_CLIENT_READ_SIGNED(orbit_intlk_ang_min_y) { return param_client_read_signed (self, service, ORBIT_INTLK_OPCODE_SET_GET_ANG_MIN_Y, orbit_intlk_ang_min_y); } + +/**************** FOFB CTRL SMIO Functions ****************/ +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_act_part) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_ACT_PART, fofb_ctrl_act_part); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_act_part) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_ACT_PART, fofb_ctrl_act_part); +} + +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_err_clr) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_ERR_CLR, fofb_ctrl_err_clr); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_err_clr) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_ERR_CLR, fofb_ctrl_err_clr); +} + +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_cc_enable) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_CC_ENABLE, fofb_ctrl_cc_enable); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_cc_enable) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_CC_ENABLE, fofb_ctrl_cc_enable); +} + +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_tfs_override) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_TFS_OVERRIDE, fofb_ctrl_tfs_override); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_tfs_override) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_TFS_OVERRIDE, fofb_ctrl_tfs_override); +} + +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_bpm_id) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_BPM_ID, fofb_ctrl_bpm_id); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_bpm_id) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_BPM_ID, fofb_ctrl_bpm_id); +} + +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_time_frame_len) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_TIME_FRAME_LEN, fofb_ctrl_time_frame_len); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_time_frame_len) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_TIME_FRAME_LEN, fofb_ctrl_time_frame_len); +} + +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_mgt_powerdown) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_MGT_POWERDOWN, fofb_ctrl_mgt_powerdown); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_mgt_powerdown) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_MGT_POWERDOWN, fofb_ctrl_mgt_powerdown); +} + +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_mgt_loopback) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_MGT_LOOPBACK, fofb_ctrl_mgt_loopback); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_mgt_loopback) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_MGT_LOOPBACK, fofb_ctrl_mgt_loopback); +} + +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_time_frame_dly) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_TIME_FRAME_DLY, fofb_ctrl_time_frame_dly); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_time_frame_dly) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_TIME_FRAME_DLY, fofb_ctrl_time_frame_dly); +} + +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_golden_orb_x) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_GOLDEN_ORB_X, fofb_ctrl_golden_orb_x); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_golden_orb_x) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_GOLDEN_ORB_X, fofb_ctrl_golden_orb_x); +} + +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_golden_orb_y) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_GOLDEN_ORB_Y, fofb_ctrl_golden_orb_y); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_golden_orb_y) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_GOLDEN_ORB_Y, fofb_ctrl_golden_orb_y); +} + +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_cust_feature) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_CUST_FEATURE, fofb_ctrl_cust_feature); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_cust_feature) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_CUST_FEATURE, fofb_ctrl_cust_feature); +} + +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_rx_polarity) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_RX_POLARITY, fofb_ctrl_rx_polarity); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_rx_polarity) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_RX_POLARITY, fofb_ctrl_rx_polarity); +} + +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_payloadsel) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_PAYLOADSEL, fofb_ctrl_payloadsel); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_payloadsel) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_PAYLOADSEL, fofb_ctrl_payloadsel); +} + +PARAM_FUNC_CLIENT_WRITE(fofb_ctrl_fofbdatasel) +{ + return param_client_write (self, service, FOFB_CTRL_OPCODE_SET_GET_FOFBDATASEL, fofb_ctrl_fofbdatasel); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_fofbdatasel) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_FOFBDATASEL, fofb_ctrl_fofbdatasel); +} + +/* Status only functions */ + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_firmware_ver) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_FIRMWARE_VER, fofb_ctrl_firmware_ver); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_sys_status) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_SYS_STATUS, fofb_ctrl_sys_status); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_link_partner_1) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_LINK_PARTNER_1, fofb_ctrl_link_partner_1); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_link_partner_2) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_LINK_PARTNER_2, fofb_ctrl_link_partner_2); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_link_partner_3) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_LINK_PARTNER_3, fofb_ctrl_link_partner_3); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_link_partner_4) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_LINK_PARTNER_4, fofb_ctrl_link_partner_4); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_link_up) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_LINK_UP, fofb_ctrl_link_up); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_time_frame_count) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_TIME_FRAME_COUNT, fofb_ctrl_time_frame_count); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_hard_err_cnt_1) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_HARD_ERR_CNT_1, fofb_ctrl_hard_err_cnt_1); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_hard_err_cnt_2) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_HARD_ERR_CNT_2, fofb_ctrl_hard_err_cnt_2); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_hard_err_cnt_3) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_HARD_ERR_CNT_3, fofb_ctrl_hard_err_cnt_3); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_hard_err_cnt_4) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_HARD_ERR_CNT_4, fofb_ctrl_hard_err_cnt_4); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_soft_err_cnt_1) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_SOFT_ERR_CNT_1, fofb_ctrl_soft_err_cnt_1); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_soft_err_cnt_2) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_SOFT_ERR_CNT_2, fofb_ctrl_soft_err_cnt_2); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_soft_err_cnt_3) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_SOFT_ERR_CNT_3, fofb_ctrl_soft_err_cnt_3); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_soft_err_cnt_4) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_SOFT_ERR_CNT_4, fofb_ctrl_soft_err_cnt_4); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_frame_err_cnt_1) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_FRAME_ERR_CNT_1, fofb_ctrl_frame_err_cnt_1); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_frame_err_cnt_2) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_FRAME_ERR_CNT_2, fofb_ctrl_frame_err_cnt_2); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_frame_err_cnt_3) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_FRAME_ERR_CNT_3, fofb_ctrl_frame_err_cnt_3); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_frame_err_cnt_4) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_FRAME_ERR_CNT_4, fofb_ctrl_frame_err_cnt_4); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_rx_pck_cnt_1) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_RX_PCK_CNT_1, fofb_ctrl_rx_pck_cnt_1); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_rx_pck_cnt_2) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_RX_PCK_CNT_2, fofb_ctrl_rx_pck_cnt_2); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_rx_pck_cnt_3) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_RX_PCK_CNT_3, fofb_ctrl_rx_pck_cnt_3); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_rx_pck_cnt_4) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_RX_PCK_CNT_4, fofb_ctrl_rx_pck_cnt_4); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_tx_pck_cnt_1) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_TX_PCK_CNT_1, fofb_ctrl_tx_pck_cnt_1); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_tx_pck_cnt_2) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_TX_PCK_CNT_2, fofb_ctrl_tx_pck_cnt_2); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_tx_pck_cnt_3) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_TX_PCK_CNT_3, fofb_ctrl_tx_pck_cnt_3); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_tx_pck_cnt_4) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_TX_PCK_CNT_4, fofb_ctrl_tx_pck_cnt_4); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_fod_process_time) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_FOD_PROCESS_TIME, fofb_ctrl_fod_process_time); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_bpm_count) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_BPM_COUNT, fofb_ctrl_bpm_count); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_bpm_id_rdback) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_BPM_ID_RDBACK, fofb_ctrl_bpm_id_rdback); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_tf_length_rdback) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_TF_LENGTH_RDBACK, fofb_ctrl_tf_length_rdback); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_powerdown_rdback) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_POWERDOWN_RDBACK, fofb_ctrl_powerdown_rdback); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_loopback_rdback) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_LOOPBACK_RDBACK, fofb_ctrl_loopback_rdback); +} + +PARAM_FUNC_CLIENT_READ(fofb_ctrl_faival_rdback) +{ + return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_FAIVAL_RDBACK, fofb_ctrl_faival_rdback); +} From e136b82754e87fec8f4cb6db55b8e5eae4db0505 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Wed, 27 Jan 2021 14:38:51 -0300 Subject: [PATCH 11/40] msg: remove bogus opcode bounds checking Any 32-bit opcode is fine. We don't need to limit ourselves by that "200" limit. --- include/msg.h | 2 -- src/msg/msg.c | 3 --- 2 files changed, 5 deletions(-) diff --git a/include/msg.h b/include/msg.h index 716219c4..f6126d45 100644 --- a/include/msg.h +++ b/include/msg.h @@ -13,8 +13,6 @@ extern "C" { #endif #define MSG_OPCODE_SIZE (sizeof (uint32_t)) -/* Arbitrary number*/ -#define MSG_OPCODE_MAX 200 /* We add more message types here */ typedef enum { diff --git a/src/msg/msg.c b/src/msg/msg.c index 5ab05da7..7d0a52ac 100644 --- a/src/msg/msg.c +++ b/src/msg/msg.c @@ -289,13 +289,10 @@ static msg_err_e _msg_gen_get_opcode (zmsg_t *zmq_msg, uint32_t *opcode) MSG_ERR_WRONG_ARGS); *opcode = *(uint32_t *) zframe_data (opcode_frm); - ASSERT_TEST(*opcode < MSG_OPCODE_MAX, "Invalid opcode received", - err_invalid_opcode, MSG_ERR_WRONG_ARGS); zframe_destroy (&opcode_frm); return err; -err_invalid_opcode: err_wrong_opcode_size: zframe_destroy (&opcode_frm); err_null_opcode: From f30c988c1f8572e4919cee49a4c168c086e6bd43 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Wed, 27 Jan 2021 16:16:06 -0300 Subject: [PATCH 12/40] examples: add fofb_ctrl example tool --- examples/CMakeLists.txt | 6 ++ examples/src/fofb_ctrl.c | 191 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 examples/src/fofb_ctrl.c diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1b0ab74c..e4efdc50 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -416,6 +416,12 @@ if(BUILD_EXAMPLE_trigger) list(APPEND bin_target_outputs "trigger") endif() +option(BUILD_EXAMPLE_fofb_ctrl "Whether or not to build example fofb_ctrl tool" ON) + +if(BUILD_EXAMPLE_fofb_ctrl) + list(APPEND bin_target_outputs "fofb_ctrl") +endif() + foreach(bin_target ${bin_target_outputs}) # add binary tool add_executable(${bin_target} src/${bin_target}.c) diff --git a/examples/src/fofb_ctrl.c b/examples/src/fofb_ctrl.c new file mode 100644 index 00000000..8495fa1b --- /dev/null +++ b/examples/src/fofb_ctrl.c @@ -0,0 +1,191 @@ +/* + * Example for demonstrating the communication between a + * a FOFB Ctrl module and a client + */ + +#include +#include +#include +#include +#include +#include + +#define DFLT_BIND_FOLDER "/tmp/malamute" + +#define DFLT_HALCS_NUMBER 0 +#define DFLT_BOARD_NUMBER 0 + +#define MAX_CHANNEL_NUM 4 +#define ALL_CHANNELS_NUM 4 + +static struct option long_options[] = +{ + {"help", no_argument, NULL, 'h'}, + {"brokerendp", required_argument, NULL, 'b'}, + {"verbose", no_argument, NULL, 'v'}, + {"halcsnumber", required_argument, NULL, 's'}, + {"boardslot", required_argument, NULL, 'o'}, + {"bpm_id", required_argument, NULL, 't'}, + {"firmware_ver", no_argument, NULL, 'c'}, + {NULL, 0, NULL, 0} +}; + +static const char* shortopt = "hb:vo:s:t:c"; + +void print_help (char *program_name) +{ + fprintf (stdout, "HALCSD FOFB Controller control utility\n" + "Usage: %s [options]\n" + "\n" + " -h --help Display this usage information\n" + " -b --brokerendp Broker endpoint\n" + " -v --verbose Verbose output\n" + " -o --boardslot \n" + " -s --halcsnumber HALCS number\n" + " Board slot number\n" + " -t --bpm_id BPM ID\n" + " -c --firmware_ver Firmware version\n", + program_name); +} + +int main (int argc, char *argv []) +{ + int verbose = 0; + int firmware_ver = 0; + char *broker_endp = NULL; + char *board_number_str = NULL; + char *halcs_number_str = NULL; + char *bpm_id_str = NULL; + int opt; + + while ((opt = getopt_long (argc, argv, shortopt, long_options, NULL)) != -1) { + /* Get the user selected options */ + switch (opt) { + /* Display Help */ + case 'h': + print_help (argv [0]); + exit (1); + break; + + case 'b': + broker_endp = strdup (optarg); + break; + + case 'v': + verbose = 1; + break; + + case 'o': + board_number_str = strdup (optarg); + break; + + case 's': + halcs_number_str = strdup (optarg); + break; + + case 't': + bpm_id_str = strdup (optarg); + break; + + case 'c': + firmware_ver = 1; + break; + + case '?': + fprintf (stderr, "[client:fofb_ctrl] Option not recognized or missing argument\n"); + print_help (argv [0]); + exit (1); + break; + + default: + fprintf (stderr, "[client:fofb_ctrl] Could not parse options\n"); + print_help (argv [0]); + exit (1); + } + } + + /* Set default broker address */ + if (broker_endp == NULL) { + fprintf (stderr, "[client:fofb_ctrl]: Setting default broker endpoint: %s\n", + "ipc://"DFLT_BIND_FOLDER); + broker_endp = strdup ("ipc://"DFLT_BIND_FOLDER); + } + + /* Set default board number */ + uint32_t board_number; + if (board_number_str == NULL) { + fprintf (stderr, "[client:fofb_ctrl]: Setting default value to BOARD number: %u\n", + DFLT_BOARD_NUMBER); + board_number = DFLT_BOARD_NUMBER; + } + else { + board_number = strtoul (board_number_str, NULL, 10); + } + + /* Set default halcs number */ + uint32_t halcs_number; + if (halcs_number_str == NULL) { + fprintf (stderr, "[client:fofb_ctrl]: Setting default value to HALCS number: %u\n", + DFLT_HALCS_NUMBER); + halcs_number = DFLT_HALCS_NUMBER; + } + else { + halcs_number = strtoul (halcs_number_str, NULL, 10); + } + + char service[50]; + snprintf (service, sizeof (service), "HALCS%u:DEVIO:FOFB_CTRL%u", board_number, halcs_number); + + halcs_client_t *halcs_client = halcs_client_new (broker_endp, verbose, NULL); + if (halcs_client == NULL) { + fprintf (stderr, "[client:fofb_ctrl]: halcs_client could be created\n"); + goto err_halcs_client_new; + } + + halcs_client_err_e err; + uint32_t bpm_id = 0; + if (bpm_id_str != NULL) { + bpm_id = strtoul (bpm_id_str, NULL, 10); + + fprintf (stdout, "[client:fofb_ctrl]: bpm_id = 0x%08X\n", bpm_id); + err = halcs_set_fofb_ctrl_bpm_id (halcs_client, service, bpm_id); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_set_bpm_id failed\n"); + goto err_halcs_exit; + } + } + + /* At the end of all register set we need to call acq_part funcion + * to trigger FOFB ram readout by the device */ + err = halcs_set_fofb_ctrl_act_part (halcs_client, service, 0x1); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_set_fofb_ctrl_act_part failed\n"); + goto err_halcs_exit; + } + + uint32_t firmware_ver_get = 0; + if (firmware_ver) { + err = halcs_get_fofb_ctrl_firmware_ver (halcs_client, service, &firmware_ver_get); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_get_firmware_ver failed\n"); + goto err_halcs_exit; + } + fprintf (stdout, "[client:fofb_ctrl]: firmware_ver = 0x%08X\n", firmware_ver_get); + } + +err_halcs_exit: + /* Try to read up until the point where the error occurs, anyway */ + halcs_set_fofb_ctrl_act_part (halcs_client, service, 0x1); +err_halcs_client_new: + free (bpm_id_str); + bpm_id_str = NULL; + free (board_number_str); + board_number_str = NULL; + free (halcs_number_str); + halcs_number_str = NULL; + free (broker_endp); + broker_endp = NULL; + halcs_client_destroy (&halcs_client); + + return 0; +} From 1b7086d4fccf7ea8a841cf896fd8c0be259988e3 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Mon, 8 Feb 2021 23:41:18 -0300 Subject: [PATCH 13/40] examples/*/fofb_ctrl: add time_frame_len register write --- examples/src/fofb_ctrl.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/examples/src/fofb_ctrl.c b/examples/src/fofb_ctrl.c index 8495fa1b..d081475d 100644 --- a/examples/src/fofb_ctrl.c +++ b/examples/src/fofb_ctrl.c @@ -26,11 +26,12 @@ static struct option long_options[] = {"halcsnumber", required_argument, NULL, 's'}, {"boardslot", required_argument, NULL, 'o'}, {"bpm_id", required_argument, NULL, 't'}, + {"time_frame_len", required_argument, NULL, 'f'}, {"firmware_ver", no_argument, NULL, 'c'}, {NULL, 0, NULL, 0} }; -static const char* shortopt = "hb:vo:s:t:c"; +static const char* shortopt = "hb:vo:s:t:f:c"; void print_help (char *program_name) { @@ -44,6 +45,8 @@ void print_help (char *program_name) " -s --halcsnumber HALCS number\n" " Board slot number\n" " -t --bpm_id BPM ID\n" + " -f --time_frame_len \n" + " Timeframe length\n" " -c --firmware_ver Firmware version\n", program_name); } @@ -56,6 +59,7 @@ int main (int argc, char *argv []) char *board_number_str = NULL; char *halcs_number_str = NULL; char *bpm_id_str = NULL; + char *time_frame_len_str = NULL; int opt; while ((opt = getopt_long (argc, argv, shortopt, long_options, NULL)) != -1) { @@ -87,6 +91,10 @@ int main (int argc, char *argv []) bpm_id_str = strdup (optarg); break; + case 'f': + time_frame_len_str = strdup (optarg); + break; + case 'c': firmware_ver = 1; break; @@ -153,6 +161,17 @@ int main (int argc, char *argv []) fprintf (stderr, "[client:fofb_ctrl]: halcs_set_bpm_id failed\n"); goto err_halcs_exit; } + + uint32_t time_frame_len = 0; + if (time_frame_len_str != NULL) { + time_frame_len = strtoul (time_frame_len_str, NULL, 10); + + fprintf (stdout, "[client:fofb_ctrl]: time_frame_len = 0x%08X\n", time_frame_len); + err = halcs_set_fofb_ctrl_time_frame_len (halcs_client, service, time_frame_len); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_set_time_frame_len failed\n"); + goto err_halcs_exit; + } } /* At the end of all register set we need to call acq_part funcion @@ -177,6 +196,8 @@ int main (int argc, char *argv []) /* Try to read up until the point where the error occurs, anyway */ halcs_set_fofb_ctrl_act_part (halcs_client, service, 0x1); err_halcs_client_new: + free (time_frame_len_str); + time_frame_len_str = NULL; free (bpm_id_str); bpm_id_str = NULL; free (board_number_str); From aa95595105f3ddffa5276dda11242d48a77491d9 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Mon, 8 Feb 2021 23:41:48 -0300 Subject: [PATCH 14/40] examples/*/fofb_ctrl: add bpm_id readbck parameter --- examples/src/fofb_ctrl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/src/fofb_ctrl.c b/examples/src/fofb_ctrl.c index d081475d..143a286a 100644 --- a/examples/src/fofb_ctrl.c +++ b/examples/src/fofb_ctrl.c @@ -162,6 +162,16 @@ int main (int argc, char *argv []) goto err_halcs_exit; } + err = halcs_get_fofb_ctrl_bpm_id_rdback (halcs_client, service, &bpm_id); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_get_bpm_id_rdback failed\n"); + goto err_halcs_exit; + } + + fprintf (stdout, "[client:fofb_ctrl]: bpm_id_rdback = 0x%08X\n", bpm_id); + } + + uint32_t time_frame_len = 0; if (time_frame_len_str != NULL) { time_frame_len = strtoul (time_frame_len_str, NULL, 10); From 653e78d37083c67ac79433712c763ee344c51fb1 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Tue, 9 Feb 2021 09:52:22 -0300 Subject: [PATCH 15/40] src/client: add missing fofb_ctrl definitions in Makefile --- src/client/Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client/Makefile b/src/client/Makefile index 808e3703..e3e846fe 100644 --- a/src/client/Makefile +++ b/src/client/Makefile @@ -123,7 +123,8 @@ OBJS_EXTERNAL = $(SMIO_TABLE_SRC_DIR)/sm_io_codes.o \ $(SMIO_TABLE_SRC_DIR)/modules/init/sm_io_init_exports.o \ $(SMIO_TABLE_SRC_DIR)/modules/afc_mgmt/sm_io_afc_mgmt_exports.o \ $(SMIO_TABLE_SRC_DIR)/modules/tim_rcv/sm_io_tim_rcv_exports.o \ - $(SMIO_TABLE_SRC_DIR)/modules/orbit_intlk/sm_io_orbit_intlk_exports.o + $(SMIO_TABLE_SRC_DIR)/modules/orbit_intlk/sm_io_orbit_intlk_exports.o \ + $(SMIO_TABLE_SRC_DIR)/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.o # Project boards boards_INCLUDE_DIRS = -I$(TOP)/include/boards/$(BOARD) @@ -154,6 +155,7 @@ INCLUDE_DIRS = -I. -Iinclude \ -I$(SMIO_SRC_DIR)/modules/afc_mgmt \ -I$(SMIO_SRC_DIR)/modules/tim_rcv \ -I$(SMIO_SRC_DIR)/modules/orbit_intlk \ + -I$(SMIO_SRC_DIR)/modules/fofb_ctrl \ -I$(SMIO_TABLE_DIR) \ -I$(SMIO_TABLE_SRC_DIR)/modules \ -I$(SMIO_TABLE_SRC_DIR)/modules/fmc130m_4ch \ @@ -176,6 +178,7 @@ INCLUDE_DIRS = -I. -Iinclude \ -I$(SMIO_TABLE_SRC_DIR)/modules/afc_mgmt \ -I$(SMIO_TABLE_SRC_DIR)/modules/tim_rcv \ -I$(SMIO_TABLE_SRC_DIR)/modules/orbit_intlk \ + -I$(SMIO_TABLE_SRC_DIR)/modules/fofb_ctrl \ -I${PREFIX}/include \ -I$(LIBERRHAND_DIR)/include \ -I$(LIBHUTILS_DIR)/include \ @@ -223,6 +226,7 @@ $(LIBNAME)_SMIO_CODES = \ $(SMIO_SRC_DIR)/modules/afc_mgmt/sm_io_afc_mgmt_codes.h \ $(SMIO_SRC_DIR)/modules/tim_rcv/sm_io_tim_rcv_codes.h \ $(SMIO_SRC_DIR)/modules/orbit_intlk/sm_io_orbit_intlk_codes.h \ + $(SMIO_SRC_DIR)/modules/fofb_ctrl/sm_io_fofb_ctrl_codes.h \ $(SMIO_TABLE_DIR)/sm_io_codes.h $(LIBNAME)_SMIO_EXPORTS = \ @@ -244,7 +248,8 @@ $(LIBNAME)_SMIO_EXPORTS = \ $(SMIO_TABLE_SRC_DIR)/modules/init/sm_io_init_exports.h \ $(SMIO_TABLE_SRC_DIR)/modules/afc_mgmt/sm_io_afc_mgmt_exports.h \ $(SMIO_TABLE_SRC_DIR)/modules/tim_rcv/sm_io_tim_rcv_exports.h \ - $(SMIO_TABLE_SRC_DIR)/modules/orbit_intlk/sm_io_orbit_intlk_exports.h + $(SMIO_TABLE_SRC_DIR)/modules/orbit_intlk/sm_io_orbit_intlk_exports.h \ + $(SMIO_TABLE_SRC_DIR)/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.h # Copy specific acq_chan.h defintions according to the BOARD MACRO $(LIBNAME)_ACQ_HEADERS_BASENAME = acq_chan From 98da495c410fdc6486a5cdd6298fda8ef51be56c Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Tue, 9 Feb 2021 10:53:21 -0300 Subject: [PATCH 16/40] examples/*/fofb_ctrl: add link_partners ID functionality --- examples/src/fofb_ctrl.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/examples/src/fofb_ctrl.c b/examples/src/fofb_ctrl.c index 143a286a..44f92392 100644 --- a/examples/src/fofb_ctrl.c +++ b/examples/src/fofb_ctrl.c @@ -28,10 +28,11 @@ static struct option long_options[] = {"bpm_id", required_argument, NULL, 't'}, {"time_frame_len", required_argument, NULL, 'f'}, {"firmware_ver", no_argument, NULL, 'c'}, + {"link_partners", no_argument, NULL, 'l'}, {NULL, 0, NULL, 0} }; -static const char* shortopt = "hb:vo:s:t:f:c"; +static const char* shortopt = "hb:vo:s:t:f:cl"; void print_help (char *program_name) { @@ -47,7 +48,8 @@ void print_help (char *program_name) " -t --bpm_id BPM ID\n" " -f --time_frame_len \n" " Timeframe length\n" - " -c --firmware_ver Firmware version\n", + " -c --firmware_ver Firmware version\n" + " -l --link_partners Link partners ID\n", program_name); } @@ -55,6 +57,7 @@ int main (int argc, char *argv []) { int verbose = 0; int firmware_ver = 0; + int link_partners = 0; char *broker_endp = NULL; char *board_number_str = NULL; char *halcs_number_str = NULL; @@ -99,6 +102,10 @@ int main (int argc, char *argv []) firmware_ver = 1; break; + case 'l': + link_partners = 1; + break; + case '?': fprintf (stderr, "[client:fofb_ctrl] Option not recognized or missing argument\n"); print_help (argv [0]); @@ -202,6 +209,23 @@ int main (int argc, char *argv []) fprintf (stdout, "[client:fofb_ctrl]: firmware_ver = 0x%08X\n", firmware_ver_get); } + uint32_t link_partners_get[4] = {0}; + if (link_partners) { + err = halcs_get_fofb_ctrl_link_partner_1 (halcs_client, service, &link_partners_get[0]); + err |= halcs_get_fofb_ctrl_link_partner_2 (halcs_client, service, &link_partners_get[1]); + err |= halcs_get_fofb_ctrl_link_partner_3 (halcs_client, service, &link_partners_get[2]); + err |= halcs_get_fofb_ctrl_link_partner_4 (halcs_client, service, &link_partners_get[3]); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_get_link_partner_X failed\n"); + goto err_halcs_exit; + } + + fprintf (stdout, "[client:fofb_ctrl]: link_partner_1 = %u\n", link_partners_get[0]); + fprintf (stdout, "[client:fofb_ctrl]: link_partner_2 = %u\n", link_partners_get[1]); + fprintf (stdout, "[client:fofb_ctrl]: link_partner_3 = %u\n", link_partners_get[2]); + fprintf (stdout, "[client:fofb_ctrl]: link_partner_4 = %u\n", link_partners_get[3]); + } + err_halcs_exit: /* Try to read up until the point where the error occurs, anyway */ halcs_set_fofb_ctrl_act_part (halcs_client, service, 0x1); From 2a957cd224d393dfed17be28673d43f1fe6a479d Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Tue, 9 Feb 2021 12:50:13 -0300 Subject: [PATCH 17/40] examples/*/fofb_ctrl: add cc_enable functionality --- examples/src/fofb_ctrl.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/examples/src/fofb_ctrl.c b/examples/src/fofb_ctrl.c index 44f92392..74fe0ef7 100644 --- a/examples/src/fofb_ctrl.c +++ b/examples/src/fofb_ctrl.c @@ -27,12 +27,13 @@ static struct option long_options[] = {"boardslot", required_argument, NULL, 'o'}, {"bpm_id", required_argument, NULL, 't'}, {"time_frame_len", required_argument, NULL, 'f'}, + {"cc_enable", required_argument, NULL, 'e'}, {"firmware_ver", no_argument, NULL, 'c'}, {"link_partners", no_argument, NULL, 'l'}, {NULL, 0, NULL, 0} }; -static const char* shortopt = "hb:vo:s:t:f:cl"; +static const char* shortopt = "hb:vo:s:t:f:e:cl"; void print_help (char *program_name) { @@ -48,6 +49,8 @@ void print_help (char *program_name) " -t --bpm_id BPM ID\n" " -f --time_frame_len \n" " Timeframe length\n" + " -e --cc_enable \n" + " CC enable\n" " -c --firmware_ver Firmware version\n" " -l --link_partners Link partners ID\n", program_name); @@ -63,6 +66,7 @@ int main (int argc, char *argv []) char *halcs_number_str = NULL; char *bpm_id_str = NULL; char *time_frame_len_str = NULL; + char *cc_enable_str = NULL; int opt; while ((opt = getopt_long (argc, argv, shortopt, long_options, NULL)) != -1) { @@ -98,6 +102,10 @@ int main (int argc, char *argv []) time_frame_len_str = strdup (optarg); break; + case 'e': + cc_enable_str = strdup (optarg); + break; + case 'c': firmware_ver = 1; break; @@ -191,6 +199,22 @@ int main (int argc, char *argv []) } } + uint32_t cc_enable = 0; + if (cc_enable_str != NULL) { + cc_enable = strtoul (cc_enable_str, NULL, 10); + if (cc_enable != 0 && cc_enable != 1) { + fprintf (stderr, "[client:fofb_ctrl]: Invalid cc_enable argument\n"); + goto err_halcs_exit; + } + + fprintf (stdout, "[client:fofb_ctrl]: cc_enable = 0x%08X\n", cc_enable); + err = halcs_set_fofb_ctrl_cc_enable (halcs_client, service, cc_enable); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_set_cc_enable failed\n"); + goto err_halcs_exit; + } + } + /* At the end of all register set we need to call acq_part funcion * to trigger FOFB ram readout by the device */ err = halcs_set_fofb_ctrl_act_part (halcs_client, service, 0x1); @@ -230,6 +254,8 @@ int main (int argc, char *argv []) /* Try to read up until the point where the error occurs, anyway */ halcs_set_fofb_ctrl_act_part (halcs_client, service, 0x1); err_halcs_client_new: + free (cc_enable_str); + cc_enable_str = NULL; free (time_frame_len_str); time_frame_len_str = NULL; free (bpm_id_str); From c1b547f7f978dd930e39fd50368d44bf2ac26a4f Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Thu, 11 Feb 2021 14:33:49 -0300 Subject: [PATCH 18/40] examples/*/trigger: add rcv/transm counters get --- examples/src/trigger.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/examples/src/trigger.c b/examples/src/trigger.c index ddde5578..5d6568fe 100644 --- a/examples/src/trigger.c +++ b/examples/src/trigger.c @@ -30,8 +30,10 @@ static struct option long_options[] = {"channumber", required_argument, NULL, 'c'}, {"rcvsrc", required_argument, NULL, 'r'}, {"rcvsel", required_argument, NULL, 'p'}, + {"rcvcount", no_argument, NULL, 'a'}, {"transmsrc", required_argument, NULL, 't'}, {"transsel", required_argument, NULL, 'u'}, + {"transmcount", no_argument, NULL, 'e'}, {"rcvlen", required_argument, NULL, 'l'}, {"trnlen", required_argument, NULL, 'm'}, {"dir", required_argument, NULL, 'd'}, @@ -39,7 +41,7 @@ static struct option long_options[] = {NULL, 0, NULL, 0} }; -static const char* shortopt = "hb:vo:s:c:r:p:t:u:l:m:d:x:"; +static const char* shortopt = "hb:vo:s:c:r:p:at:u:el:m:d:x:"; void print_help (char *program_name) { @@ -63,8 +65,10 @@ void print_help (char *program_name) " 17 -> Swithcing Clock]\n" " -r --rcvsrc \n" " -p --rcvsel \n" + " -a --rcvcount Receiver pulse counter\n" " -t --transmsrc \n" " -u --transmsel \n" + " -e --transmcount Transmitter pulse counter\n" " -l --rcvlen \n" " -m --trnlen \n" @@ -86,6 +90,7 @@ int main (int argc, char *argv []) int rcvsrc_sel = 0; char *rcvsel_str = NULL; int rcvsel_sel = 0; + int rcvcount = 0; char *transmsrc_str = NULL; int transmsrc_sel = 0; char *transmsel_str = NULL; @@ -94,6 +99,7 @@ int main (int argc, char *argv []) int rcvlen_sel = 0; char *trnlen_str = NULL; int trnlen_sel = 0; + int transmcount = 0; char *dir_str = NULL; int dir_sel = 0; char *dirpol_str = NULL; @@ -140,6 +146,10 @@ int main (int argc, char *argv []) rcvsel_sel = 1; break; + case 'a': + rcvcount = 1; + break; + case 't': transmsrc_str = strdup (optarg); transmsrc_sel = 1; @@ -150,6 +160,10 @@ int main (int argc, char *argv []) transmsel_sel = 1; break; + case 'e': + transmcount = 1; + break; + case 'l': rcvlen_str = strdup (optarg); rcvlen_sel = 1; @@ -284,6 +298,17 @@ int main (int argc, char *argv []) } } + if (rcvcount == 1) { + uint32_t arg = 0; + halcs_client_err_e err = halcs_get_trigger_count_rcv (halcs_client, service_iface, chan, &arg); + + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:trigger]: halcs_get_trigger_count_rcv failed\n"); + goto err_halcs_set; + } + printf ("[client:trigger]: halcs_get_trigger_count_rcv: %u\n", arg); + } + uint32_t transmsrc = 0; if (transmsrc_sel == 1) { transmsrc = strtoul (transmsrc_str, NULL, 10); @@ -304,6 +329,17 @@ int main (int argc, char *argv []) } } + if (transmcount == 1) { + uint32_t arg = 0; + halcs_client_err_e err = halcs_get_trigger_count_transm (halcs_client, service_iface, chan, &arg); + + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:trigger]: halcs_get_trigger_count_transm failed\n"); + goto err_halcs_set; + } + printf ("[client:trigger]: halcs_get_trigger_count_transm: %u\n", arg); + } + uint32_t rcvlen = 0; if (rcvlen_sel == 1) { rcvlen = strtoul (rcvlen_str, NULL, 10); From 2559683c3d53ab51562f2fc85987d50f57adb022 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Thu, 11 Feb 2021 14:34:09 -0300 Subject: [PATCH 19/40] examples/*/trigger: fix trivial indentation on option table --- examples/src/trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/src/trigger.c b/examples/src/trigger.c index 5d6568fe..297154fb 100644 --- a/examples/src/trigger.c +++ b/examples/src/trigger.c @@ -25,7 +25,7 @@ static struct option long_options[] = {"help", no_argument, NULL, 'h'}, {"brokerendp", required_argument, NULL, 'b'}, {"verbose", no_argument, NULL, 'v'}, - {"halcsnumber", required_argument, NULL, 's'}, + {"halcsnumber", required_argument, NULL, 's'}, {"boardslot", required_argument, NULL, 'o'}, {"channumber", required_argument, NULL, 'c'}, {"rcvsrc", required_argument, NULL, 'r'}, From 2df863a3288e9b0a1f8f19b22ba2d3f29684af6b Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Thu, 11 Feb 2021 14:34:32 -0300 Subject: [PATCH 20/40] examples/*/trigger: fix print status messages to stdout, not stderr --- examples/src/trigger.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/src/trigger.c b/examples/src/trigger.c index 297154fb..bd69750f 100644 --- a/examples/src/trigger.c +++ b/examples/src/trigger.c @@ -383,21 +383,21 @@ int main (int argc, char *argv []) /* Read all parameters from this channel */ uint32_t arg = 0; halcs_get_trigger_rcv_src (halcs_client, service_mux, chan, &arg); - fprintf (stderr, "[client:trigger]: halcs_get_trigger_rcv_src: %u\n", arg); + printf ("[client:trigger]: halcs_get_trigger_rcv_src: %u\n", arg); halcs_get_trigger_rcv_in_sel (halcs_client, service_mux, chan, &arg); - fprintf (stderr, "[client:trigger]: halcs_get_trigger_rcv_in_sel: %u\n", arg); + printf ("[client:trigger]: halcs_get_trigger_rcv_in_sel: %u\n", arg); halcs_get_trigger_transm_src (halcs_client, service_mux, chan, &arg); - fprintf (stderr, "[client:trigger]: halcs_get_trigger_transm_src: %u\n", arg); + printf ("[client:trigger]: halcs_get_trigger_transm_src: %u\n", arg); halcs_get_trigger_transm_out_sel (halcs_client, service_mux, chan, &arg); - fprintf (stderr, "[client:trigger]: halcs_get_trigger_transm_out_sel: %u\n", arg); + printf ("[client:trigger]: halcs_get_trigger_transm_out_sel: %u\n", arg); halcs_get_trigger_rcv_len (halcs_client, service_iface, chan, &arg); - fprintf (stderr, "[client:trigger]: halcs_get_trigger_rcv_len: %u\n", arg); + printf ("[client:trigger]: halcs_get_trigger_rcv_len: %u\n", arg); halcs_get_trigger_transm_len (halcs_client, service_iface, chan, &arg); - fprintf (stderr, "[client:trigger]: halcs_get_trigger_transm_len: %u\n", arg); + printf ("[client:trigger]: halcs_get_trigger_transm_len: %u\n", arg); halcs_get_trigger_dir (halcs_client, service_iface, chan, &arg); - fprintf (stderr, "[client:trigger]: halcs_get_trigger_dir: %u\n", arg); + printf ("[client:trigger]: halcs_get_trigger_dir: %u\n", arg); halcs_get_trigger_dir_pol (halcs_client, service_iface, chan, &arg); - fprintf (stderr, "[client:trigger]: halcs_get_trigger_dir_pol: %u\n", arg); + printf ("[client:trigger]: halcs_get_trigger_dir_pol: %u\n", arg); } err_halcs_set: From e94e684a7c091acfac0a7f0fff22c3d9620be0d1 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Thu, 11 Feb 2021 15:04:40 -0300 Subject: [PATCH 21/40] examples/*/trigger: fix getting parameters only when asked --- examples/src/trigger.c | 51 ++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/examples/src/trigger.c b/examples/src/trigger.c index bd69750f..8de9fc1c 100644 --- a/examples/src/trigger.c +++ b/examples/src/trigger.c @@ -286,6 +286,10 @@ int main (int argc, char *argv []) fprintf (stderr, "[client:trigger]: halcs_set_trigger_rcv_src failed\n"); goto err_halcs_set; } + + uint32_t arg = 0; + halcs_get_trigger_rcv_src (halcs_client, service_mux, chan, &arg); + printf ("[client:trigger]: halcs_get_trigger_rcv_src: %u\n", arg); } uint32_t rcvsel = 0; @@ -296,6 +300,10 @@ int main (int argc, char *argv []) fprintf (stderr, "[client:trigger]: halcs_set_trigger_rcv_sel failed\n"); goto err_halcs_set; } + + uint32_t arg = 0; + halcs_get_trigger_rcv_in_sel (halcs_client, service_mux, chan, &arg); + printf ("[client:trigger]: halcs_get_trigger_rcv_in_sel: %u\n", arg); } if (rcvcount == 1) { @@ -317,6 +325,10 @@ int main (int argc, char *argv []) fprintf (stderr, "[client:trigger]: halcs_set_trigger_transm_sel failed\n"); goto err_halcs_set; } + + uint32_t arg = 0; + halcs_get_trigger_transm_src (halcs_client, service_mux, chan, &arg); + printf ("[client:trigger]: halcs_get_trigger_transm_src: %u\n", arg); } uint32_t transmsel = 0; @@ -327,6 +339,10 @@ int main (int argc, char *argv []) fprintf (stderr, "[client:trigger]: halcs_set_trigger_transm_sel failed\n"); goto err_halcs_set; } + + uint32_t arg = 0; + halcs_get_trigger_transm_out_sel (halcs_client, service_mux, chan, &arg); + printf ("[client:trigger]: halcs_get_trigger_transm_out_sel: %u\n", arg); } if (transmcount == 1) { @@ -348,6 +364,10 @@ int main (int argc, char *argv []) fprintf (stderr, "[client:trigger]: halcs_set_trigger_rcv_len failed\n"); goto err_halcs_set; } + + uint32_t arg = 0; + halcs_get_trigger_rcv_len (halcs_client, service_iface, chan, &arg); + printf ("[client:trigger]: halcs_get_trigger_rcv_len: %u\n", arg); } uint32_t trnlen = 0; @@ -358,6 +378,10 @@ int main (int argc, char *argv []) fprintf (stderr, "[client:trigger]: halcs_set_trigger_transm_len failed\n"); goto err_halcs_set; } + + uint32_t arg = 0; + halcs_get_trigger_transm_len (halcs_client, service_iface, chan, &arg); + printf ("[client:trigger]: halcs_get_trigger_transm_len: %u\n", arg); } uint32_t dir = 0; @@ -368,6 +392,10 @@ int main (int argc, char *argv []) fprintf (stderr, "[client:trigger]: halcs_set_trigger_dir failed\n"); goto err_halcs_set; } + + uint32_t arg = 0; + halcs_get_trigger_dir (halcs_client, service_iface, chan, &arg); + printf ("[client:trigger]: halcs_get_trigger_dir: %u\n", arg); } uint32_t dirpol = 0; @@ -378,26 +406,11 @@ int main (int argc, char *argv []) fprintf (stderr, "[client:trigger]: halcs_set_trigger_dir_pol failed\n"); goto err_halcs_set; } - } - /* Read all parameters from this channel */ - uint32_t arg = 0; - halcs_get_trigger_rcv_src (halcs_client, service_mux, chan, &arg); - printf ("[client:trigger]: halcs_get_trigger_rcv_src: %u\n", arg); - halcs_get_trigger_rcv_in_sel (halcs_client, service_mux, chan, &arg); - printf ("[client:trigger]: halcs_get_trigger_rcv_in_sel: %u\n", arg); - halcs_get_trigger_transm_src (halcs_client, service_mux, chan, &arg); - printf ("[client:trigger]: halcs_get_trigger_transm_src: %u\n", arg); - halcs_get_trigger_transm_out_sel (halcs_client, service_mux, chan, &arg); - printf ("[client:trigger]: halcs_get_trigger_transm_out_sel: %u\n", arg); - halcs_get_trigger_rcv_len (halcs_client, service_iface, chan, &arg); - printf ("[client:trigger]: halcs_get_trigger_rcv_len: %u\n", arg); - halcs_get_trigger_transm_len (halcs_client, service_iface, chan, &arg); - printf ("[client:trigger]: halcs_get_trigger_transm_len: %u\n", arg); - halcs_get_trigger_dir (halcs_client, service_iface, chan, &arg); - printf ("[client:trigger]: halcs_get_trigger_dir: %u\n", arg); - halcs_get_trigger_dir_pol (halcs_client, service_iface, chan, &arg); - printf ("[client:trigger]: halcs_get_trigger_dir_pol: %u\n", arg); + uint32_t arg = 0; + halcs_get_trigger_dir_pol (halcs_client, service_iface, chan, &arg); + printf ("[client:trigger]: halcs_get_trigger_dir_pol: %u\n", arg); + } } err_halcs_set: From 31c76a93ac5ee791a1981c741b438f54b20a201c Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Thu, 11 Feb 2021 15:05:32 -0300 Subject: [PATCH 22/40] examples/*/trigger: fix "transsel" long option to "transmsel" --- examples/src/trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/src/trigger.c b/examples/src/trigger.c index 8de9fc1c..c9c9a43e 100644 --- a/examples/src/trigger.c +++ b/examples/src/trigger.c @@ -32,7 +32,7 @@ static struct option long_options[] = {"rcvsel", required_argument, NULL, 'p'}, {"rcvcount", no_argument, NULL, 'a'}, {"transmsrc", required_argument, NULL, 't'}, - {"transsel", required_argument, NULL, 'u'}, + {"transmsel", required_argument, NULL, 'u'}, {"transmcount", no_argument, NULL, 'e'}, {"rcvlen", required_argument, NULL, 'l'}, {"trnlen", required_argument, NULL, 'm'}, From b8ffe3d7e1e50e19c9b8939372f2184e367ae116 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Tue, 16 Feb 2021 10:53:44 -0300 Subject: [PATCH 23/40] examples/*/fofb_ctrl: add rx/tx packet counters --- examples/src/fofb_ctrl.c | 55 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/examples/src/fofb_ctrl.c b/examples/src/fofb_ctrl.c index 74fe0ef7..65380813 100644 --- a/examples/src/fofb_ctrl.c +++ b/examples/src/fofb_ctrl.c @@ -30,10 +30,12 @@ static struct option long_options[] = {"cc_enable", required_argument, NULL, 'e'}, {"firmware_ver", no_argument, NULL, 'c'}, {"link_partners", no_argument, NULL, 'l'}, + {"rx_pck_cnt", no_argument, NULL, 'r'}, + {"tx_pck_cnt", no_argument, NULL, 'x'}, {NULL, 0, NULL, 0} }; -static const char* shortopt = "hb:vo:s:t:f:e:cl"; +static const char* shortopt = "hb:vo:s:t:f:e:clrx"; void print_help (char *program_name) { @@ -49,10 +51,11 @@ void print_help (char *program_name) " -t --bpm_id BPM ID\n" " -f --time_frame_len \n" " Timeframe length\n" - " -e --cc_enable \n" - " CC enable\n" + " -e --cc_enable CC enable\n" " -c --firmware_ver Firmware version\n" - " -l --link_partners Link partners ID\n", + " -l --link_partners Link partners ID\n" + " -r --rx_pck_cnt RX packet count\n" + " -x --tx_pck_cnt TX packet count\n", program_name); } @@ -61,6 +64,8 @@ int main (int argc, char *argv []) int verbose = 0; int firmware_ver = 0; int link_partners = 0; + int rx_pck_cnt = 0; + int tx_pck_cnt = 0; char *broker_endp = NULL; char *board_number_str = NULL; char *halcs_number_str = NULL; @@ -114,6 +119,14 @@ int main (int argc, char *argv []) link_partners = 1; break; + case 'r': + rx_pck_cnt = 1; + break; + + case 'x': + tx_pck_cnt = 1; + break; + case '?': fprintf (stderr, "[client:fofb_ctrl] Option not recognized or missing argument\n"); print_help (argv [0]); @@ -250,6 +263,40 @@ int main (int argc, char *argv []) fprintf (stdout, "[client:fofb_ctrl]: link_partner_4 = %u\n", link_partners_get[3]); } + uint32_t rx_pck_cnt_get[4] = {0}; + if (rx_pck_cnt) { + err = halcs_get_fofb_ctrl_rx_pck_cnt_1 (halcs_client, service, &rx_pck_cnt_get[0]); + err |= halcs_get_fofb_ctrl_rx_pck_cnt_2 (halcs_client, service, &rx_pck_cnt_get[1]); + err |= halcs_get_fofb_ctrl_rx_pck_cnt_3 (halcs_client, service, &rx_pck_cnt_get[2]); + err |= halcs_get_fofb_ctrl_rx_pck_cnt_4 (halcs_client, service, &rx_pck_cnt_get[3]); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_get_rx_pck_cnt_X failed\n"); + goto err_halcs_exit; + } + + fprintf (stdout, "[client:fofb_ctrl]: rx_pck_cnt_1 = %u\n", rx_pck_cnt_get[0]); + fprintf (stdout, "[client:fofb_ctrl]: rx_pck_cnt_2 = %u\n", rx_pck_cnt_get[1]); + fprintf (stdout, "[client:fofb_ctrl]: rx_pck_cnt_3 = %u\n", rx_pck_cnt_get[2]); + fprintf (stdout, "[client:fofb_ctrl]: rx_pck_cnt_4 = %u\n", rx_pck_cnt_get[3]); + } + + uint32_t tx_pck_cnt_get[4] = {0}; + if (tx_pck_cnt) { + err = halcs_get_fofb_ctrl_tx_pck_cnt_1 (halcs_client, service, &tx_pck_cnt_get[0]); + err |= halcs_get_fofb_ctrl_tx_pck_cnt_2 (halcs_client, service, &tx_pck_cnt_get[1]); + err |= halcs_get_fofb_ctrl_tx_pck_cnt_3 (halcs_client, service, &tx_pck_cnt_get[2]); + err |= halcs_get_fofb_ctrl_tx_pck_cnt_4 (halcs_client, service, &tx_pck_cnt_get[3]); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_get_tx_pck_cnt_X failed\n"); + goto err_halcs_exit; + } + + fprintf (stdout, "[client:fofb_ctrl]: tx_pck_cnt_1 = %u\n", tx_pck_cnt_get[0]); + fprintf (stdout, "[client:fofb_ctrl]: tx_pck_cnt_2 = %u\n", tx_pck_cnt_get[1]); + fprintf (stdout, "[client:fofb_ctrl]: tx_pck_cnt_3 = %u\n", tx_pck_cnt_get[2]); + fprintf (stdout, "[client:fofb_ctrl]: tx_pck_cnt_4 = %u\n", tx_pck_cnt_get[3]); + } + err_halcs_exit: /* Try to read up until the point where the error occurs, anyway */ halcs_set_fofb_ctrl_act_part (halcs_client, service, 0x1); From a133cf4948eab5a81cdae7f69860a8973ff18e41 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Mon, 22 Feb 2021 14:40:54 -0300 Subject: [PATCH 24/40] examples/*/fofb_ctrl.c: add bpm/timeframe/fod_process_time stats --- examples/src/fofb_ctrl.c | 58 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/examples/src/fofb_ctrl.c b/examples/src/fofb_ctrl.c index 65380813..b45184e1 100644 --- a/examples/src/fofb_ctrl.c +++ b/examples/src/fofb_ctrl.c @@ -32,10 +32,13 @@ static struct option long_options[] = {"link_partners", no_argument, NULL, 'l'}, {"rx_pck_cnt", no_argument, NULL, 'r'}, {"tx_pck_cnt", no_argument, NULL, 'x'}, + {"fod_process_time", no_argument, NULL, 'y'}, + {"bpm_cnt", no_argument, NULL, 'k'}, + {"timeframe_cnt", no_argument, NULL, 'w'}, {NULL, 0, NULL, 0} }; -static const char* shortopt = "hb:vo:s:t:f:e:clrx"; +static const char* shortopt = "hb:vo:s:t:f:e:clrxykw"; void print_help (char *program_name) { @@ -55,7 +58,10 @@ void print_help (char *program_name) " -c --firmware_ver Firmware version\n" " -l --link_partners Link partners ID\n" " -r --rx_pck_cnt RX packet count\n" - " -x --tx_pck_cnt TX packet count\n", + " -x --tx_pck_cnt TX packet count\n" + " -y --fod_process_time FOD process time [in userclk cycles]\n" + " -k --bpm_cnt BPM count in current timeframe\n" + " -w --timeframe_cnt Total number of timeframes\n", program_name); } @@ -66,6 +72,9 @@ int main (int argc, char *argv []) int link_partners = 0; int rx_pck_cnt = 0; int tx_pck_cnt = 0; + int fod_process_time = 0; + int bpm_cnt = 0; + int timeframe_cnt = 0; char *broker_endp = NULL; char *board_number_str = NULL; char *halcs_number_str = NULL; @@ -127,6 +136,18 @@ int main (int argc, char *argv []) tx_pck_cnt = 1; break; + case 'y': + fod_process_time = 1; + break; + + case 'k': + bpm_cnt = 1; + break; + + case 'w': + timeframe_cnt = 1; + break; + case '?': fprintf (stderr, "[client:fofb_ctrl] Option not recognized or missing argument\n"); print_help (argv [0]); @@ -297,6 +318,39 @@ int main (int argc, char *argv []) fprintf (stdout, "[client:fofb_ctrl]: tx_pck_cnt_4 = %u\n", tx_pck_cnt_get[3]); } + uint32_t fod_process_time_get = 0; + if (fod_process_time) { + err = halcs_get_fofb_ctrl_fod_process_time (halcs_client, service, &fod_process_time_get); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_get_fod_process_time failed\n"); + goto err_halcs_exit; + } + + fprintf (stdout, "[client:fofb_ctrl]: fod_process_time = %u usrclk cycles\n", fod_process_time_get); + } + + uint32_t bpm_cnt_get = 0; + if (bpm_cnt) { + err = halcs_get_fofb_ctrl_bpm_count (halcs_client, service, &bpm_cnt_get); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_get_bpm_count failed\n"); + goto err_halcs_exit; + } + + fprintf (stdout, "[client:fofb_ctrl]: bpm_cnt = %u\n", bpm_cnt_get); + } + + uint32_t timeframe_cnt_get = 0; + if (timeframe_cnt) { + err = halcs_get_fofb_ctrl_time_frame_count (halcs_client, service, &timeframe_cnt_get); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_get_time_frame_count failed\n"); + goto err_halcs_exit; + } + + fprintf (stdout, "[client:fofb_ctrl]: timeframe_cnt = %u\n", timeframe_cnt_get); + } + err_halcs_exit: /* Try to read up until the point where the error occurs, anyway */ halcs_set_fofb_ctrl_act_part (halcs_client, service, 0x1); From d1842912407b0558798d1738d5086ec34a640a57 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Mon, 22 Feb 2021 16:53:11 -0300 Subject: [PATCH 25/40] examples/*/fofb_ctrl.c: add soft/hard/frame error stats --- examples/src/fofb_ctrl.c | 74 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/examples/src/fofb_ctrl.c b/examples/src/fofb_ctrl.c index b45184e1..18b75209 100644 --- a/examples/src/fofb_ctrl.c +++ b/examples/src/fofb_ctrl.c @@ -30,6 +30,9 @@ static struct option long_options[] = {"cc_enable", required_argument, NULL, 'e'}, {"firmware_ver", no_argument, NULL, 'c'}, {"link_partners", no_argument, NULL, 'l'}, + {"soft_err_cnt", no_argument, NULL, 'm'}, + {"hard_err_cnt", no_argument, NULL, 'n'}, + {"frame_err_cnt", no_argument, NULL, 'j'}, {"rx_pck_cnt", no_argument, NULL, 'r'}, {"tx_pck_cnt", no_argument, NULL, 'x'}, {"fod_process_time", no_argument, NULL, 'y'}, @@ -38,7 +41,7 @@ static struct option long_options[] = {NULL, 0, NULL, 0} }; -static const char* shortopt = "hb:vo:s:t:f:e:clrxykw"; +static const char* shortopt = "hb:vo:s:t:f:e:clrxykwmnj"; void print_help (char *program_name) { @@ -57,6 +60,9 @@ void print_help (char *program_name) " -e --cc_enable CC enable\n" " -c --firmware_ver Firmware version\n" " -l --link_partners Link partners ID\n" + " -m --soft_err_cnt Number of soft errors\n" + " -n --hard_err_cnt Number of hard errors\n" + " -j --frame_err_cnt Link partners ID\n" " -r --rx_pck_cnt RX packet count\n" " -x --tx_pck_cnt TX packet count\n" " -y --fod_process_time FOD process time [in userclk cycles]\n" @@ -70,6 +76,9 @@ int main (int argc, char *argv []) int verbose = 0; int firmware_ver = 0; int link_partners = 0; + int soft_err_cnt = 0; + int hard_err_cnt = 0; + int frame_err_cnt = 0; int rx_pck_cnt = 0; int tx_pck_cnt = 0; int fod_process_time = 0; @@ -128,6 +137,18 @@ int main (int argc, char *argv []) link_partners = 1; break; + case 'm': + soft_err_cnt = 1; + break; + + case 'n': + hard_err_cnt = 1; + break; + + case 'j': + frame_err_cnt = 1; + break; + case 'r': rx_pck_cnt = 1; break; @@ -284,6 +305,57 @@ int main (int argc, char *argv []) fprintf (stdout, "[client:fofb_ctrl]: link_partner_4 = %u\n", link_partners_get[3]); } + uint32_t soft_err_cnt_get[4] = {0}; + if (soft_err_cnt) { + err = halcs_get_fofb_ctrl_soft_err_cnt_1 (halcs_client, service, &soft_err_cnt_get[0]); + err |= halcs_get_fofb_ctrl_soft_err_cnt_2 (halcs_client, service, &soft_err_cnt_get[1]); + err |= halcs_get_fofb_ctrl_soft_err_cnt_3 (halcs_client, service, &soft_err_cnt_get[2]); + err |= halcs_get_fofb_ctrl_soft_err_cnt_4 (halcs_client, service, &soft_err_cnt_get[3]); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_get_soft_err_cnt_X failed\n"); + goto err_halcs_exit; + } + + fprintf (stdout, "[client:fofb_ctrl]: soft_err_cnt_1 = %u\n", soft_err_cnt_get[0]); + fprintf (stdout, "[client:fofb_ctrl]: soft_err_cnt_2 = %u\n", soft_err_cnt_get[1]); + fprintf (stdout, "[client:fofb_ctrl]: soft_err_cnt_3 = %u\n", soft_err_cnt_get[2]); + fprintf (stdout, "[client:fofb_ctrl]: soft_err_cnt_4 = %u\n", soft_err_cnt_get[3]); + } + + uint32_t hard_err_cnt_get[4] = {0}; + if (hard_err_cnt) { + err = halcs_get_fofb_ctrl_hard_err_cnt_1 (halcs_client, service, &hard_err_cnt_get[0]); + err |= halcs_get_fofb_ctrl_hard_err_cnt_2 (halcs_client, service, &hard_err_cnt_get[1]); + err |= halcs_get_fofb_ctrl_hard_err_cnt_3 (halcs_client, service, &hard_err_cnt_get[2]); + err |= halcs_get_fofb_ctrl_hard_err_cnt_4 (halcs_client, service, &hard_err_cnt_get[3]); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_get_hard_err_cnt_X failed\n"); + goto err_halcs_exit; + } + + fprintf (stdout, "[client:fofb_ctrl]: hard_err_cnt_1 = %u\n", hard_err_cnt_get[0]); + fprintf (stdout, "[client:fofb_ctrl]: hard_err_cnt_2 = %u\n", hard_err_cnt_get[1]); + fprintf (stdout, "[client:fofb_ctrl]: hard_err_cnt_3 = %u\n", hard_err_cnt_get[2]); + fprintf (stdout, "[client:fofb_ctrl]: hard_err_cnt_4 = %u\n", hard_err_cnt_get[3]); + } + + uint32_t frame_err_cnt_get[4] = {0}; + if (frame_err_cnt) { + err = halcs_get_fofb_ctrl_frame_err_cnt_1 (halcs_client, service, &frame_err_cnt_get[0]); + err |= halcs_get_fofb_ctrl_frame_err_cnt_2 (halcs_client, service, &frame_err_cnt_get[1]); + err |= halcs_get_fofb_ctrl_frame_err_cnt_3 (halcs_client, service, &frame_err_cnt_get[2]); + err |= halcs_get_fofb_ctrl_frame_err_cnt_4 (halcs_client, service, &frame_err_cnt_get[3]); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:fofb_ctrl]: halcs_get_frame_err_cnt_X failed\n"); + goto err_halcs_exit; + } + + fprintf (stdout, "[client:fofb_ctrl]: frame_err_cnt_1 = %u\n", frame_err_cnt_get[0]); + fprintf (stdout, "[client:fofb_ctrl]: frame_err_cnt_2 = %u\n", frame_err_cnt_get[1]); + fprintf (stdout, "[client:fofb_ctrl]: frame_err_cnt_3 = %u\n", frame_err_cnt_get[2]); + fprintf (stdout, "[client:fofb_ctrl]: frame_err_cnt_4 = %u\n", frame_err_cnt_get[3]); + } + uint32_t rx_pck_cnt_get[4] = {0}; if (rx_pck_cnt) { err = halcs_get_fofb_ctrl_rx_pck_cnt_1 (halcs_client, service, &rx_pck_cnt_get[0]); From 5594bfd989dff99b60676b6b1a1bf8a7f8b1e44e Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Mon, 22 Feb 2021 21:51:18 -0300 Subject: [PATCH 26/40] include/hw: update FOFB CC registers per commit lnls-dig/fofb-ctrl-gw@d4ca631cce --- include/hw/__wb_fofb_cc_regs.h | 60 +++++++++++++++++++++++++++++++++- include/hw/wb_fofb_cc_regs.h | 44 +++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 1 deletion(-) diff --git a/include/hw/__wb_fofb_cc_regs.h b/include/hw/__wb_fofb_cc_regs.h index 986e4cec..49fd650d 100644 --- a/include/hw/__wb_fofb_cc_regs.h +++ b/include/hw/__wb_fofb_cc_regs.h @@ -10,6 +10,43 @@ #define FOFB_CC_REGS_CFG_VAL_CC_ENABLE 0x8UL #define FOFB_CC_REGS_CFG_VAL_TFS_OVERRIDE 0x10UL +/* FOFB CC Time-of-Arrival configuration register */ +#define FOFB_CC_REGS_TOA_CTL 0x4UL +#define FOFB_CC_REGS_TOA_CTL_RD_EN 0x1UL +#define FOFB_CC_REGS_TOA_CTL_RD_STR 0x2UL + +/* FOFB CC Time-of-Arrival data */ +#define FOFB_CC_REGS_TOA_DATA 0x8UL +#define FOFB_CC_REGS_TOA_DATA_VAL_MASK 0xffffffffUL +#define FOFB_CC_REGS_TOA_DATA_VAL_SHIFT 0 + +/* FOFB CC Received Buffer configuration register */ +#define FOFB_CC_REGS_RCB_CTL 0xcUL +#define FOFB_CC_REGS_RCB_CTL_RD_EN 0x1UL +#define FOFB_CC_REGS_RCB_CTL_RD_STR 0x2UL + +/* FOFB CC Received Buffer data */ +#define FOFB_CC_REGS_RCB_DATA 0x10UL +#define FOFB_CC_REGS_RCB_DATA_VAL_MASK 0xffffffffUL +#define FOFB_CC_REGS_RCB_DATA_VAL_SHIFT 0 + +/* FOFB CC X/Y buffer configuration register */ +#define FOFB_CC_REGS_XY_BUFF_CTL 0x14UL +#define FOFB_CC_REGS_XY_BUFF_CTL_UNUSED_MASK 0xffffUL +#define FOFB_CC_REGS_XY_BUFF_CTL_UNUSED_SHIFT 0 +#define FOFB_CC_REGS_XY_BUFF_CTL_ADDR_MASK 0xffff0000UL +#define FOFB_CC_REGS_XY_BUFF_CTL_ADDR_SHIFT 16 + +/* FOFB CC X/Y buffer MSB */ +#define FOFB_CC_REGS_XY_BUFF_DATA_MSB 0x18UL +#define FOFB_CC_REGS_XY_BUFF_DATA_MSB_VAL_MASK 0xffffffffUL +#define FOFB_CC_REGS_XY_BUFF_DATA_MSB_VAL_SHIFT 0 + +/* FOFB CC X/Y buffer LSB */ +#define FOFB_CC_REGS_XY_BUFF_DATA_LSB 0x1cUL +#define FOFB_CC_REGS_XY_BUFF_DATA_LSB_VAL_MASK 0xffffffffUL +#define FOFB_CC_REGS_XY_BUFF_DATA_LSB_VAL_SHIFT 0 + /* FOFB CC RAM for register map */ #define FOFB_CC_REGS_RAM_REG 0x2000UL #define FOFB_CC_REGS_RAM_REG_SIZE 4 /* 0x4 */ @@ -21,8 +58,29 @@ struct fofb_cc_regs { /* [0x0]: REG (rw) FOFB CC configuration register */ uint32_t cfg_val; + /* [0x4]: REG (rw) FOFB CC Time-of-Arrival configuration register */ + uint32_t toa_ctl; + + /* [0x8]: REG (rw) FOFB CC Time-of-Arrival data */ + uint32_t toa_data; + + /* [0xc]: REG (rw) FOFB CC Received Buffer configuration register */ + uint32_t rcb_ctl; + + /* [0x10]: REG (rw) FOFB CC Received Buffer data */ + uint32_t rcb_data; + + /* [0x14]: REG (rw) FOFB CC X/Y buffer configuration register */ + uint32_t xy_buff_ctl; + + /* [0x18]: REG (rw) FOFB CC X/Y buffer MSB */ + uint32_t xy_buff_data_msb; + + /* [0x1c]: REG (rw) FOFB CC X/Y buffer LSB */ + uint32_t xy_buff_data_lsb; + /* padding to: 2048 words */ - uint32_t __padding_0[2047]; + uint32_t __padding_0[2040]; /* [0x2000]: MEMORY FOFB CC RAM for register map */ struct ram_reg { diff --git a/include/hw/wb_fofb_cc_regs.h b/include/hw/wb_fofb_cc_regs.h index 5a777fc5..df61dfb0 100644 --- a/include/hw/wb_fofb_cc_regs.h +++ b/include/hw/wb_fofb_cc_regs.h @@ -34,6 +34,50 @@ #define FOFB_CC_CFG_VAL_CC_ENABLE FOFB_CC_REGS_CFG_VAL_CC_ENABLE #define FOFB_CC_CFG_VAL_TFS_OVERRIDE FOFB_CC_REGS_CFG_VAL_TFS_OVERRIDE +#define FOFB_CC_REG_TOA_CTL FOFB_CC_REGS_TOA_CTL + +/* Definitions for FOFB CC Time-of-Arrival configuration register */ +#define FOFB_CC_TOA_CTL_RD_EN FOFB_CC_REGS_TOA_CTL_RD_EN +#define FOFB_CC_TOA_CTL_RD_STR FOFB_CC_REGS_TOA_CTL_RD_STR + +#define FOFB_CC_REG_TOA_DATA FOFB_CC_REGS_TOA_DATA + +/* Definitions for FOFB CC Time-of-Arrival data */ +#define FOFB_CC_TOA_DATA_VAL_MASK FOFB_CC_REGS_TOA_DATA_VAL_MASK +#define FOFB_CC_TOA_DATA_VAL_SHIFT FOFB_CC_REGS_TOA_DATA_VAL_SHIFT + +#define FOFB_CC_REG_RCB_CTL FOFB_CC_REGS_RCB_CTL + +/* Definitions for FOFB CC Received Buffer configuration register */ +#define FOFB_CC_RCB_CTL_RD_EN FOFB_CC_REGS_RCB_CTL_RD_EN +#define FOFB_CC_RCB_CTL_RD_STR FOFB_CC_REGS_RCB_CTL_RD_STR + +#define FOFB_CC_REG_RCB_DATA FOFB_CC_REGS_RCB_DATA + +/* Definitions for FOFB CC Received Buffer data */ +#define FOFB_CC_RCB_DATA_VAL_MASK FOFB_CC_REGS_RCB_DATA_VAL_MASK +#define FOFB_CC_RCB_DATA_VAL_SHIFT FOFB_CC_REGS_RCB_DATA_VAL_SHIFT + +#define FOFB_CC_REG_XY_BUFF_CTL FOFB_CC_REGS_XY_BUFF_CTL + +/* Definitions for FOFB CC X/Y buffer configuration register */ +#define FOFB_CC_XY_BUFF_CTL_UNUSED_MASK FOFB_CC_REGS_XY_BUFF_CTL_UNUSED_MASK +#define FOFB_CC_XY_BUFF_CTL_UNUSED_SHIFT FOFB_CC_REGS_XY_BUFF_CTL_UNUSED_SHIFT +#define FOFB_CC_XY_BUFF_CTL_ADDR_MASK FOFB_CC_REGS_XY_BUFF_CTL_ADDR_MASK +#define FOFB_CC_XY_BUFF_CTL_ADDR_SHIFT FOFB_CC_REGS_XY_BUFF_CTL_ADDR_SHIFT + +#define FOFB_CC_REG_XY_BUFF_DATA_MSB FOFB_CC_REGS_XY_BUFF_DATA_MSB + +/* Definitions for FOFB CC X/Y buffer MSB */ +#define FOFB_CC_XY_BUFF_DATA_MSB_VAL_MASK FOFB_CC_REGS_XY_BUFF_DATA_MSB_VAL_MASK +#define FOFB_CC_XY_BUFF_DATA_MSB_VAL_SHIFT FOFB_CC_REGS_XY_BUFF_DATA_MSB_VAL_SHIFT + +#define FOFB_CC_REG_XY_BUFF_DATA_LSB FOFB_CC_REGS_XY_BUFF_DATA_LSB + +/* Definitions for FOFB CC X/Y buffer LSB */ +#define FOFB_CC_XY_BUFF_DATA_LSB_VAL_MASK FOFB_CC_REGS_XY_BUFF_DATA_LSB_VAL_MASK +#define FOFB_CC_XY_BUFF_DATA_LSB_VAL_SHIFT FOFB_CC_REGS_XY_BUFF_DATA_LSB_VAL_SHIFT + #define FOFB_CC_REGS_RAM_START (FOFB_CC_REGS_RAM_REG) /* RAM-based registers. Write from Bus, Read from Device */ From 64e924fef5abe9a6fee06ee961086ae9905cdaf7 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Fri, 5 Mar 2021 15:07:36 -0300 Subject: [PATCH 27/40] scripts: add FOFB module example/tests scripts We should probably move this out of here... --- examples/scripts/cfg_fofb.sh | 23 +++++++++++++++++ examples/scripts/reformat_fofb_packet.py | 33 ++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100755 examples/scripts/cfg_fofb.sh create mode 100755 examples/scripts/reformat_fofb_packet.py diff --git a/examples/scripts/cfg_fofb.sh b/examples/scripts/cfg_fofb.sh new file mode 100755 index 00000000..4f15e3d7 --- /dev/null +++ b/examples/scripts/cfg_fofb.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# This must follow the format "," +BOARDS="$1" + +SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +OLDIFS=$IFS; IFS=','; +# Separate "tuple" arguments with positional notation +set -- ${BOARDS}; +for board in ${BOARDS[*]}; do + printf "Configuring BPM board: %s\n" "${board}" + (cd build/ && ./examples/fofb_ctrl --brokerendp ipc:///tmp/malamute --boardslot ${board} --halcsnumber 0 --bpm_id ${board} --time_frame_len 10000 --cc_enable 0) + (cd build/ && ./examples/fofb_ctrl --brokerendp ipc:///tmp/malamute --boardslot ${board} --halcsnumber 1 --bpm_id ${board} --time_frame_len 10000 --cc_enable 0) + (cd build/ && ./examples/fofb_ctrl --brokerendp ipc:///tmp/malamute --boardslot ${board} --halcsnumber 0 --cc_enable 1) + (cd build/ && ./examples/fofb_ctrl --brokerendp ipc:///tmp/malamute --boardslot ${board} --halcsnumber 1 --cc_enable 1) + (cd build/ && ./examples/trigger --brokerendp ipc:///tmp/malamute --boardslot ${board} --halcsnumber 0 --channumber 1 --rcvsrc 0 --rcvsel 3) + (cd build/ && ./examples/trigger --brokerendp ipc:///tmp/malamute --boardslot ${board} --halcsnumber 1 --channumber 1 --rcvsrc 0 --rcvsel 3) +done; + +IFS=$OLDIFS; diff --git a/examples/scripts/reformat_fofb_packet.py b/examples/scripts/reformat_fofb_packet.py new file mode 100755 index 00000000..175f5e9c --- /dev/null +++ b/examples/scripts/reformat_fofb_packet.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +import sys +import re + +def conv_int32_to_uint32(x): + INT32_TO_UINT32 = (1 << 32) + INT32_SIGN_BIT = (1 << 31) + return x + INT32_TO_UINT32 if (x & INT32_SIGN_BIT) else x + +LINE_PATTERN = "[\t ]*(-?\d+)[\t ]*(-?\d+)[\t ]*(-?\d+)[\t ]*(-?\d+)" +p = re.compile(LINE_PATTERN) + +i = 0 +print("| {:8} | {:10} | {:8} | {:6} | {:^17} | {:^17} | {:10} |". + format("packet #", "tf_cntr_16", "tf_start", "bpm_id", "bpm_x", "bpm_y", "tf_cntr_32")) +for line in sys.stdin: + m = re.match(p, line) + atoms = [conv_int32_to_uint32(int(g)) for g in m.groups()] + tf_cntr_16_lsb = (atoms[3] & 0xFFFF0000) >> 16 + tf_start = (atoms[3] & 0x8000) >> 15 + bpm_id = (atoms[3] & 0x7FFF) + bpm_pos_x_16_msb = (atoms[2] & 0xFFFF0000) >> 16 + bpm_pos_x_16_lsb = (atoms[2] & 0xFFFF) + bpm_pos_y_16_msb = (atoms[1] & 0xFFFF0000) >> 16 + bpm_pos_y_16_lsb = (atoms[1] & 0xFFFF) + tf_cnrt_32 = atoms[0] + print("| {:<8} | {:<10} | {:<8} | {:<6} | {:<8} | {:<8} | {:<8} | {:<8} | {:10} |". + format(i, tf_cntr_16_lsb, tf_start, bpm_id, + bpm_pos_x_16_msb, bpm_pos_x_16_lsb, + bpm_pos_y_16_msb, bpm_pos_y_16_lsb, + tf_cnrt_32)) + i = i + 1 From a5d8a40307251535a13ff5561e0fe2bda0e82ddb Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Sat, 6 Mar 2021 00:54:08 -0300 Subject: [PATCH 28/40] include/hw: add initial rtmlamp_ohwr register map --- include/hw/__wb_rtmlamp_ohwr_regs.h | 411 ++++++++++++++++++++++++++++ include/hw/wb_rtmlamp_ohwr_regs.h | 59 ++++ 2 files changed, 470 insertions(+) create mode 100644 include/hw/__wb_rtmlamp_ohwr_regs.h create mode 100644 include/hw/wb_rtmlamp_ohwr_regs.h diff --git a/include/hw/__wb_rtmlamp_ohwr_regs.h b/include/hw/__wb_rtmlamp_ohwr_regs.h new file mode 100644 index 00000000..2db5b29c --- /dev/null +++ b/include/hw/__wb_rtmlamp_ohwr_regs.h @@ -0,0 +1,411 @@ +#ifndef __CHEBY__RTMLAMP_OHWR_REGS__H__ +#define __CHEBY__RTMLAMP_OHWR_REGS__H__ +#define RTMLAMP_OHWR_REGS_SIZE 400 /* 0x190 */ + +/* General RTM status register */ +#define RTMLAMP_OHWR_REGS_STA 0x0UL +#define RTMLAMP_OHWR_REGS_STA_RESERVED_MASK 0xffffffffUL +#define RTMLAMP_OHWR_REGS_STA_RESERVED_SHIFT 0 + +/* General RTM control register */ +#define RTMLAMP_OHWR_REGS_CTL 0x4UL +#define RTMLAMP_OHWR_REGS_CTL_DAC_DATA_FROM_WB 0x1UL +#define RTMLAMP_OHWR_REGS_CTL_RESERVED_MASK 0xfffffffeUL +#define RTMLAMP_OHWR_REGS_CTL_RESERVED_SHIFT 1 + +/* Channel 0 status register */ +#define RTMLAMP_OHWR_REGS_CH_0_STA 0x100UL +#define RTMLAMP_OHWR_REGS_CH_0_STA_AMP_IFLAG_L 0x1UL +#define RTMLAMP_OHWR_REGS_CH_0_STA_AMP_TFLAG_L 0x2UL +#define RTMLAMP_OHWR_REGS_CH_0_STA_AMP_IFLAG_R 0x4UL +#define RTMLAMP_OHWR_REGS_CH_0_STA_AMP_TFLAG_R 0x8UL +#define RTMLAMP_OHWR_REGS_CH_0_STA_RESERVED_MASK 0xfffffff0UL +#define RTMLAMP_OHWR_REGS_CH_0_STA_RESERVED_SHIFT 4 + +/* Channel 0 control register */ +#define RTMLAMP_OHWR_REGS_CH_0_CTL 0x104UL +#define RTMLAMP_OHWR_REGS_CH_0_CTL_AMP_EN 0x1UL +#define RTMLAMP_OHWR_REGS_CH_0_CTL_RESERVED_MASK 0xfffffffeUL +#define RTMLAMP_OHWR_REGS_CH_0_CTL_RESERVED_SHIFT 1 + +/* DAC channel 0 control register */ +#define RTMLAMP_OHWR_REGS_CH_0_DAC 0x108UL +#define RTMLAMP_OHWR_REGS_CH_0_DAC_DATA_MASK 0xffffUL +#define RTMLAMP_OHWR_REGS_CH_0_DAC_DATA_SHIFT 0 +#define RTMLAMP_OHWR_REGS_CH_0_DAC_WR 0x10000UL +#define RTMLAMP_OHWR_REGS_CH_0_DAC_RESERVED_MASK 0xfffe0000UL +#define RTMLAMP_OHWR_REGS_CH_0_DAC_RESERVED_SHIFT 17 + +/* Channel 1 status register */ +#define RTMLAMP_OHWR_REGS_CH_1_STA 0x10cUL +#define RTMLAMP_OHWR_REGS_CH_1_STA_AMP_IFLAG_L 0x1UL +#define RTMLAMP_OHWR_REGS_CH_1_STA_AMP_TFLAG_L 0x2UL +#define RTMLAMP_OHWR_REGS_CH_1_STA_AMP_IFLAG_R 0x4UL +#define RTMLAMP_OHWR_REGS_CH_1_STA_AMP_TFLAG_R 0x8UL +#define RTMLAMP_OHWR_REGS_CH_1_STA_RESERVED_MASK 0xfffffff0UL +#define RTMLAMP_OHWR_REGS_CH_1_STA_RESERVED_SHIFT 4 + +/* Channel 1 control register */ +#define RTMLAMP_OHWR_REGS_CH_1_CTL 0x110UL +#define RTMLAMP_OHWR_REGS_CH_1_CTL_AMP_EN 0x1UL +#define RTMLAMP_OHWR_REGS_CH_1_CTL_RESERVED_MASK 0xfffffffeUL +#define RTMLAMP_OHWR_REGS_CH_1_CTL_RESERVED_SHIFT 1 + +/* DAC channel 1 control register */ +#define RTMLAMP_OHWR_REGS_CH_1_DAC 0x114UL +#define RTMLAMP_OHWR_REGS_CH_1_DAC_DATA_MASK 0xffffUL +#define RTMLAMP_OHWR_REGS_CH_1_DAC_DATA_SHIFT 0 +#define RTMLAMP_OHWR_REGS_CH_1_DAC_WR 0x10000UL +#define RTMLAMP_OHWR_REGS_CH_1_DAC_RESERVED_MASK 0xfffe0000UL +#define RTMLAMP_OHWR_REGS_CH_1_DAC_RESERVED_SHIFT 17 + +/* Channel 2 status register */ +#define RTMLAMP_OHWR_REGS_CH_2_STA 0x118UL +#define RTMLAMP_OHWR_REGS_CH_2_STA_AMP_IFLAG_L 0x1UL +#define RTMLAMP_OHWR_REGS_CH_2_STA_AMP_TFLAG_L 0x2UL +#define RTMLAMP_OHWR_REGS_CH_2_STA_AMP_IFLAG_R 0x4UL +#define RTMLAMP_OHWR_REGS_CH_2_STA_AMP_TFLAG_R 0x8UL +#define RTMLAMP_OHWR_REGS_CH_2_STA_RESERVED_MASK 0xfffffff0UL +#define RTMLAMP_OHWR_REGS_CH_2_STA_RESERVED_SHIFT 4 + +/* Channel 2 control register */ +#define RTMLAMP_OHWR_REGS_CH_2_CTL 0x11cUL +#define RTMLAMP_OHWR_REGS_CH_2_CTL_AMP_EN 0x1UL +#define RTMLAMP_OHWR_REGS_CH_2_CTL_RESERVED_MASK 0xfffffffeUL +#define RTMLAMP_OHWR_REGS_CH_2_CTL_RESERVED_SHIFT 1 + +/* DAC channel 2 control register */ +#define RTMLAMP_OHWR_REGS_CH_2_DAC 0x120UL +#define RTMLAMP_OHWR_REGS_CH_2_DAC_DATA_MASK 0xffffUL +#define RTMLAMP_OHWR_REGS_CH_2_DAC_DATA_SHIFT 0 +#define RTMLAMP_OHWR_REGS_CH_2_DAC_WR 0x10000UL +#define RTMLAMP_OHWR_REGS_CH_2_DAC_RESERVED_MASK 0xfffe0000UL +#define RTMLAMP_OHWR_REGS_CH_2_DAC_RESERVED_SHIFT 17 + +/* Channel 3 status register */ +#define RTMLAMP_OHWR_REGS_CH_3_STA 0x124UL +#define RTMLAMP_OHWR_REGS_CH_3_STA_AMP_IFLAG_L 0x1UL +#define RTMLAMP_OHWR_REGS_CH_3_STA_AMP_TFLAG_L 0x2UL +#define RTMLAMP_OHWR_REGS_CH_3_STA_AMP_IFLAG_R 0x4UL +#define RTMLAMP_OHWR_REGS_CH_3_STA_AMP_TFLAG_R 0x8UL +#define RTMLAMP_OHWR_REGS_CH_3_STA_RESERVED_MASK 0xfffffff0UL +#define RTMLAMP_OHWR_REGS_CH_3_STA_RESERVED_SHIFT 4 + +/* Channel 3 control register */ +#define RTMLAMP_OHWR_REGS_CH_3_CTL 0x128UL +#define RTMLAMP_OHWR_REGS_CH_3_CTL_AMP_EN 0x1UL +#define RTMLAMP_OHWR_REGS_CH_3_CTL_RESERVED_MASK 0xfffffffeUL +#define RTMLAMP_OHWR_REGS_CH_3_CTL_RESERVED_SHIFT 1 + +/* DAC channel 3 control register */ +#define RTMLAMP_OHWR_REGS_CH_3_DAC 0x12cUL +#define RTMLAMP_OHWR_REGS_CH_3_DAC_DATA_MASK 0xffffUL +#define RTMLAMP_OHWR_REGS_CH_3_DAC_DATA_SHIFT 0 +#define RTMLAMP_OHWR_REGS_CH_3_DAC_WR 0x10000UL +#define RTMLAMP_OHWR_REGS_CH_3_DAC_RESERVED_MASK 0xfffe0000UL +#define RTMLAMP_OHWR_REGS_CH_3_DAC_RESERVED_SHIFT 17 + +/* Channel 4 status register */ +#define RTMLAMP_OHWR_REGS_CH_4_STA 0x130UL +#define RTMLAMP_OHWR_REGS_CH_4_STA_AMP_IFLAG_L 0x1UL +#define RTMLAMP_OHWR_REGS_CH_4_STA_AMP_TFLAG_L 0x2UL +#define RTMLAMP_OHWR_REGS_CH_4_STA_AMP_IFLAG_R 0x4UL +#define RTMLAMP_OHWR_REGS_CH_4_STA_AMP_TFLAG_R 0x8UL +#define RTMLAMP_OHWR_REGS_CH_4_STA_RESERVED_MASK 0xfffffff0UL +#define RTMLAMP_OHWR_REGS_CH_4_STA_RESERVED_SHIFT 4 + +/* Channel 4 control register */ +#define RTMLAMP_OHWR_REGS_CH_4_CTL 0x134UL +#define RTMLAMP_OHWR_REGS_CH_4_CTL_AMP_EN 0x1UL +#define RTMLAMP_OHWR_REGS_CH_4_CTL_RESERVED_MASK 0xfffffffeUL +#define RTMLAMP_OHWR_REGS_CH_4_CTL_RESERVED_SHIFT 1 + +/* DAC channel 4 control register */ +#define RTMLAMP_OHWR_REGS_CH_4_DAC 0x138UL +#define RTMLAMP_OHWR_REGS_CH_4_DAC_DATA_MASK 0xffffUL +#define RTMLAMP_OHWR_REGS_CH_4_DAC_DATA_SHIFT 0 +#define RTMLAMP_OHWR_REGS_CH_4_DAC_WR 0x10000UL +#define RTMLAMP_OHWR_REGS_CH_4_DAC_RESERVED_MASK 0xfffe0000UL +#define RTMLAMP_OHWR_REGS_CH_4_DAC_RESERVED_SHIFT 17 + +/* Channel 5 status register */ +#define RTMLAMP_OHWR_REGS_CH_5_STA 0x13cUL +#define RTMLAMP_OHWR_REGS_CH_5_STA_AMP_IFLAG_L 0x1UL +#define RTMLAMP_OHWR_REGS_CH_5_STA_AMP_TFLAG_L 0x2UL +#define RTMLAMP_OHWR_REGS_CH_5_STA_AMP_IFLAG_R 0x4UL +#define RTMLAMP_OHWR_REGS_CH_5_STA_AMP_TFLAG_R 0x8UL +#define RTMLAMP_OHWR_REGS_CH_5_STA_RESERVED_MASK 0xfffffff0UL +#define RTMLAMP_OHWR_REGS_CH_5_STA_RESERVED_SHIFT 4 + +/* Channel 5 control register */ +#define RTMLAMP_OHWR_REGS_CH_5_CTL 0x140UL +#define RTMLAMP_OHWR_REGS_CH_5_CTL_AMP_EN 0x1UL +#define RTMLAMP_OHWR_REGS_CH_5_CTL_RESERVED_MASK 0xfffffffeUL +#define RTMLAMP_OHWR_REGS_CH_5_CTL_RESERVED_SHIFT 1 + +/* DAC channel 5 control register */ +#define RTMLAMP_OHWR_REGS_CH_5_DAC 0x144UL +#define RTMLAMP_OHWR_REGS_CH_5_DAC_DATA_MASK 0xffffUL +#define RTMLAMP_OHWR_REGS_CH_5_DAC_DATA_SHIFT 0 +#define RTMLAMP_OHWR_REGS_CH_5_DAC_WR 0x10000UL +#define RTMLAMP_OHWR_REGS_CH_5_DAC_RESERVED_MASK 0xfffe0000UL +#define RTMLAMP_OHWR_REGS_CH_5_DAC_RESERVED_SHIFT 17 + +/* Channel 6 status register */ +#define RTMLAMP_OHWR_REGS_CH_6_STA 0x148UL +#define RTMLAMP_OHWR_REGS_CH_6_STA_AMP_IFLAG_L 0x1UL +#define RTMLAMP_OHWR_REGS_CH_6_STA_AMP_TFLAG_L 0x2UL +#define RTMLAMP_OHWR_REGS_CH_6_STA_AMP_IFLAG_R 0x4UL +#define RTMLAMP_OHWR_REGS_CH_6_STA_AMP_TFLAG_R 0x8UL +#define RTMLAMP_OHWR_REGS_CH_6_STA_RESERVED_MASK 0xfffffff0UL +#define RTMLAMP_OHWR_REGS_CH_6_STA_RESERVED_SHIFT 4 + +/* Channel 6 control register */ +#define RTMLAMP_OHWR_REGS_CH_6_CTL 0x14cUL +#define RTMLAMP_OHWR_REGS_CH_6_CTL_AMP_EN 0x1UL +#define RTMLAMP_OHWR_REGS_CH_6_CTL_RESERVED_MASK 0xfffffffeUL +#define RTMLAMP_OHWR_REGS_CH_6_CTL_RESERVED_SHIFT 1 + +/* DAC channel 6 control register */ +#define RTMLAMP_OHWR_REGS_CH_6_DAC 0x150UL +#define RTMLAMP_OHWR_REGS_CH_6_DAC_DATA_MASK 0xffffUL +#define RTMLAMP_OHWR_REGS_CH_6_DAC_DATA_SHIFT 0 +#define RTMLAMP_OHWR_REGS_CH_6_DAC_WR 0x10000UL +#define RTMLAMP_OHWR_REGS_CH_6_DAC_RESERVED_MASK 0xfffe0000UL +#define RTMLAMP_OHWR_REGS_CH_6_DAC_RESERVED_SHIFT 17 + +/* Channel 7 status register */ +#define RTMLAMP_OHWR_REGS_CH_7_STA 0x154UL +#define RTMLAMP_OHWR_REGS_CH_7_STA_AMP_IFLAG_L 0x1UL +#define RTMLAMP_OHWR_REGS_CH_7_STA_AMP_TFLAG_L 0x2UL +#define RTMLAMP_OHWR_REGS_CH_7_STA_AMP_IFLAG_R 0x4UL +#define RTMLAMP_OHWR_REGS_CH_7_STA_AMP_TFLAG_R 0x8UL +#define RTMLAMP_OHWR_REGS_CH_7_STA_RESERVED_MASK 0xfffffff0UL +#define RTMLAMP_OHWR_REGS_CH_7_STA_RESERVED_SHIFT 4 + +/* Channel 7 control register */ +#define RTMLAMP_OHWR_REGS_CH_7_CTL 0x158UL +#define RTMLAMP_OHWR_REGS_CH_7_CTL_AMP_EN 0x1UL +#define RTMLAMP_OHWR_REGS_CH_7_CTL_RESERVED_MASK 0xfffffffeUL +#define RTMLAMP_OHWR_REGS_CH_7_CTL_RESERVED_SHIFT 1 + +/* DAC channel 7 control register */ +#define RTMLAMP_OHWR_REGS_CH_7_DAC 0x15cUL +#define RTMLAMP_OHWR_REGS_CH_7_DAC_DATA_MASK 0xffffUL +#define RTMLAMP_OHWR_REGS_CH_7_DAC_DATA_SHIFT 0 +#define RTMLAMP_OHWR_REGS_CH_7_DAC_WR 0x10000UL +#define RTMLAMP_OHWR_REGS_CH_7_DAC_RESERVED_MASK 0xfffe0000UL +#define RTMLAMP_OHWR_REGS_CH_7_DAC_RESERVED_SHIFT 17 + +/* Channel 8 status register */ +#define RTMLAMP_OHWR_REGS_CH_8_STA 0x160UL +#define RTMLAMP_OHWR_REGS_CH_8_STA_AMP_IFLAG_L 0x1UL +#define RTMLAMP_OHWR_REGS_CH_8_STA_AMP_TFLAG_L 0x2UL +#define RTMLAMP_OHWR_REGS_CH_8_STA_AMP_IFLAG_R 0x4UL +#define RTMLAMP_OHWR_REGS_CH_8_STA_AMP_TFLAG_R 0x8UL +#define RTMLAMP_OHWR_REGS_CH_8_STA_RESERVED_MASK 0xfffffff0UL +#define RTMLAMP_OHWR_REGS_CH_8_STA_RESERVED_SHIFT 4 + +/* Channel 8 control register */ +#define RTMLAMP_OHWR_REGS_CH_8_CTL 0x164UL +#define RTMLAMP_OHWR_REGS_CH_8_CTL_AMP_EN 0x1UL +#define RTMLAMP_OHWR_REGS_CH_8_CTL_RESERVED_MASK 0xfffffffeUL +#define RTMLAMP_OHWR_REGS_CH_8_CTL_RESERVED_SHIFT 1 + +/* DAC channel 8 control register */ +#define RTMLAMP_OHWR_REGS_CH_8_DAC 0x168UL +#define RTMLAMP_OHWR_REGS_CH_8_DAC_DATA_MASK 0xffffUL +#define RTMLAMP_OHWR_REGS_CH_8_DAC_DATA_SHIFT 0 +#define RTMLAMP_OHWR_REGS_CH_8_DAC_WR 0x10000UL +#define RTMLAMP_OHWR_REGS_CH_8_DAC_RESERVED_MASK 0xfffe0000UL +#define RTMLAMP_OHWR_REGS_CH_8_DAC_RESERVED_SHIFT 17 + +/* Channel 9 status register */ +#define RTMLAMP_OHWR_REGS_CH_9_STA 0x16cUL +#define RTMLAMP_OHWR_REGS_CH_9_STA_AMP_IFLAG_L 0x1UL +#define RTMLAMP_OHWR_REGS_CH_9_STA_AMP_TFLAG_L 0x2UL +#define RTMLAMP_OHWR_REGS_CH_9_STA_AMP_IFLAG_R 0x4UL +#define RTMLAMP_OHWR_REGS_CH_9_STA_AMP_TFLAG_R 0x8UL +#define RTMLAMP_OHWR_REGS_CH_9_STA_RESERVED_MASK 0xfffffff0UL +#define RTMLAMP_OHWR_REGS_CH_9_STA_RESERVED_SHIFT 4 + +/* Channel 9 control register */ +#define RTMLAMP_OHWR_REGS_CH_9_CTL 0x170UL +#define RTMLAMP_OHWR_REGS_CH_9_CTL_AMP_EN 0x1UL +#define RTMLAMP_OHWR_REGS_CH_9_CTL_RESERVED_MASK 0xfffffffeUL +#define RTMLAMP_OHWR_REGS_CH_9_CTL_RESERVED_SHIFT 1 + +/* DAC channel 9 control register */ +#define RTMLAMP_OHWR_REGS_CH_9_DAC 0x174UL +#define RTMLAMP_OHWR_REGS_CH_9_DAC_DATA_MASK 0xffffUL +#define RTMLAMP_OHWR_REGS_CH_9_DAC_DATA_SHIFT 0 +#define RTMLAMP_OHWR_REGS_CH_9_DAC_WR 0x10000UL +#define RTMLAMP_OHWR_REGS_CH_9_DAC_RESERVED_MASK 0xfffe0000UL +#define RTMLAMP_OHWR_REGS_CH_9_DAC_RESERVED_SHIFT 17 + +/* Channel 10 status register */ +#define RTMLAMP_OHWR_REGS_CH_10_STA 0x178UL +#define RTMLAMP_OHWR_REGS_CH_10_STA_AMP_IFLAG_L 0x1UL +#define RTMLAMP_OHWR_REGS_CH_10_STA_AMP_TFLAG_L 0x2UL +#define RTMLAMP_OHWR_REGS_CH_10_STA_AMP_IFLAG_R 0x4UL +#define RTMLAMP_OHWR_REGS_CH_10_STA_AMP_TFLAG_R 0x8UL +#define RTMLAMP_OHWR_REGS_CH_10_STA_RESERVED_MASK 0xfffffff0UL +#define RTMLAMP_OHWR_REGS_CH_10_STA_RESERVED_SHIFT 4 + +/* Channel 10 control register */ +#define RTMLAMP_OHWR_REGS_CH_10_CTL 0x17cUL +#define RTMLAMP_OHWR_REGS_CH_10_CTL_AMP_EN 0x1UL +#define RTMLAMP_OHWR_REGS_CH_10_CTL_RESERVED_MASK 0xfffffffeUL +#define RTMLAMP_OHWR_REGS_CH_10_CTL_RESERVED_SHIFT 1 + +/* DAC channel 10 control register */ +#define RTMLAMP_OHWR_REGS_CH_10_DAC 0x180UL +#define RTMLAMP_OHWR_REGS_CH_10_DAC_DATA_MASK 0xffffUL +#define RTMLAMP_OHWR_REGS_CH_10_DAC_DATA_SHIFT 0 +#define RTMLAMP_OHWR_REGS_CH_10_DAC_WR 0x10000UL +#define RTMLAMP_OHWR_REGS_CH_10_DAC_RESERVED_MASK 0xfffe0000UL +#define RTMLAMP_OHWR_REGS_CH_10_DAC_RESERVED_SHIFT 17 + +/* Channel 11 status register */ +#define RTMLAMP_OHWR_REGS_CH_11_STA 0x184UL +#define RTMLAMP_OHWR_REGS_CH_11_STA_AMP_IFLAG_L 0x1UL +#define RTMLAMP_OHWR_REGS_CH_11_STA_AMP_TFLAG_L 0x2UL +#define RTMLAMP_OHWR_REGS_CH_11_STA_AMP_IFLAG_R 0x4UL +#define RTMLAMP_OHWR_REGS_CH_11_STA_AMP_TFLAG_R 0x8UL +#define RTMLAMP_OHWR_REGS_CH_11_STA_RESERVED_MASK 0xfffffff0UL +#define RTMLAMP_OHWR_REGS_CH_11_STA_RESERVED_SHIFT 4 + +/* Channel 11 control register */ +#define RTMLAMP_OHWR_REGS_CH_11_CTL 0x188UL +#define RTMLAMP_OHWR_REGS_CH_11_CTL_AMP_EN 0x1UL +#define RTMLAMP_OHWR_REGS_CH_11_CTL_RESERVED_MASK 0xfffffffeUL +#define RTMLAMP_OHWR_REGS_CH_11_CTL_RESERVED_SHIFT 1 + +/* DAC channel 11 control register */ +#define RTMLAMP_OHWR_REGS_CH_11_DAC 0x18cUL +#define RTMLAMP_OHWR_REGS_CH_11_DAC_DATA_MASK 0xffffUL +#define RTMLAMP_OHWR_REGS_CH_11_DAC_DATA_SHIFT 0 +#define RTMLAMP_OHWR_REGS_CH_11_DAC_WR 0x10000UL +#define RTMLAMP_OHWR_REGS_CH_11_DAC_RESERVED_MASK 0xfffe0000UL +#define RTMLAMP_OHWR_REGS_CH_11_DAC_RESERVED_SHIFT 17 + +struct rtmlamp_ohwr_regs { + /* [0x0]: REG (ro) General RTM status register */ + uint32_t sta; + + /* [0x4]: REG (rw) General RTM control register */ + uint32_t ctl; + + /* padding to: 64 words */ + uint32_t __padding_0[62]; + + /* [0x100]: REG (ro) Channel 0 status register */ + uint32_t ch_0_sta; + + /* [0x104]: REG (rw) Channel 0 control register */ + uint32_t ch_0_ctl; + + /* [0x108]: REG (rw) DAC channel 0 control register */ + uint32_t ch_0_dac; + + /* [0x10c]: REG (ro) Channel 1 status register */ + uint32_t ch_1_sta; + + /* [0x110]: REG (rw) Channel 1 control register */ + uint32_t ch_1_ctl; + + /* [0x114]: REG (rw) DAC channel 1 control register */ + uint32_t ch_1_dac; + + /* [0x118]: REG (ro) Channel 2 status register */ + uint32_t ch_2_sta; + + /* [0x11c]: REG (rw) Channel 2 control register */ + uint32_t ch_2_ctl; + + /* [0x120]: REG (rw) DAC channel 2 control register */ + uint32_t ch_2_dac; + + /* [0x124]: REG (ro) Channel 3 status register */ + uint32_t ch_3_sta; + + /* [0x128]: REG (rw) Channel 3 control register */ + uint32_t ch_3_ctl; + + /* [0x12c]: REG (rw) DAC channel 3 control register */ + uint32_t ch_3_dac; + + /* [0x130]: REG (ro) Channel 4 status register */ + uint32_t ch_4_sta; + + /* [0x134]: REG (rw) Channel 4 control register */ + uint32_t ch_4_ctl; + + /* [0x138]: REG (rw) DAC channel 4 control register */ + uint32_t ch_4_dac; + + /* [0x13c]: REG (ro) Channel 5 status register */ + uint32_t ch_5_sta; + + /* [0x140]: REG (rw) Channel 5 control register */ + uint32_t ch_5_ctl; + + /* [0x144]: REG (rw) DAC channel 5 control register */ + uint32_t ch_5_dac; + + /* [0x148]: REG (ro) Channel 6 status register */ + uint32_t ch_6_sta; + + /* [0x14c]: REG (rw) Channel 6 control register */ + uint32_t ch_6_ctl; + + /* [0x150]: REG (rw) DAC channel 6 control register */ + uint32_t ch_6_dac; + + /* [0x154]: REG (ro) Channel 7 status register */ + uint32_t ch_7_sta; + + /* [0x158]: REG (rw) Channel 7 control register */ + uint32_t ch_7_ctl; + + /* [0x15c]: REG (rw) DAC channel 7 control register */ + uint32_t ch_7_dac; + + /* [0x160]: REG (ro) Channel 8 status register */ + uint32_t ch_8_sta; + + /* [0x164]: REG (rw) Channel 8 control register */ + uint32_t ch_8_ctl; + + /* [0x168]: REG (rw) DAC channel 8 control register */ + uint32_t ch_8_dac; + + /* [0x16c]: REG (ro) Channel 9 status register */ + uint32_t ch_9_sta; + + /* [0x170]: REG (rw) Channel 9 control register */ + uint32_t ch_9_ctl; + + /* [0x174]: REG (rw) DAC channel 9 control register */ + uint32_t ch_9_dac; + + /* [0x178]: REG (ro) Channel 10 status register */ + uint32_t ch_10_sta; + + /* [0x17c]: REG (rw) Channel 10 control register */ + uint32_t ch_10_ctl; + + /* [0x180]: REG (rw) DAC channel 10 control register */ + uint32_t ch_10_dac; + + /* [0x184]: REG (ro) Channel 11 status register */ + uint32_t ch_11_sta; + + /* [0x188]: REG (rw) Channel 11 control register */ + uint32_t ch_11_ctl; + + /* [0x18c]: REG (rw) DAC channel 11 control register */ + uint32_t ch_11_dac; +}; + +#endif /* __CHEBY__RTMLAMP_OHWR_REGS__H__ */ diff --git a/include/hw/wb_rtmlamp_ohwr_regs.h b/include/hw/wb_rtmlamp_ohwr_regs.h new file mode 100644 index 00000000..9f67316e --- /dev/null +++ b/include/hw/wb_rtmlamp_ohwr_regs.h @@ -0,0 +1,59 @@ +#ifndef __WB_RTMLAMP_OHWR_CC_REGS_H__ +#define __WB_RTMLAMP_OHWR_CC_REGS_H__ + +#include "__wb_rtmlamp_ohwr_regs.h" + +#ifdef __KERNEL__ +#include +#else +#include +#endif + +#if defined( __GNUC__) +#define PACKED __attribute__ ((packed)) +#else +#error "Unsupported compiler?" +#endif + +#ifndef __WBGEN2_MACROS_DEFINED__ +#define __WBGEN2_MACROS_DEFINED__ +#define WBGEN2_GEN_MASK(offset, size) (((1<<(size))-1) << (offset)) +#define WBGEN2_GEN_WRITE(value, offset, size) (((value) & ((1<<(size))-1)) << (offset)) +#define WBGEN2_GEN_READ(reg, offset, size) (((reg) >> (offset)) & ((1<<(size))-1)) +#define WBGEN2_SIGN_EXTEND(value, bits) (((value) & (1<> RTMLAMP_OHWR_CH_0_DAC_DATA_SHIFT) +#define RTMLAMP_OHWR_CH_0_DAC_DATA_W(val) ((val & RTMLAMP_OHWR_CH_0_DAC_DATA_MASK) << RTMLAMP_OHWR_CH_0_DAC_DATA_SHIFT) +#define RTMLAMP_OHWR_CH_0_DAC_WR RTMLAMP_OHWR_REGS_CH_0_DAC_WR + +#endif /* __WB_RTMLAMP_OHWR_CC_REGS_H__ */ From 0838987ef1066a108e8fd6a14f41c17631d609a4 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Sat, 6 Mar 2021 00:54:41 -0300 Subject: [PATCH 29/40] sm_io/*/rtmlamp_ohwr: add SMIO module --- src/sm_io/modules/modules.mk | 6 +- src/sm_io/modules/rtmlamp_ohwr/CMakeLists.txt | 131 ++++++++ .../modules/rtmlamp_ohwr/rtmlamp_ohwr.mk | 5 + .../rtmlamp_ohwr/sm_io_rtmlamp_ohwr_codes.h | 44 +++ .../rtmlamp_ohwr/sm_io_rtmlamp_ohwr_core.c | 64 ++++ .../rtmlamp_ohwr/sm_io_rtmlamp_ohwr_core.h | 22 ++ .../sm_io_rtmlamp_ohwr_defaults.c | 69 +++++ .../sm_io_rtmlamp_ohwr_defaults.h | 16 + .../rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exp.c | 293 ++++++++++++++++++ .../rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exp.h | 18 ++ 10 files changed, 666 insertions(+), 2 deletions(-) create mode 100644 src/sm_io/modules/rtmlamp_ohwr/CMakeLists.txt create mode 100644 src/sm_io/modules/rtmlamp_ohwr/rtmlamp_ohwr.mk create mode 100644 src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_codes.h create mode 100644 src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_core.c create mode 100644 src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_core.h create mode 100644 src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_defaults.c create mode 100644 src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_defaults.h create mode 100644 src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exp.c create mode 100644 src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exp.h diff --git a/src/sm_io/modules/modules.mk b/src/sm_io/modules/modules.mk index 70c55afa..00ba02fd 100644 --- a/src/sm_io/modules/modules.mk +++ b/src/sm_io/modules/modules.mk @@ -19,7 +19,8 @@ include $(sm_io_modules_DIR)/fmc130m_4ch/fmc130m_4ch.mk \ $(sm_io_modules_DIR)/tim_rcv/tim_rcv.mk \ $(sm_io_modules_DIR)/rffe_scpi/rffe_scpi.mk \ $(sm_io_modules_DIR)/orbit_intlk/orbit_intlk.mk \ - $(sm_io_modules_DIR)/fofb_ctrl/fofb_ctrl.mk + $(sm_io_modules_DIR)/fofb_ctrl/fofb_ctrl.mk \ + $(sm_io_modules_DIR)/rtmlamp_ohwr/rtmlamp_ohwr.mk sm_io_modules_OBJS = $(sm_io_fmc130m_4ch_OBJS) \ $(sm_io_fmc250m_4ch_OBJS) \ @@ -40,4 +41,5 @@ sm_io_modules_OBJS = $(sm_io_fmc130m_4ch_OBJS) \ $(sm_io_tim_rcv_OBJS) \ $(sm_io_rffe_scpi_OBJS) \ $(sm_io_orbit_intlk_OBJS) \ - $(sm_io_fofb_ctrl_OBJS) + $(sm_io_fofb_ctrl_OBJS) \ + $(sm_io_rtmlamp_ohwr_OBJS) diff --git a/src/sm_io/modules/rtmlamp_ohwr/CMakeLists.txt b/src/sm_io/modules/rtmlamp_ohwr/CMakeLists.txt new file mode 100644 index 00000000..954c1562 --- /dev/null +++ b/src/sm_io/modules/rtmlamp_ohwr/CMakeLists.txt @@ -0,0 +1,131 @@ +######################################################################## +# Library setup +######################################################################## + +# library basename +set (sm_io_module_rtmlamp_ohwr_OUTPUT_BASENAME "sm_io_module_rtmlamp_ohwr" + CACHE STRING + "Output sm_io_module_rtmlamp_ohwr library base name" +) + +######################################################################### +# XXX dependency +######################################################################### + +# list(APPEND sm_io_module_rtmlamp_ohwr_LIBRARIES XXX) + +######################################################################## +# Library compile options +######################################################################## + +######################################################################## +# Sources/Headers definitions +######################################################################## + +####################################### +# Our sources +####################################### + +# Source files + +set(sm_io_module_rtmlamp_ohwr_sources + ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_rtmlamp_ohwr_core.c + ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_rtmlamp_ohwr_exp.c + ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_rtmlamp_ohwr_defaults.c +) + +# for IDE project generation +source_group("Source Files" FILES + ${sm_io_module_rtmlamp_ohwr_sources} +) + +# Header files +list(APPEND sm_io_module_rtmlamp_ohwr_other_search_dirs "") + +####################################### +# SMIO header definitions +####################################### + +set(sm_io_module_rtmlamp_ohwr_public_headers + ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_rtmlamp_ohwr_core.h + ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_rtmlamp_ohwr_exp.h + ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_rtmlamp_ohwr_defaults.h + ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_rtmlamp_ohwr_codes.h +) + +# Get directory names only +list(APPEND sm_io_module_rtmlamp_ohwr_search_dirs "") + +foreach(search_dir_header ${sm_io_module_rtmlamp_ohwr_public_headers}) + get_filename_component(search_dir + ${search_dir_header} + DIRECTORY + ) + + list(APPEND sm_io_module_rtmlamp_ohwr_search_dirs ${search_dir}) +endforeach() + +# remove, well, duplicates ... +list(REMOVE_DUPLICATES sm_io_module_rtmlamp_ohwr_search_dirs) + +# append to global search list +list(APPEND sm_io_module_rtmlamp_ohwr_other_search_dirs ${sm_io_module_rtmlamp_ohwr_search_dirs}) + +####################################### +# HEADER Grouping +####################################### + +# for IDE project generation +source_group("Header Files" FILES + ${sm_io_module_rtmlamp_ohwr_public_headers} +) + +######################################################################## +# Library declaration +######################################################################## + +# build static library +add_library(sm_io_module_rtmlamp_ohwr STATIC + ${sm_io_module_rtmlamp_ohwr_sources} + ${sm_io_module_rtmlamp_ohwr_public_headers} +) + +set_target_properties(sm_io_module_rtmlamp_ohwr PROPERTIES + PUBLIC_HEADER "${sm_io_module_rtmlamp_ohwr_public_headers}" + OUTPUT_NAME "${sm_io_module_rtmlamp_ohwr_OUTPUT_BASENAME}" + PREFIX "lib") + +# sm_io_module_rtmlamp_ohwr_other_search_dirs is in quotes as this is a list +# and the first element would be concatenated with the previous +# generator expression. +target_include_directories(sm_io_module_rtmlamp_ohwr + PRIVATE + "$" + $ + $ +) + +# set debug posfix in case of debug builds +set_target_properties(sm_io_module_rtmlamp_ohwr PROPERTIES + DEBUG_POSTFIX + ${CMAKE_DEBUG_POSTFIX} + POSITION_INDEPENDENT_CODE + ON +) + +# set compiler flags +target_link_libraries(sm_io_module_rtmlamp_ohwr + PRIVATE + sm_io_compiler_flags +) + +######################################################################## +# Library dependencies +######################################################################## + +# set depedency to targets +target_link_libraries(sm_io_module_rtmlamp_ohwr + PRIVATE + ${sm_io_module_rtmlamp_ohwr_LIBRARIES} + ${halcs_LIBRARIES} +) diff --git a/src/sm_io/modules/rtmlamp_ohwr/rtmlamp_ohwr.mk b/src/sm_io/modules/rtmlamp_ohwr/rtmlamp_ohwr.mk new file mode 100644 index 00000000..8bc81887 --- /dev/null +++ b/src/sm_io/modules/rtmlamp_ohwr/rtmlamp_ohwr.mk @@ -0,0 +1,5 @@ +sm_io_rtmlamp_ohwr_DIR = $(sm_io_modules_DIR)/rtmlamp_ohwr + +sm_io_rtmlamp_ohwr_OBJS = $(sm_io_rtmlamp_ohwr_DIR)/sm_io_rtmlamp_ohwr_core.o \ + $(sm_io_rtmlamp_ohwr_DIR)/sm_io_rtmlamp_ohwr_exp.o \ + $(sm_io_rtmlamp_ohwr_DIR)/sm_io_rtmlamp_ohwr_defaults.o diff --git a/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_codes.h b/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_codes.h new file mode 100644 index 00000000..b0c8fa00 --- /dev/null +++ b/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_codes.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#ifndef _SM_IO_RTMLAMP_OHWR_CODES_H_ +#define _SM_IO_RTMLAMP_OHWR_CODES_H_ + +/* Messaging OPCODES */ +#define RTMLAMP_OHWR_OPCODE_TYPE uint32_t +#define RTMLAMP_OHWR_OPCODE_SIZE (sizeof (RTMLAMP_OHWR_OPCODE_TYPE)) + +#define RTMLAMP_OHWR_OPCODE_STA 0 +#define RTMLAMP_OHWR_NAME_STA "rtmlamp_ohwr_sta" +#define RTMLAMP_OHWR_OPCODE_DAC_DATA_FROM_WB 1 +#define RTMLAMP_OHWR_NAME_DAC_DATA_FROM_WB "rtmlamp_ohwr_dac_data_from_wb" +#define RTMLAMP_OHWR_OPCODE_AMP_IFLAG_L 100 +#define RTMLAMP_OHWR_NAME_AMP_IFLAG_L "rtmlamp_ohwr_amp_iflag_l" +#define RTMLAMP_OHWR_OPCODE_AMP_TFLAG_L 101 +#define RTMLAMP_OHWR_NAME_AMP_TFLAG_L "rtmlamp_ohwr_amp_tflag_l" +#define RTMLAMP_OHWR_OPCODE_AMP_IFLAG_R 102 +#define RTMLAMP_OHWR_NAME_AMP_IFLAG_R "rtmlamp_ohwr_amp_iflag_r" +#define RTMLAMP_OHWR_OPCODE_AMP_TFLAG_R 103 +#define RTMLAMP_OHWR_NAME_AMP_TFLAG_R "rtmlamp_ohwr_amp_tflag_r" +#define RTMLAMP_OHWR_OPCODE_AMP_EN 104 +#define RTMLAMP_OHWR_NAME_AMP_EN "rtmlamp_ohwr_amp_en" +#define RTMLAMP_OHWR_OPCODE_DAC_DATA 105 +#define RTMLAMP_OHWR_NAME_DAC_DATA "rtmlamp_ohwr_dac_data" +#define RTMLAMP_OHWR_OPCODE_DAC_WR 106 +#define RTMLAMP_OHWR_NAME_DAC_WR "rtmlamp_ohwr_dac_wr" +#define RTMLAMP_OHWR_OPCODE_END + +/* Messaging Reply OPCODES */ +#define RTMLAMP_OHWR_REPLY_TYPE uint32_t +#define RTMLAMP_OHWR_REPLY_SIZE (sizeof (RTMLAMP_OHWR_REPLY_TYPE)) + +#define RTMLAMP_OHWR_OK 0 /* Operation was successful */ +#define RTMLAMP_OHWR_ERR 1 /* Could not set/get value */ +#define RTMLAMP_OHWR_UNINPL 2 /* Unimplemented function or operation */ +#define RTMLAMP_OHWR_REPLY_END 3 /* End marker */ + +#endif diff --git a/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_core.c b/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_core.c new file mode 100644 index 00000000..91f2bb94 --- /dev/null +++ b/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_core.c @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#include "halcs_server.h" +/* Private headers */ +#include "sm_io_rtmlamp_ohwr_defaults.h" +#include "sm_io_rtmlamp_ohwr_core.h" + +/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */ +#ifdef ASSERT_TEST +#undef ASSERT_TEST +#endif +#define ASSERT_TEST(test_boolean, err_str, err_goto_label, /* err_core */ ...) \ + ASSERT_HAL_TEST(test_boolean, SM_IO, "[sm_io_rtmlamp_ohwr_core]", \ + err_str, err_goto_label, /* err_core */ __VA_ARGS__) + +#ifdef ASSERT_ALLOC +#undef ASSERT_ALLOC +#endif +#define ASSERT_ALLOC(ptr, err_goto_label, /* err_core */ ...) \ + ASSERT_HAL_ALLOC(ptr, SM_IO, "[sm_io_rtmlamp_ohwr_core]", \ + smio_err_str(SMIO_ERR_ALLOC), \ + err_goto_label, /* err_core */ __VA_ARGS__) + +#ifdef CHECK_ERR +#undef CHECK_ERR +#endif +#define CHECK_ERR(err, err_type) \ + CHECK_HAL_ERR(err, SM_IO, "[sm_io_rtmlamp_ohwr_core]", \ + smio_err_str (err_type)) + +/* Creates a new instance of Device Information */ +smio_rtmlamp_ohwr_t * smio_rtmlamp_ohwr_new (smio_t *parent) +{ + UNUSED(parent); + + smio_rtmlamp_ohwr_t *self = (smio_rtmlamp_ohwr_t *) zmalloc (sizeof *self); + ASSERT_ALLOC(self, err_self_alloc); + + return self; + +err_self_alloc: + return NULL; +} + +/* Destroy an instance of the Device Information */ +smio_err_e smio_rtmlamp_ohwr_destroy (smio_rtmlamp_ohwr_t **self_p) +{ + assert (self_p); + + if (*self_p) { + smio_rtmlamp_ohwr_t *self = *self_p; + + free (self); + *self_p = NULL; + } + + return SMIO_SUCCESS; +} + diff --git a/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_core.h b/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_core.h new file mode 100644 index 00000000..70dc2e06 --- /dev/null +++ b/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_core.h @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. +*/ + +#ifndef _SM_IO_RTMLAMP_OHWR_CORE_H_ +#define _SM_IO_RTMLAMP_OHWR_CORE_H_ + +typedef struct { + const uint32_t example; +} smio_rtmlamp_ohwr_t; + +/***************** Our methods *****************/ + +/* Creates a new instance of the smio realization */ +smio_rtmlamp_ohwr_t * smio_rtmlamp_ohwr_new (smio_t *parent); +/* Destroys the smio realizationn */ +smio_err_e smio_rtmlamp_ohwr_destroy (smio_rtmlamp_ohwr_t **self_p); + +#endif diff --git a/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_defaults.c b/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_defaults.c new file mode 100644 index 00000000..8dc89b0c --- /dev/null +++ b/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_defaults.c @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#include "halcs_server.h" +/* Private headers */ +#include "sm_io_rtmlamp_ohwr_defaults.h" + +/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */ +#ifdef ASSERT_TEST +#undef ASSERT_TEST +#endif +#define ASSERT_TEST(test_boolean, err_str, err_goto_label, /* err_core */ ...) \ + ASSERT_HAL_TEST(test_boolean, SM_IO, "[sm_io:rtmlamp_ohwr_defaults]", \ + err_str, err_goto_label, /* err_core */ __VA_ARGS__) + +#ifdef ASSERT_ALLOC +#undef ASSERT_ALLOC +#endif +#define ASSERT_ALLOC(ptr, err_goto_label, /* err_core */ ...) \ + ASSERT_HAL_ALLOC(ptr, SM_IO, "[sm_io:rtmlamp_ohwr_defaults]", \ + smio_err_str(SMIO_ERR_ALLOC), \ + err_goto_label, /* err_core */ __VA_ARGS__) + +#ifdef CHECK_ERR +#undef CHECK_ERR +#endif +#define CHECK_ERR(err, err_type) \ + CHECK_HAL_ERR(err, SM_IO, "[sm_io:rtmlamp_ohwr_defaults]", \ + smio_err_str (err_type)) + +#define SMIO_RTMLAMP_OHWR_LIBHALCSCLIENT_LOG_MODE "a" +#define SMIO_RTMLAMP_OHWR_MAX_CHAN 24 + +/* We use the actual libclient to send and configure our default values, + * maintaining internal consistency. So, in fact, we are sending ourselves + * a message containing the default values. Because of this approach, we + * only get to default our values when the functions are already exported + * to the broker, which happens on a late stage. This could cause a fast + * client to get an inconsistent state from our server */ +/* TODO: Avoid exporting the functions before we have initialized + * our server with the default values */ +smio_err_e rtmlamp_ohwr_config_defaults (char *broker_endp, char *service, + const char *log_file_name) +{ + UNUSED(log_file_name); + DBE_DEBUG (DBG_SM_IO | DBG_LVL_INFO, "[sm_io:rtmlamp_ohwr_defaults] Configuring SMIO " + "RTMLAMP_OHWR with default values ...\n"); + halcs_client_err_e client_err = HALCS_CLIENT_SUCCESS; + smio_err_e err = SMIO_SUCCESS; + + UNUSED(broker_endp); + UNUSED(log_file_name); + UNUSED(client_err); +#if 0 + halcs_client_t *config_client = halcs_client_new_log_mode (broker_endp, 0, + log_file_name, SMIO_RTMLAMP_OHWR_LIBHALCSCLIENT_LOG_MODE); + ASSERT_ALLOC(config_client, err_alloc_client); + + halcs_client_destroy (&config_client); +err_alloc_client: +#endif + DBE_DEBUG (DBG_SM_IO | DBG_LVL_INFO, "[sm_io:rtmlamp_ohwr_defaults] Exiting Config thread %s\n", + service); + return err; +} diff --git a/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_defaults.h b/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_defaults.h new file mode 100644 index 00000000..df88641e --- /dev/null +++ b/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_defaults.h @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#ifndef _RTMLAMP_OHWR_DEFAULTS_H_ +#define _RTMLAMP_OHWR_DEFAULTS_H_ + +#include "sm_io_err.h" + +smio_err_e rtmlamp_ohwr_config_defaults (char *broker_endp, char *service, + const char *log_file_name); + +#endif diff --git a/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exp.c b/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exp.c new file mode 100644 index 00000000..8d976c4e --- /dev/null +++ b/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exp.c @@ -0,0 +1,293 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#include "halcs_server.h" +/* Private headers */ +#include "sm_io_rtmlamp_ohwr_codes.h" +#include "sm_io_rtmlamp_ohwr_defaults.h" +#include "sm_io_rtmlamp_ohwr_exports.h" +#include "sm_io_rtmlamp_ohwr_core.h" +#include "sm_io_rtmlamp_ohwr_exp.h" +#include "hw/wb_rtmlamp_ohwr_regs.h" + +/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */ +#ifdef ASSERT_TEST +#undef ASSERT_TEST +#endif +#define ASSERT_TEST(test_boolean, err_str, err_goto_label, /* err_core */ ...) \ + ASSERT_HAL_TEST(test_boolean, SM_IO, "[sm_io:rtmlamp_ohwr_exp]", \ + err_str, err_goto_label, /* err_core */ __VA_ARGS__) + +#ifdef ASSERT_ALLOC +#undef ASSERT_ALLOC +#endif +#define ASSERT_ALLOC(ptr, err_goto_label, /* err_core */ ...) \ + ASSERT_HAL_ALLOC(ptr, SM_IO, "[sm_io:rtmlamp_ohwr_exp]", \ + smio_err_str(SMIO_ERR_ALLOC), \ + err_goto_label, /* err_core */ __VA_ARGS__) + +#ifdef CHECK_ERR +#undef CHECK_ERR +#endif +#define CHECK_ERR(err, err_type) \ + CHECK_HAL_ERR(err, SM_IO, "[sm_io:rtmlamp_ohwr_exp]", \ + smio_err_str (err_type)) + +/* This must match the FPGA maximum number of channels */ +#define RTMLAMP_OHWR_NUM_CHAN 12 +#define RTMLAMP_OHWR_CHAN_OFFSET 0x00c /* 3 32-bit registers */ + +/*****************************************************************/ +/************ Specific RTMLAMP_OHWR INTERFACE Operations **************/ +/*****************************************************************/ + +#define RTMLAMP_OHWR_STA_R(val) (val) +#define RTMLAMP_OHWR_STA_W(val) (val) +#define RTMLAMP_OHWR_STA_MASK ((1ULL<<32)-1) +RW_PARAM_FUNC(rtmlamp_ohwr, sta) { + SET_GET_PARAM(rtmlamp_ohwr, 0x0, RTMLAMP_OHWR, STA, /* No field */, + MULT_BIT_PARAM, /* No min check */, /* No max check */, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define RTMLAMP_OHWR_CTL_DAC_DATA_FROM_WB_MIN 0 +#define RTMLAMP_OHWR_CTL_DAC_DATA_FROM_WB_MAX 1 +RW_PARAM_FUNC(rtmlamp_ohwr, dac_data_from_wb) { + SET_GET_PARAM(rtmlamp_ohwr, 0x0, RTMLAMP_OHWR, CTL, DAC_DATA_FROM_WB, + SINGLE_BIT_PARAM, RTMLAMP_OHWR_CTL_DAC_DATA_FROM_WB_MIN, + RTMLAMP_OHWR_CTL_DAC_DATA_FROM_WB_MAX, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + +#define HALCS_RTMLAMP_OHWR_STA_AMP_IFLAG_L_MIN 0 +#define HALCS_RTMLAMP_OHWR_STA_AMP_IFLAG_L_MAX 1 +RW_PARAM_FUNC(rtmlamp_ohwr, amp_iflag_l) { + SET_GET_PARAM_CHANNEL(rtmlamp_ohwr, 0x0, RTMLAMP_OHWR, + CH_0_STA, AMP_IFLAG_L, RTMLAMP_OHWR_CHAN_OFFSET, RTMLAMP_OHWR_NUM_CHAN, SINGLE_BIT_PARAM, + HALCS_RTMLAMP_OHWR_STA_AMP_IFLAG_L_MIN, HALCS_RTMLAMP_OHWR_STA_AMP_IFLAG_L_MAX, NO_CHK_FUNC, + NO_FMT_FUNC, SET_FIELD); +} + +#define HALCS_RTMLAMP_OHWR_STA_AMP_TFLAG_L_MIN 0 +#define HALCS_RTMLAMP_OHWR_STA_AMP_TFLAG_L_MAX 1 +RW_PARAM_FUNC(rtmlamp_ohwr, amp_tflag_l) { + SET_GET_PARAM_CHANNEL(rtmlamp_ohwr, 0x0, RTMLAMP_OHWR, + CH_0_STA, AMP_TFLAG_L, RTMLAMP_OHWR_CHAN_OFFSET, RTMLAMP_OHWR_NUM_CHAN, SINGLE_BIT_PARAM, + HALCS_RTMLAMP_OHWR_STA_AMP_TFLAG_L_MIN, HALCS_RTMLAMP_OHWR_STA_AMP_TFLAG_L_MAX, NO_CHK_FUNC, + NO_FMT_FUNC, SET_FIELD); +} + +#define HALCS_RTMLAMP_OHWR_STA_AMP_IFLAG_R_MIN 0 +#define HALCS_RTMLAMP_OHWR_STA_AMP_IFLAG_R_MAX 1 +RW_PARAM_FUNC(rtmlamp_ohwr, amp_iflag_r) { + SET_GET_PARAM_CHANNEL(rtmlamp_ohwr, 0x0, RTMLAMP_OHWR, + CH_0_STA, AMP_IFLAG_R, RTMLAMP_OHWR_CHAN_OFFSET, RTMLAMP_OHWR_NUM_CHAN, SINGLE_BIT_PARAM, + HALCS_RTMLAMP_OHWR_STA_AMP_IFLAG_R_MIN, HALCS_RTMLAMP_OHWR_STA_AMP_IFLAG_R_MAX, NO_CHK_FUNC, + NO_FMT_FUNC, SET_FIELD); +} + +#define HALCS_RTMLAMP_OHWR_STA_AMP_TFLAG_R_MIN 0 +#define HALCS_RTMLAMP_OHWR_STA_AMP_TFLAG_R_MAX 1 +RW_PARAM_FUNC(rtmlamp_ohwr, amp_tflag_r) { + SET_GET_PARAM_CHANNEL(rtmlamp_ohwr, 0x0, RTMLAMP_OHWR, + CH_0_STA, AMP_TFLAG_R, RTMLAMP_OHWR_CHAN_OFFSET, RTMLAMP_OHWR_NUM_CHAN, SINGLE_BIT_PARAM, + HALCS_RTMLAMP_OHWR_STA_AMP_TFLAG_R_MIN, HALCS_RTMLAMP_OHWR_STA_AMP_TFLAG_R_MAX, NO_CHK_FUNC, + NO_FMT_FUNC, SET_FIELD); +} + +#define HALCS_RTMLAMP_OHWR_CTL_AMP_EN_MIN 0 +#define HALCS_RTMLAMP_OHWR_CTL_AMP_EN_MAX 1 +RW_PARAM_FUNC(rtmlamp_ohwr, amp_en) { + SET_GET_PARAM_CHANNEL(rtmlamp_ohwr, 0x0, RTMLAMP_OHWR, + CH_0_CTL, AMP_EN, RTMLAMP_OHWR_CHAN_OFFSET, RTMLAMP_OHWR_NUM_CHAN, SINGLE_BIT_PARAM, + HALCS_RTMLAMP_OHWR_CTL_AMP_EN_MIN, HALCS_RTMLAMP_OHWR_CTL_AMP_EN_MAX, NO_CHK_FUNC, + NO_FMT_FUNC, SET_FIELD); +} + +#define HALCS_RTMLAMP_OHWR_DAC_DATA_MIN 0 +#define HALCS_RTMLAMP_OHWR_DAC_DATA_MAX RTMLAMP_OHWR_CH_0_DAC_DATA_MASK +RW_PARAM_FUNC(rtmlamp_ohwr, dac_data) { + SET_GET_PARAM_CHANNEL(rtmlamp_ohwr, 0x0, RTMLAMP_OHWR, + CH_0_DAC, DATA, RTMLAMP_OHWR_CHAN_OFFSET, RTMLAMP_OHWR_NUM_CHAN, MULT_BIT_PARAM, + HALCS_RTMLAMP_OHWR_DAC_DATA_MIN, HALCS_RTMLAMP_OHWR_DAC_DATA_MAX, NO_CHK_FUNC, + NO_FMT_FUNC, SET_FIELD); +} + +#define HALCS_RTMLAMP_OHWR_DAC_WR_MIN 0 +#define HALCS_RTMLAMP_OHWR_DAC_WR_MAX 1 +RW_PARAM_FUNC(rtmlamp_ohwr, dac_wr) { + SET_GET_PARAM_CHANNEL(rtmlamp_ohwr, 0x0, RTMLAMP_OHWR, + CH_0_DAC, WR, RTMLAMP_OHWR_CHAN_OFFSET, RTMLAMP_OHWR_NUM_CHAN, SINGLE_BIT_PARAM, + HALCS_RTMLAMP_OHWR_DAC_WR_MIN, HALCS_RTMLAMP_OHWR_DAC_WR_MAX, NO_CHK_FUNC, + NO_FMT_FUNC, SET_FIELD); +} + + +/* Exported function pointers */ +const disp_table_func_fp rtmlamp_ohwr_exp_fp [] = { + RW_PARAM_FUNC_NAME(rtmlamp_ohwr, sta), + RW_PARAM_FUNC_NAME(rtmlamp_ohwr, dac_data_from_wb), + RW_PARAM_FUNC_NAME(rtmlamp_ohwr, amp_iflag_l), + RW_PARAM_FUNC_NAME(rtmlamp_ohwr, amp_tflag_l), + RW_PARAM_FUNC_NAME(rtmlamp_ohwr, amp_iflag_r), + RW_PARAM_FUNC_NAME(rtmlamp_ohwr, amp_tflag_r), + RW_PARAM_FUNC_NAME(rtmlamp_ohwr, amp_en), + RW_PARAM_FUNC_NAME(rtmlamp_ohwr, dac_data), + RW_PARAM_FUNC_NAME(rtmlamp_ohwr, dac_wr), + NULL +}; + +/************************************************************/ +/***************** Export methods functions *****************/ +/************************************************************/ + +static smio_err_e _rtmlamp_ohwr_do_op (void *owner, void *msg); + +/* Attach an instance of sm_io to dev_io function pointer */ +smio_err_e rtmlamp_ohwr_attach (smio_t *self, void *args) +{ + UNUSED(self); + UNUSED(args); + return SMIO_ERR_FUNC_NOT_IMPL; +} + +/* Deattach an instance of sm_io to dev_io function pointer */ +smio_err_e rtmlamp_ohwr_deattach (smio_t *self) +{ + UNUSED(self); + return SMIO_ERR_FUNC_NOT_IMPL; +} + +/* Export (register) sm_io to handle operations function pointer */ +smio_err_e rtmlamp_ohwr_export_ops (smio_t *self, + const disp_op_t** smio_exp_ops) +{ + UNUSED(self); + UNUSED(smio_exp_ops); + return SMIO_ERR_FUNC_NOT_IMPL; +} + +/* Unexport (unregister) sm_io to handle operations function pointer */ +smio_err_e rtmlamp_ohwr_unexport_ops (smio_t *self) +{ + UNUSED(self); + return SMIO_ERR_FUNC_NOT_IMPL; +} + + +/* Generic wrapper for receiving opcodes and arguments to specific funtions function pointer */ +/* FIXME: Code repetition! _devio_do_smio_op () function does almost the same!!! */ +smio_err_e _rtmlamp_ohwr_do_op (void *owner, void *msg) +{ + UNUSED(owner); + UNUSED(msg); + return SMIO_ERR_FUNC_NOT_IMPL; +} + +smio_err_e rtmlamp_ohwr_do_op (void *self, void *msg) +{ + return _rtmlamp_ohwr_do_op (self, msg); +} + +const smio_ops_t rtmlamp_ohwr_ops = { + .attach = &rtmlamp_ohwr_attach, /* Attach sm_io instance to dev_io */ + .deattach = &rtmlamp_ohwr_deattach, /* Deattach sm_io instance to dev_io */ + .export_ops = &rtmlamp_ohwr_export_ops, /* Export sm_io operations to dev_io */ + .unexport_ops = &rtmlamp_ohwr_unexport_ops, /* Unexport sm_io operations to dev_io */ + .do_op = &rtmlamp_ohwr_do_op /* Generic wrapper for handling specific operations */ +}; + +/************************************************************/ +/****************** Bootstrap Operations ********************/ +/************************************************************/ + +smio_err_e rtmlamp_ohwr_init (smio_t * self) +{ + DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:rtmlamp_ohwr_exp] Initializing rtmlamp_ohwr\n"); + + smio_err_e err = SMIO_SUCCESS; + + err = smio_set_id (self, RTMLAMP_OHWR_SDB_DEVID); + ASSERT_TEST(err == SMIO_SUCCESS, "Could not set SMIO id", err_set_id); + err = smio_set_name (self, RTMLAMP_OHWR_SDB_NAME); + ASSERT_TEST(err == SMIO_SUCCESS, "Could not set SMIO name", err_set_name); + + /* Set SMIO ops pointers */ + err = smio_set_ops (self, &rtmlamp_ohwr_ops); + ASSERT_TEST(err == SMIO_SUCCESS, "Could not set SMIO operations", + err_smio_set_ops); + err = smio_set_thsafe_client_ops (self, &smio_thsafe_client_zmq_ops); + ASSERT_TEST(err == SMIO_SUCCESS, "Could not set SMIO thsafe operations", + err_smio_set_thsafe_ops); + + /* Fill the disp_op_t description structure with the callbacks. */ + + /* disp_op_t structure is const and all of the functions performing on it + * obviously receives a const argument, but here (and only on the SMIO + * initialization) we need to make an exception if we want to keep the + * functions' description and the function pointers separate */ + err = smio_init_exp_ops (self, (disp_op_t **) rtmlamp_ohwr_exp_ops, + rtmlamp_ohwr_exp_fp); + ASSERT_TEST(err == SMIO_SUCCESS, "Could not fill SMIO " + "function descriptors with the callbacks", err_fill_desc); + + err = smio_set_exp_ops (self, rtmlamp_ohwr_exp_ops); + ASSERT_TEST(err == SMIO_SUCCESS, "Could not set SMIO exported operations", + err_smio_set_exp_ops); + + /* Initialize specific structure */ + smio_rtmlamp_ohwr_t *smio_handler = smio_rtmlamp_ohwr_new (self); + ASSERT_ALLOC(smio_handler, err_smio_handler_alloc, SMIO_ERR_ALLOC); + err = smio_set_handler (self, smio_handler); + ASSERT_TEST(err == SMIO_SUCCESS, "Could not set SMIO handler", + err_smio_set_handler); + + return err; + +err_smio_set_handler: + smio_rtmlamp_ohwr_destroy (&smio_handler); +err_smio_handler_alloc: + smio_set_exp_ops (self, NULL); +err_smio_set_exp_ops: +err_fill_desc: + smio_set_thsafe_client_ops (self, NULL); +err_smio_set_thsafe_ops: + smio_set_ops (self, NULL); +err_smio_set_ops: +err_set_name: +err_set_id: + return err; +} + +/* Destroy sm_io instance of rtmlamp_ohwr */ +smio_err_e rtmlamp_ohwr_shutdown (smio_t *self) +{ + DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:rtmlamp_ohwr_exp] Shutting down rtmlamp_ohwr\n"); + + smio_err_e err = SMIO_SUCCESS; + smio_rtmlamp_ohwr_t *trig_iface = smio_get_handler (self); + ASSERT_TEST(trig_iface != NULL, "Could not get trig_iface handler", + err_trig_iface_handler, SMIO_ERR_ALLOC /* FIXME: improve return code */); + + /* Destroy SMIO instance */ + smio_rtmlamp_ohwr_destroy (&trig_iface); + /* Nullify operation pointers */ + smio_set_exp_ops (self, NULL); + smio_set_thsafe_client_ops (self, NULL); + smio_set_ops (self, NULL); + +err_trig_iface_handler: + return err; +} + +const smio_bootstrap_ops_t rtmlamp_ohwr_bootstrap_ops = { + .init = &rtmlamp_ohwr_init, + .shutdown = &rtmlamp_ohwr_shutdown, + .config_defaults = &rtmlamp_ohwr_config_defaults +}; + +SMIO_MOD_DECLARE(RTMLAMP_OHWR_SDB_DEVID, RTMLAMP_OHWR_SDB_NAME, rtmlamp_ohwr_bootstrap_ops) diff --git a/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exp.h b/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exp.h new file mode 100644 index 00000000..5b0737d5 --- /dev/null +++ b/src/sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exp.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#ifndef _RTMLAMP_OHWR_H_ +#define _RTMLAMP_OHWR_H_ + +/* Known modules IDs (from SDB records defined in FPGA) */ +#define RTMLAMP_OHWR_SDB_DEVID 0xa1248bec +#define RTMLAMP_OHWR_SDB_NAME "RTMLAMP_OHWR" + +extern const smio_bootstrap_ops_t rtmlamp_ohwr_bootstrap_ops; + +#endif + From a9680a38bd36009a4ed12ec9e874447dd7132842 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Sat, 6 Mar 2021 00:55:17 -0300 Subject: [PATCH 30/40] sm_io_table/*/rtmlamp_ohwr: add SMIO table module --- src/sm_io_table/CMakeLists.txt | 2 + src/sm_io_table/modules/modules.mk | 6 +- .../modules/rtmlamp_ohwr/rtmlamp_ohwr.mk | 3 + .../rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.c | 142 ++++++++++++++++++ .../rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.h | 25 +++ src/sm_io_table/sm_io_codes.c | 1 + src/sm_io_table/sm_io_codes.h | 2 + 7 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 src/sm_io_table/modules/rtmlamp_ohwr/rtmlamp_ohwr.mk create mode 100644 src/sm_io_table/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.c create mode 100644 src/sm_io_table/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.h diff --git a/src/sm_io_table/CMakeLists.txt b/src/sm_io_table/CMakeLists.txt index cfc2232a..c03465a8 100644 --- a/src/sm_io_table/CMakeLists.txt +++ b/src/sm_io_table/CMakeLists.txt @@ -53,6 +53,7 @@ set(sm_io_table_sources ${CMAKE_CURRENT_SOURCE_DIR}/modules/tim_rcv/sm_io_tim_rcv_exports.c ${CMAKE_CURRENT_SOURCE_DIR}/modules/orbit_intlk/sm_io_orbit_intlk_exports.c ${CMAKE_CURRENT_SOURCE_DIR}/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.c + ${CMAKE_CURRENT_SOURCE_DIR}/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.c ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_codes.c ) @@ -90,6 +91,7 @@ set(sm_io_table_public_headers ${CMAKE_CURRENT_SOURCE_DIR}/modules/tim_rcv/sm_io_tim_rcv_exports.h ${CMAKE_CURRENT_SOURCE_DIR}/modules/orbit_intlk/sm_io_orbit_intlk_exports.h ${CMAKE_CURRENT_SOURCE_DIR}/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.h + ${CMAKE_CURRENT_SOURCE_DIR}/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.h ${CMAKE_CURRENT_SOURCE_DIR}/sm_io_codes.h ) diff --git a/src/sm_io_table/modules/modules.mk b/src/sm_io_table/modules/modules.mk index 8fd93191..976ecbbe 100644 --- a/src/sm_io_table/modules/modules.mk +++ b/src/sm_io_table/modules/modules.mk @@ -19,7 +19,8 @@ include $(sm_io_table_modules_DIR)/fmc130m_4ch/fmc130m_4ch.mk \ $(sm_io_table_modules_DIR)/tim_rcv/tim_rcv.mk \ $(sm_io_table_modules_DIR)/rffe_scpi/rffe_scpi.mk \ $(sm_io_table_modules_DIR)/orbit_intlk/orbit_intlk.mk \ - $(sm_io_table_modules_DIR)/fofb_ctrl/fofb_ctrl.mk + $(sm_io_table_modules_DIR)/fofb_ctrl/fofb_ctrl.mk \ + $(sm_io_table_modules_DIR)/rtmlamp_ohwr/rtmlamp_ohwr.mk sm_io_table_modules_OBJS = $(sm_io_table_fmc130m_4ch_OBJS) \ $(sm_io_table_fmc250m_4ch_OBJS) \ @@ -40,4 +41,5 @@ sm_io_table_modules_OBJS = $(sm_io_table_fmc130m_4ch_OBJS) \ $(sm_io_table_tim_rcv_OBJS) \ $(sm_io_table_rffe_scpi_OBJS) \ $(sm_io_table_orbit_intlk_OBJS) \ - $(sm_io_table_fofb_ctrl_OBJS) + $(sm_io_table_fofb_ctrl_OBJS) \ + $(sm_io_table_rtmlamp_ohwr_OBJS) diff --git a/src/sm_io_table/modules/rtmlamp_ohwr/rtmlamp_ohwr.mk b/src/sm_io_table/modules/rtmlamp_ohwr/rtmlamp_ohwr.mk new file mode 100644 index 00000000..5a7ccc60 --- /dev/null +++ b/src/sm_io_table/modules/rtmlamp_ohwr/rtmlamp_ohwr.mk @@ -0,0 +1,3 @@ +sm_io_table_rtmlamp_ohwr_DIR = $(sm_io_table_modules_DIR)/rtmlamp_ohwr + +sm_io_table_rtmlamp_ohwr_OBJS = $(sm_io_table_rtmlamp_ohwr_DIR)/sm_io_rtmlamp_ohwr_exports.o diff --git a/src/sm_io_table/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.c b/src/sm_io_table/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.c new file mode 100644 index 00000000..cd8fac2a --- /dev/null +++ b/src/sm_io_table/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.c @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#include "sm_io_exports_helper.h" +#include "sm_io_codes.h" + +/* Description SMIO RTMLAMP_OHWR functions */ + +disp_op_t rtmlamp_ohwr_sta_exp = { + .name = RTMLAMP_OHWR_NAME_STA, + .opcode = RTMLAMP_OHWR_OPCODE_STA, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t rtmlamp_ohwr_dac_data_from_wb_exp = { + .name = RTMLAMP_OHWR_NAME_DAC_DATA_FROM_WB, + .opcode = RTMLAMP_OHWR_OPCODE_DAC_DATA_FROM_WB, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t rtmlamp_ohwr_amp_iflag_l_exp = { + .name = RTMLAMP_OHWR_NAME_AMP_IFLAG_L, + .opcode = RTMLAMP_OHWR_OPCODE_AMP_IFLAG_L, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t rtmlamp_ohwr_amp_tflag_l_exp = { + .name = RTMLAMP_OHWR_NAME_AMP_TFLAG_L, + .opcode = RTMLAMP_OHWR_OPCODE_AMP_TFLAG_L, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t rtmlamp_ohwr_amp_iflag_r_exp = { + .name = RTMLAMP_OHWR_NAME_AMP_IFLAG_R, + .opcode = RTMLAMP_OHWR_OPCODE_AMP_IFLAG_R, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t rtmlamp_ohwr_amp_tflag_r_exp = { + .name = RTMLAMP_OHWR_NAME_AMP_TFLAG_R, + .opcode = RTMLAMP_OHWR_OPCODE_AMP_TFLAG_R, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t rtmlamp_ohwr_amp_en_exp = { + .name = RTMLAMP_OHWR_NAME_AMP_EN, + .opcode = RTMLAMP_OHWR_OPCODE_AMP_EN, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t rtmlamp_ohwr_dac_data_exp = { + .name = RTMLAMP_OHWR_NAME_DAC_DATA, + .opcode = RTMLAMP_OHWR_OPCODE_DAC_DATA, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + +disp_op_t rtmlamp_ohwr_dac_wr_exp = { + .name = RTMLAMP_OHWR_NAME_DAC_WR, + .opcode = RTMLAMP_OHWR_OPCODE_DAC_WR, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + + +/* Exported function description */ +const disp_op_t *rtmlamp_ohwr_exp_ops [] = { + &rtmlamp_ohwr_sta_exp, + &rtmlamp_ohwr_dac_data_from_wb_exp, + &rtmlamp_ohwr_amp_iflag_l_exp, + &rtmlamp_ohwr_amp_tflag_l_exp, + &rtmlamp_ohwr_amp_iflag_r_exp, + &rtmlamp_ohwr_amp_tflag_r_exp, + &rtmlamp_ohwr_amp_en_exp, + &rtmlamp_ohwr_dac_data_exp, + &rtmlamp_ohwr_dac_wr_exp, + NULL +}; + diff --git a/src/sm_io_table/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.h b/src/sm_io_table/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.h new file mode 100644 index 00000000..f774e862 --- /dev/null +++ b/src/sm_io_table/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2021 LNLS (www.lnls.br) + * Author: Lucas Russo + * + * Released according to the GNU GPL, version 3 or any later version. + */ + +#ifndef _SM_IO_RTMLAMP_OHWR_EXPORTS_H_ +#define _SM_IO_RTMLAMP_OHWR_EXPORTS_H_ + +#include "disptable.h" + +extern disp_op_t rtmlamp_ohwr_sta_exp; +extern disp_op_t rtmlamp_ohwr_dac_data_from_wb_exp; +extern disp_op_t rtmlamp_ohwr_amp_iflag_l_exp; +extern disp_op_t rtmlamp_ohwr_amp_tflag_l_exp; +extern disp_op_t rtmlamp_ohwr_amp_iflag_r_exp; +extern disp_op_t rtmlamp_ohwr_amp_tflag_r_exp; +extern disp_op_t rtmlamp_ohwr_amp_en_exp; +extern disp_op_t rtmlamp_ohwr_dac_data_exp; +extern disp_op_t rtmlamp_ohwr_dac_wr_exp; + +extern const disp_op_t *rtmlamp_ohwr_exp_ops []; + +#endif diff --git a/src/sm_io_table/sm_io_codes.c b/src/sm_io_table/sm_io_codes.c index f9ff0518..0d4182f9 100644 --- a/src/sm_io_table/sm_io_codes.c +++ b/src/sm_io_table/sm_io_codes.c @@ -28,6 +28,7 @@ const disp_op_t **smio_exp_ops [] = { tim_rcv_exp_ops, orbit_intlk_exp_ops, fofb_ctrl_exp_ops, + rtmlamp_ohwr_exp_ops, NULL }; diff --git a/src/sm_io_table/sm_io_codes.h b/src/sm_io_table/sm_io_codes.h index 02cdb071..ce86efc0 100644 --- a/src/sm_io_table/sm_io_codes.h +++ b/src/sm_io_table/sm_io_codes.h @@ -46,6 +46,7 @@ typedef struct _smio_rffe_version_t smio_rffe_version_t; #include "sm_io_tim_rcv_codes.h" #include "sm_io_orbit_intlk_codes.h" #include "sm_io_fofb_ctrl_codes.h" +#include "sm_io_rtmlamp_ohwr_codes.h" /* Include all function descriptors */ #include "sm_io_fmc130m_4ch_exports.h" @@ -68,6 +69,7 @@ typedef struct _smio_rffe_version_t smio_rffe_version_t; #include "sm_io_tim_rcv_exports.h" #include "sm_io_orbit_intlk_exports.h" #include "sm_io_fofb_ctrl_exports.h" +#include "sm_io_rtmlamp_ohwr_exports.h" /* Merge all function descriptors in a single structure */ extern const disp_op_t **smio_exp_ops []; From 91ee73bffabed96ad0b05fa3b8de6c78ae378b14 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Sat, 6 Mar 2021 00:55:53 -0300 Subject: [PATCH 31/40] client: add RTM LAMP ohwr client support --- src/client/CMakeLists.txt | 3 + src/client/Makefile | 9 ++- src/client/include/halcs_client_core.h | 64 +++++++++++++++ src/client/src/halcs_client_core.c | 106 +++++++++++++++++++++++++ 4 files changed, 180 insertions(+), 2 deletions(-) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index c12c1b40..9e19505c 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -288,6 +288,7 @@ set(halcsclient_smio_table_sources ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/tim_rcv/sm_io_tim_rcv_exports.c ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/orbit_intlk/sm_io_orbit_intlk_exports.c ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.c + ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.c ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/sm_io_codes.c ) @@ -345,6 +346,7 @@ set(halcsclient_smio_public_headers ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io/modules/tim_rcv/sm_io_tim_rcv_codes.h ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io/modules/orbit_intlk/sm_io_orbit_intlk_codes.h ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io/modules/fofb_ctrl/sm_io_fofb_ctrl_codes.h + ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_codes.h ) # Get directory names only @@ -397,6 +399,7 @@ set(halcsclient_smio_table_public_headers ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/tim_rcv/sm_io_tim_rcv_exports.h ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/orbit_intlk/sm_io_orbit_intlk_exports.h ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.h + ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.h ${CMAKE_CURRENT_SOURCE_DIR}/../sm_io_table/sm_io_codes.h ) diff --git a/src/client/Makefile b/src/client/Makefile index e3e846fe..5aaf1e3e 100644 --- a/src/client/Makefile +++ b/src/client/Makefile @@ -124,7 +124,8 @@ OBJS_EXTERNAL = $(SMIO_TABLE_SRC_DIR)/sm_io_codes.o \ $(SMIO_TABLE_SRC_DIR)/modules/afc_mgmt/sm_io_afc_mgmt_exports.o \ $(SMIO_TABLE_SRC_DIR)/modules/tim_rcv/sm_io_tim_rcv_exports.o \ $(SMIO_TABLE_SRC_DIR)/modules/orbit_intlk/sm_io_orbit_intlk_exports.o \ - $(SMIO_TABLE_SRC_DIR)/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.o + $(SMIO_TABLE_SRC_DIR)/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.o \ + $(SMIO_TABLE_SRC_DIR)/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.o # Project boards boards_INCLUDE_DIRS = -I$(TOP)/include/boards/$(BOARD) @@ -156,6 +157,7 @@ INCLUDE_DIRS = -I. -Iinclude \ -I$(SMIO_SRC_DIR)/modules/tim_rcv \ -I$(SMIO_SRC_DIR)/modules/orbit_intlk \ -I$(SMIO_SRC_DIR)/modules/fofb_ctrl \ + -I$(SMIO_SRC_DIR)/modules/rtmlamp_ohwr \ -I$(SMIO_TABLE_DIR) \ -I$(SMIO_TABLE_SRC_DIR)/modules \ -I$(SMIO_TABLE_SRC_DIR)/modules/fmc130m_4ch \ @@ -179,6 +181,7 @@ INCLUDE_DIRS = -I. -Iinclude \ -I$(SMIO_TABLE_SRC_DIR)/modules/tim_rcv \ -I$(SMIO_TABLE_SRC_DIR)/modules/orbit_intlk \ -I$(SMIO_TABLE_SRC_DIR)/modules/fofb_ctrl \ + -I$(SMIO_TABLE_SRC_DIR)/modules/rtmlamp_ohwr \ -I${PREFIX}/include \ -I$(LIBERRHAND_DIR)/include \ -I$(LIBHUTILS_DIR)/include \ @@ -227,6 +230,7 @@ $(LIBNAME)_SMIO_CODES = \ $(SMIO_SRC_DIR)/modules/tim_rcv/sm_io_tim_rcv_codes.h \ $(SMIO_SRC_DIR)/modules/orbit_intlk/sm_io_orbit_intlk_codes.h \ $(SMIO_SRC_DIR)/modules/fofb_ctrl/sm_io_fofb_ctrl_codes.h \ + $(SMIO_SRC_DIR)/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_codes.h \ $(SMIO_TABLE_DIR)/sm_io_codes.h $(LIBNAME)_SMIO_EXPORTS = \ @@ -249,7 +253,8 @@ $(LIBNAME)_SMIO_EXPORTS = \ $(SMIO_TABLE_SRC_DIR)/modules/afc_mgmt/sm_io_afc_mgmt_exports.h \ $(SMIO_TABLE_SRC_DIR)/modules/tim_rcv/sm_io_tim_rcv_exports.h \ $(SMIO_TABLE_SRC_DIR)/modules/orbit_intlk/sm_io_orbit_intlk_exports.h \ - $(SMIO_TABLE_SRC_DIR)/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.h + $(SMIO_TABLE_SRC_DIR)/modules/fofb_ctrl/sm_io_fofb_ctrl_exports.h \ + $(SMIO_TABLE_SRC_DIR)/modules/rtmlamp_ohwr/sm_io_rtmlamp_ohwr_exports.h # Copy specific acq_chan.h defintions according to the BOARD MACRO $(LIBNAME)_ACQ_HEADERS_BASENAME = acq_chan diff --git a/src/client/include/halcs_client_core.h b/src/client/include/halcs_client_core.h index fb5bc176..55f98094 100644 --- a/src/client/include/halcs_client_core.h +++ b/src/client/include/halcs_client_core.h @@ -2446,6 +2446,70 @@ halcs_client_err_e halcs_get_fofb_ctrl_loopback_rdback (halcs_client_t *self, ch halcs_client_err_e halcs_get_fofb_ctrl_faival_rdback (halcs_client_t *self, char *service, uint32_t *fofb_ctrl_faival_rdback); +/********************** RTMLAMP_OHWR Functions ********************/ + +/* RTMLAMP_OHWR Controller sta function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_get_rtmlamp_ohwr_sta (halcs_client_t *self, char *service, + uint32_t *rtmlamp_ohwr_sta); + +/* RTMLAMP_OHWR Controller dac_data_from_wb function. The functions returns + * HALCS_CLIENT_SUCCESS if the parameter was correctly set or error + * (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_rtmlamp_ohwr_dac_data_from_wb (halcs_client_t *self, char *service, + uint32_t rtmlamp_ohwr_dac_data_from_wb); +halcs_client_err_e halcs_get_rtmlamp_ohwr_dac_data_from_wb (halcs_client_t *self, char *service, + uint32_t *rtmlamp_ohwr_dac_data_from_wb); + +/* RTMLAMP_OHWR Controller AMP flags functions. The functions returns + * amplifier flags of a specified amplifier channel "chan". + * All of the functions returns HALCS_CLIENT_SUCCESS if the parameter was + * correctly set or error (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_rtmlamp_ohwr_amp_iflag_l (halcs_client_t *self, char *service, + uint32_t chan, uint32_t amp_iflag_l); +halcs_client_err_e halcs_get_rtmlamp_ohwr_amp_iflag_l (halcs_client_t *self, char *service, + uint32_t chan, uint32_t *amp_iflag_l); +halcs_client_err_e halcs_set_rtmlamp_ohwr_amp_tflag_l (halcs_client_t *self, char *service, + uint32_t chan, uint32_t amp_tflag_l); +halcs_client_err_e halcs_get_rtmlamp_ohwr_amp_tflag_l (halcs_client_t *self, char *service, + uint32_t chan, uint32_t *amp_tflag_l); +halcs_client_err_e halcs_set_rtmlamp_ohwr_amp_iflag_r (halcs_client_t *self, char *service, + uint32_t chan, uint32_t amp_iflag_r); +halcs_client_err_e halcs_get_rtmlamp_ohwr_amp_iflag_r (halcs_client_t *self, char *service, + uint32_t chan, uint32_t *amp_iflag_r); +halcs_client_err_e halcs_set_rtmlamp_ohwr_amp_tflag_r (halcs_client_t *self, char *service, + uint32_t chan, uint32_t amp_tflag_r); +halcs_client_err_e halcs_get_rtmlamp_ohwr_amp_tflag_r (halcs_client_t *self, char *service, + uint32_t chan, uint32_t *amp_tflag_r); + +/* RTMLAMP_OHWR Controller AMP enable function. The function set/get + * amplifier enable of a specified amplifier channel "chan". + * All of the functions returns HALCS_CLIENT_SUCCESS if the parameter was + * correctly set or error (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_rtmlamp_ohwr_amp_en (halcs_client_t *self, char *service, + uint32_t chan, uint32_t amp_en); +halcs_client_err_e halcs_get_rtmlamp_ohwr_amp_en (halcs_client_t *self, char *service, + uint32_t chan, uint32_t *amp_en); + +/* RTMLAMP_OHWR Controller DAC function. The function set/get + * DAC data of a specified amplifier channel "chan". + * All of the functions returns HALCS_CLIENT_SUCCESS if the parameter was + * correctly set or error (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_rtmlamp_ohwr_dac_data (halcs_client_t *self, char *service, + uint32_t chan, uint32_t dac_data); +halcs_client_err_e halcs_get_rtmlamp_ohwr_dac_data (halcs_client_t *self, char *service, + uint32_t chan, uint32_t *dac_data); + +/* RTMLAMP_OHWR Controller DAC write function. The function set/get + * DAC data write to external IC of a specified amplifier channel "chan". + * All of the functions returns HALCS_CLIENT_SUCCESS if the parameter was + * correctly set or error (see halcs_client_err.h for all possible errors)*/ +halcs_client_err_e halcs_set_rtmlamp_ohwr_dac_wr (halcs_client_t *self, char *service, + uint32_t chan, uint32_t dac_wr); +halcs_client_err_e halcs_get_rtmlamp_ohwr_dac_wr (halcs_client_t *self, char *service, + uint32_t chan, uint32_t *dac_wr); + #ifdef __cplusplus } #endif diff --git a/src/client/src/halcs_client_core.c b/src/client/src/halcs_client_core.c index 2046e18c..1469d1d0 100644 --- a/src/client/src/halcs_client_core.c +++ b/src/client/src/halcs_client_core.c @@ -3977,3 +3977,109 @@ PARAM_FUNC_CLIENT_READ(fofb_ctrl_faival_rdback) { return param_client_read (self, service, FOFB_CTRL_OPCODE_SET_GET_FAIVAL_RDBACK, fofb_ctrl_faival_rdback); } + +/**************** RTMLAM_OHWR SMIO Functions ****************/ + +PARAM_FUNC_CLIENT_WRITE(rtmlamp_ohwr_sta) +{ + return param_client_write (self, service, RTMLAMP_OHWR_OPCODE_STA, rtmlamp_ohwr_sta); +} + +PARAM_FUNC_CLIENT_READ(rtmlamp_ohwr_sta) +{ + return param_client_read (self, service, RTMLAMP_OHWR_OPCODE_STA, rtmlamp_ohwr_sta); +} + +PARAM_FUNC_CLIENT_WRITE(rtmlamp_ohwr_dac_data_from_wb) +{ + return param_client_write (self, service, RTMLAMP_OHWR_OPCODE_DAC_DATA_FROM_WB, rtmlamp_ohwr_dac_data_from_wb); +} + +PARAM_FUNC_CLIENT_READ(rtmlamp_ohwr_dac_data_from_wb) +{ + return param_client_read (self, service, RTMLAMP_OHWR_OPCODE_DAC_DATA_FROM_WB, rtmlamp_ohwr_dac_data_from_wb); +} + +PARAM_FUNC_CLIENT_WRITE2(rtmlamp_ohwr_amp_iflag_l, chan, amp_iflag_l) +{ + return param_client_write2 (self, service, RTMLAMP_OHWR_OPCODE_AMP_IFLAG_L, + chan, amp_iflag_l); +} + +PARAM_FUNC_CLIENT_WRITE_READ(rtmlamp_ohwr_amp_iflag_l, chan, amp_iflag_l) +{ + return param_client_write_read (self, service, RTMLAMP_OHWR_OPCODE_AMP_IFLAG_L, + chan, amp_iflag_l); +} + +PARAM_FUNC_CLIENT_WRITE2(rtmlamp_ohwr_amp_tflag_l, chan, amp_tflag_l) +{ + return param_client_write2 (self, service, RTMLAMP_OHWR_OPCODE_AMP_TFLAG_L, + chan, amp_tflag_l); +} + +PARAM_FUNC_CLIENT_WRITE_READ(rtmlamp_ohwr_amp_tflag_l, chan, amp_tflag_l) +{ + return param_client_write_read (self, service, RTMLAMP_OHWR_OPCODE_AMP_TFLAG_L, + chan, amp_tflag_l); +} + +PARAM_FUNC_CLIENT_WRITE2(rtmlamp_ohwr_amp_iflag_r, chan, amp_iflag_r) +{ + return param_client_write2 (self, service, RTMLAMP_OHWR_OPCODE_AMP_IFLAG_R, + chan, amp_iflag_r); +} + +PARAM_FUNC_CLIENT_WRITE_READ(rtmlamp_ohwr_amp_iflag_r, chan, amp_iflag_r) +{ + return param_client_write_read (self, service, RTMLAMP_OHWR_OPCODE_AMP_IFLAG_R, + chan, amp_iflag_r); +} + +PARAM_FUNC_CLIENT_WRITE2(rtmlamp_ohwr_amp_tflag_r, chan, amp_tflag_r) +{ + return param_client_write2 (self, service, RTMLAMP_OHWR_OPCODE_AMP_TFLAG_R, + chan, amp_tflag_r); +} + +PARAM_FUNC_CLIENT_WRITE_READ(rtmlamp_ohwr_amp_tflag_r, chan, amp_tflag_r) +{ + return param_client_write_read (self, service, RTMLAMP_OHWR_OPCODE_AMP_TFLAG_R, + chan, amp_tflag_r); +} + +PARAM_FUNC_CLIENT_WRITE2(rtmlamp_ohwr_amp_en, chan, amp_en) +{ + return param_client_write2 (self, service, RTMLAMP_OHWR_OPCODE_AMP_EN, + chan, amp_en); +} + +PARAM_FUNC_CLIENT_WRITE_READ(rtmlamp_ohwr_amp_en, chan, amp_en) +{ + return param_client_write_read (self, service, RTMLAMP_OHWR_OPCODE_AMP_EN, + chan, amp_en); +} + +PARAM_FUNC_CLIENT_WRITE2(rtmlamp_ohwr_dac_data, chan, dac_data) +{ + return param_client_write2 (self, service, RTMLAMP_OHWR_OPCODE_DAC_DATA, + chan, dac_data); +} + +PARAM_FUNC_CLIENT_WRITE_READ(rtmlamp_ohwr_dac_data, chan, dac_data) +{ + return param_client_write_read (self, service, RTMLAMP_OHWR_OPCODE_DAC_DATA, + chan, dac_data); +} + +PARAM_FUNC_CLIENT_WRITE2(rtmlamp_ohwr_dac_wr, chan, dac_wr) +{ + return param_client_write2 (self, service, RTMLAMP_OHWR_OPCODE_DAC_WR, + chan, dac_wr); +} + +PARAM_FUNC_CLIENT_WRITE_READ(rtmlamp_ohwr_dac_wr, chan, dac_wr) +{ + return param_client_write_read (self, service, RTMLAMP_OHWR_OPCODE_DAC_WR, + chan, dac_wr); +} From bab597afe03e4e2d119d5fc1c7f8fad66231adff Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Sat, 6 Mar 2021 00:56:32 -0300 Subject: [PATCH 32/40] examples: add RTM LAMP client application --- examples/CMakeLists.txt | 6 + examples/src/rtmlamp_ohwr_ctl.c | 379 ++++++++++++++++++++++++++++++++ 2 files changed, 385 insertions(+) create mode 100644 examples/src/rtmlamp_ohwr_ctl.c diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e4efdc50..dfb39721 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -422,6 +422,12 @@ if(BUILD_EXAMPLE_fofb_ctrl) list(APPEND bin_target_outputs "fofb_ctrl") endif() +option(BUILD_EXAMPLE_rtmlamp_ohwr_ctl "Whether or not to build example rtmlamp_ohwr_ctl tool" ON) + +if(BUILD_EXAMPLE_rtmlamp_ohwr_ctl) + list(APPEND bin_target_outputs "rtmlamp_ohwr_ctl") +endif() + foreach(bin_target ${bin_target_outputs}) # add binary tool add_executable(${bin_target} src/${bin_target}.c) diff --git a/examples/src/rtmlamp_ohwr_ctl.c b/examples/src/rtmlamp_ohwr_ctl.c new file mode 100644 index 00000000..e52b5ed8 --- /dev/null +++ b/examples/src/rtmlamp_ohwr_ctl.c @@ -0,0 +1,379 @@ +/* + * Simple example demonstrating the communication between + * a client and the FPGA device + * */ + +#include +#include +#include +#include +#include +#include + +#define DFLT_BIND_FOLDER "/tmp/halcs" + +#define DFLT_HALCS_NUMBER 0 +#define MAX_HALCS_NUMBER 1 + +#define DFLT_BOARD_NUMBER 0 + +#define DFLT_CHAN_NUM 0 + +static struct option long_options[] = +{ + {"help", no_argument, NULL, 'h'}, + {"brokerendp", required_argument, NULL, 'b'}, + {"verbose", no_argument, NULL, 'v'}, + {"halcsnumber", required_argument, NULL, 's'}, + {"boardslot", required_argument, NULL, 'o'}, + {"channumber", required_argument, NULL, 'c'}, + {"status", no_argument, NULL, 'y'}, + {"dac_data_from_wb", required_argument, NULL, 'w'}, + {"amp_iflag_l", no_argument, NULL, 'r'}, + {"amp_tflag_l", no_argument, NULL, 'p'}, + {"amp_iflag_r", no_argument, NULL, 'a'}, + {"amp_tflag_r", no_argument, NULL, 't'}, + {"amp_en", required_argument, NULL, 'u'}, + {"dac_data", required_argument, NULL, 'e'}, + {"dac_wr", required_argument, NULL, 'x'}, + {NULL, 0, NULL, 0} +}; + +static const char* shortopt = "hb:vo:s:c:yw:rpatu:e:r:"; + +void print_help (char *program_name) +{ + fprintf (stdout, "HALCSD RTMLAMP_OHWR Utility\n" + "Usage: %s [options]\n" + "\n" + " -h --help Display this usage information\n" + " -b --brokerendp Broker endpoint\n" + " -v --verbose Verbose output\n" + " -o --boardslot \n" + " -s --halcsnumber HALCS number\n" + " Board slot number\n" + " -c --channumber \n" + " Channel number\n" + " -y --status Get RTM LAMP Status register\n" + " -w --dac_data_from_wb <[0 = data from FPGA, 1 = data from Wishbone]>\n" + " -r --amp_iflag_l Amplifier left overcurrent flag \n" + " -p --amp_tflag_l Amplifier left overtemperature flag \n" + " -a --amp_iflag_r Amplifier right overcurrent flag \n" + " -t --amp_tflag_r Amplifier right overtemperature flag \n" + " -u --amp_en <[0 = disable, 1 = enable>\n" + " Amplifier enable\n" + " -e --dac_data DAC to be sent to DAC\n" + " -x --dac_wr Write DAC data to external IC\n", + program_name); +} + +int main (int argc, char *argv []) +{ + int verbose = 0; + char *broker_endp = NULL; + char *board_number_str = NULL; + char *halcs_number_str = NULL; + char *chan_str = NULL; + int chan_sel = 0; + int status = 0; + char *dac_data_from_wb_str = NULL; + int amp_iflag_l_sel = 0; + int amp_tflag_l_sel = 0; + int amp_iflag_r_sel = 0; + int amp_tflag_r_sel = 0; + char *amp_en_str = NULL; + char *dac_data_str = NULL; + char *dac_wr_str = NULL; + int opt; + + while ((opt = getopt_long (argc, argv, shortopt, long_options, NULL)) != -1) { + /* Get the user selected options */ + switch (opt) { + /* Display Help */ + case 'h': + print_help (argv [0]); + exit (1); + break; + + case 'b': + broker_endp = strdup (optarg); + break; + + case 'v': + verbose = 1; + break; + + case 'o': + board_number_str = strdup (optarg); + break; + + case 's': + halcs_number_str = strdup (optarg); + break; + + case 'c': + chan_str = strdup (optarg); + chan_sel = 1; + break; + + case 'y': + status = 1; + break; + + case 'w': + dac_data_from_wb_str = strdup (optarg); + break; + + case 'r': + amp_iflag_l_sel = 0; + break; + + case 'p': + amp_tflag_l_sel = 0; + break; + + case 'a': + amp_iflag_r_sel = 0; + break; + + case 't': + amp_iflag_r_sel = 0; + break; + + case 'u': + amp_en_str = strdup (optarg); + break; + + case 'e': + dac_data_str = strdup (optarg); + break; + + case 'x': + dac_wr_str = strdup (optarg); + break; + + case '?': + fprintf (stderr, "[client:rtmlamp_ohwr] Option not recognized or missing argument\n"); + print_help (argv [0]); + exit (1); + break; + + default: + fprintf (stderr, "[client:rtmlamp_ohwr] Could not parse options\n"); + print_help (argv [0]); + exit (1); + } + } + + /* If we want to change a channel property, we must select a channel first */ + if ((amp_iflag_l_sel == 1 || + amp_tflag_l_sel == 1 || + amp_iflag_r_sel == 1 || + amp_iflag_r_sel == 1 || + amp_en_str != NULL || + dac_data_str != NULL) && + chan_sel == 0) { + fprintf (stderr, "[client:rtmlamp_ohwr]: Channel number not selected (use -c or --channumber option)\n"); + exit (1); + } + + /* Set default broker address */ + if (broker_endp == NULL) { + fprintf (stderr, "[client:rtmlamp_ohwr]: Setting default broker endpoint: %s\n", + "ipc://"DFLT_BIND_FOLDER); + broker_endp = strdup ("ipc://"DFLT_BIND_FOLDER); + } + + /* Set default channel */ + uint32_t chan_min; + uint32_t chan_max; + if (chan_str == NULL) { + fprintf (stderr, "[client:rtmlamp_ohwr]: Setting default value to 'chan'\n"); + chan_min = DFLT_CHAN_NUM; + chan_max = chan_min+1; + } + else { + if (sscanf (chan_str, "[%u:%u]", &chan_min, &chan_max) != 2) { + if (sscanf (chan_str, "%u", &chan_min) != 1) { + fprintf (stderr, "[client:rtmlamp_ohwr]: Unexpected channel format\n"); + exit (1); + } + chan_max = chan_min+1; + } + else { + chan_max++; + } + + if (chan_max < chan_min) { + fprintf (stderr, "[client:rtmlamp_ohwr]: Channel range must be ascending\n"); + exit (1); + } + } + + /* Set default board number */ + uint32_t board_number; + if (board_number_str == NULL) { + fprintf (stderr, "[client:rtmlamp_ohwr]: Setting default value to BOARD number: %u\n", + DFLT_BOARD_NUMBER); + board_number = DFLT_BOARD_NUMBER; + } + else { + board_number = strtoul (board_number_str, NULL, 10); + } + + /* Set default halcs number */ + uint32_t halcs_number; + if (halcs_number_str == NULL) { + fprintf (stderr, "[client:rtmlamp_ohwr]: Setting default value to HALCS number: %u\n", + DFLT_HALCS_NUMBER); + halcs_number = DFLT_HALCS_NUMBER; + } + else { + halcs_number = strtoul (halcs_number_str, NULL, 10); + + if (halcs_number > MAX_HALCS_NUMBER) { + fprintf (stderr, "[client:rtmlamp_ohwr]: HALCS number too big! Defaulting to: %u\n", + MAX_HALCS_NUMBER); + halcs_number = MAX_HALCS_NUMBER; + } + } + + char service[50]; + snprintf (service, sizeof (service), "HALCS%u:DEVIO:RTMLAMP_OHWR0", board_number); + + halcs_client_t *halcs_client = halcs_client_new (broker_endp, verbose, NULL); + if (halcs_client == NULL) { + fprintf (stderr, "[client:rtmlamp_ohwr]: halcs_client could be created\n"); + goto err_halcs_client_new; + } + + if (status == 1) { + uint32_t arg = 0; + halcs_client_err_e err = halcs_get_rtmlamp_ohwr_sta (halcs_client, service, &arg); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:rtmlamp_ohwr]: halcs_get_rtmlamp_ohwr_sta failed\n"); + goto err_halcs_set; + } + printf ("[client:rtmlamp_ohwr]: sta: 0x%08X\n", arg); + } + + if (dac_data_from_wb_str != NULL) { + uint32_t dac_data_from_wb = strtoul (dac_data_from_wb_str, NULL, 10); + halcs_client_err_e err = halcs_set_rtmlamp_ohwr_dac_data_from_wb (halcs_client, service, dac_data_from_wb); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:rtmlamp_ohwr]: halcs_set_rtmlamp_ohwr_dac_data_from_wb failed\n"); + goto err_halcs_set; + } + + uint32_t arg = 0; + halcs_get_rtmlamp_ohwr_dac_data_from_wb (halcs_client, service, &arg); + printf ("[client:rtmlamp_ohwr]: dac_data_from_wb: 0x%08X\n", arg); + } + + uint32_t chan; + for (chan = chan_min; chan < chan_max; ++chan) { + if (amp_iflag_l_sel == 1) { + uint32_t amp_iflag_l = 0; + halcs_client_err_e err = halcs_get_rtmlamp_ohwr_amp_iflag_l (halcs_client, service, chan, &_iflag_l); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:rtmlamp_ohwr]: halcs_get_rtmlamp_ohwr_amp_iflag_l failed\n"); + goto err_halcs_set; + } + printf ("[client:rtmlamp_ohwr]: amp_iflag_l: 0x%08X\n", amp_iflag_l); + } + + if (amp_tflag_l_sel == 1) { + uint32_t amp_tflag_l = 0; + halcs_client_err_e err = halcs_get_rtmlamp_ohwr_amp_tflag_l (halcs_client, service, chan, &_tflag_l); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:rtmlamp_ohwr]: halcs_get_rtmlamp_ohwr_amp_tflag_l failed\n"); + goto err_halcs_set; + } + printf ("[client:rtmlamp_ohwr]: amp_tflag_l: 0x%08X\n", amp_tflag_l); + } + + if (amp_iflag_r_sel == 1) { + uint32_t amp_iflag_r = 0; + halcs_client_err_e err = halcs_get_rtmlamp_ohwr_amp_iflag_r (halcs_client, service, chan, &_iflag_r); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:rtmlamp_ohwr]: halcs_get_rtmlamp_ohwr_amp_iflag_r failed\n"); + goto err_halcs_set; + } + printf ("[client:rtmlamp_ohwr]: amp_iflag_r: 0x%08X\n", amp_iflag_r); + } + + if (amp_tflag_r_sel == 1) { + uint32_t amp_tflag_r = 0; + halcs_client_err_e err = halcs_get_rtmlamp_ohwr_amp_tflag_r (halcs_client, service, chan, &_tflag_r); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:rtmlamp_ohwr]: halcs_get_rtmlamp_ohwr_amp_tflag_r failed\n"); + goto err_halcs_set; + } + printf ("[client:rtmlamp_ohwr]: amp_tflag_r: 0x%08X\n", amp_tflag_r); + } + + uint32_t amp_en = 0; + if (amp_en_str != NULL) { + amp_en = strtoul (amp_en_str, NULL, 10); + halcs_client_err_e err = halcs_set_rtmlamp_ohwr_amp_en (halcs_client, service, chan, amp_en); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:rtmlamp_ohwr]: halcs_set_rtmlamp_ohwr_amp_en failed\n"); + goto err_halcs_set; + } + + uint32_t arg = 0; + halcs_get_rtmlamp_ohwr_amp_en (halcs_client, service, chan, &arg); + printf ("[client:rtmlamp_ohwr]: halcs_set_rtmlamp_ohwr_amp_en: 0x%08X\n", arg); + } + + uint32_t dac_data = 0; + if (dac_data_str != NULL) { + dac_data = strtoul (dac_data_str, NULL, 10); + halcs_client_err_e err = halcs_set_rtmlamp_ohwr_dac_data (halcs_client, service, chan, dac_data); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:rtmlamp_ohwr]: halcs_set_rtmlamp_ohwr_dac_data failed\n"); + goto err_halcs_set; + } + + uint32_t arg = 0; + halcs_get_rtmlamp_ohwr_dac_data (halcs_client, service, chan, &arg); + printf ("[client:rtmlamp_ohwr]: dac_data: 0x%08X\n", arg); + } + + uint32_t dac_wr = 0; + if (dac_wr_str != NULL) { + dac_wr = strtoul (dac_wr_str, NULL, 10); + halcs_client_err_e err = halcs_set_rtmlamp_ohwr_dac_wr (halcs_client, service, chan, dac_wr); + if (err != HALCS_CLIENT_SUCCESS){ + fprintf (stderr, "[client:rtmlamp_ohwr]: halcs_set_rtmlamp_ohwr_dac_wr failed\n"); + goto err_halcs_set; + } + + uint32_t arg = 0; + halcs_get_rtmlamp_ohwr_dac_wr (halcs_client, service, chan, &arg); + printf ("[client:rtmlamp_ohwr]: halcs_get_rtmlamp_ohwr_rcv_src: 0x%08X\n", arg); + } + } + +err_halcs_set: +err_halcs_client_new: + free (dac_wr_str); + dac_wr_str = NULL; + free (dac_data_str); + dac_data_str = NULL; + free (dac_data_from_wb_str); + dac_data_from_wb_str = NULL; + free (amp_en_str); + amp_en_str = NULL; + free (chan_str); + chan_str = NULL; + free (board_number_str); + board_number_str = NULL; + free (halcs_number_str); + halcs_number_str = NULL; + free (broker_endp); + broker_endp = NULL; + halcs_client_destroy (&halcs_client); + + return 0; +} From cadb65d362a7112da909f61b8f40d3ffc61433c8 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Wed, 10 Mar 2021 14:12:43 -0300 Subject: [PATCH 33/40] halcs_generic_udev: add fallback option to start halcs if it can't match gateware --- .../init-generic/share/halcs/scripts/run-fpga-program.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/apps/halcs_generic_udev/init-generic/share/halcs/scripts/run-fpga-program.sh b/src/apps/halcs_generic_udev/init-generic/share/halcs/scripts/run-fpga-program.sh index 7729638a..a3fee787 100755 --- a/src/apps/halcs_generic_udev/init-generic/share/halcs/scripts/run-fpga-program.sh +++ b/src/apps/halcs_generic_udev/init-generic/share/halcs/scripts/run-fpga-program.sh @@ -58,9 +58,14 @@ for i in $(seq 1 "${#HALCS_IDXS[@]}"); do pbpm-gw*) START_PROGRAM="/usr/bin/systemctl --no-block start halcs-ioc@${HALCS_IDXS[$prog_inst]}.target" ;; + *) - echo "Invalid Gateware: "${GATEWARE_NAME} >&2 - exit 2 + # Only start HALCSs for even-numbered instances, as there is no device for odd-numbered instances + if [ $((prog_inst%2)) -eq 0 ]; then + START_PROGRAM="/usr/bin/systemctl --no-block start halcs-be@${HALCS_IDXS[$prog_inst]}.service" + else + START_PROGRAM="" + fi ;; esac From 0132a0a408909aaa4fbe22a74bec2a7088a33bf4 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Fri, 19 Mar 2021 14:23:05 -0300 Subject: [PATCH 34/40] examples: fix wrong action flags for rtmlamp_ohwr_ctl example --- examples/src/rtmlamp_ohwr_ctl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/src/rtmlamp_ohwr_ctl.c b/examples/src/rtmlamp_ohwr_ctl.c index e52b5ed8..f7ddd8ef 100644 --- a/examples/src/rtmlamp_ohwr_ctl.c +++ b/examples/src/rtmlamp_ohwr_ctl.c @@ -125,19 +125,19 @@ int main (int argc, char *argv []) break; case 'r': - amp_iflag_l_sel = 0; + amp_iflag_l_sel = 1; break; case 'p': - amp_tflag_l_sel = 0; + amp_tflag_l_sel = 1; break; case 'a': - amp_iflag_r_sel = 0; + amp_iflag_r_sel = 1; break; case 't': - amp_iflag_r_sel = 0; + amp_iflag_r_sel = 1; break; case 'u': From 11e5eac6982fde0f94793771d28ce5b6dbb491e6 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Fri, 19 Mar 2021 15:48:37 -0300 Subject: [PATCH 35/40] various: prepare version number for next release v2.4.0 --- examples/include/halcs_examples_classes.h | 2 +- include/revision.h | 2 +- libs/acqclient/include/acq_client_classes.h | 2 +- libs/bpmclient/include/bpm_client_classes.h | 2 +- libs/convc/include/convc_classes.h | 2 +- libs/disptable/include/disptable_classes.h | 2 +- libs/errhand/include/errhand_classes.h | 2 +- libs/hutils/include/hutils_classes.h | 2 +- libs/llio/include/ll_io_classes.h | 2 +- libs/sdbutils/include/sdbutils_classes.h | 2 +- src/client/include/halcs_client_classes.h | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/include/halcs_examples_classes.h b/examples/include/halcs_examples_classes.h index 781ad12e..3d36df14 100644 --- a/examples/include/halcs_examples_classes.h +++ b/examples/include/halcs_examples_classes.h @@ -11,7 +11,7 @@ /* version macros for compile-time API detection */ #define HALCS_EXAMPLES_VERSION_MAJOR 2 -#define HALCS_EXAMPLES_VERSION_MINOR 3 +#define HALCS_EXAMPLES_VERSION_MINOR 4 #define HALCS_EXAMPLES_VERSION_PATCH 0 #define HALCS_EXAMPLES_MAKE_VERSION(major, minor, patch) \ diff --git a/include/revision.h b/include/revision.h index 1a9750bf..415ac43f 100644 --- a/include/revision.h +++ b/include/revision.h @@ -14,7 +14,7 @@ /* HALCS version macros for compile-time API detection */ #define HALCS_VERSION_MAJOR 2 -#define HALCS_VERSION_MINOR 3 +#define HALCS_VERSION_MINOR 4 #define HALCS_VERSION_PATCH 0 #define HALCS_MAKE_VERSION(major, minor, patch) \ diff --git a/libs/acqclient/include/acq_client_classes.h b/libs/acqclient/include/acq_client_classes.h index 27ab79a4..ae437839 100644 --- a/libs/acqclient/include/acq_client_classes.h +++ b/libs/acqclient/include/acq_client_classes.h @@ -25,7 +25,7 @@ /* version macros for compile-time API detection */ #define ACQ_CLIENT_VERSION_MAJOR 2 -#define ACQ_CLIENT_VERSION_MINOR 3 +#define ACQ_CLIENT_VERSION_MINOR 4 #define ACQ_CLIENT_VERSION_PATCH 0 #define ACQ_CLIENT_MAKE_VERSION(major, minor, patch) \ diff --git a/libs/bpmclient/include/bpm_client_classes.h b/libs/bpmclient/include/bpm_client_classes.h index 659cf10b..4c38e2dc 100644 --- a/libs/bpmclient/include/bpm_client_classes.h +++ b/libs/bpmclient/include/bpm_client_classes.h @@ -22,7 +22,7 @@ /* version macros for compile-time API detection */ #define BPM_CLIENT_VERSION_MAJOR 2 -#define BPM_CLIENT_VERSION_MINOR 3 +#define BPM_CLIENT_VERSION_MINOR 4 #define BPM_CLIENT_VERSION_PATCH 0 #define BPM_CLIENT_MAKE_VERSION(major, minor, patch) \ diff --git a/libs/convc/include/convc_classes.h b/libs/convc/include/convc_classes.h index f3664a94..e480d424 100644 --- a/libs/convc/include/convc_classes.h +++ b/libs/convc/include/convc_classes.h @@ -18,7 +18,7 @@ /* version macros for compile-time API detection */ #define CONVC_VERSION_MAJOR 2 -#define CONVC_VERSION_MINOR 3 +#define CONVC_VERSION_MINOR 4 #define CONVC_VERSION_PATCH 0 #define CONVC_MAKE_VERSION(major, minor, patch) \ diff --git a/libs/disptable/include/disptable_classes.h b/libs/disptable/include/disptable_classes.h index fbbf2beb..1473524f 100644 --- a/libs/disptable/include/disptable_classes.h +++ b/libs/disptable/include/disptable_classes.h @@ -21,7 +21,7 @@ /* version macros for compile-time API detection */ #define DISPTABLE_VERSION_MAJOR 2 -#define DISPTABLE_VERSION_MINOR 3 +#define DISPTABLE_VERSION_MINOR 4 #define DISPTABLE_VERSION_PATCH 0 #define DISPTABLE_MAKE_VERSION(major, minor, patch) \ diff --git a/libs/errhand/include/errhand_classes.h b/libs/errhand/include/errhand_classes.h index c6be8d4c..b92323c6 100644 --- a/libs/errhand/include/errhand_classes.h +++ b/libs/errhand/include/errhand_classes.h @@ -20,7 +20,7 @@ /* version macros for compile-time API detection */ #define ERRHAND_VERSION_MAJOR 2 -#define ERRHAND_VERSION_MINOR 3 +#define ERRHAND_VERSION_MINOR 4 #define ERRHAND_VERSION_PATCH 0 #define ERRHAND_MAKE_VERSION(major, minor, patch) \ diff --git a/libs/hutils/include/hutils_classes.h b/libs/hutils/include/hutils_classes.h index 45f897f7..591375c2 100644 --- a/libs/hutils/include/hutils_classes.h +++ b/libs/hutils/include/hutils_classes.h @@ -18,7 +18,7 @@ /* version macros for compile-time API detection */ #define HUTILS_VERSION_MAJOR 2 -#define HUTILS_VERSION_MINOR 3 +#define HUTILS_VERSION_MINOR 4 #define HUTILS_VERSION_PATCH 0 #define HUTILS_MAKE_VERSION(major, minor, patch) \ diff --git a/libs/llio/include/ll_io_classes.h b/libs/llio/include/ll_io_classes.h index 680962fc..f6e24f6d 100644 --- a/libs/llio/include/ll_io_classes.h +++ b/libs/llio/include/ll_io_classes.h @@ -19,7 +19,7 @@ /* HALCS version macros for compile-time API detection */ #define LL_IO_VERSION_MAJOR 2 -#define LL_IO_VERSION_MINOR 3 +#define LL_IO_VERSION_MINOR 4 #define LL_IO_VERSION_PATCH 0 #define LL_IO_MAKE_VERSION(major, minor, patch) \ diff --git a/libs/sdbutils/include/sdbutils_classes.h b/libs/sdbutils/include/sdbutils_classes.h index 5e64ebfc..fc0820cb 100644 --- a/libs/sdbutils/include/sdbutils_classes.h +++ b/libs/sdbutils/include/sdbutils_classes.h @@ -16,7 +16,7 @@ /* version macros for compile-time API detection */ #define SDBUTILS_VERSION_MAJOR 2 -#define SDBUTILS_VERSION_MINOR 3 +#define SDBUTILS_VERSION_MINOR 4 #define SDBUTILS_VERSION_PATCH 0 #define SDBUTILS_MAKE_VERSION(major, minor, patch) \ diff --git a/src/client/include/halcs_client_classes.h b/src/client/include/halcs_client_classes.h index bc0edd70..e94809fb 100644 --- a/src/client/include/halcs_client_classes.h +++ b/src/client/include/halcs_client_classes.h @@ -25,7 +25,7 @@ /* HALCS version macros for compile-time API detection */ #define HALCS_CLIENT_VERSION_MAJOR 2 -#define HALCS_CLIENT_VERSION_MINOR 3 +#define HALCS_CLIENT_VERSION_MINOR 4 #define HALCS_CLIENT_VERSION_PATCH 0 #define HALCS_CLIENT_MAKE_VERSION(major, minor, patch) \ From a9ba5b68598d5149dd7513567af6cdb75a8f1572 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Mon, 22 Mar 2021 15:43:27 -0300 Subject: [PATCH 36/40] examples: add debug flags to examples --- examples/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index dfb39721..2b82b640 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -250,8 +250,8 @@ set(gcc_c "$<$:$>") set(clang_c "$<$:$>") target_compile_options(halcs_examples_compiler_flags INTERFACE - "$<${gcc_c}:$>" - "$<${clang_c}:$>" + "$<${gcc_c}:$>" + "$<${clang_c}:$>" ) # add binaries to bin_target_outputs From 05675f2a0e6c9e7362f04c8eeb00400104eae28f Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Mon, 22 Mar 2021 15:50:00 -0300 Subject: [PATCH 37/40] */CMakeLists.txt: add RPM debuginfo package generation --- examples/CMakeLists.txt | 3 +++ libs/acqclient/CMakeLists.txt | 3 +++ libs/bpmclient/CMakeLists.txt | 3 +++ libs/convc/CMakeLists.txt | 3 +++ libs/disptable/CMakeLists.txt | 3 +++ libs/errhand/CMakeLists.txt | 3 +++ libs/hutils/CMakeLists.txt | 3 +++ libs/llio/CMakeLists.txt | 3 +++ libs/sdbfs/CMakeLists.txt | 3 +++ libs/sdbutils/CMakeLists.txt | 3 +++ src/apps/halcs_generic_udev/CMakeLists.txt | 3 +++ src/apps/halcsd/CMakeLists.txt | 3 +++ src/client/CMakeLists.txt | 3 +++ 13 files changed, 39 insertions(+) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 2b82b640..e63e26de 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -541,6 +541,9 @@ if(ENABLE_CPACK) set(CPACK_PACKAGE_VERSION_PATCH ${halcs_examples_VERSION_PATCH}) # set(CPACK_PACKAGE_INSTALL_DIRECTORY "HALCS examples Install Directory") # set(CPACK_TEMPORARY_DIRECTORY "HALCS examples Temporary CPack Directory") + # Generate debuginfo package + set(CPACK_RPM_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") include(CPack) diff --git a/libs/acqclient/CMakeLists.txt b/libs/acqclient/CMakeLists.txt index f1461804..02827353 100644 --- a/libs/acqclient/CMakeLists.txt +++ b/libs/acqclient/CMakeLists.txt @@ -536,6 +536,9 @@ if(ENABLE_CPACK) set(CPACK_PACKAGE_VERSION_PATCH ${acqclient_VERSION_PATCH}) # set(CPACK_PACKAGE_INSTALL_DIRECTORY "acqclient Install Directory") # set(CPACK_TEMPORARY_DIRECTORY "acqclient Temporary CPack Directory") + # Generate debuginfo package + set(CPACK_RPM_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") include(CPack) diff --git a/libs/bpmclient/CMakeLists.txt b/libs/bpmclient/CMakeLists.txt index 698f78fe..36a269b5 100644 --- a/libs/bpmclient/CMakeLists.txt +++ b/libs/bpmclient/CMakeLists.txt @@ -559,6 +559,9 @@ if(ENABLE_CPACK) set(CPACK_PACKAGE_VERSION_PATCH ${bpmclient_VERSION_PATCH}) # set(CPACK_PACKAGE_INSTALL_DIRECTORY "bpmclient Install Directory") # set(CPACK_TEMPORARY_DIRECTORY "bpmclient Temporary CPack Directory") + # Generate debuginfo package + set(CPACK_RPM_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") include(CPack) diff --git a/libs/convc/CMakeLists.txt b/libs/convc/CMakeLists.txt index 40f1025f..4cbe1dc4 100644 --- a/libs/convc/CMakeLists.txt +++ b/libs/convc/CMakeLists.txt @@ -430,6 +430,9 @@ if(ENABLE_CPACK) set(CPACK_PACKAGE_VERSION_PATCH ${convc_VERSION_PATCH}) # set(CPACK_PACKAGE_INSTALL_DIRECTORY "convc Install Directory") # set(CPACK_TEMPORARY_DIRECTORY "convc Temporary CPack Directory") + # Generate debuginfo package + set(CPACK_RPM_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") include(CPack) diff --git a/libs/disptable/CMakeLists.txt b/libs/disptable/CMakeLists.txt index 68e261df..3d7c7258 100644 --- a/libs/disptable/CMakeLists.txt +++ b/libs/disptable/CMakeLists.txt @@ -453,6 +453,9 @@ if(ENABLE_CPACK) set(CPACK_PACKAGE_VERSION_PATCH ${disptable_VERSION_PATCH}) # set(CPACK_PACKAGE_INSTALL_DIRECTORY "disptable Install Directory") # set(CPACK_TEMPORARY_DIRECTORY "disptable Temporary CPack Directory") + # Generate debuginfo package + set(CPACK_RPM_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") include(CPack) diff --git a/libs/errhand/CMakeLists.txt b/libs/errhand/CMakeLists.txt index dfdcec1a..c6829ef8 100644 --- a/libs/errhand/CMakeLists.txt +++ b/libs/errhand/CMakeLists.txt @@ -474,6 +474,9 @@ if(ENABLE_CPACK) set(CPACK_PACKAGE_VERSION_PATCH ${errhand_VERSION_PATCH}) # set(CPACK_PACKAGE_INSTALL_DIRECTORY "errhand Install Directory") # set(CPACK_TEMPORARY_DIRECTORY "errhand Temporary CPack Directory") + # Generate debuginfo package + set(CPACK_RPM_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") include(CPack) diff --git a/libs/hutils/CMakeLists.txt b/libs/hutils/CMakeLists.txt index f6afd2e2..241ef0cb 100644 --- a/libs/hutils/CMakeLists.txt +++ b/libs/hutils/CMakeLists.txt @@ -461,6 +461,9 @@ if(ENABLE_CPACK) set(CPACK_PACKAGE_VERSION_PATCH ${hutils_VERSION_PATCH}) # set(CPACK_PACKAGE_INSTALL_DIRECTORY "hutils Install Directory") # set(CPACK_TEMPORARY_DIRECTORY "hutils Temporary CPack Directory") + # Generate debuginfo package + set(CPACK_RPM_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") include(CPack) diff --git a/libs/llio/CMakeLists.txt b/libs/llio/CMakeLists.txt index 9bb9fca8..7d899e7e 100644 --- a/libs/llio/CMakeLists.txt +++ b/libs/llio/CMakeLists.txt @@ -520,6 +520,9 @@ if(ENABLE_CPACK) set(CPACK_PACKAGE_VERSION_PATCH ${llio_VERSION_PATCH}) # set(CPACK_PACKAGE_INSTALL_DIRECTORY "llio Install Directory") # set(CPACK_TEMPORARY_DIRECTORY "llio Temporary CPack Directory") + # Generate debuginfo package + set(CPACK_RPM_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") include(CPack) diff --git a/libs/sdbfs/CMakeLists.txt b/libs/sdbfs/CMakeLists.txt index 5b38650e..1b8bd9ff 100644 --- a/libs/sdbfs/CMakeLists.txt +++ b/libs/sdbfs/CMakeLists.txt @@ -664,6 +664,9 @@ if(ENABLE_CPACK) set(CPACK_PACKAGE_VERSION_PATCH ${sdbfs_VERSION_PATCH}) # set(CPACK_PACKAGE_INSTALL_DIRECTORY "sdbfs Install Directory") # set(CPACK_TEMPORARY_DIRECTORY "sdbfs Temporary CPack Directory") + # Generate debuginfo package + set(CPACK_RPM_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") include(CPack) diff --git a/libs/sdbutils/CMakeLists.txt b/libs/sdbutils/CMakeLists.txt index 41da2217..e16bbfce 100644 --- a/libs/sdbutils/CMakeLists.txt +++ b/libs/sdbutils/CMakeLists.txt @@ -407,6 +407,9 @@ if(ENABLE_CPACK) set(CPACK_PACKAGE_VERSION_PATCH ${sdbutils_VERSION_PATCH}) # set(CPACK_PACKAGE_INSTALL_DIRECTORY "sdbutils Install Directory") # set(CPACK_TEMPORARY_DIRECTORY "sdbutils Temporary CPack Directory") + # Generate debuginfo package + set(CPACK_RPM_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") include(CPack) diff --git a/src/apps/halcs_generic_udev/CMakeLists.txt b/src/apps/halcs_generic_udev/CMakeLists.txt index 9e9fba34..1eb59a83 100644 --- a/src/apps/halcs_generic_udev/CMakeLists.txt +++ b/src/apps/halcs_generic_udev/CMakeLists.txt @@ -176,6 +176,9 @@ if(ENABLE_CPACK) set(CPACK_PACKAGE_VERSION_PATCH ${halcs_VERSION_PATCH}) # set(CPACK_PACKAGE_INSTALL_DIRECTORY "HALCS generic udev Install Directory") # set(CPACK_TEMPORARY_DIRECTORY "HALCS generic udev Temporary CPack Directory") + # Generate debuginfo package + set(CPACK_RPM_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") include(CPack) diff --git a/src/apps/halcsd/CMakeLists.txt b/src/apps/halcsd/CMakeLists.txt index 154497ea..d4556818 100644 --- a/src/apps/halcsd/CMakeLists.txt +++ b/src/apps/halcsd/CMakeLists.txt @@ -509,6 +509,9 @@ if(ENABLE_CPACK) set(CPACK_PACKAGE_VERSION_PATCH ${halcs_VERSION_PATCH}) # set(CPACK_PACKAGE_INSTALL_DIRECTORY "halcsd Install Directory") # set(CPACK_TEMPORARY_DIRECTORY "halcsd Temporary CPack Directory") + # Generate debuginfo package + set(CPACK_RPM_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") include(CPack) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 9e19505c..07ad4fce 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -822,6 +822,9 @@ if(ENABLE_CPACK) set(CPACK_PACKAGE_VERSION_PATCH ${halcsclient_VERSION_PATCH}) # set(CPACK_PACKAGE_INSTALL_DIRECTORY "halcsclient Install Directory") # set(CPACK_TEMPORARY_DIRECTORY "halcsclient Temporary CPack Directory") + # Generate debuginfo package + set(CPACK_RPM_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") include(CPack) From 05114238dd1af529440c9d40a76086da6bd65b3d Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Mon, 22 Mar 2021 15:53:43 -0300 Subject: [PATCH 38/40] */CMakeLists.txt: add DEBIAN debuginfo package generation --- examples/CMakeLists.txt | 2 ++ libs/acqclient/CMakeLists.txt | 2 ++ libs/bpmclient/CMakeLists.txt | 2 ++ libs/convc/CMakeLists.txt | 2 ++ libs/disptable/CMakeLists.txt | 2 ++ libs/errhand/CMakeLists.txt | 2 ++ libs/hutils/CMakeLists.txt | 2 ++ libs/llio/CMakeLists.txt | 2 ++ libs/sdbfs/CMakeLists.txt | 2 ++ libs/sdbutils/CMakeLists.txt | 2 ++ src/apps/halcs_generic_udev/CMakeLists.txt | 2 ++ src/apps/halcsd/CMakeLists.txt | 2 ++ src/client/CMakeLists.txt | 2 ++ 13 files changed, 26 insertions(+) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e63e26de..2b0c7e94 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -510,6 +510,8 @@ if(ENABLE_CPACK) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + # Generate debuginfo package + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_PACKAGE_AUTOREQ no) set(CPACK_RPM_PACKAGE_AUTOPROV yes) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION diff --git a/libs/acqclient/CMakeLists.txt b/libs/acqclient/CMakeLists.txt index 02827353..3293108d 100644 --- a/libs/acqclient/CMakeLists.txt +++ b/libs/acqclient/CMakeLists.txt @@ -505,6 +505,8 @@ if(ENABLE_CPACK) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + # Generate debuginfo package + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_PACKAGE_AUTOREQ no) set(CPACK_RPM_PACKAGE_AUTOPROV yes) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION diff --git a/libs/bpmclient/CMakeLists.txt b/libs/bpmclient/CMakeLists.txt index 36a269b5..7fdd0975 100644 --- a/libs/bpmclient/CMakeLists.txt +++ b/libs/bpmclient/CMakeLists.txt @@ -528,6 +528,8 @@ if(ENABLE_CPACK) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + # Generate debuginfo package + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_PACKAGE_AUTOREQ no) set(CPACK_RPM_PACKAGE_AUTOPROV yes) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION diff --git a/libs/convc/CMakeLists.txt b/libs/convc/CMakeLists.txt index 4cbe1dc4..f185c7d4 100644 --- a/libs/convc/CMakeLists.txt +++ b/libs/convc/CMakeLists.txt @@ -399,6 +399,8 @@ if(ENABLE_CPACK) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + # Generate debuginfo package + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_PACKAGE_AUTOREQ no) set(CPACK_RPM_PACKAGE_AUTOPROV yes) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION diff --git a/libs/disptable/CMakeLists.txt b/libs/disptable/CMakeLists.txt index 3d7c7258..2413248b 100644 --- a/libs/disptable/CMakeLists.txt +++ b/libs/disptable/CMakeLists.txt @@ -422,6 +422,8 @@ if(ENABLE_CPACK) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + # Generate debuginfo package + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_PACKAGE_AUTOREQ no) set(CPACK_RPM_PACKAGE_AUTOPROV yes) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION diff --git a/libs/errhand/CMakeLists.txt b/libs/errhand/CMakeLists.txt index c6829ef8..ccbe2d75 100644 --- a/libs/errhand/CMakeLists.txt +++ b/libs/errhand/CMakeLists.txt @@ -443,6 +443,8 @@ if(ENABLE_CPACK) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + # Generate debuginfo package + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_PACKAGE_AUTOREQ no) set(CPACK_RPM_PACKAGE_AUTOPROV yes) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION diff --git a/libs/hutils/CMakeLists.txt b/libs/hutils/CMakeLists.txt index 241ef0cb..88d3f122 100644 --- a/libs/hutils/CMakeLists.txt +++ b/libs/hutils/CMakeLists.txt @@ -430,6 +430,8 @@ if(ENABLE_CPACK) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + # Generate debuginfo package + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_PACKAGE_AUTOREQ no) set(CPACK_RPM_PACKAGE_AUTOPROV yes) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION diff --git a/libs/llio/CMakeLists.txt b/libs/llio/CMakeLists.txt index 7d899e7e..fabfa69f 100644 --- a/libs/llio/CMakeLists.txt +++ b/libs/llio/CMakeLists.txt @@ -489,6 +489,8 @@ if(ENABLE_CPACK) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + # Generate debuginfo package + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_PACKAGE_AUTOREQ no) set(CPACK_RPM_PACKAGE_AUTOPROV yes) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION diff --git a/libs/sdbfs/CMakeLists.txt b/libs/sdbfs/CMakeLists.txt index 1b8bd9ff..c7c83497 100644 --- a/libs/sdbfs/CMakeLists.txt +++ b/libs/sdbfs/CMakeLists.txt @@ -633,6 +633,8 @@ if(ENABLE_CPACK) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + # Generate debuginfo package + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_PACKAGE_AUTOREQ no) set(CPACK_RPM_PACKAGE_AUTOPROV yes) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION diff --git a/libs/sdbutils/CMakeLists.txt b/libs/sdbutils/CMakeLists.txt index e16bbfce..8c5972e3 100644 --- a/libs/sdbutils/CMakeLists.txt +++ b/libs/sdbutils/CMakeLists.txt @@ -376,6 +376,8 @@ if(ENABLE_CPACK) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + # Generate debuginfo package + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_PACKAGE_AUTOREQ no) set(CPACK_RPM_PACKAGE_AUTOPROV yes) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION diff --git a/src/apps/halcs_generic_udev/CMakeLists.txt b/src/apps/halcs_generic_udev/CMakeLists.txt index 1eb59a83..275b95fa 100644 --- a/src/apps/halcs_generic_udev/CMakeLists.txt +++ b/src/apps/halcs_generic_udev/CMakeLists.txt @@ -145,6 +145,8 @@ if(ENABLE_CPACK) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + # Generate debuginfo package + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_PACKAGE_AUTOREQ no) set(CPACK_RPM_PACKAGE_AUTOPROV yes) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION diff --git a/src/apps/halcsd/CMakeLists.txt b/src/apps/halcsd/CMakeLists.txt index d4556818..ae86956e 100644 --- a/src/apps/halcsd/CMakeLists.txt +++ b/src/apps/halcsd/CMakeLists.txt @@ -475,6 +475,8 @@ if(ENABLE_CPACK) # we also depend on malamute >= 1.0, but this has not been packaged into the official # repositories yet set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsodium-dev (>= 1.0.8), libzmq3-dev (>= 4.2.5), libczmq-dev (>= 4.0.2), dkms") + # Generate debuginfo package + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_PACKAGE_AUTOREQ no) set(CPACK_RPM_PACKAGE_AUTOPROV yes) # we also depend on malamute >= 1.0, but this has not been packaged into the official diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 07ad4fce..41842ea8 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -791,6 +791,8 @@ if(ENABLE_CPACK) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + # Generate debuginfo package + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_PACKAGE_AUTOREQ no) set(CPACK_RPM_PACKAGE_AUTOPROV yes) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION From 43e9e8a3325d07bf040373978510d781625a7498 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Mon, 22 Mar 2021 18:15:40 -0300 Subject: [PATCH 39/40] sm_io/*/acq: fix buffer overrun when > END_CHAN_ID channels | > NUM_ACQ_CORE_SMIOS --- src/sm_io/modules/acq/sm_io_acq_core.c | 29 +++++++++++++++++--------- src/sm_io/modules/acq/sm_io_acq_core.h | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/sm_io/modules/acq/sm_io_acq_core.c b/src/sm_io/modules/acq/sm_io_acq_core.c index 9a298368..b5685cf5 100644 --- a/src/sm_io/modules/acq/sm_io_acq_core.c +++ b/src/sm_io/modules/acq/sm_io_acq_core.c @@ -79,6 +79,9 @@ smio_acq_t * smio_acq_new (smio_t *parent, uint32_t num_samples_pre, self->curr_chan = 0; + uint32_t __acq_buf_max_inst_id = ARRAY_SIZE(__acq_buf)-1; + uint32_t __acq_buf_max_chan = ARRAY_SIZE(__acq_buf[0])-1; + /* Initialize sample_size and max_samples for acq_buf */ for (uint32_t i = 0; i < self->num_chan; i++) { /* These are all in bit sizes */ @@ -91,9 +94,14 @@ smio_acq_t * smio_acq_new (smio_t *parent, uint32_t num_samples_pre, uint32_t max_samples = 0; uint32_t first_addr = 0; uint32_t last_addr = 0; - uint32_t acq_buf_id = __acq_buf[inst_id][i].id; - uint32_t acq_buf_start_addr = __acq_buf[inst_id][i].start_addr; - uint32_t acq_buf_end_addr = __acq_buf[inst_id][i].end_addr; + uint32_t acq_buf_id = (inst_id > __acq_buf_max_inst_id || + i > __acq_buf_max_chan)? i : __acq_buf[inst_id][i].id; + uint32_t acq_buf_start_addr = (inst_id > __acq_buf_max_inst_id || + i > __acq_buf_max_chan)? (MEM_TOTAL_SIZE-MEM_REGION_SIZE) : + __acq_buf[inst_id][i].start_addr; + uint32_t acq_buf_end_addr =(inst_id > __acq_buf_max_inst_id || + i > __acq_buf_max_chan)? (MEM_TOTAL_SIZE-DDR3_DATA_WIDTH) : + __acq_buf[inst_id][i].end_addr; /* Get channel properties */ GET_PARAM_CHANNEL(parent, acq, 0x0, ACQ_CORE, CH0_DESC, INT_WIDTH, @@ -142,6 +150,10 @@ smio_acq_t * smio_acq_new (smio_t *parent, uint32_t num_samples_pre, self->acq_buf[i].end_addr, self->acq_buf[i].sample_size, self->acq_buf[i].max_samples); } + /* Initialize acq_params */ + self->acq_params = (acq_params_t *) zmalloc ((sizeof *self->acq_params) * self->num_chan); + ASSERT_ALLOC (self->acq_params, err_acq_params_alloc); + /* Set default value for all channels */ for (uint32_t i = 0; i < self->num_chan; i++) { self->acq_params[i].num_samples_pre = num_samples_pre; @@ -159,12 +171,6 @@ smio_acq_t * smio_acq_new (smio_t *parent, uint32_t num_samples_pre, self->acq_params[i].num_shots, self->acq_params[i].trig_addr); } - /* initilize acquisition buffer areas. Defined in ddr3_map.h */ - if (inst_id > NUM_ACQ_CORE_SMIOS-1) { - DBE_DEBUG (DBG_SM_IO | DBG_LVL_ERR, "[sm_io:acq_core] Instance ID invalid\n"); - return NULL; - } - #if 0 /* Get SDB info for this core */ smio_err_e err = SMIO_SUCCESS; @@ -186,6 +192,8 @@ smio_acq_t * smio_acq_new (smio_t *parent, uint32_t num_samples_pre, #if 0 err_sdb_info: #endif +err_acq_params_alloc: + free (self->acq_params); err_atom_width: err_num_atoms: err_num_coalesce: @@ -205,7 +213,8 @@ smio_err_e smio_acq_destroy (smio_acq_t **self_p) if (*self_p) { smio_acq_t *self = *self_p; - free(self->acq_buf); + free (self->acq_params); + free (self->acq_buf); free (self); *self_p = NULL; } diff --git a/src/sm_io/modules/acq/sm_io_acq_core.h b/src/sm_io/modules/acq/sm_io_acq_core.h index edb1b96a..79ce093d 100644 --- a/src/sm_io/modules/acq/sm_io_acq_core.h +++ b/src/sm_io/modules/acq/sm_io_acq_core.h @@ -48,7 +48,7 @@ typedef struct { typedef struct { sdbutils_info_t sdbutils_info; /* SDB information for this core */ - acq_params_t acq_params[END_CHAN_ID]; /* Parameters for each channel */ + acq_params_t *acq_params; /* Parameters for each channel */ uint32_t curr_chan; /* Current channel being acquired */ uint32_t num_chan; /* Numbert of acquisition channels */ uint32_t multishot_ram_size; /* Multishot RAM size, in acquistion words */ From 1b1b0d283089188a432a0a47dfdf5e346dcf9d97 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Mon, 22 Mar 2021 18:27:34 -0300 Subject: [PATCH 40/40] examples/*/acq: fix maximum number of channels --- examples/src/acq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/src/acq.c b/examples/src/acq.c index 59c4be5f..b0236651 100644 --- a/examples/src/acq.c +++ b/examples/src/acq.c @@ -367,7 +367,7 @@ int main (int argc, char *argv []) else { chan = strtoul (chan_str, NULL, 10); - if (chan > END_CHAN_ID-1) { + if (chan > MAX_NUM_CHANS-1) { fprintf (stderr, "[client:acq]: Channel number too big. Maximum number is: %u\n", MAX_NUM_CHANS); goto err_opt_exit;