1 | /** @file
|
---|
2 | Implementation of resetting a network adapter.
|
---|
3 |
|
---|
4 | Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #include "Snp.h"
|
---|
10 |
|
---|
11 |
|
---|
12 | /**
|
---|
13 | Call UNDI to reset the NIC.
|
---|
14 |
|
---|
15 | @param Snp Pointer to the snp driver structure.
|
---|
16 |
|
---|
17 | @return EFI_SUCCESSFUL The NIC was reset.
|
---|
18 | @retval EFI_DEVICE_ERROR The NIC cannot be reset.
|
---|
19 |
|
---|
20 | **/
|
---|
21 | EFI_STATUS
|
---|
22 | PxeReset (
|
---|
23 | SNP_DRIVER *Snp
|
---|
24 | )
|
---|
25 | {
|
---|
26 | Snp->Cdb.OpCode = PXE_OPCODE_RESET;
|
---|
27 | Snp->Cdb.OpFlags = PXE_OPFLAGS_NOT_USED;
|
---|
28 | Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
|
---|
29 | Snp->Cdb.DBsize = PXE_DBSIZE_NOT_USED;
|
---|
30 | Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
|
---|
31 | Snp->Cdb.DBaddr = PXE_DBADDR_NOT_USED;
|
---|
32 | Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;
|
---|
33 | Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
|
---|
34 | Snp->Cdb.IFnum = Snp->IfNum;
|
---|
35 | Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
|
---|
36 |
|
---|
37 | //
|
---|
38 | // Issue UNDI command and check result.
|
---|
39 | //
|
---|
40 | DEBUG ((EFI_D_NET, "\nsnp->undi.reset() "));
|
---|
41 |
|
---|
42 | (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);
|
---|
43 |
|
---|
44 | if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {
|
---|
45 | DEBUG (
|
---|
46 | (EFI_D_WARN,
|
---|
47 | "\nsnp->undi32.reset() %xh:%xh\n",
|
---|
48 | Snp->Cdb.StatFlags,
|
---|
49 | Snp->Cdb.StatCode)
|
---|
50 | );
|
---|
51 |
|
---|
52 | //
|
---|
53 | // UNDI could not be reset. Return UNDI error.
|
---|
54 | //
|
---|
55 | return EFI_DEVICE_ERROR;
|
---|
56 | }
|
---|
57 |
|
---|
58 | return EFI_SUCCESS;
|
---|
59 | }
|
---|
60 |
|
---|
61 |
|
---|
62 | /**
|
---|
63 | Resets a network adapter and reinitializes it with the parameters that were
|
---|
64 | provided in the previous call to Initialize().
|
---|
65 |
|
---|
66 | This function resets a network adapter and reinitializes it with the parameters
|
---|
67 | that were provided in the previous call to Initialize(). The transmit and
|
---|
68 | receive queues are emptied and all pending interrupts are cleared.
|
---|
69 | Receive filters, the station address, the statistics, and the multicast-IP-to-HW
|
---|
70 | MAC addresses are not reset by this call. If the network interface was
|
---|
71 | successfully reset, then EFI_SUCCESS will be returned. If the driver has not
|
---|
72 | been initialized, EFI_DEVICE_ERROR will be returned.
|
---|
73 |
|
---|
74 | @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
|
---|
75 | @param ExtendedVerification Indicates that the driver may perform a more
|
---|
76 | exhaustive verification operation of the device
|
---|
77 | during reset.
|
---|
78 |
|
---|
79 | @retval EFI_SUCCESS The network interface was reset.
|
---|
80 | @retval EFI_NOT_STARTED The network interface has not been started.
|
---|
81 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
|
---|
82 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
|
---|
83 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.
|
---|
84 |
|
---|
85 | **/
|
---|
86 | EFI_STATUS
|
---|
87 | EFIAPI
|
---|
88 | SnpUndi32Reset (
|
---|
89 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
|
---|
90 | IN BOOLEAN ExtendedVerification
|
---|
91 | )
|
---|
92 | {
|
---|
93 | SNP_DRIVER *Snp;
|
---|
94 | EFI_TPL OldTpl;
|
---|
95 | EFI_STATUS Status;
|
---|
96 |
|
---|
97 | //
|
---|
98 | // Resolve Warning 4 unreferenced parameter problem
|
---|
99 | //
|
---|
100 | ExtendedVerification = 0;
|
---|
101 | DEBUG ((EFI_D_WARN, "ExtendedVerification = %d is not implemented!\n", ExtendedVerification));
|
---|
102 |
|
---|
103 | if (This == NULL) {
|
---|
104 | return EFI_INVALID_PARAMETER;
|
---|
105 | }
|
---|
106 |
|
---|
107 | Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);
|
---|
108 |
|
---|
109 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
---|
110 |
|
---|
111 | switch (Snp->Mode.State) {
|
---|
112 | case EfiSimpleNetworkInitialized:
|
---|
113 | break;
|
---|
114 |
|
---|
115 | case EfiSimpleNetworkStopped:
|
---|
116 | Status = EFI_NOT_STARTED;
|
---|
117 | goto ON_EXIT;
|
---|
118 |
|
---|
119 | default:
|
---|
120 | Status = EFI_DEVICE_ERROR;
|
---|
121 | goto ON_EXIT;
|
---|
122 | }
|
---|
123 |
|
---|
124 | Status = PxeReset (Snp);
|
---|
125 |
|
---|
126 | ON_EXIT:
|
---|
127 | gBS->RestoreTPL (OldTpl);
|
---|
128 |
|
---|
129 | return Status;
|
---|
130 | }
|
---|