From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::22f; helo=mail-wr0-x22f.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x22f.google.com (mail-wr0-x22f.google.com [IPv6:2a00:1450:400c:c0c::22f]) (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 BC697220EE096 for ; Mon, 4 Dec 2017 04:31:41 -0800 (PST) Received: by mail-wr0-x22f.google.com with SMTP id y21so17045044wrc.1 for ; Mon, 04 Dec 2017 04:36:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=52qzgzAeJmkAldR++nVwKTZ5mYHltoMNTjVTGUxKYy0=; b=Tl+E528MA/Z3hWffWBlgeGAugeJZSzCIza008imSdWnFVyT/PfzxNer/Z2OQXVSerS IB5znyweZmqtftN/9didTmggEGDLsoMUeiNszmGtwGSl4kMFuWU3H3MSK92qN5SQq132 /b0CHlrZcHmyXrMpgawOpi5fwQnLHWEfZJh78= 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:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=52qzgzAeJmkAldR++nVwKTZ5mYHltoMNTjVTGUxKYy0=; b=BADxOjjIpZDkxS2J674J7ERbPQ9w3OtBjRcRBrd+dM1jpRbr1dw8nlQeZl6qt60Qr4 9QfXJUWalJaaePcA51pMw3u78DBWTjRAJEuu+EdLKTf2wqW7o8nKbnYK+Pfjo5oFXRMO QmQWVKnkSZ3VlgXTdXmRPlOv0ELjHwdlEgMYmdSFCW0Qkumq+1EwkGdy7DZ9ke1e5zq0 RoOb6Ws/XVM7aRRg91dQ2S2RK+2H7z3VpGnZCVLjWFhfc5pRLfPNq11mXRnJTdEfbtD8 b3d3+RTUw+Ym5Q5JCzwqPlh4q4z7fDyipWqy3WkxqjmXlCfKMY6xCeZhSiKPda+RDSoj QDeA== X-Gm-Message-State: AJaThX6wy1ovV0o5+XaUT1ipYb5nZ/XfmXvmFBxWOkk4qpP5Am330RAQ S4yZyDCLeB9yudWp9f97ZjxrZg== X-Google-Smtp-Source: AGs4zMY7El5FRdRQjQ5kjSBEvRoR5wuJ9NZbcnfrJNuAoerknqSGCuz6HB/9YxuyoiM/AKyEKp3rnQ== X-Received: by 10.223.143.66 with SMTP id p60mr11588283wrb.99.1512390969044; Mon, 04 Dec 2017 04:36:09 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id m201sm7692774wma.12.2017.12.04.04.36.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Dec 2017 04:36:07 -0800 (PST) Date: Mon, 4 Dec 2017 12:36:05 +0000 From: Leif Lindholm To: "Kinney, Michael D" Cc: Udit Kumar , Meenakshi Aggarwal , Varun Sethi , "edk2-devel@lists.01.org" , "Gao, Liming" , Ard Biesheuvel Message-ID: <20171204123605.6ri2kxeeiqlghnp7@bivouac.eciton.net> References: <4A89E2EF3DFEDB4C8BFDE51014F606A14E16B65D@SHSMSX104.ccr.corp.intel.com> <20171129125114.i3y446ds4qrkohxl@bivouac.eciton.net> <20171129194836.dqsbtbqi5budvppl@bivouac.eciton.net> <20171201105744.mlspp4gsmibbpolz@bivouac.eciton.net> MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) 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.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Dec 2017 12:31:42 -0000 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Mike, In that case - do you think it should be added to MdeModulePkg? Should it be implemented simply as a wrapper on IoLib (depending on it)? / Leif On Fri, Dec 01, 2017 at 10:41:26PM +0000, Kinney, Michael D wrote: > Udit, > > I agree with your concern. > > I am in favor of adding new APIs that perform the > byte swap operations. > > Mike > > > -----Original Message----- > > From: Udit Kumar [mailto:udit.kumar@nxp.com] > > Sent: Friday, December 1, 2017 9:58 AM > > To: Leif Lindholm ; Meenakshi > > Aggarwal ; Varun Sethi > > > > Cc: Kinney, Michael D ; edk2- > > devel@lists.01.org; Gao, Liming ; > > Ard Biesheuvel > > Subject: RE: [edk2] [PATCH 1/1] MdePkg/IoLib: Add support > > for big-endian MMIO > > > > Thanks Leif, > > > > > It may require a little bit more of up-front work, but > > the end result will be a > > > platform port that works with the intended edk2 design > > principles rather than > > > > Yes, this will be re-design/code for us, breaking all > > software pieces into > > smaller blocks and exposing protocol from the same. > > This could be managed. > > > > But how do you see, if there is such dependency oN lib. > > Say a driver which is in BE mode, and is using DebugLib > > (BaseDebugLibSerialPort) > > And DebugLib uses SerialPortLib, which is in LE mode > > > > Thanks > > Udit > > > > > -----Original Message----- > > > From: edk2-devel [mailto:edk2-devel- > > bounces@lists.01.org] On Behalf Of Leif > > > Lindholm > > > Sent: Friday, December 01, 2017 4:28 PM > > > To: Meenakshi Aggarwal > > > Cc: Kinney, Michael D ; > > edk2-devel@lists.01.org; > > > Gao, Liming ; Ard Biesheuvel > > > > > > Subject: Re: [edk2] [PATCH 1/1] MdePkg/IoLib: Add > > support for big-endian > > > MMIO > > > > > > On Thu, Nov 30, 2017 at 04:15:38AM +0000, Meenakshi > > Aggarwal wrote: > > > > Hi Leif, Mike, > > > > > > > > > > > > NXP boards, at present, have few controllers with big > > endian and other > > > > with little endian memory access. > > > > > > Sure, this is not a problem. > > > > > > > Maximum controllers depend on SocLib library for > > clock information and > > > > endianness for SocLib and controllers is different. > > > > > > OK, I see in SocLib you have something called a Gur > > that is read once (and again > > > does a special per-device Pcd dance for runtime > > selection between > > > byteswapping Mmio and plain Mmio). > > > > > > > So this option will not work for us, > > > > You would then just do (in your .dsc): > > > > Platform/NXP/Drivers/WatchDog/WatchDogDxe.inf { > > > > IoLib| > > > > } > > > > > > > > Because all libraries included by WatchDog will then > > access BE mode Mmio > > > APIs. > > > > > > Which libraries performing Mmio accesses are you > > intending to include in your > > > watchdog driver? You have submitted none as part of > > this series. > > > > > > > And breaking code into separate modules with > > different access will be > > > > very difficult. > > > > > > It may require a little bit more of up-front work, but > > the end result will be a > > > platform port that works with the intended edk2 design > > principles rather than > > > against them. And that will reduce the overall effort > > (not to mention code > > > duplication). > > > > > > From the patches you have sent, the only required > > change I see (if a > > > byteswapping IoLib was added to edk2) would be to > > create a tiny driver for this > > > "Gur" device that installs a protocol containing a > > single function for reading > > > from that device's register space. That driver can be > > built against the swapping > > > or non-swapping IoLib as appropriate. > > > > > > > Watchdog is not the only module which need BE Mmio > > APIs, we have MMC > > > > and other controllers also with same requirement. > > > > > > And the same solutions are possible everywhere. > > > > > > Best Regards, > > > > > > Leif > > > > > > > We need BE Mmio APIs with a different name. > > > > > > > > Please see the possibility. > > > > > > > > Thanks & Regards, > > > > Meenakshi > > > > > > > > > -----Original Message----- > > > > > From: Leif Lindholm > > [mailto:leif.lindholm@linaro.org] > > > > > Sent: Thursday, November 30, 2017 1:19 AM > > > > > To: Kinney, Michael D > > > > > Cc: Meenakshi Aggarwal > > ; Gao, Liming > > > > > ; edk2-devel@lists.01.org; > > Ard Biesheuvel > > > > > > > > > > Subject: Re: [edk2] [PATCH 1/1] MdePkg/IoLib: Add > > support for > > > > > big-endian MMIO > > > > > > > > > > I guess there is no strict rule about a driver only > > directly > > > > > accessing one piece of HW? > > > > > > > > > > Still, that would be one possible solution: > > breaking accesses to a > > > > > separate HW in need of byteswapping out into its > > own module and > > > > > letting it override IoLib version there. > > > > > > > > > > Regards, > > > > > > > > > > Leif > > > > > > > > > > On Wed, Nov 29, 2017 at 07:25:05PM +0000, Kinney, > > Michael D wrote: > > > > > > Leif, > > > > > > > > > > > > I agree that this should be described as byte > > swapping. > > > > > > > > > > > > What about a module that needs to access HW with > > and without the > > > > > > bytes swapped? It gets more complex if a module > > is linked against > > > > > > several libs and some libs access HW with bytes > > swapped and some > > > > > > do not. > > > > > > > > > > > > Thanks, > > > > > > > > > > > > Mike > > > > > > > > > > > > > -----Original Message----- > > > > > > > From: edk2-devel [mailto:edk2-devel- > > bounces@lists.01.org] On > > > > > > > Behalf Of Leif Lindholm > > > > > > > Sent: Wednesday, November 29, 2017 4:51 AM > > > > > > > To: Meenakshi Aggarwal > > ; Gao, Liming > > > > > > > > > > > > > > Cc: Kinney, Michael D > > ; > > > > > > > edk2-devel@lists.01.org; Ard Biesheuvel > > > > > > > > > > > > > > Subject: Re: [edk2] [PATCH 1/1] MdePkg/IoLib: > > Add support for > > > > > > > big-endian MMIO > > > > > > > > > > > > > > Hi Meenakshi, > > > > > > > > > > > > > > I finally got around to looking at the watchdog > > code (that uses > > > > > > > this library), and that has convinced me the > > best solution is to > > > > > > > do what Liming proposed. > > > > > > > > > > > > > > Looking at this snippet: > > > > > > > > > > > > > > > +STATIC > > > > > > > > +UINT16 > > > > > > > > +EFIAPI > > > > > > > > +WdogRead ( > > > > > > > > +  IN  UINTN     Address > > > > > > > > +  ) > > > > > > > > +{ > > > > > > > > +  if (FixedPcdGetBool (PcdWdogBigEndian)) { > > > > > > > > +    return BeMmioRead16 (Address); > > > > > > > > +  } else { > > > > > > > > +    return MmioRead16(Address); > > > > > > > > +  } > > > > > > > > > > > > > > This is actually a pretty good demonstration of > > the arguments > > > > > > > that were made with regards to how the BeIoLib > > could be just > > > > > > > another implementation of IoLib. > > > > > > > > > > > > > > You would then just do (in your .dsc): > > > > > > >   Platform/NXP/Drivers/WatchDog/WatchDogDxe.inf > > { > > > > > > >     IoLib| > > > > > > >   } > > > > > > > > > > > > > > This causes the big-endian version of the > > library to be used for > > > > > > > this component. This makes these Wdog > > functions and the > > > > > > > Pcd redundant, and the rest of the code can use > > > > > > > MmioRead16()/MmioWrite16() > > > > > > > directly. > > > > > > > > > > > > > > But then, it is not really a big-endian or > > litte-endian version > > > > > > > of the library we need. We always know which > > endianness we are > > > > > > > building for. > > > > > > > What we need is a byteswapping flavour of > > IoLib. > > > > > > > > > > > > > > So Liming, what if we do something like adding > > a > > > > > > > > > MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSwa > > > > > > > p.inf > > > > > > > --- > > > > > > > [Defines] > > > > > > > INF_VERSION = 0x0001001A > > > > > > > BASE_NAME = > > > > > > > BaseIoLibIntrinsicSwap > > > > > > > MODULE_UNI_FILE = > > > > > > > BaseIoLibIntrinsic.uni > > > > > > > FILE_GUID = d4a60d44- > > 3688-4a50- > > > > > > > b2d0-5c6fc2422523 > > > > > > > MODULE_TYPE = BASE > > > > > > > VERSION_STRING = 1.0 > > > > > > > LIBRARY_CLASS = IoLib > > > > > > > > > > > > > > > > > > > > > # > > > > > > > # VALID_ARCHITECTURES = IA32 X64 EBC > > IPF ARM > > > > > > > AARCH64 > > > > > > > # > > > > > > > > > > > > > > [Sources] > > > > > > > BaseIoLibIntrinsicInternal.h > > > > > > > IoHighLevel.c > > > > > > > IoLib.c > > > > > > > IoLibEbc.c # Asserts on all i/o port > > accesses > > > > > > > IoLibMmioBuffer.c > > > > > > > > > > > > > > [Packages] > > > > > > > MdePkg/MdePkg.dec > > > > > > > > > > > > > > [LibraryClasses] > > > > > > > DebugLib > > > > > > > BaseLib > > > > > > > > > > > > > > [BuildOptions] > > > > > > > GCC:*_*_*_CC_FLAGS = -DSWAP_BYTES > > > > > > > --- > > > > > > > > > > > > > > And then add > > > > > > > > > > > > > > #ifdef SWAP_BYTES > > > > > > > return SwapBytesXX (Value); > > > > > > > #else > > > > > > > return Value; > > > > > > > #fi > > > > > > > > > > > > > > for the read operations and > > > > > > > > > > > > > > #ifdef SWAP_BYTES > > > > > > > *(type)Address = SwapBytesXX (Value); #else > > > > > > > *(type)Address = Value; > > > > > > > #fi > > > > > > > > > > > > > > for the write operations in IoLib.c? > > > > > > > > > > > > > > / > > > > > > > Leif > > > > > > > > > > > > > > On Mon, Nov 27, 2017 at 06:06:33AM +0000, > > Meenakshi Aggarwal > > > > > > > wrote: > > > > > > > > Hi Leif, > > > > > > > > > > > > > > > > This is regarding Big-Endian Library patch > > ([PATCH v2 > > > > > > > 1/9] > > > > > > > > Platform/NXP: Add support for Big Endian Mmio > > APIs) > > > > > > > > > > > > > > > > We have started this discussion before and > > the > > > > > > > suggestion was to > > > > > > > > create a separate .inf file keeping APIs name > > same e.g. > > > > > > > > MmioRead/MmioWrite in MdePkg. > > > > > > > > > > > > > > > > But we can't go with this approach (reason > > mentioned > > > > > > > by Udit). > > > > > > > > > > > > > > > > So please suggest if we should keep this > > library > > > > > > > under Platform/NXP > > > > > > > > or I send a new patch moving this library in > > MdePkg. > > > > > > > > > > > > > > > > But we have to keep a different name for Big > > Endian > > > > > > > MMIO APIs. > > > > > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > Meenakshi > > > > > > > > > > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > > From: Udit Kumar > > > > > > > > > Sent: Monday, October 23, 2017 12:38 PM > > > > > > > > > To: Gao, Liming ; > > Meenakshi > > > > > > > Aggarwal > > > > > > > > > ; Ard > > Biesheuvel > > > > > > > > > ; Kinney, > > Michael D > > > > > > > > > ; edk2- > > > > > > > devel@lists.01.org > > > > > > > > > Subject: RE: [edk2] [PATCH 1/1] > > MdePkg/IoLib: Add > > > > > > > support for big-endian > > > > > > > > > MMIO > > > > > > > > > > > > > > > > > > Hi Meenakshi/Liming, > > > > > > > > > My 2 cents, around this. > > > > > > > > > > > > > > > > > > 1) > > > > > > > > > Having a new lib for BE read might not be > > helpful > > > > > > > for us, e.g. a IP which is in > > > > > > > > > BE mode access the UART for print or system > > > > > > > registers which are in LE, then > > > > > > > > > with new Lib, we will get all read/write in > > BE mode > > > > > > > > > > > > > > > > > > 2) > > > > > > > > > Especially for our IPs, which are changing > > from BE > > > > > > > to LE depending on > > > > > > > > > platform. > > > > > > > > > As said before, having BE read lib with API > > name of > > > > > > > MmioRead32 etc, will not > > > > > > > > > help (I guess Meenakshi already seen some > > problems > > > > > > > around this) Adding a > > > > > > > > > new lib with MmioRead32BE API name could > > help, but > > > > > > > IP driver we need to > > > > > > > > > take care of IP mode either by Pcd or > > #define, to > > > > > > > select MmioRead32 or > > > > > > > > > MmioRead32BE. > > > > > > > > > This conditional compile needs to be done > > for all > > > > > > > IPs (which works in BE/LE > > > > > > > > > mode on different platforms). > > > > > > > > > > > > > > > > > > My preferred way of implementation to use > > one > > > > > > > function in IP driver, And > > > > > > > > > based on IP mode, do the switch. > > > > > > > > > > > > > > > > > > New Lib could have function like below > > > > > > > > > MmioRead32Generic(IN UINTN Address, > > BOOL > > > > > > > IsIPBE) { > > > > > > > > > UINT32 Value; > > > > > > > > > > > > > > > > > > ASSERT ((Address & 3) == 0); > > > > > > > > > Value = *(volatile UINT32*)Address; > > > > > > > > > If(IsIPBE) > > > > > > > > > Value = SwapBytes32(Value); return > > Value; } > > > > > > > > > > > > > > > > > > And IP driver can use it > > > > > > > > > MmioRead32Generic(ADDR, > > > > > > > > > FixedPcdGet(This_IP_Mode_For_This_platform) > > > > > > > > > > > > > > > > > > Comments are welcome. > > > > > > > > > > > > > > > > > > Regards > > > > > > > > > Udit > > > > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > > > From: edk2-devel [mailto:edk2-devel- > > > > > > > bounces@lists.01.org] On Behalf Of > > > > > > > > > > Gao, Liming > > > > > > > > > > Sent: Monday, October 16, 2017 8:48 AM > > > > > > > > > > To: Meenakshi Aggarwal > > > > > > > ; Ard Biesheuvel > > > > > > > > > > ; Kinney, > > Michael D > > > > > > > > > > ; edk2- > > > > > > > devel@lists.01.org > > > > > > > > > > Subject: Re: [edk2] [PATCH 1/1] > > MdePkg/IoLib: Add > > > > > > > support for > > > > > > > > > > big-endian MMIO > > > > > > > > > > > > > > > > > > > > Meenakshi: > > > > > > > > > > I suggest to introduce new IoLib > > library > > > > > > > instance, not to add new IoLib > > > > > > > > > APIs. > > > > > > > > > > New IoLib library instance will perform > > IO > > > > > > > operation as the big > > > > > > > > > > endian. You can update > > > > > > > MdePkg/Library/BaseIoLibIntrinsic instance, add > > > > > > > > > > new source file and new INF for it. > > > > > > > > > > > > > > > > > > > > UINT32 > > > > > > > > > > EFIAPI > > > > > > > > > > MmioRead32 ( > > > > > > > > > > IN UINTN Address > > > > > > > > > > ) > > > > > > > > > > { > > > > > > > > > > UINT32 > > Value; > > > > > > > > > > > > > > > > > > > > ASSERT ((Address & 3) == 0); > > > > > > > > > > Value = *(volatile UINT32*)Address; > > > > > > > > > > return SwapBytes32(Value); } > > > > > > > > > > > > > > > > > > > > Thanks > > > > > > > > > > Liming > > > > > > > > > > >-----Original Message----- > > > > > > > > > > >From: Meenakshi Aggarwal > > > > > > > [mailto:meenakshi.aggarwal@nxp.com] > > > > > > > > > > >Sent: Friday, October 13, 2017 2:07 PM > > > > > > > > > > >To: Ard Biesheuvel > > ; > > > > > > > Kinney, Michael D > > > > > > > > > > >; edk2- > > > > > > > devel@lists.01.org; Gao, Liming > > > > > > > > > > > > > > > > > > > > > >Subject: RE: [edk2] [PATCH 1/1] > > MdePkg/IoLib: > > > > > > > Add support for > > > > > > > > > > >big-endian MMIO > > > > > > > > > > > > > > > > > > > > > >Hi All, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >It’s a pretty old discussion, we have > > left the > > > > > > > upstreaming of NXP > > > > > > > > > > >package in between because of some other > > work, > > > > > > > but have started it > > > > > > > > > > >again > > > > > > > > > > now. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >Issue : Few NXP modules support Big > > Endian > > > > > > > MMIOs as these are ported > > > > > > > > > > >from PowerPC. > > > > > > > > > > > > > > > > > > > > > >Solution suggested : Create a separate > > library > > > > > > > for BE MMIO APIs. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >So what I have done is, I have created a > > > > > > > separate library to support > > > > > > > > > > >BE MMIO APIs and currently keeping it to > > my > > > > > > > package. > > > > > > > > > > >This library is basically a wrapper over > > > > > > > existing MMIO APIs. > > > > > > > > > > > > > > > > > > > > > >UINT32 > > > > > > > > > > >EFIAPI > > > > > > > > > > >BeMmioRead32 ( > > > > > > > > > > > IN UINTN Address > > > > > > > > > > > ) > > > > > > > > > > >{ > > > > > > > > > > > UINT32 Value; > > > > > > > > > > > > > > > > > > > > > > Value = MmioRead32(Address); > > > > > > > > > > > > > > > > > > > > > > return SwapBytes32(Value); } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >Need your opinion on below optinos: > > > > > > > > > > > > > > > > > > > > > >1. Will this be a good idea to make this > > library > > > > > > > a part of MdePkg? OR > > > > > > > > > > > > > > > > > > > > > >2. Add a new file e.g. IoBeMmio.c like > > > > > > > IoHighLevel.c in > > > > > > > > > > >MdePkg/Library/BaseIoLibIntrinsic/ > > > > > > > > > > > And made these APIs a part of IoLib > > itself. OR > > > > > > > > > > > > > > > > > > > > > >3. Keep this library internal to NXP > > package. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >Please provide your inputs. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >Thanks & Regards, > > > > > > > > > > >Meenakshi > > > > > > > > > > > > > > > > > > > > > >> -----Original Message----- > > > > > > > > > > >> From: Bhupesh Sharma > > > > > > > > > > >> Sent: Monday, October 17, 2016 3:28 PM > > > > > > > > > > >> To: Ard Biesheuvel > > > > > > > ; Kinney, Michael D > > > > > > > > > > >> > > > > > > > > > > >> Cc: Gao, Liming > > ; edk2- > > > > > > > devel@ml01.01.org; > > > > > > > > > > >> Meenakshi Aggarwal > > > > > > > > > > > > > > > > > >> Subject: RE: [edk2] [PATCH 1/1] > > MdePkg/IoLib: > > > > > > > Add support for > > > > > > > > > > >> big-endian MMIO > > > > > > > > > > >> > > > > > > > > > > >> Hi Ard, > > > > > > > > > > >> > > > > > > > > > > >> > -----Original Message----- > > > > > > > > > > >> > From: Ard Biesheuvel > > > > > > > [mailto:ard.biesheuvel@linaro.org] > > > > > > > > > > >> > Sent: Monday, October 17, 2016 1:12 > > PM > > > > > > > > > > >> > To: Kinney, Michael D > > > > > > > > > > > > > > > > > >> > Cc: Gao, Liming > > ; > > > > > > > Bhupesh Sharma > > > > > > > > > > >> > ; edk2- > > > > > > > devel@ml01.01.org > > > > > > > > > > >> > Subject: Re: [edk2] [PATCH 1/1] > > > > > > > MdePkg/IoLib: Add support for > > > > > > > > > > >> > big- endian MMIO > > > > > > > > > > >> > > > > > > > > > > > >> > 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 > > > > > > > > > > >> > } > > > > > > > > > > >> > > > > > > > > > > >> That's correct. I think creating a > > separate > > > > > > > IoLib for byte-swapping > > > > > > > > > > >> makes sense. > > > > > > > > > > >> > > > > > > > > > > >> We will rework the patch accordingly. > > > > > > > > > > >> > > > > > > > > > > >> Regards, > > > > > > > > > > >> Bhupesh > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > edk2-devel mailing list > > > > > > > > > > edk2-devel@lists.01.org > > > > > > > > > > > > > > > > > https://emea01.safelinks.protection.outlook.com/?url=http > > s%3A%2F%2Fl > > > > > ist > > > > > s.01.org%2Fmailman%2Flistinfo%2Fedk2- > > > > > > > > > > devel&data=02%7C01%7Cmeenakshi.aggarwal%40nxp.com%7C695e4 > > 3cbb51 > > > > > > > > > > a471cd44608d5376230b0%7C686ea1d3bc2b4c6fa92cd99c5c301635% > > 7C0%7C0 > > > > > > > %7C636475817220663612&sdata=hwQh8dfUkVGzm7uQB9%2FirexmYEk > > dEQ > > > > > %2Bu97606L%2FHEfg%3D&reserved=0 > > > > > > > _______________________________________________ > > > > > > > edk2-devel mailing list > > > > > > > edk2-devel@lists.01.org > > > > > > > > > > > > > > https://emea01.safelinks.protection.outlook.com/?url=http > > s%3A%2F%2Fl > > > > > ist > > > > > s.01.org%2Fmailman%2Flistinfo%2Fedk2- > > > > > > > > > > devel&data=02%7C01%7Cmeenakshi.aggarwal%40nxp.com%7C695e4 > > 3cbb51 > > > > > > > > > > a471cd44608d5376230b0%7C686ea1d3bc2b4c6fa92cd99c5c301635% > > 7C0%7C0 > > > > > > > %7C636475817220663612&sdata=hwQh8dfUkVGzm7uQB9%2FirexmYEk > > dEQ > > > > > %2Bu97606L%2FHEfg%3D&reserved=0 > > > _______________________________________________ > > > edk2-devel mailing list > > > edk2-devel@lists.01.org > > > > > https://emea01.safelinks.protection.outlook.com/?url=http > > s%3A%2F%2Flists.01 > > > .org%2Fmailman%2Flistinfo%2Fedk2- > > > > > devel&data=02%7C01%7Cudit.kumar%40nxp.com%7Cd06018336a064 > > 8fa8e440 > > > > > 8d538aa5f19%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C > > 6364772 > > > > > 26761253124&sdata=bAU%2BOidbzbKw76OOq5%2FUplwQbo8iMnE3alH > > Y4ptAX > > > MU%3D&reserved=0