source: rtems/cpukit/score/cpu/arm/rtems/score/armv7m.h @ c5ed148

4.115
Last change on this file since c5ed148 was c5ed148, checked in by Sebastian Huber <sebastian.huber@…>, on 09/24/11 at 12:56:51

2011-09-24 Sebastian Huber <sebastian.huber@…>

  • rtems/score/armv7m.h, armv7m-context-initialize.c, armv7m-context-restore.c, armv7m-context-switch.c, armv7m-exception-handler-get.c, armv7m-exception-handler-set.c, armv7m-exception-priority-get.c, armv7m-exception-priority-set.c, armv7m-initialize.c, armv7m-isr-dispatch.c, armv7m-isr-enter-leave.c, armv7m-isr-level-get.c, armv7m-isr-level-set.c, armv7m-isr-vector-install.c, armv7m-multitasking-start-stop.c: New files.
  • Makefile.am, preinstall.am: Reflect changes above.
  • rtems/score/arm.h: Define ARM_MULTILIB_ARCH_V4 and ARM_MULTILIB_ARCH_V7M.
  • rtems/score/cpu.h, cpu_asm.S, cpu.c, arm_exc_abort.S, arm_exc_handler_high.c, arm_exc_handler_low.S, arm_exc_interrupt.S: Define CPU_HAS_HARDWARE_INTERRUPT_STACK to FALSE. Use ARM_MULTILIB_ARCH_V4 and ARM_MULTILIB_ARCH_V7M.
  • Property mode set to 100644
