Debian Codegraph @

src/soc/intel/broadwell/refcode.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <string.h>
4 #include <acpi/acpi.h>
5 #include <cbmem.h>
6 #include <console/console.h>
7 #include <console/streams.h>
8 #include <program_loading.h>
9 #include <rmodule.h>
10 #include <stage_cache.h>
11 #include <soc/pei_data.h>
12 #include <soc/pei_wrapper.h>
13 #include <soc/pm.h>
14 #include <soc/refcode.h>
15
16 static pei_wrapper_entry_t load_reference_code(void)
17 {
18 if (resume_from_stage_cache()) {
19 struct prog prog;
20 stage_cache_load_stage(STAGE_REFCODE, &prog);
21 return prog_entry(&prog);
22 }
23
24 struct prog prog =
25 PROG_INIT(PROG_REFCODE, CONFIG_CBFS_PREFIX "/refcode");
26 struct rmod_stage_load refcode = {
27 .cbmem_id = CBMEM_ID_REFCODE,
28 .prog = &prog,
29 };
30
31 if (rmodule_stage_load(&refcode)) {
32 printk(BIOS_DEBUG, "Error loading reference code.\n");
33 return NULL;
34 }
35
36 /* Cache loaded reference code. */
37 stage_cache_add(STAGE_REFCODE, &prog);
38
39 return (pei_wrapper_entry_t)prog_entry(&prog);
40 }
41
42 void broadwell_run_reference_code(void)
43 {
44 int ret, dummy;
45 struct pei_data pei_data;
46 pei_wrapper_entry_t entry;
47
48 memset(&pei_data, 0, sizeof(pei_data));
49 mainboard_fill_pei_data(&pei_data);
50 broadwell_fill_pei_data(&pei_data);
51
52 pei_data.boot_mode = acpi_is_wakeup_s3() ? ACPI_S3 : 0;
53 pei_data.saved_data = (void *)&dummy;
54
55 entry = load_reference_code();
56 if (entry == NULL) {
57 printk(BIOS_ERR, "Reference code not found\n");
58 return;
59 }
60
61 /* Call into reference code. */
62 ret = entry(&pei_data);
63 if (ret != 0) {
64 printk(BIOS_ERR, "Reference code returned %d\n", ret);
65 return;
66 }
67 }