From 006eb9d8c8550ce0e8d01d37cceb88e7c1e12a5e Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Wed, 2 Oct 2019 07:45:45 -0400 Subject: libpayload: refactor fetching cbmem pointers There's a recurring pattern of reading cbtable entries that point into cbmem entries. Move that pattern into its own function. Coccinelle patch used for this: @@ identifier T, T2; expression TARGET; @@ -struct cb_cbmem_tab *const T2 = (struct cb_cbmem_tab *)T; -TARGET = phys_to_virt(T2->cbmem_tab); +TARGET = get_cbmem_ptr(T); Change-Id: I7bd4a7ad8baeeaebf0fa7d4b4de6dbc719bc781f Signed-off-by: Patrick Georgi Reviewed-on: https://review.coreboot.org/c/coreboot/+/35756 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Furquan Shaikh Reviewed-by: Stefan Reinauer --- payloads/libpayload/include/coreboot_tables.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'payloads/libpayload/include') diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h index c24d6acfd6..188f4268c3 100644 --- a/payloads/libpayload/include/coreboot_tables.h +++ b/payloads/libpayload/include/coreboot_tables.h @@ -395,4 +395,6 @@ static inline const char *cb_mb_part_string(const struct cb_mainboard *cbm) (void *)(((u8 *) (_rec)) + sizeof(*(_rec)) \ + (sizeof((_rec)->map[0]) * (_idx))) +/* Helper functions */ +void *get_cbmem_ptr(unsigned char *ptr); #endif -- cgit v1.2.3