Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Lee Leahy | 47bd2d9 | 2016-07-24 18:12:16 -0700 | [diff] [blame] | 4 | * Copyright (C) 2015-2016 Intel Corp. |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 5 | * (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 Leahy | 806fa24 | 2016-08-01 13:55:02 -0700 | [diff] [blame] | 14 | #include <bootstate.h> |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 15 | #include <console/console.h> |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 16 | #include <fsp/util.h> |
Lee Leahy | 806fa24 | 2016-08-01 13:55:02 -0700 | [diff] [blame] | 17 | #include <soc/intel/common/util.h> |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 18 | #include <string.h> |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 19 | #include <timestamp.h> |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 20 | |
Lee Leahy | 806fa24 | 2016-08-01 13:55:02 -0700 | [diff] [blame] | 21 | static void fsp_notify(enum fsp_notify_phase phase) |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 22 | { |
Brandon Breitenstein | c31ba0e | 2016-07-27 17:34:45 -0700 | [diff] [blame] | 23 | uint32_t ret; |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 24 | fsp_notify_fn fspnotify; |
| 25 | struct fsp_notify_params notify_params = { .phase = phase }; |
| 26 | |
Lee Leahy | 9671faa | 2016-07-24 18:18:52 -0700 | [diff] [blame] | 27 | if (!fsps_hdr.notify_phase_entry_offset) |
| 28 | die("Notify_phase_entry_offset is zero!\n"); |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 29 | |
Lee Leahy | 27de768 | 2017-03-10 08:33:16 -0800 | [diff] [blame] | 30 | fspnotify = (void *) (fsps_hdr.image_base + |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 31 | fsps_hdr.notify_phase_entry_offset); |
Lee Leahy | 672df16 | 2016-07-24 18:21:13 -0700 | [diff] [blame] | 32 | fsp_before_debug_notify(fspnotify, ¬ify_params); |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 33 | |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 34 | if (phase == AFTER_PCI_ENUM) { |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 35 | timestamp_add_now(TS_FSP_BEFORE_ENUMERATE); |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 36 | post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE); |
| 37 | } else if (phase == READY_TO_BOOT) { |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 38 | timestamp_add_now(TS_FSP_BEFORE_FINALIZE); |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 39 | post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE); |
Aaron Durbin | 96b3c6f | 2016-11-10 21:09:25 -0600 | [diff] [blame] | 40 | } else if (phase == END_OF_FIRMWARE) { |
| 41 | timestamp_add_now(TS_FSP_BEFORE_END_OF_FIRMWARE); |
| 42 | post_code(POST_FSP_NOTIFY_BEFORE_END_OF_FIRMWARE); |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 43 | } |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 44 | |
| 45 | ret = fspnotify(¬ify_params); |
| 46 | |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 47 | if (phase == AFTER_PCI_ENUM) { |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 48 | timestamp_add_now(TS_FSP_AFTER_ENUMERATE); |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 49 | post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE); |
| 50 | } else if (phase == READY_TO_BOOT) { |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 51 | timestamp_add_now(TS_FSP_AFTER_FINALIZE); |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 52 | post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE); |
Aaron Durbin | 96b3c6f | 2016-11-10 21:09:25 -0600 | [diff] [blame] | 53 | } else if (phase == END_OF_FIRMWARE) { |
| 54 | timestamp_add_now(TS_FSP_AFTER_END_OF_FIRMWARE); |
| 55 | post_code(POST_FSP_NOTIFY_AFTER_END_OF_FIRMWARE); |
Alexandru Gagniuc | c4ea8f7 | 2016-05-23 12:16:58 -0700 | [diff] [blame] | 56 | } |
Lee Leahy | 672df16 | 2016-07-24 18:21:13 -0700 | [diff] [blame] | 57 | fsp_debug_after_notify(ret); |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 58 | |
Lee Leahy | 9671faa | 2016-07-24 18:18:52 -0700 | [diff] [blame] | 59 | /* Handle any errors returned by FspNotify */ |
| 60 | fsp_handle_reset(ret); |
| 61 | if (ret != FSP_SUCCESS) { |
| 62 | printk(BIOS_SPEW, "FspNotify returned 0x%08x\n", ret); |
| 63 | die("FspNotify returned an error!\n"); |
| 64 | } |
Lee Leahy | 806fa24 | 2016-08-01 13:55:02 -0700 | [diff] [blame] | 65 | |
| 66 | /* Allow the platform to run something after FspNotify */ |
| 67 | platform_fsp_notify_status(phase); |
| 68 | } |
| 69 | |
| 70 | static void fsp_notify_dummy(void *arg) |
| 71 | { |
| 72 | enum fsp_notify_phase phase = (uint32_t)arg; |
| 73 | |
| 74 | /* Display the MTRRs */ |
| 75 | if (IS_ENABLED(CONFIG_DISPLAY_MTRRS)) |
| 76 | soc_display_mtrrs(); |
| 77 | |
| 78 | fsp_notify(phase); |
| 79 | if (phase == READY_TO_BOOT) |
| 80 | fsp_notify(END_OF_FIRMWARE); |
| 81 | } |
| 82 | |
Subrata Banik | 3f3025d | 2017-08-18 15:05:05 +0530 | [diff] [blame^] | 83 | 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] | 84 | (void *) AFTER_PCI_ENUM); |
| 85 | BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, fsp_notify_dummy, |
| 86 | (void *) READY_TO_BOOT); |
| 87 | BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, fsp_notify_dummy, |
| 88 | (void *) READY_TO_BOOT); |
| 89 | |
| 90 | __attribute__((weak)) void platform_fsp_notify_status( |
| 91 | enum fsp_notify_phase phase) |
| 92 | { |
Andrey Petrov | 9de55cc | 2016-02-25 14:19:07 -0800 | [diff] [blame] | 93 | } |