]> git.proxmox.com Git - mirror_edk2.git/commitdiff
fix a invalid pointer conversion when builing 32bit image.
authorerictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 8 Mar 2011 01:32:34 +0000 (01:32 +0000)
committererictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 8 Mar 2011 01:32:34 +0000 (01:32 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11352 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c

index 40012d7978c8f8fea3eb246a30e26efe1f3a7bcb..8ba0201563478f68b945668cb9842d13bd9fbdd2 100644 (file)
@@ -1778,6 +1778,9 @@ AhciCreateTransferDescriptor (
   UINT64                MaxReceiveFisSize;\r
   UINT64                MaxCommandListSize;\r
   UINT64                MaxCommandTableSize;\r
+  EFI_PHYSICAL_ADDRESS  AhciRFisPciAddr;\r
+  EFI_PHYSICAL_ADDRESS  AhciCmdListPciAddr;\r
+  EFI_PHYSICAL_ADDRESS  AhciCommandTablePciAddr;\r
 \r
   Buffer = NULL;\r
   //\r
@@ -1796,7 +1799,7 @@ AhciCreateTransferDescriptor (
                     PciIo,\r
                     AllocateAnyPages,\r
                     EfiBootServicesData,\r
-                    (UINTN)EFI_SIZE_TO_PAGES (MaxReceiveFisSize),\r
+                    EFI_SIZE_TO_PAGES ((UINTN) MaxReceiveFisSize),\r
                     &Buffer,\r
                     0\r
                     );\r
@@ -1816,7 +1819,7 @@ AhciCreateTransferDescriptor (
                     EfiPciIoOperationBusMasterCommonBuffer,\r
                     Buffer,\r
                     &Bytes,\r
-                    (EFI_PHYSICAL_ADDRESS *) &AhciRegisters->AhciRFisPciAddr,\r
+                    &AhciRFisPciAddr,\r
                     &AhciRegisters->MapRFis\r
                     );\r
 \r
@@ -1828,13 +1831,14 @@ AhciCreateTransferDescriptor (
     goto Error6;\r
   }\r
 \r
-  if ((!Support64Bit) && ((EFI_PHYSICAL_ADDRESS)(UINTN)AhciRegisters->AhciRFisPciAddr > 0x100000000ULL)) {\r
+  if ((!Support64Bit) && (AhciRFisPciAddr > 0x100000000ULL)) {\r
     //\r
     // The AHCI HBA doesn't support 64bit addressing, so should not get a >4G pci bus master address.\r
     //\r
     Status = EFI_DEVICE_ERROR;\r
     goto Error5;\r
   }\r
+  AhciRegisters->AhciRFisPciAddr = (EFI_AHCI_RECEIVED_FIS *)(UINTN)AhciRFisPciAddr;\r
 \r
   //\r
   // Allocate memory for command list\r
@@ -1846,7 +1850,7 @@ AhciCreateTransferDescriptor (
                     PciIo,\r
                     AllocateAnyPages,\r
                     EfiBootServicesData,\r
-                    (UINTN)EFI_SIZE_TO_PAGES (MaxCommandListSize),\r
+                    EFI_SIZE_TO_PAGES ((UINTN) MaxCommandListSize),\r
                     &Buffer,\r
                     0\r
                     );\r
@@ -1870,7 +1874,7 @@ AhciCreateTransferDescriptor (
                     EfiPciIoOperationBusMasterCommonBuffer,\r
                     Buffer,\r
                     &Bytes,\r
-                    (EFI_PHYSICAL_ADDRESS *)&AhciRegisters->AhciCmdListPciAddr,\r
+                    &AhciCmdListPciAddr,\r
                     &AhciRegisters->MapCmdList\r
                     );\r
 \r
@@ -1882,13 +1886,14 @@ AhciCreateTransferDescriptor (
     goto Error4;\r
   }\r
 \r
-  if ((!Support64Bit) && ((EFI_PHYSICAL_ADDRESS)(UINTN)AhciRegisters->AhciCmdListPciAddr > 0x100000000ULL)) {\r
+  if ((!Support64Bit) && (AhciCmdListPciAddr > 0x100000000ULL)) {\r
     //\r
     // The AHCI HBA doesn't support 64bit addressing, so should not get a >4G pci bus master address.\r
     //\r
     Status = EFI_DEVICE_ERROR;\r
     goto Error3;\r
   }\r
+  AhciRegisters->AhciCmdListPciAddr = (EFI_AHCI_COMMAND_LIST *)(UINTN)AhciCmdListPciAddr;\r
 \r
   //\r
   // Allocate memory for command table\r
@@ -1901,7 +1906,7 @@ AhciCreateTransferDescriptor (
                     PciIo,\r
                     AllocateAnyPages,\r
                     EfiBootServicesData,\r
-                    (UINTN)EFI_SIZE_TO_PAGES (MaxCommandTableSize),\r
+                    EFI_SIZE_TO_PAGES ((UINTN) MaxCommandTableSize),\r
                     &Buffer,\r
                     0\r
                     );\r
@@ -1925,7 +1930,7 @@ AhciCreateTransferDescriptor (
                     EfiPciIoOperationBusMasterCommonBuffer,\r
                     Buffer,\r
                     &Bytes,\r
-                    (EFI_PHYSICAL_ADDRESS *)&AhciRegisters->AhciCommandTablePciAddr,\r
+                    &AhciCommandTablePciAddr,\r
                     &AhciRegisters->MapCommandTable\r
                     );\r
 \r
@@ -1937,13 +1942,14 @@ AhciCreateTransferDescriptor (
     goto Error2;\r
   }\r
 \r
-  if ((!Support64Bit) && ((EFI_PHYSICAL_ADDRESS)(UINTN)AhciRegisters->AhciCommandTablePciAddr > 0x100000000ULL)) {\r
+  if ((!Support64Bit) && (AhciCommandTablePciAddr > 0x100000000ULL)) {\r
     //\r
     // The AHCI HBA doesn't support 64bit addressing, so should not get a >4G pci bus master address.\r
     //\r
     Status = EFI_DEVICE_ERROR;\r
     goto Error1;\r
   }\r
+  AhciRegisters->AhciCommandTablePciAddr = (EFI_AHCI_COMMAND_TABLE *)(UINTN)AhciCommandTablePciAddr;\r
 \r
   return EFI_SUCCESS;\r
   //\r
@@ -1957,7 +1963,7 @@ Error1:
 Error2:\r
   PciIo->FreeBuffer (\r
            PciIo,\r
-           (UINTN)EFI_SIZE_TO_PAGES (MaxCommandTableSize),\r
+           EFI_SIZE_TO_PAGES ((UINTN) MaxCommandTableSize),\r
            AhciRegisters->AhciCommandTable\r
            );\r
 Error3:\r
@@ -1968,7 +1974,7 @@ Error3:
 Error4:\r
   PciIo->FreeBuffer (\r
            PciIo,\r
-           (UINTN)EFI_SIZE_TO_PAGES (MaxCommandListSize),\r
+           EFI_SIZE_TO_PAGES ((UINTN) MaxCommandListSize),\r
            AhciRegisters->AhciCmdList\r
            );\r
 Error5:\r
@@ -1979,7 +1985,7 @@ Error5:
 Error6:\r
   PciIo->FreeBuffer (\r
            PciIo,\r
-           (UINTN)EFI_SIZE_TO_PAGES (MaxReceiveFisSize),\r
+           EFI_SIZE_TO_PAGES ((UINTN) MaxReceiveFisSize),\r
            AhciRegisters->AhciRFis\r
            );\r
 \r
index bbaf5523ac1b5856eef3b9be3b53a6883caff8bb..ca64df7f6bbf3f21d142ea9fa76cfdc3f59a8294 100644 (file)
@@ -2,7 +2,7 @@
   This file implements ATA_PASSTHRU_PROCTOCOL and EXT_SCSI_PASSTHRU_PROTOCOL interfaces\r
   for managed ATA controllers.\r
     \r
-  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2011, 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
@@ -610,7 +610,7 @@ AtaAtapiPassThruStop (
              );\r
     PciIo->FreeBuffer (\r
              PciIo,\r
-             (UINTN) EFI_SIZE_TO_PAGES (AhciRegisters->MaxCommandTableSize),\r
+             EFI_SIZE_TO_PAGES ((UINTN) AhciRegisters->MaxCommandTableSize),\r
              AhciRegisters->AhciCommandTable\r
              );\r
     PciIo->Unmap (\r
@@ -619,7 +619,7 @@ AtaAtapiPassThruStop (
              );\r
     PciIo->FreeBuffer (\r
              PciIo,\r
-             (UINTN) EFI_SIZE_TO_PAGES (AhciRegisters->MaxCommandListSize),\r
+             EFI_SIZE_TO_PAGES ((UINTN) AhciRegisters->MaxCommandListSize),\r
              AhciRegisters->AhciCmdList\r
              );\r
     PciIo->Unmap (\r
@@ -628,7 +628,7 @@ AtaAtapiPassThruStop (
              );\r
     PciIo->FreeBuffer (\r
              PciIo,\r
-             (UINTN) EFI_SIZE_TO_PAGES (AhciRegisters->MaxReceiveFisSize),\r
+             EFI_SIZE_TO_PAGES ((UINTN) AhciRegisters->MaxReceiveFisSize),\r
              AhciRegisters->AhciRFis\r
              );\r
   }\r