-/*++\r
+/** @file\r
+ Copyright (c) 2006, Intel Corporation \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
-Copyright (c) 2006, Intel Corporation \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
+ 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
-Module Name:\r
-\r
- idebus.c\r
- \r
-Abstract: \r
- \r
-\r
-Revision History\r
+ @par Revision Reference:\r
This module is modified from DXE\IDE module for Ide Contriller Init support\r
\r
---*/\r
+**/\r
\r
#include "idebus.h"\r
\r
// IDEBusDriverBindingSupported\r
// ***********************************************************************************\r
//\r
+/**\r
+ Register Driver Binding protocol for this driver.\r
+\r
+ @param[in] This -- A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param[in] ControllerHandle -- The handle of the controller to test.\r
+ @param[in] RemainingDevicePath -- A pointer to the remaining portion of a device path.\r
+\r
+ @retval EFI_SUCCESS Driver loaded.\r
+ @retval other Driver not loaded.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
IDEBusDriverBindingSupported (\r
IN EFI_HANDLE Controller,\r
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
)\r
-/*++\r
- \r
-Routine Description:\r
- Register Driver Binding protocol for this driver.\r
- \r
-Arguments:\r
- This -- A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
- ControllerHandle -- The handle of the controller to test.\r
- RemainingDevicePath -- A pointer to the remaining portion of a device path.\r
-\r
-Returns: \r
- EFI_SUCCESS - Driver loaded.\r
- other - Driver not loaded.\r
---*/\r
// TODO: Controller - add argument and description to function comment\r
// TODO: EFI_UNSUPPORTED - add return value to function comment\r
{\r
// IDEBusDriverBindingStart\r
// ***********************************************************************************\r
//\r
+/**\r
+ Start this driver on Controller by detecting all disks and installing \r
+ BlockIo protocol on them.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param Controller Handle of device to bind driver to.\r
+ @param RemainingDevicePath Not used, always produce all possible children.\r
+\r
+ @retval EFI_SUCCESS This driver is added to ControllerHandle.\r
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.\r
+ @retval other This driver does not support this device.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
IDEBusDriverBindingStart (\r
IN EFI_HANDLE Controller,\r
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Start this driver on Controller by detecting all disks and installing \r
- BlockIo protocol on them.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- Controller - Handle of device to bind driver to.\r
- RemainingDevicePath - Not used, always produce all possible children.\r
-\r
- Returns:\r
- EFI_SUCCESS - This driver is added to ControllerHandle.\r
- EFI_ALREADY_STARTED - This driver is already running on ControllerHandle.\r
- other - This driver does not support this device.\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
EFI_STATUS SavedStatus;\r
EfiIdeBusBeforeDevicePresenceDetection,\r
IdeChannel\r
);\r
+\r
+ //\r
+ // Prepare to detect IDE device of this channel\r
+ //\r
+ InitializeIDEChannelData ();\r
+\r
//\r
// -- 1st inner loop --- Master/Slave ------------ Step14\r
//\r
IdeBlkIoDevicePtr->IdeBusDriverPrivateData = IdeBusDriverPrivateData;\r
IdeBlkIoDevicePtr->IoPort->BusMasterBaseAddr = IdeRegsBaseAddr[IdeChannel].BusMasterBaseAddr;\r
\r
+ //\r
+ // Report Status code: is about to detect IDE drive\r
+ //\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ (EFI_IO_BUS_ATA_ATAPI | EFI_P_PC_PRESENCE_DETECT),\r
+ IdeBlkIoDevicePtr->DevicePath\r
+ );\r
+\r
//\r
// Discover device, now!\r
//\r
// Submit identify data to IDE controller init driver\r
//\r
CopyMem (&IdentifyData, IdeBlkIoDevicePtr->pIdData, sizeof (IdentifyData));\r
- // IdentifyData = *IdeBlkIoDevicePtr->pIdData;\r
IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = TRUE;\r
IdeInit->SubmitData (IdeInit, IdeChannel, IdeDevice, &IdentifyData);\r
} else {\r
(EFI_IO_BUS_ATA_ATAPI | EFI_P_PC_ENABLE),\r
IdeBlkIoDevicePtr->DevicePath\r
);\r
+ \r
+ //\r
+ // Create event to clear pending IDE interrupt\r
+ //\r
+ Status = gBS->CreateEvent (\r
+ EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,\r
+ EFI_TPL_NOTIFY,\r
+ ClearInterrupt,\r
+ IdeBlkIoDevicePtr,\r
+ &IdeBlkIoDevicePtr->ExitBootServiceEvent\r
+ );\r
+\r
//\r
// end of 2nd inner loop ----\r
//\r
// IDEBusDriverBindingStop\r
// ***********************************************************************************\r
//\r
+/**\r
+ Stop this driver on Controller Handle. \r
+\r
+ @param This Protocol instance pointer.\r
+ @param DeviceHandle Handle of device to stop driver on\r
+ @param NumberOfChildren Not used\r
+ @param ChildHandleBuffer Not used\r
+\r
+ @retval EFI_SUCCESS This driver is removed DeviceHandle\r
+ @retval other This driver was not removed from this device\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
IDEBusDriverBindingStop (\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
- DeviceHandle - 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
// TODO: Controller - add argument and description to function comment\r
// TODO: EFI_DEVICE_ERROR - add return value to function comment\r
{\r
// DeRegisterIdeDevice\r
// ***********************************************************************************\r
//\r
+/**\r
+ Deregister an IDE device and free resources\r
+\r
+ @param This Protocol instance pointer.\r
+ @param Controller Ide device handle\r
+ @param Handle Handle of device to deregister driver on\r
+\r
+ @return EFI_STATUS\r
+\r
+**/\r
EFI_STATUS\r
DeRegisterIdeDevice (\r
IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
IN EFI_HANDLE Controller,\r
IN EFI_HANDLE Handle\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Deregister an IDE device and free resources\r
- \r
-Arguments:\r
-\r
- This - Protocol instance pointer.\r
- Controller - Ide device handle\r
- Handle - Handle of device to deregister driver on \r
- \r
-Returns:\r
-\r
- EFI_STATUS\r
-\r
---*/\r
// TODO: EFI_SUCCESS - add return value to function comment\r
{\r
EFI_STATUS Status;\r
// IDEBlkIoReset\r
// ***********************************************************************************\r
//\r
+/**\r
+ TODO: This - add argument and description to function comment\r
+ TODO: ExtendedVerification - add argument and description to function comment\r
+ TODO: EFI_DEVICE_ERROR - add return value to function comment\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
IDEBlkIoReset (\r
IN EFI_BLOCK_IO_PROTOCOL *This,\r
IN BOOLEAN ExtendedVerification\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-// TODO: This - add argument and description to function comment\r
-// TODO: ExtendedVerification - add argument and description to function comment\r
-// TODO: EFI_DEVICE_ERROR - add return value to function comment\r
{\r
IDE_BLK_IO_DEV *IdeBlkIoDevice;\r
EFI_STATUS Status;\r
//\r
// for ATA device, using ATA reset method\r
//\r
- if (IdeBlkIoDevice->Type == IdeHardDisk) {\r
+ if (IdeBlkIoDevice->Type == IdeHardDisk ||\r
+ IdeBlkIoDevice->Type == Ide48bitAddressingHardDisk) {\r
return AtaSoftReset (IdeBlkIoDevice);\r
}\r
\r
return Status;\r
}\r
\r
+/**\r
+ Read data from block io device\r
+\r
+ @param This Protocol instance pointer.\r
+ @param MediaId The media ID of the device\r
+ @param LBA Starting LBA address to read data\r
+ @param BufferSize The size of data to be read\r
+ @param Buffer Caller supplied buffer to save data\r
+\r
+ @return read data status\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
IDEBlkIoReadBlocks (\r
IN UINTN BufferSize,\r
OUT VOID *Buffer\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Read data from block io device\r
- \r
-Arguments:\r
-\r
- This - Protocol instance pointer.\r
- MediaId - The media ID of the device\r
- LBA - Starting LBA address to read data\r
- BufferSize - The size of data to be read\r
- Buffer - Caller supplied buffer to save data\r
- \r
-Returns:\r
-\r
- read data status\r
-\r
---*/\r
// TODO: EFI_DEVICE_ERROR - add return value to function comment\r
{\r
IDE_BLK_IO_DEV *IdeBlkIoDevice;\r
\r
}\r
\r
+/**\r
+ Write data to block io device\r
+\r
+ @param This Protocol instance pointer.\r
+ @param MediaId The media ID of the device\r
+ @param LBA Starting LBA address to write data\r
+ @param BufferSize The size of data to be written\r
+ @param Buffer Caller supplied buffer to save data\r
+\r
+ @return write data status\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
IDEBlkIoWriteBlocks (\r
IN UINTN BufferSize,\r
IN VOID *Buffer\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Write data to block io device\r
- \r
-Arguments:\r
-\r
- This - Protocol instance pointer.\r
- MediaId - The media ID of the device\r
- LBA - Starting LBA address to write data\r
- BufferSize - The size of data to be written\r
- Buffer - Caller supplied buffer to save data\r
- \r
-Returns:\r
-\r
- write data status\r
-\r
---*/\r
// TODO: EFI_DEVICE_ERROR - add return value to function comment\r
{\r
IDE_BLK_IO_DEV *IdeBlkIoDevice;\r
// IDEBlkIoFlushBlocks\r
// ***********************************************************************************\r
//\r
+/**\r
+ TODO: This - add argument and description to function comment\r
+ TODO: EFI_SUCCESS - add return value to function comment\r
+**/\r
EFI_STATUS\r
EFIAPI\r
IDEBlkIoFlushBlocks (\r
IN EFI_BLOCK_IO_PROTOCOL *This\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-// TODO: This - add argument and description to function comment\r
-// TODO: EFI_SUCCESS - add return value to function comment\r
{\r
//\r
// return directly\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Return the results of the Inquiry command to a drive in InquiryData.\r
+ Data format of Inquiry data is defined by the Interface GUID.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param InquiryData Results of Inquiry command to device\r
+ @param InquiryDataSize Size of InquiryData in bytes.\r
+\r
+ @retval EFI_SUCCESS InquiryData valid\r
+ @retval EFI_NOT_FOUND Device does not support this data class\r
+ @retval EFI_DEVICE_ERROR Error reading InquiryData from device\r
+ @retval EFI_BUFFER_TOO_SMALL IntquiryDataSize not big enough\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
IDEDiskInfoInquiry (\r
IN OUT VOID *InquiryData,\r
IN OUT UINT32 *InquiryDataSize\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Return the results of the Inquiry command to a drive in InquiryData.\r
- Data format of Inquiry data is defined by the Interface GUID.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- InquiryData - Results of Inquiry command to device\r
- InquiryDataSize - Size of InquiryData in bytes.\r
-\r
- Returns:\r
- EFI_SUCCESS - InquiryData valid\r
- EFI_NOT_FOUND - Device does not support this data class\r
- EFI_DEVICE_ERROR - Error reading InquiryData from device \r
- EFI_BUFFER_TOO_SMALL - IntquiryDataSize not big enough\r
-\r
---*/\r
{\r
IDE_BLK_IO_DEV *IdeBlkIoDevice;\r
\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Return the results of the Identify command to a drive in IdentifyData.\r
+ Data format of Identify data is defined by the Interface GUID.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param IdentifyData Results of Identify command to device\r
+ @param IdentifyDataSize Size of IdentifyData in bytes.\r
+\r
+ @retval EFI_SUCCESS IdentifyData valid\r
+ @retval EFI_NOT_FOUND Device does not support this data class\r
+ @retval EFI_DEVICE_ERROR Error reading IdentifyData from device\r
+ @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
IDEDiskInfoIdentify (\r
IN OUT VOID *IdentifyData,\r
IN OUT UINT32 *IdentifyDataSize\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Return the results of the Identify command to a drive in IdentifyData.\r
- Data format of Identify data is defined by the Interface GUID.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- IdentifyData - Results of Identify command to device\r
- IdentifyDataSize - Size of IdentifyData in bytes.\r
-\r
- Returns:\r
- EFI_SUCCESS - IdentifyData valid\r
- EFI_NOT_FOUND - Device does not support this data class\r
- EFI_DEVICE_ERROR - Error reading IdentifyData from device \r
- EFI_BUFFER_TOO_SMALL - IdentifyDataSize not big enough\r
-\r
---*/\r
{\r
IDE_BLK_IO_DEV *IdeBlkIoDevice;\r
\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Return the results of the Request Sense command to a drive in SenseData.\r
+ Data format of Sense data is defined by the Interface GUID.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param SenseData Results of Request Sense command to device\r
+ @param SenseDataSize Size of SenseData in bytes.\r
+ @param SenseDataNumber Type of SenseData\r
+\r
+ @retval EFI_SUCCESS InquiryData valid\r
+ @retval EFI_NOT_FOUND Device does not support this data class\r
+ @retval EFI_DEVICE_ERROR Error reading InquiryData from device\r
+ @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
IDEDiskInfoSenseData (\r
IN OUT UINT32 *SenseDataSize,\r
OUT UINT8 *SenseDataNumber\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Return the results of the Request Sense command to a drive in SenseData.\r
- Data format of Sense data is defined by the Interface GUID.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- SenseData - Results of Request Sense command to device\r
- SenseDataSize - Size of SenseData in bytes.\r
- SenseDataNumber - Type of SenseData\r
-\r
- Returns:\r
- EFI_SUCCESS - InquiryData valid\r
- EFI_NOT_FOUND - Device does not support this data class\r
- EFI_DEVICE_ERROR - Error reading InquiryData from device \r
- EFI_BUFFER_TOO_SMALL - SenseDataSize not big enough\r
-\r
---*/\r
{\r
return EFI_NOT_FOUND;\r
}\r
\r
+/**\r
+ Return the results of the Request Sense command to a drive in SenseData.\r
+ Data format of Sense data is defined by the Interface GUID.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param IdeChannel Primary or Secondary\r
+ @param IdeDevice Master or Slave\r
+\r
+ @retval EFI_SUCCESS IdeChannel and IdeDevice are valid\r
+ @retval EFI_UNSUPPORTED This is not an IDE device\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
IDEDiskInfoWhichIde (\r
OUT UINT32 *IdeChannel,\r
OUT UINT32 *IdeDevice\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Return the results of the Request Sense command to a drive in SenseData.\r
- Data format of Sense data is defined by the Interface GUID.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- IdeChannel - Primary or Secondary\r
- IdeDevice - Master or Slave\r
-\r
- Returns:\r
- EFI_SUCCESS - IdeChannel and IdeDevice are valid\r
- EFI_UNSUPPORTED - This is not an IDE device\r
-\r
---*/\r
{\r
IDE_BLK_IO_DEV *IdeBlkIoDevice;\r
\r