blob: 840165375ce8b94d0a33bf8167efb4bacd0cb333 [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
13#include <arch/cpu.h>
Lee Leahy806fa242016-08-01 13:55:02 -070014#include <bootstate.h>
Andrey Petrov9de55cc2016-02-25 14:19:07 -080015#include <console/console.h>
Andrey Petrov9de55cc2016-02-25 14:19:07 -080016#include <fsp/util.h>
Lee Leahy806fa242016-08-01 13:55:02 -070017#include <soc/intel/common/util.h>
Andrey Petrov9de55cc2016-02-25 14:19:07 -080018#include <string.h>
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070019#include <timestamp.h>
Andrey Petrov9de55cc2016-02-25 14:19:07 -080020
Lee Leahy806fa242016-08-01 13:55:02 -070021static void fsp_notify(enum fsp_notify_phase phase)
Andrey Petrov9de55cc2016-02-25 14:19:07 -080022{
Brandon Breitensteinc31ba0e2016-07-27 17:34:45 -070023 uint32_t ret;
Andrey Petrov9de55cc2016-02-25 14:19:07 -080024 fsp_notify_fn fspnotify;
25 struct fsp_notify_params notify_params = { .phase = phase };
26
Lee Leahy9671faa2016-07-24 18:18:52 -070027 if (!fsps_hdr.notify_phase_entry_offset)
28 die("Notify_phase_entry_offset is zero!\n");
Andrey Petrov9de55cc2016-02-25 14:19:07 -080029
30 fspnotify = (void*) (fsps_hdr.image_base +
31 fsps_hdr.notify_phase_entry_offset);
Lee Leahy672df162016-07-24 18:21:13 -070032 fsp_before_debug_notify(fspnotify, &notify_params);
Andrey Petrov9de55cc2016-02-25 14:19:07 -080033
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070034 if (phase == AFTER_PCI_ENUM) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070035 timestamp_add_now(TS_FSP_BEFORE_ENUMERATE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070036 post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE);
37 } else if (phase == READY_TO_BOOT) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070038 timestamp_add_now(TS_FSP_BEFORE_FINALIZE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070039 post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE);
40 }
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070041
42 ret = fspnotify(&notify_params);
43
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070044 if (phase == AFTER_PCI_ENUM) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070045 timestamp_add_now(TS_FSP_AFTER_ENUMERATE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070046 post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE);
47 } else if (phase == READY_TO_BOOT) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070048 timestamp_add_now(TS_FSP_AFTER_FINALIZE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070049 post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE);
50 }
Lee Leahy672df162016-07-24 18:21:13 -070051 fsp_debug_after_notify(ret);
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070052
Lee Leahy9671faa2016-07-24 18:18:52 -070053 /* Handle any errors returned by FspNotify */
54 fsp_handle_reset(ret);
55 if (ret != FSP_SUCCESS) {
56 printk(BIOS_SPEW, "FspNotify returned 0x%08x\n", ret);
57 die("FspNotify returned an error!\n");
58 }
Lee Leahy806fa242016-08-01 13:55:02 -070059
60 /* Allow the platform to run something after FspNotify */
61 platform_fsp_notify_status(phase);
62}
63
64static void fsp_notify_dummy(void *arg)
65{
66 enum fsp_notify_phase phase = (uint32_t)arg;
67
68 /* Display the MTRRs */
69 if (IS_ENABLED(CONFIG_DISPLAY_MTRRS))
70 soc_display_mtrrs();
71
72 fsp_notify(phase);
73 if (phase == READY_TO_BOOT)
74 fsp_notify(END_OF_FIRMWARE);
75}
76
77BOOT_STATE_INIT_ENTRY(BS_DEV_RESOURCES, BS_ON_EXIT, fsp_notify_dummy,
78 (void *) AFTER_PCI_ENUM);
79BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, fsp_notify_dummy,
80 (void *) READY_TO_BOOT);
81BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, fsp_notify_dummy,
82 (void *) READY_TO_BOOT);
83
84__attribute__((weak)) void platform_fsp_notify_status(
85 enum fsp_notify_phase phase)
86{
Andrey Petrov9de55cc2016-02-25 14:19:07 -080087}