summaryrefslogtreecommitdiffstats
path: root/NetworkPkg
diff options
context:
space:
mode:
authorjoe <37425738+JoeLopez333@users.noreply.github.com>2023-08-14 15:27:08 -0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-01-17 01:43:51 +0000
commit89d413731dc99a509d4dc6e942e519ebdb0c3487 (patch)
treeb25532bd8f1a1420ae33159313a61259db2a47cd /NetworkPkg
parentc1548908c9e0873c77a59ee647a7dd6bdf833acf (diff)
downloadedk2-89d413731dc99a509d4dc6e942e519ebdb0c3487.tar.gz
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 <aaronpop@microsoft.com>
Diffstat (limited to 'NetworkPkg')
-rw-r--r--NetworkPkg/SnpDxe/Snp.c6
-rw-r--r--NetworkPkg/SnpDxe/SnpDxe.inf2
2 files changed, 6 insertions, 2 deletions
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