fvp_drtm_addr.c 1.0 KB

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