OpenCores
URL https://opencores.org/ocsvn/ao486/ao486/trunk

Subversion Repositories ao486

[/] [ao486/] [trunk/] [syn/] [components/] [sd_card/] [software/] [exe_bsp/] [HAL/] [inc/] [nios2.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
#ifndef __NIOS2_H__
2
#define __NIOS2_H__
3
 
4
/******************************************************************************
5
*                                                                             *
6
* License Agreement                                                           *
7
*                                                                             *
8
* Copyright (c) 2008 Altera Corporation, San Jose, California, USA.           *
9
* All rights reserved.                                                        *
10
*                                                                             *
11
* Permission is hereby granted, free of charge, to any person obtaining a     *
12
* copy of this software and associated documentation files (the "Software"),  *
13
* to deal in the Software without restriction, including without limitation   *
14
* the rights to use, copy, modify, merge, publish, distribute, sublicense,    *
15
* and/or sell copies of the Software, and to permit persons to whom the       *
16
* Software is furnished to do so, subject to the following conditions:        *
17
*                                                                             *
18
* The above copyright notice and this permission notice shall be included in  *
19
* all copies or substantial portions of the Software.                         *
20
*                                                                             *
21
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  *
22
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,    *
23
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
24
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      *
25
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING     *
26
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER         *
27
* DEALINGS IN THE SOFTWARE.                                                   *
28
*                                                                             *
29
* This agreement shall be governed in all respects by the laws of the State   *
30
* of California and by the laws of the United States of America.              *
31
*                                                                             *
32
******************************************************************************/
33
 
34
/*
35
 * This header provides processor specific macros for accessing the Nios2
36
 * control registers.
37
 */
38
 
39
#ifdef __cplusplus
40
extern "C"
41
{
42
#endif /* __cplusplus */
43
 
44
/*
45
 * Macros for accessing selected processor registers
46
 */
47
 
48
#define NIOS2_READ_ET(et) \
49
    do { __asm ("mov %0, et" : "=r" (et) ); } while (0)
50
 
51
#define NIOS2_WRITE_ET(et) \
52
    do { __asm volatile ("mov et, %z0" : : "rM" (et)); } while (0)
53
 
54
#define NIOS2_READ_SP(sp) \
55
    do { __asm ("mov %0, sp" : "=r" (sp) ); } while (0)
56
 
57
/*
58
 * Macros for useful processor instructions
59
 */
60
 
61
#define NIOS2_BREAK() \
62
    do { __asm volatile ("break"); } while (0)
63
 
64
#define NIOS2_REPORT_STACK_OVERFLOW() \
65
    do { __asm volatile("break 3"); } while (0)
66
 
67
/*
68
 * Macros for accessing the control registers.
69
 */
70
 
71
#define NIOS2_READ_STATUS(dest) \
72
    do { dest = __builtin_rdctl(0); } while (0)
73
 
74
#define NIOS2_WRITE_STATUS(src) \
75
    do { __builtin_wrctl(0, src); } while (0)
76
 
77
#define NIOS2_READ_ESTATUS(dest) \
78
    do { dest = __builtin_rdctl(1); } while (0)
79
 
80
#define NIOS2_READ_BSTATUS(dest) \
81
    do { dest = __builtin_rdctl(2); } while (0)
82
 
83
#define NIOS2_READ_IENABLE(dest) \
84
    do { dest = __builtin_rdctl(3); } while (0)
85
 
86
#define NIOS2_WRITE_IENABLE(src) \
87
    do { __builtin_wrctl(3, src); } while (0)
88
 
89
#define NIOS2_READ_IPENDING(dest) \
90
    do { dest = __builtin_rdctl(4); } while (0)
91
 
92
#define NIOS2_READ_CPUID(dest) \
93
    do { dest = __builtin_rdctl(5); } while (0)
94
 
95
 
96
/*
97
 * Macros for accessing extra exception registers. These
98
 * are always enabled wit the MPU or MMU, and optionally
99
 * with other advanced exception types/
100
 */
101
#define NIOS2_READ_EXCEPTION(dest) \
102
    do { dest = __builtin_rdctl(7); } while (0)
103
 
104
#define NIOS2_READ_BADADDR(dest) \
105
    do { dest = __builtin_rdctl(12); } while (0)
106
 
107
 
108
/*
109
 * Macros for accessing control registers for MPU
110
 * operation. These should not be used unless the
111
 * MPU is enabled.
112
 *
113
 * The config register may be augmented for future
114
 * enhancements. For now, only MPU support is provided.
115
 */
116
/* Config register */
117
#define NIOS2_WRITE_CONFIG(src) \
118
    do { __builtin_wrctl(13, src); } while (0)
119
 
120
#define NIOS2_READ_CONFIG(dest) \
121
    do { dest = __builtin_rdctl(13); } while (0)
122
 
123
/* MPU Base Address Register */
124
#define NIOS2_WRITE_MPUBASE(src) \
125
    do { __builtin_wrctl(14, src); } while (0)
126
 
127
#define NIOS2_READ_MPUBASE(dest) \
128
    do { dest = __builtin_rdctl(14); } while (0)
129
 
130
/* MPU Access Register */
131
#define NIOS2_WRITE_MPUACC(src) \
132
    do { __builtin_wrctl(15, src); } while (0)
133
 
134
#define NIOS2_READ_MPUACC(dest) \
135
    do { dest = __builtin_rdctl(15); } while (0)
136
 
137
 
138
/*
139
 * Nios II control registers that are always present
140
 */
141
#define NIOS2_STATUS   status
142
#define NIOS2_ESTATUS  estatus
143
#define NIOS2_BSTATUS  bstatus
144
#define NIOS2_IENABLE  ienable
145
#define NIOS2_IPENDING ipending
146
#define NIOS2_CPUID cpuid
147
 
148
/*
149
 * STATUS, BSTATUS, ESTATUS, and SSTATUS fields.
150
 * The presence of fields is a function of the Nios II configuration.
151
 */
152
#define NIOS2_STATUS_PIE_MSK  (0x00000001)
153
#define NIOS2_STATUS_PIE_OFST (0)
154
#define NIOS2_STATUS_U_MSK    (0x00000002)
155
#define NIOS2_STATUS_U_OFST   (1)
156
#define NIOS2_STATUS_EH_MSK   (0x00000004)
157
#define NIOS2_STATUS_EH_OFST  (2)
158
#define NIOS2_STATUS_IH_MSK     (0x00000008)
159
#define NIOS2_STATUS_IH_OFST    (3)
160
#define NIOS2_STATUS_IL_MSK     (0x000003f0)
161
#define NIOS2_STATUS_IL_OFST    (4)
162
#define NIOS2_STATUS_CRS_MSK    (0x0000fc00)
163
#define NIOS2_STATUS_CRS_OFST   (10)
164
#define NIOS2_STATUS_PRS_MSK    (0x003f0000)
165
#define NIOS2_STATUS_PRS_OFST   (16)
166
#define NIOS2_STATUS_NMI_MSK    (0x00400000)
167
#define NIOS2_STATUS_NMI_OFST   (22)
168
#define NIOS2_STATUS_RSIE_MSK   (0x00800000)
169
#define NIOS2_STATUS_RSIE_OFST  (23)
170
#define NIOS2_STATUS_SRS_MSK    (0x80000000)
171
#define NIOS2_STATUS_SRS_OFST   (31)
172
 
173
/*
174
 * Bit masks & offsets available with extra exceptions support
175
 */
176
 
177
/* Exception register */
178
#define NIOS2_EXCEPTION_REG_CAUSE_MASK (0x0000007c)
179
#define NIOS2_EXCEPTION_REG_CAUSE_OFST (2)
180
 
181
/*
182
 * Bit masks & offsets for MPU support
183
 *
184
 * All bit-masks are expressed relative to the position
185
 * of the data with a register. To read data that is LSB-
186
 * aligned, the register read data should be masked, then
187
 * right-shifted by the designated "OFST" macro value. The
188
 * opposite should be used for register writes when starting
189
 * with LSB-aligned data.
190
 */
191
 
192
/* Config register */
193
#define NIOS2_CONFIG_REG_PE_MASK (0x00000001)
194
#define NIOS2_CONFIG_REG_PE_OFST (0)
195
#define NIOS2_CONFIG_REG_ANI_MASK (0x00000002)
196
#define NIOS2_CONFIG_REG_ANI_OFST (1)
197
 
198
/* MPU Base Address Register */
199
#define NIOS2_MPUBASE_D_MASK         (0x00000001)
200
#define NIOS2_MPUBASE_D_OFST         (0)
201
#define NIOS2_MPUBASE_INDEX_MASK     (0x0000003e)
202
#define NIOS2_MPUBASE_INDEX_OFST     (1)
203
#define NIOS2_MPUBASE_BASE_ADDR_MASK (0xffffffc0)
204
#define NIOS2_MPUBASE_BASE_ADDR_OFST (6)
205
 
206
/* MPU Access Register */
207
#define NIOS2_MPUACC_LIMIT_MASK (0xffffffc0)
208
#define NIOS2_MPUACC_LIMIT_OFST (6)
209
#define NIOS2_MPUACC_MASK_MASK  (0xffffffc0)
210
#define NIOS2_MPUACC_MASK_OFST  (6)
211
#define NIOS2_MPUACC_C_MASK     (0x00000020)
212
#define NIOS2_MPUACC_C_OFST     (5)
213
#define NIOS2_MPUACC_PERM_MASK  (0x0000001c)
214
#define NIOS2_MPUACC_PERM_OFST  (2)
215
#define NIOS2_MPUACC_RD_MASK    (0x00000002)
216
#define NIOS2_MPUACC_RD_OFST    (1)
217
#define NIOS2_MPUACC_WR_MASK    (0x00000001)
218
#define NIOS2_MPUACC_WR_OFST    (0)
219
 
220
/*
221
 * Number of available IRQs in internal interrupt controller.
222
 */
223
#define NIOS2_NIRQ 32
224
 
225
 
226
#ifdef __cplusplus
227
}
228
#endif /* __cplusplus */
229
 
230
#endif /* __NIOS2_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.