/** @file\r
Implementation of initializing a network adapter.\r
\r
-Copyright (c) 2004 - 2008, Intel Corporation. <BR> \r
-All rights reserved. This program and the accompanying materials are licensed \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed \r
and made available under the terms and conditions of the BSD License which \r
accompanies this distribution. The full text of the license may be found at \r
http://opensource.org/licenses/bsd-license.php \r
#include "Snp.h"\r
\r
/**\r
- this routine calls undi to initialize the interface.\r
+ Call UNDI to initialize the interface.\r
\r
- @param Snp pointer to snp driver structure\r
- @param CableDetectFlag Do/don't detect the cable (depending on what undi supports)\r
+ @param Snp Pointer to snp driver structure.\r
+ @param CableDetectFlag Do/don't detect the cable (depending on what \r
+ undi supports).\r
\r
- @retval EFI_SUCCESS UNDI is initialized successfully\r
- @retval EFI_DEVICE_ERROR UNDI could not be initialized\r
- @retval Other other errors \r
+ @retval EFI_SUCCESS UNDI is initialized successfully.\r
+ @retval EFI_DEVICE_ERROR UNDI could not be initialized.\r
+ @retval Other Other errors as indicated.\r
\r
**/\r
EFI_STATUS\r
Snp->Cdb.OpCode = PXE_OPCODE_INITIALIZE;\r
Snp->Cdb.OpFlags = CableDetectFlag;\r
\r
- Snp->Cdb.CPBsize = sizeof (PXE_CPB_INITIALIZE);\r
- Snp->Cdb.DBsize = sizeof (PXE_DB_INITIALIZE);\r
+ Snp->Cdb.CPBsize = (UINT16) sizeof (PXE_CPB_INITIALIZE);\r
+ Snp->Cdb.DBsize = (UINT16) sizeof (PXE_DB_INITIALIZE);\r
\r
Snp->Cdb.CPBaddr = (UINT64)(UINTN) Snp->Cpb;\r
Snp->Cdb.DBaddr = (UINT64)(UINTN) Snp->Db;\r
//\r
Snp->TxRxBufferSize = (UINT32) (Snp->InitInfo.MemoryRequired + ExtraRxBufferSize + ExtraTxBufferSize);\r
\r
- if (Snp->Mode.MediaPresentSupported) {\r
+ //\r
+ // If UNDI support cable detect for INITIALIZE command, try it first.\r
+ //\r
+ if (Snp->CableDetectSupported) {\r
if (PxeInit (Snp, PXE_OPFLAGS_INITIALIZE_DETECT_CABLE) == EFI_SUCCESS) {\r
Snp->Mode.MediaPresent = TRUE;\r
goto ON_EXIT;\r
\r
if (EFI_ERROR (EfiStatus)) {\r
gBS->CloseEvent (Snp->Snp.WaitForPacket);\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ //\r
+ // Try to update the MediaPresent field of EFI_SIMPLE_NETWORK_MODE if the UNDI support it.\r
+ //\r
+ if (Snp->MediaStatusSupported) {\r
+ PxeGetStatus (Snp, NULL, FALSE);\r
}\r
\r
ON_EXIT:\r