2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
10 #define ERR_HANDLER_VERSION 1U
12 /* Error record access mechanism */
13 #define ERR_ACCESS_SYSREG 0
14 #define ERR_ACCESS_MEMMAP 1
17 * Register all error records on the platform.
19 * This macro must be used in the same file as the array of error record info
20 * are declared. Only then would ARRAY_SIZE() yield a meaningful value.
22 #define REGISTER_ERR_RECORD_INFO(_records) \
23 const struct err_record_mapping err_record_mappings = { \
24 .err_records = (_records), \
25 .num_err_records = ARRAY_SIZE(_records), \
28 /* Error record info iterator */
29 #define for_each_err_record_info(_i, _info) \
30 for ((_i) = 0, (_info) = err_record_mappings.err_records; \
31 (_i) < err_record_mappings.num_err_records; \
34 #define ERR_RECORD_COMMON_(_probe, _handler, _aux) \
36 .handler = _handler, \
39 #define ERR_RECORD_SYSREG_V1(_idx_start, _num_idx, _probe, _handler, _aux) \
42 .sysreg.idx_start = _idx_start, \
43 .sysreg.num_idx = _num_idx, \
44 .access = ERR_ACCESS_SYSREG, \
45 ERR_RECORD_COMMON_(_probe, _handler, _aux) \
48 #define ERR_RECORD_MEMMAP_V1(_base_addr, _size_num_k, _probe, _handler, _aux) \
51 .memmap.base_addr = _base_addr, \
52 .memmap.size_num_k = _size_num_k, \
53 .access = ERR_ACCESS_MEMMAP, \
54 ERR_RECORD_COMMON_(_probe, _handler, _aux) \
58 * Macro to be used to name and declare an array of RAS interrupts along with
61 * This macro must be used in the same file as the array of interrupts are
62 * declared. Only then would ARRAY_SIZE() yield a meaningful value. Also, the
63 * array is expected to be sorted in the increasing order of interrupt number.
65 #define REGISTER_RAS_INTERRUPTS(_array) \
66 const struct ras_interrupt_mapping ras_interrupt_mappings = { \
68 .num_intrs = ARRAY_SIZE(_array), \
75 #include <lib/extensions/ras_arch.h>
77 struct err_record_info
;
79 struct ras_interrupt
{
80 /* Interrupt number, and the associated error record info */
81 unsigned int intr_number
;
82 struct err_record_info
*err_record
;
86 /* Function to probe a error record group for error */
87 typedef int (*err_record_probe_t
)(const struct err_record_info
*info
,
90 /* Data passed to error record group handler */
91 struct err_handler_data
{
92 /* Info passed on from top-level exception handler */
97 /* Data structure version */
100 /* Reason for EA: one the ERROR_* constants */
101 unsigned int ea_reason
;
104 * For EAs received at vector, the value read from ESR; for an EA
105 * synchronized by ESB, the value of DISR.
109 /* For errors signalled via. interrupt, the raw interrupt ID; otherwise, 0. */
110 unsigned int interrupt
;
113 /* Function to handle error from an error record group */
114 typedef int (*err_record_handler_t
)(const struct err_record_info
*info
,
115 int probe_data
, const struct err_handler_data
*const data
);
117 /* Error record information */
118 struct err_record_info
{
119 /* Function to probe error record group for errors */
120 err_record_probe_t probe
;
122 /* Function to handle error record group errors */
123 err_record_handler_t handler
;
125 /* Opaque group-specific data */
128 /* Additional information for Standard Error Records */
132 * For a group accessed via. memory-mapped register,
133 * base address of the page hosting error records, and
134 * the size of the record group.
138 /* Size of group in number of KBs */
139 unsigned int size_num_k
;
144 * For error records accessed via. system register, index of
147 unsigned int idx_start
;
148 unsigned int num_idx
;
152 /* Data structure version */
153 unsigned int version
;
155 /* Error record access mechanism */
156 unsigned int access
:1;
159 struct err_record_mapping
{
160 struct err_record_info
*err_records
;
161 size_t num_err_records
;
164 struct ras_interrupt_mapping
{
165 struct ras_interrupt
*intrs
;
169 extern const struct err_record_mapping err_record_mappings
;
170 extern const struct ras_interrupt_mapping ras_interrupt_mappings
;
174 * Helper functions to probe memory-mapped and system registers implemented in
175 * Standard Error Record format
177 static inline int ras_err_ser_probe_memmap(const struct err_record_info
*info
,
180 assert(info
->version
== ERR_HANDLER_VERSION
);
182 return ser_probe_memmap(info
->memmap
.base_addr
, info
->memmap
.size_num_k
,
186 static inline int ras_err_ser_probe_sysreg(const struct err_record_info
*info
,
189 assert(info
->version
== ERR_HANDLER_VERSION
);
191 return ser_probe_sysreg(info
->sysreg
.idx_start
, info
->sysreg
.num_idx
,
195 int ras_ea_handler(unsigned int ea_reason
, uint64_t syndrome
, void *cookie
,
196 void *handle
, uint64_t flags
);
199 #endif /* __ASSEMBLY__ */