Re: [edk2] [PATCH v6 0/6] read-only UDF file system support

2017-09-08 Thread Paulo Alcantara


Ard,

On September 8, 2017 7:17:35 PM GMT-03:00, Ard Biesheuvel 
 wrote:
>On 8 September 2017 at 20:40, Laszlo Ersek  wrote:
>> On 09/08/17 21:21, Ard Biesheuvel wrote:
>>> On 8 September 2017 at 19:47, Laszlo Ersek 
>wrote:
 On 09/08/17 14:41, Paulo Alcantara wrote:
> Hi,
>
> This series introduces read-only UDF file system support in EDK2.
>As
> Laszlo (or Red Hat) seemed to be interested in such support, I'm
>posting
> it again after ~3 years.
>
> The idea is not replacing the default FAT file system, nor
>breaking any
> existing file system support, but extending EDK2 with a new file
>system
> that might be useful for some people who are looking for specific
>file
> system features that current FAT doesn't support.
>
> Originally the driver was written to support UDF file systems as
> specified by OSTA Universal Disk Format Specification 2.60.
>However,
> some Windows 10 Enterprise ISO (UDF bridge) images that I tested
> supported a revision of 1.02 thus I had to rework the driver a
>little
> bit to support such revision as well.
>
> v2:
>  - Rework to _partially_ support UDF revisions <2.60.
>  - Use existing CDROM_VOLUME_DESCRIPTOR structure defined in
>Eltorito.h
>instead of creating another one (UDF_VOLUME_DESCRIPTOR).
>  - Fixed UdfDxe to correctly follow UEFI driver model.
>  - Use HARDDRIVE_DEVICE_PATH instead of a vendor-defined one.
>  - Detect UDF file systems only in PartitionDxe, and let UdfDxe
>driver
>check for specific UDF device path to decide whether or not
>install
>SimpleFs protocol.
>  - Place MdePkg changes in a separate patch.
> v3:
>  - Install UDF partition child handles with a Vendor-Defined Media
>Device Path.
>  - Changed UdfDxe to check for Vendor-Defined Media Device Paths
>with a
>specific UDF file system GUID when determining to whether or
>not
>start the driver.
>  - Removed leading TAB chars in some source files identified by
>PatchCheck.py tool.
> v4:
>  - Added missing R-b's.
> v5:
>  - Fixed OVMF IA32 build.
>  - Fixed a typo in UdfDriveBindingStop() ("This" -> "SimpleFs")
>which
>broke retrieval of private fs data from SimpleFs protocol --
>identified by 'reconnect -r' command in UEFI shell.
> v6:
>  - Fixed a bug in UdfRead() that'd pontentially break in ARM or
>IA32
>by allowing caller to read more than 4GiB of data
>(i.e. BufferSize pointer is dereferenced as an UINT64 * and
>it's
> followed by 4 bytes that are nonzero).
>
> Repo:   https://github.com/pcacjr/edk2.git
> Branch: udf-fs-v6
>
> Cc: Laszlo Ersek 
> Cc: Jordan Justen 
> Cc: Andrew Fish 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Star Zeng 
> Cc: Eric Dong 
> Cc: Mark Doran 
> Cc: Ruiyu Ni 
> Cc: hao.a...@intel.com
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Paulo Alcantara 
> ---
>
> Paulo Alcantara (6):
>   MdePkg: Add UDF volume structure definitions
>   MdeModulePkg/PartitionDxe: Add UDF file system support
>   MdeModulePkg: Initial UDF/ECMA-167 file system support
>   OvmfPkg: Enable UDF file system support
>   ArmVirtPkg: Enable UDF file system support
>   Nt32Pkg: Enable UDF file system support
>
>  ArmVirtPkg/ArmVirtQemu.dsc |3 +-
>  ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc   |3 +-
>  ArmVirtPkg/ArmVirtQemuKernel.dsc   |3 +-
>  ArmVirtPkg/ArmVirtXen.dsc  |3 +-
>  ArmVirtPkg/ArmVirtXen.fdf  |1 +
>  .../Universal/Disk/PartitionDxe/Partition.c|9 +-
>  .../Universal/Disk/PartitionDxe/Partition.h|   32 +-
>  .../Universal/Disk/PartitionDxe/PartitionDxe.inf   |3 +-
>  MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c |  318 +++
>  MdeModulePkg/Universal/Disk/UdfDxe/ComponentName.c |  185 ++
>  MdeModulePkg/Universal/Disk/UdfDxe/File.c  |  908
>
>  MdeModulePkg/Universal/Disk/UdfDxe/FileName.c  |  195 ++
>  .../Universal/Disk/UdfDxe/FileSystemOperations.c   | 2447
>
>  MdeModulePkg/Universal/Disk/UdfDxe/Udf.c   |  344 +++
>  MdeModulePkg/Universal/Disk/UdfDxe/Udf.h   | 1244
>++
>  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf  |   66 +
>  MdePkg/Include/IndustryStandard/Udf.h  |   60 +
>  Nt32Pkg/Nt32Pkg.dsc|1 +
>  

[edk2] ApolloLake with EDK2 - Ubuntu boots but Windows 10 does not

2017-09-08 Thread Soni, Amrit
Hi,

I have built a BIOS for my custom board very similar to LeafHill (ApolloLake). 
BIOS boots fine and I can boot Ubuntu from USB stick. But when I try to boot 
Windows 10 installer from USB, it will show Windows 10 logo screen and then 
will go into spin. Any suggestions?

I use Ubuntu for building EDK2.

Thanks.

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v6 0/6] read-only UDF file system support

2017-09-08 Thread Ard Biesheuvel
On 8 September 2017 at 20:40, Laszlo Ersek  wrote:
> On 09/08/17 21:21, Ard Biesheuvel wrote:
>> On 8 September 2017 at 19:47, Laszlo Ersek  wrote:
>>> On 09/08/17 14:41, Paulo Alcantara wrote:
 Hi,

 This series introduces read-only UDF file system support in EDK2. As
 Laszlo (or Red Hat) seemed to be interested in such support, I'm posting
 it again after ~3 years.

 The idea is not replacing the default FAT file system, nor breaking any
 existing file system support, but extending EDK2 with a new file system
 that might be useful for some people who are looking for specific file
 system features that current FAT doesn't support.

 Originally the driver was written to support UDF file systems as
 specified by OSTA Universal Disk Format Specification 2.60. However,
 some Windows 10 Enterprise ISO (UDF bridge) images that I tested
 supported a revision of 1.02 thus I had to rework the driver a little
 bit to support such revision as well.

 v2:
  - Rework to _partially_ support UDF revisions <2.60.
  - Use existing CDROM_VOLUME_DESCRIPTOR structure defined in Eltorito.h
instead of creating another one (UDF_VOLUME_DESCRIPTOR).
  - Fixed UdfDxe to correctly follow UEFI driver model.
  - Use HARDDRIVE_DEVICE_PATH instead of a vendor-defined one.
  - Detect UDF file systems only in PartitionDxe, and let UdfDxe driver
check for specific UDF device path to decide whether or not install
SimpleFs protocol.
  - Place MdePkg changes in a separate patch.
 v3:
  - Install UDF partition child handles with a Vendor-Defined Media
Device Path.
  - Changed UdfDxe to check for Vendor-Defined Media Device Paths with a
specific UDF file system GUID when determining to whether or not
start the driver.
  - Removed leading TAB chars in some source files identified by
PatchCheck.py tool.
 v4:
  - Added missing R-b's.
 v5:
  - Fixed OVMF IA32 build.
  - Fixed a typo in UdfDriveBindingStop() ("This" -> "SimpleFs") which
broke retrieval of private fs data from SimpleFs protocol --
identified by 'reconnect -r' command in UEFI shell.
 v6:
  - Fixed a bug in UdfRead() that'd pontentially break in ARM or IA32
by allowing caller to read more than 4GiB of data
(i.e. BufferSize pointer is dereferenced as an UINT64 * and it's
 followed by 4 bytes that are nonzero).

 Repo:   https://github.com/pcacjr/edk2.git
 Branch: udf-fs-v6

 Cc: Laszlo Ersek 
 Cc: Jordan Justen 
 Cc: Andrew Fish 
 Cc: Michael D Kinney 
 Cc: Liming Gao 
 Cc: Star Zeng 
 Cc: Eric Dong 
 Cc: Mark Doran 
 Cc: Ruiyu Ni 
 Cc: hao.a...@intel.com
 Contributed-under: TianoCore Contribution Agreement 1.1
 Signed-off-by: Paulo Alcantara 
 ---

 Paulo Alcantara (6):
   MdePkg: Add UDF volume structure definitions
   MdeModulePkg/PartitionDxe: Add UDF file system support
   MdeModulePkg: Initial UDF/ECMA-167 file system support
   OvmfPkg: Enable UDF file system support
   ArmVirtPkg: Enable UDF file system support
   Nt32Pkg: Enable UDF file system support

  ArmVirtPkg/ArmVirtQemu.dsc |3 +-
  ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc   |3 +-
  ArmVirtPkg/ArmVirtQemuKernel.dsc   |3 +-
  ArmVirtPkg/ArmVirtXen.dsc  |3 +-
  ArmVirtPkg/ArmVirtXen.fdf  |1 +
  .../Universal/Disk/PartitionDxe/Partition.c|9 +-
  .../Universal/Disk/PartitionDxe/Partition.h|   32 +-
  .../Universal/Disk/PartitionDxe/PartitionDxe.inf   |3 +-
  MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c |  318 +++
  MdeModulePkg/Universal/Disk/UdfDxe/ComponentName.c |  185 ++
  MdeModulePkg/Universal/Disk/UdfDxe/File.c  |  908 
  MdeModulePkg/Universal/Disk/UdfDxe/FileName.c  |  195 ++
  .../Universal/Disk/UdfDxe/FileSystemOperations.c   | 2447 
 
  MdeModulePkg/Universal/Disk/UdfDxe/Udf.c   |  344 +++
  MdeModulePkg/Universal/Disk/UdfDxe/Udf.h   | 1244 ++
  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf  |   66 +
  MdePkg/Include/IndustryStandard/Udf.h  |   60 +
  Nt32Pkg/Nt32Pkg.dsc|1 +
  Nt32Pkg/Nt32Pkg.fdf|1 +
  OvmfPkg/OvmfPkgIa32.dsc|1 +
  OvmfPkg/OvmfPkgIa32.fdf|1 +
  

Re: [edk2] [PATCH v6 0/6] read-only UDF file system support

2017-09-08 Thread Laszlo Ersek
On 09/08/17 21:21, Ard Biesheuvel wrote:
> On 8 September 2017 at 19:47, Laszlo Ersek  wrote:
>> On 09/08/17 14:41, Paulo Alcantara wrote:
>>> Hi,
>>>
>>> This series introduces read-only UDF file system support in EDK2. As
>>> Laszlo (or Red Hat) seemed to be interested in such support, I'm posting
>>> it again after ~3 years.
>>>
>>> The idea is not replacing the default FAT file system, nor breaking any
>>> existing file system support, but extending EDK2 with a new file system
>>> that might be useful for some people who are looking for specific file
>>> system features that current FAT doesn't support.
>>>
>>> Originally the driver was written to support UDF file systems as
>>> specified by OSTA Universal Disk Format Specification 2.60. However,
>>> some Windows 10 Enterprise ISO (UDF bridge) images that I tested
>>> supported a revision of 1.02 thus I had to rework the driver a little
>>> bit to support such revision as well.
>>>
>>> v2:
>>>  - Rework to _partially_ support UDF revisions <2.60.
>>>  - Use existing CDROM_VOLUME_DESCRIPTOR structure defined in Eltorito.h
>>>instead of creating another one (UDF_VOLUME_DESCRIPTOR).
>>>  - Fixed UdfDxe to correctly follow UEFI driver model.
>>>  - Use HARDDRIVE_DEVICE_PATH instead of a vendor-defined one.
>>>  - Detect UDF file systems only in PartitionDxe, and let UdfDxe driver
>>>check for specific UDF device path to decide whether or not install
>>>SimpleFs protocol.
>>>  - Place MdePkg changes in a separate patch.
>>> v3:
>>>  - Install UDF partition child handles with a Vendor-Defined Media
>>>Device Path.
>>>  - Changed UdfDxe to check for Vendor-Defined Media Device Paths with a
>>>specific UDF file system GUID when determining to whether or not
>>>start the driver.
>>>  - Removed leading TAB chars in some source files identified by
>>>PatchCheck.py tool.
>>> v4:
>>>  - Added missing R-b's.
>>> v5:
>>>  - Fixed OVMF IA32 build.
>>>  - Fixed a typo in UdfDriveBindingStop() ("This" -> "SimpleFs") which
>>>broke retrieval of private fs data from SimpleFs protocol --
>>>identified by 'reconnect -r' command in UEFI shell.
>>> v6:
>>>  - Fixed a bug in UdfRead() that'd pontentially break in ARM or IA32
>>>by allowing caller to read more than 4GiB of data
>>>(i.e. BufferSize pointer is dereferenced as an UINT64 * and it's
>>> followed by 4 bytes that are nonzero).
>>>
>>> Repo:   https://github.com/pcacjr/edk2.git
>>> Branch: udf-fs-v6
>>>
>>> Cc: Laszlo Ersek 
>>> Cc: Jordan Justen 
>>> Cc: Andrew Fish 
>>> Cc: Michael D Kinney 
>>> Cc: Liming Gao 
>>> Cc: Star Zeng 
>>> Cc: Eric Dong 
>>> Cc: Mark Doran 
>>> Cc: Ruiyu Ni 
>>> Cc: hao.a...@intel.com
>>> Contributed-under: TianoCore Contribution Agreement 1.1
>>> Signed-off-by: Paulo Alcantara 
>>> ---
>>>
>>> Paulo Alcantara (6):
>>>   MdePkg: Add UDF volume structure definitions
>>>   MdeModulePkg/PartitionDxe: Add UDF file system support
>>>   MdeModulePkg: Initial UDF/ECMA-167 file system support
>>>   OvmfPkg: Enable UDF file system support
>>>   ArmVirtPkg: Enable UDF file system support
>>>   Nt32Pkg: Enable UDF file system support
>>>
>>>  ArmVirtPkg/ArmVirtQemu.dsc |3 +-
>>>  ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc   |3 +-
>>>  ArmVirtPkg/ArmVirtQemuKernel.dsc   |3 +-
>>>  ArmVirtPkg/ArmVirtXen.dsc  |3 +-
>>>  ArmVirtPkg/ArmVirtXen.fdf  |1 +
>>>  .../Universal/Disk/PartitionDxe/Partition.c|9 +-
>>>  .../Universal/Disk/PartitionDxe/Partition.h|   32 +-
>>>  .../Universal/Disk/PartitionDxe/PartitionDxe.inf   |3 +-
>>>  MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c |  318 +++
>>>  MdeModulePkg/Universal/Disk/UdfDxe/ComponentName.c |  185 ++
>>>  MdeModulePkg/Universal/Disk/UdfDxe/File.c  |  908 
>>>  MdeModulePkg/Universal/Disk/UdfDxe/FileName.c  |  195 ++
>>>  .../Universal/Disk/UdfDxe/FileSystemOperations.c   | 2447 
>>> 
>>>  MdeModulePkg/Universal/Disk/UdfDxe/Udf.c   |  344 +++
>>>  MdeModulePkg/Universal/Disk/UdfDxe/Udf.h   | 1244 ++
>>>  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf  |   66 +
>>>  MdePkg/Include/IndustryStandard/Udf.h  |   60 +
>>>  Nt32Pkg/Nt32Pkg.dsc|1 +
>>>  Nt32Pkg/Nt32Pkg.fdf|1 +
>>>  OvmfPkg/OvmfPkgIa32.dsc|1 +
>>>  OvmfPkg/OvmfPkgIa32.fdf|1 +
>>>  OvmfPkg/OvmfPkgIa32X64.dsc |1 +
>>>  OvmfPkg/OvmfPkgIa32X64.fdf |1 +
>>>  OvmfPkg/OvmfPkgX64.dsc |1 +
>>> 

Re: [edk2] [PATCH v6 0/6] read-only UDF file system support

2017-09-08 Thread Ard Biesheuvel
On 8 September 2017 at 19:47, Laszlo Ersek  wrote:
> On 09/08/17 14:41, Paulo Alcantara wrote:
>> Hi,
>>
>> This series introduces read-only UDF file system support in EDK2. As
>> Laszlo (or Red Hat) seemed to be interested in such support, I'm posting
>> it again after ~3 years.
>>
>> The idea is not replacing the default FAT file system, nor breaking any
>> existing file system support, but extending EDK2 with a new file system
>> that might be useful for some people who are looking for specific file
>> system features that current FAT doesn't support.
>>
>> Originally the driver was written to support UDF file systems as
>> specified by OSTA Universal Disk Format Specification 2.60. However,
>> some Windows 10 Enterprise ISO (UDF bridge) images that I tested
>> supported a revision of 1.02 thus I had to rework the driver a little
>> bit to support such revision as well.
>>
>> v2:
>>  - Rework to _partially_ support UDF revisions <2.60.
>>  - Use existing CDROM_VOLUME_DESCRIPTOR structure defined in Eltorito.h
>>instead of creating another one (UDF_VOLUME_DESCRIPTOR).
>>  - Fixed UdfDxe to correctly follow UEFI driver model.
>>  - Use HARDDRIVE_DEVICE_PATH instead of a vendor-defined one.
>>  - Detect UDF file systems only in PartitionDxe, and let UdfDxe driver
>>check for specific UDF device path to decide whether or not install
>>SimpleFs protocol.
>>  - Place MdePkg changes in a separate patch.
>> v3:
>>  - Install UDF partition child handles with a Vendor-Defined Media
>>Device Path.
>>  - Changed UdfDxe to check for Vendor-Defined Media Device Paths with a
>>specific UDF file system GUID when determining to whether or not
>>start the driver.
>>  - Removed leading TAB chars in some source files identified by
>>PatchCheck.py tool.
>> v4:
>>  - Added missing R-b's.
>> v5:
>>  - Fixed OVMF IA32 build.
>>  - Fixed a typo in UdfDriveBindingStop() ("This" -> "SimpleFs") which
>>broke retrieval of private fs data from SimpleFs protocol --
>>identified by 'reconnect -r' command in UEFI shell.
>> v6:
>>  - Fixed a bug in UdfRead() that'd pontentially break in ARM or IA32
>>by allowing caller to read more than 4GiB of data
>>(i.e. BufferSize pointer is dereferenced as an UINT64 * and it's
>> followed by 4 bytes that are nonzero).
>>
>> Repo:   https://github.com/pcacjr/edk2.git
>> Branch: udf-fs-v6
>>
>> Cc: Laszlo Ersek 
>> Cc: Jordan Justen 
>> Cc: Andrew Fish 
>> Cc: Michael D Kinney 
>> Cc: Liming Gao 
>> Cc: Star Zeng 
>> Cc: Eric Dong 
>> Cc: Mark Doran 
>> Cc: Ruiyu Ni 
>> Cc: hao.a...@intel.com
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Paulo Alcantara 
>> ---
>>
>> Paulo Alcantara (6):
>>   MdePkg: Add UDF volume structure definitions
>>   MdeModulePkg/PartitionDxe: Add UDF file system support
>>   MdeModulePkg: Initial UDF/ECMA-167 file system support
>>   OvmfPkg: Enable UDF file system support
>>   ArmVirtPkg: Enable UDF file system support
>>   Nt32Pkg: Enable UDF file system support
>>
>>  ArmVirtPkg/ArmVirtQemu.dsc |3 +-
>>  ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc   |3 +-
>>  ArmVirtPkg/ArmVirtQemuKernel.dsc   |3 +-
>>  ArmVirtPkg/ArmVirtXen.dsc  |3 +-
>>  ArmVirtPkg/ArmVirtXen.fdf  |1 +
>>  .../Universal/Disk/PartitionDxe/Partition.c|9 +-
>>  .../Universal/Disk/PartitionDxe/Partition.h|   32 +-
>>  .../Universal/Disk/PartitionDxe/PartitionDxe.inf   |3 +-
>>  MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c |  318 +++
>>  MdeModulePkg/Universal/Disk/UdfDxe/ComponentName.c |  185 ++
>>  MdeModulePkg/Universal/Disk/UdfDxe/File.c  |  908 
>>  MdeModulePkg/Universal/Disk/UdfDxe/FileName.c  |  195 ++
>>  .../Universal/Disk/UdfDxe/FileSystemOperations.c   | 2447 
>> 
>>  MdeModulePkg/Universal/Disk/UdfDxe/Udf.c   |  344 +++
>>  MdeModulePkg/Universal/Disk/UdfDxe/Udf.h   | 1244 ++
>>  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf  |   66 +
>>  MdePkg/Include/IndustryStandard/Udf.h  |   60 +
>>  Nt32Pkg/Nt32Pkg.dsc|1 +
>>  Nt32Pkg/Nt32Pkg.fdf|1 +
>>  OvmfPkg/OvmfPkgIa32.dsc|1 +
>>  OvmfPkg/OvmfPkgIa32.fdf|1 +
>>  OvmfPkg/OvmfPkgIa32X64.dsc |1 +
>>  OvmfPkg/OvmfPkgIa32X64.fdf |1 +
>>  OvmfPkg/OvmfPkgX64.dsc |1 +
>>  OvmfPkg/OvmfPkgX64.fdf |1 +
>>  25 files changed, 5821 insertions(+), 11 deletions(-)
>>  create mode 100644 

Re: [edk2] [PATCH v2] BaseTools/GCC: set -Wno-unused-const-variables on RELEASE builds

2017-09-08 Thread Laszlo Ersek
On 09/08/17 09:01, Thomas Lamprecht wrote:
> TianoCore BZ#700 [1]
> 
> Set the '-Wno-unused-const-variables' in RELEASE builds with the
> GGC49 and GCC5 toolchain.
> 
> This fixes the RELEASE build of OVMF with GCC in version 6 or newer.
> GCC 6 added the '-Wunused-const-variable' warning, which gets
> activated by '-Wunused-variable' and has the following behavior:
> "Warn whenever a constant static variable is unused aside from its
> declaration" [2]
> 
> Commit 2ad6ba80a1bd58382bde6b994070f7c01d2fb48d introduced a case
> where exactly this happens on a RELEASE build. All uses of the static
> const variable are located in debug code only, which gets thrown out
> by the compiler on RELEASE builds and thus triggers the
> unused-const-variable warning.
> 
> There is currently no GCC 6 toolchain target defined and doing so
> would add a lot of boilerplate code. Instead, use the fact that GCC
> ignores unknown '-Wno-*' options:
> 
> "[...] if the -Wno- form is used [...] no diagnostic is produced for
> -Wno-unknown-warning unless other diagnostics are being produced"
> 
> This behavior is available in GCC 4.9 [3] (and also earlier, for that
> matter), so add the flag to the GCC49 and GCC5 toolchain, even if
> both GCC versions do not supports it.
> GCC49 doesn't enables LTO whereas GCC5 does. As GCC 6.0 through 6.2
> had bugs relating to LTO there can be desire to use the GCC49 target
> even if compiling with GCC 6, see 432f1d83f77a.
> 
> Orient the changes on 20d00edf21d2 which moved the
> '-Wno-unused-but-set-variable' flag to RELEASE builds only, as there
> it ensure that it does not gets raised if the only usage of a
> variable is in (then collapsed) debug code.
> 
> [1] https://bugzilla.tianocore.org/show_bug.cgi?id=700
> [2] 
> https://gcc.gnu.org/onlinedocs/gcc-6.4.0/gcc/Warning-Options.html#index-Wunused-const-variable
> [3] https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Warning-Options.html
> 
> Cc: Yonghong Zhu 
> Cc: Liming Gao 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Thomas Lamprecht 
> ---
> 
> changes v1 -> v2:
>  * add the flag also to the GCC49 toolchain to allow using GCC 6 with
>LTO disabled builds, thanks for the hints Laszlo and Liming!
>  * adapt commit message slightly, especially to the fact that GCC49
>gets the flag now too.
>  * CC Ard
> 
>  BaseTools/Conf/tools_def.template | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template 
> b/BaseTools/Conf/tools_def.template
> index ba1d1a16de..cbb5024c1b 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -5179,7 +5179,7 @@ RELEASE_GCC48_AARCH64_CC_FLAGS   = 
> DEF(GCC48_AARCH64_CC_FLAGS) -Wno-unused-but-s
>  *_GCC49_IA32_NASM_FLAGS   = -f elf32
>  
>DEBUG_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os
> -RELEASE_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os 
> -Wno-unused-but-set-variable
> +RELEASE_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os 
> -Wno-unused-but-set-variable -Wno-unused-const-variable
>NOOPT_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -O0
>  
>  ##
> @@ -5207,7 +5207,7 @@ RELEASE_GCC49_IA32_CC_FLAGS   = 
> DEF(GCC49_IA32_CC_FLAGS) -Os -Wno-unused-but
>  *_GCC49_X64_NASM_FLAGS   = -f elf64
>  
>DEBUG_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os
> -RELEASE_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os 
> -Wno-unused-but-set-variable
> +RELEASE_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os 
> -Wno-unused-but-set-variable -Wno-unused-const-variable
>NOOPT_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -O0
>  
>  ##
> @@ -5240,7 +5240,7 @@ RELEASE_GCC49_X64_CC_FLAGS   = 
> DEF(GCC49_X64_CC_FLAGS) -Os -Wno-unused-but-s
>  *_GCC49_ARM_CC_XIPFLAGS  = DEF(GCC49_ARM_CC_XIPFLAGS)
>  
>DEBUG_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) -O0
> -RELEASE_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) 
> -Wno-unused-but-set-variable
> +RELEASE_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) 
> -Wno-unused-but-set-variable -Wno-unused-const-variable
>NOOPT_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) -O0
>  
>  ##
> @@ -5272,7 +5272,7 @@ RELEASE_GCC49_ARM_CC_FLAGS   = 
> DEF(GCC49_ARM_CC_FLAGS) -Wno-unused-but-set-v
>DEBUG_GCC49_AARCH64_DLINK_FLAGS  = DEF(GCC49_AARCH64_DLINK_FLAGS) -z 
> common-page-size=0x1000
>DEBUG_GCC49_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
>  
> -RELEASE_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) 
> -Wno-unused-but-set-variable -mcmodel=tiny -fomit-frame-pointer
> +RELEASE_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) 
> -Wno-unused-but-set-variable 

Re: [edk2] [PATCH v6 0/6] read-only UDF file system support

2017-09-08 Thread Laszlo Ersek
On 09/08/17 14:41, Paulo Alcantara wrote:
> Hi,
> 
> This series introduces read-only UDF file system support in EDK2. As
> Laszlo (or Red Hat) seemed to be interested in such support, I'm posting
> it again after ~3 years.
> 
> The idea is not replacing the default FAT file system, nor breaking any
> existing file system support, but extending EDK2 with a new file system
> that might be useful for some people who are looking for specific file
> system features that current FAT doesn't support.
> 
> Originally the driver was written to support UDF file systems as
> specified by OSTA Universal Disk Format Specification 2.60. However,
> some Windows 10 Enterprise ISO (UDF bridge) images that I tested
> supported a revision of 1.02 thus I had to rework the driver a little
> bit to support such revision as well.
> 
> v2:
>  - Rework to _partially_ support UDF revisions <2.60.
>  - Use existing CDROM_VOLUME_DESCRIPTOR structure defined in Eltorito.h
>instead of creating another one (UDF_VOLUME_DESCRIPTOR).
>  - Fixed UdfDxe to correctly follow UEFI driver model.
>  - Use HARDDRIVE_DEVICE_PATH instead of a vendor-defined one.
>  - Detect UDF file systems only in PartitionDxe, and let UdfDxe driver
>check for specific UDF device path to decide whether or not install
>SimpleFs protocol.
>  - Place MdePkg changes in a separate patch.
> v3:
>  - Install UDF partition child handles with a Vendor-Defined Media
>Device Path.
>  - Changed UdfDxe to check for Vendor-Defined Media Device Paths with a
>specific UDF file system GUID when determining to whether or not
>start the driver.
>  - Removed leading TAB chars in some source files identified by
>PatchCheck.py tool.
> v4:
>  - Added missing R-b's.
> v5:
>  - Fixed OVMF IA32 build.
>  - Fixed a typo in UdfDriveBindingStop() ("This" -> "SimpleFs") which
>broke retrieval of private fs data from SimpleFs protocol --
>identified by 'reconnect -r' command in UEFI shell.
> v6:
>  - Fixed a bug in UdfRead() that'd pontentially break in ARM or IA32
>by allowing caller to read more than 4GiB of data
>(i.e. BufferSize pointer is dereferenced as an UINT64 * and it's
> followed by 4 bytes that are nonzero).
> 
> Repo:   https://github.com/pcacjr/edk2.git
> Branch: udf-fs-v6
> 
> Cc: Laszlo Ersek 
> Cc: Jordan Justen 
> Cc: Andrew Fish 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Star Zeng 
> Cc: Eric Dong 
> Cc: Mark Doran 
> Cc: Ruiyu Ni 
> Cc: hao.a...@intel.com
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Paulo Alcantara 
> ---
> 
> Paulo Alcantara (6):
>   MdePkg: Add UDF volume structure definitions
>   MdeModulePkg/PartitionDxe: Add UDF file system support
>   MdeModulePkg: Initial UDF/ECMA-167 file system support
>   OvmfPkg: Enable UDF file system support
>   ArmVirtPkg: Enable UDF file system support
>   Nt32Pkg: Enable UDF file system support
> 
>  ArmVirtPkg/ArmVirtQemu.dsc |3 +-
>  ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc   |3 +-
>  ArmVirtPkg/ArmVirtQemuKernel.dsc   |3 +-
>  ArmVirtPkg/ArmVirtXen.dsc  |3 +-
>  ArmVirtPkg/ArmVirtXen.fdf  |1 +
>  .../Universal/Disk/PartitionDxe/Partition.c|9 +-
>  .../Universal/Disk/PartitionDxe/Partition.h|   32 +-
>  .../Universal/Disk/PartitionDxe/PartitionDxe.inf   |3 +-
>  MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c |  318 +++
>  MdeModulePkg/Universal/Disk/UdfDxe/ComponentName.c |  185 ++
>  MdeModulePkg/Universal/Disk/UdfDxe/File.c  |  908 
>  MdeModulePkg/Universal/Disk/UdfDxe/FileName.c  |  195 ++
>  .../Universal/Disk/UdfDxe/FileSystemOperations.c   | 2447 
> 
>  MdeModulePkg/Universal/Disk/UdfDxe/Udf.c   |  344 +++
>  MdeModulePkg/Universal/Disk/UdfDxe/Udf.h   | 1244 ++
>  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf  |   66 +
>  MdePkg/Include/IndustryStandard/Udf.h  |   60 +
>  Nt32Pkg/Nt32Pkg.dsc|1 +
>  Nt32Pkg/Nt32Pkg.fdf|1 +
>  OvmfPkg/OvmfPkgIa32.dsc|1 +
>  OvmfPkg/OvmfPkgIa32.fdf|1 +
>  OvmfPkg/OvmfPkgIa32X64.dsc |1 +
>  OvmfPkg/OvmfPkgIa32X64.fdf |1 +
>  OvmfPkg/OvmfPkgX64.dsc |1 +
>  OvmfPkg/OvmfPkgX64.fdf |1 +
>  25 files changed, 5821 insertions(+), 11 deletions(-)
>  create mode 100644 MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c
>  create mode 100644 MdeModulePkg/Universal/Disk/UdfDxe/ComponentName.c
>  create mode 100644 

