11436e37dSManish V Badarkhe /* 2*30bbc4faSBoyan Karatotev * Copyright (c) 2022-2025 Arm Limited. All rights reserved. 31436e37dSManish V Badarkhe * 41436e37dSManish V Badarkhe * SPDX-License-Identifier: BSD-3-Clause 51436e37dSManish V Badarkhe * 61436e37dSManish V Badarkhe * DRTM support for DRTM error remediation. 71436e37dSManish V Badarkhe * 81436e37dSManish V Badarkhe */ 91436e37dSManish V Badarkhe #include <inttypes.h> 101436e37dSManish V Badarkhe #include <stdint.h> 111436e37dSManish V Badarkhe 121436e37dSManish V Badarkhe #include <common/debug.h> 131436e37dSManish V Badarkhe #include <common/runtime_svc.h> 141436e37dSManish V Badarkhe #include "drtm_main.h" 151436e37dSManish V Badarkhe #include <plat/common/platform.h> 161436e37dSManish V Badarkhe 171436e37dSManish V Badarkhe uint64_t drtm_set_error(uint64_t x1, void *ctx) 181436e37dSManish V Badarkhe { 191436e37dSManish V Badarkhe int rc; 201436e37dSManish V Badarkhe 211436e37dSManish V Badarkhe rc = plat_set_drtm_error(x1); 221436e37dSManish V Badarkhe 231436e37dSManish V Badarkhe if (rc != 0) { 245e1fa574SManish V Badarkhe SMC_RET1(ctx, NOT_FOUND); 251436e37dSManish V Badarkhe } 261436e37dSManish V Badarkhe 271436e37dSManish V Badarkhe SMC_RET1(ctx, SUCCESS); 281436e37dSManish V Badarkhe } 291436e37dSManish V Badarkhe 301436e37dSManish V Badarkhe uint64_t drtm_get_error(void *ctx) 311436e37dSManish V Badarkhe { 321436e37dSManish V Badarkhe uint64_t error_code; 331436e37dSManish V Badarkhe int rc; 341436e37dSManish V Badarkhe 351436e37dSManish V Badarkhe rc = plat_get_drtm_error(&error_code); 361436e37dSManish V Badarkhe 371436e37dSManish V Badarkhe if (rc != 0) { 385e1fa574SManish V Badarkhe SMC_RET1(ctx, NOT_FOUND); 391436e37dSManish V Badarkhe } 401436e37dSManish V Badarkhe 411436e37dSManish V Badarkhe SMC_RET2(ctx, SUCCESS, error_code); 421436e37dSManish V Badarkhe } 431436e37dSManish V Badarkhe 441436e37dSManish V Badarkhe void drtm_enter_remediation(uint64_t err_code, const char *err_str) 451436e37dSManish V Badarkhe { 461436e37dSManish V Badarkhe int rc = plat_set_drtm_error(err_code); 471436e37dSManish V Badarkhe 481436e37dSManish V Badarkhe if (rc != 0) { 491436e37dSManish V Badarkhe ERROR("%s(): drtm_error_set() failed unexpectedly rc=%d\n", 501436e37dSManish V Badarkhe __func__, rc); 511436e37dSManish V Badarkhe panic(); 521436e37dSManish V Badarkhe } 531436e37dSManish V Badarkhe 541436e37dSManish V Badarkhe ERROR("DRTM: entering remediation of error:\n%" PRIu64 "\t\'%s\'\n", 551436e37dSManish V Badarkhe err_code, err_str); 561436e37dSManish V Badarkhe 571436e37dSManish V Badarkhe ERROR("%s(): system reset is not yet supported\n", __func__); 58*30bbc4faSBoyan Karatotev panic(); 591436e37dSManish V Badarkhe } 60