\r
#include "UefiPciCapPciIoLib.h"\r
\r
-\r
/**\r
Transfer bytes between the config space of a given PCI device and a memory\r
buffer.\r
STATIC\r
EFI_STATUS\r
ProtoDevTransferConfig (\r
- IN EFI_PCI_IO_PROTOCOL *PciIo,\r
- IN EFI_PCI_IO_PROTOCOL_CONFIG TransferFunction,\r
- IN UINT16 ConfigOffset,\r
- IN OUT UINT8 *Buffer,\r
- IN UINT16 Size\r
+ IN EFI_PCI_IO_PROTOCOL *PciIo,\r
+ IN EFI_PCI_IO_PROTOCOL_CONFIG TransferFunction,\r
+ IN UINT16 ConfigOffset,\r
+ IN OUT UINT8 *Buffer,\r
+ IN UINT16 Size\r
)\r
{\r
while (Size > 0) {\r
- EFI_PCI_IO_PROTOCOL_WIDTH Width;\r
- UINT16 Count;\r
- EFI_STATUS Status;\r
- UINT16 Progress;\r
+ EFI_PCI_IO_PROTOCOL_WIDTH Width;\r
+ UINT16 Count;\r
+ EFI_STATUS Status;\r
+ UINT16 Progress;\r
\r
//\r
// Pick the largest access size that is allowed by the remaining transfer\r
// possible in one iteration of the loop. Otherwise, transfer only one\r
// unit, to improve the alignment.\r
//\r
- if (Size >= 4 && (ConfigOffset & 3) == 0) {\r
+ if ((Size >= 4) && ((ConfigOffset & 3) == 0)) {\r
Width = EfiPciIoWidthUint32;\r
Count = Size >> Width;\r
- } else if (Size >= 2 && (ConfigOffset & 1) == 0) {\r
+ } else if ((Size >= 2) && ((ConfigOffset & 1) == 0)) {\r
Width = EfiPciIoWidthUint16;\r
Count = 1;\r
} else {\r
Width = EfiPciIoWidthUint8;\r
Count = 1;\r
}\r
+\r
Status = TransferFunction (PciIo, Width, ConfigOffset, Count, Buffer);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
+\r
Progress = Count << Width;\r
ConfigOffset += Progress;\r
Buffer += Progress;\r
Size -= Progress;\r
}\r
+\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
Read the config space of a given PCI device (both normal and extended).\r
\r
RETURN_STATUS\r
EFIAPI\r
ProtoDevReadConfig (\r
- IN PCI_CAP_DEV *PciDevice,\r
- IN UINT16 SourceOffset,\r
- OUT VOID *DestinationBuffer,\r
- IN UINT16 Size\r
+ IN PCI_CAP_DEV *PciDevice,\r
+ IN UINT16 SourceOffset,\r
+ OUT VOID *DestinationBuffer,\r
+ IN UINT16 Size\r
)\r
{\r
- PROTO_DEV *ProtoDev;\r
+ PROTO_DEV *ProtoDev;\r
\r
ProtoDev = PROTO_DEV_FROM_PCI_CAP_DEV (PciDevice);\r
- return ProtoDevTransferConfig (ProtoDev->PciIo, ProtoDev->PciIo->Pci.Read,\r
- SourceOffset, DestinationBuffer, Size);\r
+ return ProtoDevTransferConfig (\r
+ ProtoDev->PciIo,\r
+ ProtoDev->PciIo->Pci.Read,\r
+ SourceOffset,\r
+ DestinationBuffer,\r
+ Size\r
+ );\r
}\r
\r
-\r
/**\r
Write the config space of a given PCI device (both normal and extended).\r
\r
RETURN_STATUS\r
EFIAPI\r
ProtoDevWriteConfig (\r
- IN PCI_CAP_DEV *PciDevice,\r
- IN UINT16 DestinationOffset,\r
- IN VOID *SourceBuffer,\r
- IN UINT16 Size\r
+ IN PCI_CAP_DEV *PciDevice,\r
+ IN UINT16 DestinationOffset,\r
+ IN VOID *SourceBuffer,\r
+ IN UINT16 Size\r
)\r
{\r
- PROTO_DEV *ProtoDev;\r
+ PROTO_DEV *ProtoDev;\r
\r
ProtoDev = PROTO_DEV_FROM_PCI_CAP_DEV (PciDevice);\r
- return ProtoDevTransferConfig (ProtoDev->PciIo, ProtoDev->PciIo->Pci.Write,\r
- DestinationOffset, SourceBuffer, Size);\r
+ return ProtoDevTransferConfig (\r
+ ProtoDev->PciIo,\r
+ ProtoDev->PciIo->Pci.Write,\r
+ DestinationOffset,\r
+ SourceBuffer,\r
+ Size\r
+ );\r
}\r
\r
-\r
/**\r
Create a PCI_CAP_DEV object from an EFI_PCI_IO_PROTOCOL instance. The config\r
space accessors are based upon EFI_PCI_IO_PROTOCOL.Pci.Read() and\r
EFI_STATUS\r
EFIAPI\r
PciCapPciIoDeviceInit (\r
- IN EFI_PCI_IO_PROTOCOL *PciIo,\r
- OUT PCI_CAP_DEV **PciDevice\r
+ IN EFI_PCI_IO_PROTOCOL *PciIo,\r
+ OUT PCI_CAP_DEV **PciDevice\r
)\r
{\r
- PROTO_DEV *ProtoDev;\r
+ PROTO_DEV *ProtoDev;\r
\r
ProtoDev = AllocatePool (sizeof *ProtoDev);\r
if (ProtoDev == NULL) {\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
Free the resources used by PciDevice.\r
\r
VOID\r
EFIAPI\r
PciCapPciIoDeviceUninit (\r
- IN PCI_CAP_DEV *PciDevice\r
+ IN PCI_CAP_DEV *PciDevice\r
)\r
{\r
- PROTO_DEV *ProtoDev;\r
+ PROTO_DEV *ProtoDev;\r
\r
ProtoDev = PROTO_DEV_FROM_PCI_CAP_DEV (PciDevice);\r
FreePool (ProtoDev);\r