coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
state_machine.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <amdblocks/biosram.h>
4 
5 #include "Porting.h"
6 #include "AGESA.h"
7 
8 #include <device/device.h>
12 
13 void platform_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset)
14 {
15 }
16 
17 void platform_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early)
18 {
19  Early->GnbConfig.PsppPolicy = PsppDisabled;
20 }
21 
22 void platform_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post)
23 {
24  Post->MemConfig.UmaMode = CONFIG(GFXUMA) ? UMA_AUTO : UMA_NONE;
25  Post->MemConfig.UmaSize = 0;
26  Post->MemConfig.BottomIo = (UINT16)(CONFIG_BOTTOMIO_POSITION >> 24);
27 }
28 
29 void platform_AfterInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post)
30 {
31  /* If UMA is enabled we currently have it below TOP_MEM as well.
32  * UMA may or may not be cacheable, so Sub4GCacheTop could be
33  * higher than UmaBase. With UMA_NONE we see UmaBase==0. */
34  if (Post->MemConfig.UmaBase)
35  backup_top_of_low_cacheable(Post->MemConfig.UmaBase << 16);
36  else
37  backup_top_of_low_cacheable(Post->MemConfig.Sub4GCacheTop);
38 }
39 
40 void platform_BeforeInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env)
41 {
42  EmptyHeap();
43 }
44 
45 void platform_AfterInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env)
46 {
47 }
48 
49 void platform_BeforeInitMid(struct sysinfo *cb, AMD_MID_PARAMS *Mid)
50 {
51  amd_initcpuio();
52 
53  /* 0 iGpuVgaAdapter, 1 iGpuVgaNonAdapter; */
54  Mid->GnbMidConfiguration.iGpuVgaMode = 0;
55  Mid->GnbMidConfiguration.GnbIoapicAddress = IO_APIC2_ADDR;
56 }
57 
58 void platform_BeforeInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late)
59 {
60  const struct device *iommu_dev = pcidev_on_root(0, 2);
61 
62  if (iommu_dev && iommu_dev->enabled) {
63  /* According to AGESA headers these must be set to sane values
64  * when IOMMU build config is enabled otherwise AGESA will skip
65  * it during IOMMU init and IVRS generation.
66  */
67  Late->GnbLateConfiguration.GnbIoapicId = CONFIG_MAX_CPUS + 1;
68  Late->GnbLateConfiguration.FchIoapicId = CONFIG_MAX_CPUS;
69  }
70 
71  /* Code for creating CDIT requires hop count table. If it is not
72  * present AGESA_ERROR is returned, which confuses users. CDIT is not
73  * written to the ACPI tables anyway. */
74  Late->PlatformConfig.UserOptionCdit = 0;
75 }
76 
77 void platform_AfterInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late)
78 {
79 }
80 
81 void platform_BeforeInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume)
82 {
83 }
84 
85 void platform_AfterInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume)
86 {
87 }
88 
89 void platform_BeforeS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late)
90 {
91 }
92 
93 void platform_AfterS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late)
94 {
95  amd_initcpuio();
96 }
97 
98 void platform_AfterS3Save(struct sysinfo *cb, AMD_S3SAVE_PARAMS *S3Save)
99 {
100 }
void amd_initcpuio(void)
Definition: fixme.c:11
void backup_top_of_low_cacheable(uintptr_t ramtop)
Definition: biosram.c:61
DEVTREE_CONST struct device * pcidev_on_root(uint8_t dev, uint8_t fn)
Definition: device_const.c:260
void EmptyHeap(void)
Definition: heapmanager.c:36
@ CONFIG
Definition: dsi_common.h:201
#define IO_APIC2_ADDR
Definition: nb_common.h:10
void platform_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset)
Definition: state_machine.c:17
void platform_AfterInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late)
Definition: state_machine.c:99
void platform_BeforeS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late)
Definition: state_machine.c:78
void platform_BeforeInitMid(struct sysinfo *cb, AMD_MID_PARAMS *Mid)
Definition: state_machine.c:87
void platform_AfterS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late)
Definition: state_machine.c:83
void platform_BeforeInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env)
Definition: state_machine.c:68
void platform_BeforeInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late)
Definition: state_machine.c:95
void platform_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post)
Definition: state_machine.c:48
void platform_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early)
Definition: state_machine.c:44
void platform_AfterInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post)
Definition: state_machine.c:54
void platform_BeforeInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume)
Definition: state_machine.c:59
void platform_AfterInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env)
Definition: state_machine.c:73
void platform_AfterInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume)
Definition: state_machine.c:64
void platform_AfterS3Save(struct sysinfo *cb, AMD_S3SAVE_PARAMS *S3Save)
Definition: device.h:107
unsigned int enabled
Definition: device.h:122