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