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