fixed warning
[fw/openocd] / src / target / arm11.c
index d459dbb054fea03c1bc922a31a527e8946b76712..59b6c4fe7c85032515b3da368ffe7ebf5558e46d 100644 (file)
@@ -1,5 +1,7 @@
 /***************************************************************************
  *   Copyright (C) 2008 digenius technology GmbH.                          *
+ *   
+ *   Copyright (C) 2008 Oyvind Harboe oyvind.harboe@zylin.com              *
  *                                                                         *
  *   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  *
@@ -72,7 +74,6 @@ target_type_t arm11_target =
     ARM11_HANDLER(assert_reset),
     ARM11_HANDLER(deassert_reset),
     ARM11_HANDLER(soft_reset_halt),
-    ARM11_HANDLER(prepare_reset_halt),
        
     ARM11_HANDLER(get_gdb_reg_list),
        
@@ -93,6 +94,7 @@ target_type_t arm11_target =
     ARM11_HANDLER(register_commands),
     ARM11_HANDLER(target_command),
     ARM11_HANDLER(init_target),
+    ARM11_HANDLER(examine),
     ARM11_HANDLER(quit),
 };
 
@@ -733,8 +735,8 @@ int arm11_halt(struct target_s *target)
 
     if (target->state == TARGET_HALTED)
     {
-       LOG_WARNING("target was already halted");
-       return ERROR_OK;
+               LOG_DEBUG("target was already halted");
+               return ERROR_OK;
     }
 
     if (arm11->trst_active)
@@ -783,10 +785,10 @@ int arm11_resume(struct target_s *target, int current, u32 address, int handle_b
     LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
 
     if (target->state != TARGET_HALTED)
-    {
-       LOG_WARNING("target was not halted");
-       return ERROR_TARGET_NOT_HALTED;
-    }
+       {
+               LOG_ERROR("Target not halted");
+               return ERROR_TARGET_NOT_HALTED;
+       }
 
     if (!current)
        R(PC) = address;
@@ -995,6 +997,13 @@ int arm11_assert_reset(struct target_s *target)
     arm11->trst_active = true;
 #endif
 
+    if (target->reset_halt)
+    {
+       int retval;
+               if ((retval = target_halt(target))!=ERROR_OK)
+                       return retval;
+    }
+
     return ERROR_OK;
 }
 
@@ -1025,12 +1034,6 @@ int arm11_soft_reset_halt(struct target_s *target)
     return ERROR_OK;
 }
 
-int arm11_prepare_reset_halt(struct target_s *target)
-{
-    FNC_INFO_NOTIMPLEMENTED;
-
-    return ERROR_OK;
-}
 
 
 /* target register access for gdb */
@@ -1236,7 +1239,7 @@ int arm11_write_memory(struct target_s *target, u32 address, u32 size, u32 count
                LOG_ERROR("use 'arm11 memwrite burst disable' to disable fast burst mode");
 
            if (arm11_config_memwrite_error_fatal)
-               exit(-1);
+               return ERROR_FAIL;
        }
     }
 #endif
@@ -1348,8 +1351,7 @@ int arm11_target_command(struct command_context_s *cmd_ctx, char *cmd, char **ar
 
     if (argc < 4)
     {
-       LOG_ERROR("'target arm11' 4th argument <jtag chain pos>");
-       exit(-1);
+       return ERROR_COMMAND_SYNTAX_ERROR;
     }
 
     int chain_pos = strtoul(args[3], NULL, 0);
@@ -1368,8 +1370,8 @@ int arm11_target_command(struct command_context_s *cmd_ctx, char *cmd, char **ar
 
     if (device->ir_length != 5)
     {
-       LOG_ERROR("'target arm11' expects 'jtag_device 5 0x01 0x1F 0x1E'");
-       exit(-1);
+               LOG_ERROR("'target arm11' expects 'jtag_device 5 0x01 0x1F 0x1E'");
+               return ERROR_COMMAND_SYNTAX_ERROR;
     }
 
     target->arch_info = arm11;
@@ -1378,6 +1380,13 @@ int arm11_target_command(struct command_context_s *cmd_ctx, char *cmd, char **ar
 }
 
 int arm11_init_target(struct command_context_s *cmd_ctx, struct target_s *target)
+{
+       /* Initialize anything we can set up without talking to the target */
+       return ERROR_OK;
+}
+
+/* talk to the target and set things up */
+int arm11_examine(struct target_s *target)
 {
     FNC_INFO;
 
@@ -1416,8 +1425,8 @@ int arm11_init_target(struct command_context_s *cmd_ctx, struct target_s *target
     case 0x07B76000:   LOG_INFO("found ARM1176"); break;
     default:
     {
-       LOG_ERROR("'target arm11' expects IDCODE 0x*7B*7****");
-       exit(-1);
+               LOG_ERROR("'target arm11' expects IDCODE 0x*7B*7****");
+               return ERROR_FAIL;
     }
     }
 
@@ -1427,7 +1436,7 @@ int arm11_init_target(struct command_context_s *cmd_ctx, struct target_s *target
        arm11->debug_version != ARM11_DEBUG_V61)
     {
        LOG_ERROR("Only ARMv6 v6 and v6.1 architectures supported.");
-       exit(-1);
+       return ERROR_FAIL;
     }
 
 
@@ -1535,7 +1544,7 @@ void arm11_build_reg_cache(target_t *target)
        ARM11_REGCACHE_COUNT != asizeof(arm11_reg_defs) ||
        ARM11_REGCACHE_COUNT != ARM11_RC_MAX)
     {
-       LOG_ERROR("arm11->reg_values inconsistent (%d " ZU " " ZU " %d)", ARM11_REGCACHE_COUNT, asizeof(arm11->reg_values), asizeof(arm11_reg_defs), ARM11_RC_MAX);
+       LOG_ERROR("BUG: arm11->reg_values inconsistent (%d " ZU " " ZU " %d)", ARM11_REGCACHE_COUNT, asizeof(arm11->reg_values), asizeof(arm11_reg_defs), ARM11_RC_MAX);
        exit(-1);
     }
 
@@ -1707,8 +1716,8 @@ int arm11_handle_mrc_mcr(struct command_context_s *cmd_ctx, char *cmd, char **ar
 
        if (values[i] > arm11_coproc_instruction_limits[i])
        {
-           LOG_ERROR("Parameter %d out of bounds (%d max). %s",
-               i + 2, arm11_coproc_instruction_limits[i],
+           LOG_ERROR("Parameter %ld out of bounds (%d max). %s",
+                     (long)(i + 2), arm11_coproc_instruction_limits[i],
                read ? arm11_mrc_syntax : arm11_mcr_syntax);
            return -1;
        }