1 /* This file is part of the coreboot project. */
2 /* SPDX-License-Identifier: GPL-2.0-or-later */
5 #include <console/console.h>
6 #include <cpu/x86/mtrr.h>
10 static void fsp_notify(enum fsp_notify_phase phase
)
13 fsp_notify_fn fspnotify
;
14 struct fsp_notify_params notify_params
= { .phase
= phase
};
16 if (!fsps_hdr
.notify_phase_entry_offset
)
17 die("Notify_phase_entry_offset is zero!\n");
19 fspnotify
= (void *) (fsps_hdr
.image_base
+
20 fsps_hdr
.notify_phase_entry_offset
);
21 fsp_before_debug_notify(fspnotify
, ¬ify_params
);
23 if (phase
== AFTER_PCI_ENUM
) {
24 timestamp_add_now(TS_FSP_BEFORE_ENUMERATE
);
25 post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE
);
26 } else if (phase
== READY_TO_BOOT
) {
27 timestamp_add_now(TS_FSP_BEFORE_FINALIZE
);
28 post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE
);
29 } else if (phase
== END_OF_FIRMWARE
) {
30 timestamp_add_now(TS_FSP_BEFORE_END_OF_FIRMWARE
);
31 post_code(POST_FSP_NOTIFY_BEFORE_END_OF_FIRMWARE
);
34 ret
= fspnotify(¬ify_params
);
36 if (phase
== AFTER_PCI_ENUM
) {
37 timestamp_add_now(TS_FSP_AFTER_ENUMERATE
);
38 post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE
);
39 } else if (phase
== READY_TO_BOOT
) {
40 timestamp_add_now(TS_FSP_AFTER_FINALIZE
);
41 post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE
);
42 } else if (phase
== END_OF_FIRMWARE
) {
43 timestamp_add_now(TS_FSP_AFTER_END_OF_FIRMWARE
);
44 post_code(POST_FSP_NOTIFY_AFTER_END_OF_FIRMWARE
);
46 fsp_debug_after_notify(ret
);
48 /* Handle any errors returned by FspNotify */
49 fsp_handle_reset(ret
);
50 if (ret
!= FSP_SUCCESS
) {
51 printk(BIOS_SPEW
, "FspNotify returned 0x%08x\n", ret
);
52 die("FspNotify returned an error!\n");
55 /* Allow the platform to run something after FspNotify */
56 platform_fsp_notify_status(phase
);
59 static void fsp_notify_dummy(void *arg
)
61 enum fsp_notify_phase phase
= (uint32_t)arg
;
66 if (phase
== READY_TO_BOOT
)
67 fsp_notify(END_OF_FIRMWARE
);
70 BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE
, BS_ON_ENTRY
, fsp_notify_dummy
,
71 (void *) AFTER_PCI_ENUM
);
72 BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD
, BS_ON_EXIT
, fsp_notify_dummy
,
73 (void *) READY_TO_BOOT
);
74 BOOT_STATE_INIT_ENTRY(BS_OS_RESUME
, BS_ON_ENTRY
, fsp_notify_dummy
,
75 (void *) READY_TO_BOOT
);
77 __weak
void platform_fsp_notify_status(
78 enum fsp_notify_phase phase
)