#endif
#ifdef CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH
-externC bool do_flash_init(void);
+externC int do_flash_init(void);
externC int flash_read(void *flash_base, void *ram_base, int len, void **err_address);
#endif
while (dp < &p->config_data[sizeof(config->config_data)]) {
len = 4 + CONFIG_OBJECT_KEYLEN(dp) + CONFIG_OBJECT_ENABLE_KEYLEN(dp) +
config_length(CONFIG_OBJECT_TYPE(dp));
- val_ptr = (void *)CONFIG_OBJECT_VALUE(dp);
+ val_ptr = CONFIG_OBJECT_VALUE(dp);
switch (CONFIG_OBJECT_TYPE(dp)) {
// Note: the data may be unaligned in the configuration data
return CONFIG_OK; // Disabled field
}
}
- lp = line; *lp = '\0';
- val_ptr = (void *)CONFIG_OBJECT_VALUE(dp);
+ lp = line;
+ *lp = '\0';
+ val_ptr = CONFIG_OBJECT_VALUE(dp);
if (LIST_OPT_NICKNAMES & list_opt)
diag_printf("%s: ", CONFIG_OBJECT_KEY(dp));
if (LIST_OPT_FULLNAMES & list_opt) {
- if (title != (char *)NULL) {
+ if (title != NULL) {
diag_printf("%s: ", title);
} else {
diag_printf("%s: ", CONFIG_OBJECT_KEY(dp));
}
#endif
memcpy(backup_config, config, sizeof(struct _config));
- script = (unsigned char *)0;
+ script = NULL;
init_opts(&opts[0], 'l', false, OPTION_ARG_TYPE_FLG,
- (void *)&list_only, (bool *)0, "list configuration only");
+ &list_only, NULL, "list configuration only");
init_opts(&opts[1], 'n', false, OPTION_ARG_TYPE_FLG,
- (void *)&nicknames, (bool *)0, "show nicknames");
+ &nicknames, NULL, "show nicknames");
init_opts(&opts[2], 'f', false, OPTION_ARG_TYPE_FLG,
- (void *)&fullnames, (bool *)0, "show full names");
+ &fullnames, NULL, "show full names");
init_opts(&opts[3], 'i', false, OPTION_ARG_TYPE_FLG,
- (void *)&init, (bool *)0, "initialize configuration database");
+ &init, NULL, "initialize configuration database");
init_opts(&opts[4], 'd', false, OPTION_ARG_TYPE_FLG,
- (void *)&dumbterminal, (bool *)0, "dumb terminal: no clever edits");
+ &dumbterminal, NULL, "dumb terminal: no clever edits");
// First look to see if we are setting or getting a single option
// by just quoting its nickname
need_update = true;
}
- dp = &config->config_data[0];
+ dp = config->config_data;
while (dp < &config->config_data[sizeof(config->config_data)]) {
if (CONFIG_OBJECT_TYPE(dp) == CONFIG_EMPTY) {
break;
}
len = 4 + CONFIG_OBJECT_KEYLEN(dp) + CONFIG_OBJECT_ENABLE_KEYLEN(dp) +
- config_length(CONFIG_OBJECT_TYPE(dp));
+ config_length(CONFIG_OBJECT_TYPE(dp));
// Provide a title for well known [i.e. builtin] objects
- title = (char *)NULL;
+ title = NULL;
opt = __CONFIG_options_TAB__;
while (opt != optend) {
if (strcmp(opt->key, CONFIG_OBJECT_KEY(dp)) == 0) {
}
opt++;
}
- if ( onlyone && 0 != strcmp(CONFIG_OBJECT_KEY(dp), onlyone) )
+ if (onlyone && 0 != strcmp(CONFIG_OBJECT_KEY(dp), onlyone))
ret = CONFIG_OK; // skip this entry
else {
doneone = true;
dp += len;
break;
case CONFIG_BACK:
- dp = &config->config_data[0];
+ dp = config->config_data;
continue;
case CONFIG_BAD:
// Nothing - make him do it again
}
make_alias(name, argv[1]);
opt.type = CONFIG_STRING;
- opt.enable = (char *)0;
+ opt.enable = NULL;
opt.enable_sense = 1;
opt.key = name;
opt.dflt = (CYG_ADDRESS)argv[2];
} else {
dp = flash_lookup_config(alias);
if (dp) {
- val_ptr = (void *)CONFIG_OBJECT_VALUE(dp);
+ val_ptr = CONFIG_OBJECT_VALUE(dp);
switch (type = CONFIG_OBJECT_TYPE(dp)) {
case CONFIG_BOOL:
memcpy(&hold_bool_val, val_ptr, sizeof(bool));
break;
#endif
case CONFIG_SCRIPT:
- return (char *) val_ptr;
+ return val_ptr;
break;
default:
- return (char *)NULL;
+ return NULL;
}
return alias_buf;
}
- return (char *)NULL;
+ return NULL;
}
}
fis_update_directory();
#else
#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
- // Insure [quietly] that the config page is unlocked before trying to update
- flash_unlock((void *)cfg_base, cfg_size, (void **)&err_addr);
+ // Ensure [quietly] that the config page is unlocked before trying to update
+ flash_unlock(cfg_base, cfg_size, &err_addr);
#endif
- if ((stat = flash_erase(cfg_base, cfg_size, (void **)&err_addr)) != 0) {
+ if ((stat = flash_erase(cfg_base, cfg_size, &err_addr)) != 0) {
diag_printf(" initialization failed at %p: %s\n", err_addr, flash_errmsg(stat));
} else {
conf_endian_fixup(config);
- if ((stat = FLASH_PROGRAM(cfg_base, config, sizeof(struct _config), (void **)&err_addr)) != 0) {
+ if ((stat = FLASH_PROGRAM(cfg_base, config, sizeof(struct _config), &err_addr)) != 0) {
diag_printf("Error writing config data at %p: %s\n",
err_addr, flash_errmsg(stat));
}
conf_endian_fixup(config);
}
#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
- // Insure [quietly] that the config data is locked after the update
- flash_lock((void *)cfg_base, cfg_size, (void **)&err_addr);
+ // Ensure [quietly] that the config data is locked after the update
+ flash_lock(cfg_base, cfg_size, &err_addr);
#endif
#endif // CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG
#else // CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH
unsigned char *dp;
int len;
- if (!config_ok) return (unsigned char *)NULL;
+ if (!config_ok) return NULL;
- dp = &config->config_data[0];
+ dp = config->config_data;
while (dp < &config->config_data[sizeof(config->config_data)]) {
len = 4 + CONFIG_OBJECT_KEYLEN(dp) + CONFIG_OBJECT_ENABLE_KEYLEN(dp) +
config_length(CONFIG_OBJECT_TYPE(dp));
if (!config_ok) return false;
- if ((dp = flash_lookup_config(key)) != (unsigned char *)NULL) {
+ if ((dp = flash_lookup_config(key)) != NULL) {
if (CONFIG_OBJECT_TYPE(dp) == type) {
- val_ptr = (void *)CONFIG_OBJECT_VALUE(dp);
+ val_ptr = CONFIG_OBJECT_VALUE(dp);
switch (type) {
// Note: the data may be unaligned in the configuration data
case CONFIG_BOOL:
if (!config_ok) return false;
- if ((dp = flash_lookup_config(key)) != (unsigned char *)NULL) {
+ if ((dp = flash_lookup_config(key)) != NULL) {
if (CONFIG_OBJECT_TYPE(dp) == type) {
- val_ptr = (void *)CONFIG_OBJECT_VALUE(dp);
+ val_ptr = CONFIG_OBJECT_VALUE(dp);
switch (type) {
// Note: the data may be unaligned in the configuration data
case CONFIG_BOOL:
switch (opt->type) {
// Note: the data may be unaligned in the configuration data
case CONFIG_BOOL:
- memcpy(dp, (void *)&opt->dflt, sizeof(bool));
+ memcpy(dp, &opt->dflt, sizeof(bool));
break;
case CONFIG_INT:
- memcpy(dp, (void *)&opt->dflt, sizeof(unsigned long));
+ memcpy(dp, &opt->dflt, sizeof(unsigned long));
break;
#ifdef CYGPKG_REDBOOT_NETWORKING
case CONFIG_IP:
- memcpy(dp, (void *)&opt->dflt, sizeof(in_addr_t));
+ memcpy(dp, &opt->dflt, sizeof(in_addr_t));
break;
case CONFIG_ESA:
memcpy(dp, (void *)opt->dflt, sizeof(enet_addr_t));
// If data item is already present, just update it
// Note: only the data value can be thusly changed
- if ((dp = flash_lookup_config(opt->key)) != (unsigned char *)NULL) {
+ if ((dp = flash_lookup_config(opt->key)) != NULL) {
flash_config_insert_value(CONFIG_OBJECT_VALUE(dp), opt);
if (update) {
flash_write_config(true);
return true;
}
// Add the data item
- dp = &config->config_data[0];
+ dp = config->config_data;
size = 0;
while (size < sizeof(config->config_data)) {
if (CONFIG_OBJECT_TYPE(dp) == CONFIG_EMPTY) {
load_flash_config(void)
{
bool use_boot_script;
- unsigned char *cfg_temp = (unsigned char *)workspace_end;
+ unsigned char *cfg_temp = workspace_end;
#ifdef CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH
void *err_addr;
#endif
config_ok = false;
- script = (unsigned char *)0;
+ script = NULL;
cfg_temp -= sizeof(struct _config); // Space for primary config data
config = (struct _config *)cfg_temp;
cfg_temp -= sizeof(struct _config); // Space for backup config data
#endif
workspace_end = cfg_temp;
#ifdef CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH
- if (!do_flash_init()) return;
+ if (do_flash_init()<0) return;
#ifdef CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG
cfg_size = _rup(sizeof(struct _config), sizeof(struct fis_image_desc));
if ((fisdir_size-cfg_size) < (CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_COUNT *
_rup(sizeof(struct _config), flash_block_size);
if (CYGNUM_REDBOOT_FLASH_CONFIG_BLOCK < 0) {
cfg_base = (void *)((CYG_ADDRESS)flash_end + 1 -
- _rup(_rup((-CYGNUM_REDBOOT_FLASH_CONFIG_BLOCK*flash_block_size), cfg_size), flash_block_size));
+ _rup(_rup((-CYGNUM_REDBOOT_FLASH_CONFIG_BLOCK * flash_block_size), cfg_size),
+ flash_block_size));
} else {
cfg_base = (void *)((CYG_ADDRESS)flash_start +
- _rup(_rup((CYGNUM_REDBOOT_FLASH_CONFIG_BLOCK*flash_block_size), cfg_size), flash_block_size));
+ _rup(_rup((CYGNUM_REDBOOT_FLASH_CONFIG_BLOCK * flash_block_size), cfg_size),
+ flash_block_size));
}
#endif
FLASH_READ(cfg_base, config, sizeof(struct _config), &err_addr);