mirror of
https://github.com/ipxe/ipxe
synced 2025-12-16 17:41:18 +03:00
[efi] Ensure that all drivers are shut down before the OS boots
Reported-by: Itay Gazit <itayg@mellanox.co.il> Suggested-by: Michael R Turner <mikeyt@us.ibm.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -26,20 +26,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
|
||||
FEATURE ( FEATURE_IMAGE, "EFI", DHCP_EB_FEATURE_EFI, 1 );
|
||||
|
||||
/** Event used to signal shutdown */
|
||||
static EFI_EVENT efi_shutdown_event;
|
||||
|
||||
/**
|
||||
* Shut down in preparation for booting an OS.
|
||||
*
|
||||
* This hook gets called at ExitBootServices time in order to make sure that
|
||||
* the network cards are properly shut down before the OS takes over.
|
||||
*/
|
||||
static EFIAPI void efi_shutdown_hook ( EFI_EVENT event __unused,
|
||||
void *context __unused ) {
|
||||
shutdown_boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute EFI image
|
||||
*
|
||||
@@ -64,30 +50,14 @@ static int efi_image_exec ( struct image *image ) {
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
/* Be sure to shut down the NIC at ExitBootServices time, or else
|
||||
* DMA from the card can corrupt the OS.
|
||||
*/
|
||||
efirc = bs->CreateEvent ( EVT_SIGNAL_EXIT_BOOT_SERVICES,
|
||||
TPL_CALLBACK, efi_shutdown_hook,
|
||||
NULL, &efi_shutdown_event );
|
||||
if ( efirc ) {
|
||||
rc = EFIRC_TO_RC ( efirc );
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Start the image */
|
||||
if ( ( efirc = bs->StartImage ( handle, &exit_data_size,
|
||||
&exit_data ) ) != 0 ) {
|
||||
DBGC ( image, "EFIIMAGE %p returned with status %s\n",
|
||||
image, efi_strerror ( efirc ) );
|
||||
}
|
||||
|
||||
rc = EFIRC_TO_RC ( efirc );
|
||||
|
||||
/* Remove the shutdown hook */
|
||||
bs->CloseEvent ( efi_shutdown_event );
|
||||
|
||||
done:
|
||||
/* Unload the image. We can't leave it loaded, because we
|
||||
* have no "unload" operation.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user