File size: 5.5 KB
Line 
1/*
2 * Copyright (c) 2011 Sebastian Huber.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Obere Lagerstr. 30
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.com/license/LICENSE.
13 *
14 * $Id$
15 */
16
17#ifndef RTEMS_SCORE_ARMV7M_H
18#define RTEMS_SCORE_ARMV7M_H
19
20#include <stdint.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif /* __cplusplus */
25
26typedef struct {
27  uint32_t reserved_0;
28  uint32_t ictr;
29  uint32_t actlr;
30  uint32_t reserved_1;
31} ARMV7M_Interrupt_type;
32
33typedef void (*ARMV7M_Exception_handler)(void);
34
35typedef struct {
36  uint32_t register_r0;
37  uint32_t register_r1;
38  uint32_t register_r2;
39  uint32_t register_r3;
40  uint32_t register_r12;
41  void *register_lr;
42  void *register_pc;
43  uint32_t register_xpsr;
44} ARMV7M_Exception_frame;
45
46typedef struct {
47  uint32_t cpuid;
48
49#define ARMV7M_SCB_ICSR_NMIPENDSET (1U << 31)
50#define ARMV7M_SCB_ICSR_PENDSVSET (1U << 28)
51#define ARMV7M_SCB_ICSR_PENDSVCLR (1U << 27)
52#define ARMV7M_SCB_ICSR_PENDSTSET (1U << 26)
53#define ARMV7M_SCB_ICSR_PENDSTCLR (1U << 25)
54#define ARMV7M_SCB_ICSR_ISRPREEMPT (1U << 23)
55#define ARMV7M_SCB_ICSR_ISRPENDING (1U << 22)
56#define ARMV7M_SCB_ICSR_VECTPENDING(reg) (((reg) >> 12) & 0x1ffU)
57#define ARMV7M_SCB_ICSR_RETTOBASE (1U << 11)
58#define ARMV7M_SCB_ICSR_VECTACTIVE(reg) ((reg) & 0x1ffU)
59  uint32_t icsr;
60
61  ARMV7M_Exception_handler *vtor;
62  uint32_t aircr;
63  uint32_t scr;
64  uint32_t ccr;
65  uint8_t shpr [12];
66  uint32_t shcsr;
67  uint32_t cfsr;
68  uint32_t hfsr;
69  uint32_t dfsr;
70  uint32_t mmfar;
71  uint32_t bfar;
72  uint32_t afsr;
73} ARMV7M_SCB;
74
75typedef struct {
76#define ARMV7M_SYSTICK_CSR_COUNTFLAG (1U << 16)
77#define ARMV7M_SYSTICK_CSR_CLKSOURCE (1U << 2)
78#define ARMV7M_SYSTICK_CSR_TICKINT (1U << 1)
79#define ARMV7M_SYSTICK_CSR_ENABLE (1U << 0)
80  uint32_t csr;
81
82  uint32_t rvr;
83  uint32_t cvr;
84
85#define ARMV7M_SYSTICK_CALIB_NOREF (1U << 31)
86#define ARMV7M_SYSTICK_CALIB_SKEW (1U << 30)
87#define ARMV7M_SYSTICK_CALIB_TENMS(reg) ((reg) & 0xffffffU)
88  uint32_t calib;
89} ARMV7M_Systick;
90
91typedef struct {
92  uint32_t iser [8];
93  uint32_t reserved_0 [24];
94  uint32_t icer [8];
95  uint32_t reserved_1 [24];
96  uint32_t ispr [8];
97  uint32_t reserved_2 [24];
98  uint32_t icpr [8];
99  uint32_t reserved_3 [24];
100  uint32_t iabr [8];
101  uint32_t reserved_4 [56];
102  uint8_t  ipr [240];
103  uint32_t reserved_5 [644];
104  uint32_t stir;
105} ARMV7M_NVIC;
106
107#define ARMV7M_SCS_BASE 0xe000e000
108#define ARMV7M_SYSTICK_BASE (ARMV7M_SCS_BASE + 0x10)
109#define ARMV7M_NVIC_BASE (ARMV7M_SCS_BASE + 0x100)
110#define ARMV7M_SCB_BASE (ARMV7M_SCS_BASE + 0xd00)
111
112#define _ARMV7M_Interrupt_type \
113  ((volatile ARMV7M_Interrupt_type *) ARMV7M_SCS_BASE)
114#define _ARMV7M_SCB \
115  ((volatile ARMV7M_SCB *) ARMV7M_SCB_BASE)
116#define _ARMV7M_Systick \
117  ((volatile ARMV7M_Systick *) ARMV7M_SYSTICK_BASE)
118#define _ARMV7M_NVIC \
119  ((volatile ARMV7M_NVIC *) ARMV7M_NVIC_BASE)
120
121#define ARMV7M_VECTOR_MSP 0
122#define ARMV7M_VECTOR_RESET 1
123#define ARMV7M_VECTOR_NMI 2
124#define ARMV7M_VECTOR_HARD_FAULT 3
125#define ARMV7M_VECTOR_MEM_MANAGE 4
126#define ARMV7M_VECTOR_BUS_FAULT 5
127#define ARMV7M_VECTOR_USAGE_FAULT 6
128#define ARMV7M_VECTOR_SVC 11
129#define ARMV7M_VECTOR_DEBUG_MONITOR 12
130#define ARMV7M_VECTOR_PENDSV 14
131#define ARMV7M_VECTOR_SYSTICK 15
132#define ARMV7M_VECTOR_IRQ(n) (16 + (n))
133
134static inline uint32_t _ARMV7M_Get_basepri(void)
135{
136  uint32_t val;
137  __asm__ volatile ("mrs %[val], basepri\n" : [val] "=&r" (val));
138  return val;
139}
140
141static inline void _ARMV7M_Set_basepri(uint32_t val)
142{
143  __asm__ volatile ("msr basepri, %[val]\n" : : [val] "r" (val));
144}
145
146static inline uint32_t _ARMV7M_Get_primask(void)
147{
148  uint32_t val;
149  __asm__ volatile ("mrs %[val], primask\n" : [val] "=&r" (val));
150  return val;
151}
152
153static inline void _ARMV7M_Set_primask(uint32_t val)
154{
155  __asm__ volatile ("msr primask, %[val]\n" : : [val] "r" (val));
156}
157
158static inline uint32_t _ARMV7M_Get_faultmask(void)
159{
160  uint32_t val;
161  __asm__ volatile ("mrs %[val], faultmask\n" : [val] "=&r" (val));
162  return val;
163}
164
165static inline void _ARMV7M_Set_faultmask(uint32_t val)
166{
167  __asm__ volatile ("msr faultmask, %[val]\n" : : [val] "r" (val));
168}
169
170static inline uint32_t _ARMV7M_Get_control(void)
171{
172  uint32_t val;
173  __asm__ volatile ("mrs %[val], control\n" : [val] "=&r" (val));
174  return val;
175}
176
177static inline void _ARMV7M_Set_control(uint32_t val)
178{
179  __asm__ volatile ("msr control, %[val]\n" : : [val] "r" (val));
180}
181
182static inline uint32_t _ARMV7M_Get_MSP(void)
183{
184  uint32_t val;
185  __asm__ volatile ("mrs %[val], msp\n" : [val] "=&r" (val));
186  return val;
187}
188
189static inline void _ARMV7M_Set_MSP(uint32_t val)
190{
191  __asm__ volatile ("msr msp, %[val]\n" : : [val] "r" (val));
192}
193
194static inline uint32_t _ARMV7M_Get_PSP(void)
195{
196  uint32_t val;
197  __asm__ volatile ("mrs %[val], psp\n" : [val] "=&r" (val));
198  return val;
199}
200
201static inline void _ARMV7M_Set_PSP(uint32_t val)
202{
203  __asm__ volatile ("msr psp, %[val]\n" : : [val] "r" (val));
204}
205
206static inline uint32_t _ARMV7M_Get_XPSR(void)
207{
208  uint32_t val;
209  __asm__ volatile ("mrs %[val], xpsr\n" : [val] "=&r" (val));
210  return val;
211}
212
213int _ARMV7M_Get_exception_priority( int vector );
214
215void _ARMV7M_Set_exception_priority( int vector, int priority );
216
217ARMV7M_Exception_handler _ARMV7M_Get_exception_handler( int index );
218
219void _ARMV7M_Set_exception_handler(
220  int index,
221  ARMV7M_Exception_handler handler
222);
223
224void _ARMV7M_Interrupt_service_enter( void );
225
226void _ARMV7M_Interrupt_service_leave( void );
227
228void _ARMV7M_Pendable_service_call( void );
229
230void _ARMV7M_Supervisor_call( void );
231
232#ifdef __cplusplus
233}
234#endif /* __cplusplus */
235
236#endif /* RTEMS_SCORE_ARMV7M_H */
Note: See TracBrowser for help on using the repository browser.