]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/UefiPciLibPciRootBridgeIo/PciLib.c
Minor grammatical work--mostly adding periods. Items with ONLY period added did...
[mirror_edk2.git] / MdePkg / Library / UefiPciLibPciRootBridgeIo / PciLib.c
1 /** @file
2 PCI Library using PCI Root Bridge I/O Protocol.
3
4 Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are
6 licensed and made available under the terms and conditions of
7 the BSD License which accompanies this distribution. The full
8 text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include <PiDxe.h>
17
18 #include <Protocol/PciRootBridgeIo.h>
19
20 #include <Library/PciLib.h>
21 #include <Library/BaseLib.h>
22 #include <Library/UefiBootServicesTableLib.h>
23 #include <Library/DebugLib.h>
24
25 /**
26 Assert the validity of a PCI address. A valid PCI address should contain 1's
27 only in the low 28 bits.
28
29 @param A The address to validate.
30 @param M Additional bits to assert to be zero.
31
32 **/
33 #define ASSERT_INVALID_PCI_ADDRESS(A,M) \
34 ASSERT (((A) & (~0xfffffff | (M))) == 0)
35
36 /**
37 Translate PCI Lib address into format of PCI Root Bridge I/O Protocol.
38
39 @param A The address that encodes the PCI Bus, Device, Function and
40 Register.
41
42 **/
43 #define PCI_TO_PCI_ROOT_BRIDGE_IO_ADDRESS(A) \
44 ((((A) << 4) & 0xff000000) | (((A) >> 4) & 0x00000700) | (((A) << 1) & 0x001f0000) | (LShiftU64((A) & 0xfff, 32)))
45
46 //
47 // Global varible to cache pointer to PCI Root Bridge I/O protocol.
48 //
49 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *mPciRootBridgeIo = NULL;
50
51 /**
52 The constructor function caches the pointer to PCI Root Bridge I/O protocol.
53
54 The constructor function locates PCI Root Bridge I/O protocol from protocol database.
55 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
56
57 @param ImageHandle The firmware allocated handle for the EFI image.
58 @param SystemTable A pointer to the EFI System Table.
59
60 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
61
62 **/
63 EFI_STATUS
64 EFIAPI
65 PciLibConstructor (
66 IN EFI_HANDLE ImageHandle,
67 IN EFI_SYSTEM_TABLE *SystemTable
68 )
69 {
70 EFI_STATUS Status;
71
72 Status = gBS->LocateProtocol (&gEfiPciRootBridgeIoProtocolGuid, NULL, (VOID**) &mPciRootBridgeIo);
73 ASSERT_EFI_ERROR (Status);
74 ASSERT (mPciRootBridgeIo != NULL);
75
76 return EFI_SUCCESS;
77 }
78
79 /**
80 Internal worker function to read a PCI configuration register.
81
82 This function wraps EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Pci.Read() service.
83 It reads and returns the PCI configuration register specified by Address,
84 the width of data is specified by Width.
85
86 @param Address The address that encodes the PCI Bus, Device, Function and
87 Register.
88 @param Width Width of data to read
89
90 @return The value read from the PCI configuration register.
91
92 **/
93 UINT32
94 DxePciLibPciRootBridgeIoReadWorker (
95 IN UINTN Address,
96 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
97 )
98 {
99 UINT32 Data;
100
101 mPciRootBridgeIo->Pci.Read (
102 mPciRootBridgeIo,
103 Width,
104 PCI_TO_PCI_ROOT_BRIDGE_IO_ADDRESS (Address),
105 1,
106 &Data
107 );
108
109 return Data;
110 }
111
112 /**
113 Internal worker function to writes a PCI configuration register.
114
115 This function wraps EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Pci.Write() service.
116 It writes the PCI configuration register specified by Address with the
117 value specified by Data. The width of data is specifed by Width.
118 Data is returned.
119
120 @param Address The address that encodes the PCI Bus, Device, Function and
121 Register.
122 @param Width Width of data to write
123 @param Data The value to write.
124
125 @return The value written to the PCI configuration register.
126
127 **/
128 UINT32
129 DxePciLibPciRootBridgeIoWriteWorker (
130 IN UINTN Address,
131 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
132 IN UINT32 Data
133 )
134 {
135 mPciRootBridgeIo->Pci.Write (
136 mPciRootBridgeIo,
137 Width,
138 PCI_TO_PCI_ROOT_BRIDGE_IO_ADDRESS (Address),
139 1,
140 &Data
141 );
142 return Data;
143 }
144
145 /**
146 Registers a PCI device so PCI configuration registers may be accessed after
147 SetVirtualAddressMap().
148
149 Registers the PCI device specified by Address so all the PCI configuration registers
150 associated with that PCI device may be accessed after SetVirtualAddressMap() is called.
151
152 If Address > 0x0FFFFFFF, then ASSERT().
153
154 @param Address The address that encodes the PCI Bus, Device, Function and
155 Register.
156
157 @retval RETURN_SUCCESS The PCI device was registered for runtime access.
158 @retval RETURN_UNSUPPORTED An attempt was made to call this function
159 after ExitBootServices().
160 @retval RETURN_UNSUPPORTED The resources required to access the PCI device
161 at runtime could not be mapped.
162 @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to
163 complete the registration.
164
165 **/
166 RETURN_STATUS
167 EFIAPI
168 PciRegisterForRuntimeAccess (
169 IN UINTN Address
170 )
171 {
172 ASSERT_INVALID_PCI_ADDRESS (Address, 0);
173 return RETURN_UNSUPPORTED;
174 }
175
176 /**
177 Reads an 8-bit PCI configuration register.
178
179 Reads and returns the 8-bit PCI configuration register specified by Address.
180 This function must guarantee that all PCI read and write operations are
181 serialized.
182
183 If Address > 0x0FFFFFFF, then ASSERT().
184
185 @param Address The address that encodes the PCI Bus, Device, Function and
186 Register.
187
188 @return The read value from the PCI configuration register.
189
190 **/
191 UINT8
192 EFIAPI
193 PciRead8 (
194 IN UINTN Address
195 )
196 {
197 ASSERT_INVALID_PCI_ADDRESS (Address, 0);
198
199 return (UINT8) DxePciLibPciRootBridgeIoReadWorker (Address, EfiPciWidthUint8);
200 }
201
202 /**
203 Writes an 8-bit PCI configuration register.
204
205 Writes the 8-bit PCI configuration register specified by Address with the
206 value specified by Value. Value is returned. This function must guarantee
207 that all PCI read and write operations are serialized.
208
209 If Address > 0x0FFFFFFF, then ASSERT().
210
211 @param Address The address that encodes the PCI Bus, Device, Function and
212 Register.
213 @param Value The value to write.
214
215 @return The value written to the PCI configuration register.
216
217 **/
218 UINT8
219 EFIAPI
220 PciWrite8 (
221 IN UINTN Address,
222 IN UINT8 Value
223 )
224 {
225 ASSERT_INVALID_PCI_ADDRESS (Address, 0);
226
227 return (UINT8) DxePciLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint8, Value);
228 }
229
230 /**
231 Performs a bitwise OR of an 8-bit PCI configuration register with
232 an 8-bit value.
233
234 Reads the 8-bit PCI configuration register specified by Address, performs a
235 bitwise OR between the read result and the value specified by
236 OrData, and writes the result to the 8-bit PCI configuration register
237 specified by Address. The value written to the PCI configuration register is
238 returned. This function must guarantee that all PCI read and write operations
239 are serialized.
240
241 If Address > 0x0FFFFFFF, then ASSERT().
242
243 @param Address The address that encodes the PCI Bus, Device, Function and
244 Register.
245 @param OrData The value to OR with the PCI configuration register.
246
247 @return The value written back to the PCI configuration register.
248
249 **/
250 UINT8
251 EFIAPI
252 PciOr8 (
253 IN UINTN Address,
254 IN UINT8 OrData
255 )
256 {
257 return PciWrite8 (Address, (UINT8) (PciRead8 (Address) | OrData));
258 }
259
260 /**
261 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
262 value.
263
264 Reads the 8-bit PCI configuration register specified by Address, performs a
265 bitwise AND between the read result and the value specified by AndData, and
266 writes the result to the 8-bit PCI configuration register specified by
267 Address. The value written to the PCI configuration register is returned.
268 This function must guarantee that all PCI read and write operations are
269 serialized.
270
271 If Address > 0x0FFFFFFF, then ASSERT().
272
273 @param Address The address that encodes the PCI Bus, Device, Function and
274 Register.
275 @param AndData The value to AND with the PCI configuration register.
276
277 @return The value written back to the PCI configuration register.
278
279 **/
280 UINT8
281 EFIAPI
282 PciAnd8 (
283 IN UINTN Address,
284 IN UINT8 AndData
285 )
286 {
287 return PciWrite8 (Address, (UINT8) (PciRead8 (Address) & AndData));
288 }
289
290 /**
291 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
292 value, followed a bitwise OR with another 8-bit value.
293
294 Reads the 8-bit PCI configuration register specified by Address, performs a
295 bitwise AND between the read result and the value specified by AndData,
296 performs a bitwise OR between the result of the AND operation and
297 the value specified by OrData, and writes the result to the 8-bit PCI
298 configuration register specified by Address. The value written to the PCI
299 configuration register is returned. This function must guarantee that all PCI
300 read and write operations are serialized.
301
302 If Address > 0x0FFFFFFF, then ASSERT().
303
304 @param Address The address that encodes the PCI Bus, Device, Function and
305 Register.
306 @param AndData The value to AND with the PCI configuration register.
307 @param OrData The value to OR with the result of the AND operation.
308
309 @return The value written back to the PCI configuration register.
310
311 **/
312 UINT8
313 EFIAPI
314 PciAndThenOr8 (
315 IN UINTN Address,
316 IN UINT8 AndData,
317 IN UINT8 OrData
318 )
319 {
320 return PciWrite8 (Address, (UINT8) ((PciRead8 (Address) & AndData) | OrData));
321 }
322
323 /**
324 Reads a bit field of a PCI configuration register.
325
326 Reads the bit field in an 8-bit PCI configuration register. The bit field is
327 specified by the StartBit and the EndBit. The value of the bit field is
328 returned.
329
330 If Address > 0x0FFFFFFF, then ASSERT().
331 If StartBit is greater than 7, then ASSERT().
332 If EndBit is greater than 7, then ASSERT().
333 If EndBit is less than StartBit, then ASSERT().
334
335 @param Address The PCI configuration register to read.
336 @param StartBit The ordinal of the least significant bit in the bit field.
337 Range 0..7.
338 @param EndBit The ordinal of the most significant bit in the bit field.
339 Range 0..7.
340
341 @return The value of the bit field read from the PCI configuration register.
342
343 **/
344 UINT8
345 EFIAPI
346 PciBitFieldRead8 (
347 IN UINTN Address,
348 IN UINTN StartBit,
349 IN UINTN EndBit
350 )
351 {
352 return BitFieldRead8 (PciRead8 (Address), StartBit, EndBit);
353 }
354
355 /**
356 Writes a bit field to a PCI configuration register.
357
358 Writes Value to the bit field of the PCI configuration register. The bit
359 field is specified by the StartBit and the EndBit. All other bits in the
360 destination PCI configuration register are preserved. The new value of the
361 8-bit register is returned.
362
363 If Address > 0x0FFFFFFF, then ASSERT().
364 If StartBit is greater than 7, then ASSERT().
365 If EndBit is greater than 7, then ASSERT().
366 If EndBit is less than StartBit, then ASSERT().
367
368 @param Address The PCI configuration register to write.
369 @param StartBit The ordinal of the least significant bit in the bit field.
370 Range 0..7.
371 @param EndBit The ordinal of the most significant bit in the bit field.
372 Range 0..7.
373 @param Value The new value of the bit field.
374
375 @return The value written back to the PCI configuration register.
376
377 **/
378 UINT8
379 EFIAPI
380 PciBitFieldWrite8 (
381 IN UINTN Address,
382 IN UINTN StartBit,
383 IN UINTN EndBit,
384 IN UINT8 Value
385 )
386 {
387 return PciWrite8 (
388 Address,
389 BitFieldWrite8 (PciRead8 (Address), StartBit, EndBit, Value)
390 );
391 }
392
393 /**
394 Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and
395 writes the result back to the bit field in the 8-bit port.
396
397 Reads the 8-bit PCI configuration register specified by Address, performs a
398 bitwise OR between the read result and the value specified by
399 OrData, and writes the result to the 8-bit PCI configuration register
400 specified by Address. The value written to the PCI configuration register is
401 returned. This function must guarantee that all PCI read and write operations
402 are serialized. Extra left bits in OrData are stripped.
403
404 If Address > 0x0FFFFFFF, then ASSERT().
405 If StartBit is greater than 7, then ASSERT().
406 If EndBit is greater than 7, then ASSERT().
407 If EndBit is less than StartBit, then ASSERT().
408
409 @param Address The PCI configuration register to write.
410 @param StartBit The ordinal of the least significant bit in the bit field.
411 Range 0..7.
412 @param EndBit The ordinal of the most significant bit in the bit field.
413 Range 0..7.
414 @param OrData The value to OR with the PCI configuration register.
415
416 @return The value written back to the PCI configuration register.
417
418 **/
419 UINT8
420 EFIAPI
421 PciBitFieldOr8 (
422 IN UINTN Address,
423 IN UINTN StartBit,
424 IN UINTN EndBit,
425 IN UINT8 OrData
426 )
427 {
428 return PciWrite8 (
429 Address,
430 BitFieldOr8 (PciRead8 (Address), StartBit, EndBit, OrData)
431 );
432 }
433
434 /**
435 Reads a bit field in an 8-bit PCI configuration register, performs a bitwise
436 AND, and writes the result back to the bit field in the 8-bit register.
437
438 Reads the 8-bit PCI configuration register specified by Address, performs a
439 bitwise AND between the read result and the value specified by AndData, and
440 writes the result to the 8-bit PCI configuration register specified by
441 Address. The value written to the PCI configuration register is returned.
442 This function must guarantee that all PCI read and write operations are
443 serialized. Extra left bits in AndData are stripped.
444
445 If Address > 0x0FFFFFFF, then ASSERT().
446 If StartBit is greater than 7, then ASSERT().
447 If EndBit is greater than 7, then ASSERT().
448 If EndBit is less than StartBit, then ASSERT().
449
450 @param Address The PCI configuration register to write.
451 @param StartBit The ordinal of the least significant bit in the bit field.
452 Range 0..7.
453 @param EndBit The ordinal of the most significant bit in the bit field.
454 Range 0..7.
455 @param AndData The value to AND with the PCI configuration register.
456
457 @return The value written back to the PCI configuration register.
458
459 **/
460 UINT8
461 EFIAPI
462 PciBitFieldAnd8 (
463 IN UINTN Address,
464 IN UINTN StartBit,
465 IN UINTN EndBit,
466 IN UINT8 AndData
467 )
468 {
469 return PciWrite8 (
470 Address,
471 BitFieldAnd8 (PciRead8 (Address), StartBit, EndBit, AndData)
472 );
473 }
474
475 /**
476 Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
477 bitwise OR, and writes the result back to the bit field in the
478 8-bit port.
479
480 Reads the 8-bit PCI configuration register specified by Address, performs a
481 bitwise AND followed by a bitwise OR between the read result and
482 the value specified by AndData, and writes the result to the 8-bit PCI
483 configuration register specified by Address. The value written to the PCI
484 configuration register is returned. This function must guarantee that all PCI
485 read and write operations are serialized. Extra left bits in both AndData and
486 OrData are stripped.
487
488 If Address > 0x0FFFFFFF, then ASSERT().
489 If StartBit is greater than 7, then ASSERT().
490 If EndBit is greater than 7, then ASSERT().
491 If EndBit is less than StartBit, then ASSERT().
492
493 @param Address The PCI configuration register to write.
494 @param StartBit The ordinal of the least significant bit in the bit field.
495 Range 0..7.
496 @param EndBit The ordinal of the most significant bit in the bit field.
497 Range 0..7.
498 @param AndData The value to AND with the PCI configuration register.
499 @param OrData The value to OR with the result of the AND operation.
500
501 @return The value written back to the PCI configuration register.
502
503 **/
504 UINT8
505 EFIAPI
506 PciBitFieldAndThenOr8 (
507 IN UINTN Address,
508 IN UINTN StartBit,
509 IN UINTN EndBit,
510 IN UINT8 AndData,
511 IN UINT8 OrData
512 )
513 {
514 return PciWrite8 (
515 Address,
516 BitFieldAndThenOr8 (PciRead8 (Address), StartBit, EndBit, AndData, OrData)
517 );
518 }
519
520 /**
521 Reads a 16-bit PCI configuration register.
522
523 Reads and returns the 16-bit PCI configuration register specified by Address.
524 This function must guarantee that all PCI read and write operations are
525 serialized.
526
527 If Address > 0x0FFFFFFF, then ASSERT().
528 If Address is not aligned on a 16-bit boundary, then ASSERT().
529
530 @param Address The address that encodes the PCI Bus, Device, Function and
531 Register.
532
533 @return The read value from the PCI configuration register.
534
535 **/
536 UINT16
537 EFIAPI
538 PciRead16 (
539 IN UINTN Address
540 )
541 {
542 ASSERT_INVALID_PCI_ADDRESS (Address, 1);
543
544 return (UINT16) DxePciLibPciRootBridgeIoReadWorker (Address, EfiPciWidthUint16);
545 }
546
547 /**
548 Writes a 16-bit PCI configuration register.
549
550 Writes the 16-bit PCI configuration register specified by Address with the
551 value specified by Value. Value is returned. This function must guarantee
552 that all PCI read and write operations are serialized.
553
554 If Address > 0x0FFFFFFF, then ASSERT().
555 If Address is not aligned on a 16-bit boundary, then ASSERT().
556
557 @param Address The address that encodes the PCI Bus, Device, Function and
558 Register.
559 @param Value The value to write.
560
561 @return The value written to the PCI configuration register.
562
563 **/
564 UINT16
565 EFIAPI
566 PciWrite16 (
567 IN UINTN Address,
568 IN UINT16 Value
569 )
570 {
571 ASSERT_INVALID_PCI_ADDRESS (Address, 1);
572
573 return (UINT16) DxePciLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint16, Value);
574 }
575
576 /**
577 Performs a bitwise OR of a 16-bit PCI configuration register with
578 a 16-bit value.
579
580 Reads the 16-bit PCI configuration register specified by Address, performs a
581 bitwise OR between the read result and the value specified by
582 OrData, and writes the result to the 16-bit PCI configuration register
583 specified by Address. The value written to the PCI configuration register is
584 returned. This function must guarantee that all PCI read and write operations
585 are serialized.
586
587 If Address > 0x0FFFFFFF, then ASSERT().
588 If Address is not aligned on a 16-bit boundary, then ASSERT().
589
590 @param Address The address that encodes the PCI Bus, Device, Function and
591 Register.
592 @param OrData The value to OR with the PCI configuration register.
593
594 @return The value written back to the PCI configuration register.
595
596 **/
597 UINT16
598 EFIAPI
599 PciOr16 (
600 IN UINTN Address,
601 IN UINT16 OrData
602 )
603 {
604 return PciWrite16 (Address, (UINT16) (PciRead16 (Address) | OrData));
605 }
606
607 /**
608 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
609 value.
610
611 Reads the 16-bit PCI configuration register specified by Address, performs a
612 bitwise AND between the read result and the value specified by AndData, and
613 writes the result to the 16-bit PCI configuration register specified by
614 Address. The value written to the PCI configuration register is returned.
615 This function must guarantee that all PCI read and write operations are
616 serialized.
617
618 If Address > 0x0FFFFFFF, then ASSERT().
619 If Address is not aligned on a 16-bit boundary, then ASSERT().
620
621 @param Address The address that encodes the PCI Bus, Device, Function and
622 Register.
623 @param AndData The value to AND with the PCI configuration register.
624
625 @return The value written back to the PCI configuration register.
626
627 **/
628 UINT16
629 EFIAPI
630 PciAnd16 (
631 IN UINTN Address,
632 IN UINT16 AndData
633 )
634 {
635 return PciWrite16 (Address, (UINT16) (PciRead16 (Address) & AndData));
636 }
637
638 /**
639 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
640 value, followed a bitwise OR with another 16-bit value.
641
642 Reads the 16-bit PCI configuration register specified by Address, performs a
643 bitwise AND between the read result and the value specified by AndData,
644 performs a bitwise OR between the result of the AND operation and
645 the value specified by OrData, and writes the result to the 16-bit PCI
646 configuration register specified by Address. The value written to the PCI
647 configuration register is returned. This function must guarantee that all PCI
648 read and write operations are serialized.
649
650 If Address > 0x0FFFFFFF, then ASSERT().
651 If Address is not aligned on a 16-bit boundary, then ASSERT().
652
653 @param Address The address that encodes the PCI Bus, Device, Function and
654 Register.
655 @param AndData The value to AND with the PCI configuration register.
656 @param OrData The value to OR with the result of the AND operation.
657
658 @return The value written back to the PCI configuration register.
659
660 **/
661 UINT16
662 EFIAPI
663 PciAndThenOr16 (
664 IN UINTN Address,
665 IN UINT16 AndData,
666 IN UINT16 OrData
667 )
668 {
669 return PciWrite16 (Address, (UINT16) ((PciRead16 (Address) & AndData) | OrData));
670 }
671
672 /**
673 Reads a bit field of a PCI configuration register.
674
675 Reads the bit field in a 16-bit PCI configuration register. The bit field is
676 specified by the StartBit and the EndBit. The value of the bit field is
677 returned.
678
679 If Address > 0x0FFFFFFF, then ASSERT().
680 If Address is not aligned on a 16-bit boundary, then ASSERT().
681 If StartBit is greater than 15, then ASSERT().
682 If EndBit is greater than 15, then ASSERT().
683 If EndBit is less than StartBit, then ASSERT().
684
685 @param Address The PCI configuration register to read.
686 @param StartBit The ordinal of the least significant bit in the bit field.
687 Range 0..15.
688 @param EndBit The ordinal of the most significant bit in the bit field.
689 Range 0..15.
690
691 @return The value of the bit field read from the PCI configuration register.
692
693 **/
694 UINT16
695 EFIAPI
696 PciBitFieldRead16 (
697 IN UINTN Address,
698 IN UINTN StartBit,
699 IN UINTN EndBit
700 )
701 {
702 return BitFieldRead16 (PciRead16 (Address), StartBit, EndBit);
703 }
704
705 /**
706 Writes a bit field to a PCI configuration register.
707
708 Writes Value to the bit field of the PCI configuration register. The bit
709 field is specified by the StartBit and the EndBit. All other bits in the
710 destination PCI configuration register are preserved. The new value of the
711 16-bit register is returned.
712
713 If Address > 0x0FFFFFFF, then ASSERT().
714 If Address is not aligned on a 16-bit boundary, then ASSERT().
715 If StartBit is greater than 15, then ASSERT().
716 If EndBit is greater than 15, then ASSERT().
717 If EndBit is less than StartBit, then ASSERT().
718
719 @param Address The PCI configuration register to write.
720 @param StartBit The ordinal of the least significant bit in the bit field.
721 Range 0..15.
722 @param EndBit The ordinal of the most significant bit in the bit field.
723 Range 0..15.
724 @param Value The new value of the bit field.
725
726 @return The value written back to the PCI configuration register.
727
728 **/
729 UINT16
730 EFIAPI
731 PciBitFieldWrite16 (
732 IN UINTN Address,
733 IN UINTN StartBit,
734 IN UINTN EndBit,
735 IN UINT16 Value
736 )
737 {
738 return PciWrite16 (
739 Address,
740 BitFieldWrite16 (PciRead16 (Address), StartBit, EndBit, Value)
741 );
742 }
743
744 /**
745 Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and
746 writes the result back to the bit field in the 16-bit port.
747
748 Reads the 16-bit PCI configuration register specified by Address, performs a
749 bitwise OR between the read result and the value specified by
750 OrData, and writes the result to the 16-bit PCI configuration register
751 specified by Address. The value written to the PCI configuration register is
752 returned. This function must guarantee that all PCI read and write operations
753 are serialized. Extra left bits in OrData are stripped.
754
755 If Address > 0x0FFFFFFF, then ASSERT().
756 If Address is not aligned on a 16-bit boundary, then ASSERT().
757 If StartBit is greater than 15, then ASSERT().
758 If EndBit is greater than 15, then ASSERT().
759 If EndBit is less than StartBit, then ASSERT().
760
761 @param Address The PCI configuration register to write.
762 @param StartBit The ordinal of the least significant bit in the bit field.
763 Range 0..15.
764 @param EndBit The ordinal of the most significant bit in the bit field.
765 Range 0..15.
766 @param OrData The value to OR with the PCI configuration register.
767
768 @return The value written back to the PCI configuration register.
769
770 **/
771 UINT16
772 EFIAPI
773 PciBitFieldOr16 (
774 IN UINTN Address,
775 IN UINTN StartBit,
776 IN UINTN EndBit,
777 IN UINT16 OrData
778 )
779 {
780 return PciWrite16 (
781 Address,
782 BitFieldOr16 (PciRead16 (Address), StartBit, EndBit, OrData)
783 );
784 }
785
786 /**
787 Reads a bit field in a 16-bit PCI configuration register, performs a bitwise
788 AND, and writes the result back to the bit field in the 16-bit register.
789
790 Reads the 16-bit PCI configuration register specified by Address, performs a
791 bitwise AND between the read result and the value specified by AndData, and
792 writes the result to the 16-bit PCI configuration register specified by
793 Address. The value written to the PCI configuration register is returned.
794 This function must guarantee that all PCI read and write operations are
795 serialized. Extra left bits in AndData are stripped.
796
797 If Address > 0x0FFFFFFF, then ASSERT().
798 If Address is not aligned on a 16-bit boundary, then ASSERT().
799 If StartBit is greater than 15, then ASSERT().
800 If EndBit is greater than 15, then ASSERT().
801 If EndBit is less than StartBit, then ASSERT().
802
803 @param Address The PCI configuration register to write.
804 @param StartBit The ordinal of the least significant bit in the bit field.
805 Range 0..15.
806 @param EndBit The ordinal of the most significant bit in the bit field.
807 Range 0..15.
808 @param AndData The value to AND with the PCI configuration register.
809
810 @return The value written back to the PCI configuration register.
811
812 **/
813 UINT16
814 EFIAPI
815 PciBitFieldAnd16 (
816 IN UINTN Address,
817 IN UINTN StartBit,
818 IN UINTN EndBit,
819 IN UINT16 AndData
820 )
821 {
822 return PciWrite16 (
823 Address,
824 BitFieldAnd16 (PciRead16 (Address), StartBit, EndBit, AndData)
825 );
826 }
827
828 /**
829 Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
830 bitwise OR, and writes the result back to the bit field in the
831 16-bit port.
832
833 Reads the 16-bit PCI configuration register specified by Address, performs a
834 bitwise AND followed by a bitwise OR between the read result and
835 the value specified by AndData, and writes the result to the 16-bit PCI
836 configuration register specified by Address. The value written to the PCI
837 configuration register is returned. This function must guarantee that all PCI
838 read and write operations are serialized. Extra left bits in both AndData and
839 OrData are stripped.
840
841 If Address > 0x0FFFFFFF, then ASSERT().
842 If Address is not aligned on a 16-bit boundary, then ASSERT().
843 If StartBit is greater than 15, then ASSERT().
844 If EndBit is greater than 15, then ASSERT().
845 If EndBit is less than StartBit, then ASSERT().
846
847 @param Address The PCI configuration register to write.
848 @param StartBit The ordinal of the least significant bit in the bit field.
849 Range 0..15.
850 @param EndBit The ordinal of the most significant bit in the bit field.
851 Range 0..15.
852 @param AndData The value to AND with the PCI configuration register.
853 @param OrData The value to OR with the result of the AND operation.
854
855 @return The value written back to the PCI configuration register.
856
857 **/
858 UINT16
859 EFIAPI
860 PciBitFieldAndThenOr16 (
861 IN UINTN Address,
862 IN UINTN StartBit,
863 IN UINTN EndBit,
864 IN UINT16 AndData,
865 IN UINT16 OrData
866 )
867 {
868 return PciWrite16 (
869 Address,
870 BitFieldAndThenOr16 (PciRead16 (Address), StartBit, EndBit, AndData, OrData)
871 );
872 }
873
874 /**
875 Reads a 32-bit PCI configuration register.
876
877 Reads and returns the 32-bit PCI configuration register specified by Address.
878 This function must guarantee that all PCI read and write operations are
879 serialized.
880
881 If Address > 0x0FFFFFFF, then ASSERT().
882 If Address is not aligned on a 32-bit boundary, then ASSERT().
883
884 @param Address The address that encodes the PCI Bus, Device, Function and
885 Register.
886
887 @return The read value from the PCI configuration register.
888
889 **/
890 UINT32
891 EFIAPI
892 PciRead32 (
893 IN UINTN Address
894 )
895 {
896 ASSERT_INVALID_PCI_ADDRESS (Address, 3);
897
898 return DxePciLibPciRootBridgeIoReadWorker (Address, EfiPciWidthUint32);
899 }
900
901 /**
902 Writes a 32-bit PCI configuration register.
903
904 Writes the 32-bit PCI configuration register specified by Address with the
905 value specified by Value. Value is returned. This function must guarantee
906 that all PCI read and write operations are serialized.
907
908 If Address > 0x0FFFFFFF, then ASSERT().
909 If Address is not aligned on a 32-bit boundary, then ASSERT().
910
911 @param Address The address that encodes the PCI Bus, Device, Function and
912 Register.
913 @param Value The value to write.
914
915 @return The value written to the PCI configuration register.
916
917 **/
918 UINT32
919 EFIAPI
920 PciWrite32 (
921 IN UINTN Address,
922 IN UINT32 Value
923 )
924 {
925 ASSERT_INVALID_PCI_ADDRESS (Address, 3);
926
927 return DxePciLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint32, Value);
928 }
929
930 /**
931 Performs a bitwise OR of a 32-bit PCI configuration register with
932 a 32-bit value.
933
934 Reads the 32-bit PCI configuration register specified by Address, performs a
935 bitwise OR between the read result and the value specified by
936 OrData, and writes the result to the 32-bit PCI configuration register
937 specified by Address. The value written to the PCI configuration register is
938 returned. This function must guarantee that all PCI read and write operations
939 are serialized.
940
941 If Address > 0x0FFFFFFF, then ASSERT().
942 If Address is not aligned on a 32-bit boundary, then ASSERT().
943
944 @param Address The address that encodes the PCI Bus, Device, Function and
945 Register.
946 @param OrData The value to OR with the PCI configuration register.
947
948 @return The value written back to the PCI configuration register.
949
950 **/
951 UINT32
952 EFIAPI
953 PciOr32 (
954 IN UINTN Address,
955 IN UINT32 OrData
956 )
957 {
958 return PciWrite32 (Address, PciRead32 (Address) | OrData);
959 }
960
961 /**
962 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
963 value.
964
965 Reads the 32-bit PCI configuration register specified by Address, performs a
966 bitwise AND between the read result and the value specified by AndData, and
967 writes the result to the 32-bit PCI configuration register specified by
968 Address. The value written to the PCI configuration register is returned.
969 This function must guarantee that all PCI read and write operations are
970 serialized.
971
972 If Address > 0x0FFFFFFF, then ASSERT().
973 If Address is not aligned on a 32-bit boundary, then ASSERT().
974
975 @param Address The address that encodes the PCI Bus, Device, Function and
976 Register.
977 @param AndData The value to AND with the PCI configuration register.
978
979 @return The value written back to the PCI configuration register.
980
981 **/
982 UINT32
983 EFIAPI
984 PciAnd32 (
985 IN UINTN Address,
986 IN UINT32 AndData
987 )
988 {
989 return PciWrite32 (Address, PciRead32 (Address) & AndData);
990 }
991
992 /**
993 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
994 value, followed a bitwise OR with another 32-bit value.
995
996 Reads the 32-bit PCI configuration register specified by Address, performs a
997 bitwise AND between the read result and the value specified by AndData,
998 performs a bitwise OR between the result of the AND operation and
999 the value specified by OrData, and writes the result to the 32-bit PCI
1000 configuration register specified by Address. The value written to the PCI
1001 configuration register is returned. This function must guarantee that all PCI
1002 read and write operations are serialized.
1003
1004 If Address > 0x0FFFFFFF, then ASSERT().
1005 If Address is not aligned on a 32-bit boundary, then ASSERT().
1006
1007 @param Address The address that encodes the PCI Bus, Device, Function and
1008 Register.
1009 @param AndData The value to AND with the PCI configuration register.
1010 @param OrData The value to OR with the result of the AND operation.
1011
1012 @return The value written back to the PCI configuration register.
1013
1014 **/
1015 UINT32
1016 EFIAPI
1017 PciAndThenOr32 (
1018 IN UINTN Address,
1019 IN UINT32 AndData,
1020 IN UINT32 OrData
1021 )
1022 {
1023 return PciWrite32 (Address, (PciRead32 (Address) & AndData) | OrData);
1024 }
1025
1026 /**
1027 Reads a bit field of a PCI configuration register.
1028
1029 Reads the bit field in a 32-bit PCI configuration register. The bit field is
1030 specified by the StartBit and the EndBit. The value of the bit field is
1031 returned.
1032
1033 If Address > 0x0FFFFFFF, then ASSERT().
1034 If Address is not aligned on a 32-bit boundary, then ASSERT().
1035 If StartBit is greater than 31, then ASSERT().
1036 If EndBit is greater than 31, then ASSERT().
1037 If EndBit is less than StartBit, then ASSERT().
1038
1039 @param Address The PCI configuration register to read.
1040 @param StartBit The ordinal of the least significant bit in the bit field.
1041 Range 0..31.
1042 @param EndBit The ordinal of the most significant bit in the bit field.
1043 Range 0..31.
1044
1045 @return The value of the bit field read from the PCI configuration register.
1046
1047 **/
1048 UINT32
1049 EFIAPI
1050 PciBitFieldRead32 (
1051 IN UINTN Address,
1052 IN UINTN StartBit,
1053 IN UINTN EndBit
1054 )
1055 {
1056 return BitFieldRead32 (PciRead32 (Address), StartBit, EndBit);
1057 }
1058
1059 /**
1060 Writes a bit field to a PCI configuration register.
1061
1062 Writes Value to the bit field of the PCI configuration register. The bit
1063 field is specified by the StartBit and the EndBit. All other bits in the
1064 destination PCI configuration register are preserved. The new value of the
1065 32-bit register is returned.
1066
1067 If Address > 0x0FFFFFFF, then ASSERT().
1068 If Address is not aligned on a 32-bit boundary, then ASSERT().
1069 If StartBit is greater than 31, then ASSERT().
1070 If EndBit is greater than 31, then ASSERT().
1071 If EndBit is less than StartBit, then ASSERT().
1072
1073 @param Address The PCI configuration register to write.
1074 @param StartBit The ordinal of the least significant bit in the bit field.
1075 Range 0..31.
1076 @param EndBit The ordinal of the most significant bit in the bit field.
1077 Range 0..31.
1078 @param Value The new value of the bit field.
1079
1080 @return The value written back to the PCI configuration register.
1081
1082 **/
1083 UINT32
1084 EFIAPI
1085 PciBitFieldWrite32 (
1086 IN UINTN Address,
1087 IN UINTN StartBit,
1088 IN UINTN EndBit,
1089 IN UINT32 Value
1090 )
1091 {
1092 return PciWrite32 (
1093 Address,
1094 BitFieldWrite32 (PciRead32 (Address), StartBit, EndBit, Value)
1095 );
1096 }
1097
1098 /**
1099 Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and
1100 writes the result back to the bit field in the 32-bit port.
1101
1102 Reads the 32-bit PCI configuration register specified by Address, performs a
1103 bitwise OR between the read result and the value specified by
1104 OrData, and writes the result to the 32-bit PCI configuration register
1105 specified by Address. The value written to the PCI configuration register is
1106 returned. This function must guarantee that all PCI read and write operations
1107 are serialized. Extra left bits in OrData are stripped.
1108
1109 If Address > 0x0FFFFFFF, then ASSERT().
1110 If Address is not aligned on a 32-bit boundary, then ASSERT().
1111 If StartBit is greater than 31, then ASSERT().
1112 If EndBit is greater than 31, then ASSERT().
1113 If EndBit is less than StartBit, then ASSERT().
1114
1115 @param Address The PCI configuration register to write.
1116 @param StartBit The ordinal of the least significant bit in the bit field.
1117 Range 0..31.
1118 @param EndBit The ordinal of the most significant bit in the bit field.
1119 Range 0..31.
1120 @param OrData The value to OR with the PCI configuration register.
1121
1122 @return The value written back to the PCI configuration register.
1123
1124 **/
1125 UINT32
1126 EFIAPI
1127 PciBitFieldOr32 (
1128 IN UINTN Address,
1129 IN UINTN StartBit,
1130 IN UINTN EndBit,
1131 IN UINT32 OrData
1132 )
1133 {
1134 return PciWrite32 (
1135 Address,
1136 BitFieldOr32 (PciRead32 (Address), StartBit, EndBit, OrData)
1137 );
1138 }
1139
1140 /**
1141 Reads a bit field in a 32-bit PCI configuration register, performs a bitwise
1142 AND, and writes the result back to the bit field in the 32-bit register.
1143
1144 Reads the 32-bit PCI configuration register specified by Address, performs a
1145 bitwise AND between the read result and the value specified by AndData, and
1146 writes the result to the 32-bit PCI configuration register specified by
1147 Address. The value written to the PCI configuration register is returned.
1148 This function must guarantee that all PCI read and write operations are
1149 serialized. Extra left bits in AndData are stripped.
1150
1151 If Address > 0x0FFFFFFF, then ASSERT().
1152 If Address is not aligned on a 32-bit boundary, then ASSERT().
1153 If StartBit is greater than 31, then ASSERT().
1154 If EndBit is greater than 31, then ASSERT().
1155 If EndBit is less than StartBit, then ASSERT().
1156
1157 @param Address The PCI configuration register to write.
1158 @param StartBit The ordinal of the least significant bit in the bit field.
1159 Range 0..31.
1160 @param EndBit The ordinal of the most significant bit in the bit field.
1161 Range 0..31.
1162 @param AndData The value to AND with the PCI configuration register.
1163
1164 @return The value written back to the PCI configuration register.
1165
1166 **/
1167 UINT32
1168 EFIAPI
1169 PciBitFieldAnd32 (
1170 IN UINTN Address,
1171 IN UINTN StartBit,
1172 IN UINTN EndBit,
1173 IN UINT32 AndData
1174 )
1175 {
1176 return PciWrite32 (
1177 Address,
1178 BitFieldAnd32 (PciRead32 (Address), StartBit, EndBit, AndData)
1179 );
1180 }
1181
1182 /**
1183 Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
1184 bitwise OR, and writes the result back to the bit field in the
1185 32-bit port.
1186
1187 Reads the 32-bit PCI configuration register specified by Address, performs a
1188 bitwise AND followed by a bitwise OR between the read result and
1189 the value specified by AndData, and writes the result to the 32-bit PCI
1190 configuration register specified by Address. The value written to the PCI
1191 configuration register is returned. This function must guarantee that all PCI
1192 read and write operations are serialized. Extra left bits in both AndData and
1193 OrData are stripped.
1194
1195 If Address > 0x0FFFFFFF, then ASSERT().
1196 If Address is not aligned on a 32-bit boundary, then ASSERT().
1197 If StartBit is greater than 31, then ASSERT().
1198 If EndBit is greater than 31, then ASSERT().
1199 If EndBit is less than StartBit, then ASSERT().
1200
1201 @param Address The PCI configuration register to write.
1202 @param StartBit The ordinal of the least significant bit in the bit field.
1203 Range 0..31.
1204 @param EndBit The ordinal of the most significant bit in the bit field.
1205 Range 0..31.
1206 @param AndData The value to AND with the PCI configuration register.
1207 @param OrData The value to OR with the result of the AND operation.
1208
1209 @return The value written back to the PCI configuration register.
1210
1211 **/
1212 UINT32
1213 EFIAPI
1214 PciBitFieldAndThenOr32 (
1215 IN UINTN Address,
1216 IN UINTN StartBit,
1217 IN UINTN EndBit,
1218 IN UINT32 AndData,
1219 IN UINT32 OrData
1220 )
1221 {
1222 return PciWrite32 (
1223 Address,
1224 BitFieldAndThenOr32 (PciRead32 (Address), StartBit, EndBit, AndData, OrData)
1225 );
1226 }
1227
1228 /**
1229 Reads a range of PCI configuration registers into a caller supplied buffer.
1230
1231 Reads the range of PCI configuration registers specified by StartAddress and
1232 Size into the buffer specified by Buffer. This function only allows the PCI
1233 configuration registers from a single PCI function to be read. Size is
1234 returned. When possible 32-bit PCI configuration read cycles are used to read
1235 from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
1236 and 16-bit PCI configuration read cycles may be used at the beginning and the
1237 end of the range.
1238
1239 If StartAddress > 0x0FFFFFFF, then ASSERT().
1240 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
1241 If Size > 0 and Buffer is NULL, then ASSERT().
1242
1243 @param StartAddress The starting address that encodes the PCI Bus, Device,
1244 Function and Register.
1245 @param Size The size in bytes of the transfer.
1246 @param Buffer The pointer to a buffer receiving the data read.
1247
1248 @return Size
1249
1250 **/
1251 UINTN
1252 EFIAPI
1253 PciReadBuffer (
1254 IN UINTN StartAddress,
1255 IN UINTN Size,
1256 OUT VOID *Buffer
1257 )
1258 {
1259 UINTN ReturnValue;
1260
1261 ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);
1262 ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);
1263
1264 if (Size == 0) {
1265 return Size;
1266 }
1267
1268 ASSERT (Buffer != NULL);
1269
1270 //
1271 // Save Size for return
1272 //
1273 ReturnValue = Size;
1274
1275 if ((StartAddress & BIT0) != 0) {
1276 //
1277 // Read a byte if StartAddress is byte aligned
1278 //
1279 *(volatile UINT8 *)Buffer = PciRead8 (StartAddress);
1280 StartAddress += sizeof (UINT8);
1281 Size -= sizeof (UINT8);
1282 Buffer = (UINT8*)Buffer + 1;
1283 }
1284
1285 if (Size >= sizeof (UINT16) && (StartAddress & BIT1) != 0) {
1286 //
1287 // Read a word if StartAddress is word aligned
1288 //
1289 WriteUnaligned16 (Buffer, PciRead16 (StartAddress));
1290 StartAddress += sizeof (UINT16);
1291 Size -= sizeof (UINT16);
1292 Buffer = (UINT16*)Buffer + 1;
1293 }
1294
1295 while (Size >= sizeof (UINT32)) {
1296 //
1297 // Read as many double words as possible
1298 //
1299 WriteUnaligned32 (Buffer, PciRead32 (StartAddress));
1300 StartAddress += sizeof (UINT32);
1301 Size -= sizeof (UINT32);
1302 Buffer = (UINT32*)Buffer + 1;
1303 }
1304
1305 if (Size >= sizeof (UINT16)) {
1306 //
1307 // Read the last remaining word if exist
1308 //
1309 WriteUnaligned16 (Buffer, PciRead16 (StartAddress));
1310 StartAddress += sizeof (UINT16);
1311 Size -= sizeof (UINT16);
1312 Buffer = (UINT16*)Buffer + 1;
1313 }
1314
1315 if (Size >= sizeof (UINT8)) {
1316 //
1317 // Read the last remaining byte if exist
1318 //
1319 *(volatile UINT8 *)Buffer = PciRead8 (StartAddress);
1320 }
1321
1322 return ReturnValue;
1323 }
1324
1325 /**
1326 Copies the data in a caller supplied buffer to a specified range of PCI
1327 configuration space.
1328
1329 Writes the range of PCI configuration registers specified by StartAddress and
1330 Size from the buffer specified by Buffer. This function only allows the PCI
1331 configuration registers from a single PCI function to be written. Size is
1332 returned. When possible 32-bit PCI configuration write cycles are used to
1333 write from StartAdress to StartAddress + Size. Due to alignment restrictions,
1334 8-bit and 16-bit PCI configuration write cycles may be used at the beginning
1335 and the end of the range.
1336
1337 If StartAddress > 0x0FFFFFFF, then ASSERT().
1338 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
1339 If Size > 0 and Buffer is NULL, then ASSERT().
1340
1341 @param StartAddress The starting address that encodes the PCI Bus, Device,
1342 Function and Register.
1343 @param Size The size in bytes of the transfer.
1344 @param Buffer The pointer to a buffer containing the data to write.
1345
1346 @return Size written to StartAddress.
1347
1348 **/
1349 UINTN
1350 EFIAPI
1351 PciWriteBuffer (
1352 IN UINTN StartAddress,
1353 IN UINTN Size,
1354 IN VOID *Buffer
1355 )
1356 {
1357 UINTN ReturnValue;
1358
1359 ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);
1360 ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);
1361
1362 if (Size == 0) {
1363 return 0;
1364 }
1365
1366 ASSERT (Buffer != NULL);
1367
1368 //
1369 // Save Size for return
1370 //
1371 ReturnValue = Size;
1372
1373 if ((StartAddress & BIT0) != 0) {
1374 //
1375 // Write a byte if StartAddress is byte aligned
1376 //
1377 PciWrite8 (StartAddress, *(UINT8*)Buffer);
1378 StartAddress += sizeof (UINT8);
1379 Size -= sizeof (UINT8);
1380 Buffer = (UINT8*)Buffer + 1;
1381 }
1382
1383 if (Size >= sizeof (UINT16) && (StartAddress & BIT1) != 0) {
1384 //
1385 // Write a word if StartAddress is word aligned
1386 //
1387 PciWrite16 (StartAddress, ReadUnaligned16 (Buffer));
1388 StartAddress += sizeof (UINT16);
1389 Size -= sizeof (UINT16);
1390 Buffer = (UINT16*)Buffer + 1;
1391 }
1392
1393 while (Size >= sizeof (UINT32)) {
1394 //
1395 // Write as many double words as possible
1396 //
1397 PciWrite32 (StartAddress, ReadUnaligned32 (Buffer));
1398 StartAddress += sizeof (UINT32);
1399 Size -= sizeof (UINT32);
1400 Buffer = (UINT32*)Buffer + 1;
1401 }
1402
1403 if (Size >= sizeof (UINT16)) {
1404 //
1405 // Write the last remaining word if exist
1406 //
1407 PciWrite16 (StartAddress, ReadUnaligned16 (Buffer));
1408 StartAddress += sizeof (UINT16);
1409 Size -= sizeof (UINT16);
1410 Buffer = (UINT16*)Buffer + 1;
1411 }
1412
1413 if (Size >= sizeof (UINT8)) {
1414 //
1415 // Write the last remaining byte if exist
1416 //
1417 PciWrite8 (StartAddress, *(UINT8*)Buffer);
1418 }
1419
1420 return ReturnValue;
1421 }