2 Implementation of starting a network adapter.
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
13 Call UNDI to start the interface and changes the snp state.
15 @param Snp pointer to snp driver structure.
17 @retval EFI_SUCCESS UNDI is started successfully.
18 @retval EFI_DEVICE_ERROR UNDI could not be started.
26 PXE_CPB_START_31
*Cpb31
;
30 // Initialize UNDI Start CDB for H/W UNDI
32 Snp
->Cdb
.OpCode
= PXE_OPCODE_START
;
33 Snp
->Cdb
.OpFlags
= PXE_OPFLAGS_NOT_USED
;
34 Snp
->Cdb
.CPBsize
= PXE_CPBSIZE_NOT_USED
;
35 Snp
->Cdb
.DBsize
= PXE_DBSIZE_NOT_USED
;
36 Snp
->Cdb
.CPBaddr
= PXE_CPBADDR_NOT_USED
;
37 Snp
->Cdb
.DBaddr
= PXE_DBADDR_NOT_USED
;
38 Snp
->Cdb
.StatCode
= PXE_STATCODE_INITIALIZE
;
39 Snp
->Cdb
.StatFlags
= PXE_STATFLAGS_INITIALIZE
;
40 Snp
->Cdb
.IFnum
= Snp
->IfNum
;
41 Snp
->Cdb
.Control
= PXE_CONTROL_LAST_CDB_IN_LIST
;
44 // Make changes to H/W UNDI Start CDB if this is
48 Snp
->Cdb
.CPBsize
= (UINT16
) sizeof (PXE_CPB_START_31
);
49 Snp
->Cdb
.CPBaddr
= (UINT64
)(UINTN
) Cpb31
;
51 Cpb31
->Delay
= (UINT64
)(UINTN
) &SnpUndi32CallbackDelay
;
52 Cpb31
->Block
= (UINT64
)(UINTN
) &SnpUndi32CallbackBlock
;
55 // Virtual == Physical. This can be set to zero.
57 Cpb31
->Virt2Phys
= (UINT64
)(UINTN
) 0;
58 Cpb31
->Mem_IO
= (UINT64
)(UINTN
) &SnpUndi32CallbackMemio
;
60 Cpb31
->Map_Mem
= (UINT64
)(UINTN
) &SnpUndi32CallbackMap
;
61 Cpb31
->UnMap_Mem
= (UINT64
)(UINTN
) &SnpUndi32CallbackUnmap
;
62 Cpb31
->Sync_Mem
= (UINT64
)(UINTN
) &SnpUndi32CallbackSync
;
64 Cpb31
->Unique_ID
= (UINT64
)(UINTN
) Snp
;
67 // Issue UNDI command and check result.
69 DEBUG ((EFI_D_NET
, "\nsnp->undi.start() "));
71 (*Snp
->IssueUndi32Command
) ((UINT64
)(UINTN
) &Snp
->Cdb
);
73 if (Snp
->Cdb
.StatCode
!= PXE_STATCODE_SUCCESS
) {
75 // UNDI could not be started. Return UNDI error.
79 "\nsnp->undi.start() %xh:%xh\n",
84 return EFI_DEVICE_ERROR
;
87 // Set simple network state to Started and return success.
89 Snp
->Mode
.State
= EfiSimpleNetworkStarted
;
96 Change the state of a network interface from "stopped" to "started."
98 This function starts a network interface. If the network interface successfully
99 starts, then EFI_SUCCESS will be returned.
101 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
103 @retval EFI_SUCCESS The network interface was started.
104 @retval EFI_ALREADY_STARTED The network interface is already in the started state.
105 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid
106 EFI_SIMPLE_NETWORK_PROTOCOL structure.
107 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
108 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
114 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
123 return EFI_INVALID_PARAMETER
;
126 Snp
= EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This
);
128 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
130 switch (Snp
->Mode
.State
) {
131 case EfiSimpleNetworkStopped
:
134 case EfiSimpleNetworkStarted
:
135 case EfiSimpleNetworkInitialized
:
136 Status
= EFI_ALREADY_STARTED
;
140 Status
= EFI_DEVICE_ERROR
;
144 Status
= PxeStart (Snp
);
145 if (EFI_ERROR (Status
)) {
149 // clear the map_list in SNP structure
151 for (Index
= 0; Index
< MAX_MAP_LENGTH
; Index
++) {
152 Snp
->MapList
[Index
].VirtualAddress
= 0;
153 Snp
->MapList
[Index
].MapCookie
= 0;
156 Snp
->Mode
.MCastFilterCount
= 0;
159 gBS
->RestoreTPL (OldTpl
);