]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - CpuIo.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / CpuIo.h
... / ...
CommitLineData
1/*++\r
2\r
3Copyright (c) 2004, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13 CpuIo.h\r
14\r
15Abstract:\r
16 *.h file for the driver\r
17\r
18 Note: the EFIAPI on the CpuIo functions is used to glue MASM (assembler) code\r
19 into C code. By making the MASM functions EFIAPI it ensures that a standard\r
20 C calling convention is assumed by the compiler, reguardless of the compiler\r
21 flags.\r
22\r
23\r
24--*/\r
25\r
26#ifndef _CPU_IO_H\r
27#define _CPU_IO_H\r
28\r
29#include <PiDxe.h>\r
30\r
31#include <Protocol/CpuIo.h>\r
32\r
33#include <Library/BaseLib.h>\r
34#include <Library/DebugLib.h>\r
35#include <Library/IoLib.h>\r
36\r
37typedef union {\r
38 UINT8 volatile *buf;\r
39 UINT8 volatile *ui8;\r
40 UINT16 volatile *ui16;\r
41 UINT32 volatile *ui32;\r
42 UINT64 volatile *ui64;\r
43 UINTN volatile ui;\r
44} PTR;\r
45\r
46EFI_STATUS\r
47EFIAPI\r
48CpuIoInitialize (\r
49 IN EFI_HANDLE ImageHandle,\r
50 IN EFI_SYSTEM_TABLE *SystemTable\r
51 )\r
52/*++\r
53\r
54Routine Description:\r
55\r
56 CpuIo driver entry point.\r
57\r
58Arguments:\r
59\r
60 ImageHandle - The firmware allocated handle for the EFI image.\r
61 SystemTable - A pointer to the EFI System Table.\r
62\r
63Returns:\r
64\r
65 EFI_SUCCESS - The driver was initialized.\r
66 EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of resources.\r
67\r
68--*/\r
69;\r
70\r
71EFI_STATUS\r
72EFIAPI\r
73CpuMemoryServiceRead (\r
74 IN EFI_CPU_IO_PROTOCOL *This,\r
75 IN EFI_CPU_IO_PROTOCOL_WIDTH Width,\r
76 IN UINT64 Address,\r
77 IN UINTN Count,\r
78 OUT VOID *Buffer\r
79 )\r
80/*++\r
81\r
82Routine Description:\r
83\r
84 Perform the memory mapped I/O read service\r
85\r
86Arguments:\r
87\r
88 This - Pointer to an instance of the CPU I/O Protocol\r
89 Width - Width of the memory mapped I/O operation\r
90 Address - Base address of the memory mapped I/O operation\r
91 Count - Count of the number of accesses to perform\r
92 Buffer - Pointer to the destination buffer to store the results\r
93\r
94Returns:\r
95\r
96 EFI_SUCCESS - The data was read.\r
97 EFI_INVALID_PARAMETER - Width is invalid.\r
98 EFI_INVALID_PARAMETER - Buffer is NULL.\r
99 EFI_UNSUPPORTED - The Buffer is not aligned for the given Width.\r
100 EFI_UNSUPPORTED - The address range specified by Address, Width,\r
101 and Count is not valid.\r
102\r
103--*/\r
104;\r
105\r
106EFI_STATUS\r
107EFIAPI\r
108CpuMemoryServiceWrite (\r
109 IN EFI_CPU_IO_PROTOCOL *This,\r
110 IN EFI_CPU_IO_PROTOCOL_WIDTH Width,\r
111 IN UINT64 Address,\r
112 IN UINTN Count,\r
113 IN VOID *Buffer\r
114 )\r
115/*++\r
116\r
117Routine Description:\r
118\r
119 Perform the memory mapped I/O write service\r
120\r
121Arguments:\r
122\r
123 This - Pointer to an instance of the CPU I/O Protocol\r
124 Width - Width of the memory mapped I/O operation\r
125 Address - Base address of the memory mapped I/O operation\r
126 Count - Count of the number of accesses to perform\r
127 Buffer - Pointer to the source buffer from which to write data\r
128\r
129Returns:\r
130\r
131 EFI_SUCCESS - The data was written.\r
132 EFI_INVALID_PARAMETER - Width is invalid.\r
133 EFI_INVALID_PARAMETER - Buffer is NULL.\r
134 EFI_UNSUPPORTED - The Buffer is not aligned for the given Width.\r
135 EFI_UNSUPPORTED - The address range specified by Address, Width,\r
136 and Count is not valid.\r
137\r
138--*/\r
139;\r
140\r
141EFI_STATUS\r
142EFIAPI\r
143CpuIoServiceRead (\r
144 IN EFI_CPU_IO_PROTOCOL *This,\r
145 IN EFI_CPU_IO_PROTOCOL_WIDTH Width,\r
146 IN UINT64 UserAddress,\r
147 IN UINTN Count,\r
148 OUT VOID *UserBuffer\r
149 )\r
150/*++\r
151\r
152Routine Description:\r
153\r
154 Perform the port I/O read service\r
155\r
156Arguments:\r
157\r
158 This - Pointer to an instance of the CPU I/O Protocol\r
159 Width - Width of the port I/O operation\r
160 Address - Base address of the port I/O operation\r
161 Count - Count of the number of accesses to perform\r
162 Buffer - Pointer to the destination buffer to store the results\r
163\r
164Returns:\r
165\r
166 EFI_SUCCESS - The data was read.\r
167 EFI_INVALID_PARAMETER - Width is invalid.\r
168 EFI_INVALID_PARAMETER - Buffer is NULL.\r
169 EFI_UNSUPPORTED - The Buffer is not aligned for the given Width.\r
170 EFI_UNSUPPORTED - The address range specified by Address, Width,\r
171 and Count is not valid.\r
172\r
173--*/\r
174;\r
175\r
176EFI_STATUS\r
177EFIAPI\r
178CpuIoServiceWrite (\r
179 IN EFI_CPU_IO_PROTOCOL *This,\r
180 IN EFI_CPU_IO_PROTOCOL_WIDTH Width,\r
181 IN UINT64 UserAddress,\r
182 IN UINTN Count,\r
183 IN VOID *UserBuffer\r
184 )\r
185/*++\r
186\r
187Routine Description:\r
188\r
189 Perform the port I/O write service\r
190\r
191Arguments:\r
192\r
193 This - Pointer to an instance of the CPU I/O Protocol\r
194 Width - Width of the port I/O operation\r
195 Address - Base address of the port I/O operation\r
196 Count - Count of the number of accesses to perform\r
197 Buffer - Pointer to the source buffer from which to write data\r
198\r
199Returns:\r
200\r
201 EFI_SUCCESS - The data was written.\r
202 EFI_INVALID_PARAMETER - Width is invalid.\r
203 EFI_INVALID_PARAMETER - Buffer is NULL.\r
204 EFI_UNSUPPORTED - The Buffer is not aligned for the given Width.\r
205 EFI_UNSUPPORTED - The address range specified by Address, Width,\r
206 and Count is not valid.\r
207\r
208--*/\r
209;\r
210\r
211EFI_STATUS\r
212CpuIoCheckParameter (\r
213 IN EFI_CPU_IO_PROTOCOL_WIDTH Width,\r
214 IN UINT64 Address,\r
215 IN UINTN Count,\r
216 IN VOID *Buffer,\r
217 IN UINT64 Limit\r
218 )\r
219/*++\r
220\r
221Routine Description:\r
222\r
223 Check the validation of parameters for CPU I/O interface functions.\r
224\r
225Arguments:\r
226\r
227 Width - Width of the Memory Access\r
228 Address - Address of the Memory access\r
229 Count - Count of the number of accesses to perform\r
230 Buffer - Pointer to the buffer to read from memory\r
231 Buffer - Memory buffer for the I/O operation\r
232 Limit - Maximum address supported\r
233\r
234Returns:\r
235\r
236 EFI_INVALID_PARAMETER - Buffer is NULL\r
237 EFI_UNSUPPORTED - The address range specified by Width, Address and Count is invalid\r
238 EFI_UNSUPPORTED - The memory buffer is not aligned\r
239 EFI_SUCCESS - Parameters are OK\r
240\r
241--*/\r
242;\r
243\r
244#endif\r