From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0609.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe41::609]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4B1B61A1ECF for ; Fri, 14 Oct 2016 02:41:22 -0700 (PDT) Received: from CY1PR03CA0028.namprd03.prod.outlook.com (10.174.128.38) by BL2PR03MB322.namprd03.prod.outlook.com (10.141.68.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.649.16; Fri, 14 Oct 2016 09:41:18 +0000 Received: from BL2FFO11FD026.protection.gbl (2a01:111:f400:7c09::166) by CY1PR03CA0028.outlook.office365.com (2603:10b6:600::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.8 via Frontend Transport; Fri, 14 Oct 2016 09:41:18 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com;nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD026.mail.protection.outlook.com (10.173.161.105) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.629.5 via Frontend Transport; Fri, 14 Oct 2016 09:41:18 +0000 Received: from b45370.ap.freescale.net ([10.232.40.52]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u9E9fBRw002768; Fri, 14 Oct 2016 02:41:15 -0700 From: Bhupesh Sharma To: Date: Fri, 14 Oct 2016 15:03:35 +0530 Message-ID: <1476437615-29534-1-git-send-email-bhupesh.sharma@nxp.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131209116784279853; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(6029001)(7916002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(6916009)(6666003)(11100500001)(4326007)(68736007)(8676002)(81166006)(110136003)(81156014)(92566002)(50986999)(5003940100001)(105606002)(97736004)(85426001)(48376002)(86362001)(575784001)(87936001)(189998001)(50466002)(106466001)(33646002)(7846002)(47776003)(2351001)(2906002)(586003)(19580405001)(356003)(305945005)(50226002)(8936002)(626004)(104016004)(19580395003)(36756003)(5660300001)(8666005)(229853001)(77096005)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2PR03MB322; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD026; 1:U/acvbwoRZNUgtGSJzStzoy74tI7AqxcZ4HmIMBraS0mdOfgsqSTyZ2udfNBsPCwDvCmeN1tIiv0GayuEeIYArlq1P5k318YrzQoLxOyJqfWjUzarMvkYDur5N3ikatFSpB/Hg+HMoeV+YY1DFQPhgk2+7ltUSfmyf9rA9+dR5txdTZ4MAoBIlJCN18J7G7TygWVJ5liq0Ab3d7OeKXpicoDSIDYDWJolEiDuw7pukRTkeu8Jmsr21btngRtnOEJOY/z+KhkxqUoPzpbolCTnX5BO8v+LwRnHmPfLWbFJ4qdxv3nUti+PkLKO7nplga/AnT9XXCF2Y4p52G/WqWQh4SyfEo8TNY0bN/M7BIdOkeQUQaqn5E12b68GuwImMUOoLE+59ikwBgQHEu536/QN5qlmGNZaHH/2+TlWv4VYHzHi+eanVhYApxSaJUbMG/J0IKhHaqCqt3h1jbiX9zLSL087z1D2ktVFlsYrYPR7bpl/zBpeg9Rdxq7X/b6cSFkhRgH7nEKXYJC/iwVwudlPjEaQfQxvbW5wqQGQTbZI9lsWtMKE6ZIz2oVnkoXFijSExR+pgj1ZEBr7gIuluVzjVpNPFZeQym4D+uz5mq0kKF0H+lAIx/Xn2yU5E0vKBYgnQyd4U0iVLpi+KVq1AkrbdmxYiBjQQ7QVMtkituFxpNV1g5SZ+pRUnQrgXF9E2HgaA9dBwFX2Tul3+DJ6Q/vDo49eMA+iO4PTxtDutVut+4= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: d73e0bff-22bc-4300-dfcc-08d3f4163fac X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB322; 2:+yEHfUgKjDSVynRQwjibnb7umnWVGwSE4lZG8kLsOlBSlcSR8Fq07+eBX9IjQFKWnpDUVfbzz3MXRxO5gXhsGrMP4Hz3pQZxjNWKhe/MO188o0FYWQ5Sa0MxCiVhgbeVLVSIp7Td0s1xsXXE+LFU94EcUvvzoAMpdh88xB7mDKlSj1y1UF7YWWRSh/0yFzSBn5nMjIT+aTmqienxKceJ2g==; 3:/9jDSBOfdXNaid8jNfriHtnejy0fNd79OYcRsVjBdl3/PqzSX64So5sj0cNX4fZcA2Dm+HUJmmOdfS2VIdZYbWAXdi/8I2jg9gCOfCp0HRZUqWeUERJ1ZfQmDeX49a6MLLTv9QmfW7tcyvr6fcncVy60Ci6FQq6PMFCbIdC4jsx04M0pYJtYtTA9aWtCqaTIsld5iqqBYlSRtrwim5feiK3wguW9KqB+4k9YTlkWsXTUpjHJigaCUDEP7qWKXigF X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB322; X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB322; 25:sn1PE21rGnQk5z0xBj4r1GMChKk/NBQNlw36ljvx7omeBdus1qcj/fmc23OV4uWQh0USOiA+GGUJSkbi7IHrCWLPu839ob0syjHZekBKzHbr1nSKlarSQbno6dU2X3C2XqRHInD67UtzqkP1K+UTL8TtqibH0fgHoM/zRIJHhgAQ9EYsTcpsDf1W3tsvKQsYnKOd4CO2xM6tcdDT/ayQ7EpDh62asy/Gl+nwLLfDrq45EK3HdU8rSIKUOVSz0H07wz8kRKNi6spvmXPtuf/fsnvNm3LbCIKazewpkQXBzAvm/fzARUpkYckZq9e6daDCrQYAJBIky2sGNrkyuq5d/EQqmbEYAU/ts7s8CNCj4IiQ+5Ji+DUo6fdR37sbJx8mVIkvnm9nVapCTSK0ixnNDkpp77TuOlS1l8trMVTVkJlABYcsXk/VLzhCrvyikPOJ97Ck1E1ETL5fMB7IjP6t+DmSuzddtMRz8Wwd9ftyihBYjjpzgiXOyVRzPLkPXIs8LFs7Piaed9qxIugi6/z8D79JzFbUN93q6oUOBVPMRwcLTyNBuACm/UmFknzG28Znun6td8w6QESKN/8M5rnrCRrZlVZ8LUa5ce6QpVo5UkkpJI+xT7vr0tHzxVQQgZAiv2dnUvQvXtAnPVvkCmf0OMjU2/6NiOrIOlE+zsDrjmnOE9gMoy60uLxQywEpPWxHJgNgdLXbdF5dZZAA3tjweroGoHtz5kyzDq+IKUlXBgvC4OUk8fVRtFi3fmDNCQgo X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB322; 31:yOhBASWQmgYyqr9xDOIwm5Slh1QGxqzHgEP8wjWPqKenwI8/GXoXFRxlTb8PDGhzisFFQ53uCxXex12ifDyU7bQPDtFUgrrgPlCQtu22QFOW+6D7F1eNxiIDgNXebqUsEmbJ2Wpm+LI6YoAkC+WPzO2Exgt3HH7/Wk1Zv5gxxBL+wEdB5HbvKFhp02mJ+jr0XBwy8U18ElKaZs2OnqiD4BU9RvCNPy0i+fdcuYml0DbFnOE2asIhHKcypiFqm9QNRPPHWFhan19gX3W+M9NXYt9L0E811OJ9IH/z4AA1/kE=; 4:flyKfhU1GYOGqWiMQ+FrseZKw9LPPYAvWGojRbFe7jWpkOCsRPaxuJYA49ynIc8oGPVBd3l+iQX1BrLAEYIIoWi9YH/GaCRd6CcGYZFv5l22SSxPG7utTeu3/cbXgCtacbnxYEouSb9+BgIb4nBfuAGGmzUoNLNTxuTNR2XO5rl0r1avvPe3Z+gkqkKergW1J5+qKACRSJz6gBV79ZOp/q7yj86R7Uf4/o+qW6Sdxh6PoLMRL/+kI1qzlx9gPndHICCrlL5a2wRixICrrejoENQq4znPLY+KjAvgAy3UfsldakXr32cYam2zKx4wspwxptMd6nYScpYV+NmUkbFNO6L8eMs1llly564WGM/Ff/aXzclUgtCHlBVvTV08kRjXqdKcamyWZ2wk0rjKYCRTQ9SGkOqG6uPN6cWDHxCGe6A43Hk+gqhbzf/xSL2dzfQAB4G318h5TXV5WvKfVW2guRRJvfP5nk2gLMDSdikVb3kSCJtyXKfeE9nwfDdpjFWkGnahRX3zIIcja477iy1atccDFwliHMFM6e9bk5opjmVYYkwND8imP2aXb5bPWvHC X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13015025)(13024025)(13017025)(5005006)(8121501046)(13018025)(13023025)(3002001)(10201501046)(6055026); SRVR:BL2PR03MB322; BCL:0; PCL:0; RULEID:(400006); SRVR:BL2PR03MB322; X-Forefront-PRVS: 0095BCF226 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL2PR03MB322; 23:v3ztBFX6OusrS6eM4dNy8U5BZR6r6fgiSpTjzAjwQ0?= =?us-ascii?Q?N9eSSqIIxPwcS6cfZZaD8oq8nrhnvuvhtX7Xvs2o0JFVuI7zXhzPblLIUllh?= =?us-ascii?Q?B3AqltWH7SOLj0zSJbQCkt3YSNk9v70YnQPCybGo1QgIqVn2ZzBz8KZ3sIQE?= =?us-ascii?Q?h34Ui7TP0LSTP9Ty7mPr5BcpqwzHd5W0mz3kkmTQCVP67EbGzRQcNQxRY52k?= =?us-ascii?Q?D9gV42qkBdM3v0OccqbbvF2C9Xf1TidBsmRl7EkGnzhj3E93KrUSK8Y+rdwC?= =?us-ascii?Q?hD3rXEh8MzCVztmLqpPg8X9sJy64v9ilZcUhJ5gTZq2vpXGYgHq4GPso23Vu?= =?us-ascii?Q?OnP6GspGaiCavYHFAs7tckxwyAEKwRBa6gZ1RnphTm58Q6fmoI0Xa3TEBlTc?= =?us-ascii?Q?18LEoVds+cgWblnUblbIS8TweP9wDCan0ftR9AmBHx+3njXaZ3d0w5MLExHg?= =?us-ascii?Q?sO+zbg7db394oouFjZ6Pad+A0ewdeGVVH7TNdduC39iwoUHp+5yrCuzmC9Jr?= =?us-ascii?Q?X3df6Xe2TN0gWG++JTFwoHcGWxltYyR5ULt9lAaqIX2G+P+Ix4m9DZ51V+IG?= =?us-ascii?Q?iVBTEkF6kU54W94B0eVVafGWH3KjIohT3ibOKSHvTPWmyMjqhqV/iByeuDal?= =?us-ascii?Q?qjlJo3OeSea2FgldgORRizhXzhwDsGiGAg65ahazhORd+GhlbQOjMMNb2ePQ?= =?us-ascii?Q?IXj+zObs901FUJdJmIXEg2P13pljKKbLjb9z980X18RPMQasQj6AaJwFDtMO?= =?us-ascii?Q?GaaEC9eMSb6WduXL490b0Yj7l5mHzFLbB0XWMaGhYxGPV4iib4aySi/AjpaL?= =?us-ascii?Q?OpPS9umL8dIy7fGdghpu6bnTTe3H9VK2YggLARlqck+R19jfrDb3W91u1k2A?= =?us-ascii?Q?fkgWNu9aJfcGiVm374KZEUEbmLdUAFERpGyvkIUXdnrRhYqMmFBFAjUkoHjB?= =?us-ascii?Q?XpGT0TCGFY54mTPRYvYJru8mqjpHw6hvwmySUsyoJHNtNT4D2dvdDgMABgvw?= =?us-ascii?Q?YHGlfYPa+VJKHLUY3iJKdJcztcmx0XMD8OlLuOQvPyU742bKYfFxlp4hZ5s7?= =?us-ascii?Q?7CsiKI63QG1sjXpzfMgcZLTqnrdKQySnkxN3hJaUQlZHkU2OMVkAJdwC1SRb?= =?us-ascii?Q?LhAXkD1cB13jQQjs7EWUNzYrnLDTIvvezKUnQN7CLJeVDhmIw57nask39TPC?= =?us-ascii?Q?K3CN+2QT2DRg8xmnRZuNijesw9Th/GH5Jz?= X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB322; 6:6sbwcLOTmPx0ECenuJ0EKMcii6EdJEERT0G+uWqgEkfSsyV94ENdRqcMgSlB0JpRAxhcaiOSpXzAS4hTTu5WthJN5bGKh9TUmRHGqzwJ3xDvaZbcO72KtxEk7k0kyP5g6+K1pruL6aI444ZwHNYYeYcZ7Ht+yygdiaek065RHLgsp1OU2dSHdd+Yr4rGhn4PFUBTptlmDhHEf/sN6RCBTIsIjGhWjrVRHswRUWYV7y5oV2DzJy6sOnSRn3q+J+xXnXugBa94izSbZ5kIkFWxrSN5wFjCGc8vtGb/Z22Af0tnK5C5pSfh+Cb4PgR4Qa8+; 5:28kq2s78cNlN9RnqahOQspmALLrEI8Q8hm6MF752T/5g9Y2/t8X3BghwazCSlqJHk+cf7htRhLCNZ1JPN4wfPQNNqXYl2DF/snovKMjPxeovzuwOBnqJYYxZH8e8MTVZvYjPAYWXZ0puq6NyqcO9UaSgnWontT6B5cDnZvEPxv0D1abzxCwJf3iDdR1Yl2AO; 24:VvQ36cBFhdUB8m5izwU9zv7hszpAw8yQitx8X8vosDhYoFOLBTypfVKkMI2l2moiNVsiRPSdZD+b/YZ3JUsGYvBnjs5S4uhiM2+xk6al4Ck= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB322; 7:J3BVCni1njI9y9HD4257eAAhZeEpG2yUViV+WQwR03JaVCstg5kkewEEU4rG1EoEfc6sKwc0WtuGaXdGQ16WzYkbar6AtgAnzNO70m3AAF9a5cHPHZ3qdUnaQ8+alXpId3MFJQlOM01RtA/w50QSruB84x5mqiMUu8Q5i8itY6Px2ZNZRsPVvh6w2kaY1WfMKKoOHguRBgV3/bIbYAHgIJ3zmzYq53bkkXWCCSQRlZuA2vxOcAoJ3ZyrLheObsDcqlqt45goF9B4ntjOmYXFV6gRs6BcFH6tfY63WKO3G0rXZqQOhYkzZfHvnVk+4i1eeOXaJ5VC3XNkZVJeNHfz3cF4xwuWNQS2v97cQNIY5Jk= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2016 09:41:18.2407 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB322 Subject: [PATCH 1/1] MdePkg/IoLib: Add support for big-endian MMIO X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 09:41:22 -0000 Content-Type: text/plain Various IPs on NXP/FSL SoCs having ARM64 cores have big-endian MMIO interfaces. This implies that a byte-swap operation is needed to read/write such BE MMIO registers from the LE ARM64 cores. This patch adds the support for the same. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Meenakshi Aggarwal Signed-off-by: Bhupesh Sharma --- MdePkg/Include/Library/IoLib.h | 364 ++++++++++++++++++++ MdePkg/Library/BaseIoLibIntrinsic/IoLibArm.c | 479 +++++++++++++++++++++++++++ 2 files changed, 843 insertions(+) diff --git a/MdePkg/Include/Library/IoLib.h b/MdePkg/Include/Library/IoLib.h index a0dd16b..f5842e6 100644 --- a/MdePkg/Include/Library/IoLib.h +++ b/MdePkg/Include/Library/IoLib.h @@ -2658,6 +2658,370 @@ MmioWriteBuffer64 ( IN CONST UINT64 *Buffer ); +/** + Reads a 16-bit MMIO register in Big Endian format. + + Reads the 16-bit MMIO register specified by Address. The 16-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioReadBe16 ( + IN UINTN Address + ); + +/** + Writes a 16-bit MMIO register in Big Endian format. + + Writes the 16-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioWriteBe16 ( + IN UINTN Address, + IN UINT16 Value + ); + +/** + Reads a 32-bit MMIO register in Big Endian format. + + Reads the 32-bit MMIO register specified by Address. The 32-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioReadBe32 ( + IN UINTN Address + ); + +/** + Writes a 32-bit MMIO register in Big Endian format. + + Writes the 32-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioWriteBe32 ( + IN UINTN Address, + IN UINT32 Value + ); + + +/** + Reads a 64-bit MMIO register in Big Endian format. + + Reads the 64-bit MMIO register specified by Address. The 64-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioReadBe64 ( + IN UINTN Address + ); + + +/** + Writes a 64-bit MMIO register in Big Endian format. + + Writes the 64-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioWriteBe64 ( + IN UINTN Address, + IN UINT64 Value + ); + +/** + Clear and set a 8-bit MMIO register. + + Mask the 8-bit MMIO register specified by Address with the mask specified + by Mask and then Writes the 8-bit MMIO register specified by Address with + the value specified by Value and returns current value on register. This + function must guarantee that all MMIO read and write operations are serialized. + + @param Address The MMIO register to write. + @param Mask The Mask to clear the MMIO register. + @param Value The value to write to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioClearSet8 ( + IN UINTN Address, + IN UINT8 Mask, + IN UINT8 Value + ); + +/** + Clear and set a 16-bit MMIO register in Big Endian format. + + Mask the 16-bit MMIO register specified by Address with the mask specified + by Mask and then Writes the 16-bit MMIO register specified by Address with + the value specified by Value and returns current value on register. This + function must guarantee that all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Mask The Mask to clear the MMIO register. + @param Value The value to write to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioClearSetBe16 ( + IN UINTN Address, + IN UINT16 Mask, + IN UINT16 Value + ); + +/** + Clear and set a 32-bit MMIO register in Big Endian format. + + Mask the 32-bit MMIO register specified by Address with the mask specified + by Mask and then Writes the 32-bit MMIO register specified by Address with + the value specified by Value and returns current value on register. This + function must guarantee that all MMIO read and write operations are serialized. + + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Mask The Mask to clear the MMIO register. + @param Value The value to write to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioClearSetBe32 ( + IN UINTN Address, + IN UINT32 Mask, + IN UINT32 Value + ); + +/** + Clear and set a 64-bit MMIO register in Big Endian format. + + Mask the 64-bit MMIO register specified by Address with the mask specified + by Mask and then Writes the 64-bit MMIO register specified by Address with + the value specified by Value and returns current value on register. This + function must guarantee that all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Mask The Mask to clear the MMIO register. + @param Value The value to write to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioClearSetBe64 ( + IN UINTN Address, + IN UINT64 Mask, + IN UINT64 Value + ); + +/** + Set a 8-bit MMIO register in Big Endian format. + + Set bits of the 8-bit MMIO register specified by Address with the Bits + specified by Bits and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Bits The Bits to set in MMIO register. + +**/ +UINT8 +EFIAPI +MmioSetBits8 ( + IN UINTN Address, + IN UINT8 Bits + ); + +/** + Set a 16-bit MMIO register in Big Endian format. + + Set bits of the 16-bit MMIO register specified by Address with the Bits + specified by Bits and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Bits The Bits to set in MMIO register. + +**/ +UINT16 +EFIAPI +MmioSetBitsBe16 ( + IN UINTN Address, + IN UINT16 Bits + ); + +/** + Set a 32-bit MMIO register in Big Endian format. + + Set bits of the 32-bit MMIO register specified by Address with the Bits + specified by Bits and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Bits The Bits to set in MMIO register. + +**/ +UINT32 +EFIAPI +MmioSetBitsBe32 ( + IN UINTN Address, + IN UINT32 Bits + ); + +/** + Set a 64-bit MMIO register in Big Endian format. + + Set bits of the 64-bit MMIO register specified by Address with the Bits + specified by Bits and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Bits The Bits to set in MMIO register. + +**/ +UINT64 +EFIAPI +MmioSetBitsBe64 ( + IN UINTN Address, + IN UINT64 Bits + ); + +/** + Clear bits of the 8-bit MMIO register specified by Address with the Mask + specified by Mask and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Mask The Bits to clear in MMIO register. + +**/ +UINT8 +EFIAPI +MmioClearBits8 ( + IN UINTN Address, + IN UINT8 Mask + ); + +/** + Clear bits of the 16-bit MMIO register specified by Address with the Mask + specified by Mask and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Mask The Bits to clear in MMIO register. + +**/ +UINT16 +EFIAPI +MmioClearBitsBe16 ( + IN UINTN Address, + IN UINT16 Mask + ); + +/** + Clear bits of the 32-bit MMIO register specified by Address with the Mask + specified by Mask and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Mask The Bits to clear in MMIO register. + +**/ +UINT32 +EFIAPI +MmioClearBitsBe32 ( + IN UINTN Address, + IN UINT32 Mask + ); + +/** + Clear bits of the 64-bit MMIO register specified by Address with the Mask + specified by Mask and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Mask The Bits to clear in MMIO register. + +**/ +UINT64 +EFIAPI +MmioClearBitsBe64 ( + IN UINTN Address, + IN UINT64 Mask + ); #endif diff --git a/MdePkg/Library/BaseIoLibIntrinsic/IoLibArm.c b/MdePkg/Library/BaseIoLibIntrinsic/IoLibArm.c index b9f4c5e..f2179d1 100644 --- a/MdePkg/Library/BaseIoLibIntrinsic/IoLibArm.c +++ b/MdePkg/Library/BaseIoLibIntrinsic/IoLibArm.c @@ -19,6 +19,26 @@ // #include "BaseIoLibIntrinsicInternal.h" + +#define Uswap16(X) \ + ((((X) & 0xff00) >> 8) | \ + (((X) & 0x00ff) << 8)) +#define Uswap32(X) \ + ((((X) & 0xff000000) >> 24) | \ + (((X) & 0x00ff0000) >> 8) | \ + (((X) & 0x0000ff00) << 8) | \ + (((X) & 0x000000ff) << 24)) +#define Uswap64(X) \ + ((((X) & 0xff00000000000000) >> 56) | \ + (((X) & 0x00ff000000000000) >> 40) | \ + (((X) & 0x0000ff0000000000) >> 24) | \ + (((X) & 0x000000ff00000000) >> 8) | \ + (((X) & 0x00000000ff000000) << 8) | \ + (((X) & 0x0000000000ff0000) << 24) | \ + (((X) & 0x000000000000ff00) << 40) | \ + (((X) & 0x00000000000000ff) << 56)) + + /** Reads an 8-bit I/O port. @@ -428,3 +448,462 @@ MmioWrite64 ( return Value; } + +/** + Reads a 16-bit MMIO register in Big Endian format. + + Reads the 16-bit MMIO register specified by Address. The 16-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioReadBe16 ( + IN UINTN Address + ) +{ + UINT16 Value; + + ASSERT ((Address & 1) == 0); + Value = *(volatile UINT16*)Address; + return Uswap16(Value); +} + +/** + Writes a 16-bit MMIO register in Big Endian format. + + Writes the 16-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioWriteBe16 ( + IN UINTN Address, + IN UINT16 Value + ) +{ + ASSERT ((Address & 1) == 0); + *(volatile UINT16*)Address = Uswap16(Value); + return Value; +} + +/** + Reads a 32-bit MMIO register in Big Endian format. + + Reads the 32-bit MMIO register specified by Address. The 32-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioReadBe32 ( + IN UINTN Address + ) +{ + UINT32 Value; + + ASSERT ((Address & 3) == 0); + Value = *(volatile UINT32*)Address; + return Uswap32(Value); +} + +/** + Writes a 32-bit MMIO register in Big Endian format. + + Writes the 32-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioWriteBe32 ( + IN UINTN Address, + IN UINT32 Value + ) +{ + ASSERT ((Address & 3) == 0); + *(volatile UINT32*)Address = Uswap32(Value); + return Value; +} + +/** + Reads a 64-bit MMIO register in Big Endian format. + + Reads the 64-bit MMIO register specified by Address. The 64-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioReadBe64 ( + IN UINTN Address + ) +{ + UINT64 Value; + + ASSERT ((Address & 7) == 0); + Value = *(volatile UINT64*)Address; + return Uswap64(Value); +} + +/** + Writes a 64-bit MMIO register in Big Endian format. + + Writes the 64-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioWriteBe64 ( + IN UINTN Address, + IN UINT64 Value + ) +{ + ASSERT ((Address & 7) == 0); + *(volatile UINT64*)Address = Uswap64(Value); + return Value; +} + +/** + Clear and set a 8-bit MMIO register. + + Mask the 8-bit MMIO register specified by Address with the mask specified + by Mask and then Writes the 8-bit MMIO register specified by Address with + the value specified by Value and returns current value on register. This + function must guarantee that all MMIO read and write operations are serialized. + + @param Address The MMIO register to write. + @param Mask The Mask to clear the MMIO register. + @param Value The value to write to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioClearSet8 ( + IN UINTN Address, + IN UINT8 Mask, + IN UINT8 Value + ) +{ + *(volatile UINT8*)Address = (*(volatile UINT8*)Address & ~Mask) | Value; + return *(volatile UINT8*)Address; +} + +/** + Clear and set a 16-bit MMIO register in Big Endian format. + + Mask the 16-bit MMIO register specified by Address with the mask specified + by Mask and then Writes the 16-bit MMIO register specified by Address with + the value specified by Value and returns current value on register. This + function must guarantee that all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Mask The Mask to clear the MMIO register. + @param Value The value to write to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioClearSetBe16 ( + IN UINTN Address, + IN UINT16 Mask, + IN UINT16 Value + ) +{ + ASSERT ((Address & 1) == 0); + *(volatile UINT16*)Address = (*(volatile UINT16*)Address & Uswap16(~Mask)) + | Uswap16(Value); + return *(volatile UINT16*)Address; +} + +/** + Clear and set a 32-bit MMIO register in Big Endian format. + + Mask the 32-bit MMIO register specified by Address with the mask specified + by Mask and then Writes the 32-bit MMIO register specified by Address with + the value specified by Value and returns current value on register. This + function must guarantee that all MMIO read and write operations are serialized. + + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Mask The Mask to clear the MMIO register. + @param Value The value to write to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioClearSetBe32 ( + IN UINTN Address, + IN UINT32 Mask, + IN UINT32 Value + ) +{ + ASSERT ((Address & 3) == 0); + *(volatile UINT32*)Address = (*(volatile UINT32*)Address & Uswap32(~Mask)) + | Uswap32(Value); + return *(volatile UINT32*)Address; +} + +/** + Clear and set a 64-bit MMIO register in Big Endian format. + + Mask the 64-bit MMIO register specified by Address with the mask specified + by Mask and then Writes the 64-bit MMIO register specified by Address with + the value specified by Value and returns current value on register. This + function must guarantee that all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Mask The Mask to clear the MMIO register. + @param Value The value to write to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioClearSetBe64 ( + IN UINTN Address, + IN UINT64 Mask, + IN UINT64 Value + ) +{ + ASSERT ((Address & 7) == 0); + *(volatile UINT64*)Address = (*(volatile UINT64*)Address & Uswap64(~Mask)) + | Uswap64(Value); + return *(volatile UINT64*)Address; +} + +/** + Set a 8-bit MMIO register in Big Endian format. + + Set bits of the 8-bit MMIO register specified by Address with the Bits + specified by Bits and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Bits The Bits to set in MMIO register. + +**/ +UINT8 +EFIAPI +MmioSetBits8 ( + IN UINTN Address, + IN UINT8 Bits + ) +{ + *(volatile UINT8*)Address = *(volatile UINT8*)Address | Bits; + return *(volatile UINT8*)Address; +} + +/** + Set a 16-bit MMIO register in Big Endian format. + + Set bits of the 16-bit MMIO register specified by Address with the Bits + specified by Bits and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Bits The Bits to set in MMIO register. + +**/ +UINT16 +EFIAPI +MmioSetBitsBe16 ( + IN UINTN Address, + IN UINT16 Bits + ) +{ + ASSERT ((Address & 1) == 0); + *(volatile UINT16*)Address = *(volatile UINT16*)Address | Uswap16(Bits); + return *(volatile UINT16*)Address; +} + +/** + Set a 32-bit MMIO register in Big Endian format. + + Set bits of the 32-bit MMIO register specified by Address with the Bits + specified by Bits and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Bits The Bits to set in MMIO register. + +**/ +UINT32 +EFIAPI +MmioSetBitsBe32 ( + IN UINTN Address, + IN UINT32 Bits + ) +{ + ASSERT ((Address & 3) == 0); + *(volatile UINT32*)Address = *(volatile UINT32*)Address | Uswap32(Bits); + return *(volatile UINT32*)Address; +} + +/** + Set a 64-bit MMIO register in Big Endian format. + + Set bits of the 64-bit MMIO register specified by Address with the Bits + specified by Bits and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Bits The Bits to set in MMIO register. + +**/ +UINT64 +EFIAPI +MmioSetBitsBe64 ( + IN UINTN Address, + IN UINT64 Bits + ) +{ + ASSERT ((Address & 7) == 0); + *(volatile UINT64*)Address = *(volatile UINT64*)Address | Uswap64(Bits); + return *(volatile UINT64*)Address; +} + +/** + Clear bits of the 8-bit MMIO register specified by Address with the Mask + specified by Mask and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Mask The Bits to clear in MMIO register. + +**/ +UINT8 +EFIAPI +MmioClearBits8 ( + IN UINTN Address, + IN UINT8 Mask + ) +{ + *(volatile UINT8*)Address = *(volatile UINT8*)Address & (~Mask); + return *(volatile UINT8*)Address; +} + +/** + Clear bits of the 16-bit MMIO register specified by Address with the Mask + specified by Mask and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Mask The Bits to clear in MMIO register. + +**/ +UINT16 +EFIAPI +MmioClearBitsBe16 ( + IN UINTN Address, + IN UINT16 Mask + ) +{ + ASSERT ((Address & 1) == 0); + *(volatile UINT16*)Address = *(volatile UINT16*)Address & Uswap16(~Mask); + return *(volatile UINT16*)Address; +} + +/** + Clear bits of the 32-bit MMIO register specified by Address with the Mask + specified by Mask and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Mask The Bits to clear in MMIO register. + +**/ +UINT32 +EFIAPI +MmioClearBitsBe32 ( + IN UINTN Address, + IN UINT32 Mask + ) +{ + ASSERT ((Address & 3) == 0); + *(volatile UINT32*)Address = *(volatile UINT32*)Address & Uswap32(~Mask); + return *(volatile UINT32*)Address; +} + +/** + Clear bits of the 64-bit MMIO register specified by Address with the Mask + specified by Mask and returns register content. This function must + guarantee that all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Mask The Bits to clear in MMIO register. + +**/ +UINT64 +EFIAPI +MmioClearBitsBe64 ( + IN UINTN Address, + IN UINT64 Mask + ) +{ + ASSERT ((Address & 7) == 0); + *(volatile UINT64*)Address = *(volatile UINT64*)Address & Uswap64(~Mask); + return *(volatile UINT64*)Address; +} -- 1.9.1