// -f - specify a flash address
#endif
//
-void
+void
do_load(int argc, char *argv[])
{
int res, num_options;
#ifdef CYGPKG_REDBOOT_NETWORKING
struct sockaddr_in host;
bool hostname_set, port_set;
- unsigned int port; // int because it's an OPTION_ARG_TYPE_NUM,
- // but will be cast to short
+ unsigned int port; // int because it's an OPTION_ARG_TYPE_NUM,
+ // but will be cast to short
char *hostname;
#endif
#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
host.sin_port = 0;
#endif
- init_opts(&opts[0], 'v', false, OPTION_ARG_TYPE_FLG,
- (void *)&verbose, 0, "verbose");
- init_opts(&opts[1], 'r', false, OPTION_ARG_TYPE_FLG,
- (void *)&raw, 0, "load raw data");
- init_opts(&opts[2], 'b', true, OPTION_ARG_TYPE_NUM,
- (void *)&base, (bool *)&base_addr_set, "load address");
- init_opts(&opts[3], 'm', true, OPTION_ARG_TYPE_STR,
- (void *)&mode_str, (bool *)&mode_str_set, "download mode (TFTP, xyzMODEM, or disk)");
- init_opts(&opts[4], 'z', false, OPTION_ARG_TYPE_FLG,
- (void *)&swap16bit, 0, "swap endianness on 16 bit");
+ init_opts(&opts[0], 'v', false, OPTION_ARG_TYPE_FLG,
+ &verbose, 0, "verbose");
+ init_opts(&opts[1], 'r', false, OPTION_ARG_TYPE_FLG,
+ &raw, 0, "load raw data");
+ init_opts(&opts[2], 'b', true, OPTION_ARG_TYPE_NUM,
+ &base, &base_addr_set, "load address");
+ init_opts(&opts[3], 'm', true, OPTION_ARG_TYPE_STR,
+ &mode_str, &mode_str_set, "download mode (TFTP, xyzMODEM, or disk)");
+ init_opts(&opts[4], 'z', false, OPTION_ARG_TYPE_FLG,
+ &swap16bit, 0, "swap endianness on 16 bit");
num_options = 5;
#if CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS > 1
- init_opts(&opts[num_options], 'c', true, OPTION_ARG_TYPE_NUM,
- (void *)&chan, (bool *)&chan_set, "I/O channel");
+ init_opts(&opts[num_options], 'c', true, OPTION_ARG_TYPE_NUM,
+ &chan, &chan_set, "I/O channel");
num_options++;
#endif
#ifdef CYGPKG_REDBOOT_NETWORKING
- init_opts(&opts[num_options], 'h', true, OPTION_ARG_TYPE_STR,
- (void *)&hostname, (bool *)&hostname_set, "host name or IP address");
+ init_opts(&opts[num_options], 'h', true, OPTION_ARG_TYPE_STR,
+ &hostname, &hostname_set, "host name or IP address");
num_options++;
- init_opts(&opts[num_options], 'p', true, OPTION_ARG_TYPE_NUM,
- (void *)&port, (bool *)&port_set, "TCP port");
+ init_opts(&opts[num_options], 'p', true, OPTION_ARG_TYPE_NUM,
+ &port, &port_set, "TCP port");
num_options++;
#endif
#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
- init_opts(&opts[num_options], 'd', false, OPTION_ARG_TYPE_FLG,
- (void *)&decompress, 0, "decompress");
+ init_opts(&opts[num_options], 'd', false, OPTION_ARG_TYPE_FLG,
+ &decompress, 0, "decompress");
num_options++;
#endif
#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
init_opts(&opts[num_options], 'f', true, OPTION_ARG_TYPE_NUM,
- (void *)&base, (bool *)&flash_addr_set, "flash address");
+ &base, &flash_addr_set, "flash address");
num_options++;
#endif
CYG_ASSERT(num_options <= NUM_ELEMS(opts), "Too many options");
-
- if (!scan_opts(argc, argv, 1, opts, num_options,
- (void *)&filename, OPTION_ARG_TYPE_STR, "file name")) {
+
+ if (!scan_opts(argc, argv, 1, opts, num_options,
+ &filename, OPTION_ARG_TYPE_STR, "file name")) {
return;
}
return;
}
}
- if (port_set)
+ if (port_set)
host.sin_port = port;
#endif
if (chan >= CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS) {
return;
}
if (mode_str_set) {
- for (io_tab = __RedBoot_LOAD_TAB__;
+ for (io_tab = __RedBoot_LOAD_TAB__;
io_tab != &__RedBoot_LOAD_TAB_END__; io_tab++) {
if (strncasecmp(&mode_str[0], io_tab->name, strlen(&mode_str[0])) == 0) {
io = io_tab->funcs;
}
if (!io) {
diag_printf("Invalid 'mode': %s. Valid modes are:", mode_str);
- for (io_tab = __RedBoot_LOAD_TAB__;
+ for (io_tab = __RedBoot_LOAD_TAB__;
io_tab != &__RedBoot_LOAD_TAB_END__; io_tab++) {
diag_printf(" %s", io_tab->name);
}
}
} else {
char *which = "";
- io_tab = (struct load_io_entry *)NULL; // Default
+ io_tab = NULL; // Default
#ifdef CYGPKG_REDBOOT_NETWORKING
-#ifdef CYGSEM_REDBOOT_NET_TFTP_DOWNLOAD
+#ifdef CYGSEM_REDBOOT_NET_TFTP_DOWNLOAD
which = "TFTP";
io = &tftp_io;
#elif defined(CYGSEM_REDBOOT_NET_HTTP_DOWNLOAD)
spillover_ok = true;
}
#endif
- if (raw && !(base_addr_set
+ if (raw && !(base_addr_set
#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
|| flash_addr_set
#endif
*mp++ = res;
}
}
- end = (unsigned long) mp;
+ end = (unsigned long)mp;
// Save load base/top
-
load_address_end = end;
- entry_address = base; // best guess
+ entry_address = base; // best guess
redboot_getc_terminate(false);
if (0 == err)
- diag_printf("Raw file loaded %p-%p, assumed entry at %p\n",
+ diag_printf("Raw file loaded %p-%p, assumed entry at %p\n",
(void *)load_address, (void *)(load_address_end - 1), (void*)entry_address);
} else {
// Read initial header - to determine file [image] type
if ((res = redboot_getc()) < 0) {
err = getc_info.err;
break;
- }
+ }
type[i] = res;
}
if (res >= 0) {
end = load_srec_image(redboot_getc, base, false);
}
} else {
+ unsigned long *tt = (unsigned long *)type;
redboot_getc_terminate(true);
- err_printf("Unrecognized image type: 0x%lx\n", *(unsigned long *)type);
+ err_printf("Unrecognized image type: 0x%lx\n", *tt);
}
}
}