From 41057d7787037c9f103046251cfe9bf80dd027f6 Mon Sep 17 00:00:00 2001 From: vanjeff Date: Tue, 13 Nov 2007 09:08:17 +0000 Subject: [PATCH] Remove gEfiNetworkInterfaceIdentifierProtocolGuid reference from code base. Only left its definition in MdePkg. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4295 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Decode.c | 57 +-- MdeModulePkg/Bus/Pci/UndiRuntimeDxe/E100b.h | 4 +- MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Init.c | 47 +-- MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Undi32.h | 9 +- .../Bus/Pci/UndiRuntimeDxe/UndiRuntimeDxe.inf | 9 +- MdeModulePkg/Universal/Network/PxeBcDxe/Bc.c | 14 +- .../Universal/Network/PxeBcDxe/PxeBcDxe.inf | 1 - .../Universal/Network/SnpDxe/get_status.c | 5 - .../Universal/Network/SnpDxe/receive.c | 45 +-- MdeModulePkg/Universal/Network/SnpDxe/snp.c | 338 ++---------------- MdeModulePkg/Universal/Network/SnpDxe/snp.h | 2 +- MdeModulePkg/Universal/Network/SnpDxe/start.c | 42 +-- .../Universal/Network/SnpDxe/transmit.c | 72 ---- 13 files changed, 75 insertions(+), 570 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Decode.c b/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Decode.c index cb7fa89749..3e81c9eab7 100644 --- a/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Decode.c +++ b/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Decode.c @@ -1290,52 +1290,6 @@ Returns: return ; } -VOID -UNDI_APIEntry_old ( - IN UINT64 cdb - ) -/*++ - -Routine Description: - This is the main SW UNDI API entry using the older nii protocol. - The parameter passed in is a 64 bit flat model virtual - address of the cdb. We then jump into the common routine for both old and - new nii protocol entries. - -Arguments: - CdbPtr - Pointer to the command descriptor block. - AdapterInfo - Pointer to the NIC data structure information which the UNDI driver is layering on.. - -Returns: - None - ---*/ -// TODO: cdb - add argument and description to function comment -{ - PXE_CDB *CdbPtr; - NIC_DATA_INSTANCE *AdapterInfo; - - if (cdb == (UINT64) 0) { - return ; - - } - - CdbPtr = (PXE_CDB *) (UINTN) cdb; - - if (CdbPtr->IFnum >= pxe->IFcnt) { - CdbPtr->StatFlags = PXE_STATFLAGS_COMMAND_FAILED; - CdbPtr->StatCode = PXE_STATCODE_INVALID_CDB; - return ; - } - - AdapterInfo = &(UNDI32DeviceList[CdbPtr->IFnum]->NicInfo); - - // - // entering from older entry point - // - AdapterInfo->VersionFlag = 0x30; - UNDI_APIEntry_Common (cdb); -} VOID UNDI_APIEntry_new ( @@ -1580,8 +1534,7 @@ Returns: VOID PxeStructInit ( - IN PXE_SW_UNDI *PxePtr, - IN UINTN VersionFlag + IN PXE_SW_UNDI *PxePtr ) /*++ @@ -1629,12 +1582,8 @@ Returns: PXE_ROMID_IMP_SOFTWARE_INT_SUPPORTED | PXE_ROMID_IMP_PACKET_RX_INT_SUPPORTED; - if (VersionFlag == 0x30) { - PxePtr->EntryPoint = (UINT64) UNDI_APIEntry_old; - } else { - PxePtr->EntryPoint = (UINT64) UNDI_APIEntry_new; - PxePtr->MinorVer = PXE_ROMID_MINORVER_31; - } + PxePtr->EntryPoint = (UINT64) UNDI_APIEntry_new; + PxePtr->MinorVer = PXE_ROMID_MINORVER_31; PxePtr->reserved2[0] = 0; PxePtr->reserved2[1] = 0; diff --git a/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/E100b.h b/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/E100b.h index 80c90b5a6f..d1107ddba7 100644 --- a/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/E100b.h +++ b/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/E100b.h @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2006, Intel Corporation +Copyright (c) 2006 - 2007, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -630,7 +630,7 @@ typedef struct s_data_instance { UINT8 Rx_Filter; UINT8 VersionFlag; // UNDI30 or UNDI31?? UINT8 rsvd[3]; - + struct mc{ UINT16 reserved [3]; // padding for this structure to make it 8 byte aligned UINT16 list_len; diff --git a/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Init.c b/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Init.c index 3e3391ebee..b79c5fe7a6 100644 --- a/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Init.c +++ b/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Init.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2006, Intel Corporation +Copyright (c) 2006 - 2007, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -26,10 +26,9 @@ Revision History // // Global Variables // -PXE_SW_UNDI *pxe = 0; // 3.0 entry point -PXE_SW_UNDI *pxe_31 = 0; // 3.1 entry -UNDI32_DEV *UNDI32DeviceList[MAX_NIC_INTERFACES]; +PXE_SW_UNDI *pxe_31 = NULL; // 3.1 entry +UNDI32_DEV *UNDI32DeviceList[MAX_NIC_INTERFACES]; NII_TABLE *UndiDataPointer = NULL; VOID @@ -381,16 +380,10 @@ Returns: } else { pxe_31 = (PXE_SW_UNDI *) TmpPxePointer; } - // - // assuming that the sizeof pxe_31 is a 16 byte multiple - // - pxe = (PXE_SW_UNDI *) ((CHAR8 *) (pxe_31) + sizeof (PXE_SW_UNDI)); - PxeStructInit (pxe, 0x30); - PxeStructInit (pxe_31, 0x31); + PxeStructInit (pxe_31); } - UNDI32Device->NIIProtocol.ID = (UINT64) (UINTN) (pxe); UNDI32Device->NIIProtocol_31.ID = (UINT64) (UINTN) (pxe_31); Status = PciIoFncs->Attributes ( @@ -454,15 +447,13 @@ Returns: // the IfNum index for the current interface will be the total number // of interfaces initialized so far // - UNDI32Device->NIIProtocol.IfNum = pxe->IFcnt; UNDI32Device->NIIProtocol_31.IfNum = pxe_31->IFcnt; - PxeUpdate (&UNDI32Device->NicInfo, pxe); PxeUpdate (&UNDI32Device->NicInfo, pxe_31); - UNDI32Device->NicInfo.Io_Function = PciIoFncs; - UNDI32DeviceList[UNDI32Device->NIIProtocol.IfNum] = UNDI32Device; - UNDI32Device->Undi32BaseDevPath = UndiDevicePath; + UNDI32Device->NicInfo.Io_Function = PciIoFncs; + UNDI32DeviceList[UNDI32Device->NIIProtocol_31.IfNum] = UNDI32Device; + UNDI32Device->Undi32BaseDevPath = UndiDevicePath; Status = AppendMac2DevPath ( &UNDI32Device->Undi32DevPath, @@ -476,19 +467,6 @@ Returns: UNDI32Device->Signature = UNDI_DEV_SIGNATURE; - UNDI32Device->NIIProtocol.Revision = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION; - UNDI32Device->NIIProtocol.Type = EfiNetworkInterfaceUndi; - UNDI32Device->NIIProtocol.MajorVer = PXE_ROMID_MAJORVER; - UNDI32Device->NIIProtocol.MinorVer = PXE_ROMID_MINORVER; - UNDI32Device->NIIProtocol.ImageSize = 0; - UNDI32Device->NIIProtocol.ImageAddr = 0; - UNDI32Device->NIIProtocol.Ipv6Supported = FALSE; - - UNDI32Device->NIIProtocol.StringId[0] = 'U'; - UNDI32Device->NIIProtocol.StringId[1] = 'N'; - UNDI32Device->NIIProtocol.StringId[2] = 'D'; - UNDI32Device->NIIProtocol.StringId[3] = 'I'; - UNDI32Device->NIIProtocol_31.Revision = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION_31; UNDI32Device->NIIProtocol_31.Type = EfiNetworkInterfaceUndi; UNDI32Device->NIIProtocol_31.MajorVer = PXE_ROMID_MAJORVER; @@ -511,8 +489,6 @@ Returns: &UNDI32Device->DeviceHandle, &gEfiNetworkInterfaceIdentifierProtocolGuid_31, &UNDI32Device->NIIProtocol_31, - &gEfiNetworkInterfaceIdentifierProtocolGuid, - &UNDI32Device->NIIProtocol, &gEfiDevicePathProtocolGuid, UNDI32Device->Undi32DevPath, NULL @@ -557,19 +533,16 @@ UndiErrorAllocDataPointer: &UNDI32Device->DeviceHandle, &gEfiNetworkInterfaceIdentifierProtocolGuid_31, &UNDI32Device->NIIProtocol_31, - &gEfiNetworkInterfaceIdentifierProtocolGuid, - &UNDI32Device->NIIProtocol, &gEfiDevicePathProtocolGuid, UNDI32Device->Undi32DevPath, NULL ); UndiErrorDeleteDevicePath: - UNDI32DeviceList[UNDI32Device->NIIProtocol.IfNum] = NULL; + UNDI32DeviceList[UNDI32Device->NIIProtocol_31.IfNum] = NULL; gBS->FreePool (UNDI32Device->Undi32DevPath); UndiErrorDeletePxe: - PxeUpdate (NULL, pxe); PxeUpdate (NULL, pxe_31); if (TmpPxePointer != NULL) { gBS->FreePool (TmpPxePointer); @@ -673,7 +646,7 @@ Returns: Status = gBS->OpenProtocol ( ChildHandleBuffer[Index], - &gEfiNetworkInterfaceIdentifierProtocolGuid, + &gEfiNetworkInterfaceIdentifierProtocolGuid_31, (VOID **) &NIIProtocol, This->DriverBindingHandle, Controller, @@ -707,8 +680,6 @@ Returns: UNDI32Device->Undi32DevPath, &gEfiNetworkInterfaceIdentifierProtocolGuid_31, &UNDI32Device->NIIProtocol_31, - &gEfiNetworkInterfaceIdentifierProtocolGuid, - &UNDI32Device->NIIProtocol, NULL ); diff --git a/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Undi32.h b/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Undi32.h index 12691bb1f0..32f80fa8f2 100644 --- a/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Undi32.h +++ b/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Undi32.h @@ -1,7 +1,7 @@ /*++ -Copyright (c) 2006, Intel Corporation. +Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -61,12 +61,11 @@ Revision History #define MUST_BE_INITIALIZED 2 #define UNDI_DEV_SIGNATURE EFI_SIGNATURE_32('u','n','d','i') -#define UNDI_DEV_FROM_THIS(a) CR(a, UNDI32_DEV, NIIProtocol, UNDI_DEV_SIGNATURE) +#define UNDI_DEV_FROM_THIS(a) CR(a, UNDI32_DEV, NIIProtocol_31, UNDI_DEV_SIGNATURE) #define UNDI_DEV_FROM_NIC(a) CR(a, UNDI32_DEV, NicInfo, UNDI_DEV_SIGNATURE) typedef struct { UINTN Signature; - EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL NIIProtocol; EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL NIIProtocol_31; EFI_HANDLE DeviceHandle; EFI_DEVICE_PATH_PROTOCOL *Undi32BaseDevPath; @@ -110,7 +109,6 @@ typedef VOID (*unmap_mem)(UINT64, UINT64, UINT32, UINT32, UINT64); typedef VOID (*sync_mem)(UINT64, UINT64, UINT32, UINT32, UINT64); extern UNDI_CALL_TABLE api_table[]; -extern PXE_SW_UNDI *pxe; // !pxe structure extern PXE_SW_UNDI *pxe_31; // !pxe structure for 3.1 drivers extern UNDI32_DEV *UNDI32DeviceList[MAX_NIC_INTERFACES]; @@ -362,13 +360,12 @@ UNDI_Receive ( ); VOID UNDI_APIEntry_new(UINT64); -VOID UNDI_APIEntry_old(UINT64); VOID UNDI_APIEntry_Common(UINT64); PXE_IPV4 convert_mcip(PXE_MAC_ADDR *); INT32 validate_mcip (PXE_MAC_ADDR *MCastAddr); -VOID PxeStructInit (PXE_SW_UNDI *PxePtr, UINTN VersionFlag); +VOID PxeStructInit (PXE_SW_UNDI *PxePtr); VOID PxeUpdate (NIC_DATA_INSTANCE *NicPtr, PXE_SW_UNDI *PxePtr); #endif diff --git a/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/UndiRuntimeDxe.inf b/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/UndiRuntimeDxe.inf index fc500c6a98..5dc37e1bc5 100644 --- a/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/UndiRuntimeDxe.inf +++ b/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/UndiRuntimeDxe.inf @@ -51,13 +51,12 @@ [Guids] - gEfiEventExitBootServicesGuid - gEfiEventVirtualAddressChangeGuid + gEfiEventExitBootServicesGuid + gEfiEventVirtualAddressChangeGuid [Protocols] gEfiNetworkInterfaceIdentifierProtocolGuid_31 - gEfiNetworkInterfaceIdentifierProtocolGuid - gEfiPciIoProtocolGuid - gEfiDevicePathProtocolGuid + gEfiPciIoProtocolGuid + gEfiDevicePathProtocolGuid diff --git a/MdeModulePkg/Universal/Network/PxeBcDxe/Bc.c b/MdeModulePkg/Universal/Network/PxeBcDxe/Bc.c index 63d11d2fe1..a59f189f92 100644 --- a/MdeModulePkg/Universal/Network/PxeBcDxe/Bc.c +++ b/MdeModulePkg/Universal/Network/PxeBcDxe/Bc.c @@ -2172,19 +2172,9 @@ PxeBcDriverStart ( ); if (EFI_ERROR (Status)) { - Status = gBS->OpenProtocol ( - Controller, - &gEfiNetworkInterfaceIdentifierProtocolGuid, - (VOID **) &Private->NiiPtr, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - - if (EFI_ERROR (Status)) { - goto PxeBcError; - } + goto PxeBcError; } + // // Get the Snp interface // diff --git a/MdeModulePkg/Universal/Network/PxeBcDxe/PxeBcDxe.inf b/MdeModulePkg/Universal/Network/PxeBcDxe/PxeBcDxe.inf index 4bcd46ee94..99c5363d63 100644 --- a/MdeModulePkg/Universal/Network/PxeBcDxe/PxeBcDxe.inf +++ b/MdeModulePkg/Universal/Network/PxeBcDxe/PxeBcDxe.inf @@ -86,7 +86,6 @@ gEfiLoadFileProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiNetworkInterfaceIdentifierProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiTcpProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiNetworkInterfaceIdentifierProtocolGuid_31 # PROTOCOL ALWAYS_CONSUMED diff --git a/MdeModulePkg/Universal/Network/SnpDxe/get_status.c b/MdeModulePkg/Universal/Network/SnpDxe/get_status.c index 0c1cd8a68e..d1fa2627fc 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/get_status.c +++ b/MdeModulePkg/Universal/Network/SnpDxe/get_status.c @@ -42,7 +42,6 @@ pxe_getstatus ( { PXE_DB_GET_STATUS *db; UINT16 InterruptFlags; - UINT64 TempData; db = snp->db; snp->cdb.OpCode = PXE_OPCODE_GET_STATUS; @@ -122,10 +121,6 @@ pxe_getstatus ( (snp->cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY) ) ? 0 : (VOID *) (UINTN) db->TxBuffer[0]; - TempData = (UINT64) (UINTN) (*TransmitBufferListPtr); - if (snp->IsOldUndi && (TempData >= FOUR_GIGABYTES)) { - del_v2p ((VOID *) (UINTN) (db->TxBuffer[0])); - } } return EFI_SUCCESS; diff --git a/MdeModulePkg/Universal/Network/SnpDxe/receive.c b/MdeModulePkg/Universal/Network/SnpDxe/receive.c index 58bfa34f90..b6f0c55dde 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/receive.c +++ b/MdeModulePkg/Universal/Network/SnpDxe/receive.c @@ -54,47 +54,13 @@ pxe_receive ( PXE_CPB_RECEIVE *cpb; PXE_DB_RECEIVE *db; UINTN buf_size; - UINT64 TempData; cpb = snp->cpb; db = snp->db; buf_size = *BuffSizePtr; - // - // IMPORTANT NOTE: - // In case of the older 3.0 UNDI, if the input buffer address is beyond 4GB, - // DO NOT call the map function on the given buffer, instead use - // a global buffer. The reason is that UNDI3.0 has some unnecessary check of - // making sure that all the addresses (whether or not they will be given - // to the NIC ) supplied to it are below 4GB. It may or may not use - // the mapped address after all (like in case of CPB and DB)! - // Instead of using the global buffer whose address is allocated within the - // 2GB limit if I start mapping the given buffer we lose the data, here is - // why!!! - // if our address is > 4GB, the map call creates another buffer below 2GB and - // copies data to/from the original buffer to the mapped buffer either at - // map time or unmap time depending on the map direction. - // UNDI will not complain since we already mapped the buffer to be - // within the 2GB limit but will not use (I know undi) the mapped address - // since it does not give the user buffers to the NIC's receive unit, - // It just copies the received packet into the user buffer using the virtual - // (CPU) address rather than the mapped (device or physical) address. - // When the UNDI call returns, if we then unmap the buffer, we will lose - // the contents because unmap copies the contents of the mapped buffer into - // the original buffer (since the direction is FROM_DEVICE) !!! - // - // this is not a problem in Undi 3.1 because this undi uses it's map callback - // routine to map a cpu address to device address and it does it only if - // it is giving the address to the device and unmaps it before using the cpu - // address! - // - TempData = (UINT64) (UINTN) BufferPtr; - if (snp->IsOldUndi && (TempData >= FOUR_GIGABYTES)) { - cpb->BufferAddr = (UINT64)(UINTN) snp->receive_buf; - cpb->BufferLen = (UINT32) (snp->init_info.MediaHeaderLen + snp->init_info.FrameDataLen); - } else { - cpb->BufferAddr = (UINT64)(UINTN) BufferPtr; - cpb->BufferLen = (UINT32) *BuffSizePtr; - } + + cpb->BufferAddr = (UINT64)(UINTN) BufferPtr; + cpb->BufferLen = (UINT32) *BuffSizePtr; cpb->reserved = 0; @@ -162,11 +128,6 @@ pxe_receive ( *ProtocolPtr = (UINT16) PXE_SWAP_UINT16 (db->Protocol); /* we need to do the byte swapping */ } - TempData = (UINT64) (UINTN) BufferPtr; - if (snp->IsOldUndi && (TempData >= FOUR_GIGABYTES)) { - CopyMem (BufferPtr, snp->receive_buf, snp->init_info.MediaHeaderLen + snp->init_info.FrameDataLen); - } - return (*BuffSizePtr <= buf_size) ? EFI_SUCCESS : EFI_BUFFER_TOO_SMALL; } diff --git a/MdeModulePkg/Universal/Network/SnpDxe/snp.c b/MdeModulePkg/Universal/Network/SnpDxe/snp.c index 2f88c71ae8..31b5022bd0 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/snp.c +++ b/MdeModulePkg/Universal/Network/SnpDxe/snp.c @@ -329,9 +329,7 @@ SimpleNetworkDriverSupported ( EFI_STATUS Status; EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *NiiProtocol; PXE_UNDI *pxe; - BOOLEAN IsUndi31; - IsUndi31 = FALSE; Status = gBS->OpenProtocol ( Controller, &gEfiDevicePathProtocolGuid, @@ -352,34 +350,16 @@ SimpleNetworkDriverSupported ( Controller, EFI_OPEN_PROTOCOL_BY_DRIVER ); - if (Status == EFI_ALREADY_STARTED) - { - DEBUG ((EFI_D_INFO, "Support(): Already Started. on handle %x\n", Controller)); - return EFI_ALREADY_STARTED; - } - if (!EFI_ERROR (Status)) - { - DEBUG ((EFI_D_INFO, "Support(): UNDI3.1 found on handle %x\n", Controller)); - IsUndi31 = TRUE; - } else { - // - // try the older 3.0 driver - // - Status = gBS->OpenProtocol ( - Controller, - &gEfiNetworkInterfaceIdentifierProtocolGuid, - (VOID **) &NiiProtocol, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - return Status; + if (EFI_ERROR (Status)) { + if (Status == EFI_ALREADY_STARTED) { + DEBUG ((EFI_D_INFO, "Support(): Already Started. on handle %x\n", Controller)); } - - DEBUG ((EFI_D_INFO, "Support(): UNDI3.0 found on handle %x\n", Controller)); + return Status; } + + DEBUG ((EFI_D_INFO, "Support(): UNDI3.1 found on handle %x\n", Controller)); + // // check the version, we don't want to connect to the undi16 // @@ -445,22 +425,12 @@ SimpleNetworkDriverSupported ( DEBUG ((EFI_D_INFO, "Support(): supported on %x\n", Controller)); Done: - if (IsUndi31) { - gBS->CloseProtocol ( - Controller, - &gEfiNetworkInterfaceIdentifierProtocolGuid_31, - This->DriverBindingHandle, - Controller - ); - - } else { - gBS->CloseProtocol ( - Controller, - &gEfiNetworkInterfaceIdentifierProtocolGuid, - This->DriverBindingHandle, - Controller - ); - } + gBS->CloseProtocol ( + Controller, + &gEfiNetworkInterfaceIdentifierProtocolGuid_31, + This->DriverBindingHandle, + Controller + ); return Status; } @@ -491,11 +461,7 @@ SimpleNetworkDriverStart ( PXE_UNDI *pxe; SNP_DRIVER *snp; VOID *addr; - VOID *addrUnmap; - EFI_PHYSICAL_ADDRESS paddr; EFI_HANDLE Handle; - UINTN Size; - BOOLEAN UndiNew; PXE_PCI_CONFIG_INFO ConfigInfo; PCI_TYPE00 *ConfigHeader; UINT32 *TempBar; @@ -539,8 +505,7 @@ SimpleNetworkDriverStart ( return Status; } // - // Get the NII interface. look for 3.1 undi first, if it is not there - // then look for 3.0, validate the interface. + // Get the NII interface. // Status = gBS->OpenProtocol ( Controller, @@ -550,7 +515,7 @@ SimpleNetworkDriverStart ( Controller, EFI_OPEN_PROTOCOL_BY_DRIVER ); - if (Status == EFI_ALREADY_STARTED) { + if (EFI_ERROR (Status)) { gBS->CloseProtocol ( Controller, &gEfiDevicePathProtocolGuid, @@ -560,36 +525,7 @@ SimpleNetworkDriverStart ( return Status; } - if (!EFI_ERROR (Status)) { - // - // probably not a 3.1 UNDI - // - UndiNew = TRUE; - DEBUG ((EFI_D_INFO, "Start(): UNDI3.1 found\n")); - - } else { - UndiNew = FALSE; - Status = gBS->OpenProtocol ( - Controller, - &gEfiNetworkInterfaceIdentifierProtocolGuid, - (VOID **) &Nii, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - gBS->CloseProtocol ( - Controller, - &gEfiDevicePathProtocolGuid, - This->DriverBindingHandle, - Controller - ); - - return Status; - } - - DEBUG ((EFI_D_INFO, "Start(): UNDI3.0 found\n")); - } + DEBUG ((EFI_D_INFO, "Start(): UNDI3.1 found\n")); pxe = (PXE_UNDI *) (UINTN) (Nii->ID); @@ -632,30 +568,9 @@ SimpleNetworkDriverStart ( snp = (SNP_DRIVER *) (UINTN) addr; - if (!UndiNew) { - Size = SNP_MEM_PAGES (sizeof (SNP_DRIVER)); - - Status = mPciIoFncs->Map ( - mPciIoFncs, - EfiPciIoOperationBusMasterCommonBuffer, - addr, - &Size, - &paddr, - &addrUnmap - ); - - ASSERT (paddr); - - DEBUG ((EFI_D_NET, "\nSNP_DRIVER @ %Xh, sizeof(SNP_DRIVER) == %d", addr, sizeof (SNP_DRIVER))); - snp = (SNP_DRIVER *) (UINTN) paddr; - snp->SnpDriverUnmap = addrUnmap; - } - ZeroMem (snp, sizeof (SNP_DRIVER)); snp->IoFncs = mPciIoFncs; - snp->IsOldUndi = (BOOLEAN) (!UndiNew); - snp->Signature = SNP_DRIVER_SIGNATURE; EfiInitializeLock (&snp->lock, TPL_NOTIFY); @@ -725,26 +640,9 @@ SimpleNetworkDriverStart ( goto Error_DeleteSNP; } - if (snp->IsOldUndi) { - Size = SNP_MEM_PAGES (4096); + snp->cpb = (VOID *) (UINTN) addr; + snp->db = (VOID *) ((UINTN) addr + 2048); - Status = mPciIoFncs->Map ( - mPciIoFncs, - EfiPciIoOperationBusMasterCommonBuffer, - addr, - &Size, - &paddr, - &snp->CpbUnmap - ); - - ASSERT (paddr); - - snp->cpb = (VOID *) (UINTN) paddr; - snp->db = (VOID *) ((UINTN) paddr + 2048); - } else { - snp->cpb = (VOID *) (UINTN) addr; - snp->db = (VOID *) ((UINTN) addr + 2048); - } // // pxe_start call is going to give the callback functions to UNDI, these callback // functions use the BarIndex values from the snp structure, so these must be initialized @@ -762,7 +660,7 @@ SimpleNetworkDriverStart ( Status = pxe_start (snp); if (Status != EFI_SUCCESS) { - goto Error_DeleteCPBDB; + goto Error_DeleteSNP; } snp->cdb.OpCode = PXE_OPCODE_GET_INIT_INFO; @@ -792,7 +690,7 @@ SimpleNetworkDriverStart ( if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) { DEBUG ((EFI_D_NET, "\nsnp->undi.init_info() %xh:%xh\n", snp->cdb.StatFlags, snp->cdb.StatCode)); pxe_stop (snp); - goto Error_DeleteCPBDB; + goto Error_DeleteSNP; } snp->cdb.OpCode = PXE_OPCODE_GET_CONFIG_INFO; @@ -817,7 +715,7 @@ SimpleNetworkDriverStart ( if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) { DEBUG ((EFI_D_NET, "\nsnp->undi.config_info() %xh:%xh\n", snp->cdb.StatFlags, snp->cdb.StatCode)); pxe_stop (snp); - goto Error_DeleteCPBDB; + goto Error_DeleteSNP; } // // Find the correct BAR to do IO. @@ -846,79 +744,6 @@ SimpleNetworkDriverStart ( TempBar++; } - // - // We allocate 2 more global buffers for undi 3.0 interface. We use these - // buffers to pass to undi when the user buffers are beyond 4GB. - // UNDI 3.0 wants all the addresses passed to it to be - // within 2GB limit, create them here and map them so that when undi calls - // v2p callback to check if the physical address is < 2gb, we will pass. - // - // For 3.1 and later UNDIs, we do not do this because undi is - // going to call the map() callback if and only if it wants to use the - // device address for any address it receives. - // - if (snp->IsOldUndi) { - // - // buffer for receive - // - Size = SNP_MEM_PAGES (snp->init_info.MediaHeaderLen + snp->init_info.FrameDataLen); - Status = mPciIoFncs->AllocateBuffer ( - mPciIoFncs, - AllocateAnyPages, - EfiBootServicesData, - Size, - &addr, - 0 - ); - - if (Status != EFI_SUCCESS) { - DEBUG ((EFI_D_ERROR, "\nCould not allocate receive buffer.\n")); - goto Error_DeleteCPBDB; - } - - Status = mPciIoFncs->Map ( - mPciIoFncs, - EfiPciIoOperationBusMasterCommonBuffer, - addr, - &Size, - &paddr, - &snp->ReceiveBufUnmap - ); - - ASSERT (paddr); - - snp->receive_buf = (UINT8 *) (UINTN) paddr; - - // - // buffer for fill_header - // - Size = SNP_MEM_PAGES (snp->init_info.MediaHeaderLen); - Status = mPciIoFncs->AllocateBuffer ( - mPciIoFncs, - AllocateAnyPages, - EfiBootServicesData, - Size, - &addr, - 0 - ); - - if (Status != EFI_SUCCESS) { - DEBUG ((EFI_D_ERROR, "\nCould not allocate fill_header buffer.\n")); - goto Error_DeleteRCVBuf; - } - - Status = mPciIoFncs->Map ( - mPciIoFncs, - EfiPciIoOperationBusMasterCommonBuffer, - addr, - &Size, - &paddr, - &snp->FillHdrBufUnmap - ); - - ASSERT (paddr); - snp->fill_hdr_buf = (UINT8 *) (UINTN) paddr; - } // // Initialize simple network protocol mode structure // @@ -992,7 +817,7 @@ SimpleNetworkDriverStart ( if (Status) { pxe_stop (snp); - goto Error_DeleteHdrBuf; + goto Error_DeleteSNP; } Status = pxe_get_stn_addr (snp); @@ -1001,7 +826,7 @@ SimpleNetworkDriverStart ( DEBUG ((EFI_D_ERROR, "\nsnp->undi.get_station_addr() failed.\n")); pxe_shutdown (snp); pxe_stop (snp); - goto Error_DeleteHdrBuf; + goto Error_DeleteSNP; } snp->mode.MediaPresent = FALSE; @@ -1033,43 +858,6 @@ SimpleNetworkDriverStart ( return Status; } -Error_DeleteHdrBuf: - if (snp->IsOldUndi) { - Status = mPciIoFncs->Unmap ( - mPciIoFncs, - snp->FillHdrBufUnmap - ); - Size = SNP_MEM_PAGES (snp->init_info.MediaHeaderLen); - mPciIoFncs->FreeBuffer ( - mPciIoFncs, - Size, - snp->fill_hdr_buf - ); - } - -Error_DeleteRCVBuf: - if (snp->IsOldUndi) { - Status = mPciIoFncs->Unmap ( - mPciIoFncs, - snp->ReceiveBufUnmap - ); - Size = SNP_MEM_PAGES (snp->init_info.MediaHeaderLen + snp->init_info.FrameDataLen); - mPciIoFncs->FreeBuffer ( - mPciIoFncs, - Size, - snp->receive_buf - ); - - } - -Error_DeleteCPBDB: - if (snp->IsOldUndi) { - Status = mPciIoFncs->Unmap ( - mPciIoFncs, - snp->CpbUnmap - ); - } - Status = mPciIoFncs->FreeBuffer ( mPciIoFncs, SNP_MEM_PAGES (4096), @@ -1077,12 +865,6 @@ Error_DeleteCPBDB: ); Error_DeleteSNP: - if (snp->IsOldUndi) { - Status = mPciIoFncs->Unmap ( - mPciIoFncs, - snp->SnpDriverUnmap - ); - } mPciIoFncs->FreeBuffer ( mPciIoFncs, @@ -1090,21 +872,12 @@ Error_DeleteSNP: snp ); NiiError: - if (!UndiNew) { - gBS->CloseProtocol ( - Controller, - &gEfiNetworkInterfaceIdentifierProtocolGuid, - This->DriverBindingHandle, - Controller - ); - } else { - gBS->CloseProtocol ( - Controller, - &gEfiNetworkInterfaceIdentifierProtocolGuid_31, - This->DriverBindingHandle, - Controller - ); - } + gBS->CloseProtocol ( + Controller, + &gEfiNetworkInterfaceIdentifierProtocolGuid_31, + This->DriverBindingHandle, + Controller + ); gBS->CloseProtocol ( Controller, @@ -1163,21 +936,12 @@ SimpleNetworkDriverStop ( return Status; } - if (!Snp->IsOldUndi) { - Status = gBS->CloseProtocol ( - Controller, - &gEfiNetworkInterfaceIdentifierProtocolGuid_31, - This->DriverBindingHandle, - Controller - ); - } else { - Status = gBS->CloseProtocol ( - Controller, - &gEfiNetworkInterfaceIdentifierProtocolGuid, - This->DriverBindingHandle, - Controller - ); - } + Status = gBS->CloseProtocol ( + Controller, + &gEfiNetworkInterfaceIdentifierProtocolGuid_31, + This->DriverBindingHandle, + Controller + ); Status = gBS->CloseProtocol ( Controller, @@ -1189,38 +953,6 @@ SimpleNetworkDriverStop ( pxe_shutdown (Snp); pxe_stop (Snp); - if (Snp->IsOldUndi) { - Status = mPciIoFncs->Unmap ( - mPciIoFncs, - Snp->FillHdrBufUnmap - ); - - mPciIoFncs->FreeBuffer ( - mPciIoFncs, - SNP_MEM_PAGES (Snp->init_info.MediaHeaderLen), - Snp->fill_hdr_buf - ); - Status = mPciIoFncs->Unmap ( - mPciIoFncs, - Snp->ReceiveBufUnmap - ); - - mPciIoFncs->FreeBuffer ( - mPciIoFncs, - SNP_MEM_PAGES (Snp->init_info.MediaHeaderLen + Snp->init_info.FrameDataLen), - Snp->receive_buf - ); - - Status = mPciIoFncs->Unmap ( - mPciIoFncs, - Snp->CpbUnmap - ); - Status = mPciIoFncs->Unmap ( - mPciIoFncs, - Snp->SnpDriverUnmap - ); - } - mPciIoFncs->FreeBuffer ( mPciIoFncs, SNP_MEM_PAGES (4096), diff --git a/MdeModulePkg/Universal/Network/SnpDxe/snp.h b/MdeModulePkg/Universal/Network/SnpDxe/snp.h index 01f428d2f1..b6e58c4d27 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/snp.h +++ b/MdeModulePkg/Universal/Network/SnpDxe/snp.h @@ -95,7 +95,7 @@ typedef struct { EFI_PCI_IO_PROTOCOL *IoFncs; UINT8 IoBarIndex; UINT8 MemoryBarIndex; - BOOLEAN IsOldUndi; // true for EFI1.0 UNDI (3.0) drivers + // // Buffers for command descriptor block, command parameter block // and data block. diff --git a/MdeModulePkg/Universal/Network/SnpDxe/start.c b/MdeModulePkg/Universal/Network/SnpDxe/start.c index 10c9554a0f..eaba03c57d 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/start.c +++ b/MdeModulePkg/Universal/Network/SnpDxe/start.c @@ -33,10 +33,8 @@ pxe_start ( SNP_DRIVER *snp ) { - PXE_CPB_START_30 *cpb; PXE_CPB_START_31 *cpb_31; - cpb = snp->cpb; cpb_31 = snp->cpb; // // Initialize UNDI Start CDB for H/W UNDI @@ -57,37 +55,23 @@ pxe_start ( // a S/W UNDI. // if (snp->is_swundi) { - if (snp->IsOldUndi) { - snp->cdb.CPBsize = sizeof (PXE_CPB_START_30); - snp->cdb.CPBaddr = (UINT64)(UINTN) cpb; + snp->cdb.CPBsize = sizeof (PXE_CPB_START_31); + snp->cdb.CPBaddr = (UINT64)(UINTN) cpb_31; - cpb->Delay = (UINT64)(UINTN) &snp_undi32_callback_delay_30; - cpb->Block = (UINT64)(UINTN) &snp_undi32_callback_block_30; + cpb_31->Delay = (UINT64)(UINTN) &snp_undi32_callback_delay; + cpb_31->Block = (UINT64)(UINTN) &snp_undi32_callback_block; - // - // Virtual == Physical. This can be set to zero. - // - cpb->Virt2Phys = (UINT64)(UINTN) &snp_undi32_callback_v2p_30; - cpb->Mem_IO = (UINT64)(UINTN) &snp_undi32_callback_memio_30; - } else { - snp->cdb.CPBsize = sizeof (PXE_CPB_START_31); - snp->cdb.CPBaddr = (UINT64)(UINTN) cpb_31; + // + // Virtual == Physical. This can be set to zero. + // + cpb_31->Virt2Phys = (UINT64)(UINTN) 0; + cpb_31->Mem_IO = (UINT64)(UINTN) &snp_undi32_callback_memio; - cpb_31->Delay = (UINT64)(UINTN) &snp_undi32_callback_delay; - cpb_31->Block = (UINT64)(UINTN) &snp_undi32_callback_block; + cpb_31->Map_Mem = (UINT64)(UINTN) &snp_undi32_callback_map; + cpb_31->UnMap_Mem = (UINT64)(UINTN) &snp_undi32_callback_unmap; + cpb_31->Sync_Mem = (UINT64)(UINTN) &snp_undi32_callback_sync; - // - // Virtual == Physical. This can be set to zero. - // - cpb_31->Virt2Phys = (UINT64)(UINTN) 0; - cpb_31->Mem_IO = (UINT64)(UINTN) &snp_undi32_callback_memio; - - cpb_31->Map_Mem = (UINT64)(UINTN) &snp_undi32_callback_map; - cpb_31->UnMap_Mem = (UINT64)(UINTN) &snp_undi32_callback_unmap; - cpb_31->Sync_Mem = (UINT64)(UINTN) &snp_undi32_callback_sync; - - cpb_31->Unique_ID = (UINT64)(UINTN) snp; - } + cpb_31->Unique_ID = (UINT64)(UINTN) snp; } // // Issue UNDI command and check result. diff --git a/MdeModulePkg/Universal/Network/SnpDxe/transmit.c b/MdeModulePkg/Universal/Network/SnpDxe/transmit.c index d113edec96..8ee0cad566 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/transmit.c +++ b/MdeModulePkg/Universal/Network/SnpDxe/transmit.c @@ -52,9 +52,6 @@ pxe_fillheader ( ) { PXE_CPB_FILL_HEADER_FRAGMENTED *cpb; - EFI_STATUS Status; - struct s_v2p *pkt_v2p; - UINT64 TempData; cpb = snp->cpb; if (SourceAddrPtr) { @@ -95,35 +92,6 @@ pxe_fillheader ( cpb->FragDesc[0].reserved = cpb->FragDesc[1].reserved = 0; - if (snp->IsOldUndi) { - TempData = (UINT64) (UINTN) MacHeaderPtr; - if (TempData >= FOUR_GIGABYTES) { - cpb->FragDesc[0].FragAddr = (UINT64) (UINTN) snp->fill_hdr_buf; - cpb->FragDesc[0].FragLen = (UINT32) snp->init_info.MediaHeaderLen; - } - - TempData = (UINT64) (UINTN) (BufferPtr); - if (TempData >= FOUR_GIGABYTES) { - // - // Let the device just read this buffer - // - Status = add_v2p ( - &pkt_v2p, - EfiPciIoOperationBusMasterRead, - BufferPtr, - BufferLength - ); - if (Status != EFI_SUCCESS) { - return Status; - } - // - // give the virtual address to UNDI and it will call back on Virt2Phys - // to get the mapped address, if it needs it - // - cpb->FragDesc[1].FragLen = (UINT32) pkt_v2p->bsize; - } - } - snp->cdb.OpCode = PXE_OPCODE_FILL_HEADER; snp->cdb.OpFlags = PXE_OPFLAGS_FILL_HEADER_FRAGMENTED; @@ -145,24 +113,6 @@ pxe_fillheader ( (*snp->issue_undi32_command) ((UINT64) (UINTN) &snp->cdb); - if (snp->IsOldUndi) { - TempData = (UINT64) (UINTN) (BufferPtr); - if (TempData >= FOUR_GIGABYTES) { - del_v2p (BufferPtr); - } - // - // if we used the global buffer for header, copy the contents - // - TempData = (UINT64) (UINTN) MacHeaderPtr; - if (TempData >= FOUR_GIGABYTES) { - CopyMem ( - MacHeaderPtr, - snp->fill_hdr_buf, - snp->init_info.MediaHeaderLen - ); - } - } - switch (snp->cdb.StatCode) { case PXE_STATCODE_SUCCESS: return EFI_SUCCESS; @@ -211,32 +161,10 @@ pxe_transmit ( { PXE_CPB_TRANSMIT *cpb; EFI_STATUS Status; - struct s_v2p *v2p; - UINT64 TempData; cpb = snp->cpb; cpb->FrameAddr = (UINT64) (UINTN) BufferPtr; cpb->DataLen = (UINT32) BufferLength; - - TempData = (UINT64) (UINTN) BufferPtr; - if (snp->IsOldUndi && (TempData >= FOUR_GIGABYTES)) { - // - // we need to create a mapping now and give it to the undi when it calls - // the Virt2Phys on this address. - // this is a transmit, just map it for the device to READ - // - Status = add_v2p ( - &v2p, - EfiPciIoOperationBusMasterRead, - BufferPtr, - BufferLength - ); - if (Status != EFI_SUCCESS) { - return Status; - } - - cpb->DataLen = (UINT32) v2p->bsize; - } cpb->MediaheaderLen = 0; cpb->reserved = 0;