]>
Commit | Line | Data |
---|---|---|
e1f414b6 | 1 | /** @file\r |
2 | Common I/O Library routines.\r | |
3 | \r | |
4dd6f840 HT |
4 | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials\r | |
e1f414b6 | 6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
35a17154 | 8 | http://opensource.org/licenses/bsd-license.php.\r |
e1f414b6 | 9 | \r |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
e1f414b6 | 13 | **/\r |
14 | \r | |
f734a10a | 15 | #include "BaseIoLibIntrinsicInternal.h"\r |
e1f414b6 | 16 | \r |
17 | /**\r | |
18 | Reads a 64-bit I/O port.\r | |
19 | \r | |
20 | Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.\r | |
21 | This function must guarantee that all I/O read and write operations are\r | |
22 | serialized.\r | |
23 | \r | |
24 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
2281e7a9 | 25 | If Port is not aligned on a 64-bit boundary, then ASSERT().\r |
e1f414b6 | 26 | \r |
27 | @param Port The I/O port to read.\r | |
28 | \r | |
2281e7a9 | 29 | @return The value read.\r |
e1f414b6 | 30 | \r |
31 | **/\r | |
32 | UINT64\r | |
33 | EFIAPI\r | |
34 | IoRead64 (\r | |
35 | IN UINTN Port\r | |
36 | )\r | |
37 | {\r | |
38 | ASSERT (FALSE);\r | |
39 | return 0;\r | |
40 | }\r | |
41 | \r | |
42 | /**\r | |
43 | Writes a 64-bit I/O port.\r | |
44 | \r | |
45 | Writes the 64-bit I/O port specified by Port with the value specified by Value\r | |
46 | and returns Value. This function must guarantee that all I/O read and write\r | |
47 | operations are serialized.\r | |
48 | \r | |
49 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
2281e7a9 | 50 | If Port is not aligned on a 64-bit boundary, then ASSERT().\r |
e1f414b6 | 51 | \r |
52 | @param Port The I/O port to write.\r | |
53 | @param Value The value to write to the I/O port.\r | |
54 | \r | |
2281e7a9 | 55 | @return The value written the I/O port.\r |
e1f414b6 | 56 | \r |
57 | **/\r | |
58 | UINT64\r | |
59 | EFIAPI\r | |
60 | IoWrite64 (\r | |
61 | IN UINTN Port,\r | |
62 | IN UINT64 Value\r | |
63 | )\r | |
64 | {\r | |
65 | ASSERT (FALSE);\r | |
66 | return 0;\r | |
67 | }\r | |
68 | \r | |
9de780dc LG |
69 | \r |
70 | /**\r | |
71 | Reads an 8-bit MMIO register.\r | |
72 | \r | |
73 | Reads the 8-bit MMIO register specified by Address. The 8-bit read value is\r | |
74 | returned. This function must guarantee that all MMIO read and write\r | |
75 | operations are serialized.\r | |
76 | \r | |
77 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
78 | \r | |
79 | @param Address The MMIO register to read.\r | |
80 | \r | |
81 | @return The value read.\r | |
82 | \r | |
83 | **/\r | |
84 | UINT8\r | |
85 | EFIAPI\r | |
86 | MmioRead8 (\r | |
87 | IN UINTN Address\r | |
88 | )\r | |
89 | {\r | |
90 | UINT8 Value;\r | |
91 | \r | |
92 | MemoryFence ();\r | |
93 | Value = *(volatile UINT8*)Address;\r | |
94 | MemoryFence ();\r | |
95 | \r | |
96 | return Value;\r | |
97 | }\r | |
98 | \r | |
99 | /**\r | |
100 | Writes an 8-bit MMIO register.\r | |
101 | \r | |
102 | Writes the 8-bit MMIO register specified by Address with the value specified\r | |
103 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
104 | and write operations are serialized.\r | |
105 | \r | |
106 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
107 | \r | |
108 | @param Address The MMIO register to write.\r | |
109 | @param Value The value to write to the MMIO register.\r | |
110 | \r | |
111 | @return Value.\r | |
112 | \r | |
113 | **/\r | |
114 | UINT8\r | |
115 | EFIAPI\r | |
116 | MmioWrite8 (\r | |
117 | IN UINTN Address,\r | |
118 | IN UINT8 Value\r | |
119 | )\r | |
120 | {\r | |
121 | MemoryFence ();\r | |
122 | *(volatile UINT8*)Address = Value;\r | |
123 | MemoryFence ();\r | |
124 | \r | |
125 | return Value;\r | |
126 | }\r | |
127 | \r | |
128 | /**\r | |
129 | Reads a 16-bit MMIO register.\r | |
130 | \r | |
131 | Reads the 16-bit MMIO register specified by Address. The 16-bit read value is\r | |
132 | returned. This function must guarantee that all MMIO read and write\r | |
133 | operations are serialized.\r | |
134 | \r | |
135 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
136 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r | |
137 | \r | |
138 | @param Address The MMIO register to read.\r | |
139 | \r | |
140 | @return The value read.\r | |
141 | \r | |
142 | **/\r | |
143 | UINT16\r | |
144 | EFIAPI\r | |
145 | MmioRead16 (\r | |
146 | IN UINTN Address\r | |
147 | )\r | |
148 | {\r | |
149 | UINT16 Value;\r | |
150 | \r | |
151 | ASSERT ((Address & 1) == 0);\r | |
152 | \r | |
153 | MemoryFence ();\r | |
154 | Value = *(volatile UINT16*)Address;\r | |
155 | MemoryFence ();\r | |
156 | \r | |
157 | return Value;\r | |
158 | }\r | |
159 | \r | |
160 | /**\r | |
161 | Writes a 16-bit MMIO register.\r | |
162 | \r | |
163 | Writes the 16-bit MMIO register specified by Address with the value specified\r | |
164 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
165 | and write operations are serialized.\r | |
166 | \r | |
167 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
168 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r | |
169 | \r | |
170 | @param Address The MMIO register to write.\r | |
171 | @param Value The value to write to the MMIO register.\r | |
172 | \r | |
173 | @return Value.\r | |
174 | \r | |
175 | **/\r | |
176 | UINT16\r | |
177 | EFIAPI\r | |
178 | MmioWrite16 (\r | |
179 | IN UINTN Address,\r | |
180 | IN UINT16 Value\r | |
181 | )\r | |
182 | {\r | |
183 | ASSERT ((Address & 1) == 0);\r | |
184 | \r | |
185 | MemoryFence ();\r | |
186 | *(volatile UINT16*)Address = Value;\r | |
187 | MemoryFence ();\r | |
188 | \r | |
189 | return Value;\r | |
190 | }\r | |
191 | \r | |
192 | /**\r | |
193 | Reads a 32-bit MMIO register.\r | |
194 | \r | |
195 | Reads the 32-bit MMIO register specified by Address. The 32-bit read value is\r | |
196 | returned. This function must guarantee that all MMIO read and write\r | |
197 | operations are serialized.\r | |
198 | \r | |
199 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
200 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
201 | \r | |
202 | @param Address The MMIO register to read.\r | |
203 | \r | |
204 | @return The value read.\r | |
205 | \r | |
206 | **/\r | |
207 | UINT32\r | |
208 | EFIAPI\r | |
209 | MmioRead32 (\r | |
210 | IN UINTN Address\r | |
211 | )\r | |
212 | {\r | |
213 | UINT32 Value;\r | |
214 | \r | |
215 | ASSERT ((Address & 3) == 0);\r | |
216 | \r | |
217 | MemoryFence ();\r | |
218 | Value = *(volatile UINT32*)Address;\r | |
219 | MemoryFence ();\r | |
220 | \r | |
221 | return Value;\r | |
222 | }\r | |
223 | \r | |
224 | /**\r | |
225 | Writes a 32-bit MMIO register.\r | |
226 | \r | |
227 | Writes the 32-bit MMIO register specified by Address with the value specified\r | |
228 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
229 | and write operations are serialized.\r | |
230 | \r | |
231 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
232 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
233 | \r | |
234 | @param Address The MMIO register to write.\r | |
235 | @param Value The value to write to the MMIO register.\r | |
236 | \r | |
237 | @return Value.\r | |
238 | \r | |
239 | **/\r | |
240 | UINT32\r | |
241 | EFIAPI\r | |
242 | MmioWrite32 (\r | |
243 | IN UINTN Address,\r | |
244 | IN UINT32 Value\r | |
245 | )\r | |
246 | {\r | |
247 | ASSERT ((Address & 3) == 0);\r | |
248 | \r | |
249 | MemoryFence ();\r | |
250 | *(volatile UINT32*)Address = Value;\r | |
251 | MemoryFence ();\r | |
252 | \r | |
253 | return Value;\r | |
254 | }\r | |
255 | \r | |
256 | /**\r | |
257 | Reads a 64-bit MMIO register.\r | |
258 | \r | |
259 | Reads the 64-bit MMIO register specified by Address. The 64-bit read value is\r | |
260 | returned. This function must guarantee that all MMIO read and write\r | |
261 | operations are serialized.\r | |
262 | \r | |
263 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
264 | If Address is not aligned on a 64-bit boundary, then ASSERT().\r | |
265 | \r | |
266 | @param Address The MMIO register to read.\r | |
267 | \r | |
268 | @return The value read.\r | |
269 | \r | |
270 | **/\r | |
271 | UINT64\r | |
272 | EFIAPI\r | |
273 | MmioRead64 (\r | |
274 | IN UINTN Address\r | |
275 | )\r | |
276 | {\r | |
277 | UINT64 Value;\r | |
278 | \r | |
279 | ASSERT ((Address & 7) == 0);\r | |
280 | \r | |
281 | MemoryFence ();\r | |
282 | Value = *(volatile UINT64*)Address;\r | |
283 | MemoryFence ();\r | |
284 | \r | |
285 | return Value;\r | |
286 | }\r | |
287 | \r | |
288 | /**\r | |
289 | Writes a 64-bit MMIO register.\r | |
290 | \r | |
291 | Writes the 64-bit MMIO register specified by Address with the value specified\r | |
292 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
293 | and write operations are serialized.\r | |
294 | \r | |
295 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
296 | If Address is not aligned on a 64-bit boundary, then ASSERT().\r | |
297 | \r | |
298 | @param Address The MMIO register to write.\r | |
299 | @param Value The value to write to the MMIO register.\r | |
300 | \r | |
301 | **/\r | |
302 | UINT64\r | |
303 | EFIAPI\r | |
304 | MmioWrite64 (\r | |
305 | IN UINTN Address,\r | |
306 | IN UINT64 Value\r | |
307 | )\r | |
308 | {\r | |
309 | ASSERT ((Address & 7) == 0);\r | |
310 | \r | |
311 | MemoryFence ();\r | |
312 | *(volatile UINT64*)Address = Value;\r | |
313 | MemoryFence ();\r | |
314 | \r | |
315 | return Value;\r | |
316 | }\r | |
317 | \r |