Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
phenixOnline.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file phenixOnline.h
1 /*
2 ** Some standard definitions and typedefs for coding in the
3 ** PHENIX online system.
4 **
5 */
6 
7 #ifndef _phenixOnlineIncludeProtection_
8 #define _phenixOnlineIncludeProtection_
9 
10 
11 
12 #include "phenixTypes.h"
13 
14 #ifdef CONSTANT
15 #undef CONSTANT
16 #endif
17 #ifdef __cplusplus
18 #define CONSTANT const
19 #else
20 #define CONSTANT static
21 #endif
22 
23 #ifdef VXWORKS
24 #define INLINE_P inline
25 #define INLINE_D inline
26 #else
27 #define INLINE_P inline
28 #define INLINE_D inline
29 #endif
30 
31 /*
32 ** Include malloc for some readback routines
33 ** skip for DCM compiler.
34 */
35 #if !defined(DCM) && !defined(VXWORKS)
36 #include <memory.h>
37 #endif
38 
39 #include <assert.h>
40 #define Debug_Output
41 
42 #define DWORD_SIZE sizeof(PHDWORD)
43 #define SWORD_SIZE sizeof(SWORD)
44 
47 
48 #define PRDF_BIG_ENDIAN 2
49 #define PRDF_LITTLE_ENDIAN 1
50 
51 /*
52 ** We need to have all the various systems explicitly tested
53 ** with ifdef's to define the proper endianism.
54 */
55 #define PRDF_LOCAL_ENDIANISM PRDF_LITTLE_ENDIAN
56 
60 
61 /*
62 ** Function return values
63 */
64 typedef int LOGIC_ret;
65 typedef UINT VALUE_ret;
66 typedef PHDWORD* PTR_ret;
67 
68 #ifdef VXWORKS
69 #define TRUE 1
70 #define FALSE 0
71 #else
72 #ifndef TRUE
74 #endif
75 #ifndef FALSE
77 #endif
78 #endif
79 
80 /*
81 ** Other constant definitions
82 */
89 CONSTANT UINT maxDwordValue = 0xfffffffe ; /* reserve 0xffffffff for errors */
90 
91 
92 #define dwordCopy(out_ptr, in_ptr, numDwords) \
93 memcpy (out_ptr, in_ptr, 4*(numDwords))
94 
95 #define dwordClear(out_ptr, numDwords) \
96 memset (out_ptr, 0, 4*(numDwords))
97 
98 #define byteClear(out_ptr, numBytes) \
99 memset (out_ptr, 0, numBytes)
100 
101 #define byteCopy(out_ptr, in_ptr, numBytes) \
102 memcpy (out_ptr, in_ptr, numBytes)
103 
104 /*
105 ** Byte-swapping routines. There will likely be compiler or processor-specific
106 ** implementations of these.
107 */
108 /*
109 ** A generic byte-swapping implementation that will likely work on any
110 ** machine but is likely to be slow.
111 **
112 ** Note that the swap is not done "in-place".
113 */
114 //inline int mlp();
115 //inline unsigned long singleDwordByteSwap(DWORD);
117 {
118  PHDWORD outDword;
119 
120  outDword = (inDword & 0xFF) << 24;
121  outDword |= (inDword >> 8 & 0xFF) << 16;
122  outDword |= (inDword >> 16 & 0xFF) << 8;
123  outDword |= (inDword >> 24 & 0xFF);
124  return outDword;
125 }
126 
127 /*
128 ** A routine to byte swap a sequence of dwords.
129 **
130 ** Since singleDwordByteSwap does not do an "in-place" swap, this routine
131 ** can be safely used with in_ptr = out_ptr.
132 */
133 inline void dwordByteSwap (PHDWORD* out_ptr, PHDWORD* in_ptr, PHDWORD numDwords)
134 {
135  UINT i;
136  for (i = 0; i< numDwords; i++) *out_ptr++ = singleDwordByteSwap(*in_ptr++);
137 }
138 
139 /*
140 ** Define macros to insert/extract bit fields from DWORD
141 */
142 
143 #define getWordMACRO(packet_ptr,offsetOfDWORD) (*((packet_ptr)+(offsetOfDWORD)))
144 
145 #define getBitsMACRO(packet_ptr,offsetOfDWORD,offsetInDWORD,mask) \
146  (((*((packet_ptr)+(offsetOfDWORD)))&(mask))>>offsetInDWORD)
147 
148 
149 #define setWordMACRO(packet_ptr,offsetOfDword,value) \
150  (*(packet_ptr+offsetOfDword))=value
151 
152 
153 #define setBitsMACRO(packet_ptr,offsetOfDword,offsetInDword,mask,value) \
154  (*(packet_ptr+offsetOfDword))&=(~mask); \
155  (*(packet_ptr+offsetOfDword))|=(value<<offsetInDword)
156 
157 
158 #endif
159 
160  /* end of ifndef _phenixOnlineIncludeProtection_ */
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183 
184