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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [syn/] [components/] [sd_card/] [firmware/] [bsp/] [HAL/] [inc/] [nios2.h] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 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
 * Number of available IRQs in internal interrupt controller.
46
 */
47
#define NIOS2_NIRQ 32
48
 
49
/*
50
 * Macros for accessing select Nios II general-purpose registers.
51
 */
52
 
53
/* ET (Exception Temporary) register */
54
#define NIOS2_READ_ET(et) \
55
    do { __asm ("mov %0, et" : "=r" (et) ); } while (0)
56
 
57
#define NIOS2_WRITE_ET(et) \
58
    do { __asm volatile ("mov et, %z0" : : "rM" (et)); } while (0)
59
 
60
/* SP (Stack Pointer) register */
61
#define NIOS2_READ_SP(sp) \
62
    do { __asm ("mov %0, sp" : "=r" (sp) ); } while (0)
63
 
64
/*
65
 * Macros for useful processor instructions.
66
 */
67
#define NIOS2_BREAK() \
68
    do { __asm volatile ("break"); } while (0)
69
 
70
#define NIOS2_REPORT_STACK_OVERFLOW() \
71
    do { __asm volatile("break 3"); } while (0)
72
 
73
/*
74
 * Macros for accessing Nios II control registers.
75
 */
76
#define NIOS2_READ_STATUS(dest) \
77
    do { dest = __builtin_rdctl(0); } while (0)
78
 
79
#define NIOS2_WRITE_STATUS(src) \
80
    do { __builtin_wrctl(0, src); } while (0)
81
 
82
#define NIOS2_READ_ESTATUS(dest) \
83
    do { dest = __builtin_rdctl(1); } while (0)
84
 
85
#define NIOS2_READ_BSTATUS(dest) \
86
    do { dest = __builtin_rdctl(2); } while (0)
87
 
88
#define NIOS2_READ_IENABLE(dest) \
89
    do { dest = __builtin_rdctl(3); } while (0)
90
 
91
#define NIOS2_WRITE_IENABLE(src) \
92
    do { __builtin_wrctl(3, src); } while (0)
93
 
94
#define NIOS2_READ_IPENDING(dest) \
95
    do { dest = __builtin_rdctl(4); } while (0)
96
 
97
#define NIOS2_READ_CPUID(dest) \
98
    do { dest = __builtin_rdctl(5); } while (0)
99
 
100
#define NIOS2_READ_EXCEPTION(dest) \
101
    do { dest = __builtin_rdctl(7); } while (0)
102
 
103
#define NIOS2_READ_PTEADDR(dest) \
104
    do { dest = __builtin_rdctl(8); } while (0)
105
 
106
#define NIOS2_WRITE_PTEADDR(src) \
107
    do { __builtin_wrctl(8, src); } while (0)
108
 
109
#define NIOS2_READ_TLBACC(dest) \
110
    do { dest = __builtin_rdctl(9); } while (0)
111
 
112
#define NIOS2_WRITE_TLBACC(src) \
113
    do { __builtin_wrctl(9, src); } while (0)
114
 
115
#define NIOS2_READ_TLBMISC(dest) \
116
    do { dest = __builtin_rdctl(10); } while (0)
117
 
118
#define NIOS2_WRITE_TLBMISC(src) \
119
    do { __builtin_wrctl(10, src); } while (0)
120
 
121
#define NIOS2_READ_ECCINJ(dest) \
122
    do { dest = __builtin_rdctl(11); } while (0)
123
 
124
#define NIOS2_WRITE_ECCINJ(src) \
125
    do { __builtin_wrctl(11, src); } while (0)
126
 
127
#define NIOS2_READ_BADADDR(dest) \
128
    do { dest = __builtin_rdctl(12); } while (0)
129
 
130
#define NIOS2_WRITE_CONFIG(src) \
131
    do { __builtin_wrctl(13, src); } while (0)
132
 
133
#define NIOS2_READ_CONFIG(dest) \
134
    do { dest = __builtin_rdctl(13); } while (0)
135
 
136
#define NIOS2_WRITE_MPUBASE(src) \
137
    do { __builtin_wrctl(14, src); } while (0)
138
 
139
#define NIOS2_READ_MPUBASE(dest) \
140
    do { dest = __builtin_rdctl(14); } while (0)
141
 
142
#define NIOS2_WRITE_MPUACC(src) \
143
    do { __builtin_wrctl(15, src); } while (0)
144
 
145
#define NIOS2_READ_MPUACC(dest) \
146
    do { dest = __builtin_rdctl(15); } while (0)
147
 
148
/*
149
 * Nios II control registers that are always present
150
 */
151
#define NIOS2_STATUS   status
152
#define NIOS2_ESTATUS  estatus
153
#define NIOS2_BSTATUS  bstatus
154
#define NIOS2_IENABLE  ienable
155
#define NIOS2_IPENDING ipending
156
#define NIOS2_CPUID cpuid
157
 
