--- /dev/null
+/** @file\r
+ This portion is to register the IDE Controller Driver name:\r
+ "IDE Controller Init Driver"\r
+\r
+ Copyright (c) 2008 Intel Corporation. <BR>\r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#include "IdeController.h"\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIdeControllerComponentName = {\r
+ IdeControllerComponentNameGetDriverName,\r
+ IdeControllerComponentNameGetControllerName,\r
+ "eng"\r
+};\r
+\r
+//\r
+// EFI Component Name 2 Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIdeControllerComponentName2 = {\r
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IdeControllerComponentNameGetDriverName,\r
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IdeControllerComponentNameGetControllerName,\r
+ "en"\r
+};\r
+\r
+//\r
+// Driver Name Strings\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIdeControllerDriverNameTable[] = {\r
+ {\r
+ "eng;en",\r
+ (CHAR16 *)L"IDE Controller Init Driver"\r
+ },\r
+ {\r
+ NULL,\r
+ NULL\r
+ }\r
+};\r
+\r
+//\r
+// Controller Name Strings\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIdeControllerControllerNameTable[] = {\r
+ {\r
+ "eng;en",\r
+ (CHAR16 *)L"PCAT IDE Controller"\r
+ },\r
+ {\r
+ NULL,\r
+ NULL\r
+ }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeControllerComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ Language - A pointer to a three character ISO 639-2 language identifier.\r
+ This is the language of the driver name that that the caller \r
+ is requesting, and it must match one of the languages specified\r
+ in SupportedLanguages. The number of languages supported by a \r
+ driver is up to the driver writer.\r
+ DriverName - A pointer to the Unicode string to return. This Unicode string\r
+ is the name of the driver specified by This in the language \r
+ specified by Language.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the Driver specified by This\r
+ and the language specified by Language was returned \r
+ in DriverName.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - DriverName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ return LookupUnicodeString2 (\r
+ Language,\r
+ This->SupportedLanguages,\r
+ mIdeControllerDriverNameTable,\r
+ DriverName,\r
+ (BOOLEAN)(This == &gIdeControllerComponentName)\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeControllerComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by an EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ ControllerHandle - The handle of a controller that the driver specified by \r
+ This is managing. This handle specifies the controller \r
+ whose name is to be returned.\r
+ ChildHandle - The handle of the child controller to retrieve the name \r
+ of. This is an optional parameter that may be NULL. It \r
+ will be NULL for device drivers. It will also be NULL \r
+ for a bus drivers that wish to retrieve the name of the \r
+ bus controller. It will not be NULL for a bus driver \r
+ that wishes to retrieve the name of a child controller.\r
+ Language - A pointer to a three character ISO 639-2 language \r
+ identifier. This is the language of the controller name \r
+ that that the caller is requesting, and it must match one\r
+ of the languages specified in SupportedLanguages. The \r
+ number of languages supported by a driver is up to the \r
+ driver writer.\r
+ ControllerName - A pointer to the Unicode string to return. This Unicode\r
+ string is the name of the controller specified by \r
+ ControllerHandle and ChildHandle in the language \r
+ specified by Language from the point of view of the \r
+ driver specified by This. \r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the user readable name in the \r
+ language specified by Language for the driver \r
+ specified by This was returned in DriverName.\r
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+ EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This is not currently \r
+ managing the controller specified by \r
+ ControllerHandle and ChildHandle.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Make sure this driver is currently managing ControllHandle\r
+ //\r
+ Status = EfiTestManagedDevice (\r
+ ControllerHandle,\r
+ gIdeControllerDriverBinding.DriverBindingHandle,\r
+ &gEfiPciIoProtocolGuid\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ if (ChildHandle != NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ return LookupUnicodeString2 (\r
+ Language,\r
+ This->SupportedLanguages,\r
+ mIdeControllerControllerNameTable,\r
+ ControllerName,\r
+ (BOOLEAN)(This == &gIdeControllerComponentName)\r
+ );\r
+}\r
--- /dev/null
+/** @file\r
+ This driver module produces IDE_CONTROLLER_INIT protocol and will be used by \r
+ IDE Bus driver to support platform dependent timing information. This driver\r
+ is responsible for early initialization of IDE controller.\r
+\r
+ Copyright (c) 2008 - 2009 Intel Corporation. <BR>\r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#include "IdeController.h"\r
+\r
+//\r
+// EFI_DRIVER_BINDING_PROTOCOL instance\r
+//\r
+EFI_DRIVER_BINDING_PROTOCOL gIdeControllerDriverBinding = {\r
+ IdeControllerSupported,\r
+ IdeControllerStart,\r
+ IdeControllerStop,\r
+ 0xa,\r
+ NULL,\r
+ NULL\r
+};\r
+\r
+//\r
+// EFI_IDE_CONTROLLER_PROVATE_DATA Template\r
+//\r
+EFI_IDE_CONTROLLER_INIT_PROTOCOL gEfiIdeControllerInit = {\r
+ IdeInitGetChannelInfo,\r
+ IdeInitNotifyPhase,\r
+ IdeInitSubmitData,\r
+ IdeInitDisqualifyMode,\r
+ IdeInitCalculateMode,\r
+ IdeInitSetTiming,\r
+ ICH_IDE_ENUMER_ALL,\r
+ ICH_IDE_MAX_CHANNEL\r
+};\r
+\r
+//\r
+// EFI_ATA_COLLECTIVE_MODE Template\r
+//\r
+EFI_ATA_COLLECTIVE_MODE gEfiAtaCollectiveModeTemplate = {\r
+ { \r
+ TRUE, // PioMode.Valid\r
+ 0 // PioMode.Mode\r
+ },\r
+ {\r
+ TRUE, // SingleWordDmaMode.Valid\r
+ 0\r
+ },\r
+ {\r
+ FALSE, // MultiWordDmaMode.Valid\r
+ 0\r
+ },\r
+ {\r
+ TRUE, // UdmaMode.Valid\r
+ 0 // UdmaMode.Mode\r
+ }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeIdeControllerDriver (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+/*++\r
+ Routine Description:\r
+ \r
+ Chipset Ide Driver EntryPoint function. It follows the standard EFI driver \r
+ model. It's called by StartImage() of DXE Core\r
+ \r
+ Argments:\r
+ \r
+ ImageHnadle -- While the driver image loaded be the ImageLoader(), \r
+ an image handle is assigned to this driver binary, \r
+ all activities of the driver is tied to this ImageHandle\r
+ *SystemTable -- A pointer to the system table, for all BS(Boo Services) and\r
+ RT(Runtime Services)\r
+\r
+ Retruns:\r
+ \r
+ Always call EfiLibInstallDriverBindingProtocol( ) and retrun the result\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Install driver model protocol(s).\r
+ //\r
+ Status = EfiLibInstallDriverBindingComponentName2 (\r
+ ImageHandle,\r
+ SystemTable,\r
+ &gIdeControllerDriverBinding,\r
+ ImageHandle,\r
+ &gIdeControllerComponentName,\r
+ &gIdeControllerComponentName2\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeControllerSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ \r
+ Register Driver Binding protocol for this driver.\r
+ \r
+ Arguments:\r
+ \r
+ This -- a pointer points to the Binding Protocol instance\r
+ Controller -- The handle of controller to be tested. \r
+ *RemainingDevicePath -- A pointer to the device path. Ignored by device\r
+ driver but used by bus driver\r
+\r
+ Returns:\r
+\r
+ EFI_SUCCESS -- Driver loaded.\r
+ other -- Driver not loaded.\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+ UINT8 PciClass;\r
+ UINT8 PciSubClass;\r
+\r
+ //\r
+ // Attempt to Open PCI I/O Protocol\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ (VOID **) &PciIo,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Now further check the PCI header: Base class (offset 0x0B) and\r
+ // Sub Class (offset 0x0A). This controller should be an Ide controller\r
+ //\r
+ Status = PciIo->Pci.Read (\r
+ PciIo,\r
+ EfiPciIoWidthUint8,\r
+ PCI_CLASSCODE_OFFSET + 2,\r
+ 1,\r
+ &PciClass\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+\r
+ Status = PciIo->Pci.Read (\r
+ PciIo,\r
+ EfiPciIoWidthUint8,\r
+ PCI_CLASSCODE_OFFSET + 1,\r
+ 1,\r
+ &PciSubClass\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+\r
+ //\r
+ // Examine Ide PCI Configuration table fields\r
+ //\r
+ if ((PciClass != PCI_CLASS_MASS_STORAGE) || (PciSubClass != PCI_CLASS_MASS_STORAGE_IDE)) {\r
+ Status = EFI_UNSUPPORTED;\r
+ }\r
+\r
+Done:\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeControllerStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ \r
+ This routine is called right after the .Supported() called and return \r
+ EFI_SUCCESS. Notes: The supported protocols are checked but the Protocols\r
+ are closed.\r
+\r
+ Arguments:\r
+ \r
+ This -- a pointer points to the Binding Protocol instance\r
+ Controller -- The handle of controller to be tested. Parameter\r
+ passed by the caller\r
+ *RemainingDevicePath -- A pointer to the device path. Should be ignored by\r
+ device driver\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+\r
+ //\r
+ // Now test and open the EfiPciIoProtocol\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ (VOID **) &PciIo,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ //\r
+ // Status == EFI_SUCCESS - A normal execution flow, SUCCESS and the program proceeds.\r
+ // Status == ALREADY_STARTED - A non-zero Status code returned. It indicates\r
+ // that the protocol has been opened and should be treated as a\r
+ // normal condition and the program proceeds. The Protocol will not\r
+ // opened 'again' by this call.\r
+ // Status != ALREADY_STARTED - Error status, terminate program execution\r
+ //\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Install IDE_CONTROLLER_INIT protocol \r
+ //\r
+ return gBS->InstallMultipleProtocolInterfaces (\r
+ &Controller,\r
+ &gEfiIdeControllerInitProtocolGuid, &gEfiIdeControllerInit,\r
+ NULL\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeControllerStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ Stop this driver on Controller Handle. \r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ Controller - Handle of device to stop driver on \r
+ NumberOfChildren - Not used\r
+ ChildHandleBuffer - Not used\r
+\r
+ Returns:\r
+ EFI_SUCCESS - This driver is removed DeviceHandle\r
+ other - This driver was not removed from this device\r
+ \r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeControllerInit;\r
+\r
+ //\r
+ // Open the produced protocol\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiIdeControllerInitProtocolGuid,\r
+ (VOID **) &IdeControllerInit,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Make sure the protocol was produced by this driver\r
+ //\r
+ if (IdeControllerInit != &gEfiIdeControllerInit) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Uninstall the IDE Controller Init Protocol\r
+ //\r
+ Status = gBS->UninstallMultipleProtocolInterfaces (\r
+ Controller,\r
+ &gEfiIdeControllerInitProtocolGuid, &gEfiIdeControllerInit,\r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Close protocols opened by Ide controller driver\r
+ //\r
+ return gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+}\r
+\r
+//\r
+// Interface functions of IDE_CONTROLLER_INIT protocol\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+IdeInitGetChannelInfo (\r
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+ IN UINT8 Channel,\r
+ OUT BOOLEAN *Enabled,\r
+ OUT UINT8 *MaxDevices\r
+ )\r
+/*++\r
+Routine Description:\r
+\r
+ This function can be used to obtain information about a specified channel. \r
+ It's usually used by IDE Bus driver during enumeration process.\r
+\r
+Arguments:\r
+\r
+ This -- the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
+ Channel -- Channel number (0 based, either 0 or 1)\r
+ Enabled -- TRUE if the channel is enabled. If the channel is disabled, \r
+ then it will no be enumerated.\r
+ MaxDevices -- The Max number of IDE devices that the bus driver can expect\r
+ on this channel. For ATA/ATAPI, this number is either 1 or 2.\r
+\r
+Returns:\r
+ EFI_STATUS \r
+\r
+--*/\r
+{\r
+ //\r
+ // Channel number (0 based, either 0 or 1)\r
+ //\r
+ if (Channel < ICH_IDE_MAX_CHANNEL) {\r
+ *Enabled = TRUE;\r
+ *MaxDevices = ICH_IDE_MAX_DEVICES;\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ *Enabled = FALSE;\r
+ return EFI_INVALID_PARAMETER;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeInitNotifyPhase (\r
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+ IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase,\r
+ IN UINT8 Channel\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This function is called by IdeBus driver before executing certain actions. \r
+ This allows IDE Controller Init to prepare for each action.\r
+\r
+Arguments:\r
+\r
+ This -- the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
+ Phase -- phase indicator defined by IDE_CONTROLLER_INIT protocol\r
+ Channel -- Channel number (0 based, either 0 or 1)\r
+\r
+Returns:\r
+ \r
+--*/\r
+{\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeInitSubmitData (\r
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+ IN UINT8 Channel,\r
+ IN UINT8 Device,\r
+ IN EFI_IDENTIFY_DATA *IdentifyData\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This function is called by IdeBus driver to submit EFI_IDENTIFY_DATA data structure\r
+ obtained from IDE deivce. This structure is used to set IDE timing\r
+\r
+Arguments:\r
+\r
+ This -- the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
+ Channel -- IDE channel number (0 based, either 0 or 1)\r
+ Device -- IDE device number\r
+ IdentifyData -- A pointer to EFI_IDENTIFY_DATA data structure\r
+\r
+Returns:\r
+ \r
+--*/\r
+{\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeInitDisqualifyMode (\r
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+ IN UINT8 Channel,\r
+ IN UINT8 Device,\r
+ IN EFI_ATA_COLLECTIVE_MODE *BadModes\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This function is called by IdeBus driver to disqualify unsupported operation\r
+ mode on specfic IDE device\r
+\r
+Arguments:\r
+\r
+ This -- the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
+ Channel -- IDE channel number (0 based, either 0 or 1)\r
+ Device -- IDE device number\r
+ BadModes -- Operation mode indicator\r
+\r
+Returns:\r
+ \r
+--*/\r
+{\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeInitCalculateMode (\r
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+ IN UINT8 Channel,\r
+ IN UINT8 Device,\r
+ OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This function is called by IdeBus driver to calculate the best operation mode\r
+ supported by specific IDE device\r
+\r
+Arguments:\r
+\r
+ This -- the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
+ Channel -- IDE channel number (0 based, either 0 or 1)\r
+ Device -- IDE device number\r
+ SupportedModes -- Modes collection supported by IDE device\r
+\r
+Returns:\r
+ \r
+--*/\r
+{\r
+ if (Channel >= ICH_IDE_MAX_CHANNEL || Device >= ICH_IDE_MAX_DEVICES) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ *SupportedModes = AllocateCopyPool (sizeof (EFI_ATA_COLLECTIVE_MODE), &gEfiAtaCollectiveModeTemplate);\r
+ if (*SupportedModes == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeInitSetTiming (\r
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+ IN UINT8 Channel,\r
+ IN UINT8 Device,\r
+ IN EFI_ATA_COLLECTIVE_MODE *Modes\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This function is called by IdeBus driver to set appropriate timing on IDE\r
+ controller according supported operation mode\r
+\r
+Arguments:\r
+\r
+ This -- the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
+ Channel -- IDE channel number (0 based, either 0 or 1)\r
+ Device -- IDE device number\r
+\r
+Returns:\r
+ \r
+--*/\r
+{\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+/** @file\r
+ Header file for IDE controller driver.\r
+\r
+ Copyright (c) 2008 Intel Corporation. <BR>\r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#ifndef _IDE_CONTROLLER_H\r
+#define _IDE_CONTROLLER_H\r
+\r
+#include <Uefi.h>\r
+#include <Protocol/ComponentName.h>\r
+#include <Protocol/DriverBinding.h>\r
+#include <Protocol/PciIo.h>\r
+#include <Protocol/IdeControllerInit.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <IndustryStandard/Pci.h>\r
+\r
+//\r
+// Global Variables definitions\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gIdeControllerDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gIdeControllerComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL gIdeControllerComponentName2;\r
+\r
+//\r
+// Supports 2 channel max\r
+//\r
+#define ICH_IDE_MAX_CHANNEL 0x02\r
+//\r
+// Supports 2 devices max\r
+//\r
+#define ICH_IDE_MAX_DEVICES 0x02\r
+#define ICH_IDE_ENUMER_ALL FALSE\r
+\r
+//\r
+// Driver binding functions declaration\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+IdeControllerSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ \r
+ Register Driver Binding protocol for this driver.\r
+ \r
+ Arguments:\r
+ \r
+ This -- a pointer points to the Binding Protocol instance\r
+ Controller -- The handle of controller to be tested. \r
+ *RemainingDevicePath -- A pointer to the device path. Ignored by device\r
+ driver but used by bus driver\r
+\r
+ Returns:\r
+\r
+ EFI_SUCCESS -- Driver loaded.\r
+ other -- Driver not loaded.\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeControllerStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ \r
+ This routine is called right after the .Supported() called and return \r
+ EFI_SUCCESS. Notes: The supported protocols are checked but the Protocols\r
+ are closed.\r
+\r
+ Arguments:\r
+ \r
+ This -- a pointer points to the Binding Protocol instance\r
+ Controller -- The handle of controller to be tested. Parameter\r
+ passed by the caller\r
+ *RemainingDevicePath -- A pointer to the device path. Should be ignored by\r
+ device driver\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeControllerStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+/*++\r
+ \r
+ Routine Description:\r
+ Stop this driver on Controller Handle. \r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ Controller - Handle of device to stop driver on \r
+ NumberOfChildren - Not used\r
+ ChildHandleBuffer - Not used\r
+\r
+ Returns:\r
+ EFI_SUCCESS - This driver is removed DeviceHandle\r
+ other - This driver was not removed from this device\r
+ \r
+--*/\r
+;\r
+\r
+//\r
+// IDE controller init functions declaration\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+IdeInitGetChannelInfo (\r
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+ IN UINT8 Channel,\r
+ OUT BOOLEAN *Enabled,\r
+ OUT UINT8 *MaxDevices\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ This - TODO: add argument description\r
+ Channel - TODO: add argument description\r
+ Enabled - TODO: add argument description\r
+ MaxDevices - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeInitNotifyPhase (\r
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+ IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase,\r
+ OUT UINT8 Channel\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ This - TODO: add argument description\r
+ Phase - TODO: add argument description\r
+ Channel - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeInitSubmitData (\r
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+ IN UINT8 Channel,\r
+ IN UINT8 Device,\r
+ IN EFI_IDENTIFY_DATA *IdentifyData\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ This - TODO: add argument description\r
+ Channel - TODO: add argument description\r
+ Device - TODO: add argument description\r
+ IdentifyData - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeInitSubmitFailingModes (\r
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+ IN UINT8 Channel,\r
+ IN UINT8 Device\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ This - TODO: add argument description\r
+ Channel - TODO: add argument description\r
+ Device - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeInitDisqualifyMode (\r
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+ IN UINT8 Channel,\r
+ IN UINT8 Device,\r
+ IN EFI_ATA_COLLECTIVE_MODE *BadModes\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ This - TODO: add argument description\r
+ Channel - TODO: add argument description\r
+ Device - TODO: add argument description\r
+ BadModes - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeInitCalculateMode (\r
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+ IN UINT8 Channel,\r
+ IN UINT8 Device,\r
+ IN EFI_ATA_COLLECTIVE_MODE **SupportedModes\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ This - TODO: add argument description\r
+ Channel - TODO: add argument description\r
+ Device - TODO: add argument description\r
+ SupportedModes - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeInitSetTiming (\r
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+ IN UINT8 Channel,\r
+ IN UINT8 Device,\r
+ IN EFI_ATA_COLLECTIVE_MODE *Modes\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ This - TODO: add argument description\r
+ Channel - TODO: add argument description\r
+ Device - TODO: add argument description\r
+ Modes - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Forward reference declaration\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+IdeControllerComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ Language - A pointer to a three character ISO 639-2 language identifier.\r
+ This is the language of the driver name that that the caller \r
+ is requesting, and it must match one of the languages specified\r
+ in SupportedLanguages. The number of languages supported by a \r
+ driver is up to the driver writer.\r
+ DriverName - A pointer to the Unicode string to return. This Unicode string\r
+ is the name of the driver specified by This in the language \r
+ specified by Language.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the Driver specified by This\r
+ and the language specified by Language was returned \r
+ in DriverName.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - DriverName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IdeControllerComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by an EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ ControllerHandle - The handle of a controller that the driver specified by \r
+ This is managing. This handle specifies the controller \r
+ whose name is to be returned.\r
+ ChildHandle - The handle of the child controller to retrieve the name \r
+ of. This is an optional parameter that may be NULL. It \r
+ will be NULL for device drivers. It will also be NULL \r
+ for a bus drivers that wish to retrieve the name of the \r
+ bus controller. It will not be NULL for a bus driver \r
+ that wishes to retrieve the name of a child controller.\r
+ Language - A pointer to a three character ISO 639-2 language \r
+ identifier. This is the language of the controller name \r
+ that that the caller is requesting, and it must match one\r
+ of the languages specified in SupportedLanguages. The \r
+ number of languages supported by a driver is up to the \r
+ driver writer.\r
+ ControllerName - A pointer to the Unicode string to return. This Unicode\r
+ string is the name of the controller specified by \r
+ ControllerHandle and ChildHandle in the language \r
+ specified by Language from the point of view of the \r
+ driver specified by This. \r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the user readable name in the \r
+ language specified by Language for the driver \r
+ specified by This was returned in DriverName.\r
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+ EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This is not currently \r
+ managing the controller specified by \r
+ ControllerHandle and ChildHandle.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
--- /dev/null
+#/** @file\r
+# \r
+# Component description file for the IDE Controller Init module.\r
+#\r
+# Copyright (c) 2008, Intel Corporation. <BR>\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# \r
+#**/\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = IdeController\r
+ FILE_GUID = F3790689-FB90-4479-A2EF-B82A43AFE74D\r
+ MODULE_TYPE = UEFI_DRIVER\r
+ VERSION_STRING = 1.0\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+ ENTRY_POINT = InitializeIdeControllerDriver\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+ ComponentName.c\r
+ IdeController.c\r
+ IdeController.h\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+\r
+[LibraryClasses]\r
+ UefiDriverEntryPoint\r
+ DebugLib\r
+ UefiLib\r
+ BaseLib\r
+ BaseMemoryLib\r
+ MemoryAllocationLib\r
+ UefiBootServicesTableLib\r
+\r
+[Protocols]\r
+ gEfiPciIoProtocolGuid \r
+ gEfiIdeControllerInitProtocolGuid\r