]>
Commit | Line | Data |
---|---|---|
a1dbee50 | 1 | /** @file\r |
4cda7726 | 2 | Implementation of stopping a network interface.\r |
3 | \r | |
e5eed7d3 HT |
4 | Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials are licensed \r | |
4cda7726 | 6 | and made available under the terms and conditions of the BSD License which \r |
7 | accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
a1dbee50 | 9 | \r |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
a1dbee50 | 13 | **/\r |
14 | \r | |
15 | #include "Snp.h"\r | |
16 | \r | |
17 | \r | |
18 | /**\r | |
f3816027 | 19 | Call UNDI to stop the interface and changes the snp state.\r |
a1dbee50 | 20 | \r |
f3816027 | 21 | @param Snp Pointer to snp driver structure\r |
22 | \r | |
23 | @retval EFI_SUCCESS The network interface was stopped.\r | |
24 | @retval EFI_DEVICE_ERROR SNP is not initialized.\r | |
a1dbee50 | 25 | \r |
26 | **/\r | |
27 | EFI_STATUS\r | |
4cda7726 | 28 | PxeStop (\r |
29 | SNP_DRIVER *Snp\r | |
a1dbee50 | 30 | )\r |
31 | {\r | |
4cda7726 | 32 | Snp->Cdb.OpCode = PXE_OPCODE_STOP;\r |
33 | Snp->Cdb.OpFlags = PXE_OPFLAGS_NOT_USED;\r | |
34 | Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r | |
35 | Snp->Cdb.DBsize = PXE_DBSIZE_NOT_USED;\r | |
36 | Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r | |
37 | Snp->Cdb.DBaddr = PXE_DBADDR_NOT_USED;\r | |
38 | Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;\r | |
39 | Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r | |
40 | Snp->Cdb.IFnum = Snp->IfNum;\r | |
41 | Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r | |
a1dbee50 | 42 | \r |
43 | //\r | |
44 | // Issue UNDI command\r | |
45 | //\r | |
9cff2f8d | 46 | DEBUG ((EFI_D_NET, "\nsnp->undi.stop() "));\r |
a1dbee50 | 47 | \r |
4cda7726 | 48 | (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r |
a1dbee50 | 49 | \r |
4cda7726 | 50 | if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r |
a1dbee50 | 51 | DEBUG (\r |
9cff2f8d | 52 | (EFI_D_WARN,\r |
a1dbee50 | 53 | "\nsnp->undi.stop() %xh:%xh\n",\r |
4cda7726 | 54 | Snp->Cdb.StatCode,\r |
55 | Snp->Cdb.StatFlags)\r | |
a1dbee50 | 56 | );\r |
57 | \r | |
58 | return EFI_DEVICE_ERROR;\r | |
59 | }\r | |
60 | //\r | |
61 | // Set simple network state to Started and return success.\r | |
62 | //\r | |
4cda7726 | 63 | Snp->Mode.State = EfiSimpleNetworkStopped;\r |
a1dbee50 | 64 | return EFI_SUCCESS;\r |
65 | }\r | |
66 | \r | |
67 | \r | |
68 | /**\r | |
4cda7726 | 69 | Changes the state of a network interface from "started" to "stopped."\r |
70 | \r | |
71 | This function stops a network interface. This call is only valid if the network\r | |
72 | interface is in the started state. If the network interface was successfully\r | |
73 | stopped, then EFI_SUCCESS will be returned.\r | |
74 | \r | |
f3816027 | 75 | @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL \r |
76 | instance.\r | |
4cda7726 | 77 | \r |
78 | \r | |
79 | @retval EFI_SUCCESS The network interface was stopped.\r | |
80 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
f3816027 | 81 | @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a \r |
82 | valid EFI_SIMPLE_NETWORK_PROTOCOL structure.\r | |
83 | @retval EFI_DEVICE_ERROR The command could not be sent to the network \r | |
84 | interface.\r | |
85 | @retval EFI_UNSUPPORTED This function is not supported by the network \r | |
86 | interface.\r | |
a1dbee50 | 87 | \r |
88 | **/\r | |
89 | EFI_STATUS\r | |
90 | EFIAPI\r | |
4cda7726 | 91 | SnpUndi32Stop (\r |
92 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r | |
a1dbee50 | 93 | )\r |
94 | {\r | |
4cda7726 | 95 | SNP_DRIVER *Snp;\r |
a1dbee50 | 96 | EFI_TPL OldTpl;\r |
97 | EFI_STATUS Status;\r | |
98 | \r | |
4cda7726 | 99 | if (This == NULL) {\r |
a1dbee50 | 100 | return EFI_INVALID_PARAMETER;\r |
101 | }\r | |
102 | \r | |
4cda7726 | 103 | Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r |
a1dbee50 | 104 | \r |
105 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
106 | \r | |
4cda7726 | 107 | switch (Snp->Mode.State) {\r |
a1dbee50 | 108 | case EfiSimpleNetworkStarted:\r |
109 | break;\r | |
110 | \r | |
111 | case EfiSimpleNetworkStopped:\r | |
112 | Status = EFI_NOT_STARTED;\r | |
113 | goto ON_EXIT;\r | |
114 | \r | |
115 | default:\r | |
116 | Status = EFI_DEVICE_ERROR;\r | |
117 | goto ON_EXIT;\r | |
118 | }\r | |
119 | \r | |
4cda7726 | 120 | Status = PxeStop (Snp);\r |
a1dbee50 | 121 | \r |
122 | ON_EXIT:\r | |
123 | gBS->RestoreTPL (OldTpl);\r | |
124 | \r | |
125 | return Status;\r | |
126 | }\r |