/** @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
- 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
+ Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#include "AtapiPassThru.h"\r
\r
\r
-static SCSI_COMMAND_SET gEndTable = { 0xff, (DATA_DIRECTION) 0xff };\r
+SCSI_COMMAND_SET gEndTable = { 0xff, (DATA_DIRECTION) 0xff };\r
\r
///\r
/// This table contains all the supported ATAPI commands.\r
///\r
-static SCSI_COMMAND_SET gSupportedATAPICommands[] = {\r
+SCSI_COMMAND_SET gSupportedATAPICommands[] = {\r
{ OP_INQUIRY, DataIn },\r
{ OP_LOAD_UNLOAD_CD, NoData },\r
{ OP_MECHANISM_STATUS, DataIn },\r
};\r
\r
GLOBAL_REMOVE_IF_UNREFERENCED EFI_EXT_SCSI_PASS_THRU_MODE gExtScsiPassThruMode = {\r
- 4, \r
+ 4,\r
EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL | EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL,\r
0\r
};\r
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
that has gEfiPciIoProtocolGuid installed and is IDE Controller it will be supported.\r
- \r
+\r
Arguments:\r
\r
This - Protocol instance pointer.\r
Controller - Handle of device to test\r
RemainingDevicePath - Not used\r
- \r
+\r
Returns:\r
EFI_STATUS\r
- \r
+\r
--*/\r
{\r
EFI_STATUS Status;\r
return EFI_UNSUPPORTED;\r
}\r
\r
- if (Pci.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE || Pci.Hdr.ClassCode[1] != PCI_CLASS_IDE) {\r
+ if (Pci.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE || Pci.Hdr.ClassCode[1] != PCI_CLASS_MASS_STORAGE_IDE) {\r
\r
Status = EFI_UNSUPPORTED;\r
}\r
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Create handles for IDE channels specified by RemainingDevicePath.\r
Install SCSI Pass Thru Protocol onto each created handle.\r
- \r
+\r
Arguments:\r
\r
This - Protocol instance pointer.\r
Controller - Handle of device to test\r
RemainingDevicePath - Not used\r
- \r
+\r
Returns:\r
EFI_STATUS\r
- \r
+\r
--*/\r
{\r
EFI_STATUS Status;\r
EFI_PCI_IO_PROTOCOL *PciIo;\r
UINT64 Supports;\r
UINT64 OriginalPciAttributes;\r
+ BOOLEAN PciAttributesSaved;\r
\r
PciIo = NULL;\r
Status = gBS->OpenProtocol (\r
return Status;\r
}\r
\r
+ PciAttributesSaved = FALSE;\r
//\r
// Save original PCI attributes\r
//\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- return Status;\r
+ goto Done;\r
}\r
+ PciAttributesSaved = TRUE;\r
\r
Status = PciIo->Attributes (\r
PciIo,\r
\r
Done:\r
if (EFI_ERROR (Status)) {\r
- //\r
- // Restore original PCI attributes\r
- //\r
- PciIo->Attributes (\r
- PciIo,\r
- EfiPciIoAttributeOperationSet,\r
- OriginalPciAttributes,\r
- NULL\r
- );\r
+ if (PciAttributesSaved == TRUE) {\r
+ //\r
+ // Restore original PCI attributes\r
+ //\r
+ PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationSet,\r
+ OriginalPciAttributes,\r
+ NULL\r
+ );\r
+ }\r
\r
gBS->CloseProtocol (\r
Controller,\r
IN EFI_HANDLE *ChildHandleBuffer\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
\r
- Stop this driver on ControllerHandle. Support stoping any child handles\r
+ Stop this driver on ControllerHandle. Support stopping any child handles\r
created by this driver.\r
\r
Arguments:\r
Controller - Handle of device to stop driver on\r
NumberOfChildren - Number of Children in the ChildHandleBuffer\r
ChildHandleBuffer - List of handles for the children we need to stop.\r
- \r
+\r
Returns:\r
\r
EFI_STATUS\r
- \r
+\r
--*/\r
{\r
EFI_STATUS Status;\r
IN UINT64 OriginalPciAttributes\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
Attaches SCSI Pass Thru Protocol for specified IDE channel.\r
- \r
+\r
Arguments:\r
This - Protocol instance pointer.\r
- Controller - Parent device handle to the IDE channel. \r
- PciIo - PCI I/O protocol attached on the "Controller". \r
- \r
+ Controller - Parent device handle to the IDE channel.\r
+ PciIo - PCI I/O protocol attached on the "Controller".\r
+\r
Returns:\r
Always return EFI_SUCCESS unless installing SCSI Pass Thru Protocol failed.\r
\r
Arguments:\r
\r
This: The EFI_SCSI_PASS_THRU_PROTOCOL instance.\r
- Target: The Target ID of the ATAPI device to send the SCSI \r
+ Target: The Target ID of the ATAPI device to send the SCSI\r
Request Packet. To ATAPI devices attached on an IDE\r
Channel, Target ID 0 indicates Master device;Target\r
ID 1 indicates Slave device.\r
Lun: The LUN of the ATAPI device to send the SCSI Request\r
Packet. To the ATAPI device, Lun is always 0.\r
- Packet: The SCSI Request Packet to send to the ATAPI device \r
+ Packet: The SCSI Request Packet to send to the ATAPI device\r
specified by Target and Lun.\r
- Event: If non-blocking I/O is not supported then Event is ignored, \r
+ Event: If non-blocking I/O is not supported then Event is ignored,\r
and blocking I/O is performed.\r
If Event is NULL, then blocking I/O is performed.\r
- If Event is not NULL and non blocking I/O is supported, \r
- then non-blocking I/O is performed, and Event will be signaled \r
- when the SCSI Request Packet completes. \r
+ If Event is not NULL and non blocking I/O is supported,\r
+ then non-blocking I/O is performed, and Event will be signaled\r
+ when the SCSI Request Packet completes.\r
\r
-Returns: \r
+Returns:\r
\r
EFI_STATUS\r
- \r
+\r
--*/\r
{\r
ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;\r
if ((Target > MAX_TARGET_ID) || (Lun != 0)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
- \r
+\r
//\r
// check the data fields in Packet parameter.\r
//\r
\r
Routine Description:\r
\r
- Used to retrieve the list of legal Target IDs for SCSI devices \r
+ Used to retrieve the list of legal Target IDs for SCSI devices\r
on a SCSI channel.\r
\r
Arguments:\r
\r
This - Protocol instance pointer.\r
- Target - On input, a pointer to the Target ID of a SCSI \r
- device present on the SCSI channel. On output, \r
+ Target - On input, a pointer to the Target ID of a SCSI\r
+ device present on the SCSI channel. On output,\r
a pointer to the Target ID of the next SCSI device\r
- present on a SCSI channel. An input value of \r
- 0xFFFFFFFF retrieves the Target ID of the first \r
+ present on a SCSI channel. An input value of\r
+ 0xFFFFFFFF retrieves the Target ID of the first\r
SCSI device present on a SCSI channel.\r
Lun - On input, a pointer to the LUN of a SCSI device\r
present on the SCSI channel. On output, a pointer\r
- to the LUN of the next SCSI device present on \r
+ to the LUN of the next SCSI device present on\r
a SCSI channel.\r
Returns:\r
\r
- EFI_SUCCESS - The Target ID and Lun of the next SCSI device \r
+ EFI_SUCCESS - The Target ID and Lun of the next SCSI device\r
on the SCSI channel was returned in Target and Lun.\r
EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.\r
EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not\r
\r
Routine Description:\r
\r
- Used to allocate and build a device path node for a SCSI device \r
+ Used to allocate and build a device path node for a SCSI device\r
on a SCSI channel. Would not build device path for a SCSI Host Controller.\r
\r
Arguments:\r
This - Protocol instance pointer.\r
Target - The Target ID of the SCSI device for which\r
a device path node is to be allocated and built.\r
- Lun - The LUN of the SCSI device for which a device \r
+ Lun - The LUN of the SCSI device for which a device\r
path node is to be allocated and built.\r
- DevicePath - A pointer to a single device path node that \r
- describes the SCSI device specified by \r
- Target and Lun. This function is responsible \r
+ DevicePath - A pointer to a single device path node that\r
+ describes the SCSI device specified by\r
+ Target and Lun. This function is responsible\r
for allocating the buffer DevicePath with the boot\r
- service AllocatePool(). It is the caller's \r
+ service AllocatePool(). It is the caller's\r
responsibility to free DevicePath when the caller\r
- is finished with DevicePath. \r
+ is finished with DevicePath.\r
Returns:\r
EFI_SUCCESS - The device path node that describes the SCSI device\r
- specified by Target and Lun was allocated and \r
+ specified by Target and Lun was allocated and\r
returned in DevicePath.\r
EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does\r
not exist on the SCSI channel.\r
EFI_INVALID_PARAMETER - DevicePath is NULL.\r
- EFI_OUT_OF_RESOURCES - There are not enough resources to allocate \r
+ EFI_OUT_OF_RESOURCES - There are not enough resources to allocate\r
DevicePath.\r
--*/\r
{\r
Arguments:\r
\r
This - Protocol instance pointer.\r
- DevicePath - A pointer to the device path node that \r
+ DevicePath - A pointer to the device path node that\r
describes a SCSI device on the SCSI channel.\r
- Target - A pointer to the Target ID of a SCSI device \r
- on the SCSI channel. \r
- Lun - A pointer to the LUN of a SCSI device on \r
- the SCSI channel. \r
+ Target - A pointer to the Target ID of a SCSI device\r
+ on the SCSI channel.\r
+ Lun - A pointer to the LUN of a SCSI device on\r
+ the SCSI channel.\r
Returns:\r
\r
- EFI_SUCCESS - DevicePath was successfully translated to a \r
- Target ID and LUN, and they were returned \r
+ EFI_SUCCESS - DevicePath was successfully translated to a\r
+ Target ID and LUN, and they were returned\r
in Target and Lun.\r
EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.\r
- EFI_UNSUPPORTED - This driver does not support the device path \r
+ EFI_UNSUPPORTED - This driver does not support the device path\r
node type in DevicePath.\r
- EFI_NOT_FOUND - A valid translation from DevicePath to a \r
+ EFI_NOT_FOUND - A valid translation from DevicePath to a\r
Target ID and LUN does not exist.\r
--*/\r
{\r
\r
Routine Description:\r
\r
- Resets a SCSI channel.This operation resets all the \r
+ Resets a SCSI channel.This operation resets all the\r
SCSI devices connected to the SCSI channel.\r
\r
Arguments:\r
Returns:\r
\r
EFI_SUCCESS - The SCSI channel was reset.\r
- EFI_UNSUPPORTED - The SCSI channel does not support \r
+ EFI_UNSUPPORTED - The SCSI channel does not support\r
a channel reset operation.\r
- EFI_DEVICE_ERROR - A device error occurred while \r
+ EFI_DEVICE_ERROR - A device error occurred while\r
attempting to reset the SCSI channel.\r
- EFI_TIMEOUT - A timeout occurred while attempting \r
+ EFI_TIMEOUT - A timeout occurred while attempting\r
to reset the SCSI channel.\r
--*/\r
{\r
//\r
// disable Interrupt\r
//\r
- DeviceControlValue |= bit (1);\r
+ DeviceControlValue |= BIT1;\r
WritePortB (\r
AtapiScsiPrivate->PciIo,\r
AtapiScsiPrivate->IoPort->Alt.DeviceControl,\r
Arguments:\r
\r
This - Protocol instance pointer.\r
- Target - The Target ID of the SCSI device to reset. \r
+ Target - The Target ID of the SCSI device to reset.\r
Lun - The LUN of the SCSI device to reset.\r
- \r
+\r
Returns:\r
\r
- EFI_SUCCESS - The SCSI device specified by Target and \r
+ EFI_SUCCESS - The SCSI device specified by Target and\r
Lun was reset.\r
EFI_UNSUPPORTED - The SCSI channel does not support a target\r
reset operation.\r
EFI_INVALID_PARAMETER - Target or Lun are invalid.\r
- EFI_DEVICE_ERROR - A device error occurred while attempting \r
- to reset the SCSI device specified by Target \r
+ EFI_DEVICE_ERROR - A device error occurred while attempting\r
+ to reset the SCSI device specified by Target\r
and Lun.\r
- EFI_TIMEOUT - A timeout occurred while attempting to reset \r
+ EFI_TIMEOUT - A timeout occurred while attempting to reset\r
the SCSI device specified by Target and Lun.\r
--*/\r
{\r
//\r
// bit7 and bit5 are both set to 1 for backward compatibility\r
//\r
- DeviceSelect = (UINT8) (((bit (7) | bit (5)) | (Target << 4)));\r
+ DeviceSelect = (UINT8) (((BIT7 | BIT5) | (Target << 4)));\r
WritePortB (AtapiScsiPrivate->PciIo, AtapiScsiPrivate->IoPort->Head, DeviceSelect);\r
\r
Command = ATAPI_SOFT_RESET_CMD;\r
Arguments:\r
\r
This: The EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
- Target: The Target ID of the ATAPI device to send the SCSI \r
+ Target: The Target ID of the ATAPI device to send the SCSI\r
Request Packet. To ATAPI devices attached on an IDE\r
Channel, Target ID 0 indicates Master device;Target\r
ID 1 indicates Slave device.\r
Lun: The LUN of the ATAPI device to send the SCSI Request\r
Packet. To the ATAPI device, Lun is always 0.\r
- Packet: The SCSI Request Packet to send to the ATAPI device \r
+ Packet: The SCSI Request Packet to send to the ATAPI device\r
specified by Target and Lun.\r
- Event: If non-blocking I/O is not supported then Event is ignored, \r
+ Event: If non-blocking I/O is not supported then Event is ignored,\r
and blocking I/O is performed.\r
If Event is NULL, then blocking I/O is performed.\r
- If Event is not NULL and non blocking I/O is supported, \r
- then non-blocking I/O is performed, and Event will be signaled \r
- when the SCSI Request Packet completes. \r
+ If Event is not NULL and non blocking I/O is supported,\r
+ then non-blocking I/O is performed, and Event will be signaled\r
+ when the SCSI Request Packet completes.\r
\r
-Returns: \r
+Returns:\r
\r
EFI_STATUS\r
- \r
+\r
--*/\r
{\r
EFI_STATUS Status;\r
ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;\r
UINT8 TargetId;\r
- \r
+\r
AtapiScsiPrivate = ATAPI_EXT_SCSI_PASS_THRU_DEV_FROM_THIS (This);\r
\r
//\r
// For ATAPI device, UINT8 is enough to represent the SCSI ID on channel.\r
//\r
TargetId = Target[0];\r
- \r
+\r
//\r
// Target is not allowed beyond MAX_TARGET_ID\r
//\r
if ((TargetId > MAX_TARGET_ID) || (Lun != 0)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
- \r
+\r
//\r
// check the data fields in Packet parameter.\r
//\r
Packet->InTransferLength = Packet->OutTransferLength = 0;\r
return EFI_SUCCESS;\r
}\r
- \r
+\r
//\r
// According to Target ID, reset the Atapi I/O Register mapping\r
// (Target Id in [0,1] area, using AtapiIoPortRegisters[0],\r
TargetId = (UINT8) (TargetId % 2);\r
AtapiScsiPrivate->IoPort = &AtapiScsiPrivate->AtapiIoPortRegisters[1];\r
}\r
- \r
+\r
//\r
// the ATAPI SCSI interface does not support non-blocking I/O\r
// ignore the Event parameter\r
\r
Routine Description:\r
\r
- Used to retrieve the list of legal Target IDs for SCSI devices \r
+ Used to retrieve the list of legal Target IDs for SCSI devices\r
on a SCSI channel.\r
\r
Arguments:\r
\r
This - Protocol instance pointer.\r
- Target - On input, a pointer to the Target ID of a SCSI \r
- device present on the SCSI channel. On output, \r
+ Target - On input, a pointer to the Target ID of a SCSI\r
+ device present on the SCSI channel. On output,\r
a pointer to the Target ID of the next SCSI device\r
- present on a SCSI channel. An input value of \r
- 0xFFFFFFFF retrieves the Target ID of the first \r
+ present on a SCSI channel. An input value of\r
+ 0xFFFFFFFF retrieves the Target ID of the first\r
SCSI device present on a SCSI channel.\r
Lun - On input, a pointer to the LUN of a SCSI device\r
present on the SCSI channel. On output, a pointer\r
- to the LUN of the next SCSI device present on \r
+ to the LUN of the next SCSI device present on\r
a SCSI channel.\r
Returns:\r
\r
- EFI_SUCCESS - The Target ID and Lun of the next SCSI device \r
+ EFI_SUCCESS - The Target ID and Lun of the next SCSI device\r
on the SCSI channel was returned in Target and Lun.\r
EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.\r
EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not\r
UINT8 ByteIndex;\r
UINT8 TargetId;\r
UINT8 ScsiId[TARGET_MAX_BYTES];\r
- ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate; \r
+ ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;\r
\r
//\r
// Retrieve Device Private Data Structure.\r
if ((*Target)[ByteIndex] != 0) {\r
return EFI_INVALID_PARAMETER;\r
}\r
- } \r
+ }\r
}\r
- \r
+\r
if ((CompareMem(*Target, ScsiId, TARGET_MAX_BYTES) != 0) &&\r
((TargetId != AtapiScsiPrivate->LatestTargetId) ||\r
(*Lun != AtapiScsiPrivate->LatestLun))) {\r
\r
Routine Description:\r
\r
- Used to allocate and build a device path node for a SCSI device \r
+ Used to allocate and build a device path node for a SCSI device\r
on a SCSI channel. Would not build device path for a SCSI Host Controller.\r
\r
Arguments:\r
This - Protocol instance pointer.\r
Target - The Target ID of the SCSI device for which\r
a device path node is to be allocated and built.\r
- Lun - The LUN of the SCSI device for which a device \r
+ Lun - The LUN of the SCSI device for which a device\r
path node is to be allocated and built.\r
- DevicePath - A pointer to a single device path node that \r
- describes the SCSI device specified by \r
- Target and Lun. This function is responsible \r
+ DevicePath - A pointer to a single device path node that\r
+ describes the SCSI device specified by\r
+ Target and Lun. This function is responsible\r
for allocating the buffer DevicePath with the boot\r
- service AllocatePool(). It is the caller's \r
+ service AllocatePool(). It is the caller's\r
responsibility to free DevicePath when the caller\r
- is finished with DevicePath. \r
+ is finished with DevicePath.\r
Returns:\r
EFI_SUCCESS - The device path node that describes the SCSI device\r
- specified by Target and Lun was allocated and \r
+ specified by Target and Lun was allocated and\r
returned in DevicePath.\r
EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does\r
not exist on the SCSI channel.\r
EFI_INVALID_PARAMETER - DevicePath is NULL.\r
- EFI_OUT_OF_RESOURCES - There are not enough resources to allocate \r
+ EFI_OUT_OF_RESOURCES - There are not enough resources to allocate\r
DevicePath.\r
--*/\r
{\r
EFI_DEV_PATH *Node;\r
UINT8 TargetId;\r
\r
- TargetId = Target[0]; \r
+ TargetId = Target[0];\r
\r
//\r
// Validate parameters passed in.\r
//\r
- \r
+\r
if (DevicePath == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
- \r
+\r
//\r
// can not build device path for the SCSI Host Controller.\r
//\r
Arguments:\r
\r
This - Protocol instance pointer.\r
- DevicePath - A pointer to the device path node that \r
+ DevicePath - A pointer to the device path node that\r
describes a SCSI device on the SCSI channel.\r
- Target - A pointer to the Target ID of a SCSI device \r
- on the SCSI channel. \r
- Lun - A pointer to the LUN of a SCSI device on \r
- the SCSI channel. \r
+ Target - A pointer to the Target ID of a SCSI device\r
+ on the SCSI channel.\r
+ Lun - A pointer to the LUN of a SCSI device on\r
+ the SCSI channel.\r
Returns:\r
\r
- EFI_SUCCESS - DevicePath was successfully translated to a \r
- Target ID and LUN, and they were returned \r
+ EFI_SUCCESS - DevicePath was successfully translated to a\r
+ Target ID and LUN, and they were returned\r
in Target and Lun.\r
EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.\r
- EFI_UNSUPPORTED - This driver does not support the device path \r
+ EFI_UNSUPPORTED - This driver does not support the device path\r
node type in DevicePath.\r
- EFI_NOT_FOUND - A valid translation from DevicePath to a \r
+ EFI_NOT_FOUND - A valid translation from DevicePath to a\r
Target ID and LUN does not exist.\r
--*/\r
{\r
if (DevicePath == NULL || Target == NULL || Lun == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
- \r
+\r
//\r
// Check whether the DevicePath belongs to SCSI_DEVICE_PATH\r
//\r
\r
Routine Description:\r
\r
- Resets a SCSI channel.This operation resets all the \r
+ Resets a SCSI channel.This operation resets all the\r
SCSI devices connected to the SCSI channel.\r
\r
Arguments:\r
Returns:\r
\r
EFI_SUCCESS - The SCSI channel was reset.\r
- EFI_UNSUPPORTED - The SCSI channel does not support \r
+ EFI_UNSUPPORTED - The SCSI channel does not support\r
a channel reset operation.\r
- EFI_DEVICE_ERROR - A device error occurred while \r
+ EFI_DEVICE_ERROR - A device error occurred while\r
attempting to reset the SCSI channel.\r
- EFI_TIMEOUT - A timeout occurred while attempting \r
+ EFI_TIMEOUT - A timeout occurred while attempting\r
to reset the SCSI channel.\r
--*/\r
{\r
//\r
// disable Interrupt\r
//\r
- DeviceControlValue |= bit (1);\r
+ DeviceControlValue |= BIT1;\r
WritePortB (\r
AtapiScsiPrivate->PciIo,\r
AtapiScsiPrivate->IoPort->Alt.DeviceControl,\r
// 0xfb:1111,1011\r
//\r
DeviceControlValue &= 0xfb;\r
- \r
+\r
WritePortB (AtapiScsiPrivate->PciIo, AtapiScsiPrivate->IoPort->Alt.DeviceControl, DeviceControlValue);\r
\r
//\r
if (ResetFlag) {\r
return EFI_SUCCESS;\r
}\r
- \r
+\r
return EFI_TIMEOUT;\r
}\r
\r
Arguments:\r
\r
This - Protocol instance pointer.\r
- Target - The Target ID of the SCSI device to reset. \r
+ Target - The Target ID of the SCSI device to reset.\r
Lun - The LUN of the SCSI device to reset.\r
- \r
+\r
Returns:\r
\r
- EFI_SUCCESS - The SCSI device specified by Target and \r
+ EFI_SUCCESS - The SCSI device specified by Target and\r
Lun was reset.\r
EFI_UNSUPPORTED - The SCSI channel does not support a target\r
reset operation.\r
EFI_INVALID_PARAMETER - Target or Lun are invalid.\r
- EFI_DEVICE_ERROR - A device error occurred while attempting \r
- to reset the SCSI device specified by Target \r
+ EFI_DEVICE_ERROR - A device error occurred while attempting\r
+ to reset the SCSI device specified by Target\r
and Lun.\r
- EFI_TIMEOUT - A timeout occurred while attempting to reset \r
+ EFI_TIMEOUT - A timeout occurred while attempting to reset\r
the SCSI device specified by Target and Lun.\r
--*/\r
{\r
UINT8 DeviceSelect;\r
UINT8 TargetId;\r
ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;\r
- \r
+\r
AtapiScsiPrivate = ATAPI_EXT_SCSI_PASS_THRU_DEV_FROM_THIS (This);\r
TargetId = Target[0];\r
- \r
+\r
if ((TargetId > MAX_TARGET_ID) || (Lun != 0)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
if (TargetId == This->Mode->AdapterId) {\r
return EFI_SUCCESS;\r
}\r
- \r
+\r
//\r
// According to Target ID, reset the Atapi I/O Register mapping\r
// (Target Id in [0,1] area, using AtapiIoPortRegisters[0],\r
} else {\r
AtapiScsiPrivate->IoPort = &AtapiScsiPrivate->AtapiIoPortRegisters[1];\r
}\r
- \r
+\r
//\r
// for ATAPI device, no need to wait DRDY ready after device selecting.\r
//\r
// bit7 and bit5 are both set to 1 for backward compatibility\r
//\r
- DeviceSelect = (UINT8) (((bit (7) | bit (5)) | (TargetId << 4)));\r
+ DeviceSelect = (UINT8) ((BIT7 | BIT5) | (TargetId << 4));\r
WritePortB (AtapiScsiPrivate->PciIo, AtapiScsiPrivate->IoPort->Head, DeviceSelect);\r
\r
Command = ATAPI_SOFT_RESET_CMD;\r
if (EFI_ERROR (StatusWaitForBSYClear (AtapiScsiPrivate, 31000000))) {\r
return EFI_TIMEOUT;\r
}\r
- \r
+\r
//\r
// stall 5 seconds to make the device status stable\r
//\r
/*++\r
\r
Routine Description:\r
- Used to retrieve the list of legal Target IDs for SCSI devices \r
+ Used to retrieve the list of legal Target IDs for SCSI devices\r
on a SCSI channel.\r
\r
Arguments:\r
This - Protocol instance pointer.\r
- Target - On input, a pointer to the Target ID of a SCSI \r
- device present on the SCSI channel. On output, \r
+ Target - On input, a pointer to the Target ID of a SCSI\r
+ device present on the SCSI channel. On output,\r
a pointer to the Target ID of the next SCSI device\r
- present on a SCSI channel. An input value of \r
- 0xFFFFFFFF retrieves the Target ID of the first \r
+ present on a SCSI channel. An input value of\r
+ 0xFFFFFFFF retrieves the Target ID of the first\r
SCSI device present on a SCSI channel.\r
Lun - On input, a pointer to the LUN of a SCSI device\r
present on the SCSI channel. On output, a pointer\r
- to the LUN of the next SCSI device present on \r
+ to the LUN of the next SCSI device present on\r
a SCSI channel.\r
- \r
+\r
Returns:\r
- EFI_SUCCESS - The Target ID and Lun of the next SCSI device \r
+ EFI_SUCCESS - The Target ID and Lun of the next SCSI device\r
on the SCSI channel was returned in Target and Lun.\r
EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.\r
EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not\r
{\r
UINT8 TargetId;\r
UINT8 ScsiId[TARGET_MAX_BYTES];\r
- ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate; \r
+ ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;\r
UINT8 ByteIndex;\r
\r
//\r
EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
\r
- Checks the requested SCSI command: \r
+ Checks the requested SCSI command:\r
Is it supported by this driver?\r
Is the Data transfer direction reasonable?\r
\r
Arguments:\r
\r
- Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET \r
+ Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET\r
\r
Returns:\r
\r
{\r
UINT8 Index;\r
UINT8 *OpCode;\r
+ UINT8 ArrayLen;\r
\r
OpCode = (UINT8 *) (Packet->Cdb);\r
+ ArrayLen = (UINT8) (ARRAY_SIZE (gSupportedATAPICommands));\r
\r
- for (Index = 0; CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof (SCSI_COMMAND_SET)); Index++) {\r
+ for (Index = 0; (Index < ArrayLen) && (CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof (SCSI_COMMAND_SET)) != 0); Index++) {\r
\r
if (*OpCode == gSupportedATAPICommands[Index].OpCode) {\r
//\r
Routine Description:\r
\r
Performs blocking I/O request.\r
- \r
+\r
Arguments:\r
\r
AtapiScsiPrivate: Private data structure for the specified channel.\r
- Target: The Target ID of the ATAPI device to send the SCSI \r
+ Target: The Target ID of the ATAPI device to send the SCSI\r
Request Packet. To ATAPI devices attached on an IDE\r
Channel, Target ID 0 indicates Master device;Target\r
ID 1 indicates Slave device.\r
- Packet: The SCSI Request Packet to send to the ATAPI device \r
+ Packet: The SCSI Request Packet to send to the ATAPI device\r
specified by Target.\r
- \r
- Returns: EFI_STATUS \r
- \r
+\r
+ Returns: EFI_STATUS\r
+\r
--*/\r
{\r
UINT8 PacketCommand[12];\r
\r
Routine Description:\r
\r
- Sumbit request sense command\r
+ Submit request sense command\r
\r
Arguments:\r
\r
- AtapiScsiPrivate - The pionter of ATAPI_SCSI_PASS_THRU_DEV\r
+ AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
Target - The target ID\r
Timeout - The time to complete the command\r
SenseData - The buffer to fill in sense data\r
Returns:\r
\r
EFI_STATUS\r
- \r
+\r
--*/\r
{\r
EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET Packet;\r
Arguments:\r
\r
Packet - The pointer of EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET\r
- \r
+\r
Returns:\r
- \r
+\r
EFI_STATUS\r
\r
--*/\r
if (Packet->Cdb == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
- \r
+\r
//\r
// Checks whether the request command is supported.\r
//\r
EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet\r
)\r
/*++\r
- \r
+\r
Routine Description:\r
\r
- Checks the requested SCSI command: \r
+ Checks the requested SCSI command:\r
Is it supported by this driver?\r
Is the Data transfer direction reasonable?\r
\r
Arguments:\r
\r
- Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET \r
+ Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET\r
\r
Returns:\r
\r
{\r
UINT8 Index;\r
UINT8 *OpCode;\r
+ UINT8 ArrayLen;\r
\r
OpCode = (UINT8 *) (Packet->Cdb);\r
+ ArrayLen = (UINT8) (ARRAY_SIZE (gSupportedATAPICommands));\r
\r
- for (Index = 0; CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof (SCSI_COMMAND_SET)); Index++) {\r
+ for (Index = 0; (Index < ArrayLen) && (CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof (SCSI_COMMAND_SET)) != 0); Index++) {\r
\r
if (*OpCode == gSupportedATAPICommands[Index].OpCode) {\r
//\r
Routine Description:\r
\r
Performs blocking I/O request.\r
- \r
+\r
Arguments:\r
\r
AtapiScsiPrivate: Private data structure for the specified channel.\r
- Target: The Target ID of the ATAPI device to send the SCSI \r
+ Target: The Target ID of the ATAPI device to send the SCSI\r
Request Packet. To ATAPI devices attached on an IDE\r
Channel, Target ID 0 indicates Master device;Target\r
ID 1 indicates Slave device.\r
- Packet: The SCSI Request Packet to send to the ATAPI device \r
+ Packet: The SCSI Request Packet to send to the ATAPI device\r
specified by Target.\r
- \r
- Returns: EFI_STATUS \r
- \r
+\r
+ Returns: EFI_STATUS\r
+\r
--*/\r
{\r
UINT8 PacketCommand[12];\r
TimeoutInMicroSeconds\r
);\r
}\r
- \r
+\r
if (!EFI_ERROR (PacketCommandStatus) || (Packet->SenseData == NULL)) {\r
Packet->SenseDataLength = 0;\r
return PacketCommandStatus;\r
}\r
- \r
+\r
//\r
// Return SenseData if PacketCommandStatus matches\r
// the following return codes.\r
Routine Description:\r
\r
Submits ATAPI command packet to the specified ATAPI device.\r
- \r
+\r
Arguments:\r
\r
AtapiScsiPrivate: Private data structure for the specified channel.\r
- Target: The Target ID of the ATAPI device to send the SCSI \r
+ Target: The Target ID of the ATAPI device to send the SCSI\r
Request Packet. To ATAPI devices attached on an IDE\r
Channel, Target ID 0 indicates Master device;Target\r
ID 1 indicates Slave device.\r
Buffer: Points to the transferred data.\r
ByteCount: When input,indicates the buffer size; when output,\r
indicates the actually transferred data size.\r
- Direction: Indicates the data transfer direction. \r
+ Direction: Indicates the data transfer direction.\r
TimeoutInMicroSeconds:\r
- The timeout, in micro second units, to use for the \r
+ The timeout, in micro second units, to use for the\r
execution of this ATAPI command.\r
- A TimeoutInMicroSeconds value of 0 means that \r
- this function will wait indefinitely for the ATAPI \r
+ A TimeoutInMicroSeconds value of 0 means that\r
+ this function will wait indefinitely for the ATAPI\r
command to execute.\r
- If TimeoutInMicroSeconds is greater than zero, then \r
- this function will return EFI_TIMEOUT if the time \r
- required to execute the ATAPI command is greater \r
+ If TimeoutInMicroSeconds is greater than zero, then\r
+ this function will return EFI_TIMEOUT if the time\r
+ required to execute the ATAPI command is greater\r
than TimeoutInMicroSeconds.\r
- \r
+\r
Returns:\r
\r
EFI_STATUS\r
- \r
+\r
--*/\r
{\r
\r
\r
Performs data transfer between ATAPI device and host after the\r
ATAPI command packet is sent.\r
- \r
+\r
Arguments:\r
\r
- AtapiScsiPrivate: Private data structure for the specified channel. \r
+ AtapiScsiPrivate: Private data structure for the specified channel.\r
Buffer: Points to the transferred data.\r
ByteCount: When input,indicates the buffer size; when output,\r
indicates the actually transferred data size.\r
- Direction: Indicates the data transfer direction. \r
+ Direction: Indicates the data transfer direction.\r
TimeoutInMicroSeconds:\r
- The timeout, in micro second units, to use for the \r
+ The timeout, in micro second units, to use for the\r
execution of this ATAPI command.\r
- A TimeoutInMicroSeconds value of 0 means that \r
- this function will wait indefinitely for the ATAPI \r
+ A TimeoutInMicroSeconds value of 0 means that\r
+ this function will wait indefinitely for the ATAPI\r
command to execute.\r
- If TimeoutInMicroSeconds is greater than zero, then \r
- this function will return EFI_TIMEOUT if the time \r
- required to execute the ATAPI command is greater \r
+ If TimeoutInMicroSeconds is greater than zero, then\r
+ this function will return EFI_TIMEOUT if the time\r
+ required to execute the ATAPI command is greater\r
than TimeoutInMicroSeconds.\r
Returns:\r
\r
EFI_STATUS\r
- \r
+\r
--*/\r
{\r
UINT32 Index;\r
\r
PciIo - The pointer of EFI_PCI_IO_PROTOCOL\r
Port - IO port\r
- \r
+\r
Returns:\r
\r
A byte read out\r
\r
PciIo - The pointer of EFI_PCI_IO_PROTOCOL\r
Port - IO port\r
- \r
+\r
Returns:\r
\r
A word read out\r
PciIo - The pointer of EFI_PCI_IO_PROTOCOL\r
Port - IO port\r
Data - The data to write\r
- \r
+\r
Returns:\r
\r
NONE\r
PciIo - The pointer of EFI_PCI_IO_PROTOCOL\r
Port - IO port\r
Data - The data to write\r
- \r
+\r
Returns:\r
\r
NONE\r
- \r
+\r
--*/\r
{\r
PciIo->Io.Write (\r
\r
Check whether DRQ is clear in the Status Register. (BSY must also be cleared)\r
If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
- DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+ DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is\r
elapsed.\r
\r
Arguments:\r
\r
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
TimeoutInMicroSeconds - The time to wait for\r
- \r
+\r
Returns:\r
\r
EFI_STATUS\r
- \r
+\r
--*/\r
{\r
UINT64 Delay;\r
\r
Routine Description:\r
\r
- Check whether DRQ is clear in the Alternate Status Register. \r
- (BSY must also be cleared).If TimeoutInMicroSeconds is zero, this routine should \r
- wait infinitely for DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+ Check whether DRQ is clear in the Alternate Status Register.\r
+ (BSY must also be cleared).If TimeoutInMicroSeconds is zero, this routine should\r
+ wait infinitely for DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is\r
elapsed.\r
\r
Arguments:\r
\r
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
TimeoutInMicroSeconds - The time to wait for\r
- \r
+\r
Returns:\r
\r
EFI_STATUS\r
\r
Check whether DRQ is ready in the Status Register. (BSY must also be cleared)\r
If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
- DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+ DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is\r
elapsed.\r
\r
Arguments:\r
\r
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
TimeoutInMicroSeconds - The time to wait for\r
- \r
+\r
Returns:\r
\r
EFI_STATUS\r
\r
Routine Description:\r
\r
- Check whether DRQ is ready in the Alternate Status Register. \r
+ Check whether DRQ is ready in the Alternate Status Register.\r
(BSY must also be cleared)\r
If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
- DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+ DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is\r
elapsed.\r
\r
Arguments:\r
\r
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
TimeoutInMicroSeconds - The time to wait for\r
- \r
+\r
Returns:\r
\r
EFI_STATUS\r
\r
Check whether BSY is clear in the Status Register.\r
If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
- BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+ BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is\r
elapsed.\r
\r
Arguments:\r
\r
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
TimeoutInMicroSeconds - The time to wait for\r
- \r
+\r
Returns:\r
\r
EFI_STATUS\r
\r
Check whether BSY is clear in the Alternate Status Register.\r
If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
- BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+ BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is\r
elapsed.\r
\r
Arguments:\r
\r
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
TimeoutInMicroSeconds - The time to wait for\r
- \r
+\r
Returns:\r
\r
EFI_STATUS\r
\r
Routine Description:\r
\r
- Check whether DRDY is ready in the Status Register. \r
+ Check whether DRDY is ready in the Status Register.\r
(BSY must also be cleared)\r
If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
- DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+ DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is\r
elapsed.\r
\r
Arguments:\r
\r
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
TimeoutInMicroSeconds - The time to wait for\r
- \r
+\r
Returns:\r
\r
EFI_STATUS\r
\r
Routine Description:\r
\r
- Check whether DRDY is ready in the Alternate Status Register. \r
+ Check whether DRDY is ready in the Alternate Status Register.\r
(BSY must also be cleared)\r
If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
- DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+ DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is\r
elapsed.\r
\r
Arguments:\r
\r
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
TimeoutInMicroSeconds - The time to wait for\r
- \r
+\r
Returns:\r
\r
EFI_STATUS\r
AtapiPassThruCheckErrorStatus (\r
ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate\r
)\r
-/*++ \r
+/*++\r
\r
Routine Description:\r
\r
- Check Error Register for Error Information. \r
- \r
+ Check Error Register for Error Information.\r
+\r
Arguments:\r
\r
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
- \r
+\r
Returns:\r
\r
EFI_STATUS\r
\r
\r
/**\r
- Installs Scsi Pass Thru and/or Ext Scsi Pass Thru \r
- protocols based on feature flags. \r
+ Installs Scsi Pass Thru and/or Ext Scsi Pass Thru\r
+ protocols based on feature flags.\r
\r
- @param Controller The controller handle to \r
+ @param Controller The controller handle to\r
install these protocols on.\r
@param AtapiScsiPrivate A pointer to the protocol private\r
data structure.\r
\r
- @retval EFI_SUCCESS The installation succeeds. \r
- @retval other The installation fails. \r
- \r
+ @retval EFI_SUCCESS The installation succeeds.\r
+ @retval other The installation fails.\r
+\r
**/\r
EFI_STATUS\r
InstallScsiPassThruProtocols (\r
//\r
// This driver must support either ScsiPassThru or\r
// ExtScsiPassThru protocols\r
- // \r
+ //\r
ASSERT (FALSE);\r
Status = EFI_UNSUPPORTED;\r
}\r
);\r
ASSERT_EFI_ERROR (Status);\r
\r
+ //\r
+ // Install EFI Driver Supported EFI Version Protocol required for\r
+ // EFI drivers that are on PCI and other plug in cards.\r
+ //\r
+ gAtapiScsiPassThruDriverSupportedEfiVersion.FirmwareVersion = PcdGet32 (PcdDriverSupportedEfiVersion);\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &ImageHandle,\r
+ &gEfiDriverSupportedEfiVersionProtocolGuid,\r
+ &gAtapiScsiPassThruDriverSupportedEfiVersion,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
return Status;\r
}\r