source: rtems/bsps/arm/altera-cyclone-v/include/bsp/socal/socal.h @ 9d41fca

5
Last change on this file since 9d41fca was 9d41fca, checked in by Sebastian Huber <sebastian.huber@…>, on 02/27/19 at 10:39:29

bsp/altera-cyclone-v: Adjust Doxygen file groups

Update #3707.

  • Property mode set to 100644
File size: 10.7 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup RTEMSBSPsARMCycVContrib
5 */
6
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
38/*! \file Altera - ALT_SOCAL */
39
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
60/*!
61 * \addtogroup ALT_SOCAL_UTIL SoCAL Utilities
62 *
63 * This file contains utility and support functions for the Altera SoCAL.
64 * @{
65 */
66
67#ifdef __ASSEMBLY__
68#define ALT_CAST(type, ptr)  ptr
69#else   /* __ASSEMBLY__ */
70/*! Cast the pointer to specified pointer type.
71 *
72 *  Note: This macro expands to \e ptr value only for assembler language
73 *        targets.
74 *
75 *  \param type     The pointer type to cast to
76 *  \param ptr      The pointer to apply the type cast to
77 */
78#define ALT_CAST(type, ptr)  ((type) (ptr))
79#endif  /* __ASSEMBLY__ */
80
81/*!
82 * \addtogroup ALT_SOCAL_UTIL_RW_FUNC SoCAL Memory Read/Write Utilities
83 *
84 * This section implements read and write functionality for various
85 * memory untis. The memory unit terms used for these functions are
86 * consistent with those used in the ARM Architecture Reference Manual
87 * ARMv7-A and ARMv7-R edition manual. The terms used for units of memory are:
88 *
89 *  Unit of Memory | Abbreviation | Size in Bits
90 * :---------------|:-------------|:------------:
91 *  Byte           | byte         |       8
92 *  Half Word      | hword        |      16
93 *  Word           | word         |      32
94 *  Double Word    | dword        |      64
95 *
96 * @{
97 */
98
99/*! Write the 8 bit byte to the destination address in device memory.
100 *  \param dest - Write destination pointer address
101 *  \param src  - 8 bit data byte to write to memory
102 */
103#define alt_write_byte(dest, src)       (*ALT_CAST(volatile uint8_t *, (dest)) = (src))
104
105/*! Read and return the 8 bit byte from the source address in device memory.
106 *  \param src    Read source pointer address
107 *  \returns      8 bit data byte value
108 */
109#define alt_read_byte(src)              (*ALT_CAST(volatile uint8_t *, (src)))
110
111/*! Write the 16 bit half word to the destination address in device memory.
112 *  \param dest - Write destination pointer address
113 *  \param src  - 16 bit data half word to write to memory
114 */
115#define alt_write_hword(dest, src)      (*ALT_CAST(volatile uint16_t *, (dest)) = (src))
116
117/*! Read and return the 16 bit half word from the source address in device memory.
118 *  \param src    Read source pointer address
119 *  \returns      16 bit data half word value
120 */
121#define alt_read_hword(src)             (*ALT_CAST(volatile uint16_t *, (src)))
122
123/*! Write the 32 bit word to the destination address in device memory.
124 *  \param dest - Write destination pointer address
125 *  \param src  - 32 bit data word to write to memory
126 */
127#define alt_write_word(dest, src)       (*ALT_CAST(volatile uint32_t *, (dest)) = (src))
128
129/*! Read and return the 32 bit word from the source address in device memory.
130 *  \param src    Read source pointer address
131 *  \returns      32 bit data word value
132 */
133#define alt_read_word(src)              (*ALT_CAST(volatile uint32_t *, (src)))
134
135/*! Write the 64 bit double word to the destination address in device memory.
136 *  \param dest - Write destination pointer address
137 *  \param src  - 64 bit data double word to write to memory
138 */
139#define alt_write_dword(dest, src)      (*ALT_CAST(volatile uint64_t *, (dest)) = (src))
140
141/*! Read and return the 64 bit double word from the source address in device memory.
142 *  \param src    Read source pointer address
143 *  \returns      64 bit data double word value
144 */
145#define alt_read_dword(src)             (*ALT_CAST(volatile uint64_t *, (src)))
146
147/*! @} */
148
149/*!
150 * \addtogroup ALT_SOCAL_UTIL_SC_FUNC SoCAL Memory Bit Set/Clr/XOR/Replace Utilities
151 *
152 * This section implements useful macros to set, clear, change, and replace
153 * selected bits within a word in memory or a memory-mapped register.
154 * @{
155 *
156 */
157
158/*! Set selected bits in the 8 bit byte at the destination address in device memory.
159 *  \param dest - Destination pointer address
160 *  \param bits - Bits to set in destination byte
161 */
162#define     alt_setbits_byte(dest, bits)        (alt_write_byte(dest, alt_read_byte(dest) | (bits)))
163
164/*! Clear selected bits in the 8 bit byte at the destination address in device memory.
165 *  \param dest - Destination pointer address
166 *  \param bits - Bits to clear in destination byte
167 */
168#define     alt_clrbits_byte(dest, bits)        (alt_write_byte(dest, alt_read_byte(dest) & ~(bits)))
169
170/*! Change or toggle selected bits in the 8 bit byte at the destination address in device memory.
171 *  \param dest - Destination pointer address
172 *  \param bits - Bits to change in destination byte
173 */
174#define     alt_xorbits_byte(dest, bits)        (alt_write_byte(dest, alt_read_byte(dest) ^ (bits)))
175
176/*! Replace selected bits in the 8 bit byte at the destination address in device memory.
177 *  \param  dest - Destination pointer address
178 *  \param  msk  - Bits to replace in destination byte
179 *  \param  src  - Source bits to write to cleared bits in destination byte
180 */
181#define     alt_replbits_byte(dest, msk, src)   (alt_write_byte(dest,(alt_read_byte(dest) & ~(msk)) | ((src) & (msk))))
182
183/*! Set selected bits in the 16 bit halfword at the destination address in device memory.
184 *  \param dest - Destination pointer address
185 *  \param bits - Bits to set in destination halfword
186 */
187#define     alt_setbits_hword(dest, bits)       (alt_write_hword(dest, alt_read_hword(dest) | (bits)))
188
189/*! Clear selected bits in the 16 bit halfword at the destination address in device memory.
190 *  \param dest - Destination pointer address
191 *  \param bits - Bits to clear in destination halfword
192 */
193#define     alt_clrbits_hword(dest, bits)       (alt_write_hword(dest, alt_read_hword(dest) & ~(bits)))
194
195/*! Change or toggle selected bits in the 16 bit halfword at the destination address in device memory.
196 *  \param dest - Destination pointer address
197 *  \param bits - Bits to change in destination halfword
198 */
199#define     alt_xorbits_hword(dest, bits)       (alt_write_hword(dest, alt_read_hword(dest) ^ (bits)))
200
201/*! Replace selected bits in the 16 bit halfword at the destination address in device memory.
202 *  \param  dest - Destination pointer address
203 *  \param  msk  - Bits to replace in destination halfword
204 *  \param  src  - Source bits to write to cleared bits in destination halfword
205 */
206#define     alt_replbits_hword(dest, msk, src)   (alt_write_hword(dest,(alt_read_hword(dest) & ~(msk)) | ((src) & (msk))))
207
208/*! Set selected bits in the 32 bit word at the destination address in device memory.
209 *  \param dest - Destination pointer address
210 *  \param bits - Bits to set in destination word
211 */
212#define     alt_setbits_word(dest, bits)        (alt_write_word(dest, alt_read_word(dest) | (bits)))
213
214/*! Clear selected bits in the 32 bit word at the destination address in device memory.
215 *  \param dest - Destination pointer address
216 *  \param bits - Bits to clear in destination word
217 */
218#define     alt_clrbits_word(dest, bits)        (alt_write_word(dest, alt_read_word(dest) & ~(bits)))
219
220/*! Change or toggle selected bits in the 32 bit word at the destination address in device memory.
221 *  \param dest - Destination pointer address
222 *  \param bits - Bits to change in destination word
223 */
224#define     alt_xorbits_word(dest, bits)        (alt_write_word(dest, alt_read_word(dest) ^ (bits)))
225
226/*! Replace selected bits in the 32 bit word at the destination address in device memory.
227 *  \param  dest - Destination pointer address
228 *  \param  msk  - Bits to replace in destination word
229 *  \param  src  - Source bits to write to cleared bits in destination word
230 */
231#define     alt_replbits_word(dest, msk, src)   (alt_write_word(dest,(alt_read_word(dest) & ~(msk)) | ((src) & (msk))))
232
233/*! Set selected bits in the 64 bit doubleword at the destination address in device memory.
234 *  \param dest - Destination pointer address
235 *  \param bits - Bits to set in destination doubleword
236 */
237#define     alt_setbits_dword(dest, bits)       (alt_write_dword(dest, alt_read_dword(dest) | (bits)))
238
239/*! Clear selected bits in the 64 bit doubleword at the destination address in device memory.
240 *  \param dest - Destination pointer address
241 *  \param bits - Bits to clear in destination doubleword
242 */
243#define     alt_clrbits_dword(dest, bits)       (alt_write_dword(dest, alt_read_dword(dest) & ~(bits)))
244
245/*! Change or toggle selected bits in the 64 bit doubleword at the destination address in device memory.
246 *  \param dest - Destination pointer address
247 *  \param bits - Bits to change in destination doubleword
248 */
249#define     alt_xorbits_dword(dest, bits)       (alt_write_dword(dest, alt_read_dword(dest) ^ (bits)))
250
251/*! Replace selected bits in the 64 bit doubleword at the destination address in device memory.
252 *  \param  dest - Destination pointer address
253 *  \param  msk  - Bits to replace in destination doubleword
254 *  \param  src  - Source bits to write to cleared bits in destination word
255 */
256#define     alt_replbits_dword(dest, msk, src)   (alt_write_dword(dest,(alt_read_dword(dest) & ~(msk)) | ((src) & (msk))))
257
258/*! @} */
259
260/*! @} */
261
262#ifdef __cplusplus
263}
264#endif  /* __cplusplus */
265#endif  /* __ALTERA_SOCAL_H__ */
Note: See TracBrowser for help on using the repository browser.