eiger: deactivate at startup, hostname activates, config file for top or master, if none, reset to hardware, no binaries

This commit is contained in:
maliakal_d 2020-05-08 18:11:15 +02:00
parent 13c1f7c2d6
commit 30078d6c1f
8 changed files with 1333 additions and 1202 deletions

File diff suppressed because it is too large Load Diff

View File

@ -36,8 +36,8 @@ unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb);
void Beb_GetModuleConfiguration(int *master, int *top, int *normal);
int Beb_IsTransmitting(int *retval, int tengiga, int waitForDelay);
int Beb_SetTop(int val);
int Beb_SetMaster(int val);
int Beb_SetTop(enum TOPINDEX ind);
int Beb_SetMaster(enum MASTERINDEX ind);
int Beb_Activate(int enable);
int Beb_GetActivate();
int Beb_Set32bitOverflow(int val);

View File

@ -2459,7 +2459,7 @@ int Feb_Control_GetInterruptSubframe() {
return value[0];
}
int Feb_Control_SetTop(int val, int left, int right) {
int Feb_Control_SetTop(enum TOPINDEX ind, int left, int right) {
uint32_t offset = DAQ_REG_HRDWRE;
unsigned int addr[2] = {0, 0};
if (left) {
@ -2468,68 +2468,89 @@ int Feb_Control_SetTop(int val, int left, int right) {
if (right) {
addr[1] = Module_GetTopRightAddress(&modules[0]);
}
char *top_names[] = {TOP_NAMES};
int i = 0;
for (i = 0; i < 2; ++i) {
if (addr[i] == 0) {
continue;
}
uint32_t regVal = 0;
if (!Feb_Interface_ReadRegister(addr[i], offset, &regVal)) {
LOG(logERROR, ("Could not read %s DAQ_REG_HRDWRE reg\n",
uint32_t value = 0;
if (!Feb_Interface_ReadRegister(addr[i], offset, &value)) {
LOG(logERROR, ("Could not read %s Feb reg to set Top flag\n",
(i == 0 ? "left" : "right")));
return 0;
}
regVal |= DAQ_REG_HRDWRE_OW_TOP_MSK;
if (val) {
regVal |= DAQ_REG_HRDWRE_TOP_MSK;
} else {
regVal &= ~DAQ_REG_HRDWRE_TOP_MSK;
switch (ind) {
case TOP_HARDWARE:
value &= ~DAQ_REG_HRDWRE_OW_TOP_MSK;
break;
case OW_TOP:
value |= DAQ_REG_HRDWRE_OW_TOP_MSK;
value |= DAQ_REG_HRDWRE_TOP_MSK;
break;
case OW_BOTTOM:
value |= DAQ_REG_HRDWRE_OW_TOP_MSK;
value &= ~DAQ_REG_HRDWRE_TOP_MSK;
break;
default:
LOG(logERROR, ("Unknown top index in Feb: %d\n", ind));
return 0;
}
if (!Feb_Interface_WriteRegister(addr[i], offset, regVal, 0, 0)) {
LOG(logERROR,
("Could not overwrite top %d to %s DAQ_REG_HRDWRE reg\n", val,
(i == 0 ? "left" : "right")));
if (!Feb_Interface_WriteRegister(addr[i], offset, value, 0, 0)) {
LOG(logERROR, ("Could not set Top flag to %s in %s Feb\n", val,
top_names[ind], (i == 0 ? "left" : "right")));
return 0;
}
}
if (left && right) {
LOG(logINFOBLUE,
("Overwriting FEB Hardware: %s\n", (val ? "Top" : "Bottom")));
LOG(logINFOBLUE, ("%s Top flag to %s Feb\n",
(ind == TOP_HARDWARE ? "Resetting" : "Overwriting"),
top_names[ind]));
}
return 1;
}
int Feb_Control_SetMaster(int val) {
int Feb_Control_SetMaster(enum MASTERINDEX ind) {
uint32_t offset = DAQ_REG_HRDWRE;
unsigned int addr[2] = {0, 0};
addr[0] = Module_GetTopLeftAddress(&modules[0]);
addr[1] = Module_GetTopRightAddress(&modules[0]);
char *master_names[] = {MASTER_NAMES};
int i = 0;
for (i = 0; i < 2; ++i) {
uint32_t regVal = 0;
if (!Feb_Interface_ReadRegister(addr[i], offset, &regVal)) {
LOG(logERROR, ("Could not read %s DAQ_REG_HRDWRE reg\n",
uint32_t value = 0;
if (!Feb_Interface_ReadRegister(addr[i], offset, &value)) {
LOG(logERROR, ("Could not read %s Feb reg to set Master flag\n",
(i == 0 ? "left" : "right")));
return 0;
}
regVal |= DAQ_REG_HRDWRE_OW_MASTER_MSK;
if (val) {
regVal |= DAQ_REG_HRDWRE_MASTER_MSK;
} else {
regVal &= ~DAQ_REG_HRDWRE_MASTER_MSK;
switch (ind) {
case MASTER_HARDWARE:
value &= ~DAQ_REG_HRDWRE_OW_MASTER_MSK;
break;
case OW_MASTER:
value |= DAQ_REG_HRDWRE_OW_MASTER_MSK;
value |= DAQ_REG_HRDWRE_MASTER_MSK;
break;
case OW_SLAVE:
value |= DAQ_REG_HRDWRE_OW_MASTER_MSK;
value &= ~DAQ_REG_HRDWRE_MASTER_MSK;
break;
default:
LOG(logERROR, ("Unknown master index in Feb: %d\n", ind));
Beb_close(fd, csp0base);
return 0;
}
if (!Feb_Interface_WriteRegister(addr[i], offset, regVal, 0, 0)) {
LOG(logERROR,
("Could not write master %d to %s DAQ_REG_HRDWRE reg\n", val,
(i == 0 ? "left" : "right")));
if (!Feb_Interface_WriteRegister(addr[i], offset, value, 0, 0)) {
LOG(logERROR, ("Could not set Master flag to %s in %s Feb\n", val,
master_names[ind], (i == 0 ? "left" : "right")));
return 0;
}
}
Feb_control_master = 1;
LOG(logINFOBLUE,
("Overwriting FEB Hardware: %s\n", (val ? "Master" : "Slave")));
LOG(logINFOBLUE, ("%s Master flag to %s Feb\n",
(ind == MASTER_HARDWARE ? "Resetting" : "Overwriting"),
master_names[ind]));
return 1;
}

View File

@ -175,8 +175,8 @@ int Feb_Control_SoftwareTrigger();
int Feb_Control_SetInterruptSubframe(int val);
int Feb_Control_GetInterruptSubframe();
int Feb_Control_SetTop(int val, int left, int right);
int Feb_Control_SetMaster(int val);
int Feb_Control_SetTop(enum TOPINDEX ind, int left, int right);
int Feb_Control_SetMaster(enum MASTERINDEX ind);
int Feb_Control_SetQuad(int val);
int Feb_Control_SetReadNLines(int value);
int Feb_Control_GetReadNLines();

View File

@ -147,7 +147,7 @@
/** BEB Registers */
// module configuration - XPAR_PLB_GPIO_SYS_BASEADDR
#define BEB_CONFIG_OW_OFST (0x160) // 0x20 * 11 (P11)
#define BEB_CONFIG_WR_OFST (0x160) // 0x20 * 11 (P11)
#define BEB_CONFIG_MASTER_OFST (0)
#define BEB_CONFIG_MASTER_MSK (0x00000001 << BEB_CONFIG_MASTER_OFST)
#define BEB_CONFIG_OW_MASTER_OFST (1)

View File

@ -1,2 +1,2 @@
top 0
master 0
top 1
master 1

View File

@ -309,6 +309,14 @@ u_int32_t getDetectorIP() {
/* initialization */
void initControlServer() {
master = -1;
top = -1;
// force top or master if in config file
if (readConfigFile() == FAIL) {
return;
}
#ifdef VIRTUAL
if (initError == OK) {
getModuleConfiguration();
@ -352,7 +360,15 @@ void initControlServer() {
}
void initStopServer() {
master = -1;
top = -1;
#ifdef VIRTUAL
// force top or master if in config file
if (readConfigFile() == FAIL) {
return;
}
getModuleConfiguration();
virtual_stop = 0;
if (!isControlServer) {
@ -362,6 +378,9 @@ void initStopServer() {
LOG(logINFORED, ("Deactivated!\n"));
return;
#else
// wait till control server has configured top/master
usleep(2 * 1000 * 1000);
getModuleConfiguration();
Feb_Interface_FebInterface();
Feb_Control_FebControl();
@ -382,22 +401,33 @@ void initStopServer() {
void getModuleConfiguration() {
#ifdef VIRTUAL
// if master not modified by config file
if (master == -1) {
#ifdef VIRTUAL_MASTER
master = 1;
top = 1;
master = 1;
#else
master = 0;
#endif
}
// if top not modified by config file
if (top == -1) {
#ifdef VIRTUAL_MASTER
top = 1;
#else
master = 0;
#ifdef VIRTUAL_TOP
top = 1;
top = 1;
#else
top = 0;
top = 0;
#endif
#endif
}
#ifdef VIRTUAL_9M
normal = 0;
#else
normal = 1;
#endif
#else
// read detector id
char output[255];
@ -411,10 +441,6 @@ void getModuleConfiguration() {
Beb_GetModuleConfiguration(&master, &top, &normal);
#endif
if (readConfigFile() == FAIL) {
return;
}
if (isControlServer) {
LOG(logINFOBLUE,
("Module: %s %s %s\n", (top ? "TOP" : "BOTTOM"),
@ -476,7 +502,8 @@ int readConfigFile() {
break;
}
#ifndef VIRTUAL
if (Beb_SetTop(top) == FAIL) {
enum TOPINDEX ind = (top == 1 ? OW_TOP : OW_BOTTOM);
if (!Beb_SetTop(ind)) {
sprintf(
initErrorMessage,
"Could not overwrite top to %d in Beb from on-board server "
@ -484,7 +511,7 @@ int readConfigFile() {
top, line);
break;
}
if (Feb_Control_SetTop(top, 1, 1) == FAIL) {
if (!Feb_Control_SetTop(ind, 1, 1)) {
sprintf(
initErrorMessage,
"Could not overwrite top to %d in Feb from on-board server "
@ -506,7 +533,8 @@ int readConfigFile() {
break;
}
#ifndef VIRTUAL
if (Beb_SetMaster(master) == FAIL) {
enum MASTERINDEX ind = (master == 1 ? OW_MASTER : OW_SLAVE);
if (!Beb_SetMaster(ind)) {
sprintf(initErrorMessage,
"Could not overwrite master to %d in Beb from on-board "
"server "
@ -514,7 +542,7 @@ int readConfigFile() {
master, line);
break;
}
if (Feb_Control_SetMaster(master) == FAIL) {
if (!Feb_Control_SetMaster(ind)) {
sprintf(initErrorMessage,
"Could not overwrite master to %d in Feb from on-board "
"server "
@ -535,6 +563,39 @@ int readConfigFile() {
}
}
fclose(fd);
// reset to hardware settings if not in config file (if overwritten)
#ifndef VIRTUAL
if (top == -1) {
if (!Beb_SetTop(TOP_HARDWARE)) {
initError = FAIL;
sprintf(initErrorMessage,
"Could not reset Top flag to Beb hardware settings.\n");
return;
}
if (!Feb_Control_SetTop(TOP_HARDWARE, 1, 1)) {
initError = FAIL;
sprintf(initErrorMessage,
"Could not reset Top flag to Feb hardware settings.\n");
return;
}
}
if (master == -1) {
if (!Beb_SetMaster(TOP_HARDWARE)) {
initError = FAIL;
sprintf(initErrorMessage,
"Could not reset Master flag to Beb hardware settings.\n");
return;
}
if (!Feb_Control_SetMaster(TOP_HARDWARE)) {
initError = FAIL;
sprintf(initErrorMessage,
"Could not reset Master flag to Feb hardware settings.\n");
return;
}
}
#endif
if (strlen(initErrorMessage)) {
initError = FAIL;
LOG(logERROR, ("%s\n\n", initErrorMessage));

View File

@ -62,6 +62,11 @@ enum ADCINDEX {
enum NETWORKINDEX { TXN_LEFT, TXN_RIGHT, TXN_FRAME, FLOWCTRL_10G };
enum ROINDEX { E_PARALLEL, E_NON_PARALLEL };
enum CLKINDEX { RUN_CLK, NUM_CLOCKS };
enum TOPINDEX { TOP_HARDWARE, OW_TOP, OW_BOTTOM };
#define TOP_NAMES "hardware", "top", "bottom"
enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
#define MASTER_NAMES "hardware", "master", "slave"
#define CLK_NAMES "run"
/* Hardware Definitions */