armv7m.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * (C) Copyright 2010,2011
  3. * Vladimir Khusainov, Emcraft Systems, vlad@emcraft.com
  4. *
  5. * (C) Copyright 2015
  6. * Kamil Lulko, <kamil.lulko@gmail.com>
  7. *
  8. * SPDX-License-Identifier: GPL-2.0+
  9. */
  10. #ifndef ARMV7M_H
  11. #define ARMV7M_H
  12. #if defined(__ASSEMBLY__)
  13. .syntax unified
  14. .thumb
  15. #endif
  16. #define V7M_SCB_BASE 0xE000ED00
  17. #define V7M_MPU_BASE 0xE000ED90
  18. #define V7M_SCB_VTOR 0x08
  19. #if !defined(__ASSEMBLY__)
  20. struct v7m_scb {
  21. uint32_t cpuid; /* CPUID Base Register */
  22. uint32_t icsr; /* Interrupt Control and State Register */
  23. uint32_t vtor; /* Vector Table Offset Register */
  24. uint32_t aircr; /* App Interrupt and Reset Control Register */
  25. };
  26. #define V7M_SCB ((struct v7m_scb *)V7M_SCB_BASE)
  27. #define V7M_AIRCR_VECTKEY 0x5fa
  28. #define V7M_AIRCR_VECTKEY_SHIFT 16
  29. #define V7M_AIRCR_ENDIAN (1 << 15)
  30. #define V7M_AIRCR_PRIGROUP_SHIFT 8
  31. #define V7M_AIRCR_PRIGROUP_MSK (0x7 << V7M_AIRCR_PRIGROUP_SHIFT)
  32. #define V7M_AIRCR_SYSRESET (1 << 2)
  33. #define V7M_ICSR_VECTACT_MSK 0xFF
  34. struct v7m_mpu {
  35. uint32_t type; /* Type Register */
  36. uint32_t ctrl; /* Control Register */
  37. uint32_t rnr; /* Region Number Register */
  38. uint32_t rbar; /* Region Base Address Register */
  39. uint32_t rasr; /* Region Attribute and Size Register */
  40. };
  41. #define V7M_MPU ((struct v7m_mpu *)V7M_MPU_BASE)
  42. #define V7M_MPU_CTRL_ENABLE (1 << 0)
  43. #define V7M_MPU_CTRL_HFNMIENA (1 << 1)
  44. #define V7M_MPU_RASR_EN (1 << 0)
  45. #define V7M_MPU_RASR_SIZE_BITS 1
  46. #define V7M_MPU_RASR_SIZE_4GB (31 << V7M_MPU_RASR_SIZE_BITS)
  47. #define V7M_MPU_RASR_AP_RW_RW (3 << 24)
  48. #endif /* !defined(__ASSEMBLY__) */
  49. #endif /* ARMV7M_H */