]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/SnpDxe/shutdown.c
1. Sync the latest network stack. Add NetLibCreateIPv4DPathNode () in netlib library.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / shutdown.c
CommitLineData
8a67d61d 1/** @file\r
2Copyright (c) 2004 - 2007, Intel Corporation\r
3All rights reserved. This program and the accompanying materials\r
4are licensed and made available under the terms and conditions of the BSD License\r
5which accompanies this distribution. The full text of the license may be found at\r
6http://opensource.org/licenses/bsd-license.php\r
7\r
8THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
9WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
10\r
11Module name:\r
12 shutdown.c\r
13\r
14Abstract:\r
15\r
16Revision history:\r
17 2000-Feb-14 M(f)J Genesis.\r
18\r
19**/\r
20\r
21#include "Snp.h"\r
22\r
23\r
24/**\r
25 this routine calls undi to shut down the interface.\r
26\r
27 @param snp pointer to snp driver structure\r
28\r
29\r
30**/\r
31EFI_STATUS\r
32pxe_shutdown (\r
33 IN SNP_DRIVER *snp\r
34 )\r
35{\r
36 snp->cdb.OpCode = PXE_OPCODE_SHUTDOWN;\r
37 snp->cdb.OpFlags = PXE_OPFLAGS_NOT_USED;\r
38 snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r
39 snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;\r
40 snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r
41 snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;\r
42 snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;\r
43 snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r
44 snp->cdb.IFnum = snp->if_num;\r
45 snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r
46\r
47 //\r
48 // Issue UNDI command and check result.\r
49 //\r
50 DEBUG ((EFI_D_NET, "\nsnp->undi.shutdown() "));\r
51\r
52 (*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);\r
53\r
54 if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
55 //\r
56 // UNDI could not be shutdown. Return UNDI error.\r
57 //\r
58 DEBUG ((EFI_D_WARN, "\nsnp->undi.shutdown() %xh:%xh\n", snp->cdb.StatFlags, snp->cdb.StatCode));\r
59\r
60 return EFI_DEVICE_ERROR;\r
61 }\r
62 //\r
63 // Free allocated memory.\r
64 //\r
65 if (snp->tx_rx_buffer != NULL) {\r
66 snp->IoFncs->FreeBuffer (\r
67 snp->IoFncs,\r
68 SNP_MEM_PAGES (snp->tx_rx_bufsize),\r
69 (VOID *) snp->tx_rx_buffer\r
70 );\r
71 }\r
72\r
73 snp->tx_rx_buffer = NULL;\r
74 snp->tx_rx_bufsize = 0;\r
75\r
76 return EFI_SUCCESS;\r
77}\r
78\r
79\r
80/**\r
81 This is the SNP interface routine for shutting down the interface\r
82 This routine basically retrieves snp structure, checks the SNP state and\r
83 calls the pxe_shutdown routine to actually do the undi shutdown\r
84\r
85 @param this context pointer\r
86\r
87\r
88**/\r
89EFI_STATUS\r
90EFIAPI\r
91snp_undi32_shutdown (\r
92 IN EFI_SIMPLE_NETWORK_PROTOCOL *this\r
93 )\r
94{\r
95 SNP_DRIVER *snp;\r
96 EFI_STATUS Status;\r
97 EFI_TPL OldTpl;\r
98\r
99 //\r
100 //\r
101 //\r
102 if (this == NULL) {\r
103 return EFI_INVALID_PARAMETER;\r
104 }\r
105\r
106 snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);\r
107\r
108 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
109\r
110 //\r
111 //\r
112 //\r
113 switch (snp->mode.State) {\r
114 case EfiSimpleNetworkInitialized:\r
115 break;\r
116\r
117 case EfiSimpleNetworkStopped:\r
118 Status = EFI_NOT_STARTED;\r
119 goto ON_EXIT;\r
120\r
121 default:\r
122 Status = EFI_DEVICE_ERROR;\r
123 goto ON_EXIT;\r
124 }\r
125 //\r
126 //\r
127 //\r
128 Status = pxe_shutdown (snp);\r
129\r
130 snp->mode.State = EfiSimpleNetworkStarted;\r
131 snp->mode.ReceiveFilterSetting = 0;\r
132\r
133 snp->mode.MCastFilterCount = 0;\r
134 snp->mode.ReceiveFilterSetting = 0;\r
135 ZeroMem (snp->mode.MCastFilter, sizeof snp->mode.MCastFilter);\r
136 CopyMem (\r
137 &snp->mode.CurrentAddress,\r
138 &snp->mode.PermanentAddress,\r
139 sizeof (EFI_MAC_ADDRESS)\r
140 );\r
141\r
142 gBS->CloseEvent (snp->snp.WaitForPacket);\r
143\r
144ON_EXIT:\r
145 gBS->RestoreTPL (OldTpl);\r
146\r
147 return Status;\r
148}\r