TianoCore EDK2 master
Loading...
Searching...
No Matches
Shutdown.c
Go to the documentation of this file.
1
9#include "Snp.h"
10
22 IN SNP_DRIVER *Snp
23 )
24{
25 Snp->Cdb.OpCode = PXE_OPCODE_SHUTDOWN;
26 Snp->Cdb.OpFlags = PXE_OPFLAGS_NOT_USED;
27 Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
28 Snp->Cdb.DBsize = PXE_DBSIZE_NOT_USED;
29 Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
30 Snp->Cdb.DBaddr = PXE_DBADDR_NOT_USED;
31 Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;
32 Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
33 Snp->Cdb.IFnum = Snp->IfNum;
34 Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
35
36 //
37 // Issue UNDI command and check result.
38 //
39 DEBUG ((DEBUG_NET, "\nsnp->undi.shutdown() "));
40
41 (*Snp->IssueUndi32Command)((UINT64)(UINTN)&Snp->Cdb);
42
43 if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {
44 //
45 // UNDI could not be shutdown. Return UNDI error.
46 //
47 DEBUG ((DEBUG_WARN, "\nsnp->undi.shutdown() %xh:%xh\n", Snp->Cdb.StatFlags, Snp->Cdb.StatCode));
48
49 return EFI_DEVICE_ERROR;
50 }
51
52 //
53 // Free allocated memory.
54 //
55 if (Snp->TxRxBuffer != NULL) {
56 Snp->PciIo->FreeBuffer (
57 Snp->PciIo,
58 SNP_MEM_PAGES (Snp->TxRxBufferSize),
59 (VOID *)Snp->TxRxBuffer
60 );
61 }
62
63 Snp->TxRxBuffer = NULL;
64 Snp->TxRxBufferSize = 0;
65
66 return EFI_SUCCESS;
67}
68
89EFIAPI
92 )
93{
94 SNP_DRIVER *Snp;
95 EFI_STATUS Status;
96 EFI_TPL OldTpl;
97
98 //
99 // Get pointer to SNP driver instance for *This.
100 //
101 if (This == NULL) {
102 return EFI_INVALID_PARAMETER;
103 }
104
105 Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);
106
107 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
108
109 //
110 // Return error if the SNP is not initialized.
111 //
112 switch (Snp->Mode.State) {
113 case EfiSimpleNetworkInitialized:
114 break;
115
116 case EfiSimpleNetworkStopped:
117 Status = EFI_NOT_STARTED;
118 goto ON_EXIT;
119
120 default:
121 Status = EFI_DEVICE_ERROR;
122 goto ON_EXIT;
123 }
124
125 Status = PxeShutdown (Snp);
126
127 Snp->Mode.State = EfiSimpleNetworkStarted;
128 Snp->Mode.ReceiveFilterSetting = 0;
129
130 Snp->Mode.MCastFilterCount = 0;
131 Snp->Mode.ReceiveFilterSetting = 0;
132 ZeroMem (Snp->Mode.MCastFilter, sizeof Snp->Mode.MCastFilter);
133 CopyMem (
134 &Snp->Mode.CurrentAddress,
135 &Snp->Mode.PermanentAddress,
136 sizeof (EFI_MAC_ADDRESS)
137 );
138
139 gBS->CloseEvent (Snp->Snp.WaitForPacket);
140
141ON_EXIT:
142 gBS->RestoreTPL (OldTpl);
143
144 return Status;
145}
UINT64 UINTN
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define DEBUG(Expression)
Definition: DebugLib.h:434
EFI_STATUS EFIAPI SnpUndi32Shutdown(IN EFI_SIMPLE_NETWORK_PROTOCOL *This)
Definition: Shutdown.c:90
EFI_STATUS PxeShutdown(IN SNP_DRIVER *Snp)
Definition: Shutdown.c:21
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
UINTN EFI_TPL
Definition: UefiBaseType.h:41
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
#define PXE_CPBSIZE_NOT_USED
zero
Definition: UefiPxe.h:57
#define PXE_DBSIZE_NOT_USED
zero
Definition: UefiPxe.h:58
#define PXE_CPBADDR_NOT_USED
zero
Definition: UefiPxe.h:59
#define PXE_DBADDR_NOT_USED
zero
Definition: UefiPxe.h:60
#define PXE_STATCODE_SUCCESS
Definition: UefiPxe.h:602
#define PXE_OPCODE_SHUTDOWN
Definition: UefiPxe.h:120
EFI_MAC_ADDRESS CurrentAddress
EFI_MAC_ADDRESS MCastFilter[MAX_MCAST_FILTER_CNT]
EFI_MAC_ADDRESS PermanentAddress
Definition: Snp.h:55