From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.107.7.81; helo=eur04-he1-obe.outbound.protection.outlook.com; envelope-from=meenakshi.aggarwal@nxp.com; receiver=edk2-devel@lists.01.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70081.outbound.protection.outlook.com [40.107.7.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5260B2194D3AE for ; Tue, 25 Dec 2018 21:00:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gsbhyXfG3R4MAdvl5dejDS56QEiQEIje2eF4vThwbXs=; b=WQhJoFFiz7NBQOpRC23e1oNXZerBcbJ7LepeKMJ8OTjY0OHNa7HlgQSkxP4gVW7HgYFplRFcj/C1Ejf3PXeuWO9hsKPjwVc88wcZU7LrMHWMkPUchWrC9ZOt+rNaiGUAnHBGGio7EkEcfmUww7YzGuOBpu88khfEskg9zHt1bKs= Received: from VI1PR04MB4685.eurprd04.prod.outlook.com (20.177.56.77) by VI1PR04MB4112.eurprd04.prod.outlook.com (52.133.14.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1471.20; Wed, 26 Dec 2018 05:00:33 +0000 Received: from VI1PR04MB4685.eurprd04.prod.outlook.com ([fe80::34a5:80b4:805b:c30b]) by VI1PR04MB4685.eurprd04.prod.outlook.com ([fe80::34a5:80b4:805b:c30b%2]) with mapi id 15.20.1471.019; Wed, 26 Dec 2018 05:00:32 +0000 From: Meenakshi Aggarwal To: Leif Lindholm CC: "ard.biesheuvel@linaro.org" , "michael.d.kinney@intel.com" , "edk2-devel@lists.01.org" , Udit Kumar , Varun Sethi Thread-Topic: [PATCH edk2-platforms 01/41] Silicon/NXP: Add Library to return Mmio APIs pointer Thread-Index: AQHUhvr3gCK2T65Y0UqL2eTZGhNKG6WJtcyAgAbr1/A= Date: Wed, 26 Dec 2018 05:00:32 +0000 Message-ID: References: <1518771035-6733-1-git-send-email-meenakshi.aggarwal@nxp.com> <1543417315-5763-1-git-send-email-meenakshi.aggarwal@nxp.com> <1543417315-5763-2-git-send-email-meenakshi.aggarwal@nxp.com> <20181221191757.7ltris5cebwhmzpp@bivouac.eciton.net> In-Reply-To: <20181221191757.7ltris5cebwhmzpp@bivouac.eciton.net> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=meenakshi.aggarwal@nxp.com; x-originating-ip: [14.143.254.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR04MB4112; 6:EbV2AbPDB3V5Lt6Oc+g3BeNJvPCy5PrJAZTo/e5kQjEA4JAbVzyNCffXoKKQBpN2R/SucFcVyhKLKY/EedBmUfI0hACK1B6b4f77tUYB+KtfzsXJBzUXha2vZdtRJv0d6184kOAd5auQC6/t1wapjN9Po86KdhD5y9ivi+qyAx2091iEtEsIi/362a8r3Zs02PJdPozqjGKBWPv50DozTARC3GuiGKJUU4jIBdXMSwPFGTw3tW/mUfpgs245W7M7C6CwlPuhOiV4f9KQe8YlD1ID/r1H5ZrcfbgeB15wJIodFonuXlEHQDB2gWKbD5I5LSK7ANCLYwwoueUktlBYrKhrAbHjJpea8BxktXf7k5ZP2gvRDX+H4p63gB4bmxRMHsZHZwzgXnqGPQ3jr/XhDFEL0/6AqMniMPqclaHd/bJ+LM5Sv+91XahYVY1Yz60wnVyY6pf9jvfSxZGuG0ye/A==; 5:/P34skWyNx0Kt2aGMVQkfNiUE73BLJeereV+hXDD3cLelqzZgwBLgdzEgAqtE7/XcFGjImfCPzoFz5CPRJv+Q5YrMSvf2lZt7qrmQNzW3Od0XbG1q52OSdUOf3nwsEfvzj+fJE0h+irJDDSthGL4KWAs3JBwIL/DgaYVXTWYNPM=; 7:cNcDTrAq+rN3anhQzdX4v5Dng2vMLrBFBjKj+00cQ1c0WTPNau5FlCTobUyu8iSKuZOvYmbYYPip8lkrorRT0ESSL2snkU3mEf+EmNtkf1BhQq6SwHlW6AgMkd4l7Pj+ecqG+GnEgm6LN6jMaMDGTw== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: eb20e487-7157-496b-a1e5-08d66aef10b1 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB4112; x-ms-traffictypediagnostic: VI1PR04MB4112: x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(2401047)(8121501046)(3231475)(944501520)(4982022)(52105112)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041310)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR04MB4112; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB4112; x-forefront-prvs: 0898A6E028 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(376002)(136003)(39860400002)(396003)(199004)(189003)(13464003)(54906003)(14454004)(93886005)(6506007)(76176011)(81156014)(105586002)(81166006)(74316002)(316002)(186003)(26005)(5660300001)(2906002)(53546011)(102836004)(33656002)(229853002)(6916009)(55016002)(55236004)(8676002)(8936002)(3846002)(6116002)(106356001)(7696005)(7736002)(305945005)(6436002)(53936002)(478600001)(9686003)(53946003)(16799955002)(6246003)(66066001)(486006)(6306002)(97736004)(78486014)(11346002)(476003)(86362001)(44832011)(45080400002)(68736007)(446003)(25786009)(4326008)(19627235002)(966005)(4744004)(256004)(14444005)(71190400001)(99286004)(71200400001)(579004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB4112; H:VI1PR04MB4685.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: SVc9qlkttV26p0Qtq11x7Afl87mzhi2LnJKciIuNQOtwD85d9AY8UFavGYkJXb+cgCL+D6FYL/xKLsjoHMeYs9tqOJ1ltPAto5gg6Dy+MnctrIL7dQ+ldm7zNPSUil+Hu2gfAAoEbi43/vyA41JGvpUyx7CBJqg1K3xYfegV7xBKSZFJsDculrg0dMhfpj+F38/biNmOWoZn4RlDhIshYtigsax92W3PBNjywpUIcTi0ratOD0+0ENrJLo71AaBPfcx+O+LudpkT+x9u3A6nDNeLPXapeqDjXrYbRjH9HHaL92zeZ/i5+2n9Osw/9avA spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb20e487-7157-496b-a1e5-08d66aef10b1 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Dec 2018 05:00:32.7777 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4112 Subject: Re: [PATCH edk2-platforms 01/41] Silicon/NXP: Add Library to return Mmio APIs pointer X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Dec 2018 05:00:39 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thank you Ard and Leif for all the comments, we will work on your review c= omments and share the next version soon. > -----Original Message----- > From: Leif Lindholm > Sent: Saturday, December 22, 2018 12:48 AM > To: Meenakshi Aggarwal > Cc: ard.biesheuvel@linaro.org; michael.d.kinney@intel.com; edk2- > devel@lists.01.org; Udit Kumar ; Varun Sethi > > Subject: Re: [PATCH edk2-platforms 01/41] Silicon/NXP: Add Library to ret= urn > Mmio APIs pointer >=20 > On Wed, Nov 28, 2018 at 08:31:15PM +0530, Meenakshi Aggarwal wrote: > > This library add supports to return pointer to MMIO APIs on basis of > > Swap flag. > > If Flag is True then MMION APIs returened in which data swapped after > > reading from MMIO and before write using MMIO. >=20 > I conspicuously left this one for last. >=20 > First thing I would like to see is splitting the setting up of function p= ointers bit > from the actual I/O accesses (separate patches). >=20 > The I/O functions belong in edk2 MdeModulePkg (or possibly EmbeddedPkg, o= f > for some reason they don't want it in MdePkg). > But regardless, please send that as a separate patch, preceding the edk2- > platforms set. >=20 > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Meenakshi Aggarwal > > --- > > Silicon/NXP/Include/Library/IoAccessLib.h | 332 ++++++++++++++++= +++ > > Silicon/NXP/Library/IoAccessLib/IoAccessLib.c | 410 > ++++++++++++++++++++++++ > > Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf | 32 ++ > > 3 files changed, 774 insertions(+) > > create mode 100644 Silicon/NXP/Include/Library/IoAccessLib.h > > create mode 100644 Silicon/NXP/Library/IoAccessLib/IoAccessLib.c > > create mode 100644 Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf > > > > diff --git a/Silicon/NXP/Include/Library/IoAccessLib.h > > b/Silicon/NXP/Include/Library/IoAccessLib.h > > new file mode 100644 > > index 0000000..f7372a5 > > --- /dev/null > > +++ b/Silicon/NXP/Include/Library/IoAccessLib.h > > @@ -0,0 +1,332 @@ > > +/** @file > > + * > > + * Copyright 2017 NXP > > + * > > + * This program and the accompanying materials > > + * are licensed and made available under the terms and conditions of > > +the BSD License > > + * which accompanies this distribution. The full text of the > > +license may be found at > > + * > > +https://emea01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fop= e > > +nsource.org%2Flicenses%2Fbsd- > license.php&data=3D02%7C01%7Cmeenakshi > > > +.aggarwal%40nxp.com%7C7d85cd38d02e4e6bbdc208d6677905c6%7C686ea1d > 3bc2b > > > +4c6fa92cd99c5c301635%7C0%7C0%7C636810166817008412&sdata=3DOU > EJ2URy5 > > +LX7wpvNs9f%2BK01Q1nahX2nWPNO67yOT57M%3D&reserved=3D0 > > + * > > + * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > > +BASIS, > > + * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > > + * > > + **/ > > + > > +#ifndef __IO_ACCESS_LIB_H__ > > +#define __IO_ACCESS_LIB_H__ > > + > > +#include > > + > > +/// > > +/// Structure to have pointer to R/W /// Mmio operations for 16 > > +bits. > > +/// > > +typedef struct _MMIO_OPERATIONS_16 { > > + UINT16 (*Read) (UINTN Address); > > + UINT16 (*Write) (UINTN Address, UINT16 Value); > > + UINT16 (*Or) (UINTN Address, UINT16 Or); > > + UINT16 (*And) (UINTN Address, UINT16 AND); > > + UINT16 (*AndThenOr) (UINTN Address, UINT16 And, UINT16 Or); } > > +MMIO_OPERATIONS_16; >=20 > I have sort of hinted at this in earlier comments on this set: >=20 > Why separate structs for different access sizes? > I don't expect there will be a noticeable image size or performance diffe= rence if > they are all put into one structure. And if there is. we can conditionali= se the > inclusion of different widths with FixedPcds. >=20 > So I would like for just a single GetMmioOperations() function that retur= ns a > single struct. And I would like for the member functions to have the acce= ss size > as the suffix to their names, just like the regular IoLib functions. >=20 > > + > > +/// > > +/// Structure to have pointer to R/W /// Mmio operations for 32 > > +bits. > > +/// > > +typedef struct _MMIO_OPERATIONS_32 { > > + UINT32 (*Read) (UINTN Address); > > + UINT32 (*Write) (UINTN Address, UINT32 Value); > > + UINT32 (*Or) (UINTN Address, UINT32 Or); > > + UINT32 (*And) (UINTN Address, UINT32 AND); > > + UINT32 (*AndThenOr) (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 (*Read) (UINTN Address); > > + UINT64 (*Write) (UINTN Address, UINT64 Value); > > + UINT64 (*Or) (UINTN Address, UINT64 Or); > > + UINT64 (*And) (UINTN Address, UINT64 AND); > > + UINT64 (*AndThenOr) (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. >=20 > There is nothing inherently Big-Endian about this. > It is byte-swapping. >=20 > This concludes my review of this set, and I will now disappear on holiday= until 7 > January. >=20 > Best Regards, >=20 > Leif >=20 > > + > > + @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 > > new file mode 100644 > > index 0000000..0260777 > > --- /dev/null > > +++ b/Silicon/NXP/Library/IoAccessLib/IoAccessLib.c > > @@ -0,0 +1,410 @@ > > +/** IoAccessLib.c > > + > > + Provide MMIO APIs for BE modules. > > + > > + Copyright 2017 NXP > > + > > + This program and the accompanying materials are licensed and made > > + available under the terms and conditions of the BSD License which > > + accompanies this distribution. The full text of the license may be > > + found at > > + > > + https://emea01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fo= p > > + ensource.org%2Flicenses%2Fbsd- > license.php&data=3D02%7C01%7Cmeenaks > > + > hi.aggarwal%40nxp.com%7C7d85cd38d02e4e6bbdc208d6677905c6%7C686ea1 > d3b > > + > c2b4c6fa92cd99c5c301635%7C0%7C0%7C636810166817008412&sdata=3DO > UEJ2 > > + URy5LX7wpvNs9f%2BK01Q1nahX2nWPNO67yOT57M%3D&reserved=3D0 > > + > > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > > + BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, > EITHER EXPRESS OR IMPLIED. > > + > > +**/ > > + > > +#include > > +#include > > +#include > > +#include > > + > > +/** > > + MmioRead16 for Big-Endian modules. > > + > > + @param Address The MMIO register to read. > > + > > + @return The value read. > > + > > +**/ > > +UINT16 > > +EFIAPI > > +SwapMmioRead16 ( > > + IN UINTN Address > > + ) > > +{ > > + return SwapBytes16 (MmioRead16 (Address)); } > > + > > +/** > > + MmioRead32 for Big-Endian modules. > > + > > + @param Address The MMIO register to read. > > + > > + @return The value read. > > + > > +**/ > > +UINT32 > > +EFIAPI > > +SwapMmioRead32 ( > > + IN UINTN Address > > + ) > > +{ > > + return SwapBytes32 (MmioRead32 (Address)); } > > + > > +/** > > + MmioRead64 for Big-Endian modules. > > + > > + @param Address The MMIO register to read. > > + > > + @return The value read. > > + > > +**/ > > +UINT64 > > +EFIAPI > > +SwapMmioRead64 ( > > + IN UINTN Address > > + ) > > +{ > > + return SwapBytes64 (MmioRead64 (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 > > + ) > > +{ > > + return MmioWrite16 (Address, SwapBytes16 (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 > > + ) > > +{ > > + return MmioWrite32 (Address, SwapBytes32 (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 > > + ) > > +{ > > + return MmioWrite64 (Address, SwapBytes64 (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 > > + ) > > +{ > > + AndData =3D SwapBytes16 (AndData); > > + OrData =3D SwapBytes16 (OrData); > > + > > + return MmioAndThenOr16 (Address, AndData, 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 > > + ) > > +{ > > + AndData =3D SwapBytes32 (AndData); > > + OrData =3D SwapBytes32 (OrData); > > + > > + return MmioAndThenOr32 (Address, AndData, 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 > > + ) > > +{ > > + AndData =3D SwapBytes64 (AndData); > > + OrData =3D SwapBytes64 (OrData); > > + > > + return MmioAndThenOr64 (Address, AndData, 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 > > + ) > > +{ > > + return MmioOr16 (Address, SwapBytes16 (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 > > + ) > > +{ > > + return MmioOr32 (Address, SwapBytes32 (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 > > + ) > > +{ > > + return MmioOr64 (Address, SwapBytes64 (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 > > + ) > > +{ > > + return MmioAnd16 (Address, SwapBytes16 (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 > > + ) > > +{ > > + return MmioAnd32 (Address, SwapBytes32 (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 > > + ) > > +{ > > + return MmioAnd64 (Address, SwapBytes64 (AndData)); } > > + > > +STATIC MMIO_OPERATIONS_16 SwappingFunctions16 =3D { > > + SwapMmioRead16, > > + SwapMmioWrite16, > > + SwapMmioOr16, > > + SwapMmioAnd16, > > + SwapMmioAndThenOr16, > > +}; > > + > > +STATIC MMIO_OPERATIONS_16 NonSwappingFunctions16 =3D { > > + MmioRead16, > > + MmioWrite16, > > + MmioOr16, > > + MmioAnd16, > > + MmioAndThenOr16, > > +}; > > + > > +STATIC MMIO_OPERATIONS_32 SwappingFunctions32 =3D { > > + SwapMmioRead32, > > + SwapMmioWrite32, > > + SwapMmioOr32, > > + SwapMmioAnd32, > > + SwapMmioAndThenOr32, > > +}; > > + > > +STATIC MMIO_OPERATIONS_32 NonSwappingFunctions32 =3D { > > + MmioRead32, > > + MmioWrite32, > > + MmioOr32, > > + MmioAnd32, > > + MmioAndThenOr32, > > +}; > > + > > +STATIC MMIO_OPERATIONS_64 SwappingFunctions64 =3D { > > + SwapMmioRead64, > > + SwapMmioWrite64, > > + SwapMmioOr64, > > + SwapMmioAnd64, > > + SwapMmioAndThenOr64, > > +}; > > + > > +STATIC MMIO_OPERATIONS_64 NonSwappingFunctions64 =3D { > > + 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; > > + } > > +} > > diff --git a/Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf > > b/Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf > > new file mode 100644 > > index 0000000..e2e7606 > > --- /dev/null > > +++ b/Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf > > @@ -0,0 +1,32 @@ > > +## @IoAccessLib.inf > > + > > +# Copyright 2017 NXP > > +# > > +# This program and the accompanying materials # are licensed and > > +made available under the terms and conditions of the BSD License # > > +which accompanies this distribution. The full text of the license > > +may be found at # > > +https://emea01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fop= e > > +nsource.org%2Flicenses%2Fbsd- > license.php&data=3D02%7C01%7Cmeenakshi > > > +.aggarwal%40nxp.com%7C7d85cd38d02e4e6bbdc208d6677905c6%7C686ea1d > 3bc2b > > > +4c6fa92cd99c5c301635%7C0%7C0%7C636810166817008412&sdata=3DOU > EJ2URy5 > > +LX7wpvNs9f%2BK01Q1nahX2nWPNO67yOT57M%3D&reserved=3D0 > > +# > > +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > > +BASIS, # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, > EITHER EXPRESS OR IMPLIED. > > +# > > +## > > + > > +[Defines] > > + INF_VERSION =3D 0x0001001A > > + BASE_NAME =3D IoAccessLib > > + FILE_GUID =3D 28d77333-77eb-4faf-8735-130e5eb3e= 343 > > + MODULE_TYPE =3D BASE > > + VERSION_STRING =3D 1.0 > > + LIBRARY_CLASS =3D IoAccessLib > > + > > +[Sources.common] > > + IoAccessLib.c > > + > > +[Packages] > > + MdeModulePkg/MdeModulePkg.dec > > + MdePkg/MdePkg.dec > > + Silicon/NXP/NxpQoriqLs.dec > > + > > +[LibraryClasses] > > + IoLib > > -- > > 1.9.1 > >