• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2017-2018, 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 
10 #include <lib/utils.h>
11 
12 #include "psci_private.h"
13 
psci_mem_protect(unsigned int enable)14 u_register_t psci_mem_protect(unsigned int enable)
15 {
16 	int val;
17 
18 	assert(psci_plat_pm_ops->read_mem_protect != NULL);
19 	assert(psci_plat_pm_ops->write_mem_protect != NULL);
20 
21 	if (psci_plat_pm_ops->read_mem_protect(&val) < 0)
22 		return (u_register_t) PSCI_E_NOT_SUPPORTED;
23 	if (psci_plat_pm_ops->write_mem_protect(enable) < 0)
24 		return (u_register_t) PSCI_E_NOT_SUPPORTED;
25 
26 	return (val != 0) ? 1U : 0U;
27 }
28 
psci_mem_chk_range(uintptr_t base,u_register_t length)29 u_register_t psci_mem_chk_range(uintptr_t base, u_register_t length)
30 {
31 	int ret;
32 
33 	assert(psci_plat_pm_ops->mem_protect_chk != NULL);
34 
35 	if ((length == 0U) || check_uptr_overflow(base, length - 1U))
36 		return (u_register_t) PSCI_E_DENIED;
37 
38 	ret = psci_plat_pm_ops->mem_protect_chk(base, length);
39 	return (ret < 0) ?
40 	       (u_register_t) PSCI_E_DENIED : (u_register_t) PSCI_E_SUCCESS;
41 }
42