From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-x229.google.com (mail-io0-x229.google.com [IPv6:2607:f8b0:4001:c06::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D45E21A1E20 for ; Mon, 17 Oct 2016 00:42:25 -0700 (PDT) Received: by mail-io0-x229.google.com with SMTP id i202so178835332ioi.2 for ; Mon, 17 Oct 2016 00:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=BLsOABBwaJ9m4i3LviqQNtApcdT1kKPEMe42TjgfDNA=; b=NewBIogaqAFNXGO6/V2gfzOJiQWaETdBN/K0M4gyVB2SRnODzrqTjriUwkdbEHvly6 rH5bF0dpO51StLSZKNIz6YxVmyWc9fXrEWdYUdgO3K0ZQT3I+a60zkS1I10TcaA6WLJl /It84EQLHJSVmoiE1NWzR4xGCpZH9l5Fgr+gU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=BLsOABBwaJ9m4i3LviqQNtApcdT1kKPEMe42TjgfDNA=; b=lQ5IgmD6FkPOBJSPRz25t5Jwhle9zipu5QhdcjduxXWIk/RMRFuMZ7cjH0K3t0SWPr UCiTpZUiJ7QIbLksuk+529jhujzH6xnDBTnn4NvMZ6CW7K4axINPHbvpIrYzBBGqfzYi +Dia8loqxEpeEcauCZdLDkIO74m3+mqSDXU9qNIg4pcqxMmZ9n/a6/p3nhizOR7QzSWb b4SNazZUveXR6qGB948DJ9OmUF3TBBX+XH9UPwJszBTnAiXWOvODn1a9Z/qmR1TsV0CU h5HL7mMy0XRUPyJ7LZmc1tEi1348lrFDcBa/Fl/Q8IIj03cKAau3v6dhdkGTfSsLwVvc 3pYQ== X-Gm-Message-State: AA6/9RkXWabx96CibtC+CWs+mZ/Bp/RAjYxrMhJdQcMLHoX8tJFT3HXOgRB8vv5RJoSRmAqCwtzK5uxOpKv7cGwD X-Received: by 10.107.28.148 with SMTP id c142mr20761755ioc.45.1476690145097; Mon, 17 Oct 2016 00:42:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.5.139 with HTTP; Mon, 17 Oct 2016 00:42:24 -0700 (PDT) In-Reply-To: References: <1476437615-29534-1-git-send-email-bhupesh.sharma@nxp.com> <4A89E2EF3DFEDB4C8BFDE51014F606A14B49505E@shsmsx102.ccr.corp.intel.com> From: Ard Biesheuvel Date: Mon, 17 Oct 2016 08:42:24 +0100 Message-ID: To: "Kinney, Michael D" Cc: "Gao, Liming" , Bhupesh Sharma , "edk2-devel@ml01.01.org" Subject: Re: [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: Mon, 17 Oct 2016 07:42:26 -0000 Content-Type: text/plain; charset=UTF-8 On 17 October 2016 at 05:10, Kinney, Michael D wrote: > Bhupesh, > > It is also possible to add an ARM specific PCD to select endianness and update > MdePkg/Library/BaseIoLibIntrinsic/IoLibArm.c to use that PCD in MmioRead/Write() > APIs in that file to support both endian types. You can use the SwapBytesxx() > functions from BaseLib(as Laszlo suggested) based on the setting of this ARM > specific PCD. > > Modules that link against this lib can select endianness by setting PCD in the > scope of that module. > > The IPF version of IoLib uses an IPF specific PCD to translate I/O port accesses > to MMIO accesses. So there is already an example of an arch specific PCD in this > lib instance. > This is not a platform wide thing, it is a per-device property whether the MMIO occurs in big endian or little endian manner. So I think Liming's suggestion makes sense: create an IoLib implementation that performs the byte swapping, and selectively incorporate it into drivers that require it using BeMmioDeviceDxe.inf { IoLib|SomePkg/Library/BigEndianIoLib.inf }