Altera SoCAL  16.0
The Altera SoC Abstraction Layer (SoCAL) API Reference Manual
 All Data Structures Variables Typedefs Groups
socal.h
1 /******************************************************************************
2 *
3 * Copyright 2013 Altera Corporation. All Rights Reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors
16 * may be used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 ******************************************************************************/
32 
33 /*
34  * $Id: //depot/embedded/rel/15.0/ip/hps/altera_hps/hwlib/src/socal/socal.h#1 $
35  */
36 
39 #ifndef __ALTERA_SOCAL_H__
40 #define __ALTERA_SOCAL_H__
41 
42 #ifndef __ASSEMBLY__
43 #ifdef __cplusplus
44 #include <cstddef>
45 #include <cstdbool>
46 #include <cstdint>
47 #else /* __cplusplus */
48 #include <stddef.h>
49 #include <stdbool.h>
50 #include <stdint.h>
51 #endif /* __cplusplus */
52 #endif /* __ASSEMBLY__ */
53 
54 #ifdef __cplusplus
55 extern "C"
56 {
57 #endif /* __cplusplus */
58 
66 #ifdef __ASSEMBLY__
67 #define ALT_CAST(type, ptr) ptr
68 #else /* __ASSEMBLY__ */
69 
77 #define ALT_CAST(type, ptr) ((type) (ptr))
78 #endif /* __ASSEMBLY__ */
79 
102 #define alt_write_byte(dest, src) (*ALT_CAST(volatile uint8_t *, (dest)) = (src))
103 
108 #define alt_read_byte(src) (*ALT_CAST(volatile uint8_t *, (src)))
109 
114 #define alt_write_hword(dest, src) (*ALT_CAST(volatile uint16_t *, (dest)) = (src))
115 
120 #define alt_read_hword(src) (*ALT_CAST(volatile uint16_t *, (src)))
121 
126 #define alt_write_word(dest, src) (*ALT_CAST(volatile uint32_t *, (dest)) = (src))
127 
132 #define alt_read_word(src) (*ALT_CAST(volatile uint32_t *, (src)))
133 
138 #define alt_write_dword(dest, src) (*ALT_CAST(volatile uint64_t *, (dest)) = (src))
139 
144 #define alt_read_dword(src) (*ALT_CAST(volatile uint64_t *, (src)))
145 
161 #define alt_setbits_byte(dest, bits) (alt_write_byte(dest, alt_read_byte(dest) | (bits)))
162 
167 #define alt_clrbits_byte(dest, bits) (alt_write_byte(dest, alt_read_byte(dest) & ~(bits)))
168 
173 #define alt_xorbits_byte(dest, bits) (alt_write_byte(dest, alt_read_byte(dest) ^ (bits)))
174 
180 #define alt_replbits_byte(dest, msk, src) (alt_write_byte(dest,(alt_read_byte(dest) & ~(msk)) | ((src) & (msk))))
181 
186 #define alt_setbits_hword(dest, bits) (alt_write_hword(dest, alt_read_hword(dest) | (bits)))
187 
192 #define alt_clrbits_hword(dest, bits) (alt_write_hword(dest, alt_read_hword(dest) & ~(bits)))
193 
198 #define alt_xorbits_hword(dest, bits) (alt_write_hword(dest, alt_read_hword(dest) ^ (bits)))
199 
205 #define alt_replbits_hword(dest, msk, src) (alt_write_hword(dest,(alt_read_hword(dest) & ~(msk)) | ((src) & (msk))))
206 
211 #define alt_setbits_word(dest, bits) (alt_write_word(dest, alt_read_word(dest) | (bits)))
212 
217 #define alt_clrbits_word(dest, bits) (alt_write_word(dest, alt_read_word(dest) & ~(bits)))
218 
223 #define alt_xorbits_word(dest, bits) (alt_write_word(dest, alt_read_word(dest) ^ (bits)))
224 
230 #define alt_replbits_word(dest, msk, src) (alt_write_word(dest,(alt_read_word(dest) & ~(msk)) | ((src) & (msk))))
231 
236 #define alt_setbits_dword(dest, bits) (alt_write_dword(dest, alt_read_dword(dest) | (bits)))
237 
242 #define alt_clrbits_dword(dest, bits) (alt_write_dword(dest, alt_read_dword(dest) & ~(bits)))
243 
248 #define alt_xorbits_dword(dest, bits) (alt_write_dword(dest, alt_read_dword(dest) ^ (bits)))
249 
255 #define alt_replbits_dword(dest, msk, src) (alt_write_dword(dest,(alt_read_dword(dest) & ~(msk)) | ((src) & (msk))))
256 
261 #ifdef __cplusplus
262 }
263 #endif /* __cplusplus */
264 #endif /* __ALTERA_SOCAL_H__ */