158
/*
159
 * Bit masks & offsets for Nios II control registers.
160
 * The presence and size of a field is sometimes dependent on the Nios II
161
 * configuration.  Bit masks for every possible field and the maximum size of
162
 * that field are defined.
163
 *
164
 * All bit-masks are expressed relative to the position
165
 * of the data with a register. To read data that is LSB-
166
 * aligned, the register read data should be masked, then
167
 * right-shifted by the designated "OFST" macro value. The
168
 * opposite should be used for register writes when starting
169
 * with LSB-aligned data.
170
 */
171
 
172
/* STATUS, ESTATUS, BSTATUS, and SSTATUS registers */
173
#define NIOS2_STATUS_PIE_MSK  (0x00000001)
174
#define NIOS2_STATUS_PIE_OFST (0)
175
#define NIOS2_STATUS_U_MSK    (0x00000002)
176
#define NIOS2_STATUS_U_OFST   (1)
177
#define NIOS2_STATUS_EH_MSK   (0x00000004)
178
#define NIOS2_STATUS_EH_OFST  (2)
179
#define NIOS2_STATUS_IH_MSK     (0x00000008)
180
#define NIOS2_STATUS_IH_OFST    (3)
181
#define NIOS2_STATUS_IL_MSK     (0x000003f0)
182
#define NIOS2_STATUS_IL_OFST    (4)
183
#define NIOS2_STATUS_CRS_MSK    (0x0000fc00)
184
#define NIOS2_STATUS_CRS_OFST   (10)
185
#define NIOS2_STATUS_PRS_MSK    (0x003f0000)
186
#define NIOS2_STATUS_PRS_OFST   (16)
187
#define NIOS2_STATUS_NMI_MSK    (0x00400000)
188
#define NIOS2_STATUS_NMI_OFST   (22)
189
#define NIOS2_STATUS_RSIE_MSK   (0x00800000)
190
#define NIOS2_STATUS_RSIE_OFST  (23)
191
#define NIOS2_STATUS_SRS_MSK    (0x80000000)
192
#define NIOS2_STATUS_SRS_OFST   (31)
193
 
194
/* EXCEPTION register */
195
#define NIOS2_EXCEPTION_REG_CAUSE_MASK (0x0000007c)
196
#define NIOS2_EXCEPTION_REG_CAUSE_OFST (2)
197
#define NIOS2_EXCEPTION_REG_ECCFTL_MASK (0x80000000)
198
#define NIOS2_EXCEPTION_REG_ECCFTL_OFST (31)
199
 
200
/* PTEADDR (Page Table Entry Address) register */
201
#define NIOS2_PTEADDR_REG_VPN_OFST 2
202
#define NIOS2_PTEADDR_REG_VPN_MASK 0x3ffffc
203
#define NIOS2_PTEADDR_REG_PTBASE_OFST 22
204
#define NIOS2_PTEADDR_REG_PTBASE_MASK 0xffc00000
205
 
206
/* TLBACC (TLB Access) register */
207
#define NIOS2_TLBACC_REG_PFN_OFST 0
208
#define NIOS2_TLBACC_REG_PFN_MASK 0xfffff
209
#define NIOS2_TLBACC_REG_G_OFST 20
210
#define NIOS2_TLBACC_REG_G_MASK 0x100000
211
#define NIOS2_TLBACC_REG_X_OFST 21
212
#define NIOS2_TLBACC_REG_X_MASK 0x200000
213
#define NIOS2_TLBACC_REG_W_OFST 22
214
#define NIOS2_TLBACC_REG_W_MASK 0x400000
215
#define NIOS2_TLBACC_REG_R_OFST 23
216
#define NIOS2_TLBACC_REG_R_MASK 0x800000
217
#define NIOS2_TLBACC_REG_C_OFST 24
218
#define NIOS2_TLBACC_REG_C_MASK 0x1000000
219
#define NIOS2_TLBACC_REG_IG_OFST 25
220
#define NIOS2_TLBACC_REG_IG_MASK 0xfe000000
221
 
222
/* TLBMISC (TLB Miscellaneous) register */
223
#define NIOS2_TLBMISC_REG_D_OFST 0
224
#define NIOS2_TLBMISC_REG_D_MASK 0x1
225
#define NIOS2_TLBMISC_REG_PERM_OFST 1
226
#define NIOS2_TLBMISC_REG_PERM_MASK 0x2
227
#define NIOS2_TLBMISC_REG_BAD_OFST 2
228
#define NIOS2_TLBMISC_REG_BAD_MASK 0x4
229
#define NIOS2_TLBMISC_REG_DBL_OFST 3
230
#define NIOS2_TLBMISC_REG_DBL_MASK 0x8
231
#define NIOS2_TLBMISC_REG_PID_OFST 4
232
#define NIOS2_TLBMISC_REG_PID_MASK 0x3fff0
233
#define NIOS2_TLBMISC_REG_WE_OFST 18
234
#define NIOS2_TLBMISC_REG_WE_MASK 0x40000
235
#define NIOS2_TLBMISC_REG_RD_OFST 19
236
#define NIOS2_TLBMISC_REG_RD_MASK 0x80000
237
#define NIOS2_TLBMISC_REG_WAY_OFST 20
238
#define NIOS2_TLBMISC_REG_WAY_MASK 0xf00000
239
#define NIOS2_TLBMISC_REG_EE_OFST 24
240
#define NIOS2_TLBMISC_REG_EE_MASK 0x1000000
241
 
