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