blob: 81d27ec20217c2ec4c5168411a2f862e798d8720 [file] [log] [blame]
Manish V Badarkhe39dd5552022-06-21 09:41:32 +01001/*
Manish V Badarkheff499f42024-07-29 09:15:37 +01002 * Copyright (c) 2022-2024 Arm Limited. All rights reserved.
Manish V Badarkhe39dd5552022-06-21 09:41:32 +01003 *
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
17uint64_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 Badarkheff499f42024-07-29 09:15:37 +010024 SMC_RET1(ctx, NOT_FOUND);
Manish V Badarkhe39dd5552022-06-21 09:41:32 +010025 }
26
27 SMC_RET1(ctx, SUCCESS);
28}
29
30uint64_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 Badarkheff499f42024-07-29 09:15:37 +010038 SMC_RET1(ctx, NOT_FOUND);
Manish V Badarkhe39dd5552022-06-21 09:41:32 +010039 }
40
41 SMC_RET2(ctx, SUCCESS, error_code);
42}
43
44void 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}