[edk2] [PATCH edk2-platforms 13/14] Silicon/Socionext: add driver for SPI NOR flash

2017-09-08 Thread Ard Biesheuvel
This imports the driver sources provided by Socionext for the FIP006
SPI NOR flash device found on Synquacer SoCs. It has been slightly
tweaked to bring it up to date with the changes made on the EDK2 side
since it was forked.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/Fip006Dxe.dec|   31 +
 Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/Fip006Dxe.inf|   78 ++
 Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/Fip006Reg.h  |  242 
 Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/NorFlashBlockIoDxe.c |  136 ++
 Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/NorFlashDxe.c| 1313 

 Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/NorFlashDxe.h|  305 +
 Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/NorFlashFvbDxe.c |  845 
+
 7 files changed, 2950 insertions(+)

diff --git a/Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/Fip006Dxe.dec 
b/Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/Fip006Dxe.dec
new file mode 100644
index ..6c0ac807fd0b
--- /dev/null
+++ b/Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/Fip006Dxe.dec
@@ -0,0 +1,31 @@
+## @file
+#  Socionext FIP006 High-Speed SPI Controller with NOR Flash Driver
+#
+#  Copyright (c) 2017, Socionext 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.
+#
+##
+
+[Defines]
+  DEC_SPECIFICATION = 0x00010005
+  PACKAGE_NAME  = Fip006DxePkg
+  PACKAGE_GUID  = ABC7870B-FE82-4DAD-8179-FEC5F5194FA0
+  PACKAGE_VERSION   = 0.1
+
+[Guids]
+  gFip006DxeTokenSpaceGuid  = {0x4D45399E, 0x98F9, 0x4127, {0x8F, 
0xB9,0xF8, 0xDE, 0x22, 0xA1, 0x09, 0x2C}}
+
+[PcdsFixedAtBuild]
+  gFip006DxeTokenSpaceGuid.PcdFip006DxeRegBaseAddress|0x0|UINT32|0x0001
+  gFip006DxeTokenSpaceGuid.PcdFip006DxeMemBaseAddress|0x0|UINT32|0x0002
+  gFip006DxeTokenSpaceGuid.PcdN25qSlaveId|0x0|UINT8|0x0003
+  gFip006DxeTokenSpaceGuid.PcdN25qBlockSize|256|UINT32|0x0004
+  gFip006DxeTokenSpaceGuid.PcdN25qBlockCount|524288|UINT32|0x0005
+
diff --git a/Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/Fip006Dxe.inf 
b/Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/Fip006Dxe.inf
new file mode 100644
index ..5727d4d937c9
--- /dev/null
+++ b/Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/Fip006Dxe.inf
@@ -0,0 +1,78 @@
+## @file
+#  Socionext FIP006 High-Speed SPI Controller with NOR Flash Driver
+#
+#  Copyright (c) 2017, Socionext 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.
+#
+##
+
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = Fip006Dxe
+  FILE_GUID  = 44F7D21F-C36F-4766-BC5B-C72E97E6897B
+  MODULE_TYPE= DXE_RUNTIME_DRIVER
+  VERSION_STRING = 0.1
+  ENTRY_POINT= NorFlashInitialise
+
+[Sources]
+  NorFlashDxe.c
+  NorFlashBlockIoDxe.c
+  NorFlashFvbDxe.c
+
+[Packages]
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/Fip006Dxe.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  DevicePathLib
+  DxeServicesTableLib
+  HobLib
+  IoLib
+  MemoryAllocationLib
+  NorFlashPlatformLib
+  UefiLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+  UefiRuntimeLib
+  UefiRuntimeServicesTableLib
+
+[Guids]
+  gEfiAuthenticatedVariableGuid
+  gEfiEventVirtualAddressChangeGuid
+  gEfiSystemNvDataFvGuid
+  gEfiVariableGuid
+
+[Protocols]
+  gEfiBlockIoProtocolGuid
+  gEfiDevicePathProtocolGuid
+  gEfiDiskIoProtocolGuid
+  gEfiFirmwareVolumeBlockProtocolGuid
+
+[FixedPcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
+  

[edk2] [PATCH edk2-platforms 10/14] Silicon/Synquacer: add ACPI support

2017-09-08 Thread Ard Biesheuvel
Enable ACPI support for the SynquacerEvalBoard platform: add descriptions
of the CPUs, the GIC, the serial port, the timers and the PCIe RCs,
including the MSI routing via the GICv3 ITS.

Note that PCIe support is limited to a single bus per RC. Anything beyond
that is unsupported due to a limitation in the hardware that makes it
impossible to expose the PCIe RCs in a fully ECAM compliant manner.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc |  14 +
 Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf |  13 +
 Silicon/Socionext/Synquacer/AcpiTables/AcpiSsdtRootPci.asl   | 292 

 Silicon/Socionext/Synquacer/AcpiTables/AcpiTables.h  |  58 
 Silicon/Socionext/Synquacer/AcpiTables/AcpiTables.inf|  58 
 Silicon/Socionext/Synquacer/AcpiTables/Dsdt.asl  | 168 +++
 Silicon/Socionext/Synquacer/AcpiTables/Fadt.aslc |  88 ++
 Silicon/Socionext/Synquacer/AcpiTables/Gtdt.aslc |  98 +++
 Silicon/Socionext/Synquacer/AcpiTables/Iort.aslc | 164 +++
 Silicon/Socionext/Synquacer/AcpiTables/Madt.aslc | 152 ++
 Silicon/Socionext/Synquacer/AcpiTables/Mcfg.aslc |  63 +
 Silicon/Socionext/Synquacer/AcpiTables/Spcr.aslc | 127 +
 12 files changed, 1295 insertions(+)

diff --git a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc 
b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
index 3d4fbc87e2fa..b2befd2480c4 100644
--- a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
+++ b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
@@ -475,3 +475,17 @@
 
   DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
   }
+
+  #
+  # ACPI support
+  #
+  MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf {
+
+  #NULL|EmbeddedPkg/Library/PlatformHasAcpiLib/PlatformHasAcpiLib.inf
+
+
+  # support ACPI v5.0 or later
+  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions|0x20
+  }
+  MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+  Silicon/Socionext/Synquacer/AcpiTables/AcpiTables.inf
diff --git a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf 
b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
index bd06adf93b3c..35742ad5a347 100644
--- a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
+++ b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
@@ -183,6 +183,13 @@ READ_LOCK_STATUS   = TRUE
   INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
   INF Silicon/Socionext/Synquacer/Drivers/Net/NetsecDxe/NetsecDxe.inf
 
+  #
+  # ACPI support
+  #
+  INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+  INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+  INF RuleOverride = ACPITABLE 
Silicon/Socionext/Synquacer/AcpiTables/AcpiTables.inf
+
 [FV.FVMAIN_COMPACT]
 FvAlignment= 8
 ERASE_POLARITY = 1
@@ -329,3 +336,9 @@ READ_LOCK_STATUS   = TRUE
 UISTRING="$(MODULE_NAME)" Optional
 VERSION   STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
   }
