blob: f848986cc16be2fdc0a2dbeeaaee7ea295b5db0e [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>
14#include <console/console.h>
15#include <fsp/api.h>
16#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
Andrey Petrov9de55cc2016-02-25 14:19:07 -080020enum fsp_status fsp_notify(enum fsp_notify_phase phase)
21{
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070022 enum fsp_status ret;
Andrey Petrov9de55cc2016-02-25 14:19:07 -080023 fsp_notify_fn fspnotify;
24 struct fsp_notify_params notify_params = { .phase = phase };
25
26 if (!fsps_hdr.silicon_init_entry_offset)
27 return FSP_NOT_FOUND;
28
29 fspnotify = (void*) (fsps_hdr.image_base +
30 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);
39 }
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070040
41 ret = fspnotify(&notify_params);
42
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070043 if (phase == AFTER_PCI_ENUM) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070044 timestamp_add_now(TS_FSP_AFTER_ENUMERATE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070045 post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE);
46 } else if (phase == READY_TO_BOOT) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070047 timestamp_add_now(TS_FSP_AFTER_FINALIZE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070048 post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE);
49 }
Lee Leahy672df162016-07-24 18:21:13 -070050 fsp_debug_after_notify(ret);
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070051
52 return ret;
Andrey Petrov9de55cc2016-02-25 14:19:07 -080053}