]>
Commit | Line | Data |
---|---|---|
a1dbee50 | 1 | /** @file\r |
4cda7726 | 2 | Implementation of stopping a network interface.\r |
3 | \r | |
4 | Copyright (c) 2004 - 2007, Intel Corporation. <BR> \r | |
5 | All rights reserved. This program and the accompanying materials are licensed \r | |
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 | |
4cda7726 | 19 | this routine calls undi to stop the interface and changes the snp state.\r |
a1dbee50 | 20 | \r |
4cda7726 | 21 | @param Snp pointer to snp driver structure\r |
a1dbee50 | 22 | \r |
4cda7726 | 23 | @retval EFI_INVALID_PARAMETER invalid parameter\r |
24 | @retval EFI_NOT_STARTED SNP is not started\r | |
25 | @retval EFI_DEVICE_ERROR SNP is not initialized\r | |
26 | @retval EFI_UNSUPPORTED operation unsupported\r | |
a1dbee50 | 27 | \r |
28 | **/\r | |
29 | EFI_STATUS\r | |
4cda7726 | 30 | PxeStop (\r |
31 | SNP_DRIVER *Snp\r | |
a1dbee50 | 32 | )\r |
33 | {\r | |
4cda7726 | 34 | Snp->Cdb.OpCode = PXE_OPCODE_STOP;\r |
35 | Snp->Cdb.OpFlags = PXE_OPFLAGS_NOT_USED;\r | |
36 | Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r | |
37 | Snp->Cdb.DBsize = PXE_DBSIZE_NOT_USED;\r | |
38 | Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r | |
39 | Snp->Cdb.DBaddr = PXE_DBADDR_NOT_USED;\r | |
40 | Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;\r | |
41 | Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r | |
42 | Snp->Cdb.IFnum = Snp->IfNum;\r | |
43 | Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r | |
a1dbee50 | 44 | \r |
45 | //\r | |
46 | // Issue UNDI command\r | |
47 | //\r | |
48 | DEBUG ((EFI_D_NET, "\nsnp->undi.stop() "));\r | |
49 | \r | |
4cda7726 | 50 | (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r |
a1dbee50 | 51 | \r |
4cda7726 | 52 | if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r |
a1dbee50 | 53 | DEBUG (\r |
54 | (EFI_D_WARN,\r | |
55 | "\nsnp->undi.stop() %xh:%xh\n",\r | |
4cda7726 | 56 | Snp->Cdb.StatCode,\r |
57 | Snp->Cdb.StatFlags)\r | |
a1dbee50 | 58 | );\r |
59 | \r | |
60 | return EFI_DEVICE_ERROR;\r | |
61 | }\r | |
62 | //\r | |
63 | // Set simple network state to Started and return success.\r | |
64 | //\r | |
4cda7726 | 65 | Snp->Mode.State = EfiSimpleNetworkStopped;\r |
a1dbee50 | 66 | return EFI_SUCCESS;\r |
67 | }\r | |
68 | \r | |
69 | \r | |
70 | /**\r | |
4cda7726 | 71 | Changes the state of a network interface from "started" to "stopped."\r |
72 | \r | |
73 | This function stops a network interface. This call is only valid if the network\r | |
74 | interface is in the started state. If the network interface was successfully\r | |
75 | stopped, then EFI_SUCCESS will be returned.\r | |
76 | \r | |
77 | @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r | |
78 | \r | |
79 | \r | |
80 | @retval EFI_SUCCESS The network interface was stopped.\r | |
81 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
82 | @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid \r | |
83 | EFI_SIMPLE_NETWORK_PROTOCOL structure.\r | |
84 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
85 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r | |
a1dbee50 | 86 | \r |
87 | **/\r | |
88 | EFI_STATUS\r | |
89 | EFIAPI\r | |
4cda7726 | 90 | SnpUndi32Stop (\r |
91 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r | |
a1dbee50 | 92 | )\r |
93 | {\r | |
4cda7726 | 94 | SNP_DRIVER *Snp;\r |
a1dbee50 | 95 | EFI_TPL OldTpl;\r |
96 | EFI_STATUS Status;\r | |
97 | \r | |
4cda7726 | 98 | if (This == NULL) {\r |
a1dbee50 | 99 | return EFI_INVALID_PARAMETER;\r |
100 | }\r | |
101 | \r | |
4cda7726 | 102 | Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r |
a1dbee50 | 103 | \r |
104 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
105 | \r | |
4cda7726 | 106 | switch (Snp->Mode.State) {\r |
a1dbee50 | 107 | case EfiSimpleNetworkStarted:\r |
108 | break;\r | |
109 | \r | |
110 | case EfiSimpleNetworkStopped:\r | |
111 | Status = EFI_NOT_STARTED;\r | |
112 | goto ON_EXIT;\r | |
113 | \r | |
114 | default:\r | |
115 | Status = EFI_DEVICE_ERROR;\r | |
116 | goto ON_EXIT;\r | |
117 | }\r | |
118 | \r | |
4cda7726 | 119 | Status = PxeStop (Snp);\r |
a1dbee50 | 120 | \r |
121 | ON_EXIT:\r | |
122 | gBS->RestoreTPL (OldTpl);\r | |
123 | \r | |
124 | return Status;\r | |
125 | }\r |