|
RTEMS 6.1-rc6
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
36#ifndef LIBCPU_SHARED_UTILITY_H
37#define LIBCPU_SHARED_UTILITY_H
41#define BSP_BIT8(bit) \
42 ((uint8_t) (((unsigned int) 1) << (bit)))
44#define BSP_MSK8(first_bit, last_bit) \
45 ((uint8_t) ((BSP_BIT8((last_bit) - (first_bit) + 1) - 1) << (first_bit)))
47#define BSP_FLD8(val, first_bit, last_bit) \
49 ((((unsigned int) (val)) << (first_bit)) & BSP_MSK8(first_bit, last_bit)))
51#define BSP_FLD8GET(reg, first_bit, last_bit) \
52 ((uint8_t) (((reg) & BSP_MSK8(first_bit, last_bit)) >> (first_bit)))
54#define BSP_FLD8SET(reg, val, first_bit, last_bit) \
55 ((uint8_t) (((reg) & ~BSP_MSK8(first_bit, last_bit)) \
56 | BSP_FLD8(val, first_bit, last_bit)))
58#define BSP_BIT16(bit) \
59 ((uint16_t) (((unsigned int) 1) << (bit)))
61#define BSP_MSK16(first_bit, last_bit) \
62 ((uint16_t) ((BSP_BIT16((last_bit) - (first_bit) + 1) - 1) << (first_bit)))
64#define BSP_FLD16(val, first_bit, last_bit) \
66 ((((unsigned int) (val)) << (first_bit)) & BSP_MSK16(first_bit, last_bit)))
68#define BSP_FLD16GET(reg, first_bit, last_bit) \
69 ((uint16_t) (((reg) & BSP_MSK16(first_bit, last_bit)) >> (first_bit)))
71#define BSP_FLD16SET(reg, val, first_bit, last_bit) \
72 ((uint16_t) (((reg) & ~BSP_MSK16(first_bit, last_bit)) \
73 | BSP_FLD16(val, first_bit, last_bit)))
75#define BSP_BIT32(bit) \
76 ((uint32_t) (((uint32_t) 1) << (bit)))
78#define BSP_MSK32(first_bit, last_bit) \
79 ((uint32_t) ((BSP_BIT32((last_bit) - (first_bit) + 1) - 1) << (first_bit)))
81#define BSP_FLD32(val, first_bit, last_bit) \
83 ((((uint32_t) (val)) << (first_bit)) & BSP_MSK32(first_bit, last_bit)))
85#define BSP_FLD32GET(reg, first_bit, last_bit) \
86 ((uint32_t) (((reg) & BSP_MSK32(first_bit, last_bit)) >> (first_bit)))
88#define BSP_FLD32SET(reg, val, first_bit, last_bit) \
89 ((uint32_t) (((reg) & ~BSP_MSK32(first_bit, last_bit)) \
90 | BSP_FLD32(val, first_bit, last_bit)))
92#define BSP_BIT64(bit) \
93 ((uint64_t) (((uint64_t) 1) << (bit)))
95#define BSP_MSK64(first_bit, last_bit) \
96 ((uint64_t) ((BSP_BIT64((last_bit) - (first_bit) + 1) - 1) << (first_bit)))
98#define BSP_FLD64(val, first_bit, last_bit) \
100 ((((uint64_t) (val)) << (first_bit)) & BSP_MSK64(first_bit, last_bit)))
102#define BSP_FLD64GET(reg, first_bit, last_bit) \
103 ((uint64_t) (((reg) & BSP_MSK64(first_bit, last_bit)) >> (first_bit)))
105#define BSP_FLD64SET(reg, val, first_bit, last_bit) \
106 ((uint64_t) (((reg) & ~BSP_MSK64(first_bit, last_bit)) \
107 | BSP_FLD64(val, first_bit, last_bit)))
109#define BSP_BBIT8(bit) \
112#define BSP_BMSK8(first_bit, last_bit) \
113 BSP_MSK8(7 - (last_bit), 7 - (first_bit))
115#define BSP_BFLD8(val, first_bit, last_bit) \
116 BSP_FLD8(val, 7 - (last_bit), 7 - (first_bit))
118#define BSP_BFLD8GET(reg, first_bit, last_bit) \
119 BSP_FLD8GET(reg, 7 - (last_bit), 7 - (first_bit))
121#define BSP_BFLD8SET(reg, val, first_bit, last_bit) \
122 BSP_FLD8SET(reg, val, 7 - (last_bit), 7 - (first_bit))
124#define BSP_BBIT16(bit) \
125 BSP_BIT16(15 - (bit))
127#define BSP_BMSK16(first_bit, last_bit) \
128 BSP_MSK16(15 - (last_bit), 15 - (first_bit))
130#define BSP_BFLD16(val, first_bit, last_bit) \
131 BSP_FLD16(val, 15 - (last_bit), 15 - (first_bit))
133#define BSP_BFLD16GET(reg, first_bit, last_bit) \
134 BSP_FLD16GET(reg, 15 - (last_bit), 15 - (first_bit))
136#define BSP_BFLD16SET(reg, val, first_bit, last_bit) \
137 BSP_FLD16SET(reg, val, 15 - (last_bit), 15 - (first_bit))
139#define BSP_BBIT32(bit) \
140 BSP_BIT32(31 - (bit))
142#define BSP_BMSK32(first_bit, last_bit) \
143 BSP_MSK32(31 - (last_bit), 31 - (first_bit))
145#define BSP_BFLD32(val, first_bit, last_bit) \
146 BSP_FLD32(val, 31 - (last_bit), 31 - (first_bit))
148#define BSP_BFLD32GET(reg, first_bit, last_bit) \
149 BSP_FLD32GET(reg, 31 - (last_bit), 31 - (first_bit))
151#define BSP_BFLD32SET(reg, val, first_bit, last_bit) \
152 BSP_FLD32SET(reg, val, 31 - (last_bit), 31 - (first_bit))
154#define BSP_BBIT64(bit) \
155 BSP_BIT64(63 - (bit))
157#define BSP_BMSK64(first_bit, last_bit) \
158 BSP_MSK64(63 - (last_bit), 63 - (first_bit))
160#define BSP_BFLD64(val, first_bit, last_bit) \
161 BSP_FLD64(val, 63 - (last_bit), 63 - (first_bit))
163#define BSP_BFLD64GET(reg, first_bit, last_bit) \
164 BSP_FLD64GET(reg, 63 - (last_bit), 63 - (first_bit))
166#define BSP_BFLD64SET(reg, val, first_bit, last_bit) \
167 BSP_FLD64SET(reg, val, 63 - (last_bit), 63 - (first_bit))