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.
 
 
 
 
 
 

181 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. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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. {
  28. ARM_PC = 15,
  29. ARM_CPSR = 16
  30. }
  31. ;
  32. #define ARMV7_COMMON_MAGIC 0x0A450999
  33. /* VA to PA translation operations opc2 values*/
  34. #define V2PCWPR 0
  35. #define V2PCWPW 1
  36. #define V2PCWUR 2
  37. #define V2PCWUW 3
  38. #define V2POWPR 4
  39. #define V2POWPW 5
  40. #define V2POWUR 6
  41. #define V2POWUW 7
  42. /* L210/L220 cache controller support */
  43. struct armv7a_l2x_cache {
  44. uint32_t base;
  45. uint32_t way;
  46. };
  47. struct armv7a_cachesize
  48. {
  49. uint32_t level_num;
  50. /* cache dimensionning */
  51. uint32_t linelen;
  52. uint32_t associativity;
  53. uint32_t nsets;
  54. uint32_t cachesize;
  55. /* info for set way operation on cache */
  56. uint32_t index;
  57. uint32_t index_shift;
  58. uint32_t way;
  59. uint32_t way_shift;
  60. };
  61. struct armv7a_cache_common
  62. {
  63. int ctype;
  64. struct armv7a_cachesize d_u_size; /* data cache */
  65. struct armv7a_cachesize i_size; /* instruction cache */
  66. int i_cache_enabled;
  67. int d_u_cache_enabled;
  68. /* l2 external unified cache if some */
  69. void *l2_cache;
  70. int (*flush_all_data_cache)(struct target *target);
  71. int (*display_cache_info)(struct command_context *cmd_ctx,
  72. struct armv7a_cache_common *armv7a_cache);
  73. };
  74. struct armv7a_mmu_common
  75. {
  76. /* following field mmu working way */
  77. int32_t ttbr1_used; /* -1 not initialized, 0 no ttbr1 1 ttbr1 used and */
  78. uint32_t ttbr0_mask;/* masked to be used */
  79. uint32_t os_border;
  80. int (*read_physical_memory)(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
  81. struct armv7a_cache_common armv7a_cache;
  82. uint32_t mmu_enabled;
  83. };
  84. struct armv7a_common
  85. {
  86. struct arm armv4_5_common;
  87. int common_magic;
  88. struct reg_cache *core_cache;
  89. struct adiv5_dap dap;
  90. /* Core Debug Unit */
  91. struct arm_dpm dpm;
  92. uint32_t debug_base;
  93. uint8_t debug_ap;
  94. uint8_t memory_ap;
  95. /* mdir */
  96. uint8_t multi_processor_system;
  97. uint8_t cluster_id;
  98. uint8_t cpu_id;
  99. /* cache specific to V7 Memory Management Unit compatible with v4_5*/
  100. struct armv7a_mmu_common armv7a_mmu;
  101. int (*examine_debug_reason)(struct target *target);
  102. int (*post_debug_entry)(struct target *target);
  103. void (*pre_restore_context)(struct target *target);
  104. };
  105. static inline struct armv7a_common *
  106. target_to_armv7a(struct target *target)
  107. {
  108. return container_of(target->arch_info, struct armv7a_common,
  109. armv4_5_common);
  110. }
  111. /* register offsets from armv7a.debug_base */
  112. /* See ARMv7a arch spec section C10.2 */
  113. #define CPUDBG_DIDR 0x000
  114. /* See ARMv7a arch spec section C10.3 */
  115. #define CPUDBG_WFAR 0x018
  116. /* PCSR at 0x084 -or- 0x0a0 -or- both ... based on flags in DIDR */
  117. #define CPUDBG_DSCR 0x088
  118. #define CPUDBG_DRCR 0x090
  119. #define CPUDBG_PRCR 0x310
  120. #define CPUDBG_PRSR 0x314
  121. /* See ARMv7a arch spec section C10.4 */
  122. #define CPUDBG_DTRRX 0x080
  123. #define CPUDBG_ITR 0x084
  124. #define CPUDBG_DTRTX 0x08c
  125. /* See ARMv7a arch spec section C10.5 */
  126. #define CPUDBG_BVR_BASE 0x100
  127. #define CPUDBG_BCR_BASE 0x140
  128. #define CPUDBG_WVR_BASE 0x180
  129. #define CPUDBG_WCR_BASE 0x1C0
  130. #define CPUDBG_VCR 0x01C
  131. /* See ARMv7a arch spec section C10.6 */
  132. #define CPUDBG_OSLAR 0x300
  133. #define CPUDBG_OSLSR 0x304
  134. #define CPUDBG_OSSRR 0x308
  135. #define CPUDBG_ECR 0x024
  136. /* See ARMv7a arch spec section C10.7 */
  137. #define CPUDBG_DSCCR 0x028
  138. /* See ARMv7a arch spec section C10.8 */
  139. #define CPUDBG_AUTHSTATUS 0xFB8
  140. int armv7a_arch_state(struct target *target);
  141. int armv7a_identify_cache(struct target *target);
  142. int armv7a_init_arch_info(struct target *target, struct armv7a_common *armv7a);
  143. int armv7a_mmu_translate_va_pa(struct target *target, uint32_t va,
  144. uint32_t *val,int meminfo);
  145. int armv7a_mmu_translate_va(struct target *target, uint32_t va, uint32_t *val);
  146. int armv7a_handle_cache_info_command(struct command_context *cmd_ctx,
  147. struct armv7a_cache_common *armv7a_cache);
  148. extern const struct command_registration armv7a_command_handlers[];
  149. #endif /* ARMV4_5_H */