added target->type->examine(). Eventually this will allow for bringing up telnet...
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Fri, 11 Apr 2008 06:52:52 +0000 (06:52 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Fri, 11 Apr 2008 06:52:52 +0000 (06:52 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@563 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/openocd.c
src/target/target.c
src/target/target.h
src/target/target/xba_revA3.cfg

index 71963cb965c13d368a3b3c7f63803faf7116a53e..3c7816eabb4c12a0edb0b4cd517de5ce1a333fd1 100644 (file)
@@ -95,6 +95,10 @@ int handle_init_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
 
        atexit(exit_handler);
 
+       /* FIX!!! this should happen *after* target_init(), but
+        * for now there are target initialisations that talk
+        * to JTAG whereas that *should* happen during target_examine()
+        */
        if (jtag_init(cmd_ctx) != ERROR_OK)
                return ERROR_FAIL;
        LOG_DEBUG("jtag init complete");
@@ -103,6 +107,10 @@ int handle_init_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
                return ERROR_FAIL;
        LOG_DEBUG("target init complete");
 
+       if (target_examine(cmd_ctx) != ERROR_OK)
+               return ERROR_FAIL;
+       LOG_DEBUG("target examine complete");
+       
        if (flash_init_drivers(cmd_ctx) != ERROR_OK)
                return ERROR_FAIL;
        LOG_DEBUG("flash init complete");
index ce411b45b84dbc6e71f43ef6f7e27d5a009d3602..5850fada97e7e340f1ac21265dc0ce1da62bf3e1 100644 (file)
@@ -264,7 +264,9 @@ int target_process_reset(struct command_context_s *cmd_ctx)
        if ((retval = jtag_init_reset(cmd_ctx)) != ERROR_OK)
                return retval;
        
-
+       if ((retval = target_examine(cmd_ctx)) != ERROR_OK)
+               return retval;
+       
        /* prepare reset_halt where necessary */
        target = targets;
        while (target)
@@ -428,12 +430,36 @@ static int default_mmu(struct target_s *target, int *enabled)
        return ERROR_OK;
 }
 
+static int default_examine(struct command_context_s *cmd_ctx, struct target_s *target)
+{
+       return ERROR_OK;
+}
+
+
+int target_examine(struct command_context_s *cmd_ctx)
+{
+       int retval = ERROR_OK;
+       target_t *target = targets;
+       while (target)
+       {
+               if ((retval = target->type->examine(cmd_ctx, target))!=ERROR_OK)
+                       return retval;
+               target = target->next;
+       }
+       return retval;
+}
 int target_init(struct command_context_s *cmd_ctx)
 {
        target_t *target = targets;
        
        while (target)
        {
+               target->type->examined = 0;
+               if (target->type->examine == NULL)
+               {
+                       target->type->examine = default_examine;
+               }
+               
                if (target->type->init_target(cmd_ctx, target) != ERROR_OK)
                {
                        LOG_ERROR("target '%s' init failed", target->type->name);
index d95c4aa76572b333a41a0a70ac0bf52519480ba0..6480bc5b62342d7b789627b67a82586bc57cf425 100644 (file)
@@ -98,6 +98,8 @@ typedef struct working_area_s
 typedef struct target_type_s
 {
        char *name;
+       
+       int examined;
 
        /* poll current target status */
        int (*poll)(struct target_s *target);
@@ -168,6 +170,18 @@ typedef struct target_type_s
        
        int (*register_commands)(struct command_context_s *cmd_ctx);
        int (*target_command)(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
+       /* invoked after JTAG chain has been examined & validated. During
+        * this stage the target is examined and any additional setup is
+        * performed.
+        * 
+        * invoked every time after the jtag chain has been validated/examined
+        */
+       int (*examine)(struct command_context_s *cmd_ctx, struct target_s *target);
+       /* Set up structures for target.
+        *  
+        * It is illegal to talk to the target at this stage as this fn is invoked
+        * before the JTAG chain has been examined/verified
+     */
        int (*init_target)(struct command_context_s *cmd_ctx, struct target_s *target);
        int (*quit)(void);
        
@@ -236,7 +250,7 @@ typedef struct target_timer_callback_s
 extern int target_register_commands(struct command_context_s *cmd_ctx);
 extern int target_register_user_commands(struct command_context_s *cmd_ctx);
 extern int target_init(struct command_context_s *cmd_ctx);
-extern int target_init_reset(struct command_context_s *cmd_ctx);
+extern int target_examine(struct command_context_s *cmd_ctx);
 extern int handle_target(void *priv);
 extern int target_process_reset(struct command_context_s *cmd_ctx);
 
index 0c73e8c1eff5fc93100117d7893803be32b34b6c..5918ea6e8f29e3cef3c7498952fae3f84aa10eb9 100644 (file)
@@ -19,7 +19,7 @@ target_script 0 reset event/xba_revA3.script
 run_and_halt_time 0 100
 
 flash bank cfi 0x50000000 0x400000 2 2 0
-working_area 0 0x20010000 0x8000 nobackup
+working_area 0 0x20010000 0x8060 nobackup
 
 # halt target
 wait_halt