Felix Held submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Subrata Banik: Looks good to me, approved
drivers/intel/fsp2_0: Introduce fsp print helper macros

This patch introduces fsp print helper macros to print
`efi_return_status_t' with the appropriate format. These macros
are now used for fsp debug prints with return status

efi_return_status_t is defined as UINT64 or UNIT32 based on the
selected architecture

BUG=b:329034258
TEST=Verified on Meteor Lake board (Rex)

Change-Id: If6342c4d40c76b702351070e424797c21138a4a9
Signed-off-by: Appukuttan V K <appukuttan.vk@intel.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/81630
Reviewed-by: Subrata Banik <subratabanik@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M src/drivers/intel/fsp2_0/debug.c
M src/drivers/intel/fsp2_0/include/fsp/debug.h
M src/drivers/intel/fsp2_0/include/fsp/util.h
M src/drivers/intel/fsp2_0/memory_init.c
M src/drivers/intel/fsp2_0/silicon_init.c
M src/drivers/intel/fsp2_0/util.c
M src/include/efi/efi_datatype.h
M src/soc/amd/common/fsp/fsp_reset.c
M src/soc/intel/common/fsp_reset.c
9 files changed, 48 insertions(+), 36 deletions(-)

diff --git a/src/drivers/intel/fsp2_0/debug.c b/src/drivers/intel/fsp2_0/debug.c
index 4cd309e..9dc964d 100644
--- a/src/drivers/intel/fsp2_0/debug.c
+++ b/src/drivers/intel/fsp2_0/debug.c
@@ -85,10 +85,10 @@
printk(BIOS_SPEW, "\t%p: &hob_list_ptr\n", fsp_get_hob_list_ptr());
}

-void fsp_debug_after_memory_init(uint32_t status)
+void fsp_debug_after_memory_init(efi_return_status_t status)
{
if (CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
- printk(BIOS_SPEW, "FspMemoryInit returned 0x%08x\n", status);
+ fsp_printk(status, BIOS_SPEW, "FspMemoryInit");

if (status != FSP_SUCCESS)
return;
@@ -130,13 +130,13 @@
printk(BIOS_SPEW, "\t%p: upd\n", fsps_new_upd);
}

-void fsp_debug_after_silicon_init(uint32_t status)
+void fsp_debug_after_silicon_init(efi_return_status_t status)
{
if (CONFIG(CHECK_GPIO_CONFIG_CHANGES))
fsp_gpio_config_check(AFTER_FSP_CALL, "FSP Silicon Init");

if (CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
- printk(BIOS_SPEW, "FspSiliconInit returned 0x%08x\n", status);
+ fsp_printk(status, BIOS_SPEW, "FspSiliconInit");

/* Display the HOBs */
if (CONFIG(DISPLAY_HOBS))
@@ -164,13 +164,13 @@
printk(BIOS_SPEW, "\t%p: notify_params\n", notify_params);
}

-void fsp_debug_after_notify(uint32_t status)
+void fsp_debug_after_notify(efi_return_status_t status)
{
if (CONFIG(CHECK_GPIO_CONFIG_CHANGES))
fsp_gpio_config_check(AFTER_FSP_CALL, "FSP Notify");

if (CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
- printk(BIOS_SPEW, "FspNotify returned 0x%08x\n", status);
+ fsp_printk(status, BIOS_SPEW, "FspNotify");

/* Display the HOBs */
if (CONFIG(DISPLAY_HOBS))
diff --git a/src/drivers/intel/fsp2_0/include/fsp/debug.h b/src/drivers/intel/fsp2_0/include/fsp/debug.h
index dc5557e..e7f9f25 100644
--- a/src/drivers/intel/fsp2_0/include/fsp/debug.h
+++ b/src/drivers/intel/fsp2_0/include/fsp/debug.h
@@ -19,14 +19,14 @@
void fsp_debug_before_memory_init(fsp_memory_init_fn memory_init,
const FSPM_UPD *fspm_old_upd,
const FSPM_UPD *fspm_new_upd);
-void fsp_debug_after_memory_init(uint32_t status);
+void fsp_debug_after_memory_init(efi_return_status_t status);
void fsp_debug_before_silicon_init(fsp_silicon_init_fn silicon_init,
const FSPS_UPD *fsps_old_upd,
const FSPS_UPD *fsps_new_upd);
-void fsp_debug_after_silicon_init(uint32_t status);
+void fsp_debug_after_silicon_init(efi_return_status_t status);
void fsp_before_debug_notify(fsp_notify_fn notify,
const struct fsp_notify_params *notify_params);
-void fsp_debug_after_notify(uint32_t status);
+void fsp_debug_after_notify(efi_return_status_t status);
void fspm_display_upd_values(const FSPM_UPD *old,
const FSPM_UPD *new);
void fsp_display_hobs(void);
diff --git a/src/drivers/intel/fsp2_0/include/fsp/util.h b/src/drivers/intel/fsp2_0/include/fsp/util.h
index bed4fcb..e89b7f8 100644
--- a/src/drivers/intel/fsp2_0/include/fsp/util.h
+++ b/src/drivers/intel/fsp2_0/include/fsp/util.h
@@ -31,6 +31,17 @@
memcpy(dst, src, sizeof(src)); \
} while (0)

+/* Helper function to print a message concatenated with the a FSP return status. */
+#if CONFIG(PLATFORM_USES_FSP2_X86_32)
+#define FSP_STATUS_FMT "0x%08x"
+#else
+#define FSP_STATUS_FMT "0x%016llx"
+#endif
+#define fsp_printk(status, msg_level, fmt, ...) \
+ printk(msg_level, fmt ", status=" FSP_STATUS_FMT "\n", ##__VA_ARGS__, status)
+#define fsp_die_with_post_code(status, postcode, fmt, ...) \
+ die_with_post_code(postcode, fmt ", status=" FSP_STATUS_FMT "\n", ##__VA_ARGS__, status)
+
struct hob_header {
uint16_t type;
uint16_t length;
@@ -187,10 +198,10 @@
* SoC. If the requested status is not a reboot status or unhandled, this
* function does nothing.
*/
-void fsp_handle_reset(uint32_t status);
+void fsp_handle_reset(efi_return_status_t status);

/* SoC/chipset must provide this to handle platform-specific reset codes */
-void chipset_handle_reset(uint32_t status);
+void chipset_handle_reset(efi_return_status_t status);

#if CONFIG(PLATFORM_USES_SECOND_FSP)
/* The SoC must implement these to choose the appropriate FSP-M/FSP-S binary. */
diff --git a/src/drivers/intel/fsp2_0/memory_init.c b/src/drivers/intel/fsp2_0/memory_init.c
index dc725c3..31ae213 100644
--- a/src/drivers/intel/fsp2_0/memory_init.c
+++ b/src/drivers/intel/fsp2_0/memory_init.c
@@ -274,22 +274,22 @@
return ver;
}

-static void fspm_return_value_handler(const char *context, uint32_t status, bool die_on_error)
+static void fspm_return_value_handler(const char *context, efi_return_status_t status,
+ bool die_on_error)
{
if (status == FSP_SUCCESS)
return;

fsp_handle_reset(status);
if (die_on_error)
- die_with_post_code(POSTCODE_RAM_FAILURE, "%s returned with error 0x%zx!\n",
- context, (size_t)status);
+ fsp_die_with_post_code(status, POSTCODE_RAM_FAILURE, "%s error", context);

- printk(BIOS_SPEW, "%s returned 0x%zx\n", context, (size_t)status);
+ fsp_printk(status, BIOS_SPEW, "%s", context);
}

static void fspm_multi_phase_init(const struct fsp_header *hdr)
{
- uint32_t status;
+ efi_return_status_t status;
fsp_multi_phase_init_fn fsp_multi_phase_init;
struct fsp_multi_phase_params multi_phase_params;
struct fsp_multi_phase_get_number_of_phases_params multi_phase_get_number;
@@ -332,7 +332,7 @@

static void do_fsp_memory_init(const struct fspm_context *context, bool s3wake)
{
- uint32_t status;
+ efi_return_status_t status;
fsp_memory_init_fn fsp_raminit;
FSPM_UPD fspm_upd, *upd;
FSPM_ARCHx_UPD *arch_upd;
diff --git a/src/drivers/intel/fsp2_0/silicon_init.c b/src/drivers/intel/fsp2_0/silicon_init.c
index 08258d3..52d714d 100644
--- a/src/drivers/intel/fsp2_0/silicon_init.c
+++ b/src/drivers/intel/fsp2_0/silicon_init.c
@@ -36,7 +36,8 @@
FSP_MULTI_PHASE_SI_INIT_EXECUTE_PHASE_API
};

-static void fsps_return_value_handler(enum fsp_silicon_init_phases phases, uint32_t status)
+static void fsps_return_value_handler(enum fsp_silicon_init_phases phases,
+ efi_return_status_t status)
{
uint8_t postcode;

@@ -54,16 +55,13 @@

switch (phases) {
case FSP_SILICON_INIT_API:
- die_with_post_code(postcode, "FspSiliconInit returned with error 0x%08x\n",
- status);
+ fsp_die_with_post_code(status, postcode, "FspSiliconInit error");
break;
case FSP_MULTI_PHASE_SI_INIT_GET_NUMBER_OF_PHASES_API:
- printk(BIOS_SPEW, "FspMultiPhaseSiInit NumberOfPhases returned 0x%08x\n",
- status);
+ fsp_printk(status, BIOS_SPEW, "FspMultiPhaseSiInit NumberOfPhases");
break;
case FSP_MULTI_PHASE_SI_INIT_EXECUTE_PHASE_API:
- printk(BIOS_SPEW, "FspMultiPhaseSiInit ExecutePhase returned 0x%08x\n",
- status);
+ fsp_printk(status, BIOS_SPEW, "FspMultiPhaseSiInit ExecutePhase");
break;
default:
break;
@@ -88,7 +86,7 @@
{
FSPS_UPD *upd, *supd;
fsp_silicon_init_fn silicon_init;
- uint32_t status;
+ efi_return_status_t status;
fsp_multi_phase_init_fn multi_phase_si_init;
struct fsp_multi_phase_params multi_phase_params;
struct fsp_multi_phase_get_number_of_phases_params multi_phase_get_number;
@@ -139,7 +137,7 @@
status = silicon_init(upd);
null_breakpoint_init();

- printk(BIOS_INFO, "FSPS returned %x\n", status);
+ fsp_printk(status, BIOS_INFO, "FSPS");

timestamp_add_now(TS_FSP_SILICON_INIT_END);
post_code(POSTCODE_FSP_SILICON_EXIT);
diff --git a/src/drivers/intel/fsp2_0/util.c b/src/drivers/intel/fsp2_0/util.c
index f912d9a..47dc3e8 100644
--- a/src/drivers/intel/fsp2_0/util.c
+++ b/src/drivers/intel/fsp2_0/util.c
@@ -83,18 +83,18 @@
return CB_SUCCESS;
}

-static bool fsp_reset_requested(uint32_t status)
+static bool fsp_reset_requested(efi_return_status_t status)
{
return (status >= FSP_STATUS_RESET_REQUIRED_COLD &&
status <= FSP_STATUS_RESET_REQUIRED_8);
}

-void fsp_handle_reset(uint32_t status)
+void fsp_handle_reset(efi_return_status_t status)
{
if (!fsp_reset_requested(status))
return;

- printk(BIOS_SPEW, "FSP: handling reset type %x\n", status);
+ fsp_printk(status, BIOS_SPEW, "FSP: handling reset type");

switch (status) {
case FSP_STATUS_RESET_REQUIRED_COLD:
diff --git a/src/include/efi/efi_datatype.h b/src/include/efi/efi_datatype.h
index 31612b8..8a1a124 100644
--- a/src/include/efi/efi_datatype.h
+++ b/src/include/efi/efi_datatype.h
@@ -65,7 +65,11 @@
/* Signed value of native width. */
typedef INTN efi_intn_t;
/* Status codes common to all execution phases */
-typedef EFI_STATUS efi_return_status_t;
+#if CONFIG(PLATFORM_USES_FSP2_X86_32)
+typedef UINT32 efi_return_status_t;
+#else
+typedef UINT64 efi_return_status_t;
+#endif
/* Data structure for EFI_PHYSICAL_ADDRESS */
typedef EFI_PHYSICAL_ADDRESS efi_physical_address;
/* 128-bit buffer containing a unique identifier value */
diff --git a/src/soc/amd/common/fsp/fsp_reset.c b/src/soc/amd/common/fsp/fsp_reset.c
index 0a89dc7..761ba2b 100644
--- a/src/soc/amd/common/fsp/fsp_reset.c
+++ b/src/soc/amd/common/fsp/fsp_reset.c
@@ -6,10 +6,9 @@
#include <fsp/util.h>
#include <stdint.h>

-void chipset_handle_reset(uint32_t status)
+void chipset_handle_reset(efi_return_status_t status)
{
- printk(BIOS_ERR, "unexpected call to %s(0x%08x). Doing cold reset.\n",
- __func__, status);
+ fsp_printk(status, BIOS_ERR, "Doing cold reset due to unexpected call to %s", __func__);
BUG();
do_cold_reset();
}
diff --git a/src/soc/intel/common/fsp_reset.c b/src/soc/intel/common/fsp_reset.c
index 2bb39bd..2626c39 100644
--- a/src/soc/intel/common/fsp_reset.c
+++ b/src/soc/intel/common/fsp_reset.c
@@ -30,20 +30,20 @@
struct pch_reset_data reset_data;
};

-void chipset_handle_reset(uint32_t status)
+void chipset_handle_reset(efi_return_status_t status)
{
if (status == CONFIG_FSP_STATUS_GLOBAL_RESET) {
printk(BIOS_DEBUG, "GLOBAL RESET!\n");
global_reset();
}

- printk(BIOS_ERR, "unhandled reset type %x\n", status);
+ fsp_printk(status, BIOS_ERR, "unhandled reset type");
die("unknown reset type");
}

static uint32_t fsp_reset_type_to_status(EFI_RESET_TYPE reset_type)
{
- uint32_t status;
+ efi_return_status_t status;

switch (reset_type) {
case EfiResetCold:

To view, visit change 81630. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: If6342c4d40c76b702351070e424797c21138a4a9
Gerrit-Change-Number: 81630
Gerrit-PatchSet: 10
Gerrit-Owner: Appukuttan V K <appukuttan.vk@intel.com>
Gerrit-Reviewer: Andrey Petrov <andrey.petrov@gmail.com>
Gerrit-Reviewer: Felix Held <felix-coreboot@felixheld.de>
Gerrit-Reviewer: Fred Reitberger <reitbergerfred@gmail.com>
Gerrit-Reviewer: Jason Glenesk <jason.glenesk@gmail.com>
Gerrit-Reviewer: Matt DeVillier <matt.devillier@amd.corp-partner.google.com>
Gerrit-Reviewer: Ronak Kanabar <ronak.kanabar@intel.com>
Gerrit-Reviewer: Subrata Banik <subratabanik@google.com>
Gerrit-Reviewer: Wonkyu Kim <wonkyu.kim@intel.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Balaji Manigandan <balaji.manigandan@intel.com>
Gerrit-CC: Hannah Williams <hannah.williams@intel.com>
Gerrit-MessageType: merged