diff options
author | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
---|---|---|
committer | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
commit | b7c51c9cf4864df6aabb99a1ae843becd577237c (patch) | |
tree | eebe9b0d0ca03062955223097e57da84dd618b9a /Board/EM/IdeAcoustic | |
download | zprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz |
Diffstat (limited to 'Board/EM/IdeAcoustic')
-rw-r--r-- | Board/EM/IdeAcoustic/Acoustic.c | 393 | ||||
-rw-r--r-- | Board/EM/IdeAcoustic/Acoustic.chm | bin | 0 -> 69957 bytes | |||
-rw-r--r-- | Board/EM/IdeAcoustic/Acoustic.cif | 19 | ||||
-rw-r--r-- | Board/EM/IdeAcoustic/Acoustic.dxs | 59 | ||||
-rw-r--r-- | Board/EM/IdeAcoustic/Acoustic.h | 129 | ||||
-rw-r--r-- | Board/EM/IdeAcoustic/Acoustic.mak | 97 | ||||
-rw-r--r-- | Board/EM/IdeAcoustic/Acoustic.sd | 433 | ||||
-rw-r--r-- | Board/EM/IdeAcoustic/Acoustic.sdl | 137 | ||||
-rw-r--r-- | Board/EM/IdeAcoustic/Acoustic.uni | bin | 0 -> 10130 bytes | |||
-rw-r--r-- | Board/EM/IdeAcoustic/AcousticBoard.c | 460 | ||||
-rw-r--r-- | Board/EM/IdeAcoustic/AcousticSetup.c | 332 |
11 files changed, 2059 insertions, 0 deletions
diff --git a/Board/EM/IdeAcoustic/Acoustic.c b/Board/EM/IdeAcoustic/Acoustic.c new file mode 100644 index 0000000..f52d7c1 --- /dev/null +++ b/Board/EM/IdeAcoustic/Acoustic.c @@ -0,0 +1,393 @@ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** +//********************************************************************** +// $Header: /Alaska/SOURCE/Modules/HddAcoustic/Acoustic.c 5 12/19/11 1:09a Rameshr $ +// +// $Revision: 5 $ +// +// $Date: 12/19/11 1:09a $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/HddAcoustic/Acoustic.c $ +// +// 5 12/19/11 1:09a Rameshr +// [TAG] EIP77527 +// [Category] Improvement +// [Description] IdeSecurity, IdeAcoustic and IdeSmart changes should be +// done based on the Core Version checking. +// [Files] IdeSecurity.c, IdeSmart.c , Acoustic.c +// +// 4 12/05/11 6:22p Rajkumarkc +// [TAG] EIP77142 +// [Category] Improvement +// [Description] Added the function 'IdeNonDataCommandExp' in the +// 'IDE_BUS_PROTOCOL' and removed the existing function +// 'IdeNonDataCommand' for supporting the upper 24bits of LBA. +// [Files] +// Ata.c, IdeBus.c, Idebus.h, PIDEBus.h, Acoustic.c, IdeSecurity.c, +// IdeSMART.c +// +// 3 2/10/11 11:25a Pats +// [TAG] - EIP 52920 +// [Category]- Function Request +// [Severity]- Minor +// [Symptom] - The Acoustic mode (Bypass/Quiet/Max Performance) of port 5 +// is invalid on AMD SB700. +// [RootCause] - Special case where 2nd controller counts by incrementing +// device number only not handled properly +// [Solution] - Modified functions that handle this case. +// [Files] - Acoustic.c, AcousticBoard.c, AcousticSetup.c +// +// 2 1/07/11 12:07p Pats +// Changed the name of a variable from SataPortIndex to IdeDevice, for +// consistancy. No coding change. +// +// 1 1/05/11 12:22a Rameshr +// Initial check-in for Hdd Acoustic Management Support. +// +//********************************************************************** + + +//<AMI_FHDR_START> +//---------------------------------------------------------------------------- +// +// Name: Acoustic.c +// +// Description: Initialize and provide a protocol for the Acoustic support. +// +//---------------------------------------------------------------------------- +//<AMI_FHDR_END> + +#include <Efi.h> +#include <Dxe.h> + +#include "Acoustic.h" + +extern EFI_GUID gAcousticSetupProtocolguid; + +EFI_GUID gEfiDiskInfoProtocolGuid = EFI_DISK_INFO_PROTOCOL_GUID; +EFI_GUID gEfiBlockIoProtocolGuid = EFI_BLOCK_IO_PROTOCOL_GUID; +EFI_GUID gEfiAhciBusProtocolGuid = AHCI_BUS_INIT_PROTOCOL_GUID; +EFI_GUID gEfiIdeBusInitProtocolGuid = IDE_BUS_INIT_PROTOCOL_GUID; + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: AcousticEntryPoint +// +// Description: This routine is the entry point for the Acoustic driver. It +// Initializes various controllers and installs Driver Binding +// protocol +// +// Input: ImageHandle Handle to this driver image +// SystemTable Pointer to the system table +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS +AcousticEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable +) +{ + InitAmiLib(ImageHandle, SystemTable); + +#ifdef Debug_Level_1 + TRACE((-1,"AcousticEntryPoint Status = %x\n", Status)); +#endif + + Acoustic_BoardInit (ImageHandle, SystemTable); + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: AcousticProgramming +// +// Description: This function is called after all the controllers have been +// dispatched and at the end of BDS phase. +// +// +// Input: IN EFI_EVENT Event +// IN VOID *Context +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID +AcousticProgramming ( + IN EFI_EVENT Event, + IN VOID *Context +) +{ + EFI_STATUS Status; + EFI_DISK_INFO_PROTOCOL *DiskInfo; + EFI_PCI_IO_PROTOCOL *PciIo; + EFI_DEVICE_PATH_PROTOCOL *Dp; + ACOUSTIC_SETUP_PROTOCOL *AcousticSetupProtocol; + IDENTIFY_DATA *IdentifyDriveInfo = NULL; + UINT32 IdeDevice, IdeChannel, PortIndex; + UINTN i, j, Number, Number1; + EFI_HANDLE *Controller_Handle = NULL, *Device_Handle = NULL, Handle = NULL; + SETUP_DATA *SetupData = NULL; + UINT32 BufferSize; + UINT16 CurrentLevel; + UINT8 SubClassCode; + + Status = pBS->CloseEvent (Event); + + Status = pBS->LocateHandleBuffer(ByProtocol,&gAcousticSetupProtocolguid, NULL, &Number, &Controller_Handle); + if (EFI_ERROR(Status)) { + return; + } + // + // Get the Identify Data + // + Status = pBS->AllocatePool(EfiBootServicesData, sizeof (IDENTIFY_DATA), &IdentifyDriveInfo); + ASSERT_EFI_ERROR (Status); + + for(i=0; i<Number; i++) { + Status = pBS->HandleProtocol(Controller_Handle[i],&gAcousticSetupProtocolguid,&AcousticSetupProtocol); + if (EFI_ERROR(Status)) { + continue; + } + + Status = pBS->LocateHandleBuffer(ByProtocol,&gEfiDiskInfoProtocolGuid, NULL, &Number1, &Device_Handle); + if (EFI_ERROR(Status)) { + continue; + } + + for(j = 0; j < Number1; j++) { + // + // Now try to locate the Controller on which the device is connected + // + Status = pBS->HandleProtocol(Device_Handle[j],&gEfiDevicePathProtocolGuid,&Dp); + if (EFI_ERROR(Status)) { + continue; + } + + Status = pBS->LocateDevicePath(&gEfiPciIoProtocolGuid, &Dp, &Handle); + // + // If the controller handle doesn't match then it is a different IDE controller + // + if (Handle != Controller_Handle[i]) { + continue; + } + + Status = pBS->HandleProtocol(Device_Handle[j], &gEfiDiskInfoProtocolGuid, &DiskInfo); + if (EFI_ERROR(Status)) { + continue; + } + + Status = pBS->HandleProtocol(Controller_Handle[i], &gEfiPciIoProtocolGuid, &PciIo); + if (EFI_ERROR(Status)) { + continue; + } + + Status = PciIo->Pci.Read(PciIo, EfiPciIoWidthUint8, 0xA, 1, &SubClassCode); + // + // Get the location of the drive + // + Status = DiskInfo->WhichIde (DiskInfo, &IdeChannel, &IdeDevice); + + if (SubClassCode == 1) { // Ide mode + PortIndex = (IdeChannel * 2) + IdeDevice; + if (PortIndex == 1 || PortIndex == 2) { + PortIndex ^= 3; + } + } else { + PortIndex = IdeChannel; + } +#if SECOND_CONTROLLER_COUNTS_BY_DEVICE + if ( (SubClassCode == 1) && \ + (AcousticSetupProtocol->ControllerNumber == 1) ) { + PortIndex = IdeDevice; + } +#endif + AcousticSetupProtocol->DeviceDetected[PortIndex] = 1; + + BufferSize = sizeof (IDENTIFY_DATA); + + Status = DiskInfo->Identify (DiskInfo, IdentifyDriveInfo, &BufferSize); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR(Status)) { + continue; + } + // + // Does it support Acoustics? + // + if (!(IdentifyDriveInfo->Command_Set_Supported_83 & AUTOMATIC_ACOUSTIC_FEATURE_SET_SUPPORTED)) { + AcousticSetupProtocol->AcousticSupportIndv[PortIndex] = 0; + continue; + } + // + // Get the drive's current acoustic value + // + CurrentLevel = (IdentifyDriveInfo->Acoustic_Level_94); + // + // Acoustic is supported by the drive + // + AcousticSetupProtocol->AcousticSupportIndv[PortIndex] = 1; + + if (AcousticSetupProtocol->AcousticLevelIndv[PortIndex] != ACOUSTIC_SUPPORT_DISABLE) { + if (AcousticSetupProtocol->AcousticLevelIndv[PortIndex] == ACOUSTIC_LEVEL_BYPASS) { + if ( (CurrentLevel & 0xFF) != (CurrentLevel >> 8) ) { // If not already set + Status = IssueSetFeatureCmd(Controller_Handle[i], + Device_Handle[j], + ACOUSTIC_MANAGEMENT_ENABLE, + (UINT8)(IdentifyDriveInfo->Acoustic_Level_94 >> 8)); + } + } else { + if ( AcousticSetupProtocol->AcousticLevelIndv[PortIndex] != (UINT8)(CurrentLevel & 0xFF) ) { + Status = IssueSetFeatureCmd(Controller_Handle[i], + Device_Handle[j], + ACOUSTIC_MANAGEMENT_ENABLE, + AcousticSetupProtocol->AcousticLevelIndv[PortIndex]); + } + } + } else { + // + // Acoustic disabled in Setup but not in drive then issue cmd + // + if (IdentifyDriveInfo->Command_Set_Enabled_86 & AUTOMATIC_ACOUSTIC_FEATURE_SET_SUPPORTED) { + Status = IssueSetFeatureCmd(Controller_Handle[i], + Device_Handle[j], + ACOUSTIC_MANAGEMENT_DISABLE, + 0); + } + } + } + } + + pBS->FreePool (IdentifyDriveInfo); + + if (Controller_Handle) { + pBS->FreePool (Controller_Handle); + } + + if (Device_Handle) { + pBS->FreePool (Device_Handle); + } + + return; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: IssueSetFeatureCmd +// +// Description: This function issues the SetFeature cmd +// +// Input: EFI_HANDLE ControllerHandle, +// EFI_HANDLE DeviceHandle, +// UINT8 SubCommand, +// UINT8 Mode +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS +IssueSetFeatureCmd ( + EFI_HANDLE ControllerHandle, + EFI_HANDLE DeviceHandle, + UINT8 SubCommand, + UINT8 Mode +) +{ + EFI_STATUS Status; + EFI_BLOCK_IO_PROTOCOL *BlockIO; + AHCI_BUS_PROTOCOL *AhciBusInterface; + SATA_DEVICE_INTERFACE *SataDevInterface; + IDE_BUS_PROTOCOL *IdeBusInterface; + COMMAND_STRUCTURE CommandStructure = {0}; + + Status = pBS->HandleProtocol(DeviceHandle, &gEfiBlockIoProtocolGuid, &BlockIO); + ASSERT_EFI_ERROR(Status); + + if (EFI_ERROR(Status)) { + return Status; + } + // + // Check if IDE/AHCI by check if IDEBus/AHCUBus Protocol is installed + // + Status = pBS->OpenProtocol( ControllerHandle, + &gEfiIdeBusInitProtocolGuid, + &IdeBusInterface, + TheImageHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL ); + if(!EFI_ERROR(Status)) { + // + // We are in IDE mode + // + IdeBusInterface = ((IDE_BLOCK_IO *)BlockIO)->IdeBusInterface; + + // + // Idebus API changed from Core 4.6.5.2. Added Core Version check for the OLD + // Core support. + // +#if defined CORE_COMBINED_VERSION && (CORE_COMBINED_VERSION > 0x4028b) + + Status = IdeBusInterface->IdeNonDataCommand(IdeBusInterface, + SubCommand, Mode, 0, 0, 0, 0, 0, + 0, 0, IdeBusInterface->IdeDevice.Device << 4, + SET_FEATURE_COMMAND); +#else + Status = IdeBusInterface->IdeNonDataCommand(IdeBusInterface, + SubCommand, Mode, 0, + 0, 0, IdeBusInterface->IdeDevice.Device << 4, + SET_FEATURE_COMMAND); +#endif + return Status; + } + + Status = pBS->OpenProtocol( ControllerHandle, + &gEfiAhciBusProtocolGuid, + &AhciBusInterface, + TheImageHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL ); + + if(!EFI_ERROR(Status)) { + SataDevInterface = ((SATA_BLOCK_IO *)BlockIO)->SataDevInterface; + // + // It is in AHCI mode + // + CommandStructure.Command = SET_FEATURE_COMMAND; + CommandStructure.Features = SubCommand; + CommandStructure.SectorCount = Mode; + Status = AhciBusInterface->ExecuteNonDataCommand (SataDevInterface, CommandStructure); + } + + return Status; +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//**********************************************************************
\ No newline at end of file diff --git a/Board/EM/IdeAcoustic/Acoustic.chm b/Board/EM/IdeAcoustic/Acoustic.chm Binary files differnew file mode 100644 index 0000000..8914423 --- /dev/null +++ b/Board/EM/IdeAcoustic/Acoustic.chm diff --git a/Board/EM/IdeAcoustic/Acoustic.cif b/Board/EM/IdeAcoustic/Acoustic.cif new file mode 100644 index 0000000..7d2c90c --- /dev/null +++ b/Board/EM/IdeAcoustic/Acoustic.cif @@ -0,0 +1,19 @@ +<component> + name = "IdeAcoustic" + category = eModule + LocalRoot = "Board\EM\IdeAcoustic" + RefName = "Acoustic" +[files] +"Acoustic.sdl" +"Acoustic.mak" +"Acoustic.c" +"Acoustic.h" +"AcousticBoard.c" +"AcousticSetup.c" +"Acoustic.dxs" +"Acoustic.sd" +"Acoustic.uni" +"Acoustic.chm" +[parts] +"AcousticProtocol" +<endComponent> diff --git a/Board/EM/IdeAcoustic/Acoustic.dxs b/Board/EM/IdeAcoustic/Acoustic.dxs new file mode 100644 index 0000000..65610ee --- /dev/null +++ b/Board/EM/IdeAcoustic/Acoustic.dxs @@ -0,0 +1,59 @@ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** +//********************************************************************** +// +// $Header: /Alaska/SOURCE/Modules/HddAcoustic/Acoustic.dxs 1 1/05/11 12:22a Rameshr $ +// +// $Revision: 1 $ +// +// $Date: 1/05/11 12:22a $ +// +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/HddAcoustic/Acoustic.dxs $ +// +// 1 1/05/11 12:22a Rameshr +// Initial check-in for Hdd Acoustic Management Support. +// +//********************************************************************** + +//<AMI_FHDR_START> +//---------------------------------------------------------------------------- +// +// Name: Acoustic.DXS +// +// Description: This file is the dependency file for the Acoustic +// driver +// +//---------------------------------------------------------------------------- +//<AMI_FHDR_END> + +DEPENDENCY_START + TRUE +DEPENDENCY_END + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/Board/EM/IdeAcoustic/Acoustic.h b/Board/EM/IdeAcoustic/Acoustic.h new file mode 100644 index 0000000..9097ae7 --- /dev/null +++ b/Board/EM/IdeAcoustic/Acoustic.h @@ -0,0 +1,129 @@ +//**********************************************************************// +//**********************************************************************// +//** **// +//** (C)Copyright 1985-2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 **// +//** **// +//** Phone: (770)-246-8600 **// +//** **// +//**********************************************************************// +//**********************************************************************// +//**********************************************************************// +// $Header: /Alaska/SOURCE/Modules/HddAcoustic/Acoustic.h 2 1/05/11 6:32p Pats $ +// +// $Revision: 2 $ +// +// $Date: 1/05/11 6:32p $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/HddAcoustic/Acoustic.h $ +// +// 2 1/05/11 6:32p Pats +// Removed inlcude of SB.h, and all south bridge-specific defines. +// +// 1 1/05/11 12:22a Rameshr +// Initial check-in for Hdd Acoustic Management Support. +// +//************************************************************************* +//<AMI_FHDR_START> +// +// Name: Acoustic.h +// +// Description: Acoustic header file +// +//<AMI_FHDR_END> +//************************************************************************* + +#ifndef _Acoustic_H +#define _Acoustic_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <Token.h> +#include <AmiLib.h> +#include <AmiDxeLib.h> +#include <pci.h> +#include <Setup.h> +#include <Protocol\AcousticProtocol.h> +#include <Protocol\PciIo.h> +#include <Protocol\DevicePath.h> +#include <protocol\BlockIo.h> +#include <Protocol\PDiskInfo.h> +#include <Protocol\PIDEController.h> +#include <Protocol\PIDEBus.h> +#include <Protocol\PciRootBridgeIo.h> +#include <Protocol\DriverBinding.h> +#include <Protocol\PAhciBus.h> + +// +// PCI Defines +// +#ifndef PCI_SCC +#define PCI_SCC 0x000A // Sub Class Code Register +#endif +#ifndef PCI_CL_MASS_STOR_SCL_IDE +#define PCI_CL_MASS_STOR_SCL_IDE 0x01 // Ide Mode +#endif +#define MmPciAddress(Base, Bus, Device, Function, Register) \ + ( (UINTN)(Base) + \ + (UINTN)(Bus << 20) + \ + (UINTN)(Device << 15) + \ + (UINTN)(Function << 12) + \ + (UINTN)(Register) ) + +// +// Constant Defines +// +#define AUTOMATIC_ACOUSTIC_FEATURE_SET_SUPPORTED 0x0200 + +// +// Function defines +// +EFI_STATUS +Acoustic_BoardInit ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable +); + +EFI_STATUS +AcousticEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable +); + +EFI_STATUS +IssueSetFeatureCmd ( + EFI_HANDLE ControllerHandle, + EFI_HANDLE DeviceHandle, + UINT8 SubCommand, + UINT8 Mode +); + +extern EFI_GUID gEfiDevicePathProtocolGuid; + +/****** DO NOT WRITE BELOW THIS LINE *******/ +#ifdef __cplusplus +} +#endif + +#endif + +//**********************************************************************// +//**********************************************************************// +//** **// +//** (C)Copyright 1985-2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 **// +//** **// +//** Phone: (770)-246-8600 **// +//** **// +//**********************************************************************// +//**********************************************************************// diff --git a/Board/EM/IdeAcoustic/Acoustic.mak b/Board/EM/IdeAcoustic/Acoustic.mak new file mode 100644 index 0000000..b63ae9f --- /dev/null +++ b/Board/EM/IdeAcoustic/Acoustic.mak @@ -0,0 +1,97 @@ +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2010, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* + +#************************************************************************* +# $Header: /Alaska/SOURCE/Modules/HddAcoustic/Acoustic.mak 1 1/05/11 12:22a Rameshr $ +# +# $Revision: 1 $ +# +# $Date: 1/05/11 12:22a $ +#************************************************************************* +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/HddAcoustic/Acoustic.mak $ +# +# 1 1/05/11 12:22a Rameshr +# Initial check-in for Hdd Acoustic Management Support. +# +#************************************************************************* +#<AMI_FHDR_START> +# +# Name: Acoustic.mak +# +# Description: Make file for the Acoustic Module +# +# +#<AMI_FHDR_END> +#************************************************************************* +all : Acoustic + +Acoustic : $(BUILD_DIR)\Acoustic.mak AcousticBin + +$(BUILD_DIR)\Acoustic.mak : $(ACOUSTIC_DIR)\Acoustic.cif $(ACOUSTIC_DIR)\Acoustic.mak $(BUILD_RULES) + $(CIF2MAK) $(ACOUSTIC_DIR)\Acoustic.cif $(CIF2MAK_DEFAULTS) + +Acoustic_OBJECTS = \ + $(BUILD_DIR)\$(ACOUSTIC_DIR)\Acoustic.obj\ + $(BUILD_DIR)\$(ACOUSTIC_DIR)\AcousticBoard.obj\ + +Acoustic_INCLUDES = \ + /I$(PROJECT_DIR)\ + /I$(SB_CHIPSET_DIR)\ + /I$(ACOUSTIC_DIR)\ + /I$(SB_BOARD_DIR)\ + + +AcousticBin : $(AMIDXELIB) $(AMICSPLib) $(EFIDRIVERLIB) + $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\ + "MY_INCLUDES=$(Acoustic_INCLUDES)"\ + /f $(BUILD_DIR)\Acoustic.mak all\ + GUID=0639408B-19A6-4b5d-BAFB-12A2F5114032\ + ENTRY_POINT=AcousticEntryPoint\ + TYPE=BS_DRIVER \ + COMPRESS=1 HAS_RESOURCES=1\ + "OBJECTS=$(Acoustic_OBJECTS)" + +#--------------------------------------------------------------------------- +# Create Acoustic Setup Screens +#--------------------------------------------------------------------------- +!IF "$(LOCAL_ACOUSTIC_SETUP)"=="1" + +SetupSdbs : $(BUILD_DIR)\Acoustic.mak ACOUSTICSDB +SetupBin : $(BUILD_DIR)\AcousticSetup.obj + +ACOUSTICSDB : + $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\ + /f $(BUILD_DIR)\Acoustic.mak all\ + TYPE=SDB NAME=Acoustic MAKEFILE=$(BUILD_DIR)\Acoustic.Mak STRING_CONSUMERS=$(ACOUSTIC_DIR)\Acoustic.sd + +$(BUILD_DIR)\AcousticSetup.obj : $(ACOUSTIC_DIR)\AcousticSetup.c $(BUILD_DIR)\SetupStrTokens.h + $(CC) $(CFLAGS) /Fo$(BUILD_DIR)\ $(ACOUSTIC_DIR)\AcousticSetup.c + +!ENDIF + +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2010, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* diff --git a/Board/EM/IdeAcoustic/Acoustic.sd b/Board/EM/IdeAcoustic/Acoustic.sd new file mode 100644 index 0000000..962015b --- /dev/null +++ b/Board/EM/IdeAcoustic/Acoustic.sd @@ -0,0 +1,433 @@ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** +//********************************************************************** +// +// $Header: /Alaska/SOURCE/Modules/HddAcoustic/Acoustic.sd 3 9/22/11 4:17a Rameshr $ +// +// $Revision: 3 $ +// +// $Date: 9/22/11 4:17a $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/HddAcoustic/Acoustic.sd $ +// +// 3 9/22/11 4:17a Rameshr +// [TAG] EIP68563 +// [Category] Improvement +// [Description] Manufacturing Mode not set for the Acoustic setup +// options. +// [Files] Acoustic.sd +// +// 2 1/11/11 12:02a Rameshr +// Coding Error Resolved. +// +// 1 1/05/11 12:22a Rameshr +// Initial check-in for Hdd Acoustic Management Support. +//********************************************************************** +//<AMI_FHDR_START> +// +// Name: Acoustic.SD +// +// Description: Acoustic driver Setup data definitions +// +//<AMI_FHDR_END> +//********************************************************************** + +#ifdef SETUP_DATA_DEFINITION +/***********************************************************/ +/* Put NVRAM data definitions here. +/* For example: UINT8 Data1; +/* These definitions will be converted by the build process +/* to a definitions of SETUP_DATA fields. +/***********************************************************/ +#define DEV 0 + +#if (EFI_SPECIFICATION_VERSION > 0x00020000) + #define DEV00 0 + #define DEV01 1 + #define DEV02 2 + #define DEV03 3 + #define DEV04 4 + #define DEV05 5 + #define DEV06 6 + #define DEV07 7 + #define DEV08 8 + #define DEV09 9 + #define DEV10 10 + #define DEV11 11 + #define DEV12 12 + #define DEV13 13 +#else + #define DEV00 1 + #define DEV01 2 + #define DEV02 3 + #define DEV03 4 + #define DEV04 5 + #define DEV05 6 + #define DEV06 7 + #define DEV07 8 + #define DEV08 9 + #define DEV09 10 + #define DEV10 11 + #define DEV11 12 + #define DEV12 13 + #define DEV13 14 +#endif + UINT8 AcousticPwrMgmt; + UINT8 AcousticLevel; +// +// Porting required +// +// Add more elements if there are more than 6 SATA ports + UINT8 AcousticSupported[ACOUSTIC_DEVICE_COUNT]; + UINT8 AcousticLevelIndv[ACOUSTIC_DEVICE_COUNT]; + UINT8 AcDevicePresent[ACOUSTIC_DEVICE_COUNT]; +#endif + +#if defined(VFRCOMPILE) && !defined(CONTROLS_ARE_DEFINED) +#define CONTROL_DEFINITION +#endif +#ifdef CONTROL_DEFINITION + +#define ACOUSTIC_ONEOF_ACOUSTICPWRMGMT\ + oneof varid = SETUP_DATA.AcousticPwrMgmt,\ + prompt = STRING_TOKEN(STR_AUTO_ACOUSTIC),\ + help = STRING_TOKEN(STR_AUTO_ACOUSTIC_HELP),\ + option text = STRING_TOKEN(STR_ENABLED_STRING), value = 1, flags = 0, key = 0;\ + option text = STRING_TOKEN(STR_DISABLED_STRING), value = 0, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED, key = 0;\ + endoneof; + +#if !INDIVIDUAL_ACOUSTIC_SUPPORT + +#define ACOUSTIC_ONEOF_ACOUSTICLEVEL\ + oneof varid = SETUP_DATA.AcousticLevel,\ + prompt = STRING_TOKEN(STR_AUTO_ACOUSTIC_MODE),\ + help = STRING_TOKEN(STR_AUTO_ACOUSTIC_MODE_HELP),\ + option text = STRING_TOKEN(STR_BYPASS_STRING), value = 0xFF, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED, key = 0;\ + option text = STRING_TOKEN(STR_QUIET_STRING), value = 0x80, flags = 0, key = 0;\ + option text = STRING_TOKEN(STR_MAXIMUM_PERFORMANCE_STRING), value = 0xFE, flags = 0, key = 0;\ + endoneof; + +#else + #define ACOUSTIC_ONEOF_ACOUSTICLEVEL +#endif // END #if !INDIVIDUAL_ACOUSTIC_SUPPORT + +#if INDIVIDUAL_ACOUSTIC_SUPPORT + +#define ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_PRESENT(DEV)\ + oneof varid = SETUP_DATA.AcousticLevelIndv[DEV],\ + prompt = STRING_TOKEN(STR_AUTO_ACOUSTIC_MODE_INDV),\ + help = STRING_TOKEN(STR_AUTO_ACOUSTIC_MODE_HELP),\ + option text = STRING_TOKEN(STR_BYPASS_STRING), value = 0xFF, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED, key = 0;\ + option text = STRING_TOKEN(STR_QUIET_STRING), value = 0x80, flags = 0, key = 0;\ + option text = STRING_TOKEN(STR_MAXIMUM_PERFORMANCE_STRING), value = 0xFE, flags = 0, key = 0;\ + endoneof; + +#define ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTSUPPORTED(DEV)\ + oneof varid = SETUP_DATA.AcousticLevelIndv[DEV],\ + prompt = STRING_TOKEN(STR_AUTO_ACOUSTIC_MODE_INDV),\ + help = STRING_TOKEN(STR_AUTO_ACOUSTIC_MODE_HELP),\ + option text = STRING_TOKEN(STR_NOT_SUPPORTED), value = 0xFF, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED, key = 0;\ + endoneof; + +#define ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTAVAILABLE(DEV)\ + oneof varid = SETUP_DATA.AcousticLevelIndv[DEV],\ + prompt = STRING_TOKEN(STR_AUTO_ACOUSTIC_MODE_INDV),\ + help = STRING_TOKEN(STR_AUTO_ACOUSTIC_MODE_HELP),\ + option text = STRING_TOKEN(STR_NOT_AVAILABLE), value = 0xFF, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED, key = 0;\ + endoneof; + +#else + #define ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_PRESENT(DEV) + #define ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTSUPPORTED(DEV) + #define ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTAVAILABLE(DEV) +#endif // END #if INDIVIDUAL_ACOUSTIC_SUPPORT +#endif // END #ifdef CONTROL_DEFINITION + +#ifdef CONTROLS_WITH_DEFAULTS + ACOUSTIC_ONEOF_ACOUSTICPWRMGMT + ACOUSTIC_ONEOF_ACOUSTICLEVEL + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_PRESENT(DEV) + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTSUPPORTED(DEV) + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTAVAILABLE(DEV) +#endif // END #ifdef CONTROLS_WITH_DEFAULTS + +#ifdef ADVANCED_FORM_SET + +#ifndef SUPPRESS_GRAYOUT_ENDIF +#define SUPPRESS_GRAYOUT_ENDIF endif; +#endif + +#ifdef FORM_SET_TYPEDEF +// +//If you need any additional type definitions add them here +// +#endif + +#ifdef FORM_SET_VARSTORE +// +//If you need custom varstore's define them here +// +#endif + + #ifdef FORM_SET_ITEM +// +// Define controls to be added to the main page of the formset +// + + #endif + + #ifdef FORM_SET_GOTO + // + // Define goto commands for the forms defined in this file + // + goto SATA_ACOUSTIC_DEVICE_OPTIONS_FORM_ID, + prompt = STRING_TOKEN(STR_ACOUSTIC_SUBTITLE), + help = STRING_TOKEN(STR_ACOUSTIC_SUBTITLE_HELP); + #endif + + #ifdef FORM_SET_FORM + // + // Define forms + // + + #ifndef ACOUSTIC_FORM_MAIN + #define ACOUSTIC_FORM_MAIN + form formid = AUTO_ID(SATA_ACOUSTIC_DEVICE_OPTIONS_FORM_ID), + title = STRING_TOKEN(STR_SATA_ACOUSTIC_OPTIONS_FORM_TITLE); + + SEPARATOR + SUBTITLE(STRING_TOKEN(STR_ACOUSTIC_SUBTITLE)) + SEPARATOR + + ACOUSTIC_ONEOF_ACOUSTICPWRMGMT + + #if !INDIVIDUAL_ACOUSTIC_SUPPORT + suppressif ideqval SETUP_DATA.AcousticPwrMgmt == 0x0; + ACOUSTIC_ONEOF_ACOUSTICLEVEL + endif; + #endif + + #if INDIVIDUAL_ACOUSTIC_SUPPORT + SEPARATOR + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV00] == 0x0; + text + help = STRING_TOKEN(STR_EMPTY), + text = STRING_TOKEN(STR_ACSATA_PORT0), + text = STRING_TOKEN(STR_EMPTY), + flags = 0, + key = 0; + text + help = STRING_TOKEN(STR_EMPTY), + text = STRING_TOKEN(STR_ACHDD_0), + text = STRING_TOKEN(STR_EMPTY), + flags = 0, + key = 0; + endif; + + suppressif ideqval SETUP_DATA.AcousticPwrMgmt == 0x0 OR ideqval SETUP_DATA.AcousticSupported[DEV00] == 0x0; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_PRESENT(DEV00) + endif; + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV00] == 0x0 OR + ideqval SETUP_DATA.AcousticSupported[DEV00] == 0x1 OR + ideqval SETUP_DATA.AcousticPwrMgmt == 0x0; + grayoutif ideqval SETUP_DATA.AcousticPwrMgmt == 0x1; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTSUPPORTED(DEV00) + SUPPRESS_GRAYOUT_ENDIF + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV00] == 0x0 OR ideqval SETUP_DATA.AcousticPwrMgmt == 0x1; + grayoutif ideqval SETUP_DATA.AcousticPwrMgmt == 0x0; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTAVAILABLE(DEV00) + SUPPRESS_GRAYOUT_ENDIF + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV01] == 0x0; + text + help = STRING_TOKEN(STR_EMPTY), + text = STRING_TOKEN(STR_ACSATA_PORT1), + text = STRING_TOKEN(STR_EMPTY), + flags = 0, + key = 0; + text + help = STRING_TOKEN(STR_EMPTY), + text = STRING_TOKEN(STR_ACHDD_1), + text = STRING_TOKEN(STR_EMPTY), + flags = 0, + key = 0; + endif; + + suppressif ideqval SETUP_DATA.AcousticPwrMgmt == 0x0 OR ideqval SETUP_DATA.AcousticSupported[DEV01] == 0x0; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_PRESENT(DEV01) + endif; + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV01] == 0x0 OR + ideqval SETUP_DATA.AcousticSupported[DEV01] == 0x1 OR + ideqval SETUP_DATA.AcousticPwrMgmt == 0x0; + grayoutif ideqval SETUP_DATA.AcousticPwrMgmt == 0x1; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTSUPPORTED(DEV01) + SUPPRESS_GRAYOUT_ENDIF + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV01] == 0x0 OR ideqval SETUP_DATA.AcousticPwrMgmt == 0x1; + grayoutif ideqval SETUP_DATA.AcousticPwrMgmt == 0x0; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTAVAILABLE(DEV01) + SUPPRESS_GRAYOUT_ENDIF + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV02] == 0x0; + text + help = STRING_TOKEN(STR_EMPTY), + text = STRING_TOKEN(STR_ACSATA_PORT2), + text = STRING_TOKEN(STR_EMPTY), + flags = 0, + key = 0; + text + help = STRING_TOKEN(STR_EMPTY), + text = STRING_TOKEN(STR_ACHDD_2), + text = STRING_TOKEN(STR_EMPTY), + flags = 0, + key = 0; + endif; + + suppressif ideqval SETUP_DATA.AcousticPwrMgmt == 0x0 OR ideqval SETUP_DATA.AcousticSupported[DEV02] == 0x0; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_PRESENT(DEV02) + endif; + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV02] == 0x0 OR + ideqval SETUP_DATA.AcousticSupported[DEV02] == 0x1 OR + ideqval SETUP_DATA.AcousticPwrMgmt == 0x0; + grayoutif ideqval SETUP_DATA.AcousticPwrMgmt == 0x1; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTSUPPORTED(DEV02) + SUPPRESS_GRAYOUT_ENDIF + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV02] == 0x0 OR ideqval SETUP_DATA.AcousticPwrMgmt == 0x1; + grayoutif ideqval SETUP_DATA.AcousticPwrMgmt == 0x0; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTAVAILABLE(DEV02) + SUPPRESS_GRAYOUT_ENDIF + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV03] == 0x0; + text + help = STRING_TOKEN(STR_EMPTY), + text = STRING_TOKEN(STR_ACSATA_PORT3), + text = STRING_TOKEN(STR_EMPTY), + flags = 0, + key = 0; + text + help = STRING_TOKEN(STR_EMPTY), + text = STRING_TOKEN(STR_ACHDD_3), + text = STRING_TOKEN(STR_EMPTY), + flags = 0, + key = 0; + endif; + + suppressif ideqval SETUP_DATA.AcousticPwrMgmt == 0x0 OR ideqval SETUP_DATA.AcousticSupported[DEV03] == 0x0; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_PRESENT(DEV03) + endif; + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV03] == 0x0 OR + ideqval SETUP_DATA.AcousticSupported[DEV03] == 0x1 OR + ideqval SETUP_DATA.AcousticPwrMgmt == 0x0; + grayoutif ideqval SETUP_DATA.AcousticPwrMgmt == 0x1; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTSUPPORTED(DEV03) + SUPPRESS_GRAYOUT_ENDIF + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV03] == 0x0 OR ideqval SETUP_DATA.AcousticPwrMgmt == 0x1; + grayoutif ideqval SETUP_DATA.AcousticPwrMgmt == 0x0; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTAVAILABLE(DEV03) + SUPPRESS_GRAYOUT_ENDIF + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV04] == 0x0; + text + help = STRING_TOKEN(STR_EMPTY), + text = STRING_TOKEN(STR_ACSATA_PORT4), + text = STRING_TOKEN(STR_EMPTY), + flags = 0, + key = 0; + text + help = STRING_TOKEN(STR_EMPTY), + text = STRING_TOKEN(STR_ACHDD_4), + text = STRING_TOKEN(STR_EMPTY), + flags = 0, + key = 0; + endif; + + suppressif ideqval SETUP_DATA.AcousticPwrMgmt == 0x0 OR ideqval SETUP_DATA.AcousticSupported[DEV04] == 0x0; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_PRESENT(DEV04) + endif; + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV04] == 0x0 OR + ideqval SETUP_DATA.AcousticSupported[DEV04] == 0x1 OR + ideqval SETUP_DATA.AcousticPwrMgmt == 0x0; + grayoutif ideqval SETUP_DATA.AcousticPwrMgmt == 0x1; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTSUPPORTED(DEV04) + SUPPRESS_GRAYOUT_ENDIF + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV04] == 0x0 OR ideqval SETUP_DATA.AcousticPwrMgmt == 0x1; + grayoutif ideqval SETUP_DATA.AcousticPwrMgmt == 0x0; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTAVAILABLE(DEV04) + SUPPRESS_GRAYOUT_ENDIF + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV05] == 0x0; + text + help = STRING_TOKEN(STR_EMPTY), + text = STRING_TOKEN(STR_ACSATA_PORT5), + text = STRING_TOKEN(STR_EMPTY), + flags = 0, + key = 0; + text + help = STRING_TOKEN(STR_EMPTY), + text = STRING_TOKEN(STR_ACHDD_5), + text = STRING_TOKEN(STR_EMPTY), + flags = 0, + key = 0; + endif; + + suppressif ideqval SETUP_DATA.AcousticPwrMgmt == 0x0 OR ideqval SETUP_DATA.AcousticSupported[DEV05] == 0x0; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_PRESENT(DEV05) + endif; + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV05] == 0x0 OR + ideqval SETUP_DATA.AcousticSupported[DEV05] == 0x1 OR + ideqval SETUP_DATA.AcousticPwrMgmt == 0x0; + grayoutif ideqval SETUP_DATA.AcousticPwrMgmt == 0x1; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTSUPPORTED(DEV05) + SUPPRESS_GRAYOUT_ENDIF + + suppressif ideqval SETUP_DATA.AcDevicePresent[DEV05] == 0x0 OR ideqval SETUP_DATA.AcousticPwrMgmt == 0x1; + grayoutif ideqval SETUP_DATA.AcousticPwrMgmt == 0x0; + ACOUSTIC_ONEOF_ACOUSTICLEVELINDV_NOTAVAILABLE(DEV05) + SUPPRESS_GRAYOUT_ENDIF + + #endif + + endform;//end form SATA_DEVICE_OPTIONS_FORM_ID +#endif // END #if ACOUSTIC_FORM_MAIN + + #endif // FORM_SET_ITEM + +#endif // ADVANCED_FORM_SET + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/Board/EM/IdeAcoustic/Acoustic.sdl b/Board/EM/IdeAcoustic/Acoustic.sdl new file mode 100644 index 0000000..4303871 --- /dev/null +++ b/Board/EM/IdeAcoustic/Acoustic.sdl @@ -0,0 +1,137 @@ +TOKEN + Name = ACOUSTIC_MANAGEMENT_DRIVER_SUPPORT + Value = "1" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + TargetH = Yes + Master = Yes + Help = "Main switch to enable Acoustic Management support in Project" +End + +PATH + Name = "ACOUSTIC_DIR" +End + +MODULE + Help = "Includes Aoustic.mak to Project" + File = "Acoustic.mak" +End + +TOKEN + Name = "INDIVIDUAL_ACOUSTIC_SUPPORT" + Value = "1" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + TargetH = Yes + Token = "ACOUSTIC_MANAGEMENT_DRIVER_SUPPORT" "=" "1" +End + +TOKEN + Name = "ACOUSTIC_DEVICE_COUNT" + Value = "6" + TokenType = Integer + TargetEQU = Yes + TargetMAK = Yes + TargetH = Yes + Help = "Default number of devices that may have Acoustic support. If you need to add more than 6 devices acoustic.sd and AcousticSetup.c file also needs to be changed" +End + +TOKEN + Name = "IDE_CONTROLLER_LOCATION" + Value = "{0, 0x1F, 2}" + TokenType = Expression + TargetH = Yes + Help = "Bus, Device and Function of the First IDE (SATA) controller." + Token = "ACOUSTIC_MANAGEMENT_DRIVER_SUPPORT" "=" "1" +End + +TOKEN + Name = "NUMBER_OF_PORTS_ON_FIRST_CONTROLLER" + Value = "4" + TokenType = Integer + TargetH = Yes + Help = "Number of Ports on First IDE (SATA) controller." + Token = "ACOUSTIC_MANAGEMENT_DRIVER_SUPPORT" "=" "1" +End + +TOKEN + Name = "SECOND_CONTROLLER_LOCATION" + Value = "{0, 0x1F, 5}" + TokenType = Expression + TargetH = Yes + Help = "Location of second IDE (SATA) controller (if any)." + Token = "ACOUSTIC_MANAGEMENT_DRIVER_SUPPORT" "=" "1" +End + +TOKEN + Name = "NUMBER_OF_PORTS_ON_SECOND_CONTROLLER" + Value = "2" + TokenType = Integer + TargetH = Yes + Help = "Number of Ports on second IDE (SATA) controller (if any)." + Token = "ACOUSTIC_MANAGEMENT_DRIVER_SUPPORT" "=" "1" +End + +TOKEN + Name = "SECOND_CONTROLLER_COUNTS_BY_DEVICE" + Value = "0" + TokenType = BOOLEAN + TargetH = Yes + Help = "ON - Second controller increments the device no. only for ports after 0. OFF - Second controller increments like first controller." + Token = "ACOUSTIC_MANAGEMENT_DRIVER_SUPPORT" "=" "1" +End + +TOKEN + Name = "ACOUSTIC_MANAGEMENT_SUPPORT" + Value = "0" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + TargetH = Yes + Help = "Keep this Token always OFF." + Lock = Yes + Token = "ACOUSTIC_MANAGEMENT_DRIVER_SUPPORT" "=" "1" +End + +TOKEN + Name = "LOCAL_ACOUSTIC_SETUP" + Value = "1" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + TargetH = Yes + Help = "ON - Setup questions are in this module./OFF - Setup questions are with SATA Driver." + Token = "ACOUSTIC_MANAGEMENT_DRIVER_SUPPORT" "=" "1" +End + +ELINK + Name = "InitAcousticStrings," + Parent = "SetupStringInit" + InvokeOrder = AfterParent + Token = "LOCAL_ACOUSTIC_SETUP" "=" "1" +End + +ELINK + Name = "$(BUILD_DIR)\Acoustic.sdb" + Parent = "SETUP_SDBS" + Token = "LOCAL_ACOUSTIC_SETUP" "=" "1" + Priority = 30 + InvokeOrder = AfterParent +End + +ELINK + Name = "$(ACOUSTIC_DIR)\Acoustic.sd" + Parent = "SETUP_DEFINITIONS" + Token = "LOCAL_ACOUSTIC_SETUP" "=" "1" + Priority = 30 + InvokeOrder = AfterParent +End + +ELINK + Name = "$(BUILD_DIR)\Acoustic.ffs" + Parent = "FV_MAIN" + InvokeOrder = AfterParent +End + diff --git a/Board/EM/IdeAcoustic/Acoustic.uni b/Board/EM/IdeAcoustic/Acoustic.uni Binary files differnew file mode 100644 index 0000000..3bc1610 --- /dev/null +++ b/Board/EM/IdeAcoustic/Acoustic.uni diff --git a/Board/EM/IdeAcoustic/AcousticBoard.c b/Board/EM/IdeAcoustic/AcousticBoard.c new file mode 100644 index 0000000..449a2e4 --- /dev/null +++ b/Board/EM/IdeAcoustic/AcousticBoard.c @@ -0,0 +1,460 @@ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2014, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** +//********************************************************************** +// +// $Header: /Alaska/SOURCE/Modules/HddAcoustic/AcousticBoard.c 6 6/09/14 10:02a Anbuprakashp $ +// +// $Revision: 6 $ +// +// $Date: 6/09/14 10:02a $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/HddAcoustic/AcousticBoard.c $ +// +// 6 6/09/14 10:02a Anbuprakashp +// [TAG] EIP172447 +// [Category] Improvement +// [Description] Runtime attribute set for the some of the variable used +// by HddAcoustic driver(Aptio-IV) that needs to be reviewed +// [Files] AcousticBoard.c +// +// 5 3/05/12 3:12a Rameshr +// [TAG] EIP82971 +// [Category] Improvement +// [Description] Added dynamich PCIe base Support in IdeAcoustic +// [Files] AcousticBoard.c, AcousticSetup.c +// +// 4 2/10/11 11:27a Pats +// [TAG] - EIP 52920 +// [Category]- Function Request +// [Severity]- Minor +// [Symptom] - The Acoustic mode (Bypass/Quiet/Max Performance) of port 5 +// is invalid on AMD SB700. +// [RootCause] - Special case where 2nd controller counts by incrementing +// device number only not handled properly +// [Solution] - Modified functions that handle this case. +// [Files] - Acoustic.c, AcousticBoard.c, AcousticSetup.c +// +// 3 1/07/11 12:14p Pats +// Handles counting of devices on second controller differently depending +// on token SECOND_CONTROLLER_COUNTS_BY_DEVICE. +// +// 2 1/06/11 4:38p Pats +// On some platforms, the 2nd controller is present, but not used, in AHCI +// mode. The 2nd controller should not be registered in this case. +// InstallAcousticPlatformProtocol() is modified to not register the 2nd +// controller in AHCI mode. +// +// 1 1/05/11 12:22a Rameshr +// Initial check-in for Hdd Acoustic Management Support. +// +//<AMI_FHDR_START> +//---------------------------------------------------------------------------- +// +// Name: AcousticBoard.C +// +// Description: This file contains DXE stage board component code for Acoustic +// support +// +// +//---------------------------------------------------------------------------- +//<AMI_FHDR_END> + +#include "Acoustic.h" + +#define BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID \ + {0xdbc9fd21, 0xfad8, 0x45b0, 0x9e, 0x78, 0x27, 0x15, 0x88, 0x67, 0xcc, 0x93} + +EFI_GUID BdsAllDriversConnectedProtocolGuid = BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID; +EFI_GUID SetupEnterProtocolGuid = AMITSE_SETUP_ENTER_GUID; +EFI_GUID gSetupGuid = SETUP_GUID; +EFI_GUID gAcousticSetupProtocolguid = ACOUSTIC_SETUP_PROTOCOL_GUID; + +VOID *gAcousticNotifyReg = NULL; +VOID *gAcousticProgNotifyReg = NULL; +VOID *gAcousticSetupNotifyReg = NULL; +UINT8 gIdeControllerLocation[] = IDE_CONTROLLER_LOCATION; +UINT8 gIdeControllerLocation2[] = SECOND_CONTROLLER_LOCATION; + +ACOUSTIC_SETUP_PROTOCOL *gAcousticSetupProtocol2 = NULL; +ACOUSTIC_SETUP_PROTOCOL *gAcousticSetupProtocol5 = NULL; + +VOID InstallAcousticPlatformProtocol(IN EFI_EVENT Event, IN VOID *Context); +VOID SetupEntryCallback(IN EFI_EVENT Event, IN VOID *Context); +VOID AcousticProgramming(IN EFI_EVENT Event, IN VOID *Context); + +#if DYNAMIC_PCIEXBASE_SUPPORT +UINT32 GetPciBaseAddr(VOID); +#define PCIEX_BASE GetPciBaseAddr() +#else +#define PCIEX_BASE PCIEX_BASE_ADDRESS +#endif + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: Acoustic_BoardInit +// +// Description: This function installs the the ACOUSTIC_SETUP_PROTOCOL which +// would be used in ahci/ide bus driver. +// +// Input: ImageHandle - ImageHandle of the loaded driver +// SystemTable - Pointer to the System Table +// +// Output: EFI_SUCCESS +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS +Acoustic_BoardInit ( +IN EFI_HANDLE ImageHandle, +IN EFI_SYSTEM_TABLE *SystemTable +) +{ + EFI_STATUS Status; + EFI_EVENT Event; + + InitAmiLib(ImageHandle, SystemTable); + +#if LOCAL_ACOUSTIC_SETUP + Status = RegisterProtocolCallback( &gEfiPciIoProtocolGuid, + InstallAcousticPlatformProtocol, + NULL, + &Event, + &gAcousticNotifyReg ); + ASSERT_EFI_ERROR(Status); +#endif + + Status = RegisterProtocolCallback( &BdsAllDriversConnectedProtocolGuid, + AcousticProgramming, + NULL, + &Event, + &gAcousticProgNotifyReg ); + + ASSERT_EFI_ERROR(Status); + // + //Install callback on entring into Setup + // + Status = RegisterProtocolCallback( &SetupEnterProtocolGuid, + SetupEntryCallback, + NULL, + &Event, + &gAcousticSetupNotifyReg); + ASSERT_EFI_ERROR(Status); + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: InstallAcousticPlatformProtocol +// +// Description: This function initializes some Setup values and Acoustic +// Protocol values. +// +// Input: IN EFI_EVENT Event +// IN VOID *Context +// +// Output: None +// +// Notes: This needs to be ported for each controller. +// gAcousticSetupProtocolguid needs to be installed for each IDE/SATA +// controller on the system. +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID +InstallAcousticPlatformProtocol ( + IN EFI_EVENT Event, + IN VOID *Context +) +{ + EFI_STATUS Status; + UINTN BufferSize = sizeof (EFI_HANDLE); + EFI_HANDLE Handle; + UINTN PciSeg; + UINTN PciBus; + UINTN PciDev; + UINTN PciFun; + EFI_PCI_IO_PROTOCOL *PciIo; + UINT8 i; + SETUP_DATA *SetupData = NULL; + UINTN VariableSize = NULL; + ACOUSTIC_SETUP_PROTOCOL *gAcousticSetupProtocol; + UINTN PciAddress; + UINT8 SataMode; + // + // Callback on PCIIo Protocol + // + Status = pBS->LocateHandle( ByRegisterNotify, + NULL, + gAcousticNotifyReg, + &BufferSize, + &Handle ); + ASSERT_EFI_ERROR(Status); + + if (EFI_ERROR(Status)) { + return; + } + // + // Locate PciIo protocol installed on Handle + // + Status = pBS->HandleProtocol( Handle, &gEfiPciIoProtocolGuid, &PciIo ); + ASSERT_EFI_ERROR(Status); + // + // Get PCI Device Bus/Device/Function Numbers + // + Status = PciIo->GetLocation( PciIo, &PciSeg, &PciBus, &PciDev, &PciFun ); + ASSERT_EFI_ERROR(Status); + + if (EFI_ERROR(Status)) { + return; + } + if ( ((PciBus == gIdeControllerLocation[0]) && \ + (PciDev == gIdeControllerLocation[1]) && \ + (PciFun == gIdeControllerLocation[2])) || \ + ((PciBus == gIdeControllerLocation2[0]) && \ + (PciDev == gIdeControllerLocation2[1]) && \ + (PciFun == gIdeControllerLocation2[2])) ) { + + PciAddress = MmPciAddress(PCIEX_BASE, + gIdeControllerLocation[0], + gIdeControllerLocation[1], + gIdeControllerLocation[2], + PCI_SCC); + + SataMode = *((volatile UINT8 *)(UINTN)(PciAddress)); + + if ( (PciBus == gIdeControllerLocation2[0]) && \ + (PciDev == gIdeControllerLocation2[1]) && \ + (PciFun == gIdeControllerLocation2[2]) && \ + (SataMode != PCI_CL_MASS_STOR_SCL_IDE) ) { + return; // If in AHCI mode, don't register 2nd controller. + } + + Status = pBS->AllocatePool (EfiBootServicesData, + sizeof(ACOUSTIC_SETUP_PROTOCOL), + (VOID**)&gAcousticSetupProtocol); + if (EFI_ERROR(Status)) { + return; + } + + Status = pBS->AllocatePool(EfiBootServicesData, + ACOUSTIC_DEVICE_COUNT, + &gAcousticSetupProtocol->AcousticSupportIndv); + + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR(Status)) { + return; + } + + pBS->SetMem(gAcousticSetupProtocol->AcousticSupportIndv, ACOUSTIC_DEVICE_COUNT, 0); + + Status = pBS->AllocatePool(EfiBootServicesData, + ACOUSTIC_DEVICE_COUNT, + &gAcousticSetupProtocol->AcousticLevelIndv); + + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR(Status)) { + return; + } + + pBS->SetMem(gAcousticSetupProtocol->AcousticLevelIndv, ACOUSTIC_DEVICE_COUNT, 0); + + Status = pBS->AllocatePool(EfiBootServicesData, + ACOUSTIC_DEVICE_COUNT, + &gAcousticSetupProtocol->DeviceDetected); + + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR(Status)) { + return; + } + + pBS->SetMem(gAcousticSetupProtocol->DeviceDetected, ACOUSTIC_DEVICE_COUNT, 0); + + gAcousticSetupProtocol->ControllerNumber = 0; + + if ( (PciBus == gIdeControllerLocation2[0]) && \ + (PciDev == gIdeControllerLocation2[1]) && \ + (PciFun == gIdeControllerLocation2[2]) ) { + gAcousticSetupProtocol->ControllerNumber = 1; + } + + Status = GetEfiVariable( L"Setup", + &gSetupGuid, + NULL, + &VariableSize, + &SetupData); + + if (!EFI_ERROR(Status)) { + gAcousticSetupProtocol->DeviceCount = ACOUSTIC_DEVICE_COUNT; + gAcousticSetupProtocol->AcousticPwrMgmt = SetupData->AcousticPwrMgmt; + gAcousticSetupProtocol->AcousticLevel = SetupData->AcousticLevel; + +#if INDIVIDUAL_ACOUSTIC_SUPPORT + if ( (PciBus == gIdeControllerLocation2[0]) && \ + (PciDev == gIdeControllerLocation2[1]) && \ + (PciFun == gIdeControllerLocation2[2]) ) { + for (i = 0; i < NUMBER_OF_PORTS_ON_SECOND_CONTROLLER ; i++ ) { // Only 2 ports on 2nd controller + if (gAcousticSetupProtocol->AcousticPwrMgmt) { + gAcousticSetupProtocol->AcousticLevelIndv[i] = + SetupData->AcousticLevelIndv[i+NUMBER_OF_PORTS_ON_FIRST_CONTROLLER]; + } else { + gAcousticSetupProtocol->AcousticLevelIndv[i] = ACOUSTIC_SUPPORT_DISABLE; + } + } + } else { + for (i = 0; i<ACOUSTIC_DEVICE_COUNT; i++ ) { + if (gAcousticSetupProtocol->AcousticPwrMgmt) { + gAcousticSetupProtocol->AcousticLevelIndv[i] = SetupData->AcousticLevelIndv[i]; + } else { + gAcousticSetupProtocol->AcousticLevelIndv[i] = ACOUSTIC_SUPPORT_DISABLE; + } + } + } +#else + for (i = 0; i<ACOUSTIC_DEVICE_COUNT; i++ ){ + if (gAcousticSetupProtocol->AcousticPwrMgmt) { + gAcousticSetupProtocol->AcousticLevelIndv[i] = SETUP_DATA.AcousticLevel; + } else { + gAcousticSetupProtocol->AcousticLevelIndv[i] = ACOUSTIC_SUPPORT_DISABLE; + } + } + +#endif + } else { + // + //Incase setup data is not available, initilaize with some defaults + // + gAcousticSetupProtocol->AcousticPwrMgmt = ACOUSTIC_SUPPORT_DISABLE; + gAcousticSetupProtocol->AcousticLevel = ACOUSTIC_LEVEL_BYPASS; +#if INDIVIDUAL_ACOUSTIC_SUPPORT + for (i = 0; i<ACOUSTIC_DEVICE_COUNT; i++ ){ + gAcousticSetupProtocol->AcousticLevelIndv[i] = ACOUSTIC_LEVEL_BYPASS; + } +#endif + } + // + //Install AcousticSetup Protocol on the ""Controller"" + // + Status = pBS->InstallProtocolInterface( + &Handle, + &gAcousticSetupProtocolguid, + EFI_NATIVE_INTERFACE, + gAcousticSetupProtocol + ); + + if ( (PciBus == gIdeControllerLocation2[0]) && \ + (PciDev == gIdeControllerLocation2[1]) && \ + (PciFun == gIdeControllerLocation2[2]) ) { + gAcousticSetupProtocol5 = gAcousticSetupProtocol; + } else { + gAcousticSetupProtocol2 = gAcousticSetupProtocol; + } + } + + if (SetupData) { + pBS->FreePool (SetupData); + } + + if (gAcousticSetupProtocol2 && gAcousticSetupProtocol5) { + Status = pBS->CloseEvent (Event); + } + + return; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: SetupEntryCallback +// +// Description: This function loads setup variables with Acoustic protocol values +// +// Input: IN EFI_EVENT Event +// IN VOID *Context +// +// Output: None +// +// Notes: This needs to be ported for each controller. +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID +SetupEntryCallback ( + IN EFI_EVENT Event, + IN VOID *Context +) +{ + EFI_STATUS Status; + SETUP_DATA *SetupData = NULL; + UINTN VariableSize = NULL; + UINT8 i; + UINT32 SetupDataAttributes = 0; + + // + // Kill the Event once It's exected. + // + Status = pBS->CloseEvent (Event); + // + // If the protocol not used, return + // + if (gAcousticSetupProtocol2 == NULL) return; + + Status = GetEfiVariable( L"Setup", + &gSetupGuid, + &SetupDataAttributes, + &VariableSize, + &SetupData); + + for (i = 0; i < gAcousticSetupProtocol2->DeviceCount; i++) { + SetupData->AcousticSupported[i] = gAcousticSetupProtocol2->AcousticSupportIndv[i]; + SetupData->AcDevicePresent[i] = gAcousticSetupProtocol2->DeviceDetected[i]; + } + + if ( gAcousticSetupProtocol5 != NULL ) { + for (i = 0; i < NUMBER_OF_PORTS_ON_SECOND_CONTROLLER ; i++) { // Only 2 ports on 2nd controller + SetupData->AcousticSupported[i + NUMBER_OF_PORTS_ON_FIRST_CONTROLLER] = + gAcousticSetupProtocol5->AcousticSupportIndv[i]; + SetupData->AcDevicePresent[i + NUMBER_OF_PORTS_ON_FIRST_CONTROLLER] = + gAcousticSetupProtocol5->DeviceDetected[i]; + } + } + + Status = pRS->SetVariable(L"Setup", + &gSetupGuid, + SetupDataAttributes, + sizeof(SETUP_DATA), + SetupData); + + if (SetupData) { + pBS->FreePool (SetupData); + } + + return; +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2014, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/Board/EM/IdeAcoustic/AcousticSetup.c b/Board/EM/IdeAcoustic/AcousticSetup.c new file mode 100644 index 0000000..605d33b --- /dev/null +++ b/Board/EM/IdeAcoustic/AcousticSetup.c @@ -0,0 +1,332 @@ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** +//********************************************************************** +// $Header: /Alaska/SOURCE/Modules/HddAcoustic/AcousticSetup.c 7 3/05/12 3:14a Rameshr $ +// +// $Revision: 7 $ +// +// $Date: 3/05/12 3:14a $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/HddAcoustic/AcousticSetup.c $ +// +// 7 3/05/12 3:14a Rameshr +// [TAG] EIP82971 +// [Category] Improvement +// [Description] Added dynamich PCIe base Support in IdeAcoustic +// [Files] AcousticBoard.c, AcousticSetup.c +// +// 6 1/24/12 1:42a Rameshr +// [TAG] EIP67652 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] Build error when token SB_SETUP_SUPPORT disabled +// [RootCause] Unresolved external symbol +// gEfiDiskInfoProtocolGuid,SwapEntries referenced in function +// InitAcousticStrings +// [Solution] Added gEfiDiskInfoProtocolGuid and SwapEntries function +// locally +// [Files] AcousticSetup.c +// +// 5 2/10/11 11:28a Pats +// [TAG] - EIP 52920 +// [Category]- Function Request +// [Severity]- Minor +// [Symptom] - The Acoustic mode (Bypass/Quiet/Max Performance) of port 5 +// is invalid on AMD SB700. +// [RootCause] - Special case where 2nd controller counts by incrementing +// device number only not handled properly +// [Solution] - Modified functions that handle this case. +// [Files] - Acoustic.c, AcousticBoard.c, AcousticSetup.c +// +// 4 1/07/11 5:52p Pats +// Added processing for SECOND_CONTROLLER_COUNTS_BY_DEVICE token. +// +// 3 1/07/11 12:15p Pats +// Changed how devices on second controller are handled. +// +// 2 1/05/11 6:33p Pats +// Made more generic. Removed all south bridge-specific references. +// +// 1 1/05/11 12:22a Rameshr +// Initial check-in for Hdd Acoustic Management Support. +// +//********************************************************************** + +//********************************************************************** +//<AMI_FHDR_START> +// +// Name: AcousticSetup.c +// +// Description: This file contains functions used by the Acoustic module +// +//<AMI_FHDR_END> +//********************************************************************** + +#include <SetupStrTokens.h> +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) +#include <UefiHii.h> +#else +#include <Protocol\HII.h> +#endif +#include <Protocol\DevicePath.h> +#include "Acoustic.h" + +#if DYNAMIC_PCIEXBASE_SUPPORT +UINT32 GetPciBaseAddr(VOID); +#define PCIEX_BASE GetPciBaseAddr() +#else +#define PCIEX_BASE PCIEX_BASE_ADDRESS +#endif +#if LOCAL_ACOUSTIC_SETUP +#include <Protocol\PDiskInfo.h> + +static EFI_GUID gEfiDiskInfoProtocolGuid = EFI_DISK_INFO_PROTOCOL_GUID; + +UINT8 gIdeControllerLocation[] = IDE_CONTROLLER_LOCATION; +UINT8 gIdeControllerLocation2[] = SECOND_CONTROLLER_LOCATION; + +// +// Add more elements if there are more than 6 SATA ports +// +STRING_REF DevStrings[] = { +STRING_TOKEN( STR_ACHDD_0 ), +STRING_TOKEN( STR_ACHDD_1 ), +STRING_TOKEN( STR_ACHDD_2 ), +STRING_TOKEN( STR_ACHDD_3 ), +STRING_TOKEN( STR_ACHDD_4 ), +STRING_TOKEN( STR_ACHDD_5 ), +}; + + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: Swap_Entries +// +// Description: +// +// Inpuut: IN CHAR8 *Data, +// IN UINT16 Size +// +// Output: None +// +// Notes: +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID Swap_Entries ( + IN CHAR8 *Data, + IN UINT16 Size +) +{ + UINT16 Index; + CHAR8 Temp8; + + for (Index = 0; (Index+1) < Size; Index+=2) { + Temp8 = Data[Index]; + Data[Index] = Data[Index + 1]; + Data[Index + 1] = Temp8; + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: InitAcousticStrings +// +// Description: Initialize Acoustic misc configuration strings. +// +// Input: +// IN EFI_HII_HANDLE HiiHandle +// IN UINT16 Class +// +// Output: +// VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID +InitAcousticStrings( + EFI_HII_HANDLE HiiHandle, + UINT16 Class +) +{ + EFI_STATUS Status; + PCI_DEVICE_PATH *PciDevicePath; + CHAR8 *NewString; + UINT8 Index; + UINT8 SataMode; + UINTN HandleCount; + EFI_HANDLE *HandleBuffer; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_DEVICE_PATH_PROTOCOL *DevicePathNode; + EFI_DISK_INFO_PROTOCOL *DiskInfo; + UINT32 IdeDevice, IdeChannel; + IDENTIFY_DATA *IdentifyDriveInfo = NULL; + UINT32 BufferSize = 0; + STRING_REF Token; + CHAR8 ModelNumber[43]; + UINTN PciAddress; + UINT8 IdeControllerLocation[] = IDE_CONTROLLER_LOCATION; + + if (Class == ADVANCED_FORM_SET_CLASS) { + Status = pBS->AllocatePool(EfiBootServicesData, 43, &NewString); + ASSERT_EFI_ERROR(Status); + + PciDevicePath = NULL; + + PciAddress = MmPciAddress(PCIEX_BASE, + IdeControllerLocation[0], + IdeControllerLocation[1], + IdeControllerLocation[2], + PCI_SCC); + + SataMode = *((volatile UINT8 *)(UINTN)(PciAddress)); + + Status = pBS->LocateHandleBuffer ( + ByProtocol, + &gEfiDiskInfoProtocolGuid, + NULL, + &HandleCount, + &HandleBuffer + ); + if (EFI_ERROR(Status)) { + HandleCount = 0; + } + + for (Index = 0; Index < HandleCount; Index++) { + Status = pBS->HandleProtocol ( + HandleBuffer[Index], + &gEfiDevicePathProtocolGuid, + (VOID *) &DevicePath + ); + ASSERT_EFI_ERROR(Status); + + DevicePathNode = DevicePath; + while (!isEndNode (DevicePathNode)) { + if ((DevicePathNode->Type == HARDWARE_DEVICE_PATH) && + (DevicePathNode->SubType == HW_PCI_DP)) { + PciDevicePath = (PCI_DEVICE_PATH *) DevicePathNode; + break; + } + + DevicePathNode = NEXT_NODE (DevicePathNode); + } + + if (PciDevicePath == NULL) { + continue; + } + + if ( ((PciDevicePath->Device == gIdeControllerLocation[1]) && \ + (PciDevicePath->Function == gIdeControllerLocation[2])) || \ + ((PciDevicePath->Device == gIdeControllerLocation2[1]) && \ + (PciDevicePath->Function == gIdeControllerLocation2[2])) ) { + Status = pBS->HandleProtocol ( + HandleBuffer[Index], + &gEfiDiskInfoProtocolGuid, + &DiskInfo + ); + ASSERT_EFI_ERROR (Status); + + Status = DiskInfo->WhichIde ( + DiskInfo, + &IdeChannel, + &IdeDevice + ); + if (SataMode == PCI_CL_MASS_STOR_SCL_IDE) { // IDE MODE + + IdeDevice = (IdeChannel * 2) + IdeDevice; + +#if SECOND_CONTROLLER_COUNTS_BY_DEVICE + if ( (PciDevicePath->Device == gIdeControllerLocation2[1]) && \ + (PciDevicePath->Function == gIdeControllerLocation2[2]) ) { //Port 4, 5 in SATA2 + IdeDevice += 4; + } +#endif + if (IdeDevice == 1 || IdeDevice == 2) { // SINDX ¡V Serial ATA Index (D31:F2) + IdeDevice ^= 3; // Port 0 = Primary Master + } // Port 2 = Primary Slave +#if !SECOND_CONTROLLER_COUNTS_BY_DEVICE + if ( (PciDevicePath->Device == gIdeControllerLocation2[1]) && \ + (PciDevicePath->Function == gIdeControllerLocation2[2]) ) { //Port 4, 5 in SATA2 + IdeDevice += 4; + } +#endif + IdeChannel = IdeDevice; + } // SATA MODE + Token = DevStrings[IdeChannel]; + + Status = pBS->AllocatePool(EfiBootServicesData, sizeof (IDENTIFY_DATA), &IdentifyDriveInfo); + ASSERT_EFI_ERROR (Status); + + pBS->SetMem(IdentifyDriveInfo, sizeof (IDENTIFY_DATA), 0); + + BufferSize = sizeof (IDENTIFY_DATA); + Status = DiskInfo->Identify ( + DiskInfo, + IdentifyDriveInfo, + &BufferSize + ); + ASSERT_EFI_ERROR (Status); + + } else { + // + // Off board + // + continue; + } + + pBS->SetMem(ModelNumber, 42, 0x20); + pBS->CopyMem (ModelNumber+2, IdentifyDriveInfo->Model_Number_27, 40); + Swap_Entries (ModelNumber+2, 40); + ModelNumber[42] = '\0'; + + Sprintf(NewString, "%a", ModelNumber); + + InitString( + HiiHandle, + Token, + L"%a", + NewString + ); + + if (IdentifyDriveInfo) { + pBS->FreePool (IdentifyDriveInfo); + IdentifyDriveInfo = NULL; + } + } + + if (HandleBuffer) { + pBS->FreePool (HandleBuffer); + } + + pBS->FreePool (NewString); + } +} +#endif + +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* |