From 89d413731dc99a509d4dc6e942e519ebdb0c3487 Mon Sep 17 00:00:00 2001 From: joe <37425738+JoeLopez333@users.noreply.github.com> Date: Mon, 14 Aug 2023 15:27:08 -0700 Subject: NetworkPkg/SnpDxe: Shutdown SnpDxe on BeforeExitBootServices Event. SnpDxe registers for an ExitBootServices callback and runs the PXE_OPCODE_SHUTDOWN and PXE_OPCODE_STOP commands for any network controllers that the driver is attached to. Register the SnpDxe callback for gEfiEventBeforeExitBootServicesGuid instead of gEfiEventExitBootServicesGuid to ensure the correct ordering: 1. ExitBootServices event 2. Network card shutdown sequence is completed Also, close the event to prevent rerunning the shutdown if multiple ExitBootServices events need to be called by the OS. Signed-off-by: Aaron Pop --- NetworkPkg/SnpDxe/Snp.c | 6 +++++- NetworkPkg/SnpDxe/SnpDxe.inf | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'NetworkPkg') diff --git a/NetworkPkg/SnpDxe/Snp.c b/NetworkPkg/SnpDxe/Snp.c index 95361c3cd3..09d6c8fc99 100644 --- a/NetworkPkg/SnpDxe/Snp.c +++ b/NetworkPkg/SnpDxe/Snp.c @@ -32,6 +32,10 @@ SnpNotifyExitBootServices ( // PxeShutdown (Snp); PxeStop (Snp); + + // Since BeforeExitBootServices is run on each call, close event + // to prevent reentry. + gBS->CloseEvent (Event); } /** @@ -655,7 +659,7 @@ SimpleNetworkDriverStart ( TPL_CALLBACK, SnpNotifyExitBootServices, Snp, - &gEfiEventExitBootServicesGuid, + &gEfiEventBeforeExitBootServicesGuid, &Snp->ExitBootServicesEvent ); if (EFI_ERROR (Status)) { diff --git a/NetworkPkg/SnpDxe/SnpDxe.inf b/NetworkPkg/SnpDxe/SnpDxe.inf index d16f1888b3..e1afd46dfe 100644 --- a/NetworkPkg/SnpDxe/SnpDxe.inf +++ b/NetworkPkg/SnpDxe/SnpDxe.inf @@ -65,7 +65,7 @@ NetLib [Guids] - gEfiEventExitBootServicesGuid ## SOMETIMES_CONSUMES ## Event + gEfiEventBeforeExitBootServicesGuid ## SOMETIMES_CONSUMES ## Event [Protocols] gEfiSimpleNetworkProtocolGuid ## BY_START -- cgit