summaryrefslogtreecommitdiff
path: root/ReferenceCode/ME/ActiveManagement/IdeR
diff options
context:
space:
mode:
authorraywu <raywu0301@gmail.com>2018-06-15 00:00:50 +0800
committerraywu <raywu0301@gmail.com>2018-06-15 00:00:50 +0800
commitb7c51c9cf4864df6aabb99a1ae843becd577237c (patch)
treeeebe9b0d0ca03062955223097e57da84dd618b9a /ReferenceCode/ME/ActiveManagement/IdeR
downloadzprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz
init. 1AQQW051HEADmaster
Diffstat (limited to 'ReferenceCode/ME/ActiveManagement/IdeR')
-rw-r--r--ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.c927
-rw-r--r--ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.cif13
-rw-r--r--ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.h422
-rw-r--r--ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.inf86
-rw-r--r--ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.mak55
-rw-r--r--ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.sdl24
-rw-r--r--ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRControllerName.c172
7 files changed, 1699 insertions, 0 deletions
diff --git a/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.c b/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.c
new file mode 100644
index 0000000..8465de8
--- /dev/null
+++ b/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.c
@@ -0,0 +1,927 @@
+/** @file
+ This driver module produces IDE_CONTROLLER_INIT protocol and will be used by
+ IDE Bus driver to support platform dependent timing information. This driver
+ is responsible for early initialization of IDE Redirect controller.
+
+@copyright
+ Copyright (c) 1999 - 2012 Intel Corporation. All rights
+ reserved This software and associated documentation (if any)
+ is furnished under a license and may only be used or copied in
+ accordance with the terms of the license. Except as permitted
+ by such license, no part of this software or documentation may
+ be reproduced, stored in a retrieval system, or transmitted in
+ any form or by any means without the express written consent
+ of Intel Corporation.
+
+ This file contains an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+
+**/
+
+//
+// External include files do NOT need to be explicitly specified in real EDKII
+// environment
+//
+#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
+#include "EdkIIGlueDxe.h"
+#include "IdeRController.h"
+#include "MeLib.h"
+#endif
+
+///
+/// EFI_DRIVER_BINDING_PROTOCOL instance
+///
+EFI_DRIVER_BINDING_PROTOCOL mIdeRControllerDriverBinding = {
+ IdeRControllerSupported,
+ IdeRControllerStart,
+ IdeRControllerStop,
+ 1, // Version
+ NULL, // ImageHandle
+ NULL // DriverBindingHandle
+};
+
+/**
+ This function is used to calculate the best PIO mode supported by
+ specific IDE device
+
+ Since the LPT IDE-R doesn't support changing the timing
+ registers because they are RO 0x00, we'll just return PIO mode 2.
+
+ @param[in] IdentifyData The identify data of specific IDE device
+ @param[in] DisPioMode Disqualified PIO modes collection
+ @param[in] SelectedMode Available PIO modes collection
+
+ @retval EFI_SUCCESS SelectedMode calculated.
+**/
+EFI_STATUS
+CalculateBestPioMode (
+ IN EFI_IDENTIFY_DATA *IdentifyData,
+ IN UINT16 *DisPioMode OPTIONAL,
+ OUT UINT16 *SelectedMode
+ )
+{
+ ///
+ /// ATA_PIO_MODE_2;
+ ///
+ *SelectedMode = 2;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function is used to calculate the best UDMA mode supported by
+ specific IDE device
+
+ Since the LPT IDE-R doesn't support changing the timing
+ registers because they are RO 0x00, we'll just return DMA mode 2.
+
+ @param[in] IdentifyData The identify data of specific IDE device
+ @param[in] DisUDmaMode Disqualified UDMA modes collection
+ @param[in] SelectedMode Available UMDA modes collection
+
+ @retval EFI_SUCCESS SelectedMode calculated.
+**/
+EFI_STATUS
+CalculateBestUdmaMode (
+ IN EFI_IDENTIFY_DATA *IdentifyData,
+ IN UINT16 *DisUDmaMode OPTIONAL,
+ OUT UINT16 *SelectedMode
+ )
+{
+ ///
+ /// ATA_UDMA_MODE_2;
+ ///
+ *SelectedMode = 2;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function is used to set appropriate PIO timing on Ide
+ controller according supported PIO modes
+
+ @param[in] Channel IDE channel number (0 based, either 0 or 1).
+ For LPT IDE-R there is only one (See IDER_MAX_CHANNEL).
+ @param[in] Device IDE device number
+ @param[in] PciIo Pointer to PciIo protocol opened by Ide controller driver
+ @param[in] IdentifyData The identify struct submitted by IDE device
+ @param[in] Modes The PIO mode collection supported by IDE device
+
+ @retval EFI_SUCCESS PIO timing initialized or no need to program PIO mode
+**/
+EFI_STATUS
+IdeInitSetPioTiming (
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDENTIFY_DATA *IdentifyData,
+ IN EFI_ATA_COLLECTIVE_MODE *Modes
+ )
+{
+ ///
+ /// Since the Cantiga version of the ME IDER doesn't support registers 40-4F (they are RO),
+ /// there is no need to program PIO mode.
+ ///
+ return EFI_SUCCESS;
+}
+
+/**
+ This function is used to set appropriate UDMA timing on Ide
+ controller according supported UDMA modes
+
+ @param[in] Channel IDE channel number (0 based, either 0 or 1).
+ For LPT IDE-R there is only one (See IDER_MAX_CHANNEL).
+ @param[in] Device IDE device number
+ @param[in] PciIo Pointer to PciIo protocol opened by Ide controller driver
+ @param[in] Modes The UDMA mode collection supported by IDE device
+
+ @retval Status code returned by PciIo operations
+**/
+EFI_STATUS
+IdeInitSetUdmaTiming (
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_ATA_COLLECTIVE_MODE *Modes
+ )
+{
+ ///
+ /// Since the Cantiga version of the ME IDE-R doesn't support registers 40-C7 (they are RO),
+ /// there is no need to program PIO/UDMA mode.
+ ///
+ EFI_STATUS Status;
+ UINT16 PciCommandReg;
+ UINT8 BusMasterIdeStatusReg;
+
+ ///
+ /// PCI Command Register, offset 0x4, default 00
+ ///
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint16,
+ PCI_COMMAND_REGISTER,
+ 1,
+ &PciCommandReg
+ );
+ ///
+ /// Now set the PCH IDE Bus Master Enable bit, one bit for PCH controller
+ /// If BME bit is not set, set it
+ ///
+ if (!(PciCommandReg & BME_BUS_MASTER_ENABLE_BIT)) {
+ PciCommandReg |= BME_BUS_MASTER_ENABLE_BIT;
+
+ Status = PciIo->Pci.Write (
+ PciIo,
+ EfiPciIoWidthUint16,
+ PCI_COMMAND_REGISTER, // offset 0x4
+ 1,
+ &PciCommandReg
+ );
+ }
+
+ Status = PciIo->Io.Read (
+ PciIo,
+ EfiPciIoWidthUint8,
+ 4,
+ (Channel == 0 ? 0x2 : 0xA),
+ 1,
+ &BusMasterIdeStatusReg
+ );
+
+ BusMasterIdeStatusReg = (UINT8) (BusMasterIdeStatusReg | (Device == 0 ? BIT5 : BIT6));
+
+ Status = PciIo->Io.Write (
+ PciIo,
+ EfiPciIoWidthUint8,
+ 4,
+ (Channel == 0 ? 0x2 : 0xA),
+ 1,
+ &BusMasterIdeStatusReg
+ );
+
+ return Status;
+}
+
+/**
+ This function is called after IdeBus driver submits its EFI_IDENTIFY_DATA data struct
+ to IDE controller driver. The main purpose is to detect IDE
+ cable type.
+
+ @param[in] Channel IDE channel number (0 based, either 0 or 1).
+ For LPT IDE-R there is only one (See IDER_MAX_CHANNEL).
+ @param[in] Device IDE device number
+ @param[in] PciIo Pointer to PciIo protocol instance opened by Ide driver
+ @param[in] IdentifyData A pointer to EFI_IDENTIFY_DATA data structure
+
+ @retval EFI_SUCCESS Cable type detected
+**/
+EFI_STATUS
+IdeDetectCableType (
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDENTIFY_DATA *IdentifyData
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+AdjustUdmaModeByCableType (
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN OUT EFI_ATA_COLLECTIVE_MODE *Modes
+ )
+/**
+ This function is called AFTER IdeBus driver submits its EFI_IDENTIFY_DATA data struct.
+ The main objective of this function is to adjust best calculated UDMA mode
+ according to current cable type. LPT IDE-R is hardcoded to 40 pin UDMA-2/33 mode.
+ Note that the cable reporting bits should be set prior to this function call
+
+ @param[in] Channel IDE channel number (0 based, either 0 or 1).
+ For LPT IDE-R there is only one (See IDER_MAX_CHANNEL).
+ @param[in] Device IDE device number
+ @param[in] PciIo Pointer to PciIo protocol instance opened by Ide driver
+ @param[in] Modes The current best supported mode calculated by this driver
+
+ @retval EFI_SUCCESS UdmaMode copied
+**/
+{
+ Modes->UdmaMode.Mode = 2;
+ return EFI_SUCCESS;
+}
+
+///
+/// Interface functions of IDE_CONTROLLER_INIT protocol
+///
+
+/**
+ This function can be used to obtain information about a specified channel.
+ It's usually used by IDE Bus driver during enumeration process.
+
+ @param[in] This The EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ @param[in] Channel Channel number (0 based, either 0 or 1)
+ @param[in] Enabled TRUE if the channel is enabled. If the channel is disabled,
+ then it will no be enumerated.
+ @param[in] MaxDevices The Max number of IDE devices that the bus driver can expect
+ on this channel. For ATA/ATAPI, this number is either 1 or 2.
+
+ @retval EFI_SUCCESS Information copied
+ @retval EFI_INVALID_PARAMETER Invalid channel
+**/
+EFI_STATUS
+EFIAPI
+IdeInitGetChannelInfo (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ OUT BOOLEAN *Enabled,
+ OUT UINT8 *MaxDevices
+ )
+{
+ ///
+ /// Channel number (0 based, either 0 or 1)
+ /// For LPT IDE-R there is only one (See IDER_MAX_CHANNEL).
+ ///
+ if (Channel < IDER_MAX_CHANNEL) {
+ *Enabled = TRUE;
+ *MaxDevices = IDER_MAX_DEVICES;
+ return EFI_SUCCESS;
+
+ } else {
+ return EFI_INVALID_PARAMETER;
+ }
+}
+
+/**
+ This function is called by IdeBus driver before executing certain actions.
+ This allows IDE Controller Init to prepare for each action.
+
+ @param[in] This The EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ @param[in] Phase Phase indicator defined by IDE_CONTROLLER_INIT protocol
+ @param[in] Channel Channel number (0 based, either 0 or 1)
+
+ @retval EFI_SUCCESS Preparation done
+ @retval EFI_INVALID_PARAMETER Invalid channel
+ @exception EFI_UNSUPPORTED Invalid phase
+**/
+EFI_STATUS
+EFIAPI
+IdeInitNotifyPhase (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase,
+ IN UINT8 Channel
+ )
+{
+ if (Channel >= IDER_MAX_CHANNEL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ switch (Phase) {
+
+ case EfiIdeBeforeChannelEnumeration:
+ case EfiIdeAfterChannelEnumeration:
+ case EfiIdeBeforeChannelReset:
+ case EfiIdeAfterChannelReset:
+ case EfiIdeBusBeforeDevicePresenceDetection:
+ case EfiIdeBusAfterDevicePresenceDetection:
+ case EfiIdeResetMode:
+ ///
+ /// Do nothing at present
+ ///
+ break;
+
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function is called by IdeBus driver to submit EFI_IDENTIFY_DATA data structure
+ obtained from IDE deivce. This structure is used to set IDE timing
+
+ @param[in] This The EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ @param[in] Channel IDE channel number (0 based, either 0 or 1)
+ @param[in] Device IDE device number
+ @param[in] IdentifyData A pointer to EFI_IDENTIFY_DATA data structure
+
+ @retval EFI_SUCCESS Data submitted
+ @retval EFI_INVALID_PARAMETER Invalid channel
+**/
+EFI_STATUS
+EFIAPI
+IdeInitSubmitData (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_IDENTIFY_DATA *IdentifyData
+ )
+{
+ EFI_IDE_CONTROLLER_PRIVATE_DATA *IdePrivateData;
+
+ if (Channel >= IDER_MAX_CHANNEL || Device >= IDER_MAX_DEVICES) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ IdePrivateData = IDE_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
+ ASSERT (IdePrivateData);
+
+ ///
+ /// Make a local copy of device's IdentifyData and mark the valid flag
+ ///
+ if (IdentifyData != NULL) {
+ CopyMem (
+ &(IdePrivateData->IdentifyData[Channel][Device]),
+ IdentifyData,
+ sizeof (EFI_IDENTIFY_DATA)
+ );
+
+ IdePrivateData->IdentifyValid[Channel][Device] = TRUE;
+
+ ///
+ /// Detect cable type and set cable type reg once we get identify data
+ ///
+ IdeDetectCableType (
+ Channel,
+ Device,
+ IdePrivateData->PciIo,
+ &(IdePrivateData->IdentifyData[Channel][Device])
+ );
+
+ } else {
+ IdePrivateData->IdentifyValid[Channel][Device] = FALSE;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function is called by IdeBus driver to disqualify unsupported operation
+ mode on specfic IDE device
+
+ @param[in] This The EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ @param[in] Channel IDE channel number (0 based, either 0 or 1)
+ @param[in] Device IDE device number
+ @param[in] BadModes Operation mode indicator
+
+ @retval EFI_SUCCESS Disqulified Modes recorded
+ @retval EFI_INVALID_PARAMETER Invalid channel or invalid BadModes pointer
+**/
+EFI_STATUS
+EFIAPI
+IdeInitDisqualifyMode (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_ATA_COLLECTIVE_MODE *BadModes
+ )
+{
+ EFI_IDE_CONTROLLER_PRIVATE_DATA *IdePrivateData;
+
+ if (Channel >= IDER_MAX_CHANNEL || Device >= IDER_MAX_DEVICES || BadModes == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ IdePrivateData = IDE_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
+ ASSERT (IdePrivateData);
+
+ ///
+ /// Record the disqualified modes per channel per device. From ATA/ATAPI spec,
+ /// if a mode is not supported, the modes higher than it is also not
+ /// supported
+ ///
+ CopyMem (
+ &(IdePrivateData->DisqulifiedModes[Channel][Device]),
+ BadModes,
+ sizeof (EFI_ATA_COLLECTIVE_MODE)
+ );
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function is called by IdeBus driver to calculate the best operation mode
+ supported by specific IDE device
+
+ @param[in] This The EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ @param[in] Channel IDE channel number (0 based, either 0 or 1)
+ @param[in] Device IDE device number
+ @param[in] SupportedModes Modes collection supported by IDE device
+
+ @retval EFI_SUCCESS Disqulified Modes recorded
+ @retval EFI_INVALID_PARAMETER Invalid channel or invalid SupportedModes pointer
+ @retval EFI_NOT_READY IdentifyData is not valid
+ @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary data structures
+**/
+EFI_STATUS
+EFIAPI
+IdeInitCalculateMode (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes
+ )
+{
+ EFI_IDE_CONTROLLER_PRIVATE_DATA *IdePrivateData;
+ EFI_IDENTIFY_DATA *IdentifyData;
+ BOOLEAN IdentifyValid;
+ EFI_ATA_COLLECTIVE_MODE *DisqulifiedModes;
+ UINT16 SelectedMode;
+ EFI_STATUS Status;
+
+ if (Channel >= IDER_MAX_CHANNEL || Device >= IDER_MAX_DEVICES || SupportedModes == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ IdePrivateData = IDE_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
+ ASSERT (IdePrivateData);
+
+ IdentifyData = &(IdePrivateData->IdentifyData[Channel][Device]);
+ DisqulifiedModes = &(IdePrivateData->DisqulifiedModes[Channel][Device]);
+ IdentifyValid = IdePrivateData->IdentifyValid[Channel][Device];
+
+ ///
+ /// Make sure we've got the valid identify data of the device from SubmitData()
+ ///
+ if (!IdentifyValid) {
+ return EFI_NOT_READY;
+ }
+
+ *SupportedModes = AllocateZeroPool (sizeof (EFI_ATA_COLLECTIVE_MODE));
+ if (*SupportedModes == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = CalculateBestPioMode (
+ IdentifyData,
+ (DisqulifiedModes->PioMode.Valid ? ((UINT16 *) &(DisqulifiedModes->PioMode.Mode)) : NULL),
+ &SelectedMode
+ );
+ if (!EFI_ERROR (Status)) {
+ (*SupportedModes)->PioMode.Valid = TRUE;
+ (*SupportedModes)->PioMode.Mode = SelectedMode;
+
+ } else {
+ (*SupportedModes)->PioMode.Valid = FALSE;
+ }
+
+ Status = CalculateBestUdmaMode (
+ IdentifyData,
+ (DisqulifiedModes->UdmaMode.Valid ? ((UINT16 *) &(DisqulifiedModes->UdmaMode.Mode)) : NULL),
+ &SelectedMode
+ );
+ if (!EFI_ERROR (Status)) {
+ (*SupportedModes)->UdmaMode.Valid = TRUE;
+ (*SupportedModes)->UdmaMode.Mode = SelectedMode;
+
+ } else {
+ (*SupportedModes)->UdmaMode.Valid = FALSE;
+ }
+ ///
+ /// It is only referenced here.
+ ///
+ (*SupportedModes)->ExtModeCount = 1;
+ ///
+ /// The modes other than PIO and UDMA are not supported by Ide controller
+ ///
+ return EFI_SUCCESS;
+}
+
+/**
+ This function is called by IdeBus driver to set appropriate timing on IDE
+ controller according supported operation mode
+
+ @param[in] This The EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ @param[in] Channel IDE channel number (0 based, either 0 or 1)
+ @param[in] Device IDE device number
+ @param[in] Modes IDE device mode
+
+ @retval EFI_SUCCESS Disqulified Modes recorded
+ @retval EFI_INVALID_PARAMETER Invalid channel or invalid Modes pointer
+ @retval EFI_NOT_READY IdentifyData is not valid
+ @exception EFI_UNSUPPORTED Failed to set PIO/MDMA/SDMA timing
+**/
+EFI_STATUS
+EFIAPI
+IdeInitSetTiming (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_ATA_COLLECTIVE_MODE *Modes
+ )
+{
+ EFI_IDE_CONTROLLER_PRIVATE_DATA *IdePrivateData;
+
+ if (Channel >= IDER_MAX_CHANNEL || Device >= IDER_MAX_DEVICES || Modes == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ IdePrivateData = IDE_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
+ ASSERT (IdePrivateData);
+
+ ///
+ /// Make sure we've got the valid identify data of the device from SubmitData()
+ ///
+ if (!(IdePrivateData->IdentifyValid[Channel][Device])) {
+ return EFI_NOT_READY;
+ }
+ ///
+ /// Set UMDA timing
+ ///
+ if (Modes->UdmaMode.Valid) {
+ IdeInitSetUdmaTiming (
+ Channel,
+ Device,
+ IdePrivateData->PciIo,
+ Modes
+ );
+ }
+ ///
+ /// Set PIO/MDMA/SDMA timing (They generally share the same timing values)
+ ///
+ if (Modes->PioMode.Valid) {
+ IdeInitSetPioTiming (
+ Channel,
+ Device,
+ IdePrivateData->PciIo,
+ &(IdePrivateData->IdentifyData[Channel][Device]),
+ Modes
+ );
+
+ } else {
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+///
+/// IDE-R Controller Binding protocol declaration
+///
+
+/**
+ This function checks to see if the driver supports a device specified by
+ "Controller handle" parameter. It is called by DXE Core StartImage() or
+ ConnectController() routines. The driver uses 'device path' and/or
+ 'services' from the Bus I/O abstraction attached to the controller handle
+ to determine if the driver support this controller handle.
+
+ Note: In the BDS (Boot Device Selection) phase, the DXE core enumerate all
+ devices (or, controller) and assigns GUIDs to them.
+
+ @param[in] This a pointer points to the Binding Protocol instance
+ @param[in] Controller The handle of controller to be tested.
+ @param[in] RemainingDevicePath A pointer to the device path. Ignored by device
+ driver but used by bus driver
+
+ @retval EFI_SUCCESS Have device to support
+ @retval EFI_NOT_FOUND Relative environment not ready
+ @exception EFI_UNSUPPORTED The device doesn't support
+**/
+EFI_STATUS
+EFIAPI
+IdeRControllerSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE00 PciData;
+
+
+ ///
+ /// Ide Controller is a device driver, and should ingore the
+ /// "RemainingDevicePath" according to EFI spec
+ ///
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *) &ParentDevicePath,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (EFI_ERROR (Status)) {
+ ///
+ /// EFI_ALREADY_STARTED is also an error
+ ///
+ return Status;
+ }
+ ///
+ /// Close the protocol because we don't use it here
+ ///
+ gBS->CloseProtocol (
+ Controller, // handle of the controller
+ &gEfiDevicePathProtocolGuid, // Porotcol to be closed
+ This->DriverBindingHandle, // agent of opening the protocol
+ Controller
+ );
+
+ ///
+ /// Now test the EfiPciIoProtocol
+ ///
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ (VOID **) &PciIo,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ ///
+ /// Now further check the PCI header: Base class (offset 0x0B) and
+ /// Sub Class (offset 0x0A). This controller should be an Ide controller
+ ///
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint8,
+ 0,
+ sizeof (PciData),
+ &PciData
+ );
+
+ if (EFI_ERROR (Status)) {
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ return EFI_UNSUPPORTED;
+ }
+ ///
+ /// Examine IDE-R PCI Configuration table fields
+ ///
+ if ((PciData.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE) ||
+ (PciData.Hdr.ClassCode[1] != PCI_SUB_CLASS_IDE) ||
+ (PciData.Hdr.VendorId != V_ME_IDER_VENDOR_ID) ||
+ !IS_PCH_LPT_IDER_DEVICE_ID(PciData.Hdr.DeviceId)
+ ) {
+
+ Status = EFI_UNSUPPORTED;
+ }
+ ///
+ /// Close the I/O Abstraction(s) used to perform the supported test
+ ///
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ return Status;
+}
+
+/**
+ This routine is called right after the .Supported() called and return
+ EFI_SUCCESS. Notes: The supported protocols are checked but the Protocols
+ are closed.
+
+ @param[in] This a pointer points to the Binding Protocol instance
+ @param[in] Controller The handle of controller to be tested. Parameter
+ passed by the caller
+ @param[in] RemainingDevicePath A pointer to the device path. Should be ignored by
+ device driver
+
+ @retval EFI_SUCCESS The driver ready and initial complete.
+ @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary data structures
+ @retval EFI_DEVICE_ERROR The device doesn't initial.
+**/
+EFI_STATUS
+EFIAPI
+IdeRControllerStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+{
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_IDE_CONTROLLER_PRIVATE_DATA *IdePrivateData;
+ UINT64 CommandVal;
+
+ ///
+ /// Now test and open the EfiPciIoProtocol
+ ///
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ (VOID **) &PciIo,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+
+ ///
+ /// Status == 0 - A normal execution flow, SUCCESS and the program proceeds.
+ /// Status == ALREADY_STARTED - A non-zero Status code returned. It indicates
+ /// that the protocol has been opened and should be treated as a
+ /// normal condition and the program proceeds. The Protocol will not
+ /// opened 'again' by this call.
+ /// Status != ALREADY_STARTED - Error status, terminate program execution
+ ///
+ if (EFI_ERROR (Status)) {
+ ///
+ /// EFI_ALREADY_STARTED is also an error
+ ///
+ return Status;
+ }
+ ///
+ /// Allocate Ide private data structure
+ ///
+ IdePrivateData = AllocatePool (sizeof (EFI_IDE_CONTROLLER_PRIVATE_DATA));
+ ASSERT (IdePrivateData != NULL);
+ if (IdePrivateData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ ///
+ /// Initialize IdeR controller private data
+ ///
+ ZeroMem (IdePrivateData, sizeof (EFI_IDE_CONTROLLER_PRIVATE_DATA));
+ IdePrivateData->Signature = IDER_CONTROLLER_SIGNATURE;
+ IdePrivateData->PciIo = PciIo;
+ IdePrivateData->IdeInit.GetChannelInfo = IdeInitGetChannelInfo;
+ IdePrivateData->IdeInit.NotifyPhase = IdeInitNotifyPhase;
+ IdePrivateData->IdeInit.SubmitData = IdeInitSubmitData;
+ IdePrivateData->IdeInit.DisqualifyMode = IdeInitDisqualifyMode;
+ IdePrivateData->IdeInit.CalculateMode = IdeInitCalculateMode;
+ IdePrivateData->IdeInit.SetTiming = IdeInitSetTiming;
+ IdePrivateData->IdeInit.EnumAll = IDER_ENUMER_ALL;
+ IdePrivateData->IdeInit.ChannelCount = IDER_MAX_CHANNEL;
+
+ //
+ // Get device capabilities
+ //
+ Status = PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationSupported,
+ 0,
+ &CommandVal
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Enable Command Register
+ //
+ Status = PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationEnable,
+ CommandVal & EFI_PCI_DEVICE_ENABLE,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ ///
+ /// Install IDE_CONTROLLER_INIT protocol & private data to this instance
+ ///
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Controller,
+ &gEfiIderControllerDriverProtocolGuid,
+ IdePrivateData,
+ &gEfiIdeControllerInitProtocolGuid,
+ &(IdePrivateData->IdeInit),
+ NULL
+ );
+
+ return Status;
+}
+
+/**
+ Stop.
+
+ @param[in] This Pointer to driver binding protocol
+ @param[in] Controller Controller handle to connect
+ @param[in] NumberOfChildren Number of children handle created by this driver
+ @param[in] ChildHandleBuffer Buffer containing child handle created
+
+ @retval EFI_SUCCESS Driver disconnected successfully from controller
+ @exception EFI_UNSUPPORTED Cannot find BIOS_VIDEO_DEV structure
+**/
+EFI_STATUS
+EFIAPI
+IdeRControllerStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+{
+ EFI_STATUS Status;
+ EFI_IDE_CONTROLLER_PRIVATE_DATA *IdePrivateData;
+
+ ///
+ /// Get private data
+ ///
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiIderControllerDriverProtocolGuid,
+ (VOID **) &IdePrivateData,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ ///
+ /// Close protocols opened by Ide controller driver
+ ///
+ Status = gBS->CloseProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ gBS->UninstallMultipleProtocolInterfaces (
+ Controller,
+ &gEfiIderControllerDriverProtocolGuid,
+ IdePrivateData,
+ &gEfiIdeControllerInitProtocolGuid,
+ &(IdePrivateData->IdeInit),
+ NULL
+ );
+
+ FreePool (IdePrivateData);
+
+ return EFI_SUCCESS;
+}
+
+///
+/// IDE-R Controller Driver Entry Point
+///
+
+/**
+ Chipset Ide Driver EntryPoint function. It follows the standard EFI driver
+ model. It's called by StartImage() of DXE Core
+
+ @param[in] ImageHandle - While the driver image loaded be the ImageLoader(),
+ an image handle is assigned to this driver binary,
+ all activities of the driver is tied to this ImageHandle
+ @param[in] SystemTable - A pointer to the system table, for all BS(Boo Services) and
+ RT(Runtime Services)
+
+ @retval EFI_SUCCESS Always return EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+InitializeIdeRControllerDriver (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.cif b/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.cif
new file mode 100644
index 0000000..08416f6
--- /dev/null
+++ b/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.cif
@@ -0,0 +1,13 @@
+<component>
+ name = "IdeRController"
+ category = ModulePart
+ LocalRoot = "ReferenceCode\ME\ActiveManagement\IdeR\Dxe\"
+ RefName = "IdeRController"
+[files]
+"IdeRController.sdl"
+"IdeRController.mak"
+"IdeRController.c"
+"IdeRControllerName.c"
+"IdeRController.h"
+"IdeRController.inf"
+<endComponent>
diff --git a/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.h b/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.h
new file mode 100644
index 0000000..86ab159
--- /dev/null
+++ b/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.h
@@ -0,0 +1,422 @@
+/** @file
+ Header file for chipset IDER ATA controller driver.
+
+@copyright
+ Copyright (c) 1999 - 2012 Intel Corporation. All rights
+ reserved This software and associated documentation (if any)
+ is furnished under a license and may only be used or copied in
+ accordance with the terms of the license. Except as permitted
+ by such license, no part of this software or documentation may
+ be reproduced, stored in a retrieval system, or transmitted in
+ any form or by any means without the express written consent
+ of Intel Corporation.
+
+ This file contains an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+
+**/
+#ifndef _IDER_ATA_CONTROLLER_H
+#define _IDER_ATA_CONTROLLER_H
+
+#include "pci22.h"
+#include "AmtLib.h"
+#include "MeAccess.h"
+
+//
+// Constant definition
+//
+#include EFI_PROTOCOL_DEFINITION (PciIo)
+#include EFI_PROTOCOL_DEFINITION (IdeControllerInit)
+#include EFI_PROTOCOL_CONSUMER (PciRootBridgeIo)
+#include EFI_PROTOCOL_DEFINITION (IderControllerDriver)
+
+//
+// Global Variables definitions
+//
+extern EFI_COMPONENT_NAME_PROTOCOL mIdeRControllerName;
+extern EFI_DRIVER_BINDING_PROTOCOL mIdeRControllerDriverBinding;
+
+//
+// Symbol definition, for PCI IDE configuration field
+//
+#define PCI_SUB_CLASS_IDE 0x01
+
+#define IDER_MAX_CHANNEL 0x01 ///< Max channels number of single sata controller
+#define IDER_MAX_DEVICES 0x02 ///< Max devices number of single sata channel
+#define IDER_ENUMER_ALL TRUE
+
+//
+// PIO and DMA Mode Timing and Control Registers definition
+//
+#define PCI_COMMAND_REGISTER 0x04
+#define PCI_BUS_MASTER_IDE_BASE 0x20
+#define IDE_TIMING_REGISTER_1 0x40
+#define IDE_TIMING_REGISTER_2 0x42
+#define IDE_SLAVE_TIMING_REGISTER 0x44
+#define ULTRA_DMA_CONTROL_REGISTER 0x48
+#define ULTRA_DMA_TIMING_REGISTER 0x4A
+#define IDE_IO_CONFIG_REGISTER 0x54
+
+#define R_PCI_SVID 0x2C
+
+//
+// IDE Register Field definition
+//
+#define ENABLE_DECODE_PRIMARY 0x8000
+
+#define BME_BUS_MASTER_ENABLE_BIT BIT2
+
+//
+// Ide Timing Register 1/2 Field offset 0x40-41 / 0x42-43
+//
+#define DTE0_DRIVE_0_DMA_TIMING_ENABLE bit3
+#define DTE1_DRIVE_1_DMA_TIMING_ENABLE bit7
+
+//
+// UDMA Control Register field offset 0x48
+//
+#define PSDE0_PRIMARY_DRIVE_0_UDMA_ENABLE bit0
+#define PSDE1_PRIMARY_DRIVE_1_UDMA_ENABLE bit1
+#define SSDE0_SECONDARY_DRIVE_0_UDMA_ENABLE bit2
+#define SSDE1_SECONDARY_DRIVE_1_UDMA_ENABLE bit3
+
+//
+// UDMA Timing Register
+//
+#define CT4_RP6 0x00
+#define CT3_RP5 0x01
+#define CT2_RP4 0x02
+
+#define CT3_RP8 0x01
+#define CT2_RP8 0x02
+
+#define CT3_RP16 0x01
+
+//
+// Ide I/O Configuration Register Field offset 0x54
+//
+#define PCB0_PRIMARY_DRIVE_0_BASE_CLOCK bit0
+#define PCB1_PRIMARY_DRIVE_1_BASE_CLOCK bit1
+#define SCB0_SECONDARY_DRIVE_0_BASE_CLOCK bit2
+#define SCB1_SECONDARY_DRIVE_1_BASE_CLOCK bit3
+#define ATA_FAST_PCB0_PRIMARY_DRIVE_0 bit12
+#define ATA_FAST_PCB1_PRIMARY_DRIVE_1 bit13
+#define ATA_FAST_SCB0_SECONDARY_DRIVE_0 bit14
+#define ATA_FAST_SCB1_SECONDARY_DRIVE_1 bit15
+
+//
+// PCH timing register structure
+//
+#pragma pack(1)
+
+typedef struct _IDER_TIMING_REG {
+ //
+ // PIO/MDMA/SDMA timing control for drive 0
+ //
+ UINT16 Time0 : 1;
+ UINT16 Ie0 : 1;
+ UINT16 Ppe0 : 1;
+ UINT16 Dte0 : 1;
+
+ //
+ // PIO/MDMA/SDMA timing control for drive 1
+ //
+ UINT16 Time1 : 1;
+ UINT16 Ie1 : 1;
+ UINT16 Ppe1 : 1;
+ UINT16 Dte1 : 1;
+
+ //
+ // PIO/MDMA/SDMA timing
+ //
+ UINT16 RecoveryTime : 2;
+ UINT16 Reserved0 : 2;
+ UINT16 IoRdySample : 2;
+ UINT16 Sitre : 1;
+ UINT16 IdeDecode : 1;
+
+} IDER_TIMING_REG;
+
+typedef struct _IDER_SLAVE_TIMING_REG {
+ //
+ // PIO/MDMA/SDMA timing control for primary slave device
+ //
+ UINT16 PrimaryRecoveryTime : 2;
+ UINT16 PrimaryIoRdySample : 2;
+
+ //
+ // PIO/MDMA/SDMA timing control for secondary slave device
+ //
+ UINT16 SecondaryRecoveryTime : 2;
+ UINT16 SecondaryIoRdySample : 2;
+
+} IDER_SLAVE_TIMING_REG;
+
+#pragma pack()
+
+#define IDER_CONTROLLER_SIGNATURE EFI_SIGNATURE_32 ('I', 'D', 'E', 'R')
+
+///
+/// Ide controller driver private data structure
+///
+typedef struct _EFI_IDE_CONTROLLER_PRIVATE_DATA {
+ ///
+ /// Standard signature used to identify Ide controller private data
+ ///
+ UINT32 Signature;
+
+ ///
+ /// Protocol instance of IDE_CONTROLLER_INIT produced by this driver
+ ///
+ EFI_IDE_CONTROLLER_INIT_PROTOCOL IdeInit;
+
+ ///
+ /// copy of protocol pointers used by this driver
+ ///
+ EFI_PCI_IO_PROTOCOL *PciIo;
+
+ ///
+ /// The highest disqulified mode for each attached Ide device.
+ /// Per ATA/ATAPI spec, if a mode is not supported, the modes higher than
+ /// it should not be supported
+ ///
+ EFI_ATA_COLLECTIVE_MODE DisqulifiedModes[IDER_MAX_CHANNEL][IDER_MAX_DEVICES];
+
+ ///
+ /// A copy of EFI_IDENTIFY_DATA data for each attached Ide device and its flag
+ ///
+ EFI_IDENTIFY_DATA IdentifyData[IDER_MAX_CHANNEL][IDER_MAX_DEVICES];
+ BOOLEAN IdentifyValid[IDER_MAX_CHANNEL][IDER_MAX_DEVICES];
+} EFI_IDE_CONTROLLER_PRIVATE_DATA;
+
+#define IDE_CONTROLLER_PRIVATE_DATA_FROM_THIS(a) \
+ CR ( \
+ a, \
+ EFI_IDE_CONTROLLER_PRIVATE_DATA, \
+ IdeInit, \
+ IDER_CONTROLLER_SIGNATURE \
+ )
+
+//
+// IDE-R controller IDE_CONTROLLER_INIT protocol declaration
+//
+
+/**
+ This function can be used to obtain information about a specified channel.
+ It's usually used by IDE Bus driver during enumeration process.
+
+ @param[in] This The EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ @param[in] Channel Channel number (0 based, either 0 or 1)
+ @param[in] Enabled TRUE if the channel is enabled. If the channel is disabled,
+ then it will no be enumerated.
+ @param[in] MaxDevices The Max number of IDE devices that the bus driver can expect
+ on this channel. For ATA/ATAPI, this number is either 1 or 2.
+
+ @retval EFI_SUCCESS Information copied
+ @retval EFI_INVALID_PARAMETER Invalid channel
+**/
+EFI_STATUS
+EFIAPI
+IdeInitGetChannelInfo (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ OUT BOOLEAN *Enabled,
+ OUT UINT8 *MaxDevices
+ )
+;
+
+/**
+ This function is called by IdeBus driver before executing certain actions.
+ This allows IDE Controller Init to prepare for each action.
+
+ @param[in] This The EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ @param[in] Phase Phase indicator defined by IDE_CONTROLLER_INIT protocol
+ @param[in] Channel Channel number (0 based, either 0 or 1)
+
+ @retval EFI_SUCCESS Preparation done
+ @retval EFI_INVALID_PARAMETER Invalid channel
+ @exception EFI_UNSUPPORTED Invalid phase
+**/
+EFI_STATUS
+EFIAPI
+IdeInitNotifyPhase (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase,
+ IN UINT8 Channel
+ )
+;
+
+/**
+ This function is called by IdeBus driver to submit EFI_IDENTIFY_DATA data structure
+ obtained from IDE deivce. This structure is used to set IDE timing
+
+ @param[in] This The EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ @param[in] Channel IDE channel number (0 based, either 0 or 1)
+ @param[in] Device IDE device number
+ @param[in] IdentifyData A pointer to EFI_IDENTIFY_DATA data structure
+
+ @retval EFI_SUCCESS Data submitted
+ @retval EFI_INVALID_PARAMETER Invalid channel
+**/
+EFI_STATUS
+EFIAPI
+IdeInitSubmitData (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_IDENTIFY_DATA *IdentifyData
+ )
+;
+
+/**
+ This function is called by IdeBus driver to disqualify unsupported operation
+ mode on specfic IDE device
+
+ @param[in] This The EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ @param[in] Channel IDE channel number (0 based, either 0 or 1)
+ @param[in] Device IDE device number
+ @param[in] BadModes Operation mode indicator
+
+ @retval EFI_SUCCESS Disqulified Modes recorded
+ @retval EFI_INVALID_PARAMETER Invalid channel or invalid BadModes pointer
+**/
+EFI_STATUS
+EFIAPI
+IdeInitDisqualifyMode (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_ATA_COLLECTIVE_MODE *BadModes
+ )
+;
+
+/**
+ This function is called by IdeBus driver to calculate the best operation mode
+ supported by specific IDE device
+
+ @param[in] This The EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ @param[in] Channel IDE channel number (0 based, either 0 or 1)
+ @param[in] Device IDE device number
+ @param[in] SupportedModes Modes collection supported by IDE device
+
+ @retval EFI_SUCCESS Disqulified Modes recorded
+ @retval EFI_INVALID_PARAMETER Invalid channel or invalid SupportedModes pointer
+ @retval EFI_NOT_READY IdentifyData is not valid
+ @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary data structures
+**/
+EFI_STATUS
+EFIAPI
+IdeInitCalculateMode (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes
+ )
+;
+
+/**
+ This function is called by IdeBus driver to set appropriate timing on IDE
+ controller according supported operation mode
+
+ @param[in] This The EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ @param[in] Channel IDE channel number (0 based, either 0 or 1)
+ @param[in] Device IDE device number
+ @param[in] Modes IDE device mode
+
+ @retval EFI_SUCCESS Disqulified Modes recorded
+ @retval EFI_INVALID_PARAMETER Invalid channel or invalid Modes pointer
+ @retval EFI_NOT_READY IdentifyData is not valid
+ @exception EFI_UNSUPPORTED Failed to set PIO/MDMA/SDMA timing
+**/
+EFI_STATUS
+EFIAPI
+IdeInitSetTiming (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_ATA_COLLECTIVE_MODE *Modes
+ )
+;
+
+//
+// IDE-R Controller Binding protocol declaration
+//
+
+/**
+ This function checks to see if the driver supports a device specified by
+ "Controller handle" parameter. It is called by DXE Core StartImage() or
+ ConnectController() routines. The driver uses 'device path' and/or
+ 'services' from the Bus I/O abstraction attached to the controller handle
+ to determine if the driver support this controller handle.
+
+ Note: In the BDS (Boot Device Selection) phase, the DXE core enumerate all
+ devices (or, controller) and assigns GUIDs to them.
+
+ @param[in] This a pointer points to the Binding Protocol instance
+ @param[in] Controller The handle of controller to be tested.
+ @param[in] RemainingDevicePath A pointer to the device path. Ignored by device
+ driver but used by bus driver
+
+ @retval EFI_SUCCESS Have device to support
+ @retval EFI_NOT_FOUND Relative environment not ready
+ @exception EFI_UNSUPPORTED The device doesn't support
+**/
+EFI_STATUS
+EFIAPI
+IdeRControllerSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+;
+
+/**
+ This routine is called right after the .Supported() called and return
+ EFI_SUCCESS. Notes: The supported protocols are checked but the Protocols
+ are closed.
+
+ @param[in] This a pointer points to the Binding Protocol instance
+ @param[in] Controller The handle of controller to be tested. Parameter
+ passed by the caller
+ @param[in] RemainingDevicePath A pointer to the device path. Should be ignored by
+ device driver
+
+ @retval EFI_SUCCESS The driver ready and initial complete.
+ @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary data structures
+ @retval EFI_DEVICE_ERROR The device doesn't initial.
+**/
+EFI_STATUS
+EFIAPI
+IdeRControllerStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+;
+
+/**
+ Stop.
+
+ @param[in] This Pointer to driver binding protocol
+ @param[in] Controller Controller handle to connect
+ @param[in] NumberOfChildren Number of children handle created by this driver
+ @param[in] ChildHandleBuffer Buffer containing child handle created
+
+ @retval EFI_SUCCESS Driver disconnected successfully from controller
+ @exception EFI_UNSUPPORTED Cannot find BIOS_VIDEO_DEV structure
+**/
+EFI_STATUS
+EFIAPI
+IdeRControllerStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+;
+
+#endif // _IDER_ATA_CONTROLLER_H
diff --git a/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.inf b/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.inf
new file mode 100644
index 0000000..954e20e
--- /dev/null
+++ b/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.inf
@@ -0,0 +1,86 @@
+## @file
+# Component description file for IDE-R Controller Driver module.
+#
+#@copyright
+# Copyright (c) 1999 - 2012 Intel Corporation. All rights reserved
+# This software and associated documentation (if any) is furnished
+# under a license and may only be used or copied in accordance
+# with the terms of the license. Except as permitted by such
+# license, no part of this software or documentation may be
+# reproduced, stored in a retrieval system, or transmitted in any
+# form or by any means without the express written consent of
+# Intel Corporation.
+#
+# This file contains a 'Sample Driver' and is licensed as such
+# under the terms of your license agreement with Intel or your
+# vendor. This file may be modified by the user, subject to
+# the additional terms of the license agreement
+#
+
+[defines]
+BASE_NAME = IdeRController
+FILE_GUID = C4F2D007-37FD-422d-B63D-7ED73886E6CA
+COMPONENT_TYPE = BS_DRIVER
+
+[sources.common]
+ IdeRController.h
+ IdeRController.c
+ IdeRControllerName.c
+
+#
+# Edk II Glue Driver Entry Point
+#
+ EdkIIGlueDxeDriverEntryPoint.c
+
+[includes.common]
+ $(EFI_SOURCE)/$(PROJECT_ME_ROOT)
+ $(EFI_SOURCE)/$(PROJECT_ME_ROOT)/Include
+ $(EFI_SOURCE)/$(PROJECT_ME_ROOT)/Library/AMT/Dxe
+ $(EFI_SOURCE)/$(PROJECT_ME_ROOT)/Library/AMT/Include
+ $(EFI_SOURCE)/$(PROJECT_ME_ROOT)/Library/MeKernel/Include
+ $(EFI_SOURCE)/$(PROJECT_ME_ROOT)/Library/MeKernel/Dxe
+ $(EFI_SOURCE)/$(PROJECT_ME_ROOT)/Heci/Include
+ $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include
+
+#
+# EDK II Glue Library utilizes some standard headers from EDK
+#
+ $(EDK_SOURCE)/Foundation
+ $(EDK_SOURCE)/Foundation/Core/Dxe
+ $(EDK_SOURCE)/Foundation/Efi
+ $(EDK_SOURCE)/Foundation/Efi/Include
+ $(EDK_SOURCE)/Foundation/Framework
+ $(EDK_SOURCE)/Foundation/Framework/Include
+ $(EDK_SOURCE)/Foundation/Include
+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
+ $(EDK_SOURCE)/Foundation/Library/Dxe/Include
+ $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include
+
+[libraries.common]
+ MeGuidLib
+ AmtLib
+ EdkProtocolLib
+ EdkFrameworkProtocolLib
+ EdkIIGlueBaseMemoryLib
+ EdkIIGlueDxeReportStatusCodeLib
+ EdkIIGlueDxeDebugLibReportStatusCode
+ EdkIIGlueUefiBootServicesTableLib
+ EdkIIGlueUefiRuntimeServicesTableLib
+ EdkIIGlueUefiLib
+ EdkIIGlueUefiDriverModelLib
+
+[nmake.common]
+ IMAGE_ENTRY_POINT = _ModuleEntryPoint
+#
+# Module Entry Point
+#
+ C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_MODULE_ENTRY_POINT__=InitializeIdeRControllerDriver \
+ -D __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__=mIdeRControllerDriverBinding \
+ -D __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__=mIdeRControllerName
+ C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_BASE_MEMORY_LIB__ \
+ -D __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__ \
+ -D __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ \
+ -D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ \
+ -D __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ \
+ -D __EDKII_GLUE_UEFI_LIB__ \
+ -D __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__
diff --git a/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.mak b/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.mak
new file mode 100644
index 0000000..e7abc52
--- /dev/null
+++ b/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.mak
@@ -0,0 +1,55 @@
+# MAK file for the ModulePart:IdeRController
+all : IdeRController
+
+$(BUILD_DIR)\IdeRController.mak : $(IdeRController_DIR)\$(@B).cif $(IdeRController_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(IdeRController_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+IdeRController : $(BUILD_DIR)\IdeRController.mak IdeRControllerBin
+
+IdeRController_INCLUDES=\
+ $(ME_INCLUDES)\
+ $(EdkIIGlueLib_INCLUDES)\
+ $(EDK_INCLUDES)\
+ $(INTEL_PCH_INCLUDES)
+
+IdeRController_DEFINES=\
+ $(MY_DEFINES)\
+ /D"__EDKII_GLUE_MODULE_ENTRY_POINT__=InitializeIdeRControllerDriver"\
+ /D"__EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__=mIdeRControllerDriverBinding"\
+ /D"__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__=mIdeRControllerName"\
+ /D __EDKII_GLUE_BASE_MEMORY_LIB__ \
+ /D __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__ \
+ /D __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ \
+ /D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ \
+ /D __EDKII_GLUE_UEFI_LIB__ \
+ /D __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__
+
+IdeRController_LIBS=\
+ $(EDKPROTOCOLLIB)\
+ $(AmtGuidLib_LIB)\
+ $(AmtLibDxe_LIB)\
+ $(EDKFRAMEWORKPROTOCOLLIB)\
+ $(EdkIIGlueBaseLib_LIB)\
+!IF "$(x64_BUILD)"=="1"
+ $(EdkIIGlueBaseLibX64_LIB)\
+!ELSE
+ $(EdkIIGlueBaseLibIA32_LIB)\
+!ENDIF
+ $(EdkIIGlueBaseMemoryLib_LIB)\
+ $(EdkIIGlueDxeReportStatusCodeLib_LIB)\
+ $(EdkIIGlueDxeDebugLibReportStatusCode_LIB)\
+ $(EdkIIGlueUefiBootServicesTableLib_LIB)\
+ $(EdkIIGlueUefiLib_LIB)\
+ $(EdkIIGlueUefiDriverModelLib_LIB)\
+
+
+IdeRControllerBin : $(IdeRController_LIBS)
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ /f $(BUILD_DIR)\IdeRController.mak all \
+ "MY_INCLUDES=$(IdeRController_INCLUDES)"\
+ "MY_DEFINES=$(IdeRController_DEFINES)"\
+ GUID=C4F2D007-37FD-422d-B63D-7ED73886E6CA \
+ ENTRY_POINT=_ModuleEntryPoint \
+ TYPE=BS_DRIVER \
+ EDKIIModule=DXEDRIVER\
+ COMPRESS=1
diff --git a/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.sdl b/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.sdl
new file mode 100644
index 0000000..b73480f
--- /dev/null
+++ b/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRController.sdl
@@ -0,0 +1,24 @@
+TOKEN
+ Name = "IdeRController_SUPPORT"
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable IdeRController support in Project"
+End
+MODULE
+ Help = "Includes IdeRController.mak to Project"
+ File = "IdeRController.mak"
+End
+
+PATH
+ Name = "IdeRController_DIR"
+ Help = "iAMT IdeRController file source directory"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\IdeRController.ffs"
+ Parent = "FV_MAIN"
+ InvokeOrder = AfterParent
+End \ No newline at end of file
diff --git a/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRControllerName.c b/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRControllerName.c
new file mode 100644
index 0000000..15f3bf9
--- /dev/null
+++ b/ReferenceCode/ME/ActiveManagement/IdeR/Dxe/IdeRControllerName.c
@@ -0,0 +1,172 @@
+/** @file
+ This portion is to register the IDE Redirect Controller Driver name
+
+@copyright
+ Copyright (c) 1999 - 2012 Intel Corporation. All rights
+ reserved This software and associated documentation (if any)
+ is furnished under a license and may only be used or copied in
+ accordance with the terms of the license. Except as permitted
+ by such license, no part of this software or documentation may
+ be reproduced, stored in a retrieval system, or transmitted in
+ any form or by any means without the express written consent
+ of Intel Corporation.
+
+ This file contains an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
+#include "EdkIIGlueDxe.h"
+#include "IdeRController.h"
+#endif
+
+//
+// Forward reference declaration
+//
+EFI_STATUS
+EFIAPI
+IdeRControllerGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ );
+
+EFI_STATUS
+EFIAPI
+IdeRControllerGetControllerName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ );
+
+///
+/// EFI Component Name Protocol
+/// This portion declares a gloabl variable of EFI_COMPONENT_NAME_PROTOCOL type.
+/// It initializes the followings:
+/// - GetDriverName() to PlatformIdeGetDriverName()
+/// - SupportedLanguages to "eng" (3 char ISO639-2 language indetifier)
+///
+EFI_COMPONENT_NAME_PROTOCOL mIdeRControllerName = {
+ IdeRControllerGetDriverName,
+ IdeRControllerGetControllerName,
+ "eng" // English
+};
+
+//
+// Define the Driver's unicode name string
+// IDE controller Driver name string and IDE Controller Name string
+//
+static EFI_UNICODE_STRING_TABLE mIdeRControllerDriverNameTable[] = {
+ {
+ "eng",
+ L"IDER Controller Init Driver"
+ },
+ {
+ NULL,
+ NULL
+ }
+};
+
+static EFI_UNICODE_STRING_TABLE mIdeRControllerControllerNameTable[] = {
+ {
+ "eng",
+ L"IDER Controller"
+ },
+ {
+ NULL,
+ NULL
+ }
+};
+
+/**
+ This is a function definition of EFI_COMPONENT_NAME_PROTOCOL.GetDriverName(). This function
+ is to provide the user readable name of IDE Driver, defined in mPlaformIdeNameTable
+ This function is called by the platform management utilities to display the name of component.
+
+ @param[in] This The address of protocol
+ @param[in] Language If the caller specificed Language matches SupportedLanguage, a pointer
+ to the Driver name is returned in the DriverName.
+ @param[in] DriverName If the caller specificed Language matches SupportedLanguage, a pointer
+ to the Driver name is returned in the DriverName.
+
+ @retval EFI_SUCCESS If the caller specificed Language matches SupportedLanguage.
+ i.e. Language == gPlatformIdeName.SupportedLanguages
+ @exception EFI_UNSUPPORTED If the caller specificed Language doesn't match SupportedLanguage.
+**/
+EFI_STATUS
+EFIAPI
+IdeRControllerGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ )
+{
+
+ return LookupUnicodeString (
+ Language,
+ mIdeRControllerName.SupportedLanguages,
+ mIdeRControllerDriverNameTable,
+ DriverName
+ );
+
+}
+
+/**
+ Retrieves a Unicode string that is the user readable name of
+ the controller that is being managed by an EFI Driver.
+
+ @param[in] This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+ @param[in] ControllerHandle The handle of a controller that the driver specified by
+ This is managing. This handle specifies the controller
+ whose name is to be returned.
+ @param[in] ChildHandle The handle of the child controller to retrieve the name
+ of. This is an optional parameter that may be NULL. It
+ will be NULL for device drivers. It will also be NULL
+ for a bus drivers that wish to retrieve the name of the
+ bus controller. It will not be NULL for a bus driver
+ that wishes to retrieve the name of a child controller.
+ @param[in] Language A pointer to a three character ISO 639-2 language
+ identifier. This is the language of the controller name
+ that that the caller is requesting, and it must match one
+ of the languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up to the
+ driver writer.
+ @param[in] ControllerName A pointer to the Unicode string to return. This Unicode
+ string is the name of the controller specified by
+ ControllerHandle and ChildHandle in the language
+ specified by Language from the point of view of the
+ driver specified by This.
+
+ @retval EFI_SUCCESS The Unicode string for the user readable name in the
+ language specified by Language for the driver
+ specified by This was returned in DriverName.
+ @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. Language
+ or ControllerName is NULL.
+ @exception EFI_UNSUPPORTED The driver specified by this is not currently
+ managing the controller specified by
+ ControllerHandle and ChildHandle. Or the driver
+ specified by This does not support the language specified
+ by Language.
+**/
+EFI_STATUS
+EFIAPI
+IdeRControllerGetControllerName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ )
+{
+ return LookupUnicodeString (
+ Language,
+ mIdeRControllerName.SupportedLanguages,
+ mIdeRControllerControllerNameTable,
+ ControllerName
+ );
+}