X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=OptionRomPkg%2FAtapiPassThruDxe%2FAtapiPassThru.c;h=e6e2b36809d009ca24a424f296c04e7cf3bb2b33;hb=118f1657b9c6c338c25ef81e6c30ece392138673;hp=f3288eb4ecaeb248dbb1401278583172011885c2;hpb=bc14bdb317105f282ca5e6543e97ae545dd681df;p=mirror_edk2.git diff --git a/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c b/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c index f3288eb4ec..e6e2b36809 100644 --- a/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c +++ b/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2006, Intel Corporation - All rights reserved. This program and the accompanying materials + 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 @@ -13,12 +13,12 @@ #include "AtapiPassThru.h" -static SCSI_COMMAND_SET gEndTable = { 0xff, (DATA_DIRECTION) 0xff }; +SCSI_COMMAND_SET gEndTable = { 0xff, (DATA_DIRECTION) 0xff }; /// /// This table contains all the supported ATAPI commands. /// -static SCSI_COMMAND_SET gSupportedATAPICommands[] = { +SCSI_COMMAND_SET gSupportedATAPICommands[] = { { OP_INQUIRY, DataIn }, { OP_LOAD_UNLOAD_CD, NoData }, { OP_MECHANISM_STATUS, DataIn }, @@ -300,7 +300,7 @@ AtapiScsiPassThruDriverBindingStop ( Routine Description: - Stop this driver on ControllerHandle. Support stoping any child handles + Stop this driver on ControllerHandle. Support stopping any child handles created by this driver. Arguments: @@ -822,7 +822,7 @@ Returns: // // disable Interrupt // - DeviceControlValue |= bit (1); + DeviceControlValue |= BIT1; WritePortB ( AtapiScsiPrivate->PciIo, AtapiScsiPrivate->IoPort->Alt.DeviceControl, @@ -922,7 +922,7 @@ Returns: // // bit7 and bit5 are both set to 1 for backward compatibility // - DeviceSelect = (UINT8) (((bit (7) | bit (5)) | (Target << 4))); + DeviceSelect = (UINT8) (((BIT7 | BIT5) | (Target << 4))); WritePortB (AtapiScsiPrivate->PciIo, AtapiScsiPrivate->IoPort->Head, DeviceSelect); Command = ATAPI_SOFT_RESET_CMD; @@ -1336,7 +1336,7 @@ Returns: // // disable Interrupt // - DeviceControlValue |= bit (1); + DeviceControlValue |= BIT1; WritePortB ( AtapiScsiPrivate->PciIo, AtapiScsiPrivate->IoPort->Alt.DeviceControl, @@ -1438,7 +1438,7 @@ Returns: // // bit7 and bit5 are both set to 1 for backward compatibility // - DeviceSelect = (UINT8) (((bit (7) | bit (5)) | (TargetId << 4))); + DeviceSelect = (UINT8) ((BIT7 | BIT5) | (TargetId << 4)); WritePortB (AtapiScsiPrivate->PciIo, AtapiScsiPrivate->IoPort->Head, DeviceSelect); Command = ATAPI_SOFT_RESET_CMD; @@ -1749,10 +1749,12 @@ Returns: { UINT8 Index; UINT8 *OpCode; + UINT8 ArrayLen; OpCode = (UINT8 *) (Packet->Cdb); + ArrayLen = (UINT8) (ARRAY_SIZE (gSupportedATAPICommands)); - for (Index = 0; CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof (SCSI_COMMAND_SET)); Index++) { + for (Index = 0; (Index < ArrayLen) && (CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof (SCSI_COMMAND_SET)) != 0); Index++) { if (*OpCode == gSupportedATAPICommands[Index].OpCode) { // @@ -1883,11 +1885,11 @@ RequestSenseCommand ( Routine Description: - Sumbit request sense command + Submit request sense command Arguments: - AtapiScsiPrivate - The pionter of ATAPI_SCSI_PASS_THRU_DEV + AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV Target - The target ID Timeout - The time to complete the command SenseData - The buffer to fill in sense data @@ -1990,10 +1992,12 @@ Returns: { UINT8 Index; UINT8 *OpCode; + UINT8 ArrayLen; OpCode = (UINT8 *) (Packet->Cdb); + ArrayLen = (UINT8) (ARRAY_SIZE (gSupportedATAPICommands)); - for (Index = 0; CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof (SCSI_COMMAND_SET)); Index++) { + for (Index = 0; (Index < ArrayLen) && (CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof (SCSI_COMMAND_SET)) != 0); Index++) { if (*OpCode == gSupportedATAPICommands[Index].OpCode) { //