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