X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FBus%2FPci%2FNonDiscoverablePciDeviceDxe%2FNonDiscoverablePciDeviceDxe.c;h=2483c7296912ea5d87044e2b52a9f4c345b9d0c2;hp=0fcf2b2ec1bf9ef9268c9e40d33bce66b7041433;hb=1a3bee20820c9f68a235a31ccc92db1f299266c9;hpb=16296a126c99174ad27a6d78229df70e62049310 diff --git a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c index 0fcf2b2ec1..2483c72969 100644 --- a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c +++ b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c @@ -16,6 +16,9 @@ #include +#define MAX_NON_DISCOVERABLE_PCI_DEVICE_ID (32 * 256) + +STATIC UINTN mUniqueIdCounter = 0; EFI_CPU_ARCH_PROTOCOL *mCpu; // @@ -23,7 +26,7 @@ EFI_CPU_ARCH_PROTOCOL *mCpu; // STATIC CONST EFI_GUID * CONST -SupportedNonDiscoverableDevices [] = { +SupportedNonDiscoverableDevices[] = { &gEdkiiNonDiscoverableAhciDeviceGuid, &gEdkiiNonDiscoverableEhciDeviceGuid, &gEdkiiNonDiscoverableNvmeDeviceGuid, @@ -49,6 +52,19 @@ SupportedNonDiscoverableDevices [] = { // - 6.3 Protocol Handler Services // +/** + Supported function of Driver Binding protocol for this driver. + Test to see if this driver supports ControllerHandle. + + @param This Protocol instance pointer. + @param DeviceHandle Handle of device to test. + @param RemainingDevicePath A pointer to the device path. + it should be ignored by device driver. + + @retval EFI_SUCCESS This driver supports this device. + @retval other This driver does not support this device. + +**/ STATIC EFI_STATUS EFIAPI @@ -103,6 +119,19 @@ CloseProtocol: return Status; } +/** + This routine is called right after the .Supported() called and + Start this driver on ControllerHandle. + + @param This Protocol instance pointer. + @param DeviceHandle Handle of device to bind driver to. + @param RemainingDevicePath A pointer to the device path. + it should be ignored by device driver. + + @retval EFI_SUCCESS This driver is added to this device. + @retval other Some error occurs when binding this driver to this device. + +**/ STATIC EFI_STATUS EFIAPI @@ -115,6 +144,11 @@ NonDiscoverablePciDeviceStart ( NON_DISCOVERABLE_PCI_DEVICE *Dev; EFI_STATUS Status; + ASSERT (mUniqueIdCounter < MAX_NON_DISCOVERABLE_PCI_DEVICE_ID); + if (mUniqueIdCounter >= MAX_NON_DISCOVERABLE_PCI_DEVICE_ID) { + return EFI_OUT_OF_RESOURCES; + } + Dev = AllocateZeroPool (sizeof *Dev); if (Dev == NULL) { return EFI_OUT_OF_RESOURCES; @@ -141,6 +175,8 @@ NonDiscoverablePciDeviceStart ( goto CloseProtocol; } + Dev->UniqueId = mUniqueIdCounter++; + return EFI_SUCCESS; CloseProtocol: @@ -153,7 +189,18 @@ FreeDev: return Status; } +/** + Stop this driver on ControllerHandle. + + @param This Protocol instance pointer. + @param DeviceHandle Handle of device to stop driver on. + @param NumberOfChildren Not used. + @param ChildHandleBuffer Not used. + @retval EFI_SUCCESS This driver is removed from this device. + @retval other Some error occurs when removing this driver from this device. + +**/ STATIC EFI_STATUS EFIAPI @@ -209,9 +256,16 @@ STATIC EFI_DRIVER_BINDING_PROTOCOL gDriverBinding = { NULL }; -// -// Entry point of this driver. -// +/** + Entry point of this driver. + + @param ImageHandle Image handle this driver. + @param SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval other Some error occurred when executing this entry point. + +**/ EFI_STATUS EFIAPI NonDiscoverablePciDeviceDxeEntryPoint (