1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /********************************************************************20**
21 Name: System Services -- general
25 Desc: Macro definitions that are used by all implementations
30 *********************************************************************21*/
40 /* ss040.103: addition */
41 /* ss002.301 : errno.h is required for all */
44 /* the new driver support define */
46 #ifndef SS_DRVR_SUPPORT
47 #define SS_DRVR_SUPPORT
55 #error "SS_PROC_ID undefined!"
59 #error "SS_MAX_ENT undefined!"
63 #error "SS_MAX_INST undefined!"
67 /* ss029.103: modification: the data type of array modified */
68 #ifndef SS_MULTIPLE_PROCS
69 #define SS_INVALID_IDX 0xFF
70 #else /* SS_MULTIPLE_PROCS */
71 #define SS_INVALID_IDX 0xFFFF
72 #endif /* SS_MULTIPLE_PROCS */
77 #error "SS_MAX_TTSKS undefined!"
81 #error "SS_MAX_STSKS undefined!"
84 #ifdef SS_DRVR_SUPPORT
85 #ifndef SS_MAX_DRVRTSKS
86 #error "SS_MAX_DRVRTSKS undefined!"
88 #endif /* SS_DRVR_SUPPORT */
91 #ifndef SS_MAX_RTRTSKS
92 #error "SS_MAX_RTRTSKS undefined!"
94 #endif /* SS_RTR_SUPPORT */
96 /* ss029.103: modification: the data type of array modified */
97 #ifndef SS_MULTIPLE_PROCS
99 #else /* SS_MULTIPLE_PROCS */
100 #define SS_TSKNC 0xFFFF
101 #endif /* SS_MULTIPLE_PROCS */
106 #error "SS_MAX_TMRS undefined!"
113 #error "SS_MAX_REGS undefined!"
116 #ifndef SS_MAX_POOLS_PER_REG
117 #error "SS_MAX_POOLS_PER_REG undefined!"
122 #define SS_EVNT_DATA 0
123 #define SS_EVNT_TIMER 1
124 #define SS_EVNT_TERM 2
125 #define SS_EVNT_PERMTICK 3
129 #define SS_EVNT_TTSK_TERM 4
131 /* ss001.301: SSI Phase 2 watchdog feature additions */
133 #define SS_MAX_WD_NODES 256
134 #define SS_WD_HB_MSG_VER "1.0"
135 #define SS_WD_HB_REQ 0x0001
136 #define SS_WD_HB_RSP 0x0010
137 #define SS_WD_HB_MSG_SIZE 24
138 #define SS_WD_WDPORT 8888
139 #define SS_WD_WDPROC 99
140 #endif /* SS_WATCHDOG */
143 #ifdef SS_LOGGER_SUPPORT
144 #ifndef SS_MAX_LOGBUF_SIZE
145 #define SS_MAX_LOGBUF_SIZE 8192
148 #define SS_MAX_PATH 1024
150 #endif /* SS_LOGGER_SUPPORT */
153 /* object lock types */
154 #if (!defined(SS_STSKTBL_LOCK) \
155 || !defined(SS_STSKENTRY_LOCK) \
156 || !defined(SS_TMRTBL_LOCK) \
157 || !defined(SS_DMNDQ_LOCK) \
158 || !defined(SS_DRVRENTRY_LOCK) \
159 || !defined(SS_RTRENTRY_LOCK))
160 #error "SS_?_LOCK undefined!"
163 /* The define used for mapping the memory region with threadId */
164 #ifdef SS_THR_REG_MAP
165 /* Maximum times SSI retries to create a thread in case if it
166 * gets same pthread_self() id which already mapped with other
167 * thread. Once this limit is hit, SSI will exit. In ideal case
168 * this should not happen
170 #define SS_MAX_THREAD_CREATE_RETRY 100
172 /* Maximum thread to region mapping. The same is used to
173 * to get the reminder which is used as index for memory mapping
174 * array. This is kept as 10 to avoid any issues as we see
175 * the thread IDs are always even number and we have 4 thread
178 #define SS_MAX_THREAD_REGION_MAP 16
180 #define SS_MEM_THREAD_ID_SHIFT 24
182 #define SS_MEM_THREAD_ID_SHIFT 16
185 #define SS_INVALID_THREAD_REG_MAP 0xFF
187 #define SS_GET_THREAD_MEM_REGION() \
188 osCp.threadMemoryRegionMap[((pthread_self() >> SS_MEM_THREAD_ID_SHIFT) % SS_MAX_THREAD_REGION_MAP)]
190 #define SS_GET_THREAD_MEM_REGION() region
191 #endif /* SS_THR_REG_MAP */
193 /* ss040.103 changed how ssWaitSema is called */
194 /* ss013.13: addition */
196 /*ss014.301 SSI-4GMX specific changes*/
197 #ifndef SS_4GMX_LCORE
198 #define SS_ACQUIRE_ALL_SEMA(s, ret) \
202 for (q = 0; q < SS_MAX_STSKS; q++) \
204 while ((ret = ssWaitSema(s) != ROK) && (errno == EINTR)) \
208 SSLOGERROR(ERRCLS_DEBUG, ESSXXX, ERRZERO,\
209 "Could not lock the Semaphore");\
215 ret = ssPostSema(s); \
218 SSLOGERROR(ERRCLS_DEBUG, ESSXXX, ERRZERO,\
219 "Could not unlock the Semaphore");\
231 /* ss006.13: addition */
232 #define SS_RELEASE_ALL_SEMA(s) \
235 for (q = 0; q < SS_MAX_STSKS; q++) \
237 if ( (ssPostSema(s)) != ROK)\
239 SSLOGERROR(ERRCLS_DEBUG, ESSXXX, ERRZERO,\
240 "Could not unlock the Semaphore");\
246 /* ss040.103 changed how ssWaitSema is called */
247 #define SS_ACQUIRE_SEMA(s, ret) \
248 while ((ret = ssWaitSema(s) != ROK) && (errno == EINTR)) \
250 /* ss041.103 removed exta lines */
254 /* ss006.13: addition */
255 #define SS_RELEASE_SEMA(s) \
258 /* ss029.103: addition: multiple procIds related changes */
259 #ifdef SS_MULTIPLE_PROCS
260 #define SS_INV_PROCID_IDX 0xFFFF /* invalid index in procId table */
261 #define SS_INV_PROCID 0xFFFF /* invalid proc id */
263 #define SS_HASH_IDX(_proc) (_proc % SS_MAX_PROCS)
265 #endif /* SS_MULTIPLE_PROCS */
267 #define SS_ACQUIRE_ALL_SEMA(s, ret) \
269 ret = ssWaitSema(s); \
273 #define SS_RELEASE_ALL_SEMA(s) \
278 #define SS_ACQUIRE_SEMA(s, ret) \
281 #define SS_RELEASE_SEMA(s) \
283 #endif /* SS_4GMX_LCORE */
289 #endif /* __SSGENH__ */
293 /********************************************************************30**
296 **********************************************************************/