Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 5 | */ |
| 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 Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 23 | #elif defined(IMAGE_BL2) && BL2_AT_EL3 |
| 24 | # define BL_STRING "BL2" |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 25 | #else |
| 26 | # error This image should not be printing errata status |
| 27 | #endif |
| 28 | |
| 29 | /* Errata format: BL stage, CPU, errata ID, message */ |
| 30 | #define ERRATA_FORMAT "%s: %s: errata workaround for %s was %s\n" |
| 31 | |
| 32 | /* |
| 33 | * Returns whether errata needs to be reported. Passed arguments are private to |
| 34 | * a CPU type. |
| 35 | */ |
| 36 | int 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 Wadekar | 66231d1 | 2017-06-07 09:57:42 -0700 | [diff] [blame] | 65 | void errata_print_msg(unsigned int status, const char *cpu, const char *id) |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 66 | { |
| 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 Cunado | 8a354f1 | 2017-06-21 16:52:45 +0100 | [diff] [blame] | 77 | assert(status < ARRAY_SIZE(errata_status_str)); |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 78 | 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 | } |