par.h 687 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef PAR_H
  7. #define PAR_H
  8. #include<arch_features.h>
  9. #include<lib/extensions/sysreg128.h>
  10. static inline uint64_t get_par_el1_pa(sysreg_t par)
  11. {
  12. uint64_t pa = par & UINT64_MAX;
  13. /* PA, bits [51:12] is Output address */
  14. uint64_t mask = PAR_ADDR_MASK;
  15. #if ENABLE_FEAT_D128
  16. /* If D128 is in use, the PA is in the upper 64-bit word of PAR_EL1 */
  17. if (is_feat_d128_supported() && (par & PAR_EL1_D128)) {
  18. pa = (par >> 64) & UINT64_MAX;
  19. /* PA, bits [55:12] is Output address */
  20. mask = PAR_D128_ADDR_MASK;
  21. }
  22. #endif
  23. return pa & mask;
  24. }
  25. #endif /* PAR_H */