- char *init, *config, *refresh, *ncdl;
- char *ptr, *end;
- int i;
- struct nvram_tuple *t;
- struct nvram_header tmp;
- uint8 crc;
-
- /* Regenerate header */
- header->magic = NVRAM_MAGIC;
- header->crc_ver_init = (NVRAM_VERSION << 8);
- if (!(init = BCMINIT(_nvram_get)("sdram_init")) ||
- !(config = BCMINIT(_nvram_get)("sdram_config")) ||
- !(refresh = BCMINIT(_nvram_get)("sdram_refresh")) ||
- !(ncdl = BCMINIT(_nvram_get)("sdram_ncdl"))) {
- header->crc_ver_init |= SDRAM_INIT << 16;
- header->config_refresh = SDRAM_CONFIG;
- header->config_refresh |= SDRAM_REFRESH << 16;
- header->config_ncdl = 0;
- } else {
- header->crc_ver_init |= (bcm_strtoul(init, NULL, 0) & 0xffff) << 16;
- header->config_refresh = bcm_strtoul(config, NULL, 0) & 0xffff;
- header->config_refresh |= (bcm_strtoul(refresh, NULL, 0) & 0xffff) << 16;
- header->config_ncdl = bcm_strtoul(ncdl, NULL, 0);
- }
-
- /* Clear data area */
- ptr = (char *) header + sizeof(struct nvram_header);
- bzero(ptr, NVRAM_SPACE - sizeof(struct nvram_header));
-
- /* Leave space for a double NUL at the end */
- end = (char *) header + NVRAM_SPACE - 2;
-
- /* Write out all tuples */
- for (i = 0; i < ARRAYSIZE(BCMINIT(nvram_hash)); i++) {
- for (t = BCMINIT(nvram_hash)[i]; t; t = t->next) {
- if ((ptr + strlen(t->name) + 1 + strlen(t->value) + 1) > end)
- break;
- ptr += sprintf(ptr, "%s=%s", t->name, t->value) + 1;
- }
- }