MCPcopy Create free account
hub / github.com/coreboot/coreboot / setup_preram_cache

Function setup_preram_cache

src/lib/fmap.c:63–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63static void setup_preram_cache(struct region_device *cache_rdev)
64{
65 if (CONFIG(NO_FMAP_CACHE))
66 return;
67
68 /* No need to use FMAP cache in SMM */
69 if (ENV_SMM)
70 return;
71
72 if (!ENV_ROMSTAGE_OR_BEFORE) {
73 /* We get here if ramstage makes an FMAP access before calling
74 cbmem_initialize(). We should avoid letting it come to that,
75 so print a warning. */
76 print_once(BIOS_WARNING,
77 "WARNING: Post-RAM FMAP access too early for cache!\n");
78 return;
79 }
80
81 struct fmap *fmap = (struct fmap *)_fmap_cache;
82 if (!(ENV_INITIAL_STAGE)) {
83 /* NOTE: This assumes that the first stage will make
84 at least one FMAP access (usually from finding CBFS). */
85 if (!verify_fmap(fmap))
86 goto register_cache;
87
88 /* This shouldn't happen, so no point providing a fallback path here. */
89 die("FMAP cache corrupted?!\n");
90 }
91
92 /* In case we fail below, make sure the cache is invalid. */
93 memset(fmap->signature, 0, sizeof(fmap->signature));
94
95 boot_device_init();
96 const struct region_device *boot_rdev = boot_device_ro();
97 if (!boot_rdev)
98 return;
99
100 /* memlayout statically guarantees that the FMAP_CACHE is big enough. */
101 if (rdev_readat(boot_rdev, fmap, FMAP_OFFSET, FMAP_SIZE) != FMAP_SIZE)
102 return;
103 if (verify_fmap(fmap))
104 return;
105 report(fmap);
106
107register_cache:
108 rdev_chain_mem(cache_rdev, fmap, FMAP_SIZE);
109}
110
111static int find_fmap_directory(struct region_device *fmrd)
112{

Callers 1

find_fmap_directoryFunction · 0.85

Calls 8

verify_fmapFunction · 0.85
rdev_readatFunction · 0.85
reportFunction · 0.85
rdev_chain_memFunction · 0.85
memsetFunction · 0.70
boot_device_initFunction · 0.70
dieFunction · 0.50
boot_device_roFunction · 0.50

Tested by

no test coverage detected