242
/* ECCINJ (ECC Inject) register */
243
#define NIOS2_ECCINJ_REG_RF_OFST 0
244
#define NIOS2_ECCINJ_REG_RF_MASK 0x3
245
#define NIOS2_ECCINJ_REG_ICTAG_OFST 2
246
#define NIOS2_ECCINJ_REG_ICTAG_MASK 0xc
247
#define NIOS2_ECCINJ_REG_ICDAT_OFST 4
248
#define NIOS2_ECCINJ_REG_ICDAT_MASK 0x30
249
#define NIOS2_ECCINJ_REG_DCTAG_OFST 6
250
#define NIOS2_ECCINJ_REG_DCTAG_MASK 0xc0
251
#define NIOS2_ECCINJ_REG_DCDAT_OFST 8
252
#define NIOS2_ECCINJ_REG_DCDAT_MASK 0x300
253
#define NIOS2_ECCINJ_REG_TLB_OFST 10
254
#define NIOS2_ECCINJ_REG_TLB_MASK 0xc00
255
#define NIOS2_ECCINJ_REG_DTCM0_OFST 12
256
#define NIOS2_ECCINJ_REG_DTCM0_MASK 0x3000
257
#define NIOS2_ECCINJ_REG_DTCM1_OFST 14
258
#define NIOS2_ECCINJ_REG_DTCM1_MASK 0xc000
259
#define NIOS2_ECCINJ_REG_DTCM2_OFST 16
260
#define NIOS2_ECCINJ_REG_DTCM2_MASK 0x30000
261
#define NIOS2_ECCINJ_REG_DTCM3_OFST 18
262
#define NIOS2_ECCINJ_REG_DTCM3_MASK 0xc0000
263
 
264
/* CONFIG register */
265
#define NIOS2_CONFIG_REG_PE_MASK (0x00000001)
266
#define NIOS2_CONFIG_REG_PE_OFST (0)
267
#define NIOS2_CONFIG_REG_ANI_MASK (0x00000002)
268
#define NIOS2_CONFIG_REG_ANI_OFST (1)
269
#define NIOS2_CONFIG_REG_ECCEN_MASK (0x00000004)
270
#define NIOS2_CONFIG_REG_ECCEN_OFST (2)
271
#define NIOS2_CONFIG_REG_ECCEXC_MASK (0x00000008)
272
#define NIOS2_CONFIG_REG_ECCEXC_OFST (3)
273
 
274
/* MPUBASE (MPU Base Address) Register */
275
#define NIOS2_MPUBASE_D_MASK         (0x00000001)
276
#define NIOS2_MPUBASE_D_OFST         (0)
277
#define NIOS2_MPUBASE_INDEX_MASK     (0x0000003e)
278
#define NIOS2_MPUBASE_INDEX_OFST     (1)
279
#define NIOS2_MPUBASE_BASE_ADDR_MASK (0xffffffc0)
280
#define NIOS2_MPUBASE_BASE_ADDR_OFST (6)
281
 
282
/* MPUACC (MPU Access) Register */
283
#define NIOS2_MPUACC_LIMIT_MASK (0xffffffc0)
284
#define NIOS2_MPUACC_LIMIT_OFST (6)
285
#define NIOS2_MPUACC_MASK_MASK  (0xffffffc0)
286
#define NIOS2_MPUACC_MASK_OFST  (6)
287
#define NIOS2_MPUACC_C_MASK     (0x00000020)
288
#define NIOS2_MPUACC_C_OFST     (5)
289
#define NIOS2_MPUACC_PERM_MASK  (0x0000001c)
290
#define NIOS2_MPUACC_PERM_OFST  (2)
291
#define NIOS2_MPUACC_RD_MASK    (0x00000002)
292
#define NIOS2_MPUACC_RD_OFST    (1)
293
#define NIOS2_MPUACC_WR_MASK    (0x00000001)
294
#define NIOS2_MPUACC_WR_OFST    (0)
295
 
296
#ifdef __cplusplus
297
}
298
#endif /* __cplusplus */
299
 
300
#endif /* __NIOS2_H__ */

powered by: WebSVN 2.1.0

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