From fefc2ea4c41a1a786fb0b0dc890da1d1370f0731 Mon Sep 17 00:00:00 2001 From: Lean Sheng Tan Date: Tue, 15 Jun 2021 23:44:20 -0700 Subject: [PATCH] intel/fsp2_0: Add FSP_ARRAY_LOAD macro Add FSP_ARRAY_LOAD macro for checking and loading array type configs into array type UPDs to increase readability. Signed-off-by: Lean Sheng Tan Change-Id: I307340a2bfc0a54f2ab7241af2f24dfbf8bb111d Reviewed-on: https://review.coreboot.org/c/coreboot/+/55559 Reviewed-by: Furquan Shaikh Reviewed-by: Werner Zeh Tested-by: build bot (Jenkins) --- src/drivers/intel/fsp2_0/include/fsp/util.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/drivers/intel/fsp2_0/include/fsp/util.h b/src/drivers/intel/fsp2_0/include/fsp/util.h index 0e11eceda4..285674b912 100644 --- a/src/drivers/intel/fsp2_0/include/fsp/util.h +++ b/src/drivers/intel/fsp2_0/include/fsp/util.h @@ -15,6 +15,13 @@ #define FSP_VER_LEN 30 +/* Macro for checking and loading array type configs into array type UPDs */ +#define FSP_ARRAY_LOAD(dst, src) \ +do { \ + _Static_assert(ARRAY_SIZE(dst) >= ARRAY_SIZE(src), "copy buffer overflow!"); \ + memcpy(dst, src, sizeof(src)); \ +} while (0) + struct hob_header { uint16_t type; uint16_t length;