Manish V Badarkhe | 39dd555 | 2022-06-21 09:41:32 +0100 | [diff] [blame] | 1 | /* |
Manish V Badarkhe | ff499f4 | 2024-07-29 09:15:37 +0100 | [diff] [blame] | 2 | * Copyright (c) 2022-2024 Arm Limited. All rights reserved. |
Manish V Badarkhe | 39dd555 | 2022-06-21 09:41:32 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | * DRTM support for DRTM error remediation. |
| 7 | * |
| 8 | */ |
| 9 | #include <inttypes.h> |
| 10 | #include <stdint.h> |
| 11 | |
| 12 | #include <common/debug.h> |
| 13 | #include <common/runtime_svc.h> |
| 14 | #include "drtm_main.h" |
| 15 | #include <plat/common/platform.h> |
| 16 | |
| 17 | uint64_t drtm_set_error(uint64_t x1, void *ctx) |
| 18 | { |
| 19 | int rc; |
| 20 | |
| 21 | rc = plat_set_drtm_error(x1); |
| 22 | |
| 23 | if (rc != 0) { |
Manish V Badarkhe | ff499f4 | 2024-07-29 09:15:37 +0100 | [diff] [blame] | 24 | SMC_RET1(ctx, NOT_FOUND); |
Manish V Badarkhe | 39dd555 | 2022-06-21 09:41:32 +0100 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | SMC_RET1(ctx, SUCCESS); |
| 28 | } |
| 29 | |
| 30 | uint64_t drtm_get_error(void *ctx) |
| 31 | { |
| 32 | uint64_t error_code; |
| 33 | int rc; |
| 34 | |
| 35 | rc = plat_get_drtm_error(&error_code); |
| 36 | |
| 37 | if (rc != 0) { |
Manish V Badarkhe | ff499f4 | 2024-07-29 09:15:37 +0100 | [diff] [blame] | 38 | SMC_RET1(ctx, NOT_FOUND); |
Manish V Badarkhe | 39dd555 | 2022-06-21 09:41:32 +0100 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | SMC_RET2(ctx, SUCCESS, error_code); |
| 42 | } |
| 43 | |
| 44 | void drtm_enter_remediation(uint64_t err_code, const char *err_str) |
| 45 | { |
| 46 | int rc = plat_set_drtm_error(err_code); |
| 47 | |
| 48 | if (rc != 0) { |
| 49 | ERROR("%s(): drtm_error_set() failed unexpectedly rc=%d\n", |
| 50 | __func__, rc); |
| 51 | panic(); |
| 52 | } |
| 53 | |
| 54 | ERROR("DRTM: entering remediation of error:\n%" PRIu64 "\t\'%s\'\n", |
| 55 | err_code, err_str); |
| 56 | |
| 57 | ERROR("%s(): system reset is not yet supported\n", __func__); |
| 58 | plat_system_reset(); |
| 59 | } |