1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <commonlib/helpers.h>
4 #include <console/console.h>
5 #include <console/streams.h>
6 #include <cpu/x86/mtrr.h>
10 asmlinkage
size_t fsp_write_line(uint8_t *buffer
, size_t number_of_bytes
)
12 console_write_line(buffer
, number_of_bytes
);
13 return number_of_bytes
;
21 static void fsp_gpio_config_check(enum fsp_call_phase phase
, const char *call_str
)
25 printk(BIOS_SPEW
, "Snapshot all GPIOs before %s.\n", call_str
);
29 printk(BIOS_SPEW
, "Verify GPIO snapshot after %s...", call_str
);
30 printk(BIOS_SPEW
, "%zd changes detected!\n", gpio_verify_snapshot());
37 enum fsp_log_level
fsp_map_console_log_level(void)
39 enum fsp_log_level fsp_debug_level
;
41 switch (get_log_level()) {
46 fsp_debug_level
= FSP_LOG_LEVEL_ERR
;
49 fsp_debug_level
= FSP_LOG_LEVEL_ERR_WARN
;
52 fsp_debug_level
= FSP_LOG_LEVEL_ERR_WARN_INFO
;
55 fsp_debug_level
= FSP_LOG_LEVEL_ERR_WARN_INFO_EVENT
;
59 fsp_debug_level
= FSP_LOG_LEVEL_VERBOSE
;
62 fsp_debug_level
= FSP_LOG_LEVEL_DISABLE
;
66 if (!CONFIG(DEBUG_RAM_SETUP
))
67 fsp_debug_level
= MIN(fsp_debug_level
, FSP_LOG_LEVEL_ERR_WARN_INFO
);
69 return fsp_debug_level
;
76 void fsp_debug_before_memory_init(fsp_memory_init_fn memory_init
,
77 const FSPM_UPD
*fspm_old_upd
,
78 const FSPM_UPD
*fspm_new_upd
)
82 /* Display the UPD values */
83 if (CONFIG(DISPLAY_UPD_DATA
))
84 fspm_display_upd_values(fspm_old_upd
, fspm_new_upd
);
86 /* Display the call entry point and parameters */
87 if (!CONFIG(DISPLAY_FSP_CALLS_AND_STATUS
))
89 printk(BIOS_SPEW
, "Calling FspMemoryInit: %p\n", memory_init
);
90 printk(BIOS_SPEW
, "\t%p: raminit_upd\n", fspm_new_upd
);
91 printk(BIOS_SPEW
, "\t%p: &hob_list_ptr\n", fsp_get_hob_list_ptr());
94 void fsp_debug_after_memory_init(uint32_t status
)
96 if (CONFIG(DISPLAY_FSP_CALLS_AND_STATUS
))
97 printk(BIOS_SPEW
, "FspMemoryInit returned 0x%08x\n", status
);
99 if (status
!= FSP_SUCCESS
)
102 /* Verify that the HOB list pointer was set */
103 if (fsp_get_hob_list() == NULL
)
104 die("ERROR - HOB list pointer was not returned!\n");
106 /* Display and verify the HOBs */
107 if (CONFIG(DISPLAY_HOBS
))
109 if (CONFIG(VERIFY_HOBS
))
110 fsp_verify_memory_init_hobs();
119 void fsp_debug_before_silicon_init(fsp_silicon_init_fn silicon_init
,
120 const FSPS_UPD
*fsps_old_upd
,
121 const FSPS_UPD
*fsps_new_upd
)
123 if (CONFIG(CHECK_GPIO_CONFIG_CHANGES
))
124 fsp_gpio_config_check(BEFORE_FSP_CALL
, "FSP Silicon Init");
128 /* Display the UPD values */
129 if (CONFIG(DISPLAY_UPD_DATA
))
130 soc_display_fsps_upd_params(fsps_old_upd
, fsps_new_upd
);
132 /* Display the call to FSP SiliconInit */
133 if (!CONFIG(DISPLAY_FSP_CALLS_AND_STATUS
))
135 printk(BIOS_SPEW
, "Calling FspSiliconInit: %p\n", silicon_init
);
136 printk(BIOS_SPEW
, "\t%p: upd\n", fsps_new_upd
);
139 void fsp_debug_after_silicon_init(uint32_t status
)
141 if (CONFIG(CHECK_GPIO_CONFIG_CHANGES
))
142 fsp_gpio_config_check(AFTER_FSP_CALL
, "FSP Silicon Init");
144 if (CONFIG(DISPLAY_FSP_CALLS_AND_STATUS
))
145 printk(BIOS_SPEW
, "FspSiliconInit returned 0x%08x\n", status
);
147 /* Display the HOBs */
148 if (CONFIG(DISPLAY_HOBS
))
158 void fsp_before_debug_notify(fsp_notify_fn notify
,
159 const struct fsp_notify_params
*notify_params
)
161 if (CONFIG(CHECK_GPIO_CONFIG_CHANGES
))
162 fsp_gpio_config_check(BEFORE_FSP_CALL
, "FSP Notify");
164 /* Display the call to FspNotify */
165 if (!CONFIG(DISPLAY_FSP_CALLS_AND_STATUS
))
167 printk(BIOS_SPEW
, "0x%08x: notify_params->phase\n",
168 notify_params
->phase
);
169 printk(BIOS_SPEW
, "Calling FspNotify: %p\n", notify
);
170 printk(BIOS_SPEW
, "\t%p: notify_params\n", notify_params
);
173 void fsp_debug_after_notify(uint32_t status
)
175 if (CONFIG(CHECK_GPIO_CONFIG_CHANGES
))
176 fsp_gpio_config_check(AFTER_FSP_CALL
, "FSP Notify");
178 if (CONFIG(DISPLAY_FSP_CALLS_AND_STATUS
))
179 printk(BIOS_SPEW
, "FspNotify returned 0x%08x\n", status
);
181 /* Display the HOBs */
182 if (CONFIG(DISPLAY_HOBS
))