change console=tty0 to enable linux framebuffer console
[jz_uboot.git] / cpu / ixp / npe / include / IxEthDBLocks_p.h
blob1d8b24fdf66a5bf3eeab7a1a7f7c3376a980507f
1 /**
2 * @file IxEthAccDBLocks_p.h
4 * @brief Definition of transaction lock stacks and lock utility macros
5 *
6 * @par
7 * IXP400 SW Release version 2.0
8 *
9 * -- Copyright Notice --
11 * @par
12 * Copyright 2001-2005, Intel Corporation.
13 * All rights reserved.
15 * @par
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. Neither the name of the Intel Corporation nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
28 * @par
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
30 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
41 * @par
42 * -- End of Copyright Notice --
45 #ifndef IxEthAccDBLocks_p_H
46 #define IxEthAccDBLocks_p_H
48 #include "IxOsPrintf.h"
50 /* Lock and lock stacks */
51 typedef struct
53 IxOsalFastMutex* locks[MAX_LOCKS];
54 UINT32 stackPointer, basePointer;
55 } LockStack;
57 #define TRY_LOCK(mutex) \
58 { \
59 if (ixOsalFastMutexTryLock(mutex) != IX_SUCCESS) \
60 { \
61 return IX_ETH_DB_BUSY; \
62 } \
66 #define UNLOCK(mutex) { ixOsalFastMutexUnlock(mutex); }
68 #define INIT_STACK(stack) \
69 { \
70 (stack)->basePointer = 0; \
71 (stack)->stackPointer = 0; \
74 #define PUSH_LOCK(stack, lock) \
75 { \
76 if ((stack)->stackPointer == MAX_LOCKS) \
77 { \
78 ERROR_LOG("Ethernet DB: maximum number of elements in a lock stack has been exceeded on push, heavy chaining?\n"); \
79 UNROLL_STACK(stack); \
81 return IX_ETH_DB_NOMEM; \
82 } \
84 if (ixOsalFastMutexTryLock(lock) == IX_SUCCESS) \
85 { \
86 (stack)->locks[(stack)->stackPointer++] = (lock); \
87 } \
88 else \
89 { \
90 UNROLL_STACK(stack); \
92 return IX_ETH_DB_BUSY; \
93 } \
96 #define POP_LOCK(stack) \
97 { \
98 ixOsalFastMutexUnlock((stack)->locks[--(stack)->stackPointer]); \
101 #define UNROLL_STACK(stack) \
103 while ((stack)->stackPointer > (stack)->basePointer) \
105 POP_LOCK(stack); \
109 #define SHIFT_STACK(stack) \
111 if ((stack)->basePointer == MAX_LOCKS - 1) \
113 ERROR_LOG("Ethernet DB: maximum number of elements in a lock stack has been exceeded on shift, heavy chaining?\n"); \
114 UNROLL_STACK(stack); \
116 return IX_ETH_DB_BUSY; \
119 ixOsalFastMutexUnlock((stack)->locks[(stack)->basePointer++]); \
122 #endif /* IxEthAccDBLocks_p_H */