X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FPcatSingleSegmentPciCfg2Pei%2FPciCfg2.c;h=d2ca19c7b065156f2ad3c5c909d8ba37908188f3;hp=fdd67f7abb86b66483fca1a04631ea4c1e8b20e9;hb=109e9a6156b2c9540fd4b1b6ce17ac5be1fa03c4;hpb=303ee61d53cde4c064729709fa890ead41bbe00b diff --git a/MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c b/MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c index fdd67f7abb..d2ca19c7b0 100644 --- a/MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c +++ b/MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c @@ -1,7 +1,9 @@ /** @file - Installs Single Segment Pci Configuration PPI. + This driver installs Single Segment Pci Configuration 2 PPI + to provide read, write and modify access to Pci configuration space in PEI phase. + To follow PI specification, these services also support access to the unaligned Pci address. - Copyright (c) 2006 - 2007, Intel Corporation + Copyright (c) 2006 - 2008, 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 @@ -13,164 +15,19 @@ **/ #include - #include - #include #include #include #include - #include -/** - Reads from a given location in the PCI configuration space. - - @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation. - - @param This Pointer to local data for the interface. - - @param Width The width of the access. Enumerated in bytes. - See EFI_PEI_PCI_CFG_PPI_WIDTH above. - - @param Address The physical address of the access. The format of - the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS. - - @param Buffer A pointer to the buffer of data.. - - - @retval EFI_SUCCESS The function completed successfully. - - @retval EFI_DEVICE_ERROR There was a problem with the transaction. - - @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this - time. - -**/ -EFI_STATUS -EFIAPI -PciCfg2Read ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_PCI_CFG2_PPI *This, - IN EFI_PEI_PCI_CFG_PPI_WIDTH Width, - IN UINT64 Address, - IN OUT VOID *Buffer - ); - -/** - Write to a given location in the PCI configuration space. - - @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation. - - @param This Pointer to local data for the interface. - - @param Width The width of the access. Enumerated in bytes. - See EFI_PEI_PCI_CFG_PPI_WIDTH above. - - @param Address The physical address of the access. The format of - the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS. - - @param Buffer A pointer to the buffer of data.. - - - @retval EFI_SUCCESS The function completed successfully. - - @retval EFI_DEVICE_ERROR There was a problem with the transaction. - - @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this - time. - -**/ -EFI_STATUS -EFIAPI -PciCfg2Write ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_PCI_CFG2_PPI *This, - IN EFI_PEI_PCI_CFG_PPI_WIDTH Width, - IN UINT64 Address, - IN OUT VOID *Buffer - ); - - -/** - PCI read-modify-write operation. - - @param PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - - @param This Pointer to local data for the interface. - - @param Width The width of the access. Enumerated in bytes. Type - EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read(). - - @param Address The physical address of the access. - - @param SetBits Points to value to bitwise-OR with the read configuration value. - - The size of the value is determined by Width. - - @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value. - The size of the value is determined by Width. - - - @retval EFI_SUCCESS The function completed successfully. - - @retval EFI_DEVICE_ERROR There was a problem with the transaction. - - @retval EFI_DEVICE_NOT_READY The device is not capable of supporting - the operation at this time. - -**/ -EFI_STATUS -EFIAPI -PciCfg2Modify ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_PCI_CFG2_PPI *This, - IN EFI_PEI_PCI_CFG_PPI_WIDTH Width, - IN UINT64 Address, - IN VOID *SetBits, - IN VOID *ClearBits - ); - - - -/** - @par Ppi Description: - The EFI_PEI_PCI_CFG2_PPI interfaces are used to abstract - accesses to PCI controllers behind a PCI root bridge - controller. - - @param Read PCI read services. See the Read() function description. - - @param Write PCI write services. See the Write() function description. - - @param Modify PCI read-modify-write services. See the Modify() function description. - - @param Segment The PCI bus segment which the specified functions will access. - -**/ -GLOBAL_REMOVE_IF_UNREFERENCED -EFI_PEI_PCI_CFG2_PPI gPciCfg2Ppi = { - PciCfg2Read, - PciCfg2Write, - PciCfg2Modify -}; - -GLOBAL_REMOVE_IF_UNREFERENCED -EFI_PEI_PPI_DESCRIPTOR gPciCfg2PpiList = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiPciCfg2PpiGuid, - &gPciCfg2Ppi -}; - - /** Convert EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS to PCI_LIB_ADDRESS. - @param Address PCI address with - EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS format. + @param Address PCI address with EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS format. - @return The PCI address with PCI_LIB_ADDRESS format. + @return PCI address with PCI_LIB_ADDRESS format. **/ UINTN @@ -185,30 +42,20 @@ PciCfgAddressConvert ( return PCI_LIB_ADDRESS (Address->Bus, Address->Device, Address->Function, Address->ExtendedRegister); } - /** Reads from a given location in the PCI configuration space. @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation. - @param This Pointer to local data for the interface. - @param Width The width of the access. Enumerated in bytes. See EFI_PEI_PCI_CFG_PPI_WIDTH above. - @param Address The physical address of the access. The format of the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS. - - @param Buffer A pointer to the buffer of data.. - + @param Buffer A pointer to the buffer of data. @retval EFI_SUCCESS The function completed successfully. - - @retval EFI_DEVICE_ERROR There was a problem with the transaction. - - @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this - time. - + @retval EFI_INVALID_PARAMETER The invalid access width. + **/ EFI_STATUS EFIAPI @@ -271,24 +118,15 @@ PciCfg2Read ( Write to a given location in the PCI configuration space. @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation. - @param This Pointer to local data for the interface. - @param Width The width of the access. Enumerated in bytes. See EFI_PEI_PCI_CFG_PPI_WIDTH above. - @param Address The physical address of the access. The format of the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS. - - @param Buffer A pointer to the buffer of data.. - + @param Buffer A pointer to the buffer of data. @retval EFI_SUCCESS The function completed successfully. - - @retval EFI_DEVICE_ERROR There was a problem with the transaction. - - @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this - time. + @retval EFI_INVALID_PARAMETER The invalid access width. **/ EFI_STATUS @@ -350,32 +188,22 @@ PciCfg2Write ( /** - PCI read-modify-write operation. + This function performs a read-modify-write operation on the contents from a given + location in the PCI configuration space. @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation. - @param This Pointer to local data for the interface. - @param Width The width of the access. Enumerated in bytes. Type EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read(). - @param Address The physical address of the access. - @param SetBits Points to value to bitwise-OR with the read configuration value. - The size of the value is determined by Width. - @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value. The size of the value is determined by Width. - @retval EFI_SUCCESS The function completed successfully. - - @retval EFI_DEVICE_ERROR There was a problem with the transaction. - - @retval EFI_DEVICE_NOT_READY The device is not capable of supporting - the operation at this time. + @retval EFI_INVALID_PARAMETER The invalid access width. **/ EFI_STATUS @@ -445,9 +273,23 @@ PciCfg2Modify ( } else { return EFI_INVALID_PARAMETER; } + return EFI_SUCCESS; } +EFI_PEI_PCI_CFG2_PPI gPciCfg2Ppi = { + PciCfg2Read, + PciCfg2Write, + PciCfg2Modify, + 0 +}; + +EFI_PEI_PPI_DESCRIPTOR gPciCfg2PpiList = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiPciCfg2PpiGuid, + &gPciCfg2Ppi +}; + /** Module's entry function. This routine will install EFI_PEI_PCI_CFG2_PPI. @@ -466,10 +308,10 @@ PeimInitializePciCfg ( { EFI_STATUS Status; - ASSERT ((**PeiServices).Hdr.Revision >= PEI_SERVICES_REVISION); + ASSERT ((**PeiServices).Hdr.Revision >= PI_SPECIFICATION_VERSION); (**(EFI_PEI_SERVICES **)PeiServices).PciCfg = &gPciCfg2Ppi; - Status = (**PeiServices).InstallPpi ((CONST EFI_PEI_SERVICES **)PeiServices, &gPciCfg2PpiList); + Status = (**PeiServices).InstallPpi (PeiServices, &gPciCfg2PpiList); return Status; }