From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=XDtiRDiI; spf=pass (domain: linaro.org, ip: 209.85.221.41, mailfrom: leif.lindholm@linaro.org) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by groups.io with SMTP; Thu, 05 Sep 2019 07:28:19 -0700 Received: by mail-wr1-f41.google.com with SMTP id g7so3078170wrx.2 for ; Thu, 05 Sep 2019 07:28:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=OlabQIr2KD40bkcEz12heA0dipKf3gRkeuKnIpe8Eiw=; b=XDtiRDiIMBsalM163Xjozx0K/K0R4uGDiGWjXM0UkICAN22ahdDExdhoqcFDX+Lu20 obtql2A/fY300qvHOVkd1oxhk/COlh64K4F3f1osY3csOZrNo+5WgLhCGU6PASUrT/1+ p5WcOklO+ue0AGYuWGZdWpYtFsCU67pCnA9ZmikIAYQ6y12/9roHy7AnZQF6h/He/9Qo ivWmCZHyTmG5mxaXuXQRqIcO1Dfh81Wx15hlOTxM5E34MxS5Ce1WGBHzsgOCDvHn7cFR bijPivb7jJz400a/igbtYnf4snlrUlSVqoSpE8LtRoxKC+zI96uwRhIp8EgK8TBdGBUi mGKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=OlabQIr2KD40bkcEz12heA0dipKf3gRkeuKnIpe8Eiw=; b=KXy6yrSZWDfc5zo5Wm5tv1ovUulLAfoC7yZdy9b2Uy15oJLqFe0xwEReVE5RqrYzrO QNpdLdCsfWhBofRDP5xBkR1m1kq0faBvfkO2Jp81F7fMgIa130QOF3aSTOd33AxaxnSr fdH/jdRedboemf6JqHLWaPNLkS8DfG9xFa6g2ANKLIm0d/HK4sLmXFdwq4X+eWhRYxwL Gth9Q5DD8HtS0RG8FeLAthjYlt66qud5MpaQ2x8xa6Wjd6dCExVayGUq5C/NAWdP6slP 5dvNY1IOZBMPuhxRARRqLZmti9WSV+1kBPvGgGwv15ekGtB5bfi1qyhH1zqsEXDxf24x 5kew== X-Gm-Message-State: APjAAAUZZYR2pj8gjZj3mO1KHNx9rqtWhWU5JRWnZbmCqjLy7h3OoxPF dBr9L+/ZVy3Ik7Goa/3xtTiL+eB1aIU= X-Google-Smtp-Source: APXvYqxFysCJk1E2C5kmRR/Ny25A1J3pg4Ba9OHaM+npBi+HrPJ41jHIoKaH9x4J1cmrwobmWW2V/w== X-Received: by 2002:adf:a4c7:: with SMTP id h7mr2612288wrb.137.1567693696914; Thu, 05 Sep 2019 07:28:16 -0700 (PDT) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id o12sm2904483wmh.43.2019.09.05.07.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 07:28:16 -0700 (PDT) Date: Thu, 5 Sep 2019 15:28:14 +0100 From: "Leif Lindholm" To: devel@edk2.groups.io, abner.chang@hpe.com Subject: Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v1 07/22]: MdePkg/BaseIoLibIntrinsic: RISC-V I/O intrinsic functions. Message-ID: <20190905142814.GY29255@bivouac.eciton.net> References: <1567593797-26216-1-git-send-email-abner.chang@hpe.com> <1567593797-26216-8-git-send-email-abner.chang@hpe.com> MIME-Version: 1.0 In-Reply-To: <1567593797-26216-8-git-send-email-abner.chang@hpe.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Sep 04, 2019 at 06:43:02PM +0800, Abner Chang wrote: > RISC-V MMIO library instance. RISC-V only supports memory map I/O. However the first implementation > of RISC-V EDK2 port uses PC/AT as the RISC-V platform spec. We have > to keep the I/O functions as the temporary solution. Can you expand on the I/O port situation? Since the architecture doesn't support it, what do these functions do? For the pure MMIO ops using compliant C, we really don't need yet another implementation pretending it's architecture specific. We should just have a single IoLibMmio.c and an IoLibMmioNonCompliant.c if the x86 folks want to keep their current one. / Leif > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Abner Chang > --- > .../BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf | 8 +- > MdePkg/Library/BaseIoLibIntrinsic/IoLibRiscV.c | 697 +++++++++++++++++++++ > 2 files changed, 703 insertions(+), 2 deletions(-) > create mode 100644 MdePkg/Library/BaseIoLibIntrinsic/IoLibRiscV.c > > diff --git a/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf b/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf > index 457cce9..fbb568e 100644 > --- a/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf > +++ b/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf > @@ -2,13 +2,14 @@ > # Instance of I/O Library using compiler intrinsics. > # > # I/O Library that uses compiler intrinsics to perform IN and OUT instructions > -# for IA-32 and x64. On IPF, I/O port requests are translated into MMIO requests. > +# for IA-32, x64 and RISC-V. On IPF, I/O port requests are translated into MMIO requests. > # MMIO requests are forwarded directly to memory. For EBC, I/O port requests > # ASSERT(). > # > # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
> # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> # Copyright (c) 2017, AMD Incorporated. All rights reserved.
> +# Portinos Copyright (c) 2016, Hewlett Packard Enterprise Development LP. All rights reserved.
> # > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > @@ -25,7 +26,7 @@ > > > # > -# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64 > +# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64 RISCV64 > # > > [Sources] > @@ -55,6 +56,9 @@ > [Sources.AARCH64] > IoLibArm.c > > +[Sources.RISCV64] > + IoLibRiscV.c > + > [Packages] > MdePkg/MdePkg.dec > > diff --git a/MdePkg/Library/BaseIoLibIntrinsic/IoLibRiscV.c b/MdePkg/Library/BaseIoLibIntrinsic/IoLibRiscV.c > new file mode 100644 > index 0000000..6173d25 > --- /dev/null > +++ b/MdePkg/Library/BaseIoLibIntrinsic/IoLibRiscV.c > @@ -0,0 +1,697 @@ > +/** @file > + Common I/O Library routines for RISC-V > + > + Copyright (c) 2016 - 2019, Hewlett Packard Enterprise Development LP. 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. > +**/ > + > +#include "BaseIoLibIntrinsicInternal.h" > + > +/** > + Reads an 8-bit MMIO register. > + > + Reads the 8-bit MMIO register specified by Address. The 8-bit read value is > + returned. 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 read. > + > + @return The value read. > + > +**/ > +UINT8 > +EFIAPI > +MmioRead8 ( > + IN UINTN Address > + ) > +{ > + return *(volatile UINT8*)Address; > +} > + > +/** > + Writes an 8-bit MMIO register. > + > + Writes the 8-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 8-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. > + > + @return Value. > + > +**/ > +UINT8 > +EFIAPI > +MmioWrite8 ( > + IN UINTN Address, > + IN UINT8 Value > + ) > +{ > + *(volatile UINT8 *)Address = Value; > + return Value; > +} > + > +/** > + Reads a 16-bit MMIO register. > + > + 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(). > + If Address is not aligned on a 16-bit boundary, then ASSERT(). > + > + @param Address The MMIO register to read. > + > + @return The value read. > + > +**/ > +UINT16 > +EFIAPI > +MmioRead16 ( > + IN UINTN Address > + ) > +{ > + return *(volatile UINT16 *)Address; > +} > + > +/** > + Writes a 16-bit MMIO register. > + > + 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(). > + If Address is not aligned on a 16-bit boundary, then ASSERT(). > + > + @param Address The MMIO register to write. > + @param Value The value to write to the MMIO register. > + > + @return Value. > + > +**/ > +UINT16 > +EFIAPI > +MmioWrite16 ( > + IN UINTN Address, > + IN UINT16 Value > + ) > +{ > + *(volatile UINT16 *)Address = Value; > + return Value; > +} > + > +/** > + Reads a 32-bit MMIO register. > + > + 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(). > + If Address is not aligned on a 32-bit boundary, then ASSERT(). > + > + @param Address The MMIO register to read. > + > + @return The value read. > + > +**/ > +UINT32 > +EFIAPI > +MmioRead32 ( > + IN UINTN Address > + ) > +{ > + return *(volatile UINT32 *)Address; > +} > + > +/** > + Writes a 32-bit MMIO register. > + > + 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(). > + If Address is not aligned on a 32-bit boundary, then ASSERT(). > + > + @param Address The MMIO register to write. > + @param Value The valu return *(volatile UINT8*)Address; > + to write to the MMIO register. > + > + @return Value. > + > +**/ > +UINT32 > +EFIAPI > +MmioWrite32 ( > + IN UINTN Address, > + IN UINT32 Value > + ) > +{ > + *(volatile UINT32 *)Address = Value; > + return Value; > +} > + > +/** > + Reads a 64-bit MMIO register. > + > + 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(). > + If Address is not aligned on a 64-bit boundary, then ASSERT(). > + > + @param Address The MMIO register to read. > + > + @return The value read. > + > +**/ > +UINT64 > +EFIAPI > +MmioRead64 ( > + IN UINTN Address > + ) > +{ > + return *(volatile UINT64 *)Address; > +} > + > +/** > + Writes a 64-bit MMIO register. > + > + 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(). > + If Address is not aligned on a 64-bit boundary, then ASSERT(). > + > + @param Address The MMIO register to write. > + @param Value The value to write to the MMIO register. > + > +**/ > +UINT64 > +EFIAPI > +MmioWrite64 ( > + IN UINTN Address, > + IN UINT64 Value > + ) > +{ > + *(volatile UINT64 *)Address = Value; > + return Value; > +} > + > +/** > + Reads an 8-bit I/O port. > + > + Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned. > + 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. > + > + @return The value read. > + > +**/ > +UINT8 > +EFIAPI > +IoRead8 ( > + IN UINTN Port > + ) > +{ > + // > + // RISC-V only supports memory map I/O. However the > + // first implementation of RISC-V EDK2 port use PC/AT > + // as the RISC-V platform spec. We have to keep I/O > + // functions for temporary solution. > + // > + return *(volatile UINT8*)Port; > +} > + > +/** > + Writes an 8-bit I/O port. > + > + Writes the 8-bit I/O port specified by Port with the value specified by Value > + and returns Value. 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 write. > + @param Value The value to write to the I/O port. > + > + @return The value written the I/O port. > + > +**/ > + > +UINT8 > +EFIAPI > +IoWrite8 ( > + IN UINTN Port, > + IN UINT8 Value > + ) > +{ > + // > + // RISC-V only supports memory map I/O. However the > + // first implementation of RISC-V EDK2 port uses PC/AT > + // as the RISC-V platform spec. We have to keep I/O > + // functions as the temporary solution. > + // > + *(volatile UINT8 *)Port = Value; > + return Value; > +} > + > +/** > + Reads a 16-bit I/O port. > + > + Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned. > + 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. > + > + @return The value read. > + > +**/ > +UINT16 > +EFIAPI > +IoRead16 ( > + IN UINTN Port > + ) > +{ > + // > + // RISC-V only supports memory map I/O. However the > + // first implementation of RISC-V EDK2 port uses PC/AT > + // as the RISC-V platform spec. We have to keep I/O > + // functions as the temporary solution. > + // > + return *(volatile UINT16*)Port; > +} > + > +/** > + Writes a 16-bit I/O port. > + > + Writes the 16-bit I/O port specified by Port with the value specified by Value > + and returns Value. 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 write. > + @param Value The value to write to the I/O port. > + > + @return The value written the I/O port. > + > +**/ > +UINT16 > +EFIAPI > +IoWrite16 ( > + IN UINTN Port, > + IN UINT16 Value > + ) > +{ > + // > + // RISC-V only supports memory map I/O. However the > + // first implementation of RISC-V EDK2 port uses PC/AT > + // as the RISC-V platform spec. We have to keep I/O > + // functions as the temporary solution. > + // > + *(volatile UINT16*)Port = Value; > + return Value; > +} > + > +/** > + Reads a 32-bit I/O port. > + > + Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned. > + 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. > + > + @return The value read. > + > +**/ > +UINT32 > +EFIAPI > +IoRead32 ( > + IN UINTN Port > + ) > +{ > + // > + // RISC-V only supports memory map I/O. However the > + // first implementation of RISC-V EDK2 port uses PC/AT > + // as the RISC-V platform spec. We have to keep I/O > + // functions as the temporary solution. > + // > + return *(volatile UINT32*)Port; > +} > + > +/** > + Writes a 32-bit I/O port. > + > + Writes the 32-bit I/O port specified by Port with the value specified by Value > + and returns Value. 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 write. > + @param Value The value to write to the I/O port. > + > + @return The value written the I/O port. > + > +**/ > +UINT32 > +EFIAPI > +IoWrite32 ( > + IN UINTN Port, > + IN UINT32 Value > + ) > +{ > + // > + // RISC-V only supports memory map I/O. However the > + // first implementation of RISC-V EDK2 port uses PC/AT > + // as the RISC-V platform spec. We have to keep I/O > + // functions as the temporary solution. > + // > + *(volatile UINT32*)Port = Value; > + return Value; > +} > + > +/** > + Reads a 64-bit I/O port. > + > + Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned. > + This function must guarantee that all I/O read and write operations are > + serialized. > + > + If 64-bit I/O port operations are not supported, then ASSERT(). > + If Port is not aligned on a 64-bit boundary, then ASSERT(). > + > + @param Port The I/O port to read. > + > + @return The value read. > + > +**/ > +UINT64 > +EFIAPI > +IoRead64 ( > + IN UINTN Port > + ) > +{ > + // > + // RISC-V only supports memory map I/O. However the > + // first implementation of RISC-V EDK2 port uses PC/AT > + // as the RISC-V platform spec. We have to keep I/O > + // functions as the temporary solution. > + // > + return *(volatile UINT64*)Port; > +} > + > +/** > + Writes a 64-bit I/O port. > + > + Writes the 64-bit I/O port specified by Port with the value specified by Value > + and returns Value. This function must guarantee that all I/O read and write > + operations are serialized. > + > + If 64-bit I/O port operations are not supported, then ASSERT(). > + If Port is not aligned on a 64-bit boundary, then ASSERT(). > + > + @param Port The I/O port to write. > + @param Value The value to write to the I/O port. > + > + @return The value written to the I/O port. > + > +**/ > +UINT64 > +EFIAPI > +IoWrite64 ( > + IN UINTN Port, > + IN UINT64 Value > + ) > +{ > + // > + // RISC-V only supports memory map I/O. However the > + // first implementation of RISC-V EDK2 port uses PC/AT > + // as the RISC-V platform spec. We have to keep I/O > + // functions as the temporary solution. > + // > + *(volatile UINT64*)Port = Value; > + return 0; > +} > + > +/** > + 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 > + ) > +{ > + UINT8 *Buffer8; > + > + // > + // RISC-V only supports memory map I/O. However the > + // first implementation of RISC-V EDK2 port uses PC/AT > + // as the RISC-V platform spec. We have to keep I/O > + // functions as the temporary solution. > + // > + Buffer8 = (UINT8 *)Buffer; > + while (Count-- > 0) { > + *Buffer8++ = *(volatile UINT8 *)Port++; > + } > +} > + > +/** > + 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 retrieve the write data from. > + > +**/ > +VOID > +EFIAPI > +IoWriteFifo8 ( > + IN UINTN Port, > + IN UINTN Count, > + IN VOID *Buffer > + ) > +{ > + UINT8 *Buffer8; > + > + // > + // RISC-V only supports memory map I/O. However the > + // first implementation of RISC-V EDK2 port uses PC/AT > + // as the RISC-V platform spec. We have to keep I/O > + // functions as the temporary solution. > + // > + Buffer8 = (UINT8 *)Buffer; > + while (Count-- > 0) { > + *(volatile UINT8 *)Port++ = *Buffer8++; > + } > +} > + > +/** > + 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 > + ) > +{ > + UINT16 *Buffer16; > + > + // > + // RISC-V only supports memory map I/O. However the > + // first implementation of RISC-V EDK2 port uses PC/AT > + // as the RISC-V platform spec. We have to keep I/O > + // functions as the temporary solution. > + // > + Buffer16 = (UINT16 *)Buffer; > + while (Count-- > 0) { > + *Buffer16++ = *(volatile UINT16 *)Port++; > + } > +} > + > +/** > + 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 retrieve the write data from. > + > +**/ > +VOID > +EFIAPI > +IoWriteFifo16 ( > + IN UINTN Port, > + IN UINTN Count, > + IN VOID *Buffer > + ) > +{ > + UINT16 *Buffer16; > + > + // > + // RISC-V only supports memory map I/O. However the > + // first implementation of RISC-V EDK2 port uses PC/AT > + // as the RISC-V platform spec. We have to keep I/O > + // functions as the temporary solution. > + // > + Buffer16 = (UINT16 *)Buffer; > + while (Count-- > 0) { > + *(volatile UINT16 *)Port++ = *Buffer16++; > + } > +} > + > +/** > + 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 > + ) > +{ > + UINT32 *Buffer32; > + > + // > + // RISC-V only supports memory map I/O. However the > + // first implementation of RISC-V EDK2 port uses PC/AT > + // as the RISC-V platform spec. We have to keep I/O > + // functions as the temporary solution. > + // > + Buffer32 = (UINT32 *)Buffer; > + while (Count-- > 0) { > + *Buffer32++ = *(volatile UINT32 *)Port++; > + } > +} > + > +/** > + 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 retrieve the write data from. > + > +**/ > +VOID > +EFIAPI > +IoWriteFifo32 ( > + IN UINTN Port, > + IN UINTN Count, > + IN VOID *Buffer > + ) > +{ > + UINT32 *Buffer32; > + > + // > + // RISC-V only supports memory map I/O. However the > + // first implementation of RISC-V EDK2 port uses PC/AT > + // as the RISC-V platform spec. We have to keep I/O > + // functions as the temporary solution. > + // > + Buffer32 = (UINT32 *)Buffer; > + while (Count-- > 0) { > + *(volatile UINT32 *)Port++ = *Buffer32++; > + } > +} > -- > 2.7.4 > > > >