2 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
7 /* Runtime firmware routines to report errata status for the current CPU. */
12 #include <arch_helpers.h>
13 #include <common/debug.h>
14 #include <lib/cpus/errata_report.h>
15 #include <lib/el3_runtime/cpu_data.h>
16 #include <lib/spinlock.h>
17 #include <lib/utils.h>
20 # define BL_STRING "BL1"
21 #elif defined(AARCH64) && defined(IMAGE_BL31)
22 # define BL_STRING "BL31"
23 #elif defined(AARCH32) && defined(IMAGE_BL32)
24 # define BL_STRING "BL32"
25 #elif defined(IMAGE_BL2) && BL2_AT_EL3
26 # define BL_STRING "BL2"
28 # error This image should not be printing errata status
31 /* Errata format: BL stage, CPU, errata ID, message */
32 #define ERRATA_FORMAT "%s: %s: CPU workaround for %s was %s\n"
35 * Returns whether errata needs to be reported. Passed arguments are private to
38 int errata_needs_reporting(spinlock_t
*lock
, uint32_t *reported
)
42 /* If already reported, return false. */
47 * Acquire lock. Determine whether status needs reporting, and then mark
48 * report status to true.
51 report_now
= (*reported
== 0U);
60 * Print errata status message.
65 * Not applied: VERBOSE
67 void errata_print_msg(unsigned int status
, const char *cpu
, const char *id
)
69 /* Errata status strings */
70 static const char *const errata_status_str
[] = {
71 [ERRATA_NOT_APPLIES
] = "not applied",
72 [ERRATA_APPLIES
] = "applied",
73 [ERRATA_MISSING
] = "missing!"
75 static const char *const __unused bl_str
= BL_STRING
;
76 const char *msg __unused
;
79 assert(status
< ARRAY_SIZE(errata_status_str
));
83 msg
= errata_status_str
[status
];
86 case ERRATA_NOT_APPLIES
:
87 VERBOSE(ERRATA_FORMAT
, bl_str
, cpu
, id
, msg
);
91 INFO(ERRATA_FORMAT
, bl_str
, cpu
, id
, msg
);
95 WARN(ERRATA_FORMAT
, bl_str
, cpu
, id
, msg
);
99 WARN(ERRATA_FORMAT
, bl_str
, cpu
, id
, "unknown");