blob: 94737720320d3e75c0021fa745a91719ac511b2b [file] [log] [blame]
Patrick Georgi02363b52020-05-05 20:48:50 +02001/* This file is part of the coreboot project. */
Patrick Georgiac959032020-05-05 22:49:26 +02002/* SPDX-License-Identifier: GPL-2.0-or-later */
Andrey Petrov9de55cc2016-02-25 14:19:07 -08003
Lee Leahy806fa242016-08-01 13:55:02 -07004#include <bootstate.h>
Andrey Petrov9de55cc2016-02-25 14:19:07 -08005#include <console/console.h>
Nico Huberd67edca2018-11-13 19:28:07 +01006#include <cpu/x86/mtrr.h>
Andrey Petrov9de55cc2016-02-25 14:19:07 -08007#include <fsp/util.h>
Alexandru Gagniuc010225c2016-05-06 08:22:45 -07008#include <timestamp.h>
Andrey Petrov9de55cc2016-02-25 14:19:07 -08009
Lee Leahy806fa242016-08-01 13:55:02 -070010static void fsp_notify(enum fsp_notify_phase phase)
Andrey Petrov9de55cc2016-02-25 14:19:07 -080011{
Brandon Breitensteinc31ba0e2016-07-27 17:34:45 -070012 uint32_t ret;
Andrey Petrov9de55cc2016-02-25 14:19:07 -080013 fsp_notify_fn fspnotify;
14 struct fsp_notify_params notify_params = { .phase = phase };
15
Lee Leahy9671faa2016-07-24 18:18:52 -070016 if (!fsps_hdr.notify_phase_entry_offset)
17 die("Notify_phase_entry_offset is zero!\n");
Andrey Petrov9de55cc2016-02-25 14:19:07 -080018
Lee Leahy27de7682017-03-10 08:33:16 -080019 fspnotify = (void *) (fsps_hdr.image_base +
Andrey Petrov9de55cc2016-02-25 14:19:07 -080020 fsps_hdr.notify_phase_entry_offset);
Lee Leahy672df162016-07-24 18:21:13 -070021 fsp_before_debug_notify(fspnotify, &notify_params);
Andrey Petrov9de55cc2016-02-25 14:19:07 -080022
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070023 if (phase == AFTER_PCI_ENUM) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070024 timestamp_add_now(TS_FSP_BEFORE_ENUMERATE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070025 post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE);
26 } else if (phase == READY_TO_BOOT) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070027 timestamp_add_now(TS_FSP_BEFORE_FINALIZE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070028 post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE);
Aaron Durbin96b3c6f2016-11-10 21:09:25 -060029 } 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);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070032 }
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070033
34 ret = fspnotify(&notify_params);
35
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070036 if (phase == AFTER_PCI_ENUM) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070037 timestamp_add_now(TS_FSP_AFTER_ENUMERATE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070038 post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE);
39 } else if (phase == READY_TO_BOOT) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070040 timestamp_add_now(TS_FSP_AFTER_FINALIZE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070041 post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE);
Aaron Durbin96b3c6f2016-11-10 21:09:25 -060042 } 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);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070045 }
Lee Leahy672df162016-07-24 18:21:13 -070046 fsp_debug_after_notify(ret);
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070047
Lee Leahy9671faa2016-07-24 18:18:52 -070048 /* 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");
53 }
Lee Leahy806fa242016-08-01 13:55:02 -070054
55 /* Allow the platform to run something after FspNotify */
56 platform_fsp_notify_status(phase);
57}
58
59static void fsp_notify_dummy(void *arg)
60{
61 enum fsp_notify_phase phase = (uint32_t)arg;
62
Nico Huberd67edca2018-11-13 19:28:07 +010063 display_mtrrs();
Lee Leahy806fa242016-08-01 13:55:02 -070064
65 fsp_notify(phase);
66 if (phase == READY_TO_BOOT)
67 fsp_notify(END_OF_FIRMWARE);
68}
69
Subrata Banik3f3025d2017-08-18 15:05:05 +053070BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fsp_notify_dummy,
Lee Leahy806fa242016-08-01 13:55:02 -070071 (void *) AFTER_PCI_ENUM);
72BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, fsp_notify_dummy,
73 (void *) READY_TO_BOOT);
74BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, fsp_notify_dummy,
75 (void *) READY_TO_BOOT);
76
Aaron Durbin64031672018-04-21 14:45:32 -060077__weak void platform_fsp_notify_status(
Lee Leahy806fa242016-08-01 13:55:02 -070078 enum fsp_notify_phase phase)
79{
Andrey Petrov9de55cc2016-02-25 14:19:07 -080080}