- u32 start_address; /* start address, if one is set */
- char error_str[IMAGE_MAX_ERROR_STRING];
-} image_t;
-
-typedef struct image_binary_s
-{
- fileio_t fileio;
-} image_binary_t;
-
-typedef struct image_ihex_s
-{
- fileio_t fileio;
- u8 *buffer;
- u8 **section_pointer;
-} image_ihex_t;
-
-typedef struct image_memory_s
-{
- target_t *target;
-} image_memory_t;
-
-extern int image_open(image_t *image, void *source, enum fileio_access access);
-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);
+ uint32_t start_address; /* start address, if one is set */
+};
+
+struct image_binary {
+ struct fileio fileio;
+};
+
+struct image_ihex {
+ struct fileio fileio;
+ uint8_t *buffer;
+};
+
+struct image_memory {
+ struct target *target;
+ uint8_t *cache;
+ uint32_t cache_address;
+};
+
+struct image_elf {
+ struct fileio fileio;
+ Elf32_Ehdr *header;
+ Elf32_Phdr *segments;
+ uint32_t segment_count;
+ uint8_t endianness;
+};
+
+struct image_mot {
+ struct fileio fileio;
+ uint8_t *buffer;
+};
+
+int image_open(struct image *image, const char *url, const char *type_string);
+int image_read_section(struct image *image, int section, uint32_t offset,
+ uint32_t size, uint8_t *buffer, size_t *size_read);
+void image_close(struct image *image);
+
+int image_add_section(struct image *image, uint32_t base, uint32_t size,
+ int flags, uint8_t *data);
+
+int image_calculate_checksum(uint8_t *buffer, uint32_t nbytes,
+ uint32_t *checksum);