summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/intel/fsp2_0/notify.c68
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 &notify_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, &notify_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)&notify_params);
else
ret = fspnotify(&notify_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 */