diff mbox series

[edk2,edk2-staging,06/19] IntelUndiPkg/GigUndiDxe: use intermediate UINTN casts for pointers

Message ID 20181106175833.26964-7-ard.biesheuvel@linaro.org
State New
Headers show
Series IntelUndiPkg/GigUndiDxe: build fixes for AARCH64/ARM/GCC | expand

Commit Message

Ard Biesheuvel Nov. 6, 2018, 5:58 p.m. UTC
Use intermediate (UINTN) casts when casting pointers to UINT64.
This is needed to be able to build this code for 32-bit architectures
such as ARM or IA32.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 IntelUndiPkg/GigUndiDxe/Dma.c               |  8 ++++----
 IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c |  6 +++---
 IntelUndiPkg/GigUndiDxe/Init.c              |  6 +++---
 IntelUndiPkg/GigUndiDxe/e1000.c             | 10 +++++-----
 IntelUndiPkg/GigUndiDxe/e1000.h             |  4 ++--
 5 files changed, 17 insertions(+), 17 deletions(-)

-- 
2.19.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Ryszard Knop Jan. 30, 2019, 10:59 a.m. UTC | #1
Reviewed-by: Ryszard Knop <ryszard.knop@linux.intel.com>


On Tue, 2018-11-06 at 18:58 +0100, ard.biesheuvela wrote:
> Use intermediate (UINTN) casts when casting pointers to UINT64.

> This is needed to be able to build this code for 32-bit architectures

> such as ARM or IA32.

> 

> Contributed-under: TianoCore Contribution Agreement 1.1

> Signed-off-by: Ard Biesheuvel <ard.biesheuvel at linaro.org>

> ---

>  IntelUndiPkg/GigUndiDxe/Dma.c               |  8 ++++----

>  IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c |  6 +++---

>  IntelUndiPkg/GigUndiDxe/Init.c              |  6 +++---

>  IntelUndiPkg/GigUndiDxe/e1000.c             | 10 +++++-----

>  IntelUndiPkg/GigUndiDxe/e1000.h             |  4 ++--

>  5 files changed, 17 insertions(+), 17 deletions(-)

> 

> diff --git a/IntelUndiPkg/GigUndiDxe/Dma.c

> b/IntelUndiPkg/GigUndiDxe/Dma.c

> index bf94c1e2fd54..eee2aa8a1ce3 100644

> --- a/IntelUndiPkg/GigUndiDxe/Dma.c

> +++ b/IntelUndiPkg/GigUndiDxe/Dma.c

> @@ -127,7 +127,7 @@ FREE_BUF_ON_ERROR:

>    PciIo->FreeBuffer (

>             PciIo,

>             BytesToPages (DmaMapping->Size),

> -           (VOID *) DmaMapping->UnmappedAddress

> +           (VOID *)(UINTN)DmaMapping->UnmappedAddress

>             );

>    DmaMapping->Size = 0;

>    DmaMapping->UnmappedAddress = 0;

