blob: f2551de5d985c5814880a40674802b3fb7f55673 [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
23#define HAS_LEGACY_WRAPPER (IS_ENABLED(CONFIG_AGESA_LEGACY_WRAPPER) || \
Kyösti Mälkki903ce252016-11-25 11:21:02 +020024 IS_ENABLED(CONFIG_BINARYPI_LEGACY_WRAPPER))
Kyösti Mälkkiacc599b2016-11-24 14:31:07 +020025
26/* eventlog */
27const char *agesa_struct_name(int state);
28const char *heap_status_name(int status);
29void agesawrapper_trace(AGESA_STATUS ret, AMD_CONFIG_PARAMS *StdHeader, const char *func);
Kyösti Mälkki0a7cab82017-07-29 08:11:52 +030030AGESA_STATUS agesawrapper_amdreadeventlog(UINT8 HeapStatus);
Kyösti Mälkki967d94d2016-11-22 11:52:14 +020031
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020032/* For suspend-to-ram support. */
33
34#if !IS_ENABLED(CONFIG_CPU_AMD_PI)
35/* TODO: With binaryPI we need different interface. */
36AGESA_STATUS OemInitResume(AMD_S3_PARAMS *dataBlock);
37AGESA_STATUS OemS3LateRestore(AMD_S3_PARAMS *dataBlock);
38AGESA_STATUS OemS3Save(AMD_S3_PARAMS *dataBlock);
39#endif
40
Kyösti Mälkki38aff1a2017-07-26 00:57:30 +030041/* For FCH */
42AGESA_STATUS fchs3earlyrestore(AMD_CONFIG_PARAMS *StdHeader);
43AGESA_STATUS fchs3laterestore(AMD_CONFIG_PARAMS *StdHeader);
44
Kyösti Mälkki967d94d2016-11-22 11:52:14 +020045struct sysinfo
46{
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020047 AMD_CONFIG_PARAMS StdHeader;
48
Kyösti Mälkki967d94d2016-11-22 11:52:14 +020049 int s3resume;
50};
51
Kyösti Mälkkidf7ff312016-11-25 12:02:00 +020052void agesa_main(struct sysinfo *cb);
Kyösti Mälkkiba22e152016-11-23 06:47:15 +020053void agesa_postcar(struct sysinfo *cb);
54
55void board_BeforeAgesa(struct sysinfo *cb);
56void platform_once(struct sysinfo *cb);
Kyösti Mälkkidf7ff312016-11-25 12:02:00 +020057
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020058void agesa_set_interface(struct sysinfo *cb);
59int agesa_execute_state(struct sysinfo *cb, AGESA_STRUCT_NAME func);
60
61/* AGESA dispatchers */
62
63AGESA_STATUS module_dispatch(AGESA_STRUCT_NAME func, AMD_CONFIG_PARAMS *StdHeader);
64
65void platform_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset);
66void board_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset);
67
68void platform_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early);
69void board_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early);
70
71/* Normal boot */
72void platform_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post);
73void board_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post);
74void platform_AfterInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post);
75
76void platform_BeforeInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env);
77void board_BeforeInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env);
78void platform_AfterInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env);
79
80void platform_BeforeInitMid(struct sysinfo *cb, AMD_MID_PARAMS *Mid);
81void board_BeforeInitMid(struct sysinfo *cb, AMD_MID_PARAMS *Mid);
82
83void platform_AfterInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late);
84void completion_InitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late);
85
86/* S3 Resume */
87void platform_BeforeInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume);
88void platform_AfterInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume);
89
90void platform_BeforeS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late);
91void platform_AfterS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late);
92
93#if IS_ENABLED(CONFIG_CPU_AMD_PI_00660F01)
94typedef void AMD_S3SAVE_PARAMS;
95#endif
96void platform_AfterS3Save(struct sysinfo *cb, AMD_S3SAVE_PARAMS *S3Save);
97
Kyösti Mälkkibf201d52017-03-30 17:26:25 +030098/* FCH callouts, not used with CIMx. */
99#define HAS_AGESA_FCH_OEM_CALLOUT \
100 IS_ENABLED(CONFIG_SOUTHBRIDGE_AMD_AGESA_HUDSON) || \
101 IS_ENABLED(CONFIG_SOUTHBRIDGE_AMD_AGESA_YANGTZE) || \
Kyösti Mälkki903ce252016-11-25 11:21:02 +0200102 IS_ENABLED(CONFIG_SOUTHBRIDGE_AMD_AGESA_BOLTON) || \
103 IS_ENABLED(CONFIG_SOUTHBRIDGE_AMD_PI_AVALON) || \
104 IS_ENABLED(CONFIG_SOUTHBRIDGE_AMD_PI_BOLTON) || \
105 IS_ENABLED(CONFIG_SOUTHBRIDGE_AMD_PI_KERN)
Kyösti Mälkkibf201d52017-03-30 17:26:25 +0300106
107#if HAS_AGESA_FCH_OEM_CALLOUT
108/* FIXME: Structures included here were supposed to be private to AGESA. */
109#include <FchCommonCfg.h>
110void agesa_fch_oem_config(uintptr_t Data, AMD_CONFIG_PARAMS *StdHeader);
111void board_FCH_InitReset(struct sysinfo *cb, FCH_RESET_DATA_BLOCK *FchReset);
112void board_FCH_InitEnv(struct sysinfo *cb, FCH_DATA_BLOCK *FchEnv);
113#endif
114
Kyösti Mälkki967d94d2016-11-22 11:52:14 +0200115#endif /* _STATE_MACHINE_H_ */