Save original PCI attributes in start() function and restore it in Stop() for those PCI device drivers.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4212 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006, 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
Copyright (c) 2006, 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
@@ -113,15 +113,15 @@ typedef struct CONFIG_HEADER {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Offsets to the various registers.
|
||||
// All accesses need not be longword aligned.
|
||||
// All accesses need not be longword aligned.
|
||||
//-------------------------------------------------------------------------
|
||||
enum speedo_offsets {
|
||||
SCBStatus = 0, SCBCmd = 2, // Rx/Command Unit command and status.
|
||||
SCBPointer = 4, // General purpose pointer.
|
||||
SCBPort = 8, // Misc. commands and operands.
|
||||
SCBflash = 12, SCBeeprom = 14, // EEPROM and flash memory control.
|
||||
SCBCtrlMDI = 16, // MDI interface control.
|
||||
SCBEarlyRx = 20, // Early receive byte count.
|
||||
SCBStatus = 0, SCBCmd = 2, // Rx/Command Unit command and status.
|
||||
SCBPointer = 4, // General purpose pointer.
|
||||
SCBPort = 8, // Misc. commands and operands.
|
||||
SCBflash = 12, SCBeeprom = 14, // EEPROM and flash memory control.
|
||||
SCBCtrlMDI = 16, // MDI interface control.
|
||||
SCBEarlyRx = 20, // Early receive byte count.
|
||||
SCBEarlyRxInt = 24, SCBFlowCtrlReg = 25, SCBPmdr = 27,
|
||||
// offsets for general control registers (GCRs)
|
||||
SCBGenCtrl = 28, SCBGenStatus = 29, SCBGenCtrl2 = 30, SCBRsvd = 31
|
||||
@@ -130,7 +130,7 @@ enum speedo_offsets {
|
||||
#define GCR2_EEPROM_ACCESS_SEMAPHORE 0x80 // bit offset into the gcr2
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Action commands - Commands that can be put in a command list entry.
|
||||
// Action commands - Commands that can be put in a command list entry.
|
||||
//-------------------------------------------------------------------------
|
||||
enum commands {
|
||||
CmdNOp = 0, CmdIASetup = 1, CmdConfigure = 2, CmdMulticastList = 3,
|
||||
@@ -249,7 +249,7 @@ enum commands {
|
||||
#define BIT_4_6 0x0070
|
||||
#define BIT_4_7 0x00F0
|
||||
#define BIT_5_7 0x00E0
|
||||
#define BIT_5_9 0x03E0
|
||||
#define BIT_5_9 0x03E0
|
||||
#define BIT_5_12 0x1FE0
|
||||
#define BIT_5_15 0xFFE0
|
||||
#define BIT_6_7 0x00c0
|
||||
@@ -640,6 +640,10 @@ typedef struct s_data_instance {
|
||||
UINT64 Unique_ID;
|
||||
|
||||
EFI_PCI_IO_PROTOCOL *Io_Function;
|
||||
//
|
||||
// Original PCI attributes
|
||||
//
|
||||
UINT64 OriginalPciAttributes;
|
||||
|
||||
VOID (*Delay_30)(UINTN); // call back routine
|
||||
VOID (*Virt2Phys_30)(UINT64 virtual_addr, UINT64 physical_ptr); // call back routine
|
||||
|
@@ -1,13 +1,13 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006, 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
Copyright (c) 2006, 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
@@ -22,7 +22,7 @@ Revision History
|
||||
--*/
|
||||
|
||||
#include "Undi32.h"
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
//
|
||||
// Global Variables
|
||||
//
|
||||
@@ -30,7 +30,7 @@ PXE_SW_UNDI *pxe = 0; // 3.0 entry point
|
||||
PXE_SW_UNDI *pxe_31 = 0; // 3.1 entry
|
||||
UNDI32_DEV *UNDI32DeviceList[MAX_NIC_INTERFACES];
|
||||
|
||||
NII_TABLE *UnidiDataPointer=NULL;
|
||||
NII_TABLE *UndiDataPointer = NULL;
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
@@ -103,7 +103,7 @@ UndiNotifyExitBs (
|
||||
|
||||
Routine Description:
|
||||
|
||||
When EFI is shuting down the boot services, we need to install a
|
||||
When EFI is shuting down the boot services, we need to install a
|
||||
configuration table for UNDI to work at runtime!
|
||||
|
||||
Arguments:
|
||||
@@ -152,15 +152,15 @@ Routine Description:
|
||||
Arguments:
|
||||
|
||||
This - Protocol instance pointer.
|
||||
|
||||
|
||||
Controller - Handle of device to test.
|
||||
|
||||
|
||||
RemainingDevicePath - Not used.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - This driver supports this device.
|
||||
|
||||
|
||||
other - This driver does not support this device.
|
||||
|
||||
--*/
|
||||
@@ -266,15 +266,15 @@ Routine Description:
|
||||
Arguments:
|
||||
|
||||
This - Protocol instance pointer.
|
||||
|
||||
|
||||
Controller - Handle of device to work with.
|
||||
|
||||
|
||||
RemainingDevicePath - Not used, always produce all possible children.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - This driver is added to Controller.
|
||||
|
||||
|
||||
other - This driver does not support this device.
|
||||
|
||||
--*/
|
||||
@@ -286,7 +286,7 @@ Returns:
|
||||
UINT16 NewCommand;
|
||||
UINT8 *TmpPxePointer;
|
||||
EFI_PCI_IO_PROTOCOL *PciIoFncs;
|
||||
UINTN Len;
|
||||
UINTN Len;
|
||||
UINT64 Supports;
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
@@ -334,6 +334,20 @@ Returns:
|
||||
|
||||
ZeroMem ((CHAR8 *) UNDI32Device, sizeof (UNDI32_DEV));
|
||||
|
||||
//
|
||||
// Get original PCI attributes
|
||||
//
|
||||
Status = PciIoFncs->Attributes (
|
||||
PciIoFncs,
|
||||
EfiPciIoAttributeOperationGet,
|
||||
0,
|
||||
&UNDI32Device->NicInfo.OriginalPciAttributes
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// allocate and initialize both (old and new) the !pxe structures here,
|
||||
// there should only be one copy of each of these structure for any number
|
||||
@@ -509,22 +523,22 @@ Returns:
|
||||
}
|
||||
|
||||
//
|
||||
// if the table exists, free it and alloc again, or alloc it directly
|
||||
// if the table exists, free it and alloc again, or alloc it directly
|
||||
//
|
||||
if (UnidiDataPointer != NULL) {
|
||||
Status = gBS->FreePool(UnidiDataPointer);
|
||||
if (UndiDataPointer != NULL) {
|
||||
Status = gBS->FreePool(UndiDataPointer);
|
||||
}
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto UndiErrorDeleteDevicePath;
|
||||
}
|
||||
|
||||
Len = (pxe_31->IFcnt * sizeof (NII_ENTRY)) + sizeof (UnidiDataPointer);
|
||||
Status = gBS->AllocatePool (EfiRuntimeServicesData, Len, (VOID **) &UnidiDataPointer);
|
||||
Len = (pxe_31->IFcnt * sizeof (NII_ENTRY)) + sizeof (UndiDataPointer);
|
||||
Status = gBS->AllocatePool (EfiRuntimeServicesData, Len, (VOID **) &UndiDataPointer);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto UndiErrorAllocDataPointer;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Open For Child Device
|
||||
//
|
||||
@@ -563,6 +577,16 @@ UndiErrorDeletePxe:
|
||||
}
|
||||
|
||||
UndiErrorDeleteDevice:
|
||||
//
|
||||
// Restore original PCI attributes
|
||||
//
|
||||
PciIoFncs->Attributes (
|
||||
PciIoFncs,
|
||||
EfiPciIoAttributeOperationSet,
|
||||
UNDI32Device->NicInfo.OriginalPciAttributes,
|
||||
NULL
|
||||
);
|
||||
|
||||
gBS->FreePool (UNDI32Device);
|
||||
|
||||
UndiError:
|
||||
@@ -659,6 +683,17 @@ Returns:
|
||||
|
||||
UNDI32Device = UNDI_DEV_FROM_THIS (NIIProtocol);
|
||||
|
||||
//
|
||||
// Restore original PCI attributes
|
||||
//
|
||||
Status = UNDI32Device->NicInfo.Io_Function->Attributes (
|
||||
UNDI32Device->NicInfo.Io_Function,
|
||||
EfiPciIoAttributeOperationSet,
|
||||
UNDI32Device->NicInfo.OriginalPciAttributes,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
@@ -721,7 +756,7 @@ Routine Description:
|
||||
Arguments:
|
||||
|
||||
UnqId - Runtime O/S routine might use this, this temp routine does not use it
|
||||
|
||||
|
||||
MicroSeconds - Determines the length of pause.
|
||||
|
||||
Returns:
|
||||
@@ -751,13 +786,13 @@ Routine Description:
|
||||
Arguments:
|
||||
|
||||
UnqId - Runtime O/S routine may use this field, this temp routine does not.
|
||||
|
||||
|
||||
ReadWrite - Determine if it is an I/O or Memory Read/Write Operation.
|
||||
|
||||
|
||||
Len - Determines the width of the data operation.
|
||||
|
||||
|
||||
Port - What port to Read/Write from.
|
||||
|
||||
|
||||
BuffAddr - Address to read to or write from.
|
||||
|
||||
Returns:
|
||||
@@ -851,15 +886,15 @@ Routine Description:
|
||||
Arguments:
|
||||
|
||||
DevPtr - Pointer which will point to the newly created device path with the MAC node attached.
|
||||
|
||||
|
||||
BaseDevPtr - Pointer to the device path which the UNDI device driver is latching on to.
|
||||
|
||||
|
||||
AdapterInfo - Pointer to the NIC data structure information which the UNDI driver is layering on..
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - A MAC address was successfully appended to the Base Device Path.
|
||||
|
||||
|
||||
other - Not enough resources available to create new Device Path node.
|
||||
|
||||
--*/
|
||||
@@ -991,7 +1026,7 @@ Arguments:
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Install a GUID/Pointer pair into the system's configuration table.
|
||||
|
||||
|
||||
other - Did not successfully install the GUID/Pointer pair into the configuration table.
|
||||
|
||||
--*/
|
||||
@@ -1007,12 +1042,12 @@ Returns:
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if(UnidiDataPointer == NULL) {
|
||||
if(UndiDataPointer == NULL) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
UndiData = (NII_TABLE *)UnidiDataPointer;
|
||||
|
||||
|
||||
UndiData = (NII_TABLE *)UndiDataPointer;
|
||||
|
||||
UndiData->NumEntries = pxe_31->IFcnt;
|
||||
UndiData->NextLink = NULL;
|
||||
|
||||
@@ -1067,12 +1102,12 @@ Returns:
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
|
||||
Install driver binding protocol of UNDI.
|
||||
|
||||
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
||||
|
||||
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
||||
@param[in] SystemTable A pointer to the EFI System Table.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS The entry point is executed successfully.
|
||||
@retval other Some error occurs when executing this entry point.
|
||||
|
||||
|
@@ -2,13 +2,13 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006, 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
@@ -157,7 +157,7 @@ VOID PhyReset (NIC_DATA_INSTANCE *AdapterInfo);
|
||||
VOID
|
||||
MdiWrite (
|
||||
IN NIC_DATA_INSTANCE *AdapterInfo,
|
||||
IN UINT8 RegAddress,
|
||||
IN UINT8 RegAddress,
|
||||
IN UINT8 PhyAddress,
|
||||
IN UINT16 DataValue
|
||||
);
|
||||
@@ -165,7 +165,7 @@ MdiWrite (
|
||||
VOID
|
||||
MdiRead(
|
||||
IN NIC_DATA_INSTANCE *AdapterInfo,
|
||||
IN UINT8 RegAddress,
|
||||
IN UINT8 RegAddress,
|
||||
IN UINT8 PhyAddress,
|
||||
IN OUT UINT16 *DataValue
|
||||
);
|
||||
|
Reference in New Issue
Block a user