ARM7TDMI uses the new inheritance/nesting scheme

Use target_to_arm7_9(), replacing needless pointer traversals.

Also:  remove now-useless contents of arm7tdmi struct; it's
almost ready to be removed.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
This commit is contained in:
David Brownell 2009-11-05 22:04:04 -08:00
parent 11fe2ec62e
commit fec3c4763a
2 changed files with 28 additions and 70 deletions

View File

@ -44,9 +44,7 @@
static int arm7tdmi_examine_debug_reason(target_t *target) static int arm7tdmi_examine_debug_reason(target_t *target)
{ {
int retval = ERROR_OK; int retval = ERROR_OK;
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
/* only check the debug reason if we don't know it already */ /* only check the debug reason if we don't know it already */
if ((target->debug_reason != DBG_REASON_DBGRQ) if ((target->debug_reason != DBG_REASON_DBGRQ)
@ -268,9 +266,7 @@ static int arm7tdmi_clock_data_in_endianness(arm_jtag_t *jtag_info,
static void arm7tdmi_change_to_arm(target_t *target, static void arm7tdmi_change_to_arm(target_t *target,
uint32_t *r0, uint32_t *pc) uint32_t *r0, uint32_t *pc)
{ {
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
/* save r0 before using it and put system in ARM state /* save r0 before using it and put system in ARM state
@ -327,9 +323,7 @@ static void arm7tdmi_read_core_regs(target_t *target,
uint32_t mask, uint32_t* core_regs[16]) uint32_t mask, uint32_t* core_regs[16])
{ {
int i; int i;
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
/* STMIA r0-15, [r0] at debug speed /* STMIA r0-15, [r0] at debug speed
@ -354,9 +348,7 @@ static void arm7tdmi_read_core_regs_target_buffer(target_t *target,
uint32_t mask, void* buffer, int size) uint32_t mask, void* buffer, int size)
{ {
int i; int i;
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
int be = (target->endianness == TARGET_BIG_ENDIAN) ? 1 : 0; int be = (target->endianness == TARGET_BIG_ENDIAN) ? 1 : 0;
uint32_t *buf_u32 = buffer; uint32_t *buf_u32 = buffer;
@ -396,9 +388,7 @@ static void arm7tdmi_read_core_regs_target_buffer(target_t *target,
static void arm7tdmi_read_xpsr(target_t *target, uint32_t *xpsr, int spsr) static void arm7tdmi_read_xpsr(target_t *target, uint32_t *xpsr, int spsr)
{ {
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
/* MRS r0, cpsr */ /* MRS r0, cpsr */
@ -416,9 +406,7 @@ static void arm7tdmi_read_xpsr(target_t *target, uint32_t *xpsr, int spsr)
static void arm7tdmi_write_xpsr(target_t *target, uint32_t xpsr, int spsr) static void arm7tdmi_write_xpsr(target_t *target, uint32_t xpsr, int spsr)
{ {
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
LOG_DEBUG("xpsr: %8.8" PRIx32 ", spsr: %i", xpsr, spsr); LOG_DEBUG("xpsr: %8.8" PRIx32 ", spsr: %i", xpsr, spsr);
@ -448,9 +436,7 @@ static void arm7tdmi_write_xpsr(target_t *target, uint32_t xpsr, int spsr)
static void arm7tdmi_write_xpsr_im8(target_t *target, static void arm7tdmi_write_xpsr_im8(target_t *target,
uint8_t xpsr_im, int rot, int spsr) uint8_t xpsr_im, int rot, int spsr)
{ {
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
LOG_DEBUG("xpsr_im: %2.2x, rot: %i, spsr: %i", xpsr_im, rot, spsr); LOG_DEBUG("xpsr_im: %2.2x, rot: %i, spsr: %i", xpsr_im, rot, spsr);
@ -469,9 +455,7 @@ static void arm7tdmi_write_core_regs(target_t *target,
uint32_t mask, uint32_t core_regs[16]) uint32_t mask, uint32_t core_regs[16])
{ {
int i; int i;
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
/* LDMIA r0-15, [r0] at debug speed /* LDMIA r0-15, [r0] at debug speed
@ -495,9 +479,7 @@ static void arm7tdmi_write_core_regs(target_t *target,
static void arm7tdmi_load_word_regs(target_t *target, uint32_t mask) static void arm7tdmi_load_word_regs(target_t *target, uint32_t mask)
{ {
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
/* put system-speed load-multiple into the pipeline */ /* put system-speed load-multiple into the pipeline */
@ -508,9 +490,7 @@ static void arm7tdmi_load_word_regs(target_t *target, uint32_t mask)
static void arm7tdmi_load_hword_reg(target_t *target, int num) static void arm7tdmi_load_hword_reg(target_t *target, int num)
{ {
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
/* put system-speed load half-word into the pipeline */ /* put system-speed load half-word into the pipeline */
@ -521,9 +501,7 @@ static void arm7tdmi_load_hword_reg(target_t *target, int num)
static void arm7tdmi_load_byte_reg(target_t *target, int num) static void arm7tdmi_load_byte_reg(target_t *target, int num)
{ {
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
/* put system-speed load byte into the pipeline */ /* put system-speed load byte into the pipeline */
@ -534,9 +512,7 @@ static void arm7tdmi_load_byte_reg(target_t *target, int num)
static void arm7tdmi_store_word_regs(target_t *target, uint32_t mask) static void arm7tdmi_store_word_regs(target_t *target, uint32_t mask)
{ {
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
/* put system-speed store-multiple into the pipeline */ /* put system-speed store-multiple into the pipeline */
@ -547,9 +523,7 @@ static void arm7tdmi_store_word_regs(target_t *target, uint32_t mask)
static void arm7tdmi_store_hword_reg(target_t *target, int num) static void arm7tdmi_store_hword_reg(target_t *target, int num)
{ {
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
/* put system-speed store half-word into the pipeline */ /* put system-speed store half-word into the pipeline */
@ -560,9 +534,7 @@ static void arm7tdmi_store_hword_reg(target_t *target, int num)
static void arm7tdmi_store_byte_reg(target_t *target, int num) static void arm7tdmi_store_byte_reg(target_t *target, int num)
{ {
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
/* put system-speed store byte into the pipeline */ /* put system-speed store byte into the pipeline */
@ -573,9 +545,7 @@ static void arm7tdmi_store_byte_reg(target_t *target, int num)
static void arm7tdmi_write_pc(target_t *target, uint32_t pc) static void arm7tdmi_write_pc(target_t *target, uint32_t pc)
{ {
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
/* LDMIA r0-15, [r0] at debug speed /* LDMIA r0-15, [r0] at debug speed
@ -600,9 +570,7 @@ static void arm7tdmi_write_pc(target_t *target, uint32_t pc)
static void arm7tdmi_branch_resume(target_t *target) static void arm7tdmi_branch_resume(target_t *target)
{ {
/* get pointers to arch-specific information */ struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
arm7tdmi_clock_out(jtag_info, ARMV4_5_NOP, NULL, 1); arm7tdmi_clock_out(jtag_info, ARMV4_5_NOP, NULL, 1);
@ -611,14 +579,13 @@ static void arm7tdmi_branch_resume(target_t *target)
static void arm7tdmi_branch_resume_thumb(target_t *target) static void arm7tdmi_branch_resume_thumb(target_t *target)
{ {
LOG_DEBUG("-"); struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
struct armv4_5_common_s *armv4_5 = &arm7_9->armv4_5_common;
/* get pointers to arch-specific information */
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
reg_t *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT]; reg_t *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT];
LOG_DEBUG("-");
/* LDMIA r0, [r0] at debug speed /* LDMIA r0, [r0] at debug speed
* register values will start to appear on 4th DCLK * register values will start to appear on 4th DCLK
*/ */
@ -673,8 +640,7 @@ static void arm7tdmi_branch_resume_thumb(target_t *target)
static void arm7tdmi_build_reg_cache(target_t *target) static void arm7tdmi_build_reg_cache(target_t *target)
{ {
reg_cache_t **cache_p = register_get_last_cache_p(&target->reg_cache); reg_cache_t **cache_p = register_get_last_cache_p(&target->reg_cache);
/* get pointers to arch-specific information */ struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target);
armv4_5_common_t *armv4_5 = target->arch_info;
(*cache_p) = armv4_5_build_reg_cache(target, armv4_5); (*cache_p) = armv4_5_build_reg_cache(target, armv4_5);
armv4_5->core_cache = (*cache_p); armv4_5->core_cache = (*cache_p);
@ -682,9 +648,10 @@ static void arm7tdmi_build_reg_cache(target_t *target)
int arm7tdmi_examine(struct target_s *target) int arm7tdmi_examine(struct target_s *target)
{ {
struct arm7_9_common_s *arm7_9 = target_to_arm7_9(target);
int retval; int retval;
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
if (!target_was_examined(target)) if (!target_was_examined(target))
{ {
/* get pointers to arch-specific information */ /* get pointers to arch-specific information */
@ -725,11 +692,7 @@ int arm7tdmi_init_target(struct command_context_s *cmd_ctx, struct target_s *tar
int arm7tdmi_init_arch_info(target_t *target, arm7tdmi_common_t *arm7tdmi, jtag_tap_t *tap) int arm7tdmi_init_arch_info(target_t *target, arm7tdmi_common_t *arm7tdmi, jtag_tap_t *tap)
{ {
armv4_5_common_t *armv4_5; struct arm7_9_common_s *arm7_9 = &arm7tdmi->arm7_9_common;
arm7_9_common_t *arm7_9;
arm7_9 = &arm7tdmi->arm7_9_common;
armv4_5 = &arm7_9->armv4_5_common;
/* prepare JTAG information for the new target */ /* prepare JTAG information for the new target */
arm7_9->jtag_info.tap = tap; arm7_9->jtag_info.tap = tap;
@ -771,10 +734,6 @@ int arm7tdmi_init_arch_info(target_t *target, arm7tdmi_common_t *arm7tdmi, jtag_
arm7_9->thumb_bkpt = 0xdeee; arm7_9->thumb_bkpt = 0xdeee;
arm7_9->dbgreq_adjust_pc = 2; arm7_9->dbgreq_adjust_pc = 2;
arm7_9->arch_info = arm7tdmi;
arm7tdmi->arch_info = NULL;
arm7tdmi->common_magic = ARM7TDMI_COMMON_MAGIC;
arm7_9_init_arch_info(target, arm7_9); arm7_9_init_arch_info(target, arm7_9);

View File

@ -25,12 +25,11 @@
#include "embeddedice.h" #include "embeddedice.h"
#define ARM7TDMI_COMMON_MAGIC 0x00a700a7 /* FIXME we don't really need a separate arm7tdmi struct any more...
* remove it, the arm7/arm9 common struct suffices.
*/
typedef struct arm7tdmi_common_s typedef struct arm7tdmi_common_s
{ {
int common_magic;
void *arch_info;
arm7_9_common_t arm7_9_common; arm7_9_common_t arm7_9_common;
} arm7tdmi_common_t; } arm7tdmi_common_t;