> @@ -173,7 +173,7 @@ UndiDmaFreeCommonBuffer (

>    PciIo->FreeBuffer (

>             PciIo,

>             BytesToPages (DmaMapping->Size),

> -           (VOID *) DmaMapping->UnmappedAddress

> +           (VOID *)(UINTN)DmaMapping->UnmappedAddress

>             );

>  

>    DmaMapping->UnmappedAddress = 0;

> @@ -209,7 +209,7 @@ UndiDmaMapCommonBuffer (

>    return PciIo->Map (

>                    PciIo,

>                    EfiPciIoOperationBusMasterCommonBuffer,

> -                  (VOID *) DmaMapping->UnmappedAddress,

> +                  (VOID *)(UINTN)DmaMapping->UnmappedAddress,

>                    &DmaMapping->Size,

>                    &DmaMapping->PhysicalAddress,

>                    &DmaMapping->Mapping

> @@ -243,7 +243,7 @@ UndiDmaMapMemoryRead (

>    return PciIo->Map (

>                    PciIo,

>                    EfiPciIoOperationBusMasterRead,

> -                  (VOID *) DmaMapping->UnmappedAddress,

> +                  (VOID *)(UINTN)DmaMapping->UnmappedAddress,

>                    &DmaMapping->Size,

>                    &DmaMapping->PhysicalAddress,

>                    &DmaMapping->Mapping

> diff --git a/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c

> b/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c

> index 559f2133281e..aceb015e480f 100644

> --- a/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c

> +++ b/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c

> @@ -1132,7 +1132,7 @@ GigUndiRunPhyLoopback (

>    while (j < PHY_LOOPBACK_ITERATIONS) {

>      Status = E1000Transmit (

>                 GigAdapterInfo,

> -               (UINT64) &PxeCpbTransmit,

> +               (UINT64)(UINTN)&PxeCpbTransmit,

>                 PXE_OPFLAGS_TRANSMIT_WHOLE

>               );

>      _DisplayBuffersAndDescriptors (GigAdapterInfo);

> @@ -1161,8 +1161,8 @@ GigUndiRunPhyLoopback (

>      for (i = 0; i <= 100000; i++) {

>        Status = E1000Receive (

>                   GigAdapterInfo,

> -                 (UINT64) &CpbReceive,

> -                 (UINT64) &DbReceive

> +                 (UINT64)(UINTN)&CpbReceive,

> +                 (UINT64)(UINTN)&DbReceive

>                 );

>        gBS->Stall (10);

>  

> diff --git a/IntelUndiPkg/GigUndiDxe/Init.c

> b/IntelUndiPkg/GigUndiDxe/Init.c

> index 74b933674589..f99734d72823 100644

> --- a/IntelUndiPkg/GigUndiDxe/Init.c

> +++ b/IntelUndiPkg/GigUndiDxe/Init.c

> @@ -301,7 +301,7 @@ GigUndiPxeStructInit (

>                             PXE_ROMID_IMP_TX_COMPLETE_INT_SUPPORTED |

>                             PXE_ROMID_IMP_PACKET_RX_INT_SUPPORTED;

>  

> -  PxePtr->EntryPoint    = (UINT64) E1000UndiApiEntry;

> +  PxePtr->EntryPoint    = (UINT64)(UINTN)E1000UndiApiEntry;

>    PxePtr->reserved2[0]  = 0;

>    PxePtr->reserved2[1]  = 0;

>    PxePtr->reserved2[2]  = 0;

> @@ -842,7 +842,7 @@ InitNiiProtocol (

>      return EFI_INVALID_PARAMETER;

>    }

>  

> -  NiiProtocol31->Id             = (UINT64) (mE1000Pxe31);

> +  NiiProtocol31->Id             = (UINT64)(UINTN)mE1000Pxe31;

>    NiiProtocol31->IfNum          = mE1000Pxe31->IFcnt;

>  

>    NiiProtocol31->Revision       =

> EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION_31;

> @@ -938,7 +938,7 @@ InitUndiCallbackFunctions (

>    NicInfo->MapMem      = (VOID *) 0;

>    NicInfo->UnMapMem    = (VOID *) 0;

>    NicInfo->SyncMem     = (VOID *) 0;

> -  NicInfo->UniqueId    = (UINT64) NicInfo;

> +  NicInfo->UniqueId    = (UINT64)(UINTN)NicInfo;

>    NicInfo->VersionFlag = 0x31;

>  }

>  

> diff --git a/IntelUndiPkg/GigUndiDxe/e1000.c

> b/IntelUndiPkg/GigUndiDxe/e1000.c

> index 6f8529abf046..1f08a5d67b2d 100644

> --- a/IntelUndiPkg/GigUndiDxe/e1000.c

> +++ b/IntelUndiPkg/GigUndiDxe/e1000.c

> @@ -128,7 +128,7 @@ E1000MapMem (

>                      VirtualAddress,

>                      Size,

>                      TO_DEVICE,

> -                    (UINT64) MappedAddress

> +                    (UINT64)(UINTN)MappedAddress

>                    );

>  

>      if (*MappedAddress == 0) {

> @@ -1079,7 +1079,7 @@ E1000TxRxConfigure (

>  

>    ZeroMem (GigAdapter->TxBufferMappings, sizeof (GigAdapter-

> >TxBufferMappings));

>  

> -  RxBuffer = (LOCAL_RX_BUFFER *) GigAdapter-

> >RxBufferMapping.PhysicalAddress;

> +  RxBuffer = (LOCAL_RX_BUFFER *)(UINTN)GigAdapter-

> >RxBufferMapping.PhysicalAddress;

>  

>    DEBUGPRINT (

>      E1000, ("Tx Ring %x Added %x\n",

> @@ -1578,17 +1578,17 @@ E1000Inititialize (

>    TempBar = NULL;

>  

>    ZeroMem (

> -    (VOID *) GigAdapter->RxRing.UnmappedAddress,

> +    (VOID *)(UINTN)GigAdapter->RxRing.UnmappedAddress,

>      RX_RING_SIZE

>      );

>  

>    ZeroMem (

> -    (VOID *) GigAdapter->TxRing.UnmappedAddress,

> +    (VOID *)(UINTN)GigAdapter->TxRing.UnmappedAddress,

>      TX_RING_SIZE

>      );

>  

>    ZeroMem (

> -    (VOID *) GigAdapter->RxBufferMapping.UnmappedAddress,

> +    (VOID *)(UINTN)GigAdapter->RxBufferMapping.UnmappedAddress,

>      RX_BUFFERS_SIZE

>      );

>  

> diff --git a/IntelUndiPkg/GigUndiDxe/e1000.h

> b/IntelUndiPkg/GigUndiDxe/e1000.h

> index 71fe4591af05..a44fe3fa2ec8 100644

> --- a/IntelUndiPkg/GigUndiDxe/e1000.h

> +++ b/IntelUndiPkg/GigUndiDxe/e1000.h

> @@ -233,7 +233,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE

> POSSIBILITY OF SUCH DAMAGE.

>     @return   Descriptor retrieved

>  **/

>  #define E1000_RX_DESC(R, i)          \

> -          (&(((struct e1000_rx_desc *) ((R)->UnmappedAddress))[i]))

> +          (&(((struct e1000_rx_desc *)(UINTN)((R)-

> >UnmappedAddress))[i]))

>  

>  /** Retrieves TX descriptor from TX ring structure

>  

> @@ -243,7 +243,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE

> POSSIBILITY OF SUCH DAMAGE.

>     @return   Descriptor retrieved

>  **/

>  #define E1000_TX_DESC(R, i)          \

> -          (&(((struct e1000_tx_desc *) ((R)->UnmappedAddress))[i]))

> +          (&(((struct e1000_tx_desc *)(UINTN)((R)-

> >UnmappedAddress))[i]))

>  

>  /** Retrieves UNDI_PRIVATE_DATA structure using NII Protocol 3.1

> instance

>  


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox series

Patch

diff --git a/IntelUndiPkg/GigUndiDxe/Dma.c b/IntelUndiPkg/GigUndiDxe/Dma.c
index bf94c1e2fd54..eee2aa8a1ce3 100644
--- a/IntelUndiPkg/GigUndiDxe/Dma.c
+++ b/IntelUndiPkg/GigUndiDxe/Dma.c
@@ -127,7 +127,7 @@  FREE_BUF_ON_ERROR:
   PciIo->FreeBuffer (
            PciIo,
            BytesToPages (DmaMapping->Size),
-           (VOID *) DmaMapping->UnmappedAddress
+           (VOID *)(UINTN)DmaMapping->UnmappedAddress
            );
   DmaMapping->Size = 0;
   DmaMapping->UnmappedAddress = 0;
@@ -173,7 +173,7 @@  UndiDmaFreeCommonBuffer (
   PciIo->FreeBuffer (
            PciIo,
            BytesToPages (DmaMapping->Size),
-           (VOID *) DmaMapping->UnmappedAddress
+           (VOID *)(UINTN)DmaMapping->UnmappedAddress
            );
 
   DmaMapping->UnmappedAddress = 0;
@@ -209,7 +209,7 @@  UndiDmaMapCommonBuffer (
   return PciIo->Map (
                   PciIo,
                   EfiPciIoOperationBusMasterCommonBuffer,
-                  (VOID *) DmaMapping->UnmappedAddress,
+                  (VOID *)(UINTN)DmaMapping->UnmappedAddress,
                   &DmaMapping->Size,
                   &DmaMapping->PhysicalAddress,
                   &DmaMapping->Mapping
@@ -243,7 +243,7 @@  UndiDmaMapMemoryRead (
   return PciIo->Map (
                   PciIo,
                   EfiPciIoOperationBusMasterRead,
-                  (VOID *) DmaMapping->UnmappedAddress,
+                  (VOID *)(UINTN)DmaMapping->UnmappedAddress,
                   &DmaMapping->Size,
                   &DmaMapping->PhysicalAddress,
                   &DmaMapping->Mapping
diff --git a/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c b/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c
index 559f2133281e..aceb015e480f 100644
--- a/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c
+++ b/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c
@@ -1132,7 +1132,7 @@  GigUndiRunPhyLoopback (
   while (j < PHY_LOOPBACK_ITERATIONS) {
     Status = E1000Transmit (
                GigAdapterInfo,
-               (UINT64) &PxeCpbTransmit,
+               (UINT64)(UINTN)&PxeCpbTransmit,
                PXE_OPFLAGS_TRANSMIT_WHOLE
              );
     _DisplayBuffersAndDescriptors (GigAdapterInfo);
@@ -1161,8 +1161,8 @@  GigUndiRunPhyLoopback (
     for (i = 0; i <= 100000; i++) {
       Status = E1000Receive (
                  GigAdapterInfo,
-                 (UINT64) &CpbReceive,
-                 (UINT64) &DbReceive
+                 (UINT64)(UINTN)&CpbReceive,
+                 (UINT64)(UINTN)&DbReceive
                );
       gBS->Stall (10);
 
diff --git a/IntelUndiPkg/GigUndiDxe/Init.c b/IntelUndiPkg/GigUndiDxe/Init.c
index 74b933674589..f99734d72823 100644
--- a/IntelUndiPkg/GigUndiDxe/Init.c
+++ b/IntelUndiPkg/GigUndiDxe/Init.c
@@ -301,7 +301,7 @@  GigUndiPxeStructInit (
                            PXE_ROMID_IMP_TX_COMPLETE_INT_SUPPORTED |
                            PXE_ROMID_IMP_PACKET_RX_INT_SUPPORTED;
 
-  PxePtr->EntryPoint    = (UINT64) E1000UndiApiEntry;
+  PxePtr->EntryPoint    = (UINT64)(UINTN)E1000UndiApiEntry;
   PxePtr->reserved2[0]  = 0;
   PxePtr->reserved2[1]  = 0;
   PxePtr->reserved2[2]  = 0;
@@ -842,7 +842,7 @@  InitNiiProtocol (
     return EFI_INVALID_PARAMETER;
   }
 
-  NiiProtocol31->Id             = (UINT64) (mE1000Pxe31);
+  NiiProtocol31->Id             = (UINT64)(UINTN)mE1000Pxe31;
   NiiProtocol31->IfNum          = mE1000Pxe31->IFcnt;
 
   NiiProtocol31->Revision       = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION_31;
@@ -938,7 +938,7 @@  InitUndiCallbackFunctions (
   NicInfo->MapMem      = (VOID *) 0;
   NicInfo->UnMapMem    = (VOID *) 0;
   NicInfo->SyncMem     = (VOID *) 0;
-  NicInfo->UniqueId    = (UINT64) NicInfo;
+  NicInfo->UniqueId    = (UINT64)(UINTN)NicInfo;
   NicInfo->VersionFlag = 0x31;
 }
 
diff --git a/IntelUndiPkg/GigUndiDxe/e1000.c b/IntelUndiPkg/GigUndiDxe/e1000.c
index 6f8529abf046..1f08a5d67b2d 100644
--- a/IntelUndiPkg/GigUndiDxe/e1000.c
+++ b/IntelUndiPkg/GigUndiDxe/e1000.c
@@ -128,7 +128,7 @@  E1000MapMem (
                     VirtualAddress,
                     Size,
                     TO_DEVICE,
-                    (UINT64) MappedAddress
+                    (UINT64)(UINTN)MappedAddress
                   );
 
     if (*MappedAddress == 0) {
@@ -1079,7 +1079,7 @@  E1000TxRxConfigure (
 
   ZeroMem (GigAdapter->TxBufferMappings, sizeof (GigAdapter->TxBufferMappings));
 
-  RxBuffer = (LOCAL_RX_BUFFER *) GigAdapter->RxBufferMapping.PhysicalAddress;
+  RxBuffer = (LOCAL_RX_BUFFER *)(UINTN)GigAdapter->RxBufferMapping.PhysicalAddress;
 
   DEBUGPRINT (
     E1000, ("Tx Ring %x Added %x\n",
@@ -1578,17 +1578,17 @@  E1000Inititialize (
   TempBar = NULL;
 
   ZeroMem (
-    (VOID *) GigAdapter->RxRing.UnmappedAddress,
+    (VOID *)(UINTN)GigAdapter->RxRing.UnmappedAddress,
     RX_RING_SIZE
     );
 
   ZeroMem (
-    (VOID *) GigAdapter->TxRing.UnmappedAddress,
+    (VOID *)(UINTN)GigAdapter->TxRing.UnmappedAddress,
     TX_RING_SIZE
     );
 
   ZeroMem (
-    (VOID *) GigAdapter->RxBufferMapping.UnmappedAddress,
+    (VOID *)(UINTN)GigAdapter->RxBufferMapping.UnmappedAddress,
     RX_BUFFERS_SIZE
     );
 
diff --git a/IntelUndiPkg/GigUndiDxe/e1000.h b/IntelUndiPkg/GigUndiDxe/e1000.h
index 71fe4591af05..a44fe3fa2ec8 100644
--- a/IntelUndiPkg/GigUndiDxe/e1000.h
+++ b/IntelUndiPkg/GigUndiDxe/e1000.h
@@ -233,7 +233,7 @@  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    @return   Descriptor retrieved
 **/
 #define E1000_RX_DESC(R, i)          \
-          (&(((struct e1000_rx_desc *) ((R)->UnmappedAddress))[i]))
+          (&(((struct e1000_rx_desc *)(UINTN)((R)->UnmappedAddress))[i]))
 
 /** Retrieves TX descriptor from TX ring structure
 
@@ -243,7 +243,7 @@  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    @return   Descriptor retrieved
 **/
 #define E1000_TX_DESC(R, i)          \
-          (&(((struct e1000_tx_desc *) ((R)->UnmappedAddress))[i]))
+          (&(((struct e1000_tx_desc *)(UINTN)((R)->UnmappedAddress))[i]))
 
 /** Retrieves UNDI_PRIVATE_DATA structure using NII Protocol 3.1 instance