+
+[Rule.Common.USER_DEFINED.ACPITABLE]
+  FILE FREEFORM = $(NAMED_GUID) {
+RAW ACPI   |.acpi
+RAW ASL|.aml
+  }
diff --git a/Silicon/Socionext/Synquacer/AcpiTables/AcpiSsdtRootPci.asl 
b/Silicon/Socionext/Synquacer/AcpiTables/AcpiSsdtRootPci.asl
new file mode 100644
index ..f8d503d65ead
--- /dev/null
+++ b/Silicon/Socionext/Synquacer/AcpiTables/AcpiSsdtRootPci.asl
@@ -0,0 +1,292 @@
+/** @file
+  Secondary System Description Table (SSDT) for Synquacer PCIe RCs
+
+  Copyright (c) 2014-2016, ARM Ltd. All rights reserved.
+  Copyright (c) 2017, Linaro Ltd. 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 
+
+#include "AcpiTables.h"
+
+DefinitionBlock("SsdtPci.aml", "SSDT", 1, "LINARO", "SYNQUACR", 
EFI_ACPI_OEM_REVISION) {
+  Scope(_SB) {
+//
+// PCI Root Complex
+//
+Device(PCI0)
+{
+Name(_HID, EISAID("PNP0A08"))   // PCI Express Root Bridge
+Name(_CID, EISAID("PNP0A03"))   // Compatible PCI Root Bridge
+Name(_SEG, Zero)// PCI Segment Group number
+Name(_BBN, Zero)// PCI Base Bus Number
+Name(_CCA, 1)   // Cache Coherency Attribute
+
+// PCI Routing Table
+Name(_PRT, Package() {
+

[edk2] [PATCH edk2-platforms 01/14] Silicon/Synquacer: add package with platform headers

2017-09-08 Thread Ard Biesheuvel
Add a package .DEC description for Synquacer with an [Includes]
section, and add header files containing descriptions of the
platform's memory map and PCIe configuration. No code yet.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Silicon/Socionext/Synquacer/Include/Platform/MemoryMap.h | 65 

 Silicon/Socionext/Synquacer/Include/Platform/Pcie.h  | 63 
+++
 Silicon/Socionext/Synquacer/Synquacer.dec| 22 +++
 3 files changed, 150 insertions(+)

diff --git a/Silicon/Socionext/Synquacer/Include/Platform/MemoryMap.h 
b/Silicon/Socionext/Synquacer/Include/Platform/MemoryMap.h
new file mode 100644
index ..1b5393c32f1d
--- /dev/null
+++ b/Silicon/Socionext/Synquacer/Include/Platform/MemoryMap.h
@@ -0,0 +1,65 @@
+/** @file
+  PCI memory configuration for Synquacer
+
+  Copyright (c) 2017, Linaro Ltd. 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 _SYNQUACER_PLATFORM_MEMORYMAP_H_
+#define _SYNQUACER_PLATFORM_MEMORYMAP_H_
+
+// Memory mapped SPI NOR
+#define SYNQUACER_SPI_NOR_BASE  0x0800
+#define SYNQUACER_SPI_NOR_SIZE  SIZE_128MB
+
+// On-Chip non-secure ROM
+#define SYNQUACER_NON_SECURE_ROM_BASE   0x1F00
+#define SYNQUACER_NON_SECURE_ROM_SZ SIZE_512KB
+
+// On-Chip Peripherals
+#define SYNQUACER_PERIPHERALS_BASE  0x2000
+#define SYNQUACER_PERIPHERALS_SZ0x0E00
+
+// On-Chip non-secure SRAM
+#define SYNQUACER_NON_SECURE_SRAM_BASE  0x2E00
+#define SYNQUACER_NON_SECURE_SRAM_SZSIZE_32KB
+
+// GIC-500
+#define SYNQUACER_GIC500_DIST_BASE  FixedPcdGet64 (PcdGicDistributorBase)
+#define SYNQUACER_GIC500_DIST_SIZE  SIZE_256KB
+#define SYNQUACER_GIC500_RDIST_BASE FixedPcdGet64 
(PcdGicRedistributorsBase)
+#define SYNQUACER_GIC500_RDIST_SIZE SIZE_8MB
+
+// eMMC(SDH30)
+#define SYNQUACER_EMMC_BASE 0x5230
+#define SYNQUACER_EMMC_BASE_SZ  SIZE_4KB
+
+#define SYNQUACER_EEPROM_BASE   0x1000
+#define SYNQUACER_EEPROM_BASE_SZSIZE_64KB
+
+// NETSEC
+#define SYNQUACER_NETSEC_BASE   0x522D
+#define SYNQUACER_NETSEC_BASE_SZSIZE_64KB
+
+#define SYNQUACER_SYSTEM_MEMORY_1_BASE  0x8000
+#define SYNQUACER_SYSTEM_MEMORY_1_SZ(SIZE_2GB - SIZE_16MB)
+
+#define SYNQUACER_SYSTEM_MEMORY_2_BASE  0x088000ULL
+#define SYNQUACER_SYSTEM_MEMORY_2_SZ(SIZE_32GB - SIZE_2GB)
+
+#define SYNQUACER_SYSTEM_MEMORY_3_BASE  0x88ULL
+#define SYNQUACER_SYSTEM_MEMORY_3_SZSIZE_32GB
+
+// PCI
+#define SYNQUACER_PCIE_BASE 0x5820
+#define SYNQUACER_PCIE_SIZE 0x0020
+
+#endif
diff --git a/Silicon/Socionext/Synquacer/Include/Platform/Pcie.h 
b/Silicon/Socionext/Synquacer/Include/Platform/Pcie.h
new file mode 100644
index ..f7bdc13ad915
--- /dev/null
+++ b/Silicon/Socionext/Synquacer/Include/Platform/Pcie.h
@@ -0,0 +1,63 @@
+/** @file
+  PCI memory configuration for Synquacer
+
+  Copyright (c) 2017, Linaro Ltd. 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 _SYNQUACER_PLATFORM_PCI_H_
+#define _SYNQUACER_PLATFORM_PCI_H_
+
+#define SYNQUACER_PCI_SEG0_CONFIG_BASE  0x6000
+#define SYNQUACER_PCI_SEG0_CONFIG_SIZE  0x07f0
+#define SYNQUACER_PCI_SEG0_DBI_BASE 0x583d
+#define SYNQUACER_PCI_SEG0_EXS_BASE 0x5839
+
+#define SYNQUACER_PCI_SEG0_BUSNUM_MIN   0x0
+#define SYNQUACER_PCI_SEG0_BUSNUM_MAX   0x7e
+
+#define SYNQUACER_PCI_SEG0_PORTIO_MIN   0x0
+#define SYNQUACER_PCI_SEG0_PORTIO_MAX   0x
+#define SYNQUACER_PCI_SEG0_PORTIO_SIZE  0x1
+#define SYNQUACER_PCI_SEG0_PORTIO_MEMBASE   0x67f0
+#define SYNQUACER_PCI_SEG0_PORTIO_MEMSIZE   SYNQUACER_PCI_SEG0_PORTIO_SIZE
+
+#define SYNQUACER_PCI_SEG0_MMIO32_MIN   0x6800
+#define SYNQUACER_PCI_SEG0_MMIO32_MAX   0x6fff
+#define SYNQUACER_PCI_SEG0_MMIO32_SIZE  0x0800
+
+#define SYNQUACER_PCI_SEG0_MMIO64_MIN   0x3e
+#define SYNQUACER_PCI_SEG0_MMIO64_MAX   0x3e
+#define SYNQUACER_PCI_SEG0_MMIO64_SIZE  0x1
+
+#define SYNQUACER_PCI_SEG1_CONFIG_BASE 

Re: [edk2] [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at ExitBootServices

2017-09-08 Thread Laszlo Ersek
On 09/08/17 00:41, Laszlo Ersek wrote:
> Repo:   https://github.com/lersek/edk2.git
> Branch: iommu_exit_boot
> 
> This series is the result of the discussion under
> 
>   [edk2] [PATCH 0/4] MdeModulePkg: some PCI HC drivers: unmap common
>  buffers at ExitBootServices()
>   https://lists.01.org/pipermail/edk2-devel/2017-September/014099.html
> 
> At ExitBootServices(), PCI and VirtIo drivers should only care about
> aborting pending DMA on the devices. Cleaning up PciIo mappings (which
> ultimately boil down to IOMMU mappings) for those aborted DMA operations
> should be the job of the IOMMU driver.
> 
> Patches 01 through 03 clean up the AtaAtapiPassThru driver in
> MdeModulePkg a little bit, because at present, (a) it unmaps the buffers
> and disables BMDMA in the wrong order in its DriverBindingStop()
> function, (b) it doesn't abort pending DMA at ExitBootServices().
> 
> This subset can be treated separately from the rest of the series, but I
> thought they belonged loosely together (given that AtaAtapiPassThru is
> used on QEMU's Q35 machine type).
> 
> Patches 04 through 07 remove VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer()
> calls from the VirtIo drivers' ExitBootServices() handlers.
> 
> (The conversion of VirtioNetDxe to device addresses is still in progress
> -- Brijesh, when you submit v2 of that, under this approach, there is no
> need to change VirtioNetExitBoot() relative to current upstream, and you
> can use VirtioOperationBusMasterRead to map outgoing packets.)
> 
> Patches 08 through 10 make OvmfPkg/IoMmuDxe track all mappings, and
> unmap all mappings (Read, Write, CommonBuffer) that are in effect when
> ExitBootServices() is called. It is ensured that PCI and VirtIo drivers
> abort pending DMA first, and IoMmuDxe clean up the mappings last.
> 
> Cc: Ard Biesheuvel 
> Cc: Brijesh Singh 
> Cc: Eric Dong 
> Cc: Jiewen Yao 
> Cc: Jordan Justen 
> Cc: Star Zeng 
> 
> Thanks
> Laszlo
> 
> Laszlo Ersek (10):
>   MdeModulePkg/AtaAtapiPassThru: cache EnabledPciAttributes
>   MdeModulePkg/AtaAtapiPassThru: unmap DMA buffers after disabling BM
> DMA
>   MdeModulePkg/AtaAtapiPassThru: disable the device at
> ExitBootServices()
>   OvmfPkg/VirtioBlkDxe: don't unmap VRING at ExitBootServices()
>   OvmfPkg/VirtioGpuDxe: don't unmap VRING & BackingStore at
> ExitBootServices
>   OvmfPkg/VirtioRngDxe: don't unmap VRING at ExitBootServices()
>   OvmfPkg/VirtioScsiDxe: don't unmap VRING at ExitBootServices()
>   OvmfPkg/IoMmuDxe: track all mappings
>   OvmfPkg/IoMmuDxe: generalize IoMmuUnmap() to IoMmuUnmapWorker()
>   OvmfPkg/IoMmuDxe: unmap all IOMMU mappings at ExitBootServices()
> 
>  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 103 +---
>  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h |   7 +
>  OvmfPkg/IoMmuDxe/AmdSevIoMmu.c   | 246 
> +---
>  OvmfPkg/VirtioBlkDxe/VirtioBlk.c |   7 +-
>  OvmfPkg/VirtioGpuDxe/Commands.c  |  23 +-
>  OvmfPkg/VirtioRngDxe/VirtioRng.c |   7 +-
>  OvmfPkg/VirtioScsiDxe/VirtioScsi.c   |   7 +-
>  7 files changed, 299 insertions(+), 101 deletions(-)
> 

Supreme kudos to everyone for the feedback!; series pushed as commit
range 3281ebb4ae7d..7aee391fa3d0.

Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms 05/14] Silicon/Synquacer: implement PciHostBridgeLib support

2017-09-08 Thread Ard Biesheuvel
Implement the glue library that exposes the PCIe root complexes to
the generic PCI host bridge driver. Since that driver is the first
one to access the PCI config space, put the low level init code for
the RCs into this library's constructor.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 
Silicon/Socionext/Synquacer/Library/SynquacerPciHostBridgeLib/SynquacerPciHostBridgeLib.c
| 223 
 
Silicon/Socionext/Synquacer/Library/SynquacerPciHostBridgeLib/SynquacerPciHostBridgeLib.inf
  |  50 +++
 
Silicon/Socionext/Synquacer/Library/SynquacerPciHostBridgeLib/SynquacerPciHostBridgeLibConstructor.c
 | 383 
 3 files changed, 656 insertions(+)

diff --git 
a/Silicon/Socionext/Synquacer/Library/SynquacerPciHostBridgeLib/SynquacerPciHostBridgeLib.c
 
b/Silicon/Socionext/Synquacer/Library/SynquacerPciHostBridgeLib/SynquacerPciHostBridgeLib.c
new file mode 100644
index ..10ddaac3b924
--- /dev/null
+++ 
b/Silicon/Socionext/Synquacer/Library/SynquacerPciHostBridgeLib/SynquacerPciHostBridgeLib.c
@@ -0,0 +1,223 @@
+/** @file
+  PCI Host Bridge Library instance for Socionext Synquacer ARM SOC
+
+  Copyright (c) 2017, Linaro Ltd. 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#pragma pack(1)
+typedef struct {
+  ACPI_HID_DEVICE_PATH AcpiDevicePath;
+  EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
+} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH;
+#pragma pack ()
+
+STATIC CONST EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath[] = {
+  {
+{
+  {
+ACPI_DEVICE_PATH,
+ACPI_DP,
+{
+  (UINT8) (sizeof(ACPI_HID_DEVICE_PATH)),
+  (UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8)
+}
+  },
+  EISA_PNP_ID(0x0A08), // PCI Express
+  0
+},
+
+{
+  END_DEVICE_PATH_TYPE,
+  END_ENTIRE_DEVICE_PATH_SUBTYPE,
+  {
+END_DEVICE_PATH_LENGTH,
+0
+  }
+}
+  },
+  {
+{
+  {
+ACPI_DEVICE_PATH,
+ACPI_DP,
+{
+  (UINT8) (sizeof(ACPI_HID_DEVICE_PATH)),
+  (UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8)
+}
+  },
+  EISA_PNP_ID(0x0A08), // PCI Express
+  1
+},
+
+{
+  END_DEVICE_PATH_TYPE,
+  END_ENTIRE_DEVICE_PATH_SUBTYPE,
+  {
+END_DEVICE_PATH_LENGTH,
+0
+  }
+}
+  }
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED
+CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = {
+  L"Mem", L"I/O", L"Bus"
+};
+
+STATIC PCI_ROOT_BRIDGE mPciRootBridges[] = {
+  {
+0,  // Segment
+0,  // Supports
+0,  // Attributes
+TRUE,   // DmaAbove4G
+FALSE,  // NoExtendedConfigSpace
+FALSE,  // ResourceAssigned
+EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM |
+EFI_PCI_HOST_BRIDGE_MEM64_DECODE,   // AllocationAttributes
+{ SYNQUACER_PCI_SEG0_BUSNUM_MIN,
+  SYNQUACER_PCI_SEG0_BUSNUM_MAX },  // Bus
+{ SYNQUACER_PCI_SEG0_PORTIO_MIN,
+  SYNQUACER_PCI_SEG0_PORTIO_MAX },  // Io
+{ SYNQUACER_PCI_SEG0_MMIO32_MIN,
+  SYNQUACER_PCI_SEG0_MMIO32_MAX },  // Mem
+{ SYNQUACER_PCI_SEG0_MMIO64_MIN,
+  SYNQUACER_PCI_SEG0_MMIO64_MAX },  // MemAbove4G
+{ MAX_UINT64, 0x0 },// PMem
+{ MAX_UINT64, 0x0 },// PMemAbove4G
+(EFI_DEVICE_PATH_PROTOCOL *)[0]
+  }, {
+1,  // Segment
+0,  // Supports
+0,  // Attributes
+TRUE,   // DmaAbove4G
+FALSE,  // NoExtendedConfigSpace
+FALSE,  // ResourceAssigned
+EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM |
+EFI_PCI_HOST_BRIDGE_MEM64_DECODE,   // AllocationAttributes
+{ SYNQUACER_PCI_SEG1_BUSNUM_MIN,
+  SYNQUACER_PCI_SEG1_BUSNUM_MAX },  // Bus
+{ SYNQUACER_PCI_SEG1_PORTIO_MIN,
+  SYNQUACER_PCI_SEG1_PORTIO_MAX },  // Io
+{ SYNQUACER_PCI_SEG1_MMIO32_MIN,
+  SYNQUACER_PCI_SEG1_MMIO32_MAX },  // Mem
+{ SYNQUACER_PCI_SEG1_MMIO64_MIN,
+  SYNQUACER_PCI_SEG1_MMIO64_MAX },  // MemAbove4G
+{ MAX_UINT64, 0x0 },// 

[edk2] [PATCH edk2-platforms 09/14] Platform/SynquacerEvalBoard: add NETSEC driver

2017-09-08 Thread Ard Biesheuvel
Add the NETSEC driver to the SynquacerEvalBoard platform.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc | 34 

 Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf | 17 ++
 2 files changed, 51 insertions(+)

diff --git a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc 
b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
index aea39b46d91b..3d4fbc87e2fa 100644
--- a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
+++ b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
@@ -217,6 +217,20 @@
   gArmTokenSpaceGuid.PcdGenericWatchdogControlBase|0x2a44
   gArmTokenSpaceGuid.PcdGenericWatchdogRefreshBase|0x2a45
 
+  #
+  # NETSEC Info
+  #
+  gNetsecDxeTokenSpaceGuid.PcdNetsecDxeBaseAddress|0x522D
+  gNetsecDxeTokenSpaceGuid.PcdEepRomBase|0x1000
+  gNetsecDxeTokenSpaceGuid.PcdEncTxDescNum|128
+  gNetsecDxeTokenSpaceGuid.PcdDecRxDescNum|128
+  gNetsecDxeTokenSpaceGuid.PcdJumboPacket|0
+  gNetsecDxeTokenSpaceGuid.PcdFlowCtrl|0
+  gNetsecDxeTokenSpaceGuid.PcdFlowCtrlStartThreshold|36
+  gNetsecDxeTokenSpaceGuid.PcdFlowCtrlStopThreshold|48
+  gNetsecDxeTokenSpaceGuid.PcdPauseTime|256
+  gNetsecDxeTokenSpaceGuid.PcdPhyDevAddr|1
+
   gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|100
   gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|100
   gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|100
@@ -441,3 +455,23 @@
   # RNG
   #
   Silicon/Openmoko/ChaosKeyDxe/ChaosKeyDxe.inf
+
+  #
+  # Networking stack
+  #
+  MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
+  MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
+  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
+  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
+  MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf
+  MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
+  MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
+  MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
+  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf
+  MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
+  MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
+  MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
+  Silicon/Socionext/Synquacer/Drivers/Net/NetsecDxe/NetsecDxe.inf {
+
+  DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
+  }
diff --git a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf 
b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
index befad354918e..bd06adf93b3c 100644
--- a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
+++ b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
@@ -166,6 +166,23 @@ READ_LOCK_STATUS   = TRUE
   #
   INF Silicon/Openmoko/ChaosKeyDxe/ChaosKeyDxe.inf
 
+  #
+  # Networking stack
+  #
+  INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
+  INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
+  INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
+  INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
+  INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
+  INF MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf
+  INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
+  INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
+  INF MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf
+  INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
+  INF MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
+  INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
+  INF Silicon/Socionext/Synquacer/Drivers/Net/NetsecDxe/NetsecDxe.inf
+
 [FV.FVMAIN_COMPACT]
 FvAlignment= 8
 ERASE_POLARITY = 1
-- 
2.11.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms 11/14] Silicon/Synquacer: add device tree support for eval board

2017-09-08 Thread Ard Biesheuvel
Add a device tree description of the Synquacer SoC, and expose it for
the SynquacerEvalBoard platforms. This includes the menu option in the
UEFI boot menu to switch between ACPI and DT.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc  |   9 +
 Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf  |  12 +
 Silicon/Socionext/Synquacer/DeviceTree/Synquacer.dtsi | 517 

 Silicon/Socionext/Synquacer/DeviceTree/SynquacerEvalBoard.dts |  21 +
 Silicon/Socionext/Synquacer/DeviceTree/SynquacerEvalBoard.inf |  28 ++
 5 files changed, 587 insertions(+)

diff --git a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc 
b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
index b2befd2480c4..92c1d3eb8283 100644
--- a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
+++ b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
@@ -489,3 +489,12 @@
   }
   MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
   Silicon/Socionext/Synquacer/AcpiTables/AcpiTables.inf
+
+  #
+  # DT support
+  #
+  Silicon/Socionext/Synquacer/DeviceTree/SynquacerEvalBoard.inf
+  EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf {
+
+  
DtPlatformDtbLoaderLib|EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.inf
+  }
diff --git a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf 
b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
index 35742ad5a347..de97d3e56ded 100644
--- a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
+++ b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
@@ -1,3 +1,4 @@
+
 #
 #  Copyright (c) 2013-2014, ARM Limited. All rights reserved.
 #  Copyright (c) 2017, Linaro Limited. All rights reserved.
@@ -190,6 +191,12 @@ READ_LOCK_STATUS   = TRUE
   INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
   INF RuleOverride = ACPITABLE 
Silicon/Socionext/Synquacer/AcpiTables/AcpiTables.inf
 
+  #
+  # DT support
+  #
+  INF EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf
+  INF RuleOverride = DTB 
Silicon/Socionext/Synquacer/DeviceTree/SynquacerEvalBoard.inf
+
 [FV.FVMAIN_COMPACT]
 FvAlignment= 8
 ERASE_POLARITY = 1
@@ -342,3 +349,8 @@ READ_LOCK_STATUS   = TRUE
 RAW ACPI   |.acpi
 RAW ASL|.aml
   }
+
+[Rule.Common.USER_DEFINED.DTB]
+  FILE FREEFORM = $(NAMED_GUID) {
+RAW BIN|.dtb
+  }
diff --git a/Silicon/Socionext/Synquacer/DeviceTree/Synquacer.dtsi 
b/Silicon/Socionext/Synquacer/DeviceTree/Synquacer.dtsi
new file mode 100644
index ..8142bcc6adc8
--- /dev/null
+++ b/Silicon/Socionext/Synquacer/DeviceTree/Synquacer.dtsi
@@ -0,0 +1,517 @@
+/** @file
+ * Copyright (c) 2017, Linaro Limited. 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.
+ */
+
+#define GIC_SPI 0
+#define GIC_PPI 1
+
+#define IRQ_TYPE_NONE   0
+#define IRQ_TYPE_EDGE_RISING1
+#define IRQ_TYPE_EDGE_FALLING   2
+#define IRQ_TYPE_EDGE_BOTH  (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
+#define IRQ_TYPE_LEVEL_HIGH 4
+#define IRQ_TYPE_LEVEL_LOW  8
+
+/ {
+#address-cells = <2>;
+#size-cells = <2>;
+interrupt-parent = <>;
+dma-ranges = <0x0 0x0 0x0 0x0 0x100 0x0>;
+
+aliases {
+serial0 = _uart0;
+};
+
+chosen {
+stdout-path = "serial0:115200n8";
+};
+
+cpus {
+#address-cells = <1>;
+#size-cells = <0>;
+
+CPU0: cpu@0 {
+device_type = "cpu";
+compatible = "arm,cortex-a53","arm,armv8";
+reg = <0x0>;
+enable-method = "psci";
+cpu-idle-states = <_SLEEP_0 _SLEEP_0>;
+};
+CPU1: cpu@1 {
+device_type = "cpu";
+compatible = "arm,cortex-a53","arm,armv8";
+reg = <0x1>;
+enable-method = "psci";
+cpu-idle-states = <_SLEEP_0 _SLEEP_0>;
+};
+CPU2: cpu@100 {
+device_type = "cpu";
+compatible = "arm,cortex-a53","arm,armv8";
+reg = <0x100>;
+enable-method = "psci";
+cpu-idle-states = <_SLEEP_0 _SLEEP_0>;
+};
+CPU3: cpu@101 {
+device_type = "cpu";
+compatible = "arm,cortex-a53","arm,armv8";
+reg = <0x101>;
+enable-method = "psci";
+cpu-idle-states = <_SLEEP_0 _SLEEP_0>;

[edk2] [PATCH edk2-platforms 14/14] Platform/Synquacer: incorporate NOR flash and variable drivers

2017-09-08 Thread Ard Biesheuvel
Wire up the non-volatile EFI variable store support, by switching from
the emulation driver to the real one, and enabling the prerequisite
FTW and NOR flash drivers.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc   
 | 32 ++--
 Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf   
 |  9 --
 
Silicon/Socionext/Synquacer/Library/SynquacerMemoryInitPeiLib/SynquacerMemoryInitPeiLib.c
   | 10 ++
 
Silicon/Socionext/Synquacer/Library/SynquacerMemoryInitPeiLib/SynquacerMemoryInitPeiLib.inf
 |  2 ++
 4 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc 
b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
index 92c1d3eb8283..11b2e63453cd 100644
--- a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
+++ b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
@@ -319,6 +319,19 @@
   #
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE
 
+  #
+  # Variable store
+  #
+  gFip006DxeTokenSpaceGuid.PcdFip006DxeRegBaseAddress|0x5480
+  gFip006DxeTokenSpaceGuid.PcdFip006DxeMemBaseAddress|0x0800
+
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x0840
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x0001
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0x0841
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x0001
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x0842
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x0001
+
 [PcdsDynamicHii]
   
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|5
 
@@ -360,7 +373,6 @@
   MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
   ArmPkg/Drivers/TimerDxe/TimerDxe.inf
-  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
   ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
 
@@ -378,6 +390,22 @@
   }
 
   #
+  # Variable services
+  #
+  Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/Fip006Dxe.inf {
+
+  
NorFlashPlatformLib|Silicon/Socionext/Synquacer/Library/NorFlashSynquacerLib/NorFlashSynquacerLib.inf
+  }
+  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
+  }
+
+  #
   # UEFI application (Shell Embedded Boot Loader)
   #
   ShellPkg/Application/Shell/Shell.inf {
@@ -481,7 +509,7 @@
   #
   MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf {
 
-  #NULL|EmbeddedPkg/Library/PlatformHasAcpiLib/PlatformHasAcpiLib.inf
+  NULL|EmbeddedPkg/Library/PlatformHasAcpiLib/PlatformHasAcpiLib.inf
 
 
   # support ACPI v5.0 or later
diff --git a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf 
b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
index de97d3e56ded..86685a22208b 100644
--- a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
+++ b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
@@ -1,4 +1,3 @@
-
 #
 #  Copyright (c) 2013-2014, ARM Limited. All rights reserved.
 #  Copyright (c) 2017, Linaro Limited. All rights reserved.
@@ -102,7 +101,6 @@ READ_LOCK_STATUS   = TRUE
   INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
   INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
   INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf
-  INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
   INF ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf
   INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
 
@@ -116,6 +114,13 @@ READ_LOCK_STATUS   = TRUE
   INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
 
   #
+  # Variable services
+  #
+  INF Silicon/Socionext/Synquacer/Drivers/Fip006Dxe/Fip006Dxe.inf
+  INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
+  INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+
+  #
   # UEFI applications
   #
   INF ShellPkg/Application/Shell/Shell.inf
diff --git 
a/Silicon/Socionext/Synquacer/Library/SynquacerMemoryInitPeiLib/SynquacerMemoryInitPeiLib.c
 
b/Silicon/Socionext/Synquacer/Library/SynquacerMemoryInitPeiLib/SynquacerMemoryInitPeiLib.c
index 1d25d63f1b6c..1af30a2bbe60 100644
--- 

[edk2] [PATCH edk2-platforms 12/14] Silicon/Synquacer: add NorFlashPlatformLib implementation

2017-09-08 Thread Ard Biesheuvel
Add the platform glue for the NOR flash driver.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Silicon/Socionext/Synquacer/Library/NorFlashSynquacerLib/NorFlashSynquacer.c   
   | 60 
 
Silicon/Socionext/Synquacer/Library/NorFlashSynquacerLib/NorFlashSynquacerLib.inf
 | 38 +
 2 files changed, 98 insertions(+)

diff --git 
a/Silicon/Socionext/Synquacer/Library/NorFlashSynquacerLib/NorFlashSynquacer.c 
b/Silicon/Socionext/Synquacer/Library/NorFlashSynquacerLib/NorFlashSynquacer.c
new file mode 100644
index ..0d9a81b61b73
--- /dev/null
+++ 
b/Silicon/Socionext/Synquacer/Library/NorFlashSynquacerLib/NorFlashSynquacer.c
@@ -0,0 +1,60 @@
+/** @file
+
+ Copyright (c) 2011-2014, ARM Ltd. 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 
+#include 
+#include 
+#include 
+
+#include 
+
+STATIC NOR_FLASH_DESCRIPTION mNorFlashDevices[] = {
+  {
+// Environment variable region
+SYNQUACER_SPI_NOR_BASE, // device base
+FixedPcdGet32 (PcdFlashNvStorageVariableBase),  // region base
+FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
+FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
+FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize),  // region size
+SIZE_64KB,  // block size
+{
+  0x3105BD7A, 0x82C3, 0x486F, { 0xB1, 0x03, 0x1E, 0x09, 0x54, 0xEC, 0x85, 
0x75 }
+}
+  },
+};
+
+EFI_STATUS
+NorFlashPlatformInitialization (
+  VOID
+  )
+{
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+NorFlashPlatformGetDevices (
+  OUT NOR_FLASH_DESCRIPTION   **NorFlashDevices,
+  OUT UINT32  *Count
+  )
+{
+  if (NorFlashDevices == NULL ||
+  Count == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  *Count = ARRAY_SIZE (mNorFlashDevices);
+  *NorFlashDevices = mNorFlashDevices;
+
+  return EFI_SUCCESS;
+}
diff --git 
a/Silicon/Socionext/Synquacer/Library/NorFlashSynquacerLib/NorFlashSynquacerLib.inf
 
b/Silicon/Socionext/Synquacer/Library/NorFlashSynquacerLib/NorFlashSynquacerLib.inf
new file mode 100644
index ..bd84be0aebf8
--- /dev/null
+++ 
b/Silicon/Socionext/Synquacer/Library/NorFlashSynquacerLib/NorFlashSynquacerLib.inf
@@ -0,0 +1,38 @@
+#/** @file
+#
+#  Copyright (c) 2011 - 2014, ARM Ltd. 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.
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = NorFlashSynquacerLib
+  FILE_GUID  = 8279227C-C555-4D75-B439-D8A959635CDD
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = NorFlashPlatformLib
+
+[Sources]
+  NorFlashSynquacer.c
+
+[Packages]
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+  Silicon/Socionext/Synquacer/Synquacer.dec
+
+[LibraryClasses]
+  BaseLib
+
+[FixedPcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
-- 
2.11.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms 07/14] Platform/SynquacerEvalBoard: add PCI support

2017-09-08 Thread Ard Biesheuvel
Wire up the various drivers and libraries for the SynquacerEvalBoard
platform. Also enable the usual PCI suspects: XHCI, SATA and NVME,
and the various bus, partition and file system drivers that we need
to make use of PCIe devices.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc | 49 

 Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf | 38 
+++
 2 files changed, 87 insertions(+)

diff --git a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc 
b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
index 2a9a0037dcda..aea39b46d91b 100644
--- a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
+++ b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
@@ -100,6 +100,7 @@
   DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
   SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
   UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
+  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
 
   # BDS Libraries
   
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
@@ -148,6 +149,12 @@
   
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
   PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
 
+  #
+  # PCI
+  #
+  
PciSegmentLib|Silicon/Socionext/Synquacer/Library/SynquacerPciSegmentLib/SynquacerPciSegmentLib.inf
+  
PciHostBridgeLib|Silicon/Socionext/Synquacer/Library/SynquacerPciHostBridgeLib/SynquacerPciHostBridgeLib.inf
+
 [LibraryClasses.common.UEFI_APPLICATION]
   PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
   HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
@@ -184,6 +191,7 @@
   gArmTokenSpaceGuid.PcdSystemMemoryBase|0x8000
   gArmTokenSpaceGuid.PcdSystemMemorySize|0x7F00
   gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|40
+  gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|24
 
   # Ashbrook 12-Cluster profile
   gArmPlatformTokenSpaceGuid.PcdCoreCount|2
@@ -392,3 +400,44 @@
   NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf
   
NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
   }
+
+  #
+  # PCI
+  #
+  
Silicon/Socionext/Synquacer/Drivers/SynquacerPciCpuIo2dxe/SynquacerPciCpuIo2Dxe.inf
+  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {
+
+gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8010004F
+  }
+  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
+  MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
+
+  #
+  # AHCI Support
+  #
+  MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
+  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
+  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
+  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
+  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+
+  #
+  # USB
+  #
+  MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+  MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+  MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
+
+  #
+  # FAT filesystem + GPT/MBR partitioning
+  #
+  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
+  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
+  MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
+  FatPkg/EnhancedFatDxe/Fat.inf
+
+  #
+  # RNG
+  #
+  Silicon/Openmoko/ChaosKeyDxe/ChaosKeyDxe.inf
diff --git a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf 
b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
index 6c00e16b169e..befad354918e 100644
--- a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
+++ b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
@@ -128,6 +128,44 @@ READ_LOCK_STATUS   = TRUE
   INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
   INF MdeModulePkg/Application/UiApp/UiApp.inf
 
+  #
+  # PCI
+  #
+  INF 
Silicon/Socionext/Synquacer/Drivers/SynquacerPciCpuIo2dxe/SynquacerPciCpuIo2Dxe.inf
+  INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
+  INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
+  INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
+
+  #
+  # AHCI Support
+  #
+  INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
+  INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
+  INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
+  INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
+  INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+
+  #
+  # USB
+  #
+  INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+  INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+  INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+  INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
+
+  #
+  # FAT filesystem + GPT/MBR partitioning
+  #
+  INF 

[edk2] [PATCH edk2-platforms 06/14] Silicon/Synquacer: implement EFI_CPU_IO2_PROTOCOL

2017-09-08 Thread Ard Biesheuvel
The Synquacer SOC has two separate PCIe RCs, which means there is
no single value for the translation offset between I/O port accesses
and MMIO accesses. So add a special implementation of EFI_CPU_IO2_PROTOCOL
that takes the two disjoint I/O windows into account.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 
Silicon/Socionext/Synquacer/Drivers/SynquacerPciCpuIo2dxe/SynquacerPciCpuIo2Dxe.c
   | 588 
 
Silicon/Socionext/Synquacer/Drivers/SynquacerPciCpuIo2dxe/SynquacerPciCpuIo2Dxe.inf
 |  50 ++
 2 files changed, 638 insertions(+)

diff --git 
a/Silicon/Socionext/Synquacer/Drivers/SynquacerPciCpuIo2dxe/SynquacerPciCpuIo2Dxe.c
 
b/Silicon/Socionext/Synquacer/Drivers/SynquacerPciCpuIo2dxe/SynquacerPciCpuIo2Dxe.c
new file mode 100644
index ..8591a251aea3
--- /dev/null
+++ 
b/Silicon/Socionext/Synquacer/Drivers/SynquacerPciCpuIo2dxe/SynquacerPciCpuIo2Dxe.c
@@ -0,0 +1,588 @@
+/** @file
+  Produces the CPU I/O 2 Protocol.
+
+Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2016 - 2017, Linaro Ltd. 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 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MAX_IO_PORT_ADDRESS   SYNQUACER_PCI_SEG1_PORTIO_MAX
+
+//
+// Handle for the CPU I/O 2 Protocol
+//
+STATIC EFI_HANDLE  mHandle = NULL;
+
+//
+// Lookup table for increment values based on transfer widths
+//
+STATIC CONST UINT8 mInStride[] = {
+  1, // EfiCpuIoWidthUint8
+  2, // EfiCpuIoWidthUint16
+  4, // EfiCpuIoWidthUint32
+  8, // EfiCpuIoWidthUint64
+  0, // EfiCpuIoWidthFifoUint8
+  0, // EfiCpuIoWidthFifoUint16
+  0, // EfiCpuIoWidthFifoUint32
+  0, // EfiCpuIoWidthFifoUint64
+  1, // EfiCpuIoWidthFillUint8
+  2, // EfiCpuIoWidthFillUint16
+  4, // EfiCpuIoWidthFillUint32
+  8  // EfiCpuIoWidthFillUint64
+};
+
+//
+// Lookup table for increment values based on transfer widths
+//
+STATIC CONST UINT8 mOutStride[] = {
+  1, // EfiCpuIoWidthUint8
+  2, // EfiCpuIoWidthUint16
+  4, // EfiCpuIoWidthUint32
+  8, // EfiCpuIoWidthUint64
+  1, // EfiCpuIoWidthFifoUint8
+  2, // EfiCpuIoWidthFifoUint16
+  4, // EfiCpuIoWidthFifoUint32
+  8, // EfiCpuIoWidthFifoUint64
+  0, // EfiCpuIoWidthFillUint8
+  0, // EfiCpuIoWidthFillUint16
+  0, // EfiCpuIoWidthFillUint32
+  0  // EfiCpuIoWidthFillUint64
+};
+
+/**
+  Check parameters to a CPU I/O 2 Protocol service request.
+
+  The I/O operations are carried out exactly as requested. The caller is 
responsible
+  for satisfying any alignment and I/O width restrictions that a PI System on a
+  platform might require. For example on some platforms, width requests of
+  EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will
+  be handled by the driver.
+
+  @param[in] MmioOperation  TRUE for an MMIO operation, FALSE for I/O Port 
operation.
+  @param[in] Width  Signifies the width of the I/O or Memory operation.
+  @param[in] AddressThe base address of the I/O operation.
+  @param[in] Count  The number of I/O operations to perform. The 
number of
+bytes moved is Width size * Count, starting at 
Address.
+  @param[in] Buffer For read operations, the destination buffer to 
store the results.
+For write operations, the source buffer from which 
to write data.
+
+  @retval EFI_SUCCESSThe parameters for this request pass the 
checks.
+  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.
+  @retval EFI_INVALID_PARAMETER  Buffer is NULL.
+  @retval EFI_UNSUPPORTEDThe Buffer is not aligned for the given Width.
+  @retval EFI_UNSUPPORTEDThe address range specified by Address, Width,
+ and Count is not valid for this PI system.
+
+**/
+STATIC
+EFI_STATUS
+CpuIoCheckParameter (
+  IN BOOLEANMmioOperation,
+  IN EFI_CPU_IO_PROTOCOL_WIDTH  Width,
+  IN UINT64 Address,
+  IN UINTN  Count,
+  IN VOID   *Buffer
+  )
+{
+  UINT64  MaxCount;
+  UINT64  Limit;
+
+  //
+  // Check to see if Buffer is NULL
+  //
+  if (Buffer == NULL) {
+ASSERT (FALSE);
+return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // Check to see if Width is in the valid range
+  //
+  if ((UINT32)Width >= EfiCpuIoWidthMaximum) {
+ASSERT (FALSE);
+return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // For FIFO type, the target address won't increase during the access,
+  // so treat 

[edk2] [PATCH edk2-platforms 02/14] Silicon/Synquacer: add MemoryInitPeiLib implementation

2017-09-08 Thread Ard Biesheuvel
Replace the common MemoryInitPeiLib implementation with one that does
not remove the primary FV from the memory map. This is a waste of
memory and TLB entries, given that the OS can no longer use a 1 GB
block mapping to map this memory.

Since we have our own implementation now, there is no point in using
ArmPlatformLib's GetVirtualMemoryMap() implementation, and we can
simply declare and map the regions directly.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 
Silicon/Socionext/Synquacer/Library/SynquacerMemoryInitPeiLib/SynquacerMemoryInitPeiLib.c
   | 140 
 
Silicon/Socionext/Synquacer/Library/SynquacerMemoryInitPeiLib/SynquacerMemoryInitPeiLib.inf
 |  50 +++
 2 files changed, 190 insertions(+)

diff --git 
a/Silicon/Socionext/Synquacer/Library/SynquacerMemoryInitPeiLib/SynquacerMemoryInitPeiLib.c
 
b/Silicon/Socionext/Synquacer/Library/SynquacerMemoryInitPeiLib/SynquacerMemoryInitPeiLib.c
new file mode 100644
index ..1d25d63f1b6c
--- /dev/null
+++ 
b/Silicon/Socionext/Synquacer/Library/SynquacerMemoryInitPeiLib/SynquacerMemoryInitPeiLib.c
@@ -0,0 +1,140 @@
+/** @file
+*
+*  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
+*  Copyright (c) 2017, Linaro, Ltd. 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 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define ARM_MEMORY_REGION(Base, Size) \
+  { (Base), (Base), (Size), ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK }
+
+#define ARM_DEVICE_REGION(Base, Size) \
+  { (Base), (Base), (Size), ARM_MEMORY_REGION_ATTRIBUTE_DEVICE }
+
+VOID
+BuildMemoryTypeInformationHob (
+  VOID
+  );
+
+STATIC ARM_MEMORY_REGION_DESCRIPTOR mVirtualMemoryTable[] = {
+  // DDR - 2 GB
+  ARM_MEMORY_REGION (SYNQUACER_SYSTEM_MEMORY_1_BASE,
+ SYNQUACER_SYSTEM_MEMORY_1_SZ),
+
+  // DDR - 30 GB
+  ARM_MEMORY_REGION (SYNQUACER_SYSTEM_MEMORY_2_BASE,
+ SYNQUACER_SYSTEM_MEMORY_2_SZ),
+
+  // DDR - 32 GB
+//  ARM_MEMORY_REGION (SYNQUACER_SYSTEM_MEMORY_3_BASE,
+// SYNQUACER_SYSTEM_MEMORY_3_SZ),
+
+  // Synquacer OnChip non-secure ROM
+  ARM_MEMORY_REGION (SYNQUACER_NON_SECURE_ROM_BASE,
+ SYNQUACER_NON_SECURE_ROM_SZ),
+
+  // Synquacer OnChip peripherals
+  ARM_DEVICE_REGION (SYNQUACER_PERIPHERALS_BASE,
+ SYNQUACER_PERIPHERALS_SZ),
+
+  // Synquacer OnChip non-secure SRAM
+  ARM_MEMORY_REGION (SYNQUACER_NON_SECURE_SRAM_BASE,
+ SYNQUACER_NON_SECURE_SRAM_SZ),
+
+  // Synquacer GIC-500
+  ARM_DEVICE_REGION (SYNQUACER_GIC500_DIST_BASE, SYNQUACER_GIC500_DIST_SIZE),
+  ARM_DEVICE_REGION (SYNQUACER_GIC500_RDIST_BASE, SYNQUACER_GIC500_RDIST_SIZE),
+
+  // Synquacer eMMC(SDH30)
+  ARM_DEVICE_REGION (SYNQUACER_EMMC_BASE, SYNQUACER_EMMC_BASE_SZ),
+
+  // Synquacer EEPROM
+  ARM_DEVICE_REGION (SYNQUACER_EEPROM_BASE, SYNQUACER_EEPROM_BASE_SZ),
+
+  // Synquacer NETSEC
+  ARM_DEVICE_REGION (SYNQUACER_NETSEC_BASE, SYNQUACER_NETSEC_BASE_SZ),
+
+  // PCIe control registers
+  ARM_DEVICE_REGION (SYNQUACER_PCIE_BASE, SYNQUACER_PCIE_SIZE),
+
+  // PCIe config space
+  ARM_DEVICE_REGION (SYNQUACER_PCI_SEG0_CONFIG_BASE,
+ SYNQUACER_PCI_SEG0_CONFIG_SIZE),
+  ARM_DEVICE_REGION (SYNQUACER_PCI_SEG1_CONFIG_BASE,
+ SYNQUACER_PCI_SEG1_CONFIG_SIZE),
+
+  // PCIe I/O space
+  ARM_DEVICE_REGION (SYNQUACER_PCI_SEG0_PORTIO_MEMBASE,
+ SYNQUACER_PCI_SEG0_PORTIO_MEMSIZE),
+  ARM_DEVICE_REGION (SYNQUACER_PCI_SEG1_PORTIO_MEMBASE,
+ SYNQUACER_PCI_SEG1_PORTIO_MEMSIZE),
+
+  { }
+};
+
+EFI_STATUS
+EFIAPI
+MemoryPeim (
+  IN EFI_PHYSICAL_ADDRESS   UefiMemoryBase,
+  IN UINT64 UefiMemorySize
+  )
+{
+  EFI_RESOURCE_ATTRIBUTE_TYPE   ResourceAttributes;
+  RETURN_STATUS Status;
+
+  ResourceAttributes =
+  EFI_RESOURCE_ATTRIBUTE_PRESENT |
+  EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
+  EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
+  EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
+  EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |
+  EFI_RESOURCE_ATTRIBUTE_TESTED;
+
+  BuildResourceDescriptorHob (
+EFI_RESOURCE_SYSTEM_MEMORY,
+ResourceAttributes,
+SYNQUACER_SYSTEM_MEMORY_1_BASE,
+SYNQUACER_SYSTEM_MEMORY_1_SZ);
+
+  BuildResourceDescriptorHob (
+EFI_RESOURCE_SYSTEM_MEMORY,
+ResourceAttributes,
+SYNQUACER_SYSTEM_MEMORY_2_BASE,
+SYNQUACER_SYSTEM_MEMORY_2_SZ);
+
+//  BuildResourceDescriptorHob (
+//  

[edk2] [PATCH edk2-platforms 04/14] Silicon/Synquacer: implement PciSegmentLib to support dual RCs

2017-09-08 Thread Ard Biesheuvel
Having two distinct root complexes is not supported by the standard
set of PciLib/PciExpressLib/PciSegmentLib, so let's reimplement one
of the latter specifically for this platform (and forget about the
others).

This also allows us to implement the Synopsys Designware PCIe specific
workaround for PCI config space accesses to devices 1 and up on bus 0.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Silicon/Socionext/Synquacer/Library/SynquacerPciSegmentLib/PciSegmentLib.c 
   | 1396 
 
Silicon/Socionext/Synquacer/Library/SynquacerPciSegmentLib/SynquacerPciSegmentLib.inf
 |   35 +
 2 files changed, 1431 insertions(+)

diff --git 
a/Silicon/Socionext/Synquacer/Library/SynquacerPciSegmentLib/PciSegmentLib.c 
b/Silicon/Socionext/Synquacer/Library/SynquacerPciSegmentLib/PciSegmentLib.c
new file mode 100644
index ..a9b57883b6cf
--- /dev/null
+++ b/Silicon/Socionext/Synquacer/Library/SynquacerPciSegmentLib/PciSegmentLib.c
@@ -0,0 +1,1396 @@
+/** @file
+  PCI Segment Library for Synquacer SoC with multiple RCs
+
+  Copyright (c) 2007 - 2012, Intel Corporation. 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 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+typedef enum {
+  PciCfgWidthUint8  = 0,
+  PciCfgWidthUint16,
+  PciCfgWidthUint32,
+  PciCfgWidthMax
+} PCI_CFG_WIDTH;
+
+/**
+  Assert the validity of a PCI Segment address.
+  A valid PCI Segment address should not contain 1's in bits 28..31 and 48..63
+
+  @param  A The address to validate.
+  @param  M Additional bits to assert to be zero.
+
+**/
+#define ASSERT_INVALID_PCI_SEGMENT_ADDRESS(A,M) \
+  ASSERT (((A) & (0xf000ULL | (M))) == 0)
+
+STATIC
+UINT64
+PciSegmentLibGetConfigBase (
+  IN  UINT64  Address
+  )
+{
+  switch ((UINT16)(Address >> 32)) {
+  case 0:
+return SYNQUACER_PCI_SEG0_CONFIG_BASE;
+  case 1:
+return SYNQUACER_PCI_SEG1_CONFIG_BASE;
+  default:
+ASSERT (FALSE);
+  }
+
+  return 0;
+}
+
+/**
+  Internal worker function to read a PCI configuration register.
+
+  @param  Address The address that encodes the PCI Bus, Device, Function and
+  Register.
+  @param  Width   The width of data to read
+
+  @return The value read from the PCI configuration register.
+
+**/
+STATIC
+UINT32
+PciSegmentLibReadWorker (
+  IN  UINT64  Address,
+  IN  PCI_CFG_WIDTH   Width
+  )
+{
+  UINT64Base;
+
+  Base = PciSegmentLibGetConfigBase (Address);
+
+  // ignore devices > 0 on bus 0
+  if ((Address & 0xff0) == 0 && (Address & 0xf800) != 0) {
+return 0x;
+  }
+
+  switch (Width) {
+  case PciCfgWidthUint8:
+return MmioRead8 (Base + (UINT32)Address);
+  case PciCfgWidthUint16:
+return MmioRead16 (Base + (UINT32)Address);
+  case PciCfgWidthUint32:
+return MmioRead32 (Base + (UINT32)Address);
+  default:
+ASSERT (FALSE);
+  }
+
+  return 0;
+}
+
+/**
+  Internal worker function to writes a PCI configuration register.
+
+  @param  Address The address that encodes the PCI Bus, Device, Function and
+  Register.
+  @param  Width   The width of data to write
+  @param  DataThe value to write.
+
+  @return The value written to the PCI configuration register.
+
+**/
+STATIC
+UINT32
+PciSegmentLibWriteWorker (
+  IN  UINT64  Address,
+  IN  PCI_CFG_WIDTH   Width,
+  IN  UINT32  Data
+  )
+{
+  UINT64Base;
+
+  Base = PciSegmentLibGetConfigBase (Address);
+
+  // ignore devices > 0 on bus 0
+  if ((Address & 0xff0) == 0 && (Address & 0xf800) != 0) {
+return Data;
+  }
+
+  switch (Width) {
+  case PciCfgWidthUint8:
+MmioWrite8 (Base + (UINT32)Address, Data);
+break;
+  case PciCfgWidthUint16:
+MmioWrite16 (Base + (UINT32)Address, Data);
+break;
+  case PciCfgWidthUint32:
+MmioWrite32 (Base + (UINT32)Address, Data);
+break;
+  default:
+ASSERT (FALSE);
+  }
+
+  return Data;
+}
+
+/**
+  Register a PCI device so PCI configuration registers may be accessed after
+  SetVirtualAddressMap().
+
+  If any reserved bits in Address are set, then ASSERT().
+
+  @param  Address The address that encodes the PCI Bus, Device, Function and
+  Register.
+
+  @retval RETURN_SUCCESS   The PCI device was registered for runtime 
access.
+  @retval RETURN_UNSUPPORTED   An attempt was made to call this function
+   after ExitBootServices().
+  @retval RETURN_UNSUPPORTED  

[edk2] [PATCH edk2-platforms 03/14] Platform: add support for Socionext Synquacer eval board

2017-09-08 Thread Ard Biesheuvel
This is a barebones port based on the .DSC/.FDF and ArmPlatformLib
code provided by Socionext. It can boot into the UiApp menu screen
or the UEFI Shell, but lacks support for any peripherals.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc   | 
394 
 Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf   | 
276 ++
 Silicon/Socionext/Synquacer/Library/SynquacerLib/AArch64/SynquacerHelper.S |  
93 +
 Silicon/Socionext/Synquacer/Library/SynquacerLib/Arm/SynquacerHelper.S |  
93 +
 Silicon/Socionext/Synquacer/Library/SynquacerLib/Synquacer.c   | 
124 ++
 Silicon/Socionext/Synquacer/Library/SynquacerLib/SynquacerLib.inf  |  
39 ++
 6 files changed, 1019 insertions(+)

diff --git a/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc 
b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
new file mode 100644
index ..2a9a0037dcda
--- /dev/null
+++ b/Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.dsc
@@ -0,0 +1,394 @@
+#
+#  Copyright (c) 2013-2014, ARM Limited. All rights reserved.
+#  Copyright (c) 2017, Linaro Limited. 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.
+#
+
+
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+
+[Defines]
+  PLATFORM_NAME  = SynquacerEvalBoard
+  PLATFORM_GUID  = a8180daa-fb8b-11e5-ab24-9fc3167c073d
+  PLATFORM_VERSION   = 0.1
+  DSC_SPECIFICATION  = 0x00010005
+  OUTPUT_DIRECTORY   = Build/$(PLATFORM_NAME)
+  SUPPORTED_ARCHITECTURES= AARCH64|ARM
+  BUILD_TARGETS  = DEBUG|RELEASE
+  SKUID_IDENTIFIER   = DEFAULT
+  FLASH_DEFINITION   = 
Platform/Socionext/SynquacerEvalBoard/SynquacerEvalBoard.fdf
+
+[BuildOptions]
+  RELEASE_*_*_CC_FLAGS  = -DMDEPKG_NDEBUG -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
+
+[BuildOptions.common.EDKII.DXE_CORE,BuildOptions.common.EDKII.DXE_DRIVER,BuildOptions.common.EDKII.UEFI_DRIVER,BuildOptions.common.EDKII.UEFI_APPLICATION]
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+
+[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
+  GCC:*_*_ARM_DLINK_FLAGS = -z common-page-size=0x1000
+  GCC:*_*_AARCH64_DLINK_FLAGS = -z common-page-size=0x1
+
+[LibraryClasses.common]
+  
ArmPlatformLib|Silicon/Socionext/Synquacer/Library/SynquacerLib/SynquacerLib.inf
+  ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf
+  ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
+
+  TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
+  FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+
+!if $(TARGET) == RELEASE
+  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+!else
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!endif
+  
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
+
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf
+
+  # Networking Requirements
+  NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
+  DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
+  UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
+  IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
+
+  # ARM Architectural Libraries
+  
CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
+  
DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
+  CpuExceptionHandlerLib|ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf
+  ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
+  ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
+  ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
+  ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
+  ArmGicArchLib|ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf
+  
ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf
+  ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
+  
ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
+
+  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+  
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
+  

Re: [edk2] WARNING: No source level debug

2017-09-08 Thread david moheban
I checked all of the DebugLib instances and I believe they are all there
though in different locations in Mdemodulepkg.dsc vs nt32pkg.dsc. I have
tried every suggestion and made every configuration change possible. Spent
hours google searching the issue. Getting rid of the Null debuglib
reference, using the intel package vs mdepkg and so on. Sorting it out
further unfortunately is beyond my abilities at the moment. I think the
issue is that the debug calls get ignored because a driver based on
Mdemodulepkg is running off of the NT32pkg firmware volume image I copied
from the NT32 build X64 folder into the Mdemodulepkg build x64 folder along
with SecMain so that the VM can run when I type 'Build run -p
mdemodulepkg'. If there is another way to rebuild that firmware volume
someone please clue me in because i think that would fix it. I only know
how to build it from Nt32pkg. In anycase Ill just start over and use the
NT32pkg platform instead.

Thank you

Sent from my iPad
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at ExitBootServices

2017-09-08 Thread Laszlo Ersek
On 09/08/17 17:50, Brijesh Singh wrote:
> Patch 4 - 10
> 
> Reviewed-by: Brijesh Singh 
> Tested-by: Brijesh Singh 
> 
> Thank you Laszlo! I will work to finish virtio-net next week.

Awesome!

Thanks!
Laszlo

> On 09/07/2017 05:41 PM, Laszlo Ersek wrote:
>> Repo:   https://github.com/lersek/edk2.git
>> Branch: iommu_exit_boot
>>
>> This series is the result of the discussion under
>>
>>    [edk2] [PATCH 0/4] MdeModulePkg: some PCI HC drivers: unmap common
>>   buffers at ExitBootServices()
>>    https://lists.01.org/pipermail/edk2-devel/2017-September/014099.html
>>
>> At ExitBootServices(), PCI and VirtIo drivers should only care about
>> aborting pending DMA on the devices. Cleaning up PciIo mappings (which
>> ultimately boil down to IOMMU mappings) for those aborted DMA operations
>> should be the job of the IOMMU driver.
>>
>> Patches 01 through 03 clean up the AtaAtapiPassThru driver in
>> MdeModulePkg a little bit, because at present, (a) it unmaps the buffers
>> and disables BMDMA in the wrong order in its DriverBindingStop()
>> function, (b) it doesn't abort pending DMA at ExitBootServices().
>>
>> This subset can be treated separately from the rest of the series, but I
>> thought they belonged loosely together (given that AtaAtapiPassThru is
>> used on QEMU's Q35 machine type).
>>
>> Patches 04 through 07 remove VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer()
>> calls from the VirtIo drivers' ExitBootServices() handlers.
>>
>> (The conversion of VirtioNetDxe to device addresses is still in progress
>> -- Brijesh, when you submit v2 of that, under this approach, there is no
>> need to change VirtioNetExitBoot() relative to current upstream, and you
>> can use VirtioOperationBusMasterRead to map outgoing packets.)
>>
>> Patches 08 through 10 make OvmfPkg/IoMmuDxe track all mappings, and
>> unmap all mappings (Read, Write, CommonBuffer) that are in effect when
>> ExitBootServices() is called. It is ensured that PCI and VirtIo drivers
>> abort pending DMA first, and IoMmuDxe clean up the mappings last.
>>
>> Cc: Ard Biesheuvel 
>> Cc: Brijesh Singh 
>> Cc: Eric Dong 
>> Cc: Jiewen Yao 
>> Cc: Jordan Justen 
>> Cc: Star Zeng 
>>
>> Thanks
>> Laszlo
>>
>> Laszlo Ersek (10):
>>    MdeModulePkg/AtaAtapiPassThru: cache EnabledPciAttributes
>>    MdeModulePkg/AtaAtapiPassThru: unmap DMA buffers after disabling BM
>>  DMA
>>    MdeModulePkg/AtaAtapiPassThru: disable the device at
>>  ExitBootServices()
>>    OvmfPkg/VirtioBlkDxe: don't unmap VRING at ExitBootServices()
>>    OvmfPkg/VirtioGpuDxe: don't unmap VRING & BackingStore at
>>  ExitBootServices
>>    OvmfPkg/VirtioRngDxe: don't unmap VRING at ExitBootServices()
>>    OvmfPkg/VirtioScsiDxe: don't unmap VRING at ExitBootServices()
>>    OvmfPkg/IoMmuDxe: track all mappings
>>    OvmfPkg/IoMmuDxe: generalize IoMmuUnmap() to IoMmuUnmapWorker()
>>    OvmfPkg/IoMmuDxe: unmap all IOMMU mappings at ExitBootServices()
>>
>>   MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 103 +---
>>   MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h |   7 +
>>   OvmfPkg/IoMmuDxe/AmdSevIoMmu.c   | 246
>> +---
>>   OvmfPkg/VirtioBlkDxe/VirtioBlk.c |   7 +-
>>   OvmfPkg/VirtioGpuDxe/Commands.c  |  23 +-
>>   OvmfPkg/VirtioRngDxe/VirtioRng.c |   7 +-
>>   OvmfPkg/VirtioScsiDxe/VirtioScsi.c   |   7 +-
>>   7 files changed, 299 insertions(+), 101 deletions(-)
>>

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at ExitBootServices

2017-09-08 Thread Brijesh Singh

Patch 4 - 10

Reviewed-by: Brijesh Singh 
Tested-by: Brijesh Singh 

Thank you Laszlo! I will work to finish virtio-net next week.

-Brijesh


On 09/07/2017 05:41 PM, Laszlo Ersek wrote:

Repo:   https://github.com/lersek/edk2.git
Branch: iommu_exit_boot

This series is the result of the discussion under

   [edk2] [PATCH 0/4] MdeModulePkg: some PCI HC drivers: unmap common
  buffers at ExitBootServices()
   https://lists.01.org/pipermail/edk2-devel/2017-September/014099.html

At ExitBootServices(), PCI and VirtIo drivers should only care about
aborting pending DMA on the devices. Cleaning up PciIo mappings (which
ultimately boil down to IOMMU mappings) for those aborted DMA operations
should be the job of the IOMMU driver.

Patches 01 through 03 clean up the AtaAtapiPassThru driver in
MdeModulePkg a little bit, because at present, (a) it unmaps the buffers
and disables BMDMA in the wrong order in its DriverBindingStop()
function, (b) it doesn't abort pending DMA at ExitBootServices().

This subset can be treated separately from the rest of the series, but I
thought they belonged loosely together (given that AtaAtapiPassThru is
used on QEMU's Q35 machine type).

Patches 04 through 07 remove VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer()
calls from the VirtIo drivers' ExitBootServices() handlers.

(The conversion of VirtioNetDxe to device addresses is still in progress
-- Brijesh, when you submit v2 of that, under this approach, there is no
need to change VirtioNetExitBoot() relative to current upstream, and you
can use VirtioOperationBusMasterRead to map outgoing packets.)

Patches 08 through 10 make OvmfPkg/IoMmuDxe track all mappings, and
unmap all mappings (Read, Write, CommonBuffer) that are in effect when
ExitBootServices() is called. It is ensured that PCI and VirtIo drivers
abort pending DMA first, and IoMmuDxe clean up the mappings last.

Cc: Ard Biesheuvel 
Cc: Brijesh Singh 
Cc: Eric Dong 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Star Zeng 

Thanks
Laszlo

Laszlo Ersek (10):
   MdeModulePkg/AtaAtapiPassThru: cache EnabledPciAttributes
   MdeModulePkg/AtaAtapiPassThru: unmap DMA buffers after disabling BM
 DMA
   MdeModulePkg/AtaAtapiPassThru: disable the device at
 ExitBootServices()
   OvmfPkg/VirtioBlkDxe: don't unmap VRING at ExitBootServices()
   OvmfPkg/VirtioGpuDxe: don't unmap VRING & BackingStore at
 ExitBootServices
   OvmfPkg/VirtioRngDxe: don't unmap VRING at ExitBootServices()
   OvmfPkg/VirtioScsiDxe: don't unmap VRING at ExitBootServices()
   OvmfPkg/IoMmuDxe: track all mappings
   OvmfPkg/IoMmuDxe: generalize IoMmuUnmap() to IoMmuUnmapWorker()
   OvmfPkg/IoMmuDxe: unmap all IOMMU mappings at ExitBootServices()

  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 103 +---
  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h |   7 +
  OvmfPkg/IoMmuDxe/AmdSevIoMmu.c   | 246 
+---
  OvmfPkg/VirtioBlkDxe/VirtioBlk.c |   7 +-
  OvmfPkg/VirtioGpuDxe/Commands.c  |  23 +-
  OvmfPkg/VirtioRngDxe/VirtioRng.c |   7 +-
  OvmfPkg/VirtioScsiDxe/VirtioScsi.c   |   7 +-
  7 files changed, 299 insertions(+), 101 deletions(-)


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] Fwd: StartImage with Secure Boot on Self-Signed App

2017-09-08 Thread David F.
Actually, even a StartImageEx() would be fine with parameter to allow options.

On Thu, Sep 7, 2017 at 7:51 PM, David F.  wrote:
> Thanks, looking forward, can the people on the board dealing with the
> specification please consider revising EFI_LOADED_IMAGE_PROTOCOL to
> include a new "Flags" field and one of the bits allows StartImage to
> start the image even if LoadImage reported a EFI_SECURITY_VIOLATION
> was reported.  defined bit name could be #define
> EFI_LOADED_IMAGE_PROTOCOL_FLAG_SELF_VALIDATED  0x0001ULL.
>  This provides a clean interface for applications without having to
> hack StartImage() with a potential conflict with future changes to the
> internal firmware.
>
>
> On Thu, Sep 7, 2017 at 7:11 PM, Gary Lin  wrote:
>> On Thu, Sep 07, 2017 at 01:00:03PM -0700, David F. wrote:
>>> Hello,
>>>
>>> What is the proper way to allow running another app that is verified
>>> with a self-signed certificate?
>>>
>>> Example, App1 is signed with one that allows secure boot booting (in
>>> firmware) and has a public key embedded in the signed code, App2 is
>>> verified by App1 and so is allowed to run, but because the key is not
>>> in secure boot firmware, StartImage will not run it (although
>>> LoadImage did what it needed to do and already reported the security
>>> violation potential).   Do we have to roll our own StartImage?  or is
>>> something already in place?  I can't rely on changing an internal
>>> private structure field to allow StartImage to work since each
>>> firmware platform may change the way it all works, looking for the
>>> proper method as designed.
>>>
>> The major linux distros are using shim(*) to verify the bootloaders and
>> kernels signed by ourselves, and shim implements its own StartImage.
>>
>> If your application is going to be deployed to the newer UEFI, instead
>> of using the built-in openssl, you can try EFI_PKCS7_VERIFY_PROTOCOL to
>> verify the UEFI images. It will make your application much slimmer and
>> easier to maintain.
>>
>> Cheers,
>>
>> Gary Lin
>>
>> (*) https://github.com/rhboot/shim
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v6 0/6] read-only UDF file system support

2017-09-08 Thread Ni, Ruiyu
Reviewed-by: Ruiyu Ni 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Laszlo 
Ersek
Sent: Friday, September 8, 2017 9:26 PM
To: Paulo Alcantara ; Ni, Ruiyu 
Cc: Dong, Eric ; Wu, Hao A ; Justen, 
Jordan L ; edk2-devel@lists.01.org; Andrew Fish 
; Gao, Liming ; Kinney, Michael D 
; Zeng, Star 
Subject: Re: [edk2] [PATCH v6 0/6] read-only UDF file system support

Ray,

On 09/08/17 14:41, Paulo Alcantara wrote:

> v6:
>  - Fixed a bug in UdfRead() that'd pontentially break in ARM or IA32
>by allowing caller to read more than 4GiB of data
>(i.e. BufferSize pointer is dereferenced as an UINT64 * and it's
> followed by 4 bytes that are nonzero).
>
> Repo:   https://github.com/pcacjr/edk2.git
> Branch: udf-fs-v6

The v5-v6 diff is as follows:

> diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c 
> b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> index 2dbcff0be4a3..8b9339567f8e 100644
> --- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> +++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> @@ -325,8 +325,9 @@ UdfRead (
>UDF_FILE_IDENTIFIER_DESCRIPTOR  *NewFileIdentifierDesc;
>VOID*NewFileEntryData;
>CHAR16  FileName[UDF_FILENAME_LENGTH] = { 0 };
>UINT64  FileSize;
> +  UINT64  BufferSizeUint64;
>
>OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
>
>if (This == NULL || BufferSize == NULL || (*BufferSize != 0 && @@ 
> -363,18 +364,22 @@ UdfRead (
>Status = EFI_SUCCESS;
>goto Done;
>  }
>
> +BufferSizeUint64 = *BufferSize;
> +
>  Status = ReadFileData (
>BlockIo,
>DiskIo,
>Volume,
>Parent,
>PrivFileData->FileSize,
>>FilePosition,
>Buffer,
> -  (UINT64 *)(UINTN)BufferSize
> +  
>);
> +ASSERT (BufferSizeUint64 <= MAX_UINTN);
> +*BufferSize = (UINTN)BufferSizeUint64;
>} else if (IS_FID_DIRECTORY_FILE (Parent->FileIdentifierDesc)) {
>  if (ReadDirInfo->FidOffset == 0 && PrivFileData->FilePosition > 0) {
>Status = EFI_DEVICE_ERROR;
>*BufferSize = 0;

It looks OK to me, and it builds fine for IA32, X64, ARM and AARCH64:

  Build/ArmVirtQemu-AARCH64/DEBUG_GCC5/AARCH64/UdfDxe.efi
  Build/ArmVirtQemu-ARM/DEBUG_GCC5/ARM/UdfDxe.efi
  Build/OvmfIa32/NOOPT_GCC48/IA32/UdfDxe.efi
  Build/OvmfX64/NOOPT_GCC48/X64/UdfDxe.efi

Green light from your side?

Paulo: you forgot to pick up Ray's R-b for patches #4 and #5, from his
v5 response
<734D49CCEBEEF84792F5B80ED585239D5BA282B7@SHSMSX104.ccr.corp.intel.com">http://mid.mail-archive.com/734D49CCEBEEF84792F5B80ED585239D5BA282B7@SHSMSX104.ccr.corp.intel.com>
-- it was for the entire series.

But, I'll apply that for you.

Thanks,
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 02/11] MdeModulePkg/Dec: Add IOMMU_PPI GUID.

2017-09-08 Thread Jiewen Yao
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao 
---
 MdeModulePkg/MdeModulePkg.dec | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 593bff3..403a66a 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -431,6 +431,9 @@
   ## Include/Ppi/SdMmcHostController.h
   gEdkiiPeiSdMmcHostControllerPpiGuid = { 0xb30dfeed, 0x947f, 0x4396, { 0xb1, 
0x5a, 0xdf, 0xbd, 0xb9, 0x16, 0xdc, 0x24 }}
 
+  ## Include/Ppi/IoMmu.h
+  gEdkiiIoMmuPpiGuid = { 0x70b0af26, 0xf847, 0x4bb6, { 0xaa, 0xb9, 0xcd, 0xe8, 
0x4f, 0xc6, 0x14, 0x31 } }
+
 [Protocols]
   ## Load File protocol provides capability to load and unload EFI image into 
memory and execute it.
   #  Include/Protocol/LoadPe32Image.h
-- 
2.7.4.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 09/11] IntelSiliconPkg: Add PlatformVTdInfoSamplePei.

2017-09-08 Thread Jiewen Yao
This is a sample driver to produce VTD_INFO PPI.

Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao 
---
 IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.c| 
65 
 IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.inf  | 
51 +++
 IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.uni  | 
20 ++
 IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePeiExtra.uni | 
20 ++
 4 files changed, 156 insertions(+)

diff --git 
a/IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.c 
b/IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.c
new file mode 100644
index 000..c79398f
--- /dev/null
+++ b/IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.c
@@ -0,0 +1,65 @@
+/** @file
+  Platform VTd Info Sample PEI driver.
+
+  Copyright (c) 2017, Intel Corporation. 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 
+
+#include 
+
+#include 
+#include 
+
+typedef struct {
+  UINT64  Revision;
+  UINT8   HostAddressWidth;
+  UINT8   Reserved[3];
+  UINT32  VTdEngineCount;
+  UINT64  VTdEngineAddress[2];
+} MY_VTD_INFO_PPI;
+
+MY_VTD_INFO_PPI  mPlatformVTdSample = {
+  EDKII_VTD_INFO_PPI_REVISION,
+  0x26,
+  {0},
+  2,
+  {0xFED9, 0xFED91000},
+};
+
+EFI_PEI_PPI_DESCRIPTOR mPlatformVTdInfoSampleDesc = {
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+  ,
+  
+};
+
+/**
+  Platform VTd Info sample driver.
+
+  @param[in] FileHandle  Handle of the file being invoked.
+  @param[in] PeiServices Describes the list of possible PEI Services.
+
+  @retval EFI_SUCCESS if it completed successfully.
+**/
+EFI_STATUS
+EFIAPI
+PlatformVTdInfoSampleInitialize (
+  IN   EFI_PEI_FILE_HANDLE  FileHandle,
+  IN CONST EFI_PEI_SERVICES **PeiServices
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = PeiServicesInstallPpi ();
+  ASSERT_EFI_ERROR (Status);
+
+  return Status;
+}
diff --git 
a/IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.inf 
b/IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.inf
new file mode 100644
index 000..fe12821
--- /dev/null
+++ b/IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.inf
@@ -0,0 +1,51 @@
+## @file
+# Platform VTd Info Sample PEI driver.
+#
+# Copyright (c) 2017, Intel Corporation. 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.
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = PlatformVTdInfoSamplePei
+  MODULE_UNI_FILE= PlatformVTdInfoSamplePei.uni
+  FILE_GUID  = 839EB770-5C64-4EED-A6D5-EC515B2B2B23
+  MODULE_TYPE= PEIM
+  VERSION_STRING = 1.0
+  ENTRY_POINT= PlatformVTdInfoSampleInitialize
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64 IPF EBC
+#
+#
+
+[Sources]
+  PlatformVTdInfoSamplePei.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  IntelSiliconPkg/IntelSiliconPkg.dec
+
+[LibraryClasses]
+  PeimEntryPoint
+  PeiServicesLib
+
+[Ppis]
+  gEdkiiVTdInfoPpiGuid ## PRODUCES
+
+[Depex]
+  gEfiPeiMemoryDiscoveredPpiGuid
+
+[UserExtensions.TianoCore."ExtraFiles"]
+  PlatformVTdInfoSamplePeiExtra.uni
+
diff --git 
a/IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.uni 
b/IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.uni
new file mode 100644
index 000..36f9183
--- /dev/null
+++ b/IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.uni
@@ -0,0 +1,20 @@
+// /** @file
+// PlatformVTdInfoSamplePei Module Localized Abstract and Description Content
+//
+// Copyright (c) 2017, Intel Corporation. All rights reserved.
+//
+// This program and the accompanying materials are
+// licensed and made available under 

[edk2] [PATCH 07/11] IntelSiliconPkg: Add IntelVTdPmrPei.

2017-09-08 Thread Jiewen Yao
This PEIM is to produce IOMMU_PPI, so that PEI device
driver can have better DAM management.

This PEIM will setup VTD PMR register to protect
most DRAM. It allocates a big chunk DMA buffer in
the entrypoint, and only use this buffer for DMA.
Any other region is DMA protected.

Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao 
---
 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmr.c   | 314 ++
 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.c| 615 

 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.h|  68 +++
 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.inf  |  59 ++
 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.uni  |  20 +
 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPeiExtra.uni |  20 +
 6 files changed, 1096 insertions(+)

diff --git a/IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmr.c 
b/IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmr.c
new file mode 100644
index 000..ef08e29
--- /dev/null
+++ b/IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmr.c
@@ -0,0 +1,314 @@
+/** @file
+
+  Copyright (c) 2017, Intel Corporation. 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "IntelVTdPmrPei.h"
+
+extern EDKII_VTD_INFO_PPI*mVTdInfoPpi;
+
+/**
+  Get protected low memory alignment.
+
+  @param VtdUnitBaseAddress The base address of the VTd engine.
+
+  @return protected low memory alignment.
+**/
+UINT32
+GetPlmrAlignment (
+  IN UINTN VtdUnitBaseAddress
+  )
+{
+  UINT32Data32;
+
+  MmioWrite32 (VtdUnitBaseAddress + R_PMEN_LOW_BASE_REG, 0x);
+  Data32 = MmioRead32 (VtdUnitBaseAddress + R_PMEN_LOW_BASE_REG);
+  Data32 = ~Data32 + 1;
+
+  return Data32;
+}
+
+/**
+  Get protected high memory alignment.
+
+  @param VtdUnitBaseAddress The base address of the VTd engine.
+
+  @return protected high memory alignment.
+**/
+UINT64
+GetPhmrAlignment (
+  IN UINTN VtdUnitBaseAddress
+  )
+{
+  UINT64Data64;
+  UINT8 HostAddressWidth;
+
+  HostAddressWidth = mVTdInfoPpi->HostAddressWidth;
+
+  MmioWrite64 (VtdUnitBaseAddress + R_PMEN_HIGH_BASE_REG, 0x);
+  Data64 = MmioRead64 (VtdUnitBaseAddress + R_PMEN_HIGH_BASE_REG);
+  Data64 = ~Data64 + 1;
+  Data64 = Data64 & (LShiftU64 (1, HostAddressWidth) - 1);
+
+  return Data64;
+}
+
+/**
+  Get protected low memory alignment.
+
+  @return protected low memory alignment.
+**/
+UINT32
+GetLowMemoryAlignment (
+  VOID
+  )
+{
+  UINTN Index;
+  UINT32Alignment;
+  UINT32FinalAlignment;
+
+  FinalAlignment = 0;
+  for (Index = 0; Index < mVTdInfoPpi->VTdEngineCount; Index++) {
+Alignment = GetPlmrAlignment ((UINTN)mVTdInfoPpi->VTdEngineAddress[Index]);
+if (FinalAlignment < Alignment) {
+  FinalAlignment = Alignment;
+}
+  }
+  return FinalAlignment;
+}
+
+/**
+  Get protected high memory alignment.
+
+  @return protected high memory alignment.
+**/
+UINT64
+GetHighMemoryAlignment (
+  VOID
+  )
+{
+  UINTN Index;
+  UINT64Alignment;
+  UINT64FinalAlignment;
+
+  FinalAlignment = 0;
+  for (Index = 0; Index < mVTdInfoPpi->VTdEngineCount; Index++) {
+Alignment = GetPhmrAlignment ((UINTN)mVTdInfoPpi->VTdEngineAddress[Index]);
+if (FinalAlignment < Alignment) {
+  FinalAlignment = Alignment;
+}
+  }
+  return FinalAlignment;
+}
+
+/**
+  Enable PMR in the VTd engine.
+
+  @param VtdUnitBaseAddress The base address of the VTd engine.
+
+  @retval EFI_SUCCESS  The PMR is enabled.
+  @retval EFI_UNSUPPORTED  The PMR is not supported.
+**/
+EFI_STATUS
+EnablePmr (
+  IN UINTN VtdUnitBaseAddress
+  )
+{
+  UINT32Reg32;
+  VTD_CAP_REG   CapReg;
+
+  CapReg.Uint64 = MmioRead64 (VtdUnitBaseAddress + R_CAP_REG);
+  if (CapReg.Bits.PLMR == 0 || CapReg.Bits.PHMR == 0) {
+return EFI_UNSUPPORTED;
+  }
+
+  Reg32 = MmioRead32 (VtdUnitBaseAddress + R_PMEN_ENABLE_REG);
+  if ((Reg32 & BIT0) == 0) {
+MmioWrite32 (VtdUnitBaseAddress + R_PMEN_ENABLE_REG, BIT31);
+do {
+  Reg32 = MmioRead32 (VtdUnitBaseAddress + R_PMEN_ENABLE_REG);
+} while((Reg32 & BIT0) == 0);
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Disable PMR in the VTd engine.
+
+  @param VtdUnitBaseAddress The base address of the VTd engine.
+
+  @retval EFI_SUCCESS  The PMR is disabled.
+  @retval EFI_UNSUPPORTED  The PMR is not supported.
+**/
+EFI_STATUS
+DisablePmr (
+  IN UINTN VtdUnitBaseAddress
+  )
+{
+  UINT32 

[edk2] [PATCH 00/11] Add IOMMU PEI support.

2017-09-08 Thread Jiewen Yao
This series patch added IOMMU PEI support.
It is also posted to https://github.com/jyao1/edk2/tree/IoMmuPpi.

1) Patch 1 and 2 add EDKII_IOMMU_PPI.
It is similar to EDKII_IOMMU_PROTOCOL.

2) Patch 3 and 4 add Intel VTD PMR register support
for DXE phase IntelVTdDxe.
This is to prepare handle PMR usage in PEI phase.

3) Patch 5 and 6 add EDKII_VTD_INFO_PPI.
This PPI is to provide Intel VTD information in PEI.
In DXE, the VTd driver can get VTD info from ACPI DMAR table.
But in PEI, there is no way to get VTD info before.
VTD_INFO_PPI is added to resolve the problem.

4) Patch 7 and 8 add IntelVTdPmrPei driver.
This driver consumes EDKII_VTD_INFO_PPI and produces IOMMU_PPI.
It enables VTD PMR register to provide DMA protection.
The PMR based DMA protection is a simple solution to
mark 2 regions can be DMA protected.
The IntelVTdPmrPei allocates a small chunk buffer for DMA
and protect the rest memory.

5) Patch 9 and 10 add a sample VTdInfo PEI driver.
It provides a sample to show how to report VTd info in PEI phase.

6) Patch 11 updates XhciPei driver to consume IOMMU_PPI.
If the IOMMU_PPI is present, XhciPei will use IOMMU_PPI to
allocate DMA buffer. Or the XhciPei will still use old way -
PeiServiceAllocatePage to allocate DRAM as DMA buffer.
This is the first PEI device driver consuming IOMMU_PPI to
show the concept. The rest PEI device drivers will be
updated in separated patches.


This series patch is validated on Intel Kabylake Platform.
1) We can use XHCI to do file transfer in PEI phase,
2) We can still use XHCI in DXE phase, such as shell environment.
3) If the device driver does not consume IOMMU_PPI, the DMA fails.

