file not found SEGFAULT fix
[openocd.git] / src / target / arm9tdmi.c
index 0df6a14b15e3de046573e0e0b7e33cfd6a213bf7..0937c2abd58657ebe26b74b0808ad8e545e04a4a 100644 (file)
@@ -2,6 +2,9 @@
  *   Copyright (C) 2005 by Dominic Rath                                    *
  *   Dominic.Rath@gmx.de                                                   *
  *                                                                         *
+ *   Copyright (C) 2008 by Spencer Oliver                                  *
+ *   spen@spen-soft.co.uk                                                  *
+ *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
@@ -46,9 +49,10 @@ int arm9tdmi_register_commands(struct command_context_s *cmd_ctx);
 int handle_arm9tdmi_catch_vectors_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
 
 /* forward declarations */
-int arm9tdmi_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
+int arm9tdmi_target_create( struct target_s *target, Jim_Interp *interp );
+
 int arm9tdmi_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
-int arm9tdmi_quit();
+int arm9tdmi_quit(void);
                
 target_type_t arm9tdmi_target =
 {
@@ -73,6 +77,7 @@ target_type_t arm9tdmi_target =
        .write_memory = arm7_9_write_memory,
        .bulk_write_memory = arm7_9_bulk_write_memory,
        .checksum_memory = arm7_9_checksum_memory,
+       .blank_check_memory = arm7_9_blank_check_memory,
        
        .run_algorithm = armv4_5_run_algorithm,
        
@@ -82,7 +87,7 @@ target_type_t arm9tdmi_target =
        .remove_watchpoint = arm7_9_remove_watchpoint,
 
        .register_commands = arm9tdmi_register_commands,
-       .target_command = arm9tdmi_target_command,
+       .target_create = arm9tdmi_target_create,
        .init_target = arm9tdmi_init_target,
        .examine = arm9tdmi_examine,
        .quit = arm9tdmi_quit
@@ -380,7 +385,7 @@ int arm9tdmi_clock_data_in_endianness(arm_jtag_t *jtag_info, void *in, int size,
                        
                if (in)
                {
-                       LOG_DEBUG("in: 0x%8.8x", *in);
+                       LOG_DEBUG("in: 0x%8.8x", *(u32*)in);
                }
                else
                {
@@ -843,26 +848,46 @@ void arm9tdmi_build_reg_cache(target_t *target)
        reg_cache_t **cache_p = register_get_last_cache_p(&target->reg_cache);
        /* 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;
 
        (*cache_p) = armv4_5_build_reg_cache(target, armv4_5);
        armv4_5->core_cache = (*cache_p);
-       
-       /* one extra register (vector catch) */
-       (*cache_p)->next = embeddedice_build_reg_cache(target, arm7_9);
-       arm7_9->eice_cache = (*cache_p)->next;
+}
 
+
+int arm9tdmi_examine(struct target_s *target)
+{
+       /* get pointers to arch-specific information */
+       int retval;
+       armv4_5_common_t *armv4_5 = target->arch_info;
+       arm7_9_common_t *arm7_9 = armv4_5->arch_info;
+       if (!target->type->examined)
+       {
+               reg_cache_t **cache_p = register_get_last_cache_p(&target->reg_cache);
+               reg_cache_t *t;
+               /* one extra register (vector catch) */
+               t=embeddedice_build_reg_cache(target, arm7_9);
+               if (t==NULL)
+                       return ERROR_FAIL;
+               (*cache_p) = t;
+               arm7_9->eice_cache = (*cache_p);
+       
+               if (arm7_9->etm_ctx)
+               {
+                       arm_jtag_t *jtag_info = &arm7_9->jtag_info;
+                       (*cache_p)->next = etm_build_reg_cache(target, jtag_info, arm7_9->etm_ctx);
+                       arm7_9->etm_ctx->reg_cache = (*cache_p)->next;
+               }
+               target->type->examined = 1;
+       }
+       if ((retval=embeddedice_setup(target))!=ERROR_OK)
+               return retval;
+       if ((retval=arm7_9_setup(target))!=ERROR_OK)
+               return retval;
        if (arm7_9->etm_ctx)
        {
-               (*cache_p)->next->next = etm_build_reg_cache(target, jtag_info, arm7_9->etm_ctx);
-               arm7_9->etm_ctx->reg_cache = (*cache_p)->next->next;
+               if ((retval=etm_setup(target))!=ERROR_OK)
+                       return retval;
        }
-}
-
-int arm9tdmi_examine(struct command_context_s *cmd_ctx, struct target_s *target)
-{
-       target->type->examined = 1;
        return ERROR_OK;
 }
 
@@ -875,13 +900,13 @@ int arm9tdmi_init_target(struct command_context_s *cmd_ctx, struct target_s *tar
        
 }
 
-int arm9tdmi_quit()
+int arm9tdmi_quit(void)
 {
        
        return ERROR_OK;
 }
 
-int arm9tdmi_init_arch_info(target_t *target, arm9tdmi_common_t *arm9tdmi, int chain_pos, char *variant)
+int arm9tdmi_init_arch_info(target_t *target, arm9tdmi_common_t *arm9tdmi, int chain_pos, const char *variant)
 {
        armv4_5_common_t *armv4_5;
        arm7_9_common_t *arm7_9;
@@ -929,8 +954,6 @@ int arm9tdmi_init_arch_info(target_t *target, arm9tdmi_common_t *arm9tdmi, int c
        arm7_9->arm_bkpt = 0xdeeedeee;
        arm7_9->thumb_bkpt = 0xdeee;
        
-       arm7_9->sw_bkpts_use_wp = 1;
-       arm7_9->sw_bkpts_enabled = 0;
        arm7_9->dbgreq_adjust_pc = 3;
        arm7_9->arch_info = arm9tdmi;
        
@@ -988,26 +1011,12 @@ int arm9tdmi_get_arch_pointers(target_t *target, armv4_5_common_t **armv4_5_p, a
 }
 
 
-/* target arm9tdmi <endianess> <startup_mode> <chain_pos> <variant>*/
-int arm9tdmi_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target)
+
+int arm9tdmi_target_create(struct target_s *target, Jim_Interp *interp)
 {
-       int chain_pos;
-       char *variant = NULL;
-       arm9tdmi_common_t *arm9tdmi = malloc(sizeof(arm9tdmi_common_t));
-       memset(arm9tdmi, 0, sizeof(*arm9tdmi));
+       arm9tdmi_common_t *arm9tdmi = calloc(1,sizeof(arm9tdmi_common_t));
 
-       if (argc < 4)
-       {
-               LOG_ERROR("'target arm9tdmi' requires at least one additional argument");
-               exit(-1);
-       }
-       
-       chain_pos = strtoul(args[3], NULL, 0);
-       
-       if (argc >= 5)
-               variant = args[4];
-       
-       arm9tdmi_init_arch_info(target, arm9tdmi, chain_pos, variant);
+       arm9tdmi_init_arch_info(target, arm9tdmi, target->chain_position, target->variant);
        
        return ERROR_OK;
 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)