X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=OptionRomPkg%2FAtapiPassThruDxe%2FAtapiPassThru.c;h=3578a1e4459c97cd13bf167e53c39cb78714c783;hb=ea5396f31a8db7344177b4dd5335ebd617861d58;hp=ac12be4ee048aed5d5406620043e568f782d2a3c;hpb=6a6d955c5f670141344c614c65dbea332f393b57;p=mirror_edk2.git diff --git a/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c b/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c index ac12be4ee0..3578a1e445 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 }, @@ -163,7 +163,7 @@ Returns: return EFI_UNSUPPORTED; } - if (Pci.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE || Pci.Hdr.ClassCode[1] != PCI_CLASS_IDE) { + if (Pci.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE || Pci.Hdr.ClassCode[1] != PCI_CLASS_MASS_STORAGE_IDE) { Status = EFI_UNSUPPORTED; } @@ -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) (sizeof (gSupportedATAPICommands) / sizeof (gSupportedATAPICommands[0])); - 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) { // @@ -1990,10 +1992,12 @@ Returns: { UINT8 Index; UINT8 *OpCode; + UINT8 ArrayLen; OpCode = (UINT8 *) (Packet->Cdb); + ArrayLen = (UINT8) (sizeof (gSupportedATAPICommands) / sizeof (gSupportedATAPICommands[0])); - 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) { //