2 * @file IxOsalOsServices.c (linux)
4 * @brief Implementation for Irq, Mem, sleep.
8 * IXP400 SW Release version 1.5
10 * -- Copyright Notice --
13 * Copyright 2001-2005, Intel Corporation.
14 * All rights reserved.
17 * SPDX-License-Identifier: BSD-3-Clause
19 * -- End of Copyright Notice --
31 static char *traceHeaders[] = {
43 /* by default trace all but debug message */
44 PRIVATE int ixOsalCurrLogLevel = IX_OSAL_LOG_LVL_MESSAGE;
46 /**************************************
48 *************************************/
51 ixOsalIrqBind (UINT32 vector, IxOsalVoidFnVoidPtr routine, void *parameter)
57 ixOsalIrqUnbind (UINT32 vector)
68 /* Enable interrupts and task scheduling,
69 * input parameter: irqEnable status returned
73 ixOsalIrqUnlock (UINT32 lockKey)
78 ixOsalIrqLevelSet (UINT32 level)
84 ixOsalIrqEnable (UINT32 irqLevel)
89 ixOsalIrqDisable (UINT32 irqLevel)
93 /*********************
95 *********************/
98 ixOsalLog (IxOsalLogLevel level,
99 IxOsalLogDevice device,
100 char *format, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)
103 * Return -1 for custom display devices
105 if ((device != IX_OSAL_LOG_DEV_STDOUT)
106 && (device != IX_OSAL_LOG_DEV_STDERR))
108 debug("ixOsalLog: only IX_OSAL_LOG_DEV_STDOUT and IX_OSAL_LOG_DEV_STDERR are supported \n");
109 return (IX_OSAL_LOG_ERROR);
112 if (level <= ixOsalCurrLogLevel && level != IX_OSAL_LOG_LVL_NONE)
114 #if 0 /* sr: U-Boots printf or debug doesn't return a length */
115 int headerByteCount = (level == IX_OSAL_LOG_LVL_USER) ? 0 : diag_printf(traceHeaders[level - 1]);
117 return headerByteCount + diag_printf (format, arg1, arg2, arg3, arg4, arg5, arg6);
119 int headerByteCount = (level == IX_OSAL_LOG_LVL_USER) ? 0 : strlen(traceHeaders[level - 1]);
121 return headerByteCount + strlen(format);
129 return (IX_OSAL_LOG_ERROR);
134 ixOsalLogLevelSet (UINT32 level)
141 if ((level < IX_OSAL_LOG_LVL_NONE) || (level > IX_OSAL_LOG_LVL_ALL))
143 ixOsalLog (IX_OSAL_LOG_LVL_MESSAGE,
144 IX_OSAL_LOG_DEV_STDOUT,
145 "ixOsalLogLevelSet: Log Level is between %d and%d \n",
146 IX_OSAL_LOG_LVL_NONE, IX_OSAL_LOG_LVL_ALL, 0, 0, 0, 0);
147 return IX_OSAL_LOG_LVL_NONE;
149 oldLevel = ixOsalCurrLogLevel;
151 ixOsalCurrLogLevel = level;
156 /**************************************
158 *************************************/
161 ixOsalBusySleep (UINT32 microseconds)
163 udelay(microseconds);
167 ixOsalSleep (UINT32 milliseconds)
169 if (milliseconds != 0) {
172 * sr: We poll while we wait because interrupts are off in U-Boot
173 * and CSR expects messages, etc to be dispatched while sleeping.
176 IxQMgrDispatcherFuncPtr qDispatcherFunc;
178 ixQMgrDispatcherLoopGet(&qDispatcherFunc);
180 while (milliseconds--) {
181 for (i = 1; i <= 2; i++)
182 ixNpeMhMessagesReceive(i);
183 (*qDispatcherFunc)(IX_QMGR_QUELOW_GROUP);
191 /**************************************
193 *************************************/
196 ixOsalMemAlloc (UINT32 size)
202 ixOsalMemFree (void *ptr)
207 * Copy count bytes from src to dest ,
208 * returns pointer to the dest mem zone.
211 ixOsalMemCopy (void *dest, void *src, UINT32 count)
213 IX_OSAL_ASSERT (dest != NULL);
214 IX_OSAL_ASSERT (src != NULL);
215 return (memcpy (dest, src, count));
219 * Fills a memory zone with a given constant byte,
220 * returns pointer to the memory zone.
223 ixOsalMemSet (void *ptr, UINT8 filler, UINT32 count)
225 IX_OSAL_ASSERT (ptr != NULL);
226 return (memset (ptr, filler, count));