Patrick Georgi | 02363b5 | 2020-05-05 20:48:50 +0200 | [diff] [blame] | 1 | /* This file is part of the coreboot project. */ |
Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame^] | 2 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 3 | |
Lee Leahy | 806fa24 | 2016-08-01 13:55:02 -0700 | [diff] [blame] | 4 | #include <bootstate.h> |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 5 | #include <console/console.h> |
Nico Huber | d67edca | 2018-11-13 19:28:07 +0100 | [diff] [blame] | 6 | #include <cpu/x86/mtrr.h> |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 7 | #include <fsp/util.h> |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 8 | #include <timestamp.h> |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 9 | |
Lee Leahy | 806fa24 | 2016-08-01 13:55:02 -0700 | [diff] [blame] | 10 | static void fsp_notify(enum fsp_notify_phase phase) |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 11 | { |
Brandon Breitenstein | c31ba0e | 2016-07-27 17:34:45 -0700 | [diff] [blame] | 12 | uint32_t ret; |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 13 | fsp_notify_fn fspnotify; |
| 14 | struct fsp_notify_params notify_params = { .phase = phase }; |
| 15 | |
Lee Leahy | 9671faa | 2016-07-24 18:18:52 -0700 | [diff] [blame] | 16 | if (!fsps_hdr.notify_phase_entry_offset) |
| 17 | die("Notify_phase_entry_offset is zero!\n"); |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 18 | |
Lee Leahy | 27de768 | 2017-03-10 08:33:16 -0800 | [diff] [blame] | 19 | fspnotify = (void *) (fsps_hdr.image_base + |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 20 | fsps_hdr.notify_phase_entry_offset); |
Lee Leahy | 672df16 | 2016-07-24 18:21:13 -0700 | [diff] [blame] | 21 | fsp_before_debug_notify(fspnotify, ¬ify_params); |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 22 | |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 23 | if (phase == AFTER_PCI_ENUM) { |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 24 | timestamp_add_now(TS_FSP_BEFORE_ENUMERATE); |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 25 | post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE); |
| 26 | } else if (phase == READY_TO_BOOT) { |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 27 | timestamp_add_now(TS_FSP_BEFORE_FINALIZE); |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 28 | post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE); |
Aaron Durbin | 96b3c6f | 2016-11-10 21:09:25 -0600 | [diff] [blame] | 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); |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 32 | } |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 33 | |
| 34 | ret = fspnotify(¬ify_params); |
| 35 | |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 36 | if (phase == AFTER_PCI_ENUM) { |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 37 | timestamp_add_now(TS_FSP_AFTER_ENUMERATE); |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 38 | post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE); |
| 39 | } else if (phase == READY_TO_BOOT) { |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 40 | timestamp_add_now(TS_FSP_AFTER_FINALIZE); |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 41 | post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE); |
Aaron Durbin | 96b3c6f | 2016-11-10 21:09:25 -0600 | [diff] [blame] | 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); |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 45 | } |
Lee Leahy | 672df16 | 2016-07-24 18:21:13 -0700 | [diff] [blame] | 46 | fsp_debug_after_notify(ret); |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 47 | |
Lee Leahy | 9671faa | 2016-07-24 18:18:52 -0700 | [diff] [blame] | 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"); |
| 53 | } |
Lee Leahy | 806fa24 | 2016-08-01 13:55:02 -0700 | [diff] [blame] | 54 | |
| 55 | /* Allow the platform to run something after FspNotify */ |
| 56 | platform_fsp_notify_status(phase); |
| 57 | } |
| 58 | |
| 59 | static void fsp_notify_dummy(void *arg) |
| 60 | { |
| 61 | enum fsp_notify_phase phase = (uint32_t)arg; |
| 62 | |
Nico Huber | d67edca | 2018-11-13 19:28:07 +0100 | [diff] [blame] | 63 | display_mtrrs(); |
Lee Leahy | 806fa24 | 2016-08-01 13:55:02 -0700 | [diff] [blame] | 64 | |
| 65 | fsp_notify(phase); |
| 66 | if (phase == READY_TO_BOOT) |
| 67 | fsp_notify(END_OF_FIRMWARE); |
| 68 | } |
| 69 | |
Subrata Banik | 3f3025d | 2017-08-18 15:05:05 +0530 | [diff] [blame] | 70 | BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fsp_notify_dummy, |
Lee Leahy | 806fa24 | 2016-08-01 13:55:02 -0700 | [diff] [blame] | 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); |
| 76 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 77 | __weak void platform_fsp_notify_status( |
Lee Leahy | 806fa24 | 2016-08-01 13:55:02 -0700 | [diff] [blame] | 78 | enum fsp_notify_phase phase) |
| 79 | { |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 80 | } |