#ifndef _GAPG_LIBGALAPAGOS_H_ #define _GAPG_LIBGALAPAGOS_H_ /** * \file * C user library to work with galapagos.ko kernel module * * \author JAM (Joern Adamczewski-Musch, GSI Darmstadt, Germany -- j.adamczewski@gsi.de) * \date 26-August-2014 -- 10-Sep-2015 * */ #include #include #include "../include/gapg_user.h" #ifdef GALAPAGOS_NOMBS #define printm printf #else void printm (char *, ...); /* use mbs logger, or for gosipcmd this will be reimplemented as printf for link time switching*/ #endif ////////////// #define galapagos_assert_handle(handle) \ if(handle < 0) \ { \ printm("Error: illegal file handle %d \n", \ handle); \ return -1; \ } #define GALAPAGOS_MAXCOMMANDNAME 128 #define GALAPAGOS_NUMCOMMMANDS 32 #define GALAPAGOS_MAXSOURCELENGTH 65536 #define GALAPAGOS_MAXLABELS 64 #define GALAPAGOS_NUMKERNELS 68 #define GALAPAGOS_KERNELINSTRUCTIONSIZE 0x9000 #define GALAPAGOS_KERNELPATTERNSIZE 0x80000 /** the allowed command ids*/ typedef enum { GAPG_NOP, //NoOperation GAPG_END_KERNEL, //EndKernel GAPG_RUN_SEQUENCE, //RunSequence GAPG_KEEP_LEVEL, //KeepLevel GAPG_LOOP, //Loop GAPG_JUMP, //Jump GAPG_SYNC_CORES, //SyncCores GAPG_SYNC_HOST, //SyncHost GAPG_SYNC_HOSTBRANCH, //SyncHostAndBranch GAPG_ALERTSTOP, //AlertAndStop GAPG_WAIT_DOCKPATTERN, //WaitDockPattern GAPG_CHECK_DOCKBRANCH, //CheckDockAndBranch GAPG_SET_LOCALDELAY, //SetLocalDelay GAPG_INC_LOCALDELAY, //IncLocalDelay GAPG_DEC_LOCALDELAY, //DecLocalDelay GAPG_SET_DOCKDELAY, //SetDockDelay GAPG_INC_DOCKDELAY, //IncDockDelay GAPG_DEC_DOCKDELAY, //DecDockDelay GAPG_SET_ATTEN, //SetAttenuation GAPG_INC_ATTEN, //IncAttenuation GAPG_DEC_ATTEN //DecAttenuation } galapagos_cmd_id; /** command structure*/ typedef struct{ galapagos_cmd_id id; /**< command identifier*/ char opcode; /**< operation code*/ uint64_t argument; /**< contains command parameters after compilation*/ char commandname[GALAPAGOS_MAXCOMMANDNAME]; /** explicit commmand name in source code*/ char argnames [GALAPAGOS_MAXCOMMANDNAME]; /** description of command arguments*/ char numargs; /**< number of command arguments required at compile time */ } galapagos_cmd ; /** type of kernel. must match the core*/ typedef enum { GAPG_CORE_NO, //No kernel GAPG_CORE_CH, //regular signal output channel GAPG_CORE_TRG, // trigger GAPG_CORE_USP, // ultra short pulse GAPG_CORE_LJP, // low jitter pulse GAPG_CORE_RFDAC // 2 RF DACs } galapagos_core_t; /** a label with absolute position in the kernel colde*/ typedef struct { size_t jump_position; /**< position of label in kernel instruction code from the beginning*/ char labelname[GALAPAGOS_MAXCOMMANDNAME]; /**< explicit label name in source code*/ } galapagos_label; /** This list will keep source labels and jump offsets during compilation*/ typedef struct { galapagos_label label[GALAPAGOS_MAXLABELS]; /**