From f94d66d7c5f3c018ba72593b720746e4c5be1a16 Mon Sep 17 00:00:00 2001 From: drath Date: Wed, 30 May 2007 15:47:18 +0000 Subject: - reworked image handling to support multiple sections (tested with ihex file containing gaps) This checkin is still experimental, not recommended for general use git-svn-id: svn://svn.berlios.de/openocd/trunk@159 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/target/image.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/target/image.h') diff --git a/src/target/image.h b/src/target/image.h index 3df175a8..75288791 100644 --- a/src/target/image.h +++ b/src/target/image.h @@ -24,11 +24,12 @@ #include "target.h" #define IMAGE_MAX_ERROR_STRING (128) +#define IMAGE_MAX_SECTIONS (128) typedef enum image_type { IMAGE_BINARY, /* plain binary */ - IMAGE_IHEX, /* intel hex-record format */ + IMAGE_IHEX, /* intel hex-record format */ IMAGE_MEMORY, /* target-memory pseudo-image */ /* * Possible future enhancements: @@ -37,15 +38,23 @@ typedef enum image_type */ } image_type_t; +typedef struct image_section_s +{ + u32 base_address; + u32 size; + int flags; +} image_section_t; + typedef struct image_s { image_type_t type; /* image type (plain, ihex, ...) */ void *type_private; /* type private data */ - int base_address_set; /* whether the image start address has been set */ - u32 base_address; /* base address of image in target memory */ + int num_sections; /* number of sections contained in the image */ + image_section_t *sections; /* array of sections */ + int base_address_set; /* whether the image has a base address set (for relocation purposes) */ + int base_address; /* base address, if one is set */ int start_address_set; /* whether the image has a start address (entry point) associated */ u32 start_address; /* start address, if one is set */ - u32 size; /* image size in byte */ char error_str[IMAGE_MAX_ERROR_STRING]; } image_t; @@ -57,9 +66,8 @@ typedef struct image_binary_s typedef struct image_ihex_s { fileio_t fileio; - u32 position; - u32 raw_size; u8 *buffer; + u8 **section_pointer; } image_ihex_t; typedef struct image_memory_s @@ -68,8 +76,7 @@ typedef struct image_memory_s } image_memory_t; extern int image_open(image_t *image, void *source, enum fileio_access access); -extern int image_read(image_t *image, u32 size, u8 *buffer, u32 *size_written); -extern int image_write(image_t *image, u32 size, u8 *buffer, u32 *size_written); +extern int image_read_section(image_t *image, int section, u32 offset, u32 size, u8 *buffer, u32 *size_read); extern int image_close(image_t *image); extern int identify_image_type(image_type_t *type, char *type_string); -- cgit v1.2.3