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