You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

174 lines
5.2 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2009 by David Brownell *
  3. * *
  4. * This program is free software; you can redistribute it and/or modify *
  5. * it under the terms of the GNU General Public License as published by *
  6. * the Free Software Foundation; either version 2 of the License, or *
  7. * (at your option) any later version. *
  8. * *
  9. * This program is distributed in the hope that it will be useful, *
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12. * GNU General Public License for more details. *
  13. * *
  14. * You should have received a copy of the GNU General Public License *
  15. * along with this program; if not, write to the *
  16. * Free Software Foundation, Inc., *
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
  18. ***************************************************************************/
  19. #ifndef ARMV7A_H
  20. #define ARMV7A_H
  21. #include "arm_adi_v5.h"
  22. #include "arm.h"
  23. #include "armv4_5_mmu.h"
  24. #include "armv4_5_cache.h"
  25. #include "arm_dpm.h"
  26. enum {
  27. ARM_PC = 15,
  28. ARM_CPSR = 16
  29. };
  30. #define ARMV7_COMMON_MAGIC 0x0A450999
  31. /* VA to PA translation operations opc2 values*/
  32. #define V2PCWPR 0
  33. #define V2PCWPW 1
  34. #define V2PCWUR 2
  35. #define V2PCWUW 3
  36. #define V2POWPR 4
  37. #define V2POWPW 5
  38. #define V2POWUR 6
  39. #define V2POWUW 7
  40. /* L210/L220 cache controller support */
  41. struct armv7a_l2x_cache {
  42. uint32_t base;
  43. uint32_t way;
  44. };
  45. struct armv7a_cachesize {
  46. uint32_t level_num;
  47. /* cache dimensionning */
  48. uint32_t linelen;
  49. uint32_t associativity;
  50. uint32_t nsets;
  51. uint32_t cachesize;
  52. /* info for set way operation on cache */
  53. uint32_t index;
  54. uint32_t index_shift;
  55. uint32_t way;
  56. uint32_t way_shift;
  57. };
  58. struct armv7a_cache_common {
  59. int ctype;
  60. struct armv7a_cachesize d_u_size; /* data cache */
  61. struct armv7a_cachesize i_size; /* instruction cache */
  62. int i_cache_enabled;
  63. int d_u_cache_enabled;
  64. /* l2 external unified cache if some */
  65. void *l2_cache;
  66. int (*flush_all_data_cache)(struct target *target);
  67. int (*display_cache_info)(struct command_context *cmd_ctx,
  68. struct armv7a_cache_common *armv7a_cache);
  69. };
  70. struct armv7a_mmu_common {
  71. /* following field mmu working way */
  72. int32_t ttbr1_used; /* -1 not initialized, 0 no ttbr1 1 ttbr1 used and */
  73. uint32_t ttbr0_mask;/* masked to be used */
  74. uint32_t os_border;
  75. int (*read_physical_memory)(struct target *target, uint32_t address, uint32_t size,
  76. uint32_t count, uint8_t *buffer);
  77. struct armv7a_cache_common armv7a_cache;
  78. uint32_t mmu_enabled;
  79. };
  80. struct armv7a_common {
  81. struct arm arm;
  82. int common_magic;
  83. struct reg_cache *core_cache;
  84. struct adiv5_dap dap;
  85. /* Core Debug Unit */
  86. struct arm_dpm dpm;
  87. uint32_t debug_base;
  88. uint8_t debug_ap;
  89. uint8_t memory_ap;
  90. bool memory_ap_available;
  91. /* mdir */
  92. uint8_t multi_processor_system;
  93. uint8_t cluster_id;
  94. uint8_t cpu_id;
  95. bool is_armv7r;
  96. /* cache specific to V7 Memory Management Unit compatible with v4_5*/
  97. struct armv7a_mmu_common armv7a_mmu;
  98. int (*examine_debug_reason)(struct target *target);
  99. int (*post_debug_entry)(struct target *target);
  100. void (*pre_restore_context)(struct target *target);
  101. };
  102. static inline struct armv7a_common *
  103. target_to_armv7a(struct target *target)
  104. {
  105. return container_of(target->arch_info, struct armv7a_common, arm);
  106. }
  107. /* register offsets from armv7a.debug_base */
  108. /* See ARMv7a arch spec section C10.2 */
  109. #define CPUDBG_DIDR 0x000
  110. /* See ARMv7a arch spec section C10.3 */
  111. #define CPUDBG_WFAR 0x018
  112. /* PCSR at 0x084 -or- 0x0a0 -or- both ... based on flags in DIDR */
  113. #define CPUDBG_DSCR 0x088
  114. #define CPUDBG_DRCR 0x090
  115. #define CPUDBG_PRCR 0x310
  116. #define CPUDBG_PRSR 0x314
  117. /* See ARMv7a arch spec section C10.4 */
  118. #define CPUDBG_DTRRX 0x080
  119. #define CPUDBG_ITR 0x084
  120. #define CPUDBG_DTRTX 0x08c
  121. /* See ARMv7a arch spec section C10.5 */
  122. #define CPUDBG_BVR_BASE 0x100
  123. #define CPUDBG_BCR_BASE 0x140
  124. #define CPUDBG_WVR_BASE 0x180
  125. #define CPUDBG_WCR_BASE 0x1C0
  126. #define CPUDBG_VCR 0x01C
  127. /* See ARMv7a arch spec section C10.6 */
  128. #define CPUDBG_OSLAR 0x300
  129. #define CPUDBG_OSLSR 0x304
  130. #define CPUDBG_OSSRR 0x308
  131. #define CPUDBG_ECR 0x024
  132. /* See ARMv7a arch spec section C10.7 */
  133. #define CPUDBG_DSCCR 0x028
  134. /* See ARMv7a arch spec section C10.8 */
  135. #define CPUDBG_AUTHSTATUS 0xFB8
  136. int armv7a_arch_state(struct target *target);
  137. int armv7a_identify_cache(struct target *target);
  138. int armv7a_init_arch_info(struct target *target, struct armv7a_common *armv7a);
  139. int armv7a_mmu_translate_va_pa(struct target *target, uint32_t va,
  140. uint32_t *val, int meminfo);
  141. int armv7a_mmu_translate_va(struct target *target, uint32_t va, uint32_t *val);
  142. int armv7a_handle_cache_info_command(struct command_context *cmd_ctx,
  143. struct armv7a_cache_common *armv7a_cache);
  144. extern const struct command_registration armv7a_command_handlers[];
  145. #endif /* ARMV4_5_H */