coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
car.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <arch/romstage.h>
4 #include <arch/symbols.h>
5 #include <cbfs.h>
6 #include <cbmem.h>
7 #include <console/console.h>
8 #include <commonlib/helpers.h>
9 #include <cpu/x86/mtrr.h>
10 #include <fsp/car.h>
11 #include <fsp/util.h>
12 
14 {
15  uintptr_t top_of_ram;
16 
17  /* Cache at least 8 MiB below the top of ram, and at most 8 MiB
18  * above top of the ram. This satisfies MTRR alignment requirement
19  * with different TSEG size configurations. */
20  top_of_ram = ALIGN_DOWN((uintptr_t)cbmem_top(), 8*MiB);
21  postcar_frame_add_mtrr(pcf, top_of_ram - 8*MiB, 16*MiB, MTRR_TYPE_WRBACK);
22 
23 }
24 
25 /* This is the romstage entry called from cpu/intel/car/romstage.c */
27 {
28  /* Need to locate the current FSP_INFO_HEADER. The cache-as-ram
29  * is still enabled. We can directly access work buffer here. */
30  void *fsp = cbfs_map("fsp.bin", NULL);
31 
32  if (!fsp)
33  die_with_post_code(POST_INVALID_CBFS, "Unable to locate fsp.bin");
34 
35  /* This leaks a mapping which this code assumes is benign as
36  * the flash is memory mapped CPU's address space. */
37  FSP_INFO_HEADER *fih = find_fsp((uintptr_t)fsp);
38 
39  if (!fih)
40  die("Invalid FSP header\n");
41 
43 }
void postcar_frame_add_mtrr(struct postcar_frame *pcf, uintptr_t addr, size_t size, int type)
#define ALIGN_DOWN(x, a)
Definition: helpers.h:18
#define MiB
Definition: helpers.h:76
static void * cbfs_map(const char *name, size_t *size_out)
Definition: cbfs.h:246
void * cbmem_top(void)
Definition: imd_cbmem.c:18
void __noreturn die(const char *fmt,...)
Definition: die.c:17
#define die_with_post_code(value, fmt,...)
Definition: console.h:21
void mainboard_romstage_entry(void)
Definition: car.c:26
void fill_postcar_frame(struct postcar_frame *pcf)
Definition: car.c:13
void cache_as_ram_stage_main(FSP_INFO_HEADER *fih)
Definition: romstage.c:95
FSP_INFO_HEADER * find_fsp(uintptr_t fsp_base_address)
Definition: fsp_util.c:12
#define POST_INVALID_CBFS
Invalid or corrupt CBFS.
Definition: post_codes.h:330
#define NULL
Definition: stddef.h:19
unsigned long uintptr_t
Definition: stdint.h:21
#define MTRR_TYPE_WRBACK
Definition: mtrr.h:14