Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/38736 )
Change subject: lib/imd_cbmem.c: Add a helper function to indicate that cbmem is ready ......................................................................
Patch Set 5:
(1 comment)
https://review.coreboot.org/c/coreboot/+/38736/1/src/include/cbmem.h File src/include/cbmem.h:
https://review.coreboot.org/c/coreboot/+/38736/1/src/include/cbmem.h@84 PS1, Line 84: /* Returns 1 if cbmem is initialized, 0 otherwise */
Would probably make sense to make this a static inline and call cbmem_possibly_online() first, so […]
It makes a big difference for compile time elimination. If you did something like
if (cbmem_online()) huge_function();
your current implementation would always pull huge_function() (and other code only referenced from there) into the binary. If you make it a static inline, then stages where cbmem_possibly_online() is false can completely eliminate it. This is both useful for size and sometimes to make it compile at all (e.g. huge_function() can then refer to symbols that are only available in stages where cbmem_possibly_online() is true, it won't cause undefined reference errors in the stages where it's not going to be used anyway).
See vboot_logic_executed() for an example of how to make this a static inline without exposing the cbmem_initialized global directly.