2 Copyright (c) 2004 - 2007, Intel Corporation
3 All rights reserved. This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 2000-Feb-07 M(f)J Genesis.
25 this routine calls undi to start the interface and changes the snp state!
27 @param snp pointer to snp driver structure
36 PXE_CPB_START_31
*cpb_31
;
40 // Initialize UNDI Start CDB for H/W UNDI
42 snp
->cdb
.OpCode
= PXE_OPCODE_START
;
43 snp
->cdb
.OpFlags
= PXE_OPFLAGS_NOT_USED
;
44 snp
->cdb
.CPBsize
= PXE_CPBSIZE_NOT_USED
;
45 snp
->cdb
.DBsize
= PXE_DBSIZE_NOT_USED
;
46 snp
->cdb
.CPBaddr
= PXE_CPBADDR_NOT_USED
;
47 snp
->cdb
.DBaddr
= PXE_DBADDR_NOT_USED
;
48 snp
->cdb
.StatCode
= PXE_STATCODE_INITIALIZE
;
49 snp
->cdb
.StatFlags
= PXE_STATFLAGS_INITIALIZE
;
50 snp
->cdb
.IFnum
= snp
->if_num
;
51 snp
->cdb
.Control
= PXE_CONTROL_LAST_CDB_IN_LIST
;
54 // Make changes to H/W UNDI Start CDB if this is
58 snp
->cdb
.CPBsize
= sizeof (PXE_CPB_START_31
);
59 snp
->cdb
.CPBaddr
= (UINT64
)(UINTN
) cpb_31
;
61 cpb_31
->Delay
= (UINT64
)(UINTN
) &snp_undi32_callback_delay
;
62 cpb_31
->Block
= (UINT64
)(UINTN
) &snp_undi32_callback_block
;
65 // Virtual == Physical. This can be set to zero.
67 cpb_31
->Virt2Phys
= (UINT64
)(UINTN
) 0;
68 cpb_31
->Mem_IO
= (UINT64
)(UINTN
) &snp_undi32_callback_memio
;
70 cpb_31
->Map_Mem
= (UINT64
)(UINTN
) &snp_undi32_callback_map
;
71 cpb_31
->UnMap_Mem
= (UINT64
)(UINTN
) &snp_undi32_callback_unmap
;
72 cpb_31
->Sync_Mem
= (UINT64
)(UINTN
) &snp_undi32_callback_sync
;
74 cpb_31
->Unique_ID
= (UINT64
)(UINTN
) snp
;
77 // Issue UNDI command and check result.
79 DEBUG ((EFI_D_NET
, "\nsnp->undi.start() "));
81 (*snp
->issue_undi32_command
) ((UINT64
)(UINTN
) &snp
->cdb
);
83 if (snp
->cdb
.StatCode
!= PXE_STATCODE_SUCCESS
) {
85 // UNDI could not be started. Return UNDI error.
89 "\nsnp->undi.start() %xh:%xh\n",
94 return EFI_DEVICE_ERROR
;
97 // Set simple network state to Started and return success.
99 snp
->mode
.State
= EfiSimpleNetworkStarted
;
106 This is the SNP interface routine for starting the interface
107 This routine basically retrieves snp structure, checks the SNP state and
108 calls the pxe_start routine to actually do start undi interface
110 @param This context pointer
112 @retval EFI_INVALID_PARAMETER "This" is Null
113 @retval No SNP driver can be extracted from "This"
114 @retval EFI_ALREADY_STARTED The state of SNP is EfiSimpleNetworkStarted or
115 EfiSimpleNetworkInitialized
116 @retval EFI_DEVICE_ERROR The state of SNP is other than
117 EfiSimpleNetworkStarted,
118 EfiSimpleNetworkInitialized, and
119 EfiSimpleNetworkStopped
120 @retval EFI_SUCCESS UNDI interface is succesfully started
121 @retval Other Error occurs while calling pxe_start function.
127 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
136 return EFI_INVALID_PARAMETER
;
139 Snp
= EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This
);
141 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
143 switch (Snp
->mode
.State
) {
144 case EfiSimpleNetworkStopped
:
147 case EfiSimpleNetworkStarted
:
148 case EfiSimpleNetworkInitialized
:
149 Status
= EFI_ALREADY_STARTED
;
153 Status
= EFI_DEVICE_ERROR
;
157 Status
= pxe_start (Snp
);
158 if (EFI_ERROR (Status
)) {
162 // clear the map_list in SNP structure
164 for (Index
= 0; Index
< MAX_MAP_LENGTH
; Index
++) {
165 Snp
->map_list
[Index
].virt
= 0;
166 Snp
->map_list
[Index
].map_cookie
= 0;
169 Snp
->mode
.MCastFilterCount
= 0;
172 gBS
->RestoreTPL (OldTpl
);