]>
Commit | Line | Data |
---|---|---|
11f43dfd | 1 | /** @file\r |
4ca0802e | 2 | I/O Library. The implementations are based on EFI_PEI_SERVICE->CpuIo interface.\r |
11f43dfd | 3 | \r |
5240b97c | 4 | Copyright (c) 2006 - 2008, Intel Corporation<BR>\r |
11f43dfd | 5 | All rights reserved. This program and the accompanying materials\r |
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 | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
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 | |
11f43dfd | 13 | **/\r |
14 | \r | |
c892d846 | 15 | \r |
11f43dfd | 16 | #include <PiPei.h>\r |
c892d846 | 17 | \r |
11f43dfd | 18 | #include <Library/IoLib.h>\r |
19 | #include <Library/DebugLib.h>\r | |
20 | #include <Library/BaseLib.h>\r | |
21 | #include <Library/PeiServicesTablePointerLib.h>\r | |
22 | \r | |
23 | /**\r | |
24 | Reads an 8-bit I/O port.\r | |
25 | \r | |
26 | Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.\r | |
27 | This function must guarantee that all I/O read and write operations are\r | |
28 | serialized.\r | |
29 | \r | |
30 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
31 | \r | |
32 | @param Port The I/O port to read.\r | |
33 | \r | |
f80b0830 | 34 | @return The value read from Port.\r |
11f43dfd | 35 | \r |
36 | **/\r | |
37 | UINT8\r | |
38 | EFIAPI\r | |
39 | IoRead8 (\r | |
40 | IN UINTN Port\r | |
41 | )\r | |
42 | {\r | |
fe7fd578 | 43 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 44 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
45 | \r | |
5240b97c | 46 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 47 | CpuIo = (*PeiServices)->CpuIo;\r |
48 | ASSERT (CpuIo != NULL);\r | |
49 | \r | |
50 | return CpuIo->IoRead8 (PeiServices, CpuIo, (UINT64) Port);\r | |
51 | }\r | |
52 | \r | |
53 | /**\r | |
54 | Writes an 8-bit I/O port.\r | |
55 | \r | |
56 | Writes the 8-bit I/O port specified by Port with the value specified by Value\r | |
57 | and returns Value. This function must guarantee that all I/O read and write\r | |
58 | operations are serialized.\r | |
59 | \r | |
60 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
61 | \r | |
62 | @param Port The I/O port to write.\r | |
63 | @param Value The value to write to the I/O port.\r | |
64 | \r | |
65 | @return The value written the I/O port.\r | |
66 | \r | |
67 | **/\r | |
68 | UINT8\r | |
69 | EFIAPI\r | |
70 | IoWrite8 (\r | |
71 | IN UINTN Port,\r | |
72 | IN UINT8 Value\r | |
73 | )\r | |
74 | {\r | |
fe7fd578 | 75 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 76 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
77 | \r | |
5240b97c | 78 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 79 | CpuIo = (*PeiServices)->CpuIo;\r |
80 | ASSERT (CpuIo != NULL);\r | |
81 | \r | |
82 | CpuIo->IoWrite8 (PeiServices, CpuIo, (UINT64) Port, Value);\r | |
83 | return Value;\r | |
84 | }\r | |
85 | \r | |
86 | /**\r | |
87 | Reads a 16-bit I/O port.\r | |
88 | \r | |
89 | Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.\r | |
90 | This function must guarantee that all I/O read and write operations are\r | |
91 | serialized.\r | |
92 | \r | |
93 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
94 | \r | |
95 | @param Port The I/O port to read.\r | |
96 | \r | |
f80b0830 | 97 | @return The value read from Port.\r |
11f43dfd | 98 | \r |
99 | **/\r | |
100 | UINT16\r | |
101 | EFIAPI\r | |
102 | IoRead16 (\r | |
103 | IN UINTN Port\r | |
104 | )\r | |
105 | {\r | |
fe7fd578 | 106 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 107 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
108 | \r | |
5240b97c | 109 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 110 | CpuIo = (*PeiServices)->CpuIo;\r |
111 | ASSERT (CpuIo != NULL);\r | |
112 | //\r | |
113 | // Make sure Port is aligned on a 16-bit boundary.\r | |
114 | //\r | |
115 | ASSERT ((Port & 1) == 0);\r | |
116 | return CpuIo->IoRead16 (PeiServices, CpuIo, (UINT64) Port);\r | |
117 | }\r | |
118 | \r | |
119 | /**\r | |
120 | Writes a 16-bit I/O port.\r | |
121 | \r | |
122 | Writes the 16-bit I/O port specified by Port with the value specified by Value\r | |
123 | and returns Value. This function must guarantee that all I/O read and write\r | |
124 | operations are serialized.\r | |
125 | \r | |
126 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
127 | \r | |
128 | @param Port The I/O port to write.\r | |
129 | @param Value The value to write to the I/O port.\r | |
130 | \r | |
131 | @return The value written the I/O port.\r | |
132 | \r | |
133 | **/\r | |
134 | UINT16\r | |
135 | EFIAPI\r | |
136 | IoWrite16 (\r | |
137 | IN UINTN Port,\r | |
138 | IN UINT16 Value\r | |
139 | )\r | |
140 | {\r | |
fe7fd578 | 141 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 142 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
143 | \r | |
5240b97c | 144 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 145 | CpuIo = (*PeiServices)->CpuIo;\r |
146 | ASSERT (CpuIo != NULL);\r | |
147 | //\r | |
148 | // Make sure Port is aligned on a 16-bit boundary.\r | |
149 | //\r | |
150 | ASSERT ((Port & 1) == 0);\r | |
151 | CpuIo->IoWrite16 (PeiServices, CpuIo, (UINT64) Port, Value);\r | |
152 | return Value;\r | |
153 | }\r | |
154 | \r | |
155 | /**\r | |
156 | Reads a 32-bit I/O port.\r | |
157 | \r | |
158 | Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.\r | |
159 | This function must guarantee that all I/O read and write operations are\r | |
160 | serialized.\r | |
161 | \r | |
162 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
163 | \r | |
164 | @param Port The I/O port to read.\r | |
165 | \r | |
f80b0830 | 166 | @return The value read from Port.\r |
11f43dfd | 167 | \r |
168 | **/\r | |
169 | UINT32\r | |
170 | EFIAPI\r | |
171 | IoRead32 (\r | |
172 | IN UINTN Port\r | |
173 | )\r | |
174 | {\r | |
fe7fd578 | 175 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 176 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
177 | \r | |
5240b97c | 178 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 179 | CpuIo = (*PeiServices)->CpuIo;\r |
180 | ASSERT (CpuIo != NULL);\r | |
181 | //\r | |
182 | // Make sure Port is aligned on a 32-bit boundary.\r | |
183 | //\r | |
184 | ASSERT ((Port & 3) == 0);\r | |
185 | return CpuIo->IoRead32 (PeiServices, CpuIo, (UINT64) Port);\r | |
186 | }\r | |
187 | \r | |
188 | /**\r | |
189 | Writes a 32-bit I/O port.\r | |
190 | \r | |
191 | Writes the 32-bit I/O port specified by Port with the value specified by Value\r | |
192 | and returns Value. This function must guarantee that all I/O read and write\r | |
193 | operations are serialized.\r | |
194 | \r | |
195 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
196 | \r | |
197 | @param Port The I/O port to write.\r | |
198 | @param Value The value to write to the I/O port.\r | |
199 | \r | |
200 | @return The value written the I/O port.\r | |
201 | \r | |
202 | **/\r | |
203 | UINT32\r | |
204 | EFIAPI\r | |
205 | IoWrite32 (\r | |
206 | IN UINTN Port,\r | |
207 | IN UINT32 Value\r | |
208 | )\r | |
209 | {\r | |
fe7fd578 | 210 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 211 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
212 | \r | |
5240b97c | 213 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 214 | CpuIo = (*PeiServices)->CpuIo;\r |
215 | ASSERT (CpuIo != NULL);\r | |
216 | //\r | |
217 | // Make sure Port is aligned on a 32-bit boundary.\r | |
218 | //\r | |
219 | ASSERT ((Port & 3) == 0);\r | |
220 | CpuIo->IoWrite32 (PeiServices, CpuIo, (UINT64) Port, Value);\r | |
221 | return Value;\r | |
222 | }\r | |
223 | \r | |
224 | /**\r | |
225 | Reads a 64-bit I/O port.\r | |
226 | \r | |
227 | Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.\r | |
228 | This function must guarantee that all I/O read and write operations are\r | |
229 | serialized.\r | |
230 | \r | |
231 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
232 | \r | |
233 | @param Port The I/O port to read.\r | |
234 | \r | |
f80b0830 | 235 | @return The value read from Port.\r |
11f43dfd | 236 | \r |
237 | **/\r | |
238 | UINT64\r | |
239 | EFIAPI\r | |
240 | IoRead64 (\r | |
241 | IN UINTN Port\r | |
242 | )\r | |
243 | {\r | |
fe7fd578 | 244 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 245 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
246 | \r | |
5240b97c | 247 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 248 | CpuIo = (*PeiServices)->CpuIo;\r |
249 | ASSERT (CpuIo != NULL);\r | |
250 | //\r | |
251 | // Make sure Port is aligned on a 64-bit boundary.\r | |
252 | //\r | |
253 | ASSERT ((Port & 7) == 0);\r | |
254 | return CpuIo->IoRead64 (PeiServices, CpuIo, (UINT64) Port);\r | |
255 | }\r | |
256 | \r | |
257 | /**\r | |
258 | Writes a 64-bit I/O port.\r | |
259 | \r | |
260 | Writes the 64-bit I/O port specified by Port with the value specified by Value\r | |
261 | and returns Value. This function must guarantee that all I/O read and write\r | |
262 | operations are serialized.\r | |
263 | \r | |
264 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
265 | \r | |
266 | @param Port The I/O port to write.\r | |
267 | @param Value The value to write to the I/O port.\r | |
268 | \r | |
269 | @return The value written the I/O port.\r | |
270 | \r | |
271 | **/\r | |
272 | UINT64\r | |
273 | EFIAPI\r | |
274 | IoWrite64 (\r | |
275 | IN UINTN Port,\r | |
276 | IN UINT64 Value\r | |
277 | )\r | |
278 | {\r | |
fe7fd578 | 279 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 280 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
281 | \r | |
5240b97c | 282 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 283 | CpuIo = (*PeiServices)->CpuIo;\r |
284 | ASSERT (CpuIo != NULL);\r | |
285 | //\r | |
286 | // Make sure Port is aligned on a 64-bit boundary.\r | |
287 | //\r | |
288 | ASSERT ((Port & 7) == 0);\r | |
289 | CpuIo->IoWrite64 (PeiServices, CpuIo, (UINT64) Port, Value);\r | |
290 | return Value;;\r | |
291 | }\r | |
292 | \r | |
293 | /**\r | |
294 | Reads an 8-bit MMIO register.\r | |
295 | \r | |
296 | Reads the 8-bit MMIO register specified by Address. The 8-bit read value is\r | |
297 | returned. This function must guarantee that all MMIO read and write\r | |
298 | operations are serialized.\r | |
299 | \r | |
300 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
301 | \r | |
302 | @param Address The MMIO register to read.\r | |
303 | \r | |
f80b0830 | 304 | @return The value read from Port.\r |
11f43dfd | 305 | \r |
306 | **/\r | |
307 | UINT8\r | |
308 | EFIAPI\r | |
309 | MmioRead8 (\r | |
310 | IN UINTN Address\r | |
311 | )\r | |
312 | {\r | |
fe7fd578 | 313 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 314 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
315 | \r | |
5240b97c | 316 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 317 | CpuIo = (*PeiServices)->CpuIo;\r |
318 | ASSERT (CpuIo != NULL);\r | |
319 | \r | |
320 | return CpuIo->MemRead8 (PeiServices, CpuIo, (UINT64) Address);\r | |
321 | }\r | |
322 | \r | |
323 | /**\r | |
324 | Writes an 8-bit MMIO register.\r | |
325 | \r | |
326 | Writes the 8-bit MMIO register specified by Address with the value specified\r | |
327 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
328 | and write operations are serialized.\r | |
329 | \r | |
330 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
331 | \r | |
332 | @param Address The MMIO register to write.\r | |
333 | @param Value The value to write to the MMIO register.\r | |
f80b0830 | 334 | \r |
335 | @return The Value written back to Mmio register.\r | |
11f43dfd | 336 | **/\r |
337 | UINT8\r | |
338 | EFIAPI\r | |
339 | MmioWrite8 (\r | |
340 | IN UINTN Address,\r | |
341 | IN UINT8 Value\r | |
342 | )\r | |
343 | {\r | |
fe7fd578 | 344 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 345 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
346 | \r | |
5240b97c | 347 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 348 | CpuIo = (*PeiServices)->CpuIo;\r |
349 | ASSERT (CpuIo != NULL);\r | |
350 | \r | |
351 | CpuIo->MemWrite8 (PeiServices, CpuIo, (UINT64) Address, Value);\r | |
352 | return Value;\r | |
353 | }\r | |
354 | \r | |
355 | /**\r | |
356 | Reads a 16-bit MMIO register.\r | |
357 | \r | |
358 | Reads the 16-bit MMIO register specified by Address. The 16-bit read value is\r | |
359 | returned. This function must guarantee that all MMIO read and write\r | |
360 | operations are serialized.\r | |
361 | \r | |
362 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
363 | \r | |
364 | @param Address The MMIO register to read.\r | |
365 | \r | |
f80b0830 | 366 | @return The value read from Address.\r |
11f43dfd | 367 | \r |
368 | **/\r | |
369 | UINT16\r | |
370 | EFIAPI\r | |
371 | MmioRead16 (\r | |
372 | IN UINTN Address\r | |
373 | )\r | |
374 | {\r | |
fe7fd578 | 375 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 376 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
377 | \r | |
5240b97c | 378 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 379 | CpuIo = (*PeiServices)->CpuIo;\r |
380 | ASSERT (CpuIo != NULL);\r | |
381 | //\r | |
382 | // Make sure Address is aligned on a 16-bit boundary.\r | |
383 | //\r | |
384 | ASSERT ((Address & 1) == 0);\r | |
385 | return CpuIo->MemRead16 (PeiServices, CpuIo, (UINT64) Address);\r | |
386 | \r | |
387 | }\r | |
388 | \r | |
389 | /**\r | |
390 | Writes a 16-bit MMIO register.\r | |
391 | \r | |
392 | Writes the 16-bit MMIO register specified by Address with the value specified\r | |
393 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
394 | and write operations are serialized.\r | |
395 | \r | |
396 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
397 | \r | |
398 | @param Address The MMIO register to write.\r | |
399 | @param Value The value to write to the MMIO register.\r | |
f80b0830 | 400 | \r |
401 | @return The Value written back to Mmio register\r | |
11f43dfd | 402 | \r |
403 | **/\r | |
404 | UINT16\r | |
405 | EFIAPI\r | |
406 | MmioWrite16 (\r | |
407 | IN UINTN Address,\r | |
408 | IN UINT16 Value\r | |
409 | )\r | |
410 | {\r | |
fe7fd578 | 411 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 412 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
413 | \r | |
5240b97c | 414 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 415 | CpuIo = (*PeiServices)->CpuIo;\r |
416 | ASSERT (CpuIo != NULL);\r | |
417 | //\r | |
418 | // Make sure Address is aligned on a 16-bit boundary.\r | |
419 | //\r | |
420 | ASSERT ((Address & 1) == 0);\r | |
421 | CpuIo->MemWrite16 (PeiServices, CpuIo, (UINT64) Address, Value);\r | |
422 | return Value;\r | |
423 | }\r | |
424 | \r | |
425 | /**\r | |
426 | Reads a 32-bit MMIO register.\r | |
427 | \r | |
428 | Reads the 32-bit MMIO register specified by Address. The 32-bit read value is\r | |
429 | returned. This function must guarantee that all MMIO read and write\r | |
430 | operations are serialized.\r | |
431 | \r | |
432 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
433 | \r | |
434 | @param Address The MMIO register to read.\r | |
435 | \r | |
f80b0830 | 436 | @return The value read from Address.\r |
11f43dfd | 437 | \r |
438 | **/\r | |
439 | UINT32\r | |
440 | EFIAPI\r | |
441 | MmioRead32 (\r | |
442 | IN UINTN Address\r | |
443 | )\r | |
444 | {\r | |
fe7fd578 | 445 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 446 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
447 | \r | |
5240b97c | 448 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 449 | CpuIo = (*PeiServices)->CpuIo;\r |
450 | ASSERT (CpuIo != NULL);\r | |
451 | //\r | |
452 | // Make sure Address is aligned on a 32-bit boundary.\r | |
453 | //\r | |
454 | ASSERT ((Address & 3) == 0);\r | |
455 | return CpuIo->MemRead32 (PeiServices, CpuIo, (UINT64) Address);\r | |
456 | \r | |
457 | }\r | |
458 | \r | |
459 | /**\r | |
460 | Writes a 32-bit MMIO register.\r | |
461 | \r | |
462 | Writes the 32-bit MMIO register specified by Address with the value specified\r | |
463 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
464 | and write operations are serialized.\r | |
465 | \r | |
466 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
467 | \r | |
468 | @param Address The MMIO register to write.\r | |
469 | @param Value The value to write to the MMIO register.\r | |
f80b0830 | 470 | \r |
471 | @return The Value written back to Mmio register\r | |
11f43dfd | 472 | \r |
473 | **/\r | |
474 | UINT32\r | |
475 | EFIAPI\r | |
476 | MmioWrite32 (\r | |
477 | IN UINTN Address,\r | |
478 | IN UINT32 Value\r | |
479 | )\r | |
480 | {\r | |
fe7fd578 | 481 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 482 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
483 | \r | |
5240b97c | 484 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 485 | CpuIo = (*PeiServices)->CpuIo;\r |
486 | ASSERT (CpuIo != NULL);\r | |
487 | //\r | |
488 | // Make sure Address is aligned on a 32-bit boundary.\r | |
489 | //\r | |
490 | ASSERT ((Address & 3) == 0);\r | |
491 | CpuIo->MemWrite32 (PeiServices, CpuIo, (UINT64) Address, Value);\r | |
492 | return Value;\r | |
493 | }\r | |
494 | \r | |
495 | /**\r | |
496 | Reads a 64-bit MMIO register.\r | |
497 | \r | |
498 | Reads the 64-bit MMIO register specified by Address. The 64-bit read value is\r | |
499 | returned. This function must guarantee that all MMIO read and write\r | |
500 | operations are serialized.\r | |
501 | \r | |
502 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
503 | \r | |
504 | @param Address The MMIO register to read.\r | |
505 | \r | |
f80b0830 | 506 | @return The value read from Address.\r |
11f43dfd | 507 | \r |
508 | **/\r | |
509 | UINT64\r | |
510 | EFIAPI\r | |
511 | MmioRead64 (\r | |
512 | IN UINTN Address\r | |
513 | )\r | |
514 | {\r | |
fe7fd578 | 515 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 516 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
517 | \r | |
5240b97c | 518 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 519 | CpuIo = (*PeiServices)->CpuIo;\r |
520 | ASSERT (CpuIo != NULL);\r | |
521 | //\r | |
522 | // Make sure Address is aligned on a 64-bit boundary.\r | |
523 | //\r | |
4efb2b4d | 524 | ASSERT ((Address & (sizeof (UINT64) - 1)) == 0);\r |
11f43dfd | 525 | return CpuIo->MemRead64 (PeiServices, CpuIo, (UINT64) Address);\r |
526 | \r | |
527 | }\r | |
528 | \r | |
529 | /**\r | |
530 | Writes a 64-bit MMIO register.\r | |
531 | \r | |
532 | Writes the 64-bit MMIO register specified by Address with the value specified\r | |
533 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
534 | and write operations are serialized.\r | |
535 | \r | |
536 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
537 | \r | |
538 | @param Address The MMIO register to write.\r | |
539 | @param Value The value to write to the MMIO register.\r | |
540 | \r | |
f80b0830 | 541 | @return The Value written back to Mmio register\r |
11f43dfd | 542 | **/\r |
543 | UINT64\r | |
544 | EFIAPI\r | |
545 | MmioWrite64 (\r | |
546 | IN UINTN Address,\r | |
547 | IN UINT64 Value\r | |
548 | )\r | |
549 | {\r | |
fe7fd578 | 550 | CONST EFI_PEI_SERVICES **PeiServices;\r |
11f43dfd | 551 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
552 | \r | |
5240b97c | 553 | PeiServices = GetPeiServicesTablePointer ();\r |
11f43dfd | 554 | CpuIo = (*PeiServices)->CpuIo;\r |
555 | ASSERT (CpuIo != NULL);\r | |
556 | //\r | |
557 | // Make sure Address is aligned on a 64-bit boundary.\r | |
558 | //\r | |
559 | ASSERT ((Address & 7) == 0);\r | |
560 | CpuIo->MemWrite64 (PeiServices, CpuIo, (UINT64) Address, Value);\r | |
561 | return Value;\r | |
562 | }\r |