From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.groups.io with SMTP id smtpd.web12.4295.1570703152255221514 for ; Thu, 10 Oct 2019 03:25:52 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=uVR/ZuCU; spf=pass (domain: linaro.org, ip: 209.85.221.66, mailfrom: leif.lindholm@linaro.org) Received: by mail-wr1-f66.google.com with SMTP id w12so7186925wro.5 for ; Thu, 10 Oct 2019 03:25:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=resent-from:resent-date:resent-message-id:resent-to:date:from:to:cc :subject:message-id:references:mime-version:content-disposition :in-reply-to:user-agent; bh=CPPG1f/fRDv8XaYo4SmMl96x5HLnPj6VN9zeLxig3Ao=; b=uVR/ZuCUeOE2dxKMhv58fbDq34SM2Xl5CCVkXPkya6vJCC0jJYZMTLwGaJ9ZmfApGr Mg36jVrRIE4XTqXy3QPjqfXSOixSIHPQni2Geb0c2qW2i5GMbL3ShX35/8671DM83ByO adNq14xXI6lcDRM2LbLUkQpvBk90EEpVKafP0NT27m5HdJsQJpJzotTBFpFDBES3nu5X feeTs0ovf2eBVSSoCzznzg/vPoUOTmg0SlITq5t4bo9C4qlSBnaC7exnZtBTcCvEziNS kbLgbUKumYqGL7mMGjFW3LdsMQp6ud3oqSiHq/tOxr9D/x8TR5Ggv01K3zUv+yN08t9k 2l8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:resent-from:resent-date:resent-message-id :resent-to:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CPPG1f/fRDv8XaYo4SmMl96x5HLnPj6VN9zeLxig3Ao=; b=ALEjxSTG1j+jyHJMwn+ZqhYuIkMdp3E6RWCDAHt3+4trFl8UZga4u4vKUh+L/ncS0d VojcZCL03IhZBWKbYI1bJUPqSHaDZ6Fv25+z7/EDg+VeAi/ap+67tqjDCPQ/coaJPcqK mGqIHFBM6uIcOj+IWj5g1UKitVf9A91HgFbXs1rROFpeC4IpTsKUSsgYF5RIYZ2CsbqB KGdjvAptGBZNHfAlh3zujTTsXueOeAWcr8pAXk5vbW2ePyJTlDp3qe0UbkHwzcTQZyro eBpS+RufBOv7UcyRPerSf0bty1Mxw4xOBOmHR4CoAiG7+0MOAdc2lpKmstjk7rlaxcgo 6lAg== X-Gm-Message-State: APjAAAWL0Wm9si+FDVzqWhaJBQ8wac7dngOoOI09JmsPipIwxA/wI8Ki QhD+LGIzWZtLv5RZYGi21kv1N2yIg6k= X-Google-Smtp-Source: APXvYqycL9he5Q0HZFTWzTXwBADTI6OZYNuIfJDxr6XHyC3OlqQRxcilnRLbB0+nXYbZYcM3Y2rpFw== X-Received: by 2002:adf:df81:: with SMTP id z1mr8007984wrl.367.1570703150457; Thu, 10 Oct 2019 03:25:50 -0700 (PDT) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id l6sm3739927wmg.2.2019.10.10.03.25.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 03:25:50 -0700 (PDT) Resent-From: Leif Lindholm Resent-Date: Thu, 10 Oct 2019 11:25:49 +0100 Resent-Message-ID: <20191010102549.GA25504@bivouac.eciton.net> Resent-To: devel@edk2.groups.io Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id d15sm5309333wru.50.2019.10.10.03.23.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 03:23:16 -0700 (PDT) Date: Thu, 10 Oct 2019 11:23:15 +0100 From: "Leif Lindholm" To: Meenakshi Aggarwal Cc: ard.biesheuvel@linaro.org, michael.d.kinney@intel.com, edk2-devel@lists.01.org, v.sethi@nxp.com Subject: Re: [PATCH edk2-platforms 02/12] Silicon/NXP: Add function to return swapped Mmio APIs pointer Message-ID: <20191010102315.GY25504@bivouac.eciton.net> References: <1543417315-5763-1-git-send-email-meenakshi.aggarwal@nxp.com> <1570639758-30355-1-git-send-email-meenakshi.aggarwal@nxp.com> <1570639758-30355-3-git-send-email-meenakshi.aggarwal@nxp.com> MIME-Version: 1.0 In-Reply-To: <1570639758-30355-3-git-send-email-meenakshi.aggarwal@nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Oct 09, 2019 at 10:19:08PM +0530, Meenakshi Aggarwal wrote: > Add support to return pointer to MMIO APIs on basis of Swap flag. > If Flag is True then MMIO APIs returned in which data > swapped after reading from MMIO and before write using MMIO. > > Signed-off-by: Meenakshi Aggarwal > --- > Silicon/NXP/Include/Library/IoAccessLib.h | 78 ++++++++++++++++++++ > Silicon/NXP/Library/IoAccessLib/IoAccessLib.c | 102 ++++++++++++++++++++++++++ > 2 files changed, 180 insertions(+) > > diff --git a/Silicon/NXP/Include/Library/IoAccessLib.h b/Silicon/NXP/Include/Library/IoAccessLib.h > index b72e65c..1e7c028 100644 > --- a/Silicon/NXP/Include/Library/IoAccessLib.h > +++ b/Silicon/NXP/Include/Library/IoAccessLib.h > @@ -11,6 +11,84 @@ > > #include > > +/// > +/// Structure to have pointer to R/W > +/// Mmio operations for 16 bits. > +/// > +typedef struct _MMIO_OPERATIONS_16 { > + UINT16 (*Read16) (UINTN Address); > + UINT16 (*Write16) (UINTN Address, UINT16 Value); > + UINT16 (*Or16) (UINTN Address, UINT16 Or); > + UINT16 (*And16) (UINTN Address, UINT16 AND); > + UINT16 (*AndThenOr16) (UINTN Address, UINT16 And, UINT16 Or); The idea of having variables called "Or" and "And" makes my head hurt. Thankfully, they are not called that in the actual implementations. If you change all the "AND" to "AndData" and all the "Or" to "OrData" in this file: Reviewed-by: Leif Lindholm > +} MMIO_OPERATIONS_16; > + > +/// > +/// Structure to have pointer to R/W > +/// Mmio operations for 32 bits. > +/// > +typedef struct _MMIO_OPERATIONS_32 { > + UINT32 (*Read32) (UINTN Address); > + UINT32 (*Write32) (UINTN Address, UINT32 Value); > + UINT32 (*Or32) (UINTN Address, UINT32 Or); > + UINT32 (*And32) (UINTN Address, UINT32 AND); > + UINT32 (*AndThenOr32) (UINTN Address, UINT32 And, UINT32 Or); > +} MMIO_OPERATIONS_32; > + > +/// > +/// Structure to have pointer to R/W > +/// Mmio operations for 64 bits. > +/// > +typedef struct _MMIO_OPERATIONS_64 { > + UINT64 (*Read64) (UINTN Address); > + UINT64 (*Write64) (UINTN Address, UINT64 Value); > + UINT64 (*Or64) (UINTN Address, UINT64 Or); > + UINT64 (*And64) (UINTN Address, UINT64 AND); > + UINT64 (*AndThenOr64) (UINTN Address, UINT64 And, UINT64 Or); > +} MMIO_OPERATIONS_64; > + > +/** > + Function to return pointer to 16 bit Mmio operations. > + > + @param Swap Flag to tell if Swap is needed or not > + on Mmio Operations. > + > + @return Pointer to Mmio Operations. > + > +**/ > +MMIO_OPERATIONS_16 * > +GetMmioOperations16 ( > + IN BOOLEAN Swap > + ); > + > +/** > + Function to return pointer to 32 bit Mmio operations. > + > + @param Swap Flag to tell if Swap is needed or not > + on Mmio Operations. > + > + @return Pointer to Mmio Operations. > + > +**/ > +MMIO_OPERATIONS_32 * > +GetMmioOperations32 ( > + IN BOOLEAN Swap > + ); > + > +/** > + Function to return pointer to 64 bit Mmio operations. > + > + @param Swap Flag to tell if Swap is needed or not > + on Mmio Operations. > + > + @return Pointer to Mmio Operations. > + > +**/ > +MMIO_OPERATIONS_64 * > +GetMmioOperations64 ( > + IN BOOLEAN Swap > + ); > + > /** > MmioRead16 for Big-Endian modules. > > diff --git a/Silicon/NXP/Library/IoAccessLib/IoAccessLib.c b/Silicon/NXP/Library/IoAccessLib/IoAccessLib.c > index e9e535f..6ed83d0 100644 > --- a/Silicon/NXP/Library/IoAccessLib/IoAccessLib.c > +++ b/Silicon/NXP/Library/IoAccessLib/IoAccessLib.c > @@ -300,3 +300,105 @@ SwapMmioAnd64 ( > { > return MmioAnd64 (Address, SwapBytes64 (AndData)); > } > + > +STATIC MMIO_OPERATIONS_16 SwappingFunctions16 = { > + SwapMmioRead16, > + SwapMmioWrite16, > + SwapMmioOr16, > + SwapMmioAnd16, > + SwapMmioAndThenOr16, > +}; > + > +STATIC MMIO_OPERATIONS_16 NonSwappingFunctions16 = { > + MmioRead16, > + MmioWrite16, > + MmioOr16, > + MmioAnd16, > + MmioAndThenOr16, > +}; > + > +STATIC MMIO_OPERATIONS_32 SwappingFunctions32 = { > + SwapMmioRead32, > + SwapMmioWrite32, > + SwapMmioOr32, > + SwapMmioAnd32, > + SwapMmioAndThenOr32, > +}; > + > +STATIC MMIO_OPERATIONS_32 NonSwappingFunctions32 = { > + MmioRead32, > + MmioWrite32, > + MmioOr32, > + MmioAnd32, > + MmioAndThenOr32, > +}; > + > +STATIC MMIO_OPERATIONS_64 SwappingFunctions64 = { > + SwapMmioRead64, > + SwapMmioWrite64, > + SwapMmioOr64, > + SwapMmioAnd64, > + SwapMmioAndThenOr64, > +}; > + > +STATIC MMIO_OPERATIONS_64 NonSwappingFunctions64 = { > + MmioRead64, > + MmioWrite64, > + MmioOr64, > + MmioAnd64, > + MmioAndThenOr64, > +}; > + > +/** > + Function to return pointer to 16 bit Mmio operations. > + > + @param Swap Flag to tell if Swap is needed or not > + on Mmio Operations. > + > + @return Pointer to Mmio Operations. > + > +**/ > +MMIO_OPERATIONS_16 * > +GetMmioOperations16 (BOOLEAN Swap) { > + if (Swap) { > + return &SwappingFunctions16; > + } else { > + return &NonSwappingFunctions16; > + } > +} > + > +/** > + Function to return pointer to 32 bit Mmio operations. > + > + @param Swap Flag to tell if Swap is needed or not > + on Mmio Operations. > + > + @return Pointer to Mmio Operations. > + > +**/ > +MMIO_OPERATIONS_32 * > +GetMmioOperations32 (BOOLEAN Swap) { > + if (Swap) { > + return &SwappingFunctions32; > + } else { > + return &NonSwappingFunctions32; > + } > +} > + > +/** > + Function to return pointer to 64 bit Mmio operations. > + > + @param Swap Flag to tell if Swap is needed or not > + on Mmio Operations. > + > + @return Pointer to Mmio Operations. > + > +**/ > +MMIO_OPERATIONS_64 * > +GetMmioOperations64 (BOOLEAN Swap) { > + if (Swap) { > + return &SwappingFunctions64; > + } else { > + return &NonSwappingFunctions64; > + } > +} > -- > 1.9.1 >