X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FUefiPciLibPciRootBridgeIo%2FPciLib.c;h=ba51019a77a67f26dec0a687bb8bf8580006bf40;hp=5a43f66f860786ab5d28db3c6ee32adb39896841;hb=19388d2960b2fe0347da23799e93ccc52f540214;hpb=62991af27f84e5f20e55dee6e1f90eb77ec5325e diff --git a/MdePkg/Library/UefiPciLibPciRootBridgeIo/PciLib.c b/MdePkg/Library/UefiPciLibPciRootBridgeIo/PciLib.c index 5a43f66f86..ba51019a77 100644 --- a/MdePkg/Library/UefiPciLibPciRootBridgeIo/PciLib.c +++ b/MdePkg/Library/UefiPciLibPciRootBridgeIo/PciLib.c @@ -1,8 +1,8 @@ /** @file PCI Library using PCI Root Bridge I/O Protocol. - Copyright (c) 2007 - 2008, Intel Corporation All rights - reserved. This program and the accompanying materials are + Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -143,9 +143,12 @@ DxePciLibPciRootBridgeIoWriteWorker ( } /** - Register a PCI device so PCI configuration registers may be accessed after + Registers a PCI device so PCI configuration registers may be accessed after SetVirtualAddressMap(). + Registers the PCI device specified by Address so all the PCI configuration registers + associated with that PCI device may be accessed after SetVirtualAddressMap() is called. + If Address > 0x0FFFFFFF, then ASSERT(). @param Address Address that encodes the PCI Bus, Device, Function and @@ -166,6 +169,7 @@ PciRegisterForRuntimeAccess ( IN UINTN Address ) { + ASSERT_INVALID_PCI_ADDRESS (Address, 0); return RETURN_UNSUPPORTED; } @@ -181,7 +185,7 @@ PciRegisterForRuntimeAccess ( @param Address Address that encodes the PCI Bus, Device, Function and Register. - @return The value read from the PCI configuration register. + @return The read value from the PCI configuration register. **/ UINT8 @@ -206,7 +210,7 @@ PciRead8 ( @param Address Address that encodes the PCI Bus, Device, Function and Register. - @param Data The value to write. + @param Value The value to write. @return The value written to the PCI configuration register. @@ -215,12 +219,12 @@ UINT8 EFIAPI PciWrite8 ( IN UINTN Address, - IN UINT8 Data + IN UINT8 Value ) { ASSERT_INVALID_PCI_ADDRESS (Address, 0); - return (UINT8) DxePciLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint8, Data); + return (UINT8) DxePciLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint8, Value); } /** @@ -526,7 +530,7 @@ PciBitFieldAndThenOr8 ( @param Address Address that encodes the PCI Bus, Device, Function and Register. - @return The value read from the PCI configuration register. + @return The read value from the PCI configuration register. **/ UINT16 @@ -552,7 +556,7 @@ PciRead16 ( @param Address Address that encodes the PCI Bus, Device, Function and Register. - @param Data The value to write. + @param Value The value to write. @return The value written to the PCI configuration register. @@ -561,12 +565,12 @@ UINT16 EFIAPI PciWrite16 ( IN UINTN Address, - IN UINT16 Data + IN UINT16 Value ) { ASSERT_INVALID_PCI_ADDRESS (Address, 1); - return (UINT16) DxePciLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint16, Data); + return (UINT16) DxePciLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint16, Value); } /** @@ -880,7 +884,7 @@ PciBitFieldAndThenOr16 ( @param Address Address that encodes the PCI Bus, Device, Function and Register. - @return The value read from the PCI configuration register. + @return The read value from the PCI configuration register. **/ UINT32 @@ -906,7 +910,7 @@ PciRead32 ( @param Address Address that encodes the PCI Bus, Device, Function and Register. - @param Data The value to write. + @param Value The value to write. @return The value written to the PCI configuration register. @@ -915,12 +919,12 @@ UINT32 EFIAPI PciWrite32 ( IN UINTN Address, - IN UINT32 Data + IN UINT32 Value ) { ASSERT_INVALID_PCI_ADDRESS (Address, 3); - return DxePciLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint32, Data); + return DxePciLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint32, Value); } /** @@ -1282,7 +1286,7 @@ PciReadBuffer ( // // Read a word if StartAddress is word aligned // - *(volatile UINT16 *)Buffer = PciRead16 (StartAddress); + WriteUnaligned16 (Buffer, PciRead16 (StartAddress)); StartAddress += sizeof (UINT16); Size -= sizeof (UINT16); Buffer = (UINT16*)Buffer + 1; @@ -1292,7 +1296,7 @@ PciReadBuffer ( // // Read as many double words as possible // - *(volatile UINT32 *)Buffer = PciRead32 (StartAddress); + WriteUnaligned32 (Buffer, PciRead32 (StartAddress)); StartAddress += sizeof (UINT32); Size -= sizeof (UINT32); Buffer = (UINT32*)Buffer + 1; @@ -1302,7 +1306,7 @@ PciReadBuffer ( // // Read the last remaining word if exist // - *(volatile UINT16 *)Buffer = PciRead16 (StartAddress); + WriteUnaligned16 (Buffer, PciRead16 (StartAddress)); StartAddress += sizeof (UINT16); Size -= sizeof (UINT16); Buffer = (UINT16*)Buffer + 1; @@ -1339,7 +1343,7 @@ PciReadBuffer ( @param Size Size in bytes of the transfer. @param Buffer Pointer to a buffer containing the data to write. - @return Size + @return Size written to StartAddress. **/ UINTN @@ -1380,7 +1384,7 @@ PciWriteBuffer ( // // Write a word if StartAddress is word aligned // - PciWrite16 (StartAddress, *(UINT16*)Buffer); + PciWrite16 (StartAddress, ReadUnaligned16 (Buffer)); StartAddress += sizeof (UINT16); Size -= sizeof (UINT16); Buffer = (UINT16*)Buffer + 1; @@ -1390,7 +1394,7 @@ PciWriteBuffer ( // // Write as many double words as possible // - PciWrite32 (StartAddress, *(UINT32*)Buffer); + PciWrite32 (StartAddress, ReadUnaligned32 (Buffer)); StartAddress += sizeof (UINT32); Size -= sizeof (UINT32); Buffer = (UINT32*)Buffer + 1; @@ -1400,7 +1404,7 @@ PciWriteBuffer ( // // Write the last remaining word if exist // - PciWrite16 (StartAddress, *(UINT16*)Buffer); + PciWrite16 (StartAddress, ReadUnaligned16 (Buffer)); StartAddress += sizeof (UINT16); Size -= sizeof (UINT16); Buffer = (UINT16*)Buffer + 1;