-
- /* DANGER!!! beware of unsigned comparision here!!! */
-
- if ((image.sections[i].base_address+buf_cnt>=min_address)&&
- (image.sections[i].base_address<max_address))
- {
- if (image.sections[i].base_address<min_address)
- {
- /* clip addresses below */
- offset+=min_address-image.sections[i].base_address;
- length-=offset;
- }
-
- if (image.sections[i].base_address+buf_cnt>max_address)
- {
- length-=(image.sections[i].base_address+buf_cnt)-max_address;
- }
-
- fastload[i].address=image.sections[i].base_address+offset;
- fastload[i].data=malloc(length);
- if (fastload[i].data==NULL)
- {
- free(buffer);
- break;
- }
- memcpy(fastload[i].data, buffer+offset, length);
- fastload[i].length=length;
-
- image_size += length;
- command_print(cmd_ctx, "%u byte written at address 0x%8.8x", length, image.sections[i].base_address+offset);
- }
-
- free(buffer);
- }
-
- duration_stop_measure(&duration, &duration_text);
- if (retval==ERROR_OK)
- {
- command_print(cmd_ctx, "Loaded %u bytes in %s", image_size, duration_text);
- command_print(cmd_ctx, "NB!!! image has not been loaded to target, issue a subsequent 'fast_load' to do so.");
- }
- free(duration_text);
-
- image_close(&image);
-
- if (retval!=ERROR_OK)
- {
- free_fastload();
- }
-
- return retval;
-}
-
-int handle_fast_load_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
-{
- if (argc>0)
- return ERROR_COMMAND_SYNTAX_ERROR;
- if (fastload==NULL)
- {
- LOG_ERROR("No image in memory");
- return ERROR_FAIL;
- }
- int i;
- int ms=timeval_ms();
- int size=0;
- for (i=0; i<fastload_num;i++)
- {
- int retval;
- target_t *target = get_current_target(cmd_ctx);
- if ((retval = target_write_buffer(target, fastload[i].address, fastload[i].length, fastload[i].data)) != ERROR_OK)
- {
- return retval;
- }
- size+=fastload[i].length;
- }
- int after=timeval_ms();
- command_print(cmd_ctx, "Loaded image %f kBytes/s", (float)(size/1024.0)/((float)(after-ms)/1000.0));
- return ERROR_OK;
-}
-
-
-/* Give TELNET a way to find out what version this is */
-int handle_zy1000_version_command(struct command_context_s *cmd_ctx, char *cmd,
- char **args, int argc)
-{
- if (argc > 1)
- {
- return ERROR_COMMAND_SYNTAX_ERROR;
- }
- if (argc == 0)
- {
- command_print(cmd_ctx, ZYLIN_OPENOCD_VERSION);
- } else if (strcmp("openocd", args[0])==0)
- {
- int revision;
- revision=atol(ZYLIN_OPENOCD+strlen("XRevision: "));
- command_print(cmd_ctx, "%d", revision);
- } else if (strcmp("zy1000", args[0])==0)
- {
- command_print(cmd_ctx, "%s", ZYLIN_VERSION);
- } else if (strcmp("date", args[0])==0)
- {
- command_print(cmd_ctx, "%s", ZYLIN_DATE);
- } else
- {
- return ERROR_COMMAND_SYNTAX_ERROR;
- }
-
- return ERROR_OK;
-}
-
-extern flash_driver_t *flash_drivers[];
-extern target_type_t *target_types[];