2 * ============================================================================
6 * IXP400 SW Release version 2.0
8 * -- Copyright Notice --
11 * Copyright 2001-2005, Intel Corporation.
12 * All rights reserved.
15 * SPDX-License-Identifier: BSD-3-Clause
17 * -- End of Copyright Notice --
19 * Intel(r) IXP425 Software Release
25 * This file will define the basic preprocessor macros that are going to be used
26 * the IXA SDK Framework API.
32 * 4/22/2002 4:41:05 PM - creation time
33 * ============================================================================
36 #if !defined(__IX_MACROS_H__)
37 #define __IX_MACROS_H__
40 #if defined(__cplusplus)
43 #endif /* end defined(__cplusplus) */
47 * MACRO NAME: IX_BIT_FIELD_MASK16
49 * DESCRIPTION: Builds the mask required to extract the bit field from a 16 bit unsigned integer value.
51 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
52 * bit of the bit field.
53 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
54 * bit of the bit field.
56 * @Return: Returns a 16 bit mask that will extract the bit field from a 16 bit unsigned integer value.
58 #define IX_BIT_FIELD_MASK16( \
62 ((ix_bit_mask16)((((ix_uint16)1 << (arg_FieldMSBBit + 1 - arg_FieldLSBBit)) - \
63 (ix_uint16)1) << arg_FieldLSBBit))
68 * MACRO NAME: IX_GET_BIT_FIELD16
70 * DESCRIPTION: Extracts a bit field from 16 bit unsigned integer. The returned value is normalized in
71 * in the sense that will be right aligned.
73 * @Param: - IN arg_PackedData16 a 16 bit unsigned integer that contains the bit field of interest.
74 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
75 * bit of the bit field.
76 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
77 * bit of the bit field.
79 * @Return: Returns the value of the bit field. The value can be from 0 to (1 << (arg_FieldMSBBit + 1 -
80 * arg_FieldLSBBit)) - 1.
82 #define IX_GET_BIT_FIELD16( \
87 (((ix_uint16)(arg_PackedData16) & IX_BIT_FIELD_MASK16(arg_FieldLSBBit, arg_FieldMSBBit)) >> \
92 * MACRO NAME: IX_MAKE_BIT_FIELD16
94 * DESCRIPTION: This macro will create a temporary 16 bit value with the bit field
95 * desired set to the desired value.
97 * @Param: - IN arg_BitFieldValue is the new value of the bit field. The value can be from 0 to
98 * (1 << (arg_FieldMSBBit + 1 - arg_FieldLSBBit)) - 1.
99 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
100 * bit of the bit field.
101 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
102 * bit of the bit field.
104 * @Return: Returns a temporary ix_uint16 value that has the bit field set to the appropriate value.
106 #define IX_MAKE_BIT_FIELD16( \
111 (((ix_uint16)(arg_BitFieldValue) << arg_FieldLSBBit) & \
112 IX_BIT_FIELD_MASK16(arg_FieldLSBBit, arg_FieldMSBBit))
115 * MACRO NAME: IX_SET_BIT_FIELD16
117 * DESCRIPTION: Sets a new value for a bit field from a 16 bit unsigned integer.
119 * @Param: - IN arg_PackedData16 a 16 bit unsigned integer that contains the bit field of interest.
120 * @Param: - IN arg_BitFieldValue is the new vale of the bit field. The value can be from 0 to
121 * (1 << (arg_FieldMSBBit + 1 - arg_FieldLSBBit)) - 1.
122 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
123 * bit of the bit field.
124 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
125 * bit of the bit field.
127 * @Return: Returns the updated value of arg_PackedData16.
129 #define IX_SET_BIT_FIELD16( \
135 (arg_PackedData16 = (((ix_uint16)(arg_PackedData16) & \
136 ~(IX_BIT_FIELD_MASK16(arg_FieldLSBBit, arg_FieldMSBBit))) | \
137 IX_MAKE_BIT_FIELD16(arg_BitFieldValue, arg_FieldLSBBit, arg_FieldMSBBit)))
141 * MACRO NAME: IX_BIT_FIELD_MASK32
143 * DESCRIPTION: Builds the mask required to extract the bit field from a 32 bit unsigned integer value.
145 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
146 * bit of the bit field.
147 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
148 * bit of the bit field.
150 * @Return: Returns a 32 bit mask that will extract the bit field from a 32 bit unsigned integer value.
152 #define IX_BIT_FIELD_MASK32( \
156 ((ix_bit_mask32)((((ix_uint32)1 << (arg_FieldMSBBit + 1 - arg_FieldLSBBit)) - \
157 (ix_uint32)1) << arg_FieldLSBBit))
162 * MACRO NAME: IX_GET_BIT_FIELD32
164 * DESCRIPTION: Extracts a bit field from 32 bit unsigned integer. The returned value is normalized in
165 * in the sense that will be right aligned.
167 * @Param: - IN arg_PackedData32 a 32 bit unsigned integer that contains the bit field of interest.
168 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
169 * bit of the bit field.
170 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
171 * bit of the bit field.
173 * @Return: Returns the value of the bit field. The value can be from 0 to (1 << (arg_FieldMSBBit + 1 -
174 * arg_FieldLSBBit)) - 1.
176 #define IX_GET_BIT_FIELD32( \
181 (((ix_uint32)(arg_PackedData32) & IX_BIT_FIELD_MASK32(arg_FieldLSBBit, arg_FieldMSBBit)) >> \
188 * MACRO NAME: IX_MAKE_BIT_FIELD32
190 * DESCRIPTION: This macro will create a temporary 32 bit value with the bit field
191 * desired set to the desired value.
193 * @Param: - IN arg_BitFieldValue is the new value of the bit field. The value can be from 0 to
194 * (1 << (arg_FieldMSBBit + 1 - arg_FieldLSBBit)) - 1.
195 * @Param: - IN arg_FieldLSBBit an unsigned integer value representing the position of the least significant
196 * bit of the bit field.
197 * @Param: - IN arg_FieldMSBBit an unsigned integer value representing the position of the most significant
198 * bit of the bit field.
200 * @Return: Returns a temporary ix_uint32 value that has the bit field set to the appropriate value.
202 #define IX_MAKE_BIT_FIELD32( \
207 (((ix_uint32)(arg_BitFieldValue) << arg_FieldLSBBit) & \
208 IX_BIT_FIELD_MASK32(arg_FieldLSBBit, arg_FieldMSBBit))
212 * MACRO NAME: IX_SET_BIT_FIELD32
214 * DESCRIPTION: Sets a new value for a bit field from a 32 bit unsigned integer.
216 * @Param: - IN arg_PackedData32 a 32 bit unsigned integer that contains the bit field of interest.
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 the updated value of arg_PackedData32.
226 #define IX_SET_BIT_FIELD32( \
232 (arg_PackedData32 = (((ix_uint32)(arg_PackedData32) & \
233 ~(IX_BIT_FIELD_MASK32(arg_FieldLSBBit, arg_FieldMSBBit))) | \
234 IX_MAKE_BIT_FIELD32(arg_BitFieldValue, arg_FieldLSBBit, arg_FieldMSBBit)))
238 #if defined(__cplusplus)
240 #endif /* end defined(__cplusplus) */
242 #endif /* end !defined(__IX_MACROS_H__) */