RTEMS 6.1-rc5
Loading...
Searching...
No Matches
socal.h
Go to the documentation of this file.
1
7/******************************************************************************
8 *
9 * Copyright 2013 Altera Corporation. All Rights Reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3. The name of the author may not be used to endorse or promote products
22 * derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO
27 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
29 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
33 * OF SUCH DAMAGE.
34 *
35 ******************************************************************************/
36
37
40#ifndef __ALTERA_SOCAL_H__
41#define __ALTERA_SOCAL_H__
42
43#ifndef __ASSEMBLY__
44#ifdef __cplusplus
45#include <cstddef>
46#include <cstdbool>
47#include <cstdint>
48#else /* __cplusplus */
49#include <stddef.h>
50#include <stdbool.h>
51#include <stdint.h>
52#endif /* __cplusplus */
53#endif /* __ASSEMBLY__ */
54
55#ifdef __cplusplus
56extern "C"
57{
58#endif /* __cplusplus */
59
67#ifdef __ASSEMBLY__
68#define ALT_CAST(type, ptr) ptr
69#else /* __ASSEMBLY__ */
78#define ALT_CAST(type, ptr) ((type) (ptr))
79#endif /* __ASSEMBLY__ */
80
103#define alt_write_byte(dest, src) (*ALT_CAST(volatile uint8_t *, (dest)) = (src))
104
109#define alt_read_byte(src) (*ALT_CAST(volatile uint8_t *, (src)))
110
115#define alt_write_hword(dest, src) (*ALT_CAST(volatile uint16_t *, (dest)) = (src))
116
121#define alt_read_hword(src) (*ALT_CAST(volatile uint16_t *, (src)))
122
127#define alt_write_word(dest, src) (*ALT_CAST(volatile uint32_t *, (dest)) = (src))
128
133#define alt_read_word(src) (*ALT_CAST(volatile uint32_t *, (src)))
134
139#define alt_write_dword(dest, src) (*ALT_CAST(volatile uint64_t *, (dest)) = (src))
140
145#define alt_read_dword(src) (*ALT_CAST(volatile uint64_t *, (src)))
146
162#define alt_setbits_byte(dest, bits) (alt_write_byte(dest, alt_read_byte(dest) | (bits)))
163
168#define alt_clrbits_byte(dest, bits) (alt_write_byte(dest, alt_read_byte(dest) & ~(bits)))
169
174#define alt_xorbits_byte(dest, bits) (alt_write_byte(dest, alt_read_byte(dest) ^ (bits)))
175
181#define alt_replbits_byte(dest, msk, src) (alt_write_byte(dest,(alt_read_byte(dest) & ~(msk)) | ((src) & (msk))))
182
187#define alt_setbits_hword(dest, bits) (alt_write_hword(dest, alt_read_hword(dest) | (bits)))
188
193#define alt_clrbits_hword(dest, bits) (alt_write_hword(dest, alt_read_hword(dest) & ~(bits)))
194
199#define alt_xorbits_hword(dest, bits) (alt_write_hword(dest, alt_read_hword(dest) ^ (bits)))
200
206#define alt_replbits_hword(dest, msk, src) (alt_write_hword(dest,(alt_read_hword(dest) & ~(msk)) | ((src) & (msk))))
207
212#define alt_setbits_word(dest, bits) (alt_write_word(dest, alt_read_word(dest) | (bits)))
213
218#define alt_clrbits_word(dest, bits) (alt_write_word(dest, alt_read_word(dest) & ~(bits)))
219
224#define alt_xorbits_word(dest, bits) (alt_write_word(dest, alt_read_word(dest) ^ (bits)))
225
231#define alt_replbits_word(dest, msk, src) (alt_write_word(dest,(alt_read_word(dest) & ~(msk)) | ((src) & (msk))))
232
237#define alt_setbits_dword(dest, bits) (alt_write_dword(dest, alt_read_dword(dest) | (bits)))
238
243#define alt_clrbits_dword(dest, bits) (alt_write_dword(dest, alt_read_dword(dest) & ~(bits)))
244
249#define alt_xorbits_dword(dest, bits) (alt_write_dword(dest, alt_read_dword(dest) ^ (bits)))
250
256#define alt_replbits_dword(dest, msk, src) (alt_write_dword(dest,(alt_read_dword(dest) & ~(msk)) | ((src) & (msk))))
257
262#ifdef __cplusplus
263}
264#endif /* __cplusplus */
265#endif /* __ALTERA_SOCAL_H__ */