blob: bd489d4ce60f90ff0a6793a2de4dfbabdaf5e56a [file] [log] [blame]
Andrey Petrov9de55cc2016-02-25 14:19:07 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2015 Intel Corp.
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>
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
20struct fsp_notify_params {
21 enum fsp_notify_phase phase;
22};
23
24typedef asmlinkage enum fsp_status (*fsp_notify_fn)
25 (struct fsp_notify_params *);
26
27enum fsp_status fsp_notify(enum fsp_notify_phase phase)
28{
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070029 enum fsp_status ret;
Andrey Petrov9de55cc2016-02-25 14:19:07 -080030 fsp_notify_fn fspnotify;
31 struct fsp_notify_params notify_params = { .phase = phase };
32
33 if (!fsps_hdr.silicon_init_entry_offset)
34 return FSP_NOT_FOUND;
35
36 fspnotify = (void*) (fsps_hdr.image_base +
37 fsps_hdr.notify_phase_entry_offset);
38
39 printk(BIOS_DEBUG, "FspNotify %x\n", (uint32_t) phase);
40
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070041 if (phase == AFTER_PCI_ENUM) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070042 timestamp_add_now(TS_FSP_BEFORE_ENUMERATE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070043 post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE);
44 } else if (phase == READY_TO_BOOT) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070045 timestamp_add_now(TS_FSP_BEFORE_FINALIZE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070046 post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE);
47 }
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070048
49 ret = fspnotify(&notify_params);
50
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070051 if (phase == AFTER_PCI_ENUM) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070052 timestamp_add_now(TS_FSP_AFTER_ENUMERATE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070053 post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE);
54 } else if (phase == READY_TO_BOOT) {
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070055 timestamp_add_now(TS_FSP_AFTER_FINALIZE);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070056 post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE);
57 }
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070058
59 return ret;
Andrey Petrov9de55cc2016-02-25 14:19:07 -080060}