Re: [edk2] [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library

2018-01-10 Thread Ard Biesheuvel
On 10 January 2018 at 11:45, Alexei Fedorov  wrote:
> Hi Ard,
>
>
> You wrote
>
> "Well, the fact that you need to override the BaseMemoryLib
> implementation is telling. This means the region is treated as memory
> in the code, but mapped with device semantics. So this is not about
> performance, but about the face that the UEFI spec stipulates that
> unaligned access to memory are allowed on AArch64, and so if the
> contents of these regions are dereferenced as memory, they should be
> mapped as memory. If they are mapped as device, you should only use
> MmioRead32/MmioWrite32 accessors."
>
>
> In that case could you comment on the following commits:
>
> "The BaseMemoryLib has switch to use BaseMemoryLibOptDxe at OPP, but the
> flash module is device attributes and have to be alignment accessed. so we
> change the flash related drivers to use generic BaseMemoryLib which is
> alignment access. "
>
>
> Hisilicon/D02: flash related drivers switch to use generic BaseMemoryLib:
> https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D02/Pv660D02.dsc?id=e3c520596d9ebdc525f284a9da95f080af815ec9
>
>
> Hisilicon/D03: flash related drivers switch to use generic BaseMemoryLib:
> https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D03/D03.dsc?id=337713801cceb684326bfde22975310ca1bd0cc0
>
>
> Hisilicon/D05: flash related drivers switch to use generic BaseMemoryLib:
> https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D05/D05.dsc?id=0749464022407f11c0c6a46cb8eb293fc74ef236
>

NOR flash can only be mapped as device memory, because it switches
between array mode and command mode, and in the latter mode, we
require device semantics.

Ideally, we should be able to switch between cacheable and device
mappings in this case (because we also switch between modes), but this
is not possible when running under the OS, and VariableRuntimeDxe is a
DXE_RUNTIME_DRIVER type module.

In general, memory should not be mapped with device semantics and vice
versa. NOR flash is arguably a corner case, especially because the
generic variable driver is shared with x86 which doesn't care about
any of this, and so the code is quite sloppy when it comes to
dereferencing pointers that may point outside of memory.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library

2018-01-10 Thread Alexei Fedorov
Hi Ard,


You wrote

"Well, the fact that you need to override the BaseMemoryLib
implementation is telling. This means the region is treated as memory
in the code, but mapped with device semantics. So this is not about
performance, but about the face that the UEFI spec stipulates that
unaligned access to memory are allowed on AArch64, and so if the
contents of these regions are dereferenced as memory, they should be
mapped as memory. If they are mapped as device, you should only use
MmioRead32/MmioWrite32 accessors."


In that case could you comment on the following commits:

"The BaseMemoryLib has switch to use BaseMemoryLibOptDxe at OPP, but the flash 
module is device attributes and have to be alignment accessed. so we change the 
flash related drivers to use generic BaseMemoryLib which is alignment access. "


Hisilicon/D02: flash related drivers switch to use generic BaseMemoryLib:
https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D02/Pv660D02.dsc?id=e3c520596d9ebdc525f284a9da95f080af815ec9


Hisilicon/D03: flash related drivers switch to use generic BaseMemoryLib:
https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D03/D03.dsc?id=337713801cceb684326bfde22975310ca1bd0cc0


Hisilicon/D05: flash related drivers switch to use generic BaseMemoryLib:
https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D05/D05.dsc?id=0749464022407f11c0c6a46cb8eb293fc74ef236


Alexei.



From: edk2-devel <edk2-devel-boun...@lists.01.org> on behalf of Ard Biesheuvel 
<ard.biesheu...@linaro.org>
Sent: 09 January 2018 18:26:57
To: Evan Lloyd
Cc: matteo.carl...@arm.com@arm.com; leif.lindh...@linaro.org@arm.com; 
n...@arm.com@arm.com; edk2-devel@lists.01.org; Arvind Chauhan; 
ard.biesheu...@linaro.org@arm.com; Thomas Abraham
Subject: Re: [edk2] [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD 
platform library

On 9 January 2018 at 18:21, Evan Lloyd <evan.ll...@arm.com> wrote:
>
>
>> -Original Message-
>> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
>> Sent: 23 December 2017 16:23
>> To: Evan Lloyd <evan.ll...@arm.com>
>> Cc: edk2-devel@lists.01.org; Arvind Chauhan <arvind.chau...@arm.com>;
>> Daniil Egranov <daniil.egra...@arm.com>; Thomas Abraham
>> <thomas.abra...@arm.com>; "ard.biesheu...@linaro.org"@arm.com;
>> "leif.lindh...@linaro.org"@arm.com;
>> "matteo.carl...@arm.com"@arm.com; "n...@arm.com"@arm.com
>> Subject: Re: [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD
>> platform library
>>
>> On 22 December 2017 at 19:08,  <evan.ll...@arm.com> wrote:
>> > From: Girish Pathak <girish.pat...@arm.com>
>> >
>> > This change adds the HDLCD platform lib for the Juno plaform. This
>> > library will be instantiated as a LcdPlatformLib to link with
>> > LcdGraphicsOutputDxe for the Juno platform.
>> >
>> > HDLCD platform library depends on the Arm SCMI DXE driver for
>> > communication with the SCP for clock setting. Therefore this change
>> > also enables building of Arm SCMI DXE driver for the Juno platform.
>> >
>> > Contributed-under: TianoCore Contribution Agreement 1.1
>> > Signed-off-by: Girish Pathak <girish.pat...@arm.com>
>>
>> Missing signoff?
> [[Evan Lloyd]] Yes.  Oops.
>
>>
>> > ---
>> >  Platform/ARM/JunoPkg/ArmJuno.dec |   8 +
>> >  Platform/ARM/JunoPkg/ArmJuno.dsc |  29 +
>> >  Platform/ARM/JunoPkg/ArmJuno.fdf |  12 +-
>> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf   |   5 +-
>> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
>> |  40 ++
>> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c |
>> 18 +-
>> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c  |
>> 559 
>> >  7 files changed, 668 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/Platform/ARM/JunoPkg/ArmJuno.dec
>> > b/Platform/ARM/JunoPkg/ArmJuno.dec
>> > index
>> >
>> b733480c3198d135df16ca024b5e85ff350e11c7..cd6710feb2faf0bd17b5ea
>> 39a21d
>> > be5406cd4ffd 100644
>> > --- a/Platform/ARM/JunoPkg/ArmJuno.dec
>> > +++ b/Platform/ARM/JunoPkg/ArmJuno.dec
>> > @@ -53,3 +53,11 @@ [PcdsFixedAtBuild.common]
>> >
>> gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase|0x2E00|UINT64|0
>> x0025
>> >
>> gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize|0x80|UINT32|0x0
>> 026

Re: [edk2] [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library

2018-01-09 Thread Ard Biesheuvel
On 9 January 2018 at 18:21, Evan Lloyd  wrote:
>
>
>> -Original Message-
>> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
>> Sent: 23 December 2017 16:23
>> To: Evan Lloyd 
>> Cc: edk2-devel@lists.01.org; Arvind Chauhan ;
>> Daniil Egranov ; Thomas Abraham
>> ; "ard.biesheu...@linaro.org"@arm.com;
>> "leif.lindh...@linaro.org"@arm.com;
>> "matteo.carl...@arm.com"@arm.com; "n...@arm.com"@arm.com
>> Subject: Re: [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD
>> platform library
>>
>> On 22 December 2017 at 19:08,   wrote:
>> > From: Girish Pathak 
>> >
>> > This change adds the HDLCD platform lib for the Juno plaform. This
>> > library will be instantiated as a LcdPlatformLib to link with
>> > LcdGraphicsOutputDxe for the Juno platform.
>> >
>> > HDLCD platform library depends on the Arm SCMI DXE driver for
>> > communication with the SCP for clock setting. Therefore this change
>> > also enables building of Arm SCMI DXE driver for the Juno platform.
>> >
>> > Contributed-under: TianoCore Contribution Agreement 1.1
>> > Signed-off-by: Girish Pathak 
>>
>> Missing signoff?
> [[Evan Lloyd]] Yes.  Oops.
>
>>
>> > ---
>> >  Platform/ARM/JunoPkg/ArmJuno.dec |   8 +
>> >  Platform/ARM/JunoPkg/ArmJuno.dsc |  29 +
>> >  Platform/ARM/JunoPkg/ArmJuno.fdf |  12 +-
>> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf   |   5 +-
>> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
>> |  40 ++
>> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c |
>> 18 +-
>> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c  |
>> 559 
>> >  7 files changed, 668 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/Platform/ARM/JunoPkg/ArmJuno.dec
>> > b/Platform/ARM/JunoPkg/ArmJuno.dec
>> > index
>> >
>> b733480c3198d135df16ca024b5e85ff350e11c7..cd6710feb2faf0bd17b5ea
>> 39a21d
>> > be5406cd4ffd 100644
>> > --- a/Platform/ARM/JunoPkg/ArmJuno.dec
>> > +++ b/Platform/ARM/JunoPkg/ArmJuno.dec
>> > @@ -53,3 +53,11 @@ [PcdsFixedAtBuild.common]
>> >
>> gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase|0x2E00|UINT64|0
>> x0025
>> >
>> gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize|0x80|UINT32|0x0
>> 026
>> >
>> > +  # MaxMode must be one number higher than the actual max mode,  #
>> > + i.e. for actual maximum mode 2, set the value to 3.
>> > +  #
>> > +  # Default value zero allows platform to enumerate maximum
>> supported mode.
>> > +  #
>> > +  # For a list of mode numbers look in HdLcdArmJuno.c
>> > +
>> gArmJunoTokenSpaceGuid.PcdArmHdLcdMaxMode|0|UINT32|0x001
>> 7
>> > +
>> > diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc
>> > b/Platform/ARM/JunoPkg/ArmJuno.dsc
>> > index
>> >
>> fe860956a4dc497cac52be70bab3657246a08bd0..9027c5b0728a6941f850
>> 636b3bc3
>> > 15fd33b867fb 100644
>> > --- a/Platform/ARM/JunoPkg/ArmJuno.dsc
>> > +++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
>> > @@ -50,6 +50,11 @@ [LibraryClasses.common]
>> ># SCMI Mailbox Transport Layer
>> >ArmMtl|Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
>> >
>> > +!ifndef HEADLESS_PLATFORM
>>
>> Wouldn't it make more sense to add a macro ENABLE_HDLCD, rather than
>> inverting the logic?
>
>  [[Evan Lloyd]] We used this to correspond with the ACPI (FADT) terminology, 
> where HEADLESS implies more than just no display (e.g. no keyboard or mouse).
> It would be possible to insert another level to define ENABLE_HDLCD, 
> ENABLE_KEYBOARD, and ENABLE_MOUSE when  HEADLESS_PLATFORM is not defined, but 
> I'm not convinced that would improve clarity.
> For mobile platforms (Juno, say) the default seems obvious, as a mobile 
> without MMI is pretty pointless (unless you contemplate UEFI on IOT?).  For 
> servers, less so, but the option is still available.  It also seems more 
> natural to explicitly exclude support for hardware that is present, rather 
> than defaulting to a crippled state.
>
>

Fair enough.

>>
>> > +
>> >
> ...
>> > +  # SCMI Driver
>> > +  ArmPlatformPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf {
>> > +
>> > +
>> BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
>>
>> I take it your trusted SRAM does not tolerate unaligned memcpy() because
>> it is mapped as device memory. Couldn't you map it as non-cacheable
>> memory instead? (I meant to ask in response to the other patch but I forgot)
>>
>
>  [[Evan Lloyd]]  As this is generic code we can't know what the platform SCP 
> interface memory constraints might be, so we've gone for the safest option. 
> (It might be fine for Juno, but future stuff is unknown.)  As far as I can 
> tell, the only advantage of non-cacheable would be to permit unaligned 
> access, which might give a small performance improvement.  My current guess 

Re: [edk2] [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library

2018-01-09 Thread Evan Lloyd


> -Original Message-
> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> Sent: 23 December 2017 16:23
> To: Evan Lloyd 
> Cc: edk2-devel@lists.01.org; Arvind Chauhan ;
> Daniil Egranov ; Thomas Abraham
> ; "ard.biesheu...@linaro.org"@arm.com;
> "leif.lindh...@linaro.org"@arm.com;
> "matteo.carl...@arm.com"@arm.com; "n...@arm.com"@arm.com
> Subject: Re: [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD
> platform library
>
> On 22 December 2017 at 19:08,   wrote:
> > From: Girish Pathak 
> >
> > This change adds the HDLCD platform lib for the Juno plaform. This
> > library will be instantiated as a LcdPlatformLib to link with
> > LcdGraphicsOutputDxe for the Juno platform.
> >
> > HDLCD platform library depends on the Arm SCMI DXE driver for
> > communication with the SCP for clock setting. Therefore this change
> > also enables building of Arm SCMI DXE driver for the Juno platform.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Girish Pathak 
>
> Missing signoff?
[[Evan Lloyd]] Yes.  Oops.

>
> > ---
> >  Platform/ARM/JunoPkg/ArmJuno.dec |   8 +
> >  Platform/ARM/JunoPkg/ArmJuno.dsc |  29 +
> >  Platform/ARM/JunoPkg/ArmJuno.fdf |  12 +-
> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf   |   5 +-
> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
> |  40 ++
> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c |
> 18 +-
> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c  |
> 559 
> >  7 files changed, 668 insertions(+), 3 deletions(-)
> >
> > diff --git a/Platform/ARM/JunoPkg/ArmJuno.dec
> > b/Platform/ARM/JunoPkg/ArmJuno.dec
> > index
> >
> b733480c3198d135df16ca024b5e85ff350e11c7..cd6710feb2faf0bd17b5ea
> 39a21d
> > be5406cd4ffd 100644
> > --- a/Platform/ARM/JunoPkg/ArmJuno.dec
> > +++ b/Platform/ARM/JunoPkg/ArmJuno.dec
> > @@ -53,3 +53,11 @@ [PcdsFixedAtBuild.common]
> >
> gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase|0x2E00|UINT64|0
> x0025
> >
> gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize|0x80|UINT32|0x0
> 026
> >
> > +  # MaxMode must be one number higher than the actual max mode,  #
> > + i.e. for actual maximum mode 2, set the value to 3.
> > +  #
> > +  # Default value zero allows platform to enumerate maximum
> supported mode.
> > +  #
> > +  # For a list of mode numbers look in HdLcdArmJuno.c
> > +
> gArmJunoTokenSpaceGuid.PcdArmHdLcdMaxMode|0|UINT32|0x001
> 7
> > +
> > diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc
> > b/Platform/ARM/JunoPkg/ArmJuno.dsc
> > index
> >
> fe860956a4dc497cac52be70bab3657246a08bd0..9027c5b0728a6941f850
> 636b3bc3
> > 15fd33b867fb 100644
> > --- a/Platform/ARM/JunoPkg/ArmJuno.dsc
> > +++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
> > @@ -50,6 +50,11 @@ [LibraryClasses.common]
> ># SCMI Mailbox Transport Layer
> >ArmMtl|Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
> >
> > +!ifndef HEADLESS_PLATFORM
>
> Wouldn't it make more sense to add a macro ENABLE_HDLCD, rather than
> inverting the logic?

 [[Evan Lloyd]] We used this to correspond with the ACPI (FADT) terminology, 
where HEADLESS implies more than just no display (e.g. no keyboard or mouse).
It would be possible to insert another level to define ENABLE_HDLCD, 
ENABLE_KEYBOARD, and ENABLE_MOUSE when  HEADLESS_PLATFORM is not defined, but 
I'm not convinced that would improve clarity.
For mobile platforms (Juno, say) the default seems obvious, as a mobile without 
MMI is pretty pointless (unless you contemplate UEFI on IOT?).  For servers, 
less so, but the option is still available.  It also seems more natural to 
explicitly exclude support for hardware that is present, rather than defaulting 
to a crippled state.


>
> > +
> >
...
> > +  # SCMI Driver
> > +  ArmPlatformPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf {
> > +
> > +
> BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
>
> I take it your trusted SRAM does not tolerate unaligned memcpy() because
> it is mapped as device memory. Couldn't you map it as non-cacheable
> memory instead? (I meant to ask in response to the other patch but I forgot)
>

 [[Evan Lloyd]]  As this is generic code we can't know what the platform SCP 
interface memory constraints might be, so we've gone for the safest option. (It 
might be fine for Juno, but future stuff is unknown.)  As far as I can tell, 
the only advantage of non-cacheable would be to permit unaligned access, which 
might give a small performance improvement.  My current guess is that the 
caller's protocol message structures are likely to be properly aligned anyway, 
so the benefit might be negligible.  The drawback would be that you need to add 
barriers.
The bottom line is, we'll change it if 

Re: [edk2] [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library

2017-12-23 Thread Ard Biesheuvel
On 22 December 2017 at 19:08,   wrote:
> From: Girish Pathak 
>
> This change adds the HDLCD platform lib for the Juno plaform. This
> library will be instantiated as a LcdPlatformLib to link with
> LcdGraphicsOutputDxe for the Juno platform.
>
> HDLCD platform library depends on the Arm SCMI DXE driver for
> communication with the SCP for clock setting. Therefore this change also
> enables building of Arm SCMI DXE driver for the Juno platform.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak 

Missing signoff?

> ---
>  Platform/ARM/JunoPkg/ArmJuno.dec |   8 +
>  Platform/ARM/JunoPkg/ArmJuno.dsc |  29 +
>  Platform/ARM/JunoPkg/ArmJuno.fdf |  12 +-
>  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf   |   5 +-
>  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf |  40 ++
>  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c |  18 +-
>  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c  | 559 
> 
>  7 files changed, 668 insertions(+), 3 deletions(-)
>
> diff --git a/Platform/ARM/JunoPkg/ArmJuno.dec 
> b/Platform/ARM/JunoPkg/ArmJuno.dec
> index 
> b733480c3198d135df16ca024b5e85ff350e11c7..cd6710feb2faf0bd17b5ea39a21dbe5406cd4ffd
>  100644
> --- a/Platform/ARM/JunoPkg/ArmJuno.dec
> +++ b/Platform/ARM/JunoPkg/ArmJuno.dec
> @@ -53,3 +53,11 @@ [PcdsFixedAtBuild.common]
>gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase|0x2E00|UINT64|0x0025
>gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize|0x80|UINT32|0x0026
>
> +  # MaxMode must be one number higher than the actual max mode,
> +  # i.e. for actual maximum mode 2, set the value to 3.
> +  #
> +  # Default value zero allows platform to enumerate maximum supported mode.
> +  #
> +  # For a list of mode numbers look in HdLcdArmJuno.c
> +  gArmJunoTokenSpaceGuid.PcdArmHdLcdMaxMode|0|UINT32|0x0017
> +
> diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc 
> b/Platform/ARM/JunoPkg/ArmJuno.dsc
> index 
> fe860956a4dc497cac52be70bab3657246a08bd0..9027c5b0728a6941f850636b3bc315fd33b867fb
>  100644
> --- a/Platform/ARM/JunoPkg/ArmJuno.dsc
> +++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
> @@ -50,6 +50,11 @@ [LibraryClasses.common]
># SCMI Mailbox Transport Layer
>ArmMtl|Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
>
> +!ifndef HEADLESS_PLATFORM

Wouldn't it make more sense to add a macro ENABLE_HDLCD, rather than
inverting the logic?

> +  
> LcdPlatformLib|Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
> +  LcdHwLib|ArmPlatformPkg/Library/HdLcd/HdLcd.inf
> +!endif
> +
>  [LibraryClasses.common.SEC]
>PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
>
> ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
> @@ -100,7 +105,15 @@ [PcdsFixedAtBuild.common]
>
># System Memory (2GB - 16MB of Trusted DRAM at the top of the 32bit 
> address space)
>gArmTokenSpaceGuid.PcdSystemMemoryBase|0x8000
> +
> +!ifdef HEADLESS_PLATFORM
>gArmTokenSpaceGuid.PcdSystemMemorySize|0x7F00
> +!else
> +  gArmTokenSpaceGuid.PcdSystemMemorySize|0x7B00
> +  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0xFB00
> +  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize|0x0400
> +  gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect|TRUE
> +!endif
>
># Juno Dual-Cluster profile
>gArmPlatformTokenSpaceGuid.PcdCoreCount|6
> @@ -142,6 +155,11 @@ [PcdsFixedAtBuild.common]
>gArmTokenSpaceGuid.PcdGicDistributorBase|0x2C01
>gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x2C02F000
>
> +!ifndef HEADLESS_PLATFORM
> +  # ARM Juno HDLCD Base
> +  gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase|0x7FF6
> +!endif
> +
>#
># PLDA PCI Root Complex
>#
> @@ -314,6 +332,11 @@ [Components.common]
>MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
>
> MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
>
> +!ifndef HEADLESS_PLATFORM
> +  # Graphic Output Protocol
> +  ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
> +!endif
> +
>#
># Juno platform driver
>#
> @@ -347,6 +370,12 @@ [Components.common]
>BdsLib|Platform/ARM/Library/BdsLib/BdsLib.inf
>}
>
> +  # SCMI Driver
> +  ArmPlatformPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf {
> +
> +  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf

I take it your trusted SRAM does not tolerate unaligned memcpy()
because it is mapped as device memory. Couldn't you map it as
non-cacheable memory instead? (I meant to ask in response to the other
patch but I forgot)


> +  }
> +
>  [Components.AARCH64]
>#
># EBC
> diff --git a/Platform/ARM/JunoPkg/ArmJuno.fdf 
> b/Platform/ARM/JunoPkg/ArmJuno.fdf
> index 
> 

[edk2] [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library

2017-12-22 Thread evan . lloyd
From: Girish Pathak 

This change adds the HDLCD platform lib for the Juno plaform. This
library will be instantiated as a LcdPlatformLib to link with
LcdGraphicsOutputDxe for the Juno platform.

HDLCD platform library depends on the Arm SCMI DXE driver for
communication with the SCP for clock setting. Therefore this change also
enables building of Arm SCMI DXE driver for the Juno platform.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak 
---
 Platform/ARM/JunoPkg/ArmJuno.dec |   8 +
 Platform/ARM/JunoPkg/ArmJuno.dsc |  29 +
 Platform/ARM/JunoPkg/ArmJuno.fdf |  12 +-
 Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf   |   5 +-
 Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf |  40 ++
 Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c |  18 +-
 Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c  | 559 

 7 files changed, 668 insertions(+), 3 deletions(-)

diff --git a/Platform/ARM/JunoPkg/ArmJuno.dec b/Platform/ARM/JunoPkg/ArmJuno.dec
index 
b733480c3198d135df16ca024b5e85ff350e11c7..cd6710feb2faf0bd17b5ea39a21dbe5406cd4ffd
 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.dec
+++ b/Platform/ARM/JunoPkg/ArmJuno.dec
@@ -53,3 +53,11 @@ [PcdsFixedAtBuild.common]
   gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase|0x2E00|UINT64|0x0025
   gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize|0x80|UINT32|0x0026
 
+  # MaxMode must be one number higher than the actual max mode,
+  # i.e. for actual maximum mode 2, set the value to 3.
+  #
+  # Default value zero allows platform to enumerate maximum supported mode.
+  #
+  # For a list of mode numbers look in HdLcdArmJuno.c
+  gArmJunoTokenSpaceGuid.PcdArmHdLcdMaxMode|0|UINT32|0x0017
+
diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc b/Platform/ARM/JunoPkg/ArmJuno.dsc
index 
fe860956a4dc497cac52be70bab3657246a08bd0..9027c5b0728a6941f850636b3bc315fd33b867fb
 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.dsc
+++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
@@ -50,6 +50,11 @@ [LibraryClasses.common]
   # SCMI Mailbox Transport Layer
   ArmMtl|Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
 
+!ifndef HEADLESS_PLATFORM
+  
LcdPlatformLib|Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
+  LcdHwLib|ArmPlatformPkg/Library/HdLcd/HdLcd.inf
+!endif
+
 [LibraryClasses.common.SEC]
   PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
   
ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
@@ -100,7 +105,15 @@ [PcdsFixedAtBuild.common]
 
   # System Memory (2GB - 16MB of Trusted DRAM at the top of the 32bit address 
space)
   gArmTokenSpaceGuid.PcdSystemMemoryBase|0x8000
+
+!ifdef HEADLESS_PLATFORM
   gArmTokenSpaceGuid.PcdSystemMemorySize|0x7F00
+!else
+  gArmTokenSpaceGuid.PcdSystemMemorySize|0x7B00
+  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0xFB00
+  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize|0x0400
+  gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect|TRUE
+!endif
 
   # Juno Dual-Cluster profile
   gArmPlatformTokenSpaceGuid.PcdCoreCount|6
@@ -142,6 +155,11 @@ [PcdsFixedAtBuild.common]
   gArmTokenSpaceGuid.PcdGicDistributorBase|0x2C01
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x2C02F000
 
+!ifndef HEADLESS_PLATFORM
+  # ARM Juno HDLCD Base
+  gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase|0x7FF6
+!endif
+
   #
   # PLDA PCI Root Complex
   #
@@ -314,6 +332,11 @@ [Components.common]
   MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
   
MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
 
+!ifndef HEADLESS_PLATFORM
+  # Graphic Output Protocol
+  ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
+!endif
+
   #
   # Juno platform driver
   #
@@ -347,6 +370,12 @@ [Components.common]
   BdsLib|Platform/ARM/Library/BdsLib/BdsLib.inf
   }
 
+  # SCMI Driver
+  ArmPlatformPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf {
+
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+  }
+
 [Components.AARCH64]
   #
   # EBC
diff --git a/Platform/ARM/JunoPkg/ArmJuno.fdf b/Platform/ARM/JunoPkg/ArmJuno.fdf
index 
ee9d0e7f4f6e6ac99ded6a14e88eb2c7854dd473..0b62760cbb3ff93490204ac636b41d5a867dfb80
 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.fdf
+++ b/Platform/ARM/JunoPkg/ArmJuno.fdf
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) 2013-2015, ARM Limited. All rights reserved.
+#  Copyright (c) 2013-2017, ARM Limited. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -163,6 +163,13 @@ [FV.FvMain]
   INF MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouseDxe.inf
   INF 
MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
 
+!ifndef