1#ifndef ZEPHYR_INCLUDE_ARCH_NIOS2_NIOS2_H_
2#define ZEPHYR_INCLUDE_ARCH_NIOS2_NIOS2_H_
52#define SYSTEM_BUS_WIDTH 32
65static inline uint32_t _nios2_read_et(
void)
69 __asm__(
"mov %0, et" :
"=r" (et));
73static inline void _nios2_write_et(
uint32_t et)
75 __asm__
volatile(
"mov et, %z0" : :
"rM" (et));
78static inline uint32_t _nios2_read_sp(
void)
82 __asm__(
"mov %0, sp" :
"=r" (sp));
89static inline void z_nios2_break(
void)
91 __asm__
volatile(
"break");
94static inline void _nios2_report_stack_overflow(
void)
96 __asm__
volatile(
"break 3");
102static inline void _nios2_dcache_addr_flush(
void *addr)
104 __asm__
volatile (
"flushda (%0)" ::
"r" (addr));
107static inline void z_nios2_dcache_flush(
uint32_t offset)
109 __asm__
volatile (
"flushd (%0)" ::
"r" (offset));
112static inline void z_nios2_icache_flush(
uint32_t offset)
114 __asm__
volatile (
"flushi %0" ::
"r" (offset));
117static inline void z_nios2_pipeline_flush(
void)
119 __asm__
volatile (
"flushp");
157#define z_nios2_creg_read(reg) __builtin_rdctl(reg)
158#define z_nios2_creg_write(reg, val) __builtin_wrctl(reg, val)
160#define z_nios2_get_register_address(base, regnum) \
161 ((void *)(((uint8_t *)base) + ((regnum) * (SYSTEM_BUS_WIDTH / 8))))
163static inline void _nios2_reg_write(
void *base,
int regnum,
uint32_t data)
166 (
mm_reg_t)z_nios2_get_register_address(base, regnum));
169static inline uint32_t _nios2_reg_read(
void *base,
int regnum)
179#define NIOS2_STATUS status
180#define NIOS2_ESTATUS estatus
181#define NIOS2_BSTATUS bstatus
182#define NIOS2_IENABLE ienable
183#define NIOS2_IPENDING ipending
184#define NIOS2_CPUID cpuid
201#define NIOS2_STATUS_PIE_MSK (0x00000001)
202#define NIOS2_STATUS_PIE_OFST (0)
203#define NIOS2_STATUS_U_MSK (0x00000002)
204#define NIOS2_STATUS_U_OFST (1)
205#define NIOS2_STATUS_EH_MSK (0x00000004)
206#define NIOS2_STATUS_EH_OFST (2)
207#define NIOS2_STATUS_IH_MSK (0x00000008)
208#define NIOS2_STATUS_IH_OFST (3)
209#define NIOS2_STATUS_IL_MSK (0x000003f0)
210#define NIOS2_STATUS_IL_OFST (4)
211#define NIOS2_STATUS_CRS_MSK (0x0000fc00)
212#define NIOS2_STATUS_CRS_OFST (10)
213#define NIOS2_STATUS_PRS_MSK (0x003f0000)
214#define NIOS2_STATUS_PRS_OFST (16)
215#define NIOS2_STATUS_NMI_MSK (0x00400000)
216#define NIOS2_STATUS_NMI_OFST (22)
217#define NIOS2_STATUS_RSIE_MSK (0x00800000)
218#define NIOS2_STATUS_RSIE_OFST (23)
219#define NIOS2_STATUS_SRS_MSK (0x80000000)
220#define NIOS2_STATUS_SRS_OFST (31)
223#define NIOS2_EXCEPTION_REG_CAUSE_MASK (0x0000007c)
224#define NIOS2_EXCEPTION_REG_CAUSE_OFST (2)
225#define NIOS2_EXCEPTION_REG_ECCFTL_MASK (0x80000000)
226#define NIOS2_EXCEPTION_REG_ECCFTL_OFST (31)
229#define NIOS2_PTEADDR_REG_VPN_OFST 2
230#define NIOS2_PTEADDR_REG_VPN_MASK 0x3ffffc
231#define NIOS2_PTEADDR_REG_PTBASE_OFST 22
232#define NIOS2_PTEADDR_REG_PTBASE_MASK 0xffc00000
235#define NIOS2_TLBACC_REG_PFN_OFST 0
236#define NIOS2_TLBACC_REG_PFN_MASK 0xfffff
237#define NIOS2_TLBACC_REG_G_OFST 20
238#define NIOS2_TLBACC_REG_G_MASK 0x100000
239#define NIOS2_TLBACC_REG_X_OFST 21
240#define NIOS2_TLBACC_REG_X_MASK 0x200000
241#define NIOS2_TLBACC_REG_W_OFST 22
242#define NIOS2_TLBACC_REG_W_MASK 0x400000
243#define NIOS2_TLBACC_REG_R_OFST 23
244#define NIOS2_TLBACC_REG_R_MASK 0x800000
245#define NIOS2_TLBACC_REG_C_OFST 24
246#define NIOS2_TLBACC_REG_C_MASK 0x1000000
247#define NIOS2_TLBACC_REG_IG_OFST 25
248#define NIOS2_TLBACC_REG_IG_MASK 0xfe000000
251#define NIOS2_TLBMISC_REG_D_OFST 0
252#define NIOS2_TLBMISC_REG_D_MASK 0x1
253#define NIOS2_TLBMISC_REG_PERM_OFST 1
254#define NIOS2_TLBMISC_REG_PERM_MASK 0x2
255#define NIOS2_TLBMISC_REG_BAD_OFST 2
256#define NIOS2_TLBMISC_REG_BAD_MASK 0x4
257#define NIOS2_TLBMISC_REG_DBL_OFST 3
258#define NIOS2_TLBMISC_REG_DBL_MASK 0x8
259#define NIOS2_TLBMISC_REG_PID_OFST 4
260#define NIOS2_TLBMISC_REG_PID_MASK 0x3fff0
261#define NIOS2_TLBMISC_REG_WE_OFST 18
262#define NIOS2_TLBMISC_REG_WE_MASK 0x40000
263#define NIOS2_TLBMISC_REG_RD_OFST 19
264#define NIOS2_TLBMISC_REG_RD_MASK 0x80000
265#define NIOS2_TLBMISC_REG_WAY_OFST 20
266#define NIOS2_TLBMISC_REG_WAY_MASK 0xf00000
267#define NIOS2_TLBMISC_REG_EE_OFST 24
268#define NIOS2_TLBMISC_REG_EE_MASK 0x1000000
271#define NIOS2_ECCINJ_REG_RF_OFST 0
272#define NIOS2_ECCINJ_REG_RF_MASK 0x3
273#define NIOS2_ECCINJ_REG_ICTAG_OFST 2
274#define NIOS2_ECCINJ_REG_ICTAG_MASK 0xc
275#define NIOS2_ECCINJ_REG_ICDAT_OFST 4
276#define NIOS2_ECCINJ_REG_ICDAT_MASK 0x30
277#define NIOS2_ECCINJ_REG_DCTAG_OFST 6
278#define NIOS2_ECCINJ_REG_DCTAG_MASK 0xc0
279#define NIOS2_ECCINJ_REG_DCDAT_OFST 8
280#define NIOS2_ECCINJ_REG_DCDAT_MASK 0x300
281#define NIOS2_ECCINJ_REG_TLB_OFST 10
282#define NIOS2_ECCINJ_REG_TLB_MASK 0xc00
283#define NIOS2_ECCINJ_REG_DTCM0_OFST 12
284#define NIOS2_ECCINJ_REG_DTCM0_MASK 0x3000
285#define NIOS2_ECCINJ_REG_DTCM1_OFST 14
286#define NIOS2_ECCINJ_REG_DTCM1_MASK 0xc000
287#define NIOS2_ECCINJ_REG_DTCM2_OFST 16
288#define NIOS2_ECCINJ_REG_DTCM2_MASK 0x30000
289#define NIOS2_ECCINJ_REG_DTCM3_OFST 18
290#define NIOS2_ECCINJ_REG_DTCM3_MASK 0xc0000
293#define NIOS2_CONFIG_REG_PE_MASK (0x00000001)
294#define NIOS2_CONFIG_REG_PE_OFST (0)
295#define NIOS2_CONFIG_REG_ANI_MASK (0x00000002)
296#define NIOS2_CONFIG_REG_ANI_OFST (1)
297#define NIOS2_CONFIG_REG_ECCEN_MASK (0x00000004)
298#define NIOS2_CONFIG_REG_ECCEN_OFST (2)
299#define NIOS2_CONFIG_REG_ECCEXC_MASK (0x00000008)
300#define NIOS2_CONFIG_REG_ECCEXC_OFST (3)
303#define NIOS2_MPUBASE_D_MASK (0x00000001)
304#define NIOS2_MPUBASE_D_OFST (0)
305#define NIOS2_MPUBASE_INDEX_MASK (0x0000003e)
306#define NIOS2_MPUBASE_INDEX_OFST (1)
307#define NIOS2_MPUBASE_BASE_ADDR_MASK (0xffffffc0)
308#define NIOS2_MPUBASE_BASE_ADDR_OFST (6)
311#define NIOS2_MPUACC_LIMIT_MASK (0xffffffc0)
312#define NIOS2_MPUACC_LIMIT_OFST (6)
313#define NIOS2_MPUACC_MASK_MASK (0xffffffc0)
314#define NIOS2_MPUACC_MASK_OFST (6)
315#define NIOS2_MPUACC_C_MASK (0x00000020)
316#define NIOS2_MPUACC_C_OFST (5)
317#define NIOS2_MPUACC_PERM_MASK (0x0000001c)
318#define NIOS2_MPUACC_PERM_OFST (2)
319#define NIOS2_MPUACC_RD_MASK (0x00000002)
320#define NIOS2_MPUACC_RD_OFST (1)
321#define NIOS2_MPUACC_WR_MASK (0x00000001)
322#define NIOS2_MPUACC_WR_OFST (0)
nios2_creg
Definition nios2.h:126
@ NIOS2_CR_ESTATUS
Definition nios2.h:128
@ NIOS2_CR_MPUACC
Definition nios2.h:142
@ NIOS2_CR_TLBACC
Definition nios2.h:136
@ NIOS2_CR_IPENDING
Definition nios2.h:131
@ NIOS2_CR_BSTATUS
Definition nios2.h:129
@ NIOS2_CR_BADADDR
Definition nios2.h:139
@ NIOS2_CR_TLBMISC
Definition nios2.h:137
@ NIOS2_CR_CONFIG
Definition nios2.h:140
@ NIOS2_CR_STATUS
Definition nios2.h:127
@ NIOS2_CR_MPUBASE
Definition nios2.h:141
@ NIOS2_CR_EXCEPTION
Definition nios2.h:134
@ NIOS2_CR_ECCINJ
Definition nios2.h:138
@ NIOS2_CR_CPUID
Definition nios2.h:132
@ NIOS2_CR_PTEADDR
Definition nios2.h:135
@ NIOS2_CR_IENABLE
Definition nios2.h:130
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
static ALWAYS_INLINE void sys_write32(uint32_t data, mem_addr_t addr)
Definition sys-io-common.h:70
static ALWAYS_INLINE uint32_t sys_read32(mem_addr_t addr)
Definition sys-io-common.h:59
uintptr_t mm_reg_t
Definition sys_io.h:20