static int prepare_mrc_cache(struct pei_data *pei_data) { struct mrc_data_container *mrc_cache; struct fmap_entry entry; int ret; ret = read_seed_from_cmos(pei_data); if (ret) return ret; ret = get_mrc_entry(NULL, &entry); if (ret) return ret; mrc_cache = mrccache_find_current(&entry); if (!mrc_cache) return -ENOENT; /* * TODO([email protected]): Skip this for now as it causes boot * problems */ if (0) { pei_data->mrc_input = mrc_cache->data; pei_data->mrc_input_len = mrc_cache->data_size; } debug("%s: at %p, size %x checksum %04x\n", __func__, pei_data->mrc_input, pei_data->mrc_input_len, mrc_cache->checksum); return 0; }
int mrccache_update(struct udevice *sf, struct mrc_region *entry, struct mrc_data_container *cur) { struct mrc_data_container *cache; ulong offset; ulong base_addr; int ret; if (!is_mrc_cache(cur)) return -EINVAL; /* Find the last used block */ base_addr = entry->base + entry->offset; debug("Updating MRC cache data\n"); cache = mrccache_find_current(entry); if (cache && (cache->data_size == cur->data_size) && (!memcmp(cache, cur, cache->data_size + sizeof(*cur)))) { debug("MRC data in flash is up to date. No update\n"); return -EEXIST; } /* Move to the next block, which will be the first unused block */ if (cache) cache = find_next_mrc_cache(entry, cache); /* * If we have got to the end, erase the entire mrc-cache area and start * again at block 0. */ if (!cache) { debug("Erasing the MRC cache region of %x bytes at %x\n", entry->length, entry->offset); ret = spi_flash_erase_dm(sf, entry->offset, entry->length); if (ret) { debug("Failed to erase flash region\n"); return ret; } cache = (struct mrc_data_container *)base_addr; } /* Write the data out */ offset = (ulong)cache - base_addr + entry->offset; debug("Write MRC cache update to flash at %lx\n", offset); ret = spi_flash_write_dm(sf, offset, cur->data_size + sizeof(*cur), cur); if (ret) { debug("Failed to write to SPI flash\n"); return ret; } return 0; }
static __maybe_unused void *fsp_prepare_mrc_cache(void) { struct mrc_data_container *cache; struct mrc_region entry; int ret; ret = mrccache_get_region(NULL, &entry); if (ret) return NULL; cache = mrccache_find_current(&entry); if (!cache) return NULL; debug("%s: mrc cache at %p, size %x checksum %04x\n", __func__, cache->data, cache->data_size, cache->checksum); return cache->data; }
static int prepare_mrc_cache(struct pei_data *pei_data) { struct mrc_data_container *mrc_cache; struct mrc_region entry; int ret; ret = mrccache_get_region(NULL, &entry); if (ret) return ret; mrc_cache = mrccache_find_current(&entry); if (!mrc_cache) return -ENOENT; pei_data->saved_data = mrc_cache->data; pei_data->saved_data_size = mrc_cache->data_size; debug("%s: at %p, size %x checksum %04x\n", __func__, pei_data->saved_data, pei_data->saved_data_size, mrc_cache->checksum); return 0; }