2 Copyright (c) 2006, 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.
30 this routine calls undi to start the interface and changes the snp state!
33 snp - pointer to snp driver structure
39 PXE_CPB_START_30
*cpb
;
40 PXE_CPB_START_31
*cpb_31
;
45 // Initialize UNDI Start CDB for H/W UNDI
47 snp
->cdb
.OpCode
= PXE_OPCODE_START
;
48 snp
->cdb
.OpFlags
= PXE_OPFLAGS_NOT_USED
;
49 snp
->cdb
.CPBsize
= PXE_CPBSIZE_NOT_USED
;
50 snp
->cdb
.DBsize
= PXE_DBSIZE_NOT_USED
;
51 snp
->cdb
.CPBaddr
= PXE_CPBADDR_NOT_USED
;
52 snp
->cdb
.DBaddr
= PXE_DBADDR_NOT_USED
;
53 snp
->cdb
.StatCode
= PXE_STATCODE_INITIALIZE
;
54 snp
->cdb
.StatFlags
= PXE_STATFLAGS_INITIALIZE
;
55 snp
->cdb
.IFnum
= snp
->if_num
;
56 snp
->cdb
.Control
= PXE_CONTROL_LAST_CDB_IN_LIST
;
59 // Make changes to H/W UNDI Start CDB if this is
64 snp
->cdb
.CPBsize
= sizeof (PXE_CPB_START_30
);
65 snp
->cdb
.CPBaddr
= (UINT64
) (UINTN
) cpb
;
67 cpb
->Delay
= (UINT64
) &snp_undi32_callback_delay_30
;
68 cpb
->Block
= (UINT64
) &snp_undi32_callback_block_30
;
71 // Virtual == Physical. This can be set to zero.
73 cpb
->Virt2Phys
= (UINT64
) &snp_undi32_callback_v2p_30
;
74 cpb
->Mem_IO
= (UINT64
) &snp_undi32_callback_memio_30
;
76 snp
->cdb
.CPBsize
= sizeof (PXE_CPB_START_31
);
77 snp
->cdb
.CPBaddr
= (UINT64
) (UINTN
) cpb_31
;
79 cpb_31
->Delay
= (UINT64
) &snp_undi32_callback_delay
;
80 cpb_31
->Block
= (UINT64
) &snp_undi32_callback_block
;
83 // Virtual == Physical. This can be set to zero.
85 cpb_31
->Virt2Phys
= (UINT64
) 0;
86 cpb_31
->Mem_IO
= (UINT64
) &snp_undi32_callback_memio
;
88 cpb_31
->Map_Mem
= (UINT64
) &snp_undi32_callback_map
;
89 cpb_31
->UnMap_Mem
= (UINT64
) &snp_undi32_callback_unmap
;
90 cpb_31
->Sync_Mem
= (UINT64
) &snp_undi32_callback_sync
;
92 cpb_31
->Unique_ID
= (UINT64
) (UINTN
) snp
;
96 // Issue UNDI command and check result.
98 DEBUG ((EFI_D_NET
, "\nsnp->undi.start() "));
100 (*snp
->issue_undi32_command
) ((UINT64
) (UINTN
) &snp
->cdb
);
102 if (snp
->cdb
.StatCode
!= PXE_STATCODE_SUCCESS
) {
104 // UNDI could not be started. Return UNDI error.
108 "\nsnp->undi.start() %xh:%xh\n",
113 return EFI_DEVICE_ERROR
;
116 // Set simple network state to Started and return success.
118 snp
->mode
.State
= EfiSimpleNetworkStarted
;
126 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
131 This is the SNP interface routine for starting the interface
132 This routine basically retrieves snp structure, checks the SNP state and
133 calls the pxe_start routine to actually do start undi interface
136 This - context pointer
139 EFI_INVALID_PARAMETER - "This" is Null
140 - No SNP driver can be extracted from "This"
141 EFI_ALREADY_STARTED - The state of SNP is EfiSimpleNetworkStarted
142 or EfiSimpleNetworkInitialized
143 EFI_DEVICE_ERROR - The state of SNP is other than EfiSimpleNetworkStarted,
144 EfiSimpleNetworkInitialized, and EfiSimpleNetworkStopped
145 EFI_SUCCESS - UNDI interface is succesfully started
146 Other - Error occurs while calling pxe_start function.
155 return EFI_INVALID_PARAMETER
;
158 Snp
= EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This
);
161 return EFI_INVALID_PARAMETER
;
164 switch (Snp
->mode
.State
) {
165 case EfiSimpleNetworkStopped
:
168 case EfiSimpleNetworkStarted
:
169 case EfiSimpleNetworkInitialized
:
170 return EFI_ALREADY_STARTED
;
173 return EFI_DEVICE_ERROR
;
176 Status
= pxe_start (Snp
);
177 if (Status
!= EFI_SUCCESS
) {
181 // clear the map_list in SNP structure
183 for (Index
= 0; Index
< MAX_MAP_LENGTH
; Index
++) {
184 Snp
->map_list
[Index
].virt
= 0;
185 Snp
->map_list
[Index
].map_cookie
= 0;
188 Snp
->mode
.MCastFilterCount
= 0;