versadac  1
versadac - Scalable Recorder Firmware
platform.h
1 /*---------------------------------------------------------------------------*/
2 /* Copyright (C) 2006 Woodhead Software & Electonics. All rights reserved. */
3 /*---------------------------------------------------------------------------*/
4 /* This program is protected by international copyright. */
5 /* */
6 /* The use of this software including but not limited to its Source Code */
7 /* is subject to restrictions as agreed in the license agreement between */
8 /* you and Woodhead. */
9 /* Copying or distribution is not allowed unless expressly permitted */
10 /* according to your license agreement with Woodhead. */
11 /*---------------------------------------------------------------------------*/
12 /* */
13 /* Project : STACK PROFINET Device */
14 /* Component : OS RELATION */
15 /* $Workfile:: platform.h $*/
16 /* $Revision:: 1 $*/
17 /* $Date:: 15/06/10 16:29 $*/
18 /* */
19 /*---------------------------------------------------------------------------*/
20 /* */
21 /* D e s c r i p t i o n : */
22 /* Definition */
23 /* */
24 /*---------------------------------------------------------------------------*/
25 #ifndef _PLATFORM_H
26 #define _PLATFORM_H
27 
28 /*-----------------------------------------------------------------------*/
29 /* define network element type */
30 /*-----------------------------------------------------------------------*/
31 #define IODEVICE
32 
33 /*-----------------------------------------------------------------------*/
34 /* Hardware information */
35 /*-----------------------------------------------------------------------*/
36 #define PLATFORM_BIG_ENDIAN /* motorola*/
37 /*#define PLATFORM_LITTLE_ENDIAN intel*/
38 
39 /*-----------------------------------------------------------------------*/
40 /* informs the os layer to use the aux clock and not the sys clock */
41 /*-----------------------------------------------------------------------*/
42 #define TIMER_HARD
43 
44 /*-----------------------------------------------------------------------*/
45 /* informs the os layer to use the PTI hardware time (SDR specific) */
46 /* this will allow the OsWait_ms routine to be accurate to 1 ms */
47 /* else the accuracy will only be at best 16ms */
48 /*-----------------------------------------------------------------------*/
49 #define PTI_TIMER
50 
51 /*-----------------------------------------------------------------------*/
52 /* define multi-device */
53 /*-----------------------------------------------------------------------*/
54 #define MAX_DEVICE 1
55 
56 /*-----------------------------------------------------------------------*/
57 /* define multi-instance */
58 /* This version of the stack do not support multi instance. */
59 /* MAX_INSTANCE_PER_DEVICE shall be set to 1. */
60 /*-----------------------------------------------------------------------*/
61 #define MAX_INSTANCE_PER_DEVICE 1
62 
63 /*-----------------------------------------------------------------------*/
64 /* define Conections per device */
65 /*-----------------------------------------------------------------------*/
66 #define MAX_CONNEXION_PER_INSTANCE 2
67 
68 /*-----------------------------------------------------------------------*/
69 /* define CR per device */
70 /*-----------------------------------------------------------------------*/
71 #define MAX_CR_IN_PER_AR 1 /* One input CR: input for controller then, PPM CR */
72 #define MAX_CR_OUT_PER_AR 1 /* One output CR: output for controller then, CPM CR */
73 #define MAX_CR_PER_AR (MAX_CR_IN_PER_AR+MAX_CR_OUT_PER_AR) /* One input CR and one output CR */
74 
75 /*-----------------------------------------------------------------------*/
76 /* The range value of the API */
77 /*-----------------------------------------------------------------------*/
78 #define API_RANGE_MIN 0 /* An Api can't be smallest than this value */
79 #define API_RANGE_MAX 1 /* An Api can't be Largest than this value */
80 
81 /*-----------------------------------------------------------------------*/
82 /* The value of the upper Slot */
83 /*-----------------------------------------------------------------------*/
84 #define SLOT_RANGE_MIN 0 /* A Slot number can't be smaller than this value */
85 #define SLOT_RANGE_MAX 20 /* A Slot number can't be Larger than this value */
86 
87 /*-----------------------------------------------------------------------*/
88 /* The range value of the subSlot */
89 /*-----------------------------------------------------------------------*/
90 #define SUBSLOT_RANGE_MIN 1 /* A Subslot number can't be smaller than this value */
91 #define SUBSLOT_RANGE_MAX 0X8010 /* A Subslot number can't be Larger than this value */
92 
93 /*-----------------------------------------------------------------------*/
94 /* Scheduler configuration */
95 /*-----------------------------------------------------------------------*/
96 #define SCHEDULE_NB_TRIG 1
97 #define SYSTEM_POLLING_DELAY 1
98 #define MAX_CBF (5+MAX_DEVICE*10)
99 
100 /*--------------------------------------------------------------------------------------------------------*/
101 /* The value are use to reset device information when he receive a factory reset */
102 /* Factory Reset shall permanent set (norme 2.1 - 4.3.1.4.11 Coding of the field SuboptionFactoryReset ) */
103 /* - the NameOfStation to "" */
104 /* - the IP address, the subnet mask and the standard gateway to 0.0.0.0 */
105 /* - all other parameters to the manufacturers default value. */
106 /*--------------------------------------------------------------------------------------------------------*/
107 
108 #define FACTORY_RESET_IP 0 /* This is the IP use when device receive a device factory reset : this ip must be form as a DWORD */
109  /* (nb: for exemple, on vxworks, this constante can be set to inet_addr(0.0.0.0) ) */
110 
111 #define FACTORY_RESET_SUBNETMASK 0 /* This is the sub net mask use when device receive a device factory reset : this sub net mask must be form as a DWORD */
112  /* (nb: for exemple, on vxworks, this constante can be set to inet_addr(0.0.0.0) ) */
113 
114 #define FACTORY_RESET_GATEWAY 0 /* This is the Mask used when device receive a dcp factory reset : this gateway must be form as a DWORD*/
115  /* (nb: for exemple, on vxworks, this constante can be set to inet_addr(0.0.0.0) ) */
116 
117 #define FACTORY_RESET_NAME "" /* This is the name used when device receive a device factory reset */
118 
119 
120 /* FUNCTIONNAL COMPILATION CONSTANTS */
121 #define RECORD_INTERNAL
122 #define RECORD_INTERNAL_IM /* sub definition of RECORD_INTERNAL: this one allow stack to answer I&M0 record with default values (from define) */
123 #define RECORD_INTERNAL_INTERFACE /* sub definition of RECORD_INTERNAL: this one allow stack to answer interface record with default values (from LLDP and define) */
124 #define RECORD_INTERNAL_IO /* sub definition of RECORD_INTERNAL: this one allow stack to answer Input/Output record with default values (from PPM and CPM) */
125 
126 /*-----------------------------------------------------------------------*/
127 /* Includes an intterupt to inform the DUA from the stack when input */
128 /* data has change, this way we dont need to poll th einputs form the IO */
129 /* controller on every update, should be more efficient */
130 /*-----------------------------------------------------------------------*/
131 #define NEW_INPUT_DATA_MODE
132 
133 /*-----------------------------------------------------------------------*/
134 /* Allow controller to set device into DHCP mode */
135 /*-----------------------------------------------------------------------*/
136 //#define DHCP_ACTIVATE
137 
138 /*
139 Define the maximal number of alarm request from DUA the Stack can manage.
140 Whith a maximal set to 2, there can be one alarm in process and one stored
141 in queue. The third one will be refused and returned as error.
142 */
143 #define ALARM_MAX_QUEUE_LEVEL 3
144 
145 
146 /*-----------------------------------------------------------------------*/
147 /* define min send clock factor value */
148 /*-----------------------------------------------------------------------*/
149 #define MIN_SEND_CLOCK_FACTOR_VALUE 32
150 #define MAX_SEND_CLOCK_FACTOR_VALUE 128
151 
152 
153 /*-----------------------------------------------------------------------*/
154 /* define min reduction ratio value */
155 /*-----------------------------------------------------------------------*/
156 #define MIN_REDUCTION_RATIO_VALUE 1
157 
158 /*-----------------------------------------------------------------------*/
159 /* LLDP related define */
160 /*-----------------------------------------------------------------------*/
161 /* LLDP Definition */
162 #define LLDP_SUPPORTED
163 #define LLDP_RECEIVER
164 
165 /*#define LLDP_STD_DESC_SUPPORT*/
166 #define LLDP_SUPPORT_PN
167 #define LLDP_SUPPORT_8023
168 #define LLDP_STD_DESC_SUPPORT
169 
170 /* Maximal number of port on the system */
171 #define WSE_LLDP_MAX_PORT 1
172 
173 /* depth of remote mib per port: Max number of remote system per port*/
174 #define WSE_LLDP_REMOTE_SYSTEM_PORT 2
175 
176 /* WSE_LLDP_MAX_PORT* WSE_LLDP_REMOTE_SYSTEM_PORT shall be smaller than 255 !!! */
177 
178 /* Default CHASSIS ID */
179 #define WSE_LLDP_CHASSIS_DEFAULT {0xcc, 0xaa, 0xcc, 0xaa, 0xcc, 0xaa }
180 #define WSE_LLDP_CHASSIS_DEFAULT_LEN 6
181 
182 
183 /* Nb maximal of TLV per LLDPDU */
184 #define MAX_TLV_PER_LLDPDU 20
185 #define MAX_UNKNOWN_TLV_PER_LLDPDU MAX_TLV_PER_LLDPDU/5
186 
187 #ifndef LLDP_SUPPORT_MRP
188 #define MAX_PN_TLV_PER_LLDPDU 2
189 #endif
190 
191 #ifdef LLDP_SUPPORT_MRP
192 #define MAX_PN_TLV_PER_LLDPDU 3
193 #endif
194 
195 #define MAX_8023_TLV_PER_LLDPDU 1
196 
197 
198 /*-----------------------------------------------------------------------*/
199 /* Addin related define */
200 /*-----------------------------------------------------------------------*/
201 /*#define ADDIN_QUEUE*/
202 
203 /*-----------------------------------------------------------------------*/
204 /* MRP related define (need ADDIN_QUEUE define) */
205 /*-----------------------------------------------------------------------*/
206 /*
207 #define MRP_SUPPORTED
208 #define MRM_SUPPORTED
209 #define MRC_SUPPORTED
210 */
211 #ifdef MRP_SUPPORTED
212  #define LLDP_SUPPORT_MRP
213 #endif
214 
215 /*-----------------------------------------------------------------------*/
216 /* Table 238 norm V2.1 */
217 /* ARProperties.DataRate */
218 /* Value(hexadecimal) Meaning Usage */
219 /*-----------------------------------------------------------------------*/
220 
221 /* AR properties data rate is stored in Ar prperties
222  param server mask is 0110 0000 then the value 0 keep 0
223 */
224 /* At least 100 MB/s or more Default, Do Not Change */
225 #define AR_DATA_RATE_DEFAULT 0x00
226 
227 /* 100 MB/s is Supported Do not change value */
228 #define AR_DATA_RATE_100MB 32
229 
230 /* 1 GB/s is Supported Do not change value */
231 /* #define AR_DATA_RATE_1GB 64*/
232 
233 /* 10 GB/s is Supported Do not change value */
234 /* #define AR_DATA_RATE_10GB 96*/ /* 0x03*/
235 
236 
237 
238 /*----------------------------------------------------------------------------------------*/
239 /* Hash Table management: constant use in hash table management to optimize memory acces */
240 /*----------------------------------------------------------------------------------------*/
241 #define HASH_KEY_MAX_API 1 /* Max API stack will accepted */
242 #define HASH_KEY_MAX_SLOT 20 /* Max Slot stack will accepted */
243 #define HASH_KEY_MAX_SSLOT 16 /* Max SubSlot stack will accepted */
244 
245 /*Max Api+1 * Max size of an API */
246 #define HASH_SIZE ( (HASH_KEY_MAX_API+1)*( (HASH_KEY_MAX_SSLOT) * (HASH_KEY_MAX_SLOT) ) )
247 
248 /*-----------------------------------------------------------------------*/
249 /* Block version use to response to the record request */
250 /*-----------------------------------------------------------------------*/
251 #define RECORD_RSP_BLOCK_VERSION_HIGTH 1 /* Alowed value : 1*/
252 #define RECORD_RSP_BLOCK_VERSION_LOW 0 /* Alowed value : 0 or 1 */
253 
254 /*------------------------------------------------------------------------------------------------*/
255 /* This value is the max time awaiting before sending a DCP response */
256 /* PN-Al-Service: */
257 /* Client Hold Time */
258 /* This attribute shall contain the maximum value in seconds, which a server shall only allow */
259 /* Get or Set services from the last active client. Service requests from other server shall be */
260 /* ignored before. */
261 /* Attribute Type: Unsigned16 */
262 /* Default Value: 3 */
263 /*------------------------------------------------------------------------------------------------*/
264 #define DCP_CLIENT_HOLD_TIME 3 /* 3 seconde */
265 
266 
267 /*-----------------------------------------------------------------------*/
268 /* define RT_Class supported by device */
269 /* Stack device Profinet IO WoodHead only support RT_CLASS_1 in this */
270 /* version */
271 /*-----------------------------------------------------------------------*/
272 
273 #define RT_CLASS_1 0x1 /*the only one spported by the device */
274 #define RT_CLASS_2 0x2
275 #define RT_CLASS_3 0x3
276 #define RT_CLASS_UDP 0x4
277 
278 #define RT_CLASS_USE_BY_DEVICE RT_CLASS_1 /* the only one supported */
279 
280 /*-----------------------------------------------------------------------*/
281 /* ID of each Queue (Indirection between queue and Task/Thread) */
282 /*-----------------------------------------------------------------------*/
283 /*We need this if in the future we would like to modify number of thread*/
284 #define ID_QUEUE_ERROR 0
285 #define TASK_NAME_ERROR "ERROR"
286 #define ID_QUEUE_FALDEV 1
287 #define TASK_NAME_FALDEV "FAL"
288 #define ID_QUEUE_CMDEV 2
289 #define TASK_NAME_CMDEV "CMDEV"
290 #define ID_QUEUE_RMPM 3
291 #define TASK_NAME_RMPM "RMPM"
292 #define ID_QUEUE_RPC 4
293 #define TASK_NAME_RPC "RPC"
294 #define ID_QUEUE_CPM 5
295 #define TASK_NAME_CPM "CPM"
296 #define ID_QUEUE_PPM 6
297 #define TASK_NAME_PPM "PPM"
298 #define ID_QUEUE_DCP 7
299 #define TASK_NAME_DCP "DCP"
300 #define ID_QUEUE_ALM 8
301 #define TASK_NAME_ALM "ALM"
302 #define ID_QUEUE_MS 9
303 #define TASK_NAME_MS "MS"
304 #define ID_QUEUE_LMPM 10
305 #define TASK_NAME_LMPM "LMPM"
306 #define ID_QUEUE_FSPMDEV 11
307 #define TASK_NAME_FSPMDEV "FSPMDEV"
308 #define ID_QUEUE_DEBUG 12
309 #define TASK_NAME_DEBUG "MONITORING"
310 #define ID_QUEUE_SCHEDULE 13
311 #define TASK_NAME_SCHEDULE "SCHEDULE"
312 #define ID_QUEUE_ASESM 14
313 #define TASK_NAME_ASESM "STTUP"
314 
315 #define ID_QUEUE_ADDIN 15
316 #define TASK_NAME_ADDIN "ADDIN"
317 
318 #define ID_QUEUE_MRP 16
319 #define TASK_NAME_MRP "MRP"
320 
321 #define ID_QUEUE_LLDP 17
322 #define TASK_NAME_LLDP "LLDP"
323 
324 #define ID_QUEUE_WEB 18
325 #define TASK_NAME_WEB "WEB"
326 
327 #define ID_QUEUE_MAX ID_QUEUE_WEB
328 
329 #define _DEBUG_MAX_ALLOC_ 3000
330 
331 
332 /*-----------------------------------------------------------------------*/
333 /* acyclic */
334 /*-----------------------------------------------------------------------*/
335 
336 /*Max acyclic request manage simultaneously / application should regulate this*/
337 #define MAX_SIMULTANEOUS_ACYC_REQ 1
338 
339 /*Max data size of a rpc frag */
340 #define RPC_DATA_FRAG_SIZE (ETHERNET_MAX_FRAME_LENGTH - 14 - 8 - 20 - 8 - 80 - 4 ) /* Ethernet Frame size - Ethernet header - LLC frame for SNAP - ip header size - udp header size - rpc header size - CRC size */
341 
342 /*Max fragment per acyc request */
343 #define MAX_ACYC_FRAG 4
344 
345 /*Max rpc that could be call simultaneously (=> 1 socket by simultaneous rpc) */
346 #define MAX_RPCCLIENT (MAX_SIMULTANEOUS_ACYC_REQ * MAX_CONNEXION_PER_INSTANCE + 1)
347 
348 /*Max rpc that could be received simultaneously (= 1 socket) */
349 #define MAX_RPCSERVER (MAX_SIMULTANEOUS_ACYC_REQ * MAX_CONNEXION_PER_INSTANCE + 1)
350 
351 /*-----------------------------------------------------------------------*/
352 /* DCP */
353 /*-----------------------------------------------------------------------*/
354 #define MAX_SIMULTANEOUS_DCP_REQ 2 /* A unicast one and a multicast one */
355 
356 /*-----------------------------------------------------------------------*/
357 /* Sanity check */
358 /*-----------------------------------------------------------------------*/
359 #if defined IOCONTROLLER && defined IODEVICE
360  #pragma error ("Platform.h-->Profinet IO role definition Error")
361 #endif
362 #ifndef IOCONTROLLER
363  #ifndef IODEVICE
364  #pragma error ("Platform.h-->Profinet IO role shall be defined")
365  #endif
366 #endif
367 #ifndef IODEVICE
368  #pragma error ("Platform.h-->Profinet IO role shall be defined as IODEVICE")
369 #endif
370 #ifdef IODEVICE
371  #if MAX_DEVICE == 0
372  #pragma error ("Platform.h-->MAx device shall be greater than 0")
373  #endif
374 
375  #if MAX_INSTANCE_PER_DEVICE == 0
376  #pragma error ("Platform.h-->Device support at least one Instance")
377  #endif
378  #if MAX_INSTANCE_PER_DEVICE > 1
379  #pragma error ("Platform.h-->Multi Instance not yet implemented")
380  #endif
381 
382  #if MAX_ACYC_FRAG == 0
383  #pragma error ("Platform.h-->Max Acyclic Fragment shall be greater than 0")
384  #endif
385 
386  #if MAX_SIMULTANEOUS_ACYC_REQ == 0
387  #pragma error ("Platform.h-->Max Simultaneous Acyclic request shall be greater than 0")
388  #endif
389 
390  #if RT_CLASS_USE_BY_DEVICE != RT_CLASS_1
391  #pragma error ("Platform.h-->RT_CLASS is not supported")
392  #endif
393 
394  #if (API_RANGE_MIN > API_RANGE_MAX)
395  #pragma error ("Platform.h-->MAX_SLOT_SUPPORTED shall be greater than 0")
396  #endif
397 
398  #if (SLOT_RANGE_MIN > SLOT_RANGE_MAX)
399  #pragma error ("Platform.h-->MAX_SUBSLOT_SUPPORTED shall be greater than 0")
400  #endif
401 
402  #if (SUBSLOT_RANGE_MIN > SUBSLOT_RANGE_MAX)
403  #pragma error ("Platform.h-->MAX_API_SUPPORTED shall be greater than 0")
404  #endif
405 
406  #if MAX_CONNEXION_PER_INSTANCE == 0
407  #pragma error ("Platform.h-->MAX_CONNEXION_PER_INSTANCE shall be greater than 0")
408  #endif
409 
410  #if WSE_LLDP_MAX_PORT > 255
411  #pragma error ("Platform.h-->WSE_LLDP_MAX_PORT shall be smaller than 255")
412  #endif
413 
414 
415 
416 #endif
417 
418 #endif
419 
420 /*-----------------------------------------------------------------------*/
421 /* Debug instrumentation for wse use only */
422 /*-----------------------------------------------------------------------*/
423 /* #define _DEBUG_OS_ALLOC */
424 /* #define TEST_TIMER_PRECISION_WSE */
425 /* #define WEB_STAT */
426 
427  //#define ACTIVATE_LOG_EVENT
428  //#define ACTIVATE_LOG_L2_EVENT
429  //#define ACTIVATE_LOG_CBF_EVENT
430  //#define ACTIVATE_LOG_CBFIO_EVENT
431  #define MAX_EVENT_LOGGER 40