| 109 | } |
| 110 | |
| 111 | static int find_fmap_directory(struct region_device *fmrd) |
| 112 | { |
| 113 | const struct region_device *boot; |
| 114 | struct fmap *fmap; |
| 115 | size_t offset = FMAP_OFFSET; |
| 116 | |
| 117 | /* Try FMAP cache first */ |
| 118 | if (!region_device_sz(&fmap_cache)) |
| 119 | setup_preram_cache(&fmap_cache); |
| 120 | if (region_device_sz(&fmap_cache)) |
| 121 | return rdev_chain_full(fmrd, &fmap_cache); |
| 122 | |
| 123 | /* Cache setup in pre-RAM stages can't fail, unless flash I/O in general failed. */ |
| 124 | if (!CONFIG(NO_FMAP_CACHE) && ENV_ROMSTAGE_OR_BEFORE) |
| 125 | return -1; |
| 126 | |
| 127 | boot_device_init(); |
| 128 | boot = boot_device_ro(); |
| 129 | |
| 130 | if (boot == NULL) |
| 131 | return -1; |
| 132 | |
| 133 | fmap = rdev_mmap(boot, offset, |
| 134 | CONFIG(CBFS_VERIFICATION) ? FMAP_SIZE : sizeof(struct fmap)); |
| 135 | |
| 136 | if (fmap == NULL) |
| 137 | return -1; |
| 138 | |
| 139 | if (verify_fmap(fmap)) { |
| 140 | rdev_munmap(boot, fmap); |
| 141 | return -1; |
| 142 | } |
| 143 | |
| 144 | report(fmap); |
| 145 | |
| 146 | rdev_munmap(boot, fmap); |
| 147 | |
| 148 | return rdev_chain(fmrd, boot, offset, FMAP_SIZE); |
| 149 | } |
| 150 | |
| 151 | int fmap_locate_area_as_rdev(const char *name, struct region_device *area) |
| 152 | { |
no test coverage detected