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 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 * 3. Neither the name of the Intel Corporation nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * -- End of Copyright Notice --
55 static char *traceHeaders[] = {
67 /* by default trace all but debug message */
68 PRIVATE int ixOsalCurrLogLevel = IX_OSAL_LOG_LVL_MESSAGE;
70 /**************************************
72 *************************************/
75 ixOsalIrqBind (UINT32 vector, IxOsalVoidFnVoidPtr routine, void *parameter)
81 ixOsalIrqUnbind (UINT32 vector)
92 /* Enable interrupts and task scheduling,
93 * input parameter: irqEnable status returned
97 ixOsalIrqUnlock (UINT32 lockKey)
102 ixOsalIrqLevelSet (UINT32 level)
108 ixOsalIrqEnable (UINT32 irqLevel)
113 ixOsalIrqDisable (UINT32 irqLevel)
117 /*********************
119 *********************/
122 ixOsalLog (IxOsalLogLevel level,
123 IxOsalLogDevice device,
124 char *format, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)
127 * Return -1 for custom display devices
129 if ((device != IX_OSAL_LOG_DEV_STDOUT)
130 && (device != IX_OSAL_LOG_DEV_STDERR))
132 debug("ixOsalLog: only IX_OSAL_LOG_DEV_STDOUT and IX_OSAL_LOG_DEV_STDERR are supported \n");
133 return (IX_OSAL_LOG_ERROR);
136 if (level <= ixOsalCurrLogLevel && level != IX_OSAL_LOG_LVL_NONE)
138 #if 0 /* sr: U-Boots printf or debug doesn't return a length */
139 int headerByteCount = (level == IX_OSAL_LOG_LVL_USER) ? 0 : diag_printf(traceHeaders[level - 1]);
141 return headerByteCount + diag_printf (format, arg1, arg2, arg3, arg4, arg5, arg6);
143 int headerByteCount = (level == IX_OSAL_LOG_LVL_USER) ? 0 : strlen(traceHeaders[level - 1]);
145 return headerByteCount + strlen(format);
153 return (IX_OSAL_LOG_ERROR);
158 ixOsalLogLevelSet (UINT32 level)
165 if ((level < IX_OSAL_LOG_LVL_NONE) || (level > IX_OSAL_LOG_LVL_ALL))
167 ixOsalLog (IX_OSAL_LOG_LVL_MESSAGE,
168 IX_OSAL_LOG_DEV_STDOUT,
169 "ixOsalLogLevelSet: Log Level is between %d and%d \n",
170 IX_OSAL_LOG_LVL_NONE, IX_OSAL_LOG_LVL_ALL, 0, 0, 0, 0);
171 return IX_OSAL_LOG_LVL_NONE;
173 oldLevel = ixOsalCurrLogLevel;
175 ixOsalCurrLogLevel = level;
180 /**************************************
182 *************************************/
185 ixOsalBusySleep (UINT32 microseconds)
187 udelay(microseconds);
191 ixOsalSleep (UINT32 milliseconds)
193 if (milliseconds != 0) {
196 * sr: We poll while we wait because interrupts are off in U-Boot
197 * and CSR expects messages, etc to be dispatched while sleeping.
200 IxQMgrDispatcherFuncPtr qDispatcherFunc;
202 ixQMgrDispatcherLoopGet(&qDispatcherFunc);
204 while (milliseconds--) {
205 for (i = 1; i <= 2; i++)
206 ixNpeMhMessagesReceive(i);
207 (*qDispatcherFunc)(IX_QMGR_QUELOW_GROUP);
215 /**************************************
217 *************************************/
220 ixOsalMemAlloc (UINT32 size)
226 ixOsalMemFree (void *ptr)
231 * Copy count bytes from src to dest ,
232 * returns pointer to the dest mem zone.
235 ixOsalMemCopy (void *dest, void *src, UINT32 count)
237 IX_OSAL_ASSERT (dest != NULL);
238 IX_OSAL_ASSERT (src != NULL);
239 return (memcpy (dest, src, count));
243 * Fills a memory zone with a given constant byte,
244 * returns pointer to the memory zone.
247 ixOsalMemSet (void *ptr, UINT8 filler, UINT32 count)
249 IX_OSAL_ASSERT (ptr != NULL);
250 return (memset (ptr, filler, count));