Construct memory map on the stack
The memory map uses 1k of SRAM and is only needed during attach. Release after use lowers pressure on SRAM.
This commit is contained in:
parent
6127a6431e
commit
5f404cdbc0
|
@ -354,7 +354,9 @@ handle_q_packet(char *packet, int len)
|
|||
gdb_putpacketz("E01");
|
||||
return;
|
||||
}
|
||||
handle_q_string_reply(target_mem_map(cur_target), packet + 23);
|
||||
char buf[1024];
|
||||
target_mem_map(cur_target, buf, sizeof(buf)); /* Fixme: Check size!*/
|
||||
handle_q_string_reply(buf, packet + 23);
|
||||
|
||||
} else if (strncmp (packet, "qXfer:features:read:target.xml:", 31) == 0) {
|
||||
/* Read target description */
|
||||
|
|
|
@ -45,7 +45,7 @@ bool target_attached(target *t);
|
|||
const char *target_driver_name(target *t);
|
||||
|
||||
/* Memory access functions */
|
||||
const char *target_mem_map(target *t);
|
||||
bool target_mem_map(target *t, char *buf, size_t len);
|
||||
int target_mem_read(target *t, void *dest, target_addr src, size_t len);
|
||||
int target_mem_write(target *t, target_addr dest, const void *src, size_t len);
|
||||
/* Flash memory access functions */
|
||||
|
|
|
@ -56,10 +56,6 @@ bool target_foreach(void (*cb)(int, target *t, void *context), void *context)
|
|||
|
||||
void target_mem_map_free(target *t)
|
||||
{
|
||||
if (t->dyn_mem_map) {
|
||||
free(t->dyn_mem_map);
|
||||
t->dyn_mem_map = NULL;
|
||||
}
|
||||
while (t->ram) {
|
||||
void * next = t->ram->next;
|
||||
free(t->ram);
|
||||
|
@ -175,14 +171,8 @@ static ssize_t map_flash(char *buf, size_t len, struct target_flash *f)
|
|||
return i;
|
||||
}
|
||||
|
||||
const char *target_mem_map(target *t)
|
||||
bool target_mem_map(target *t, char *tmp, size_t len)
|
||||
{
|
||||
if (t->dyn_mem_map)
|
||||
return t->dyn_mem_map;
|
||||
|
||||
/* FIXME size buffer */
|
||||
size_t len = 1024;
|
||||
char *tmp = malloc(len);
|
||||
size_t i = 0;
|
||||
i = snprintf(&tmp[i], len - i, "<memory-map>");
|
||||
/* Map each defined RAM */
|
||||
|
@ -193,9 +183,9 @@ const char *target_mem_map(target *t)
|
|||
i += map_flash(&tmp[i], len - i, f);
|
||||
i += snprintf(&tmp[i], len - i, "</memory-map>");
|
||||
|
||||
t->dyn_mem_map = tmp;
|
||||
|
||||
return t->dyn_mem_map;
|
||||
if (i > (len -2))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static struct target_flash *flash_for_addr(target *t, uint32_t addr)
|
||||
|
|
|
@ -109,8 +109,6 @@ struct target_s {
|
|||
unsigned target_options;
|
||||
uint32_t idcode;
|
||||
|
||||
/* Target memory map */
|
||||
char *dyn_mem_map;
|
||||
struct target_ram *ram;
|
||||
struct target_flash *flash;
|
||||
|
||||
|
|
Loading…
Reference in New Issue