From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=104.47.2.65; helo=eur01-db5-obe.outbound.protection.outlook.com; envelope-from=udit.kumar@nxp.com; receiver=edk2-devel@lists.01.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0065.outbound.protection.outlook.com [104.47.2.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CB65A2244E41C for ; Mon, 16 Apr 2018 23:57:49 -0700 (PDT) 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; bh=zmMFznD75GBmGzUydwYTBxvaiXJpVClzj49+TqPKGCc=; b=JQLjRqYowgl7qj3tyJ24+Jw1qiETUz+FmBFZ1G8Kykj31EQ4UyAGfpTqt2m7L/YEuwXyCYctIKmxc23a2xUaoTNqkmmDx314/WYpvlua7WMeqgpEbM9XkHEtbZEzG5k76qEDLSb6NW9xEvEYfMWkicLtdZUyoFfvqUXzL0ohVzg= Received: from AM6PR0402MB3334.eurprd04.prod.outlook.com (52.133.18.151) by AM6PR0402MB3333.eurprd04.prod.outlook.com (52.133.18.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.675.14; Tue, 17 Apr 2018 06:57:42 +0000 Received: from AM6PR0402MB3334.eurprd04.prod.outlook.com ([fe80::28c1:57d5:1b06:e35b]) by AM6PR0402MB3334.eurprd04.prod.outlook.com ([fe80::28c1:57d5:1b06:e35b%13]) with mapi id 15.20.0675.015; Tue, 17 Apr 2018 06:57:42 +0000 From: Udit Kumar To: "Kinney, Michael D" , Leif Lindholm CC: "edk2-devel@lists.01.org" , Laszlo Ersek , "Gao, Liming" Thread-Topic: [edk2] [PATCH] MdePkg: add big-endian MMIO BaseBeIoLib Thread-Index: AQHT007FDvjdHbPkR0WQ38GOtMXuhKP/EwwggAB3ywD//8uvEIAETZUA///NthCAARkggA== Date: Tue, 17 Apr 2018 06:57:41 +0000 Message-ID: References: <20180413174211.858-1-leif.lindholm@linaro.org> <20180413193143.t45tua3yi7sopk4d@bivouac.eciton.net> <20180416100712.6v642ycksvmoffvt@bivouac.eciton.net> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=udit.kumar@nxp.com; x-originating-ip: [14.143.30.134] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM6PR0402MB3333; 7:anEM9eBpYRoYdIY2mBZCO2yKKdB6ZA7+wN/TktUl/+1YRO7YIxDwYUFo9PU4SjFOkq3EI6ige8aoDZpBndWvsrfTCT2CVXGOK96phcb3yvd7GUZrtV49k9QzFPUwiB891r9FLGAuNIqVu6dgNUUJ2f3BFEq8GNl73mIYAF94TnyGcyT+4zMJH+E5CSbnT/Ae3rM2UTSVwLidWadCLPt4Eyhy/dsh1gT2aPmmA5MMaoxxDVUAVKlxiHRt9CZO6/uA x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020); SRVR:AM6PR0402MB3333; x-ms-traffictypediagnostic: AM6PR0402MB3333: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(189930954265078)(35073007944872)(185117386973197)(162533806227266)(45079756050767)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231232)(944501327)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:AM6PR0402MB3333; BCL:0; PCL:0; RULEID:; SRVR:AM6PR0402MB3333; x-forefront-prvs: 0645BEB7AA x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6029001)(39860400002)(396003)(346002)(39380400002)(376002)(366004)(13464003)(43544003)(189003)(199004)(76176011)(55016002)(6246003)(16799955002)(6436002)(316002)(229853002)(2900100001)(7696005)(99286004)(186003)(9686003)(2906002)(53946003)(6306002)(53936002)(5250100002)(3660700001)(3280700002)(476003)(486006)(11346002)(16200700003)(44832011)(446003)(575784001)(86362001)(97736004)(45080400002)(25786009)(4326008)(966005)(478600001)(66066001)(59450400001)(105586002)(106356001)(53546011)(6506007)(55236004)(33656002)(6116002)(26005)(93886005)(81166006)(8676002)(305945005)(102836004)(74316002)(54906003)(8936002)(81156014)(5660300001)(68736007)(14454004)(3846002)(7736002)(110136005)(559001)(569006); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR0402MB3333; H:AM6PR0402MB3334.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: vYUKcXVUBBEFnmw5i6GvIeKmAt9iNXFiJKQdbk4tHzyJK4JMLL8kbkyWdobEsahO4Dg/Jk1lTsUnzZw4rdvzs9N1IvN9B38z/4gzrSGzewir1WVbkG9sbM/3Tf42gpvFcUw2Rnb9l2H6j3UqO/F/JbNWJEpf0pi9INHsgyLvWWX/MXqPiDxwVsx7ud0kY/aI spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 852a7c30-d911-4d05-edb5-08d5a43083d5 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 852a7c30-d911-4d05-edb5-08d5a43083d5 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Apr 2018 06:57:41.9076 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0402MB3333 Subject: Re: [PATCH] MdePkg: add big-endian MMIO BaseBeIoLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Apr 2018 06:57:50 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Mike,=20 Do we want to support BE CPUs, ? If yes then Last discussion of Lazlo is valid, where driver don't need to t= ake care of CPU endianness.=20 Regards Udit=20 > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Kinney, Michael D > Sent: Monday, April 16, 2018 7:41 PM > To: Leif Lindholm ; Kinney, Michael D > > Cc: edk2-devel@lists.01.org; Laszlo Ersek ; Gao, Limin= g > > Subject: Re: [edk2] [PATCH] MdePkg: add big-endian MMIO BaseBeIoLib >=20 > Leif, >=20 > I agree that the opposite use case is a BE CPU > needing a LE operation. >=20 > I think we only need a single lib class and lib > Instance that does the byte swap and we should > not use Le or Be in any of the names of the class, > instance, or APIs. Just "Swap". >=20 > The 4 cases >=20 > * LE CPU, LE I/O. Use BaseIoLib > * BE CPU, BE I/O. Use BaseIoLib > * LE CPU, BE I/O. Use BaseIoSwapLib > * BE CPU, LE I/O. Use BaseIoSwapLib >=20 > Mike >=20 >=20 > > -----Original Message----- > > From: Leif Lindholm [mailto:leif.lindholm@linaro.org] > > Sent: Monday, April 16, 2018 3:07 AM > > To: Kinney, Michael D > > Cc: edk2-devel@lists.01.org; Laszlo Ersek > > ; Gao, Liming > > Subject: Re: [edk2] [PATCH] MdePkg: add big-endian MMIO > > BaseBeIoLib > > > > On Fri, Apr 13, 2018 at 11:32:35PM +0000, Kinney, > > Michael D wrote: > > > Leif, > > > > > > I am curious why a Swap class/instances is not > > sufficient. > > > > > > Currently EDK II follows the UEFI/PI specs, which for > > > all supported CPU architectures use little endian > > ABI. > > > The BaseIoLib follows the endianness of the CPU. If > > > UEFI/PI added a CPU that was big endian, I would > > expect > > > BaseIoLib when built for that CPU would perform big > > endian > > > operations. > > > > > > Am I missing something? > > > > If you did add a big-endian CPU, you could then find > > yourself in the > > exact opposite situation and require a little-endian > > i/o access > > library. Which would be implemented exactly as the > > contents of > > IoLibSwap.c. > > > > The header file necessarily needs to be endianness- > > specific, and if > > the coding style had permitted functions in header > > files, my automatic > > reaction would have been to make all of these static > > inline helper > > functions (even with the code duplication). > > > > / > > Leif > > > > > Mike > > > > > > > > > > -----Original Message----- > > > > From: edk2-devel [mailto:edk2-devel- > > > > bounces@lists.01.org] On Behalf Of Leif Lindholm > > > > Sent: Friday, April 13, 2018 12:32 PM > > > > To: Kinney, Michael D > > > > Cc: edk2-devel@lists.01.org; Laszlo Ersek > > > > ; Gao, Liming > > > > > > Subject: Re: [edk2] [PATCH] MdePkg: add big-endian > > MMIO > > > > BaseBeIoLib > > > > > > > > On Fri, Apr 13, 2018 at 07:24:06PM +0000, Kinney, > > > > Michael D wrote: > > > > > Hi Leif, > > > > > > > > > > I think we need to look at the names. I see a > > mix of > > > > > "Be" and "Swap". We should pick one and use it > > > > > consistently. > > > > > > > > This was what I meant by the comments: > > > > --- > > > > This modified version introduces a single BeIoLib > > > > instance, backed by > > > > a source-file that could be used also for a > > > > hypothetical LeIoLib. > > > > There is no LeIoLib.h included though. > > > > > > > > While this is arguably overengineered, I do feel > > > > reasonably strongly > > > > that code should be named for what it does, not for > > how > > > > it is used, > > > > and doing it this way lets me follow that rule. > > > > --- > > > > > > > > Clearly this is open for discussion, but the above > > is > > > > my opinion and > > > > the code intentionally reflects that. > > > > > > > > Regards, > > > > > > > > Leif > > > > > > > > > Mike > > > > > > > > > > > -----Original Message----- > > > > > > From: Leif Lindholm > > > > [mailto:leif.lindholm@linaro.org] > > > > > > Sent: Friday, April 13, 2018 10:42 AM > > > > > > To: edk2-devel@lists.01.org > > > > > > Cc: Kinney, Michael D > > ; > > > > > > Gao, Liming ; Laszlo > > Ersek > > > > > > ; udit.kumar@nxp.com > > > > > > Subject: [PATCH] MdePkg: add big-endian MMIO > > > > > > BaseBeIoLib > > > > > > > > > > > > When performing MMIO to a destination of the > > > > opposite > > > > > > endianness to the > > > > > > executing processor, this library provides > > > > automatic > > > > > > byte order reversal > > > > > > on inputs and outputs. > > > > > > > > > > > > Contributed-under: TianoCore Contribution > > Agreement > > > > 1.1 > > > > > > Signed-off-by: Leif Lindholm > > > > > > > > > > --- > > > > > > > > > > > > Udit, many apologies for this dragging out - > > back- > > > > to- > > > > > > back conferences, > > > > > > holidays, and lots of catching up. > > > > > > > > > > > > This modified version introduces a single > > BeIoLib > > > > > > instance, backed by > > > > > > a source-file that could be used also for a > > > > > > hypothetical LeIoLib. > > > > > > There is no LeIoLib.h included though. > > > > > > > > > > > > While this is arguably overengineered, I do > > feel > > > > > > reasonably strongly > > > > > > that code should be named for what it does, not > > for > > > > how > > > > > > it is used, > > > > > > and doing it this way lets me follow that rule. > > > > > > > > > > > > I have not duplicated the .uni file together > > with > > > > the > > > > > > .inf, since > > > > > > this follows what is done in > > BaseIoLibIntrinsic. > > > > > > > > > > > > MdePkg/Include/Library/BeIoLib.h > > | > > > > 376 > > > > > > +++++++++++++++++++ > > > > > > MdePkg/Library/BaseIoLibSwap/BaseBeIoLib.inf > > | > > > > 48 > > > > > > +++ > > > > > > MdePkg/Library/BaseIoLibSwap/BaseIoLibSwap.uni > > | > > > > 23 > > > > > > ++ > > > > > > MdePkg/Library/BaseIoLibSwap/IoLibSwap.c > > | > > > > 477 > > > > > > +++++++++++++++++++++++++ > > > > > > MdePkg/MdePkg.dec > > | > > > > 3 + > > > > > > 5 files changed, 927 insertions(+) > > > > > > create mode 100644 > > > > MdePkg/Include/Library/BeIoLib.h > > > > > > create mode 100644 > > > > > > MdePkg/Library/BaseIoLibSwap/BaseBeIoLib.inf > > > > > > create mode 100644 > > > > > > MdePkg/Library/BaseIoLibSwap/BaseIoLibSwap.uni > > > > > > create mode 100644 > > > > > > MdePkg/Library/BaseIoLibSwap/IoLibSwap.c > > > > > > > > > > > > diff --git a/MdePkg/Include/Library/BeIoLib.h > > > > > > b/MdePkg/Include/Library/BeIoLib.h > > > > > > new file mode 100644 > > > > > > index 0000000000..5b2dc1a8e1 > > > > > > --- /dev/null > > > > > > +++ b/MdePkg/Include/Library/BeIoLib.h > > > > > > @@ -0,0 +1,376 @@ > > > > > > +/** @file > > > > > > + Provide byte-swapping services to access > > MMIO > > > > > > registers. > > > > > > + > > > > > > +Copyright (c) 2006 - 2012, Intel Corporation. > > All > > > > > > rights reserved.
> > > > > > +Copyright (c) 2017, AMD Incorporated. All > > rights > > > > > > reserved.
> > > > > > +Copyright (c) 2018, Linaro ltd. All rights > > > > > > reserved.
> > > > > > + > > > > > > +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%2Fopen= s > ource.org%2Flicenses%2Fbsd- > license.php&data=3D02%7C01%7Cudit.kumar%40nxp.com%7Cb19fee0925904c90 > 410408d5a3a3e0cf%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63 > 6594846625431426&sdata=3DeLshi0I6KkdE%2Fu29DsZEtIiE86NLDeps%2FaG9USh0 > wcw%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 __BE_IO_LIB_H__ > > > > > > +#define __BE_IO_LIB_H__ > > > > > > + > > > > > > +/** > > > > > > + Reads a 16-bit MMIO register of opposite > > > > endianness. > > > > > > + > > > > > > + Reads the 16-bit MMIO register specified by > > > > Address. > > > > > > + The 16-bit read value is returned in > > reversed > > > > byte > > > > > > order. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @param Address The MMIO register to read. > > > > > > + > > > > > > + @return The value read. > > > > > > + > > > > > > +**/ > > > > > > +UINT16 > > > > > > +EFIAPI > > > > > > +BeMmioRead16 ( > > > > > > + IN UINTN Address > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Writes a 16-bit MMIO register of opposite > > > > > > endianness. > > > > > > + > > > > > > + Writes the 16-bit MMIO register specified by > > > > Address > > > > > > with the byte-reversed > > > > > > + version of the value specified by Value and > > > > returns > > > > > > the original Value. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @param Address The MMIO register to write. > > > > > > + @param Value The value to write to the > > MMIO > > > > > > register. > > > > > > + > > > > > > + @return Value. > > > > > > + > > > > > > +**/ > > > > > > +UINT16 > > > > > > +EFIAPI > > > > > > +BeMmioWrite16 ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT16 Value > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Reads a 16-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise OR, > > > > > > + and writes the result back to the 16-bit > > MMIO > > > > > > register. > > > > > > + > > > > > > + Reads the 16-bit MMIO register specified by > > > > Address, > > > > > > byte-reverses the read > > > > > > + result, performs a bitwise OR between the > > read > > > > > > result and the value specified > > > > > > + by OrData, byte-reverses the result, and > > writes > > > > the > > > > > > result to the 16-bit MMIO > > > > > > + register specified by Address. The pre- > > reversal > > > > > > value written to the MMIO > > > > > > + register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +BeMmioOr16 ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT16 OrData > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Reads a 16-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise AND, > > > > > > + and writes the result back to the 16-bit > > MMIO > > > > > > register. > > > > > > + > > > > > > + Reads the 16-bit MMIO register specified by > > > > Address, > > > > > > byte-reverses the read > > > > > > + result, performs a bitwise AND between the > > read > > > > > > result and the value specified > > > > > > + by AndData, byte-reverses the result, and > > writes > > > > the > > > > > > result to the 16-bit MMIO > > > > > > + register specified by Address. The pre- > > reversal > > > > > > value written to the MMIO > > > > > > + register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +BeMmioAnd16 ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT16 AndData > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Reads a 16-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise AND > > > > > > + followed by a bitwise OR, and writes the > > result > > > > back > > > > > > to the 16-bit MMIO > > > > > > + register. > > > > > > + > > > > > > + Reads the 16-bit MMIO register specified by > > > > Address, > > > > > > byte reverses the read > > > > > > + result, performs a bitwise AND between the > > read > > > > > > result and the value specified > > > > > > + by AndData, performs a bitwise OR between > > the > > > > result > > > > > > of the AND operation and > > > > > > + the value specified by OrData, byte-reverses > > the > > > > > > result, and writes the result > > > > > > + to the 16-bit MMIO register specified by > > > > Address. > > > > > > The pre-reversal value > > > > > > + written to the MMIO register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +BeMmioAndThenOr16 ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT16 AndData, > > > > > > + IN UINT16 OrData > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Reads a 32-bit MMIO register of opposite > > > > endianness. > > > > > > + > > > > > > + Reads the 32-bit MMIO register specified by > > > > Address. > > > > > > + The 32-bit read value is returned in > > reversed > > > > byte > > > > > > order. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @param Address The MMIO register to read. > > > > > > + > > > > > > + @return The value read. > > > > > > + > > > > > > +**/ > > > > > > +UINT32 > > > > > > +EFIAPI > > > > > > +BeMmioRead32 ( > > > > > > + IN UINTN Address > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Writes a 32-bit MMIO register of opposite > > > > > > endianness. > > > > > > + > > > > > > + Writes the 32-bit MMIO register specified by > > > > Address > > > > > > with the byte-reversed > > > > > > + version of the value specified by Value and > > > > returns > > > > > > the original Value. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @param Address The MMIO register to write. > > > > > > + @param Value The value to write to the > > MMIO > > > > > > register. > > > > > > + > > > > > > + @return Value. > > > > > > + > > > > > > +**/ > > > > > > +UINT32 > > > > > > +EFIAPI > > > > > > +BeMmioWrite32 ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT32 Value > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Reads a 32-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise OR, > > > > > > + and writes the result back to the 32-bit > > MMIO > > > > > > register. > > > > > > + > > > > > > + Reads the 32-bit MMIO register specified by > > > > Address, > > > > > > byte-reverses the read > > > > > > + result, performs a bitwise OR between the > > read > > > > > > result and the value specified > > > > > > + by OrData, byte-reverses the result, and > > writes > > > > the > > > > > > result to the 32-bit MMIO > > > > > > + register specified by Address. The pre- > > reversal > > > > > > value written to the MMIO > > > > > > + register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +BeMmioOr32 ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT32 OrData > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Reads a 32-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise AND, > > > > > > + and writes the result back to the 32-bit > > MMIO > > > > > > register. > > > > > > + > > > > > > + Reads the 32-bit MMIO register specified by > > > > Address, > > > > > > byte-reverses the read > > > > > > + result, performs a bitwise AND between the > > read > > > > > > result and the value specified > > > > > > + by AndData, byte-reverses the result, and > > writes > > > > the > > > > > > result to the 32-bit MMIO > > > > > > + register specified by Address. The pre- > > reversal > > > > > > value written to the MMIO > > > > > > + register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +BeMmioAnd32 ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT32 AndData > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Reads a 32-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise AND > > > > > > + followed by a bitwise OR, and writes the > > result > > > > back > > > > > > to the 32-bit MMIO > > > > > > + register. > > > > > > + > > > > > > + Reads the 32-bit MMIO register specified by > > > > Address, > > > > > > byte reverses the read > > > > > > + value, performs a bitwise AND between the > > read > > > > > > result and the value specified > > > > > > + by AndData, performs a bitwise OR between > > the > > > > result > > > > > > of the AND operation and > > > > > > + the value specified by OrData, byte-reverses > > the > > > > > > result, and writes the result > > > > > > + to the 32-bit MMIO register specified by > > > > Address. > > > > > > The pre-reversal value > > > > > > + written to the MMIO register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +BeMmioAndThenOr32 ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT32 AndData, > > > > > > + IN UINT32 OrData > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Reads a 64-bit MMIO register of opposite > > > > endianness. > > > > > > + > > > > > > + Reads the 64-bit MMIO register specified by > > > > Address. > > > > > > + The 64-bit read value is returned in > > reversed > > > > byte > > > > > > order. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @param Address The MMIO register to read. > > > > > > + > > > > > > + @return The value read. > > > > > > + > > > > > > +**/ > > > > > > +UINT64 > > > > > > +EFIAPI > > > > > > +BeMmioRead64 ( > > > > > > + IN UINTN Address > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Writes a 64-bit MMIO register of opposite > > > > > > endianness. > > > > > > + > > > > > > + Writes the 64-bit MMIO register specified by > > > > Address > > > > > > with the byte-reversed > > > > > > + version of the value specified by Value and > > > > returns > > > > > > Value. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @param Address The MMIO register to write. > > > > > > + @param Value The value to write to the > > MMIO > > > > > > register. > > > > > > + > > > > > > +**/ > > > > > > +UINT64 > > > > > > +EFIAPI > > > > > > +BeMmioWrite64 ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT64 Value > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Reads a 64-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise OR, > > > > > > + and writes the result back to the 64-bit > > MMIO > > > > > > register. > > > > > > + > > > > > > + Reads the 64-bit MMIO register specified by > > > > Address, > > > > > > byte reverses the read > > > > > > + result, performs a bitwise OR between the > > read > > > > > > result and the value specified > > > > > > + by OrData, byte-reverses the result, and > > writes > > > > the > > > > > > result to the 64-bit MMIO > > > > > > + register specified by Address. The pre- > > reversal > > > > > > value written to the > > > > > > + MMIO register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +BeMmioOr64 ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT64 OrData > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Reads a 64-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise AND, > > > > > > + and writes the result back to the 64-bit > > MMIO > > > > > > register. > > > > > > + > > > > > > + Reads the 64-bit MMIO register specified by > > > > Address, > > > > > > byte-reverses the read > > > > > > + value, performs a bitwise AND between the > > read > > > > > > result and the value specified > > > > > > + by AndData, byte-reverses the result, and > > writes > > > > the > > > > > > result to the 64-bit MMIO > > > > > > + register specified by Address. The pre- > > reversal > > > > > > value written to the MMIO > > > > > > + register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +BeMmioAnd64 ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT64 AndData > > > > > > + ); > > > > > > + > > > > > > +/** > > > > > > + Reads a 64-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise AND > > > > > > + followed by a bitwise OR, and writes the > > result > > > > back > > > > > > to the 64-bit MMIO > > > > > > + register. > > > > > > + > > > > > > + Reads the 64-bit MMIO register specified by > > > > Address, > > > > > > byte-reverses the read > > > > > > + result, performs a bitwise AND between the > > read > > > > > > result and the value specified > > > > > > + by AndData, performs a bitwise OR between > > the > > > > result > > > > > > of the AND operation and > > > > > > + the value specified by OrData, byte-reverses > > the > > > > > > result, and writes the result > > > > > > + to the 64-bit MMIO register specified by > > > > Address. > > > > > > The pre-reversal value > > > > > > + written to the MMIO register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +BeMmioAndThenOr64 ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT64 AndData, > > > > > > + IN UINT64 OrData > > > > > > + ); > > > > > > + > > > > > > +#endif > > > > > > diff --git > > > > > > a/MdePkg/Library/BaseIoLibSwap/BaseBeIoLib.inf > > > > > > b/MdePkg/Library/BaseIoLibSwap/BaseBeIoLib.inf > > > > > > new file mode 100644 > > > > > > index 0000000000..fbd68b9929 > > > > > > --- /dev/null > > > > > > +++ > > b/MdePkg/Library/BaseIoLibSwap/BaseBeIoLib.inf > > > > > > @@ -0,0 +1,48 @@ > > > > > > +## @file > > > > > > +# Byte swapping I/O Library. > > > > > > +# > > > > > > +# Byte swapping I/O Library for all > > > > architectures. > > > > > > Only MMIO supported. I/O > > > > > > +# accesses take place through the normal > > IoLib, > > > > but > > > > > > values read and written > > > > > > +# are byte-reversed to interact with > > peripherals > > > > of > > > > > > non-native endianness. > > > > > > +# > > > > > > +# Copyright (c) 2007 - 2015, Intel > > Corporation. > > > > All > > > > > > rights reserved.
> > > > > > +# Portions copyright (c) 2008 - 2009, Apple > > Inc. > > > > All > > > > > > rights reserved.
> > > > > > +# Copyright (c) 2017, AMD Incorporated. All > > > > rights > > > > > > reserved.
> > > > > > +# > > > > > > +# 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%2Fopens= o > urce.org%2Flicenses%2Fbsd- > &data=3D02%7C01%7Cudit.kumar%40nxp.com%7Cb19fee0925904c90410408d5a > 3a3e0cf%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63659484662 > 5431426&sdata=3DNU7t2MgJuefLsTQO4sCpyb0yRHZCZtT5SkXbMJdpC%2Fk%3D&r > eserved=3D0 > > license.php. > > > > > > +# 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 BaseBeIoLib > > > > > > + MODULE_UNI_FILE =3D > > > > BaseIoLibSwap.uni > > > > > > + FILE_GUID =3D 073c3fbd- > > ff0d- > > > > 41b6- > > > > > > a209-1e42fd2a3bab > > > > > > + MODULE_TYPE =3D BASE > > > > > > + VERSION_STRING =3D 1.0 > > > > > > + LIBRARY_CLASS =3D BeIoLib > > > > > > + > > > > > > + > > > > > > +# > > > > > > +# VALID_ARCHITECTURES =3D IA32 X64 > > EBC > > > > IPF > > > > > > ARM AARCH64 > > > > > > +# > > > > > > + > > > > > > +[Sources] > > > > > > + IoLibSwap.c > > > > > > + > > > > > > +[Packages] > > > > > > + MdePkg/MdePkg.dec > > > > > > + > > > > > > +[LibraryClasses] > > > > > > + BaseLib > > > > > > + IoLib > > > > > > + > > > > > > +[BuildOptions] > > > > > > + GCC:*_*_*_CC_FLAGS =3D -D > > > > > > FUNCTION_PREFIX=3DBe > > > > > > + INTEL:*_*_*_CC_FLAGS =3D /D > > > > > > FUNCTION_PREFIX=3DBe > > > > > > + MSFT:*_*_*_CC_FLAGS =3D /D > > > > > > FUNCTION_PREFIX=3DBe > > > > > > diff --git > > > > > > > > a/MdePkg/Library/BaseIoLibSwap/BaseIoLibSwap.uni > > > > > > > > b/MdePkg/Library/BaseIoLibSwap/BaseIoLibSwap.uni > > > > > > new file mode 100644 > > > > > > index 0000000000..e35b4abef7 > > > > > > --- /dev/null > > > > > > +++ > > > > b/MdePkg/Library/BaseIoLibSwap/BaseIoLibSwap.uni > > > > > > @@ -0,0 +1,23 @@ > > > > > > +// /** @file > > > > > > +// Byte swapping I/O Library. > > > > > > +// > > > > > > +// Byte swapping I/O Library for all > > > > architectures. > > > > > > Only MMIO supported. I/O > > > > > > +// accesses take place through the normal > > IoLib, > > > > but > > > > > > values read and written > > > > > > +// are byte-reversed to interact with > > peripherals > > > > of > > > > > > non-native endianness. > > > > > > +// > > > > > > +// Copyright (c) 2018, Linaro ltd. All rights > > > > > > reserved.
> > > > > > +// > > > > > > +// 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%2Fopens= o > urce.org%2Flicenses%2Fbsd- > &data=3D02%7C01%7Cudit.kumar%40nxp.com%7Cb19fee0925904c90410408d5a > 3a3e0cf%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63659484662 > 5431426&sdata=3DNU7t2MgJuefLsTQO4sCpyb0yRHZCZtT5SkXbMJdpC%2Fk%3D&r > eserved=3D0 > > license.php. > > > > > > +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD > > > > LICENSE ON > > > > > > AN "AS IS" BASIS, > > > > > > +// WITHOUT WARRANTIES OR REPRESENTATIONS OF > > ANY > > > > KIND, > > > > > > EITHER EXPRESS OR IMPLIED. > > > > > > +// > > > > > > +// **/ > > > > > > + > > > > > > + > > > > > > +#string STR_MODULE_ABSTRACT > > #language > > > > en- > > > > > > US "Byte swapping I/O Library" > > > > > > + > > > > > > +#string STR_MODULE_DESCRIPTION > > #language > > > > en- > > > > > > US "Byte swapping I/O Library for all > > > > architectures. > > > > > > Only MMIO supported. I/O accesses take place > > > > through > > > > > > the normal IoLib, but values read and written > > are > > > > byte- > > > > > > reversed to interact with peripherals of non- > > native > > > > > > endianness." > > > > > > + > > > > > > diff --git > > > > a/MdePkg/Library/BaseIoLibSwap/IoLibSwap.c > > > > > > b/MdePkg/Library/BaseIoLibSwap/IoLibSwap.c > > > > > > new file mode 100644 > > > > > > index 0000000000..f4f49f72d2 > > > > > > --- /dev/null > > > > > > +++ b/MdePkg/Library/BaseIoLibSwap/IoLibSwap.c > > > > > > @@ -0,0 +1,477 @@ > > > > > > +/** @file > > > > > > + Provide byte-swapping services to access > > MMIO > > > > > > registers. > > > > > > + > > > > > > +Copyright (c) 2006 - 2012, Intel Corporation. > > All > > > > > > rights reserved.
> > > > > > +Copyright (c) 2017, AMD Incorporated. All > > rights > > > > > > reserved.
> > > > > > +Copyright (c) 2018, Linaro ltd. All rights > > > > > > reserved.
> > > > > > + > > > > > > +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%2Fopen= s > ource.org%2Flicenses%2Fbsd- > license.php&data=3D02%7C01%7Cudit.kumar%40nxp.com%7Cb19fee0925904c90 > 410408d5a3a3e0cf%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63 > 6594846625431426&sdata=3DeLshi0I6KkdE%2Fu29DsZEtIiE86NLDeps%2FaG9USh0 > wcw%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 > > > > > > + > > > > > > +#define __CONCATENATE(a, b) a ## b > > > > > > +#define _CONCATENATE(a, b) __CONCATENATE(a, b) > > > > > > +#define ADD_PREFIX(name) _CONCATENATE > > > > > > (FUNCTION_PREFIX, name) > > > > > > + > > > > > > +/** > > > > > > + Reads a 16-bit MMIO register of opposite > > > > endianness. > > > > > > + > > > > > > + Reads the 16-bit MMIO register specified by > > > > Address. > > > > > > + The 16-bit read value is returned in > > reversed > > > > byte > > > > > > order. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @param Address The MMIO register to read. > > > > > > + > > > > > > + @return The value read. > > > > > > + > > > > > > +**/ > > > > > > +UINT16 > > > > > > +EFIAPI > > > > > > +ADD_PREFIX (MmioRead16) ( > > > > > > + IN UINTN Address > > > > > > + ) > > > > > > +{ > > > > > > + return SwapBytes16 (MmioRead16 (Address)); > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Writes a 16-bit MMIO register of opposite > > > > > > endianness. > > > > > > + > > > > > > + Writes the 16-bit MMIO register specified by > > > > Address > > > > > > with the byte-reversed > > > > > > + version of the value specified by Value and > > > > returns > > > > > > the original Value. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @param Address The MMIO register to write. > > > > > > + @param Value The value to write to the > > MMIO > > > > > > register. > > > > > > + > > > > > > + @return Value. > > > > > > + > > > > > > +**/ > > > > > > +UINT16 > > > > > > +EFIAPI > > > > > > +ADD_PREFIX (MmioWrite16) ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT16 Value > > > > > > + ) > > > > > > +{ > > > > > > + (VOID) MmioWrite16 (Address, SwapBytes16 > > > > (Value)); > > > > > > + > > > > > > + return Value; > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Reads a 16-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise OR, > > > > > > + and writes the result back to the 16-bit > > MMIO > > > > > > register. > > > > > > + > > > > > > + Reads the 16-bit MMIO register specified by > > > > Address, > > > > > > byte-reverses the read > > > > > > + result, performs a bitwise OR between the > > read > > > > > > result and the value specified > > > > > > + by OrData, byte-reverses the result, and > > writes > > > > the > > > > > > result to the 16-bit MMIO > > > > > > + register specified by Address. The pre- > > reversal > > > > > > value written to the MMIO > > > > > > + register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +ADD_PREFIX (MmioOr16) ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT16 OrData > > > > > > + ) > > > > > > +{ > > > > > > + UINT16 Value; > > > > > > + > > > > > > + Value =3D ADD_PREFIX (MmioRead16) (Address); > > > > > > + Value |=3D OrData; > > > > > > + > > > > > > + return ADD_PREFIX (MmioWrite16) (Address, > > > > Value); > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Reads a 16-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise AND, > > > > > > + and writes the result back to the 16-bit > > MMIO > > > > > > register. > > > > > > + > > > > > > + Reads the 16-bit MMIO register specified by > > > > Address, > > > > > > byte-reverses the read > > > > > > + result, performs a bitwise AND between the > > read > > > > > > result and the value specified > > > > > > + by AndData, byte-reverses the result, and > > writes > > > > the > > > > > > result to the 16-bit MMIO > > > > > > + register specified by Address. The pre- > > reversal > > > > > > value written to the MMIO > > > > > > + register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +ADD_PREFIX (MmioAnd16) ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT16 AndData > > > > > > + ) > > > > > > +{ > > > > > > + UINT16 Value; > > > > > > + > > > > > > + Value =3D ADD_PREFIX (MmioRead16) (Address); > > > > > > + Value &=3D AndData; > > > > > > + > > > > > > + return ADD_PREFIX (MmioWrite16) (Address, > > > > Value); > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Reads a 16-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise AND > > > > > > + followed by a bitwise OR, and writes the > > result > > > > back > > > > > > to the 16-bit MMIO > > > > > > + register. > > > > > > + > > > > > > + Reads the 16-bit MMIO register specified by > > > > Address, > > > > > > byte reverses the read > > > > > > + result, performs a bitwise AND between the > > read > > > > > > result and the value specified > > > > > > + by AndData, performs a bitwise OR between > > the > > > > result > > > > > > of the AND operation and > > > > > > + the value specified by OrData, byte-reverses > > the > > > > > > result, and writes the result > > > > > > + to the 16-bit MMIO register specified by > > > > Address. > > > > > > The pre-reversal value > > > > > > + written to the MMIO register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +ADD_PREFIX (MmioAndThenOr16) ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT16 AndData, > > > > > > + IN UINT16 OrData > > > > > > + ) > > > > > > +{ > > > > > > + UINT16 Value; > > > > > > + > > > > > > + Value =3D ADD_PREFIX (MmioRead16) (Address); > > > > > > + Value &=3D AndData; > > > > > > + Value |=3D OrData; > > > > > > + > > > > > > + return ADD_PREFIX (MmioWrite16) (Address, > > > > Value); > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Reads a 32-bit MMIO register of opposite > > > > endianness. > > > > > > + > > > > > > + Reads the 32-bit MMIO register specified by > > > > Address. > > > > > > + The 32-bit read value is returned in > > reversed > > > > byte > > > > > > order. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @param Address The MMIO register to read. > > > > > > + > > > > > > + @return The value read. > > > > > > + > > > > > > +**/ > > > > > > +UINT32 > > > > > > +EFIAPI > > > > > > +ADD_PREFIX (MmioRead32) ( > > > > > > + IN UINTN Address > > > > > > + ) > > > > > > +{ > > > > > > + return SwapBytes32 (MmioRead32 (Address)); > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Writes a 32-bit MMIO register of opposite > > > > > > endianness. > > > > > > + > > > > > > + Writes the 32-bit MMIO register specified by > > > > Address > > > > > > with the byte-reversed > > > > > > + version of the value specified by Value and > > > > returns > > > > > > the original Value. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @param Address The MMIO register to write. > > > > > > + @param Value The value to write to the > > MMIO > > > > > > register. > > > > > > + > > > > > > + @return Value. > > > > > > + > > > > > > +**/ > > > > > > +UINT32 > > > > > > +EFIAPI > > > > > > +ADD_PREFIX (MmioWrite32) ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT32 Value > > > > > > + ) > > > > > > +{ > > > > > > + (VOID) MmioWrite32 (Address, SwapBytes32 > > > > (Value)); > > > > > > + > > > > > > + return Value; > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Reads a 32-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise OR, > > > > > > + and writes the result back to the 32-bit > > MMIO > > > > > > register. > > > > > > + > > > > > > + Reads the 32-bit MMIO register specified by > > > > Address, > > > > > > byte-reverses the read > > > > > > + result, performs a bitwise OR between the > > read > > > > > > result and the value specified > > > > > > + by OrData, byte-reverses the result, and > > writes > > > > the > > > > > > result to the 32-bit MMIO > > > > > > + register specified by Address. The pre- > > reversal > > > > > > value written to the MMIO > > > > > > + register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +ADD_PREFIX (MmioOr32) ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT32 OrData > > > > > > + ) > > > > > > +{ > > > > > > + UINT32 Value; > > > > > > + > > > > > > + Value =3D ADD_PREFIX (MmioRead32) (Address); > > > > > > + Value |=3D OrData; > > > > > > + > > > > > > + return ADD_PREFIX (MmioWrite32) (Address, > > > > Value); > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Reads a 32-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise AND, > > > > > > + and writes the result back to the 32-bit > > MMIO > > > > > > register. > > > > > > + > > > > > > + Reads the 32-bit MMIO register specified by > > > > Address, > > > > > > byte-reverses the read > > > > > > + result, performs a bitwise AND between the > > read > > > > > > result and the value specified > > > > > > + by AndData, byte-reverses the result, and > > writes > > > > the > > > > > > result to the 32-bit MMIO > > > > > > + register specified by Address. The pre- > > reversal > > > > > > value written to the MMIO > > > > > > + register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +ADD_PREFIX (MmioAnd32) ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT32 AndData > > > > > > + ) > > > > > > +{ > > > > > > + UINT32 Value; > > > > > > + > > > > > > + Value =3D ADD_PREFIX (MmioRead32) (Address); > > > > > > + Value &=3D AndData; > > > > > > + > > > > > > + return ADD_PREFIX (MmioWrite32) (Address, > > > > Value); > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Reads a 32-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise AND > > > > > > + followed by a bitwise OR, and writes the > > result > > > > back > > > > > > to the 32-bit MMIO > > > > > > + register. > > > > > > + > > > > > > + Reads the 32-bit MMIO register specified by > > > > Address, > > > > > > byte reverses the read > > > > > > + value, performs a bitwise AND between the > > read > > > > > > result and the value specified > > > > > > + by AndData, performs a bitwise OR between > > the > > > > result > > > > > > of the AND operation and > > > > > > + the value specified by OrData, byte-reverses > > the > > > > > > result, and writes the result > > > > > > + to the 32-bit MMIO register specified by > > > > Address. > > > > > > The pre-reversal value > > > > > > + written to the MMIO register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +ADD_PREFIX (MmioAndThenOr32) ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT32 AndData, > > > > > > + IN UINT32 OrData > > > > > > + ) > > > > > > +{ > > > > > > + UINT32 Value; > > > > > > + > > > > > > + Value =3D ADD_PREFIX (MmioRead32) (Address); > > > > > > + Value &=3D AndData; > > > > > > + Value |=3D OrData; > > > > > > + > > > > > > + return ADD_PREFIX (MmioWrite32) (Address, > > > > Value); > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Reads a 64-bit MMIO register of opposite > > > > endianness. > > > > > > + > > > > > > + Reads the 64-bit MMIO register specified by > > > > Address. > > > > > > + The 64-bit read value is returned in > > reversed > > > > byte > > > > > > order. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @param Address The MMIO register to read. > > > > > > + > > > > > > + @return The value read. > > > > > > + > > > > > > +**/ > > > > > > +UINT64 > > > > > > +EFIAPI > > > > > > +ADD_PREFIX (MmioRead64) ( > > > > > > + IN UINTN Address > > > > > > + ) > > > > > > +{ > > > > > > + return SwapBytes64 (MmioRead64 (Address)); > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Writes a 64-bit MMIO register of opposite > > > > > > endianness. > > > > > > + > > > > > > + Writes the 64-bit MMIO register specified by > > > > Address > > > > > > with the byte-reversed > > > > > > + version of the value specified by Value and > > > > returns > > > > > > Value. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @param Address The MMIO register to write. > > > > > > + @param Value The value to write to the > > MMIO > > > > > > register. > > > > > > + > > > > > > +**/ > > > > > > +UINT64 > > > > > > +EFIAPI > > > > > > +ADD_PREFIX (MmioWrite64) ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT64 Value > > > > > > + ) > > > > > > +{ > > > > > > + (VOID) MmioWrite64 (Address, SwapBytes64 > > > > (Value)); > > > > > > + > > > > > > + return Value; > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Reads a 64-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise OR, > > > > > > + and writes the result back to the 64-bit > > MMIO > > > > > > register. > > > > > > + > > > > > > + Reads the 64-bit MMIO register specified by > > > > Address, > > > > > > byte reverses the read > > > > > > + result, performs a bitwise OR between the > > read > > > > > > result and the value specified > > > > > > + by OrData, byte-reverses the result, and > > writes > > > > the > > > > > > result to the 64-bit MMIO > > > > > > + register specified by Address. The pre- > > reversal > > > > > > value written to the > > > > > > + MMIO register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +ADD_PREFIX (MmioOr64) ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT64 OrData > > > > > > + ) > > > > > > +{ > > > > > > + UINT64 Value; > > > > > > + > > > > > > + Value =3D ADD_PREFIX (MmioRead64) (Address); > > > > > > + Value |=3D OrData; > > > > > > + > > > > > > + return ADD_PREFIX (MmioWrite64) (Address, > > > > Value); > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Reads a 64-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise AND, > > > > > > + and writes the result back to the 64-bit > > MMIO > > > > > > register. > > > > > > + > > > > > > + Reads the 64-bit MMIO register specified by > > > > Address, > > > > > > byte-reverses the read > > > > > > + value, performs a bitwise AND between the > > read > > > > > > result and the value specified > > > > > > + by AndData, byte-reverses the result, and > > writes > > > > the > > > > > > result to the 64-bit MMIO > > > > > > + register specified by Address. The pre- > > reversal > > > > > > value written to the MMIO > > > > > > + register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +ADD_PREFIX (MmioAnd64) ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT64 AndData > > > > > > + ) > > > > > > +{ > > > > > > + UINT64 Value; > > > > > > + > > > > > > + Value =3D ADD_PREFIX (MmioRead64) (Address); > > > > > > + Value &=3D AndData; > > > > > > + > > > > > > + return ADD_PREFIX (MmioWrite64) (Address, > > > > Value); > > > > > > +} > > > > > > + > > > > > > +/** > > > > > > + Reads a 64-bit MMIO register of opposite > > > > endianness, > > > > > > performs a bitwise AND > > > > > > + followed by a bitwise OR, and writes the > > result > > > > back > > > > > > to the 64-bit MMIO > > > > > > + register. > > > > > > + > > > > > > + Reads the 64-bit MMIO register specified by > > > > Address, > > > > > > byte-reverses the read > > > > > > + result, performs a bitwise AND between the > > read > > > > > > result and the value specified > > > > > > + by AndData, performs a bitwise OR between > > the > > > > result > > > > > > of the AND operation and > > > > > > + the value specified by OrData, byte-reverses > > the > > > > > > result, and writes the result > > > > > > + to the 64-bit MMIO register specified by > > > > Address. > > > > > > The pre-reversal value > > > > > > + written to the MMIO register is returned. > > > > > > + This function must guarantee that all MMIO > > read > > > > and > > > > > > write > > > > > > + operations are serialized. > > > > > > + > > > > > > + @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 > > > > > > +ADD_PREFIX (MmioAndThenOr64) ( > > > > > > + IN UINTN Address, > > > > > > + IN UINT64 AndData, > > > > > > + IN UINT64 OrData > > > > > > + ) > > > > > > +{ > > > > > > + UINT64 Value; > > > > > > + > > > > > > + Value =3D ADD_PREFIX (MmioRead64) (Address); > > > > > > + Value &=3D AndData; > > > > > > + Value |=3D OrData; > > > > > > + > > > > > > + return ADD_PREFIX (MmioWrite64) (Address, > > > > Value); > > > > > > +} > > > > > > diff --git a/MdePkg/MdePkg.dec > > b/MdePkg/MdePkg.dec > > > > > > index 0e64f22f4a..ae7c8dfa11 100644 > > > > > > --- a/MdePkg/MdePkg.dec > > > > > > +++ b/MdePkg/MdePkg.dec > > > > > > @@ -160,6 +160,9 @@ [LibraryClasses] > > > > > > ## @libraryclass Provide services to > > access > > > > I/O > > > > > > Ports and MMIO registers. > > > > > > IoLib|Include/Library/IoLib.h > > > > > > > > > > > > + ## @libraryclass Provide big-endian > > services > > > > to > > > > > > access MMIO registers. > > > > > > + BeIoLib|Include/Library/BeIoLib.h > > > > > > + > > > > > > ## @libraryclass Provide services to > > create, > > > > get > > > > > > and update HSTI table in AIP protocol. > > > > > > HstiLib|Include/Library/HstiLib.h > > > > > > > > > > > > -- > > > > > > 2.11.0 > > > > > > > > > _______________________________________________ > > > > edk2-devel mailing list > > > > edk2-devel@lists.01.org > > > > > https://emea01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Flist= s.01 > .org%2Fmailman%2Flistinfo%2Fedk2- > devel&data=3D02%7C01%7Cudit.kumar%40nxp.com%7Cb19fee0925904c9041040 > 8d5a3a3e0cf%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6365948 > 46625431426&sdata=3D6sl8JIjudPAKEcb6A8cQHsEm4QYs4NXLMvCRsNtjY%2B0%3 > D&reserved=3D0 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://emea01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Flist= s.01 > .org%2Fmailman%2Flistinfo%2Fedk2- > devel&data=3D02%7C01%7Cudit.kumar%40nxp.com%7Cb19fee0925904c9041040 > 8d5a3a3e0cf%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6365948 > 46625431426&sdata=3D6sl8JIjudPAKEcb6A8cQHsEm4QYs4NXLMvCRsNtjY%2B0%3 > D&reserved=3D0