mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 20:09:22 +01:00
Xilinx ctb (#884)
* updated registers, arm64 * compiler set to aarch64 for xilinx server * updated RegisterDefs.h * merge into generate branch and resolving conflicts and adding the xilinx changes to callerspecial and commands.yaml * compiles and can print firmware version (using a different csp0 address) * fixing other servers (gotthard, jungfrau, moench, mythen3) that it returns in case of mapping failure, xilinxctb: added that it checks type, prints proper fw version, checks kernel date, added armprocessor define to use in common places, added specifiers to supress overflow and truncation warnings * added detector ip and mac adddress to the printout * fixed tests and recompiled servers
This commit is contained in:
75
slsDetectorServers/slsDetectorServer/src/arm64.c
Normal file
75
slsDetectorServers/slsDetectorServer/src/arm64.c
Normal file
@@ -0,0 +1,75 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "arm64.h"
|
||||
#include "RegisterDefs.h"
|
||||
#include "clogger.h"
|
||||
#include "common.h"
|
||||
#include "sls/ansi.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#include <fcntl.h> // open
|
||||
#include <sys/mman.h> // mmap
|
||||
|
||||
|
||||
/* global variables */
|
||||
#define CSP0 (0xB0010000)/// 0xB008_0000
|
||||
#define MEM_SIZE 0x100000
|
||||
|
||||
u_int32_t *csp0base = 0;
|
||||
|
||||
void bus_w(u_int32_t offset, u_int32_t data) {
|
||||
volatile u_int32_t *ptr1;
|
||||
ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t)));
|
||||
*ptr1 = data;
|
||||
}
|
||||
|
||||
u_int32_t bus_r(u_int32_t offset) {
|
||||
volatile u_int32_t *ptr1;
|
||||
ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t)));
|
||||
return *ptr1;
|
||||
}
|
||||
|
||||
uint64_t getU64BitReg(int aLSB, int aMSB) {
|
||||
uint64_t retval = bus_r(aMSB);
|
||||
retval = (retval << 32) | bus_r(aLSB);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void setU64BitReg(uint64_t value, int aLSB, int aMSB) {
|
||||
bus_w(aLSB, value & (0xffffffff));
|
||||
bus_w(aMSB, (value >> 32) & (0xffffffff));
|
||||
}
|
||||
|
||||
int mapCSP0(void) {
|
||||
// if not mapped
|
||||
if (csp0base == 0) {
|
||||
LOG(logINFO, ("Mapping memory\n"));
|
||||
#ifdef VIRTUAL
|
||||
csp0base = malloc(MEM_SIZE);
|
||||
if (csp0base == NULL) {
|
||||
LOG(logERROR, ("Could not allocate virtual memory.\n"));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("memory allocated\n"));
|
||||
#else
|
||||
int fd;
|
||||
fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
||||
if (fd == -1) {
|
||||
LOG(logERROR, ("Can't find /dev/mem\n"));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG1, ("/dev/mem opened\n"));
|
||||
csp0base = (u_int32_t*)mmap(0, MEM_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_FILE | MAP_SHARED, fd, CSP0);
|
||||
if (csp0base == MAP_FAILED) {
|
||||
LOG(logERROR, ("Can't map memmory area\n"));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
LOG(logINFO, ("csp0base mapped from %p to %p\n", csp0base,
|
||||
(csp0base + MEM_SIZE)));
|
||||
} else
|
||||
LOG(logINFO, ("Memory already mapped before\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -114,6 +114,10 @@ int getTimeFromString(char *buf, time_t *result) {
|
||||
t.tm_mday, t.tm_mon, t.tm_year + 1900, t.tm_hour, t.tm_min, t.tm_sec));
|
||||
|
||||
*result = mktime(&t);
|
||||
if (*result == -1) {
|
||||
LOG(logERROR, ("Could not convert time structure to time_t\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -130,6 +134,7 @@ int getKernelVersion(char *retvals) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int validateKernelVersion(char *expectedVersion) {
|
||||
// extract kernel date string
|
||||
char version[255] = {0};
|
||||
@@ -143,15 +148,26 @@ int validateKernelVersion(char *expectedVersion) {
|
||||
#ifdef VIRTUAL
|
||||
strcpy(currentVersion, expectedVersion);
|
||||
#else
|
||||
#ifndef ARMPROCESSOR
|
||||
// remove first word (#version number)
|
||||
const char *ptr = strchr(version, ' ');
|
||||
const char *ptr = strstr(version, " ");
|
||||
if (ptr == NULL) {
|
||||
LOG(logERROR, ("Could not parse kernel version\n"));
|
||||
return FAIL;
|
||||
}
|
||||
strcpy(currentVersion, version + (ptr - version + 1));
|
||||
strcpy(currentVersion, ptr + 1);
|
||||
#else
|
||||
// remove first two words (#version number and SMP)
|
||||
const char *ptr = strstr(version, "SMP ");
|
||||
if (ptr == NULL) {
|
||||
LOG(logERROR, ("Could not parse kernel version\n"));
|
||||
return FAIL;
|
||||
}
|
||||
strcpy(currentVersion, ptr + 4);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
currentVersion[sizeof(currentVersion) - 1] = '\0';
|
||||
|
||||
// convert kernel date string into time
|
||||
time_t kernelDate;
|
||||
if (getTimeFromString(currentVersion, &kernelDate) == FAIL) {
|
||||
@@ -159,6 +175,7 @@ int validateKernelVersion(char *expectedVersion) {
|
||||
("Could not parse retrieved kernel date, %s\n", currentVersion));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG, ("Kernel Date: [%s]\n", ctime(&kernelDate)));
|
||||
|
||||
// convert expected date into time
|
||||
time_t expDate;
|
||||
@@ -167,11 +184,12 @@ int validateKernelVersion(char *expectedVersion) {
|
||||
("Could not parse expected kernel date, %s\n", expectedVersion));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG, ("Expected Date: [%s]\n", ctime(&expDate)));
|
||||
|
||||
// compare if kernel time is older than expected time
|
||||
if (kernelDate < expDate) {
|
||||
LOG(logERROR, ("Kernel Version Incompatible (too old)! Expected: [%s], "
|
||||
"Got [%s]\n",
|
||||
LOG(logERROR, ("Kernel Version Incompatible (too old)!\nExpected: '%s'"
|
||||
"\nGot : '%s'\n",
|
||||
expectedVersion, currentVersion));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ const enum detectorType myDetectorType = MOENCH;
|
||||
const enum detectorType myDetectorType = MYTHEN3;
|
||||
#elif GOTTHARD2D
|
||||
const enum detectorType myDetectorType = GOTTHARD2;
|
||||
#elif XILINX_CHIPTESTBOARDD
|
||||
const enum detectorType myDetectorType = XILINX_CHIPTESTBOARD;
|
||||
#else
|
||||
const enum detectorType myDetectorType = GENERIC;
|
||||
#endif
|
||||
@@ -717,6 +719,9 @@ int set_timing_mode(int file_des) {
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("Setting external communication mode to %d\n", arg));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// set
|
||||
if (((int)arg != GET_FLAG) && (Server_VerifyLock() == OK)) {
|
||||
switch (arg) {
|
||||
@@ -753,7 +758,7 @@ int set_timing_mode(int file_des) {
|
||||
validate(&ret, mess, (int)arg, (int)retval, "set timing mode", DEC);
|
||||
#endif
|
||||
LOG(logDEBUG1, ("Timing Mode: %d\n", retval));
|
||||
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -787,7 +792,7 @@ int get_serial_number(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int64_t retval = -1;
|
||||
#ifdef EIGERD
|
||||
#if defined(EIGERD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
retval = getDetectorNumber();
|
||||
@@ -1119,6 +1124,8 @@ enum DACINDEX getDACIndex(enum dacIndex ind) {
|
||||
case IBIAS_SFP:
|
||||
serverDacIndex = MO_IBIAS_SFP;
|
||||
break;
|
||||
#elif XILINX_CHIPTESTBOARDD
|
||||
|
||||
#endif
|
||||
|
||||
default:
|
||||
@@ -1137,8 +1144,9 @@ enum DACINDEX getDACIndex(enum dacIndex ind) {
|
||||
|
||||
int validateAndSetDac(enum dacIndex ind, int val, int mV) {
|
||||
int retval = -1;
|
||||
enum DACINDEX serverDacIndex = 0;
|
||||
|
||||
#ifndef XILINX_CHIPTESTBOARDD
|
||||
enum DACINDEX serverDacIndex = 0;
|
||||
// valid enums
|
||||
switch (ind) {
|
||||
case HIGH_VOLTAGE:
|
||||
@@ -1389,6 +1397,7 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -1401,6 +1410,9 @@ int set_dac(int file_des) {
|
||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
enum dacIndex ind = args[0];
|
||||
int mV = args[1];
|
||||
int val = args[2];
|
||||
@@ -1411,6 +1423,7 @@ int set_dac(int file_des) {
|
||||
if ((val == GET_FLAG) || (Server_VerifyLock() == OK)) {
|
||||
retval = validateAndSetDac(ind, val, mV);
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -1423,6 +1436,9 @@ int get_adc(int file_des) {
|
||||
if (receiveData(file_des, &ind, sizeof(ind), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
enum ADCINDEX serverAdcIndex = 0;
|
||||
|
||||
// get
|
||||
@@ -1544,6 +1560,7 @@ int get_adc(int file_des) {
|
||||
LOG(logDEBUG1, ("ADC(%d): %d\n", serverAdcIndex, retval));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
@@ -1560,6 +1577,9 @@ int write_register(int file_des) {
|
||||
uint32_t val = args[1];
|
||||
LOG(logDEBUG1, ("Writing to register 0x%x, data 0x%x\n", addr, val));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
#ifdef GOTTHARDD
|
||||
@@ -1594,6 +1614,7 @@ int write_register(int file_des) {
|
||||
}
|
||||
LOG(logDEBUG1, ("Write register (0x%x): 0x%x\n", retval));
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -1608,6 +1629,10 @@ int read_register(int file_des) {
|
||||
|
||||
LOG(logDEBUG1, ("Reading from register 0x%x\n", addr));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
|
||||
// get
|
||||
#ifdef GOTTHARDD
|
||||
retval = readRegister16And32(addr);
|
||||
@@ -1624,7 +1649,7 @@ int read_register(int file_des) {
|
||||
retval = readRegister(addr);
|
||||
#endif
|
||||
LOG(logINFO, ("Read register (0x%x): 0x%x\n", addr, retval));
|
||||
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -1828,7 +1853,7 @@ int set_settings(int file_des) {
|
||||
if (receiveData(file_des, &isett, sizeof(isett), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
|
||||
#ifdef CHIPTESTBOARDD
|
||||
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
LOG(logDEBUG1, ("Setting settings %d\n", isett));
|
||||
@@ -1905,6 +1930,9 @@ int acquire(int blocking, int file_des) {
|
||||
} else {
|
||||
LOG(logINFOBLUE, ("Unblocking Acquisition\n"));
|
||||
}
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
#if defined(JUNGFRAUD)
|
||||
@@ -2003,10 +2031,12 @@ int acquire(int blocking, int file_des) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
void *start_state_machine(void *arg) {
|
||||
#ifndef XILINX_CHIPTESTBOARDD
|
||||
int *blocking = (int *)arg;
|
||||
int times = 1;
|
||||
// start of scan
|
||||
@@ -2132,6 +2162,7 @@ void *start_state_machine(void *arg) {
|
||||
if (scan && sharedMemory_getScanStatus() != ERROR) {
|
||||
sharedMemory_setScanStatus(IDLE);
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2149,6 +2180,9 @@ int stop_acquisition(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
||||
LOG(logDEBUG1, ("Stopping Acquisition\n"));
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
ret = stopStateMachine();
|
||||
@@ -2158,6 +2192,7 @@ int stop_acquisition(int file_des) {
|
||||
}
|
||||
LOG(logDEBUG1, ("Stopping Acquisition ret: %d\n", ret));
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -2167,9 +2202,13 @@ int get_run_status(int file_des) {
|
||||
enum runStatus retval = ERROR;
|
||||
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only get
|
||||
retval = getRunStatus();
|
||||
LOG(logDEBUG1, ("Status: %d\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -2180,6 +2219,9 @@ int get_num_frames(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int64_t retval = -1;
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
if (!scan) {
|
||||
retval = getNumFrames();
|
||||
@@ -2189,6 +2231,7 @@ int get_num_frames(int file_des) {
|
||||
LOG(logDEBUG1, ("retval num frames (num scan steps) %lld\n",
|
||||
(long long int)retval));
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -2201,6 +2244,9 @@ int set_num_frames(int file_des) {
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("Setting number of frames %lld\n", (long long int)arg));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
// only set number of frames if normal mode (not scan)
|
||||
@@ -2246,6 +2292,7 @@ int set_num_frames(int file_des) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -2254,9 +2301,13 @@ int get_num_triggers(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int64_t retval = -1;
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = getNumTriggers();
|
||||
LOG(logDEBUG1, ("retval num triggers %lld\n", (long long int)retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -2269,6 +2320,9 @@ int set_num_triggers(int file_des) {
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("Setting number of triggers %lld\n", (long long int)arg));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
#if JUNGFRAUD
|
||||
@@ -2288,6 +2342,7 @@ int set_num_triggers(int file_des) {
|
||||
validate64(&ret, mess, arg, retval, "set number of triggers", DEC);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -2447,6 +2502,9 @@ int get_exptime(int file_des) {
|
||||
if (receiveData(file_des, &gateIndex, sizeof(gateIndex), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
#ifdef MYTHEN3D
|
||||
if (gateIndex < 0 || gateIndex > 2) {
|
||||
@@ -2470,6 +2528,7 @@ int get_exptime(int file_des) {
|
||||
retval = getExpTime();
|
||||
LOG(logDEBUG1, ("retval exptime %lld ns\n", (long long int)retval));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||
}
|
||||
@@ -2486,6 +2545,9 @@ int set_exptime(int file_des) {
|
||||
LOG(logDEBUG1, ("Setting exptime %lld ns (gateIndex:%d)\n",
|
||||
(long long int)val, gateIndex));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
#ifdef MYTHEN3D
|
||||
@@ -2550,6 +2612,7 @@ int set_exptime(int file_des) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -2558,9 +2621,13 @@ int get_period(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int64_t retval = -1;
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = getPeriod();
|
||||
LOG(logDEBUG1, ("retval period %lld ns\n", (long long int)retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -2573,6 +2640,9 @@ int set_period(int file_des) {
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("Setting period %lld ns\n", (long long int)arg));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
ret = setPeriod(arg);
|
||||
@@ -2584,6 +2654,7 @@ int set_period(int file_des) {
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -2991,6 +3062,9 @@ int set_dynamic_range(int file_des) {
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("Setting dr to %d\n", dr));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// set & get
|
||||
if ((dr == GET_FLAG) || (Server_VerifyLock() == OK)) {
|
||||
// check dr
|
||||
@@ -3039,6 +3113,7 @@ int set_dynamic_range(int file_des) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -3153,7 +3228,7 @@ int enable_ten_giga(int file_des) {
|
||||
LOG(logDEBUG, ("Setting 10GbE: %d\n", arg));
|
||||
|
||||
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARDD) || \
|
||||
defined(GOTTHARD2D)
|
||||
defined(GOTTHARD2D) || defined(XILINX_CHIPTESTBOARDD)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// set & get
|
||||
@@ -4322,7 +4397,7 @@ int reboot_controller(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
||||
#ifdef EIGERD
|
||||
#if defined(EIGERD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
functionNotImplemented();
|
||||
#elif VIRTUAL
|
||||
ret = GOODBYE;
|
||||
@@ -4951,6 +5026,9 @@ int set_detector_position(int file_des) {
|
||||
LOG(logDEBUG, ("Setting detector positions: [maxy:%u, modIndex:%u]\n",
|
||||
args[0], args[1]));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
// if in update mode, there is no need to do this (also detector not set
|
||||
@@ -4961,10 +5039,14 @@ int set_detector_position(int file_des) {
|
||||
calculate_and_set_position();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int check_detector_idle(const char *s) {
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
return FAIL;
|
||||
#else
|
||||
enum runStatus status = getRunStatus();
|
||||
if (status != IDLE && status != RUN_FINISHED && status != STOPPED &&
|
||||
status != ERROR) {
|
||||
@@ -4976,6 +5058,7 @@ int check_detector_idle(const char *s) {
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
int is_udp_configured() {
|
||||
@@ -5042,6 +5125,7 @@ int is_udp_configured() {
|
||||
}
|
||||
|
||||
void configure_mac() {
|
||||
#ifndef XILINX_CHIPTESTBOARDD
|
||||
if (isControlServer) {
|
||||
if (is_udp_configured() == OK) {
|
||||
ret = configureMAC();
|
||||
@@ -5068,6 +5152,7 @@ void configure_mac() {
|
||||
}
|
||||
configured = FAIL;
|
||||
LOG(logWARNING, ("Configure FAIL, not all parameters configured yet\n"));
|
||||
#endif
|
||||
}
|
||||
|
||||
int set_source_udp_ip(int file_des) {
|
||||
@@ -5080,6 +5165,9 @@ int set_source_udp_ip(int file_des) {
|
||||
arg = __builtin_bswap32(arg);
|
||||
LOG(logINFO, ("Setting udp source ip: 0x%x\n", arg));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle("configure mac") == OK) {
|
||||
@@ -5092,6 +5180,7 @@ int set_source_udp_ip(int file_des) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -5101,11 +5190,14 @@ int get_source_udp_ip(int file_des) {
|
||||
uint32_t retval = -1;
|
||||
LOG(logDEBUG1, ("Getting udp source ip\n"));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = udpDetails[0].srcip;
|
||||
retval = __builtin_bswap32(retval);
|
||||
LOG(logDEBUG1, ("udp soure ip retval: 0x%x\n", retval));
|
||||
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -5165,6 +5257,9 @@ int set_dest_udp_ip(int file_des) {
|
||||
arg = __builtin_bswap32(arg);
|
||||
LOG(logINFO, ("Setting udp destination ip: 0x%x\n", arg));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle("configure mac") == OK) {
|
||||
@@ -5174,6 +5269,7 @@ int set_dest_udp_ip(int file_des) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -5183,11 +5279,14 @@ int get_dest_udp_ip(int file_des) {
|
||||
uint32_t retval = -1;
|
||||
LOG(logDEBUG1, ("Getting destination ip\n"));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = udpDetails[0].dstip;
|
||||
retval = __builtin_bswap32(retval);
|
||||
LOG(logDEBUG1, ("udp destination ip retval: 0x%x\n", retval));
|
||||
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -5243,6 +5342,9 @@ int set_source_udp_mac(int file_des) {
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("Setting udp source mac: 0x%lx\n", arg));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle("configure mac") == OK) {
|
||||
@@ -5264,6 +5366,7 @@ int set_source_udp_mac(int file_des) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -5272,11 +5375,13 @@ int get_source_udp_mac(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint64_t retval = -1;
|
||||
LOG(logDEBUG1, ("Getting udp source mac\n"));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = udpDetails[0].srcmac;
|
||||
LOG(logDEBUG1, ("udp soure mac retval: 0x%lx\n", retval));
|
||||
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -5333,6 +5438,9 @@ int set_dest_udp_mac(int file_des) {
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("Setting udp destination mac: 0x%lx\n", arg));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle("configure mac") == OK) {
|
||||
@@ -5342,6 +5450,7 @@ int set_dest_udp_mac(int file_des) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -5350,11 +5459,13 @@ int get_dest_udp_mac(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint64_t retval = -1;
|
||||
LOG(logDEBUG1, ("Getting udp destination mac\n"));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = udpDetails[0].dstmac;
|
||||
LOG(logDEBUG1, ("udp destination mac retval: 0x%lx\n", retval));
|
||||
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -5408,6 +5519,9 @@ int set_dest_udp_port(int file_des) {
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("Setting udp destination port: %hu\n", arg));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle("configure mac") == OK) {
|
||||
@@ -5417,6 +5531,7 @@ int set_dest_udp_port(int file_des) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT16, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -5425,11 +5540,13 @@ int get_dest_udp_port(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint16_t retval = -1;
|
||||
LOG(logDEBUG1, ("Getting destination port"));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = udpDetails[0].dstport;
|
||||
LOG(logDEBUG, ("udp destination port retval: %hu\n", retval));
|
||||
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT16, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -5485,7 +5602,8 @@ int set_num_interfaces(int file_des) {
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("Setting number of interfaces: %d\n", arg));
|
||||
|
||||
#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D)
|
||||
#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D) && \
|
||||
!defined(XLINX_CHIPTESTBOARDD)
|
||||
// fixed number of udp interfaces
|
||||
int num_interfaces = getNumberofUDPInterfaces();
|
||||
if (arg != num_interfaces) {
|
||||
@@ -5557,7 +5675,6 @@ int get_num_interfaces(int file_des) {
|
||||
|
||||
// get only
|
||||
retval = getNumberofUDPInterfaces();
|
||||
|
||||
LOG(logDEBUG1, ("Number of udp interfaces retval: %u\n", retval));
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
@@ -7020,6 +7137,10 @@ int get_receiver_parameters(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
||||
LOG(logDEBUG1, ("Getting receiver parameters\n"));
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
#else
|
||||
// get only
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
|
||||
@@ -7477,7 +7598,7 @@ int get_receiver_parameters(int file_des) {
|
||||
return printSocketReadError();
|
||||
|
||||
LOG(logINFO, ("Sent %d bytes for receiver parameters\n", n));
|
||||
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -7819,6 +7940,9 @@ int set_scan(int file_des) {
|
||||
if (receiveData(file_des, &dacTime, sizeof(dacTime), INT64) < 0)
|
||||
return printSocketReadError();
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
int enable = args[0];
|
||||
@@ -7908,6 +8032,7 @@ int set_scan(int file_des) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@@ -8265,6 +8390,9 @@ int reconfigure_udp(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
if (Server_VerifyLock() == OK) {
|
||||
LOG(logINFO, ("Reconfiguring UDP\n"));
|
||||
if (check_detector_idle("configure mac") == OK) {
|
||||
@@ -8277,6 +8405,7 @@ int reconfigure_udp(int file_des) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -8377,7 +8506,7 @@ int reset_to_default_dacs(int file_des) {
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("Resetting dacs to defaults (hard reset: %d)\n", arg));
|
||||
|
||||
#ifdef CHIPTESTBOARDD
|
||||
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
if (Server_VerifyLock() == OK) {
|
||||
@@ -8792,7 +8921,7 @@ int get_default_dac(int file_des) {
|
||||
LOG(logDEBUG1,
|
||||
("Getting default dac [dacindex:%d, settings: %d]\n", dacindex, sett));
|
||||
|
||||
#ifdef CHIPTESTBOARDD
|
||||
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
@@ -8832,7 +8961,7 @@ int set_default_dac(int file_des) {
|
||||
LOG(logDEBUG1, ("Setting default dac [dacindex: %d, settings: %d] to %d\n",
|
||||
(int)dacindex, (int)sett, value));
|
||||
|
||||
#ifdef CHIPTESTBOARDD
|
||||
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
@@ -9452,6 +9581,11 @@ int clear_all_udp_dst(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
||||
LOG(logINFO, ("Clearing all udp destinations\n"));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle("clear all udp destinations") == OK) {
|
||||
memset(udpDetails, 0, sizeof(udpDetails));
|
||||
@@ -9479,6 +9613,7 @@ int clear_all_udp_dst(int file_des) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -9618,7 +9753,9 @@ int get_kernel_version(int file_des) {
|
||||
memset(retvals, 0, MAX_STR_LENGTH);
|
||||
|
||||
LOG(logDEBUG1, ("Getting kernel version\n"));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
ret = getKernelVersion(retvals);
|
||||
if (ret == FAIL) {
|
||||
@@ -9631,13 +9768,14 @@ int get_kernel_version(int file_des) {
|
||||
} else {
|
||||
LOG(logDEBUG1, ("kernel version: [%s]\n", retvals));
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
|
||||
}
|
||||
|
||||
int update_kernel(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
#ifdef EIGERD
|
||||
#if defined(EIGERD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
functionNotImplemented();
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
#else
|
||||
@@ -9689,7 +9827,8 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
|
||||
LOG(logINFO, ("\tServer Name: %s\n", serverName));
|
||||
}
|
||||
|
||||
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) && !defined(EIGERD)
|
||||
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) && !defined(EIGERD) && \
|
||||
!defined(XILINX_CHIPTESTBOARDD)
|
||||
int forceDeleteNormalFile = 0;
|
||||
if (receiveData(file_des, &forceDeleteNormalFile,
|
||||
sizeof(forceDeleteNormalFile), INT32) < 0)
|
||||
@@ -9725,7 +9864,8 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
|
||||
}
|
||||
|
||||
if (ret == OK) {
|
||||
#if defined(GOTTHARD2D) || defined(MYTHEN3D) || defined(EIGERD)
|
||||
#if defined(GOTTHARD2D) || defined(MYTHEN3D) || defined(EIGERD) || \
|
||||
defined(XILINX_CHIPTESTBOARDD)
|
||||
receive_program_default(file_des, index, functionType, filesize,
|
||||
checksum, serverName);
|
||||
#else
|
||||
@@ -9871,7 +10011,8 @@ void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
|
||||
void receive_program_default(int file_des, enum PROGRAM_INDEX index,
|
||||
char *functionType, uint64_t filesize,
|
||||
char *checksum, char *serverName) {
|
||||
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) && !defined(EIGERD)
|
||||
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) && !defined(EIGERD) && \
|
||||
!defined(XILINX_CHIPTESTBOARDD)
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not %s. program via blackfin not implmented for this "
|
||||
@@ -10389,8 +10530,12 @@ int get_hardware_version(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
char retvals[MAX_STR_LENGTH];
|
||||
memset(retvals, 0, MAX_STR_LENGTH);
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
getHardwareVersion(retvals);
|
||||
LOG(logDEBUG1, ("hardware version retval: %s\n", retvals));
|
||||
#endif
|
||||
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
|
||||
}
|
||||
|
||||
@@ -10443,6 +10588,10 @@ int set_bit(int file_des) {
|
||||
int nBit = (int)args[1];
|
||||
LOG(logDEBUG1, ("Setting bit %d of reg 0x%x\n", nBit, addr));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (nBit < 0 || nBit > 31) {
|
||||
@@ -10473,6 +10622,7 @@ int set_bit(int file_des) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -10487,6 +10637,9 @@ int clear_bit(int file_des) {
|
||||
int nBit = (int)args[1];
|
||||
LOG(logDEBUG1, ("Clearing bit %d of reg 0x%x\n", nBit, addr));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (nBit < 0 || nBit > 31) {
|
||||
@@ -10517,6 +10670,7 @@ int clear_bit(int file_des) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -10532,6 +10686,9 @@ int get_bit(int file_des) {
|
||||
int nBit = (int)args[1];
|
||||
LOG(logDEBUG1, ("Getting bit %d of reg 0x%x\n", nBit, addr));
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
if (nBit < 0 || nBit > 31) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
@@ -10556,6 +10713,7 @@ int get_bit(int file_des) {
|
||||
LOG(logDEBUG1, ("regval: 0x%x bit value:0%d\n", regval, retval));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user