From fc7239bdc8384d02a190723ef4e030d6ef2620a9 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 29 Mar 2011 21:35:06 +0100 Subject: [efi] Ensure that all drivers are shut down before the OS boots Reported-by: Itay Gazit Suggested-by: Michael R Turner Signed-off-by: Michael Brown --- src/interface/efi/efi_pci.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/interface/efi/efi_pci.c') diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index 3b393fcbe..fa71e7d84 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -489,7 +489,7 @@ static struct efi_driver efipci_driver = * Install EFI PCI driver * */ -static void efipci_driver_init ( void ) { +static void efipci_driver_startup ( void ) { struct efi_driver *efidrv = &efipci_driver; EFI_STATUS efirc; @@ -503,7 +503,27 @@ static void efipci_driver_init ( void ) { DBGC ( efidrv, "EFIPCI driver installed\n" ); } +/** + * Shut down EFI PCI driver + * + * @v booting System is shutting down for OS boot + */ +static void efipci_driver_shutdown ( int booting __unused ) { + struct efi_driver *efidrv = &efipci_driver; + struct efi_pci_device *efipci; + struct efi_pci_device *tmp; + + /* Shut down any remaining devices */ + list_for_each_entry_safe ( efipci, tmp, &efi_pci_devices, list ) { + DBGC ( efipci, "EFIPCI " PCI_FMT " still active at shutdown; " + "forcing close\n", PCI_ARGS ( &efipci->pci ) ); + pci_remove ( &efipci->pci ); + efipci_destroy ( efidrv, efipci ); + } +} + /** EFI PCI startup function */ struct startup_fn startup_pci __startup_fn ( STARTUP_NORMAL ) = { - .startup = efipci_driver_init, + .startup = efipci_driver_startup, + .shutdown = efipci_driver_shutdown, }; -- cgit v1.2.3-55-g7522