summaryrefslogtreecommitdiff
path: root/src/target/image.c
diff options
context:
space:
mode:
authordrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2007-08-14 09:48:54 +0000
committerdrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2007-08-14 09:48:54 +0000
commit29000b204d039bc1123027eba755329ab36a3dde (patch)
tree841d600e015592b5abd77b982dfb0d9cde51a399 /src/target/image.c
parentabbd2b62ad445d4056567e2573416498a55da9af (diff)
downloadopenocd_libswd-29000b204d039bc1123027eba755329ab36a3dde.tar.gz
openocd_libswd-29000b204d039bc1123027eba755329ab36a3dde.tar.bz2
openocd_libswd-29000b204d039bc1123027eba755329ab36a3dde.tar.xz
openocd_libswd-29000b204d039bc1123027eba755329ab36a3dde.zip
- reworked presto.c to allow use of either FTD2XX or libftdi (libftdi not functional yet). Configure option changed from --enable-presto to
--enable-presto_ftd2xx and --enable-presto_libftdi - completed trace point support for use with ARM7/9 DCC - completed debug message output with support for HEX dumps (1, 2 or 4 byte quantities) - fixed bug in delete_debug_msg_receiver (thanks to Pavel Chromy) - fixed bug in image_add_section (thanks to Pavel Chromy) - at91sam7 sector erase reworked (thanks to Pavel Chromy) - merge consecutive sections during flash image write to work around possible section alignment issues with LPC2000 targets git-svn-id: svn://svn.berlios.de/openocd/trunk@194 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/target/image.c')
-rw-r--r--src/target/image.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/target/image.c b/src/target/image.c
index c85f387d..0c203f6b 100644
--- a/src/target/image.c
+++ b/src/target/image.c
@@ -878,30 +878,37 @@ int image_read_section(image_t *image, int section, u32 offset, u32 size, u8 *bu
int image_add_section(image_t *image, u32 base, u32 size, int flags, u8 *data)
{
+ image_section_t *section;
+
/* only image builder supports adding sections */
if (image->type != IMAGE_BUILDER)
return ERROR_INVALID_ARGUMENTS;
- /* see if it's enough to extend an existing section */
- if (((image->sections[image->num_sections - 1].base_address + image->sections[image->num_sections - 1].size) == base)
- && (image->sections[image->num_sections - 1].flags == flags))
+ /* see if there's a previous section */
+ if (image->num_sections)
{
- u32 old_size = image->sections[image->num_sections - 1].size;
- image->sections[image->num_sections - 1].size += size;
- image->sections[image->num_sections - 1].private = realloc(image->sections[image->num_sections - 1].private, image->sections[image->num_sections - 1].size);
- memcpy((u8*)image->sections[image->num_sections - 1].private + old_size, data, size);
+ section = &image->sections[image->num_sections - 1];
- return ERROR_OK;
+ /* see if it's enough to extend the last section,
+ * adding data to previous sections or merging is not supported */
+ if (((section->base_address + section->size) == base) && (section->flags == flags))
+ {
+ section->private = realloc(section->private, section->size + size);
+ memcpy((u8*)section->private + section->size, data, size);
+ section->size += size;
+ return ERROR_OK;
+ }
}
/* allocate new section */
image->num_sections++;
image->sections = realloc(image->sections, sizeof(image_section_t) * image->num_sections);
- image->sections[image->num_sections - 1].base_address = base;
- image->sections[image->num_sections - 1].size = size;
- image->sections[image->num_sections - 1].flags = flags;
- image->sections[image->num_sections - 1].private = malloc(sizeof(u8) * size);
- memcpy((u8*)image->sections[image->num_sections - 1].private, data, size);
+ section = &image->sections[image->num_sections - 1];
+ section->base_address = base;
+ section->size = size;
+ section->flags = flags;
+ section->private = malloc(sizeof(u8) * size);
+ memcpy((u8*)section->private, data, size);
return ERROR_OK;
}