summaryrefslogtreecommitdiff
path: root/DuetPkg
diff options
context:
space:
mode:
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2009-07-24 07:36:29 +0000
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2009-07-24 07:36:29 +0000
commit93d4ce918198c9de4a4e30681c78b811d6e90bb5 (patch)
tree7e29c2330a71f09257b08dcad2e400cd9950c7c4 /DuetPkg
parentac10c7278248f5f54af8292287cd6c76a509b098 (diff)
downloadedk2-platforms-93d4ce918198c9de4a4e30681c78b811d6e90bb5.tar.xz
Add IDE support for edk2 Duet platform.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9000 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'DuetPkg')
-rw-r--r--DuetPkg/DuetPkg.dsc5
-rw-r--r--DuetPkg/DuetPkg.fdf3
-rw-r--r--DuetPkg/IdeControllerDxe/ComponentName.h145
-rw-r--r--DuetPkg/IdeControllerDxe/IdeController.c631
-rw-r--r--DuetPkg/IdeControllerDxe/IdeController.h382
-rw-r--r--DuetPkg/IdeControllerDxe/IdeController.inf55
-rw-r--r--DuetPkg/IdeControllerDxe/IdeControllerName.c215
-rw-r--r--DuetPkg/IdeControllerDxe/IdeData.h311
8 files changed, 1744 insertions, 3 deletions
diff --git a/DuetPkg/DuetPkg.dsc b/DuetPkg/DuetPkg.dsc
index fa45258732..525aa79344 100644
--- a/DuetPkg/DuetPkg.dsc
+++ b/DuetPkg/DuetPkg.dsc
@@ -158,8 +158,9 @@
IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.inf
# IDE Support
- #IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf
-
+ IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf
+ DuetPkg/IdeControllerDxe/IdeController.inf
+
# Usb Support
MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
diff --git a/DuetPkg/DuetPkg.fdf b/DuetPkg/DuetPkg.fdf
index 928b0f991f..aa1b6f7689 100644
--- a/DuetPkg/DuetPkg.fdf
+++ b/DuetPkg/DuetPkg.fdf
@@ -94,7 +94,8 @@ INF IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortDxe.inf
INF IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.inf
# IDE Support
-#IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf
+INF IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf
+INF DuetPkg/IdeControllerDxe/IdeController.inf
# Usb Support
INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
diff --git a/DuetPkg/IdeControllerDxe/ComponentName.h b/DuetPkg/IdeControllerDxe/ComponentName.h
new file mode 100644
index 0000000000..9797650f17
--- /dev/null
+++ b/DuetPkg/IdeControllerDxe/ComponentName.h
@@ -0,0 +1,145 @@
+/*++
+
+Copyright (c) 2006 - 2007 Intel Corporation. All rights reserved
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ ComponentName.h
+
+Abstract:
+
+
+Revision History
+--*/
+
+#ifndef _IDE_CONTROLLER_COMPONENT_NAME_H
+#define _IDE_CONTROLLER_COMPONENT_NAME_H
+
+#ifndef EFI_SIZE_REDUCTION_APPLIED
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (ComponentName)
+#include EFI_PROTOCOL_DEFINITION (ComponentName2)
+
+//
+// Global Variables definitions
+//
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+extern EFI_COMPONENT_NAME2_PROTOCOL gIdeControllerName;
+#else
+extern EFI_COMPONENT_NAME_PROTOCOL gIdeControllerName;
+#endif
+
+//
+// Forward reference declaration
+//
+EFI_STATUS
+EFIAPI
+IdeControllerGetDriverName (
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+#else
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+#endif
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ )
+/*++
+
+ Routine Description:
+ Retrieves a Unicode string that is the user readable name of the EFI Driver.
+
+ Arguments:
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+ Language - A pointer to a three character ISO 639-2 language identifier.
+ This is the language of the driver 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.
+ DriverName - A pointer to the Unicode string to return. This Unicode string
+ is the name of the driver specified by This in the language
+ specified by Language.
+
+ Returns:
+ EFI_SUCCESS - The Unicode string for the Driver specified by This
+ and the language specified by Language was returned
+ in DriverName.
+ EFI_INVALID_PARAMETER - Language is NULL.
+ EFI_INVALID_PARAMETER - DriverName is NULL.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+IdeControllerGetControllerName (
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+#else
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+#endif
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ )
+/*++
+
+ Routine Description:
+ Retrieves a Unicode string that is the user readable name of the controller
+ that is being managed by an EFI Driver.
+
+ Arguments:
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+ 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.
+ 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.
+ 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.
+ 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.
+
+ Returns:
+ 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.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
+ EFI_HANDLE.
+ EFI_INVALID_PARAMETER - Language is NULL.
+ EFI_INVALID_PARAMETER - ControllerName is NULL.
+ EFI_UNSUPPORTED - The driver specified by This is not currently
+ managing the controller specified by
+ ControllerHandle and ChildHandle.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+
+--*/
+;
+
+#endif
+
+#endif
diff --git a/DuetPkg/IdeControllerDxe/IdeController.c b/DuetPkg/IdeControllerDxe/IdeController.c
new file mode 100644
index 0000000000..d1334c0f33
--- /dev/null
+++ b/DuetPkg/IdeControllerDxe/IdeController.c
@@ -0,0 +1,631 @@
+/*++
+
+Copyright (c) 2006 - 2007 Intel Corporation. All rights reserved
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ IdeController.c
+
+Abstract:
+
+ 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 controller.
+
+Revision History
+--*/
+
+#include "IdeController.h"
+#include "IdeData.h"
+
+//
+// IDE Controller Init Guid
+//
+EFI_GUID
+ gIdeControllerDriverGuid = { 0x91e365e9, 0xe0c0, 0x4647, 0xb0, 0xeb, 0xf6, 0x78, 0xf6, 0x21, 0xf8, 0x8d };
+
+//
+// EFI_DRIVER_BINDING_PROTOCOL instance
+//
+EFI_DRIVER_BINDING_PROTOCOL gIdeControllerDriverBinding = {
+ IdeControllerSupported,
+ IdeControllerStart,
+ IdeControllerStop,
+ 0xa,
+ NULL,
+ NULL
+};
+
+//
+// Internal function definitions
+//
+EFI_STATUS
+EnableNativeIdeDecode (
+ IN EFI_PCI_IO_PROTOCOL *PciIo
+ );
+
+EFI_STATUS
+EnableLegacyIdeDecode (
+ EFI_EVENT Event,
+ VOID *Context
+ );
+
+EFI_STATUS
+IdeDetectCableType (
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDENTIFY_DATA *IdentifyData
+ );
+
+EFI_STATUS
+AdjustUdmaModeByCableType (
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN OUT EFI_ATA_COLLECTIVE_MODE *Modes
+ );
+
+EFI_STATUS
+CalculateBestPioMode (
+ IN EFI_IDENTIFY_DATA * IdentifyData,
+ IN UINT16 *DisPioMode OPTIONAL,
+ OUT UINT16 *SelectedMode
+ );
+
+EFI_STATUS
+CalculateBestUdmaMode (
+ IN EFI_IDENTIFY_DATA * IdentifyData,
+ IN UINT16 *DisUDmaMode OPTIONAL,
+ OUT UINT16 *SelectedMode
+ );
+
+EFI_STATUS
+IdeInitSetUdmaTiming (
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_ATA_COLLECTIVE_MODE *Modes
+ );
+
+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
+ );
+
+//
+// *************************************
+// IdeController Driver Entry Point
+// *************************************
+//
+EFI_STATUS
+EFIAPI
+InitializeIdeControllerDriver (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+ Routine Description:
+
+ Chipset Ide Driver EntryPoint function. It follows the standard EFI driver
+ model. It's called by StartImage() of DXE Core
+
+ Argments:
+
+ ImageHnadle -- 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
+ *SystemTable -- A pointer to the system table, for all BS(Boo Services) and
+ RT(Runtime Services)
+
+ Retruns:
+
+ Always call EfiLibInstallDriverBindingProtocol( ) and retrun the result
+
+--*/
+{
+
+ return EfiLibInstallDriverBindingComponentName2 (
+ ImageHandle,
+ SystemTable,
+ &gIdeControllerDriverBinding,
+ ImageHandle,
+ &gIdeControllerName,
+ &gIdeControllerName2
+ );
+}
+
+EFI_STATUS
+EFIAPI
+IdeControllerSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+/*++
+
+ Routine Description:
+
+ Register Driver Binding protocol for this driver.
+
+ Arguments:
+
+ This -- a pointer points to the Binding Protocol instance
+ Controller -- The handle of controller to be tested.
+ *RemainingDevicePath -- A pointer to the device path. Ignored by device
+ driver but used by bus driver
+
+ Returns:
+
+ EFI_SUCCESS -- Driver loaded.
+ other -- Driver not loaded.
+--*/
+{
+ 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,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ 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 PCI Configuration table fields
+ //
+ if ((PciData.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE) ||
+ (PciData.Hdr.ClassCode[1] != PCI_SUB_CLASS_IDE)
+ ) {
+
+ Status = EFI_UNSUPPORTED;
+ }
+
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+IdeControllerStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+/*++
+
+ Routine Description:
+
+ This routine is called right after the .Supported() called and return
+ EFI_SUCCESS. Notes: The supported protocols are checked but the Protocols
+ are closed.
+
+ Arguments:
+
+ This -- a pointer points to the Binding Protocol instance
+ Controller -- The handle of controller to be tested. Parameter
+ passed by the caller
+ *RemainingDevicePath -- A pointer to the device path. Should be ignored by
+ device driver
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_IDE_CONTROLLER_PRIVATE_DATA *IdePrivateData;
+
+ //
+ // 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
+ //
+ Status = gBS->AllocatePool (
+ EfiBootServicesData,
+ sizeof (EFI_IDE_CONTROLLER_PRIVATE_DATA),
+ (VOID **) &IdePrivateData
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ //
+ // Initialize Ide controller private data
+ //
+ ZeroMem (IdePrivateData, sizeof (EFI_IDE_CONTROLLER_PRIVATE_DATA));
+ IdePrivateData->Signature = IDE_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 = ICH_IDE_ENUMER_ALL;
+ IdePrivateData->IdeInit.ChannelCount = ICH_IDE_MAX_CHANNEL;
+
+ //
+ // Install IDE_CONTROLLER_INIT protocol & private data to this instance
+ //
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Controller,
+ &gIdeControllerDriverGuid,
+ IdePrivateData,
+ &gEfiIdeControllerInitProtocolGuid,
+ &(IdePrivateData->IdeInit),
+ NULL
+ );
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+IdeControllerStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+/*++
+
+ Routine Description:
+ Stop this driver on Controller Handle.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Controller - Handle of device to stop driver on
+ NumberOfChildren - Not used
+ ChildHandleBuffer - Not used
+
+ Returns:
+ EFI_SUCCESS - This driver is removed DeviceHandle
+ other - This driver was not removed from this device
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_IDE_CONTROLLER_PRIVATE_DATA *IdePrivateData;
+
+ //
+ // Get private data
+ //
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gIdeControllerDriverGuid,
+ (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,
+ &gIdeControllerDriverGuid,
+ IdePrivateData,
+ &gEfiIdeControllerInitProtocolGuid,
+ &(IdePrivateData->IdeInit),
+ NULL
+ );
+
+ gBS->FreePool (IdePrivateData);
+
+ return EFI_SUCCESS;
+}
+
+//
+// Interface functions of IDE_CONTROLLER_INIT protocol
+//
+EFI_STATUS
+EFIAPI
+IdeInitGetChannelInfo (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ OUT BOOLEAN *Enabled,
+ OUT UINT8 *MaxDevices
+ )
+/*++
+Routine Description:
+
+ This function can be used to obtain information about a specified channel.
+ It's usually used by IDE Bus driver during enumeration process.
+
+Arguments:
+
+ This -- the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ Channel -- Channel number (0 based, either 0 or 1)
+ Enabled -- TRUE if the channel is enabled. If the channel is disabled,
+ then it will no be enumerated.
+ 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.
+
+Returns:
+ EFI_STATUS
+
+--*/
+{
+ //
+ // Channel number (0 based, either 0 or 1)
+ //
+ if (Channel < ICH_IDE_MAX_CHANNEL) {
+ *Enabled = TRUE;
+ *MaxDevices = ICH_IDE_MAX_DEVICES;
+ return EFI_SUCCESS;
+ }
+
+ *Enabled = FALSE;
+ return EFI_INVALID_PARAMETER;
+}
+
+
+EFI_STATUS
+EFIAPI
+IdeInitNotifyPhase (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase,
+ IN UINT8 Channel
+ )
+/*++
+
+Routine Description:
+
+ This function is called by IdeBus driver before executing certain actions.
+ This allows IDE Controller Init to prepare for each action.
+
+Arguments:
+
+ This -- the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ Phase -- phase indicator defined by IDE_CONTROLLER_INIT protocol
+ Channel -- Channel number (0 based, either 0 or 1)
+
+Returns:
+
+--*/
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+IdeInitSubmitData (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_IDENTIFY_DATA *IdentifyData
+ )
+/*++
+
+Routine Description:
+
+ 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
+
+Arguments:
+
+ This -- the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ Channel -- IDE channel number (0 based, either 0 or 1)
+ Device -- IDE device number
+ IdentifyData -- A pointer to EFI_IDENTIFY_DATA data structure
+
+Returns:
+
+--*/
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+IdeInitDisqualifyMode (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_ATA_COLLECTIVE_MODE *BadModes
+ )
+/*++
+
+Routine Description:
+
+ This function is called by IdeBus driver to disqualify unsupported operation
+ mode on specfic IDE device
+
+Arguments:
+
+ This -- the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ Channel -- IDE channel number (0 based, either 0 or 1)
+ Device -- IDE device number
+ BadModes -- Operation mode indicator
+
+Returns:
+
+--*/
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+IdeInitCalculateMode (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes
+ )
+/*++
+
+Routine Description:
+
+ This function is called by IdeBus driver to calculate the best operation mode
+ supported by specific IDE device
+
+Arguments:
+
+ This -- the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ Channel -- IDE channel number (0 based, either 0 or 1)
+ Device -- IDE device number
+ SupportedModes -- Modes collection supported by IDE device
+
+Returns:
+
+--*/
+{
+ if (Channel >= ICH_IDE_MAX_CHANNEL || Device >= ICH_IDE_MAX_DEVICES) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *SupportedModes = AllocateZeroPool (sizeof (EFI_ATA_COLLECTIVE_MODE));
+ if (*SupportedModes == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // In EoE enviroment, when nothing is known about the platform hardware,
+ // just set the mode to lowest PIO mode for compatibility.
+ //
+ (*SupportedModes)->PioMode.Valid = TRUE;
+ (*SupportedModes)->PioMode.Mode = AtaPioModeBelow2;
+ (*SupportedModes)->UdmaMode.Valid = FALSE;
+ (*SupportedModes)->SingleWordDmaMode.Valid = FALSE;
+ (*SupportedModes)->MultiWordDmaMode.Valid = FALSE;
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+IdeInitSetTiming (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_ATA_COLLECTIVE_MODE *Modes
+ )
+/*++
+
+Routine Description:
+
+ This function is called by IdeBus driver to set appropriate timing on IDE
+ controller according supported operation mode
+
+Arguments:
+
+ This -- the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
+ Channel -- IDE channel number (0 based, either 0 or 1)
+ Device -- IDE device number
+
+Returns:
+
+--*/
+{
+ return EFI_SUCCESS;
+}
+
+
diff --git a/DuetPkg/IdeControllerDxe/IdeController.h b/DuetPkg/IdeControllerDxe/IdeController.h
new file mode 100644
index 0000000000..15f7ba4136
--- /dev/null
+++ b/DuetPkg/IdeControllerDxe/IdeController.h
@@ -0,0 +1,382 @@
+/*++
+
+Copyright (c) 2006 Intel Corporation. All rights reserved
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ IdeController.h
+
+Abstract:
+
+ Header file for chipset ATA controller driver.
+
+Revision History
+--*/
+
+#ifndef _IDE_CONTROLLER_H
+#define _IDE_CONTROLLER_H
+
+#include <PiDxe.h>
+
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiLib.h>
+#include <Protocol/PciIo.h>
+#include <Protocol/IdeControllerInit.h>
+
+//
+// Driver Binding Externs
+//
+extern EFI_DRIVER_BINDING_PROTOCOL gIdeControllerDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gIdeControllerName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gIdeControllerName2;
+
+#include <IndustryStandard/Pci22.h>
+
+//
+// Symbol definition, for PCI IDE configuration field
+//
+#define PCI_CLASS_MASS_STORAGE 0x01
+#define PCI_SUB_CLASS_IDE 0x01
+
+//
+// Supports 2 channel max
+//
+#define ICH_IDE_MAX_CHANNEL 0x02
+//
+// Supports 2 devices max
+//
+#define ICH_IDE_MAX_DEVICES 0x02
+#define ICH_IDE_ENUMER_ALL FALSE
+
+#define IDE_CONTROLLER_SIGNATURE SIGNATURE_32 ('i', 'i', 'd', 'e')
+
+//
+// Ide controller driver private data structure
+//
+typedef struct {
+ //
+ // 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[ICH_IDE_MAX_CHANNEL][ICH_IDE_MAX_DEVICES];
+
+ //
+ // A copy of EFI_IDENTIFY_DATA data for each attached Ide device and its flag
+ //
+ EFI_IDENTIFY_DATA IdentifyData[ICH_IDE_MAX_CHANNEL][ICH_IDE_MAX_DEVICES];
+ BOOLEAN IdentifyValid[ICH_IDE_MAX_CHANNEL][ICH_IDE_MAX_DEVICES];
+
+} EFI_IDE_CONTROLLER_PRIVATE_DATA;
+
+#define IDE_CONTROLLER_PRIVATE_DATA_FROM_THIS(a) \
+ CR (a, \
+ EFI_IDE_CONTROLLER_PRIVATE_DATA, \
+ IdeInit, \
+ IDE_CONTROLLER_SIGNATURE \
+ )
+
+//
+// Driver binding functions declaration
+//
+EFI_STATUS
+EFIAPI
+IdeControllerSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+/*++
+
+ Routine Description:
+
+ Register Driver Binding protocol for this driver.
+
+ Arguments:
+
+ This -- a pointer points to the Binding Protocol instance
+ Controller -- The handle of controller to be tested.
+ *RemainingDevicePath -- A pointer to the device path. Ignored by device
+ driver but used by bus driver
+
+ Returns:
+
+ EFI_SUCCESS -- Driver loaded.
+ other -- Driver not loaded.
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+IdeControllerStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+/*++
+
+ Routine Description:
+
+ This routine is called right after the .Supported() called and return
+ EFI_SUCCESS. Notes: The supported protocols are checked but the Protocols
+ are closed.
+
+ Arguments:
+
+ This -- a pointer points to the Binding Protocol instance
+ Controller -- The handle of controller to be tested. Parameter
+ passed by the caller
+ *RemainingDevicePath -- A pointer to the device path. Should be ignored by
+ device driver
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+IdeControllerStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+/*++
+
+ Routine Description:
+ Stop this driver on Controller Handle.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Controller - Handle of device to stop driver on
+ NumberOfChildren - Not used
+ ChildHandleBuffer - Not used
+
+ Returns:
+ EFI_SUCCESS - This driver is removed DeviceHandle
+ other - This driver was not removed from this device
+
+--*/
+;
+
+//
+// IDE controller init functions declaration
+//
+EFI_STATUS
+EFIAPI
+IdeInitGetChannelInfo (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ OUT BOOLEAN *Enabled,
+ OUT UINT8 *MaxDevices
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ This - TODO: add argument description
+ Channel - TODO: add argument description
+ Enabled - TODO: add argument description
+ MaxDevices - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+IdeInitNotifyPhase (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase,
+ OUT UINT8 Channel
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ This - TODO: add argument description
+ Phase - TODO: add argument description
+ Channel - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+IdeInitSubmitData (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_IDENTIFY_DATA *IdentifyData
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ This - TODO: add argument description
+ Channel - TODO: add argument description
+ Device - TODO: add argument description
+ IdentifyData - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+IdeInitSubmitFailingModes (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ This - TODO: add argument description
+ Channel - TODO: add argument description
+ Device - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+IdeInitDisqualifyMode (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_ATA_COLLECTIVE_MODE *BadModes
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ This - TODO: add argument description
+ Channel - TODO: add argument description
+ Device - TODO: add argument description
+ BadModes - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+IdeInitCalculateMode (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_ATA_COLLECTIVE_MODE **SupportedModes
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ This - TODO: add argument description
+ Channel - TODO: add argument description
+ Device - TODO: add argument description
+ SupportedModes - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+IdeInitSetTiming (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_ATA_COLLECTIVE_MODE *Modes
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ This - TODO: add argument description
+ Channel - TODO: add argument description
+ Device - TODO: add argument description
+ Modes - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+#endif
diff --git a/DuetPkg/IdeControllerDxe/IdeController.inf b/DuetPkg/IdeControllerDxe/IdeController.inf
new file mode 100644
index 0000000000..076dd10642
--- /dev/null
+++ b/DuetPkg/IdeControllerDxe/IdeController.inf
@@ -0,0 +1,55 @@
+#/*++
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# IdeController.inf
+#
+# Abstract:
+#
+# Component description file for IDE Controller Driver module.
+#
+#--*/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = IdeController
+ FILE_GUID = F3790689-FB90-4479-A2EF-B82A43AFE74D
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ EDK_RELEASE_VERSION = 0x00020000
+ EFI_SPECIFICATION_VERSION = 0x00020000
+ ENTRY_POINT = InitializeIdeControllerDriver
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ DuetPkg/DuetPkg.dec
+
+[Sources]
+ IdeController.h
+ IdeController.c
+ IdeControllerName.c
+
+
+[LibraryClasses]
+ UefiLib
+ MemoryAllocationLib
+ DebugLib
+ BaseMemoryLib
+ UefiDriverEntryPoint
+ UefiBootServicesTableLib
+
+[Protocols]
+ gEfiDevicePathProtocolGuid # PROTOCOL TO_START
+ gEfiIdeControllerInitProtocolGuid # PROTOCOL BY_START
+ gEfiPciIoProtocolGuid # PROTOCOL TO_START
+
diff --git a/DuetPkg/IdeControllerDxe/IdeControllerName.c b/DuetPkg/IdeControllerDxe/IdeControllerName.c
new file mode 100644
index 0000000000..69ef253de4
--- /dev/null
+++ b/DuetPkg/IdeControllerDxe/IdeControllerName.c
@@ -0,0 +1,215 @@
+/*++
+
+Copyright (c) 2006 - 2007 Intel Corporation. All rights reserved
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ IdeControllerName.c
+
+Abstract:
+
+ This portion is to register the IDE Controller Driver name:
+ "IDE Controller Init Driver"
+
+Revision History
+--*/
+
+#include "IdeController.h"
+
+EFI_STATUS
+EFIAPI
+IdeControllerGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ );
+
+EFI_STATUS
+EFIAPI
+IdeControllerGetControllerName (
+ 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() and
+// SupportedLanguages to LANGUAGE_CODE_ENGLISH (3 char ISO639-2 language indetifier)
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIdeControllerName = {
+ IdeControllerGetDriverName,
+ IdeControllerGetControllerName,
+ "eng" // Egnlish
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIdeControllerName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IdeControllerGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IdeControllerGetControllerName,
+ "en" // Egnlish
+};
+
+//
+// Define the Driver's unicode name string
+// IDE controller Driver name string and IDE Controller Name string
+//
+static EFI_UNICODE_STRING_TABLE mIdeControllerDriverNameTable[] = {
+ {
+ "eng;en",
+ L"IDE Controller Init Driver"
+ },
+ {
+ NULL,
+ NULL
+ }
+};
+
+static EFI_UNICODE_STRING_TABLE mIdeControllerControllerNameTable[] = {
+ {
+ "eng;en",
+ L"ICH IDE Controller"
+ },
+ {
+ NULL,
+ NULL
+ }
+};
+
+
+EFI_STATUS
+EFIAPI
+IdeControllerGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ )
+/*++
+
+ Routine Description:
+ Retrieves a Unicode string that is the user readable name of the EFI Driver.
+
+ Arguments:
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+ Language - A pointer to a three character ISO 639-2 language identifier.
+ This is the language of the driver 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.
+ DriverName - A pointer to the Unicode string to return. This Unicode string
+ is the name of the driver specified by This in the language
+ specified by Language.
+
+ Returns:
+ EFI_SUCCESS - The Unicode string for the Driver specified by This
+ and the language specified by Language was returned
+ in DriverName.
+ EFI_INVALID_PARAMETER - Language is NULL.
+ EFI_INVALID_PARAMETER - DriverName is NULL.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+
+--*/
+{
+
+ return LookupUnicodeString2 (
+ Language,
+ This->SupportedLanguages,
+ mIdeControllerDriverNameTable,
+ DriverName,
+ (BOOLEAN)(This == &gIdeControllerName)
+ );
+}
+
+EFI_STATUS
+EFIAPI
+IdeControllerGetControllerName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ )
+/*++
+
+ Routine Description:
+ Retrieves a Unicode string that is the user readable name of the controller
+ that is being managed by an EFI Driver.
+
+ Arguments:
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+ 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.
+ 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.
+ 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.
+ 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.
+
+ Returns:
+ 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.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
+ EFI_HANDLE.
+ EFI_INVALID_PARAMETER - Language is NULL.
+ EFI_INVALID_PARAMETER - ControllerName is NULL.
+ EFI_UNSUPPORTED - The driver specified by This is not currently
+ managing the controller specified by
+ ControllerHandle and ChildHandle.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ if (ChildHandle != NULL) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Make sure this driver is currently managing ControllHandle
+ //
+ Status = EfiTestManagedDevice (
+ ControllerHandle,
+ gIdeControllerDriverBinding.DriverBindingHandle,
+ &gEfiPciIoProtocolGuid
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return LookupUnicodeString2 (
+ Language,
+ This->SupportedLanguages,
+ mIdeControllerControllerNameTable,
+ ControllerName,
+ (BOOLEAN)(This == &gIdeControllerName)
+ );
+}
diff --git a/DuetPkg/IdeControllerDxe/IdeData.h b/DuetPkg/IdeControllerDxe/IdeData.h
new file mode 100644
index 0000000000..1baf46b6d6
--- /dev/null
+++ b/DuetPkg/IdeControllerDxe/IdeData.h
@@ -0,0 +1,311 @@
+/** @file
+ Header file for IDE Bus Driver's Data Structures
+
+ Copyright (c) 2006 - 2007 Intel Corporation. <BR>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _IDE_DATA_H_
+#define _IDE_DATA_H_
+
+#include <IndustryStandard/Atapi.h>
+
+//
+// common constants
+//
+#define STALL_1_MILLI_SECOND 1000 // stall 1 ms
+#define STALL_1_SECOND 1000000 // stall 1 second
+typedef enum {
+ IdePrimary = 0,
+ IdeSecondary = 1,
+ IdeMaxChannel = 2
+} EFI_IDE_CHANNEL;
+
+typedef enum {
+ IdeMaster = 0,
+ IdeSlave = 1,
+ IdeMaxDevice = 2
+} EFI_IDE_DEVICE;
+
+typedef enum {
+ IdeMagnetic, /* ZIP Drive or LS120 Floppy Drive */
+ IdeCdRom, /* ATAPI CDROM */
+ IdeHardDisk, /* Hard Disk */
+ Ide48bitAddressingHardDisk, /* Hard Disk larger than 120GB */
+ IdeUnknown
+} IDE_DEVICE_TYPE;
+
+typedef enum {
+ SenseNoSenseKey,
+ SenseDeviceNotReadyNoRetry,
+ SenseDeviceNotReadyNeedRetry,
+ SenseNoMedia,
+ SenseMediaChange,
+ SenseMediaError,
+ SenseOtherSense
+} SENSE_RESULT;
+
+typedef enum {
+ AtaUdmaReadOp,
+ AtaUdmaReadExtOp,
+ AtaUdmaWriteOp,
+ AtaUdmaWriteExtOp
+} ATA_UDMA_OPERATION;
+
+//
+// IDE Registers
+//
+typedef union {
+ UINT16 Command; /* when write */
+ UINT16 Status; /* when read */
+} IDE_CMD_OR_STATUS;
+
+typedef union {
+ UINT16 Error; /* when read */
+ UINT16 Feature; /* when write */
+} IDE_ERROR_OR_FEATURE;
+
+typedef union {
+ UINT16 AltStatus; /* when read */
+ UINT16 DeviceControl; /* when write */
+} IDE_ALTSTATUS_OR_DEVICECONTROL;
+
+//
+// IDE registers set
+//
+typedef struct {
+ UINT16 Data;
+ IDE_ERROR_OR_FEATURE Reg1;
+ UINT16 SectorCount;
+ UINT16 SectorNumber;
+ UINT16 CylinderLsb;
+ UINT16 CylinderMsb;
+ UINT16 Head;
+ IDE_CMD_OR_STATUS Reg;
+
+ IDE_ALTSTATUS_OR_DEVICECONTROL Alt;
+ UINT16 DriveAddress;
+
+ UINT16 MasterSlave;
+ UINT16 BusMasterBaseAddr;
+} IDE_BASE_REGISTERS;
+
+//
+// IDE registers' base addresses
+//
+typedef struct {
+ UINT16 CommandBlockBaseAddr;
+ UINT16 ControlBlockBaseAddr;
+ UINT16 BusMasterBaseAddr;
+} IDE_REGISTERS_BASE_ADDR;
+
+//
+// Bit definitions in Programming Interface byte of the Class Code field
+// in PCI IDE controller's Configuration Space
+//
+#define IDE_PRIMARY_OPERATING_MODE BIT0
+#define IDE_PRIMARY_PROGRAMMABLE_INDICATOR BIT1
+#define IDE_SECONDARY_OPERATING_MODE BIT2
+#define IDE_SECONDARY_PROGRAMMABLE_INDICATOR BIT3
+
+
+//
+// Bus Master Reg
+//
+#define BMIC_NREAD BIT3
+#define BMIC_START BIT0
+#define BMIS_INTERRUPT BIT2
+#define BMIS_ERROR BIT1
+
+#define BMICP_OFFSET 0x00
+#define BMISP_OFFSET 0x02
+#define BMIDP_OFFSET 0x04
+#define BMICS_OFFSET 0x08
+#define BMISS_OFFSET 0x0A
+#define BMIDS_OFFSET 0x0C
+
+//
+// Time Out Value For IDE Device Polling
+//
+
+//
+// ATATIMEOUT is used for waiting time out for ATA device
+//
+
+//
+// 1 second
+//
+#define ATATIMEOUT 1000
+
+//
+// ATAPITIMEOUT is used for waiting operation
+// except read and write time out for ATAPI device
+//
+
+//
+// 1 second
+//
+#define ATAPITIMEOUT 1000
+
+//
+// ATAPILONGTIMEOUT is used for waiting read and
+// write operation timeout for ATAPI device
+//
+
+//
+// 2 seconds
+//
+#define CDROMLONGTIMEOUT 2000
+
+//
+// 5 seconds
+//
+#define ATAPILONGTIMEOUT 5000
+
+//
+// 10 seconds
+//
+#define ATASMARTTIMEOUT 10000
+
+
+//
+// ATAPI6 related data structure definition
+//
+
+//
+// The maximum sectors count in 28 bit addressing mode
+//
+#define MAX_28BIT_ADDRESSING_CAPACITY 0xfffffff
+
+#pragma pack(1)
+
+typedef struct {
+ UINT32 RegionBaseAddr;
+ UINT16 ByteCount;
+ UINT16 EndOfTable;
+} IDE_DMA_PRD;
+
+#pragma pack()
+
+#define SETFEATURE TRUE
+#define CLEARFEATURE FALSE
+
+///
+/// PIO mode definition
+///
+typedef enum _ATA_PIO_MODE_ {
+ AtaPioModeBelow2,
+ AtaPioMode2,
+ AtaPioMode3,
+ AtaPioMode4
+} ATA_PIO_MODE;
+
+//
+// Multi word DMA definition
+//
+typedef enum _ATA_MDMA_MODE_ {
+ AtaMdmaMode0,
+ AtaMdmaMode1,
+ AtaMdmaMode2
+} ATA_MDMA_MODE;
+
+//
+// UDMA mode definition
+//
+typedef enum _ATA_UDMA_MODE_ {
+ AtaUdmaMode0,
+ AtaUdmaMode1,
+ AtaUdmaMode2,
+ AtaUdmaMode3,
+ AtaUdmaMode4,
+ AtaUdmaMode5
+} ATA_UDMA_MODE;
+
+#define ATA_MODE_CATEGORY_DEFAULT_PIO 0x00
+#define ATA_MODE_CATEGORY_FLOW_PIO 0x01
+#define ATA_MODE_CATEGORY_MDMA 0x04
+#define ATA_MODE_CATEGORY_UDMA 0x08
+
+#pragma pack(1)
+
+typedef struct {
+ UINT8 ModeNumber : 3;
+ UINT8 ModeCategory : 5;
+} ATA_TRANSFER_MODE;
+
+typedef struct {
+ UINT8 Sector;
+ UINT8 Heads;
+ UINT8 MultipleSector;
+} ATA_DRIVE_PARMS;
+
+#pragma pack()
+//
+// IORDY Sample Point field value
+//
+#define ISP_5_CLK 0
+#define ISP_4_CLK 1
+#define ISP_3_CLK 2
+#define ISP_2_CLK 3
+
+//
+// Recovery Time field value
+//
+#define RECVY_4_CLK 0
+#define RECVY_3_CLK 1
+#define RECVY_2_CLK 2
+#define RECVY_1_CLK 3
+
+//
+// Slave IDE Timing Register Enable
+//
+#define SITRE BIT14
+
+//
+// DMA Timing Enable Only Select 1
+//
+#define DTE1 BIT7
+
+//
+// Pre-fetch and Posting Enable Select 1
+//
+#define PPE1 BIT6
+
+//
+// IORDY Sample Point Enable Select 1
+//
+#define IE1 BIT5
+
+//
+// Fast Timing Bank Drive Select 1
+//
+#define TIME1 BIT4
+
+//
+// DMA Timing Enable Only Select 0
+//
+#define DTE0 BIT3
+
+//
+// Pre-fetch and Posting Enable Select 0
+//
+#define PPE0 BIT2
+
+//
+// IOREY Sample Point Enable Select 0
+//
+#define IE0 BIT1
+
+//
+// Fast Timing Bank Drive Select 0
+//
+#define TIME0 BIT0
+
+#endif