* Locate the RW_SPD_CACHE area in the fmap and read SPD_CACHE data. * return CB_SUCCESS ,if the SPD_CACHE data is ready and the pointer return at *spd_cache. * return CB_ERR ,if it cannot locate RW_SPD_CACHE area in the fmap or data cannot be read. */
| 93 | * return CB_ERR ,if it cannot locate RW_SPD_CACHE area in the fmap or data cannot be read. |
| 94 | */ |
| 95 | enum cb_err load_spd_cache(uint8_t **spd_cache, size_t *spd_cache_sz) |
| 96 | { |
| 97 | struct region_device rdev; |
| 98 | |
| 99 | if (fmap_locate_area_as_rdev(SPD_CACHE_FMAP_NAME, &rdev) < 0) { |
| 100 | printk(BIOS_ERR, "SPD_CACHE: Cannot find %s region\n", SPD_CACHE_FMAP_NAME); |
| 101 | return CB_ERR; |
| 102 | } |
| 103 | |
| 104 | /* Assume boot device is memory mapped. */ |
| 105 | assert(CONFIG(BOOT_DEVICE_MEMORY_MAPPED)); |
| 106 | *spd_cache = rdev_mmap_full(&rdev); |
| 107 | |
| 108 | if (*spd_cache == NULL) |
| 109 | return CB_ERR; |
| 110 | |
| 111 | *spd_cache_sz = region_device_sz(&rdev); |
| 112 | |
| 113 | /* SPD cache found */ |
| 114 | printk(BIOS_INFO, "SPD_CACHE: cache found, size 0x%zx\n", *spd_cache_sz); |
| 115 | |
| 116 | return CB_SUCCESS; |
| 117 | } |
| 118 | |
| 119 | /* Use to verify the cache data is valid. */ |
| 120 | bool spd_cache_is_valid(uint8_t *spd_cache, size_t spd_cache_sz) |