EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dataBlock.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file dataBlock.h
1 /*
2 ** dataBlock.h
3 **
4 ** Author: $Author: phoncs $
5 ** Date: $Date: 2010/09/21 19:37:49 $
6 **
7 ** $Log: dataBlock.h,v $
8 ** Revision 1.2 2010/09/21 19:37:49 phoncs
9 ** DLW: change name of DWORD to PHDWORD
10 **
11 ** Revision 1.1.1.1 2000/07/21 01:51:11 purschke
12 ** mlp -- adding the new automakified "basic" module to CVS.
13 **
14 **
15 ** Revision 1.6 2000/03/22 22:58:37 phoncs
16 ** mlp -- added DWORD
17 **
18 ** Revision 1.5 1998/12/11 22:01:15 markacs
19 ** (stephen markacs) adding log into cvs tags
20 **
21 */
22 /*
23 ** dataBlock.h
24 **
25 ** This routine provides acces to information in the data descriptor.
26 ** The data descriptor has a format which changes depending on the
27 ** data structure employed. So there are as many routines for
28 ** creating data descriptors as there are data structures.
29 ** Currently, the types of structures are:
30 **
31 ** - Unstructured: sets three fields, the hitFormat, dataPadding
32 ** and wordSize, in a one dword descriptor.
33 **
34 */
35 
36 #ifndef _DATABLOCK_
37 #define _DATABLOCK_
38 
39 #include "phenixOnline.h"
40 #include "packetPublic.h"
41 #include "Cpacket.h"
42 #include "formatError.h"
43 
44 /*
45 ** Use C linkage.
46 */
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 
53  /*
54  ** These are the offsets for unstructured data.
55  ** For unstructured data the descriptor has a length
56  ** of one dword.
57  */
58 
59 #define UNSTRUCT_DATA_PADDING_OFFSET_OF_DWORD 0
60 #define UNSTRUCT_DATA_PADDING_OFFSET_IN_DWORD 24
61 #define UNSTRUCT_DATA_PADDING_NUM_BITS 8
62 #define UNSTRUCT_DATA_PADDING_MASK 0xff000000
63 
64 #define UNSTRUCT_WORD_SIZE_OFFSET_OF_DWORD 0
65 #define UNSTRUCT_WORD_SIZE_OFFSET_IN_DWORD 16
66 #define UNSTRUCT_WORD_SIZE_NUM_BITS 8
67 #define UNSTRUCT_WORD_SIZE_MASK 0x00ff0000
68 
69 #define UNSTRUCT_HIT_FORMAT_OFFSET_OF_DWORD 0
70 #define UNSTRUCT_HIT_FORMAT_OFFSET_IN_DWORD 0
71 #define UNSTRUCT_HIT_FORMAT_NUM_BITS 16
72 #define UNSTRUCT_HIT_FORMAT_MASK 0x0000ffff
73 
75 
76 
77 
78  /*
79  ** These routines set/get unstructured descriptor fields given a pointer
80  ** to a packet.
81  */
82 
84 
88 
92 
96 
97 
98  /*
99  ** These routines set/get fields from the descriptor given a pointer
100  ** to the descriptor.
101  */
102 
104 
108 
112 
113 
115  UINT inWordSize,
116  UINT inHitFormat)
117 {
118  PHDWORD *descr_ptr;
119 
120  /*
121  ** Set the descriptor length in the packet header
122  */
123  setPacketDataDescrLength(packet_ptr, UnstructDataDescrLength);
124 
125  descr_ptr = findPacketDataDescr(packet_ptr);
126  if (descr_ptr == ptrFailure) return logicFailure;
127  else return makeUnstructDataDescr(descr_ptr, inWordSize, inHitFormat);
128 }
129 
131 {
132  PHDWORD* descr_ptr = findPacketDataDescr(packet_ptr);
133  if (descr_ptr == ptrFailure) return valueFailure;
134  else return getUnstructDescrWordSize(descr_ptr);
135 }
136 
138 {
139  PHDWORD* descr_ptr = findPacketDataDescr(packet_ptr);
140  if (descr_ptr == ptrFailure) return valueFailure;
141  else return getUnstructDescrHitFormat(descr_ptr);
142 }
143 
145 {
146  PHDWORD* descr_ptr = findPacketDataDescr(packet_ptr);
147  if (descr_ptr == ptrFailure) return valueFailure;
148  else return getUnstructDescrDataPadding(descr_ptr);
149 }
150 
152 {
153  PHDWORD* descr_ptr = findPacketDataDescr(packet_ptr);
154  if (descr_ptr == ptrFailure) return valueFailure;
155  else {
156  return setUnstructDescrHitFormat(descr_ptr, unHitFormat);
157  }
158 }
159 
161 {
162  PHDWORD* descr_ptr = findPacketDataDescr(packet_ptr);
163  if (descr_ptr == ptrFailure) return valueFailure;
164  else {
165  return setUnstructDescrWordSize(descr_ptr, unWordSize);
166  }
167 }
168 
170 {
171  PHDWORD* descr_ptr = findPacketDataDescr(packet_ptr);
172  if (descr_ptr == ptrFailure) return valueFailure;
173  else {
174  return setUnstructDescrDataPadding(descr_ptr, paddingBytes);
175  }
176 }
177 
178  /*
179  ** This routine creates a one dword data descriptor for unstructured data. The
180  ** wordSize and hitFormat are user specified values, the data padding entry is
181  ** initialized to zero.
182  */
183 
184 INLINE_D LOGIC_ret makeUnstructDataDescr (PHDWORD* dataDescr_ptr, UINT inWordSize,
185  UINT inHitFormat)
186 {
187  *dataDescr_ptr = 0;
188  setUnstructDescrWordSize (dataDescr_ptr, inWordSize);
189  setUnstructDescrHitFormat (dataDescr_ptr, inHitFormat);
190 
191  return logicSuccess;
192 }
193 
194 /* Return the word size from the unstructured descriptor
195  */
197 {
201 }
202 
203 /* Return the hit format from the unstructured descriptor
204  */
206 {
210 }
211 
212 /* Return the data padding field from the unstructured descriptor
213  */
215 {
219 }
220 
221 /* Set the word size in the unstructured descriptor
222  */
224 {
227  UNSTRUCT_WORD_SIZE_MASK, wordSize);
228  return TRUE;
229 }
230 
231 /* Set the hit format in the unstructured descriptor
232  */
234 {
237  UNSTRUCT_HIT_FORMAT_MASK, hitFormat);
238  return TRUE;
239 }
240 
241 /* Set the padding field in the unstructured descriptor
242  */
244  UINT paddingBytes)
245 {
248  UNSTRUCT_DATA_PADDING_MASK, paddingBytes);
249  return TRUE;
250 }
251 
252 #ifdef __cplusplus
253 }
254 /* end of external C */
255 #endif
256 
257 #endif
258 /* end of indef _DATABLOCK_ */
259 
260 
261 
262