blob: c679336c1b654e0504b047152171f518eee11158 [file] [log] [blame]
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00001/*
Dimitris Papastamos84e02dc2018-01-16 10:42:20 +00002 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00005 */
6
7/* Runtime firmware routines to report errata status for the current CPU. */
8
9#include <arch_helpers.h>
10#include <assert.h>
11#include <cpu_data.h>
12#include <debug.h>
13#include <errata_report.h>
14#include <spinlock.h>
15#include <utils.h>
16
17#ifdef IMAGE_BL1
18# define BL_STRING "BL1"
19#elif defined(AARCH64) && defined(IMAGE_BL31)
20# define BL_STRING "BL31"
21#elif defined(AARCH32) && defined(IMAGE_BL32)
22# define BL_STRING "BL32"
Roberto Vargase0e99462017-10-30 14:43:43 +000023#elif defined(IMAGE_BL2) && BL2_AT_EL3
24# define BL_STRING "BL2"
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000025#else
26# error This image should not be printing errata status
27#endif
28
29/* Errata format: BL stage, CPU, errata ID, message */
Dimitris Papastamos84e02dc2018-01-16 10:42:20 +000030#define ERRATA_FORMAT "%s: %s: CPU workaround for %s was %s\n"
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000031
32/*
33 * Returns whether errata needs to be reported. Passed arguments are private to
34 * a CPU type.
35 */
36int errata_needs_reporting(spinlock_t *lock, uint32_t *reported)
37{
38 int report_now;
39
40 /* If already reported, return false. */
41 if (*reported)
42 return 0;
43
44 /*
45 * Acquire lock. Determine whether status needs reporting, and then mark
46 * report status to true.
47 */
48 spin_lock(lock);
49 report_now = !(*reported);
50 if (report_now)
51 *reported = 1;
52 spin_unlock(lock);
53
54 return report_now;
55}
56
57/*
58 * Print errata status message.
59 *
60 * Unknown: WARN
61 * Missing: WARN
62 * Applied: INFO
63 * Not applied: VERBOSE
64 */
Varun Wadekar66231d12017-06-07 09:57:42 -070065void errata_print_msg(unsigned int status, const char *cpu, const char *id)
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000066{
67 /* Errata status strings */
68 static const char *const errata_status_str[] = {
69 [ERRATA_NOT_APPLIES] = "not applied",
70 [ERRATA_APPLIES] = "applied",
71 [ERRATA_MISSING] = "missing!"
72 };
73 static const char *const __unused bl_str = BL_STRING;
74 const char *msg __unused;
75
76
David Cunado8a354f12017-06-21 16:52:45 +010077 assert(status < ARRAY_SIZE(errata_status_str));
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000078 assert(cpu);
79 assert(id);
80
81 msg = errata_status_str[status];
82
83 switch (status) {
84 case ERRATA_NOT_APPLIES:
85 VERBOSE(ERRATA_FORMAT, bl_str, cpu, id, msg);
86 break;
87
88 case ERRATA_APPLIES:
89 INFO(ERRATA_FORMAT, bl_str, cpu, id, msg);
90 break;
91
92 case ERRATA_MISSING:
93 WARN(ERRATA_FORMAT, bl_str, cpu, id, msg);
94 break;
95
96 default:
97 WARN(ERRATA_FORMAT, bl_str, cpu, id, "unknown");
98 break;
99 }
100}