From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web12.3752.1588762099961540938 for ; Wed, 06 May 2020 03:48:20 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=CeWTR1Eu; spf=pass (domain: nuviainc.com, ip: 209.85.221.65, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f65.google.com with SMTP id s8so1611526wrt.9 for ; Wed, 06 May 2020 03:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WmWufNgYA7upV/rwV/jb6op9IXt4RyGVMBTJXlY6fls=; b=CeWTR1EuqqUwrV7RMFh9Qt551b3BRIMmKXDJjSnGnuFcihqnLAyjdhabda3JCpSQ3/ JYkSzY+iiIf/X2JkYfBQipMga5r88YwQQgcSnMDAKRiGMI/ez9ktUpipmQ+NHR/CZd9O tdFcGnEIw7yN9WVB9tdB6u4mrByao7NYp/E0ALoaJ9ukDyg8HtcQS3Regomlm7pqKHxR sATMLGF70jFnMVE2dR0v1OHzGH+CEKObr6ural4WhOTl3IIAfJiCZMXkr+qRN70mK53P gVx1cfGGCCpb4gGnafXLqq8N+rXTNoWW+w53mwslkM0dQ6gxZoC8bWOpjGfrEA7WyuaL Sjhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WmWufNgYA7upV/rwV/jb6op9IXt4RyGVMBTJXlY6fls=; b=WE9D54wa66fNEK3ew0UOYRa53uMvlWypZMQSZj+gMyq+y9aeCKD0xa2N/h+tw4WFke uJAymT9wICT9B4aGkJ6bVn5cnnAft0d6hVM/85o/L/mF5bfX2Rr6EkCxrMRrnYXHw1n0 fdZmIeWljdzYYsmKcUJeY3R2qVV8Nw8/ExtPC8YlaT83rrHsfq8Tqu2+66+lN9R5TXw7 OBPU+bIj7xgcN1cXM/CZS/QWJ3cJEae8dfdz+5pVAb+XC6mYEZ724ljh7Ydj2XiuceMx FK6njxoFRIXgQHY6qKgf2SP7dZm5GILiNALI63/kWhGCbfj4s0jAZal98Col7JPKTi6l l8Sg== X-Gm-Message-State: AGi0PuYUhLTryUEBlGa1lanKlQ2rctMoGkaCX+OggnCgHLO/G+cdtb7R 841iU3Uq2oTSxcXhnlG0ZuiuFg== X-Google-Smtp-Source: APiQypIMT3999v0widAr7QlzChfKiA1CJu8tEnbPfJX15aN2o1E5ALNnD54wWrI3OrV4OrKBLcTmPg== X-Received: by 2002:adf:e4cf:: with SMTP id v15mr8581831wrm.43.1588762098208; Wed, 06 May 2020 03:48:18 -0700 (PDT) Return-Path: Received: from vanye ([2001:470:1f09:12f0:b26e:bfff:fea9:f1b8]) by smtp.gmail.com with ESMTPSA id d133sm2666505wmc.27.2020.05.06.03.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 03:48:17 -0700 (PDT) Date: Wed, 6 May 2020 11:48:15 +0100 From: "Leif Lindholm" To: Pankaj Bansal Cc: Meenakshi Aggarwal , Michael D Kinney , devel@edk2.groups.io, Varun Sethi , Samer El-Haj-Mahmoud , Jon Nettleton , Ard Biesheuvel Subject: Re: [PATCH edk2-platforms v4 15/24] Silicon: NXP: Remove direct calls to SwapMmio* APIs Message-ID: <20200506104815.GM21486@vanye> References: <20200501054955.13025-1-pankaj.bansal@oss.nxp.com> <20200501054955.13025-16-pankaj.bansal@oss.nxp.com> MIME-Version: 1.0 In-Reply-To: <20200501054955.13025-16-pankaj.bansal@oss.nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, May 01, 2020 at 11:19:46 +0530, Pankaj Bansal wrote: > From: Pankaj Bansal > > The SwapMmio** APIs are supposed to be called indirectly via > GetMmioOperations** APIs. > Therefore, remove the SwapMmio** APIs from IoAccessLib.h and make > these APIs STATIC to IoAccessLib.c, so that no accidental call can > be made to these. > > Signed-off-by: Pankaj Bansal Reviewed-by: Leif Lindholm > --- > > Notes: > V4: > - Use GetMmioOperations in place of GetMmioOperations32 > - Use MMIO_OPERATIONS in place of MMIO_OPERATIONS_32 > > V3: > - New commit > > Silicon/NXP/Include/Library/IoAccessLib.h | 236 +------------------- > Silicon/NXP/Library/IoAccessLib/IoAccessLib.c | 17 +- > Silicon/NXP/Library/SocLib/Chassis.c | 10 +- > 3 files changed, 22 insertions(+), 241 deletions(-) > > diff --git a/Silicon/NXP/Include/Library/IoAccessLib.h b/Silicon/NXP/Include/Library/IoAccessLib.h > index 0f5b19dcf149..3dbb35d2ce5a 100644 > --- a/Silicon/NXP/Include/Library/IoAccessLib.h > +++ b/Silicon/NXP/Include/Library/IoAccessLib.h > @@ -1,6 +1,6 @@ > /** @file > * > - * Copyright 2017-2019 NXP > + * Copyright 2017-2020 NXP > * > * SPDX-License-Identifier: BSD-2-Clause-Patent > * > @@ -47,238 +47,4 @@ GetMmioOperations ( > IN BOOLEAN Swap > ); > > -/** > - MmioRead16 for Big-Endian modules. > - > - @param Address The MMIO register to read. > - > - @return The value read. > - > -**/ > -UINT16 > -EFIAPI > -SwapMmioRead16 ( > - IN UINTN Address > - ); > - > -/** > - MmioRead32 for Big-Endian modules. > - > - @param Address The MMIO register to read. > - > - @return The value read. > - > -**/ > -UINT32 > -EFIAPI > -SwapMmioRead32 ( > - IN UINTN Address > - ); > - > -/** > - MmioRead64 for Big-Endian modules. > - > - @param Address The MMIO register to read. > - > - @return The value read. > - > -**/ > -UINT64 > -EFIAPI > -SwapMmioRead64 ( > - IN UINTN Address > - ); > - > -/** > - MmioWrite16 for Big-Endian modules. > - > - @param Address The MMIO register to write. > - @param Value The value to write to the MMIO register. > - > -**/ > -UINT16 > -EFIAPI > -SwapMmioWrite16 ( > - IN UINTN Address, > - IN UINT16 Value > - ); > - > -/** > - MmioWrite32 for Big-Endian modules. > - > - @param Address The MMIO register to write. > - @param Value The value to write to the MMIO register. > - > -**/ > -UINT32 > -EFIAPI > -SwapMmioWrite32 ( > - IN UINTN Address, > - IN UINT32 Value > - ); > - > -/** > - MmioWrite64 for Big-Endian modules. > - > - @param Address The MMIO register to write. > - @param Value The value to write to the MMIO register. > - > -**/ > -UINT64 > -EFIAPI > -SwapMmioWrite64 ( > - IN UINTN Address, > - IN UINT64 Value > - ); > - > -/** > - MmioAndThenOr16 for Big-Endian modules. > - > - @param Address The MMIO register to write. > - @param AndData The value to AND with the read value from the MMIO register. > - @param OrData The value to OR with the result of the AND operation. > - > - @return The value written back to the MMIO register. > - > -**/ > -UINT16 > -EFIAPI > -SwapMmioAndThenOr16 ( > - IN UINTN Address, > - IN UINT16 AndData, > - IN UINT16 OrData > - ); > - > -/** > - MmioAndThenOr32 for Big-Endian modules. > - > - @param Address The MMIO register to write. > - @param AndData The value to AND with the read value from the MMIO register. > - @param OrData The value to OR with the result of the AND operation. > - > - @return The value written back to the MMIO register. > - > -**/ > -UINT32 > -EFIAPI > -SwapMmioAndThenOr32 ( > - IN UINTN Address, > - IN UINT32 AndData, > - IN UINT32 OrData > - ); > - > -/** > - MmioAndThenOr64 for Big-Endian modules. > - > - @param Address The MMIO register to write. > - @param AndData The value to AND with the read value from the MMIO register. > - @param OrData The value to OR with the result of the AND operation. > - > - @return The value written back to the MMIO register. > - > -**/ > -UINT64 > -EFIAPI > -SwapMmioAndThenOr64 ( > - IN UINTN Address, > - IN UINT64 AndData, > - IN UINT64 OrData > - ); > - > -/** > - MmioOr16 for Big-Endian modules. > - > - @param Address The MMIO register to write. > - @param OrData The value to OR with the read value from the MMIO register. > - > - @return The value written back to the MMIO register. > - > -**/ > -UINT16 > -EFIAPI > -SwapMmioOr16 ( > - IN UINTN Address, > - IN UINT16 OrData > - ); > - > -/** > - MmioOr32 for Big-Endian modules. > - > - @param Address The MMIO register to write. > - @param OrData The value to OR with the read value from the MMIO register. > - > - @return The value written back to the MMIO register. > - > -**/ > -UINT32 > -EFIAPI > -SwapMmioOr32 ( > - IN UINTN Address, > - IN UINT32 OrData > - ); > - > -/** > - MmioOr64 for Big-Endian modules. > - > - @param Address The MMIO register to write. > - @param OrData The value to OR with the read value from the MMIO register. > - > - @return The value written back to the MMIO register. > - > -**/ > -UINT64 > -EFIAPI > -SwapMmioOr64 ( > - IN UINTN Address, > - IN UINT64 OrData > - ); > - > -/** > - MmioAnd16 for Big-Endian modules. > - > - @param Address The MMIO register to write. > - @param AndData The value to AND with the read value from the MMIO register. > - > - @return The value written back to the MMIO register. > - > -**/ > -UINT16 > -EFIAPI > -SwapMmioAnd16 ( > - IN UINTN Address, > - IN UINT16 AndData > - ); > - > -/** > - MmioAnd32 for Big-Endian modules. > - > - @param Address The MMIO register to write. > - @param AndData The value to AND with the read value from the MMIO register. > - > - @return The value written back to the MMIO register. > - > -**/ > -UINT32 > -EFIAPI > -SwapMmioAnd32 ( > - IN UINTN Address, > - IN UINT32 AndData > - ); > - > -/** > - MmioAnd64 for Big-Endian modules. > - > - @param Address The MMIO register to write. > - @param AndData The value to AND with the read value from the MMIO register. > - > - @return The value written back to the MMIO register. > - > -**/ > -UINT64 > -EFIAPI > -SwapMmioAnd64 ( > - IN UINTN Address, > - IN UINT64 AndData > - ); > - > #endif /* IO_ACCESS_LIB_H_ */ > diff --git a/Silicon/NXP/Library/IoAccessLib/IoAccessLib.c b/Silicon/NXP/Library/IoAccessLib/IoAccessLib.c > index 33039afda40f..2c6160e8acef 100644 > --- a/Silicon/NXP/Library/IoAccessLib/IoAccessLib.c > +++ b/Silicon/NXP/Library/IoAccessLib/IoAccessLib.c > @@ -2,7 +2,7 @@ > > Provide MMIO APIs for BE modules. > > - Copyright 2017-2019 NXP > + Copyright 2017-2020 NXP > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -21,6 +21,7 @@ > @return The value read. > > **/ > +STATIC > UINT16 > EFIAPI > SwapMmioRead16 ( > @@ -38,6 +39,7 @@ SwapMmioRead16 ( > @return The value read. > > **/ > +STATIC > UINT32 > EFIAPI > SwapMmioRead32 ( > @@ -55,6 +57,7 @@ SwapMmioRead32 ( > @return The value read. > > **/ > +STATIC > UINT64 > EFIAPI > SwapMmioRead64 ( > @@ -71,6 +74,7 @@ SwapMmioRead64 ( > @param Value The value to write to the MMIO register. > > **/ > +STATIC > UINT16 > EFIAPI > SwapMmioWrite16 ( > @@ -88,6 +92,7 @@ SwapMmioWrite16 ( > @param Value The value to write to the MMIO register. > > **/ > +STATIC > UINT32 > EFIAPI > SwapMmioWrite32 ( > @@ -105,6 +110,7 @@ SwapMmioWrite32 ( > @param Value The value to write to the MMIO register. > > **/ > +STATIC > UINT64 > EFIAPI > SwapMmioWrite64 ( > @@ -125,6 +131,7 @@ SwapMmioWrite64 ( > @return The value written back to the MMIO register. > > **/ > +STATIC > UINT16 > EFIAPI > SwapMmioAndThenOr16 ( > @@ -149,6 +156,7 @@ SwapMmioAndThenOr16 ( > @return The value written back to the MMIO register. > > **/ > +STATIC > UINT32 > EFIAPI > SwapMmioAndThenOr32 ( > @@ -173,6 +181,7 @@ SwapMmioAndThenOr32 ( > @return The value written back to the MMIO register. > > **/ > +STATIC > UINT64 > EFIAPI > SwapMmioAndThenOr64 ( > @@ -196,6 +205,7 @@ SwapMmioAndThenOr64 ( > @return The value written back to the MMIO register. > > **/ > +STATIC > UINT16 > EFIAPI > SwapMmioOr16 ( > @@ -215,6 +225,7 @@ SwapMmioOr16 ( > @return The value written back to the MMIO register. > > **/ > +STATIC > UINT32 > EFIAPI > SwapMmioOr32 ( > @@ -234,6 +245,7 @@ SwapMmioOr32 ( > @return The value written back to the MMIO register. > > **/ > +STATIC > UINT64 > EFIAPI > SwapMmioOr64 ( > @@ -253,6 +265,7 @@ SwapMmioOr64 ( > @return The value written back to the MMIO register. > > **/ > +STATIC > UINT16 > EFIAPI > SwapMmioAnd16 ( > @@ -272,6 +285,7 @@ SwapMmioAnd16 ( > @return The value written back to the MMIO register. > > **/ > +STATIC > UINT32 > EFIAPI > SwapMmioAnd32 ( > @@ -291,6 +305,7 @@ SwapMmioAnd32 ( > @return The value written back to the MMIO register. > > **/ > +STATIC > UINT64 > EFIAPI > SwapMmioAnd64 ( > diff --git a/Silicon/NXP/Library/SocLib/Chassis.c b/Silicon/NXP/Library/SocLib/Chassis.c > index 90677f0f36ca..05c5462446a4 100644 > --- a/Silicon/NXP/Library/SocLib/Chassis.c > +++ b/Silicon/NXP/Library/SocLib/Chassis.c > @@ -30,11 +30,11 @@ GurRead ( > IN UINTN Address > ) > { > - if (FixedPcdGetBool (PcdGurBigEndian)) { > - return SwapMmioRead32 (Address); > - } else { > - return MmioRead32 (Address); > - } > + MMIO_OPERATIONS *GurOps; > + > + GurOps = GetMmioOperations (FixedPcdGetBool (PcdGurBigEndian)); > + > + return GurOps->Read32 (Address); > } > > /* > -- > 2.17.1 >