diff options
author | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-11-28 03:55:36 +0000 |
---|---|---|
committer | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-11-28 03:55:36 +0000 |
commit | 6a6d955c5f670141344c614c65dbea332f393b57 (patch) | |
tree | 80cb86cc7d44521d19279bb917146363376f67f1 /OptionRomPkg | |
parent | ac4f8b5abe6758183102be3feea30c7430eedf3a (diff) | |
download | edk2-platforms-6a6d955c5f670141344c614c65dbea332f393b57.tar.xz |
Fixed potential issues to release resources when error occurs.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4341 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OptionRomPkg')
-rw-r--r-- | OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c | 457 | ||||
-rw-r--r-- | OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c | 24 |
2 files changed, 245 insertions, 236 deletions
diff --git a/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c b/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c index 482933dc1b..ac12be4ee0 100644 --- a/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c +++ b/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c @@ -73,7 +73,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_SCSI_PASS_THRU_PROTOCOL gScsiPassThruProtocolT };
GLOBAL_REMOVE_IF_UNREFERENCED EFI_EXT_SCSI_PASS_THRU_MODE gExtScsiPassThruMode = {
- 4,
+ 4,
EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL | EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL,
0
};
@@ -106,20 +106,20 @@ AtapiScsiPassThruDriverBindingSupported ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
-
+
Routine Description:
Test to see if this driver supports ControllerHandle. Any ControllerHandle
that has gEfiPciIoProtocolGuid installed and is IDE Controller it will be supported.
-
+
Arguments:
This - Protocol instance pointer.
Controller - Handle of device to test
RemainingDevicePath - Not used
-
+
Returns:
EFI_STATUS
-
+
--*/
{
EFI_STATUS Status;
@@ -186,26 +186,27 @@ AtapiScsiPassThruDriverBindingStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
-
+
Routine Description:
Create handles for IDE channels specified by RemainingDevicePath.
Install SCSI Pass Thru Protocol onto each created handle.
-
+
Arguments:
This - Protocol instance pointer.
Controller - Handle of device to test
RemainingDevicePath - Not used
-
+
Returns:
EFI_STATUS
-
+
--*/
{
EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo;
UINT64 Supports;
UINT64 OriginalPciAttributes;
+ BOOLEAN PciAttributesSaved;
PciIo = NULL;
Status = gBS->OpenProtocol (
@@ -220,6 +221,7 @@ Returns: return Status;
}
+ PciAttributesSaved = FALSE;
//
// Save original PCI attributes
//
@@ -231,8 +233,9 @@ Returns: );
if (EFI_ERROR (Status)) {
- return Status;
+ goto Done;
}
+ PciAttributesSaved = TRUE;
Status = PciIo->Attributes (
PciIo,
@@ -262,15 +265,17 @@ Returns: Done:
if (EFI_ERROR (Status)) {
- //
- // Restore original PCI attributes
- //
- PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationSet,
- OriginalPciAttributes,
- NULL
- );
+ if (PciAttributesSaved == TRUE) {
+ //
+ // Restore original PCI attributes
+ //
+ PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationSet,
+ OriginalPciAttributes,
+ NULL
+ );
+ }
gBS->CloseProtocol (
Controller,
@@ -292,7 +297,7 @@ AtapiScsiPassThruDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer
)
/*++
-
+
Routine Description:
Stop this driver on ControllerHandle. Support stoping any child handles
@@ -304,11 +309,11 @@ Arguments: Controller - Handle of device to stop driver on
NumberOfChildren - Number of Children in the ChildHandleBuffer
ChildHandleBuffer - List of handles for the children we need to stop.
-
+
Returns:
EFI_STATUS
-
+
--*/
{
EFI_STATUS Status;
@@ -400,15 +405,15 @@ RegisterAtapiScsiPassThru ( IN UINT64 OriginalPciAttributes
)
/*++
-
+
Routine Description:
Attaches SCSI Pass Thru Protocol for specified IDE channel.
-
+
Arguments:
This - Protocol instance pointer.
- Controller - Parent device handle to the IDE channel.
- PciIo - PCI I/O protocol attached on the "Controller".
-
+ Controller - Parent device handle to the IDE channel.
+ PciIo - PCI I/O protocol attached on the "Controller".
+
Returns:
Always return EFI_SUCCESS unless installing SCSI Pass Thru Protocol failed.
@@ -472,25 +477,25 @@ Routine Description: Arguments:
This: The EFI_SCSI_PASS_THRU_PROTOCOL instance.
- Target: The Target ID of the ATAPI device to send the SCSI
+ Target: The Target ID of the ATAPI device to send the SCSI
Request Packet. To ATAPI devices attached on an IDE
Channel, Target ID 0 indicates Master device;Target
ID 1 indicates Slave device.
Lun: The LUN of the ATAPI device to send the SCSI Request
Packet. To the ATAPI device, Lun is always 0.
- Packet: The SCSI Request Packet to send to the ATAPI device
+ Packet: The SCSI Request Packet to send to the ATAPI device
specified by Target and Lun.
- Event: If non-blocking I/O is not supported then Event is ignored,
+ Event: If non-blocking I/O is not supported then Event is ignored,
and blocking I/O is performed.
If Event is NULL, then blocking I/O is performed.
- If Event is not NULL and non blocking I/O is supported,
- then non-blocking I/O is performed, and Event will be signaled
- when the SCSI Request Packet completes.
+ If Event is not NULL and non blocking I/O is supported,
+ then non-blocking I/O is performed, and Event will be signaled
+ when the SCSI Request Packet completes.
-Returns:
+Returns:
EFI_STATUS
-
+
--*/
{
ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;
@@ -504,7 +509,7 @@ Returns: if ((Target > MAX_TARGET_ID) || (Lun != 0)) {
return EFI_INVALID_PARAMETER;
}
-
+
//
// check the data fields in Packet parameter.
//
@@ -556,25 +561,25 @@ AtapiScsiPassThruGetNextDevice ( Routine Description:
- Used to retrieve the list of legal Target IDs for SCSI devices
+ Used to retrieve the list of legal Target IDs for SCSI devices
on a SCSI channel.
Arguments:
This - Protocol instance pointer.
- Target - On input, a pointer to the Target ID of a SCSI
- device present on the SCSI channel. On output,
+ Target - On input, a pointer to the Target ID of a SCSI
+ device present on the SCSI channel. On output,
a pointer to the Target ID of the next SCSI device
- present on a SCSI channel. An input value of
- 0xFFFFFFFF retrieves the Target ID of the first
+ present on a SCSI channel. An input value of
+ 0xFFFFFFFF retrieves the Target ID of the first
SCSI device present on a SCSI channel.
Lun - On input, a pointer to the LUN of a SCSI device
present on the SCSI channel. On output, a pointer
- to the LUN of the next SCSI device present on
+ to the LUN of the next SCSI device present on
a SCSI channel.
Returns:
- EFI_SUCCESS - The Target ID and Lun of the next SCSI device
+ EFI_SUCCESS - The Target ID and Lun of the next SCSI device
on the SCSI channel was returned in Target and Lun.
EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
@@ -635,7 +640,7 @@ AtapiScsiPassThruBuildDevicePath ( Routine Description:
- Used to allocate and build a device path node for a SCSI device
+ Used to allocate and build a device path node for a SCSI device
on a SCSI channel. Would not build device path for a SCSI Host Controller.
Arguments:
@@ -643,23 +648,23 @@ Arguments: This - Protocol instance pointer.
Target - The Target ID of the SCSI device for which
a device path node is to be allocated and built.
- Lun - The LUN of the SCSI device for which a device
+ Lun - The LUN of the SCSI device for which a device
path node is to be allocated and built.
- DevicePath - A pointer to a single device path node that
- describes the SCSI device specified by
- Target and Lun. This function is responsible
+ DevicePath - A pointer to a single device path node that
+ describes the SCSI device specified by
+ Target and Lun. This function is responsible
for allocating the buffer DevicePath with the boot
- service AllocatePool(). It is the caller's
+ service AllocatePool(). It is the caller's
responsibility to free DevicePath when the caller
- is finished with DevicePath.
+ is finished with DevicePath.
Returns:
EFI_SUCCESS - The device path node that describes the SCSI device
- specified by Target and Lun was allocated and
+ specified by Target and Lun was allocated and
returned in DevicePath.
EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
not exist on the SCSI channel.
EFI_INVALID_PARAMETER - DevicePath is NULL.
- EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
+ EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
DevicePath.
--*/
{
@@ -716,21 +721,21 @@ Routine Description: Arguments:
This - Protocol instance pointer.
- DevicePath - A pointer to the device path node that
+ DevicePath - A pointer to the device path node that
describes a SCSI device on the SCSI channel.
- Target - A pointer to the Target ID of a SCSI device
- on the SCSI channel.
- Lun - A pointer to the LUN of a SCSI device on
- the SCSI channel.
+ Target - A pointer to the Target ID of a SCSI device
+ on the SCSI channel.
+ Lun - A pointer to the LUN of a SCSI device on
+ the SCSI channel.
Returns:
- EFI_SUCCESS - DevicePath was successfully translated to a
- Target ID and LUN, and they were returned
+ EFI_SUCCESS - DevicePath was successfully translated to a
+ Target ID and LUN, and they were returned
in Target and Lun.
EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.
- EFI_UNSUPPORTED - This driver does not support the device path
+ EFI_UNSUPPORTED - This driver does not support the device path
node type in DevicePath.
- EFI_NOT_FOUND - A valid translation from DevicePath to a
+ EFI_NOT_FOUND - A valid translation from DevicePath to a
Target ID and LUN does not exist.
--*/
{
@@ -773,7 +778,7 @@ AtapiScsiPassThruResetChannel ( Routine Description:
- Resets a SCSI channel.This operation resets all the
+ Resets a SCSI channel.This operation resets all the
SCSI devices connected to the SCSI channel.
Arguments:
@@ -783,11 +788,11 @@ Arguments: Returns:
EFI_SUCCESS - The SCSI channel was reset.
- EFI_UNSUPPORTED - The SCSI channel does not support
+ EFI_UNSUPPORTED - The SCSI channel does not support
a channel reset operation.
- EFI_DEVICE_ERROR - A device error occurred while
+ EFI_DEVICE_ERROR - A device error occurred while
attempting to reset the SCSI channel.
- EFI_TIMEOUT - A timeout occurred while attempting
+ EFI_TIMEOUT - A timeout occurred while attempting
to reset the SCSI channel.
--*/
{
@@ -868,20 +873,20 @@ Routine Description: Arguments:
This - Protocol instance pointer.
- Target - The Target ID of the SCSI device to reset.
+ Target - The Target ID of the SCSI device to reset.
Lun - The LUN of the SCSI device to reset.
-
+
Returns:
- EFI_SUCCESS - The SCSI device specified by Target and
+ EFI_SUCCESS - The SCSI device specified by Target and
Lun was reset.
EFI_UNSUPPORTED - The SCSI channel does not support a target
reset operation.
EFI_INVALID_PARAMETER - Target or Lun are invalid.
- EFI_DEVICE_ERROR - A device error occurred while attempting
- to reset the SCSI device specified by Target
+ EFI_DEVICE_ERROR - A device error occurred while attempting
+ to reset the SCSI device specified by Target
and Lun.
- EFI_TIMEOUT - A timeout occurred while attempting to reset
+ EFI_TIMEOUT - A timeout occurred while attempting to reset
the SCSI device specified by Target and Lun.
--*/
{
@@ -958,45 +963,45 @@ Routine Description: Arguments:
This: The EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
- Target: The Target ID of the ATAPI device to send the SCSI
+ Target: The Target ID of the ATAPI device to send the SCSI
Request Packet. To ATAPI devices attached on an IDE
Channel, Target ID 0 indicates Master device;Target
ID 1 indicates Slave device.
Lun: The LUN of the ATAPI device to send the SCSI Request
Packet. To the ATAPI device, Lun is always 0.
- Packet: The SCSI Request Packet to send to the ATAPI device
+ Packet: The SCSI Request Packet to send to the ATAPI device
specified by Target and Lun.
- Event: If non-blocking I/O is not supported then Event is ignored,
+ Event: If non-blocking I/O is not supported then Event is ignored,
and blocking I/O is performed.
If Event is NULL, then blocking I/O is performed.
- If Event is not NULL and non blocking I/O is supported,
- then non-blocking I/O is performed, and Event will be signaled
- when the SCSI Request Packet completes.
+ If Event is not NULL and non blocking I/O is supported,
+ then non-blocking I/O is performed, and Event will be signaled
+ when the SCSI Request Packet completes.
-Returns:
+Returns:
EFI_STATUS
-
+
--*/
{
EFI_STATUS Status;
ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;
UINT8 TargetId;
-
+
AtapiScsiPrivate = ATAPI_EXT_SCSI_PASS_THRU_DEV_FROM_THIS (This);
//
// For ATAPI device, UINT8 is enough to represent the SCSI ID on channel.
//
TargetId = Target[0];
-
+
//
// Target is not allowed beyond MAX_TARGET_ID
//
if ((TargetId > MAX_TARGET_ID) || (Lun != 0)) {
return EFI_INVALID_PARAMETER;
}
-
+
//
// check the data fields in Packet parameter.
//
@@ -1013,7 +1018,7 @@ Returns: Packet->InTransferLength = Packet->OutTransferLength = 0;
return EFI_SUCCESS;
}
-
+
//
// According to Target ID, reset the Atapi I/O Register mapping
// (Target Id in [0,1] area, using AtapiIoPortRegisters[0],
@@ -1026,7 +1031,7 @@ Returns: TargetId = (UINT8) (TargetId % 2);
AtapiScsiPrivate->IoPort = &AtapiScsiPrivate->AtapiIoPortRegisters[1];
}
-
+
//
// the ATAPI SCSI interface does not support non-blocking I/O
// ignore the Event parameter
@@ -1048,25 +1053,25 @@ AtapiExtScsiPassThruGetNextTargetLun ( Routine Description:
- Used to retrieve the list of legal Target IDs for SCSI devices
+ Used to retrieve the list of legal Target IDs for SCSI devices
on a SCSI channel.
Arguments:
This - Protocol instance pointer.
- Target - On input, a pointer to the Target ID of a SCSI
- device present on the SCSI channel. On output,
+ Target - On input, a pointer to the Target ID of a SCSI
+ device present on the SCSI channel. On output,
a pointer to the Target ID of the next SCSI device
- present on a SCSI channel. An input value of
- 0xFFFFFFFF retrieves the Target ID of the first
+ present on a SCSI channel. An input value of
+ 0xFFFFFFFF retrieves the Target ID of the first
SCSI device present on a SCSI channel.
Lun - On input, a pointer to the LUN of a SCSI device
present on the SCSI channel. On output, a pointer
- to the LUN of the next SCSI device present on
+ to the LUN of the next SCSI device present on
a SCSI channel.
Returns:
- EFI_SUCCESS - The Target ID and Lun of the next SCSI device
+ EFI_SUCCESS - The Target ID and Lun of the next SCSI device
on the SCSI channel was returned in Target and Lun.
EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
@@ -1076,7 +1081,7 @@ Returns: UINT8 ByteIndex;
UINT8 TargetId;
UINT8 ScsiId[TARGET_MAX_BYTES];
- ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;
+ ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;
//
// Retrieve Device Private Data Structure.
@@ -1102,9 +1107,9 @@ Returns: if ((*Target)[ByteIndex] != 0) {
return EFI_INVALID_PARAMETER;
}
- }
+ }
}
-
+
if ((CompareMem(*Target, ScsiId, TARGET_MAX_BYTES) != 0) &&
((TargetId != AtapiScsiPrivate->LatestTargetId) ||
(*Lun != AtapiScsiPrivate->LatestLun))) {
@@ -1145,7 +1150,7 @@ AtapiExtScsiPassThruBuildDevicePath ( Routine Description:
- Used to allocate and build a device path node for a SCSI device
+ Used to allocate and build a device path node for a SCSI device
on a SCSI channel. Would not build device path for a SCSI Host Controller.
Arguments:
@@ -1153,39 +1158,39 @@ Arguments: This - Protocol instance pointer.
Target - The Target ID of the SCSI device for which
a device path node is to be allocated and built.
- Lun - The LUN of the SCSI device for which a device
+ Lun - The LUN of the SCSI device for which a device
path node is to be allocated and built.
- DevicePath - A pointer to a single device path node that
- describes the SCSI device specified by
- Target and Lun. This function is responsible
+ DevicePath - A pointer to a single device path node that
+ describes the SCSI device specified by
+ Target and Lun. This function is responsible
for allocating the buffer DevicePath with the boot
- service AllocatePool(). It is the caller's
+ service AllocatePool(). It is the caller's
responsibility to free DevicePath when the caller
- is finished with DevicePath.
+ is finished with DevicePath.
Returns:
EFI_SUCCESS - The device path node that describes the SCSI device
- specified by Target and Lun was allocated and
+ specified by Target and Lun was allocated and
returned in DevicePath.
EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
not exist on the SCSI channel.
EFI_INVALID_PARAMETER - DevicePath is NULL.
- EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
+ EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
DevicePath.
--*/
{
EFI_DEV_PATH *Node;
UINT8 TargetId;
- TargetId = Target[0];
+ TargetId = Target[0];
//
// Validate parameters passed in.
//
-
+
if (DevicePath == NULL) {
return EFI_INVALID_PARAMETER;
}
-
+
//
// can not build device path for the SCSI Host Controller.
//
@@ -1228,21 +1233,21 @@ Routine Description: Arguments:
This - Protocol instance pointer.
- DevicePath - A pointer to the device path node that
+ DevicePath - A pointer to the device path node that
describes a SCSI device on the SCSI channel.
- Target - A pointer to the Target ID of a SCSI device
- on the SCSI channel.
- Lun - A pointer to the LUN of a SCSI device on
- the SCSI channel.
+ Target - A pointer to the Target ID of a SCSI device
+ on the SCSI channel.
+ Lun - A pointer to the LUN of a SCSI device on
+ the SCSI channel.
Returns:
- EFI_SUCCESS - DevicePath was successfully translated to a
- Target ID and LUN, and they were returned
+ EFI_SUCCESS - DevicePath was successfully translated to a
+ Target ID and LUN, and they were returned
in Target and Lun.
EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.
- EFI_UNSUPPORTED - This driver does not support the device path
+ EFI_UNSUPPORTED - This driver does not support the device path
node type in DevicePath.
- EFI_NOT_FOUND - A valid translation from DevicePath to a
+ EFI_NOT_FOUND - A valid translation from DevicePath to a
Target ID and LUN does not exist.
--*/
{
@@ -1254,7 +1259,7 @@ Returns: if (DevicePath == NULL || Target == NULL || Lun == NULL) {
return EFI_INVALID_PARAMETER;
}
-
+
//
// Check whether the DevicePath belongs to SCSI_DEVICE_PATH
//
@@ -1287,7 +1292,7 @@ AtapiExtScsiPassThruResetChannel ( Routine Description:
- Resets a SCSI channel.This operation resets all the
+ Resets a SCSI channel.This operation resets all the
SCSI devices connected to the SCSI channel.
Arguments:
@@ -1297,11 +1302,11 @@ Arguments: Returns:
EFI_SUCCESS - The SCSI channel was reset.
- EFI_UNSUPPORTED - The SCSI channel does not support
+ EFI_UNSUPPORTED - The SCSI channel does not support
a channel reset operation.
- EFI_DEVICE_ERROR - A device error occurred while
+ EFI_DEVICE_ERROR - A device error occurred while
attempting to reset the SCSI channel.
- EFI_TIMEOUT - A timeout occurred while attempting
+ EFI_TIMEOUT - A timeout occurred while attempting
to reset the SCSI channel.
--*/
{
@@ -1348,7 +1353,7 @@ Returns: // 0xfb:1111,1011
//
DeviceControlValue &= 0xfb;
-
+
WritePortB (AtapiScsiPrivate->PciIo, AtapiScsiPrivate->IoPort->Alt.DeviceControl, DeviceControlValue);
//
@@ -1362,7 +1367,7 @@ Returns: if (ResetFlag) {
return EFI_SUCCESS;
}
-
+
return EFI_TIMEOUT;
}
@@ -1382,20 +1387,20 @@ Routine Description: Arguments:
This - Protocol instance pointer.
- Target - The Target ID of the SCSI device to reset.
+ Target - The Target ID of the SCSI device to reset.
Lun - The LUN of the SCSI device to reset.
-
+
Returns:
- EFI_SUCCESS - The SCSI device specified by Target and
+ EFI_SUCCESS - The SCSI device specified by Target and
Lun was reset.
EFI_UNSUPPORTED - The SCSI channel does not support a target
reset operation.
EFI_INVALID_PARAMETER - Target or Lun are invalid.
- EFI_DEVICE_ERROR - A device error occurred while attempting
- to reset the SCSI device specified by Target
+ EFI_DEVICE_ERROR - A device error occurred while attempting
+ to reset the SCSI device specified by Target
and Lun.
- EFI_TIMEOUT - A timeout occurred while attempting to reset
+ EFI_TIMEOUT - A timeout occurred while attempting to reset
the SCSI device specified by Target and Lun.
--*/
{
@@ -1403,10 +1408,10 @@ Returns: UINT8 DeviceSelect;
UINT8 TargetId;
ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;
-
+
AtapiScsiPrivate = ATAPI_EXT_SCSI_PASS_THRU_DEV_FROM_THIS (This);
TargetId = Target[0];
-
+
if ((TargetId > MAX_TARGET_ID) || (Lun != 0)) {
return EFI_INVALID_PARAMETER;
}
@@ -1416,7 +1421,7 @@ Returns: if (TargetId == This->Mode->AdapterId) {
return EFI_SUCCESS;
}
-
+
//
// According to Target ID, reset the Atapi I/O Register mapping
// (Target Id in [0,1] area, using AtapiIoPortRegisters[0],
@@ -1427,7 +1432,7 @@ Returns: } else {
AtapiScsiPrivate->IoPort = &AtapiScsiPrivate->AtapiIoPortRegisters[1];
}
-
+
//
// for ATAPI device, no need to wait DRDY ready after device selecting.
//
@@ -1447,7 +1452,7 @@ Returns: if (EFI_ERROR (StatusWaitForBSYClear (AtapiScsiPrivate, 31000000))) {
return EFI_TIMEOUT;
}
-
+
//
// stall 5 seconds to make the device status stable
//
@@ -1466,24 +1471,24 @@ AtapiExtScsiPassThruGetNextTarget ( /*++
Routine Description:
- Used to retrieve the list of legal Target IDs for SCSI devices
+ Used to retrieve the list of legal Target IDs for SCSI devices
on a SCSI channel.
Arguments:
This - Protocol instance pointer.
- Target - On input, a pointer to the Target ID of a SCSI
- device present on the SCSI channel. On output,
+ Target - On input, a pointer to the Target ID of a SCSI
+ device present on the SCSI channel. On output,
a pointer to the Target ID of the next SCSI device
- present on a SCSI channel. An input value of
- 0xFFFFFFFF retrieves the Target ID of the first
+ present on a SCSI channel. An input value of
+ 0xFFFFFFFF retrieves the Target ID of the first
SCSI device present on a SCSI channel.
Lun - On input, a pointer to the LUN of a SCSI device
present on the SCSI channel. On output, a pointer
- to the LUN of the next SCSI device present on
+ to the LUN of the next SCSI device present on
a SCSI channel.
-
+
Returns:
- EFI_SUCCESS - The Target ID and Lun of the next SCSI device
+ EFI_SUCCESS - The Target ID and Lun of the next SCSI device
on the SCSI channel was returned in Target and Lun.
EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
@@ -1492,7 +1497,7 @@ Returns: {
UINT8 TargetId;
UINT8 ScsiId[TARGET_MAX_BYTES];
- ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;
+ ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;
UINT8 ByteIndex;
//
@@ -1725,16 +1730,16 @@ IsCommandValid ( EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
)
/*++
-
+
Routine Description:
- Checks the requested SCSI command:
+ Checks the requested SCSI command:
Is it supported by this driver?
Is the Data transfer direction reasonable?
Arguments:
- Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
+ Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
Returns:
@@ -1791,19 +1796,19 @@ SubmitBlockingIoCommand ( Routine Description:
Performs blocking I/O request.
-
+
Arguments:
AtapiScsiPrivate: Private data structure for the specified channel.
- Target: The Target ID of the ATAPI device to send the SCSI
+ Target: The Target ID of the ATAPI device to send the SCSI
Request Packet. To ATAPI devices attached on an IDE
Channel, Target ID 0 indicates Master device;Target
ID 1 indicates Slave device.
- Packet: The SCSI Request Packet to send to the ATAPI device
+ Packet: The SCSI Request Packet to send to the ATAPI device
specified by Target.
-
- Returns: EFI_STATUS
-
+
+ Returns: EFI_STATUS
+
--*/
{
UINT8 PacketCommand[12];
@@ -1891,7 +1896,7 @@ Arguments: Returns:
EFI_STATUS
-
+
--*/
{
EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET Packet;
@@ -1931,9 +1936,9 @@ Routine Description: Arguments:
Packet - The pointer of EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
-
+
Returns:
-
+
EFI_STATUS
--*/
@@ -1949,7 +1954,7 @@ Returns: if (Packet->Cdb == NULL) {
return EFI_INVALID_PARAMETER;
}
-
+
//
// Checks whether the request command is supported.
//
@@ -1966,16 +1971,16 @@ IsExtCommandValid ( EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
)
/*++
-
+
Routine Description:
- Checks the requested SCSI command:
+ Checks the requested SCSI command:
Is it supported by this driver?
Is the Data transfer direction reasonable?
Arguments:
- Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
+ Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
Returns:
@@ -2032,19 +2037,19 @@ SubmitExtBlockingIoCommand ( Routine Description:
Performs blocking I/O request.
-
+
Arguments:
AtapiScsiPrivate: Private data structure for the specified channel.
- Target: The Target ID of the ATAPI device to send the SCSI
+ Target: The Target ID of the ATAPI device to send the SCSI
Request Packet. To ATAPI devices attached on an IDE
Channel, Target ID 0 indicates Master device;Target
ID 1 indicates Slave device.
- Packet: The SCSI Request Packet to send to the ATAPI device
+ Packet: The SCSI Request Packet to send to the ATAPI device
specified by Target.
-
- Returns: EFI_STATUS
-
+
+ Returns: EFI_STATUS
+
--*/
{
UINT8 PacketCommand[12];
@@ -2087,12 +2092,12 @@ Arguments: TimeoutInMicroSeconds
);
}
-
+
if (!EFI_ERROR (PacketCommandStatus) || (Packet->SenseData == NULL)) {
Packet->SenseDataLength = 0;
return PacketCommandStatus;
}
-
+
//
// Return SenseData if PacketCommandStatus matches
// the following return codes.
@@ -2137,11 +2142,11 @@ AtapiPacketCommand ( Routine Description:
Submits ATAPI command packet to the specified ATAPI device.
-
+
Arguments:
AtapiScsiPrivate: Private data structure for the specified channel.
- Target: The Target ID of the ATAPI device to send the SCSI
+ Target: The Target ID of the ATAPI device to send the SCSI
Request Packet. To ATAPI devices attached on an IDE
Channel, Target ID 0 indicates Master device;Target
ID 1 indicates Slave device.
@@ -2149,22 +2154,22 @@ Arguments: Buffer: Points to the transferred data.
ByteCount: When input,indicates the buffer size; when output,
indicates the actually transferred data size.
- Direction: Indicates the data transfer direction.
+ Direction: Indicates the data transfer direction.
TimeoutInMicroSeconds:
- The timeout, in micro second units, to use for the
+ The timeout, in micro second units, to use for the
execution of this ATAPI command.
- A TimeoutInMicroSeconds value of 0 means that
- this function will wait indefinitely for the ATAPI
+ A TimeoutInMicroSeconds value of 0 means that
+ this function will wait indefinitely for the ATAPI
command to execute.
- If TimeoutInMicroSeconds is greater than zero, then
- this function will return EFI_TIMEOUT if the time
- required to execute the ATAPI command is greater
+ If TimeoutInMicroSeconds is greater than zero, then
+ this function will return EFI_TIMEOUT if the time
+ required to execute the ATAPI command is greater
than TimeoutInMicroSeconds.
-
+
Returns:
EFI_STATUS
-
+
--*/
{
@@ -2300,28 +2305,28 @@ Routine Description: Performs data transfer between ATAPI device and host after the
ATAPI command packet is sent.
-
+
Arguments:
- AtapiScsiPrivate: Private data structure for the specified channel.
+ AtapiScsiPrivate: Private data structure for the specified channel.
Buffer: Points to the transferred data.
ByteCount: When input,indicates the buffer size; when output,
indicates the actually transferred data size.
- Direction: Indicates the data transfer direction.
+ Direction: Indicates the data transfer direction.
TimeoutInMicroSeconds:
- The timeout, in micro second units, to use for the
+ The timeout, in micro second units, to use for the
execution of this ATAPI command.
- A TimeoutInMicroSeconds value of 0 means that
- this function will wait indefinitely for the ATAPI
+ A TimeoutInMicroSeconds value of 0 means that
+ this function will wait indefinitely for the ATAPI
command to execute.
- If TimeoutInMicroSeconds is greater than zero, then
- this function will return EFI_TIMEOUT if the time
- required to execute the ATAPI command is greater
+ If TimeoutInMicroSeconds is greater than zero, then
+ this function will return EFI_TIMEOUT if the time
+ required to execute the ATAPI command is greater
than TimeoutInMicroSeconds.
Returns:
EFI_STATUS
-
+
--*/
{
UINT32 Index;
@@ -2428,7 +2433,7 @@ Arguments: PciIo - The pointer of EFI_PCI_IO_PROTOCOL
Port - IO port
-
+
Returns:
A byte read out
@@ -2465,7 +2470,7 @@ Arguments: PciIo - The pointer of EFI_PCI_IO_PROTOCOL
Port - IO port
-
+
Returns:
A word read out
@@ -2503,7 +2508,7 @@ Arguments: PciIo - The pointer of EFI_PCI_IO_PROTOCOL
Port - IO port
Data - The data to write
-
+
Returns:
NONE
@@ -2538,11 +2543,11 @@ Arguments: PciIo - The pointer of EFI_PCI_IO_PROTOCOL
Port - IO port
Data - The data to write
-
+
Returns:
NONE
-
+
--*/
{
PciIo->Io.Write (
@@ -2566,18 +2571,18 @@ Routine Description: Check whether DRQ is clear in the Status Register. (BSY must also be cleared)
If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
- DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
+ DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
elapsed.
Arguments:
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
TimeoutInMicroSeconds - The time to wait for
-
+
Returns:
EFI_STATUS
-
+
--*/
{
UINT64 Delay;
@@ -2648,16 +2653,16 @@ AltStatusDRQClear ( Routine Description:
- Check whether DRQ is clear in the Alternate Status Register.
- (BSY must also be cleared).If TimeoutInMicroSeconds is zero, this routine should
- wait infinitely for DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
+ Check whether DRQ is clear in the Alternate Status Register.
+ (BSY must also be cleared).If TimeoutInMicroSeconds is zero, this routine should
+ wait infinitely for DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
elapsed.
Arguments:
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
TimeoutInMicroSeconds - The time to wait for
-
+
Returns:
EFI_STATUS
@@ -2732,14 +2737,14 @@ Routine Description: Check whether DRQ is ready in the Status Register. (BSY must also be cleared)
If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
- DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
+ DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
elapsed.
Arguments:
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
TimeoutInMicroSeconds - The time to wait for
-
+
Returns:
EFI_STATUS
@@ -2814,17 +2819,17 @@ AltStatusDRQReady ( Routine Description:
- Check whether DRQ is ready in the Alternate Status Register.
+ Check whether DRQ is ready in the Alternate Status Register.
(BSY must also be cleared)
If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
- DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
+ DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
elapsed.
Arguments:
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
TimeoutInMicroSeconds - The time to wait for
-
+
Returns:
EFI_STATUS
@@ -2900,14 +2905,14 @@ Routine Description: Check whether BSY is clear in the Status Register.
If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
- BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
+ BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
elapsed.
Arguments:
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
TimeoutInMicroSeconds - The time to wait for
-
+
Returns:
EFI_STATUS
@@ -2966,14 +2971,14 @@ Routine Description: Check whether BSY is clear in the Alternate Status Register.
If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
- BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
+ BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
elapsed.
Arguments:
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
TimeoutInMicroSeconds - The time to wait for
-
+
Returns:
EFI_STATUS
@@ -3029,17 +3034,17 @@ StatusDRDYReady ( Routine Description:
- Check whether DRDY is ready in the Status Register.
+ Check whether DRDY is ready in the Status Register.
(BSY must also be cleared)
If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
- DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
+ DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
elapsed.
Arguments:
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
TimeoutInMicroSeconds - The time to wait for
-
+
Returns:
EFI_STATUS
@@ -3109,17 +3114,17 @@ AltStatusDRDYReady ( Routine Description:
- Check whether DRDY is ready in the Alternate Status Register.
+ Check whether DRDY is ready in the Alternate Status Register.
(BSY must also be cleared)
If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
- DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
+ DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
elapsed.
Arguments:
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
TimeoutInMicroSeconds - The time to wait for
-
+
Returns:
EFI_STATUS
@@ -3184,16 +3189,16 @@ EFI_STATUS AtapiPassThruCheckErrorStatus (
ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate
)
-/*++
+/*++
Routine Description:
- Check Error Register for Error Information.
-
+ Check Error Register for Error Information.
+
Arguments:
AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
-
+
Returns:
EFI_STATUS
@@ -3291,17 +3296,17 @@ Returns: /**
- Installs Scsi Pass Thru and/or Ext Scsi Pass Thru
- protocols based on feature flags.
+ Installs Scsi Pass Thru and/or Ext Scsi Pass Thru
+ protocols based on feature flags.
- @param Controller The controller handle to
+ @param Controller The controller handle to
install these protocols on.
@param AtapiScsiPrivate A pointer to the protocol private
data structure.
- @retval EFI_SUCCESS The installation succeeds.
- @retval other The installation fails.
-
+ @retval EFI_SUCCESS The installation succeeds.
+ @retval other The installation fails.
+
**/
EFI_STATUS
InstallScsiPassThruProtocols (
@@ -3349,7 +3354,7 @@ InstallScsiPassThruProtocols ( //
// This driver must support either ScsiPassThru or
// ExtScsiPassThru protocols
- //
+ //
ASSERT (FALSE);
Status = EFI_UNSUPPORTED;
}
@@ -3391,7 +3396,7 @@ InitializeAtapiPassThru( ASSERT_EFI_ERROR (Status);
//
- // Install EFI Driver Supported EFI Version Protocol required for
+ // Install EFI Driver Supported EFI Version Protocol required for
// EFI drivers that are on PCI and other plug in cards.
//
gAtapiScsiPassThruDriverSupportedEfiVersion.FirmwareVersion = PcdGet32 (PcdDriverSupportedEfiVersion);
diff --git a/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c b/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c index eb5ce3b6fc..424e19df1e 100644 --- a/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c +++ b/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c @@ -211,7 +211,9 @@ CirrusLogic5430ControllerDriverStart ( {
EFI_STATUS Status;
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;
+ BOOLEAN PciAttributesSaved;
+ PciAttributesSaved = FALSE;
//
// Allocate Private context data for UGA Draw inteface.
//
@@ -255,6 +257,7 @@ CirrusLogic5430ControllerDriverStart ( if (EFI_ERROR (Status)) {
goto Error;
}
+ PciAttributesSaved = TRUE;
Status = Private->PciIo->Attributes (
Private->PciIo,
@@ -319,16 +322,17 @@ Error: if (EFI_ERROR (Status)) {
if (Private) {
if (Private->PciIo) {
- //
- // Restore original PCI attributes
- //
- Private->PciIo->Attributes (
- Private->PciIo,
- EfiPciIoAttributeOperationSet,
- Private->OriginalPciAttributes,
- NULL
- );
-
+ if (PciAttributesSaved == TRUE) {
+ //
+ // Restore original PCI attributes
+ //
+ Private->PciIo->Attributes (
+ Private->PciIo,
+ EfiPciIoAttributeOperationSet,
+ Private->OriginalPciAttributes,
+ NULL
+ );
+ }
//
// Close the PCI I/O Protocol
//
|