8376b2ad40a68b9952716f3e3afff99512634522
[oweals/u-boot.git] / arch / x86 / include / asm / fsp1 / fsp_support.h
1 /* SPDX-License-Identifier: Intel */
2 /*
3  * Copyright (C) 2013, Intel Corporation
4  * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
5  */
6
7 #ifndef __FSP_SUPPORT_H__
8 #define __FSP_SUPPORT_H__
9
10 #include <asm/fsp/fsp_fv.h>
11 #include <asm/fsp/fsp_types.h>
12 #include "fsp_hob.h"
13 #include "fsp_ffs.h"
14 #include "fsp_infoheader.h"
15 #include "fsp_bootmode.h"
16 #include <asm/fsp_arch.h>
17 #include <asm/fsp/fsp_azalia.h>
18
19 #define FSP_LOWMEM_BASE         0x100000UL
20 #define FSP_HIGHMEM_BASE        0x100000000ULL
21 #define UPD_TERMINATOR          0x55AA
22
23 /**
24  * FSP Continuation assembly helper routine
25  *
26  * This routine jumps to the C version of FSP continuation function
27  */
28 void asm_continuation(void);
29
30 /**
31  * FSP initialization complete
32  *
33  * This is the function that indicates FSP initialization is complete and jumps
34  * back to the bootloader with HOB list pointer as the parameter.
35  *
36  * @hob_list:    HOB list pointer
37  */
38 void fsp_init_done(void *hob_list);
39
40 /**
41  * FSP Continuation function
42  *
43  * @status:      Always 0
44  * @hob_list:    HOB list pointer
45  *
46  * @retval:      Never returns
47  */
48 void fsp_continue(u32 status, void *hob_list);
49
50 /**
51  * Find FSP header offset in FSP image
52  *
53  * @retval: the offset of FSP header. If signature is invalid, returns 0.
54  */
55 struct fsp_header *find_fsp_header(void);
56
57 /**
58  * FSP initialization wrapper function.
59  *
60  * @stack_top: bootloader stack top address
61  * @boot_mode: boot mode defined in fsp_bootmode.h
62  * @nvs_buf:   Non-volatile memory buffer pointer
63  */
64 void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf);
65
66 /**
67  * FSP notification wrapper function
68  *
69  * @fsp_hdr: Pointer to FSP information header
70  * @phase:   FSP initialization phase defined in enum fsp_phase
71  *
72  * @retval:  compatible status code with EFI_STATUS defined in PI spec
73  */
74 u32 fsp_notify(struct fsp_header *fsp_hdr, u32 phase);
75
76 /**
77  * This function retrieves the top of usable low memory.
78  *
79  * @hob_list: A HOB list pointer.
80  *
81  * @retval:   Usable low memory top.
82  */
83 u32 fsp_get_usable_lowmem_top(const void *hob_list);
84
85 /**
86  * This function retrieves the top of usable high memory.
87  *
88  * @hob_list: A HOB list pointer.
89  *
90  * @retval:   Usable high memory top.
91  */
92 u64 fsp_get_usable_highmem_top(const void *hob_list);
93
94 /**
95  * This function retrieves a special reserved memory region.
96  *
97  * @hob_list: A HOB list pointer.
98  * @len:      A pointer to the GUID HOB data buffer length.
99  *            If the GUID HOB is located, the length will be updated.
100  * @guid:     A pointer to the owner guild.
101  *
102  * @retval:   Reserved region start address.
103  *            0 if this region does not exist.
104  */
105 u64 fsp_get_reserved_mem_from_guid(const void *hob_list,
106                                    u64 *len, const efi_guid_t *guid);
107
108 /**
109  * This function retrieves the FSP reserved normal memory.
110  *
111  * @hob_list: A HOB list pointer.
112  * @len:      A pointer to the FSP reserved memory length buffer.
113  *            If the GUID HOB is located, the length will be updated.
114  * @retval:   FSP reserved memory base
115  *            0 if this region does not exist.
116  */
117 u32 fsp_get_fsp_reserved_mem(const void *hob_list, u32 *len);
118
119 /**
120  * This function retrieves the TSEG reserved normal memory.
121  *
122  * @hob_list:      A HOB list pointer.
123  * @len:           A pointer to the TSEG reserved memory length buffer.
124  *                 If the GUID HOB is located, the length will be updated.
125  *
126  * @retval NULL:   Failed to find the TSEG reserved memory.
127  * @retval others: TSEG reserved memory base.
128  */
129 u32 fsp_get_tseg_reserved_mem(const void *hob_list, u32 *len);
130
131 /**
132  * This function retrieves FSP Non-volatile Storage HOB buffer and size.
133  *
134  * @hob_list:      A HOB list pointer.
135  * @len:           A pointer to the NVS data buffer length.
136  *                 If the HOB is located, the length will be updated.
137  *
138  * @retval NULL:   Failed to find the NVS HOB.
139  * @retval others: FSP NVS data buffer pointer.
140  */
141 void *fsp_get_nvs_data(const void *hob_list, u32 *len);
142
143 /**
144  * This function retrieves Bootloader temporary stack buffer and size.
145  *
146  * @hob_list:      A HOB list pointer.
147  * @len:           A pointer to the bootloader temporary stack length.
148  *                 If the HOB is located, the length will be updated.
149  *
150  * @retval NULL:   Failed to find the bootloader temporary stack HOB.
151  * @retval others: Bootloader temporary stackbuffer pointer.
152  */
153 void *fsp_get_bootloader_tmp_mem(const void *hob_list, u32 *len);
154
155 /**
156  * This function retrieves graphics information.
157  *
158  * @hob_list:      A HOB list pointer.
159  * @len:           A pointer to the graphics info HOB length.
160  *                 If the HOB is located, the length will be updated.
161  *
162  * @retval NULL:   Failed to find the graphics info HOB.
163  * @retval others: A pointer to struct hob_graphics_info.
164  */
165 void *fsp_get_graphics_info(const void *hob_list, u32 *len);
166
167 /**
168  * This function overrides the default configurations of FSP.
169  *
170  * @config:  A pointer to the FSP configuration data structure
171  * @rt_buf:  A pointer to the FSP runtime buffer data structure
172  *
173  * @return:  None
174  */
175 void update_fsp_configs(struct fsp_config_data *config,
176                         struct fspinit_rtbuf *rt_buf);
177
178 /**
179  * fsp_init_phase_pci() - Tell the FSP that we have completed PCI init
180  *
181  * @return 0 if OK, -EPERM if the FSP gave an error.
182  */
183 int fsp_init_phase_pci(void);
184
185 #endif