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