Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/36273 )
Change subject: lib/cbmem_top: Add a common cbmem_top implementation ......................................................................
lib/cbmem_top: Add a common cbmem_top implementation
This adds a common cbmem_top implementation to be used by all coreboot target. To ease the review process it is currently guarded by a Kconfig symbol to be able to make transition platforms/arch step by step.
To avoid a lot of preprocessor and/or changing file inclusion all current cbmem_top implementations will be renamed cbmem_top_romstage and called by the common cbmem_top function.
Change-Id: Ie767542ee25483acc9a56785ce20a885e9a63098 Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/include/cbmem.h M src/lib/Kconfig M src/lib/Makefile.inc A src/lib/cbmem_top.c 4 files changed, 38 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/36273/1
diff --git a/src/include/cbmem.h b/src/include/cbmem.h index f972ba6..a6cd277 100644 --- a/src/include/cbmem.h +++ b/src/include/cbmem.h @@ -74,7 +74,9 @@ * upper limit. * x86 boards or chipsets must return NULL before the cbmem backing store has * been initialized. */ +extern uintptr_t _cbmem_top_ptr; void *cbmem_top(void); +void *cbmem_top_romstage(void);
/* Add a cbmem entry of a given size and id. These return NULL on failure. The * add function performs a find first and do not check against the original diff --git a/src/lib/Kconfig b/src/lib/Kconfig index cb1e4a5..aede4b3 100644 --- a/src/lib/Kconfig +++ b/src/lib/Kconfig @@ -24,6 +24,12 @@ help Selected by features that require `libhwbase` in ramstage.
+config RAMSTAGE_CBMEM_TOP_ARG + bool + help + Select this if stages run after romstage get the cbmem_top + pointer the function arguments when called from romstage. + config FLATTENED_DEVICE_TREE bool help diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc index e5678ff..0c569c5 100644 --- a/src/lib/Makefile.inc +++ b/src/lib/Makefile.inc @@ -149,6 +149,7 @@ ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit.c ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit_payload.c
+romstage-$(CONFIG_RAMSTAGE_CBMEM_TOP_ARG) += cbmem_top.c romstage-y += cbmem_common.c romstage-y += imd_cbmem.c romstage-y += imd.c diff --git a/src/lib/cbmem_top.c b/src/lib/cbmem_top.c new file mode 100644 index 0000000..6eee0d5 --- /dev/null +++ b/src/lib/cbmem_top.c @@ -0,0 +1,29 @@ +/* + * This file is part of the coreboot project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <cbmem.h> + +#if !ENV_ROMSTAGE +void *cbmem_top(void) +{ + return (void *)_cbmem_top_ptr; +} +#else +void *cbmem_top(void) +{ + /* TODO use a static variable once NO_CAR_GLOBAL_MIGRATION + is implemented */ + return cbmem_top_romstage(); +} + +#endif