RTEMS 6.1-rc5
Loading...
Searching...
No Matches
or1k-utility.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
8/*
9 * COPYRIGHT (c) 2014 Hesham ALMatary <heshamelmatary@gmail.com>
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef _RTEMS_SCORE_OR1K_UTILITY_H
34#define _RTEMS_SCORE_OR1K_UTILITY_H
35
36/* SPR groups definitions */
37#define SPR_GRP_SHAMT 11
38#define SPR_GRP0_SYS_CTRL (0 << SPR_GRP_SHAMT)
39#define SPR_GRP1_DMMU (1 << SPR_GRP_SHAMT)
40#define SPR_GRP2_IMMU (2 << SPR_GRP_SHAMT)
41#define SPR_GRP3_DC (3 << SPR_GRP_SHAMT)
42#define SPR_GRP4_IC (4 << SPR_GRP_SHAMT)
43#define SPR_GRP5_MAC (5 << SPR_GRP_SHAMT)
44#define SPR_GRP6_DEBUG (6 << SPR_GRP_SHAMT)
45#define SPR_GRP7_PERF_CTR (7 << SPR_GRP_SHAMT)
46#define SPR_GRP8_PWR_MNG (8 << SPR_GRP_SHAMT)
47#define SPR_GRP9_PIC (9 << SPR_GRP_SHAMT)
48#define SPR_GPR10_TICK_TMR (10 << SPR_GRP_SHAMT)
49#define SPR_GPR11_FPU (11 << SPR_GRP_SHAMT)
50
51/* SPR registers definitions */
52
53/* Group 0: System control registers */
54#define CPU_OR1K_SPR_VR (SPR_GRP0_SYS_CTRL + 0)
55#define CPU_OR1K_SPR_UPR (SPR_GRP0_SYS_CTRL + 1)
56#define CPU_OR1K_SPR_CPUCFGR (SPR_GRP0_SYS_CTRL + 2)
57#define CPU_OR1K_SPR_DMMUCFGR (SPR_GRP0_SYS_CTRL + 3)
58#define CPU_OR1K_SPR_IMMUCFGR (SPR_GRP0_SYS_CTRL + 4)
59#define CPU_OR1K_SPR_DCCFGR (SPR_GRP0_SYS_CTRL + 5)
60#define CPU_OR1K_SPR_ICCFGR (SPR_GRP0_SYS_CTRL + 6)
61#define CPU_OR1K_SPR_DCFGR (SPR_GRP0_SYS_CTRL + 7)
62#define CPU_OR1K_SPR_PCCFGR (SPR_GRP0_SYS_CTRL + 8)
63#define CPU_OR1K_SPR_VR2 (SPR_GRP0_SYS_CTRL + 9)
64#define CPU_OR1K_SPR_AVR (SPR_GRP0_SYS_CTRL + 10)
65#define CPU_OR1K_SPR_EVBAR (SPR_GRP0_SYS_CTRL + 11)
66#define CPU_OR1K_SPR_AECR (SPR_GRP0_SYS_CTRL + 12)
67#define CPU_OR1K_SPR_AESR (SPR_GRP0_SYS_CTRL + 13)
68#define CPU_OR1K_SPR_NPC (SPR_GRP0_SYS_CTRL + 16)
69#define CPU_OR1K_SPR_SR (SPR_GRP0_SYS_CTRL + 17)
70#define CPU_OR1K_SPR_PPC (SPR_GRP0_SYS_CTRL + 18)
71#define CPU_OR1K_SPR_FPCSR (SPR_GRP0_SYS_CTRL + 20)
72#define CPU_OR1K_SPR_EPCR0 (SPR_GRP0_SYS_CTRL + 32)
73#define CPU_OR1K_SPR_EPCR1 (SPR_GRP0_SYS_CTRL + 33)
74#define CPU_OR1K_SPR_EPCR2 (SPR_GRP0_SYS_CTRL + 34)
75#define CPU_OR1K_SPR_EPCR3 (SPR_GRP0_SYS_CTRL + 35)
76#define CPU_OR1K_SPR_EPCR4 (SPR_GRP0_SYS_CTRL + 36)
77#define CPU_OR1K_SPR_EPCR5 (SPR_GRP0_SYS_CTRL + 37)
78#define CPU_OR1K_SPR_EPCR6 (SPR_GRP0_SYS_CTRL + 38)
79#define CPU_OR1K_SPR_EPCR7 (SPR_GRP0_SYS_CTRL + 39)
80#define CPU_OR1K_SPR_EPCR8 (SPR_GRP0_SYS_CTRL + 40)
81#define CPU_OR1K_SPR_EPCR9 (SPR_GRP0_SYS_CTRL + 41)
82#define CPU_OR1K_SPR_EPCR10 (SPR_GRP0_SYS_CTRL + 42)
83#define CPU_OR1K_SPR_EPCR11 (SPR_GRP0_SYS_CTRL + 43)
84#define CPU_OR1K_SPR_EPCR12 (SPR_GRP0_SYS_CTRL + 44)
85#define CPU_OR1K_SPR_EPCR13 (SPR_GRP0_SYS_CTRL + 45)
86#define CPU_OR1K_SPR_EPCR14 (SPR_GRP0_SYS_CTRL + 46)
87#define CPU_OR1K_SPR_EPCR15 (SPR_GRP0_SYS_CTRL + 47)
88#define CPU_OR1K_SPR_EEAR0 (SPR_GRP0_SYS_CTRL + 48)
89#define CPU_OR1K_SPR_EEAR1 (SPR_GRP0_SYS_CTRL + 49)
90#define CPU_OR1K_SPR_EEAR2 (SPR_GRP0_SYS_CTRL + 50)
91#define CPU_OR1K_SPR_EEAR3 (SPR_GRP0_SYS_CTRL + 51)
92#define CPU_OR1K_SPR_EEAR4 (SPR_GRP0_SYS_CTRL + 52)
93#define CPU_OR1K_SPR_EEAR5 (SPR_GRP0_SYS_CTRL + 53)
94#define CPU_OR1K_SPR_EEAR6 (SPR_GRP0_SYS_CTRL + 54)
95#define CPU_OR1K_SPR_EEAR7 (SPR_GRP0_SYS_CTRL + 55)
96#define CPU_OR1K_SPR_EEAR8 (SPR_GRP0_SYS_CTRL + 56)
97#define CPU_OR1K_SPR_EEAR9 (SPR_GRP0_SYS_CTRL + 57)
98#define CPU_OR1K_SPR_EEAR10 (SPR_GRP0_SYS_CTRL + 58)
99#define CPU_OR1K_SPR_EEAR11 (SPR_GRP0_SYS_CTRL + 59)
100#define CPU_OR1K_SPR_EEAR12 (SPR_GRP0_SYS_CTRL + 60)
101#define CPU_OR1K_SPR_EEAR13 (SPR_GRP0_SYS_CTRL + 61)
102#define CPU_OR1K_SPR_EEAR14 (SPR_GRP0_SYS_CTRL + 62)
103#define CPU_OR1K_SPR_EEAR15 (SPR_GRP0_SYS_CTRL + 63)
104#define CPU_OR1K_SPR_ESR0 (SPR_GRP0_SYS_CTRL + 64)
105#define CPU_OR1K_SPR_ESR1 (SPR_GRP0_SYS_CTRL + 65)
106#define CPU_OR1K_SPR_ESR2 (SPR_GRP0_SYS_CTRL + 66)
107#define CPU_OR1K_SPR_ESR3 (SPR_GRP0_SYS_CTRL + 67)
108#define CPU_OR1K_SPR_ESR4 (SPR_GRP0_SYS_CTRL + 68)
109#define CPU_OR1K_SPR_ESR5 (SPR_GRP0_SYS_CTRL + 69)
110#define CPU_OR1K_SPR_ESR6 (SPR_GRP0_SYS_CTRL + 70)
111#define CPU_OR1K_SPR_ESR7 (SPR_GRP0_SYS_CTRL + 71)
112#define CPU_OR1K_SPR_ESR8 (SPR_GRP0_SYS_CTRL + 72)
113#define CPU_OR1K_SPR_ESR9 (SPR_GRP0_SYS_CTRL + 73)
114#define CPU_OR1K_SPR_ESR10 (SPR_GRP0_SYS_CTRL + 74)
115#define CPU_OR1K_SPR_ESR11 (SPR_GRP0_SYS_CTRL + 75)
116#define CPU_OR1K_SPR_ESR12 (SPR_GRP0_SYS_CTRL + 76)
117#define CPU_OR1K_SPR_ESR13 (SPR_GRP0_SYS_CTRL + 77)
118#define CPU_OR1K_SPR_ESR14 (SPR_GRP0_SYS_CTRL + 78)
119#define CPU_OR1K_SPR_ESR15 (SPR_GRP0_SYS_CTRL + 79)
120
121/* Shadow registers base */
122#define CPU_OR1K_SPR_GPR32 (SPR_GRP0_SYS_CTRL + 1024)
123
124/* Group1: Data MMU registers */
125#define CPU_OR1K_SPR_DMMUCR (SPR_GRP1_DMMU + 0)
126#define CPU_OR1K_SPR_DMMUPR (SPR_GRP1_DMMU + 1)
127#define CPU_OR1K_SPR_DTLBEIR (SPR_GRP1_DMMU + 2)
128#define CPU_OR1K_SPR_DATBMR0 (SPR_GRP1_DMMU + 4)
129#define CPU_OR1K_SPR_DATBMR1 (SPR_GRP1_DMMU + 5)
130#define CPU_OR1K_SPR_DATBMR2 (SPR_GRP1_DMMU + 6)
131#define CPU_OR1K_SPR_DATBMR3 (SPR_GRP1_DMMU + 7)
132#define CPU_OR1K_SPR_DATBTR0 (SPR_GRP1_DMMU + 8)
133#define CPU_OR1K_SPR_DATBTR1 (SPR_GRP1_DMMU + 9)
134#define CPU_OR1K_SPR_DATBTR2 (SPR_GRP1_DMMU + 10)
135#define CPU_OR1K_SPR_DATBTR3 (SPR_GRP1_DMMU + 11)
136
137/* Group2: Instruction MMU registers */
138#define CPU_OR1K_SPR_IMMUCR (SPR_GRP2_IMMU + 0)
139#define CPU_OR1K_SPR_IMMUPR (SPR_GRP2_IMMU + 1)
140#define CPU_OR1K_SPR_ITLBEIR (SPR_GRP2_IMMU + 2)
141#define CPU_OR1K_SPR_IATBMR0 (SPR_GRP2_IMMU + 4)
142#define CPU_OR1K_SPR_IATBMR1 (SPR_GRP2_IMMU + 5)
143#define CPU_OR1K_SPR_IATBMR2 (SPR_GRP2_IMMU + 6)
144#define CPU_OR1K_SPR_IATBMR3 (SPR_GRP2_IMMU + 7)
145#define CPU_OR1K_SPR_IATBTR0 (SPR_GRP2_IMMU + 8)
146#define CPU_OR1K_SPR_IATBTR1 (SPR_GRP2_IMMU + 9)
147#define CPU_OR1K_SPR_IATBTR2 (SPR_GRP2_IMMU + 10)
148#define CPU_OR1K_SPR_IATBTR3 (SPR_GRP2_IMMU + 11)
149
150/* Group3: Data Cache registers */
151#define CPU_OR1K_SPR_DCCR (SPR_GRP3_DC + 0)
152#define CPU_OR1K_SPR_DCBPR (SPR_GRP3_DC + 1)
153#define CPU_OR1K_SPR_DCBFR (SPR_GRP3_DC + 2)
154#define CPU_OR1K_SPR_DCBIR (SPR_GRP3_DC + 3)
155#define CPU_OR1K_SPR_DCBWR (SPR_GRP3_DC + 4)
156#define CPU_OR1K_SPR_DCBLR (SPR_GRP3_DC + 5)
157
158/* Group4: Instruction Cache registers */
159#define CPU_OR1K_SPR_ICCR (SPR_GRP4_IC + 0)
160#define CPU_OR1K_SPR_ICBPR (SPR_GRP4_IC + 1)
161#define CPU_OR1K_SPR_ICBIR (SPR_GRP4_IC + 2)
162#define CPU_OR1K_SPR_ICBLR (SPR_GRP4_IC + 3)
163
164/* Group5: MAC registers */
165#define CPU_OR1K_SPR_MACLO (SPR_GRP5_MAC + 1)
166#define CPU_OR1K_SPR_MACHI (SPR_GRP5_MAC + 2)
167
168/* Group6: Debug registers */
169#define CPU_OR1K_SPR_DVR0 (SPR_GRP6_DEBUG + 0)
170#define CPU_OR1K_SPR_DVR1 (SPR_GRP6_DEBUG + 1)
171#define CPU_OR1K_SPR_DVR2 (SPR_GRP6_DEBUG + 2)
172#define CPU_OR1K_SPR_DVR3 (SPR_GRP6_DEBUG + 3)
173#define CPU_OR1K_SPR_DVR4 (SPR_GRP6_DEBUG + 4)
174#define CPU_OR1K_SPR_DVR5 (SPR_GRP6_DEBUG + 5)
175#define CPU_OR1K_SPR_DVR6 (SPR_GRP6_DEBUG + 6)
176#define CPU_OR1K_SPR_DVR7 (SPR_GRP6_DEBUG + 7)
177#define CPU_OR1K_SPR_DCR0 (SPR_GRP6_DEBUG + 8)
178#define CPU_OR1K_SPR_DCR1 (SPR_GRP6_DEBUG + 9)
179#define CPU_OR1K_SPR_DCR2 (SPR_GRP6_DEBUG + 10)
180#define CPU_OR1K_SPR_DCR3 (SPR_GRP6_DEBUG + 11)
181#define CPU_OR1K_SPR_DCR4 (SPR_GRP6_DEBUG + 12)
182#define CPU_OR1K_SPR_DCR5 (SPR_GRP6_DEBUG + 13)
183#define CPU_OR1K_SPR_DCR6 (SPR_GRP6_DEBUG + 14)
184#define CPU_OR1K_SPR_DCR7 (SPR_GRP6_DEBUG + 15)
185#define CPU_OR1K_SPR_DMR1 (SPR_GRP6_DEBUG + 16)
186#define CPU_OR1K_SPR_DMR2 (SPR_GRP6_DEBUG + 17)
187#define CPU_OR1K_SPR_DCWR0 (SPR_GRP6_DEBUG + 18)
188#define CPU_OR1K_SPR_DCWR1 (SPR_GRP6_DEBUG + 19)
189#define CPU_OR1K_SPR_DSR (SPR_GRP6_DEBUG + 20)
190#define CPU_OR1K_SPR_DRR (SPR_GRP6_DEBUG + 21)
191
192/* Group7: Performance counters registers */
193#define CPU_OR1K_SPR_PCCR0 (SPR_GRP7_PERF_CTR + 0)
194#define CPU_OR1K_SPR_PCCR1 (SPR_GRP7_PERF_CTR + 1)
195#define CPU_OR1K_SPR_PCCR2 (SPR_GRP7_PERF_CTR + 2)
196#define CPU_OR1K_SPR_PCCR3 (SPR_GRP7_PERF_CTR + 3)
197#define CPU_OR1K_SPR_PCCR4 (SPR_GRP7_PERF_CTR + 4)
198#define CPU_OR1K_SPR_PCCR5 (SPR_GRP7_PERF_CTR + 5)
199#define CPU_OR1K_SPR_PCCR6 (SPR_GRP7_PERF_CTR + 6)
200#define CPU_OR1K_SPR_PCCR7 (SPR_GRP7_PERF_CTR + 7)
201#define CPU_OR1K_SPR_PCMR0 (SPR_GRP7_PERF_CTR + 8)
202#define CPU_OR1K_SPR_PCMR1 (SPR_GRP7_PERF_CTR + 9)
203#define CPU_OR1K_SPR_PCMR2 (SPR_GRP7_PERF_CTR + 10)
204#define CPU_OR1K_SPR_PCMR3 (SPR_GRP7_PERF_CTR + 11)
205#define CPU_OR1K_SPR_PCMR4 (SPR_GRP7_PERF_CTR + 12)
206#define CPU_OR1K_SPR_PCMR5 (SPR_GRP7_PERF_CTR + 13)
207#define CPU_OR1K_SPR_PCMR6 (SPR_GRP7_PERF_CTR + 14)
208#define CPU_OR1K_SPR_PCMR7 (SPR_GRP7_PERF_CTR + 15)
209
210/* Group8: Power management register */
211#define CPU_OR1K_SPR_PMR (SPR_GRP8_PWR_MNG + 0)
212
213/* Group9: PIC registers */
214#define CPU_OR1K_SPR_PICMR (SPR_GRP9_PIC + 0)
215#define CPU_OR1K_SPR_PICSR (SPR_GRP9_PIC + 2)
216
217/* Group10: Tick Timer registers */
218#define CPU_OR1K_SPR_TTMR (SPR_GPR10_TICK_TMR + 0)
219#define CPU_OR1K_SPR_TTCR (SPR_GPR10_TICK_TMR + 1)
220
221 /* Shift amount macros for bits position in Supervision Register */
222#define CPU_OR1K_SPR_SR_SHAMT_SM (0)
223#define CPU_OR1K_SPR_SR_SHAMT_TEE (1)
224#define CPU_OR1K_SPR_SR_SHAMT_IEE (2)
225#define CPU_OR1K_SPR_SR_SHAMT_DCE (3)
226#define CPU_OR1K_SPR_SR_SHAMT_ICE (4)
227#define CPU_OR1K_SPR_SR_SHAMT_DME (5)
228#define CPU_OR1K_SPR_SR_SHAMT_IME (6)
229#define CPU_OR1K_SPR_SR_SHAMT_LEE (7)
230#define CPU_OR1K_SPR_SR_SHAMT_CE (8)
231#define CPU_OR1K_SPR_SR_SHAMT_F (9)
232#define CPU_OR1K_SPR_SR_SHAMT_CY (10)
233#define CPU_OR1K_SPR_SR_SHAMT_OV (11)
234#define CPU_OR1K_SPR_SR_SHAMT_OVE (12)
235#define CPU_OR1K_SPR_SR_SHAMT_DSX (13)
236#define CPU_OR1K_SPR_SR_SHAMT_EPH (14)
237#define CPU_OR1K_SPR_SR_SHAMT_FO (15)
238#define CPU_OR1K_SPR_SR_SHAMT_SUMRA (16)
239#define CPU_OR1K_SPR_SR_SHAMT_CID (28)
240
241/* Supervision Mode Register. @see OpenRISC architecture manual*/
242
243 /* Supervisor Mode */
244#define CPU_OR1K_SPR_SR_SM (1 << CPU_OR1K_SPR_SR_SHAMT_SM)
245/* Tick Timer Exception Enabled */
246#define CPU_OR1K_SPR_SR_TEE (1 << CPU_OR1K_SPR_SR_SHAMT_TEE)
247/* Interrupt Exception Enabled */
248#define CPU_OR1K_SPR_SR_IEE (1 << CPU_OR1K_SPR_SR_SHAMT_IEE)
249/* Data Cache Enable */
250#define CPU_OR1K_SPR_SR_DCE (1 << CPU_OR1K_SPR_SR_SHAMT_DCE)
251/* Instruction Cache Enable */
252#define CPU_OR1K_SPR_SR_ICE (1 << CPU_OR1K_SPR_SR_SHAMT_ICE)
253/* Data MMU Enable */
254#define CPU_OR1K_SPR_SR_DME (1 << CPU_OR1K_SPR_SR_SHAMT_DME)
255/* Instruction MMU Enable */
256#define CPU_OR1K_SPR_SR_IME (1 << CPU_OR1K_SPR_SR_SHAMT_IME)
257/* Little Endian Enable */
258#define CPU_OR1K_SPR_SR_LEE (1 << CPU_OR1K_SPR_SR_SHAMT_LEE)
259/* CID Enable */
260#define CPU_OR1K_SPR_SR_CE (1 << CPU_OR1K_SPR_SR_SHAMT_CE)
261/* Conditional branch flag */
262#define CPU_OR1K_SPR_SR_F (1 << CPU_OR1K_SPR_SR_SHAMT_F)
263/* Carry flag */
264#define CPU_OR1K_SPR_SR_CY (1 << CPU_OR1K_SPR_SR_SHAMT_CY)
265/* Overflow flag */
266#define CPU_OR1K_SPR_SR_OV (1 << CPU_OR1K_SPR_SR_SHAMT_OV)
267/* Overflow flag Exception */
268#define CPU_OR1K_SPR_SR_OVE (1 << CPU_OR1K_SPR_SR_SHAMT_OVE)
269/* Delay Slot Exception */
270#define CPU_OR1K_SPR_SR_DSX (1 << CPU_OR1K_SPR_SR_SHAMT_DSX)
271 /* Exception Prefix High */
272#define CPU_OR1K_SPR_SR_EPH (1 << CPU_OR1K_SPR_SR_SHAMT_EPH)
273/* Fixed One */
274#define CPU_OR1K_SPR_SR_FO (1 << CPU_OR1K_SPR_SR_SHAMT_FO)
275/* SPRs User Mode Read Access */
276#define CPU_OR1K_SPR_SR_SUMRA (1 << CPU_OR1K_SPR_SR_SHAMT_SUMRA)
277/*Context ID (Fast Context Switching) */
278#define CPU_OR1K_SPR_SR_CID (F << CPU_OR1K_SPR_SR_SHAMT_CID)
279
280/* Tick timer configuration bits */
281#define CPU_OR1K_SPR_TTMR_SHAMT_IP 28
282#define CPU_OR1K_SPR_TTMR_SHAMT_IE 29
283#define CPU_OR1K_SPR_TTMR_SHAMT_MODE 30
284
285#define CPU_OR1K_SPR_TTMR_TP_MASK (0x0FFFFFFF)
286#define CPU_OR1K_SPR_TTMR_IP (1 << CPU_OR1K_SPR_TTMR_SHAMT_IP)
287#define CPU_OR1K_SPR_TTMR_IE (1 << CPU_OR1K_SPR_TTMR_SHAMT_IE)
288#define CPU_OR1K_SPR_TTMR_MODE_RESTART (1 << CPU_OR1K_SPR_TTMR_SHAMT_MODE)
289#define CPU_OR1K_SPR_TTMR_MODE_ONE_SHOT (2 << CPU_OR1K_SPR_TTMR_SHAMT_MODE)
290#define CPU_OR1K_SPR_TTMR_MODE_CONT (3 << CPU_OR1K_SPR_TTMR_SHAMT_MODE)
291
292/* Power management register bits */
293
294/* Shift amount macros for bit positions in Power Management register */
295#define CPU_OR1K_SPR_PMR_SHAMT_SDF 0
296#define CPU_OR1K_SPR_PMR_SHAMT_DME 4
297#define CPU_OR1K_SPR_PMR_SHAMT_SME 5
298#define CPU_OR1K_SPR_PMR_SHAMT_DCGE 6
299#define CPU_OR1K_SPR_PMR_SHAMT_SUME 7
300
301#define CPU_OR1K_SPR_PMR_SDF (0xF << CPU_OR1K_SPR_PMR_SHAMT_SDF)
302#define CPU_OR1K_SPR_PMR_DME (1 << CPU_OR1K_SPR_PMR_SHAMT_DME)
303#define CPU_OR1K_SPR_PMR_SME (1 << CPU_OR1K_SPR_PMR_SHAMT_SME)
304#define CPU_OR1K_SPR_PMR_DCGE (1 << CPU_OR1K_SPR_PMR_SHAMT_DCGE)
305#define CPU_OR1K_SPR_PMR_SUME (1 << CPU_OR1K_SPR_PMR_SHAMT_SUME)
306
307#ifndef ASM
308
309#include <stddef.h>
310#include <stdint.h>
311#include <stdbool.h>
312
313#ifdef __cplusplus
314extern "C" {
315#endif /* __cplusplus */
316
322typedef enum {
323 OR1K_EXCEPTION_RESET = 1,
324 OR1K_EXCEPTION_BUS_ERR = 2,
325 OR1K_EXCEPTION_D_PF = 3, /* Data Page Fault */
326 OR1K_EXCEPTION_I_PF = 4, /* Instruction Page Fault */
327 OR1K_EXCEPTION_TICK_TIMER = 5,
328 OR1K_EXCEPTION_ALIGNMENT = 6,
329 OR1K_EXCEPTION_I_UNDEF= 7, /* Undefiend instruction */
330 OR1K_EXCEPTION_IRQ = 8, /* External interrupt */
331 OR1K_EXCPETION_D_TLB = 9, /* Data TLB miss */
332 OR1K_EXCPETION_I_TLB = 10, /* Instruction TLB miss */
333 OR1K_EXCPETION_RANGE = 11, /* Range exception */
334 OR1K_EXCPETION_SYS_CALL = 12,
335 OR1K_EXCPETION_FP = 13, /* Floating point exception */
336 OR1K_EXCPETION_TRAP = 14, /* Caused by l.trap instruction or by debug unit */
337 OR1K_EXCPETION_RESERVED1 = 15,
338 OR1K_EXCPETION_RESERVED2 = 16,
339 OR1K_EXCPETION_RESERVED3 = 17,
340 MAX_EXCEPTIONS = 17,
341 OR1K_EXCEPTION_MAKE_ENUM_32_BIT = 0xffffffff
343
344static inline uint32_t _OR1K_mfspr(uint32_t reg)
345{
346 uint32_t spr_value;
347
348 __asm__ volatile (
349 "l.mfspr %0, %1, 0;\n\t"
350 : "=r" (spr_value) : "r" (reg));
351
352 return spr_value;
353}
354
355static inline void _OR1K_mtspr(uint32_t reg, uint32_t value)
356{
357 __asm__ volatile (
358 "l.mtspr %1, %0, 0;\n\t"
359 :: "r" (value), "r" (reg)
360 );
361}
362
373#define _OR1K_CPU_SlowDown(value) \
374 _OR1K_mtspr(CPU_OR1K_SPR_PMR, (value & CPU_OR1K_SPR_PMR_SDF))
375
376
377#define _OR1K_CPU_Doze() \
378 _OR1K_mtspr(CPU_OR1K_SPR_PMR, CPU_OR1K_SPR_PMR_DME)
379
380
381#define _OR1K_CPU_Sleep() \
382 _OR1K_mtspr(CPU_OR1K_SPR_PMR, CPU_OR1K_SPR_PMR_SME)
383
384#define _OR1K_CPU_Suspend() \
385 _OR1K_mtspr(CPU_OR1K_SPR_PMR, CPU_OR1K_SPR_PMR_SME)
386
387static inline void _OR1K_Sync_mem( void )
388{
389 __asm__ volatile("l.msync");
390}
391
392static inline void _OR1K_Sync_pipeline( void )
393{
394 __asm__ volatile("l.psync");
395}
396
404#define _OR1KSIM_CPU_Halt() \
405 __asm__ volatile ("l.nop 0xc")
406
407#ifdef __cplusplus
408}
409#endif
410
411#else /* ASM */
412
413#endif /* ASM */
414
415#endif /* _RTEMS_SCORE_OR1K_UTILITY_H */
OR1K_Symbolic_exception_name
Supervision Mode registers definitions.
Definition: or1k-utility.h:322