mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-31 10:09:16 +08:00
* Makefile.in (SFILES): Add target-memory.c.
(COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
This commit is contained in:
46
gdb/target.c
46
gdb/target.c
@ -465,6 +465,8 @@ update_current_target (void)
|
||||
INHERIT (to_get_thread_local_address, t);
|
||||
INHERIT (to_magic, t);
|
||||
/* Do not inherit to_memory_map. */
|
||||
/* Do not inherit to_flash_erase. */
|
||||
/* Do not inherit to_flash_done. */
|
||||
}
|
||||
#undef INHERIT
|
||||
|
||||
@ -892,6 +894,12 @@ memory_xfer_partial (struct target_ops *ops, void *readbuf, const void *writebuf
|
||||
if (readbuf != NULL)
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case MEM_FLASH:
|
||||
/* We only support writing to flash during "load" for now. */
|
||||
if (writebuf != NULL)
|
||||
error (_("Writing to flash memory forbidden in this context"));
|
||||
break;
|
||||
}
|
||||
|
||||
if (region->attrib.cache)
|
||||
@ -1089,6 +1097,39 @@ target_memory_map (void)
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
target_flash_erase (ULONGEST address, LONGEST length)
|
||||
{
|
||||
struct target_ops *t;
|
||||
|
||||
for (t = current_target.beneath; t != NULL; t = t->beneath)
|
||||
if (t->to_flash_erase != NULL)
|
||||
{
|
||||
if (targetdebug)
|
||||
fprintf_unfiltered (gdb_stdlog, "target_flash_erase (%s, %s)\n",
|
||||
paddr (address), phex (length, 0));
|
||||
return t->to_flash_erase (t, address, length);
|
||||
}
|
||||
|
||||
tcomplain ();
|
||||
}
|
||||
|
||||
void
|
||||
target_flash_done (void)
|
||||
{
|
||||
struct target_ops *t;
|
||||
|
||||
for (t = current_target.beneath; t != NULL; t = t->beneath)
|
||||
if (t->to_flash_done != NULL)
|
||||
{
|
||||
if (targetdebug)
|
||||
fprintf_unfiltered (gdb_stdlog, "target_flash_done\n");
|
||||
return t->to_flash_done (t);
|
||||
}
|
||||
|
||||
tcomplain ();
|
||||
}
|
||||
|
||||
#ifndef target_stopped_data_address_p
|
||||
int
|
||||
target_stopped_data_address_p (struct target_ops *target)
|
||||
@ -1229,6 +1270,11 @@ target_write_with_progress (struct target_ops *ops,
|
||||
void (*progress) (ULONGEST, void *), void *baton)
|
||||
{
|
||||
LONGEST xfered = 0;
|
||||
|
||||
/* Give the progress callback a chance to set up. */
|
||||
if (progress)
|
||||
(*progress) (0, baton);
|
||||
|
||||
while (xfered < len)
|
||||
{
|
||||
LONGEST xfer = target_write_partial (ops, object, annex,
|
||||
|
Reference in New Issue
Block a user