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