Jiewen Yao (11):
  MdeModulePkg/Include: Add IOMMU_PPI.
  MdeModulePkg/Dec: Add IOMMU_PPI GUID.
  IntelSiliconPkg/Vtd.h: Add definition for PMR.
  IntelSiliconPkg/VTdDxe: Disable PMR
  IntelSiliconPkg/include: Add VTD_INFO PPI.
  IntelSiliconPkg/dec: Add VTD_INFO PPI GUID
  IntelSiliconPkg: Add IntelVTdPmrPei.
  IntelSiliconPkg/dsc: Add IntelVTdPmrPeim.
  IntelSiliconPkg: Add PlatformVTdInfoSamplePei.
  IntelSiliconPkg/dsc: Add PlatformVTdInfoSamplePei.
  MdeModulePkg/XhciPei: Support IoMmu.

 IntelSiliconPkg/Include/IndustryStandard/Vtd.h |   
6 +
 IntelSiliconPkg/Include/Ppi/VtdInfo.h  |  
40 ++
 IntelSiliconPkg/IntelSiliconPkg.dec|   
3 +
 IntelSiliconPkg/IntelSiliconPkg.dsc|  
10 +
 IntelSiliconPkg/IntelVTdDxe/VtdReg.c   |  
51 +-
 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmr.c   | 
314 ++
 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.c| 
615 
 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.h|  
68 +++
 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.inf  |  
59 ++
 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.uni  |  
20 +
 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPeiExtra.uni |  
20 +
 IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.c|  
65 +++
 IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.inf  |  
51 ++
 IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.uni  |  
20 +
 IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePeiExtra.uni |  
20 +
 MdeModulePkg/Bus/Pci/XhciPei/DmaMem.c  | 
249 
 MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c|  
55 +-
 MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.h|   
9 +-
 MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.c |  
55 +-
 MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.h | 
107 
 MdeModulePkg/Bus/Pci/XhciPei/XhciPei.inf   |   
3 +
 MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c   |  
47 +-
 MdeModulePkg/Bus/Pci/XhciPei/XhciSched.h   |   
1 +
 MdeModulePkg/Include/Ppi/IoMmu.h   | 
196 +++
 MdeModulePkg/MdeModulePkg.dec  |   
