tcr2.c 860 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2024, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <arch_features.h>
  8. #include <arch_helpers.h>
  9. #include <lib/extensions/tcr2.h>
  10. void tcr2_enable(cpu_context_t *ctx)
  11. {
  12. u_register_t reg;
  13. el3_state_t *state;
  14. state = get_el3state_ctx(ctx);
  15. /* Set the TCR2EN bit in SCR_EL3 to enable access to TCR2_EL1,
  16. * and TCR2_EL2 registers .
  17. */
  18. reg = read_ctx_reg(state, CTX_SCR_EL3);
  19. reg |= SCR_TCR2EN_BIT;
  20. write_ctx_reg(state, CTX_SCR_EL3, reg);
  21. }
  22. void tcr2_disable(cpu_context_t *ctx)
  23. {
  24. u_register_t reg;
  25. el3_state_t *state;
  26. state = get_el3state_ctx(ctx);
  27. /* Clear the TCR2EN bit in SCR_EL3 to disable access to TCR2_EL1,
  28. * and TCR2_EL2 registers .
  29. */
  30. reg = read_ctx_reg(state, CTX_SCR_EL3);
  31. reg &= ~SCR_TCR2EN_BIT;
  32. write_ctx_reg(state, CTX_SCR_EL3, reg);
  33. }