Merge commit 'origin/master' into next
[linux-2.6] / drivers / staging / epl / EplObjDef.h
1 /****************************************************************************
2
3   (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4       www.systec-electronic.com
5
6   Project:      openPOWERLINK
7
8   Description:  defines objdict dictionary
9
10   License:
11
12     Redistribution and use in source and binary forms, with or without
13     modification, are permitted provided that the following conditions
14     are met:
15
16     1. Redistributions of source code must retain the above copyright
17        notice, this list of conditions and the following disclaimer.
18
19     2. Redistributions in binary form must reproduce the above copyright
20        notice, this list of conditions and the following disclaimer in the
21        documentation and/or other materials provided with the distribution.
22
23     3. Neither the name of SYSTEC electronic GmbH nor the names of its
24        contributors may be used to endorse or promote products derived
25        from this software without prior written permission. For written
26        permission, please contact info@systec-electronic.com.
27
28     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32     COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39     POSSIBILITY OF SUCH DAMAGE.
40
41     Severability Clause:
42
43         If a provision of this License is or becomes illegal, invalid or
44         unenforceable in any jurisdiction, that shall not affect:
45         1. the validity or enforceability in that jurisdiction of any other
46            provision of this License; or
47         2. the validity or enforceability in other jurisdictions of that or
48            any other provision of this License.
49
50   -------------------------------------------------------------------------
51
52                 $RCSfile: EplObjDef.h,v $
53
54                 $Author: D.Krueger $
55
56                 $Revision: 1.4 $  $Date: 2008/04/17 21:36:32 $
57
58                 $State: Exp $
59
60                 Build Environment:
61                     GCC V3.4
62
63   -------------------------------------------------------------------------
64
65   Revision History:
66
67   2006/06/06    k.t.:   take ObjDef.h from CANopen and modify for EPL
68
69 ****************************************************************************/
70
71 #ifndef _EPLOBJDEF_H_
72 #define _EPLOBJDEF_H_
73
74 //---------------------------------------------------------------------------
75 // security checks
76 //---------------------------------------------------------------------------
77
78 //---------------------------------------------------------------------------
79 // macros to help building OD
80 //---------------------------------------------------------------------------
81
82 //---------------------------------------------------------------------------
83 #if (defined (EPL_OBD_USE_VARIABLE_SUBINDEX_TAB) && (EPL_OBD_USE_VARIABLE_SUBINDEX_TAB != FALSE))
84
85 #define CCM_SUBINDEX_RAM_ONLY(a)    a;
86 #define CCM_SUBINDEX_RAM_ONEOF(a,b) a
87
88 #else
89
90 #define CCM_SUBINDEX_RAM_ONLY(a)
91 #define CCM_SUBINDEX_RAM_ONEOF(a,b) b
92
93 #endif
94
95 //---------------------------------------------------------------------------
96 // To prevent unused memory in subindex tables we need this macro.
97 // But not all compilers support to preset the last struct value followed by a comma.
98 // Compilers which does not support a comma after last struct value has to place in a dummy subindex.
99 #if ((DEV_SYSTEM & _DEV_COMMA_EXT_) != 0)
100
101 #define EPL_OBD_END_SUBINDEX()
102 #define EPL_OBD_MAX_ARRAY_SUBENTRIES    2
103
104 #else
105
106 #define EPL_OBD_END_SUBINDEX()          {0,0,0,NULL,NULL}
107 #define EPL_OBD_MAX_ARRAY_SUBENTRIES    3
108
109 #endif
110
111 //---------------------------------------------------------------------------
112 //---------------------------------------------------------------------------
113 // globale vars
114 //---------------------------------------------------------------------------
115 //---------------------------------------------------------------------------
116
117 // -------------------------------------------------------------------------
118 // creation of data in ROM memory
119 // -------------------------------------------------------------------------
120 #define EPL_OBD_CREATE_ROM_DATA
121 #include "objdict.h"
122 #undef EPL_OBD_CREATE_ROM_DATA
123
124 // -------------------------------------------------------------------------
125 // creation of data in RAM memory
126 // -------------------------------------------------------------------------
127
128 #define EPL_OBD_CREATE_RAM_DATA
129 #include "objdict.h"
130 #undef EPL_OBD_CREATE_RAM_DATA
131
132 // -------------------------------------------------------------------------
133 // creation of subindex tables in ROM and RAM
134 // -------------------------------------------------------------------------
135
136 #define EPL_OBD_CREATE_SUBINDEX_TAB
137 #include "objdict.h"
138 #undef EPL_OBD_CREATE_SUBINDEX_TAB
139
140 // -------------------------------------------------------------------------
141 // creation of index tables for generic, manufacturer and device part
142 // -------------------------------------------------------------------------
143
144 #define EPL_OBD_CREATE_INDEX_TAB
145 #include "objdict.h"
146 #undef EPL_OBD_CREATE_INDEX_TAB
147
148 //=========================================================================//
149 //                                                                         //
150 //          P U B L I C   F U N C T I O N S                                //
151 //                                                                         //
152 //=========================================================================//
153
154 // ----------------------------------------------------------------------------
155 //
156 // Function:    EPL_OBD_INIT_RAM_NAME()
157 //
158 // Description: function to initialize object dictionary
159 //
160 // Parameters:  pInitParam_p    = pointer to init param struct of Epl
161 //
162 // Returns:     tEplKernel      = error code
163 //
164 // State:
165 //
166 // ----------------------------------------------------------------------------
167
168 EPLDLLEXPORT tEplKernel PUBLIC EPL_OBD_INIT_RAM_NAME(tEplObdInitParam MEM *
169                                                      pInitParam_p)
170 {
171
172         tEplObdInitParam MEM *pInitParam = pInitParam_p;
173
174         // check if pointer to parameter structure is valid
175         // if not then only copy subindex tables below
176         if (pInitParam != NULL) {
177                 // at first delete all parameters (all pointers will be set zu NULL)
178                 EPL_MEMSET(pInitParam, 0, sizeof(tEplObdInitParam));
179
180 #define EPL_OBD_CREATE_INIT_FUNCTION
181                 {
182                         // inserts code to init pointer to index tables
183 #include "objdict.h"
184                 }
185 #undef EPL_OBD_CREATE_INIT_FUNCTION
186
187 #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
188                 {
189                         // to begin no user OD is defined
190                         pInitParam_p->m_pUserPart = NULL;
191                 }
192 #endif
193         }
194 #define EPL_OBD_CREATE_INIT_SUBINDEX
195         {
196                 // inserts code to copy subindex tables
197 #include "objdict.h"
198         }
199 #undef EPL_OBD_CREATE_INIT_SUBINDEX
200
201         return kEplSuccessful;
202
203 }
204
205 #endif // _EPLOBJDEF_H_
206
207 // Die letzte Zeile muß unbedingt eine leere Zeile sein, weil manche Compiler
208 // damit ein Problem haben, wenn das nicht so ist (z.B. GNU oder Borland C++ Builder).