1 /* 2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <assert.h> 8 #include <limits.h> 9 #include <utils.h> 10 #include "psci_private.h" 11 psci_mem_protect(unsigned int enable)12int psci_mem_protect(unsigned int enable) 13 { 14 int val; 15 16 assert(psci_plat_pm_ops->read_mem_protect); 17 assert(psci_plat_pm_ops->write_mem_protect); 18 19 if (psci_plat_pm_ops->read_mem_protect(&val) < 0) 20 return PSCI_E_NOT_SUPPORTED; 21 if (psci_plat_pm_ops->write_mem_protect(enable) < 0) 22 return PSCI_E_NOT_SUPPORTED; 23 24 return val != 0; 25 } 26 psci_mem_chk_range(uintptr_t base,u_register_t length)27int psci_mem_chk_range(uintptr_t base, u_register_t length) 28 { 29 int ret; 30 31 assert(psci_plat_pm_ops->mem_protect_chk); 32 33 if (length == 0 || check_uptr_overflow(base, length-1)) 34 return PSCI_E_DENIED; 35 36 ret = psci_plat_pm_ops->mem_protect_chk(base, length); 37 return (ret < 0) ? PSCI_E_DENIED : PSCI_E_SUCCESS; 38 } 39