Sounds like you may be doing it the hard (less portable) way in EFI.

Why not just use the PCI IO Protocols that where produced by the platforms PCI 
Bus driver. This is what the EFI PCI Drivers use.  

Take a look at the PCI chapter in the UEFI 2.3.1 spec. 

Andrew Fish


On Sep 7, 2012, at 12:59 PM, Rafael Machado wrote:

> Hi everyone
> 
> I have a question.
> On my project I need to check all PCIe functions on each bus, so I have a 
> loop from bus 0 to the max bus number.
> This max bus number I get from acpi table.
> 
> This is done here:
> 
> EFI_STATUS
> PciGetNextBusRange (
>   IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  **Descriptors,
>   OUT    UINT16                             *MinBus,
>   OUT    UINT16                             *MaxBus,
>   OUT    BOOLEAN                            *IsEnd
>   )
> {
>   *IsEnd = FALSE;
> 
>   //
>   // When *Descriptors is NULL, Configuration() is not implemented, so assume
>   // range is 0~PCI_MAX_BUS
>   //
>   if ((*Descriptors) == NULL) {
>     *MinBus = 0;
>     *MaxBus = PCI_MAX_BUS;
>     return EFI_SUCCESS;
>   }
>   //
>   // *Descriptors points to one or more address space descriptors, which
>   // ends with a end tagged descriptor. Examine each of the descriptors,
>   // if a bus typed one is found and its bus range covers bus, this handle
>   // is the handle we are looking for.
>   //
> 
>   while ((*Descriptors)->Desc != ACPI_END_TAG_DESCRIPTOR) {
>     if ((*Descriptors)->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) {
>       *MinBus = (UINT16) (*Descriptors)->AddrRangeMin;
>       *MaxBus = (UINT16) (*Descriptors)->AddrRangeMax;
>       (*Descriptors)++;
>       return (EFI_SUCCESS);
>     }
> 
>     (*Descriptors)++;
>   }
> 
>   if ((*Descriptors)->Desc == ACPI_END_TAG_DESCRIPTOR) {
>     *IsEnd = TRUE;
>   }
> 
>   return EFI_SUCCESS;
> }
> 
> The problem is that on a nootbook, that has devices and functions up to bus 
> 0x7f, this function returns just 0x0A,
> so I dont check everything I need.
> 
> Do I need to change something at this code, so I can get the correct max bus 
> number ? (0x7f instead of 0xA)
> 
> Thanks and Regards
> Rafael R. Machado
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. 
> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to