blob: a5c7ef07daa34962f678242ad9381972991482b6 [file] [log] [blame]
Andrey Petrov9de55cc2016-02-25 14:19:07 -08001/*
2 * This file is part of the coreboot project.
3 *
Lee Leahy47bd2d92016-07-24 18:12:16 -07004 * Copyright (C) 2015-2016 Intel Corp.
Andrey Petrov9de55cc2016-02-25 14:19:07 -08005 * (Written by Andrey Petrov <andrey.petrov@intel.com> for Intel Corp.)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
Lee Leahy806fa242016-08-01 13:55:02 -070013#include <bootstate.h>
Andrey Petrov9de55cc2016-02-25 14:19:07 -080014#include <console/console.h>
Nico Huberd67edca2018-11-13 19:28:07 +010015#include <cpu/x86/mtrr.h>
Andrey Petrov9de55cc2016-02-25 14:19:07 -080016#include <fsp/util.h>
17#include <string.h>
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070018#include <timestamp.h>
Andrey Petrov9de55cc2016-02-25 14:19:07 -080019
Lee Leahy806fa242016-08-01 13:55:02 -070020static void fsp_notify(enum fsp_notify_phase phase)
Andrey Petrov9de55cc2016-02-25 14:19:07 -080021{
Brandon Breitensteinc31ba0e2016-07-27 17:34:45 -070022 uint32_t ret;
Andrey Petrov9de55cc2016-02-25 14:19:07 -080023 fsp_notify_fn fspnotify;
24 struct fsp_notify_params notify_params = { .phase = phase };
25
Lee Leahy9671faa2016-07-24 18:18:52 -070026 if (!fsps_hdr.notify_phase_entry_offset)
27 die("Notify_phase_entry_offset is zero!\n");
Andrey Petrov9de55cc2016-02-25 14:19:07 -080028
Lee Leahy27de7682017-03-10 08:33:16 -080029 fspnotify = (void *) (fsps_hdr.image_base +
Andrey Petrov9de55cc2016-02-25 14:19:07 -080030 fsps_hdr.notify_phase_entry_offset);
Lee Leahy672df162016-07-24 18:21:13 -070031 fsp_before_debug_notify(fspnotify, &notify_params);
Andrey Petrov9de55cc2016-02-25 14:19:07 -080032
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070033 if (phase == AFTER_PCI_ENUM) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070034 timestamp_add_now(TS_FSP_BEFORE_ENUMERATE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070035 post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE);
36 } else if (phase == READY_TO_BOOT) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070037 timestamp_add_now(TS_FSP_BEFORE_FINALIZE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070038 post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE);
Aaron Durbin96b3c6f2016-11-10 21:09:25 -060039 } else if (phase == END_OF_FIRMWARE) {
40 timestamp_add_now(TS_FSP_BEFORE_END_OF_FIRMWARE);
41 post_code(POST_FSP_NOTIFY_BEFORE_END_OF_FIRMWARE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070042 }
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070043
44 ret = fspnotify(&notify_params);
45
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070046 if (phase == AFTER_PCI_ENUM) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070047 timestamp_add_now(TS_FSP_AFTER_ENUMERATE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070048 post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE);
49 } else if (phase == READY_TO_BOOT) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070050 timestamp_add_now(TS_FSP_AFTER_FINALIZE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070051 post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE);
Aaron Durbin96b3c6f2016-11-10 21:09:25 -060052 } else if (phase == END_OF_FIRMWARE) {
53 timestamp_add_now(TS_FSP_AFTER_END_OF_FIRMWARE);
54 post_code(POST_FSP_NOTIFY_AFTER_END_OF_FIRMWARE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070055 }
Lee Leahy672df162016-07-24 18:21:13 -070056 fsp_debug_after_notify(ret);
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070057
Lee Leahy9671faa2016-07-24 18:18:52 -070058 /* Handle any errors returned by FspNotify */
59 fsp_handle_reset(ret);
60 if (ret != FSP_SUCCESS) {
61 printk(BIOS_SPEW, "FspNotify returned 0x%08x\n", ret);
62 die("FspNotify returned an error!\n");
63 }
Lee Leahy806fa242016-08-01 13:55:02 -070064
65 /* Allow the platform to run something after FspNotify */
66 platform_fsp_notify_status(phase);
67}
68
69static void fsp_notify_dummy(void *arg)
70{
71 enum fsp_notify_phase phase = (uint32_t)arg;
72
Nico Huberd67edca2018-11-13 19:28:07 +010073 display_mtrrs();
Lee Leahy806fa242016-08-01 13:55:02 -070074
75 fsp_notify(phase);
76 if (phase == READY_TO_BOOT)
77 fsp_notify(END_OF_FIRMWARE);
78}
79
Subrata Banik3f3025d2017-08-18 15:05:05 +053080BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fsp_notify_dummy,
Lee Leahy806fa242016-08-01 13:55:02 -070081 (void *) AFTER_PCI_ENUM);
82BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, fsp_notify_dummy,
83 (void *) READY_TO_BOOT);
84BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, fsp_notify_dummy,
85 (void *) READY_TO_BOOT);
86
Aaron Durbin64031672018-04-21 14:45:32 -060087__weak void platform_fsp_notify_status(
Lee Leahy806fa242016-08-01 13:55:02 -070088 enum fsp_notify_phase phase)
89{
Andrey Petrov9de55cc2016-02-25 14:19:07 -080090}