mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-30 01:40:04 +02:00
eiger: deactivate at startup, hostname activates, config file for top or master, if none, reset to hardware, no binaries
This commit is contained in:
parent
13c1f7c2d6
commit
30078d6c1f
File diff suppressed because it is too large
Load Diff
@ -36,8 +36,8 @@ unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb);
|
|||||||
void Beb_GetModuleConfiguration(int *master, int *top, int *normal);
|
void Beb_GetModuleConfiguration(int *master, int *top, int *normal);
|
||||||
int Beb_IsTransmitting(int *retval, int tengiga, int waitForDelay);
|
int Beb_IsTransmitting(int *retval, int tengiga, int waitForDelay);
|
||||||
|
|
||||||
int Beb_SetTop(int val);
|
int Beb_SetTop(enum TOPINDEX ind);
|
||||||
int Beb_SetMaster(int val);
|
int Beb_SetMaster(enum MASTERINDEX ind);
|
||||||
int Beb_Activate(int enable);
|
int Beb_Activate(int enable);
|
||||||
int Beb_GetActivate();
|
int Beb_GetActivate();
|
||||||
int Beb_Set32bitOverflow(int val);
|
int Beb_Set32bitOverflow(int val);
|
||||||
|
@ -2459,7 +2459,7 @@ int Feb_Control_GetInterruptSubframe() {
|
|||||||
return value[0];
|
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;
|
uint32_t offset = DAQ_REG_HRDWRE;
|
||||||
unsigned int addr[2] = {0, 0};
|
unsigned int addr[2] = {0, 0};
|
||||||
if (left) {
|
if (left) {
|
||||||
@ -2468,68 +2468,89 @@ int Feb_Control_SetTop(int val, int left, int right) {
|
|||||||
if (right) {
|
if (right) {
|
||||||
addr[1] = Module_GetTopRightAddress(&modules[0]);
|
addr[1] = Module_GetTopRightAddress(&modules[0]);
|
||||||
}
|
}
|
||||||
|
char *top_names[] = {TOP_NAMES};
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (i = 0; i < 2; ++i) {
|
for (i = 0; i < 2; ++i) {
|
||||||
if (addr[i] == 0) {
|
if (addr[i] == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
uint32_t regVal = 0;
|
uint32_t value = 0;
|
||||||
if (!Feb_Interface_ReadRegister(addr[i], offset, ®Val)) {
|
if (!Feb_Interface_ReadRegister(addr[i], offset, &value)) {
|
||||||
LOG(logERROR, ("Could not read %s DAQ_REG_HRDWRE reg\n",
|
LOG(logERROR, ("Could not read %s Feb reg to set Top flag\n",
|
||||||
(i == 0 ? "left" : "right")));
|
(i == 0 ? "left" : "right")));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
regVal |= DAQ_REG_HRDWRE_OW_TOP_MSK;
|
switch (ind) {
|
||||||
if (val) {
|
case TOP_HARDWARE:
|
||||||
regVal |= DAQ_REG_HRDWRE_TOP_MSK;
|
value &= ~DAQ_REG_HRDWRE_OW_TOP_MSK;
|
||||||
} else {
|
break;
|
||||||
regVal &= ~DAQ_REG_HRDWRE_TOP_MSK;
|
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, value, 0, 0)) {
|
||||||
if (!Feb_Interface_WriteRegister(addr[i], offset, regVal, 0, 0)) {
|
LOG(logERROR, ("Could not set Top flag to %s in %s Feb\n", val,
|
||||||
LOG(logERROR,
|
top_names[ind], (i == 0 ? "left" : "right")));
|
||||||
("Could not overwrite top %d to %s DAQ_REG_HRDWRE reg\n", val,
|
|
||||||
(i == 0 ? "left" : "right")));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (left && right) {
|
if (left && right) {
|
||||||
LOG(logINFOBLUE,
|
LOG(logINFOBLUE, ("%s Top flag to %s Feb\n",
|
||||||
("Overwriting FEB Hardware: %s\n", (val ? "Top" : "Bottom")));
|
(ind == TOP_HARDWARE ? "Resetting" : "Overwriting"),
|
||||||
|
top_names[ind]));
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Feb_Control_SetMaster(int val) {
|
int Feb_Control_SetMaster(enum MASTERINDEX ind) {
|
||||||
uint32_t offset = DAQ_REG_HRDWRE;
|
uint32_t offset = DAQ_REG_HRDWRE;
|
||||||
unsigned int addr[2] = {0, 0};
|
unsigned int addr[2] = {0, 0};
|
||||||
addr[0] = Module_GetTopLeftAddress(&modules[0]);
|
addr[0] = Module_GetTopLeftAddress(&modules[0]);
|
||||||
addr[1] = Module_GetTopRightAddress(&modules[0]);
|
addr[1] = Module_GetTopRightAddress(&modules[0]);
|
||||||
|
char *master_names[] = {MASTER_NAMES};
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (i = 0; i < 2; ++i) {
|
for (i = 0; i < 2; ++i) {
|
||||||
uint32_t regVal = 0;
|
uint32_t value = 0;
|
||||||
if (!Feb_Interface_ReadRegister(addr[i], offset, ®Val)) {
|
if (!Feb_Interface_ReadRegister(addr[i], offset, &value)) {
|
||||||
LOG(logERROR, ("Could not read %s DAQ_REG_HRDWRE reg\n",
|
LOG(logERROR, ("Could not read %s Feb reg to set Master flag\n",
|
||||||
(i == 0 ? "left" : "right")));
|
(i == 0 ? "left" : "right")));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
regVal |= DAQ_REG_HRDWRE_OW_MASTER_MSK;
|
switch (ind) {
|
||||||
if (val) {
|
case MASTER_HARDWARE:
|
||||||
regVal |= DAQ_REG_HRDWRE_MASTER_MSK;
|
value &= ~DAQ_REG_HRDWRE_OW_MASTER_MSK;
|
||||||
} else {
|
break;
|
||||||
regVal &= ~DAQ_REG_HRDWRE_MASTER_MSK;
|
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)) {
|
if (!Feb_Interface_WriteRegister(addr[i], offset, value, 0, 0)) {
|
||||||
LOG(logERROR,
|
LOG(logERROR, ("Could not set Master flag to %s in %s Feb\n", val,
|
||||||
("Could not write master %d to %s DAQ_REG_HRDWRE reg\n", val,
|
master_names[ind], (i == 0 ? "left" : "right")));
|
||||||
(i == 0 ? "left" : "right")));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Feb_control_master = 1;
|
LOG(logINFOBLUE, ("%s Master flag to %s Feb\n",
|
||||||
LOG(logINFOBLUE,
|
(ind == MASTER_HARDWARE ? "Resetting" : "Overwriting"),
|
||||||
("Overwriting FEB Hardware: %s\n", (val ? "Master" : "Slave")));
|
master_names[ind]));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,8 +175,8 @@ int Feb_Control_SoftwareTrigger();
|
|||||||
int Feb_Control_SetInterruptSubframe(int val);
|
int Feb_Control_SetInterruptSubframe(int val);
|
||||||
int Feb_Control_GetInterruptSubframe();
|
int Feb_Control_GetInterruptSubframe();
|
||||||
|
|
||||||
int Feb_Control_SetTop(int val, int left, int right);
|
int Feb_Control_SetTop(enum TOPINDEX ind, int left, int right);
|
||||||
int Feb_Control_SetMaster(int val);
|
int Feb_Control_SetMaster(enum MASTERINDEX ind);
|
||||||
int Feb_Control_SetQuad(int val);
|
int Feb_Control_SetQuad(int val);
|
||||||
int Feb_Control_SetReadNLines(int value);
|
int Feb_Control_SetReadNLines(int value);
|
||||||
int Feb_Control_GetReadNLines();
|
int Feb_Control_GetReadNLines();
|
||||||
|
@ -147,7 +147,7 @@
|
|||||||
/** BEB Registers */
|
/** BEB Registers */
|
||||||
|
|
||||||
// module configuration - XPAR_PLB_GPIO_SYS_BASEADDR
|
// 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_OFST (0)
|
||||||
#define BEB_CONFIG_MASTER_MSK (0x00000001 << BEB_CONFIG_MASTER_OFST)
|
#define BEB_CONFIG_MASTER_MSK (0x00000001 << BEB_CONFIG_MASTER_OFST)
|
||||||
#define BEB_CONFIG_OW_MASTER_OFST (1)
|
#define BEB_CONFIG_OW_MASTER_OFST (1)
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
top 0
|
top 1
|
||||||
master 0
|
master 1
|
||||||
|
@ -309,6 +309,14 @@ u_int32_t getDetectorIP() {
|
|||||||
/* initialization */
|
/* initialization */
|
||||||
|
|
||||||
void initControlServer() {
|
void initControlServer() {
|
||||||
|
master = -1;
|
||||||
|
top = -1;
|
||||||
|
|
||||||
|
// force top or master if in config file
|
||||||
|
if (readConfigFile() == FAIL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
if (initError == OK) {
|
if (initError == OK) {
|
||||||
getModuleConfiguration();
|
getModuleConfiguration();
|
||||||
@ -352,7 +360,15 @@ void initControlServer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initStopServer() {
|
void initStopServer() {
|
||||||
|
master = -1;
|
||||||
|
top = -1;
|
||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
|
// force top or master if in config file
|
||||||
|
if (readConfigFile() == FAIL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
getModuleConfiguration();
|
getModuleConfiguration();
|
||||||
virtual_stop = 0;
|
virtual_stop = 0;
|
||||||
if (!isControlServer) {
|
if (!isControlServer) {
|
||||||
@ -362,6 +378,9 @@ void initStopServer() {
|
|||||||
LOG(logINFORED, ("Deactivated!\n"));
|
LOG(logINFORED, ("Deactivated!\n"));
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
|
// wait till control server has configured top/master
|
||||||
|
usleep(2 * 1000 * 1000);
|
||||||
|
|
||||||
getModuleConfiguration();
|
getModuleConfiguration();
|
||||||
Feb_Interface_FebInterface();
|
Feb_Interface_FebInterface();
|
||||||
Feb_Control_FebControl();
|
Feb_Control_FebControl();
|
||||||
@ -382,22 +401,33 @@ void initStopServer() {
|
|||||||
|
|
||||||
void getModuleConfiguration() {
|
void getModuleConfiguration() {
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
|
// if master not modified by config file
|
||||||
|
if (master == -1) {
|
||||||
#ifdef VIRTUAL_MASTER
|
#ifdef VIRTUAL_MASTER
|
||||||
master = 1;
|
master = 1;
|
||||||
top = 1;
|
#else
|
||||||
|
master = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
// if top not modified by config file
|
||||||
|
if (top == -1) {
|
||||||
|
#ifdef VIRTUAL_MASTER
|
||||||
|
top = 1;
|
||||||
#else
|
#else
|
||||||
master = 0;
|
|
||||||
#ifdef VIRTUAL_TOP
|
#ifdef VIRTUAL_TOP
|
||||||
top = 1;
|
top = 1;
|
||||||
#else
|
#else
|
||||||
top = 0;
|
top = 0;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef VIRTUAL_9M
|
#ifdef VIRTUAL_9M
|
||||||
normal = 0;
|
normal = 0;
|
||||||
#else
|
#else
|
||||||
normal = 1;
|
normal = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// read detector id
|
// read detector id
|
||||||
char output[255];
|
char output[255];
|
||||||
@ -411,10 +441,6 @@ void getModuleConfiguration() {
|
|||||||
|
|
||||||
Beb_GetModuleConfiguration(&master, &top, &normal);
|
Beb_GetModuleConfiguration(&master, &top, &normal);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (readConfigFile() == FAIL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isControlServer) {
|
if (isControlServer) {
|
||||||
LOG(logINFOBLUE,
|
LOG(logINFOBLUE,
|
||||||
("Module: %s %s %s\n", (top ? "TOP" : "BOTTOM"),
|
("Module: %s %s %s\n", (top ? "TOP" : "BOTTOM"),
|
||||||
@ -476,7 +502,8 @@ int readConfigFile() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
if (Beb_SetTop(top) == FAIL) {
|
enum TOPINDEX ind = (top == 1 ? OW_TOP : OW_BOTTOM);
|
||||||
|
if (!Beb_SetTop(ind)) {
|
||||||
sprintf(
|
sprintf(
|
||||||
initErrorMessage,
|
initErrorMessage,
|
||||||
"Could not overwrite top to %d in Beb from on-board server "
|
"Could not overwrite top to %d in Beb from on-board server "
|
||||||
@ -484,7 +511,7 @@ int readConfigFile() {
|
|||||||
top, line);
|
top, line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (Feb_Control_SetTop(top, 1, 1) == FAIL) {
|
if (!Feb_Control_SetTop(ind, 1, 1)) {
|
||||||
sprintf(
|
sprintf(
|
||||||
initErrorMessage,
|
initErrorMessage,
|
||||||
"Could not overwrite top to %d in Feb from on-board server "
|
"Could not overwrite top to %d in Feb from on-board server "
|
||||||
@ -506,7 +533,8 @@ int readConfigFile() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
if (Beb_SetMaster(master) == FAIL) {
|
enum MASTERINDEX ind = (master == 1 ? OW_MASTER : OW_SLAVE);
|
||||||
|
if (!Beb_SetMaster(ind)) {
|
||||||
sprintf(initErrorMessage,
|
sprintf(initErrorMessage,
|
||||||
"Could not overwrite master to %d in Beb from on-board "
|
"Could not overwrite master to %d in Beb from on-board "
|
||||||
"server "
|
"server "
|
||||||
@ -514,7 +542,7 @@ int readConfigFile() {
|
|||||||
master, line);
|
master, line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (Feb_Control_SetMaster(master) == FAIL) {
|
if (!Feb_Control_SetMaster(ind)) {
|
||||||
sprintf(initErrorMessage,
|
sprintf(initErrorMessage,
|
||||||
"Could not overwrite master to %d in Feb from on-board "
|
"Could not overwrite master to %d in Feb from on-board "
|
||||||
"server "
|
"server "
|
||||||
@ -535,6 +563,39 @@ int readConfigFile() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fd);
|
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)) {
|
if (strlen(initErrorMessage)) {
|
||||||
initError = FAIL;
|
initError = FAIL;
|
||||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||||
|
@ -62,6 +62,11 @@ enum ADCINDEX {
|
|||||||
enum NETWORKINDEX { TXN_LEFT, TXN_RIGHT, TXN_FRAME, FLOWCTRL_10G };
|
enum NETWORKINDEX { TXN_LEFT, TXN_RIGHT, TXN_FRAME, FLOWCTRL_10G };
|
||||||
enum ROINDEX { E_PARALLEL, E_NON_PARALLEL };
|
enum ROINDEX { E_PARALLEL, E_NON_PARALLEL };
|
||||||
enum CLKINDEX { RUN_CLK, NUM_CLOCKS };
|
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"
|
#define CLK_NAMES "run"
|
||||||
|
|
||||||
/* Hardware Definitions */
|
/* Hardware Definitions */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user