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