]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
fix a invalid pointer conversion when builing 32bit image.
[mirror_edk2.git] / MdeModulePkg / Bus / Ata / AtaAtapiPassThru / AhciMode.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