coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
notify.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <bootstate.h>
4 #include <console/console.h>
5 #include <cpu/x86/mtrr.h>
6 #include <fsp/util.h>
7 #include <mode_switch.h>
8 #include <timestamp.h>
9 #include <types.h>
10 
13  bool skip;
18 };
19 
20 static const struct fsp_notify_phase_data notify_data[] = {
21  {
23  .skip = !CONFIG(USE_FSP_NOTIFY_PHASE_POST_PCI_ENUM),
24  .post_code_before = POST_FSP_NOTIFY_BEFORE_ENUMERATE,
25  .post_code_after = POST_FSP_NOTIFY_AFTER_ENUMERATE,
26  .timestamp_before = TS_FSP_ENUMERATE_START,
27  .timestamp_after = TS_FSP_ENUMERATE_END,
28  },
29  {
30  .notify_phase = READY_TO_BOOT,
31  .skip = !CONFIG(USE_FSP_NOTIFY_PHASE_READY_TO_BOOT),
32  .post_code_before = POST_FSP_NOTIFY_BEFORE_FINALIZE,
33  .post_code_after = POST_FSP_NOTIFY_AFTER_FINALIZE,
34  .timestamp_before = TS_FSP_FINALIZE_START,
35  .timestamp_after = TS_FSP_FINALIZE_END,
36  },
37  {
38  .notify_phase = END_OF_FIRMWARE,
39  .skip = !CONFIG(USE_FSP_NOTIFY_PHASE_END_OF_FIRMWARE),
40  .post_code_before = POST_FSP_NOTIFY_BEFORE_END_OF_FIRMWARE,
41  .post_code_after = POST_FSP_NOTIFY_AFTER_END_OF_FIRMWARE,
42  .timestamp_before = TS_FSP_END_OF_FIRMWARE_START,
43  .timestamp_after = TS_FSP_END_OF_FIRMWARE_END,
44  },
45 };
46 
48 {
49  for (size_t i = 0; i < ARRAY_SIZE(notify_data); i++) {
50  if (notify_data[i].notify_phase == phase)
51  return &notify_data[i];
52  }
53  die("Unknown FSP notify phase %u\n", phase);
54 }
55 
56 static void fsp_notify(enum fsp_notify_phase phase)
57 {
58  const struct fsp_notify_phase_data *data = get_notify_phase_data(phase);
59  struct fsp_notify_params notify_params = { .phase = phase };
60  fsp_notify_fn fspnotify;
61  uint32_t ret;
62 
63  if (data->skip) {
64  printk(BIOS_INFO, "coreboot skipped calling FSP notify phase: %08x.\n", phase);
65  return;
66  }
67 
68  if (!fsps_hdr.notify_phase_entry_offset)
69  die("Notify_phase_entry_offset is zero!\n");
70 
71  fspnotify = (void *)(uintptr_t)(fsps_hdr.image_base +
72  fsps_hdr.notify_phase_entry_offset);
73  fsp_before_debug_notify(fspnotify, &notify_params);
74 
77 
78  if (ENV_X86_64 && CONFIG(PLATFORM_USES_FSP2_X86_32))
79  ret = protected_mode_call_1arg(fspnotify, (uintptr_t)&notify_params);
80  else
81  ret = fspnotify(&notify_params);
82 
85 
87 
88  /* Handle any errors returned by FspNotify */
89  fsp_handle_reset(ret);
90  if (ret != FSP_SUCCESS)
91  die("FspNotify returned with error 0x%08x!\n", ret);
92 
93  /* Allow the platform to run something after FspNotify */
95 }
96 
97 static void fsp_notify_dummy(void *arg)
98 {
100 
101  display_mtrrs();
102 
103  fsp_notify(phase);
104  if (phase == READY_TO_BOOT)
106 }
107 
111 
113 {
114 }
@ BS_PAYLOAD_LOAD
Definition: bootstate.h:88
@ BS_DEV_ENABLE
Definition: bootstate.h:82
@ BS_OS_RESUME
Definition: bootstate.h:86
@ BS_ON_ENTRY
Definition: bootstate.h:95
@ BS_ON_EXIT
Definition: bootstate.h:96
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define printk(level,...)
Definition: stdlib.h:16
void __noreturn die(const char *fmt,...)
Definition: die.c:17
asmlinkage void display_mtrrs(void)
Definition: debug.c:186
void fsp_before_debug_notify(fsp_notify_fn notify, const struct fsp_notify_params *notify_params)
Definition: debug.c:158
void fsp_debug_after_notify(uint32_t status)
Definition: debug.c:173
asmlinkage uint32_t(* fsp_notify_fn)(struct fsp_notify_params *)
Definition: util.h:163
void fsp_handle_reset(uint32_t status)
Definition: util.c:92
@ CONFIG
Definition: dsi_common.h:201
#define FSP_SUCCESS
Definition: api.h:11
fsp_notify_phase
Definition: api.h:28
@ END_OF_FIRMWARE
Definition: api.h:31
@ AFTER_PCI_ENUM
Definition: api.h:29
@ READY_TO_BOOT
Definition: api.h:30
struct fsp_header fsps_hdr
Definition: silicon_init.c:19
struct bootblock_arg arg
Definition: decompressor.c:22
void timestamp_add_now(enum timestamp_id id)
Definition: timestamp.c:141
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
static int protected_mode_call_1arg(void *func, uint32_t arg1)
Definition: mode_switch.h:57
static void fsp_notify_dummy(void *arg)
Definition: notify.c:97
BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fsp_notify_dummy,(void *) AFTER_PCI_ENUM)
static const struct fsp_notify_phase_data * get_notify_phase_data(enum fsp_notify_phase phase)
Definition: notify.c:47
__weak void platform_fsp_notify_status(enum fsp_notify_phase phase)
Definition: notify.c:112
static const struct fsp_notify_phase_data notify_data[]
Definition: notify.c:20
static void fsp_notify(enum fsp_notify_phase phase)
Definition: notify.c:56
#define post_code(value)
Definition: post_code.h:12
#define POST_FSP_NOTIFY_BEFORE_FINALIZE
Before calling FSP Notify (ready to boot)
Definition: post_codes.h:260
#define POST_FSP_NOTIFY_BEFORE_ENUMERATE
Before calling FSP Notify (after PCI enumeration)
Definition: post_codes.h:253
#define POST_FSP_NOTIFY_AFTER_END_OF_FIRMWARE
After calling FSP Notify (end of firmware)
Definition: post_codes.h:218
#define POST_FSP_NOTIFY_AFTER_ENUMERATE
After calling FSP Notify (after PCI enumeration)
Definition: post_codes.h:309
#define POST_FSP_NOTIFY_BEFORE_END_OF_FIRMWARE
Before calling FSP Notify (end of firmware)
Definition: post_codes.h:211
#define POST_FSP_NOTIFY_AFTER_FINALIZE
After calling FSP Notify (ready to boot)
Definition: post_codes.h:316
#define ENV_X86_64
Definition: rules.h:250
const struct smm_save_state_ops *legacy_ops __weak
Definition: save_state.c:8
unsigned int uint32_t
Definition: stdint.h:14
unsigned long uintptr_t
Definition: stdint.h:21
unsigned char uint8_t
Definition: stdint.h:8
enum fsp_notify_phase phase
Definition: util.h:37
enum timestamp_id timestamp_after
Definition: notify.c:17
uint8_t post_code_after
Definition: notify.c:15
uint8_t post_code_before
Definition: notify.c:14
enum fsp_notify_phase notify_phase
Definition: notify.c:12
enum timestamp_id timestamp_before
Definition: notify.c:16
@ TS_FSP_FINALIZE_END
@ TS_FSP_END_OF_FIRMWARE_END
@ TS_FSP_FINALIZE_START
@ TS_FSP_ENUMERATE_END
@ TS_FSP_END_OF_FIRMWARE_START
@ TS_FSP_ENUMERATE_START