sysreg.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Macros for accessing system registers with older binutils.
  3. *
  4. * Copyright (C) 2014 ARM Ltd.
  5. * Author: Catalin Marinas <catalin.marinas@arm.com>
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __ASM_SYSREG_H
  20. #define __ASM_SYSREG_H
  21. #define sys_reg(op0, op1, crn, crm, op2) \
  22. ((((op0)-2)<<19)|((op1)<<16)|((crn)<<12)|((crm)<<8)|((op2)<<5))
  23. #ifdef __ASSEMBLY__
  24. .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30
  25. .equ __reg_num_x\num, \num
  26. .endr
  27. .equ __reg_num_xzr, 31
  28. .macro mrs_s, rt, sreg
  29. .inst 0xd5300000|(\sreg)|(__reg_num_\rt)
  30. .endm
  31. .macro msr_s, sreg, rt
  32. .inst 0xd5100000|(\sreg)|(__reg_num_\rt)
  33. .endm
  34. #else
  35. asm(
  36. " .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30\n"
  37. " .equ __reg_num_x\\num, \\num\n"
  38. " .endr\n"
  39. " .equ __reg_num_xzr, 31\n"
  40. "\n"
  41. " .macro mrs_s, rt, sreg\n"
  42. " .inst 0xd5300000|(\\sreg)|(__reg_num_\\rt)\n"
  43. " .endm\n"
  44. "\n"
  45. " .macro msr_s, sreg, rt\n"
  46. " .inst 0xd5100000|(\\sreg)|(__reg_num_\\rt)\n"
  47. " .endm\n"
  48. );
  49. #endif
  50. #endif /* __ASM_SYSREG_H */