]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c
OptionRomPkg/AtapiPassThruDxe: rebase to ARRAY_SIZE()
[mirror_edk2.git] / OptionRomPkg / AtapiPassThruDxe / AtapiPassThru.c
index ac12be4ee048aed5d5406620043e568f782d2a3c..e2654e5c25662b8f373928154f0bfe7ae5fa7e6f 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
-  Copyright (c) 2006, Intel Corporation\r
-  All rights reserved. This program and the accompanying materials\r
+  Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+  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
 #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
@@ -163,7 +163,7 @@ Returns:
     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
@@ -822,7 +822,7 @@ Returns:
     //\r
     // disable Interrupt\r
     //\r
-    DeviceControlValue |= bit (1);\r
+    DeviceControlValue |= BIT1;\r
     WritePortB (\r
       AtapiScsiPrivate->PciIo,\r
       AtapiScsiPrivate->IoPort->Alt.DeviceControl,\r
@@ -922,7 +922,7 @@ Returns:
   //\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
@@ -1336,7 +1336,7 @@ Returns:
     //\r
     // disable Interrupt\r
     //\r
-    DeviceControlValue |= bit (1);\r
+    DeviceControlValue |= BIT1;\r
     WritePortB (\r
       AtapiScsiPrivate->PciIo,\r
       AtapiScsiPrivate->IoPort->Alt.DeviceControl,\r
@@ -1438,7 +1438,7 @@ Returns:
   //\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
@@ -1749,10 +1749,12 @@ Returns:
 {\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
@@ -1990,10 +1992,12 @@ Returns:
 {\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