4.104.115
Last change
on this file since 23f35aa was
23f35aa,
checked in by Sebastian Huber <sebastian.huber@…>, on 05/21/10 at 08:01:14
|
2010-05-21 Sebastian Huber <sebastian.huber@…>
- include/utility.h: Macros use now first and last bit values instead
of shift and length parameters.
|
-
Property mode set to
100644
|
File size:
1006 bytes
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup bsp_kit |
---|
5 | * |
---|
6 | * @brief Utility macros. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2008, 2010 |
---|
11 | * embedded brains GmbH |
---|
12 | * Obere Lagerstr. 30 |
---|
13 | * D-82178 Puchheim |
---|
14 | * Germany |
---|
15 | * <rtems@embedded-brains.de> |
---|
16 | * |
---|
17 | * The license and distribution terms for this file may be |
---|
18 | * found in the file LICENSE in this distribution or at |
---|
19 | * http://www.rtems.com/license/LICENSE. |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef LIBCPU_SHARED_UTILITY_H |
---|
23 | #define LIBCPU_SHARED_UTILITY_H |
---|
24 | |
---|
25 | #include <stdint.h> |
---|
26 | |
---|
27 | #define BIT32(bit) \ |
---|
28 | ((uint32_t) 1 << (bit)) |
---|
29 | |
---|
30 | #define MASK32(first_bit, last_bit) \ |
---|
31 | ((BIT32((last_bit) - (first_bit) + 1) - (uint32_t) 1) << (first_bit)) |
---|
32 | |
---|
33 | #define FIELD32(val, first_bit, last_bit) \ |
---|
34 | (((uint32_t) (val) << (first_bit)) & MASK32(first_bit, last_bit)) |
---|
35 | |
---|
36 | #define GETFIELD32(reg, first_bit, last_bit) \ |
---|
37 | (((reg) & MASK32(first_bit, last_bit)) >> (first_bit)) |
---|
38 | |
---|
39 | #define SETFIELD32(reg, val, first_bit, last_bit) \ |
---|
40 | (((reg) & ~MASK32(first_bit, last_bit)) | FIELD32(val, first_bit, last_bit)) |
---|
41 | |
---|
42 | #endif /* LIBCPU_SHARED_UTILITY_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.