blob: eeaa3425b890aabd0b39f743f8e6442adcc4b2f8 [file] [log] [blame]
Manish V Badarkheb6149692022-07-04 14:51:07 +01001/*
2 * Copyright (c) 2022 Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#include <stdint.h>
9
10#include <plat/common/platform.h>
11#include <platform_def.h>
12
13/*******************************************************************************
14 * Check passed region is within Non-Secure region of DRAM
15 ******************************************************************************/
16int plat_drtm_validate_ns_region(uintptr_t region_start,
17 size_t region_size)
18{
19 uintptr_t region_end = region_start + region_size - 1;
20
21 if (region_start >= region_end) {
22 return -1;
23 } else if ((region_start >= ARM_NS_DRAM1_BASE) &&
24 (region_start < (ARM_NS_DRAM1_BASE + ARM_NS_DRAM1_SIZE)) &&
25 (region_end >= ARM_NS_DRAM1_BASE) &&
26 (region_end < (ARM_NS_DRAM1_BASE + ARM_NS_DRAM1_SIZE))) {
27 return 0;
28 } else if ((region_start >= ARM_DRAM2_BASE) &&
29 (region_start < (ARM_DRAM2_BASE + ARM_DRAM2_SIZE)) &&
30 (region_end >= ARM_DRAM2_BASE) &&
31 (region_end < (ARM_DRAM2_BASE + ARM_DRAM2_SIZE))) {
32 return 0;
33 }
34
35 return -1;
36}