diff options
author | Angel Pons <th3fanbus@gmail.com> | 2022-01-01 17:03:10 +0100 |
---|---|---|
committer | Subrata Banik <subratabanik@google.com> | 2022-01-02 12:34:13 +0000 |
commit | 355d8444a8ffb70a4a09aaad0e4b3ab15ffedc56 (patch) | |
tree | 0088da36eab0409772e96103fc0ce7ee58eff702 /src/drivers/intel/fsp2_0 | |
parent | 654930e7f2227f9e03f1436e0094252fd7e59a88 (diff) |
drivers/intel/fsp2_0/notify.c: Group per-phase data
Group all data specific to each notify phase in a struct to avoid
redundant code.
Change-Id: Ib4ab3d87edfcd5426ce35c168cbb780ade87290e
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/60639
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Subrata Banik <subratabanik@google.com>
Diffstat (limited to 'src/drivers/intel/fsp2_0')
-rw-r--r-- | src/drivers/intel/fsp2_0/notify.c | 68 |
1 files changed, 48 insertions, 20 deletions
diff --git a/src/drivers/intel/fsp2_0/notify.c b/src/drivers/intel/fsp2_0/notify.c index b3563c0dbc..cdace31905 100644 --- a/src/drivers/intel/fsp2_0/notify.c +++ b/src/drivers/intel/fsp2_0/notify.c @@ -6,9 +6,52 @@ #include <fsp/util.h> #include <mode_switch.h> #include <timestamp.h> +#include <types.h> + +struct fsp_notify_phase_data { + enum fsp_notify_phase notify_phase; + uint8_t post_code_before; + uint8_t post_code_after; + enum timestamp_id timestamp_before; + enum timestamp_id timestamp_after; +}; + +static const struct fsp_notify_phase_data notify_data[] = { + { + .notify_phase = AFTER_PCI_ENUM, + .post_code_before = POST_FSP_NOTIFY_BEFORE_ENUMERATE, + .post_code_after = POST_FSP_NOTIFY_AFTER_ENUMERATE, + .timestamp_before = TS_FSP_BEFORE_ENUMERATE, + .timestamp_after = TS_FSP_AFTER_ENUMERATE, + }, + { + .notify_phase = READY_TO_BOOT, + .post_code_before = POST_FSP_NOTIFY_BEFORE_FINALIZE, + .post_code_after = POST_FSP_NOTIFY_AFTER_FINALIZE, + .timestamp_before = TS_FSP_BEFORE_FINALIZE, + .timestamp_after = TS_FSP_AFTER_FINALIZE, + }, + { + .notify_phase = END_OF_FIRMWARE, + .post_code_before = POST_FSP_NOTIFY_BEFORE_END_OF_FIRMWARE, + .post_code_after = POST_FSP_NOTIFY_AFTER_END_OF_FIRMWARE, + .timestamp_before = TS_FSP_BEFORE_END_OF_FIRMWARE, + .timestamp_after = TS_FSP_AFTER_END_OF_FIRMWARE, + }, +}; + +static const struct fsp_notify_phase_data *get_notify_phase_data(enum fsp_notify_phase phase) +{ + for (size_t i = 0; i < ARRAY_SIZE(notify_data); i++) { + if (notify_data[i].notify_phase == phase) + return ¬ify_data[i]; + } + die("Unknown FSP notify phase %u\n", phase); +} static void fsp_notify(enum fsp_notify_phase phase) { + const struct fsp_notify_phase_data *data = get_notify_phase_data(phase); struct fsp_notify_params notify_params = { .phase = phase }; fsp_notify_fn fspnotify; uint32_t ret; @@ -20,32 +63,17 @@ static void fsp_notify(enum fsp_notify_phase phase) fsps_hdr.notify_phase_entry_offset); fsp_before_debug_notify(fspnotify, ¬ify_params); - if (phase == AFTER_PCI_ENUM) { - timestamp_add_now(TS_FSP_BEFORE_ENUMERATE); - post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE); - } else if (phase == READY_TO_BOOT) { - timestamp_add_now(TS_FSP_BEFORE_FINALIZE); - post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE); - } else if (phase == END_OF_FIRMWARE) { - timestamp_add_now(TS_FSP_BEFORE_END_OF_FIRMWARE); - post_code(POST_FSP_NOTIFY_BEFORE_END_OF_FIRMWARE); - } + timestamp_add_now(data->timestamp_before); + post_code(data->post_code_before); if (ENV_X86_64 && CONFIG(PLATFORM_USES_FSP2_X86_32)) ret = protected_mode_call_1arg(fspnotify, (uintptr_t)¬ify_params); else ret = fspnotify(¬ify_params); - if (phase == AFTER_PCI_ENUM) { - timestamp_add_now(TS_FSP_AFTER_ENUMERATE); - post_code(POST_FSP_NOTIFY_AFTER_ENUMERATE); - } else if (phase == READY_TO_BOOT) { - timestamp_add_now(TS_FSP_AFTER_FINALIZE); - post_code(POST_FSP_NOTIFY_AFTER_FINALIZE); - } else if (phase == END_OF_FIRMWARE) { - timestamp_add_now(TS_FSP_AFTER_END_OF_FIRMWARE); - post_code(POST_FSP_NOTIFY_AFTER_END_OF_FIRMWARE); - } + timestamp_add_now(data->timestamp_after); + post_code(data->post_code_after); + fsp_debug_after_notify(ret); /* Handle any errors returned by FspNotify */ |