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.

mips_ejtag.h 7.7 KiB

mips: m4k alternate pracc code. Patch 1 This patch and the following patches define another way of doing processor access without the need to read back the pracc address as needed in current pracc code. Current pracc code is executed linearly and unconditionally. The processor starts execution at 0xff200200 and the fetch address is ever incremented by 4, including the last instruction in the delay slot of the branch to start. Most of the processor accesses are fetch and some are store accesses. After a previous patch regarding the way of restoring registers (reg8 and reg9), there are no load processor accesses. The pracc address for a store depends only on the store instruction given before. m4k core has a 5 stage pipeline and the memory access is done in the 3rth stage. This means that the store access will not arrive immediately after a store instruction, it appears after another instruction enters the pipeline. For reference: MD00249 mips32 m4k manual. A new struct pracc_queue_info is defined to help each function in generating the code. The field pracc_list holds in the lower half the list of instructions and in the upper half the store addressess, if any. In this way the list can be used by current code or by the new one to generate the sequence of pracc accesses. For every pracc access only one scan to register "all" is used by calling the new function mips_ejtag_add_scan_96(). This function does not call jtag_execute_queue(), all the scans needed can be queued before calling for execution. The pracc bit is not checked before execution, is checked after the queue has been executed. Without calling the wait function the code works much faster, but the scan frequency must be limited. For pic32mx with core clock at 4Mhz works up to 600Khz and with 8Mhz up to 1200. To increase the scan frequency a delay between scans is added by calling jtag_add_cloks(). A time delay in nano seconds is stored in scan_delay, a new field in ejtag_info, and a handler is provided for it. A mode field is added to ejtag_info to hold the working mode. If a time delay of 2ms (2000000 ns) or higher is set, current code is executed, if lower, new code is executed. Initial default values are set in function mips32_init_arch_info. A reset does not change this settings. Change-Id: I266bdb386b24744435b6e29d8489a68c0c15ff65 Signed-off-by: Salvador Arroyo <sarroyofdez@yahoo.es> Reviewed-on: http://openocd.zylin.com/1193 Tested-by: jenkins Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
11 years ago
mips: m4k alternate pracc code. Patch 1 This patch and the following patches define another way of doing processor access without the need to read back the pracc address as needed in current pracc code. Current pracc code is executed linearly and unconditionally. The processor starts execution at 0xff200200 and the fetch address is ever incremented by 4, including the last instruction in the delay slot of the branch to start. Most of the processor accesses are fetch and some are store accesses. After a previous patch regarding the way of restoring registers (reg8 and reg9), there are no load processor accesses. The pracc address for a store depends only on the store instruction given before. m4k core has a 5 stage pipeline and the memory access is done in the 3rth stage. This means that the store access will not arrive immediately after a store instruction, it appears after another instruction enters the pipeline. For reference: MD00249 mips32 m4k manual. A new struct pracc_queue_info is defined to help each function in generating the code. The field pracc_list holds in the lower half the list of instructions and in the upper half the store addressess, if any. In this way the list can be used by current code or by the new one to generate the sequence of pracc accesses. For every pracc access only one scan to register "all" is used by calling the new function mips_ejtag_add_scan_96(). This function does not call jtag_execute_queue(), all the scans needed can be queued before calling for execution. The pracc bit is not checked before execution, is checked after the queue has been executed. Without calling the wait function the code works much faster, but the scan frequency must be limited. For pic32mx with core clock at 4Mhz works up to 600Khz and with 8Mhz up to 1200. To increase the scan frequency a delay between scans is added by calling jtag_add_cloks(). A time delay in nano seconds is stored in scan_delay, a new field in ejtag_info, and a handler is provided for it. A mode field is added to ejtag_info to hold the working mode. If a time delay of 2ms (2000000 ns) or higher is set, current code is executed, if lower, new code is executed. Initial default values are set in function mips32_init_arch_info. A reset does not change this settings. Change-Id: I266bdb386b24744435b6e29d8489a68c0c15ff65 Signed-off-by: Salvador Arroyo <sarroyofdez@yahoo.es> Reviewed-on: http://openocd.zylin.com/1193 Tested-by: jenkins Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /***************************************************************************
  2. * Copyright (C) 2008 by Spencer Oliver *
  3. * spen@spen-soft.co.uk *
  4. * *
  5. * Copyright (C) 2008 by David T.L. Wong *
  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 as published by *
  9. * the Free Software Foundation; either version 2 of the License, or *
  10. * (at your option) any later version. *
  11. * *
  12. * This program is distributed in the hope that it will be useful, *
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15. * GNU General Public License for more details. *
  16. * *
  17. * You should have received a copy of the GNU General Public License *
  18. * along with this program; if not, write to the *
  19. * Free Software Foundation, Inc., *
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
  21. ***************************************************************************/
  22. #ifndef MIPS_EJTAG
  23. #define MIPS_EJTAG
  24. #include <jtag/jtag.h>
  25. /* tap instructions */
  26. #define EJTAG_INST_IDCODE 0x01
  27. #define EJTAG_INST_IMPCODE 0x03
  28. #define EJTAG_INST_ADDRESS 0x08
  29. #define EJTAG_INST_DATA 0x09
  30. #define EJTAG_INST_CONTROL 0x0A
  31. #define EJTAG_INST_ALL 0x0B
  32. #define EJTAG_INST_EJTAGBOOT 0x0C
  33. #define EJTAG_INST_NORMALBOOT 0x0D
  34. #define EJTAG_INST_FASTDATA 0x0E
  35. #define EJTAG_INST_TCBCONTROLA 0x10
  36. #define EJTAG_INST_TCBCONTROLB 0x11
  37. #define EJTAG_INST_TCBDATA 0x12
  38. #define EJTAG_INST_BYPASS 0xFF
  39. /* microchip PIC32MX specific instructions */
  40. #define MTAP_SW_MTAP 0x04
  41. #define MTAP_SW_ETAP 0x05
  42. #define MTAP_COMMAND 0x07
  43. /* microchip specific cmds */
  44. #define MCHP_ASERT_RST 0xd1
  45. #define MCHP_DE_ASSERT_RST 0xd0
  46. #define MCHP_ERASE 0xfc
  47. #define MCHP_STATUS 0x00
  48. /* ejtag control register bits ECR */
  49. #define EJTAG_CTRL_TOF (1 << 1)
  50. #define EJTAG_CTRL_TIF (1 << 2)
  51. #define EJTAG_CTRL_BRKST (1 << 3)
  52. #define EJTAG_CTRL_DLOCK (1 << 5)
  53. #define EJTAG_CTRL_DRWN (1 << 9)
  54. #define EJTAG_CTRL_DERR (1 << 10)
  55. #define EJTAG_CTRL_DSTRT (1 << 11)
  56. #define EJTAG_CTRL_JTAGBRK (1 << 12)
  57. #define EJTAG_CTRL_SETDEV (1 << 14)
  58. #define EJTAG_CTRL_PROBEN (1 << 15)
  59. #define EJTAG_CTRL_PRRST (1 << 16)
  60. #define EJTAG_CTRL_DMAACC (1 << 17)
  61. #define EJTAG_CTRL_PRACC (1 << 18)
  62. #define EJTAG_CTRL_PRNW (1 << 19)
  63. #define EJTAG_CTRL_PERRST (1 << 20)
  64. #define EJTAG_CTRL_SYNC (1 << 23)
  65. #define EJTAG_CTRL_DNM (1 << 28)
  66. #define EJTAG_CTRL_ROCC (1 << 31)
  67. /* Debug Register (CP0 Register 23, Select 0) */
  68. #define EJTAG_DEBUG_DSS (1 << 0)
  69. #define EJTAG_DEBUG_DBP (1 << 1)
  70. #define EJTAG_DEBUG_DDBL (1 << 2)
  71. #define EJTAG_DEBUG_DDBS (1 << 3)
  72. #define EJTAG_DEBUG_DIB (1 << 4)
  73. #define EJTAG_DEBUG_DINT (1 << 5)
  74. #define EJTAG_DEBUG_OFFLINE (1 << 7)
  75. #define EJTAG_DEBUG_SST (1 << 8)
  76. #define EJTAG_DEBUG_NOSST (1 << 9)
  77. #define EJTAG_DEBUG_DDBLIMPR (1 << 18)
  78. #define EJTAG_DEBUG_DDBSIMPR (1 << 19)
  79. #define EJTAG_DEBUG_IEXI (1 << 20)
  80. #define EJTAG_DEBUG_DBUSEP (1 << 21)
  81. #define EJTAG_DEBUG_CACHEEP (1 << 22)
  82. #define EJTAG_DEBUG_MCHECKP (1 << 23)
  83. #define EJTAG_DEBUG_IBUSEP (1 << 24)
  84. #define EJTAG_DEBUG_COUNTDM (1 << 25)
  85. #define EJTAG_DEBUG_HALT (1 << 26)
  86. #define EJTAG_DEBUG_DOZE (1 << 27)
  87. #define EJTAG_DEBUG_LSNM (1 << 28)
  88. #define EJTAG_DEBUG_NODCR (1 << 29)
  89. #define EJTAG_DEBUG_DM (1 << 30)
  90. #define EJTAG_DEBUG_DBD (1 << 31)
  91. /* implementaion register bits */
  92. #define EJTAG_IMP_R3K (1 << 28)
  93. #define EJTAG_IMP_DINT (1 << 24)
  94. #define EJTAG_IMP_NODMA (1 << 14)
  95. #define EJTAG_IMP_MIPS16 (1 << 16)
  96. #define EJTAG_DCR_MIPS64 (1 << 0)
  97. /* Debug Control Register DCR */
  98. #define EJTAG_DCR 0xFF300000
  99. #define EJTAG_DCR_ENM (1 << 29)
  100. #define EJTAG_DCR_DB (1 << 17)
  101. #define EJTAG_DCR_IB (1 << 16)
  102. #define EJTAG_DCR_INTE (1 << 4)
  103. #define EJTAG_DCR_MP (1 << 2)
  104. /* breakpoint support */
  105. /* EJTAG_V20_* was tested on Broadcom BCM7401
  106. * and may or will differ with other hardware. For example EZ4021-FC. */
  107. #define EJTAG_V20_IBS 0xFF300004
  108. #define EJTAG_V20_IBA0 0xFF300100
  109. #define EJTAG_V20_IBC_OFFS 0x4 /* IBC Offset */
  110. #define EJTAG_V20_IBM_OFFS 0x8
  111. #define EJTAG_V20_IBAn_STEP 0x10 /* Offset for next channel */
  112. #define EJTAG_V20_DBS 0xFF30008
  113. #define EJTAG_V20_DBA0 0xFF300200
  114. #define EJTAG_V20_DBC_OFFS 0x4
  115. #define EJTAG_V20_DBM_OFFS 0x8
  116. #define EJTAG_V20_DBV_OFFS 0xc
  117. #define EJTAG_V20_DBAn_STEP 0x10
  118. #define EJTAG_V25_IBS 0xFF301000
  119. #define EJTAG_V25_IBA0 0xFF301100
  120. #define EJTAG_V25_IBM_OFFS 0x8
  121. #define EJTAG_V25_IBASID_OFFS 0x10
  122. #define EJTAG_V25_IBC_OFFS 0x18
  123. #define EJTAG_V25_IBAn_STEP 0x100
  124. #define EJTAG_V25_DBS 0xFF302000
  125. #define EJTAG_V25_DBA0 0xFF302100
  126. #define EJTAG_V25_DBM_OFFS 0x8
  127. #define EJTAG_V25_DBASID_OFFS 0x10
  128. #define EJTAG_V25_DBC_OFFS 0x18
  129. #define EJTAG_V25_DBV_OFFS 0x20
  130. #define EJTAG_V25_DBAn_STEP 0x100
  131. #define EJTAG_DBCn_NOSB (1 << 13)
  132. #define EJTAG_DBCn_NOLB (1 << 12)
  133. #define EJTAG_DBCn_BLM_MASK 0xff
  134. #define EJTAG_DBCn_BLM_SHIFT 4
  135. #define EJTAG_DBCn_BE (1 << 0)
  136. #define EJTAG_VERSION_20 0
  137. #define EJTAG_VERSION_25 1
  138. #define EJTAG_VERSION_26 2
  139. #define EJTAG_VERSION_31 3
  140. #define EJTAG_VERSION_41 4
  141. #define EJTAG_VERSION_51 5
  142. struct mips_ejtag {
  143. struct jtag_tap *tap;
  144. uint32_t impcode;
  145. uint32_t idcode;
  146. uint32_t ejtag_ctrl;
  147. int fast_access_save;
  148. uint32_t reg8;
  149. uint32_t reg9;
  150. unsigned scan_delay;
  151. int mode;
  152. unsigned int ejtag_version;
  153. /* Memory-Mapped Registers. This addresses are not same on different
  154. * EJTAG versions. */
  155. uint32_t ejtag_ibs_addr; /* Instruction Address Break Status */
  156. uint32_t ejtag_iba0_addr; /* IAB channel 0 */
  157. uint32_t ejtag_ibc_offs; /* IAB Control offset */
  158. uint32_t ejtag_ibm_offs; /* IAB Mask offset */
  159. uint32_t ejtag_ibasid_offs; /* IAB ASID (4Kc) */
  160. uint32_t ejtag_dbs_addr; /* Data Address Break Status Register */
  161. uint32_t ejtag_dba0_addr; /* DAB channel 0 */
  162. uint32_t ejtag_dbc_offs; /* DAB Control offset */
  163. uint32_t ejtag_dbm_offs; /* DAB Mask offset */
  164. uint32_t ejtag_dbv_offs; /* DAB Value offset */
  165. uint32_t ejtag_dbasid_offs; /* DAB ASID (4Kc) */
  166. uint32_t ejtag_iba_step_size;
  167. uint32_t ejtag_dba_step_size; /* siez of step till next
  168. * *DBAn register. */
  169. };
  170. void mips_ejtag_set_instr(struct mips_ejtag *ejtag_info,
  171. int new_instr);
  172. int mips_ejtag_enter_debug(struct mips_ejtag *ejtag_info);
  173. int mips_ejtag_exit_debug(struct mips_ejtag *ejtag_info);
  174. int mips_ejtag_get_idcode(struct mips_ejtag *ejtag_info, uint32_t *idcode);
  175. void mips_ejtag_add_scan_96(struct mips_ejtag *ejtag_info,
  176. uint32_t ctrl, uint32_t data, uint8_t *in_scan_buf);
  177. void mips_ejtag_drscan_32_out(struct mips_ejtag *ejtag_info, uint32_t data);
  178. int mips_ejtag_drscan_32(struct mips_ejtag *ejtag_info, uint32_t *data);
  179. void mips_ejtag_drscan_8_out(struct mips_ejtag *ejtag_info, uint8_t data);
  180. int mips_ejtag_drscan_8(struct mips_ejtag *ejtag_info, uint32_t *data);
  181. int mips_ejtag_fastdata_scan(struct mips_ejtag *ejtag_info, int write_t, uint32_t *data);
  182. int mips_ejtag_init(struct mips_ejtag *ejtag_info);
  183. int mips_ejtag_config_step(struct mips_ejtag *ejtag_info, int enable_step);
  184. static inline void mips_le_to_h_u32(jtag_callback_data_t arg)
  185. {
  186. uint8_t *in = (uint8_t *)arg;
  187. *((uint32_t *)arg) = le_to_h_u32(in);
  188. }
  189. #endif /* MIPS_EJTAG */