From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0612.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe42::612]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 00D39819BB for ; Thu, 5 Jan 2017 12:46:31 -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=pBdpjdlWQY7cc1cRJgNbwRzDpvJWhFqrM+yrh0cu510=; b=zfVTRiXKMVPEyOhkyksX5Cs2mxOxExLKV3BcS8DMqEl52sF5hJFraC56k/QXrtawTYb1K6BLM6nhExekIz8hF+fjysA+Mg1DcIANslhqZJS6I6VOOENbzbDzzAMZ1KDI4aRuZ4ZPCS6VvGdcYN34Pwkbq1GwbwHJgJu5+2twVfI= 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 BN6PR12MB1236.namprd12.prod.outlook.com (10.168.227.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 20:46:26 +0000 From: Leo Duran To: CC: , , , , , , , , , , , , Leo Duran Date: Thu, 5 Jan 2017 14:46:11 -0600 Message-ID: <1483649174-14011-2-git-send-email-leo.duran@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1483649174-14011-1-git-send-email-leo.duran@amd.com> References: <1483649174-14011-1-git-send-email-leo.duran@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BLUPR0301CA0019.namprd03.prod.outlook.com (10.162.113.157) To BN6PR12MB1236.namprd12.prod.outlook.com (10.168.227.22) X-MS-Office365-Filtering-Correlation-Id: 8dd7f031-4099-4a15-36c3-08d435abeb79 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BN6PR12MB1236; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1236; 3:SFlGcwlxmV+8CZNn8GBGG8szbENfQDYXONjYQo1+tg4aOoltSfFn9x/eoo3k1kFbecM2dR/KaOre2WCLp2FMz5kYBWwgbNAAQrMFdwn3kQY5VqhYqUqKYd4Z8X+gpATAGxaiYBmkTE3Cr+K5ZSHX/CH53a9DMplYLYB8duQC5dJRKqtnck3ihVg1c9S3niCf0t+81hZjHFNrFhTGj2pom/1v9MmmcLCEw+wspTsIv7T5Y3fhY7c7LAvKiScnsXluQwYDFZ06paE4PuRHR7qNLw== X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1236; 25:76T205Q02iR/E0FXdp/NryHTSFnBfF+PRdVSFwf4Sev+gaC1HCUmdnUlXB5twSq3QMtkVx+zlkvALlb1kVFO2hJZhDkP+eCRD4/VWfn8G6mW2XjCE+gKdYXPid1fEJiT1pLFxkUy5eDui8JQkUCZDA8Q6lL65ZKZK+dmoHVpkjnYYSf+7vQrgmRNMckThO4+WBAHuy6Oi4RotZC1ZUw4eC+N8M9OMWWwhHOvJWJ2x292LJ3HIXboi7yPv3JBUtOvu5T7KNxH1I7YCBt9D4XM/cY34IBHk/ONZbEK4wZ3M26Jpx8dU8C6MQKVRFPlRv7eu0gmaGpli9VP3xYYXfjlTKOUOShU27pgGGLAwbw2wdcsZxyouRHmqEM2FhGbKPaOzcxd3gaggCcQJtl3cBtrWQq8uE9rtd3IovAT6K66WDMHQocpUzOi/PSJQGKUA6Qq//xtkcvQSfQQcvzDU7cZtf6VeDppM/x/gRsZAoXX1YN0gBP81bxNNScn1RH1SE44PLVRKCiF/wDfwKhdST4GPRLsW33snC85akj9XYe/JIKuKShixehjKwvIsaXCuv3A4nd+yud45Pd4fz5Mr3pZ0xRx862+93b//JPtRNnhM29CU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399110); 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:BN6PR12MB1236; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1236; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1236; 4:3I7zADKaXN+TXiX7su+PINPgYNMlt4CISXrCerRo6hgb9+yZ9Lj4MlXZTMb1kV9m9ldshTtX2uVCvpKHHYFFhI15f9Q3CgqxrTaMJojsasxM9HjwkxBmT9/SLFaC6dHfOmWNQ92mi+eeBQxURECepFC4vSEBdUwo0Si0l+88dxK0DmMQXsNzJV4rmY4+Ef4Q5mzTROXu7dlU9WzMKNNxErXnbbhSPSQhHugSg07en94oK7h+wDaj7gJfvu7xr5iPZoVnjZQd4wY1m+zr+PzlMwnydIhxd4JaPDjdzVBXEP4rVMKRIg6OsEjSRM+SLnJmRI34vz0NfPBLpCXy96fX7iS5fLOpq86755s9CXRODr3R1j/NzPjaTfNMDS4/6OoYsgGW7qjBJ0tPmG+SV0SwEuhzoNqXzPkCdeW7cgquG2rF8ctHHgnZwtENU+gHaL+vTonD+Z0pCu39MfQLSE4yNG5XExya+wBwHP0lp8DMAJS6e9uoZTPf0mDg4sF8a9rcK4uZHtgCkBoR2KO9hik1RNGy0JMNYZi/6Z2qAsnXjEQWV0U2/LiHUUXUKyoAxo4EkbgMNt194V4blVXIlG39RcK2d9iLUzzPnwGjgWZOmItwZgY3Fd+XG9m5zm+5tLs6 X-Forefront-PRVS: 0178184651 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6029001)(6009001)(7916002)(39840400002)(39450400003)(39860400002)(39850400002)(39410400002)(199003)(189002)(105586002)(2351001)(106356001)(5660300001)(6916009)(50466002)(6486002)(86362001)(48376002)(68736007)(76176999)(42186005)(50226002)(50986999)(53416004)(110136003)(33646002)(2950100002)(6666003)(8676002)(101416001)(81156014)(47776003)(81166006)(4326007)(7416002)(66066001)(6306002)(15395725005)(38730400001)(54906002)(2906002)(92566002)(189998001)(7736002)(36756003)(31430400001)(15188155005)(305945005)(5003940100001)(97736004)(3846002)(25786008)(16799955002)(6116002)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1236; H:leduran-Precision-WorkStation-T5400.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; BN6PR12MB1236; 23:ZuT4t0zTg7WCJH802y05op1XH76+71mHwBFHEE+Ba?= =?us-ascii?Q?Jth7zzFeg3SY4nO3P9IiESWVYLqTKZyhRKkKG+pNQxNrWa+sPbKxJBzlNSHf?= =?us-ascii?Q?/5NPx8hYVWWyfWcn7G/O3jUXfxkb3teFIgjrz0ajFktKX8gqqg70O4gMF13Z?= =?us-ascii?Q?FwIcmkLPjnLo5RiAatqhgeDLmq7Ml+S5tVFq6vfMQoGl8OX1dPmOIkjsEbFo?= =?us-ascii?Q?AhrYP+iiCdj/LlPz9htUpx8KcIQzizfqE+2TFpQM72k6f+cMBhSbgArSS/h/?= =?us-ascii?Q?Xd9jarwMOSk17s/l5RDeWVTA8EGhPD3pRrgINZPuPw1SeTqDJoQT6Csp6+Jy?= =?us-ascii?Q?L+SmRKchnXQqIXex0BPJUPGTL5dHUfmlU9Cto4SGUdfRNbCIiszzWNjw77Uk?= =?us-ascii?Q?fo9/jx0vHvP/0ecj2winZeE041e9eVJtPxhUGfUAx0fpJ/sP/P3P56FalDZY?= =?us-ascii?Q?seCg0hjT4jQMBct61opwNp2pt/5vvMo+wjHllXakiEDHZrAQ/z7qC7ZLCxLz?= =?us-ascii?Q?BkR6Bijpsq3stGYX5HtCFH8EEJ5BCc873On4/O7IzL3ezFiIFirppZ6MJLqW?= =?us-ascii?Q?qO0wtUt+ytejXR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lfWBbR9kHyNhY6x5I56LKhvtVuOS98E96eUWP9z3Gh84Gg2x5kv7C1B1bZVxakhT02xpJNKkXS7jBs3oziKAJSGi4AfWH59WVGQiyW1KLTGBvjgUrXeArmCCevlW+3q3YJYtvnzxs3kW2Ff09OfBxa06QcuE7k6fta4VYN7O4/A0dmh9Xl+uWEfqwUGO4uIux5rA==; 20:6nfvIuii1+TiObeM+EdrhSGRF6EtOHuNeujFgk10nEXW3TOD9xaFYk/NSIrlEPkG84lWLQOjg0kZRpGGFzJrXzrtbEYITEHZWfR8SZ60RcDB0S/Myb9QZYMWiwSjVwVPPcNFsbl/oPlLx1/vK7m/JhImKJARXo92yzIDUVXK+WD0cAdsdGZPsIkv5qTB4iUIzYBiuFHZGow5pqIG3v/fWtBvei7i00GMExVpYA2GEx51Wz3rx2+hifCRq83+wJVe X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2017 20:46:26.4175 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1236 Subject: [PATCH v2 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 20:46:31 -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: 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