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.
 
 
 
 
 
 

130 lines
4.4 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2005, 2006 by Dominic Rath *
  3. * Dominic.Rath@gmx.de *
  4. * *
  5. * Copyright (C) 2007,2008 Øyvind Harboe *
  6. * oyvind.harboe@zylin.com *
  7. * *
  8. * Copyright (C) 2008 by Spencer Oliver *
  9. * spen@spen-soft.co.uk *
  10. * *
  11. * This program is free software; you can redistribute it and/or modify *
  12. * it under the terms of the GNU General Public License as published by *
  13. * the Free Software Foundation; either version 2 of the License, or *
  14. * (at your option) any later version. *
  15. * *
  16. * This program is distributed in the hope that it will be useful, *
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  19. * GNU General Public License for more details. *
  20. * *
  21. * You should have received a copy of the GNU General Public License *
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>. *
  23. ***************************************************************************/
  24. #ifndef OPENOCD_TARGET_EMBEDDEDICE_H
  25. #define OPENOCD_TARGET_EMBEDDEDICE_H
  26. #include "arm7_9_common.h"
  27. enum {
  28. EICE_DBG_CTRL = 0,
  29. EICE_DBG_STAT = 1,
  30. EICE_COMMS_CTRL = 2,
  31. EICE_COMMS_DATA = 3,
  32. EICE_W0_ADDR_VALUE = 4,
  33. EICE_W0_ADDR_MASK = 5,
  34. EICE_W0_DATA_VALUE = 6,
  35. EICE_W0_DATA_MASK = 7,
  36. EICE_W0_CONTROL_VALUE = 8,
  37. EICE_W0_CONTROL_MASK = 9,
  38. EICE_W1_ADDR_VALUE = 10,
  39. EICE_W1_ADDR_MASK = 11,
  40. EICE_W1_DATA_VALUE = 12,
  41. EICE_W1_DATA_MASK = 13,
  42. EICE_W1_CONTROL_VALUE = 14,
  43. EICE_W1_CONTROL_MASK = 15,
  44. EICE_VEC_CATCH = 16
  45. };
  46. enum {
  47. EICE_DBG_CONTROL_ICEDIS = 5,
  48. EICE_DBG_CONTROL_MONEN = 4,
  49. EICE_DBG_CONTROL_INTDIS = 2,
  50. EICE_DBG_CONTROL_DBGRQ = 1,
  51. EICE_DBG_CONTROL_DBGACK = 0,
  52. };
  53. enum {
  54. EICE_DBG_STATUS_IJBIT = 5,
  55. EICE_DBG_STATUS_ITBIT = 4,
  56. EICE_DBG_STATUS_SYSCOMP = 3,
  57. EICE_DBG_STATUS_IFEN = 2,
  58. EICE_DBG_STATUS_DBGRQ = 1,
  59. EICE_DBG_STATUS_DBGACK = 0
  60. };
  61. enum {
  62. EICE_W_CTRL_ENABLE = 0x100,
  63. EICE_W_CTRL_RANGE = 0x80,
  64. EICE_W_CTRL_CHAIN = 0x40,
  65. EICE_W_CTRL_EXTERN = 0x20,
  66. EICE_W_CTRL_NTRANS = 0x10,
  67. EICE_W_CTRL_NOPC = 0x8,
  68. EICE_W_CTRL_MAS = 0x6,
  69. EICE_W_CTRL_ITBIT = 0x2,
  70. EICE_W_CTRL_NRW = 0x1
  71. };
  72. enum {
  73. EICE_COMM_CTRL_WBIT = 1,
  74. EICE_COMM_CTRL_RBIT = 0
  75. };
  76. struct embeddedice_reg {
  77. int addr;
  78. struct arm_jtag *jtag_info;
  79. };
  80. struct reg_cache *embeddedice_build_reg_cache(struct target *target,
  81. struct arm7_9_common *arm7_9);
  82. void embeddedice_free_reg_cache(struct reg_cache *reg_cache);
  83. int embeddedice_setup(struct target *target);
  84. int embeddedice_read_reg(struct reg *reg);
  85. int embeddedice_read_reg_w_check(struct reg *reg,
  86. uint8_t *check_value, uint8_t *check_mask);
  87. void embeddedice_write_reg(struct reg *reg, uint32_t value);
  88. void embeddedice_store_reg(struct reg *reg);
  89. void embeddedice_set_reg(struct reg *reg, uint32_t value);
  90. int embeddedice_receive(struct arm_jtag *jtag_info, uint32_t *data, uint32_t size);
  91. int embeddedice_send(struct arm_jtag *jtag_info, uint32_t *data, uint32_t size);
  92. int embeddedice_handshake(struct arm_jtag *jtag_info, int hsbit, uint32_t timeout);
  93. /* If many embeddedice_write_reg() follow each other, then the >1 invocations can be
  94. * this faster version of embeddedice_write_reg
  95. */
  96. static inline void embeddedice_write_reg_inner(struct jtag_tap *tap, int reg_addr, uint32_t value)
  97. {
  98. uint8_t out_reg_addr = (1 << 5) | reg_addr;
  99. uint8_t out_value[4];
  100. buf_set_u32(out_value, 0, 32, value);
  101. struct scan_field fields[2] = {
  102. { .num_bits = 32, .out_value = out_value },
  103. { .num_bits = 6, .out_value = &out_reg_addr },
  104. };
  105. jtag_add_dr_scan(tap, 2, fields, TAP_IDLE);
  106. }
  107. void embeddedice_write_dcc(struct jtag_tap *tap, int reg_addr, const uint8_t *buffer,
  108. int little, int count);
  109. #endif /* OPENOCD_TARGET_EMBEDDEDICE_H */