RTEMS 7.0-rc1
Loading...
Searching...
No Matches
vectors.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0+-with-RTEMS-exception */
2
12/*
13 * Copyright (C) 1999 Eric Valette (eric.valette@free.fr)
14 * Canon Centre Recherche France.
15 *
16 * Copyright (C) 2007 Till Straumann <strauman@slac.stanford.edu>
17 *
18 * Copyright (C) 2009 embedded brains GmbH & Co. KG
19 *
20 * Enhanced by Jay Kulpinski <jskulpin@eng01.gdds.com>
21 * to support 603, 603e, 604, 604e exceptions
22 *
23 * Moved to "libcpu/powerpc/new-exceptions" and consolidated
24 * by Thomas Doerfler <Thomas.Doerfler@embedded-brains.de>
25 * to be common for all PPCs with new exceptions.
26 *
27 * Derived from file "libcpu/powerpc/new-exceptions/raw_exception.h".
28 * Derived from file "libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_bspsupp.h".
29 *
30 * The license and distribution terms for this file may be
31 * found in the file LICENSE in this distribution or at
32 * http://www.rtems.org/license/LICENSE.
33 */
34
35/* DO NOT INTRODUCE #ifdef <cpu_flavor> in this file */
36
37#ifndef LIBCPU_VECTORS_H
38#define LIBCPU_VECTORS_H
39
40#include <bspopts.h>
41#include <rtems/score/cpuimpl.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
56#define ASM_RESET_VECTOR 0x01
57#define ASM_MACH_VECTOR 0x02
58#define ASM_PROT_VECTOR 0x03
59#define ASM_ISI_VECTOR 0x04
60#define ASM_EXT_VECTOR 0x05
61#define ASM_ALIGN_VECTOR 0x06
62#define ASM_PROG_VECTOR 0x07
63#define ASM_FLOAT_VECTOR 0x08
64#define ASM_DEC_VECTOR 0x09
65#define ASM_SYS_VECTOR 0x0C
66#define ASM_TRACE_VECTOR 0x0D
67
68#define ASM_PPC405_APU_UNAVAIL_VECTOR ASM_60X_VEC_ASSIST_VECTOR
69
70#define ASM_8XX_FLOATASSIST_VECTOR 0x0E
71#define ASM_8XX_SOFTEMUL_VECTOR 0x10
72#define ASM_8XX_ITLBMISS_VECTOR 0x11
73#define ASM_8XX_DTLBMISS_VECTOR 0x12
74#define ASM_8XX_ITLBERROR_VECTOR 0x13
75#define ASM_8XX_DTLBERROR_VECTOR 0x14
76#define ASM_8XX_DBREAK_VECTOR 0x1C
77#define ASM_8XX_IBREAK_VECTOR 0x1D
78#define ASM_8XX_PERIFBREAK_VECTOR 0x1E
79#define ASM_8XX_DEVPORT_VECTOR 0x1F
80
81#define ASM_5XX_FLOATASSIST_VECTOR 0x0E
82#define ASM_5XX_SOFTEMUL_VECTOR 0x10
83#define ASM_5XX_IPROT_VECTOR 0x13
84#define ASM_5XX_DPROT_VECTOR 0x14
85#define ASM_5XX_DBREAK_VECTOR 0x1C
86#define ASM_5XX_IBREAK_VECTOR 0x1D
87#define ASM_5XX_MEBREAK_VECTOR 0x1E
88#define ASM_5XX_NMEBREAK_VECTOR 0x1F
89
90#define ASM_60X_VEC_VECTOR 0x0A
91#define ASM_60X_PERFMON_VECTOR 0x0F
92#define ASM_60X_IMISS_VECTOR 0x10
93#define ASM_60X_DLMISS_VECTOR 0x11
94#define ASM_60X_DSMISS_VECTOR 0x12
95#define ASM_60X_ADDR_VECTOR 0x13
96#define ASM_60X_SYSMGMT_VECTOR 0x14
97#define ASM_60X_VEC_ASSIST_VECTOR 0x16
98#define ASM_60X_ITM_VECTOR 0x17
99
100/* Book E */
101#define ASM_BOOKE_CRIT_VECTOR 0x01
102/* We could use the std. decrementer vector # on bookE, too,
103 * but the bookE decrementer has slightly different semantics
104 * so we use a different vector (which happens to be
105 * the PIT vector on the 405 which is like the booke decrementer)
106 */
107#define ASM_BOOKE_DEC_VECTOR 0x10
108#define ASM_BOOKE_ITLBMISS_VECTOR 0x11
109#define ASM_BOOKE_DTLBMISS_VECTOR 0x12
110#define ASM_BOOKE_FIT_VECTOR 0x13
111#define ASM_BOOKE_WDOG_VECTOR 0x14
112#define ASM_BOOKE_APU_VECTOR 0x18
113#define ASM_BOOKE_DEBUG_VECTOR ASM_TRACE_VECTOR
114
115/* e200 and e500 */
116#define ASM_E500_SPE_UNAVAILABLE_VECTOR ASM_60X_VEC_VECTOR
117#define ASM_E500_EMB_FP_DATA_VECTOR 0x19
118#define ASM_E500_EMB_FP_ROUND_VECTOR 0x1A
119#define ASM_E500_PERFMON_VECTOR ASM_60X_PERFMON_VECTOR
120
121/* e300 */
122#define ASM_E300_CRIT_VECTOR 0x0A
123#define ASM_E300_PERFMON_VECTOR ASM_60X_PERFMON_VECTOR
124#define ASM_E300_IMISS_VECTOR ASM_60X_IMISS_VECTOR /* Special case: Shadowed GPRs */
125#define ASM_E300_DLMISS_VECTOR ASM_60X_DLMISS_VECTOR /* Special case: Shadowed GPRs */
126#define ASM_E300_DSMISS_VECTOR ASM_60X_DSMISS_VECTOR /* Special case: Shadowed GPRs */
127#define ASM_E300_ADDR_VECTOR ASM_60X_ADDR_VECTOR
128#define ASM_E300_SYSMGMT_VECTOR ASM_60X_SYSMGMT_VECTOR
129
130/*
131 * If you change that number make sure to adjust the wrapper code in ppc_exc.S
132 * and that ppc_exc_handler_table will be correctly initialized.
133 */
134#define LAST_VALID_EXC 0x1F
135
136/* DO NOT USE -- this symbol is DEPRECATED
137 * (only used by libbsp/shared/vectors/vectors.S
138 * which should not be used by new BSPs).
139 */
140#define ASM_60X_VEC_VECTOR_OFFSET 0xf20
141
142#define ASM_PPC405_FIT_VECTOR_OFFSET 0x1010
143#define ASM_PPC405_WDOG_VECTOR_OFFSET 0x1020
144#define ASM_PPC405_TRACE_VECTOR_OFFSET 0x2000
145
156/*
157 * The callee (high level exception code written in C)
158 * will store the Link Registers (return address) at entry r1 + 4 !!!.
159 * So let room for it!!!.
160 */
161#define LINK_REGISTER_CALLEE_UPDATE_ROOM 4
162
163#define EXC_GENERIC_SIZE (PPC_EXC_FRAME_SIZE + PPC_STACK_RED_ZONE_SIZE)
164
165#define PPC_EXC_INTERRUPT_FRAME_SIZE CPU_INTERRUPT_FRAME_SIZE
166
167#if defined(__ALTIVEC__) && !defined(PPC_MULTILIB_ALTIVEC)
168#define EXC_VEC_OFFSET EXC_GENERIC_SIZE
169#ifndef PPC_CACHE_ALIGNMENT
170#error "Missing include file!"
171#endif
172/* 20 volatile registers
173 * + cache-aligned area for vcsr, vrsave
174 * + area for alignment
175 */
176#define EXC_VEC_SIZE (16*20 + 2*PPC_CACHE_ALIGNMENT)
177#else
178#define EXC_VEC_SIZE (0)
179#endif
180
181/*
182 * maintain the EABI requested 8 bytes aligment
183 * As SVR4 ABI requires 16, make it 16 (as some
184 * exception may need more registers to be processed...)
185 */
186#define EXCEPTION_FRAME_END (EXC_GENERIC_SIZE + EXC_VEC_SIZE)
187
190#ifndef ASM
191
199
212
217
218void BSP_printStackTrace(const BSP_Exception_frame *excPtr);
219
228typedef enum {
229 PPC_EXC_INVALID = 0,
230 PPC_EXC_ASYNC = 1,
231 PPC_EXC_CLASSIC = 2,
232 PPC_EXC_CLASSIC_ASYNC = PPC_EXC_CLASSIC | PPC_EXC_ASYNC,
233 PPC_EXC_405_CRITICAL = 4,
234 PPC_EXC_405_CRITICAL_ASYNC = PPC_EXC_405_CRITICAL | PPC_EXC_ASYNC,
235 PPC_EXC_BOOKE_CRITICAL = 6,
236 PPC_EXC_BOOKE_CRITICAL_ASYNC = PPC_EXC_BOOKE_CRITICAL | PPC_EXC_ASYNC,
237 PPC_EXC_E500_MACHCHK = 8,
238 PPC_EXC_E500_MACHCHK_ASYNC = PPC_EXC_E500_MACHCHK | PPC_EXC_ASYNC,
239 PPC_EXC_NAKED = 10
241
245typedef uint8_t ppc_exc_categories [LAST_VALID_EXC + 1];
246
247static inline bool ppc_exc_is_valid_category(ppc_exc_category category)
248{
249 return (unsigned) category <= (unsigned) PPC_EXC_NAKED;
250}
251
258void *ppc_exc_vector_address(unsigned vector, void *vector_base);
259
264const ppc_exc_categories *ppc_exc_categories_for_cpu(ppc_cpu_id_t cpu);
265
270static inline const ppc_exc_categories *ppc_exc_current_categories(void)
271{
272 return ppc_exc_categories_for_cpu(ppc_cpu_current());
273}
274
280 const ppc_exc_categories *categories,
281 unsigned vector
282);
283
298 unsigned vector,
299 void *vector_base,
300 ppc_exc_category category,
301 uint32_t *prologue,
302 size_t *prologue_size
303);
304
305static inline void ppc_exc_initialize_interrupt_stack(uintptr_t stack_begin)
306{
307 uintptr_t stack_size = rtems_configuration_get_interrupt_stack_size();
308 uintptr_t stack_end = stack_begin + stack_size;
309 uintptr_t stack_pointer = stack_end - PPC_MINIMUM_STACK_FRAME_SIZE;
310
311 /* Ensure proper interrupt stack alignment */
312 stack_pointer &= ~((uintptr_t) CPU_STACK_ALIGNMENT - 1);
313
314 /* Tag interrupt stack bottom */
315 *(uint32_t *) stack_pointer = 0;
316
317 /* Move interrupt stack values to special purpose registers */
318 PPC_SET_SPECIAL_PURPOSE_REGISTER(SPRG1, stack_pointer);
319 PPC_SET_SPECIAL_PURPOSE_REGISTER(SPRG2, stack_begin);
320}
321
328 uintptr_t interrupt_stack_begin,
329 void *vector_base
330);
331
345static inline void ppc_exc_initialize(void)
346{
348 (uintptr_t) _ISR_Stack_area_begin,
349 NULL
350 );
351}
352
361typedef int (*ppc_exc_handler_t)(BSP_Exception_frame *f, unsigned vector);
362
368int ppc_exc_handler_default(BSP_Exception_frame *f, unsigned int vector);
369
370#ifndef PPC_EXC_CONFIG_BOOKE_ONLY
371
382extern uint32_t ppc_exc_msr_bits;
383
384#endif /* PPC_EXC_CONFIG_BOOKE_ONLY */
385
399extern uint32_t ppc_exc_cache_wb_check;
400
401#ifndef PPC_EXC_CONFIG_USE_FIXED_HANDLER
405 extern ppc_exc_handler_t ppc_exc_handler_table [LAST_VALID_EXC + 1];
406
411#else /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
415 extern const ppc_exc_handler_t ppc_exc_handler_table [LAST_VALID_EXC + 1];
416
420 void bsp_interrupt_dispatch(uintptr_t exception_number);
421#endif /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
422
446
451
462extern uint32_t (*ppc_exc_get_DAR)(void);
463
464void
465ppc_exc_wrapup(BSP_Exception_frame *f);
466
473int ppc_exc_alignment_handler(BSP_Exception_frame *frame, unsigned excNum);
474
477/*
478 * Compatibility with pc386
479 */
480typedef exception_handler_t cpuExcHandlerType;
481
482#endif /* ASM */
483
484#ifdef __cplusplus
485}
486#endif
487
488#endif /* LIBCPU_VECTORS_H */
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
#define rtems_configuration_get_interrupt_stack_size()
Gets the interrupt stack size in bytes of this application.
Definition: config.h:440
#define PPC_SET_SPECIAL_PURPOSE_REGISTER(spr, val)
Sets the Special Purpose Register with number spr to the value in val.
Definition: powerpc-utility.h:590
char _ISR_Stack_area_begin[]
The interrupt stack area begin.
uint32_t(* ppc_exc_get_DAR)(void)
Function for DAR access.
Definition: ppc_exc_print.c:67
void ppc_exc_initialize_with_vector_base(uintptr_t interrupt_stack_begin, void *vector_base)
Initializes the exception handling.
Definition: ppc_exc_initialize.c:82
uint8_t ppc_exc_categories[LAST_VALID_EXC+1]
Categorie set type.
Definition: vectors.h:245
ppc_exc_handler_t ppc_exc_handler_table[LAST_VALID_EXC+1]
High-level exception handler table.
Definition: ppc_exc_hdl.c:60
int(* ppc_exc_handler_t)(BSP_Exception_frame *f, unsigned vector)
High-level exception handler type.
Definition: vectors.h:361
uint32_t ppc_exc_cache_wb_check
Cache write back check flag.
Definition: ppc_exc_initialize.c:32
ppc_exc_category ppc_exc_category_for_vector(const ppc_exc_categories *categories, unsigned vector)
Returns the category for the vector vector using the category set categories.
Definition: ppc_exc_categories.c:320
void * ppc_exc_vector_address(unsigned vector, void *vector_base)
Returns the entry address of the vector.
Definition: ppc_exc_address.c:62
int ppc_exc_handler_default(BSP_Exception_frame *f, unsigned int vector)
Default high-level exception handler.
Definition: ppc_exc_hdl.c:47
void C_exception_handler(BSP_Exception_frame *excPtr)
Default global exception handler.
Definition: ppc_exc_global_handler.c:24
exception_handler_t globalExceptHdl
Global exception handler.
Definition: ppc_exc_hdl.c:57
ppc_exc_handler_t ppc_exc_get_handler(unsigned vector)
Returns the currently active high-level exception handler.
Definition: ppc_exc_hdl.c:66
rtems_status_code ppc_exc_set_handler(unsigned vector, ppc_exc_handler_t hdl)
Set high-level exception handler.
Definition: ppc_exc_hdl.c:78
ppc_exc_category
Exception categories.
Definition: vectors.h:228
rtems_status_code ppc_exc_make_prologue(unsigned vector, void *vector_base, ppc_exc_category category, uint32_t *prologue, size_t *prologue_size)
Makes a minimal prologue for the vector vector with the category category.
Definition: ppc_exc_prologue.c:120
void(* exception_handler_t)(BSP_Exception_frame *)
Global exception handler type.
Definition: vectors.h:211
const ppc_exc_categories * ppc_exc_categories_for_cpu(ppc_cpu_id_t cpu)
Returns the category set for a CPU of type cpu, or NULL if there is no category set available for thi...
Definition: ppc_exc_categories.c:254
int ppc_exc_alignment_handler(BSP_Exception_frame *frame, unsigned excNum)
Standard aligment handler.
Definition: ppc_exc_alignment.c:31
uint32_t ppc_exc_msr_bits
Bits for MSR update.
Definition: ppc_exc_hdl.c:43
General purpose assembler macros, linker command file support and some inline functions for direct re...
The set of registers that specifies the complete processor state.
Definition: cpu.h:500