From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on062b.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe48::62b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9B1E5819C0 for ; Thu, 5 Jan 2017 13:49:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=E199W5GbY+wRStNT7fCOiZ/DcpESekRVi5d21MOOi74=; b=kp8LmET9+Q0RzgmlRS4vvmRD2TaEzyAUwRz/DnTLXdi7/KF0Hw1bK2Pz965p5GnSqwmUbE94JiWwQEt8gHmV66oKopfEYZJIOvKMiwDH/+EnmYz+Nab0h+vsM5RhvGk4iKWct4IXEf0sozBuFzoaVZ1fwHZjmIOyZlEZjBD4GWk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=leo.duran@amd.com; Received: from leduran-Precision-WorkStation-T5400.amd.com (165.204.77.1) by DM5PR12MB1243.namprd12.prod.outlook.com (10.168.237.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.817.10; Thu, 5 Jan 2017 21:49:36 +0000 From: Leo Duran To: CC: , , , , , , , , , , , , Leo Duran Date: Thu, 5 Jan 2017 15:49:22 -0600 Message-ID: <1483652965-14357-2-git-send-email-leo.duran@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1483652965-14357-1-git-send-email-leo.duran@amd.com> References: <1483652965-14357-1-git-send-email-leo.duran@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR14CA0005.namprd14.prod.outlook.com (10.173.227.15) To DM5PR12MB1243.namprd12.prod.outlook.com (10.168.237.22) X-MS-Office365-Filtering-Correlation-Id: 9eb37d39-43ad-4c62-4263-08d435b4beec X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM5PR12MB1243; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1243; 3:iAaXEFaJExdPISMCZbZrZdNJykSWkcQPqHUrY+Y8Sxwd28s5ltseZW93CY07BtnmgvY0DcemEuFrCNzesBZi/Dwda9QkjKNxWNNHDiOlpk3NJ2hByzdx6vImwhi4qfMRQnV6HluCfbj63Octv5JkGvU+uQE6zdXedDunU6INRScLDwEHQYbuqfMkR8YHVnhOF1W+cc7NbtgvmvNAgz2kNbxdRkpL82NPihyfFzLiesE0zc3xhAI/UFkuqzzQRJ2V2M7SoD7urO8OBCutlXA3JQ== X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1243; 25:miiH0HlcduORXDnkh1KzgPYUPye76iZRWd6d0g0e/nAW6Hbl+bDWLmWK0+SE8JoxgfMgID12Hem9DGhKW2xoYw96IqdcjGtt7FVU0smHgKErMvJm5g05N0WlnOEB+aRRcjrBbKi1tvFtjFq+URaTmxpDPEGQiSffr7H51aesGaCiB+WakvQdYupwO9jEJ/9nflu948OWp5cV3g0sFMKxBcnsgud2N6nnUsmIeo8buz1l4tnH4c1FUvFyE7u/Fz/Aj2TqrQ0x72Y6MSALZGxvILghXFKLRziQOS/vwTzG7dPE9PXEYHRa8nyx2kJQpmQrWKj8YA7GV9nLbN0ga1458OZAMF1rR2tWrHwRC3CQGoeAaXXQiOse1/hZbCJ5cm+8c7wx4EZHSa7SnYkr8eTwhUQ2JXJoMWdEImB7UoaOq6wjTlyVMRPoq4c8+EvUnnQE4GO1k7jJw1dwkHa1nHX9QOBk+CgYqfWItR5ift4pB8snaTyK7nJVmsJjXmNJPyBAeBanCZvS4IzPzJYht67bPROwOCO+9FGE7mucVXNRdGUMb2tVUcWwexNqCt57FCzmHXmbROkU93dKI/yyqQmzJ/VaDXwrlXoXY2nPKYfLIDXg32lbouX8BmGtxFLYBOcMsnc03sztV6kiEcd5CLwpVkBX3INo38+II83Q8CcaAwj0HE/nRExkmBYurafOthIHTwhEj09wwFa31pZlCbc+obnP1FN5+NyIejvU7ZffPUqELKaX+7D0tK6UKHZLohLRpFJXkzkINt4mDLbBHlomZ9dIFWw99fBOg1rGzAY9JW/Brb7Hl/pH3v1AbYv06SFE X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1243; 31:4HInfcveNR9fOFshDSOhQ8sFzJ92McG3TzEXobAjJLHI0egg48vJpN+5VCvOm9JZidy0zd/JMFk+A03W//f2Zh7zGhquqbjeUrJ7olkmtHewOV4CndUsvDxB2YaNi4s9Mk6jFB2iLPLVXuz+TdCG3X/e2tlwqATPqJKntXew+xzycBTtmlMDMKVGC9FKmELAc2xHeNdX/2MMnpg5yZM819ye7unR/6v3mpFmdMioQG/GOMq0+aX94dkl44qqb+7QpzBj6NvYD5www1fkVazhGg==; 20:D8GokRaNkjSG/V9VZ3rb2UjgEDH7XteMM7h00yOz1dtjWvczdJxdrK+UgTTHqGDMQFHoc/cuGrp9Ac4dwNcZqe1mhDo4r8bylxAoaIdF4g6/RM0ru1sY0m3RIaULPAAivB7WH+AynRgs1fcMvaP3tFffJPGOrKR6QmeF39OzEwCWKYy8hvtm+vlTd2j2QOYNXn9BYI9Yd/XpZ2G6rynDwNM/ukZZw6lfeDfm9d43RbmIkJEoTT2wR4VFspxC6+CM/4qXNdALEtFy6et/BLbuWf0O1Foi+BG5MYFL8NBQqJdGs8nPPgFWvmEiu2cjXXDFQYtNJWAHfU1rIe0+Tvi+6Ws9oEflcPjK6e7RCMp+/dMbwzjEuq/h1qg4fTCSdzbIdHDkpDucDYJ3Nflm2OBk+inb0MO9+2AsVhU5lAY0+WnP0XhzishYfwe5m+LPVZ5THpnOo6YA+itfHXRb9U4bJJWDPd08p0aEMfiru7ONgAoVzA7XSfns0/mW1cQHCJ4E X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6041248)(20161123555025)(20161123560025)(20161123564025)(20161123562025)(6072148); SRVR:DM5PR12MB1243; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1243; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1243; 4:N3vJ+J9rEW9RSEqz0rAJljktc+N/bjRhXGylxylL/HMmmkmGRpXGcJfdbw90HcKKpKcME8ZWUpfBjTiWVoo7fBGrZQQpYjLY+6LvJp7HL8qDGdo+VZhN2FuvLye3iYO4DvcWCpryWxtsWbcCq6k0U9knHZlxTE/feSKRBLu8OEGSph6QrGycR3dawUy5SE/YZXtuaFfJ3mmpgmBX5b3Mc2ak3K0UiRNqIgxRQyCxXnPwkehzxksxfsrga2JWK9V6I7UH1P4Z/R9/FyfKga0QzujQ5VWM8iGHvWNBHPkKOK8wZhwQmMMX9qnAyEaZdyBgw88hVPqF18NDLH21D0UlnaRxFJpYSAZEQTU+hbFE5nuPjNvFiY+PqVEOvj3vFBU98mItyhds14IdbCJSR/lyXzMCaKY0PO2jiinHC5+2vVQJ9RI+1cztzGnbRS/L3sWwsG2hmd+LYOuNCgOus3Hq2KSQEb3Q9Y2MF66JKPP7Ryg0hmcEYaKjFfWDQewbe+K/k2Na9ABOtoyWzRRN7XHc76jl9WgS2P+gNlocc9C+sBAOBumW4+YoYZ+lJwopF8UQPbiPHrrDnqfu2L2tOjDRSBsj/vimJBFUH+sP/OsyXTycriYz3bnlY29dgitiv2JD X-Forefront-PRVS: 0178184651 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6029001)(6009001)(7916002)(39840400002)(39450400003)(39860400002)(39850400002)(39410400002)(189002)(199003)(5003940100001)(8676002)(15395725005)(50226002)(105586002)(92566002)(6666003)(42186005)(25786008)(54906002)(68736007)(31430400001)(189998001)(53416004)(3846002)(305945005)(106356001)(4326007)(7416002)(36756003)(86362001)(50986999)(6486002)(33646002)(76176999)(81166006)(15188155005)(16799955002)(48376002)(50466002)(2351001)(6116002)(38730400001)(6916009)(6306002)(47776003)(66066001)(5660300001)(2906002)(2950100002)(81156014)(110136003)(101416001)(97736004)(7736002)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1243; H:leduran-Precision-WorkStation-T5400.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR12MB1243; 23:t5TyGfypD1hnlV7oc6lXPVJI8gEwCSAlcz395yhg2?= =?us-ascii?Q?W6SyueuonvGHormFPM23M1Xh737fZEMJRiOtIx3x/ItNXy7CdTPdzZ3Qkx7o?= =?us-ascii?Q?YK3Iq/BFXUw+hMeDNn7A63KpbA0OckK5HuPKH+SjvwYbzxZwcL0Q0mcFboDe?= =?us-ascii?Q?6eBfhOvtJtkNCpJWOucwmiDSGv1td99XDSbG8IEgnGQlwOchAqxjr8pmxWHf?= =?us-ascii?Q?hCSNLwYrmCVwmhNRA5hTR/Lu0j325zBiLuXo7A3B+GKGzhD/Iw4Eq9pzLJWh?= =?us-ascii?Q?mf5y8QCO0HiJEMuiuJAaBlfg7HgAbAb1K2o3DOlk3q+m/ndsHAQP6jBmTbJg?= =?us-ascii?Q?iCSRcIBZC2p14ePcrYTA2+l6/aUDsx5+prPIIoFA6rINkcGMOdDIcf/dXVdp?= =?us-ascii?Q?AL6HlCipdRYJ/LGolUOc/6hf8H56ZwGjLd9cxKVeV3nILhcZ3ygaEG2X3sb5?= =?us-ascii?Q?EF6PNVOw09bSh4GY514KJqAewII5DeMnamYABtc3lArwWiaeyxMbWwV8Frw4?= =?us-ascii?Q?soRgagl0UAZGOwwfjq6nF+lPAQH8s1GmiVgpZse1IyoSWY+xayNmnxUj/liI?= =?us-ascii?Q?WD3h6jG99VkfZCtDH1Nxv7Lirq9uNYmwoIUH50qKdJVQCuzmlRRwShWwMUhD?= =?us-ascii?Q?jgv2vVDDDsVLSmps1Ak7uKytqx4bzFUt1+EYRUUbK4Utl4fOcV1Z6q/JwCi5?= =?us-ascii?Q?h/LA/IYm8J/rAtmKvK5tZfCE8g5S6RbykoYIgXsYlMYsGpXyFWOsTpztSB9w?= =?us-ascii?Q?T6Kgvl2r4qJggK+vnTRzxLZxN//6GeLtHfEwsdxOIWSvZXKEhYkGuQX2ZYOc?= =?us-ascii?Q?znBw249NJcuKBUYkmR8RjfGGYjRSPVnJXRPsrmg1dWRD6JPL5iBt16glpfxJ?= =?us-ascii?Q?uapvgZaycdt6ti3M7BnRYhLmUhYbcu+ZI3QsJcx3416fikesySF8eH6RSDg2?= =?us-ascii?Q?DcRJ1TAVtfIRHFYNlzaWxy9yBMuHd1GkIwXF7MbMxjIbgLFWgPNoUBBLyqBq?= =?us-ascii?Q?Cv4KFoTQI/xJxs0eDZ4m/Qsduzfu6fAc/HkQoi50kJCiKCrPcuEakeLBX3IL?= =?us-ascii?Q?1+2gIq9TnjtxTS3qCUe05Y0ZDRrLBJb+vv4QNFlPxacf9MTrXhBCOjq6z3k0?= =?us-ascii?Q?UuPNh7CGinAtf4Nn36pTM1znj+jKfOpjbRMgmB2Am0GOm8RB1kc9fb7dEKPl?= =?us-ascii?Q?Ot1Q/tNDG/8nYWpiaUMJTEntaxpi28ME7pW22j3G6k9VFKCQIUtIpTaNcPzZ?= =?us-ascii?Q?W4AieuZfrnenXy/o+QZ9c6Ry+j+Afo9nT3gscjokiD9pTAUDCa8VIrKjny/0?= =?us-ascii?Q?FD13m38IPOdfhCfvgOIPp438kmOMt5NvwldW89K4cWFCQFvlbpAhz+pQOo9w?= =?us-ascii?Q?2Icvn6FkgiwF0RZbZPG3D3aCOpdoHNO8fOAXB8SKHMPrBvu?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1243; 6:neXZxQ/J29D5OtfgVQfIldkkHYi6VgMsQ9NVjGqN864T6MX+Yl7G6Ed7lKKp8IhsTzxT5o6bO+EPJooJeEgavdJodl7DD653Xim7aEMJUi6JtOwrl52TsAAb+kJ/UnoycMCZqBKLl/iaIe8AtMV7eo1sYMzcKa8xYw6czQQJnK/223w1wEVnRg0Ue9w7IG+o3vMKMA1UIQbsxhNDkNLXJTExngnCr3d47WIlcftGv0FGZEnqI44V2pVq54Ffw/BLW8H96gczPZjZTHtYyeocelZqV1/0UEQYbs3EmnyzUY+svRGRx1evZYTijgOAewLeI0ss1TEXLtWRZmZdgIlbNl/EpUhWzzOgrc/b8gOhpYS2ZxQRaKrdVPbLZJC9x+AuRyD1rzBVscpwACOrdTOXh9Iqo6B1FaArewLtCYKJYZln+dFVKBbJH4REysp5qN53CEyh9GStJiyL395P7wSZLg==; 5:Blgx/iPQf1z5yDwd/jaHFEKJVoIC8yCRBEtx/3gb79vgYIYVx1CFeMiMnypxqRivYTyz3b71E7najMKoqr35/sGou3Ey+yas9/jNhYhJLDToxMrP61OwtFqz/ELfYXHd0xFL/DnoZwLlebdy48fvog==; 24:4XyCOU2rASkQdLzBDxbryiXETu8l45me3qoSlVn64vBzuSDAMY2/abjv97rPmdnbs+McDyp5xPn4BC1yLw+HZnaxC2BqYuoXgX3xV9O4ga0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1243; 7:6AlpN5m/QwsYysNBfGdH+tUpuyx15g9E9mwnnpj8jsDOXVktVJOBCDnnbeKZ/ypruj4lC0JwyMyMagDbm855W2/IU27atRYJQrHRq8ZkhZBpO3U1WTYeX97In4SQgutFNiqTH4Ukh/dxbRb/knrwrXAVV2Vz4tyIlLP90Oj0g57EpaqfHRFBtGqN+4/+goFD52jAE4sDcKSgjaq7fBFTKbLJPQ3h9uzXcrzSMKWEYlFo/Za/OjQMQSrBb8qrSbrDbCeET8E8p5t1uyUCdnsK1N6iZA+6uudFfy4Ky7yUyAA4TaioMBezcM82rE095YatGTevCWOFXEKan+peHDlpw2ZP/6Ka2oqlh3h2MIUR9F0Gbs56RIiX43YqG57V2RB0DYHrng4KE/j5ToazCN1Z3q3ht14Ta6YNEXh3aAd0Ch7xheXjCtXj1l4Z4ja0ZZFjUd6K30Bg88TQwzUdmSNJnQ==; 20:o3bqyNWKRULIdnUxHDlT1jfu60Ymhecxnuxw9FAzznn8URllwvHdTTudqzYUsJxVxE0fpK5DNqGoHE6494Y8qEasaoKus3+cGc3sVa43IDDpSPqV+t+G/xdwQ+MOXqvG8l6DrCDijCnCw4fjU877rTrmxPKwUf5FAFkHTeb7DllcsZ7X/uWqOuo9rlGMkmbTfZfNntoIqshjlJTEafrDRRMWqcsVcLl3yr+7JXFINFATqr1k74pGyqFV6Orc6kL4 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2017 21:49:36.4800 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1243 Subject: [PATCH v3 1/4] MdePkg: Add BaseIoFifoLib library 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: Thu, 05 Jan 2017 21:49:39 -0000 Content-Type: text/plain From: Brijesh Singh The UefiCpuPkg/CpuIo2Dxe driver and the QemuCfgLib library have duplicate implementations of I/O Fifo routines. The patch moves the I/O Fifo routines into a common BaseIofifoLib library supporting IA32 and X64 architectures under MdePkg. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Brijesh Singh Signed-off-by: Leo Duran --- MdePkg/Include/Library/IoFifoLib.h | 176 +++++++++++++++++++++++++ MdePkg/Library/BaseIoFifoLib/BaseIoFifoLib.inf | 44 +++++++ MdePkg/Library/BaseIoFifoLib/Ia32/IoFifo.asm | 140 ++++++++++++++++++++ MdePkg/Library/BaseIoFifoLib/Ia32/IoFifo.nasm | 136 +++++++++++++++++++ MdePkg/Library/BaseIoFifoLib/X64/IoFifo.asm | 126 ++++++++++++++++++ MdePkg/Library/BaseIoFifoLib/X64/IoFifo.nasm | 125 ++++++++++++++++++ MdePkg/MdePkg.dec | 4 + MdePkg/MdePkg.dsc | 2 + 8 files changed, 753 insertions(+) create mode 100644 MdePkg/Include/Library/IoFifoLib.h create mode 100644 MdePkg/Library/BaseIoFifoLib/BaseIoFifoLib.inf create mode 100644 MdePkg/Library/BaseIoFifoLib/Ia32/IoFifo.asm create mode 100644 MdePkg/Library/BaseIoFifoLib/Ia32/IoFifo.nasm create mode 100644 MdePkg/Library/BaseIoFifoLib/X64/IoFifo.asm create mode 100644 MdePkg/Library/BaseIoFifoLib/X64/IoFifo.nasm diff --git a/MdePkg/Include/Library/IoFifoLib.h b/MdePkg/Include/Library/IoFifoLib.h new file mode 100644 index 0000000..f606a41 --- /dev/null +++ b/MdePkg/Include/Library/IoFifoLib.h @@ -0,0 +1,176 @@ +/** @file + I/O FIFO routines + + Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, AMD Inc. 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 + http://opensource.org/licenses/bsd-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. + +**/ + +#ifndef __IO_FIFO_LIB_H__ +#define __IO_FIFO_LIB_H__ + +/** + Reads an 8-bit I/O port fifo into a block of memory. + + Reads the 8-bit I/O fifo port specified by Port. + + The port is read Count times, and the read data is + stored in the provided Buffer. + + This function must guarantee that all I/O read and write operations are + serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + @param Count The number of times to read I/O port. + @param Buffer The buffer to store the read data into. + +**/ +VOID +EFIAPI +IoReadFifo8 ( + IN UINTN Port, + IN UINTN Count, + OUT VOID *Buffer + ); + +/** + Reads a 16-bit I/O port fifo into a block of memory. + + Reads the 16-bit I/O fifo port specified by Port. + + The port is read Count times, and the read data is + stored in the provided Buffer. + + This function must guarantee that all I/O read and write operations are + serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + @param Count The number of times to read I/O port. + @param Buffer The buffer to store the read data into. + +**/ +VOID +EFIAPI +IoReadFifo16 ( + IN UINTN Port, + IN UINTN Count, + OUT VOID *Buffer + ); + +/** + Reads a 32-bit I/O port fifo into a block of memory. + + Reads the 32-bit I/O fifo port specified by Port. + + The port is read Count times, and the read data is + stored in the provided Buffer. + + This function must guarantee that all I/O read and write operations are + serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + @param Count The number of times to read I/O port. + @param Buffer The buffer to store the read data into. + +**/ +VOID +EFIAPI +IoReadFifo32 ( + IN UINTN Port, + IN UINTN Count, + OUT VOID *Buffer + ); + +/** + Writes a block of memory into an 8-bit I/O port fifo. + + Writes the 8-bit I/O fifo port specified by Port. + + The port is written Count times, and the write data is + retrieved from the provided Buffer. + + This function must guarantee that all I/O write and write operations are + serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Count The number of times to write I/O port. + @param Buffer The buffer to store the write data into. + +**/ +VOID +EFIAPI +IoWriteFifo8 ( + IN UINTN Port, + IN UINTN Count, + OUT VOID *Buffer + ); + +/** + Writes a block of memory into a 16-bit I/O port fifo. + + Writes the 16-bit I/O fifo port specified by Port. + + The port is written Count times, and the write data is + retrieved from the provided Buffer. + + This function must guarantee that all I/O write and write operations are + serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Count The number of times to write I/O port. + @param Buffer The buffer to store the write data into. + +**/ +VOID +EFIAPI +IoWriteFifo16 ( + IN UINTN Port, + IN UINTN Count, + OUT VOID *Buffer + ); + +/** + Writes a block of memory into a 32-bit I/O port fifo. + + Writes the 32-bit I/O fifo port specified by Port. + + The port is written Count times, and the write data is + retrieved from the provided Buffer. + + This function must guarantee that all I/O write and write operations are + serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Count The number of times to write I/O port. + @param Buffer The buffer to store the write data into. + +**/ +VOID +EFIAPI +IoWriteFifo32 ( + IN UINTN Port, + IN UINTN Count, + OUT VOID *Buffer + ); + +#endif diff --git a/MdePkg/Library/BaseIoFifoLib/BaseIoFifoLib.inf b/MdePkg/Library/BaseIoFifoLib/BaseIoFifoLib.inf new file mode 100644 index 0000000..91ee89f --- /dev/null +++ b/MdePkg/Library/BaseIoFifoLib/BaseIoFifoLib.inf @@ -0,0 +1,44 @@ +## @file +# Base I/O FiFo Library using REP string instructions. +# +# Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+# Copyright (c) 2017, AMD Inc. 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 +# http://opensource.org/licenses/bsd-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. +# +# Derived from: +# UefiCpuPkg/CpuIo2Dxe +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = BaseIoFifoLib + FILE_GUID = 5591c2ef-cb95-4b56-a907-f057b1b96a3d + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = IoFifoLib + +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources.IA32] + Ia32/IoFifo.nasm + Ia32/IoFifo.asm + +[Sources.X64] + X64/IoFifo.nasm + X64/IoFifo.asm + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + DebugLib diff --git a/MdePkg/Library/BaseIoFifoLib/Ia32/IoFifo.asm b/MdePkg/Library/BaseIoFifoLib/Ia32/IoFifo.asm new file mode 100644 index 0000000..96286c2 --- /dev/null +++ b/MdePkg/Library/BaseIoFifoLib/Ia32/IoFifo.asm @@ -0,0 +1,140 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+; Copyright (c) 2017, AMD Inc. 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 +; http://opensource.org/licenses/bsd-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. +; +;------------------------------------------------------------------------------ + + .586P + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoReadFifo8 ( +; IN UINTN Port, +; IN UINTN Size, +; IN VOID *Buffer +; ); +;------------------------------------------------------------------------------ +IoReadFifo8 PROC + push edi + cld + mov dx, [esp + 8] + mov ecx, [esp + 12] + mov edi, [esp + 16] +rep insb + pop edi + ret +IoReadFifo8 ENDP + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoReadFifo16 ( +; IN UINTN Port, +; IN UINTN Size, +; IN VOID *Buffer +; ); +;------------------------------------------------------------------------------ +IoReadFifo16 PROC + push edi + cld + mov dx, [esp + 8] + mov ecx, [esp + 12] + mov edi, [esp + 16] +rep insw + pop edi + ret +IoReadFifo16 ENDP + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoReadFifo32 ( +; IN UINTN Port, +; IN UINTN Size, +; IN VOID *Buffer +; ); +;------------------------------------------------------------------------------ +IoReadFifo32 PROC + push edi + cld + mov dx, [esp + 8] + mov ecx, [esp + 12] + mov edi, [esp + 16] +rep insd + pop edi + ret +IoReadFifo32 ENDP + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoWriteFifo8 ( +; IN UINTN Port, +; IN UINTN Size, +; IN VOID *Buffer +; ); +;------------------------------------------------------------------------------ +IoWriteFifo8 PROC + push esi + cld + mov dx, [esp + 8] + mov ecx, [esp + 12] + mov esi, [esp + 16] +rep outsb + pop esi + ret +IoWriteFifo8 ENDP + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoWriteFifo16 ( +; IN UINTN Port, +; IN UINTN Size, +; IN VOID *Buffer +; ); +;------------------------------------------------------------------------------ +IoWriteFifo16 PROC + push esi + cld + mov dx, [esp + 8] + mov ecx, [esp + 12] + mov esi, [esp + 16] +rep outsw + pop esi + ret +IoWriteFifo16 ENDP + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoWriteFifo32 ( +; IN UINTN Port, +; IN UINTN Size, +; IN VOID *Buffer +; ); +;------------------------------------------------------------------------------ +IoWriteFifo32 PROC + push esi + cld + mov dx, [esp + 8] + mov ecx, [esp + 12] + mov esi, [esp + 16] +rep outsd + pop esi + ret +IoWriteFifo32 ENDP + + END diff --git a/MdePkg/Library/BaseIoFifoLib/Ia32/IoFifo.nasm b/MdePkg/Library/BaseIoFifoLib/Ia32/IoFifo.nasm new file mode 100644 index 0000000..f4210cb --- /dev/null +++ b/MdePkg/Library/BaseIoFifoLib/Ia32/IoFifo.nasm @@ -0,0 +1,136 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+; Copyright (c) 2017, AMD Inc. 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 +; http://opensource.org/licenses/bsd-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. +; +;------------------------------------------------------------------------------ + + SECTION .text + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoReadFifo8 ( +; IN UINTN Port, +; IN UINTN Size, +; IN VOID *Buffer +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(IoReadFifo8) +ASM_PFX(IoReadFifo8): + push edi + cld + mov dx, [esp + 8] + mov ecx, [esp + 12] + mov edi, [esp + 16] +rep insb + pop edi + ret + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoReadFifo16 ( +; IN UINTN Port, +; IN UINTN Size, +; IN VOID *Buffer +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(IoReadFifo16) +ASM_PFX(IoReadFifo16): + push edi + cld + mov dx, [esp + 8] + mov ecx, [esp + 12] + mov edi, [esp + 16] +rep insw + pop edi + ret + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoReadFifo32 ( +; IN UINTN Port, +; IN UINTN Size, +; IN VOID *Buffer +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(IoReadFifo32) +ASM_PFX(IoReadFifo32): + push edi + cld + mov dx, [esp + 8] + mov ecx, [esp + 12] + mov edi, [esp + 16] +rep insd + pop edi + ret + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoWriteFifo8 ( +; IN UINTN Port, +; IN UINTN Size, +; IN VOID *Buffer +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(IoWriteFifo8) +ASM_PFX(IoWriteFifo8): + push esi + cld + mov dx, [esp + 8] + mov ecx, [esp + 12] + mov esi, [esp + 16] +rep outsb + pop esi + ret + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoWriteFifo16 ( +; IN UINTN Port, +; IN UINTN Size, +; IN VOID *Buffer +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(IoWriteFifo16) +ASM_PFX(IoWriteFifo16): + push esi + cld + mov dx, [esp + 8] + mov ecx, [esp + 12] + mov esi, [esp + 16] +rep outsw + pop esi + ret + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoWriteFifo32 ( +; IN UINTN Port, +; IN UINTN Size, +; IN VOID *Buffer +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(IoWriteFifo32) +ASM_PFX(IoWriteFifo32): + push esi + cld + mov dx, [esp + 8] + mov ecx, [esp + 12] + mov esi, [esp + 16] +rep outsd + pop esi + ret diff --git a/MdePkg/Library/BaseIoFifoLib/X64/IoFifo.asm b/MdePkg/Library/BaseIoFifoLib/X64/IoFifo.asm new file mode 100644 index 0000000..dfdaeea --- /dev/null +++ b/MdePkg/Library/BaseIoFifoLib/X64/IoFifo.asm @@ -0,0 +1,126 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+; Copyright (c) 2017, AMD Inc. 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 +; http://opensource.org/licenses/bsd-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. +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoReadFifo8 ( +; IN UINTN Port, // rcx +; IN UINTN Size, // rdx +; IN VOID *Buffer // r8 +; ); +;------------------------------------------------------------------------------ +IoReadFifo8 PROC + cld + xchg rcx, rdx + xchg rdi, r8 ; rdi: buffer address; r8: save rdi +rep insb + mov rdi, r8 ; restore rdi + ret +IoReadFifo8 ENDP + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoReadFifo16 ( +; IN UINTN Port, // rcx +; IN UINTN Size, // rdx +; IN VOID *Buffer // r8 +; ); +;------------------------------------------------------------------------------ +IoReadFifo16 PROC + cld + xchg rcx, rdx + xchg rdi, r8 ; rdi: buffer address; r8: save rdi +rep insw + mov rdi, r8 ; restore rdi + ret +IoReadFifo16 ENDP + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoReadFifo32 ( +; IN UINTN Port, // rcx +; IN UINTN Size, // rdx +; IN VOID *Buffer // r8 +; ); +;------------------------------------------------------------------------------ +IoReadFifo32 PROC + cld + xchg rcx, rdx + xchg rdi, r8 ; rdi: buffer address; r8: save rdi +rep insd + mov rdi, r8 ; restore rdi + ret +IoReadFifo32 ENDP + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoWriteFifo8 ( +; IN UINTN Port, // rcx +; IN UINTN Size, // rdx +; IN VOID *Buffer // r8 +; ); +;------------------------------------------------------------------------------ +IoWriteFifo8 PROC + cld + xchg rcx, rdx + xchg rsi, r8 ; rsi: buffer address; r8: save rsi +rep outsb + mov rsi, r8 ; restore rsi + ret +IoWriteFifo8 ENDP + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoWriteFifo16 ( +; IN UINTN Port, // rcx +; IN UINTN Size, // rdx +; IN VOID *Buffer // r8 +; ); +;------------------------------------------------------------------------------ +IoWriteFifo16 PROC + cld + xchg rcx, rdx + xchg rsi, r8 ; rsi: buffer address; r8: save rsi +rep outsw + mov rsi, r8 ; restore rsi + ret +IoWriteFifo16 ENDP + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoWriteFifo32 ( +; IN UINTN Port, // rcx +; IN UINTN Size, // rdx +; IN VOID *Buffer // r8 +; ); +;------------------------------------------------------------------------------ +IoWriteFifo32 PROC + cld + xchg rcx, rdx + xchg rsi, r8 ; rsi: buffer address; r8: save rsi +rep outsd + mov rsi, r8 ; restore rsi + ret +IoWriteFifo32 ENDP + + END diff --git a/MdePkg/Library/BaseIoFifoLib/X64/IoFifo.nasm b/MdePkg/Library/BaseIoFifoLib/X64/IoFifo.nasm new file mode 100644 index 0000000..40f90f9 --- /dev/null +++ b/MdePkg/Library/BaseIoFifoLib/X64/IoFifo.nasm @@ -0,0 +1,125 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+; Copyright (c) 2017, AMD Inc. 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 +; http://opensource.org/licenses/bsd-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. +; +;------------------------------------------------------------------------------ + + DEFAULT REL + SECTION .text + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoReadFifo8 ( +; IN UINTN Port, // rcx +; IN UINTN Size, // rdx +; IN VOID *Buffer // r8 +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(IoReadFifo8) +ASM_PFX(IoReadFifo8): + cld + xchg rcx, rdx + xchg rdi, r8 ; rdi: buffer address; r8: save rdi +rep insb + mov rdi, r8 ; restore rdi + ret + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoReadFifo16 ( +; IN UINTN Port, // rcx +; IN UINTN Size, // rdx +; IN VOID *Buffer // r8 +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(IoReadFifo16) +ASM_PFX(IoReadFifo16): + cld + xchg rcx, rdx + xchg rdi, r8 ; rdi: buffer address; r8: save rdi +rep insw + mov rdi, r8 ; restore rdi + ret + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoReadFifo32 ( +; IN UINTN Port, // rcx +; IN UINTN Size, // rdx +; IN VOID *Buffer // r8 +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(IoReadFifo32) +ASM_PFX(IoReadFifo32): + cld + xchg rcx, rdx + xchg rdi, r8 ; rdi: buffer address; r8: save rdi +rep insd + mov rdi, r8 ; restore rdi + ret + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoWriteFifo8 ( +; IN UINTN Port, // rcx +; IN UINTN Size, // rdx +; IN VOID *Buffer // r8 +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(IoWriteFifo8) +ASM_PFX(IoWriteFifo8): + cld + xchg rcx, rdx + xchg rsi, r8 ; rsi: buffer address; r8: save rsi +rep outsb + mov rsi, r8 ; restore rsi + ret + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoWriteFifo16 ( +; IN UINTN Port, // rcx +; IN UINTN Size, // rdx +; IN VOID *Buffer // r8 +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(IoWriteFifo16) +ASM_PFX(IoWriteFifo16): + cld + xchg rcx, rdx + xchg rsi, r8 ; rsi: buffer address; r8: save rsi +rep outsw + mov rsi, r8 ; restore rsi + ret + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; IoWriteFifo32 ( +; IN UINTN Port, // rcx +; IN UINTN Size, // rdx +; IN VOID *Buffer // r8 +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(IoWriteFifo32) +ASM_PFX(IoWriteFifo32): + cld + xchg rcx, rdx + xchg rsi, r8 ; rsi: buffer address; r8: save rsi +rep outsd + mov rsi, r8 ; restore rsi + ret diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index f2bdb30..4475d4d 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -7,6 +7,7 @@ # Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2017, AMD Inc. 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. @@ -254,6 +255,9 @@ [LibraryClasses.IA32, LibraryClasses.X64] # RngLib|Include/Library/RngLib.h + ## @libraryclass Provide services to access I/O Fifo Ports + IoFifoLib|Include/Library/IoFifoLib.h + [LibraryClasses.IPF] ## @libraryclass The SAL Library provides a service to make a SAL CALL. SalLib|Include/Library/SalLib.h diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index b4575cd..93c5ee4 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -3,6 +3,7 @@ # # Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+# Copyright (c) 2017, AMD Inc. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -155,6 +156,7 @@ [Components.IA32, Components.X64] MdePkg/Library/SmmMemLib/SmmMemLib.inf MdePkg/Library/BaseRngLib/BaseRngLib.inf MdePkg/Library/SmmPciExpressLib/SmmPciExpressLib.inf + MdePkg/Library/BaseIoFifoLib/BaseIoFifoLib.inf [Components.IPF] MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf -- 1.9.1