blob: 93625fce12439e95c42a769e98491061ed3bd4e3 [file] [log] [blame]
Kyösti Mälkki967d94d2016-11-22 11:52:14 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2016 Kyösti Mälkki
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef _STATE_MACHINE_H_
17#define _STATE_MACHINE_H_
18
19#include <stdint.h>
Kyösti Mälkkiacc599b2016-11-24 14:31:07 +020020#include <AGESA.h>
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020021#include <AMD.h>
22
Julius Wernercd49cce2019-03-05 16:53:33 -080023#define HAS_LEGACY_WRAPPER CONFIG(BINARYPI_LEGACY_WRAPPER)
Kyösti Mälkkiacc599b2016-11-24 14:31:07 +020024
25/* eventlog */
26const char *agesa_struct_name(int state);
27const char *heap_status_name(int status);
28void agesawrapper_trace(AGESA_STATUS ret, AMD_CONFIG_PARAMS *StdHeader, const char *func);
Kyösti Mälkki0a7cab82017-07-29 08:11:52 +030029AGESA_STATUS agesawrapper_amdreadeventlog(UINT8 HeapStatus);
Kyösti Mälkki967d94d2016-11-22 11:52:14 +020030
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020031/* For suspend-to-ram support. */
32
Julius Wernercd49cce2019-03-05 16:53:33 -080033#if !CONFIG(CPU_AMD_PI)
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020034/* TODO: With binaryPI we need different interface. */
35AGESA_STATUS OemInitResume(AMD_S3_PARAMS *dataBlock);
36AGESA_STATUS OemS3LateRestore(AMD_S3_PARAMS *dataBlock);
37AGESA_STATUS OemS3Save(AMD_S3_PARAMS *dataBlock);
38#endif
39
Kyösti Mälkki38aff1a2017-07-26 00:57:30 +030040/* For FCH */
41AGESA_STATUS fchs3earlyrestore(AMD_CONFIG_PARAMS *StdHeader);
42AGESA_STATUS fchs3laterestore(AMD_CONFIG_PARAMS *StdHeader);
43
Kyösti Mälkki967d94d2016-11-22 11:52:14 +020044struct sysinfo
45{
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020046 AMD_CONFIG_PARAMS StdHeader;
47
Kyösti Mälkki967d94d2016-11-22 11:52:14 +020048 int s3resume;
49};
50
Kyösti Mälkkidf7ff312016-11-25 12:02:00 +020051void agesa_main(struct sysinfo *cb);
Kyösti Mälkkiba22e152016-11-23 06:47:15 +020052void agesa_postcar(struct sysinfo *cb);
53
54void board_BeforeAgesa(struct sysinfo *cb);
55void platform_once(struct sysinfo *cb);
Kyösti Mälkkidf7ff312016-11-25 12:02:00 +020056
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020057void agesa_set_interface(struct sysinfo *cb);
58int agesa_execute_state(struct sysinfo *cb, AGESA_STRUCT_NAME func);
59
60/* AGESA dispatchers */
61
62AGESA_STATUS module_dispatch(AGESA_STRUCT_NAME func, AMD_CONFIG_PARAMS *StdHeader);
63
64void platform_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset);
65void board_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset);
66
67void platform_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early);
68void board_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early);
69
70/* Normal boot */
71void platform_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post);
72void board_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post);
73void platform_AfterInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post);
74
75void platform_BeforeInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env);
76void board_BeforeInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env);
77void platform_AfterInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env);
78
79void platform_BeforeInitMid(struct sysinfo *cb, AMD_MID_PARAMS *Mid);
80void board_BeforeInitMid(struct sysinfo *cb, AMD_MID_PARAMS *Mid);
81
82void platform_AfterInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late);
83void completion_InitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late);
84
85/* S3 Resume */
86void platform_BeforeInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume);
87void platform_AfterInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume);
88
89void platform_BeforeS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late);
90void platform_AfterS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late);
91
Julius Wernercd49cce2019-03-05 16:53:33 -080092#if CONFIG(CPU_AMD_PI_00660F01)
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020093typedef void AMD_S3SAVE_PARAMS;
94#endif
95void platform_AfterS3Save(struct sysinfo *cb, AMD_S3SAVE_PARAMS *S3Save);
96
Kyösti Mälkkibf201d52017-03-30 17:26:25 +030097/* FCH callouts, not used with CIMx. */
98#define HAS_AGESA_FCH_OEM_CALLOUT \
Julius Wernercd49cce2019-03-05 16:53:33 -080099 CONFIG(SOUTHBRIDGE_AMD_AGESA_HUDSON) || \
100 CONFIG(SOUTHBRIDGE_AMD_AGESA_YANGTZE) || \
101 CONFIG(SOUTHBRIDGE_AMD_PI_AVALON) || \
102 CONFIG(SOUTHBRIDGE_AMD_PI_BOLTON) || \
103 CONFIG(SOUTHBRIDGE_AMD_PI_KERN)
Kyösti Mälkkibf201d52017-03-30 17:26:25 +0300104
105#if HAS_AGESA_FCH_OEM_CALLOUT
106/* FIXME: Structures included here were supposed to be private to AGESA. */
107#include <FchCommonCfg.h>
108void agesa_fch_oem_config(uintptr_t Data, AMD_CONFIG_PARAMS *StdHeader);
109void board_FCH_InitReset(struct sysinfo *cb, FCH_RESET_DATA_BLOCK *FchReset);
110void board_FCH_InitEnv(struct sysinfo *cb, FCH_DATA_BLOCK *FchEnv);
111#endif
112
Kyösti Mälkki967d94d2016-11-22 11:52:14 +0200113#endif /* _STATE_MACHINE_H_ */