Hide target list internals form command.c
Remove unused support for extended target structure size.
This commit is contained in:
parent
72790893ae
commit
07f27d1b70
|
@ -39,7 +39,7 @@ static bool cmd_help(target *t);
|
||||||
|
|
||||||
static bool cmd_jtag_scan(target *t, int argc, char **argv);
|
static bool cmd_jtag_scan(target *t, int argc, char **argv);
|
||||||
static bool cmd_swdp_scan(void);
|
static bool cmd_swdp_scan(void);
|
||||||
static bool cmd_targets(target *t);
|
static bool cmd_targets(void);
|
||||||
static bool cmd_morse(void);
|
static bool cmd_morse(void);
|
||||||
static bool cmd_connect_srst(target *t, int argc, const char **argv);
|
static bool cmd_connect_srst(target *t, int argc, const char **argv);
|
||||||
static bool cmd_hard_srst(void);
|
static bool cmd_hard_srst(void);
|
||||||
|
@ -183,7 +183,7 @@ static bool cmd_jtag_scan(target *t, int argc, char **argv)
|
||||||
gdb_out("JTAG device scan failed!\n");
|
gdb_out("JTAG device scan failed!\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cmd_targets(NULL);
|
cmd_targets();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,27 +214,26 @@ bool cmd_swdp_scan(void)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_targets(NULL);
|
cmd_targets();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmd_targets(target *cur_target)
|
static void display_target(int i, target *t, void *context)
|
||||||
{
|
{
|
||||||
struct target_s *t;
|
(void)context;
|
||||||
int i;
|
gdb_outf("%2d %c %s\n", i, target_attached(t)?'*':' ', target_driver_name(t));
|
||||||
|
}
|
||||||
|
|
||||||
if(!target_list) {
|
bool cmd_targets(void)
|
||||||
|
{
|
||||||
|
gdb_out("Available Targets:\n");
|
||||||
|
gdb_out("No. Att Driver\n");
|
||||||
|
if (!target_foreach(display_target, NULL)) {
|
||||||
gdb_out("No usable targets found.\n");
|
gdb_out("No usable targets found.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdb_out("Available Targets:\n");
|
|
||||||
gdb_out("No. Att Driver\n");
|
|
||||||
for(t = target_list, i = 1; t; t = t->next, i++)
|
|
||||||
gdb_outf("%2d %c %s\n", i, t==cur_target?'*':' ',
|
|
||||||
t->driver);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -360,7 +360,7 @@ bool cortexa_probe(ADIv5_AP_t *apb, uint32_t debug_base)
|
||||||
{
|
{
|
||||||
target *t;
|
target *t;
|
||||||
|
|
||||||
t = target_new(sizeof(*t));
|
t = target_new();
|
||||||
adiv5_ap_ref(apb);
|
adiv5_ap_ref(apb);
|
||||||
struct cortexa_priv *priv = calloc(1, sizeof(*priv));
|
struct cortexa_priv *priv = calloc(1, sizeof(*priv));
|
||||||
t->priv = priv;
|
t->priv = priv;
|
||||||
|
|
|
@ -229,7 +229,7 @@ bool cortexm_probe(ADIv5_AP_t *ap)
|
||||||
{
|
{
|
||||||
target *t;
|
target *t;
|
||||||
|
|
||||||
t = target_new(sizeof(*t));
|
t = target_new();
|
||||||
adiv5_ap_ref(ap);
|
adiv5_ap_ref(ap);
|
||||||
struct cortexm_priv *priv = calloc(1, sizeof(*priv));
|
struct cortexm_priv *priv = calloc(1, sizeof(*priv));
|
||||||
t->priv = priv;
|
t->priv = priv;
|
||||||
|
|
|
@ -30,6 +30,7 @@ typedef struct target_s target;
|
||||||
int adiv5_swdp_scan(void);
|
int adiv5_swdp_scan(void);
|
||||||
int jtag_scan(const uint8_t *lrlens);
|
int jtag_scan(const uint8_t *lrlens);
|
||||||
|
|
||||||
|
bool target_foreach(void (*cb)(int i, target *t, void *context), void *context);
|
||||||
void target_list_free(void);
|
void target_list_free(void);
|
||||||
|
|
||||||
/* The destroy callback function will be called by target_list_free() just
|
/* The destroy callback function will be called by target_list_free() just
|
||||||
|
@ -48,6 +49,7 @@ target *target_attach(target *t, target_destroy_callback destroy_cb);
|
||||||
target *target_attach_n(int n, target_destroy_callback destroy_cb);
|
target *target_attach_n(int n, target_destroy_callback destroy_cb);
|
||||||
void target_detach(target *t);
|
void target_detach(target *t);
|
||||||
bool target_check_error(target *t);
|
bool target_check_error(target *t);
|
||||||
|
bool target_attached(target *t);
|
||||||
|
|
||||||
/* Memory access functions */
|
/* Memory access functions */
|
||||||
void target_mem_read(target *t, void *dest, uint32_t src, size_t len);
|
void target_mem_read(target *t, void *dest, uint32_t src, size_t len);
|
||||||
|
@ -69,13 +71,11 @@ int target_clear_hw_bp(target *t, uint32_t addr, uint8_t len);
|
||||||
|
|
||||||
int target_set_hw_wp(target *t, uint8_t type, uint32_t addr, uint8_t len);
|
int target_set_hw_wp(target *t, uint8_t type, uint32_t addr, uint8_t len);
|
||||||
int target_clear_hw_wp(target *t, uint8_t type, uint32_t addr, uint8_t len);
|
int target_clear_hw_wp(target *t, uint8_t type, uint32_t addr, uint8_t len);
|
||||||
|
|
||||||
int target_check_hw_wp(target *t, uint32_t *addr);
|
int target_check_hw_wp(target *t, uint32_t *addr);
|
||||||
|
|
||||||
/* Flash memory access functions */
|
/* Flash memory access functions */
|
||||||
int target_flash_erase(target *t, uint32_t addr, size_t len);
|
int target_flash_erase(target *t, uint32_t addr, size_t len);
|
||||||
int target_flash_write(target *t,
|
int target_flash_write(target *t, uint32_t dest, const void *src, size_t len);
|
||||||
uint32_t dest, const void *src, size_t len);
|
|
||||||
int target_flash_done(target *t);
|
int target_flash_done(target *t);
|
||||||
|
|
||||||
/* Host I/O */
|
/* Host I/O */
|
||||||
|
@ -85,6 +85,7 @@ void target_hostio_reply(target *t, int32_t retcode, uint32_t errcode);
|
||||||
int target_regs_size(target *t);
|
int target_regs_size(target *t);
|
||||||
const char *target_tdesc(target *t);
|
const char *target_tdesc(target *t);
|
||||||
const char *target_mem_map(target *t);
|
const char *target_mem_map(target *t);
|
||||||
|
const char *target_driver_name(target *t);
|
||||||
|
|
||||||
struct target_command_s {
|
struct target_command_s {
|
||||||
const char *specific_name;
|
const char *specific_name;
|
||||||
|
|
27
src/target.c
27
src/target.c
|
@ -23,15 +23,24 @@
|
||||||
|
|
||||||
target *target_list = NULL;
|
target *target_list = NULL;
|
||||||
|
|
||||||
target *target_new(unsigned size)
|
target *target_new(void)
|
||||||
{
|
{
|
||||||
target *t = (void*)calloc(1, size);
|
target *t = (void*)calloc(1, sizeof(*t));
|
||||||
t->next = target_list;
|
t->next = target_list;
|
||||||
target_list = t;
|
target_list = t;
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool target_foreach(void (*cb)(int, target *t, void *context), void *context)
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
target *t = target_list;
|
||||||
|
for (; t; t = t->next, i++)
|
||||||
|
cb(i, t, context);
|
||||||
|
return target_list != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void target_list_free(void)
|
void target_list_free(void)
|
||||||
{
|
{
|
||||||
struct target_command_s *tc;
|
struct target_command_s *tc;
|
||||||
|
@ -100,6 +109,7 @@ target *target_attach(target *t, target_destroy_callback destroy_cb)
|
||||||
if (!t->attach(t))
|
if (!t->attach(t))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
t->attached = true;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,8 +275,14 @@ int target_flash_done_buffered(struct target_flash *f)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wrapper functions */
|
/* Wrapper functions */
|
||||||
void target_detach(target *t) { t->detach(t); }
|
void target_detach(target *t)
|
||||||
|
{
|
||||||
|
t->detach(t);
|
||||||
|
t->attached = false;
|
||||||
|
}
|
||||||
|
|
||||||
bool target_check_error(target *t) { return t->check_error(t); }
|
bool target_check_error(target *t) { return t->check_error(t); }
|
||||||
|
bool target_attached(target *t) { return t->attached; }
|
||||||
|
|
||||||
/* Memory access functions */
|
/* Memory access functions */
|
||||||
void target_mem_read(target *t, void *dest, uint32_t src, size_t len)
|
void target_mem_read(target *t, void *dest, uint32_t src, size_t len)
|
||||||
|
@ -332,6 +348,11 @@ const char *target_tdesc(target *t)
|
||||||
return t->tdesc ? t->tdesc : "";
|
return t->tdesc ? t->tdesc : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *target_driver_name(target *t)
|
||||||
|
{
|
||||||
|
return t->driver;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t target_mem_read32(target *t, uint32_t addr)
|
uint32_t target_mem_read32(target *t, uint32_t addr)
|
||||||
{
|
{
|
||||||
uint32_t ret;
|
uint32_t ret;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#define __TARGET_INTERNAL_H
|
#define __TARGET_INTERNAL_H
|
||||||
|
|
||||||
extern target *target_list;
|
extern target *target_list;
|
||||||
target *target_new(unsigned size);
|
target *target_new(void);
|
||||||
|
|
||||||
struct target_ram {
|
struct target_ram {
|
||||||
uint32_t start;
|
uint32_t start;
|
||||||
|
@ -55,6 +55,7 @@ struct target_flash {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct target_s {
|
struct target_s {
|
||||||
|
bool attached;
|
||||||
/* Notify controlling debugger if target is lost */
|
/* Notify controlling debugger if target is lost */
|
||||||
target_destroy_callback destroy_callback;
|
target_destroy_callback destroy_callback;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue