X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkModulePkg%2FBus%2FPci%2FIdeBus%2FDxe%2Fidebus.c;h=73b302cd4273639f80905b874a317a9b0f38740e;hp=2b8f52aa54a7eacc423962a34a1168ed72501350;hb=635a3f5c797729687bb5bfdf6d03b5f7cfbfd168;hpb=878ddf1fc3540a715f63594ed22b6929e881afb4 diff --git a/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebus.c b/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebus.c index 2b8f52aa54..73b302cd42 100644 --- a/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebus.c +++ b/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebus.c @@ -1,25 +1,17 @@ -/*++ +/** @file + 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 -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. + 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: - - idebus.c - -Abstract: - - -Revision History + @par Revision Reference: This module is modified from DXE\IDE module for Ide Contriller Init support ---*/ +**/ #include "idebus.h" @@ -34,7 +26,7 @@ EFI_DRIVER_BINDING_PROTOCOL gIDEBusDriverBinding = { IDEBusDriverBindingSupported, IDEBusDriverBindingStart, IDEBusDriverBindingStop, - 0x10, + 0xa, NULL, NULL }; @@ -44,6 +36,17 @@ EFI_DRIVER_BINDING_PROTOCOL gIDEBusDriverBinding = { // IDEBusDriverBindingSupported // *********************************************************************************** // +/** + Register Driver Binding protocol for this driver. + + @param[in] This -- A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle -- The handle of the controller to test. + @param[in] RemainingDevicePath -- A pointer to the remaining portion of a device path. + + @retval EFI_SUCCESS Driver loaded. + @retval other Driver not loaded. + +**/ EFI_STATUS EFIAPI IDEBusDriverBindingSupported ( @@ -51,20 +54,6 @@ IDEBusDriverBindingSupported ( IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) -/*++ - -Routine Description: - Register Driver Binding protocol for this driver. - -Arguments: - This -- A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. - ControllerHandle -- The handle of the controller to test. - RemainingDevicePath -- A pointer to the remaining portion of a device path. - -Returns: - EFI_SUCCESS - Driver loaded. - other - Driver not loaded. ---*/ // TODO: Controller - add argument and description to function comment // TODO: EFI_UNSUPPORTED - add return value to function comment { @@ -102,7 +91,7 @@ Returns: } // - // Clsoe protocol, don't use device path protocol in the .Support() function + // Close protocol, don't use device path protocol in the .Support() function // gBS->CloseProtocol ( Controller, @@ -150,6 +139,19 @@ Returns: // IDEBusDriverBindingStart // *********************************************************************************** // +/** + Start this driver on Controller by detecting all disks and installing + BlockIo protocol on them. + + @param This Protocol instance pointer. + @param Controller Handle of device to bind driver to. + @param RemainingDevicePath Not used, always produce all possible children. + + @retval EFI_SUCCESS This driver is added to ControllerHandle. + @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle. + @retval other This driver does not support this device. + +**/ EFI_STATUS EFIAPI IDEBusDriverBindingStart ( @@ -157,23 +159,6 @@ IDEBusDriverBindingStart ( IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) -/*++ - - Routine Description: - Start this driver on Controller by detecting all disks and installing - BlockIo protocol on them. - - Arguments: - This - Protocol instance pointer. - Controller - Handle of device to bind driver to. - RemainingDevicePath - Not used, always produce all possible children. - - Returns: - EFI_SUCCESS - This driver is added to ControllerHandle. - EFI_ALREADY_STARTED - This driver is already running on ControllerHandle. - other - This driver does not support this device. - ---*/ { EFI_STATUS Status; EFI_STATUS SavedStatus; @@ -196,7 +181,6 @@ IDEBusDriverBindingStart ( UINT16 CommandBlockBaseAddr; UINT16 ControlBlockBaseAddr; UINTN DataSize; - UINT32 Attributes; IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData; // @@ -205,7 +189,6 @@ IDEBusDriverBindingStart ( EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeInit; BOOLEAN EnumAll; BOOLEAN ChannelEnabled; - UINT8 ChannelCount; UINT8 MaxDevices; EFI_IDENTIFY_DATA IdentifyData; EFI_ATA_COLLECTIVE_MODE *SupportedModes; @@ -255,10 +238,9 @@ IDEBusDriverBindingStart ( } // - // Save Enumall and ChannelCount. Step7.2 + // Save Enumall. Step7.2 // EnumAll = IdeInit->EnumAll; - ChannelCount = IdeInit->ChannelCount; // // Consume PCI I/O protocol. Note that the OpenProtocol with _GET_PROTOCOL @@ -331,7 +313,7 @@ IDEBusDriverBindingStart ( Status = gRT->GetVariable ( (CHAR16 *) L"Configuration", &gEfiCallerIdGuid, - &Attributes, + NULL, &DataSize, &ConfigurationOptions ); @@ -431,6 +413,12 @@ IDEBusDriverBindingStart ( EfiIdeBusBeforeDevicePresenceDetection, IdeChannel ); + + // + // Prepare to detect IDE device of this channel + // + InitializeIDEChannelData (); + // // -- 1st inner loop --- Master/Slave ------------ Step14 // @@ -463,8 +451,8 @@ IDEBusDriverBindingStart ( ZeroMem (IdeBlkIoDevicePtr, sizeof (IDE_BLK_IO_DEV)); IdeBlkIoDevicePtr->Signature = IDE_BLK_IO_DEV_SIGNATURE; - IdeBlkIoDevicePtr->Channel = IdeChannel; - IdeBlkIoDevicePtr->Device = IdeDevice; + IdeBlkIoDevicePtr->Channel = (EFI_IDE_CHANNEL) IdeChannel; + IdeBlkIoDevicePtr->Device = (EFI_IDE_DEVICE) IdeDevice; // // initialize Block IO interface's Media pointer @@ -505,11 +493,15 @@ IDEBusDriverBindingStart ( // // Report Status code: is about to detect IDE drive // - REPORT_STATUS_CODE_WITH_DEVICE_PATH ( + REPORT_STATUS_CODE_EX ( EFI_PROGRESS_CODE, (EFI_IO_BUS_ATA_ATAPI | EFI_P_PC_PRESENCE_DETECT), - IdeBlkIoDevicePtr->DevicePath - ); + 0, + &gEfiCallerIdGuid, + NULL, + NULL, + 0 + ); // // Discover device, now! @@ -546,7 +538,6 @@ IDEBusDriverBindingStart ( // Submit identify data to IDE controller init driver // CopyMem (&IdentifyData, IdeBlkIoDevicePtr->pIdData, sizeof (IdentifyData)); - // IdentifyData = *IdeBlkIoDevicePtr->pIdData; IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = TRUE; IdeInit->SubmitData (IdeInit, IdeChannel, IdeDevice, &IdentifyData); } else { @@ -638,7 +629,11 @@ IDEBusDriverBindingStart ( IdeBlkIoDevicePtr = NULL; continue; } - + // + // Record Udma Mode + // + IdeBlkIoDevicePtr->UdmaMode.Valid = TRUE; + IdeBlkIoDevicePtr->UdmaMode.Mode = SupportedModes->UdmaMode.Mode; EnableInterrupt (IdeBlkIoDevicePtr); } else if (SupportedModes->MultiWordDmaMode.Valid) { @@ -673,7 +668,7 @@ IDEBusDriverBindingStart ( // // Record PIO mode used in private data // - IdeBlkIoDevicePtr->PioMode = SupportedModes->PioMode.Mode; + IdeBlkIoDevicePtr->PioMode = (ATA_PIO_MODE) SupportedModes->PioMode.Mode; // // Set IDE controller Timing Blocks in the PCI Configuration Space @@ -720,6 +715,18 @@ IDEBusDriverBindingStart ( (EFI_IO_BUS_ATA_ATAPI | EFI_P_PC_ENABLE), IdeBlkIoDevicePtr->DevicePath ); + + // + // Create event to clear pending IDE interrupt + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES, + EFI_TPL_NOTIFY, + ClearInterrupt, + IdeBlkIoDevicePtr, + &IdeBlkIoDevicePtr->ExitBootServiceEvent + ); + // // end of 2nd inner loop ---- // @@ -800,6 +807,18 @@ ErrorExit: // IDEBusDriverBindingStop // *********************************************************************************** // +/** + Stop this driver on Controller Handle. + + @param This Protocol instance pointer. + @param DeviceHandle Handle of device to stop driver on + @param NumberOfChildren Not used + @param ChildHandleBuffer Not used + + @retval EFI_SUCCESS This driver is removed DeviceHandle + @retval other This driver was not removed from this device + +**/ EFI_STATUS EFIAPI IDEBusDriverBindingStop ( @@ -808,22 +827,6 @@ IDEBusDriverBindingStop ( IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer ) -/*++ - - Routine Description: - Stop this driver on Controller Handle. - - Arguments: - This - Protocol instance pointer. - DeviceHandle - 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 - ---*/ // TODO: Controller - add argument and description to function comment // TODO: EFI_DEVICE_ERROR - add return value to function comment { @@ -921,29 +924,22 @@ IDEBusDriverBindingStop ( // DeRegisterIdeDevice // *********************************************************************************** // +/** + Deregister an IDE device and free resources + + @param This Protocol instance pointer. + @param Controller Ide device handle + @param Handle Handle of device to deregister driver on + + @return EFI_STATUS + +**/ EFI_STATUS DeRegisterIdeDevice ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_HANDLE Handle ) -/*++ - -Routine Description: - - Deregister an IDE device and free resources - -Arguments: - - This - Protocol instance pointer. - Controller - Ide device handle - Handle - Handle of device to deregister driver on - -Returns: - - EFI_STATUS - ---*/ // TODO: EFI_SUCCESS - add return value to function comment { EFI_STATUS Status; @@ -1024,26 +1020,18 @@ Returns: // IDEBlkIoReset // *********************************************************************************** // +/** + TODO: This - add argument and description to function comment + TODO: ExtendedVerification - add argument and description to function comment + TODO: EFI_DEVICE_ERROR - add return value to function comment + +**/ EFI_STATUS EFIAPI IDEBlkIoReset ( IN EFI_BLOCK_IO_PROTOCOL *This, IN BOOLEAN ExtendedVerification ) -/*++ - -Routine Description: - -Arguments: - -Returns: - - None - ---*/ -// TODO: This - add argument and description to function comment -// TODO: ExtendedVerification - add argument and description to function comment -// TODO: EFI_DEVICE_ERROR - add return value to function comment { IDE_BLK_IO_DEV *IdeBlkIoDevice; EFI_STATUS Status; @@ -1057,7 +1045,8 @@ Returns: // // for ATA device, using ATA reset method // - if (IdeBlkIoDevice->Type == IdeHardDisk) { + if (IdeBlkIoDevice->Type == IdeHardDisk || + IdeBlkIoDevice->Type == Ide48bitAddressingHardDisk) { return AtaSoftReset (IdeBlkIoDevice); } @@ -1076,6 +1065,18 @@ Returns: return Status; } +/** + Read data from block io device + + @param This Protocol instance pointer. + @param MediaId The media ID of the device + @param LBA Starting LBA address to read data + @param BufferSize The size of data to be read + @param Buffer Caller supplied buffer to save data + + @return read data status + +**/ EFI_STATUS EFIAPI IDEBlkIoReadBlocks ( @@ -1085,25 +1086,6 @@ IDEBlkIoReadBlocks ( IN UINTN BufferSize, OUT VOID *Buffer ) -/*++ - -Routine Description: - - Read data from block io device - -Arguments: - - This - Protocol instance pointer. - MediaId - The media ID of the device - LBA - Starting LBA address to read data - BufferSize - The size of data to be read - Buffer - Caller supplied buffer to save data - -Returns: - - read data status - ---*/ // TODO: EFI_DEVICE_ERROR - add return value to function comment { IDE_BLK_IO_DEV *IdeBlkIoDevice; @@ -1146,6 +1128,18 @@ Returns: } +/** + Write data to block io device + + @param This Protocol instance pointer. + @param MediaId The media ID of the device + @param LBA Starting LBA address to write data + @param BufferSize The size of data to be written + @param Buffer Caller supplied buffer to save data + + @return write data status + +**/ EFI_STATUS EFIAPI IDEBlkIoWriteBlocks ( @@ -1155,25 +1149,6 @@ IDEBlkIoWriteBlocks ( IN UINTN BufferSize, IN VOID *Buffer ) -/*++ - -Routine Description: - - Write data to block io device - -Arguments: - - This - Protocol instance pointer. - MediaId - The media ID of the device - LBA - Starting LBA address to write data - BufferSize - The size of data to be written - Buffer - Caller supplied buffer to save data - -Returns: - - write data status - ---*/ // TODO: EFI_DEVICE_ERROR - add return value to function comment { IDE_BLK_IO_DEV *IdeBlkIoDevice; @@ -1220,24 +1195,15 @@ Returns: // IDEBlkIoFlushBlocks // *********************************************************************************** // +/** + TODO: This - add argument and description to function comment + TODO: EFI_SUCCESS - add return value to function comment +**/ EFI_STATUS EFIAPI IDEBlkIoFlushBlocks ( IN EFI_BLOCK_IO_PROTOCOL *This ) -/*++ - -Routine Description: - -Arguments: - -Returns: - - None - ---*/ -// TODO: This - add argument and description to function comment -// TODO: EFI_SUCCESS - add return value to function comment { // // return directly @@ -1245,6 +1211,20 @@ Returns: return EFI_SUCCESS; } +/** + Return the results of the Inquiry command to a drive in InquiryData. + Data format of Inquiry data is defined by the Interface GUID. + + @param This Protocol instance pointer. + @param InquiryData Results of Inquiry command to device + @param InquiryDataSize Size of InquiryData in bytes. + + @retval EFI_SUCCESS InquiryData valid + @retval EFI_NOT_FOUND Device does not support this data class + @retval EFI_DEVICE_ERROR Error reading InquiryData from device + @retval EFI_BUFFER_TOO_SMALL IntquiryDataSize not big enough + +**/ EFI_STATUS EFIAPI IDEDiskInfoInquiry ( @@ -1252,24 +1232,6 @@ IDEDiskInfoInquiry ( IN OUT VOID *InquiryData, IN OUT UINT32 *InquiryDataSize ) -/*++ - - Routine Description: - Return the results of the Inquiry command to a drive in InquiryData. - Data format of Inquiry data is defined by the Interface GUID. - - Arguments: - This - Protocol instance pointer. - InquiryData - Results of Inquiry command to device - InquiryDataSize - Size of InquiryData in bytes. - - Returns: - EFI_SUCCESS - InquiryData valid - EFI_NOT_FOUND - Device does not support this data class - EFI_DEVICE_ERROR - Error reading InquiryData from device - EFI_BUFFER_TOO_SMALL - IntquiryDataSize not big enough - ---*/ { IDE_BLK_IO_DEV *IdeBlkIoDevice; @@ -1290,6 +1252,20 @@ IDEDiskInfoInquiry ( return EFI_SUCCESS; } +/** + Return the results of the Identify command to a drive in IdentifyData. + Data format of Identify data is defined by the Interface GUID. + + @param This Protocol instance pointer. + @param IdentifyData Results of Identify command to device + @param IdentifyDataSize Size of IdentifyData in bytes. + + @retval EFI_SUCCESS IdentifyData valid + @retval EFI_NOT_FOUND Device does not support this data class + @retval EFI_DEVICE_ERROR Error reading IdentifyData from device + @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough + +**/ EFI_STATUS EFIAPI IDEDiskInfoIdentify ( @@ -1297,24 +1273,6 @@ IDEDiskInfoIdentify ( IN OUT VOID *IdentifyData, IN OUT UINT32 *IdentifyDataSize ) -/*++ - - Routine Description: - Return the results of the Identify command to a drive in IdentifyData. - Data format of Identify data is defined by the Interface GUID. - - Arguments: - This - Protocol instance pointer. - IdentifyData - Results of Identify command to device - IdentifyDataSize - Size of IdentifyData in bytes. - - Returns: - EFI_SUCCESS - IdentifyData valid - EFI_NOT_FOUND - Device does not support this data class - EFI_DEVICE_ERROR - Error reading IdentifyData from device - EFI_BUFFER_TOO_SMALL - IdentifyDataSize not big enough - ---*/ { IDE_BLK_IO_DEV *IdeBlkIoDevice; @@ -1335,6 +1293,21 @@ IDEDiskInfoIdentify ( return EFI_SUCCESS; } +/** + Return the results of the Request Sense command to a drive in SenseData. + Data format of Sense data is defined by the Interface GUID. + + @param This Protocol instance pointer. + @param SenseData Results of Request Sense command to device + @param SenseDataSize Size of SenseData in bytes. + @param SenseDataNumber Type of SenseData + + @retval EFI_SUCCESS InquiryData valid + @retval EFI_NOT_FOUND Device does not support this data class + @retval EFI_DEVICE_ERROR Error reading InquiryData from device + @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough + +**/ EFI_STATUS EFIAPI IDEDiskInfoSenseData ( @@ -1343,29 +1316,22 @@ IDEDiskInfoSenseData ( IN OUT UINT32 *SenseDataSize, OUT UINT8 *SenseDataNumber ) -/*++ - - Routine Description: - Return the results of the Request Sense command to a drive in SenseData. - Data format of Sense data is defined by the Interface GUID. - - Arguments: - This - Protocol instance pointer. - SenseData - Results of Request Sense command to device - SenseDataSize - Size of SenseData in bytes. - SenseDataNumber - Type of SenseData - - Returns: - EFI_SUCCESS - InquiryData valid - EFI_NOT_FOUND - Device does not support this data class - EFI_DEVICE_ERROR - Error reading InquiryData from device - EFI_BUFFER_TOO_SMALL - SenseDataSize not big enough - ---*/ { return EFI_NOT_FOUND; } +/** + Return the results of the Request Sense command to a drive in SenseData. + Data format of Sense data is defined by the Interface GUID. + + @param This Protocol instance pointer. + @param IdeChannel Primary or Secondary + @param IdeDevice Master or Slave + + @retval EFI_SUCCESS IdeChannel and IdeDevice are valid + @retval EFI_UNSUPPORTED This is not an IDE device + +**/ EFI_STATUS EFIAPI IDEDiskInfoWhichIde ( @@ -1373,22 +1339,6 @@ IDEDiskInfoWhichIde ( OUT UINT32 *IdeChannel, OUT UINT32 *IdeDevice ) -/*++ - - Routine Description: - Return the results of the Request Sense command to a drive in SenseData. - Data format of Sense data is defined by the Interface GUID. - - Arguments: - This - Protocol instance pointer. - IdeChannel - Primary or Secondary - IdeDevice - Master or Slave - - Returns: - EFI_SUCCESS - IdeChannel and IdeDevice are valid - EFI_UNSUPPORTED - This is not an IDE device - ---*/ { IDE_BLK_IO_DEV *IdeBlkIoDevice;