Skip to content

Commit

Permalink
NetworkPkg/SnpDxe: Shutdown SnpDxe on BeforeExitBootServices Event.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
JoeLopez333 authored and apop5 committed Jul 31, 2024
1 parent f8f34ed commit 3f0c329
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion NetworkPkg/SnpDxe/Snp.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ SnpNotifyExitBootServices (
//
PxeShutdown (Snp);
PxeStop (Snp);

// Since BeforeExitBootServices is run on each call, close event
// to prevent reentry.
gBS->CloseEvent (Event);
}

/**
Expand Down Expand Up @@ -655,7 +659,7 @@ SimpleNetworkDriverStart (
TPL_CALLBACK,
SnpNotifyExitBootServices,
Snp,
&gEfiEventExitBootServicesGuid,
&gEfiEventBeforeExitBootServicesGuid,
&Snp->ExitBootServicesEvent
);
if (EFI_ERROR (Status)) {
Expand Down
2 changes: 1 addition & 1 deletion NetworkPkg/SnpDxe/SnpDxe.inf
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
NetLib

[Guids]
gEfiEventExitBootServicesGuid ## SOMETIMES_CONSUMES ## Event
gEfiEventBeforeExitBootServicesGuid ## SOMETIMES_CONSUMES ## Event

[Protocols]
gEfiSimpleNetworkProtocolGuid ## BY_START
Expand Down

0 comments on commit 3f0c329

Please sign in to comment.