3 +
 25 files changed, 2052 insertions(+), 35 deletions(-)
 create mode 100644 IntelSiliconPkg/Include/Ppi/VtdInfo.h
 create mode 100644 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmr.c
 create mode 100644 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.c
 create mode 100644 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.h
 create mode 100644 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.inf
 create mode 100644 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.uni
 create mode 100644 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPeiExtra.uni
 create mode 100644 
IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.c
 create mode 100644 

[edk2] [PATCH 11/11] MdeModulePkg/XhciPei: Support IoMmu.

2017-09-08 Thread Jiewen Yao
Update XHCI driver to consume IOMMU_PPI to allocate DMA buffer.

If no IOMMU_PPI exists, this driver still calls PEI service
to allocate DMA buffer, with assumption that DRAM==DMA.

This is a compatible change.

Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao 
---
 MdeModulePkg/Bus/Pci/XhciPei/DmaMem.c| 249 
 MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c  |  55 +++--
 MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.h  |   9 +-
 MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.c   |  55 -
 MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.h   | 107 +
 MdeModulePkg/Bus/Pci/XhciPei/XhciPei.inf |   3 +
 MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c |  47 +++-
 MdeModulePkg/Bus/Pci/XhciPei/XhciSched.h |   1 +
 8 files changed, 492 insertions(+), 34 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciPei/DmaMem.c 
