change console=tty0 to enable linux framebuffer console
[jz_uboot.git] / cpu / ixp / npe / include / ix_macros.h
blob53f5942f9790999c66686a1778299e9ae105801c
1 /**
2 * ============================================================================
3 * = COPYRIGHT
4 *
5 * @par
6 * IXP400 SW Release version 2.0
7 *
8 * -- Copyright Notice --
9 *
10 * @par
11 * Copyright 2001-2005, Intel Corporation.
12 * All rights reserved.
14 * @par
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. Neither the name of the Intel Corporation nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * @par
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
40 * @par
41 * -- End of Copyright Notice --
42 * = PRODUCT
43 * Intel(r) IXP425 Software Release
45 * = FILENAME
46 * ix_macros.h
48 * = DESCRIPTION
49 * This file will define the basic preprocessor macros that are going to be used
50 * the IXA SDK Framework API.
52 * = AUTHOR
53 * Intel Corporation
55 * = CHANGE HISTORY
56 * 4/22/2002 4:41:05 PM - creation time
57 * ============================================================================
60 #if !defined(__IX_MACROS_H__)
61 #define __IX_MACROS_H__
64 #if defined(__cplusplus)
65 extern "C"
67 #endif /* end defined(__cplusplus) */
70 /**
71 * MACRO NAME: IX_BIT_FIELD_MASK16
73 * DESCRIPTION: Builds the mask required to extract the bit field from a 16 bit unsigned integer value.
75 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
76 * bit of the bit field.
77 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
78 * bit of the bit field.
80 * @Return: Returns a 16 bit mask that will extract the bit field from a 16 bit unsigned integer value.
82 #define IX_BIT_FIELD_MASK16( \
83 arg_FieldLSBBit, \
84 arg_FieldMSBBit \
85 ) \
86 ((ix_bit_mask16)((((ix_uint16)1 << (arg_FieldMSBBit + 1 - arg_FieldLSBBit)) - \
87 (ix_uint16)1) << arg_FieldLSBBit))
91 /**
92 * MACRO NAME: IX_GET_BIT_FIELD16
94 * DESCRIPTION: Extracts a bit field from 16 bit unsigned integer. The returned value is normalized in
95 * in the sense that will be right aligned.
97 * @Param: - IN arg_PackedData16 a 16 bit unsigned integer that contains the bit field of interest.
98 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
99 * bit of the bit field.
100 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
101 * bit of the bit field.
103 * @Return: Returns the value of the bit field. The value can be from 0 to (1 << (arg_FieldMSBBit + 1 -
104 * arg_FieldLSBBit)) - 1.
106 #define IX_GET_BIT_FIELD16( \
107 arg_PackedData16, \
108 arg_FieldLSBBit, \
109 arg_FieldMSBBit \
111 (((ix_uint16)(arg_PackedData16) & IX_BIT_FIELD_MASK16(arg_FieldLSBBit, arg_FieldMSBBit)) >> \
112 arg_FieldLSBBit)
116 * MACRO NAME: IX_MAKE_BIT_FIELD16
118 * DESCRIPTION: This macro will create a temporary 16 bit value with the bit field
119 * desired set to the desired value.
121 * @Param: - IN arg_BitFieldValue is the new value of the bit field. The value can be from 0 to
122 * (1 << (arg_FieldMSBBit + 1 - arg_FieldLSBBit)) - 1.
123 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
124 * bit of the bit field.
125 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
126 * bit of the bit field.
128 * @Return: Returns a temporary ix_uint16 value that has the bit field set to the appropriate value.
130 #define IX_MAKE_BIT_FIELD16( \
131 arg_BitFieldValue, \
132 arg_FieldLSBBit, \
133 arg_FieldMSBBit \
135 (((ix_uint16)(arg_BitFieldValue) << arg_FieldLSBBit) & \
136 IX_BIT_FIELD_MASK16(arg_FieldLSBBit, arg_FieldMSBBit))
139 * MACRO NAME: IX_SET_BIT_FIELD16
141 * DESCRIPTION: Sets a new value for a bit field from a 16 bit unsigned integer.
143 * @Param: - IN arg_PackedData16 a 16 bit unsigned integer that contains the bit field of interest.
144 * @Param: - IN arg_BitFieldValue is the new vale of the bit field. The value can be from 0 to
145 * (1 << (arg_FieldMSBBit + 1 - arg_FieldLSBBit)) - 1.
146 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
147 * bit of the bit field.
148 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
149 * bit of the bit field.
151 * @Return: Returns the updated value of arg_PackedData16.
153 #define IX_SET_BIT_FIELD16( \
154 arg_PackedData16, \
155 arg_BitFieldValue, \
156 arg_FieldLSBBit, \
157 arg_FieldMSBBit \
159 (arg_PackedData16 = (((ix_uint16)(arg_PackedData16) & \
160 ~(IX_BIT_FIELD_MASK16(arg_FieldLSBBit, arg_FieldMSBBit))) | \
161 IX_MAKE_BIT_FIELD16(arg_BitFieldValue, arg_FieldLSBBit, arg_FieldMSBBit)))
165 * MACRO NAME: IX_BIT_FIELD_MASK32
167 * DESCRIPTION: Builds the mask required to extract the bit field from a 32 bit unsigned integer value.
169 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
170 * bit of the bit field.
171 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
172 * bit of the bit field.
174 * @Return: Returns a 32 bit mask that will extract the bit field from a 32 bit unsigned integer value.
176 #define IX_BIT_FIELD_MASK32( \
177 arg_FieldLSBBit, \
178 arg_FieldMSBBit \
180 ((ix_bit_mask32)((((ix_uint32)1 << (arg_FieldMSBBit + 1 - arg_FieldLSBBit)) - \
181 (ix_uint32)1) << arg_FieldLSBBit))
186 * MACRO NAME: IX_GET_BIT_FIELD32
188 * DESCRIPTION: Extracts a bit field from 32 bit unsigned integer. The returned value is normalized in
189 * in the sense that will be right aligned.
191 * @Param: - IN arg_PackedData32 a 32 bit unsigned integer that contains the bit field of interest.
192 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
193 * bit of the bit field.
194 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
195 * bit of the bit field.
197 * @Return: Returns the value of the bit field. The value can be from 0 to (1 << (arg_FieldMSBBit + 1 -
198 * arg_FieldLSBBit)) - 1.
200 #define IX_GET_BIT_FIELD32( \
201 arg_PackedData32, \
202 arg_FieldLSBBit, \
203 arg_FieldMSBBit \
205 (((ix_uint32)(arg_PackedData32) & IX_BIT_FIELD_MASK32(arg_FieldLSBBit, arg_FieldMSBBit)) >> \
206 arg_FieldLSBBit)
212 * MACRO NAME: IX_MAKE_BIT_FIELD32
214 * DESCRIPTION: This macro will create a temporary 32 bit value with the bit field
215 * desired set to the desired value.
217 * @Param: - IN arg_BitFieldValue is the new value of the bit field. The value can be from 0 to
218 * (1 << (arg_FieldMSBBit + 1 - arg_FieldLSBBit)) - 1.
219 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
220 * bit of the bit field.
221 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
222 * bit of the bit field.
224 * @Return: Returns a temporary ix_uint32 value that has the bit field set to the appropriate value.
226 #define IX_MAKE_BIT_FIELD32( \
227 arg_BitFieldValue, \
228 arg_FieldLSBBit, \
229 arg_FieldMSBBit \
231 (((ix_uint32)(arg_BitFieldValue) << arg_FieldLSBBit) & \
232 IX_BIT_FIELD_MASK32(arg_FieldLSBBit, arg_FieldMSBBit))
236 * MACRO NAME: IX_SET_BIT_FIELD32
238 * DESCRIPTION: Sets a new value for a bit field from a 32 bit unsigned integer.
240 * @Param: - IN arg_PackedData32 a 32 bit unsigned integer that contains the bit field of interest.
241 * @Param: - IN arg_BitFieldValue is the new value of the bit field. The value can be from 0 to
242 * (1 << (arg_FieldMSBBit + 1 - arg_FieldLSBBit)) - 1.
243 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
244 * bit of the bit field.
245 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
246 * bit of the bit field.
248 * @Return: Returns the updated value of arg_PackedData32.
250 #define IX_SET_BIT_FIELD32( \
251 arg_PackedData32, \
252 arg_BitFieldValue, \
253 arg_FieldLSBBit, \
254 arg_FieldMSBBit \
256 (arg_PackedData32 = (((ix_uint32)(arg_PackedData32) & \
257 ~(IX_BIT_FIELD_MASK32(arg_FieldLSBBit, arg_FieldMSBBit))) | \
258 IX_MAKE_BIT_FIELD32(arg_BitFieldValue, arg_FieldLSBBit, arg_FieldMSBBit)))
262 #if defined(__cplusplus)
264 #endif /* end defined(__cplusplus) */
266 #endif /* end !defined(__IX_MACROS_H__) */