target/image: Use proper data types
While at it, fix some coding style issues. Change-Id: Id521394d89e0bf787a6f812701c2cc0fe7e4e63f Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5919 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
parent
6dbfdcd00f
commit
73746d78b7
|
@ -702,7 +702,7 @@ int flash_write_unlock(struct target *target, struct image *image,
|
||||||
{
|
{
|
||||||
int retval = ERROR_OK;
|
int retval = ERROR_OK;
|
||||||
|
|
||||||
int section;
|
unsigned int section;
|
||||||
uint32_t section_offset;
|
uint32_t section_offset;
|
||||||
struct flash_bank *c;
|
struct flash_bank *c;
|
||||||
int *padding;
|
int *padding;
|
||||||
|
@ -727,8 +727,8 @@ int flash_write_unlock(struct target *target, struct image *image,
|
||||||
* whereas an image can have sections out of order. */
|
* whereas an image can have sections out of order. */
|
||||||
struct imagesection **sections = malloc(sizeof(struct imagesection *) *
|
struct imagesection **sections = malloc(sizeof(struct imagesection *) *
|
||||||
image->num_sections);
|
image->num_sections);
|
||||||
int i;
|
|
||||||
for (i = 0; i < image->num_sections; i++)
|
for (unsigned int i = 0; i < image->num_sections; i++)
|
||||||
sections[i] = &image->sections[i];
|
sections[i] = &image->sections[i];
|
||||||
|
|
||||||
qsort(sections, image->num_sections, sizeof(struct imagesection *),
|
qsort(sections, image->num_sections, sizeof(struct imagesection *),
|
||||||
|
@ -738,7 +738,7 @@ int flash_write_unlock(struct target *target, struct image *image,
|
||||||
while (section < image->num_sections) {
|
while (section < image->num_sections) {
|
||||||
uint32_t buffer_idx;
|
uint32_t buffer_idx;
|
||||||
uint8_t *buffer;
|
uint8_t *buffer;
|
||||||
int section_last;
|
unsigned int section_last;
|
||||||
target_addr_t run_address = sections[section]->base_address + section_offset;
|
target_addr_t run_address = sections[section]->base_address + section_offset;
|
||||||
uint32_t run_size = sections[section]->size - section_offset;
|
uint32_t run_size = sections[section]->size - section_offset;
|
||||||
int pad_bytes = 0;
|
int pad_bytes = 0;
|
||||||
|
|
|
@ -635,9 +635,9 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command)
|
||||||
|
|
||||||
/* The image will always start at offset 0 */
|
/* The image will always start at offset 0 */
|
||||||
struct image image;
|
struct image image;
|
||||||
image.base_address_set = 1;
|
image.base_address_set = true;
|
||||||
image.base_address = 0;
|
image.base_address = 0;
|
||||||
image.start_address_set = 0;
|
image.start_address_set = false;
|
||||||
|
|
||||||
const char *filename = CMD_ARGV[1];
|
const char *filename = CMD_ARGV[1];
|
||||||
const char *type = (CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL;
|
const char *type = (CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL;
|
||||||
|
|
|
@ -441,14 +441,14 @@ COMMAND_HANDLER(handle_flash_write_image_command)
|
||||||
duration_start(&bench);
|
duration_start(&bench);
|
||||||
|
|
||||||
if (CMD_ARGC >= 2) {
|
if (CMD_ARGC >= 2) {
|
||||||
image.base_address_set = 1;
|
image.base_address_set = true;
|
||||||
COMMAND_PARSE_NUMBER(llong, CMD_ARGV[1], image.base_address);
|
COMMAND_PARSE_NUMBER(llong, CMD_ARGV[1], image.base_address);
|
||||||
} else {
|
} else {
|
||||||
image.base_address_set = 0;
|
image.base_address_set = false;
|
||||||
image.base_address = 0x0;
|
image.base_address = 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
image.start_address_set = 0;
|
image.start_address_set = false;
|
||||||
|
|
||||||
retval = image_open(&image, CMD_ARGV[0], (CMD_ARGC == 3) ? CMD_ARGV[2] : NULL);
|
retval = image_open(&image, CMD_ARGV[0], (CMD_ARGC == 3) ? CMD_ARGV[2] : NULL);
|
||||||
if (retval != ERROR_OK)
|
if (retval != ERROR_OK)
|
||||||
|
|
|
@ -393,7 +393,7 @@ static int ulink_load_firmware_and_renumerate(struct ulink **device,
|
||||||
static int ulink_load_firmware(struct ulink *device, const char *filename)
|
static int ulink_load_firmware(struct ulink *device, const char *filename)
|
||||||
{
|
{
|
||||||
struct image ulink_firmware_image;
|
struct image ulink_firmware_image;
|
||||||
int ret, i;
|
int ret;
|
||||||
|
|
||||||
ret = ulink_cpu_reset(device, CPU_RESET);
|
ret = ulink_cpu_reset(device, CPU_RESET);
|
||||||
if (ret != ERROR_OK) {
|
if (ret != ERROR_OK) {
|
||||||
|
@ -402,7 +402,7 @@ static int ulink_load_firmware(struct ulink *device, const char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
ulink_firmware_image.base_address = 0;
|
ulink_firmware_image.base_address = 0;
|
||||||
ulink_firmware_image.base_address_set = 0;
|
ulink_firmware_image.base_address_set = false;
|
||||||
|
|
||||||
ret = image_open(&ulink_firmware_image, filename, "ihex");
|
ret = image_open(&ulink_firmware_image, filename, "ihex");
|
||||||
if (ret != ERROR_OK) {
|
if (ret != ERROR_OK) {
|
||||||
|
@ -411,7 +411,7 @@ static int ulink_load_firmware(struct ulink *device, const char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Download all sections in the image to ULINK */
|
/* Download all sections in the image to ULINK */
|
||||||
for (i = 0; i < ulink_firmware_image.num_sections; i++) {
|
for (unsigned int i = 0; i < ulink_firmware_image.num_sections; i++) {
|
||||||
ret = ulink_write_firmware_section(device, &ulink_firmware_image, i);
|
ret = ulink_write_firmware_section(device, &ulink_firmware_image, i);
|
||||||
if (ret != ERROR_OK)
|
if (ret != ERROR_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -134,7 +134,7 @@ static int load_usb_blaster_firmware(struct libusb_device_handle *libusb_dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
ublast2_firmware_image.base_address = 0;
|
ublast2_firmware_image.base_address = 0;
|
||||||
ublast2_firmware_image.base_address_set = 0;
|
ublast2_firmware_image.base_address_set = false;
|
||||||
|
|
||||||
int ret = image_open(&ublast2_firmware_image, low->firmware_path, "ihex");
|
int ret = image_open(&ublast2_firmware_image, low->firmware_path, "ihex");
|
||||||
if (ret != ERROR_OK) {
|
if (ret != ERROR_OK) {
|
||||||
|
@ -162,7 +162,7 @@ static int load_usb_blaster_firmware(struct libusb_device_handle *libusb_dev,
|
||||||
100);
|
100);
|
||||||
|
|
||||||
/* Download all sections in the image to ULINK */
|
/* Download all sections in the image to ULINK */
|
||||||
for (int i = 0; i < ublast2_firmware_image.num_sections; i++) {
|
for (unsigned int i = 0; i < ublast2_firmware_image.num_sections; i++) {
|
||||||
ret = ublast2_write_firmware_section(libusb_dev,
|
ret = ublast2_write_firmware_section(libusb_dev,
|
||||||
&ublast2_firmware_image, i);
|
&ublast2_firmware_image, i);
|
||||||
if (ret != ERROR_OK) {
|
if (ret != ERROR_OK) {
|
||||||
|
|
|
@ -650,7 +650,6 @@ static struct etm_capture_driver *etm_capture_drivers[] = {
|
||||||
|
|
||||||
static int etm_read_instruction(struct etm_context *ctx, struct arm_instruction *instruction)
|
static int etm_read_instruction(struct etm_context *ctx, struct arm_instruction *instruction)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int section = -1;
|
int section = -1;
|
||||||
size_t size_read;
|
size_t size_read;
|
||||||
uint32_t opcode;
|
uint32_t opcode;
|
||||||
|
@ -660,7 +659,7 @@ static int etm_read_instruction(struct etm_context *ctx, struct arm_instruction
|
||||||
return ERROR_TRACE_IMAGE_UNAVAILABLE;
|
return ERROR_TRACE_IMAGE_UNAVAILABLE;
|
||||||
|
|
||||||
/* search for the section the current instruction belongs to */
|
/* search for the section the current instruction belongs to */
|
||||||
for (i = 0; i < ctx->image->num_sections; i++) {
|
for (unsigned int i = 0; i < ctx->image->num_sections; i++) {
|
||||||
if ((ctx->image->sections[i].base_address <= ctx->current_pc) &&
|
if ((ctx->image->sections[i].base_address <= ctx->current_pc) &&
|
||||||
(ctx->image->sections[i].base_address + ctx->image->sections[i].size >
|
(ctx->image->sections[i].base_address + ctx->image->sections[i].size >
|
||||||
ctx->current_pc)) {
|
ctx->current_pc)) {
|
||||||
|
@ -1683,15 +1682,15 @@ COMMAND_HANDLER(handle_etm_image_command)
|
||||||
}
|
}
|
||||||
|
|
||||||
etm_ctx->image = malloc(sizeof(struct image));
|
etm_ctx->image = malloc(sizeof(struct image));
|
||||||
etm_ctx->image->base_address_set = 0;
|
etm_ctx->image->base_address_set = false;
|
||||||
etm_ctx->image->start_address_set = 0;
|
etm_ctx->image->start_address_set = false;
|
||||||
|
|
||||||
/* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
|
/* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
|
||||||
if (CMD_ARGC >= 2) {
|
if (CMD_ARGC >= 2) {
|
||||||
etm_ctx->image->base_address_set = 1;
|
etm_ctx->image->base_address_set = true;
|
||||||
COMMAND_PARSE_NUMBER(llong, CMD_ARGV[1], etm_ctx->image->base_address);
|
COMMAND_PARSE_NUMBER(llong, CMD_ARGV[1], etm_ctx->image->base_address);
|
||||||
} else
|
} else
|
||||||
etm_ctx->image->base_address_set = 0;
|
etm_ctx->image->base_address_set = false;
|
||||||
|
|
||||||
if (image_open(etm_ctx->image, CMD_ARGV[0],
|
if (image_open(etm_ctx->image, CMD_ARGV[0],
|
||||||
(CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL) != ERROR_OK) {
|
(CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL) != ERROR_OK) {
|
||||||
|
|
|
@ -124,7 +124,6 @@ static int image_ihex_buffer_complete_inner(struct image *image,
|
||||||
uint32_t full_address;
|
uint32_t full_address;
|
||||||
uint32_t cooked_bytes;
|
uint32_t cooked_bytes;
|
||||||
bool end_rec = false;
|
bool end_rec = false;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* we can't determine the number of sections that we'll have to create ahead of time,
|
/* we can't determine the number of sections that we'll have to create ahead of time,
|
||||||
* so we locally hold them until parsing is finished */
|
* so we locally hold them until parsing is finished */
|
||||||
|
@ -207,7 +206,7 @@ static int image_ihex_buffer_complete_inner(struct image *image,
|
||||||
|
|
||||||
/* copy section information */
|
/* copy section information */
|
||||||
image->sections = malloc(sizeof(struct imagesection) * image->num_sections);
|
image->sections = malloc(sizeof(struct imagesection) * image->num_sections);
|
||||||
for (i = 0; i < image->num_sections; i++) {
|
for (unsigned int i = 0; i < image->num_sections; i++) {
|
||||||
image->sections[i].private = section[i].private;
|
image->sections[i].private = section[i].private;
|
||||||
image->sections[i].base_address = section[i].base_address;
|
image->sections[i].base_address = section[i].base_address;
|
||||||
image->sections[i].size = section[i].size;
|
image->sections[i].size = section[i].size;
|
||||||
|
@ -294,7 +293,7 @@ static int image_ihex_buffer_complete_inner(struct image *image,
|
||||||
cal_checksum += (uint8_t)start_address;
|
cal_checksum += (uint8_t)start_address;
|
||||||
bytes_read += 8;
|
bytes_read += 8;
|
||||||
|
|
||||||
image->start_address_set = 1;
|
image->start_address_set = true;
|
||||||
image->start_address = be_to_h_u32((uint8_t *)&start_address);
|
image->start_address = be_to_h_u32((uint8_t *)&start_address);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR("unhandled IHEX record type: %i", (int)record_type);
|
LOG_ERROR("unhandled IHEX record type: %i", (int)record_type);
|
||||||
|
@ -471,7 +470,7 @@ static int image_elf_read_headers(struct image *image)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
image->start_address_set = 1;
|
image->start_address_set = true;
|
||||||
image->start_address = field32(elf, elf->header->e_entry);
|
image->start_address = field32(elf, elf->header->e_entry);
|
||||||
|
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
|
@ -529,7 +528,6 @@ static int image_mot_buffer_complete_inner(struct image *image,
|
||||||
uint32_t full_address;
|
uint32_t full_address;
|
||||||
uint32_t cooked_bytes;
|
uint32_t cooked_bytes;
|
||||||
bool end_rec = false;
|
bool end_rec = false;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* we can't determine the number of sections that we'll have to create ahead of time,
|
/* we can't determine the number of sections that we'll have to create ahead of time,
|
||||||
* so we locally hold them until parsing is finished */
|
* so we locally hold them until parsing is finished */
|
||||||
|
@ -658,7 +656,7 @@ static int image_mot_buffer_complete_inner(struct image *image,
|
||||||
|
|
||||||
/* copy section information */
|
/* copy section information */
|
||||||
image->sections = malloc(sizeof(struct imagesection) * image->num_sections);
|
image->sections = malloc(sizeof(struct imagesection) * image->num_sections);
|
||||||
for (i = 0; i < image->num_sections; i++) {
|
for (unsigned int i = 0; i < image->num_sections; i++) {
|
||||||
image->sections[i].private = section[i].private;
|
image->sections[i].private = section[i].private;
|
||||||
image->sections[i].base_address = section[i].base_address;
|
image->sections[i].base_address = section[i].base_address;
|
||||||
image->sections[i].size = section[i].size;
|
image->sections[i].size = section[i].size;
|
||||||
|
@ -821,21 +819,20 @@ int image_open(struct image *image, const char *url, const char *type_string)
|
||||||
}
|
}
|
||||||
} else if (image->type == IMAGE_BUILDER) {
|
} else if (image->type == IMAGE_BUILDER) {
|
||||||
image->num_sections = 0;
|
image->num_sections = 0;
|
||||||
image->base_address_set = 0;
|
image->base_address_set = false;
|
||||||
image->sections = NULL;
|
image->sections = NULL;
|
||||||
image->type_private = NULL;
|
image->type_private = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (image->base_address_set) {
|
if (image->base_address_set) {
|
||||||
/* relocate */
|
/* relocate */
|
||||||
int section;
|
for (unsigned int section = 0; section < image->num_sections; section++)
|
||||||
for (section = 0; section < image->num_sections; section++)
|
|
||||||
image->sections[section].base_address += image->base_address;
|
image->sections[section].base_address += image->base_address;
|
||||||
/* we're done relocating. The two statements below are mainly
|
/* we're done relocating. The two statements below are mainly
|
||||||
* for documentation purposes: stop anyone from empirically
|
* for documentation purposes: stop anyone from empirically
|
||||||
* thinking they should use these values henceforth. */
|
* thinking they should use these values henceforth. */
|
||||||
image->base_address = 0;
|
image->base_address = 0;
|
||||||
image->base_address_set = 0;
|
image->base_address_set = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -1009,9 +1006,7 @@ void image_close(struct image *image)
|
||||||
free(image_mot->buffer);
|
free(image_mot->buffer);
|
||||||
image_mot->buffer = NULL;
|
image_mot->buffer = NULL;
|
||||||
} else if (image->type == IMAGE_BUILDER) {
|
} else if (image->type == IMAGE_BUILDER) {
|
||||||
int i;
|
for (unsigned int i = 0; i < image->num_sections; i++) {
|
||||||
|
|
||||||
for (i = 0; i < image->num_sections; i++) {
|
|
||||||
free(image->sections[i].private);
|
free(image->sections[i].private);
|
||||||
image->sections[i].private = NULL;
|
image->sections[i].private = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,11 +55,11 @@ struct imagesection {
|
||||||
struct image {
|
struct image {
|
||||||
enum image_type type; /* image type (plain, ihex, ...) */
|
enum image_type type; /* image type (plain, ihex, ...) */
|
||||||
void *type_private; /* type private data */
|
void *type_private; /* type private data */
|
||||||
int num_sections; /* number of sections contained in the image */
|
unsigned int num_sections; /* number of sections contained in the image */
|
||||||
struct imagesection *sections; /* array of sections */
|
struct imagesection *sections; /* array of sections */
|
||||||
int base_address_set; /* whether the image has a base address set (for relocation purposes) */
|
bool base_address_set; /* whether the image has a base address set (for relocation purposes) */
|
||||||
long long base_address; /* base address, if one is set */
|
long long base_address; /* base address, if one is set */
|
||||||
int start_address_set; /* whether the image has a start address (entry point) associated */
|
bool start_address_set; /* whether the image has a start address (entry point) associated */
|
||||||
uint32_t start_address; /* start address, if one is set */
|
uint32_t start_address; /* start address, if one is set */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3404,11 +3404,11 @@ static COMMAND_HELPER(parse_load_image_command_CMD_ARGV, struct image *image,
|
||||||
target_addr_t addr;
|
target_addr_t addr;
|
||||||
COMMAND_PARSE_ADDRESS(CMD_ARGV[1], addr);
|
COMMAND_PARSE_ADDRESS(CMD_ARGV[1], addr);
|
||||||
image->base_address = addr;
|
image->base_address = addr;
|
||||||
image->base_address_set = 1;
|
image->base_address_set = true;
|
||||||
} else
|
} else
|
||||||
image->base_address_set = 0;
|
image->base_address_set = false;
|
||||||
|
|
||||||
image->start_address_set = 0;
|
image->start_address_set = false;
|
||||||
|
|
||||||
if (CMD_ARGC >= 4)
|
if (CMD_ARGC >= 4)
|
||||||
COMMAND_PARSE_ADDRESS(CMD_ARGV[3], *min_address);
|
COMMAND_PARSE_ADDRESS(CMD_ARGV[3], *min_address);
|
||||||
|
@ -3431,7 +3431,6 @@ COMMAND_HANDLER(handle_load_image_command)
|
||||||
uint32_t image_size;
|
uint32_t image_size;
|
||||||
target_addr_t min_address = 0;
|
target_addr_t min_address = 0;
|
||||||
target_addr_t max_address = -1;
|
target_addr_t max_address = -1;
|
||||||
int i;
|
|
||||||
struct image image;
|
struct image image;
|
||||||
|
|
||||||
int retval = CALL_COMMAND_HANDLER(parse_load_image_command_CMD_ARGV,
|
int retval = CALL_COMMAND_HANDLER(parse_load_image_command_CMD_ARGV,
|
||||||
|
@ -3449,7 +3448,7 @@ COMMAND_HANDLER(handle_load_image_command)
|
||||||
|
|
||||||
image_size = 0x0;
|
image_size = 0x0;
|
||||||
retval = ERROR_OK;
|
retval = ERROR_OK;
|
||||||
for (i = 0; i < image.num_sections; i++) {
|
for (unsigned int i = 0; i < image.num_sections; i++) {
|
||||||
buffer = malloc(image.sections[i].size);
|
buffer = malloc(image.sections[i].size);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
command_print(CMD,
|
command_print(CMD,
|
||||||
|
@ -3582,7 +3581,6 @@ static COMMAND_HELPER(handle_verify_image_command_internal, enum verify_mode ver
|
||||||
uint8_t *buffer;
|
uint8_t *buffer;
|
||||||
size_t buf_cnt;
|
size_t buf_cnt;
|
||||||
uint32_t image_size;
|
uint32_t image_size;
|
||||||
int i;
|
|
||||||
int retval;
|
int retval;
|
||||||
uint32_t checksum = 0;
|
uint32_t checksum = 0;
|
||||||
uint32_t mem_checksum = 0;
|
uint32_t mem_checksum = 0;
|
||||||
|
@ -3606,13 +3604,13 @@ static COMMAND_HELPER(handle_verify_image_command_internal, enum verify_mode ver
|
||||||
target_addr_t addr;
|
target_addr_t addr;
|
||||||
COMMAND_PARSE_ADDRESS(CMD_ARGV[1], addr);
|
COMMAND_PARSE_ADDRESS(CMD_ARGV[1], addr);
|
||||||
image.base_address = addr;
|
image.base_address = addr;
|
||||||
image.base_address_set = 1;
|
image.base_address_set = true;
|
||||||
} else {
|
} else {
|
||||||
image.base_address_set = 0;
|
image.base_address_set = false;
|
||||||
image.base_address = 0x0;
|
image.base_address = 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
image.start_address_set = 0;
|
image.start_address_set = false;
|
||||||
|
|
||||||
retval = image_open(&image, CMD_ARGV[0], (CMD_ARGC == 3) ? CMD_ARGV[2] : NULL);
|
retval = image_open(&image, CMD_ARGV[0], (CMD_ARGC == 3) ? CMD_ARGV[2] : NULL);
|
||||||
if (retval != ERROR_OK)
|
if (retval != ERROR_OK)
|
||||||
|
@ -3621,12 +3619,12 @@ static COMMAND_HELPER(handle_verify_image_command_internal, enum verify_mode ver
|
||||||
image_size = 0x0;
|
image_size = 0x0;
|
||||||
int diffs = 0;
|
int diffs = 0;
|
||||||
retval = ERROR_OK;
|
retval = ERROR_OK;
|
||||||
for (i = 0; i < image.num_sections; i++) {
|
for (unsigned int i = 0; i < image.num_sections; i++) {
|
||||||
buffer = malloc(image.sections[i].size);
|
buffer = malloc(image.sections[i].size);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
command_print(CMD,
|
command_print(CMD,
|
||||||
"error allocating buffer for section (%d bytes)",
|
"error allocating buffer for section (%" PRIu32 " bytes)",
|
||||||
(int)(image.sections[i].size));
|
image.sections[i].size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
retval = image_read_section(&image, i, 0x0, image.sections[i].size, buffer, &buf_cnt);
|
retval = image_read_section(&image, i, 0x0, image.sections[i].size, buffer, &buf_cnt);
|
||||||
|
@ -5871,7 +5869,6 @@ COMMAND_HANDLER(handle_fast_load_image_command)
|
||||||
uint32_t image_size;
|
uint32_t image_size;
|
||||||
target_addr_t min_address = 0;
|
target_addr_t min_address = 0;
|
||||||
target_addr_t max_address = -1;
|
target_addr_t max_address = -1;
|
||||||
int i;
|
|
||||||
|
|
||||||
struct image image;
|
struct image image;
|
||||||
|
|
||||||
|
@ -5897,7 +5894,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
}
|
}
|
||||||
memset(fastload, 0, sizeof(struct FastLoad)*image.num_sections);
|
memset(fastload, 0, sizeof(struct FastLoad)*image.num_sections);
|
||||||
for (i = 0; i < image.num_sections; i++) {
|
for (unsigned int i = 0; i < image.num_sections; i++) {
|
||||||
buffer = malloc(image.sections[i].size);
|
buffer = malloc(image.sections[i].size);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
command_print(CMD, "error allocating buffer for section (%d bytes)",
|
command_print(CMD, "error allocating buffer for section (%d bytes)",
|
||||||
|
|
|
@ -2582,7 +2582,6 @@ static int xscale_read_instruction(struct target *target, uint32_t pc,
|
||||||
struct arm_instruction *instruction)
|
struct arm_instruction *instruction)
|
||||||
{
|
{
|
||||||
struct xscale_common *const xscale = target_to_xscale(target);
|
struct xscale_common *const xscale = target_to_xscale(target);
|
||||||
int i;
|
|
||||||
int section = -1;
|
int section = -1;
|
||||||
size_t size_read;
|
size_t size_read;
|
||||||
uint32_t opcode;
|
uint32_t opcode;
|
||||||
|
@ -2592,7 +2591,7 @@ static int xscale_read_instruction(struct target *target, uint32_t pc,
|
||||||
return ERROR_TRACE_IMAGE_UNAVAILABLE;
|
return ERROR_TRACE_IMAGE_UNAVAILABLE;
|
||||||
|
|
||||||
/* search for the section the current instruction belongs to */
|
/* search for the section the current instruction belongs to */
|
||||||
for (i = 0; i < xscale->trace.image->num_sections; i++) {
|
for (unsigned int i = 0; i < xscale->trace.image->num_sections; i++) {
|
||||||
if ((xscale->trace.image->sections[i].base_address <= pc) &&
|
if ((xscale->trace.image->sections[i].base_address <= pc) &&
|
||||||
(xscale->trace.image->sections[i].base_address +
|
(xscale->trace.image->sections[i].base_address +
|
||||||
xscale->trace.image->sections[i].size > pc)) {
|
xscale->trace.image->sections[i].size > pc)) {
|
||||||
|
@ -3428,15 +3427,15 @@ COMMAND_HANDLER(xscale_handle_trace_image_command)
|
||||||
}
|
}
|
||||||
|
|
||||||
xscale->trace.image = malloc(sizeof(struct image));
|
xscale->trace.image = malloc(sizeof(struct image));
|
||||||
xscale->trace.image->base_address_set = 0;
|
xscale->trace.image->base_address_set = false;
|
||||||
xscale->trace.image->start_address_set = 0;
|
xscale->trace.image->start_address_set = false;
|
||||||
|
|
||||||
/* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
|
/* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
|
||||||
if (CMD_ARGC >= 2) {
|
if (CMD_ARGC >= 2) {
|
||||||
xscale->trace.image->base_address_set = 1;
|
xscale->trace.image->base_address_set = true;
|
||||||
COMMAND_PARSE_NUMBER(llong, CMD_ARGV[1], xscale->trace.image->base_address);
|
COMMAND_PARSE_NUMBER(llong, CMD_ARGV[1], xscale->trace.image->base_address);
|
||||||
} else
|
} else
|
||||||
xscale->trace.image->base_address_set = 0;
|
xscale->trace.image->base_address_set = false;
|
||||||
|
|
||||||
if (image_open(xscale->trace.image, CMD_ARGV[0],
|
if (image_open(xscale->trace.image, CMD_ARGV[0],
|
||||||
(CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL) != ERROR_OK) {
|
(CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL) != ERROR_OK) {
|
||||||
|
|
Loading…
Reference in New Issue