b/MdeModulePkg/Bus/Pci/XhciPei/DmaMem.c
new file mode 100644
index 000..6e2c1b5
--- /dev/null
+++ b/MdeModulePkg/Bus/Pci/XhciPei/DmaMem.c
@@ -0,0 +1,249 @@
+/** @file
+The DMA memory help function.
+
+Copyright (c) 2017, Intel Corporation. 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 "XhcPeim.h"
+
+EDKII_IOMMU_PPI  *mIoMmu;
+
+/**
+  Provides the controller-specific addresses required to access system memory 
from a
+  DMA bus master.
+
+  @param  Operation Indicates if the bus master is going to read 
or write to system memory.
+  @param  HostAddress   The system memory address to map to the PCI 
controller.
+  @param  NumberOfBytes On input the number of bytes to map. On output 
the number of bytes
+that were mapped.
+  @param  DeviceAddress The resulting map address for the bus master 
PCI controller to use to
+access the hosts HostAddress.
+  @param  Mapping   A resulting value to pass to Unmap().
+
+  @retval EFI_SUCCESS   The range was mapped for the returned 
NumberOfBytes.
+  @retval EFI_UNSUPPORTED   The HostAddress cannot be mapped as a common 
buffer.
+  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a 
lack of resources.
+  @retval EFI_DEVICE_ERROR  The system hardware could not map the 
requested address.
+
+**/
+EFI_STATUS
+IoMmuMap (
+  IN  EDKII_IOMMU_OPERATION Operation,
+  IN VOID   *HostAddress,
+  IN  OUT UINTN *NumberOfBytes,
+  OUT EFI_PHYSICAL_ADDRESS  *DeviceAddress,
+  OUT VOID  **Mapping
+  )
+{
+  EFI_STATUS  Status;
+  UINT64  Attribute;
+
+  if (mIoMmu != NULL) {
+Status = mIoMmu->Map (
+   mIoMmu,
+   Operation,
+   HostAddress,
+   NumberOfBytes,
+   DeviceAddress,
+   Mapping
+   );
+if (EFI_ERROR (Status)) {
+  return EFI_OUT_OF_RESOURCES;
+}
+switch (Operation) {
+case EdkiiIoMmuOperationBusMasterRead:
+case EdkiiIoMmuOperationBusMasterRead64:
+  Attribute = EDKII_IOMMU_ACCESS_READ;
+  break;
+case EdkiiIoMmuOperationBusMasterWrite:
+case EdkiiIoMmuOperationBusMasterWrite64:
+  Attribute = EDKII_IOMMU_ACCESS_WRITE;
+  break;
+case EdkiiIoMmuOperationBusMasterCommonBuffer:
+case EdkiiIoMmuOperationBusMasterCommonBuffer64:
+  Attribute = EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE;
+  break;
+default:
+  ASSERT(FALSE);
+  return EFI_INVALID_PARAMETER;
+}
+Status = mIoMmu->SetAttribute (
+   mIoMmu,
+   *Mapping,
+   Attribute
+   );
+if (EFI_ERROR (Status)) {
+  return Status;
+}
+  } else {
+*DeviceAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress;
+*Mapping = NULL;
+Status = EFI_SUCCESS;
+  }
+  return Status;
+}
+
+/**
+  Completes the Map() operation and releases any corresponding resources.
+
+  @param  Mapping   The mapping value returned from Map().
+
+  @retval EFI_SUCCESS   The range was unmapped.
+  @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by 
Map().
+  @retval EFI_DEVICE_ERROR  The data was not committed to the target 
system memory.
+**/
+EFI_STATUS
+IoMmuUnmap (
+  IN VOID  *Mapping
+  )
+{
+  EFI_STATUS  Status;
+
+  if (mIoMmu != NULL) {
+Status = mIoMmu->SetAttribute (mIoMmu, Mapping, 0);
+

[edk2] [PATCH 04/11] IntelSiliconPkg/VTdDxe: Disable PMR

2017-09-08 Thread Jiewen Yao
When VTd translation is enabled, PMR can be disable.
Or the DMA will be blocked by PMR.

Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao 
---
 IntelSiliconPkg/IntelVTdDxe/VtdReg.c | 51 +++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/IntelSiliconPkg/IntelVTdDxe/VtdReg.c 
b/IntelSiliconPkg/IntelVTdDxe/VtdReg.c
index 7402d81..1404af7 100644
--- a/IntelSiliconPkg/IntelVTdDxe/VtdReg.c
+++ b/IntelSiliconPkg/IntelVTdDxe/VtdReg.c
@@ -196,6 +196,39 @@ PrepareVtdConfig (
 }
 
 /**
+  Disable PMR in all VTd engine.
+**/
+VOID
+DisablePmr (
+  VOID
+  )
+{
+  UINT32Reg32;
+  VTD_CAP_REG   CapReg;
+  UINTN Index;
+
+  DEBUG ((DEBUG_INFO,"DisablePmr\n"));
+  for (Index = 0; Index < mVtdUnitNumber; Index++) {
+CapReg.Uint64 = MmioRead64 (mVtdUnitInformation[Index].VtdUnitBaseAddress 
+ R_CAP_REG);
+if (CapReg.Bits.PLMR == 0 || CapReg.Bits.PHMR == 0) {
+  continue ;
+}
+
+Reg32 = MmioRead32 (mVtdUnitInformation[Index].VtdUnitBaseAddress + 
R_PMEN_ENABLE_REG);
+if ((Reg32 & BIT0) != 0) {
+  MmioWrite32 (mVtdUnitInformation[Index].VtdUnitBaseAddress + 
R_PMEN_ENABLE_REG, 0x0);
+  do {
+Reg32 = MmioRead32 (mVtdUnitInformation[Index].VtdUnitBaseAddress + 
R_PMEN_ENABLE_REG);
+  } while((Reg32 & BIT0) != 0);
+  DEBUG ((DEBUG_INFO,"Pmr(%d) disabled\n", Index));
+} else {
+  DEBUG ((DEBUG_INFO,"Pmr(%d) not enabled\n", Index));
+}
+  }
+  return ;
+}
+
+/**
   Enable DMAR translation.
 
   @retval EFI_SUCCESS   DMAR translation is enabled.
@@ -259,6 +292,11 @@ EnableDmar (
 DEBUG ((DEBUG_INFO,"VTD (%d) enabled!<<\n",Index));
   }
 
+  //
+  // Need disable PMR, since we already setup translation table.
+  //
+  DisablePmr ();
+
   mVtdEnabled = TRUE;
 
   return EFI_SUCCESS;
@@ -502,7 +540,7 @@ DumpVtdIfError (
 for (Index = 0; Index < (UINTN)CapReg.Bits.NFR + 1; Index++) {
   FrcdReg.Uint64[0] = MmioRead64 
(mVtdUnitInformation[Num].VtdUnitBaseAddress + ((CapReg.Bits.FRO * 16) + (Index 
* 16) + R_FRCD_REG));
   FrcdReg.Uint64[1] = MmioRead64 
(mVtdUnitInformation[Num].VtdUnitBaseAddress + ((CapReg.Bits.FRO * 16) + (Index 
* 16) + R_FRCD_REG + sizeof(UINT64)));
-  if ((FrcdReg.Uint64[0] != 0) || (FrcdReg.Uint64[1] != 0)) {
+  if (FrcdReg.Bits.F != 0) {
 HasError = TRUE;
   }
 }
@@ -511,6 +549,17 @@ DumpVtdIfError (
   DEBUG((DEBUG_INFO, "\n ERROR \n"));
   DumpVtdRegs (Num);
   DEBUG((DEBUG_INFO, " ERROR \n\n"));
+  //
+  // Clear
+  //
+  for (Index = 0; Index < (UINTN)CapReg.Bits.NFR + 1; Index++) {
+FrcdReg.Uint64[1] = MmioRead64 
(mVtdUnitInformation[Num].VtdUnitBaseAddress + ((CapReg.Bits.FRO * 16) + (Index 
* 16) + R_FRCD_REG + sizeof(UINT64)));
+if (FrcdReg.Bits.F != 0) {
+  FrcdReg.Bits.F = 0;
+  MmioWrite64 (mVtdUnitInformation[Num].VtdUnitBaseAddress + 
((CapReg.Bits.FRO * 16) + (Index * 16) + R_FRCD_REG + sizeof(UINT64)), 
FrcdReg.Uint64[1]);
+}
+MmioWrite32 (mVtdUnitInformation[Num].VtdUnitBaseAddress + R_FSTS_REG, 
MmioRead32 (mVtdUnitInformation[Num].VtdUnitBaseAddress + R_FSTS_REG));
+  }
 }
   }
 }
-- 
2.7.4.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 05/11] IntelSiliconPkg/include: Add VTD_INFO PPI.

2017-09-08 Thread Jiewen Yao
This VTD_INFO_PPI is to provide VTD information in PEI.
As such, we can have a generic VTd driver.

It is a lightweight version DMAR table, but it does
not contain PCI device information.

Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao 
---
 IntelSiliconPkg/Include/Ppi/VtdInfo.h | 40 
 1 file changed, 40 insertions(+)

diff --git a/IntelSiliconPkg/Include/Ppi/VtdInfo.h 
b/IntelSiliconPkg/Include/Ppi/VtdInfo.h
new file mode 100644
index 000..e8be63f
--- /dev/null
+++ b/IntelSiliconPkg/Include/Ppi/VtdInfo.h
@@ -0,0 +1,40 @@
+/** @file
+  The definition for VTD information PPI.
+
+  This is a lightweight VTd information report in PEI phase.
+
+  Copyright (c) 2017, Intel Corporation. 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 __VTD_INFO_PPI_H__
+#define __VTD_INFO_PPI_H__
+
+#define EDKII_VTD_INFO_PPI_GUID \
+{ \
+  0x8a59fcb3, 0xf191, 0x400c, { 0x97, 0x67, 0x67, 0xaf, 0x2b, 0x25, 0x68, 
0x4a } \
+}
+
+typedef struct _EDKII_VTD_INFO_PPI  EDKII_VTD_INFO_PPI;
+
+#define EDKII_VTD_INFO_PPI_REVISION 0x0001
+
+struct _EDKII_VTD_INFO_PPI {
+  UINT64  Revision;
+  UINT8   HostAddressWidth;
+  UINT8   Reserved[3];
+  UINT32  VTdEngineCount;
+  UINT64  VTdEngineAddress[1];
+};
+
+extern EFI_GUID gEdkiiVTdInfoPpiGuid;
+
+#endif
+
-- 
2.7.4.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 06/11] IntelSiliconPkg/dec: Add VTD_INFO PPI GUID

2017-09-08 Thread Jiewen Yao
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao 
---
 IntelSiliconPkg/IntelSiliconPkg.dec | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/IntelSiliconPkg/IntelSiliconPkg.dec 
b/IntelSiliconPkg/IntelSiliconPkg.dec
index 2fc6379..941380a 100644
--- a/IntelSiliconPkg/IntelSiliconPkg.dec
+++ b/IntelSiliconPkg/IntelSiliconPkg.dec
@@ -33,6 +33,9 @@
   # Generic DXE Library / Driver can locate HOB(s) and add SMBIOS records into 
SMBIOS table
   gIntelSmbiosDataHobGuid = { 0x798e722e, 0x15b2, 0x4e13, { 0x8a, 
0xe9, 0x6b, 0xa3, 0x0f, 0xf7, 0xf1, 0x67 }}
 
+[Ppis]
+  gEdkiiVTdInfoPpiGuid = { 0x8a59fcb3, 0xf191, 0x400c, { 0x97, 0x67, 0x67, 
0xaf, 0x2b, 0x25, 0x68, 0x4a } }
+
 [Protocols]
   gEdkiiPlatformVTdPolicyProtocolGuid = { 0x3d17e448, 0x466, 0x4e20, { 0x99, 
0x9f, 0xb2, 0xe1, 0x34, 0x88, 0xee, 0x22 }}
 
-- 
2.7.4.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 10/11] IntelSiliconPkg/dsc: Add PlatformVTdInfoSamplePei.

2017-09-08 Thread Jiewen Yao
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao 
---
 IntelSiliconPkg/IntelSiliconPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/IntelSiliconPkg/IntelSiliconPkg.dsc 
b/IntelSiliconPkg/IntelSiliconPkg.dsc
index 33e822f..422e202 100644
--- a/IntelSiliconPkg/IntelSiliconPkg.dsc
+++ b/IntelSiliconPkg/IntelSiliconPkg.dsc
@@ -82,6 +82,7 @@
   IntelSiliconPkg/IntelVTdDxe/IntelVTdDxe.inf
   IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.inf
   IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.inf
+  IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.inf
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
-- 
2.7.4.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 03/11] IntelSiliconPkg/Vtd.h: Add definition for PMR.

2017-09-08 Thread Jiewen Yao
Add missing PMR definition in VTd spec.

Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao 
---
 IntelSiliconPkg/Include/IndustryStandard/Vtd.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/IntelSiliconPkg/Include/IndustryStandard/Vtd.h 
b/IntelSiliconPkg/Include/IndustryStandard/Vtd.h
index 3b7012c..cfead61 100644
--- a/IntelSiliconPkg/Include/IndustryStandard/Vtd.h
+++ b/IntelSiliconPkg/Include/IndustryStandard/Vtd.h
@@ -247,6 +247,12 @@ typedef union {
 
 #define R_FRCD_REG   0x00 // + FRO
 
+#define R_PMEN_ENABLE_REG 0x64
+#define R_PMEN_LOW_BASE_REG   0x68
+#define R_PMEN_LOW_LIMITE_REG 0x6C
+#define R_PMEN_HIGH_BASE_REG  0x70
+#define R_PMEN_HIGH_LIMITE_REG0x78
+
 typedef union {
   struct {
 UINT8 ND:3; // Number of domains supported
-- 
2.7.4.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 01/11] MdeModulePkg/Include: Add IOMMU_PPI.

2017-09-08 Thread Jiewen Yao
This IOMMU_PPI is to provide IOMMU abstraction in PEI.

Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao 
---
 MdeModulePkg/Include/Ppi/IoMmu.h | 196 
 1 file changed, 196 insertions(+)

diff --git a/MdeModulePkg/Include/Ppi/IoMmu.h b/MdeModulePkg/Include/Ppi/IoMmu.h
new file mode 100644
index 000..5303d68
--- /dev/null
+++ b/MdeModulePkg/Include/Ppi/IoMmu.h
@@ -0,0 +1,196 @@
+/** @file
+  PEI IOMMU PPI.
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available 
under
+the terms and conditions of the BSD License that 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 __PEI_IOMMU_H__
+#define __PEI_IOMMU_H__
+
+//
+// for EFI_ALLOCATE_TYPE
+//
+#include 
+
+//
+// Include protocol for common definition
+//   EDKII_IOMMU_ACCESS_xxx
+//   EDKII_IOMMU_OPERATION
+//
+#include 
+
+//
+// IOMMU Ppi GUID value
+//
+#define EDKII_IOMMU_PPI_GUID \
+{ \
+  0x70b0af26, 0xf847, 0x4bb6, { 0xaa, 0xb9, 0xcd, 0xe8, 0x4f, 0xc6, 0x14, 
0x31 } \
+}
+
+//
+// Forward reference for pure ANSI compatability
+//
+typedef struct _EDKII_IOMMU_PPI  EDKII_IOMMU_PPI;
+
+//
+// Revision The revision to which the IOMMU interface adheres.
+//  All future revisions must be backwards compatible.
+//  If a future version is not back wards compatible it is not the 
same GUID.
+//
+#define EDKII_IOMMU_PPI_REVISION 0x0001
+
+/**
+  Set IOMMU attribute for a system memory.
+
+  If the IOMMU PPI exists, the system memory cannot be used
+  for DMA by default.
+
+  When a device requests a DMA access for a system memory,
+  the device driver need use SetAttribute() to update the IOMMU
+  attribute to request DMA access (read and/or write).
+
+  @param[in]  This  The PPI instance pointer.
+  @param[in]  Mapping   The mapping value returned from Map().
+  @param[in]  IoMmuAccess   The IOMMU access.
+
+  @retval EFI_SUCCESSThe IoMmuAccess is set for the memory range 
specified by DeviceAddress and Length.
+  @retval EFI_INVALID_PARAMETER  Mapping is not a value that was returned by 
Map().
+  @retval EFI_INVALID_PARAMETER  IoMmuAccess specified an illegal combination 
of access.
+  @retval EFI_UNSUPPORTEDThe bit mask of IoMmuAccess is not supported 
by the IOMMU.
+  @retval EFI_UNSUPPORTEDThe IOMMU does not support the memory range 
specified by Mapping.
+  @retval EFI_OUT_OF_RESOURCES   There are not enough resources available to 
modify the IOMMU access.
+  @retval EFI_DEVICE_ERROR   The IOMMU device reported an error while 
attempting the operation.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_PEI_IOMMU_SET_ATTRIBUTE)(
+  IN EDKII_IOMMU_PPI   *This,
+  IN VOID  *Mapping,
+  IN UINT64IoMmuAccess
+  );
+
+/**
+  Provides the controller-specific addresses required to access system memory 
from a
+  DMA bus master.
+
+  @param  This  The PPI instance pointer.
+  @param  Operation Indicates if the bus master is going to read 
or write to system memory.
+  @param  HostAddress   The system memory address to map to the PCI 
controller.
+  @param  NumberOfBytes On input the number of bytes to map. On output 
the number of bytes
+that were mapped.
+  @param  DeviceAddress The resulting map address for the bus master 
PCI controller to use to
+access the hosts HostAddress.
+  @param  Mapping   A resulting value to pass to Unmap().
+
+  @retval EFI_SUCCESS   The range was mapped for the returned 
NumberOfBytes.
+  @retval EFI_UNSUPPORTED   The HostAddress cannot be mapped as a common 
buffer.
+  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a 
lack of resources.
+  @retval EFI_DEVICE_ERROR  The system hardware could not map the 
requested address.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_PEI_IOMMU_MAP)(
+  IN EDKII_IOMMU_PPI*This,
+  IN EDKII_IOMMU_OPERATION  Operation,
+  IN VOID   *HostAddress,
+  IN OUT UINTN  *NumberOfBytes,
+  OUTEFI_PHYSICAL_ADDRESS   *DeviceAddress,
+  OUTVOID   **Mapping
+  );
+
+/**
+  Completes the Map() operation and releases any corresponding resources.
+
+  @param  This  The PPI instance pointer.
+  @param  Mapping   

[edk2] [PATCH 08/11] IntelSiliconPkg/dsc: Add IntelVTdPmrPeim.

2017-09-08 Thread Jiewen Yao
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao 
---
 IntelSiliconPkg/IntelSiliconPkg.dsc | 9 +
 1 file changed, 9 insertions(+)

diff --git a/IntelSiliconPkg/IntelSiliconPkg.dsc 
b/IntelSiliconPkg/IntelSiliconPkg.dsc
index 9a9920f..33e822f 100644
--- a/IntelSiliconPkg/IntelSiliconPkg.dsc
+++ b/IntelSiliconPkg/IntelSiliconPkg.dsc
@@ -40,6 +40,14 @@
   SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
   
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
 
+[LibraryClasses.common.PEIM]
+  PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
+  
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
+
+  
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+
 [LibraryClasses.common.DXE_DRIVER]
   
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
   
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
@@ -72,6 +80,7 @@
 [Components]
   IntelSiliconPkg/Library/DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.inf
   IntelSiliconPkg/IntelVTdDxe/IntelVTdDxe.inf
+  IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.inf
   IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.inf
 
 [BuildOptions]
-- 
2.7.4.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v6 0/6] read-only UDF file system support

2017-09-08 Thread Paulo Alcantara

Hi,

On 08/09/2017 10:25, Laszlo Ersek wrote:

Ray,

On 09/08/17 14:41, Paulo Alcantara wrote:


v6:
  - Fixed a bug in UdfRead() that'd pontentially break in ARM or IA32
by allowing caller to read more than 4GiB of data
(i.e. BufferSize pointer is dereferenced as an UINT64 * and it's
 followed by 4 bytes that are nonzero).

Repo:   https://github.com/pcacjr/edk2.git
Branch: udf-fs-v6


The v5-v6 diff is as follows:


diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c 
b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
index 2dbcff0be4a3..8b9339567f8e 100644
--- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
+++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
@@ -325,8 +325,9 @@ UdfRead (
UDF_FILE_IDENTIFIER_DESCRIPTOR  *NewFileIdentifierDesc;
VOID*NewFileEntryData;
CHAR16  FileName[UDF_FILENAME_LENGTH] = { 0 };
UINT64  FileSize;
+  UINT64  BufferSizeUint64;

OldTpl = gBS->RaiseTPL (TPL_CALLBACK);

if (This == NULL || BufferSize == NULL || (*BufferSize != 0 &&
@@ -363,18 +364,22 @@ UdfRead (
Status = EFI_SUCCESS;
goto Done;
  }

+BufferSizeUint64 = *BufferSize;
+
  Status = ReadFileData (
BlockIo,
DiskIo,
Volume,
Parent,
PrivFileData->FileSize,
>FilePosition,
Buffer,
-  (UINT64 *)(UINTN)BufferSize
+  
);
+ASSERT (BufferSizeUint64 <= MAX_UINTN);
+*BufferSize = (UINTN)BufferSizeUint64;
} else if (IS_FID_DIRECTORY_FILE (Parent->FileIdentifierDesc)) {
  if (ReadDirInfo->FidOffset == 0 && PrivFileData->FilePosition > 0) {
Status = EFI_DEVICE_ERROR;
*BufferSize = 0;


It looks OK to me, and it builds fine for IA32, X64, ARM and AARCH64:

   Build/ArmVirtQemu-AARCH64/DEBUG_GCC5/AARCH64/UdfDxe.efi
   Build/ArmVirtQemu-ARM/DEBUG_GCC5/ARM/UdfDxe.efi
   Build/OvmfIa32/NOOPT_GCC48/IA32/UdfDxe.efi
   Build/OvmfX64/NOOPT_GCC48/X64/UdfDxe.efi

Green light from your side?


Yes - at least from what I've been testing :-)



Paulo: you forgot to pick up Ray's R-b for patches #4 and #5, from his
v5 response
<734D49CCEBEEF84792F5B80ED585239D5BA282B7@SHSMSX104.ccr.corp.intel.com">http://mid.mail-archive.com/734D49CCEBEEF84792F5B80ED585239D5BA282B7@SHSMSX104.ccr.corp.intel.com>
-- it was for the entire series.


D'oh - I only considered the Mde*Pkg and Nt32Pkg R-b's. Sorry.


But, I'll apply that for you.


Thank you very much!

Paulo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v6 0/6] read-only UDF file system support

2017-09-08 Thread Laszlo Ersek
Ray,

On 09/08/17 14:41, Paulo Alcantara wrote:

> v6:
>  - Fixed a bug in UdfRead() that'd pontentially break in ARM or IA32
>by allowing caller to read more than 4GiB of data
>(i.e. BufferSize pointer is dereferenced as an UINT64 * and it's
> followed by 4 bytes that are nonzero).
>
> Repo:   https://github.com/pcacjr/edk2.git
> Branch: udf-fs-v6

The v5-v6 diff is as follows:

> diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c 
> b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> index 2dbcff0be4a3..8b9339567f8e 100644
> --- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> +++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> @@ -325,8 +325,9 @@ UdfRead (
>UDF_FILE_IDENTIFIER_DESCRIPTOR  *NewFileIdentifierDesc;
>VOID*NewFileEntryData;
>CHAR16  FileName[UDF_FILENAME_LENGTH] = { 0 };
>UINT64  FileSize;
> +  UINT64  BufferSizeUint64;
>
>OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
>
>if (This == NULL || BufferSize == NULL || (*BufferSize != 0 &&
> @@ -363,18 +364,22 @@ UdfRead (
>Status = EFI_SUCCESS;
>goto Done;
>  }
>
> +BufferSizeUint64 = *BufferSize;
> +
>  Status = ReadFileData (
>BlockIo,
>DiskIo,
>Volume,
>Parent,
>PrivFileData->FileSize,
>>FilePosition,
>Buffer,
> -  (UINT64 *)(UINTN)BufferSize
> +  
>);
> +ASSERT (BufferSizeUint64 <= MAX_UINTN);
> +*BufferSize = (UINTN)BufferSizeUint64;
>} else if (IS_FID_DIRECTORY_FILE (Parent->FileIdentifierDesc)) {
>  if (ReadDirInfo->FidOffset == 0 && PrivFileData->FilePosition > 0) {
>Status = EFI_DEVICE_ERROR;
>*BufferSize = 0;

It looks OK to me, and it builds fine for IA32, X64, ARM and AARCH64:

  Build/ArmVirtQemu-AARCH64/DEBUG_GCC5/AARCH64/UdfDxe.efi
  Build/ArmVirtQemu-ARM/DEBUG_GCC5/ARM/UdfDxe.efi
  Build/OvmfIa32/NOOPT_GCC48/IA32/UdfDxe.efi
  Build/OvmfX64/NOOPT_GCC48/X64/UdfDxe.efi

Green light from your side?

Paulo: you forgot to pick up Ray's R-b for patches #4 and #5, from his
v5 response
<734D49CCEBEEF84792F5B80ED585239D5BA282B7@SHSMSX104.ccr.corp.intel.com">http://mid.mail-archive.com/734D49CCEBEEF84792F5B80ED585239D5BA282B7@SHSMSX104.ccr.corp.intel.com>
-- it was for the entire series.

But, I'll apply that for you.

Thanks,
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v6 5/6] ArmVirtPkg: Enable UDF file system support

2017-09-08 Thread Paulo Alcantara
This patch enables UDF file system support by default.

Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Paulo Alcantara 
Reviewed-by: Ard Biesheuvel 
Reviewed-by: Laszlo Ersek 
---
 ArmVirtPkg/ArmVirtQemu.dsc   | 3 ++-
 ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 3 ++-
 ArmVirtPkg/ArmVirtQemuKernel.dsc | 3 ++-
 ArmVirtPkg/ArmVirtXen.dsc| 3 ++-
 ArmVirtPkg/ArmVirtXen.fdf| 1 +
 5 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 2e6e762249..609697f293 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -300,12 +300,13 @@
   OvmfPkg/VirtioRngDxe/VirtioRng.inf
 
   #
-  # FAT filesystem + GPT/MBR partitioning
+  # FAT filesystem + GPT/MBR partitioning + UDF filesystem
   #
   MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
   MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
   MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
   FatPkg/EnhancedFatDxe/Fat.inf
+  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
 
   #
   # Bds
diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc 
b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
index 3194aa3edc..e54eeea41e 100644
--- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
+++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
@@ -83,12 +83,13 @@ READ_LOCK_STATUS   = TRUE
   INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
 
   #
-  # FAT filesystem + GPT/MBR partitioning
+  # FAT filesystem + GPT/MBR partitioning + UDF filesystem
   #
   INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
   INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
   INF FatPkg/EnhancedFatDxe/Fat.inf
   INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
+  INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
 
   #
   # Platform Driver
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index 69de887277..cb3704727b 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -291,12 +291,13 @@
   OvmfPkg/VirtioRngDxe/VirtioRng.inf
 
   #
-  # FAT filesystem + GPT/MBR partitioning
+  # FAT filesystem + GPT/MBR partitioning + UDF filesystem
   #
   MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
   MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
   MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
   FatPkg/EnhancedFatDxe/Fat.inf
+  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
 
   #
   # Bds
diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc
index eb37137f27..e9437066ca 100644
--- a/ArmVirtPkg/ArmVirtXen.dsc
+++ b/ArmVirtPkg/ArmVirtXen.dsc
@@ -191,12 +191,13 @@
   ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf
 
   #
-  # FAT filesystem + GPT/MBR partitioning
+  # FAT filesystem + GPT/MBR partitioning + UDF filesystem
   #
   MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
   MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
   MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
   FatPkg/EnhancedFatDxe/Fat.inf
+  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
 
   #
   # Bds
diff --git a/ArmVirtPkg/ArmVirtXen.fdf b/ArmVirtPkg/ArmVirtXen.fdf
index 67fde73e69..70e76df228 100644
--- a/ArmVirtPkg/ArmVirtXen.fdf
+++ b/ArmVirtPkg/ArmVirtXen.fdf
@@ -163,6 +163,7 @@ READ_LOCK_STATUS   = TRUE
   INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
   INF FatPkg/EnhancedFatDxe/Fat.inf
   INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
+  INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
 
   #
   # UEFI application (Shell Embedded Boot Loader)
-- 
2.11.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v6 6/6] Nt32Pkg: Enable UDF file system support

2017-09-08 Thread Paulo Alcantara
This patch enables UDF file system support by default.

Cc: Ruiyu Ni 
Cc: Hao Wu 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Paulo Alcantara 
Reviewed-by: Ruiyu Ni 
---
 Nt32Pkg/Nt32Pkg.dsc | 1 +
 Nt32Pkg/Nt32Pkg.fdf | 1 +
 2 files changed, 2 insertions(+)

diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc
index 847411cde9..fcd833858d 100644
--- a/Nt32Pkg/Nt32Pkg.dsc
+++ b/Nt32Pkg/Nt32Pkg.dsc
@@ -440,6 +440,7 @@
   MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
   MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
   FatPkg/EnhancedFatDxe/Fat.inf
+  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
   MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
   MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf ##This driver follows 
UEFI specification definition
   MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf##This driver follows 
UEFI specification definition
diff --git a/Nt32Pkg/Nt32Pkg.fdf b/Nt32Pkg/Nt32Pkg.fdf
index e03999b0cb..d104cb7645 100644
--- a/Nt32Pkg/Nt32Pkg.fdf
+++ b/Nt32Pkg/Nt32Pkg.fdf
@@ -295,6 +295,7 @@ INF  EdkShellBinPkg/FullShell/FullShell.inf
 !endif
 
 INF FatPkg/EnhancedFatDxe/Fat.inf
+INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
 
 INF MdeModulePkg/Logo/LogoDxe.inf
 INF MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.inf
-- 
2.11.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v6 4/6] OvmfPkg: Enable UDF file system support

2017-09-08 Thread Paulo Alcantara
This patch enables UDF file system support by default.

Cc: Jordan Justen 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Paulo Alcantara 
Reviewed-by: Laszlo Ersek 
---
 OvmfPkg/OvmfPkgIa32.dsc| 1 +
 OvmfPkg/OvmfPkgIa32.fdf| 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
 OvmfPkg/OvmfPkgIa32X64.fdf | 1 +
 OvmfPkg/OvmfPkgX64.dsc | 1 +
 OvmfPkg/OvmfPkgX64.fdf | 1 +
 6 files changed, 6 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 5a14325f73..92e943d4a0 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -685,6 +685,7 @@
   MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
   MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
   FatPkg/EnhancedFatDxe/Fat.inf
+  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
   MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
   MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
   OvmfPkg/SataControllerDxe/SataControllerDxe.inf
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 5e5ade2a1f..7515224118 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -282,6 +282,7 @@ INF  
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
 INF  
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
 
 INF  FatPkg/EnhancedFatDxe/Fat.inf
+INF  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
 
 !ifndef $(USE_OLD_SHELL)
 INF  ShellPkg/Application/Shell/Shell.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 2f17a70db8..7f9220ccb9 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -694,6 +694,7 @@
   MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
   MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
   FatPkg/EnhancedFatDxe/Fat.inf
+  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
   MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
   MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
   OvmfPkg/SataControllerDxe/SataControllerDxe.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index aa0d8c69f3..f1a2044fb7 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -283,6 +283,7 @@ INF  
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
 INF  
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
 
 INF  FatPkg/EnhancedFatDxe/Fat.inf
+INF  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
 
 !ifndef $(USE_OLD_SHELL)
 INF  ShellPkg/Application/Shell/Shell.inf
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index c0bd5d0ea6..36c60fc19c 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -692,6 +692,7 @@
   MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
   MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
   FatPkg/EnhancedFatDxe/Fat.inf
+  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
   MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
   MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
   OvmfPkg/SataControllerDxe/SataControllerDxe.inf
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 98a0cf17da..32000a3b93 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -283,6 +283,7 @@ INF  
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
 INF  
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
 
 INF  FatPkg/EnhancedFatDxe/Fat.inf
+INF  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
 
 !ifndef $(USE_OLD_SHELL)
 INF  ShellPkg/Application/Shell/Shell.inf
-- 
2.11.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v6 1/6] MdePkg: Add UDF volume structure definitions

2017-09-08 Thread Paulo Alcantara
This patch adds basic volume structure definitions necessary to identify
a valid UDF file system on a block device, as specified by OSTA
Universal Disk Format Specification 2.60.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Paulo Alcantara 
Reviewed-by: Ruiyu Ni 
---
 MdePkg/Include/IndustryStandard/Udf.h | 60 +++
 1 file changed, 60 insertions(+)
 create mode 100644 MdePkg/Include/IndustryStandard/Udf.h

diff --git a/MdePkg/Include/IndustryStandard/Udf.h 
b/MdePkg/Include/IndustryStandard/Udf.h
new file mode 100644
index 00..0febb4bcda
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/Udf.h
@@ -0,0 +1,60 @@
+/** @file
+  OSTA Universal Disk Format (UDF) definitions.
+
+  Copyright (C) 2014-2017 Paulo Alcantara 
+
+  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 __UDF_H__
+#define __UDF_H__
+
+#define UDF_BEA_IDENTIFIER   "BEA01"
+#define UDF_NSR2_IDENTIFIER  "NSR02"
+#define UDF_NSR3_IDENTIFIER  "NSR03"
+#define UDF_TEA_IDENTIFIER   "TEA01"
+
+#define UDF_LOGICAL_SECTOR_SHIFT  11
+#define UDF_LOGICAL_SECTOR_SIZE   ((UINT64)(1ULL << UDF_LOGICAL_SECTOR_SHIFT))
+#define UDF_VRS_START_OFFSET  ((UINT64)(16ULL << UDF_LOGICAL_SECTOR_SHIFT))
+
+#define _GET_TAG_ID(_Pointer) \
+  (((UDF_DESCRIPTOR_TAG *)(_Pointer))->TagIdentifier)
+
+#define IS_AVDP(_Pointer) \
+  ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 2))
+
+#pragma pack(1)
+
+typedef struct {
+  UINT16  TagIdentifier;
+  UINT16  DescriptorVersion;
+  UINT8   TagChecksum;
+  UINT8   Reserved;
+  UINT16  TagSerialNumber;
+  UINT16  DescriptorCRC;
+  UINT16  DescriptorCRCLength;
+  UINT32  TagLocation;
+} UDF_DESCRIPTOR_TAG;
+
+typedef struct {
+  UINT32  ExtentLength;
+  UINT32  ExtentLocation;
+} UDF_EXTENT_AD;
+
+typedef struct {
+  UDF_DESCRIPTOR_TAG  DescriptorTag;
+  UDF_EXTENT_AD   MainVolumeDescriptorSequenceExtent;
+  UDF_EXTENT_AD   ReserveVolumeDescriptorSequenceExtent;
+  UINT8   Reserved[480];
+} UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER;
+
+#pragma pack()
+
+#endif
-- 
2.11.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v6 0/6] read-only UDF file system support

2017-09-08 Thread Paulo Alcantara
Hi,

This series introduces read-only UDF file system support in EDK2. As
Laszlo (or Red Hat) seemed to be interested in such support, I'm posting
it again after ~3 years.

The idea is not replacing the default FAT file system, nor breaking any
existing file system support, but extending EDK2 with a new file system
that might be useful for some people who are looking for specific file
system features that current FAT doesn't support.

Originally the driver was written to support UDF file systems as
specified by OSTA Universal Disk Format Specification 2.60. However,
some Windows 10 Enterprise ISO (UDF bridge) images that I tested
supported a revision of 1.02 thus I had to rework the driver a little
bit to support such revision as well.

v2:
 - Rework to _partially_ support UDF revisions <2.60.
 - Use existing CDROM_VOLUME_DESCRIPTOR structure defined in Eltorito.h
   instead of creating another one (UDF_VOLUME_DESCRIPTOR).
 - Fixed UdfDxe to correctly follow UEFI driver model.
 - Use HARDDRIVE_DEVICE_PATH instead of a vendor-defined one.
 - Detect UDF file systems only in PartitionDxe, and let UdfDxe driver
   check for specific UDF device path to decide whether or not install
   SimpleFs protocol.
 - Place MdePkg changes in a separate patch.
v3:
 - Install UDF partition child handles with a Vendor-Defined Media
   Device Path.
 - Changed UdfDxe to check for Vendor-Defined Media Device Paths with a
   specific UDF file system GUID when determining to whether or not
   start the driver.
 - Removed leading TAB chars in some source files identified by
   PatchCheck.py tool.
v4:
 - Added missing R-b's.
v5:
 - Fixed OVMF IA32 build.
 - Fixed a typo in UdfDriveBindingStop() ("This" -> "SimpleFs") which
   broke retrieval of private fs data from SimpleFs protocol --
   identified by 'reconnect -r' command in UEFI shell.
v6:
 - Fixed a bug in UdfRead() that'd pontentially break in ARM or IA32
   by allowing caller to read more than 4GiB of data
   (i.e. BufferSize pointer is dereferenced as an UINT64 * and it's
followed by 4 bytes that are nonzero).

Repo:   https://github.com/pcacjr/edk2.git
Branch: udf-fs-v6

Cc: Laszlo Ersek 
Cc: Jordan Justen 
Cc: Andrew Fish 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Star Zeng 
Cc: Eric Dong 
Cc: Mark Doran 
Cc: Ruiyu Ni 
Cc: hao.a...@intel.com
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Paulo Alcantara 
---

Paulo Alcantara (6):
  MdePkg: Add UDF volume structure definitions
  MdeModulePkg/PartitionDxe: Add UDF file system support
  MdeModulePkg: Initial UDF/ECMA-167 file system support
  OvmfPkg: Enable UDF file system support
  ArmVirtPkg: Enable UDF file system support
  Nt32Pkg: Enable UDF file system support

 ArmVirtPkg/ArmVirtQemu.dsc |3 +-
 ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc   |3 +-
 ArmVirtPkg/ArmVirtQemuKernel.dsc   |3 +-
 ArmVirtPkg/ArmVirtXen.dsc  |3 +-
 ArmVirtPkg/ArmVirtXen.fdf  |1 +
 .../Universal/Disk/PartitionDxe/Partition.c|9 +-
 .../Universal/Disk/PartitionDxe/Partition.h|   32 +-
 .../Universal/Disk/PartitionDxe/PartitionDxe.inf   |3 +-
 MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c |  318 +++
 MdeModulePkg/Universal/Disk/UdfDxe/ComponentName.c |  185 ++
 MdeModulePkg/Universal/Disk/UdfDxe/File.c  |  908 
 MdeModulePkg/Universal/Disk/UdfDxe/FileName.c  |  195 ++
 .../Universal/Disk/UdfDxe/FileSystemOperations.c   | 2447 
 MdeModulePkg/Universal/Disk/UdfDxe/Udf.c   |  344 +++
 MdeModulePkg/Universal/Disk/UdfDxe/Udf.h   | 1244 ++
 MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf  |   66 +
 MdePkg/Include/IndustryStandard/Udf.h  |   60 +
 Nt32Pkg/Nt32Pkg.dsc|1 +
 Nt32Pkg/Nt32Pkg.fdf|1 +
 OvmfPkg/OvmfPkgIa32.dsc|1 +
 OvmfPkg/OvmfPkgIa32.fdf|1 +
 OvmfPkg/OvmfPkgIa32X64.dsc |1 +
 OvmfPkg/OvmfPkgIa32X64.fdf |1 +
 OvmfPkg/OvmfPkgX64.dsc |1 +
 OvmfPkg/OvmfPkgX64.fdf |1 +
 25 files changed, 5821 insertions(+), 11 deletions(-)
 create mode 100644 MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c
 create mode 100644 MdeModulePkg/Universal/Disk/UdfDxe/ComponentName.c
 create mode 100644 MdeModulePkg/Universal/Disk/UdfDxe/File.c
 create mode 100644 MdeModulePkg/Universal/Disk/UdfDxe/FileName.c
 create mode 100644 MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c
 create mode 100644 MdeModulePkg/Universal/Disk/UdfDxe/Udf.c
 create mode 100644 

[edk2] [PATCH v6 2/6] MdeModulePkg/PartitionDxe: Add UDF file system support

2017-09-08 Thread Paulo Alcantara
Scan for UDF file systems on all block devices, as specified by OSTA
Universal Disk Format Specification 2.60, and install a Vendor-Defined
Media Device Path for each file system found.

The Vendor-Defined Media Device Path for the UDF file system is then
checked by UdfDxe to decide whether or not start the driver.

Cc: Star Zeng 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Paulo Alcantara 
Reviewed-by: Ruiyu Ni 
---
 .../Universal/Disk/PartitionDxe/Partition.c|   9 +-
 .../Universal/Disk/PartitionDxe/Partition.h|  32 ++-
 .../Universal/Disk/PartitionDxe/PartitionDxe.inf   |   3 +-
 MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c | 318 +
 4 files changed, 355 insertions(+), 7 deletions(-)
 create mode 100644 MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c

diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c 
b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
index 5a7d119b43..f6030e0897 100644
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
@@ -1,7 +1,7 @@
 /** @file
   Partition driver that produces logical BlockIo devices from a physical
   BlockIo device. The logical BlockIo devices are based on the format
-  of the raw block devices media. Currently "El Torito CD-ROM", Legacy
+  of the raw block devices media. Currently "El Torito CD-ROM", UDF, Legacy
   MBR, and GPT partition schemes are supported.
 
 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
@@ -45,6 +45,7 @@ PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] = {
   PartitionInstallGptChildHandles,
   PartitionInstallElToritoChildHandles,
   PartitionInstallMbrChildHandles,
+  PartitionInstallUdfChildHandles,
   NULL
 };
 
@@ -305,9 +306,9 @@ PartitionDriverBindingStart (
   if (BlockIo->Media->MediaPresent ||
   (BlockIo->Media->RemovableMedia && !BlockIo->Media->LogicalPartition)) {
 //
-// Try for GPT, then El Torito, and then legacy MBR partition types. If the
-// media supports a given partition type install child handles to represent
-// the partitions described by the media.
+// Try for GPT, then El Torito, then UDF, and then legacy MBR partition
+// types. If the media supports a given partition type install child 
handles
+// to represent the partitions described by the media.
 //
 Routine = [0];
 while (*Routine != NULL) {
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h 
b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h
index f2f6185317..c763c676a9 100644
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h
@@ -1,7 +1,7 @@
 /** @file
   Partition driver that produces logical BlockIo devices from a physical 
   BlockIo device. The logical BlockIo devices are based on the format
-  of the raw block devices media. Currently "El Torito CD-ROM", Legacy 
+  of the raw block devices media. Currently "El Torito CD-ROM", UDF, Legacy
   MBR, and GPT partition schemes are supported.
 
 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
@@ -39,7 +39,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
 #include 
 #include 
-
+#include 
 
 //
 // Partition private data
@@ -445,6 +445,34 @@ PartitionInstallMbrChildHandles (
   IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath
   );
 
+/**
+  Install child handles if the Handle supports UDF/ECMA-167 volume format.
+
+  @param[in]  ThisCalling context.
+  @param[in]  Handle  Parent Handle.
+  @param[in]  DiskIo  Parent DiskIo interface.
+  @param[in]  DiskIo2 Parent DiskIo2 interface.
+  @param[in]  BlockIo Parent BlockIo interface.
+  @param[in]  BlockIo2Parent BlockIo2 interface.
+  @param[in]  DevicePath  Parent Device Path
+
+
+  @retval EFI_SUCCESS Child handle(s) was added.
+  @retval EFI_MEDIA_CHANGED   Media changed Detected.
+  @retval other   no child handle was added.
+
+**/
+EFI_STATUS
+PartitionInstallUdfChildHandles (
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN  EFI_HANDLE   Handle,
+  IN  EFI_DISK_IO_PROTOCOL *DiskIo,
+  IN  EFI_DISK_IO2_PROTOCOL*DiskIo2,
+  IN  EFI_BLOCK_IO_PROTOCOL*BlockIo,
+  IN  EFI_BLOCK_IO2_PROTOCOL   *BlockIo2,
+  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath
+  );
+
 typedef
 EFI_STATUS
 (*PARTITION_DETECT_ROUTINE) (
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf 
b/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
index 48212773e8..fb2ea87a9d 100644
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
@@ -4,7 +4,7 @@
 #  This module produces the logical Block I/O device that 

Re: [edk2] [PATCH v5 0/6] read-only UDF file system support

2017-09-08 Thread Paulo Alcantara



On 08/09/2017 05:35, Laszlo Ersek wrote:

Paulo,

On 09/08/17 02:56, Paulo Alcantara wrote:

Ray,

On 07/09/2017 20:13, Paulo Alcantara wrote:

v5:
   - Fixed OVMF IA32 build.
   - Fixed a typo in UdfDriveBindingStop() ("This" -> "SimpleFs") which
 broke retrieval of private fs data from SimpleFs protocol --
 identified by 'reconnect -r' command in UEFI shell.


Follow the diff between v4 and v5 for Mde*Pkg changes (forgot to include
it when resending):

diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
index 8ad14fe594..2dbcff0be4 100644
--- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
+++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
@@ -372,7 +372,7 @@ UdfRead (
PrivFileData->FileSize,
>FilePosition,
Buffer,
-  BufferSize
+  (UINT64 *)(UINTN)BufferSize^M
);


This change is not correct.

(1) The UdfRead() function takes the following parameter:

   IN OUT  UINTN  *BufferSize,

This means that, in an IA32 or ARM build,

   sizeof *BufferSize == 4

and in an AARCH64 or X64 build,

   sizeof *BufferSize == 8

(2) The above type-casting is part of a call to the ReadFileData()
function. The ReadFileData() function takes the following parameter:

   IN OUT  UINT64 *BufferSize

This means that, regardless of architecture,

   sizeof *BufferSize == 8

The consequence is that, in an IA32 or ARM build, the ReadFileData()
function will both read and write beyond the end of the outermost
caller's "BufferSize" variable. The write is a problem without a doubt,
but the read is a problem too if the outermost caller's "BufferSize" (a
UINT32 object) is followed by four bytes that are not all zero. Then
ReadFileData() will attempt to read more than 4GB of data.


You're right. Thanks for the explanation.



The right way to fix this is the following:


diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
index 2dbcff0be4a3..07c7ec207fcd 100644
--- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
+++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
@@ -326,6 +326,7 @@ UdfRead (
VOID*NewFileEntryData;
CHAR16  FileName[UDF_FILENAME_LENGTH] = { 0 };
UINT64  FileSize;
+  UINT64  BufferSizeUint64;
  
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
  
@@ -364,6 +365,7 @@ UdfRead (

goto Done;
  }
  
+BufferSizeUint64 = *BufferSize;

  Status = ReadFileData (
BlockIo,
DiskIo,
@@ -372,8 +374,10 @@ UdfRead (
PrivFileData->FileSize,
>FilePosition,
Buffer,
-  (UINT64 *)(UINTN)BufferSize
+  
);
+ASSERT (BufferSizeUint64 <= MAX_UINTN);
+*BufferSize = (UINTN)BufferSizeUint64;
} else if (IS_FID_DIRECTORY_FILE (Parent->FileIdentifierDesc)) {
  if (ReadDirInfo->FidOffset == 0 && PrivFileData->FilePosition > 0) {
Status = EFI_DEVICE_ERROR;


I'll include this in v6.

Paulo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at ExitBootServices

2017-09-08 Thread Ard Biesheuvel
On 8 September 2017 at 10:48, Laszlo Ersek  wrote:
> On 09/08/17 10:53, Ard Biesheuvel wrote:
>> (cc'ing the trinity)
>>
>> On 7 September 2017 at 23:41, Laszlo Ersek  wrote:
>>> Repo:   https://github.com/lersek/edk2.git
>>> Branch: iommu_exit_boot
>>>
>>> This series is the result of the discussion under
>>>
>>>   [edk2] [PATCH 0/4] MdeModulePkg: some PCI HC drivers: unmap common
>>>  buffers at ExitBootServices()
>>>   https://lists.01.org/pipermail/edk2-devel/2017-September/014099.html
>>>
>>> At ExitBootServices(), PCI and VirtIo drivers should only care about
>>> aborting pending DMA on the devices. Cleaning up PciIo mappings (which
>>> ultimately boil down to IOMMU mappings) for those aborted DMA operations
>>> should be the job of the IOMMU driver.
>>>
>>> Patches 01 through 03 clean up the AtaAtapiPassThru driver in
>>> MdeModulePkg a little bit, because at present, (a) it unmaps the buffers
>>> and disables BMDMA in the wrong order in its DriverBindingStop()
>>> function, (b) it doesn't abort pending DMA at ExitBootServices().
>>>
>>> This subset can be treated separately from the rest of the series, but I
>>> thought they belonged loosely together (given that AtaAtapiPassThru is
>>> used on QEMU's Q35 machine type).
>>>
>>> Patches 04 through 07 remove VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer()
>>> calls from the VirtIo drivers' ExitBootServices() handlers.
>>>
>>> (The conversion of VirtioNetDxe to device addresses is still in progress
>>> -- Brijesh, when you submit v2 of that, under this approach, there is no
>>> need to change VirtioNetExitBoot() relative to current upstream, and you
>>> can use VirtioOperationBusMasterRead to map outgoing packets.)
>>>
>>> Patches 08 through 10 make OvmfPkg/IoMmuDxe track all mappings, and
>>> unmap all mappings (Read, Write, CommonBuffer) that are in effect when
>>> ExitBootServices() is called. It is ensured that PCI and VirtIo drivers
>>> abort pending DMA first, and IoMmuDxe clean up the mappings last.
>>>
>>
>> The patches look fine to me
>>
>> Reviewed-by: Ard Biesheuvel 
>
> Thank you!
>
>> Given that we are now depending on events signalled in an event
>> handler to be queued after all currently pending events,
>
> marking this (*)
>
>> I think we
>> need to explicitly agree that this behavior that needs to be
>> preserved, and documented somewhere, given that the UEFI spec does not
>> offer this guarantee.
>
> The condition that you describe under (*) *is* guaranteed in the UEFI spec.
>
> The *only* bit that is edk2 specific in the last patch is that we invoke
> gBS->SignalEvent() from the notification function of an event that
> *specifically* has type EVT_SIGNAL_EXIT_BOOT_SERVICES.
>
> If the event, whose notification function we were calling
> gBS->SignalEvent() from, was a plain EVT_NOTIFY_SIGNAL type event, then
> *nothing* in the last patch would be edk2-specific.
>
> * It is guaranteed by the UEFI spec that signaling an event group queues
> the notification functions for all not-yet-signaled events in that
> group, before the first notification function is invoked (regardless of
> the signaled events' TPLs). From "CreateEventEx()": "All events are
> guaranteed to be signaled before the first notification action is taken."
>
> * The UEFI spec guarantees that, within the same TPL, if an event is
> signaled that is not pending yet, the notify function will be queued
> after notify functions already queued on the same TPL. See "CreateEvent()":
>
> Events exist in one of two states, “waiting” or “signaled.” When an
> event is created, firmware puts it in the “waiting” state. When the
> event is signaled, firmware changes its state to “signaled” and, if
> EVT_NOTIFY_SIGNAL is specified, places a call to its notification
> function in a FIFO queue. There is a queue for each of the “basic”
> task priority levels defined in Section 7.1 (TPL_CALLBACK, and
> TPL_NOTIFY). The functions in these queues are invoked in FIFO
> order, starting with the highest priority level queue and proceeding
> to the lowest priority queue that is unmasked by the current TPL. If
> the current TPL is equal to or greater than the queued notification,
> it will wait until the TPL is lowered via
> EFI_BOOT_SERVICES.RestoreTPL().
>
> * gBS->SignalEvent() is valid to call at TPL_CALLBACK and TPL_NOTIFY
> levels (see "Table 23. TPL Restrictions"); in fact it is one of the few
> services that can even be called at TPL_HIGH_LEVEL (which is reserved
> for the platform firmware).
>
> The upshot is:
>
> (1) assume you have Event1, Event2, Event3, Event4 in event group
> EventGroupFoobarGuid
>
> (2) assume all events are EVT_NOTIFY_SIGNAL type
>
> (3) assume Event1 and Event2 have TPL_NOTIFY, Event3 and Event4 are
> TPL_CALLBACK
>
> (4) Assume Event5 is also of type EVT_NOTIFY_SIGNAL, not part of any
> event group, and has TPL_CALLBACK task prio level
>

Re: [edk2] [PATCH v2] BaseTools/GCC: set -Wno-unused-const-variables on RELEASE builds

2017-09-08 Thread Gao, Liming
Reviewed-by: Liming Gao 

>-Original Message-
>From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>Thomas Lamprecht
>Sent: Friday, September 08, 2017 3:02 PM
>To: edk2-devel@lists.01.org
>Cc: Laszlo Ersek ; Gao, Liming ;
>Ard Biesheuvel 
>Subject: [edk2] [PATCH v2] BaseTools/GCC: set -Wno-unused-const-variables
>on RELEASE builds
>
>TianoCore BZ#700 [1]
>
>Set the '-Wno-unused-const-variables' in RELEASE builds with the
>GGC49 and GCC5 toolchain.
>
>This fixes the RELEASE build of OVMF with GCC in version 6 or newer.
>GCC 6 added the '-Wunused-const-variable' warning, which gets
>activated by '-Wunused-variable' and has the following behavior:
>"Warn whenever a constant static variable is unused aside from its
>declaration" [2]
>
>Commit 2ad6ba80a1bd58382bde6b994070f7c01d2fb48d introduced a case
>where exactly this happens on a RELEASE build. All uses of the static
>const variable are located in debug code only, which gets thrown out
>by the compiler on RELEASE builds and thus triggers the
>unused-const-variable warning.
>
>There is currently no GCC 6 toolchain target defined and doing so
>would add a lot of boilerplate code. Instead, use the fact that GCC
>ignores unknown '-Wno-*' options:
>
>"[...] if the -Wno- form is used [...] no diagnostic is produced for
>-Wno-unknown-warning unless other diagnostics are being produced"
>
>This behavior is available in GCC 4.9 [3] (and also earlier, for that
>matter), so add the flag to the GCC49 and GCC5 toolchain, even if
>both GCC versions do not supports it.
>GCC49 doesn't enables LTO whereas GCC5 does. As GCC 6.0 through 6.2
>had bugs relating to LTO there can be desire to use the GCC49 target
>even if compiling with GCC 6, see 432f1d83f77a.
>
>Orient the changes on 20d00edf21d2 which moved the
>'-Wno-unused-but-set-variable' flag to RELEASE builds only, as there
>it ensure that it does not gets raised if the only usage of a
>variable is in (then collapsed) debug code.
>
>[1] https://bugzilla.tianocore.org/show_bug.cgi?id=700
>[2] https://gcc.gnu.org/onlinedocs/gcc-6.4.0/gcc/Warning-
>Options.html#index-Wunused-const-variable
>[3] https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Warning-Options.html
>
>Cc: Yonghong Zhu 
>Cc: Liming Gao 
>Cc: Laszlo Ersek 
>Cc: Ard Biesheuvel 
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Thomas Lamprecht 
>---
>
>changes v1 -> v2:
> * add the flag also to the GCC49 toolchain to allow using GCC 6 with
>   LTO disabled builds, thanks for the hints Laszlo and Liming!
> * adapt commit message slightly, especially to the fact that GCC49
>   gets the flag now too.
> * CC Ard
>
> BaseTools/Conf/tools_def.template | 16 
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
>diff --git a/BaseTools/Conf/tools_def.template
>b/BaseTools/Conf/tools_def.template
>index ba1d1a16de..cbb5024c1b 100755
>--- a/BaseTools/Conf/tools_def.template
>+++ b/BaseTools/Conf/tools_def.template
>@@ -5179,7 +5179,7 @@ RELEASE_GCC48_AARCH64_CC_FLAGS   =
>DEF(GCC48_AARCH64_CC_FLAGS) -Wno-unused-but-s
> *_GCC49_IA32_NASM_FLAGS   = -f elf32
>
>   DEBUG_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os
>-RELEASE_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os -
>Wno-unused-but-set-variable
>+RELEASE_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os -
>Wno-unused-but-set-variable -Wno-unused-const-variable
>   NOOPT_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -O0
>
> ##
>@@ -5207,7 +5207,7 @@ RELEASE_GCC49_IA32_CC_FLAGS   =
>DEF(GCC49_IA32_CC_FLAGS) -Os -Wno-unused-but
> *_GCC49_X64_NASM_FLAGS   = -f elf64
>
>   DEBUG_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os
>-RELEASE_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os -
>Wno-unused-but-set-variable
>+RELEASE_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os -
>Wno-unused-but-set-variable -Wno-unused-const-variable
>   NOOPT_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -O0
>
> ##
>@@ -5240,7 +5240,7 @@ RELEASE_GCC49_X64_CC_FLAGS   =
>DEF(GCC49_X64_CC_FLAGS) -Os -Wno-unused-but-s
> *_GCC49_ARM_CC_XIPFLAGS  = DEF(GCC49_ARM_CC_XIPFLAGS)
>
>   DEBUG_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) -O0
>-RELEASE_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) -Wno-
>unused-but-set-variable
>+RELEASE_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) -Wno-
>unused-but-set-variable -Wno-unused-const-variable
>   NOOPT_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) -O0
>
> ##
>@@ -5272,7 +5272,7 @@ RELEASE_GCC49_ARM_CC_FLAGS   =
>DEF(GCC49_ARM_CC_FLAGS) -Wno-unused-but-set-v
>   DEBUG_GCC49_AARCH64_DLINK_FLAGS  =
>DEF(GCC49_AARCH64_DLINK_FLAGS) -z common-page-size=0x1000
>   

Re: [edk2] [PATCH] MdeModulePkg Xhci: Correct description of Timeout param in XhciReg.h

2017-09-08 Thread Ni, Ruiyu
Reviewed-by: Ruiyu Ni 

Thanks/Ray

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Star Zeng
> Sent: Thursday, September 7, 2017 7:13 PM
> To: edk2-devel@lists.01.org
> Cc: Alexei Fedorov ; Ni, Ruiyu
> ; Zeng, Star 
> Subject: [edk2] [PATCH] MdeModulePkg Xhci: Correct description of Timeout
> param in XhciReg.h
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=653
> 
> Correct description of Timeout param in XhciReg.h to be matched with
> XhciReg.c.
> 
> Cc: Alexei Fedorov 
> Cc: Ruiyu Ni 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h | 10 +-
> MdeModulePkg/Bus/Pci/XhciPei/XhciReg.h |  4 ++--
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
> b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
> index b748c8d39739..838a44628c27 100644
> --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
> +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
> @@ -2,7 +2,7 @@
> 
>This file contains the register definition of XHCI host controller.
> 
> -Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.
> +Copyright (c) 2011 - 2017, Intel Corporation. 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
> @@ -399,7 +399,7 @@ XhcClearOpRegBit (
>@param  Offset   The offset of the operational register.
>@param  Bit  The bit of the register to wait for.
>@param  WaitToSetWait the bit to set or clear.
> -  @param  Timeout  The time to wait before abort (in microsecond, us).
> +  @param  Timeout  The time to wait before abort (in millisecond, ms).
> 
>@retval EFI_SUCCESS  The bit successfully changed by host controller.
>@retval EFI_TIMEOUT  The time out occurred.
> @@ -521,7 +521,7 @@ XhcIsSysError (
>Reset the XHCI host controller.
> 
>@param  Xhc  The XHCI Instance.
> -  @param  Timeout  Time to wait before abort (in microsecond, us).
> +  @param  Timeout  Time to wait before abort (in millisecond, ms).
> 
>@retval EFI_SUCCESS  The XHCI host controller is reset.
>@return Others   Failed to reset the XHCI before Timeout.
> @@ -537,7 +537,7 @@ XhcResetHC (
>Halt the XHCI host controller.
> 
>@param  Xhc  The XHCI Instance.
> -  @param  Timeout  Time to wait before abort (in microsecond, us).
> +  @param  Timeout  Time to wait before abort (in millisecond, ms).
> 
>@return EFI_SUCCESS  The XHCI host controller is halt.
>@return EFI_TIMEOUT  Failed to halt the XHCI before Timeout.
> @@ -553,7 +553,7 @@ XhcHaltHC (
>Set the XHCI host controller to run.
> 
>@param  Xhc  The XHCI Instance.
> -  @param  Timeout  Time to wait before abort (in microsecond, us).
> +  @param  Timeout  Time to wait before abort (in millisecond, ms).
> 
>@return EFI_SUCCESS  The XHCI host controller is running.
>@return EFI_TIMEOUT  Failed to set the XHCI to run before Timeout.
> diff --git a/MdeModulePkg/Bus/Pci/XhciPei/XhciReg.h
> b/MdeModulePkg/Bus/Pci/XhciPei/XhciReg.h
> index 1a6256066599..0297072ffd6b 100644
> --- a/MdeModulePkg/Bus/Pci/XhciPei/XhciReg.h
> +++ b/MdeModulePkg/Bus/Pci/XhciPei/XhciReg.h
> @@ -1,7 +1,7 @@
>  /** @file
>  Private Header file for Usb Host Controller PEIM
> 
> -Copyright (c) 2014, Intel Corporation. All rights reserved.
> +Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.
> 
>  This program and the accompanying materials  are licensed and made
> available under the terms and conditions @@ -287,7 +287,7 @@
> XhcPeiClearOpRegBit (
>@param  OffsetThe offset of the operational register.
>@param  Bit   The bit of the register to wait for.
>@param  WaitToSet Wait the bit to set or clear.
> -  @param  Timeout   The time to wait before abort (in microsecond, us).
> +  @param  Timeout   The time to wait before abort (in millisecond, ms).
> 
>@retval EFI_SUCCESS   The bit successfully changed by host controller.
>@retval EFI_TIMEOUT   The time out occurred.
> --
> 2.7.0.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2] BaseTools/GCC: set -Wno-unused-const-variables on RELEASE builds

2017-09-08 Thread Ard Biesheuvel
On 8 September 2017 at 09:48, Laszlo Ersek  wrote:
> On 09/08/17 09:01, Thomas Lamprecht wrote:
>> TianoCore BZ#700 [1]
>>
>> Set the '-Wno-unused-const-variables' in RELEASE builds with the
>> GGC49 and GCC5 toolchain.
>>
>> This fixes the RELEASE build of OVMF with GCC in version 6 or newer.
>> GCC 6 added the '-Wunused-const-variable' warning, which gets
>> activated by '-Wunused-variable' and has the following behavior:
>> "Warn whenever a constant static variable is unused aside from its
>> declaration" [2]
>>
>> Commit 2ad6ba80a1bd58382bde6b994070f7c01d2fb48d introduced a case
>> where exactly this happens on a RELEASE build. All uses of the static
>> const variable are located in debug code only, which gets thrown out
>> by the compiler on RELEASE builds and thus triggers the
>> unused-const-variable warning.
>>
>> There is currently no GCC 6 toolchain target defined and doing so
>> would add a lot of boilerplate code. Instead, use the fact that GCC
>> ignores unknown '-Wno-*' options:
>>
>> "[...] if the -Wno- form is used [...] no diagnostic is produced for
>> -Wno-unknown-warning unless other diagnostics are being produced"
>>
>> This behavior is available in GCC 4.9 [3] (and also earlier, for that
>> matter), so add the flag to the GCC49 and GCC5 toolchain, even if
>> both GCC versions do not supports it.
>> GCC49 doesn't enables LTO whereas GCC5 does. As GCC 6.0 through 6.2
>> had bugs relating to LTO there can be desire to use the GCC49 target
>> even if compiling with GCC 6, see 432f1d83f77a.
>>
>> Orient the changes on 20d00edf21d2 which moved the
>> '-Wno-unused-but-set-variable' flag to RELEASE builds only, as there
>> it ensure that it does not gets raised if the only usage of a
>> variable is in (then collapsed) debug code.
>>
>> [1] https://bugzilla.tianocore.org/show_bug.cgi?id=700
>> [2] 
>> https://gcc.gnu.org/onlinedocs/gcc-6.4.0/gcc/Warning-Options.html#index-Wunused-const-variable
>> [3] https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Warning-Options.html
>>
>> Cc: Yonghong Zhu 
>> Cc: Liming Gao 
>> Cc: Laszlo Ersek 
>> Cc: Ard Biesheuvel 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Thomas Lamprecht 

Reviewed-by: Ard Biesheuvel 


>> ---
>>
>> changes v1 -> v2:
>>  * add the flag also to the GCC49 toolchain to allow using GCC 6 with
>>LTO disabled builds, thanks for the hints Laszlo and Liming!
>>  * adapt commit message slightly, especially to the fact that GCC49
>>gets the flag now too.
>>  * CC Ard
>>
>>  BaseTools/Conf/tools_def.template | 16 
>>  1 file changed, 8 insertions(+), 8 deletions(-)
>>
>> diff --git a/BaseTools/Conf/tools_def.template 
>> b/BaseTools/Conf/tools_def.template
>> index ba1d1a16de..cbb5024c1b 100755
>> --- a/BaseTools/Conf/tools_def.template
>> +++ b/BaseTools/Conf/tools_def.template
>> @@ -5179,7 +5179,7 @@ RELEASE_GCC48_AARCH64_CC_FLAGS   = 
>> DEF(GCC48_AARCH64_CC_FLAGS) -Wno-unused-but-s
>>  *_GCC49_IA32_NASM_FLAGS   = -f elf32
>>
>>DEBUG_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os
>> -RELEASE_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os 
>> -Wno-unused-but-set-variable
>> +RELEASE_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os 
>> -Wno-unused-but-set-variable -Wno-unused-const-variable
>>NOOPT_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -O0
>>
>>  ##
>> @@ -5207,7 +5207,7 @@ RELEASE_GCC49_IA32_CC_FLAGS   = 
>> DEF(GCC49_IA32_CC_FLAGS) -Os -Wno-unused-but
>>  *_GCC49_X64_NASM_FLAGS   = -f elf64
>>
>>DEBUG_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os
>> -RELEASE_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os 
>> -Wno-unused-but-set-variable
>> +RELEASE_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os 
>> -Wno-unused-but-set-variable -Wno-unused-const-variable
>>NOOPT_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -O0
>>
>>  ##
>> @@ -5240,7 +5240,7 @@ RELEASE_GCC49_X64_CC_FLAGS   = 
>> DEF(GCC49_X64_CC_FLAGS) -Os -Wno-unused-but-s
>>  *_GCC49_ARM_CC_XIPFLAGS  = DEF(GCC49_ARM_CC_XIPFLAGS)
>>
>>DEBUG_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) -O0
>> -RELEASE_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) 
>> -Wno-unused-but-set-variable
>> +RELEASE_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) 
>> -Wno-unused-but-set-variable -Wno-unused-const-variable
>>NOOPT_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) -O0
>>
>>  ##
>> @@ -5272,7 +5272,7 @@ RELEASE_GCC49_ARM_CC_FLAGS   = 
>> DEF(GCC49_ARM_CC_FLAGS) -Wno-unused-but-set-v
>>DEBUG_GCC49_AARCH64_DLINK_FLAGS  = DEF(GCC49_AARCH64_DLINK_FLAGS) -z 
>> common-page-size=0x1000
>>DEBUG_GCC49_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
>>
>> -RELEASE_GCC49_AARCH64_CC_FLAGS = 

Re: [edk2] [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at ExitBootServices

2017-09-08 Thread Ard Biesheuvel
(cc'ing the trinity)

On 7 September 2017 at 23:41, Laszlo Ersek  wrote:
> Repo:   https://github.com/lersek/edk2.git
> Branch: iommu_exit_boot
>
> This series is the result of the discussion under
>
>   [edk2] [PATCH 0/4] MdeModulePkg: some PCI HC drivers: unmap common
>  buffers at ExitBootServices()
>   https://lists.01.org/pipermail/edk2-devel/2017-September/014099.html
>
> At ExitBootServices(), PCI and VirtIo drivers should only care about
> aborting pending DMA on the devices. Cleaning up PciIo mappings (which
> ultimately boil down to IOMMU mappings) for those aborted DMA operations
> should be the job of the IOMMU driver.
>
> Patches 01 through 03 clean up the AtaAtapiPassThru driver in
> MdeModulePkg a little bit, because at present, (a) it unmaps the buffers
> and disables BMDMA in the wrong order in its DriverBindingStop()
> function, (b) it doesn't abort pending DMA at ExitBootServices().
>
> This subset can be treated separately from the rest of the series, but I
> thought they belonged loosely together (given that AtaAtapiPassThru is
> used on QEMU's Q35 machine type).
>
> Patches 04 through 07 remove VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer()
> calls from the VirtIo drivers' ExitBootServices() handlers.
>
> (The conversion of VirtioNetDxe to device addresses is still in progress
> -- Brijesh, when you submit v2 of that, under this approach, there is no
> need to change VirtioNetExitBoot() relative to current upstream, and you
> can use VirtioOperationBusMasterRead to map outgoing packets.)
>
> Patches 08 through 10 make OvmfPkg/IoMmuDxe track all mappings, and
> unmap all mappings (Read, Write, CommonBuffer) that are in effect when
> ExitBootServices() is called. It is ensured that PCI and VirtIo drivers
> abort pending DMA first, and IoMmuDxe clean up the mappings last.
>

The patches look fine to me

Reviewed-by: Ard Biesheuvel 

Given that we are now depending on events signalled in an event
handler to be queued after all currently pending events, I think we
need to explicitly agree that this behavior that needs to be
preserved, and documented somewhere, given that the UEFI spec does not
offer this guarantee.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2] BaseTools/GCC: set -Wno-unused-const-variables on RELEASE builds

2017-09-08 Thread Laszlo Ersek
On 09/08/17 09:01, Thomas Lamprecht wrote:
> TianoCore BZ#700 [1]
> 
> Set the '-Wno-unused-const-variables' in RELEASE builds with the
> GGC49 and GCC5 toolchain.
> 
> This fixes the RELEASE build of OVMF with GCC in version 6 or newer.
> GCC 6 added the '-Wunused-const-variable' warning, which gets
> activated by '-Wunused-variable' and has the following behavior:
> "Warn whenever a constant static variable is unused aside from its
> declaration" [2]
> 
> Commit 2ad6ba80a1bd58382bde6b994070f7c01d2fb48d introduced a case
> where exactly this happens on a RELEASE build. All uses of the static
> const variable are located in debug code only, which gets thrown out
> by the compiler on RELEASE builds and thus triggers the
> unused-const-variable warning.
> 
> There is currently no GCC 6 toolchain target defined and doing so
> would add a lot of boilerplate code. Instead, use the fact that GCC
> ignores unknown '-Wno-*' options:
> 
> "[...] if the -Wno- form is used [...] no diagnostic is produced for
> -Wno-unknown-warning unless other diagnostics are being produced"
> 
> This behavior is available in GCC 4.9 [3] (and also earlier, for that
> matter), so add the flag to the GCC49 and GCC5 toolchain, even if
> both GCC versions do not supports it.
> GCC49 doesn't enables LTO whereas GCC5 does. As GCC 6.0 through 6.2
> had bugs relating to LTO there can be desire to use the GCC49 target
> even if compiling with GCC 6, see 432f1d83f77a.
> 
> Orient the changes on 20d00edf21d2 which moved the
> '-Wno-unused-but-set-variable' flag to RELEASE builds only, as there
> it ensure that it does not gets raised if the only usage of a
> variable is in (then collapsed) debug code.
> 
> [1] https://bugzilla.tianocore.org/show_bug.cgi?id=700
> [2] 
> https://gcc.gnu.org/onlinedocs/gcc-6.4.0/gcc/Warning-Options.html#index-Wunused-const-variable
> [3] https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Warning-Options.html
> 
> Cc: Yonghong Zhu 
> Cc: Liming Gao 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Thomas Lamprecht 
> ---
> 
> changes v1 -> v2:
>  * add the flag also to the GCC49 toolchain to allow using GCC 6 with
>LTO disabled builds, thanks for the hints Laszlo and Liming!
>  * adapt commit message slightly, especially to the fact that GCC49
>gets the flag now too.
>  * CC Ard
> 
>  BaseTools/Conf/tools_def.template | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template 
> b/BaseTools/Conf/tools_def.template
> index ba1d1a16de..cbb5024c1b 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -5179,7 +5179,7 @@ RELEASE_GCC48_AARCH64_CC_FLAGS   = 
> DEF(GCC48_AARCH64_CC_FLAGS) -Wno-unused-but-s
>  *_GCC49_IA32_NASM_FLAGS   = -f elf32
>  
>DEBUG_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os
> -RELEASE_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os 
> -Wno-unused-but-set-variable
> +RELEASE_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os 
> -Wno-unused-but-set-variable -Wno-unused-const-variable
>NOOPT_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -O0
>  
>  ##
> @@ -5207,7 +5207,7 @@ RELEASE_GCC49_IA32_CC_FLAGS   = 
> DEF(GCC49_IA32_CC_FLAGS) -Os -Wno-unused-but
>  *_GCC49_X64_NASM_FLAGS   = -f elf64
>  
>DEBUG_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os
> -RELEASE_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os 
> -Wno-unused-but-set-variable
> +RELEASE_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os 
> -Wno-unused-but-set-variable -Wno-unused-const-variable
>NOOPT_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -O0
>  
>  ##
> @@ -5240,7 +5240,7 @@ RELEASE_GCC49_X64_CC_FLAGS   = 
> DEF(GCC49_X64_CC_FLAGS) -Os -Wno-unused-but-s
>  *_GCC49_ARM_CC_XIPFLAGS  = DEF(GCC49_ARM_CC_XIPFLAGS)
>  
>DEBUG_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) -O0
> -RELEASE_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) 
> -Wno-unused-but-set-variable
> +RELEASE_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) 
> -Wno-unused-but-set-variable -Wno-unused-const-variable
>NOOPT_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) -O0
>  
>  ##
> @@ -5272,7 +5272,7 @@ RELEASE_GCC49_ARM_CC_FLAGS   = 
> DEF(GCC49_ARM_CC_FLAGS) -Wno-unused-but-set-v
>DEBUG_GCC49_AARCH64_DLINK_FLAGS  = DEF(GCC49_AARCH64_DLINK_FLAGS) -z 
> common-page-size=0x1000
>DEBUG_GCC49_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
>  
> -RELEASE_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) 
> -Wno-unused-but-set-variable -mcmodel=tiny -fomit-frame-pointer
> +RELEASE_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) 
> -Wno-unused-but-set-variable 

Re: [edk2] [PATCH v5 0/6] read-only UDF file system support

2017-09-08 Thread Laszlo Ersek
Paulo,

On 09/08/17 02:56, Paulo Alcantara wrote:
> Ray,
>
> On 07/09/2017 20:13, Paulo Alcantara wrote:
>> v5:
>>   - Fixed OVMF IA32 build.
>>   - Fixed a typo in UdfDriveBindingStop() ("This" -> "SimpleFs") which
>> broke retrieval of private fs data from SimpleFs protocol --
>> identified by 'reconnect -r' command in UEFI shell.
>
> Follow the diff between v4 and v5 for Mde*Pkg changes (forgot to include
> it when resending):
>
> diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> index 8ad14fe594..2dbcff0be4 100644
> --- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> +++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> @@ -372,7 +372,7 @@ UdfRead (
>PrivFileData->FileSize,
>>FilePosition,
>Buffer,
> -  BufferSize
> +  (UINT64 *)(UINTN)BufferSize^M
>);

This change is not correct.

(1) The UdfRead() function takes the following parameter:

  IN OUT  UINTN  *BufferSize,

This means that, in an IA32 or ARM build,

  sizeof *BufferSize == 4

and in an AARCH64 or X64 build,

  sizeof *BufferSize == 8

(2) The above type-casting is part of a call to the ReadFileData()
function. The ReadFileData() function takes the following parameter:

  IN OUT  UINT64 *BufferSize

This means that, regardless of architecture,

  sizeof *BufferSize == 8

The consequence is that, in an IA32 or ARM build, the ReadFileData()
function will both read and write beyond the end of the outermost
caller's "BufferSize" variable. The write is a problem without a doubt,
but the read is a problem too if the outermost caller's "BufferSize" (a
UINT32 object) is followed by four bytes that are not all zero. Then
ReadFileData() will attempt to read more than 4GB of data.

The right way to fix this is the following:

> diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> index 2dbcff0be4a3..07c7ec207fcd 100644
> --- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> +++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> @@ -326,6 +326,7 @@ UdfRead (
>VOID*NewFileEntryData;
>CHAR16  FileName[UDF_FILENAME_LENGTH] = { 0 };
>UINT64  FileSize;
> +  UINT64  BufferSizeUint64;
>  
>OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
>  
> @@ -364,6 +365,7 @@ UdfRead (
>goto Done;
>  }
>  
> +BufferSizeUint64 = *BufferSize;
>  Status = ReadFileData (
>BlockIo,
>DiskIo,
> @@ -372,8 +374,10 @@ UdfRead (
>PrivFileData->FileSize,
>>FilePosition,
>Buffer,
> -  (UINT64 *)(UINTN)BufferSize
> +  
>);
> +ASSERT (BufferSizeUint64 <= MAX_UINTN);
> +*BufferSize = (UINTN)BufferSizeUint64;
>} else if (IS_FID_DIRECTORY_FILE (Parent->FileIdentifierDesc)) {
>  if (ReadDirInfo->FidOffset == 0 && PrivFileData->FilePosition > 0) {
>Status = EFI_DEVICE_ERROR;

Thanks,
Laszlo

>} else if (IS_FID_DIRECTORY_FILE (Parent->FileIdentifierDesc)) {
>  if (ReadDirInfo->FidOffset == 0 && PrivFileData->FilePosition > 0) {
> diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/Udf.c
> b/MdeModulePkg/Universal/Disk/UdfDxe/Udf.c
> index 9f10c78ca9..49dc7077b7 100644
> --- a/MdeModulePkg/Universal/Disk/UdfDxe/Udf.c
> +++ b/MdeModulePkg/Universal/Disk/UdfDxe/Udf.c
> @@ -264,7 +264,7 @@ UdfDriverBindingStop (
>  EFI_OPEN_PROTOCOL_GET_PROTOCOL
>  );
>if (!EFI_ERROR (Status)) {
> -PrivFsData = PRIVATE_UDF_SIMPLE_FS_DATA_FROM_THIS (This);
> +PrivFsData = PRIVATE_UDF_SIMPLE_FS_DATA_FROM_THIS (SimpleFs);^M
>
>  //
>  // Uninstall child handle
>
>
> Thanks,
> Paulo

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at ExitBootServices

2017-09-08 Thread Yao, Jiewen
Patch 8~10: reviewed-by: jiewen@intel.com

From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Yao, 
Jiewen
Sent: Friday, September 8, 2017 3:28 PM
To: Laszlo Ersek ; edk2-devel-01 
Cc: Justen, Jordan L ; Brijesh Singh 
; Dong, Eric ; Zeng, Star 
; Ard Biesheuvel 
Subject: Re: [edk2] [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at 
ExitBootServices

Patch 1~3 reviewed-by: jiewen@intel.com


> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Friday, September 8, 2017 6:41 AM
> To: edk2-devel-01 >
> Cc: Ard Biesheuvel 
> >; Brijesh Singh
> >; Dong, Eric 
> >; Yao, Jiewen
> >; Justen, Jordan L 
> >; Zeng,
> Star >
> Subject: [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at
> ExitBootServices
>
> Repo:   https://github.com/lersek/edk2.git
> Branch: iommu_exit_boot
>
> This series is the result of the discussion under
>
>   [edk2] [PATCH 0/4] MdeModulePkg: some PCI HC drivers: unmap common
>  buffers at ExitBootServices()
>   https://lists.01.org/pipermail/edk2-devel/2017-September/014099.html
>
> At ExitBootServices(), PCI and VirtIo drivers should only care about
> aborting pending DMA on the devices. Cleaning up PciIo mappings (which
> ultimately boil down to IOMMU mappings) for those aborted DMA operations
> should be the job of the IOMMU driver.
>
> Patches 01 through 03 clean up the AtaAtapiPassThru driver in
> MdeModulePkg a little bit, because at present, (a) it unmaps the buffers
> and disables BMDMA in the wrong order in its DriverBindingStop()
> function, (b) it doesn't abort pending DMA at ExitBootServices().
>
> This subset can be treated separately from the rest of the series, but I
> thought they belonged loosely together (given that AtaAtapiPassThru is
> used on QEMU's Q35 machine type).
>
> Patches 04 through 07 remove
> VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer()
> calls from the VirtIo drivers' ExitBootServices() handlers.
>
> (The conversion of VirtioNetDxe to device addresses is still in progress
> -- Brijesh, when you submit v2 of that, under this approach, there is no
> need to change VirtioNetExitBoot() relative to current upstream, and you
> can use VirtioOperationBusMasterRead to map outgoing packets.)
>
> Patches 08 through 10 make OvmfPkg/IoMmuDxe track all mappings, and
> unmap all mappings (Read, Write, CommonBuffer) that are in effect when
> ExitBootServices() is called. It is ensured that PCI and VirtIo drivers
> abort pending DMA first, and IoMmuDxe clean up the mappings last.
>
> Cc: Ard Biesheuvel 
> >
> Cc: Brijesh Singh >
> Cc: Eric Dong >
> Cc: Jiewen Yao >
> Cc: Jordan Justen 
> >
> Cc: Star Zeng >
>
> Thanks
> Laszlo
>
> Laszlo Ersek (10):
>   MdeModulePkg/AtaAtapiPassThru: cache EnabledPciAttributes
>   MdeModulePkg/AtaAtapiPassThru: unmap DMA buffers after disabling BM
> DMA
>   MdeModulePkg/AtaAtapiPassThru: disable the device at
> ExitBootServices()
>   OvmfPkg/VirtioBlkDxe: don't unmap VRING at ExitBootServices()
>   OvmfPkg/VirtioGpuDxe: don't unmap VRING & BackingStore at
> ExitBootServices
>   OvmfPkg/VirtioRngDxe: don't unmap VRING at ExitBootServices()
>   OvmfPkg/VirtioScsiDxe: don't unmap VRING at ExitBootServices()
>   OvmfPkg/IoMmuDxe: track all mappings
>   OvmfPkg/IoMmuDxe: generalize IoMmuUnmap() to IoMmuUnmapWorker()
>   OvmfPkg/IoMmuDxe: unmap all IOMMU mappings at ExitBootServices()
>
>  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 103 +---
>  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h |   7 +
>  OvmfPkg/IoMmuDxe/AmdSevIoMmu.c   | 246
> +---
>  OvmfPkg/VirtioBlkDxe/VirtioBlk.c |   7 +-
>  OvmfPkg/VirtioGpuDxe/Commands.c  |  23 +-
>  OvmfPkg/VirtioRngDxe/VirtioRng.c |   7 +-
>  OvmfPkg/VirtioScsiDxe/VirtioScsi.c   |   7 +-
>  7 files changed, 299 insertions(+), 101 deletions(-)
>
> --
> 2.14.1.3.gb7cf6e02401b

___
edk2-devel mailing list

Re: [edk2] [Patch] MdeModulePkg: Update PiDxeS3BootScriptLib Internal function name

2017-09-08 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Liming 
Gao
Sent: Friday, September 8, 2017 10:40 AM
To: edk2-devel@lists.01.org
Subject: [edk2] [Patch] MdeModulePkg: Update PiDxeS3BootScriptLib Internal 
function name

To avoid the function name conflict, update the internal function name to be 
the specific one.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
---
 MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c 
b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
index b865d44..8761d69 100644
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
@@ -57,7 +57,7 @@
 
 **/
 EFI_STATUS
-SmbusExecute (
+InternalSmbusExecute (
   IN UINTNSmbusAddress,
   IN EFI_SMBUS_OPERATION  Operation,
   IN OUT UINTN*Length,
@@ -1053,7 +1053,7 @@ BootScriptExecuteSmbusExecute (
 
   SmBusAddress = (UINTN)SmbusExecuteEntry.SmBusAddress;
   DataSize = (UINTN) SmbusExecuteEntry.DataSize;
-  return SmbusExecute (
+  return InternalSmbusExecute (
SmBusAddress,
(EFI_SMBUS_OPERATION) SmbusExecuteEntry.Operation,
,
--
2.8.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at ExitBootServices

2017-09-08 Thread Zeng, Star
Reviewed-by: Star Zeng  to MdeModulePkg changes.

-Original Message-
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Friday, September 8, 2017 6:41 AM
To: edk2-devel-01 
Cc: Ard Biesheuvel ; Brijesh Singh 
; Dong, Eric ; Yao, Jiewen 
; Justen, Jordan L ; Zeng, 
Star 
Subject: [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at 
ExitBootServices

Repo:   https://github.com/lersek/edk2.git
Branch: iommu_exit_boot

This series is the result of the discussion under

  [edk2] [PATCH 0/4] MdeModulePkg: some PCI HC drivers: unmap common
 buffers at ExitBootServices()
  https://lists.01.org/pipermail/edk2-devel/2017-September/014099.html

At ExitBootServices(), PCI and VirtIo drivers should only care about aborting 
pending DMA on the devices. Cleaning up PciIo mappings (which ultimately boil 
down to IOMMU mappings) for those aborted DMA operations should be the job of 
the IOMMU driver.

Patches 01 through 03 clean up the AtaAtapiPassThru driver in MdeModulePkg a 
little bit, because at present, (a) it unmaps the buffers and disables BMDMA in 
the wrong order in its DriverBindingStop() function, (b) it doesn't abort 
pending DMA at ExitBootServices().

This subset can be treated separately from the rest of the series, but I 
thought they belonged loosely together (given that AtaAtapiPassThru is used on 
QEMU's Q35 machine type).

Patches 04 through 07 remove VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer()
calls from the VirtIo drivers' ExitBootServices() handlers.

(The conversion of VirtioNetDxe to device addresses is still in progress
-- Brijesh, when you submit v2 of that, under this approach, there is no need 
to change VirtioNetExitBoot() relative to current upstream, and you can use 
VirtioOperationBusMasterRead to map outgoing packets.)

Patches 08 through 10 make OvmfPkg/IoMmuDxe track all mappings, and unmap all 
mappings (Read, Write, CommonBuffer) that are in effect when
ExitBootServices() is called. It is ensured that PCI and VirtIo drivers abort 
pending DMA first, and IoMmuDxe clean up the mappings last.

Cc: Ard Biesheuvel 
Cc: Brijesh Singh 
Cc: Eric Dong 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Star Zeng 

Thanks
Laszlo

Laszlo Ersek (10):
  MdeModulePkg/AtaAtapiPassThru: cache EnabledPciAttributes
  MdeModulePkg/AtaAtapiPassThru: unmap DMA buffers after disabling BM
DMA
  MdeModulePkg/AtaAtapiPassThru: disable the device at
ExitBootServices()
  OvmfPkg/VirtioBlkDxe: don't unmap VRING at ExitBootServices()
  OvmfPkg/VirtioGpuDxe: don't unmap VRING & BackingStore at
ExitBootServices
  OvmfPkg/VirtioRngDxe: don't unmap VRING at ExitBootServices()
  OvmfPkg/VirtioScsiDxe: don't unmap VRING at ExitBootServices()
  OvmfPkg/IoMmuDxe: track all mappings
  OvmfPkg/IoMmuDxe: generalize IoMmuUnmap() to IoMmuUnmapWorker()
  OvmfPkg/IoMmuDxe: unmap all IOMMU mappings at ExitBootServices()

 MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 103 +---
 MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h |   7 +
 OvmfPkg/IoMmuDxe/AmdSevIoMmu.c   | 246 
+---
 OvmfPkg/VirtioBlkDxe/VirtioBlk.c |   7 +-
 OvmfPkg/VirtioGpuDxe/Commands.c  |  23 +-
 OvmfPkg/VirtioRngDxe/VirtioRng.c |   7 +-
 OvmfPkg/VirtioScsiDxe/VirtioScsi.c   |   7 +-
 7 files changed, 299 insertions(+), 101 deletions(-)

--
2.14.1.3.gb7cf6e02401b

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at ExitBootServices

2017-09-08 Thread Yao, Jiewen
Patch 1~3 reviewed-by: jiewen@intel.com


> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Friday, September 8, 2017 6:41 AM
> To: edk2-devel-01 
> Cc: Ard Biesheuvel ; Brijesh Singh
> ; Dong, Eric ; Yao, Jiewen
> ; Justen, Jordan L ; Zeng,
> Star 
> Subject: [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at
> ExitBootServices
> 
> Repo:   https://github.com/lersek/edk2.git
> Branch: iommu_exit_boot
> 
> This series is the result of the discussion under
> 
>   [edk2] [PATCH 0/4] MdeModulePkg: some PCI HC drivers: unmap common
>  buffers at ExitBootServices()
>   https://lists.01.org/pipermail/edk2-devel/2017-September/014099.html
> 
> At ExitBootServices(), PCI and VirtIo drivers should only care about
> aborting pending DMA on the devices. Cleaning up PciIo mappings (which
> ultimately boil down to IOMMU mappings) for those aborted DMA operations
> should be the job of the IOMMU driver.
> 
> Patches 01 through 03 clean up the AtaAtapiPassThru driver in
> MdeModulePkg a little bit, because at present, (a) it unmaps the buffers
> and disables BMDMA in the wrong order in its DriverBindingStop()
> function, (b) it doesn't abort pending DMA at ExitBootServices().
> 
> This subset can be treated separately from the rest of the series, but I
> thought they belonged loosely together (given that AtaAtapiPassThru is
> used on QEMU's Q35 machine type).
> 
> Patches 04 through 07 remove
> VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer()
> calls from the VirtIo drivers' ExitBootServices() handlers.
> 
> (The conversion of VirtioNetDxe to device addresses is still in progress
> -- Brijesh, when you submit v2 of that, under this approach, there is no
> need to change VirtioNetExitBoot() relative to current upstream, and you
> can use VirtioOperationBusMasterRead to map outgoing packets.)
> 
> Patches 08 through 10 make OvmfPkg/IoMmuDxe track all mappings, and
> unmap all mappings (Read, Write, CommonBuffer) that are in effect when
> ExitBootServices() is called. It is ensured that PCI and VirtIo drivers
> abort pending DMA first, and IoMmuDxe clean up the mappings last.
> 
> Cc: Ard Biesheuvel 
> Cc: Brijesh Singh 
> Cc: Eric Dong 
> Cc: Jiewen Yao 
> Cc: Jordan Justen 
> Cc: Star Zeng 
> 
> Thanks
> Laszlo
> 
> Laszlo Ersek (10):
>   MdeModulePkg/AtaAtapiPassThru: cache EnabledPciAttributes
>   MdeModulePkg/AtaAtapiPassThru: unmap DMA buffers after disabling BM
> DMA
>   MdeModulePkg/AtaAtapiPassThru: disable the device at
> ExitBootServices()
>   OvmfPkg/VirtioBlkDxe: don't unmap VRING at ExitBootServices()
>   OvmfPkg/VirtioGpuDxe: don't unmap VRING & BackingStore at
> ExitBootServices
>   OvmfPkg/VirtioRngDxe: don't unmap VRING at ExitBootServices()
>   OvmfPkg/VirtioScsiDxe: don't unmap VRING at ExitBootServices()
>   OvmfPkg/IoMmuDxe: track all mappings
>   OvmfPkg/IoMmuDxe: generalize IoMmuUnmap() to IoMmuUnmapWorker()
>   OvmfPkg/IoMmuDxe: unmap all IOMMU mappings at ExitBootServices()
> 
>  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 103 +---
>  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h |   7 +
>  OvmfPkg/IoMmuDxe/AmdSevIoMmu.c   | 246
> +---
>  OvmfPkg/VirtioBlkDxe/VirtioBlk.c |   7 +-
>  OvmfPkg/VirtioGpuDxe/Commands.c  |  23 +-
>  OvmfPkg/VirtioRngDxe/VirtioRng.c |   7 +-
>  OvmfPkg/VirtioScsiDxe/VirtioScsi.c   |   7 +-
>  7 files changed, 299 insertions(+), 101 deletions(-)
> 
> --
> 2.14.1.3.gb7cf6e02401b

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017 2/2] BroxtonPlatformPkg: RTC initialize

2017-09-08 Thread zwei4
Force RTC century to 20 in case core driver has failed to
initialize it.

Contributed-under: TianoCore Contribution Agreement 1.1

Signed-off-by: zwei4 
---
 .../Common/PlatformSettings/PlatformDxe/Platform.c |  5 +++
 .../PlatformSettings/PlatformDxe/PlatformDxe.h |  6 +++
 .../PlatformSettings/PlatformDxe/PlatformDxe.inf   |  1 +
 .../Common/PlatformSettings/PlatformDxe/Rtc.c  | 51 ++
 4 files changed, 63 insertions(+)
 create mode 100644 
Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Rtc.c

diff --git 
a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Platform.c 
b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Platform.c
index abe635d90..a6d251ded 100644
--- a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Platform.c
+++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Platform.c
@@ -390,6 +390,11 @@ ReadyToBootFunction (
 mPciLanInfo = NULL;
   }
 
+  //
+  // Set RTC century in case RTC core driver failed to initialize it.
+  //
+  AdjustRtcCentury ();
+
   return;
 }
 
diff --git 
a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.h 
b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.h
index 1475c4cab..a27277bb7 100644
--- 
a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.h
+++ 
b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.h
@@ -235,6 +235,12 @@ InitSioPlatformPolicy (
   VOID
   );
 
+VOID
+EFIAPI
+AdjustRtcCentury (
+  VOID
+  );
+
 //
 // Global externs
 //
diff --git 
a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf
 
b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf
index 7516a1548..ee8fd5a68 100644
--- 
a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf
+++ 
b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf
@@ -33,6 +33,7 @@
   PciDevice.c
   IchTcoReset.c
   SensorVar.c
+  Rtc.c
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git 
a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Rtc.c 
b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Rtc.c
new file mode 100644
index 0..4b6ab285e
--- /dev/null
+++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Rtc.c
@@ -0,0 +1,51 @@
+/** @file
+  Adjust Default System Time.
+  
+  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+   

+  This program and the accompanying materials are licensed and made available 
under
+  the terms and conditions of the BSD License that 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 
+
+//
+// Date and time initial values.
+// They are used if the RTC values are invalid during driver initialization
+//
+#define RTC_INIT_SECOND 0
+#define RTC_INIT_MINUTE 0
+#define RTC_INIT_HOUR   0
+
+#define RTC_ADDRESS_CENTURY  50
+
+#define RTC_ADDRESS_REGISTER 0x70
+#define RTC_DATA_REGISTER0x71
+
+/**
+  Set RTC century to 20 in case RTC core driver failed to initialize it.
+
+**/
+VOID
+EFIAPI
+AdjustRtcCentury (
+  VOID
+  )
+{
+
+  UINT8  Century;
+
+  Century = 20;
+  Century = DecimalToBcd8 (20);
+  IoWrite8 (RTC_ADDRESS_REGISTER, (UINT8) (RTC_ADDRESS_CENTURY | (UINT8) 
(IoRead8 (PCAT_RTC_ADDRESS_REGISTER) & 0x80)));
+  IoWrite8 (RTC_DATA_REGISTER, Century);
+  Century = IoRead8(RTC_DATA_REGISTER);
+
+  return;
+}
-- 
2.14.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017 1/2] Clean up CMOS code.

2017-09-08 Thread zwei4
Contributed-under: TianoCore Contribution Agreement 1.1

Signed-off-by: zwei4 
---
 .../Library/BaseSerialPortLib/BaseSerialPortLib.c  | 69 +++---
 .../BaseSerialPortLib/BaseSerialPortLib.inf|  3 +-
 .../BaseSerialPortLib/BaseSerialPortLibNoInit.c| 46 ++-
 .../BaseSerialPortLib/BaseSerialPortLibNoInit.inf  |  3 +-
 .../Library/PlatformSecLib/Vtf0PlatformSecLib.inf  |  1 -
 .../Common/PlatformSettings/PlatformDxe/Platform.c | 25 
 .../PlatformSettings/PlatformDxe/PlatformDxe.inf   |  1 -
 .../PlatformDsc/LibraryClasses.IA32.PEI.dsc|  1 -
 .../PlatformDsc/LibraryClasses.dsc |  6 --
 .../PlatformDsc/PcdsFixedAtBuild.dsc   |  2 -
 10 files changed, 15 insertions(+), 142 deletions(-)

diff --git 
a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.c
 
b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.c
index 5fc9d8c71..2c63f9878 100644
--- 
a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.c
+++ 
b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.c
@@ -1,7 +1,7 @@
 /** @file
   Serial I/O Port library functions with no library constructor/destructor.
 
-  Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
@@ -18,9 +18,7 @@
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
 #include 
 
 #ifdef TRACE_HUB_DEBUGLIB_USAGE
@@ -104,13 +102,12 @@ UARTInitialize (
   //
   // Calculate divisor for baud generator
   //
-  BaudRate = GetSerialPortBaudRate ();
+  BaudRate = PcdGet32 (PcdSerialBaudRate);
   if ((BaudRate == 0) || ((BaudRate % 9600) != 0)) {
 //
 // If Serail Baud Rate is not valid, set it to the default value
 //
 BaudRate = PcdGet32 (PcdSerialBaudRate);
-SetSerialPortBaudRate (BaudRate);
   }
   Divisor = MAX_BAUD_RATE / BaudRate;
 
@@ -174,23 +171,8 @@ SerialPortInitialize (
   VOID
   )
 {
-  UINT8  CmosStatusCodeFlags;
 
-  CmosStatusCodeFlags = GetDebugInterface ();
-  if ((!(CmosStatusCodeFlags & STATUS_CODE_CMOS_VALID)) || 
(CmosStatusCodeFlags & STATUS_CODE_CMOS_INVALID)) {
-CmosStatusCodeFlags = STATUS_CODE_USE_SERIALIO | STATUS_CODE_CMOS_VALID;
-SetDebugInterface (CmosStatusCodeFlags);
-  }
-  //
-  // no init for MEM
-  //
-
-  if (CmosStatusCodeFlags & STATUS_CODE_USE_SERIALIO) {
-PchSerialIoUartInit (PcdGet8 (PcdSerialIoUartNumber), TRUE, 115200, 3, 
FALSE);
-  }
-  //
-  // no init for TRACEHUB
-  //
+  PchSerialIoUartInit (PcdGet8 (PcdSerialIoUartNumber), TRUE, 115200, 3, 
FALSE);
 
   return RETURN_SUCCESS;
 }
@@ -307,19 +289,8 @@ SerialPortWrite (
   IN UINTN NumberOfBytes
   )
 {
-  UINT8CmosStatusCodeFlags;
 
-  CmosStatusCodeFlags = GetDebugInterface ();
-  if ((!(CmosStatusCodeFlags & STATUS_CODE_CMOS_VALID)) || 
(CmosStatusCodeFlags & STATUS_CODE_CMOS_INVALID)) {
-//
-// invalid cmos value, it means action was attempted before Init
-//
-return RETURN_NOT_READY;
-  }
-
-  if (CmosStatusCodeFlags & STATUS_CODE_USE_SERIALIO) {
-PchSerialIoUartOut (PcdGet8 (PcdSerialIoUartNumber), Buffer, 
NumberOfBytes);
-  }
+  PchSerialIoUartOut (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes);
 
   return RETURN_SUCCESS;
 }
@@ -399,21 +370,9 @@ SerialPortRead (
   IN  UINTN NumberOfBytes
   )
 {
-  UINT8CmosStatusCodeFlags;
-
-  CmosStatusCodeFlags = GetDebugInterface ();
 
-  if ((!(CmosStatusCodeFlags & STATUS_CODE_CMOS_VALID)) || 
(CmosStatusCodeFlags & STATUS_CODE_CMOS_INVALID)) {
-//
-// invalid cmos value, it means action was attempted before Init
-//
-return RETURN_NOT_READY;
-  }
-
-
-  if (CmosStatusCodeFlags & STATUS_CODE_USE_SERIALIO) {
-PchSerialIoUartIn (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes, 
FALSE);
-  }
+  PchSerialIoUartIn (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes, 
FALSE);
+ 
   return RETURN_SUCCESS;
 }
 
@@ -475,23 +434,11 @@ SerialPortPoll (
   VOID
   )
 {
-  UINT8 CmosStatusCodeFlags;
-  BOOLEAN   Status;
-
-  CmosStatusCodeFlags = GetDebugInterface ();
-  if ((!(CmosStatusCodeFlags & STATUS_CODE_CMOS_VALID)) || 
(CmosStatusCodeFlags & STATUS_CODE_CMOS_INVALID)) {
 
-//
-// invalid cmos value, it means action was attempted before Init
-//
-return FALSE;
-  }
+  BOOLEAN   Status;
 
   Status = FALSE;
-
-  if (CmosStatusCodeFlags & STATUS_CODE_USE_SERIALIO) {
-Status |= PchSerialIoUartPoll (PcdGet8 (PcdSerialIoUartNumber));
-  }
+  Status |= PchSerialIoUartPoll (PcdGet8 (PcdSerialIoUartNumber));
 
   return Status;
 }
diff --git 
a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.inf
 

[edk2] [PATCH v2] BaseTools/GCC: set -Wno-unused-const-variables on RELEASE builds

2017-09-08 Thread Thomas Lamprecht
TianoCore BZ#700 [1]

Set the '-Wno-unused-const-variables' in RELEASE builds with the
GGC49 and GCC5 toolchain.

This fixes the RELEASE build of OVMF with GCC in version 6 or newer.
GCC 6 added the '-Wunused-const-variable' warning, which gets
activated by '-Wunused-variable' and has the following behavior:
"Warn whenever a constant static variable is unused aside from its
declaration" [2]

Commit 2ad6ba80a1bd58382bde6b994070f7c01d2fb48d introduced a case
where exactly this happens on a RELEASE build. All uses of the static
const variable are located in debug code only, which gets thrown out
by the compiler on RELEASE builds and thus triggers the
unused-const-variable warning.

There is currently no GCC 6 toolchain target defined and doing so
would add a lot of boilerplate code. Instead, use the fact that GCC
ignores unknown '-Wno-*' options:

"[...] if the -Wno- form is used [...] no diagnostic is produced for
-Wno-unknown-warning unless other diagnostics are being produced"

This behavior is available in GCC 4.9 [3] (and also earlier, for that
matter), so add the flag to the GCC49 and GCC5 toolchain, even if
both GCC versions do not supports it.
GCC49 doesn't enables LTO whereas GCC5 does. As GCC 6.0 through 6.2
had bugs relating to LTO there can be desire to use the GCC49 target
even if compiling with GCC 6, see 432f1d83f77a.

Orient the changes on 20d00edf21d2 which moved the
'-Wno-unused-but-set-variable' flag to RELEASE builds only, as there
it ensure that it does not gets raised if the only usage of a
variable is in (then collapsed) debug code.

[1] https://bugzilla.tianocore.org/show_bug.cgi?id=700
[2] 
https://gcc.gnu.org/onlinedocs/gcc-6.4.0/gcc/Warning-Options.html#index-Wunused-const-variable
[3] https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Warning-Options.html

Cc: Yonghong Zhu 
Cc: Liming Gao 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Thomas Lamprecht 
---

changes v1 -> v2:
 * add the flag also to the GCC49 toolchain to allow using GCC 6 with
   LTO disabled builds, thanks for the hints Laszlo and Liming!
 * adapt commit message slightly, especially to the fact that GCC49
   gets the flag now too.
 * CC Ard

 BaseTools/Conf/tools_def.template | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index ba1d1a16de..cbb5024c1b 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -5179,7 +5179,7 @@ RELEASE_GCC48_AARCH64_CC_FLAGS   = 
DEF(GCC48_AARCH64_CC_FLAGS) -Wno-unused-but-s
 *_GCC49_IA32_NASM_FLAGS   = -f elf32
 
   DEBUG_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os
-RELEASE_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os 
-Wno-unused-but-set-variable
+RELEASE_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os 
-Wno-unused-but-set-variable -Wno-unused-const-variable
   NOOPT_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -O0
 
 ##
@@ -5207,7 +5207,7 @@ RELEASE_GCC49_IA32_CC_FLAGS   = 
DEF(GCC49_IA32_CC_FLAGS) -Os -Wno-unused-but
 *_GCC49_X64_NASM_FLAGS   = -f elf64
 
   DEBUG_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os
-RELEASE_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os 
-Wno-unused-but-set-variable
+RELEASE_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os 
-Wno-unused-but-set-variable -Wno-unused-const-variable
   NOOPT_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -O0
 
 ##
@@ -5240,7 +5240,7 @@ RELEASE_GCC49_X64_CC_FLAGS   = 
DEF(GCC49_X64_CC_FLAGS) -Os -Wno-unused-but-s
 *_GCC49_ARM_CC_XIPFLAGS  = DEF(GCC49_ARM_CC_XIPFLAGS)
 
   DEBUG_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) -O0
-RELEASE_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) 
-Wno-unused-but-set-variable
+RELEASE_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) 
-Wno-unused-but-set-variable -Wno-unused-const-variable
   NOOPT_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) -O0
 
 ##
@@ -5272,7 +5272,7 @@ RELEASE_GCC49_ARM_CC_FLAGS   = 
DEF(GCC49_ARM_CC_FLAGS) -Wno-unused-but-set-v
   DEBUG_GCC49_AARCH64_DLINK_FLAGS  = DEF(GCC49_AARCH64_DLINK_FLAGS) -z 
common-page-size=0x1000
   DEBUG_GCC49_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
 
-RELEASE_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) 
-Wno-unused-but-set-variable -mcmodel=tiny -fomit-frame-pointer
+RELEASE_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) 
-Wno-unused-but-set-variable -Wno-unused-const-variable -mcmodel=tiny 
-fomit-frame-pointer
 RELEASE_GCC49_AARCH64_DLINK_FLAGS  = DEF(GCC49_AARCH64_DLINK_FLAGS)
 
   NOOPT_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) -O0 
-mcmodel=small
@@ -5326,7 +5326,7 @@ RELEASE_GCC49_AARCH64_DLINK_FLAGS  = 

[edk2] StartImage() return value an error or return code ?

2017-09-08 Thread David F.
Hi,

Is there a way to tell if the return code from StartImage() is
actually an error from StartImage() vs the exit code of some
application (generic application that may return an error code value
but not set exitdata).It would seem to conflict with
EFI_INVALID_PARAMETER and EFI_SECURITY_VIOLATION  so where actual
value came from is unknown?

TIA!!
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] BaseTools/GCC5: set -Wno-unused-const-variables on RELEASE builds

2017-09-08 Thread Thomas Lamprecht

On 09/07/2017 06:48 PM, Laszlo Ersek wrote:

On 09/07/17 17:04, Gao, Liming wrote:

I suggest to also add this option in GCC49 tool chain RELEASE builds. GCC49 can 
be used for GCC 4.9 or the above version. It doesn't enable LTO.


Good idea. There could be several reasons for picking GCC49; see e.g.
commit 432f1d83f77a ("OvmfPkg/build.sh: Use GCC49 toolchains with GCC
6.[0-2]", 2016-12-06).



My rationale was to add it just to the "newest" ancestor of GCC 6 so
that it could be even removed if in the future a GCC6 toolchain target
still would get added, to reduce the "impact" of an unrecognized
option warning on diagnostic output.

But thanks to pointing out why it can make sense to use the GCC49
target even with GCC 6.


Thomas, can you please CC Ard on v2?


Yes, will do so.

cheers,
Thomas



Thank you!
Laszlo



-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Thomas 
Lamprecht
Sent: Thursday, September 7, 2017 10:55 PM
To: edk2-devel@lists.01.org
Cc: Laszlo Ersek ; Gao, Liming 
Subject: [edk2] [PATCH] BaseTools/GCC5: set -Wno-unused-const-variables on 
RELEASE builds

TianoCore BZ#700 

This fixes the RELEASE build of OVMF with GCC in version 6 or newer.
GCC 6 added the '-Wunused-const-variable' warning, which gets
activated by '-Wunused-variable' and has the following behavior:
"Warn whenever a constant static variable is unused aside from its
declaration" [1]

Commit 2ad6ba80a1bd58382bde6b994070f7c01d2fb48d introduced a case
where exactly this happens on a RELEASE build. All uses of the static
const variable are located in debug code only, which gets thrown out
by the compiler on RELEASE builds and thus triggers the
unused-const-variable warning.

There is currently no GCC 6 toolchain target defined and doing so
would add a lot of boilerplate code. Instead, use the fact that GCC
ignores unkown '-Wno-*' options:

"[...] if the -Wno- form is used [...] no diagnostic is produced for
-Wno-unknown-warning unless other diagnostics are being produced"

This behavior is available in GCC 5 [2] (and also earlier, for that
matter), so add the flag to the GCC5 toolchain, even if GCC 5 itself
does not supports it.

Orient the changes on 20d00edf21d2 which moved the
'-Wno-unused-but-set-variable' flag to RELEASE builds only, as there
it ensure that it does not gets raised if the only usage of a
variable is in (then collapsed) debug code.

[1] 
https://gcc.gnu.org/onlinedocs/gcc-6.4.0/gcc/Warning-Options.html#index-Wunused-const-variable
[2] https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/Warning-Options.html

Cc: Yonghong Zhu 
Cc: Liming Gao 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Thomas Lamprecht 
---

I hope I CCed the correct people and got the style right :)

  BaseTools/Conf/tools_def.template | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index ba1d1a16de..7db7a174c3 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -5326,7 +5326,7 @@ RELEASE_GCC49_AARCH64_DLINK_FLAGS  = 
DEF(GCC49_AARCH64_DLINK_FLAGS)
DEBUG_GCC5_IA32_CC_FLAGS   = DEF(GCC5_IA32_CC_FLAGS) -flto -Os
DEBUG_GCC5_IA32_DLINK_FLAGS= DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Os 
-Wl,-m,elf_i386,--oformat=elf32-i386

-RELEASE_GCC5_IA32_CC_FLAGS   = DEF(GCC5_IA32_CC_FLAGS) -flto -Os 
-Wno-unused-but-set-variable
+RELEASE_GCC5_IA32_CC_FLAGS   = DEF(GCC5_IA32_CC_FLAGS) -flto -Os 
-Wno-unused-but-set-variable
-Wno-unused-const-variable
  RELEASE_GCC5_IA32_DLINK_FLAGS= DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Os 
-Wl,-m,elf_i386,--oformat=elf32-i386

NOOPT_GCC5_IA32_CC_FLAGS   = DEF(GCC5_IA32_CC_FLAGS) -O0
@@ -5358,7 +5358,7 @@ RELEASE_GCC5_IA32_DLINK_FLAGS= 
DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Os -Wl,
DEBUG_GCC5_X64_CC_FLAGS= DEF(GCC5_X64_CC_FLAGS) -flto -DUSING_LTO 
-Os
DEBUG_GCC5_X64_DLINK_FLAGS = DEF(GCC5_X64_DLINK_FLAGS) -flto -Os

-RELEASE_GCC5_X64_CC_FLAGS= DEF(GCC5_X64_CC_FLAGS) -flto -DUSING_LTO 
-Os -Wno-unused-but-set-variable
+RELEASE_GCC5_X64_CC_FLAGS= DEF(GCC5_X64_CC_FLAGS) -flto -DUSING_LTO 
-Os -Wno-unused-but-set-variable
-Wno-unused-const-variable
  RELEASE_GCC5_X64_DLINK_FLAGS = DEF(GCC5_X64_DLINK_FLAGS) -flto -Os

NOOPT_GCC5_X64_CC_FLAGS= DEF(GCC5_X64_CC_FLAGS) -O0
@@ -5393,7 +5393,7 @@ RELEASE_GCC5_X64_DLINK_FLAGS = 
DEF(GCC5_X64_DLINK_FLAGS) -flto -Os
DEBUG_GCC5_ARM_CC_FLAGS= DEF(GCC5_ARM_CC_FLAGS) -O0
DEBUG_GCC5_ARM_DLINK_FLAGS = DEF(GCC5_ARM_DLINK_FLAGS)

-RELEASE_GCC5_ARM_CC_FLAGS= DEF(GCC5_ARM_CC_FLAGS) -flto 
-Wno-unused-but-set-variable
+RELEASE_GCC5_ARM_CC_FLAGS= DEF(GCC5_ARM_CC_FLAGS) 

Re: [edk2] [PATCH v5 0/6] read-only UDF file system support

2017-09-08 Thread Ni, Ruiyu
Reviewed-by: Ruiyu Ni 

Thanks/Ray

> -Original Message-
> From: Paulo Alcantara [mailto:pca...@zytor.com]
> Sent: Friday, September 8, 2017 8:56 AM
> To: edk2-devel@lists.01.org
> Cc: Laszlo Ersek ; Justen, Jordan L
> ; Andrew Fish ; Kinney,
> Michael D ; Gao, Liming
> ; Zeng, Star ; Dong, Eric
> ; Doran, Mark ; Ni, Ruiyu
> ; Wu, Hao A 
> Subject: Re: [PATCH v5 0/6] read-only UDF file system support
> 
> Ray,
> 
> On 07/09/2017 20:13, Paulo Alcantara wrote:
> > v5:
> >   - Fixed OVMF IA32 build.
> >   - Fixed a typo in UdfDriveBindingStop() ("This" -> "SimpleFs") which
> > broke retrieval of private fs data from SimpleFs protocol --
> > identified by 'reconnect -r' command in UEFI shell.
> 
> Follow the diff between v4 and v5 for Mde*Pkg changes (forgot to include it
> when resending):
> 
> diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> index 8ad14fe594..2dbcff0be4 100644
> --- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> +++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> @@ -372,7 +372,7 @@ UdfRead (
> PrivFileData->FileSize,
> >FilePosition,
> Buffer,
> -  BufferSize
> +  (UINT64 *)(UINTN)BufferSize^M
> );
> } else if (IS_FID_DIRECTORY_FILE (Parent->FileIdentifierDesc)) {
>   if (ReadDirInfo->FidOffset == 0 && PrivFileData->FilePosition > 0) { 
> diff --
> git a/MdeModulePkg/Universal/Disk/UdfDxe/Udf.c
> b/MdeModulePkg/Universal/Disk/UdfDxe/Udf.c
> index 9f10c78ca9..49dc7077b7 100644
> --- a/MdeModulePkg/Universal/Disk/UdfDxe/Udf.c
> +++ b/MdeModulePkg/Universal/Disk/UdfDxe/Udf.c
> @@ -264,7 +264,7 @@ UdfDriverBindingStop (
>   EFI_OPEN_PROTOCOL_GET_PROTOCOL
>   );
> if (!EFI_ERROR (Status)) {
> -PrivFsData = PRIVATE_UDF_SIMPLE_FS_DATA_FROM_THIS (This);
> +PrivFsData = PRIVATE_UDF_SIMPLE_FS_DATA_FROM_THIS
> (SimpleFs);^M
> 
>   //
>   // Uninstall child handle
> 
> 
> Thanks,
> Paulo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017] Ubuntu boot

2017-09-08 Thread xianhu2x
Add Ubuntu boot loader file path \\EFI\\UBUNTU\\GRUBX64.EFI into known OS 
loader list.

Contributed-under: TianoCore Contribution Agreement 1.1

Signed-off-by: xianhu2x 
---
 .../Library/GenericBdsLib/BdsBoot.c| 28 ++
 Core/MdePkg/Include/Uefi/UefiSpec.h| 11 +
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/Core/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c 
b/Core/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
index d1da635f3..ce1dd4a0b 100644
--- a/Core/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
+++ b/Core/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
@@ -2384,6 +2384,22 @@ BdsLibBootViaBootOption (
   0,
   
   );
+
+  if (EFI_ERROR(Status)) {
+//
+//Try Ubuntu boot loader
+//
+FilePath = FileDevicePath (Handle, 
EFI_REMOVABLE_MEDIA_FILE_NAME_UBUNTU_X64);
+Status = gBS->LoadImage (
+TRUE,
+gImageHandle,
+FilePath,
+NULL,
+0,
+
+);
+  }
+   
 }
   }
 }
@@ -3721,6 +3737,18 @@ BdsLibGetBootableHandle (
  ,
  Hdr
  );
+
+  if (EFI_ERROR(Status)) {
+//
+//Try Ubuntu boot loader
+//
+Status = BdsLibGetImageHeader (
+   SimpleFileSystemHandles[Index],
+   EFI_REMOVABLE_MEDIA_FILE_NAME_UBUNTU_X64,
+   ,
+   Hdr
+   );
+  }
   if (!EFI_ERROR (Status) &&
 EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Hdr.Pe32->FileHeader.Machine) &&
 Hdr.Pe32->OptionalHeader.Subsystem == 
EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) {
diff --git a/Core/MdePkg/Include/Uefi/UefiSpec.h 
b/Core/MdePkg/Include/Uefi/UefiSpec.h
index 57cb4e804..e5556952b 100644
--- a/Core/MdePkg/Include/Uefi/UefiSpec.h
+++ b/Core/MdePkg/Include/Uefi/UefiSpec.h
@@ -2166,11 +2166,12 @@ typedef struct {
 //
 // EFI File location to boot from on removable media devices
 //
-#define EFI_REMOVABLE_MEDIA_FILE_NAME_IA32L"\\EFI\\BOOT\\BOOTIA32.EFI"
-#define EFI_REMOVABLE_MEDIA_FILE_NAME_IA64L"\\EFI\\BOOT\\BOOTIA64.EFI"
-#define EFI_REMOVABLE_MEDIA_FILE_NAME_X64 L"\\EFI\\BOOT\\BOOTX64.EFI"
-#define EFI_REMOVABLE_MEDIA_FILE_NAME_ARM L"\\EFI\\BOOT\\BOOTARM.EFI"
-#define EFI_REMOVABLE_MEDIA_FILE_NAME_AARCH64 L"\\EFI\\BOOT\\BOOTAA64.EFI"
+#define EFI_REMOVABLE_MEDIA_FILE_NAME_IA32   L"\\EFI\\BOOT\\BOOTIA32.EFI"
+#define EFI_REMOVABLE_MEDIA_FILE_NAME_IA64   L"\\EFI\\BOOT\\BOOTIA64.EFI"
+#define EFI_REMOVABLE_MEDIA_FILE_NAME_X64L"\\EFI\\BOOT\\BOOTX64.EFI"
+#define EFI_REMOVABLE_MEDIA_FILE_NAME_ARML"\\EFI\\BOOT\\BOOTARM.EFI"
+#define EFI_REMOVABLE_MEDIA_FILE_NAME_AARCH64L"\\EFI\\BOOT\\BOOTAA64.EFI"
+#define EFI_REMOVABLE_MEDIA_FILE_NAME_UBUNTU_X64 L"\\EFI\\UBUNTU\\GRUBX64.EFI"
 
 #if   defined (MDE_CPU_IA32)
   #define EFI_REMOVABLE_MEDIA_FILE_NAME   EFI_REMOVABLE_MEDIA_FILE_NAME_IA32
-- 
2.14.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel