blob: ee04630ca1af54fc883454642a1c3e0dcafbf86d [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Andrey Petrov9de55cc2016-02-25 14:19:07 -08002
Lee Leahy806fa242016-08-01 13:55:02 -07003#include <bootstate.h>
Andrey Petrov9de55cc2016-02-25 14:19:07 -08004#include <console/console.h>
Nico Huberd67edca2018-11-13 19:28:07 +01005#include <cpu/x86/mtrr.h>
Andrey Petrov9de55cc2016-02-25 14:19:07 -08006#include <fsp/util.h>
Alexandru Gagniuc010225c2016-05-06 08:22:45 -07007#include <timestamp.h>
Andrey Petrov9de55cc2016-02-25 14:19:07 -08008
Lee Leahy806fa242016-08-01 13:55:02 -07009static void fsp_notify(enum fsp_notify_phase phase)
Andrey Petrov9de55cc2016-02-25 14:19:07 -080010{
Brandon Breitensteinc31ba0e2016-07-27 17:34:45 -070011 uint32_t ret;
Andrey Petrov9de55cc2016-02-25 14:19:07 -080012 fsp_notify_fn fspnotify;
13 struct fsp_notify_params notify_params = { .phase = phase };
14
Lee Leahy9671faa2016-07-24 18:18:52 -070015 if (!fsps_hdr.notify_phase_entry_offset)
16 die("Notify_phase_entry_offset is zero!\n");
Andrey Petrov9de55cc2016-02-25 14:19:07 -080017
Lee Leahy27de7682017-03-10 08:33:16 -080018 fspnotify = (void *) (fsps_hdr.image_base +
Andrey Petrov9de55cc2016-02-25 14:19:07 -080019 fsps_hdr.notify_phase_entry_offset);
Lee Leahy672df162016-07-24 18:21:13 -070020 fsp_before_debug_notify(fspnotify, &notify_params);
Andrey Petrov9de55cc2016-02-25 14:19:07 -080021
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070022 if (phase == AFTER_PCI_ENUM) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070023 timestamp_add_now(TS_FSP_BEFORE_ENUMERATE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070024 post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE);
25 } else if (phase == READY_TO_BOOT) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070026 timestamp_add_now(TS_FSP_BEFORE_FINALIZE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070027 post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE);
Aaron Durbin96b3c6f2016-11-10 21:09:25 -060028 } else if (phase == END_OF_FIRMWARE) {
29 timestamp_add_now(TS_FSP_BEFORE_END_OF_FIRMWARE);
30 post_code(POST_FSP_NOTIFY_BEFORE_END_OF_FIRMWARE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070031 }
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070032
33 ret = fspnotify(&notify_params);
34
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070035 if (phase == AFTER_PCI_ENUM) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070036 timestamp_add_now(TS_FSP_AFTER_ENUMERATE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070037 post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE);
38 } else if (phase == READY_TO_BOOT) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070039 timestamp_add_now(TS_FSP_AFTER_FINALIZE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070040 post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE);
Aaron Durbin96b3c6f2016-11-10 21:09:25 -060041 } else if (phase == END_OF_FIRMWARE) {
42 timestamp_add_now(TS_FSP_AFTER_END_OF_FIRMWARE);
43 post_code(POST_FSP_NOTIFY_AFTER_END_OF_FIRMWARE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070044 }
Lee Leahy672df162016-07-24 18:21:13 -070045 fsp_debug_after_notify(ret);
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070046
Lee Leahy9671faa2016-07-24 18:18:52 -070047 /* Handle any errors returned by FspNotify */
48 fsp_handle_reset(ret);
49 if (ret != FSP_SUCCESS) {
50 printk(BIOS_SPEW, "FspNotify returned 0x%08x\n", ret);
51 die("FspNotify returned an error!\n");
52 }
Lee Leahy806fa242016-08-01 13:55:02 -070053
54 /* Allow the platform to run something after FspNotify */
55 platform_fsp_notify_status(phase);
56}
57
58static void fsp_notify_dummy(void *arg)
59{
Patrick Rudolph90fda022020-11-30 13:44:17 +010060 enum fsp_notify_phase phase = (uint32_t)(uintptr_t)arg;
Lee Leahy806fa242016-08-01 13:55:02 -070061
Nico Huberd67edca2018-11-13 19:28:07 +010062 display_mtrrs();
Lee Leahy806fa242016-08-01 13:55:02 -070063
64 fsp_notify(phase);
65 if (phase == READY_TO_BOOT)
66 fsp_notify(END_OF_FIRMWARE);
67}
68
Subrata Banik3f3025d2017-08-18 15:05:05 +053069BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fsp_notify_dummy,
Lee Leahy806fa242016-08-01 13:55:02 -070070 (void *) AFTER_PCI_ENUM);
71BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, fsp_notify_dummy,
72 (void *) READY_TO_BOOT);
73BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, fsp_notify_dummy,
74 (void *) READY_TO_BOOT);
75
Aaron Durbin64031672018-04-21 14:45:32 -060076__weak void platform_fsp_notify_status(
Lee Leahy806fa242016-08-01 13:55:02 -070077 enum fsp_notify_phase phase)
78{
Andrey Petrov9de55cc2016-02-25 14:19:07 -080079}