- if (Snp->Cdb.StatCode == PXE_STATCODE_SUCCESS) {\r
- Snp->Mode.State = EfiSimpleNetworkInitialized;\r
-\r
- Status = EFI_SUCCESS;\r
+ //\r
+ // There are two fields need to be checked here:\r
+ // First is the upper two bits (14 & 15) in the CDB.StatFlags field. Until these bits change to report \r
+ // PXE_STATFLAGS_COMMAND_COMPLETE or PXE_STATFLAGS_COMMAND_FAILED, the command has not been executed by the UNDI.\r
+ // Second is the CDB.StatCode field. After command execution completes, either successfully or not, \r
+ // the CDB.StatCode field contains the result of the command execution.\r
+ //\r
+ if ((((Snp->Cdb.StatFlags) & PXE_STATFLAGS_STATUS_MASK) == PXE_STATFLAGS_COMMAND_COMPLETE) &&\r
+ (Snp->Cdb.StatCode == PXE_STATCODE_SUCCESS)) {\r
+ //\r
+ // If cable detect feature is enabled in CDB.OpFlags, check the CDB.StatFlags to see if there is an \r
+ // active connection to this network device. If the no media StatFlag is set, the UNDI and network \r
+ // device are still initialized. \r
+ //\r
+ if (CableDetectFlag == PXE_OPFLAGS_INITIALIZE_DETECT_CABLE) {\r
+ if(((Snp->Cdb.StatFlags) & PXE_STATFLAGS_INITIALIZED_NO_MEDIA) != PXE_STATFLAGS_INITIALIZED_NO_MEDIA) {\r
+ Snp->Mode.MediaPresent = TRUE;\r
+ } else {\r
+ Snp->Mode.MediaPresent = FALSE;\r
+ }\r
+ }\r
+ \r
+ Snp->Mode.State = EfiSimpleNetworkInitialized;\r
+ Status = EFI_SUCCESS;\r