coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
refcode.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <cbmem.h>
4 #include <console/console.h>
5 #include <console/streams.h>
6 #include <cpu/x86/tsc.h>
7 #include <program_loading.h>
8 #include <rmodule.h>
9 #include <stage_cache.h>
10 
11 #include <soc/ramstage.h>
12 #include <soc/efi_wrapper.h>
13 
14 static void ABI_X86 send_to_console(unsigned char b)
15 {
16  console_tx_byte(b);
17 }
18 
20 {
22  struct prog prog;
24  return prog_entry(&prog);
25  }
26 
27  struct prog prog =
28  PROG_INIT(PROG_REFCODE, CONFIG_CBFS_PREFIX "/refcode");
29  struct rmod_stage_load refcode = {
31  .prog = &prog,
32  };
33 
34  if (rmodule_stage_load(&refcode)) {
35  printk(BIOS_DEBUG, "Error loading reference code.\n");
36  return NULL;
37  }
38 
39  /* Cache loaded reference code. */
41 
42  return prog_entry(&prog);
43 }
44 
46 {
47  int ret;
48  efi_wrapper_entry_t entry;
49  struct efi_wrapper_params wrp = {
51  .console_out = send_to_console,
52  };
53 
54  entry = load_reference_code();
55 
56  if (entry == NULL)
57  return;
58 
60 
61  /* Call into reference code. */
62  ret = entry(&wrp);
63 
64  if (ret != 0) {
65  printk(BIOS_DEBUG, "Reference code returned %d\n", ret);
66  return;
67  }
68 }
static efi_wrapper_entry_t load_reference_code(void)
Definition: refcode.c:19
static void ABI_X86 send_to_console(unsigned char b)
Definition: refcode.c:14
void baytrail_run_reference_code(void)
Definition: refcode.c:45
#define CBMEM_ID_REFCODE
Definition: cbmem_id.h:47
#define printk(level,...)
Definition: stdlib.h:16
void console_tx_byte(unsigned char byte)
Definition: console.c:53
int ABI_X86(* efi_wrapper_entry_t)(struct efi_wrapper_params *)
Definition: efi_wrapper.h:25
#define ABI_X86
Definition: efi_wrapper.h:9
#define EFI_WRAPPER_VER
Definition: efi_wrapper.h:6
unsigned long tsc_freq_mhz(void)
Definition: fsb.c:118
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
static void * prog_entry(const struct prog *prog)
#define PROG_INIT(type_, name_)
@ PROG_REFCODE
int rmodule_stage_load(struct rmod_stage_load *rsl)
Definition: rmodule.c:249
@ STAGE_REFCODE
Definition: stage_cache.h:14
static void stage_cache_load_stage(int stage_id, struct prog *stage)
Definition: stage_cache.h:36
static int resume_from_stage_cache(void)
Definition: stage_cache.h:42
static void stage_cache_add(int stage_id, const struct prog *stage)
Definition: stage_cache.h:35
#define NULL
Definition: stddef.h:19
unsigned int tsc_ticks_per_microsecond
Definition: efi_wrapper.h:22
struct prog * prog
Definition: rmodule.h:44
uint32_t cbmem_id
Definition: rmodule.h:43