// common.h #ifndef __COMMONH #define __COMMONH #include "services.h" #include #include #include #include /* getenv, exit */ #include #include typedef char INT8; typedef short INT16; typedef int INT32; typedef long long INT64; typedef unsigned char UINT8; typedef unsigned short UINT16; typedef unsigned int UINT32; typedef unsigned long long UINT64; typedef unsigned char UCHAR; typedef unsigned short USHORT; typedef unsigned int UINT; typedef unsigned long ULONG; typedef int BOOL; typedef int STATUS; typedef int ARGINT; #define SIG_RT1 SIGRTMIN+1 #define SIG_RT2 SIGRTMIN+2 #define SIGWAKEUP SIG_RT1 /* program states */ #define IDLE 0 /* state after program load */ #define READY 1 /* state after SETUP */ #define STOPPED 1 /* DA stopped - same as READY */ #define HALTED 1 #define GOING 2 #define FLUSH 3 /* used during STOP */ #define PAUSED 4 #define RESUMED 5 /* MERGE Commands */ #define DO_STOP 1 #define DO_GO 2 #define DO_SETUP 3 #define DO_RESET 4 #define DO_START 5 #define DO_PAUSE 6 #define DO_RESUME 7 /* MERGE_State */ #define MERGE_STOPPED 0 #define MERGE_GOING 1 #define MERGE_RESET 2 #define MERGE_DOINGSETUP 3 #define MERGE_DOINGGO 4 #define MERGE_DOINGSTOP 5 #define MERGE_ERROR 6 #define MERGE_DOINGRESET 7 #define MERGE_UNDEFINED 8 #define MERGE_EXECUTING 9 /* LINK commands */ #define LINK_STOP 21 #define LINK_GO 22 #define LINK_IDLE 23 #define LINK_FLUSH 24 /* LINK_State */ #define WAS_ACTIVE 0 /* #define IDLE 0 */ #define IS_ACTIVE 1 #define IS_WAITING 2 #define IS_DEAD 3 #define WAS_DEAD 4 #define LINK_STOPPED 0 #define LINK_GOING 1 #define LINK_RESET 2 #define LINK_DOINGSETUP 3 #define LINK_DOINGGO 4 #define LINK_DOINGSTOP 5 #define LINK_DOINGIDLE 6 #define LINK_ERROR 8 #define LINK_DOINGRESET 7 #define LINK_UNDEFINED 10 #define LINK_EXECUTING 9 /* MERGE Stats Commands */ #define STATS_CLR 41 // default key to use for the Shared Memory Segment #define SHMKEY 11000 #define MERGE_TCP_PORT 11001 // default start port #define MAXPORTS 64 #define N_DRIVER_DATALENGTH 16384 // in units of words (ie 4096 => 16 Kbyte) // length of path names used #define PATH_LENGTH 100 #define NUMlinks 64 #define N_DATA_BUFFERS 10 /*512*/ #define DATA_BUFFER_SIZE 64 /* for data coming in from network - units 1Kbytes */ /* currently each data/timestamp pair from ADC => new structure of (2 * (2*32 bit words) + 1 * (1*64 bit word)) i.e. 3 * the original size */ #define TRANSFER_BUFFER_SIZE (3 * DATA_BUFFER_SIZE) /* for data moving from link to merge - units 1Kbytes */ // The status_table etc are located in the Shared Memory Segment typedef struct s_status_table { int data_buffer_size; int buffer_table_offset; int link_table_offset[NUMlinks]; int num_links; int merge_state; int merge_ctrl; int merge_sem; pid_t master_pid; pid_t link_pid[NUMlinks]; pid_t merge_pid; pid_t statrate_pid; int msg_logging_level; int msg_reporting_level; int server_options; int data_block_size; // bytes } STATUS_TABLE; // table of data link tasks typedef struct s_link_table { int link_status; int link_ctrl; int link_state; int link_sem; pid_t link_pid; int link_index; /* this links ID */ int link_isActive; long link_TimeActive; int link_buffer_index; /* index of buffer currently being filled */ int link_buffer_head; int link_buffer_tail; int link_buffer_length[N_DATA_BUFFERS+1]; int link_buffer_data[N_DATA_BUFFERS+1]; /* index of buffer data in bufferarea */ int link_arg; char link_task[PATH_LENGTH]; } LINK_TABLE; // buffer access control table typedef struct s_buffer_table { int buffer_status[NUMlinks * N_DATA_BUFFERS]; int buffers_free[NUMlinks]; void * buffer_baseaddress[NUMlinks]; } BUFFER_TABLE; #define N_REQUEST_LENGTH 1024 #define N_RESPONSE_LENGTH 2048 #endif