#include "config.h"
#endif
-#include <stdlib.h>
-#include <string.h>
-#ifdef HAVE_ELF_H
-#include <elf.h>
-#endif
-
#include "image.h"
-
-#include "types.h"
-#include "replacements.h"
+#include "target.h"
#include "log.h"
-#include "fileio.h"
-#include "target.h"
/* convert ELF header field to host endianness */
#define field16(elf,field)\
return ERROR_OK;
}
-int identify_image_type(image_t *image, char *type_string, char *url)
+static int identify_image_type(image_t *image, char *type_string, char *url)
{
if (type_string)
{
return ERROR_OK;
}
-int image_ihex_buffer_complete(image_t *image)
+static int image_ihex_buffer_complete(image_t *image)
{
image_ihex_t *ihex = image->type_private;
fileio_t *fileio = &ihex->fileio;
while (count-- > 0)
{
- sscanf(&lpszLine[bytes_read], "%2x", (u32*)&ihex->buffer[cooked_bytes]);
+ unsigned value;
+ sscanf(&lpszLine[bytes_read], "%2x", &value);
+ ihex->buffer[cooked_bytes] = (u8)value;
cal_checksum += (u8)ihex->buffer[cooked_bytes];
bytes_read += 2;
cooked_bytes += 1;
return ERROR_IMAGE_FORMAT_ERROR;
}
-int image_elf_read_headers(image_t *image)
+static int image_elf_read_headers(image_t *image)
{
image_elf_t *elf = image->type_private;
u32 read_bytes;
return ERROR_OK;
}
-int image_elf_read_section(image_t *image, int section, u32 offset, u32 size, u8 *buffer, u32 *size_read)
+static int image_elf_read_section(image_t *image, int section, u32 offset, u32 size, u8 *buffer, u32 *size_read)
{
image_elf_t *elf = image->type_private;
Elf32_Phdr *segment = (Elf32_Phdr *)image->sections[section].private;
return ERROR_OK;
}
-int image_mot_buffer_complete(image_t *image)
+static int image_mot_buffer_complete(image_t *image)
{
image_mot_t *mot = image->type_private;
fileio_t *fileio = &mot->fileio;
while (count-- > 0)
{
- sscanf(&lpszLine[bytes_read], "%2x", (u32*)&mot->buffer[cooked_bytes]);
+ unsigned value;
+ sscanf(&lpszLine[bytes_read], "%2x", &value);
+ mot->buffer[cooked_bytes] = (u8)value;
cal_checksum += (u8)mot->buffer[cooked_bytes];
bytes_read += 2;
cooked_bytes += 1;
}
else if (image->type == IMAGE_MEMORY)
{
- target_t *target = get_target_by_num(strtoul(url, NULL, 0));
- if (target==NULL)
+ target_t *target = get_target(url);
+
+ if (target == NULL)
{
- LOG_ERROR("Target '%s' does not exist", url);
+ LOG_ERROR("target '%s' not defined", url);
return ERROR_FAIL;
}