Re: [edk2] [Patch] Maintainers.txt: Update maintainers for MdeModulePkg

2017-05-02 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Zeng, Star 
Sent: Wednesday, May 3, 2017 10:33 AM
To: Dong, Eric <eric.d...@intel.com>; edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Zeng, Star <star.z...@intel.com>
Subject: RE: [Patch] Maintainers.txt: Update maintainers for MdeModulePkg

Reviewed-by: Star Zeng <star.z...@intel.com>

Thanks,
Star
-Original Message-
From: Dong, Eric 
Sent: Wednesday, May 3, 2017 10:23 AM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Zeng, Star <star.z...@intel.com>
Subject: [Patch] Maintainers.txt: Update maintainers for MdeModulePkg

Cc: Feng Tian <feng.t...@intel.com>
Cc: Zeng Star <star.z...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.d...@intel.com>
---
 Maintainers.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Maintainers.txt b/Maintainers.txt index 77df275..f412b65 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -152,8 +152,8 @@ M: Giri P Mudusuru <giri.p.mudus...@intel.com>
 
 MdeModulePkg
 W: https://github.com/tianocore/tianocore.github.io/wiki/MdeModulePkg
-M: Feng Tian <feng.t...@intel.com>
 M: Star Zeng <star.z...@intel.com>
+M: Eric Dong <eric.d...@intel.com>
 
 MdePkg
 W: https://github.com/tianocore/tianocore.github.io/wiki/MdePkg
--
2.7.0.windows.1

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


Re: [edk2] [PATCH] UefiCpuPkg: Move ProgramVirtualWireMode() to MpInitLib

2017-04-25 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

-Original Message-
From: Fan, Jeff 
Sent: Friday, April 21, 2017 1:30 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>
Subject: [PATCH] UefiCpuPkg: Move ProgramVirtualWireMode() to MpInitLib

In PEI phase, BSP did not program vitural wired mode while APs did.

Move program virtual wired mode from CpuDxe to MpInitLib, thus it could benefit 
on both CpuDxe and CpuMpPei.

https://bugzilla.tianocore.org/show_bug.cgi?id=496

Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/CpuDxe/CpuDxe.c   | 5 -
 UefiCpuPkg/Library/MpInitLib/MpLib.c | 4 
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c index 
4a5e282..8680656 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -1136,11 +1136,6 @@ InitializeCpu (
   InitInterruptDescriptorTable ();
 
   //
-  // Enable the local APIC for Virtual Wire Mode.
-  //
-  ProgramVirtualWireMode ();
-
-  //
   // Install CPU Architectural Protocol
   //
   Status = gBS->InstallMultipleProtocolInterfaces ( diff --git 
a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 03d6c2d..e5e211d 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -1364,6 +1364,10 @@ MpInitLibInitialize (
   // Store BSP's MTRR setting
   //
   MtrrGetAllMtrrs (>MtrrTable);
+  //
+  // Enable the local APIC for Virtual Wire Mode.
+  //
+  ProgramVirtualWireMode ();
 
   if (OldCpuMpData == NULL) {
 if (MaxLogicalProcessorNumber > 1) {
--
2.9.3.windows.2

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


Re: [edk2] [PATCH v2] UefiCpuPkg/MpLib.c: Set AP state after X2APIC mode enabled

2017-04-25 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

-Original Message-
From: Fan, Jeff 
Sent: Tuesday, April 25, 2017 2:54 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>
Subject: [PATCH v2] UefiCpuPkg/MpLib.c: Set AP state after X2APIC mode enabled

After X2APIC mode is enabled, APs need to be set tp IDLE state, otherwise APs 
cannot be waken up by MP PPI services.

https://bugzilla.tianocore.org/show_bug.cgi?id=505

Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/Library/MpInitLib/MpLib.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 03d6c2d..e502e36 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -434,6 +434,8 @@ CollectProcessorCount (
   IN CPU_MP_DATA *CpuMpData
   )
 {
+  UINTN  Index;
+
   //
   // Send 1st broadcast IPI to APs to wakeup APs
   //
@@ -465,6 +467,12 @@ CollectProcessorCount (
 // Enable x2APIC on BSP
 //
 SetApicMode (LOCAL_APIC_MODE_X2APIC);
+//
+// Set BSP/Aps state to IDLE
+//
+for (Index = 0; Index < CpuMpData->CpuCount; Index++) {
+  SetApState (>CpuData[Index], CpuStateIdle);
+}
   }
   DEBUG ((DEBUG_INFO, "APIC MODE is %d\n", GetApicMode ()));
   //
--
2.9.3.windows.2

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


Re: [edk2] [PATCH 0/2] Borrow the space below 1MB for AP reset vector

2017-04-24 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Fan, Jeff 
Sent: Friday, April 21, 2017 2:04 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>
Subject: [PATCH 0/2] Borrow the space below 1MB for AP reset vector

Current, CpuMpPei will find the available memory space below 1MB for AP reset 
vector. And CpuMpPei will build resource HOB on this range to prevent other PEI 
modules to use this range.

However, on some FSP usage model, this range maybe used by the code out of FSP.
CpuMpPei may change the original memory contents and cause other code crash.

We could update CpuMpPei not to change the original contents of this range 
around AP waking up. Thus, it will not impact the other code on FSP usage model.

This updating is tiny and less impact on performance.

https://bugzilla.tianocore.org/show_bug.cgi?id=500

Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>

Jeff Fan (2):
  UefiCpuPkg/MpInitLib: save/restore original contents
  UefiCpuPkg/MpInitLib: needn't to allocate AP reset vector

 UefiCpuPkg/Library/MpInitLib/MpLib.h  |  22 +-
 UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf |   6 +-
 UefiCpuPkg/Library/MpInitLib/PeiMpLib.c   | 107 +-
 3 files changed, 5 insertions(+), 130 deletions(-)

--
2.9.3.windows.2

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


Re: [edk2] [PATCH 0/2] MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init

2017-04-19 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

-Original Message-
From: Wu, Hao A 
Sent: Wednesday, March 22, 2017 9:28 AM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A <hao.a...@intel.com>; Tian, Feng <feng.t...@intel.com>
Subject: [PATCH 0/2] MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices 
during init

The series changes the UFS host to wait for the device to clear the 
'fDeviceInit' bit by a device after setting this flag.

The series also cleans up the usages of 'EFI_D_XXX' and replaces them with 
'DEBUG_XXX' in DEBUG().

Cc: Feng Tian <feng.t...@intel.com>

Hao Wu (2):
  MdeModulePkg/UfsPassThruDxe: Replace 'EFI_D_XXX' with 'DEBUG_XXX'
  MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init

 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c|  89 ++--
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h|  53 ++-
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 471 +---
 3 files changed, 312 insertions(+), 301 deletions(-)

--
2.12.0.windows.1

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


Re: [edk2] NvmExpressDxe async application crash with UDK debugger

2017-04-11 Thread Tian, Feng
Arka,

Could you please share us your test code?

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Arka 
Sharma
Sent: Wednesday, April 12, 2017 12:59 PM
To: edk2-devel@lists.01.org
Subject: [edk2] NvmExpressDxe async application crash with UDK debugger

Hi,

I am testing async io in NvmExpressDxe. The target system is Asrock
Z97 which I have connected to host with serial port where UDK debugger is 
running. So my application does following

1. CreateEvent
2. Call Passthru
3. CmdSent++;
4. Repeat 1-3 until not ready from driver 5. while (CmdRecd < CmdSent); 4. 
Close all the events.

CmdRecvd is incremented inside EventCallback. I am allocating both CmdSent and 
CmdRecvd and passing the address of CmdRecvd in CreateEvent. With this I face 
WinDbg exception quite often and it says "Target encountered an exception: 
Vector = 6, Error Code = ".
I can share the application code for more clarity. I am building with /Od and 
GenFw with --keepexceptiontable

Regards,
Arka
___
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 v3 0/5] Fix undefined behavior in signed left shift

2017-04-11 Thread Tian, Feng
PS: lt's a typo on pkg name: IntelFWMdlPkg/IdeBusDxe: Fix undefined behavior in 
signed left shift

-Original Message-
From: Tian, Feng 
Sent: Wednesday, April 12, 2017 9:53 AM
To: Wu, Hao A <hao.a...@intel.com>; edk2-devel@lists.01.org; guoh...@huawei.com
Cc: Tian, Feng <feng.t...@intel.com>
Subject: RE: [PATCH v3 0/5] Fix undefined behavior in signed left shift

Series reviewed-by: Feng Tian <feng.t...@intel.com>

-Original Message-
From: Wu, Hao A 
Sent: Wednesday, April 12, 2017 9:52 AM
To: edk2-devel@lists.01.org; guoh...@huawei.com
Cc: Wu, Hao A <hao.a...@intel.com>; Tian, Feng <feng.t...@intel.com>
Subject: [PATCH v3 0/5] Fix undefined behavior in signed left shift

After searching the whole code base, more cases are found related with:
'LastLba3 << 24'

Send a new patch series (V3 based on the patch for ScsiDisk) to fix the 
suspicious undefined behavior in signed left shift.

Cc: Feng Tian <feng.t...@intel.com>

Hao Wu (5):
  MdeModulePkg/ScsiDiskDxe: Fix undefined behavior in signed left shift
  MdeModulePkg/IdeBusPei: Fix undefined behavior in signed left shift
  MdeModulePkg/UfsBlkIoPei: Fix undefined behavior in signed left shift
  MdeModulePkg/UsbBotPei: Fix undefined behavior in signed left shift
  IntelFWMdlPkg/IdeBusDxe: Fix undefined behavior in signed left shift

 IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c  | 6 +++---
 MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c | 4 ++--
 MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c   | 4 ++--
 MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c | 6 +++---
 MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c  | 6 +++---
 5 files changed, 13 insertions(+), 13 deletions(-)

--
2.12.0.windows.1

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


Re: [edk2] [PATCH v3 0/5] Fix undefined behavior in signed left shift

2017-04-11 Thread Tian, Feng
Series reviewed-by: Feng Tian <feng.t...@intel.com>

-Original Message-
From: Wu, Hao A 
Sent: Wednesday, April 12, 2017 9:52 AM
To: edk2-devel@lists.01.org; guoh...@huawei.com
Cc: Wu, Hao A <hao.a...@intel.com>; Tian, Feng <feng.t...@intel.com>
Subject: [PATCH v3 0/5] Fix undefined behavior in signed left shift

After searching the whole code base, more cases are found related with:
'LastLba3 << 24'

Send a new patch series (V3 based on the patch for ScsiDisk) to fix the 
suspicious undefined behavior in signed left shift.

Cc: Feng Tian <feng.t...@intel.com>

Hao Wu (5):
  MdeModulePkg/ScsiDiskDxe: Fix undefined behavior in signed left shift
  MdeModulePkg/IdeBusPei: Fix undefined behavior in signed left shift
  MdeModulePkg/UfsBlkIoPei: Fix undefined behavior in signed left shift
  MdeModulePkg/UsbBotPei: Fix undefined behavior in signed left shift
  IntelFWMdlPkg/IdeBusDxe: Fix undefined behavior in signed left shift

 IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c  | 6 +++---
 MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c | 4 ++--
 MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c   | 4 ++--
 MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c | 6 +++---
 MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c  | 6 +++---
 5 files changed, 13 insertions(+), 13 deletions(-)

--
2.12.0.windows.1

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


Re: [edk2] [PATCH 3/3] UefiCpuPkg: Error Level is not used correctly

2017-04-11 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

-Original Message-
From: Fan, Jeff 
Sent: Monday, April 10, 2017 2:20 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Yao, Jiewen <jiewen@intel.com>
Subject: [PATCH 3/3] UefiCpuPkg: Error Level is not used correctly

Cc: Feng Tian <feng.t...@intel.com>
Cc: Jiewen Yao <jiewen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/CpuDxe/CpuPageTable.c  |  2 +-
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 68 +++
 2 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTable.c
index ab664b4..2c61e75 100644
--- a/UefiCpuPkg/CpuDxe/CpuPageTable.c
+++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c
@@ -634,10 +634,10 @@ ConvertMemoryPageAttributes (
   switch(CurrentPagingContext.MachineType) {
   case IMAGE_FILE_MACHINE_I386:
 if (CurrentPagingContext.ContextData.Ia32.PageTableBase == 0) {
-  DEBUG ((DEBUG_ERROR, "PageTable is 0!\n"));
   if (Attributes == 0) {
 return EFI_SUCCESS;
   } else {
+DEBUG ((DEBUG_ERROR, "PageTable is 0!\n"));
 return EFI_UNSUPPORTED;
   }
 }
diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c 
b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index a9d1042..e53ed21 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -4,7 +4,7 @@
   This module will execute the boot script saved during last boot and after 
that,
   control is passed to OS waking up handler.
 
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights 
+ reserved.
   Copyright (c) 2017, AMD Incorporated. All rights reserved.
 
   This program and the accompanying materials @@ -531,7 +531,7 @@ 
S3ResumeBootOs (
   //
   // X64 long mode waking vector
   //
-  DEBUG (( EFI_D_ERROR, "Transfer to 64bit OS waking vector - %x\r\n", 
(UINTN)Facs->XFirmwareWakingVector));
+  DEBUG ((DEBUG_INFO, "Transfer to 64bit OS waking vector - 
+ %x\r\n", (UINTN)Facs->XFirmwareWakingVector));
   if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
 AsmEnablePaging64 (
   0x38,
@@ -557,7 +557,7 @@ S3ResumeBootOs (
   //
   // IA32 protected mode waking vector (Page disabled)
   //
-  DEBUG (( EFI_D_ERROR, "Transfer to 32bit OS waking vector - %x\r\n", 
(UINTN)Facs->XFirmwareWakingVector));
+  DEBUG ((DEBUG_INFO, "Transfer to 32bit OS waking vector - 
+ %x\r\n", (UINTN)Facs->XFirmwareWakingVector));
   SwitchStack (
 (SWITCH_STACK_ENTRY_POINT) (UINTN) Facs->XFirmwareWakingVector,
 NULL,
@@ -569,7 +569,7 @@ S3ResumeBootOs (
 //
 // 16bit Realmode waking vector
 //
-DEBUG (( EFI_D_ERROR, "Transfer to 16bit OS waking vector - %x\r\n", 
(UINTN)Facs->FirmwareWakingVector));
+DEBUG ((DEBUG_INFO, "Transfer to 16bit OS waking vector - %x\r\n", 
+ (UINTN)Facs->FirmwareWakingVector));
 AsmTransferControl (Facs->FirmwareWakingVector, 0x0);
   }
 
@@ -630,7 +630,7 @@ RestoreS3PageTables (
 //
 // The assumption is : whole page table is allocated in CONTINUOUS memory 
and CR3 points to TOP page.
 //
-DEBUG ((EFI_D_ERROR, "S3NvsPageTableAddress - %x (%x)\n", 
(UINTN)S3NvsPageTableAddress, (UINTN)Build4GPageTableOnly));
+DEBUG ((DEBUG_INFO, "S3NvsPageTableAddress - %x (%x)\n", 
+ (UINTN)S3NvsPageTableAddress, (UINTN)Build4GPageTableOnly));
 
 //
 // By architecture only one PageMapLevel4 exists - so lets allocate 
storage for it.
@@ -783,7 +783,7 @@ S3ResumeExecuteBootScript (
   PEI_S3_RESUME_STATE*PeiS3ResumeState;
   BOOLEANInterruptStatus;
 
-  DEBUG ((EFI_D_ERROR, "S3ResumeExecuteBootScript()\n"));
+  DEBUG ((DEBUG_INFO, "S3ResumeExecuteBootScript()\n"));
 
   //
   // Attempt to use content from SMRAM first @@ -810,13 +810,13 @@ 
S3ResumeExecuteBootScript (
   (VOID **) 
   );
 if (!EFI_ERROR (Status)) {
-  DEBUG ((EFI_D_ERROR, "Close all SMRAM regions before executing boot 
script\n"));
+  DEBUG ((DEBUG_INFO, "Close all SMRAM regions before executing 
+ boot script\n"));
   
   for (Index = 0, Status = EFI_SUCCESS; !EFI_ERROR (Status); Index++) {
 Status = SmmAccess->Close ((EFI_PEI_SERVICES 
**)GetPeiServicesTablePointer (), SmmAccess, Index);
   }
 
-  DEBUG ((EFI_D_ERROR, "Lock all SMRAM regions before executing boot 
script\n"));
+  DEBUG ((DEBUG_INFO, "Lock all SMRAM regions before executing boot 
+ script\n"));
   
   

Re: [edk2] [PATCH 1/3] MdeModulePkg: Error Level is not used correctly

2017-04-11 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

-Original Message-
From: Fan, Jeff 
Sent: Monday, April 10, 2017 2:20 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: [PATCH 1/3] MdeModulePkg: Error Level is not used correctly

Cc: Feng Tian <feng.t...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 .../Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c   | 10 +-
 .../Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c |  4 ++--
 MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c |  2 +-
 MdeModulePkg/Universal/CapsulePei/UefiCapsule.c|  2 +-
 .../Universal/CapsuleRuntimeDxe/X64/SaveLongModeContext.c  |  4 ++--
 MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c | 10 +-
 .../Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c  |  4 ++--
 7 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c 
b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c
index 5147e66..4545d6e 100644
--- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c
+++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c
@@ -103,7 +103,7 @@ S3BootScriptExecutorEntryFunction (
   //
   // X64 S3 Resume
   //
-  DEBUG ((EFI_D_ERROR, "Call AsmDisablePaging64() to return to S3 Resume 
in PEI Phase\n"));
+  DEBUG ((DEBUG_INFO, "Call AsmDisablePaging64() to return to S3 
+ Resume in PEI Phase\n"));
   PeiS3ResumeState->AsmTransferControl = 
(EFI_PHYSICAL_ADDRESS)(UINTN)AsmTransferControl32;
 
   if ((Facs != NULL) &&
@@ -128,7 +128,7 @@ S3BootScriptExecutorEntryFunction (
   //
   // IA32 S3 Resume
   //
-  DEBUG ((EFI_D_ERROR, "Call SwitchStack() to return to S3 Resume in PEI 
Phase\n"));
+  DEBUG ((DEBUG_INFO, "Call SwitchStack() to return to S3 Resume in 
+ PEI Phase\n"));
   PeiS3ResumeState->AsmTransferControl = 
(EFI_PHYSICAL_ADDRESS)(UINTN)AsmTransferControl;
 
   SwitchStack (
@@ -160,7 +160,7 @@ S3BootScriptExecutorEntryFunction (
   //
   // X64 long mode waking vector
   //
-  DEBUG (( EFI_D_ERROR, "Transfer to 64bit OS waking vector - %x\r\n", 
(UINTN)Facs->XFirmwareWakingVector));
+  DEBUG ((DEBUG_INFO, "Transfer to 64bit OS waking vector - 
+ %x\r\n", (UINTN)Facs->XFirmwareWakingVector));
   if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
 SwitchStack (
   (SWITCH_STACK_ENTRY_POINT)(UINTN)Facs->XFirmwareWakingVector,
@@ -177,7 +177,7 @@ S3BootScriptExecutorEntryFunction (
   //
   // IA32 protected mode waking vector (Page disabled)
   //
-  DEBUG (( EFI_D_ERROR, "Transfer to 32bit OS waking vector - %x\r\n", 
(UINTN)Facs->XFirmwareWakingVector));
+  DEBUG ((DEBUG_INFO, "Transfer to 32bit OS waking vector - 
+ %x\r\n", (UINTN)Facs->XFirmwareWakingVector));
   if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
 AsmDisablePaging64 (
   0x10,
@@ -199,7 +199,7 @@ S3BootScriptExecutorEntryFunction (
 //
 // 16bit Realmode waking vector
 //
-DEBUG (( EFI_D_ERROR, "Transfer to 16bit OS waking vector - %x\r\n", 
(UINTN)Facs->FirmwareWakingVector));
+DEBUG ((DEBUG_INFO, "Transfer to 16bit OS waking vector - %x\r\n", 
+ (UINTN)Facs->FirmwareWakingVector));
 AsmTransferControl (Facs->FirmwareWakingVector, 0x0);
   }
 
diff --git 
a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c 
b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
index d433cf1..70eecf5 100644
--- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
+++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.
+++ c
@@ -3,7 +3,7 @@
 
   Set a IDT entry for interrupt vector 3 for debug purpose for x64 platform
 
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 Copyright (c) 2017, AMD Incorporated. All rights reserved.
 
 
@@ -234,7 +234,7 @@ PageFaultHandler (
   UINTN  PTIndex;
 
   PFAddress = AsmReadCr2 ();
-  DEBUG ((EFI_D_ERROR, "BootScript - PageFaultHandler: Cr2 - %lx\n", 
PFAddress));
+  DEBUG ((DEBUG_INFO, "BootScript - PageFaultHandler: Cr2 - %lx\n", 
+ PFAddress));
 
   if (PFAddress >= mPhyMask + SIZE_4KB) {
 return FALSE;
diff --git a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c 
b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c
index dcfd61c..3c05558 100644
--- a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c
+++ b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c
@@ -407,7 +407,7 @@ S3AllocatePageT

Re: [edk2] Using USB-Ethernet adapter in UEFI on an arm64 platform

2017-04-10 Thread Tian, Feng
Ax88772b driver's quality is better than Ax88772. But all of them aren't 
handled no-data case without latency. So if possible, I would suggest you to 
not use Ax88772x device. Realtek usb2lan is a good choice but the disadvantage 
of it is there looks like has no corresponding open-source UEFI driver for use.

Thanks
Feng

-Original Message-
From: Vladimir Olovyannikov [mailto:vladimir.olovyanni...@broadcom.com] 
Sent: Tuesday, April 11, 2017 12:14 AM
To: Tian, Feng <feng.t...@intel.com>; edk2-devel@lists.01.org
Subject: RE: [edk2] Using USB-Ethernet adapter in UEFI on an arm64 platform

Hi Feng,

Thank you for your explanation.
I have Cisco 300M AX88772A-based adapter, so AX88772 (with no "b") driver was 
picked up.
I had to modify it with circular buffer to get ping and tftp going. Also I had 
to receive packets in GetStatus rather than in SN_Receive (otherwise I could 
never get into the Shell).
This way I have ping with response time of approx. 200ms, and tftp working, 
albeit it is slow.
So do you suggest me to use Ax88772b driver for AX88772A/AX88772 usb-ethernet 
adapter?
Also maybe you know if there are UEFI drivers for other USB-ethernet adapters 
(maybe 1G?) available somewhere?

Thank you,
Vladimir
-Original Message-----
From: Tian, Feng [mailto:feng.t...@intel.com]
Sent: April-09-17 9:49 PM
To: Vladimir Olovyannikov; edk2-devel@lists.01.org
Cc: Tian, Feng
Subject: RE: [edk2] Using USB-Ethernet adapter in UEFI on an arm64 platform

Hi, Vladimir,

Which usb2lan driver you are using for AX88772 adpater? The one in 
OptionRomPkg\Bus\Usb\UsbNetworking has bug on the polling performance. The one 
in OptionRomPkg\Bus\Usb\UsbNetworking\Ax88772b is better but if there is no 
data received, the polling operation still wastes some time.

The root cause about the low performance of polling is because USB spec doesn't 
clearly define which value should be returned if user requests Bulk Read 
operation but there is no data. Some data-streaming usb devices, such as 
Realtek usb2lan, return success with data length setting to 0, but others, such 
as AX88772, just keep active and wait for data always. From BIOS view, we have 
to return EFI_TIMEOUT for latter case to avoid system hang. That's why you see 
the low performance for polling operation in no-data case.

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Vladimir 
Olovyannikov
Sent: Saturday, April 8, 2017 3:06 AM
To: edk2-devel@lists.01.org
Subject: [edk2] Using USB-Ethernet adapter in UEFI on an arm64 platform

Hi,

I would like to enable Ethernet using USB-Ethernet AX88772 adapter in the UEFI 
on an armv8 arm64 platform.
Ethernet polling is done by MnpPoll() periodically. This creates a burden on 
the system so that UEFI boots in 1 minute to the Shell due to receive polling.
The USB operation is very resource expensive which causes UEFI to choke up.
There is DisableBackgroundPolling option in the EFI_MANAGED_NETWORK_CONFIG_DATA 
structure, but it is turned off by all other drivers (DNSDxe, Ip4Dxe, 
ArpDxe...).
Can anybody advise what I could do?
Mass storage/keyboard/etc. all work fine...

Thank you,
Vladimir
___
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] MdeModulePkg/ScsiDiskDxe: Fix undefined behavior in signed left shift

2017-04-10 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Wu, Hao A 
Sent: Tuesday, April 11, 2017 9:30 AM
To: edk2-devel@lists.01.org; ler...@redhat.com; guoh...@huawei.com
Cc: Wu, Hao A <hao.a...@intel.com>; Tian, Feng <feng.t...@intel.com>
Subject: [PATCH v2] MdeModulePkg/ScsiDiskDxe: Fix undefined behavior in signed 
left shift

In function GetMediaInfo(), the following expression:
ScsiDiskDevice->BlkIo.Media->LastBlock =  (Capacity10->LastLba3 << 24) |
  (Capacity10->LastLba2 << 16) |
  (Capacity10->LastLba1 << 8)  |
   Capacity10->LastLba0; will involve 
undefined behavior in signed left shift operations.

Since Capacity10->LastLbaX is of type UINT8, and
ScsiDiskDevice->BlkIo.Media->LastBlock is of type UINT64. Therefore,
Capacity10->LastLbaX will be promoted to int (32 bits, signed) first,
and then perform the left shift operation.

According to the C11 spec, Section 6.5.7:
4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
  bits are filled with zeros. If E1 has an unsigned type, the value
  of the result is E1 * 2^E2 , reduced modulo one more than the
  maximum value representable in the result type. If E1 has a signed
  type and nonnegative value, and E1 * 2^E2 is representable in the
  result type, then that is the resulting value; otherwise, the
  behavior is undefined.

So if bit 7 of Capacity10->LastLba3 is 1, (Capacity10->LastLba3 << 24) will be 
out of the range within int type. The undefined behavior of the signed left 
shift will lead to a potential of setting the high 32 bits of 
ScsiDiskDevice->BlkIo.Media->LastBlock to 1 during the cast from type int to 
type UINT64.

This commit will add an explicit UINT32 type cast for
Capacity10->LastLba3 to resolve this issue.

Cc: Feng Tian <feng.t...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a...@intel.com>
---
 MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c 
b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
index b5eff25b9b..2289f20152 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
@@ -1,7 +1,7 @@
 /** @file
   SCSI disk driver that layers on every SCSI IO protocol in the system.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 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 @@ -2754,7 +2754,7 
@@ GetMediaInfo (
   UINT8   *Ptr;
 
   if (!ScsiDiskDevice->Cdb16Byte) {
-ScsiDiskDevice->BlkIo.Media->LastBlock =  (Capacity10->LastLba3 << 24) |
+ScsiDiskDevice->BlkIo.Media->LastBlock =  ((UINT32) 
+ Capacity10->LastLba3 << 24) |
   (Capacity10->LastLba2 << 16) |
   (Capacity10->LastLba1 << 8)  |
Capacity10->LastLba0;
--
2.12.0.windows.1

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


Re: [edk2] Using USB-Ethernet adapter in UEFI on an arm64 platform

2017-04-09 Thread Tian, Feng
Hi, Vladimir,

Which usb2lan driver you are using for AX88772 adpater? The one in 
OptionRomPkg\Bus\Usb\UsbNetworking has bug on the polling performance. The one 
in OptionRomPkg\Bus\Usb\UsbNetworking\Ax88772b is better but if there is no 
data received, the polling operation still wastes some time.

The root cause about the low performance of polling is because USB spec doesn't 
clearly define which value should be returned if user requests Bulk Read 
operation but there is no data. Some data-streaming usb devices, such as 
Realtek usb2lan, return success with data length setting to 0, but others, such 
as AX88772, just keep active and wait for data always. From BIOS view, we have 
to return EFI_TIMEOUT for latter case to avoid system hang. That's why you see 
the low performance for polling operation in no-data case. 

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Vladimir 
Olovyannikov
Sent: Saturday, April 8, 2017 3:06 AM
To: edk2-devel@lists.01.org
Subject: [edk2] Using USB-Ethernet adapter in UEFI on an arm64 platform

Hi,

I would like to enable Ethernet using USB-Ethernet AX88772 adapter in the UEFI 
on an armv8 arm64 platform.
Ethernet polling is done by MnpPoll() periodically. This creates a burden on 
the system so that UEFI boots in 1 minute to the Shell due to receive polling.
The USB operation is very resource expensive which causes UEFI to choke up.
There is DisableBackgroundPolling option in the EFI_MANAGED_NETWORK_CONFIG_DATA 
structure, but it is turned off by all other drivers (DNSDxe, Ip4Dxe, 
ArpDxe...).
Can anybody advise what I could do?
Mass storage/keyboard/etc. all work fine...

Thank you,
Vladimir
___
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] NvmExpressDxe TimerEvent frequency

2017-04-09 Thread Tian, Feng
Yes.

For example, old platforms usually use 50ms as timer interval. So at such 
platforms, even the code is programming to use 1 ms timer, the actual trigger 
time interval is 50ms.

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Arka 
Sharma
Sent: Sunday, April 9, 2017 12:41 PM
To: edk2-devel@lists.01.org
Subject: [edk2] NvmExpressDxe TimerEvent frequency

Hi,

UEFI Driver Write Guide section 5.1.6 says "UEFI system firmware uses a 
hardware timer interrupt to measure time.
These. These
time measurements are used to determine when enough time has passed to signal a 
timer event programmed with SetTimer(). In most systems, the timer interrupt is 
generated every 10 ms to 50 ms, but the UEFI Specification does not require any 
specific interrupt rate. This lack of specificity means that a periodic timer 
programmed with a period much smaller than 10 ms may only be signaled every 10 
ms to 50 ms.". So in case of NvmExpressDxe the Private->TimerEvent is set with 
1 ms, so the frequency of the routine ProcessAsyncTaskList might be more than 1 
ms as per the frequency of the timer interrupt ?

Regards,
Arka
___
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] UefiCpuPkg/CpuFeatures: Change CPU features name to follow IA32 SDM

2017-04-06 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Jeff Fan
Sent: Thursday, April 6, 2017 1:47 PM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D <michael.d.kin...@intel.com>; Tian, Feng 
<feng.t...@intel.com>
Subject: [edk2] [PATCH] UefiCpuPkg/CpuFeatures: Change CPU features name to 
follow IA32 SDM

Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h 
b/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h
index 4765bc3..4aa3529 100644
--- a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h
+++ b/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h
@@ -45,8 +45,8 @@
 #define CPU_FEATURE_C1E 16
 #define CPU_FEATURE_C1_AUTO_DEMOTION17
 #define CPU_FEATURE_C3_AUTO_DEMOTION18
-#define CPU_FEATURE_C1_AUTO_UNDEMOTION  19
-#define CPU_FEATURE_C3_AUTO_UNDEMOTION  20
+#define CPU_FEATURE_C1_UNDEMOTION   19
+#define CPU_FEATURE_C3_UNDEMOTION   20
 #define CPU_FEATURE_C_STATE 21
 #define CPU_FEATURE_TM  22
 #define CPU_FEATURE_TM2 23
-- 
2.9.3.windows.2

___
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] MdeModulePkg/UefiBootManagerLib: Enhance short-form expanding logic

2017-04-06 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Ni, Ruiyu 
Sent: Thursday, April 6, 2017 5:45 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Dong, Eric <eric.d...@intel.com>; Fan, 
Jeff <jeff@intel.com>
Subject: [PATCH] MdeModulePkg/UefiBootManagerLib: Enhance short-form expanding 
logic

Old implementation only finds first matched full device path for a given 
short-form device path.
The patch adds internal function BmGetNextLoadOptionBuffer() to finds all 
matched full device path for a given short-form device path.
There are 6 kinds of device paths. Some of them match to multiple load options, 
some of them don't.

1. Media device path:
   Returns multiple load options: The media device path may point
   to a physical BlockIo which contains multiple logic partitions,
   each logic partitions contains \EFI\BOOT\BOOT${ARCH}.EFI.

2. Short-form hard-drive device path:
   Returns one load option because the partition signature is unique.

3. Short-form file-path device path:
   Returns multiple load options: There are multiple SimpleFileSystem
   instances and each contains the same file.

4. Short-form URI device path:
   Returns multiple load options: There are multiple LoadFile
   instances and each can boot.

5. Short-form USB device path:
   Returns multiple load options: There are multiple UsbIo instances
   and each contains the boot-able file.

6. FV device path, device path pointing to SimpleFileSystem, device
   path pointing to LoadFile
   Returns one load option.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
Cc: Eric Dong <eric.d...@intel.com>
Cc: Jeff Fan <jeff@intel.com>
---
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   | 470 -
 .../Library/UefiBootManagerLib/BmLoadOption.c  | 173 ++--
 .../Library/UefiBootManagerLib/InternalBm.h| 100 +++--
 3 files changed, 475 insertions(+), 268 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 8a3a402..aa79c90 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -131,21 +131,16 @@ BmFindBootOptionInVariable (  }
 
 /**
-  Get the file buffer using a Memory Mapped Device Path.
-
+  Return the correct FV file path.
   FV address may change across reboot. This routine promises the FV file 
device path is right.
 
   @param  FilePath The Memory Mapped Device Path to get the file buffer.
-  @param  FullPath Receive the updated FV Device Path pointint to the file.
-  @param  FileSize Receive the file buffer size.
 
-  @return  The file buffer.
+  @return  The updated FV Device Path pointint to the file.
 **/
-VOID *
-BmGetFileBufferByFvFilePath (
-  IN EFI_DEVICE_PATH_PROTOCOL  *FilePath,
-  OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,
-  OUT UINTN*FileSize
+EFI_DEVICE_PATH_PROTOCOL *
+BmAdjustFvFilePath (
+  IN EFI_DEVICE_PATH_PROTOCOL  *FilePath
   )
 {
   EFI_STATUSStatus;
@@ -153,11 +148,10 @@ BmGetFileBufferByFvFilePath (
   EFI_DEVICE_PATH_PROTOCOL  *FvFileNode;
   EFI_HANDLEFvHandle;
   EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
-  UINT32AuthenticationStatus;
   UINTN FvHandleCount;
   EFI_HANDLE*FvHandles;
   EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;
-  VOID  *FileBuffer;
+  EFI_DEVICE_PATH_PROTOCOL  *FullPath;
 
   //
   // Get the file buffer by using the exactly FilePath.
@@ -165,11 +159,7 @@ BmGetFileBufferByFvFilePath (
   FvFileNode = FilePath;
   Status = gBS->LocateDevicePath (, 
, );
   if (!EFI_ERROR (Status)) {
-FileBuffer = GetFileBufferByFilePath (TRUE, FilePath, FileSize, 
);
-if (FileBuffer != NULL) {
-  *FullPath = DuplicateDevicePath (FilePath);
-}
-return FileBuffer;
+return DuplicateDevicePath (FilePath);
   }
 
   //
@@ -190,11 +180,10 @@ BmGetFileBufferByFvFilePath (
  (VOID **) 
  );
   NewDevicePath = AppendDevicePathNode (DevicePathFromHandle 
(LoadedImage->DeviceHandle), FvFileNode);
-  FileBuffer = BmGetFileBufferByFvFilePath (NewDevicePath, FullPath, FileSize);
+  FullPath = BmAdjustFvFilePath (NewDevicePath);
   FreePool (NewDevicePath);
-
-  if (FileBuffer != NULL) {
-return FileBuffer;
+  if (FullPath != NULL) {
+return FullPath;
   }
 
   //
@@ -207,22 +196,25 @@ BmGetFileBufferByFvFilePath (
  ,
  
  );
-  for (Index = 0; (Index < FvHandleCount) && (FileBuffer == NULL); Index++) {
+  for (Index = 0; Index < FvHandleCount; Index++) {
 if (FvHandles[Index] == LoadedImage->DeviceHandle) {
   //
-  // Skip current FV
+  // 

Re: [edk2] [PATCH] UefiCpuPkg/MpLib.c: Load microcode before mtrr sync per IA32 SDM

2017-04-04 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Fan, Jeff 
Sent: Wednesday, April 5, 2017 11:07 AM
To: edk2-devel@lists.01.org
Cc: Yao, Jiewen <jiewen@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>; Tian, Feng <feng.t...@intel.com>
Subject: [PATCH] UefiCpuPkg/MpLib.c: Load microcode before mtrr sync per IA32 
SDM

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=453
Cc: Jiewen Yao <jiewen@intel.com>
Cc: Michael Kinney <michael.d.kin...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/Library/MpInitLib/MpLib.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index bb93526..03d6c2d 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -382,13 +382,13 @@ ApInitializeSync (
 
   CpuMpData = (CPU_MP_DATA *) Buffer;
   //
-  // Sync BSP's MTRR table to AP
-  //
-  MtrrSetAllMtrrs (>MtrrTable);
-  //
   // Load microcode on AP
   //
   MicrocodeDetect (CpuMpData);
+  //
+  // Sync BSP's MTRR table to AP
+  //
+  MtrrSetAllMtrrs (>MtrrTable);
 }
 
 /**
-- 
2.9.3.windows.2

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


Re: [edk2] DisconnectController API not working.

2017-04-04 Thread Tian, Feng
Kumar,

Do "map -r" at first please.


PS: for the issue you encounter, are you trying to disconnect the usb 
controller in use? Please note at this time you are reading the file from usb 
key. It means the disconnect will never succeed. 

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Andrew 
Fish
Sent: Tuesday, April 4, 2017 12:07 AM
To: Amit kumar 
Cc: edk2-devel@lists.01.org
Subject: Re: [edk2] DisconnectController API not working.


> On Apr 3, 2017, at 2:58 AM, Amit kumar  wrote:
> 
> Hi Andrew ,
> 
> I did some testing and found out, same code works fine on Server boards but 
> it fails on desktop boards.
> 

Servers tend to connect less things as it can take a long time. 

> I Have double checked the ControllerHandle by printing its handle index using 
> ConvertHandleToHandleIndex(ControllerHandle), the  ControllerHandle looks 
> correct.
> 
> 
> I have one new query;
> 
> i have made a startup.nsh file in which i am issuing load driver.efi , i am 
> getting file not found.
> 
> i have also tried using load fs0:driver.efi, and again i get  file not found. 
>  I have been trying to run this script from internal shell as well as usb 
> shell.
> 

Does that command work if you boot the shell? 

Thanks,

Andrew Fish

> 
> Regards
> 
> Amit Kumar
> 
> 
> From: af...@apple.com  on behalf of Andrew Fish 
> 
> Sent: Friday, March 31, 2017 10:42:08 PM
> To: Amit kumar
> Cc: edk2-devel@lists.01.org
> Subject: Re: [edk2] DisconnectController API not working.
> 
> 
> On Mar 31, 2017, at 5:26 AM, Amit kumar 
> > wrote:
> 
> 
> Hi ,
> 
> I am trying to disconnect a controller from the usb mass storage 
> driver, for which i am using
> 
>   Status = gBS->DisconnectController (
> ControllerHandle,
> NULL,
> NULL
> );
> 
> after the call i get Status = SUCCESS , but when i run drivers command in 
> shell, i find it still being manged by the same old driver handle.
> Although when i run disconnect command from shell (e.g disconnect 163 
> ...output disconnect(163,0,0):Status = SUCCESS) it works as expected and 
> detaches the controller from the driver.
> Can some body point me out what could be the reason.
> 
> Amit,
> 
> It is always good to double check you are using the right ControllerHandle.
> 
> Sequence of events matters. There are boot flows and Shell commands that do 
> ConnectController.
> ~/work/src/edk2/ShellPkg(master)>git grep ConnectController
> Library/UefiShellDebug1CommandsLib/LoadPciRom.c:402:
> gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
> Library/UefiShellDriver1CommandsLib/Connect.c:54:Status = 
> gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);
> Library/UefiShellDriver1CommandsLib/Connect.c:95:gBS->ConnectController 
> (RootBridgeHandleBuffer[RootBridgeIndex], NULL, NULL, FALSE);
> Library/UefiShellDriver1CommandsLib/Connect.c:116:ConnectControllers (
> Library/UefiShellDriver1CommandsLib/Connect.c:150:  // This is where we call 
> the gBS->ConnectController function.
> Library/UefiShellDriver1CommandsLib/Connect.c:158:  Status = 
> gBS->ConnectController(*HandleWalker, DriverHandleList, NULL, Recursive);
> Library/UefiShellDriver1CommandsLib/Connect.c:167:Status = 
> gBS->ConnectController(ControllerHandle, DriverHandleList, NULL, Recursive);
> Library/UefiShellDriver1CommandsLib/Connect.c:298:Status = 
> gBS->ConnectController (
> Library/UefiShellDriver1CommandsLib/Connect.c:354:ConvertAndConnectCon
> trollers (
> Library/UefiShellDriver1CommandsLib/Connect.c:391:  return 
> (ConnectControllers(Handle1, Handle2, Recursive, Output, (BOOLEAN)(Handle2 != 
> NULL && Handle1 != NULL)));
> Library/UefiShellDriver1CommandsLib/Connect.c:536:  Status = 
> ConvertAndConnectControllers(Handle1, Handle2, 
> ShellCommandLineGetFlag(Package, L"-r"), (BOOLEAN)(Count!=0));
> Library/UefiShellDriver1CommandsLib/DrvCfg.c:492:  EFI_HANDLE  
> ConnectControllerContextOverride[2];
> Library/UefiShellDriver1CommandsLib/DrvCfg.c:514:
> ConnectControllerContextOverride[0]  = DriverImageHandle;
> Library/UefiShellDriver1CommandsLib/DrvCfg.c:515:
> ConnectControllerContextOverride[1]  = NULL;
> Library/UefiShellDriver1CommandsLib/DrvCfg.c:516:gBS->ConnectController 
> (ControllerHandle, ConnectControllerContextOverride, NULL, TRUE);
> Library/UefiShellLevel2CommandsLib/Load.c:52:Status = 
> gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
> 
> 
> Thanks,
> 
> Andrew Fish
> 
> ___
> 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
> 

Re: [edk2] [Patch] MdeModulePkg: Remove unsupported PcdExpression usage in module INF

2017-03-30 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Gao, Liming 
Sent: Friday, March 31, 2017 1:04 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Zeng, Star <star.z...@intel.com>
Subject: [Patch] MdeModulePkg: Remove unsupported PcdExpression usage in module 
INF

https://bugzilla.tianocore.org/show_bug.cgi?id=442

PcdExpression used in INF to control PCD and Source is unsupported feature.
Current sample usage in module INF brings confuse.

Cc: Feng Tian <feng.t...@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming@intel.com>
---
 MdeModulePkg/Application/HelloWorld/HelloWorld.inf   |  6 +++---
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf  | 12 ++--
 .../Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf|  4 ++--
 MdeModulePkg/Universal/PCD/Pei/Pcd.inf   |  4 ++--
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/MdeModulePkg/Application/HelloWorld/HelloWorld.inf 
b/MdeModulePkg/Application/HelloWorld/HelloWorld.inf
index 2240e17..1cfed2d 100644
--- a/MdeModulePkg/Application/HelloWorld/HelloWorld.inf
+++ b/MdeModulePkg/Application/HelloWorld/HelloWorld.inf
@@ -6,7 +6,7 @@
 #
 #  It demos how to use EDKII PCD mechanism to make code more flexible.
 #
-#  Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
+#  Copyright (c) 2008 - 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 @@ -55,8 +55,8 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdHelloWorldPrintEnable   ## CONSUMES
 
 [Pcd]
-  gEfiMdeModulePkgTokenSpaceGuid.PcdHelloWorldPrintString || 
gEfiMdeModulePkgTokenSpaceGuid.PcdHelloWorldPrintEnable## SOMETIMES_CONSUMES
-  gEfiMdeModulePkgTokenSpaceGuid.PcdHelloWorldPrintTimes  || 
gEfiMdeModulePkgTokenSpaceGuid.PcdHelloWorldPrintEnable## SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdHelloWorldPrintString   ## 
SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdHelloWorldPrintTimes## 
SOMETIMES_CONSUMES
 
 [UserExtensions.TianoCore."ExtraFiles"]
   HelloWorldExtra.uni
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf 
b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
index d62bd9b..c54afe4 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
@@ -5,7 +5,7 @@
 #  PPI to discover and dispatch the DXE Foundation and components that are  #  
needed to run the DXE Foundation.
 #
-#  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2017, Intel Corporation. All rights 
+reserved.
 #  Copyright (c) 2017, AMD Incorporated. All rights reserved.  #  #  This 
program and the accompanying materials @@ -39,12 +39,12 @@
   DxeLoad.c
 
 [Sources.Ia32]
-  X64/VirtualMemory.h  
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode
-  X64/VirtualMemory.c  
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode
+  X64/VirtualMemory.h
+  X64/VirtualMemory.c
   Ia32/DxeLoadFunc.c
-  
Ia32/IdtVectorAsm.nasmgEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode
-  
Ia32/IdtVectorAsm.asmgEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode
-  Ia32/IdtVectorAsm.S  
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode
+  Ia32/IdtVectorAsm.nasm
+  Ia32/IdtVectorAsm.asm
+  Ia32/IdtVectorAsm.S
 
 [Sources.X64]
   X64/VirtualMemory.h
diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf 
b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
index 7a7a3e3..9ab04ce 100644
--- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
+++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
@@ -4,7 +4,7 @@
 #  It installs the Capsule Architectural Protocol defined in PI1.0a to signify 
 #  the capsule runtime services are ready.
 #
-#  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 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 @@ 
-81,7 +81,7 @@
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule   ## 
SOMETIMES_CONSUMES
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule || 
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset ## 
SOMETIMES_CONSUMES # Populate Image requires reset support.
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule  ## 
SOMETIMES_CONSUMES # Populate Image requires reset support.
 
 [Pcd.X64]
   gEfiMdeModulePkgTokenSpaceGuid.PcdCapsulePeiLongModeStackSize   ## 
SOMETIMES_CONSUMES
diff --git a/MdeModul

Re: [edk2] [PATCH 1/2] MdeModulePkg/Tcp4Dxe: Fix unconditional window shrinking

2017-03-29 Thread Tian, Feng
Adding network module owners for further review.

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
ate...@kraftway.ru
Sent: Tuesday, March 28, 2017 3:20 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH 1/2] MdeModulePkg/Tcp4Dxe: Fix unconditional window 
shrinking

Moving Right window edge to the left on sender side without additional checks 
leads to the situation when sender assumes the receiver shrunk its rcv buffer, 
when, in fact, it only reduced window size. This is a TCP deadlock situation. 
Receiver ACKs proper segment, while sender discards it for future ACK. Add 
check for negative usable window to prevent erroneous window shrinking.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Andrey Tepin 
---
 MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c 
b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
index 1000538..ea0766a 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
@@ -703,6 +703,7 @@ TcpInput (
   TCP_SEG *Seg;
   TCP_SEQNO   Right;
   TCP_SEQNO   Urg;
+  INT32   UsableWnd;
 
   NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
 
@@ -1188,7 +1189,10 @@ TcpInput (
 
   if (TCP_SEQ_LT (Right, Tcb->SndNxt)) {
 
-Tcb->SndNxt = Right;
+UsableWnd = Tcb->SndUna + Tcb->SndWnd - Tcb->SndNxt;
+if (UsableWnd < 0) {
+  Tcb->SndNxt = Right;
+}
 
 if (Right == Tcb->SndUna) {
 
--
1.9.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 1/2] MdeModulePkg/MemoryProtection: Fix coding style issue

2017-03-28 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Bi, Dandan 
Sent: Tuesday, March 28, 2017 9:02 AM
To: edk2-devel@lists.01.org
Cc: Ard Biesheuvel <ard.biesheu...@linaro.org>; Tian, Feng <feng.t...@intel.com>
Subject: [patch 1/2] MdeModulePkg/MemoryProtection: Fix coding style issue

Cc: Ard Biesheuvel <ard.biesheu...@linaro.org>
Cc: Feng Tian <feng.t...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan...@intel.com>
---
 MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c 
b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
index 93f96f0..a73c4cc 100644
--- a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
+++ b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
@@ -382,11 +382,11 @@ FreeImageRecord (
   }
   FreePool (ImageRecord);
 }
 
 /**
-  Protect UEFI PE/COFF image
+  Protect UEFI PE/COFF image.
 
   @param[in]  LoadedImage  The loaded image protocol
   @param[in]  LoadedImageDevicePathThe loaded image device path protocol
 **/
 VOID
-- 
1.9.5.msysgit.1

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


Re: [edk2] [PATCH v2] UefiCpuPkg/MpLib.c: Add checking CR0 PG bit

2017-03-27 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Fan, Jeff 
Sent: Tuesday, March 28, 2017 8:57 AM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>
Subject: [PATCH v2] UefiCpuPkg/MpLib.c: Add checking CR0 PG bit

If CR0 PG bit is not set, it means paging is not enabled on BSP. Thus, Execute 
Disable feature is not working actually. Thus, we cannot enable it on APs.

v2:
  Correct the commit log.

Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/Library/MpInitLib/MpLib.c | 38 +++-
 1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 55fe812..bb93526 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -1,7 +1,7 @@
 /** @file
   CPU MP Initialize Library common functions.
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 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 @@ -18,8 +18,11 @@ EFI_GUID mCpuInitMpLibHobGuid = 
CPU_INIT_MP_LIB_HOB_GUID;
 
 /**
   The function will check if BSP Execute Disable is enabled.
-  DxeIpl may have enabled Execute Disable for BSP,
-  APs need to get the status and sync up the settings.
+
+  DxeIpl may have enabled Execute Disable for BSP, APs need to  get the 
+ status and sync up the settings.
+  If BSP's CR0.Paging is not set, BSP execute Disble feature is  not 
+ working actually.
 
   @retval TRUE  BSP Execute Disable is enabled.
   @retval FALSE BSP Execute Disable is not enabled.
@@ -33,23 +36,30 @@ IsBspExecuteDisableEnabled (
   CPUID_EXTENDED_CPU_SIG_EDX  Edx;
   MSR_IA32_EFER_REGISTER  EferMsr;
   BOOLEAN Enabled;
+  IA32_CR0Cr0;
 
   Enabled = FALSE;
-  AsmCpuid (CPUID_EXTENDED_FUNCTION, , NULL, NULL, NULL);
-  if (Eax >= CPUID_EXTENDED_CPU_SIG) {
-AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, );
+  Cr0.UintN = AsmReadCr0 ();
+  if (Cr0.Bits.PG != 0) {
 //
-// CPUID 0x8001
-// Bit 20: Execute Disable Bit available.
+// If CR0 Paging bit is set
 //
-if (Edx.Bits.NX != 0) {
-  EferMsr.Uint64 = AsmReadMsr64 (MSR_IA32_EFER);
+AsmCpuid (CPUID_EXTENDED_FUNCTION, , NULL, NULL, NULL);
+if (Eax >= CPUID_EXTENDED_CPU_SIG) {
+  AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, );
   //
-  // MSR 0xC080
-  // Bit 11: Execute Disable Bit enable.
+  // CPUID 0x8001
+  // Bit 20: Execute Disable Bit available.
   //
-  if (EferMsr.Bits.NXE != 0) {
-Enabled = TRUE;
+  if (Edx.Bits.NX != 0) {
+EferMsr.Uint64 = AsmReadMsr64 (MSR_IA32_EFER);
+//
+// MSR 0xC080
+// Bit 11: Execute Disable Bit enable.
+//
+if (EferMsr.Bits.NXE != 0) {
+  Enabled = TRUE;
+}
   }
 }
   }
--
2.9.3.windows.2

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


Re: [edk2] [PATCH 0/2] [UefiCpuPkg] Support 64bit MMIO address in CPU Register Table

2017-03-26 Thread Tian, Feng
Series Reviewed-by: Feng Tian 

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Fan, Jeff
Sent: Thursday, March 23, 2017 1:28 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH 0/2] [UefiCpuPkg] Support 64bit MMIO address in CPU 
Register Table

The current CPU_REGISTER_TABLE_ENTRY structure only defined UINT32 Index to 
indicate MSR/MMIO address. It's ok for MSR because MSR address is UINT32 type 
actually. But for MMIO address, UINT32 limits MMIO address exceeds 4GB.

https://bugzilla.tianocore.org/show_bug.cgi?id=347

Jeff Fan (2):
  UefiCpuPkg/RegisterCpuFeaturesLib: Define Index to UINT64
  UefiCpuPkg/AcpiCpuData.h: Support >4GB MMIO address

 UefiCpuPkg/Include/AcpiCpuData.h | 12 +++-
 UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h  |  4 ++--
 .../Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c   |  6 +++---
 .../Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c  |  9 +
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c|  2 +-
 5 files changed, 18 insertions(+), 15 deletions(-)

--
2.9.3.windows.2

___
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] UefiCpuPkg/RegisterCpuFeaturesLib: Add ASSERT on allocated memory

2017-03-26 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Fan, Jeff
Sent: Thursday, March 23, 2017 3:21 PM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D <michael.d.kin...@intel.com>; Tian, Feng 
<feng.t...@intel.com>
Subject: [edk2] [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Add ASSERT on 
allocated memory

Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c 
b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
index 34e6c6b..cd689af 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
@@ -65,6 +65,7 @@ GetSupportPcds (
 
   BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);
   SupportBitMask = AllocateZeroPool (BitMaskSize);
+  ASSERT (SupportBitMask != NULL);
   SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport);
 
   return SupportBitMask;
@@ -85,6 +86,7 @@ GetConfigurationPcds (
 
   BitMaskSize = PcdGetSize (PcdCpuFeaturesUserConfiguration);
   SupportBitMask = AllocateZeroPool (BitMaskSize);
+  ASSERT (SupportBitMask != NULL);
   SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesUserConfiguration);
 
   return SupportBitMask;
@@ -165,6 +167,7 @@ CpuInitDataInitialize (
   for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) 
{
 InitOrder = >InitOrder[ProcessorNumber];
 InitOrder->FeaturesSupportedMask = AllocateZeroPool 
(CpuFeaturesData->BitMaskSize);
+ASSERT (InitOrder->FeaturesSupportedMask != NULL);
 InitializeListHead (>OrderList);
 Status = GetProcessorInformation (ProcessorNumber, );
 ASSERT_EFI_ERROR (Status);
@@ -417,6 +420,7 @@ AnalysisProcessorFeatures (
 
   CpuFeaturesData = GetCpuFeaturesData ();
   CpuFeaturesData->CapabilityPcds = AllocatePool 
(CpuFeaturesData->BitMaskSize);
+  ASSERT (CpuFeaturesData->CapabilityPcds != NULL);
   SetMem (CpuFeaturesData->CapabilityPcds, CpuFeaturesData->BitMaskSize, 0xFF);
   for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) 
{
 CpuInitOrder = >InitOrder[ProcessorNumber];
@@ -430,6 +434,7 @@ AnalysisProcessorFeatures (
   //
 
   CpuFeaturesData->SettingPcds = AllocateCopyPool 
(CpuFeaturesData->BitMaskSize, CpuFeaturesData->CapabilityPcds);
+  ASSERT (CpuFeaturesData->SettingPcds != NULL);
   SupportedMaskAnd (CpuFeaturesData->SettingPcds, 
CpuFeaturesData->ConfigurationPcds);
 
   //
@@ -478,6 +483,7 @@ AnalysisProcessorFeatures (
   CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry);
   if (IsBitMaskMatch (CpuFeature->FeatureMask, 
CpuFeaturesData->CapabilityPcds)) {
 CpuFeatureInOrder = AllocateCopyPool (sizeof (CPU_FEATURES_ENTRY), 
CpuFeature);
+ASSERT (CpuFeatureInOrder != NULL);
 InsertTailList (>OrderList, >Link);
   }
   Entry = Entry->ForwardLink;
-- 
2.9.3.windows.2

___
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 0/5] [UefiCpuPkg/CpuFeatures] Fix some comments and meta data issues.

2017-03-26 Thread Tian, Feng
Series Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Fan, Jeff 
Sent: Monday, March 27, 2017 11:02 AM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>
Subject: [PATCH 0/5] [UefiCpuPkg/CpuFeatures] Fix some comments and meta data 
issues.

Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael Kinney <michael.d.kin...@intel.com>

Jeff Fan (5):
  UefiCpuPkg/RegisterCpuFeaturesLib: Fix the function header issues
  UefiCpuPkg/RegisterCpuFeaturesLib: Remove static type
  UefiCpuPkg/RegisterCpuFeaturesLib: Fix meta data comments
  UefiCpuPkg/CpuCommonFeaturesLib: Generate new INF GUID value
  UefiCpuPkg: Add new PCDs PROMPT/HELP string in UNI file

 UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf  |  4 +-
 UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf  |  2 +-
 .../Include/Library/RegisterCpuFeaturesLib.h   | 60 +++--
 .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf  |  8 +--  
.../RegisterCpuFeaturesLib/CpuFeaturesInitialize.c |  2 +-
 .../DxeRegisterCpuFeaturesLib.c| 12 ++---
 .../PeiRegisterCpuFeaturesLib.c|  2 +-
 .../RegisterCpuFeaturesLib/RegisterCpuFeatures.h   |  2 +-
 .../RegisterCpuFeaturesLib.c   | 62 +++---
 UefiCpuPkg/UefiCpuPkg.dec  | 12 ++---
 UefiCpuPkg/UefiCpuPkg.uni  | 31 +++
 11 files changed, 116 insertions(+), 81 deletions(-)

--
2.9.3.windows.2

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


Re: [edk2] [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Set CpuFeatureEntry initial value

2017-03-22 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

-Original Message-
From: Fan, Jeff 
Sent: Thursday, March 23, 2017 9:45 AM
To: edk2-de...@ml01.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>
Subject: [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Set CpuFeatureEntry initial 
value

CpuFeatureEntry will be set before using it. But VS2012 build reported the 
build warning "potentially uninitialized local variable 'CpuFeatureEntry' used".

This fix is to set CpuFeatureEntry initial value and add ASSERT check later.

Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c 
b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c
index 7a1470b..396618b 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c
@@ -272,6 +272,7 @@ RegisterCpuFeatureWorker (
   ASSERT (CpuFeaturesData->BitMaskSize == BitMaskSize);
 
   FeatureExist = FALSE;
+  CpuFeatureEntry = NULL;
   Entry = GetFirstNode (>FeatureList);
   while (!IsNull (>FeatureList, Entry)) {
 CpuFeatureEntry = CPU_FEATURE_ENTRY_FROM_LINK (Entry); @@ -293,6 +294,7 @@ 
RegisterCpuFeatureWorker (
   } else {
 DEBUG ((DEBUG_INFO, "[OVERRIDE] "));
 DumpCpuFeature (CpuFeature);
+ASSERT (CpuFeatureEntry != NULL);
 //
 // Overwrite original parameters of CPU feature
 //
--
2.9.3.windows.2

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


Re: [edk2] [PATCH] UefiCpuPkg/CpuCommonFeaturesLib: Fix case write issue

2017-03-22 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

-Original Message-
From: Fan, Jeff 
Sent: Thursday, March 23, 2017 9:16 AM
To: edk2-de...@ml01.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>
Subject: [PATCH] UefiCpuPkg/CpuCommonFeaturesLib: Fix case write issue

Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
index 63fc03d..8118c1f 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
@@ -25,7 +25,7 @@
 #include   #include 
 
-#include 
+#include 
 #include 
 
 /**
--
2.9.3.windows.2

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


Re: [edk2] [PATCH v5 00/11] Add CPU features driver

2017-03-21 Thread Tian, Feng
Series Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Fan, Jeff 
Sent: Monday, March 20, 2017 4:20 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>
Subject: [PATCH v5 00/11] Add CPU features driver

This serial of patches will add CPU featuers initialization on boot time.

1) One new Register CPU Features Library and instances are added to provide the
   capability to register CPU feature's detect/initialize services.
2) One new NULL class CPU Commong Features Library instance is added to provide
   detect/initialize servcies of CPU features defined in SDM.
3) New CPU features PEI/DXE drivers are added to initialize CPU features in PEI
   phase or DXE phase, by consuming Register CPU Features Library.

https://bugzilla.tianocore.org/show_bug.cgi?id=421

The whole updated UefiCpuPkg v5 could be accessed at 
https://github.com/JeffFan/edk2/tree/CpuFeaturesV5/UefiCpuPkg for review.

v2:
  #9: Format debug messages.
  #10:
1. Using MSR_IA32_EFER to enable/disable NX feature instead of using
   MSR_IA32_MISC_ENABLE.
2. Fix bug that SMX and VMX feature is swapped.

v3:
  #9:  Trim white space at end of line.
  #10: Add AesniGetConfigData() to get current register state.

v4:
  #3, #8, #9: Fix GCC complied issue.

v5:
  #3:  Set DestinationRegisterTableList[Index].RegisterTableEntry before
   RegisterTableEntry is updated.
  #10: Move MSR reading from AesniGetConfigData() to AesniSupport().

Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>

Jeff Fan (11):
  UefiCpuPkg/AcpiCpuData: Update RegisterTableEntry type
  UefiCpuPkg/CpuS3DataDxe: Consume the existing PcdCpuS3DataAddress
  UefiCpuPkg/PiSmmCpuDxeSmm: Skip if AllocatedSize is 0
  UefiCpuPkg/Msr: Add CPUID signature check MACROs
  UefiCpuPkg/UefiCpuPkg.dec: Add a set of CPU features PCDs
  UefiCpuPkg: Add GUID gEdkiiCpuFeaturesSetDoneGuid
  UefiCpuPkg: Add GUID gEdkiiCpuFeaturesInitDoneGuid
  UefiCpuPkg/Include/Library: Add Register CPU Features Library
  UefiCpuPkg: Add PEI/DXE Register CPU Features Library instances
  UefiCpuPkg: Add NULL CPU Common Features Library instance
  UefiCpuPkg: Add CPU Features PEI/DXE drivers

 UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c| 122 +++
 UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf  |  53 ++
 UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni  |  22 +
 UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni |  20 +
 UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c|  75 ++
 UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf  |  49 ++
 UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni  |  22 +
 UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni |  20 +
 UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c|  56 +-
 UefiCpuPkg/Include/AcpiCpuData.h   |   6 +-
 UefiCpuPkg/Include/Guid/CpuFeaturesInitDone.h  |  26 +
 UefiCpuPkg/Include/Guid/CpuFeaturesSetDone.h   |  26 +
 .../Include/Library/RegisterCpuFeaturesLib.h   | 516 
 UefiCpuPkg/Include/Register/Msr/AtomMsr.h  |  22 +-
 UefiCpuPkg/Include/Register/Msr/BroadwellMsr.h |  21 +-
 UefiCpuPkg/Include/Register/Msr/Core2Msr.h |  19 +-
 UefiCpuPkg/Include/Register/Msr/CoreMsr.h  |  18 +-
 UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h  |  18 +-
 UefiCpuPkg/Include/Register/Msr/HaswellEMsr.h  |  18 +-
 UefiCpuPkg/Include/Register/Msr/HaswellMsr.h   |  20 +-
 UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h |  18 +-
 UefiCpuPkg/Include/Register/Msr/NehalemMsr.h   |  21 +-
 UefiCpuPkg/Include/Register/Msr/P6Msr.h|  23 +-
 UefiCpuPkg/Include/Register/Msr/Pentium4Msr.h  |  15 +-
 UefiCpuPkg/Include/Register/Msr/PentiumMMsr.h  |  18 +-
 UefiCpuPkg/Include/Register/Msr/PentiumMsr.h   |  20 +-
 UefiCpuPkg/Include/Register/Msr/SandyBridgeMsr.h   |  19 +-
 UefiCpuPkg/Include/Register/Msr/SilvermontMsr.h|  22 +-
 UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h   |  19 +-
 UefiCpuPkg/Include/Register/Msr/Xeon5600Msr.h  |  19 +-
 UefiCpuPkg/Include/Register/Msr/XeonDMsr.h |  19 +-
 UefiCpuPkg/Include/Register/Msr/XeonE7Msr.h|  18 +-
 UefiCpuPkg/Include/Register/Msr/XeonPhiMsr.h   |  18 +-
 UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c| 127 +++
 UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c  |  79 ++
 .../Library/CpuCommonFeaturesLib/ClockModulation.c | 106 +++
 .../CpuCommonFeaturesLib/CpuCommonFeatures.h   | 867 +
 .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.c| 227 ++
 .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf  |  68 ++  
.../CpuCommonFeaturesLib/CpuCommonFeaturesLib.uni  |  25 +
 UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c |  81 ++
 .../Library/CpuCommonFeaturesLib/Exec

Re: [edk2] [PATCH v2 03/12] MdeModulePkg/RamDiskDxe: fix C string literal catenation in info messages

2017-03-19 Thread Tian, Feng
Ok to me as well.

Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Zeng, Star 
Sent: Monday, March 20, 2017 10:16 AM
To: Laszlo Ersek <ler...@redhat.com>; edk2-devel-01 <edk2-devel@lists.01.org>
Cc: Ard Biesheuvel <ard.biesheu...@linaro.org>; Tian, Feng 
<feng.t...@intel.com>; Wu, Hao A <hao.a...@intel.com>; Leif Lindholm 
<leif.lindh...@linaro.org>; Zeng, Star <star.z...@intel.com>
Subject: RE: [PATCH v2 03/12] MdeModulePkg/RamDiskDxe: fix C string literal 
catenation in info messages

I am ok with this patch.

Feng and Hao, do you have any comments?

Thanks,
Star
-Original Message-
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Saturday, March 18, 2017 4:47 AM
To: edk2-devel-01 <edk2-devel@lists.01.org>
Cc: Ard Biesheuvel <ard.biesheu...@linaro.org>; Tian, Feng 
<feng.t...@intel.com>; Wu, Hao A <hao.a...@intel.com>; Leif Lindholm 
<leif.lindh...@linaro.org>; Zeng, Star <star.z...@intel.com>
Subject: [PATCH v2 03/12] MdeModulePkg/RamDiskDxe: fix C string literal 
catenation in info messages

RamDiskDxe installs the RamDiskAcpiCheck() Ready To Boot callback function. If 
EFI_ACPI_TABLE_PROTOCOL and/or EFI_ACPI_SDT_PROTOCOL are not found, then 
informational messages are logged, and the RAM disks are not published to the 
(nonexistent) NFIT table.

The logic is fine, but the info messages are not concatenated correctly from 
multiple string literals -- the second parts are passed as (unused) arguments 
to DEBUG(). Fix the typos.

Cc: Ard Biesheuvel <ard.biesheu...@linaro.org>
Cc: Feng Tian <feng.t...@intel.com>
Cc: Hao Wu <hao.a...@intel.com>
Cc: Leif Lindholm <leif.lindh...@linaro.org>
Cc: Star Zeng <star.z...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c 
b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c
index d1dd13a8197b..b2bafc58bb71 100644
--- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c
+++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c
@@ -74,7 +74,7 @@ RamDiskAcpiCheck (
   if (EFI_ERROR (Status)) {
 DEBUG ((
   EFI_D_INFO,
-  "RamDiskAcpiCheck: Cannot locate the EFI ACPI Table Protocol,",
+  "RamDiskAcpiCheck: Cannot locate the EFI ACPI Table Protocol, "
   "unable to publish RAM disks to NFIT.\n"
   ));
 return;
@@ -91,7 +91,7 @@ RamDiskAcpiCheck (
   if (EFI_ERROR (Status)) {
 DEBUG ((
   EFI_D_INFO,
-  "RamDiskAcpiCheck: Cannot locate the EFI ACPI Sdt Protocol,",
+  "RamDiskAcpiCheck: Cannot locate the EFI ACPI Sdt Protocol, "
   "unable to publish RAM disks to NFIT.\n"
   ));
 mAcpiTableProtocol = NULL;
--
2.9.3


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


Re: [edk2] [PATCH] UefiCpuPkg/CpuDxe: Remove MSR_IA32_MISC_ENABLE check

2017-03-16 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Jeff Fan
Sent: Wednesday, March 15, 2017 9:55 AM
To: edk2-devel@lists.01.org
Cc: Anthony PERARD <anthony.per...@citrix.com>; Tian, Feng 
<feng.t...@intel.com>; Yao, Jiewen <jiewen@intel.com>
Subject: [edk2] [PATCH] UefiCpuPkg/CpuDxe: Remove MSR_IA32_MISC_ENABLE check

The architectural MSR MSR_IA32_MISC_ENABLE is not supported by AMD processors.
Because reading CPUID.8001H:EDK[20] is enough to check if XD feature is 
supported or not, we just remove checking MSR_IA32_MISC_ENABLE(0x1A0).

Cc: Anthony PERARD <anthony.per...@citrix.com>
Cc: Jiewen Yao <jiewen@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/CpuDxe/CpuPageTable.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTable.c
index 65f607a..ab664b4 100644
--- a/UefiCpuPkg/CpuDxe/CpuPageTable.c
+++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c
@@ -193,12 +193,9 @@ GetCurrentPagingContext (
 AsmCpuid (0x8001, NULL, NULL, NULL, );
 if ((RegEdx & BIT20) != 0) {
   // XD supported
-  if ((AsmReadMsr64 (0x01A0) & BIT34) == 0) {
-// XD enabled
-if ((AsmReadMsr64 (0xC080) & BIT11) != 0) {
-  // XD activated
-  PagingContext->ContextData.Ia32.Attributes |= 
PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED;
-}
+  if ((AsmReadMsr64 (0xC080) & BIT11) != 0) {
+// XD activated
+PagingContext->ContextData.Ia32.Attributes |= 
+ PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED;
   }
 }
 if ((RegEdx & BIT26) != 0) {
--
2.9.3.windows.2

___
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] MdeModulePkg/LogoDxe: Add missing dependency gEfiHiiImageExProtocolGuid

2017-03-16 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Thursday, March 16, 2017 2:05 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Dong, Eric <eric.d...@intel.com>
Subject: [edk2] [PATCH] MdeModulePkg/LogoDxe: Add missing dependency 
gEfiHiiImageExProtocolGuid

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
Cc: Eric Dong <eric.d...@intel.com>
---
 MdeModulePkg/Logo/LogoDxe.inf | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Logo/LogoDxe.inf b/MdeModulePkg/Logo/LogoDxe.inf 
index 3ffc64b..28fe74d 100644
--- a/MdeModulePkg/Logo/LogoDxe.inf
+++ b/MdeModulePkg/Logo/LogoDxe.inf
@@ -1,7 +1,7 @@
 ## @file
 #  The default logo bitmap picture shown on setup screen.
 #
-#  Copyright (c) 2016, Intel Corporation. All rights reserved.
+#  Copyright (c) 2016 - 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 @@ -54,7 +54,8 @@ 
[Protocols]
   gEdkiiPlatformLogoProtocolGuid ## PRODUCES
 
 [Depex]
-  gEfiHiiDatabaseProtocolGuid
+  gEfiHiiDatabaseProtocolGuid AND
+  gEfiHiiImageExProtocolGuid
 
 [UserExtensions.TianoCore."ExtraFiles"]
   LogoDxeExtra.uni
--
2.9.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] Nt32Pkg: Use Shell source code directly

2017-03-16 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Ni, Ruiyu 
Sent: Thursday, March 16, 2017 1:58 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: [PATCH] Nt32Pkg: Use Shell source code directly

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
---
 Nt32Pkg/Nt32Pkg.dsc | 20 +++-  Nt32Pkg/Nt32Pkg.fdf |  2 +-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc index 8927dcd..fa3446b 
100644
--- a/Nt32Pkg/Nt32Pkg.dsc
+++ b/Nt32Pkg/Nt32Pkg.dsc
@@ -115,7 +115,7 @@ [LibraryClasses]
   
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
   PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
   
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
-  SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
+  SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
   #
   # UEFI & PI
   #
@@ -522,6 +522,24 @@ [Components]
   
NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf
   }
   MdeModulePkg/Logo/LogoDxe.inf
+  ShellPkg/Application/Shell/Shell.inf {
+
+  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+
+  
NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf
+  
NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf
+  
NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf
+  
NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf
+  
NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf
+  
NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
+  
NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
+  
NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf
+  ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+  
ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf
+  
HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
+  
BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf
+  
+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+  }
 
 
###
 #
diff --git a/Nt32Pkg/Nt32Pkg.fdf b/Nt32Pkg/Nt32Pkg.fdf index 282e59c..ffa4b0a 
100644
--- a/Nt32Pkg/Nt32Pkg.fdf
+++ b/Nt32Pkg/Nt32Pkg.fdf
@@ -289,7 +289,7 @@ [FV.FvRecovery]
 #
 

 !ifndef $(USE_OLD_SHELL)
-INF  ShellBinPkg/UefiShell/UefiShell.inf
+INF  ShellPkg/Application/Shell/Shell.inf
 !else
 INF  EdkShellBinPkg/FullShell/FullShell.inf
 !endif
--
2.9.0.windows.1

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


Re: [edk2] Testing NVMe async commands

2017-03-15 Thread Tian, Feng
Hi, Sharma

As far as I know, we have UEFI SCT test suite to cover NVME_PASS_THRU async 
test. But it's not complex as your case.

As you have sent 210720 cmds, it's more like memory leak issue. Could you 
please only send 1 cmds and compare the memory map change before and after? 
If there is big memory map change, then there should have memory leak. 

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Arka 
Sharma
Sent: Wednesday, March 15, 2017 10:32 PM
To: edk2-devel@lists.01.org
Subject: [edk2] Testing NVMe async commands

We have developed an application to test the async flow in NvmExpressDxe. We 
have allocated a buffer of size 8 MB and in that buffer we are reading 128k 
chunks, which results in 64 commands as the async submission queue depth is 64, 
after calling passthru with the Event we increment a counter and inside the 
notification function we decrement the counter. After sending all the commands 
we wait till the counter becomes 0. After 64 reads are completed we issue 64 
write command passing the buffer we have just read. So after 8 MB is done we 
increment the lba and repeat the same. In the application we are putting the 
starting lba of each 8 mb operation, so it increments as 0x0, 0x4000, 0x8000 as 
lba size of the device is 512 bytes. We are observing a hang at lba 0x66E4000, 
after processing 210720 commands.
We are creating and closing the events after each 8 MB read and write.
This stuck is seen consistently. May be there is something wrong we are doing 
in the application.

Please let me know if there is any reference UEFI application to test async ?
___
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 3/3] MdeModulePkg BmPerf: Handle "/" separator in debug path for GCC build

2017-03-14 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Zeng, Star 
Sent: Wednesday, March 15, 2017 1:51 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.z...@intel.com>; Gao, Liming <liming@intel.com>; Ni, 
Ruiyu <ruiyu...@intel.com>; Tian, Feng <feng.t...@intel.com>
Subject: [PATCH 3/3] MdeModulePkg BmPerf: Handle "/" separator in debug path 
for GCC build

Cc: Liming Gao <liming@intel.com>
Cc: Ruiyu Ni <ruiyu...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.z...@intel.com>
---
 MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
index 0abd0194409c..4d4495b2a826 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
@@ -3,7 +3,7 @@
   performance, all the function will only include if the performance
   switch is set.
 
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 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 @@ -49,7 +49,7 @@ 
BmGetShortPdbFileName (
   ;
 
 for (Index = 0; PdbFileName[Index] != 0; Index++) {
-  if (PdbFileName[Index] == '\\') {
+  if ((PdbFileName[Index] == '\\') || (PdbFileName[Index] == '/')) 
+ {
 StartIndex = Index + 1;
   }
 
--
2.7.0.windows.1

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


Re: [edk2] [PATCH 0/3] Add Context in SmiHandlerProfileUnregister.

2017-03-12 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Fan, Jeff 
Sent: Monday, March 13, 2017 10:06 AM
To: Yao, Jiewen <jiewen@intel.com>; edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Zeng, Star <star.z...@intel.com>; Bret 
Barkelew <bret.barke...@microsoft.com>
Subject: RE: [PATCH 0/3] Add Context in SmiHandlerProfileUnregister.

Reviewed-by: Jeff Fan <jeff@intel.com>

-Original Message-
From: Yao, Jiewen 
Sent: Friday, March 10, 2017 3:35 PM
To: edk2-devel@lists.01.org
Cc: Fan, Jeff; Tian, Feng; Zeng, Star; Bret Barkelew
Subject: [PATCH 0/3] Add Context in SmiHandlerProfileUnregister.

This issue is reported by bret.barke...@microsoft.com.

We observe that a platform may use same Handler for different context.

In order to support Unregister such handler, we have to input context 
information as well.


The patch does not impact any platform with SmiHandlerProfile disabled.

Unit tests below:
1) register same handler with different context, and unregister each.
2) register and unregister UsbContext.

Cc: Jeff Fan <jeff@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Cc: Bret Barkelew <bret.barke...@microsoft.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen@intel.com>

Jiewen Yao (3):
  MdePkg/SmiHandlerProfile: Add Context support in Unregister
  MdeModulePkg/SmiHandlerProfile: Add Context support in Unregister
  MdeModulePkg/SmmCore: Add Context in SmiHandlerProfileUnregister.

 MdeModulePkg/Core/PiSmmCore/PiSmmCore.h|   8 +-
 MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c| 103 

 MdeModulePkg/Include/Guid/SmiHandlerProfile.h  |  41 
+++-
 MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c |  10 +-
 MdePkg/Include/Library/SmiHandlerProfileLib.h  |   8 +-
 MdePkg/Library/SmiHandlerProfileLibNull/SmiHandlerProfileLibNull.c |   8 +-
 6 files changed, 151 insertions(+), 27 deletions(-)

--
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] MdeModulePkg/UefiBootManagerLib: Generate boot description for NVME

2017-03-12 Thread Tian, Feng
There is no such library class/instance. It should be HPE-specific stuff.

Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Ni, Ruiyu 
Sent: Monday, March 13, 2017 10:24 AM
To: Wang, Sunny (HPS SW) <sunnyw...@hpe.com>; edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Haskell, Darrell <darrell.hask...@hpe.com>
Subject: RE: [edk2] [PATCH] MdeModulePkg/UefiBootManagerLib: Generate boot 
description for NVME

I didn't find this library in EDKII.
When I firstly saw your comments, I was a little bit unwilling to change 
UefiBootManagerLib to depend on UefiNvmExpressLib. Because it would require all 
platforms to include UefiNvmExpressLib in DSC.
But since now I find no such library, I feel much better

Thanks/Ray

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Wang, Sunny (HPS SW)
> Sent: Friday, March 10, 2017 6:11 PM
> To: Ni, Ruiyu <ruiyu...@intel.com>; edk2-devel@lists.01.org
> Cc: Tian, Feng <feng.t...@intel.com>; Haskell, Darrell 
> <darrell.hask...@hpe.com>
> Subject: Re: [edk2] [PATCH] MdeModulePkg/UefiBootManagerLib:
> Generate boot description for NVME
> 
> Hi Ray,
> Just a question out of curiosity. Why don't we use UefiNvmExpressLib's
> NvmExpressIdentify() for sending ADMIN_IDENTIFY command to NVME 
> controller?
> Others look good to me.
> 
> Regards,
> Sunny Wang
> 
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Ruiyu Ni
> Sent: Friday, March 10, 2017 3:58 PM
> To: edk2-devel@lists.01.org
> Cc: Feng Tian <feng.t...@intel.com>
> Subject: [edk2] [PATCH] MdeModulePkg/UefiBootManagerLib: Generate boot 
> description for NVME
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu...@intel.com>
> Cc: Feng Tian <feng.t...@intel.com>
> ---
>  .../Library/UefiBootManagerLib/BmBootDescription.c | 104
> -
>  .../Library/UefiBootManagerLib/InternalBm.h|   4 +-
>  .../UefiBootManagerLib/UefiBootManagerLib.inf  |   1 +
>  3 files changed, 107 insertions(+), 2 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> index 050647d..501a0cc 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> @@ -1,7 +1,7 @@
>  /** @file
>Library functions which relate with boot option description.
> 
> -Copyright (c) 2011 - 2016, Intel Corporation. All rights 
> reserved.
> +Copyright (c) 2011 - 2017, Intel Corporation. All rights 
> +reserved.
>  (C) Copyright 2015 Hewlett Packard Enterprise Development LP  
> This program and the accompanying materials  are licensed and made 
> available under the terms and conditions of the BSD License @@ -501,6 
> +501,107 @@ BmGetLoadFileDescription (  }
> 
>  /**
> +  Return the boot description for NVME boot device.
> +
> +  @param HandleController handle.
> +
> +  @return  The description string.
> +**/
> +CHAR16 *
> +BmGetNvmeDescription (
> +  IN EFI_HANDLE  Handle
> +  )
> +{
> +  EFI_STATUS   Status;
> +  EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL   *NvmePassthru;
> +  EFI_DEV_PATH_PTR DevicePath;
> +  EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
> +  EFI_NVM_EXPRESS_COMMAND  Command;
> +  EFI_NVM_EXPRESS_COMPLETION   Completion;
> +  NVME_ADMIN_CONTROLLER_DATA   ControllerData;
> +  CHAR16   *Description;
> +  CHAR16   *Char;
> +  UINTNIndex;
> +
> +  Status = gBS->HandleProtocol (Handle, , 
> + (VOID **) );  if (EFI_ERROR (Status)) {
> +return NULL;
> +  }
> +
> +  Status = gBS->LocateDevicePath 
> + (,
> + , );  if (EFI_ERROR (Status) ||
> +  (DevicePathType (DevicePath.DevPath) != MESSAGING_DEVICE_PATH)
> ||
> +  (DevicePathSubType (DevicePath.DevPath) !=
> MSG_NVME_NAMESPACE_DP)) {
> +//
> +// Do not return description when the Handle is not a child of 
> + NVME
> controller.
> +//
> +return NULL;
> +  }
> +
> +  //
> +  // Send ADMIN_IDENTIFY command to NVME controller to get the model
> and serial number.
> +  //
> +  Status = gBS->HandleProtocol (Handle, 
> + , (VOID **) ); 
> + ASSERT_EFI_ERROR (Status);
> +
> +  ZeroMem (,
> + sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
> +  ZeroMe

Re: [edk2] [PATCH v3 02/12] MdeModulePkg: Refine casting expression result to bigger size

2017-03-05 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Wu, Hao A 
Sent: Saturday, February 25, 2017 1:12 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A <hao.a...@intel.com>; Tian, Feng <feng.t...@intel.com>; Zeng, 
Star <star.z...@intel.com>
Subject: [PATCH v3 02/12] MdeModulePkg: Refine casting expression result to 
bigger size

There are cases that the operands of an expression are all with rank less
than UINT64/INT64 and the result of the expression is explicitly cast to
UINT64/INT64 to fit the target size.

An example will be:
UINT32 a,b;
// a and b can be any unsigned int type with rank less than UINT64, like
// UINT8, UINT16, etc.
UINT64 c;
c = (UINT64) (a + b);

Some static code checkers may warn that the expression result might
overflow within the rank of "int" (integer promotions) and the result is
then cast to a bigger size.

The commit refines codes by the following rules:
1). When the expression is possible to overflow the range of unsigned int/
int:
c = (UINT64)a + b;

2). When the expression will not overflow within the rank of "int", remove
the explicit type casts:
c = a + b;

3). When the expression will be cast to pointer of possible greater size:
UINT32 a,b;
VOID *c;
c = (VOID *)(UINTN)(a + b); --> c = (VOID *)((UINTN)a + b);

4). When one side of a comparison expression contains only operands with
rank less than UINT32:
UINT8 a;
UINT16 b;
UINTN c;
if ((UINTN)(a + b) > c) {...} --> if (((UINT32)a + b) > c) {...}

For rule 4), if we remove the 'UINTN' type cast like:
if (a + b > c) {...}
The VS compiler will complain with warning C4018 (signed/unsigned
mismatch, level 3 warning) due to promoting 'a + b' to type 'int'.

Cc: Feng Tian <feng.t...@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a...@intel.com>
---
 MdeModulePkg/Application/UiApp/FrontPage.c|  4 
++--
 MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c|  8 

 MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c|  4 
++--
 MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c  |  2 
+-
 MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c| 20 
++--
 MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c   |  6 
+++---
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c  |  6 
+++---
 MdeModulePkg/Core/Dxe/Image/Image.c   | 14 
++
 MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c   |  4 
++--
 MdeModulePkg/Core/Pei/Image/Image.c   | 12 
+---
 MdeModulePkg/Core/PiSmmCore/Dispatcher.c  | 18 
--
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c| 12 
+---
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c |  4 
++--
 MdeModulePkg/Library/DxeCoreMemoryAllocationLib/MemoryAllocationLib.c |  4 
++--
 MdeModulePkg/Library/DxeNetLib/DxeNetLib.c|  4 
++--
 MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c|  4 
++--
 MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c   |  4 
++--
 MdeModulePkg/Library/SmmMemoryAllocationProfileLib/MemoryAllocationLib.c  |  4 
++--
 MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c  |  4 
++--
 MdeModulePkg/Library/UefiHiiLib/HiiLib.c  |  4 
++--
 MdeModulePkg/Library/UefiMemoryAllocationProfileLib/MemoryAllocationLib.c |  4 
++--
 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c |  6 
+++---
 MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c |  4 
++--
 MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c|  6 
+++---
 MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c|  4 
++--
 MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c |  8 

 MdeModulePkg/Universal/EbcDxe/EbcExecute.c| 10 
+-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c |  4 
++--
 MdeModulePkg/Universal/HiiDatabaseDxe/Font.c  | 20 
++--
 MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c   |  6 
+++---
 MdeModulePkg/Universal/PCD/Dxe/Service.c  |  4 
++--
 MdeModulePkg/Universal/PCD/Pei/Service.c  |  4 
++--
 MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c  |  6 
+++---
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c |  6 
+++---
 34 files changed, 113

Re: [edk2] [PATCH v3 1/6] MdeModulePkg: Refine type cast for pointer subtraction

2017-03-05 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Wu, Hao A 
Sent: Saturday, February 25, 2017 12:05 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A <hao.a...@intel.com>; Tian, Feng <feng.t...@intel.com>; Zeng, 
Star <star.z...@intel.com>
Subject: [PATCH v3 1/6] MdeModulePkg: Refine type cast for pointer subtraction

For pointer subtraction, the result is of type "ptrdiff_t". According to the 
C11 standard (Committee Draft - April 12, 2011):

"When two pointers are subtracted, both shall point to elements of the same 
array object, or one past the last element of the array object; the result is 
the difference of the subscripts of the two array elements. The size of the 
result is implementation-defined, and its type (a signed integer type) is 
ptrdiff_t defined in the  header. If the result is not representable 
in an object of that type, the behavior is undefined."

In our codes, there are cases that the pointer subtraction is not performed by 
pointers to elements of the same array object. This might lead to potential 
issues, since the behavior is undefined according to C11 standard.

Also, since the size of type "ptrdiff_t" is implementation-defined. Some static 
code checkers may warn that the pointer subtraction might underflow first and 
then being cast to a bigger size. For example:

UINT8  *Ptr1, *Ptr2;
UINTN  PtrDiff;
...
PtrDiff = (UINTN) (Ptr1 - Ptr2);

The commit will refine the pointer subtraction expressions by casting each 
pointer to UINTN first and then perform the subtraction:

PtrDiff = (UINTN) Ptr1 - (UINTN) Ptr2;

Cc: Feng Tian <feng.t...@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a...@intel.com>
Acked-by: Laszlo Ersek <ler...@redhat.com>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c  |  4 ++--
 MdeModulePkg/Include/Library/NetLib.h |  6 +++---
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c |  4 ++--
 MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c |  2 +-
 MdeModulePkg/Library/FileExplorerLib/FileExplorer.c   |  4 ++--
 MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c|  4 ++--
 MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c|  4 ++--
 MdeModulePkg/Universal/DebugPortDxe/DebugPort.c   |  4 ++--
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c |  4 ++--
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c |  4 ++--
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 10 
+-
 11 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
index 2bc4f8c..d2ad94e 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
@@ -1,7 +1,7 @@
 /** @file
   PCI Rom supporting funtions implementation for PCI Bus module.
 
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 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 @@ -776,7 +776,7 @@ 
ProcessOpRomImage (
 NextImage:
 RomBarOffset += ImageSize;
 
-  } while (((Indicator & 0x80) == 0x00) && ((UINTN) (RomBarOffset - (UINT8 *) 
RomBar) < PciDevice->RomSize));
+  } while (((Indicator & 0x80) == 0x00) && (((UINTN) RomBarOffset - 
+ (UINTN) RomBar) < PciDevice->RomSize));
 
   return RetStatus;
 }
diff --git a/MdeModulePkg/Include/Library/NetLib.h 
b/MdeModulePkg/Include/Library/NetLib.h
index 09ead09..3b8ff1a 100644
--- a/MdeModulePkg/Include/Library/NetLib.h
+++ b/MdeModulePkg/Include/Library/NetLib.h
@@ -2,7 +2,7 @@
   This library is only intended to be used by UEFI network stack modules.
   It provides basic functions for the UEFI network stack.
 
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 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 @@ -1610,10 
+1610,10 @@ typedef struct {
   (sizeof (NET_BUF) + ((BlockOpNum) - 1) * sizeof (NET_BLOCK_OP))
 
 #define NET_HEADSPACE(BlockOp)  \
-  (UINTN)((BlockOp)->Head - (BlockOp)->BlockHead)
+  ((UINTN)((BlockOp)->Head) - (UINTN)((BlockOp)->BlockHead))
 
 #define NET_TAILSPACE(BlockOp)  \
-  (UINTN)((BlockOp)->BlockTail - (BlockOp)->Tail)
+  ((UINTN)((BlockOp)-&g

Re: [edk2] [Patch] MdeModulePkg: use LShiftU64() instead of "<<" to avoid IA32 build error.

2017-02-28 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Zeng, Star 
Sent: Wednesday, March 1, 2017 12:13 PM
To: Fu, Siyuan <siyuan...@intel.com>; edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Ard Biesheuvel 
<ard.biesheu...@linaro.org>; Zeng, Star <star.z...@intel.com>
Subject: RE: [Patch] MdeModulePkg: use LShiftU64() instead of "<<" to avoid 
IA32 build error.

Reviewed-by: Star Zeng <star.z...@intel.com>

Cc Ard.

Thanks,
Star
-Original Message-
From: Fu, Siyuan 
Sent: Wednesday, March 1, 2017 12:05 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Zeng, Star <star.z...@intel.com>
Subject: [Patch] MdeModulePkg: use LShiftU64() instead of "<<" to avoid IA32 
build error.

Cc: Feng Tian <feng.t...@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan...@intel.com>
---
 MdeModulePkg/Core/Dxe/Mem/Page.c  | 2 +-
 MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c
index d596db7..7e8fa94 100644
--- a/MdeModulePkg/Core/Dxe/Mem/Page.c
+++ b/MdeModulePkg/Core/Dxe/Mem/Page.c
@@ -554,7 +554,7 @@ CoreAddMemoryDescriptor (
   CoreReleaseMemoryLock ();
 
   ApplyMemoryProtectionPolicy (EfiMaxMemoryType, Type, Start,
-EFI_PAGES_TO_SIZE (NumberOfPages));
+LShiftU64 (NumberOfPages, EFI_PAGE_SHIFT));
 
   //
   // If Loading Module At Fixed Address feature is enabled. try to allocate 
memory with Runtime code & Boot time code type diff --git 
a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c 
b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
index 172d667..45f360c 100644
--- a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
+++ b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
@@ -851,7 +851,7 @@ InitializeDxeNxMemoryProtectionPolicy (
 if (Attributes != 0) {
   SetUefiImageMemoryAttributes (
 MemoryMapEntry->PhysicalStart,
-EFI_PAGES_TO_SIZE (MemoryMapEntry->NumberOfPages),
+LShiftU64 (MemoryMapEntry->NumberOfPages, EFI_PAGE_SHIFT),
 Attributes);
 }
 MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
--
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 v3 1/6] MdeModulePkg: Add DxeBmDmaLib (BmDmaLib class) library

2017-02-28 Thread Tian, Feng
A minor comment:

> +  LIBRARY_CLASS  = BmDmaLib|DXE_DRIVER

Shouldn't this lib support UEFI driver?

Thanks
Feng

-Original Message-
From: Ni, Ruiyu 
Sent: Wednesday, March 1, 2017 10:39 AM
To: Leo Duran <leo.du...@amd.com>; edk2-de...@ml01.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Zeng, Star <star.z...@intel.com>
Subject: RE: [edk2] [PATCH v3 1/6] MdeModulePkg: Add DxeBmDmaLib (BmDmaLib 
class) library

I suggest to align to BS->FreePages() prototype. Other parts of this patch are 
good to me.

BmDmaFreeBuffer (,
  IN  VOID *HostAddress
  IN  UINTNPages

Thanks/Ray

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Leo Duran
> Sent: Friday, February 10, 2017 12:40 AM
> To: edk2-de...@ml01.01.org
> Cc: Tian, Feng <feng.t...@intel.com>; Leo Duran <leo.du...@amd.com>; 
> Zeng, Star <star.z...@intel.com>
> Subject: [edk2] [PATCH v3 1/6] MdeModulePkg: Add DxeBmDmaLib (BmDmaLib 
> class) library
> 
> This patch provides an abstraction layer for Bus-master DMA operations 
> as currently implemented by the PciHostBridgeDxe driver. The intent is 
> to then allow override of this library as may be required by specific 
> hardware implementations, such as AMD's Secure Encrypted Virtualization (SEV).
> 
> This new BmDmaLib class library is cloned from the existing DmaLib 
> with an additional DmaAbove4GB (BOOLEAN) parameter for the Map and 
> Allocate interfaces, so that decisions can be made about the need to 
> allocate DMA buffers below the 4GB boundary.
> 
> Cc: Feng Tian <feng.t...@intel.com>
> Cc: Star Zeng <star.z...@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Leo Duran <leo.du...@amd.com>
> ---
>  MdeModulePkg/Include/Library/BmDmaLib.h  | 161 +++
>  MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.c   | 351
> +++
>  MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.inf |  41 +++
>  MdeModulePkg/MdeModulePkg.dsc|   1 +
>  4 files changed, 554 insertions(+)
>  create mode 100644 MdeModulePkg/Include/Library/BmDmaLib.h
>  create mode 100644
> MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.c
>  create mode 100644
> MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.inf
> 
> diff --git a/MdeModulePkg/Include/Library/BmDmaLib.h
> b/MdeModulePkg/Include/Library/BmDmaLib.h
> new file mode 100644
> index 000..2c0e50f
> --- /dev/null
> +++ b/MdeModulePkg/Include/Library/BmDmaLib.h
> @@ -0,0 +1,161 @@
> +/** @file
> +  DMA abstraction library APIs. Based on PCI IO protocol DMA abstractions.
> +
> +  Copyright (c) 2008 - 2010, Apple Inc. All rights reserved. 
> + Copyright (c) 2017, AMD Inc. All rights reserved.
> +
> +  DMA Bus Master Read Operation:
> +Call BmDmaMap() for DmaOperationBusMasterRead.
> +Program the DMA Bus Master with the DeviceAddress returned by
> BmDmaMap().
> +Start the DMA Bus Master.
> +Wait for DMA Bus Master to complete the read operation.
> +Call BmDmaUnmap().
> +
> +  DMA Bus Master Write Operation:
> +Call BmDmaMap() for DmaOperationBusMasterWrite.
> +Program the DMA Bus Master with the DeviceAddress returned by
> BmDmaMap().
> +Start the DMA Bus Master.
> +Wait for DMA Bus Master to complete the write operation.
> +Call BmDmaUnmap().
> +
> +  DMA Bus Master Common Buffer Operation:
> +Call BmDmaAllocateBuffer() to allocate a common buffer.
> +Call BmDmaMap() for DmaOperationBusMasterCommonBuffer.
> +Program the DMA Bus Master with the DeviceAddress returned by
> BmDmaMap().
> +The common buffer can now be accessed equally by the processor 
> + and
> the DMA bus master.
> +Call BmDmaUnmap().
> +Call BmDmaFreeBuffer().
> +
> +  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.
> +
> + Derived from:
> +   EmbeddedPkg/Include/Library/DmaLib.h
> +
> +**/
> +
> +#ifndef __BM_DMA_LIB_H__
> +#define __BM_DMA_LIB_H__
> +
> +
> +typedef enum {
> +  ///
> +  /// A read operation from system memory by a bus master.
> +  ///
> +  DmaOperationBusMasterRead,
> +  ///
> +  /// A write operation from system memory by a bus master.
> +  ///
> +  DmaOperationBusMasterWrite,
> +  /

Re: [edk2] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Remove used SetCacheability()

2017-02-26 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Fan, Jeff 
Sent: Monday, February 27, 2017 1:31 PM
To: edk2-devel@lists.01.org
Cc: Leo Duran <leo.du...@amd.com>; Tian, Feng <feng.t...@intel.com>; Kinney, 
Michael D <michael.d.kin...@intel.com>
Subject: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Remove used SetCacheability()

No one uses the internal function SetCacheability().

https://bugzilla.tianocore.org/show_bug.cgi?id=400

This updating is suggested by Leo' comments at 
https://www.mail-archive.com/edk2-devel@lists.01.org/msg22634.html

Cc: Leo Duran <leo.du...@amd.com>
Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael D Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 70 +--
 1 file changed, 1 insertion(+), 69 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index c7aa48b..b180b14 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -1,7 +1,7 @@
 /** @file
 SMM MP service implementation
 
-Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 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 @@ -827,74 +827,6 
@@ Gen4GPageTable (  }
 
 /**
-  Set memory cache ability.
-
-  @paramPageTable  PageTable Address
-  @paramAddressMemory Address to change cache ability
-  @paramCacheability   Cache ability to set
-
-**/
-VOID
-SetCacheability (
-  IN  UINT64*PageTable,
-  IN  UINTN Address,
-  IN  UINT8 Cacheability
-  )
-{
-  UINTN   PTIndex;
-  VOID*NewPageTableAddress;
-  UINT64  *NewPageTable;
-  UINTN   Index;
-
-  ASSERT ((Address & EFI_PAGE_MASK) == 0);
-
-  if (sizeof (UINTN) == sizeof (UINT64)) {
-PTIndex = (UINTN)RShiftU64 (Address, 39) & 0x1ff;
-ASSERT (PageTable[PTIndex] & IA32_PG_P);
-PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & gPhyMask);
-  }
-
-  PTIndex = (UINTN)RShiftU64 (Address, 30) & 0x1ff;
-  ASSERT (PageTable[PTIndex] & IA32_PG_P);
-  PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & gPhyMask);
-
-  //
-  // A perfect implementation should check the original cacheability with the
-  // one being set, and break a 2M page entry into pieces only when they
-  // disagreed.
-  //
-  PTIndex = (UINTN)RShiftU64 (Address, 21) & 0x1ff;
-  if ((PageTable[PTIndex] & IA32_PG_PS) != 0) {
-//
-// Allocate a page from SMRAM
-//
-NewPageTableAddress = AllocatePageTableMemory (1);
-ASSERT (NewPageTableAddress != NULL);
-
-NewPageTable = (UINT64 *)NewPageTableAddress;
-
-for (Index = 0; Index < 0x200; Index++) {
-  NewPageTable[Index] = PageTable[PTIndex];
-  if ((NewPageTable[Index] & IA32_PG_PAT_2M) != 0) {
-NewPageTable[Index] &= ~((UINT64)IA32_PG_PAT_2M);
-NewPageTable[Index] |= (UINT64)IA32_PG_PAT_4K;
-  }
-  NewPageTable[Index] |= (UINT64)(Index << EFI_PAGE_SHIFT);
-}
-
-PageTable[PTIndex] = ((UINTN)NewPageTableAddress & gPhyMask) | 
PAGE_ATTRIBUTE_BITS;
-  }
-
-  ASSERT (PageTable[PTIndex] & IA32_PG_P);
-  PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & gPhyMask);
-
-  PTIndex = (UINTN)RShiftU64 (Address, 12) & 0x1ff;
-  ASSERT (PageTable[PTIndex] & IA32_PG_P);
-  PageTable[PTIndex] &= ~((UINT64)((IA32_PG_PAT_4K | IA32_PG_CD | 
IA32_PG_WT)));
-  PageTable[PTIndex] |= (UINT64)Cacheability; -}
-
-/**
   Schedule a procedure to run on the specified CPU.
 
   @param[in]   ProcedureThe address of the procedure to run
--
2.9.3.windows.2

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


Re: [edk2] Should Path Name in File Path Media Device Path node be NULL terminated?

2017-02-23 Thread Tian, Feng
UEFI spec clearly say:

"Path Name" is A NULL-terminated Path string including directory and file 
names. The length of this string n can be determined by
subtracting 4 from the Length entry. A device path may contain one or more of 
these nodes. Each node can optionally add a "\" separator to the beginning 
and/or the end of the Path Name string. The complete path to a file can be 
found by logically concatenating all the Path Name strings in the File Path 
Media Device Path nodes. This is typically used to describe the directory path 
in one node, and the filename in another node.

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Andrei 
Borzenkov
Sent: Friday, February 24, 2017 3:06 PM
To: edk2-devel-01 ; The development of GNU GRUB 

Subject: [edk2] Should Path Name in File Path Media Device Path node be NULL 
terminated?

Historically grub2 built image paths using two File Path nodes - one for 
directory and one for file name relative to directory. These nodes had path 
names that were not NULL terminated.

Recently we had bug report that secure boot using grub2 failed. It was tracked 
down to exactly the fact that paths were not NULL terminated.
See
http://git.savannah.gnu.org/cgit/grub.git/commit/?id=ce95549cc54b5d6f494608a7c390dba3aab4fba7

Unfortunately this caused another regression which looks like firmware 
truncating passed image path on first NULL

https://bugzilla.opensuse.org/show_bug.cgi?id=1026344

Could someone clarify what is expected by EFI spec? Should each Path Name (even 
intermediate) be NULL terminated, or spec intends to say that only full path 
must be NULL terminated?
___
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 v3 2/7] MdePkg IndustryStandard/Scsi.h: Add sense code macro

2017-02-23 Thread Tian, Feng
Linton,

Could you let me know where the +#define EFI_SCSI_REQUEST_SENSE_ERROR  (0x70) 
comes from?

According to SCSI SPC5r08 spec, the first byte of sense data is the RESPONSE 
CODE field. 

And 0x70 means

a) the result of an error, exception condition, or protocol specific failure 
that is associated with CHECK
CONDITION status; or
b) additional information that is associated with a status other than CHECK 
CONDITION.

It's possible that 0x70 means success... so this naming may be not quite 
appropriate.

And in your usage, you forcedly convert Packet->SenseData to UINT8 and access 
each sense data field by array index. I think it's unnecessary. 
Packet->SenseData is EFI_SCSI_SENSE_DATA type, which has defined the meaning of 
each field. With this structure, you don't need introduce EFI_SCSI_SK_VALUE 
macro again.

+sense = (UINT8 *)Packet->SenseData;
+if ((Packet->SenseDataLength > 13) &&
+(sense[0] & EFI_SCSI_REQUEST_SENSE_ERROR)) {
+  DEBUG ((DEBUG_INFO, "SiI3132ScsiPassRead() Key %X ASC(Q) %02X%02X\n",
+  EFI_SCSI_SK_VALUE (sense[2]), sense[12], sense[13]));
+}

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Jeremy 
Linton
Sent: Friday, February 24, 2017 6:34 AM
To: edk2-devel@lists.01.org
Cc: ard.biesheu...@linaro.org; steve.cap...@arm.com; ryan.har...@linaro.org; 
leif.lindh...@linaro.org; linaro-u...@lists.linaro.org
Subject: [edk2] [PATCH v3 2/7] MdePkg IndustryStandard/Scsi.h: Add sense code 
macro

Add some definitions to mask the sense key from sense data, and check the 
validity of the returned sense data.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeremy Linton 
---
 MdePkg/Include/IndustryStandard/Scsi.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MdePkg/Include/IndustryStandard/Scsi.h 
b/MdePkg/Include/IndustryStandard/Scsi.h
index 0d81314..802479e 100644
--- a/MdePkg/Include/IndustryStandard/Scsi.h
+++ b/MdePkg/Include/IndustryStandard/Scsi.h
@@ -369,6 +369,8 @@ typedef struct {
 //
 // Sense Key
 //
+#define EFI_SCSI_REQUEST_SENSE_ERROR  (0x70)
+#define EFI_SCSI_SK_VALUE(byte)   (byte&0x0F)
 #define EFI_SCSI_SK_NO_SENSE  (0x0)
 #define EFI_SCSI_SK_RECOVERY_ERROR(0x1)
 #define EFI_SCSI_SK_NOT_READY (0x2)
--
2.9.3

___
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] UefiCpuPkg/CpuDxe: Do not ASSERT on AllocateMemorySpace() error

2017-02-23 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Fan, Jeff 
Sent: Friday, February 24, 2017 2:12 PM
To: edk2-devel@lists.01.org
Cc: Laszlo Ersek <ler...@redhat.com>; Zeng, Star <star.z...@intel.com>; Tian, 
Feng <feng.t...@intel.com>; Kinney, Michael D <michael.d.kin...@intel.com>
Subject: [PATCH] UefiCpuPkg/CpuDxe: Do not ASSERT on AllocateMemorySpace() error

Platform PEI may add LOCAL APIC memory mapped space into 
EFI_HOB_MEMORY_ALLOCATION. Or platform may allocate this range before.

So, we skip AllocateMemorySpace()'s return status checking. Instead, we add one 
DEBUG message for possible trace.

https://bugzilla.tianocore.org/show_bug.cgi?id=390

This updating is suggested by Ersek's comments at 
https://www.mail-archive.com/edk2-devel@lists.01.org/msg22585.html

Cc: Laszlo Ersek <ler...@redhat.com>
Cc: Star Zeng <star.z...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael D Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/CpuDxe/CpuDxe.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c index 
2fd2f31..4a5e282 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -1075,6 +1075,11 @@ AddLocalApicMemorySpace (
   Status = AddMemoryMappedIoSpace (BaseAddress, SIZE_4KB, EFI_MEMORY_UC);
   ASSERT_EFI_ERROR (Status);
 
+  //
+  // Try to allocate APIC memory mapped space, does not check return  
+ // status because it may be allocated by other driver, or DXE Core if  
+ // this range is built into Memory Allocation HOB.
+  //
   Status = gDS->AllocateMemorySpace (
   EfiGcdAllocateAddress,
   EfiGcdMemoryTypeMemoryMappedIo, @@ -1084,7 +1089,10 @@ 
AddLocalApicMemorySpace (
   ImageHandle,
   NULL
   );
-  ASSERT_EFI_ERROR (Status);
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_INFO, "%a: %a: AllocateMemorySpace() Status - %r\n",
+ gEfiCallerBaseName, __FUNCTION__, Status));  }
 }
 
 /**
-- 
2.9.3.windows.2

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


Re: [edk2] [PATCH] MdeModulePkg SmmSmiHandlerProfileLib: Fix GCC build failure

2017-02-23 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Zeng, Star 
Sent: Friday, February 24, 2017 9:56 AM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.z...@intel.com>; Tian, Feng <feng.t...@intel.com>; Yao, 
Jiewen <jiewen@intel.com>
Subject: [PATCH] MdeModulePkg SmmSmiHandlerProfileLib: Fix GCC build failure

Cc: Feng Tian <feng.t...@intel.com>
Cc: Jiewen Yao <jiewen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.z...@intel.com>
---
 MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c 
b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c
index 0191cdebbf12..2edc71be3efb 100644
--- a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c
+++ b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c
@@ -99,7 +99,7 @@ SmmSmiHandlerProfileLibConstructor (
   gSmst->SmmLocateProtocol (
,
NULL,
-   
+   (VOID **) 
);
   return EFI_SUCCESS;
 }
-- 
2.7.0.windows.1

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


Re: [edk2] [PATCH] UefiCpuPkg/CpuDxe: Replace EFI_D_xxx with DEBUG_xxx in DEBUG()

2017-02-21 Thread Tian, Feng
Reviewed-by: Feng Tian<feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Fan, Jeff 
Sent: Wednesday, February 22, 2017 3:56 PM
To: edk2-de...@ml01.01.org
Cc: Laszlo Ersek <ler...@redhat.com>; Tian, Feng <feng.t...@intel.com>; Kinney, 
Michael D <michael.d.kin...@intel.com>
Subject: [PATCH] UefiCpuPkg/CpuDxe: Replace EFI_D_xxx with DEBUG_xxx in DEBUG()

Cc: Laszlo Ersek <ler...@redhat.com>
Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael D Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/CpuDxe/CpuDxe.c | 8   UefiCpuPkg/CpuDxe/CpuMp.c  | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c index 
1a5a725..2fd2f31 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -403,7 +403,7 @@ CpuSetMemoryAttributes (
   // to avoid unnecessary computing.
   //
   if (mIsFlushingGCD) {
-DEBUG((EFI_D_INFO, "  Flushing GCD\n"));
+DEBUG((DEBUG_INFO, "  Flushing GCD\n"));
 return EFI_SUCCESS;
   }
 
@@ -979,13 +979,13 @@ IntersectMemoryDescriptor (
 IntersectionBase, IntersectionEnd - IntersectionBase,
 Capabilities);
 
-DEBUG ((EFI_ERROR (Status) ? EFI_D_ERROR : EFI_D_VERBOSE,
+DEBUG ((EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE,
   "%a: %a: add [%Lx, %Lx): %r\n", gEfiCallerBaseName, __FUNCTION__,
   IntersectionBase, IntersectionEnd, Status));
 return Status;
   }
 
-  DEBUG ((EFI_D_ERROR, "%a: %a: desc [%Lx, %Lx) type %u cap %Lx conflicts "
+  DEBUG ((DEBUG_ERROR, "%a: %a: desc [%Lx, %Lx) type %u cap %Lx conflicts "
 "with aperture [%Lx, %Lx) cap %Lx\n", gEfiCallerBaseName, __FUNCTION__,
 Descriptor->BaseAddress, Descriptor->BaseAddress + Descriptor->Length,
 (UINT32)Descriptor->GcdMemoryType, Descriptor->Capabilities, @@ -1018,7 
+1018,7 @@ AddMemoryMappedIoSpace (
 
   Status = gDS->GetMemorySpaceMap (, );
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "%a: %a: GetMemorySpaceMap(): %r\n",
+DEBUG ((DEBUG_ERROR, "%a: %a: GetMemorySpaceMap(): %r\n",
   gEfiCallerBaseName, __FUNCTION__, Status));
 return Status;
   }
diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c index 
9659bd2..4456946 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -1,7 +1,7 @@
 /** @file
   CPU DXE Module to produce CPU MP Protocol.
 
-  Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2008 - 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 @@ -571,7 +571,7 @@ CollectBistDataFromHob (
   BspCpuInstance.InfoRecord.IA32HealthFlags.Uint32  = 
SecPlatformInformation->IA32HealthFlags.Uint32;
   CpuInstance = 
 } else {
-  DEBUG ((EFI_D_INFO, "Does not find any HOB stored CPU BIST 
information!\n"));
+  DEBUG ((DEBUG_INFO, "Does not find any HOB stored CPU BIST 
+ information!\n"));
   //
   // Does not find any HOB stored BIST information
   //
@@ -622,7 +622,7 @@ InitializeMpSupport (
 
   MpInitLibGetNumberOfProcessors (, 
);
   mNumberOfProcessors = NumberOfProcessors;
-  DEBUG ((EFI_D_ERROR, "Detect CPU count: %d\n", mNumberOfProcessors));
+  DEBUG ((DEBUG_ERROR, "Detect CPU count: %d\n", mNumberOfProcessors));
 
   //
   // Update CPU healthy information from Guided HOB
--
2.9.3.windows.2

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


Re: [edk2] [PATCH] UefiCpuPkg/CpuDxe: Fix hard code actual TimerPeriod value

2017-02-21 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

-Original Message-
From: Fan, Jeff 
Sent: Monday, February 20, 2017 4:38 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>
Subject: [PATCH] UefiCpuPkg/CpuDxe: Fix hard code actual TimerPeriod value

Current CpuGetTimerValue() implementation return hard code TimerPeriod value. 
We could calculate the actual TimerPeriod value over period of time (100us) at 
the first time invoking CpuGetTimerValue() and save the TimerPeriod value into 
one global variable to avoid delay at the next CpuGetTimerValue() invoking.

https://bugzilla.tianocore.org/show_bug.cgi?id=382

Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael D Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/CpuDxe/CpuDxe.c   | 26 +++---
 UefiCpuPkg/CpuDxe/CpuDxe.h   |  3 ++-
 UefiCpuPkg/CpuDxe/CpuDxe.inf |  3 ++-
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c index 
f6d0a67..9fb6d76 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -1,7 +1,7 @@
 /** @file
   CPU DXE Module to produce CPU ARCH Protocol.
 
-  Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2008 - 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
@@ -23,6 +23,7 @@ EFI_HANDLEmCpuHandle = NULL;
 BOOLEAN   mIsFlushingGCD;
 UINT64mValidMtrrAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS;
 UINT64mValidMtrrBitsMask= MTRR_LIB_MSR_VALID_MASK;
+UINT64mTimerPeriod = 0;
 
 FIXED_MTRRmFixedMtrrTable[] = {
   {
@@ -293,6 +294,9 @@ CpuGetTimerValue (
   OUT UINT64*TimerPeriod OPTIONAL
   )
 {
+  UINT64  BeginValue;
+  UINT64  EndValue;
+
   if (TimerValue == NULL) {
 return EFI_INVALID_PARAMETER;
   }
@@ -304,10 +308,26 @@ CpuGetTimerValue (
   *TimerValue = AsmReadTsc ();
 
   if (TimerPeriod != NULL) {
+if (mTimerPeriod == 0) {
+  //
+  // Read time stamp counter before and after delay of 100 
+ microseconds
   //
-  // BugBug: Hard coded. Don't know how to do this generically
+  BeginValue = AsmReadTsc ();
+  MicroSecondDelay (100);
+  EndValue   = AsmReadTsc ();
   //
-  *TimerPeriod = 10;
+  // Calculate the actual frequency
+  //
+  mTimerPeriod = DivU64x64Remainder (
+   MultU64x32 (
+ 1000 * 1000 * 1000,
+ 100
+ ),
+   EndValue - BeginValue,
+   NULL
+   );
+}
+*TimerPeriod = mTimerPeriod;
   }
 
   return EFI_SUCCESS;
diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.h b/UefiCpuPkg/CpuDxe/CpuDxe.h index 
6dd0ad3..27ad45b 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.h
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.h
@@ -1,7 +1,7 @@
 /** @file
   CPU DXE Module to produce CPU ARCH Protocol and CPU MP Protocol.
 
-  Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2008 - 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 @@ -39,6 +39,7 @@  #include   #include 
  #include 
+#include 
 
 #include 
 #include 
diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.inf b/UefiCpuPkg/CpuDxe/CpuDxe.inf index 
bf389bb..3cedce1 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.inf
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.inf
@@ -1,7 +1,7 @@
 ## @file
 #  CPU driver installs CPU Architecture Protocol and CPU MP protocol.
 #
-#  Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
+#  Copyright (c) 2008 - 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 @@ 
-44,6 +44,7 @@
   HobLib
   ReportStatusCodeLib
   MpInitLib
+  TimerLib
 
 [Sources]
   CpuDxe.c
--
2.9.3.windows.2

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


Re: [edk2] [PATCH] MdeModulePkg/SdMmc: Avoid assigning 0 to the BlockSize of Trb

2017-02-19 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Wu, Hao A 
Sent: Monday, February 20, 2017 11:06 AM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A <hao.a...@intel.com>; Tian, Feng <feng.t...@intel.com>
Subject: [PATCH] MdeModulePkg/SdMmc: Avoid assigning 0 to the BlockSize of Trb

Refine code to avoid potential divide by zero when calculating block number.

Cc: Feng Tian <feng.t...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a...@intel.com>
---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 4 ++--
 MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c | 4 ++--
 MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
index ccbf355..aa75aa8 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
@@ -4,7 +4,7 @@
 
   It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use.
 
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+  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
   which accompanies this distribution.  The full text of the license may be 
found at @@ -1265,7 +1265,7 @@ SdMmcCreateTrb (
 goto Error;
   }
 
-  if (Trb->DataLen < Trb->BlockSize) {
+  if ((Trb->DataLen != 0) && (Trb->DataLen < Trb->BlockSize)) {
 Trb->BlockSize = (UINT16)Trb->DataLen;
   }
 
diff --git a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c 
b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c
index 5a9e0b2..2c0baca 100644
--- a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c
+++ b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+  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
   which accompanies this distribution.  The full text of the license may be 
found at @@ -1032,7 +1032,7 @@ EmmcPeimCreateTrb (
 goto Error;
   }
 
-  if (Trb->DataLen < Trb->BlockSize) {
+  if ((Trb->DataLen != 0) && (Trb->DataLen < Trb->BlockSize)) {
 Trb->BlockSize = (UINT16)Trb->DataLen;
   }
 
diff --git a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c 
b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c
index 72efd56..23e6563 100644
--- a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c
+++ b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+  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
   which accompanies this distribution.  The full text of the license may be 
found at @@ -1032,7 +1032,7 @@ SdPeimCreateTrb (
 goto Error;
   }
 
-  if (Trb->DataLen < Trb->BlockSize) {
+  if ((Trb->DataLen != 0) && (Trb->DataLen < Trb->BlockSize)) {
 Trb->BlockSize = (UINT16)Trb->DataLen;
   }
 
--
1.9.5.msysgit.0

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


Re: [edk2] [PATCH v2] MdeModulePkg PiSmmIpl: Update SmmCommunication comments to match code logic

2017-02-08 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Liming 
Gao
Sent: Thursday, February 9, 2017 3:05 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Zeng, Star <star.z...@intel.com>
Subject: [edk2] [PATCH v2] MdeModulePkg PiSmmIpl: Update SmmCommunication 
comments to match code logic

Cc: Star Zeng <star.z...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming@intel.com>
---
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c 
b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
index d3a5cda..26b71f1 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
@@ -1,7 +1,7 @@
 /** @file
   SMM IPL that produces SMM related runtime protocols and load the SMM Core 
into SMRAM
 
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 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
@@ -521,7 +521,7 @@ SmmCommunicationCommunicate (
   gSmmCorePrivate->InSmm = TRUE;
 
   //
-  // Already in SMM and before SetVirtualAddressMap(), so call SmiManage() 
directly.
+  // Before SetVirtualAddressMap(), we are in SMM or SMRAM is open and 
unlocked, call SmiManage() directly.
   //
   CommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *)CommBuffer;
   *CommSize -= OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
-- 
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 v2 1/6] MdeModulePkg/PciSioSerialDxe: Use MAX_UINT8 instead of PCI_BAR_ALL

2017-02-07 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Ni, Ruiyu 
Sent: Monday, February 6, 2017 2:01 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: [PATCH v2 1/6] MdeModulePkg/PciSioSerialDxe: Use MAX_UINT8 instead of 
PCI_BAR_ALL

When BarIndex equals to 0xFF, default value 0 is used as the BAR index. Though 
PCI_BAR_ALL and MAX_UINT8 shares the same value, using PCI_BAR_ALL is like to 
match any BAR not BAR 0, it's more proper to use MAX_UINT8 here.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
---
 MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c 
b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c
index 65ddf5d..a9dc827 100644
--- a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c
+++ b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c
@@ -473,7 +473,7 @@ CreateSerialDevice (
   // For PCI serial device, use the information from PCD
   //
   if (PciSerialParameter != NULL) {
-BarIndex = (PciSerialParameter->BarIndex == PCI_BAR_ALL) ? 0 : 
PciSerialParameter->BarIndex;
+BarIndex = (PciSerialParameter->BarIndex == MAX_UINT8) ? 0 : 
+ PciSerialParameter->BarIndex;
 Offset = PciSerialParameter->Offset;
 if (PciSerialParameter->RegisterStride != 0) {
   SerialDevice->RegisterStride = PciSerialParameter->RegisterStride;
--
2.9.0.windows.1

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


Re: [edk2] [PATCH] Fix some typos of "according"

2017-02-07 Thread Tian, Feng
MdeModulePkg reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Zeng, Star 
Sent: Wednesday, February 8, 2017 9:45 AM
To: Rebecca Cran <rebe...@bluestop.org>; edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Fu, Siyuan <siyuan...@intel.com>; Wu, 
Jiaxin <jiaxin...@intel.com>; Gao, Liming <liming@intel.com>; Zeng, Star 
<star.z...@intel.com>
Subject: RE: [PATCH] Fix some typos of "according"

Reviewed-by: Star Zeng <star.z...@intel.com>

-Original Message-
From: Rebecca Cran [mailto:rebe...@bluestop.org] 
Sent: Wednesday, February 8, 2017 3:41 AM
To: edk2-devel@lists.01.org
Cc: Rebecca Cran <rebe...@bluestop.org>; Tian, Feng <feng.t...@intel.com>; 
Zeng, Star <star.z...@intel.com>; Fu, Siyuan <siyuan...@intel.com>; Wu, Jiaxin 
<jiaxin...@intel.com>; Gao, Liming <liming@intel.com>
Subject: [PATCH] Fix some typos of "according"

Cc: Feng Tian <feng.t...@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Cc: Siyuan Fu <siyuan...@intel.com>
Cc: Jiaxin Wu <jiaxin...@intel.com>
Cc: Liming Gao <liming@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Rebecca Cran <rebe...@bluestop.org>
---
 EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c | 2 +-
 MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c   | 4 ++--
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c  | 2 +-
 MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdMemory.c  | 2 +-
 MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdSymbol.c  | 6 +++---
 MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.c  | 2 +-
 MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h  | 2 +-
 MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c   | 2 +-
 NetworkPkg/HttpBootDxe/HttpBootConfigStrings.uni  | 2 +-
 9 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c 
b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c
index 535a265046..e71b5e4e7d 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c
@@ -854,7 +854,7 @@ GetLangCode (
   }
 
   //
-  // Convert the language accoring to the table.
+  // Convert the language according to the table.
   //
   for (Index = 0; LanguageConvertTable[Index].ISO639 != NULL; Index++) {
 if (wcscmp(LanguageConvertTable[Index].ISO639, Lang) == 0) { diff --git 
a/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c 
b/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c
index eba938e2a9..6cfd35945a 100644
--- a/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c
+++ b/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c
@@ -785,7 +785,7 @@ SmmCoreGetMemoryMapMemoryAttributesTable (  //
 
 /**
-  Set MemoryProtectionAttribute accroding to PE/COFF image section alignment.
+  Set MemoryProtectionAttribute according to PE/COFF image section alignment.
 
   @param[in]  SectionAlignmentPE/COFF section alignment
 **/
@@ -1225,7 +1225,7 @@ Finish:
 }
 
 /**
-  Find image record accroding to image base and size.
+  Find image record according to image base and size.
 
   @param[in]  ImageBaseBase of PE image
   @param[in]  ImageSizeSize of PE image
diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index a4579bf043..8734291ae3 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -396,7 +396,7 @@ HttpParseUrl (
   FoundAt = FALSE;
   for (Char = Url; Char < Url + Length; Char++) {
 //
-// Update state machine accoring to next char.
+// Update state machine according to next char.
 //
 State = NetHttpParseUrlChar (*Char, State);
 
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdMemory.c 
b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdMemory.c
index 74c17bd248..3dc6376215 100644
--- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdMemory.c
+++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdMemory.c
@@ -37,7 +37,7 @@ EdbDisplayMemoryUnit (
   UINT64 Data64;
 
   //
-  // Print accroding to width
+  // Print according to width
   //
   switch (Width) {
   case EdbWidthUint8:
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdSymbol.c 
b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdSymbol.c
index ba62c6ac27..3ca793059f 100644
--- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdSymbol.c
+++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdSymbol.c
@@ -70,7 +70,7 @@ GetDirNameFromFullPath (
 
 /**
 
-  Construct full path accroding to dir and file path.
+  Construct full path according to dir and file path.
 
   @param  DirPath - dir path
   @

Re: [edk2] [PATCH v2 2/6] MdeModulePkg/PciBus: Accept Spec values as BarIndex and Alignment

2017-02-06 Thread Tian, Feng
2/3/4 looks good to me

Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Ni, Ruiyu 
Sent: Monday, February 6, 2017 2:01 PM
To: edk2-devel@lists.01.org
Cc: Fan, Jeff <jeff@intel.com>; Tian, Feng <feng.t...@intel.com>
Subject: [PATCH v2 2/6] MdeModulePkg/PciBus: Accept Spec values as BarIndex and 
Alignment

PI spec IncompatiblePciSupport part defines (UINT64) -1 as all BARs and 0 to 
use existing alignment. PciBus driver didn't accept these values. It treated 
0xFF as all BARs and 0xULL to use existing alignment.
The patch changes the code to still accept old values while also accept values 
defined in PI spec. So that the driver can provide backward compatibility and 
follow spec.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu...@intel.com>
Cc: Jeff Fan <jeff@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
---
 .../Bus/Pci/PciBusDxe/PciEnumeratorSupport.c   | 37 ++
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
index ac4d323..978116a 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
@@ -1,7 +1,7 @@
 /** @file
   PCI emumeration support functions implementation for PCI Bus module.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 (C) Copyright 2015 Hewlett Packard Enterprise Development LP  This program 
and the accompanying materials  are licensed and made available under the terms 
and conditions of the BSD License @@ -17,6 +17,12 @@ WITHOUT WARRANTIES OR 
REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 extern CHAR16  *mBarTypeStr[];
 
+
+#define OLD_ALIGN   0xULL
+#define EVEN_ALIGN  0xFFFEULL #define SQUAD_ALIGN 
+0xFFFDULL #define DQUAD_ALIGN 0xFFFCULL
+
 /**
   This routine is used to check whether the pci device is present.
 
@@ -1335,8 +1341,8 @@ UpdatePciInfo (
   )
 {
   EFI_STATUSStatus;
-  UINTN BarIndex;
-  UINTN BarEndIndex;
+  UINT64BarIndex;
+  UINT64BarEndIndex;
   BOOLEAN   SetFlag;
   VOID  *Configuration;
   EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Ptr; @@ -1390,18 +1396,19 @@ 
UpdatePciInfo (
   break;
 }
 
-BarIndex= (UINTN) Ptr->AddrTranslationOffset;
+BarIndex= Ptr->AddrTranslationOffset;
 BarEndIndex = BarIndex;
 
 //
 // Update all the bars in the device
+// Compare against 0xFF is to keep backward compatibility.
 //
-if (BarIndex == PCI_BAR_ALL) {
+if ((BarIndex == (UINT64)-1) || (BarIndex == 0xFF)) {
   BarIndex= 0;
   BarEndIndex = PCI_MAX_BAR - 1;
 }
 
-if (BarIndex > PCI_MAX_BAR) {
+if (BarIndex >= PCI_MAX_BAR) {
   Ptr++;
   continue;
 }
@@ -1472,7 +1479,7 @@ UpdatePciInfo (
 //
 // Update the new length for the device
 //
-if (Ptr->AddrLen != PCI_BAR_NOCHANGE) {
+if (Ptr->AddrLen != 0) {
   PciIoDevice->PciBar[BarIndex].Length = Ptr->AddrLen;
 }
   }
@@ -1488,6 +1495,8 @@ UpdatePciInfo (
 
 /**
   This routine will update the alignment with the new alignment.
+  Compare with OLD_ALIGN/EVEN_ALIGN/SQUAD_ALIGN/DQUAD_ALIGN is to keep  
+ backward compatibility.
 
   @param AlignmentInput Old alignment. Output updated alignment.
   @param NewAlignment New alignment.
@@ -1506,15 +1515,15 @@ SetNewAlign (
   // The new alignment is the same as the original,
   // so skip it
   //
-  if (NewAlignment == PCI_BAR_OLD_ALIGN) {
+  if ((NewAlignment == 0) || (NewAlignment == OLD_ALIGN)) {
 return ;
   }
   //
   // Check the validity of the parameter
   //
-   if (NewAlignment != PCI_BAR_EVEN_ALIGN  &&
-   NewAlignment != PCI_BAR_SQUAD_ALIGN &&
-   NewAlignment != PCI_BAR_DQUAD_ALIGN ) {
+   if (NewAlignment != EVEN_ALIGN  &&
+   NewAlignment != SQUAD_ALIGN &&
+   NewAlignment != DQUAD_ALIGN ) {
 *Alignment = NewAlignment;
 return ;
   }
@@ -1533,15 +1542,15 @@ SetNewAlign (
   //
   // Adjust the alignment to even, quad or double quad boundary
   //
-  if (NewAlignment == PCI_BAR_EVEN_ALIGN) {
+  if (NewAlignment == EVEN_ALIGN) {
 if ((OldAlignment & 0x01) != 0) {
   OldAlignment = OldAlignment + 2 - (OldAlignment & 0x01);
 }
-  } else if (NewAlignment == PCI_BAR_SQUAD_ALIGN) {
+  } else if (NewAlignment == SQUAD_ALIGN) {
 if ((OldAlignment & 0x03) != 0) {
   OldAlignment = OldAlignment + 4 - (OldAlignment & 

Re: [edk2] [PATCH 3/3] MdeModulePkg/DxeCore: Add UEFI image protection.

2017-02-05 Thread Tian, Feng
Jiewen,

So where will you add such limitation statements? In this commit log or other 
places?
Thanks
Feng

From: Gao, Liming
Sent: Saturday, February 4, 2017 11:40 AM
To: Yao, Jiewen <jiewen@intel.com>; edk2-devel@lists.01.org
Cc: Kinney, Michael D <michael.d.kin...@intel.com>; Tian, Feng 
<feng.t...@intel.com>; Zeng, Star <star.z...@intel.com>
Subject: RE: [edk2] [PATCH 3/3] MdeModulePkg/DxeCore: Add UEFI image protection.

Jiewen:
  I agree to keep the same policy to SMM and Runtime driver.

Thanks
Liming
From: Yao, Jiewen
Sent: Saturday, February 04, 2017 8:42 AM
To: Gao, Liming <liming@intel.com<mailto:liming@intel.com>>; 
edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
Cc: Kinney, Michael D 
<michael.d.kin...@intel.com<mailto:michael.d.kin...@intel.com>>; Tian, Feng 
<feng.t...@intel.com<mailto:feng.t...@intel.com>>; Zeng, Star 
<star.z...@intel.com<mailto:star.z...@intel.com>>
Subject: RE: [edk2] [PATCH 3/3] MdeModulePkg/DxeCore: Add UEFI image protection.

It is pre-requisite that code section and data section should not be not merged.
That is same criteria for SMM and Runtime driver.

The problem is that I am not able to see the difference. I can only get LINK 
warning below:
LINK : warning LNK4254: section '.data' (C040) merged into '.text' 
(6020) with different attributes
But final attribute in PE code section is same.

Thank you
Yao Jiewen

From: Gao, Liming
Sent: Friday, February 3, 2017 4:40 PM
To: Yao, Jiewen <jiewen@intel.com<mailto:jiewen@intel.com>>; 
edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
Cc: Kinney, Michael D 
<michael.d.kin...@intel.com<mailto:michael.d.kin...@intel.com>>; Tian, Feng 
<feng.t...@intel.com<mailto:feng.t...@intel.com>>; Zeng, Star 
<star.z...@intel.com<mailto:star.z...@intel.com>>
Subject: RE: [edk2] [PATCH 3/3] MdeModulePkg/DxeCore: Add UEFI image protection.

Jiewen:
  I have one comment. If VS linker option /MERGE:.data=.text is set, the 
generated PE image will have one .text section. If this section is set to RO, 
its data will be RO. Does this patch specially handle this case?

Thanks
Liming
>-Original Message-
>From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>Jiewen Yao
>Sent: Thursday, January 26, 2017 4:39 PM
>To: edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
>Cc: Kinney, Michael D 
><michael.d.kin...@intel.com<mailto:michael.d.kin...@intel.com>>; Tian, Feng
><feng.t...@intel.com<mailto:feng.t...@intel.com>>; Zeng, Star 
><star.z...@intel.com<mailto:star.z...@intel.com>>
>Subject: [edk2] [PATCH 3/3] MdeModulePkg/DxeCore: Add UEFI image
>protection.
>
>If the UEFI image is page aligned, the image code section is set to read
>only and the image data section is set to non-executable.
>
>1) This policy is applied for all UEFI image including boot service driver,
>runtime driver or application.
>2) This policy is applied only if the UEFI image meets the page alignment
>requirement.
>3) This policy is applied only if the UEFI image is from firmware volume.
>If the image is from OPROM, file system, or network, this policy is not
>applied, even if the image meets the page alignment requirement.
>4) This policy is not applied to the non-PE image region.
>
>The DxeCore calls CpuArchProtocol->SetMemoryAttributes() to protect
>the image. If the CpuArch protocol is not installed yet, the DxeCore
>enqueues the protection request. Once the CpuArch is installed, the
>DxeCore dequeues the protection request and applies policy.
>
>Once the image is unloaded, the protection is removed automatically.
>
>Cc: Star Zeng <star.z...@intel.com<mailto:star.z...@intel.com>>
>Cc: Feng Tian <feng.t...@intel.com<mailto:feng.t...@intel.com>>
>Cc: Michael Kinney 
><michael.d.kin...@intel.com<mailto:michael.d.kin...@intel.com>>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Jiewen Yao <jiewen@intel.com<mailto:jiewen@intel.com>>
>---
> MdeModulePkg/Core/Dxe/DxeMain.h   |  53 ++
> MdeModulePkg/Core/Dxe/DxeMain.inf |   2 +
> MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c   |   1 +
> MdeModulePkg/Core/Dxe/Image/Image.c   |   5 +
> MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 822
>
> MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c  |  22 -
> 6 files changed, 883 insertions(+), 22 deletions(-)
>
>diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h
>b/MdeModulePkg/Core/Dxe/DxeMain.h
>index ae35fbb..67b5a5a 100644
>--- a/MdeModulePkg/Core/Dxe/DxeMain.h
>+++ b/MdeModulePkg/Core/Dxe/DxeMain.h
>@@ -267,6 +267,26 @@ typedef struct {
> #define LOADED_IMAGE_

Re: [edk2] [PATCH 1/2] MdeModulePkg/AcpiTableDxe: condense whitespace around FADT.{DSDT, X_DSDT}

2017-02-05 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Thursday, February 2, 2017 1:57 AM
To: edk2-devel-01 <edk2-devel@lists.01.org>
Cc: Al Stone <a...@redhat.com>; Ard Biesheuvel <ard.biesheu...@linaro.org>; 
Tian, Feng <feng.t...@intel.com>; Igor Mammedov <imamm...@redhat.com>; Leo 
Duran <leo.du...@amd.com>; Michael Tsirkin <mtsir...@redhat.com>; Phil 
Dennis-Jordan <p...@philjordan.eu>; Zeng, Star <star.z...@intel.com>
Subject: [PATCH 1/2] MdeModulePkg/AcpiTableDxe: condense whitespace around 
FADT.{DSDT,X_DSDT}

This patch incurs no functional changes, it just removes some whitespace, and 
also makes sure we always assign

  AcpiTableInstance->Fadt3->Dsdt

first, and

  AcpiTableInstance->Fadt3->XDsdt

second. The goal is to separate the syntactic changes from the functional 
changes implemented by the next patch.

Cc: Al Stone <a...@redhat.com>
Cc: Ard Biesheuvel <ard.biesheu...@linaro.org>
Cc: Feng Tian <feng.t...@intel.com>
Cc: Igor Mammedov <imamm...@redhat.com>
Cc: Leo Duran <leo.du...@amd.com>
Cc: Michael Tsirkin <mtsir...@redhat.com>
Cc: Phil Dennis-Jordan <p...@philjordan.eu>
Cc: Star Zeng <star.z...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---

Notes:
NOTE for people on the CC list:

If you are not presently subscribed to edk2-devel and wish to comment on
this patch publicly, you need to subscribe first, and wait for the
subscription request to *complete* (see your inbox), *before* sending
your followup. This is not ideal, but edk2-devel requires subscription
before reflecting messages from someone.

Subscribe at <https://lists.01.org/mailman/listinfo/edk2-devel>. Thanks.

 MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 20 
++--
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c 
b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
index 7f95b9dc709d..7795ff7269ca 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
@@ -646,16 +646,12 @@ AddTableToList (
 AcpiTableInstance->Fadt3->FirmwareCtrl = 0;
   }
   if ((UINT64)(UINTN)AcpiTableInstance->Dsdt3 < BASE_4GB) {
-AcpiTableInstance->Fadt3->Dsdt  = (UINT32) (UINTN) 
AcpiTableInstance->Dsdt3;
+AcpiTableInstance->Fadt3->Dsdt = (UINT32) (UINTN) 
+ AcpiTableInstance->Dsdt3;
 ZeroMem (>Fadt3->XDsdt, sizeof (UINT64));
   } else {
-Buffer64  = (UINT64) (UINTN) 
AcpiTableInstance->Dsdt3;
-CopyMem (
-  >Fadt3->XDsdt,
-  ,
-  sizeof (UINT64)
-  );
 AcpiTableInstance->Fadt3->Dsdt = 0;
+Buffer64 = (UINT64) (UINTN) AcpiTableInstance->Dsdt3;
+CopyMem (>Fadt3->XDsdt, , sizeof 
+ (UINT64));
   }
 
   //
@@ -850,14 +846,10 @@ AddTableToList (
   //
   if (AcpiTableInstance->Fadt3 != NULL) {
 if ((UINT64)(UINTN)AcpiTableInstance->Dsdt3 < BASE_4GB) {
-  AcpiTableInstance->Fadt3->Dsdt  = (UINT32) (UINTN) 
AcpiTableInstance->Dsdt3;
+  AcpiTableInstance->Fadt3->Dsdt = (UINT32) (UINTN) 
+ AcpiTableInstance->Dsdt3;
 }
-Buffer64  = (UINT64) (UINTN) 
AcpiTableInstance->Dsdt3;
-CopyMem (
-  >Fadt3->XDsdt,
-  ,
-  sizeof (UINT64)
-  );
+Buffer64 = (UINT64) (UINTN) AcpiTableInstance->Dsdt3;
+CopyMem (>Fadt3->XDsdt, , sizeof 
+ (UINT64));
 
 //
 // Checksum FADT table
--
2.9.3


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


Re: [edk2] [Patch] MdeModulePkg PiSmmIpl: Update SmmCommunication comments to match code logic

2017-02-05 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Gao, Liming 
Sent: Friday, February 3, 2017 9:35 AM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.z...@intel.com>; Tian, Feng <feng.t...@intel.com>
Subject: [Patch] MdeModulePkg PiSmmIpl: Update SmmCommunication comments to 
match code logic

Cc: Star Zeng <star.z...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming@intel.com>
---
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c 
b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
index d3a5cda..7a4f4df 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
@@ -1,7 +1,7 @@
 /** @file
   SMM IPL that produces SMM related runtime protocols and load the SMM Core 
into SMRAM
 
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 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
@@ -508,7 +508,7 @@ SmmCommunicationCommunicate (
   }
 
   //
-  // If we are not in SMM, don't allow call SmiManage() directly when SMRAM is 
closed or locked.
+  // Before SetVirtualAddressMap(), we are in SMM or SMRAM is open and unlock, 
call SmiManage() directly.
   //
   if ((!gSmmCorePrivate->InSmm) && (!mSmmAccess->OpenState || 
mSmmAccess->LockState)) {
 return EFI_INVALID_PARAMETER;
-- 
2.8.0.windows.1

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


Re: [edk2] [PATCH 2/3] MdeModulePkg: Update PcdSmbiosDocRev to 0x1 for SMBIOS spec 3.1.1

2017-01-23 Thread Tian, Feng
reviewed-by: Feng Tian <feng.t...@intel.com>

-Original Message-
From: Zeng, Star 
Sent: Sunday, January 22, 2017 4:18 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.z...@intel.com>; Tian, Feng <feng.t...@intel.com>; Gao, 
Liming <liming@intel.com>
Subject: [PATCH 2/3] MdeModulePkg: Update PcdSmbiosDocRev to 0x1 for SMBIOS 
spec 3.1.1

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=349

Cc: Feng Tian <feng.t...@intel.com>
Cc: Liming Gao <liming@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.z...@intel.com>
---
 MdeModulePkg/MdeModulePkg.dec | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec 
index 7e67ddccbb85..273cd7e1716f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1519,7 +1519,7 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, 
PcdsDynamicEx]
 
   ## SMBIOS Docrev field in SMBIOS 3.0 (64-bit) Entry Point Structure.
   # @Prompt SMBIOS Docrev field in SMBIOS 3.0 (64-bit) Entry Point Structure.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0|UINT8|0x0001006A
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x1|UINT8|0x0001006A
 
   ## SMBIOS produce method.
   #  BIT0 set indicates 32-bit entry point and table are produced.
--
2.7.0.windows.1

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


Re: [edk2] [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Refine ConfigurePixelBitMaskFormat

2017-01-23 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Ni, Ruiyu 
Sent: Monday, January 23, 2017 2:12 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Refine 
ConfigurePixelBitMaskFormat

https://bugzilla.tianocore.org/show_bug.cgi?id=339
The patch refines ConfigurePixelBitMaskFormat() to prepare the enhancement in 
next commit: Enhance this library to use dynamic allocated line buffer to 
reduce memory usage of frame buffer configure.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
---
 .../Library/FrameBufferBltLib/FrameBufferBltLib.c  | 71 +-
 1 file changed, 43 insertions(+), 28 deletions(-)

diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c 
b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
index c9bb206..5f6eddc 100644
--- a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
+++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
@@ -1,7 +1,7 @@
 /** @file
   FrameBufferBltLib - Library to perform blt operations on a frame buffer.
 
-  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2007 - 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 @@ -30,8 +30,8 @@ struct FRAME_BUFFER_CONFIGURE {
   UINT8   *FrameBuffer;
   EFI_GRAPHICS_PIXEL_FORMAT   PixelFormat;
   EFI_PIXEL_BITMASK   PixelMasks;
-  INTNPixelShl[4]; // R-G-B-Rsvd
-  INTNPixelShr[4]; // R-G-B-Rsvd
+  INT8PixelShl[4]; // R-G-B-Rsvd
+  INT8PixelShr[4]; // R-G-B-Rsvd
 };
 
 CONST EFI_PIXEL_BITMASK mRgbPixelMasks = { @@ -45,43 +45,47 @@ CONST 
EFI_PIXEL_BITMASK mBgrPixelMasks = {
 /**
   Initialize the bit mask in frame buffer configure.
 
-  @param Configure  The frame buffer configure.
-  @param BitMaskThe bit mask of pixel.
+  @param BitMask   The bit mask of pixel.
+  @param BytesPerPixel Size in bytes of pixel.
+  @param PixelShl  Left shift array.
+  @param PixelShr  Right shift array.
 **/
 VOID
-ConfigurePixelBitMaskFormat (
-  IN FRAME_BUFFER_CONFIGURE *Configure,
-  IN CONST EFI_PIXEL_BITMASK*BitMask
+FrameBufferBltLibConfigurePixelFormat (
+  IN CONST EFI_PIXEL_BITMASK*BitMask,
+  OUT UINTN *BytesPerPixel,
+  OUT INT8  *PixelShl,
+  OUT INT8  *PixelShr
   )
 {
-  UINTN   Loop;
+  UINT8   Index;
   UINT32  *Masks;
   UINT32  MergedMasks;
 
+  ASSERT (BytesPerPixel != NULL);
+
   MergedMasks = 0;
   Masks = (UINT32*) BitMask;
-  for (Loop = 0; Loop < 3; Loop++) {
-ASSERT ((Loop == 3) || (Masks[Loop] != 0));
-ASSERT ((MergedMasks & Masks[Loop]) == 0);
-Configure->PixelShl[Loop] = HighBitSet32 (Masks[Loop]) - 23 + (Loop * 8);
-if (Configure->PixelShl[Loop] < 0) {
-  Configure->PixelShr[Loop] = -Configure->PixelShl[Loop];
-  Configure->PixelShl[Loop] = 0;
+  for (Index = 0; Index < 3; Index++) {
+ASSERT ((MergedMasks & Masks[Index]) == 0);
+
+PixelShl[Index] = (INT8) HighBitSet32 (Masks[Index]) - 23 + (Index * 8);
+if (PixelShl[Index] < 0) {
+  PixelShr[Index] = -PixelShl[Index];
+  PixelShl[Index] = 0;
 } else {
-  Configure->PixelShr[Loop] = 0;
+  PixelShr[Index] = 0;
 }
-MergedMasks = (UINT32) (MergedMasks | Masks[Loop]);
-DEBUG ((EFI_D_VERBOSE, "%d: shl:%d shr:%d mask:%x\n", Loop,
-Configure->PixelShl[Loop], Configure->PixelShr[Loop], 
Masks[Loop]));
+DEBUG ((DEBUG_INFO, "%d: shl:%d shr:%d mask:%x\n", Index,
+PixelShl[Index], PixelShr[Index], Masks[Index]));
+
+MergedMasks = (UINT32) (MergedMasks | Masks[Index]);
   }
   MergedMasks = (UINT32) (MergedMasks | Masks[3]);
 
   ASSERT (MergedMasks != 0);
-  Configure->BytesPerPixel = (UINTN) ((HighBitSet32 (MergedMasks) + 7) / 8);
-
-  DEBUG ((EFI_D_VERBOSE, "Bytes per pixel: %d\n", Configure->BytesPerPixel));
-
-  CopyMem (>PixelMasks, BitMask, sizeof (*BitMask));
+  *BytesPerPixel = (UINTN) ((HighBitSet32 (MergedMasks) + 7) / 8);  
+ DEBUG ((DEBUG_INFO, "Bytes per pixel: %d\n", *BytesPerPixel));
 }
 
 /**
@@ -110,6 +114,11 @@ FrameBufferBltConfigure (
   IN OUT UINTN *ConfigureSize
   )
 {
+  CONST EFI_PIXEL_BITMASK  *BitMask;
+  UINTNBytesPerPixel;
+  INT8 PixelShl[4];
+  INT8   

Re: [edk2] [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Use dynamic allocated line buffer

2017-01-23 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Ni, Ruiyu 
Sent: Monday, January 23, 2017 2:12 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Use dynamic allocated line 
buffer

https://bugzilla.tianocore.org/show_bug.cgi?id=339

The patch uses dynamic allocated line buffer to reduce memory usage of frame 
buffer configure. (Original implementation uses 0x4000 bytes for line buffer.)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
---
 .../Library/FrameBufferBltLib/FrameBufferBltLib.c  | 24 +++---
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c 
b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
index 5f6eddc..011d9c5 100644
--- a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
+++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
@@ -26,12 +26,12 @@ struct FRAME_BUFFER_CONFIGURE {
   UINTN   BytesPerPixel;
   UINTN   WidthInPixels;
   UINTN   Height;
-  UINT8   LineBuffer[SIZE_4KB * sizeof 
(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)];
   UINT8   *FrameBuffer;
   EFI_GRAPHICS_PIXEL_FORMAT   PixelFormat;
   EFI_PIXEL_BITMASK   PixelMasks;
   INT8PixelShl[4]; // R-G-B-Rsvd
   INT8PixelShr[4]; // R-G-B-Rsvd
+  UINT8   LineBuffer[0];
 };
 
 CONST EFI_PIXEL_BITMASK mRgbPixelMasks = { @@ -123,15 +123,6 @@ 
FrameBufferBltConfigure (
 return RETURN_INVALID_PARAMETER;
   }
 
-  if (*ConfigureSize < sizeof (FRAME_BUFFER_CONFIGURE)) {
-*ConfigureSize = sizeof (FRAME_BUFFER_CONFIGURE);
-return RETURN_BUFFER_TOO_SMALL;
-  }
-
-  if (Configure == NULL) {
-return RETURN_INVALID_PARAMETER;
-  }
-
   switch (FrameBufferInfo->PixelFormat) {
   case PixelRedGreenBlueReserved8BitPerColor:
 BitMask = 
@@ -156,6 +147,17 @@ FrameBufferBltConfigure (
 
   FrameBufferBltLibConfigurePixelFormat (BitMask, , PixelShl, 
PixelShr);
 
+  if (*ConfigureSize < sizeof (FRAME_BUFFER_CONFIGURE)
+ + FrameBufferInfo->HorizontalResolution * BytesPerPixel) {
+*ConfigureSize = sizeof (FRAME_BUFFER_CONFIGURE)
+   + FrameBufferInfo->HorizontalResolution * BytesPerPixel;
+return RETURN_BUFFER_TOO_SMALL;
+  }
+
+  if (Configure == NULL) {
+return RETURN_INVALID_PARAMETER;
+  }
+
   CopyMem (>PixelMasks, BitMask,  sizeof (*BitMask));
   CopyMem (Configure->PixelShl,PixelShl, sizeof (PixelShl));
   CopyMem (Configure->PixelShr,PixelShr, sizeof (PixelShr));
@@ -166,8 +168,6 @@ FrameBufferBltConfigure (
   Configure->Height= (UINTN) FrameBufferInfo->VerticalResolution;
   Configure->WidthInBytes  = Configure->WidthInPixels * 
Configure->BytesPerPixel;
 
-  ASSERT (Configure->WidthInBytes < sizeof (Configure->LineBuffer));
-
   return RETURN_SUCCESS;
 }
 
--
2.9.0.windows.1

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


Re: [edk2] [PATCH 0/7] Make the event empty function in UefiLib public

2017-01-19 Thread Tian, Feng
MdeModulePkg reviewed-by: Feng Tian <feng.t...@intel.com> 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Laszlo 
Ersek
Sent: Thursday, January 19, 2017 6:30 PM
To: Zeng, Star <star.z...@intel.com>; edk2-devel@lists.01.org 
<edk2-de...@ml01.01.org>; Kinney, Michael D <michael.d.kin...@intel.com>; Fan, 
Jeff <jeff@intel.com>; Tian, Feng <feng.t...@intel.com>; Ni, Ruiyu 
<ruiyu...@intel.com>; Ma, Maurice <maurice...@intel.com>; Agyeman, Prince 
<prince.agye...@intel.com>; Steele, Kelly <kelly.ste...@intel.com>; Leif 
Lindholm <leif.lindh...@linaro.org>
Cc: Gao, Liming <liming@intel.com>; Ard Biesheuvel 
<ard.biesheu...@linaro.org>
Subject: Re: [edk2] [PATCH 0/7] Make the event empty function in UefiLib public

Hi Star,

On 01/19/17 11:27, Zeng, Star wrote:
> Hi,
> 
> Please kindly help take a review to the patches. :)
> 
> So far, I have got the RB from Liming and Ard to MdePkg and ArmPlatformPkg.

I didn't ignore the series, it's just that I don't co-maintain any of the 
packages being modified.

Thanks
Laszlo

> -Original Message-
> From: Zeng, Star
> Sent: Tuesday, January 17, 2017 3:09 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.z...@intel.com>; Gao, Liming 
> <liming@intel.com>; Kinney, Michael D 
> <michael.d.kin...@intel.com>; Fan, Jeff <jeff@intel.com>; Tian, 
> Feng <feng.t...@intel.com>; Ni, Ruiyu <ruiyu...@intel.com>; Ma, 
> Maurice <maurice...@intel.com>; Agyeman, Prince 
> <prince.agye...@intel.com>; Steele, Kelly <kelly.ste...@intel.com>; 
> Leif Lindholm <leif.lindh...@linaro.org>; Ard Biesheuvel 
> <ard.biesheu...@linaro.org>; Laszlo Ersek <ler...@redhat.com>
> Subject: [PATCH 0/7] Make the event empty function in UefiLib public
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=298
> 
> We found there are many event empty functions in EDK2 code base, these 
> patches are to make the event empty function in UefiLib public, then this 
> event empty function can be used to remove the duplication in drivers and 
> other libraries.
> 
> In CorebootPayloadPkg/QuarkPlatformPkg/ArmPlatformPkg, EfiEventGroupSignal 
> from UefiLib can be used to remove the duplication of event empty function.
> 
> Cc: Liming Gao <liming@intel.com>
> Cc: Michael Kinney <michael.d.kin...@intel.com>
> Cc: Jeff Fan <jeff@intel.com>
> Cc: Feng Tian <feng.t...@intel.com>
> Cc: Ruiyu Ni <ruiyu...@intel.com>
> Cc: Maurice Ma <maurice...@intel.com>
> Cc: Prince Agyeman <prince.agye...@intel.com>
> Cc: Kelly Steele <kelly.ste...@intel.com>
> Cc: Leif Lindholm <leif.lindh...@linaro.org>
> Cc: Ard Biesheuvel <ard.biesheu...@linaro.org>
> Cc: Laszlo Ersek <ler...@redhat.com>
> 
> Star Zeng (7):
>   MdePkg UefiLib: Make the event empty function public
>   IntelFrameworkPkg UefiLib: Make the event empty function public
>   MdeModulePkg: Use EfiEventEmptyFunction from UefiLib
>   IntelFrameworkModulePkg: Use EfiEventEmptyFunction from UefiLib
>   CorebootPayloadPkg: Use EfiEventGroupSignal from UefiLib
>   QuarkPlatformPkg: Use EfiEventGroupSignal from UefiLib
>   ArmPlatformPkg: Use EfiEventGroupSignal from UefiLib
> 
>  .../Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 36 ++-  
> .../Library/PlatformIntelBdsLib/IntelBdsPlatform.h |  3 +-
>  .../PlatformIntelBdsLib/PlatformIntelBdsLib.inf|  3 +-
>  .../PlatformBootManagerLib/PlatformBootManager.c   | 25 ++---
>  .../Universal/BdsDxe/BdsEntry.c| 20 +--
>  .../Library/FrameworkUefiLib/UefiLib.c | 42 
> +++---
>  .../Library/FrameworkUefiLib/UefiLibInternal.h | 20 +--
>  .../Library/FrameworkUefiLib/UefiNotTiano.c|  4 +--
>  MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c  | 23 ++--
>  MdeModulePkg/Core/Dxe/DxeMain.h| 18 +-
>  MdeModulePkg/Core/Dxe/Event/Event.c|  4 +--
>  MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c | 19 ++  
> .../Universal/Console/ConSplitterDxe/ConSplitter.c | 22 ++--  
> .../Universal/Console/ConSplitterDxe/ConSplitter.h | 18 +-
>  .../Universal/DriverSampleDxe/DriverSample.c   | 20 ++-
>  .../Universal/SetupBrowserDxe/Presentation.c   | 20 ++-
>  MdePkg/Include/Library/UefiLib.h   | 18 +-
>  MdePkg/Library/UefiLib/UefiLib.c   | 42 
> +++---
>  MdePkg/Library/UefiLib/UefiLibInternal.h   | 20 +--
>  MdePkg/Library/UefiLib/UefiNotTiano.c  | 10 +++

Re: [edk2] Why is USB_BOOT_IO_BLOCKS set to 128?

2017-01-18 Thread Tian, Feng
Hi, Heyi

Just I said before, it's just an experience value. 

The transfer length limitation only comes from real h/w and the largest 
transfer length shipped by SCSI Read10/Write10 cmd.

A SCSI Read10/Write10 cmd supports max 0x blocks. But according to our 
experience, some h/w devices don't have such big internal buffer to support 
read/write 0x blocks once. That's why we introduced a back-off algorithm in 
ScsiDiskDxe to handle such case. 

As for Usb cdrom/bot devices, we just directly use such a macro to specify the 
max transfer length. If you met real problem, please tell me the device 
model/serial no, then we can modify this value accordingly.

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Heyi Guo
Sent: Wednesday, January 18, 2017 2:41 PM
To: Tian, Feng <feng.t...@intel.com>; edk2-devel@lists.01.org
Cc: Zeng, Star <star.z...@intel.com>
Subject: Re: [edk2] Why is USB_BOOT_IO_BLOCKS set to 128?

Hi Feng,

Digging in the code history, I found the original value of USB_BOOT_IO_BLOCKS 
was 64, but it was changed to be 128 by the commit 41e8ff2. So could you help 
to explain my questions as below?

1. What was the exact reason to change this value?

2. And for the comment in the code, it says "Max carried size is 512B *
128 = 64KB", but we see that some USB CDROM has block size of 2KB. So do we 
mean something for 64KB max size?

3. From USB specification perspective, is there any limit for transfer length, 
or the device should be able to transfer arbitrary length?

commit 41e8ff2781f3ca14f73ef5f39e781ccba8cb373d
Author: yshang1 <yshang1@6f19259b-4bc3-4df7-8a09-765794883524>
Date:   Mon Oct 8 06:14:13 2007 +

 Fixed unexpected timeout in Usb MassStorage Driver.
 Fixed unexpected timeout in Uhci/Ehci driver.

 git-svn-id: 
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4038
6f19259b-4bc3-4df7-8a09-765794883524

Thanks and regards,

Heyi


在 10/19/2016 10:10 AM, Tian, Feng 写道:
> It's just an experience value and has been here about 10 years...
>
> Which usb brand/model name do you have problem on?
>
> Thanks
> Feng
>
> -Original Message-
> From: Heyi Guo [mailto:heyi@linaro.org]
> Sent: Wednesday, October 19, 2016 9:57 AM
> To: edk2-devel@lists.01.org
> Cc: Tian, Feng <feng.t...@intel.com>; Zeng, Star <star.z...@intel.com>
> Subject: [edk2] Why is USB_BOOT_IO_BLOCKS set to 128?
>
> Dear experts,
>
> Could anyone help to explain why USB_BOOT_IO_BLOCKS in 
> MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h is set to 128?
>
> We found on some platforms this value may cause USB boot failure and
> *64* blocks will make them work. Though we have not got the final root cause, 
> it will be really helpful if you can tell the reason of setting it to 128 and 
> possible root cause for such issue.
>
> Thanks and regards,
>
> Heyi
>

___
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 0/3] Add SMBIOS spec 3.1.0 support

2017-01-16 Thread Tian, Feng
MdeModulePkg reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Zeng, Star 
Sent: Tuesday, January 17, 2017 11:25 AM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.z...@intel.com>; Gao, Liming <liming@intel.com>; 
Kinney, Michael D <michael.d.kin...@intel.com>; Tian, Feng 
<feng.t...@intel.com>; Ni, Ruiyu <ruiyu...@intel.com>; Carsey, Jaben 
<jaben.car...@intel.com>
Subject: [PATCH 0/3] Add SMBIOS spec 3.1.0 support

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=340

TPM Device (Type 43) support has been added at
713e4b007cb791829397522ad8f366dd1e08bee6 and 
e9f0be021b7649c15d823e193110c0088cda9a89.

These patch are to add support for below items.
• BIOS Information (Type 0):
– Add new entry for extended BIOS ROM size • System Enclosure or Chassis (Type 
3):
– Add new chassis types: IoT Gateway and Embedded PC – Add new chassis types: 
Mini PC and Stick PC • Processor Information (Type 4):
– Add Intel Core m3 m5 m7 processors
– Add processor socket AM4
– Add processor socket LGA1151
– Add processor socket BGA1356, BGA1440, BGA1515 – Add AMD Opteron A-Series 
processor – Add processor socket LGA3647-1 – Add processor socket SP3 
Processors – Add families for ARMv7 and ARMv8 – Add family for AMD Opteron(TM) 
X3000 Series APU • Cache Information (Type 7):
– Extend to support Cache sizes >2047 MB • System Slots (Type 9):
– Add Mini PCIe support

Cc: Liming Gao <liming@intel.com>
Cc: Michael Kinney <michael.d.kin...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
Cc: Ruiyu Ni <ruiyu...@intel.com>
Cc: Jaben Carsey <jaben.car...@intel.com>

Star Zeng (3):
  MdePkg: Add definitions for SMBIOS spec 3.1.0
  MdeModulePkg: Update PcdSmbiosVersion to 0x0301 for SMBIOS spec 3.1.0
  ShellPkg SmbiosView: Add decoding of SMBIOS spec 3.1.0

 MdeModulePkg/MdeModulePkg.dec  |  2 +-
 MdePkg/Include/IndustryStandard/SmBios.h   | 46 --
 .../SmbiosView/PrintInfo.c | 44 -
 .../SmbiosView/QueryTable.c| 56 ++
 .../SmbiosView/SmbiosViewStrings.uni   |  1 +
 .../UefiShellDebug1CommandsLib.uni |  3 +-
 6 files changed, 145 insertions(+), 7 deletions(-)

--
2.7.0.windows.1

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


Re: [edk2] [PATCH v2 5/5] MdeModulePkg/UfsBlockIoPei: fix initialize OCS value to 0x0F

2017-01-16 Thread Tian, Feng
Agree.

How about naming it as UFS_TRD_OCS_INIT_VALUE?

If there is no objection, I will help make this change and push these patches 
into EDKII trunk.

Series reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Leif Lindholm [mailto:leif.lindh...@linaro.org] 
Sent: Tuesday, January 17, 2017 12:03 AM
To: Haojian Zhuang <haojian.zhu...@linaro.org>
Cc: Tian, Feng <feng.t...@intel.com>; ard.biesheu...@linaro.org; 
edk2-devel@lists.01.org
Subject: Re: [PATCH v2 5/5] MdeModulePkg/UfsBlockIoPei: fix initialize OCS 
value to 0x0F

On Mon, Jan 16, 2017 at 08:22:58PM +0800, Haojian Zhuang wrote:
> The OCS value should be initiliazed as 0x0F according to UFS spec.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Haojian Zhuang <haojian.zhu...@linaro.org>
> ---
>  MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c 
> b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c
> index cccacce..67042b7 100644
> --- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c
> +++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c
> @@ -480,6 +480,7 @@ UfsCreateScsiCommandDesc (
>Trd->Int= UFS_INTERRUPT_COMMAND;
>Trd->Dd = DataDirection;
>Trd->Ct = UFS_STORAGE_COMMAND_TYPE;
> +  Trd->Ocs= 0x0F;

Could these be given some #define in UfsHci.h rather than inline magic numbers?

Regards,

Leif

>Trd->UcdBa  = (UINT32)RShiftU64 ((UINT64)(UINTN)CommandUpiu, 7);
>Trd->UcdBaU = (UINT32)RShiftU64 ((UINT64)(UINTN)CommandUpiu, 32);
>Trd->RuL= (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof 
> (UTP_RESPONSE_UPIU)), sizeof (UINT32));
> @@ -637,6 +638,7 @@ UfsCreateNopCommandDesc (
>Trd->Int= UFS_INTERRUPT_COMMAND;
>Trd->Dd = 0x00;
>Trd->Ct = UFS_STORAGE_COMMAND_TYPE;
> +  Trd->Ocs= 0x0F;
>Trd->UcdBa  = (UINT32)RShiftU64 ((UINT64)(UINTN)NopOutUpiu, 7);
>Trd->UcdBaU = (UINT32)RShiftU64 ((UINT64)(UINTN)NopOutUpiu, 32);
>Trd->RuL= (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof 
> (UTP_NOP_IN_UPIU)), sizeof (UINT32));
> --
> 2.7.4
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 1/8] MdeModulePkg/TerminalDxe: Replace macro with enum for terminal types

2017-01-10 Thread Tian, Feng
Series reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Ni, Ruiyu 
Sent: Tuesday, January 10, 2017 4:39 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.z...@intel.com>; Tian, Feng <feng.t...@intel.com>
Subject: [PATCH 1/8] MdeModulePkg/TerminalDxe: Replace macro with enum for 
terminal types

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu...@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
---
 .../Universal/Console/TerminalDxe/Terminal.c   | 50 ++--
 .../Universal/Console/TerminalDxe/Terminal.h   | 14 ++--
 .../Universal/Console/TerminalDxe/TerminalConIn.c  | 88 +++--- 
 .../Universal/Console/TerminalDxe/TerminalConOut.c | 28 +++
 4 files changed, 91 insertions(+), 89 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c 
b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index a209bf3..1c1f5e1 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -2,7 +2,7 @@
   Produces Simple Text Input Protocol, Simple Text Input Extended Protocol and
   Simple Text Output Protocol upon Serial IO Protocol.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 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 @@ -270,23 +270,23 
@@ BuildTerminalDevpath  (
 
   } else if (CompareGuid (>Guid, )) {
 
-TerminalType = PCANSITYPE;
+TerminalType = TerminalTypePcAnsi;
 
   } else if (CompareGuid (>Guid, )) {
 
-TerminalType = VT100TYPE;
+TerminalType = TerminalTypeVt100;
 
   } else if (CompareGuid (>Guid, )) {
 
-TerminalType = VT100PLUSTYPE;
+TerminalType = TerminalTypeVt100Plus;
 
   } else if (CompareGuid (>Guid, )) {
 
-TerminalType = VTUTF8TYPE;
+TerminalType = TerminalTypeVtUtf8;
 
   } else if (CompareGuid (>Guid, )) {
 
-TerminalType = TTYTERMTYPE;
+TerminalType = TerminalTypeTtyTerm;
 
   } else {
 return NULL;
@@ -713,9 +713,9 @@ TerminalDriverBindingStart (
 if (RemainingDevicePath == NULL) {
   TerminalType = PcdGet8 (PcdDefaultTerminalType);
   //
-  // Must be between PCANSITYPE (0) and TTYTERMTYPE (4)
+  // Must be between TerminalTypePcAnsi (0) and TerminalTypeTtyTerm 
+ (4)
   //
-  ASSERT (TerminalType <= TTYTERMTYPE);
+  ASSERT (TerminalType <= TerminalTypeTtyTerm);
 } else if (!IsDevicePathEnd (RemainingDevicePath)) {
   //
   // If RemainingDevicePath isn't the End of Device Path Node, @@ -723,15 
+723,15 @@ TerminalDriverBindingStart (
   //
   Node = (VENDOR_DEVICE_PATH *)RemainingDevicePath;
   if (CompareGuid (>Guid, )) {
-TerminalType = PCANSITYPE;
+TerminalType = TerminalTypePcAnsi;
   } else if (CompareGuid (>Guid, )) {
-TerminalType = VT100TYPE;
+TerminalType = TerminalTypeVt100;
   } else if (CompareGuid (>Guid, )) {
-TerminalType = VT100PLUSTYPE;
+TerminalType = TerminalTypeVt100Plus;
   } else if (CompareGuid (>Guid, )) {
-TerminalType = VTUTF8TYPE;
+TerminalType = TerminalTypeVtUtf8;
   } else if (CompareGuid (>Guid, )) {
-TerminalType = TTYTERMTYPE;
+TerminalType = TerminalTypeTtyTerm;
   } else {
 goto Error;
   }
@@ -863,7 +863,7 @@ TerminalDriverBindingStart (
 //
 TerminalDevice->ControllerNameTable = NULL;
 switch (TerminalDevice->TerminalType) {
-case PCANSITYPE:
+case TerminalTypePcAnsi:
   AddUnicodeString2 (
 "eng",
 gTerminalComponentName.SupportedLanguages,
@@ -881,7 +881,7 @@ TerminalDriverBindingStart (
 
   break;
 
-case VT100TYPE:
+case TerminalTypeVt100:
   AddUnicodeString2 (
 "eng",
 gTerminalComponentName.SupportedLanguages,
@@ -899,7 +899,7 @@ TerminalDriverBindingStart (
 
   break;
 
-case VT100PLUSTYPE:
+case TerminalTypeVt100Plus:
   AddUnicodeString2 (
 "eng",
 gTerminalComponentName.SupportedLanguages,
@@ -917,7 +917,7 @@ TerminalDriverBindingStart (
 
   break;
 
-case VTUTF8TYPE:
+case TerminalTypeVtUtf8:
   AddUnicodeString2 (
 "eng",
 gTerminalComponentName.SupportedLanguages,
@@ -935,7 +935,7 @@ TerminalDriverBindingStart (
 
   break;
 
-case TTYTERMTYPE:
+case TerminalTypeTtyTerm:
   AddUnicodeString2 (
 "eng",
 gTerminalComponentName.SupportedLanguages,
@@ -1473,7 +1473,7 @@ TerminalUpdateConsoleDevVariable (
   //
   // Append terminal device path 

Re: [edk2] [PATCH] MdeModulePkg/Stall: Refine to compare 2 values with the same type

2017-01-10 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Wu, Hao A 
Sent: Friday, January 6, 2017 4:52 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A <hao.a...@intel.com>; Tian, Feng <feng.t...@intel.com>; Zeng, 
Star <star.z...@intel.com>; Kinney, Michael D <michael.d.kin...@intel.com>
Subject: [PATCH] MdeModulePkg/Stall: Refine to compare 2 values with the same 
type

Cc: Feng Tian <feng.t...@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Cc: Michael Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a...@intel.com>
---
 MdeModulePkg/Core/Dxe/Misc/Stall.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Misc/Stall.c 
b/MdeModulePkg/Core/Dxe/Misc/Stall.c
index 73e9078..95a5615 100644
--- a/MdeModulePkg/Core/Dxe/Misc/Stall.c
+++ b/MdeModulePkg/Core/Dxe/Misc/Stall.c
@@ -1,7 +1,7 @@
 /** @file
   UEFI Miscellaneous boot Services Stall service implementation
 
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 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 @@ -67,7 +67,7 @@ 
CoreStall (
   // Counter = Microseconds * 10 / gMetronome->TickPeriod
   // 0x1999 = (2^64 - 1) / 10
   //
-  if (Microseconds > 0x1999ULL) {
+  if ((UINT64) Microseconds > 0x1999ULL) {
 //
 // Microseconds is too large to multiple by 10 first.  Perform the divide 
 // operation first and loop 10 times to avoid 64-bit math overflow.
--
1.9.5.msysgit.0

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


Re: [edk2] [PATCH 4/9] Ufs: fix to set UTRLBA and UTRLBAU register

2017-01-10 Thread Tian, Feng
You can try 5966dd8ff2ef60095227523794ad07af675a3aeb of git repo or svn 
https://svn.code.sf.net/p/edk2/code/trunk/edk2@18088


Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Haojian 
Zhuang
Sent: Tuesday, January 10, 2017 5:52 PM
To: Tian, Feng <feng.t...@intel.com>; leif.lindh...@linaro.org; 
ard.biesheu...@linaro.org; edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: Re: [edk2] [PATCH 4/9] Ufs: fix to set UTRLBA and UTRLBAU register

Hi Feng,



What’s the commit number of the old EDKII UFS driver?



Best Regards

Haojian



From: Tian, Feng<mailto:feng.t...@intel.com>
Sent: 2017年1月10日 15:47
To: haojian.zhu...@linaro.org<mailto:haojian.zhu...@linaro.org>; 
leif.lindh...@linaro.org<mailto:leif.lindh...@linaro.org>; 
ard.biesheu...@linaro.org<mailto:ard.biesheu...@linaro.org>; 
edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
Cc: Tian, Feng<mailto:feng.t...@intel.com>
Subject: RE: [PATCH 4/9] Ufs: fix to set UTRLBA and UTRLBAU register



Haojian

It's weird, I ever tested it with real h/w. it worked well.

As I have no UFS at hand, could you please test the old revision if EDKII UFS 
driver to see if it's regression?

And just like I said before, your fix has problem if selected slot is not zero.

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
haojian.zhu...@linaro.org
Sent: Tuesday, January 10, 2017 2:09 PM
To: Tian, Feng <feng.t...@intel.com>; leif.lindh...@linaro.org; 
ard.biesheu...@linaro.org; edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: Re: [edk2] [PATCH 4/9] Ufs: fix to set UTRLBA and UTRLBAU register

Hi Feng,

The problem is failing to send scsi command without this patch.

Without this patch, I’ll find there’s no response UPIU of command UPIU.

Best Regards
Haojian

From: Tian, Feng
Sent: 2017年1月9日 9:25
To: Haojian Zhuang; leif.lindh...@linaro.org; ard.biesheu...@linaro.org; 
edk2-devel@lists.01.org
Cc: Tian, Feng
Subject: RE: [PATCH 4/9] Ufs: fix to set UTRLBA and UTRLBAU register

___
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-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 4/9] Ufs: fix to set UTRLBA and UTRLBAU register

2017-01-09 Thread Tian, Feng
Haojian

It's weird, I ever tested it with real h/w. it worked well.

As I have no UFS at hand, could you please test the old revision if EDKII UFS 
driver to see if it's regression?

And just like I said before, your fix has problem if selected slot is not zero.

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
haojian.zhu...@linaro.org
Sent: Tuesday, January 10, 2017 2:09 PM
To: Tian, Feng <feng.t...@intel.com>; leif.lindh...@linaro.org; 
ard.biesheu...@linaro.org; edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: Re: [edk2] [PATCH 4/9] Ufs: fix to set UTRLBA and UTRLBAU register

Hi Feng,

The problem is failing to send scsi command without this patch.

Without this patch, I’ll find there’s no response UPIU of command UPIU.

Best Regards
Haojian

From: Tian, Feng
Sent: 2017年1月9日 9:25
To: Haojian Zhuang; leif.lindh...@linaro.org; ard.biesheu...@linaro.org; 
edk2-devel@lists.01.org
Cc: Tian, Feng
Subject: RE: [PATCH 4/9] Ufs: fix to set UTRLBA and UTRLBAU register

___
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] MdeModulePkg/DxeCore: Fix ASSERT() from GCD DEBUG() messages

2017-01-08 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Zeng, Star 
Sent: Monday, January 9, 2017 1:06 PM
To: Kinney, Michael D <michael.d.kin...@intel.com>; edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: RE: [Patch] MdeModulePkg/DxeCore: Fix ASSERT() from GCD DEBUG() 
messages

Reviewed-by: Star Zeng <star.z...@intel.com>

-Original Message-
From: Kinney, Michael D 
Sent: Monday, January 9, 2017 1:00 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Zeng, Star <star.z...@intel.com>
Subject: [Patch] MdeModulePkg/DxeCore: Fix ASSERT() from GCD DEBUG() messages

If a BaseAddress of NULL is passed into DXE Core services
CoreAllocateIoSpace() or CoreAllocateMemorySpace(), and
DEBUG() messages are enabled, then a NULL pointer reference is made.  The 
parameter check for BaseAddress is performed in the function 
CoreAllocateSpace() after the DEBUG() messages.  A check is added in the 
DEBUG() messages to prevent the NULL pointer reference.

This issue was found with PI SCTs with DEBUG messages enabled in the DXE Core.

Cc: Feng Tian <feng.t...@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kin...@intel.com>
---
 MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c 
index bd7c6c6..e008ce8 100644
--- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -3,7 +3,7 @@
   The GCD services are used to manage the memory and I/O regions that
   are accessible to the CPU that is executing the DXE core.
 
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 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 @@ -1337,7 +1337,11 
@@ CoreAllocateMemorySpace (
   IN EFI_HANDLE DeviceHandle OPTIONAL
   )
 {
-  DEBUG ((DEBUG_GCD, "GCD:AllocateMemorySpace(Base=%016lx,Length=%016lx)\n", 
*BaseAddress, Length));
+  if (BaseAddress != NULL) {
+DEBUG ((DEBUG_GCD, 
+ "GCD:AllocateMemorySpace(Base=%016lx,Length=%016lx)\n", *BaseAddress, 
Length));  } else {
+DEBUG ((DEBUG_GCD, 
+ "GCD:AllocateMemorySpace(Base=,Length=%016lx)\n", Length));  }
   DEBUG ((DEBUG_GCD, "  GcdAllocateType = %a\n", mGcdAllocationTypeNames[MIN 
(GcdAllocateType, EfiGcdMaxAllocateType)]));
   DEBUG ((DEBUG_GCD, "  GcdMemoryType   = %a\n", mGcdMemoryTypeNames[MIN 
(GcdMemoryType, EfiGcdMemoryTypeMaximum)]));
   DEBUG ((DEBUG_GCD, "  Alignment   = %016lx\n", LShiftU64 (1, 
Alignment)));
@@ -1761,7 +1765,11 @@ CoreAllocateIoSpace (
   IN EFI_HANDLE DeviceHandle OPTIONAL
   )
 {
-  DEBUG ((DEBUG_GCD, "GCD:AllocateIoSpace(Base=%016lx,Length=%016lx)\n", 
*BaseAddress, Length));
+  if (BaseAddress != NULL) {
+DEBUG ((DEBUG_GCD, 
+ "GCD:AllocateIoSpace(Base=%016lx,Length=%016lx)\n", *BaseAddress, Length));  
} else {
+DEBUG ((DEBUG_GCD, 
+ "GCD:AllocateIoSpace(Base=,Length=%016lx)\n", Length));  }
   DEBUG ((DEBUG_GCD, "  GcdAllocateType = %a\n", mGcdAllocationTypeNames[MIN 
(GcdAllocateType, EfiGcdMaxAllocateType)]));
   DEBUG ((DEBUG_GCD, "  GcdIoType   = %a\n", mGcdIoTypeNames[MIN 
(GcdIoType, EfiGcdIoTypeMaximum)]));
   DEBUG ((DEBUG_GCD, "  Alignment   = %016lx\n", LShiftU64 (1, 
Alignment)));
--
2.6.3.windows.1

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


Re: [edk2] [PATCH 4/9] Ufs: fix to set UTRLBA and UTRLBAU register

2017-01-08 Thread Tian, Feng
Haojian,

Please refer to below pic.

For example, we set UTRL as 0x1, and we found 5th slot is free, then we 
should doorbell the 5th bit of UTRLDBR.

Your change will set UTRL as 0x100050,(assume each TRD uses 0x10bytes for easy 
understanding), then you have to set doorbell to 0.

Besides this, your fix also disobeys the UFS spec, which requests the UTRLBA is 
1KB align.

[cid:image003.jpg@01D26A5A.4655E180]

Thanks
Feng

From: Haojian Zhuang [mailto:haojian.zhu...@linaro.org]
Sent: Friday, January 6, 2017 5:06 PM
To: Tian, Feng <feng.t...@intel.com>; leif.lindh...@linaro.org; 
ard.biesheu...@linaro.org; edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: RE: [PATCH 4/9] Ufs: fix to set UTRLBA and UTRLBAU register


Hi Feng,



I don’t understand why doorbell location should be updated too. If we don’t 
update UTRLBA & UTRLBAU for sending each UPIU packet, we have to extend the 
size of UTRD packet. Then we could avoid to create a new command buffer.



Best Regards

Haojian



From: Tian, Feng<mailto:feng.t...@intel.com>
Sent: 2017年1月6日 16:36
To: Haojian Zhuang<mailto:haojian.zhu...@linaro.org>; 
leif.lindh...@linaro.org<mailto:leif.lindh...@linaro.org>; 
ard.biesheu...@linaro.org<mailto:ard.biesheu...@linaro.org>; 
edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
Cc: Tian, Feng<mailto:feng.t...@intel.com>
Subject: RE: [PATCH 4/9] Ufs: fix to set UTRLBA and UTRLBAU register


Hi, Haojian

If the UTRLBA & UTRLBAU gets changed like below, the doorbell location also 
should be updated. So I don't suggest to update them.

Thanks
Feng

-Original Message-
From: Haojian Zhuang [mailto:haojian.zhu...@linaro.org]
Sent: Friday, January 6, 2017 2:52 PM
To: Tian, Feng <feng.t...@intel.com<mailto:feng.t...@intel.com>>; 
leif.lindh...@linaro.org<mailto:leif.lindh...@linaro.org>; 
ard.biesheu...@linaro.org<mailto:ard.biesheu...@linaro.org>; 
edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
Cc: Haojian Zhuang <haojian.zhu...@linaro.org<mailto:haojian.zhu...@linaro.org>>
Subject: [PATCH 4/9] Ufs: fix to set UTRLBA and UTRLBAU register

Although UfsInitTransferRequestList () assigns UTRLBA && UTRLBAU registers, 
UfsCreateScsiCommandDesc () creates a page of command buffer. It means that 
UTRLBA && UTRLBAU registers should be updated.

Always set UTRLBA && UTRLBAU registers before sending UPIU packet.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Haojian Zhuang 
<haojian.zhu...@linaro.org<mailto:haojian.zhu...@linaro.org>>
---
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c 
b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index e556b62..5c256a9 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -937,6 +937,8 @@ UfsRwDeviceDesc (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBA_OFFSET, (UINTN)Trd &
+ 0x);
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBAU_OFFSET, ((UINTN)Trd >> 32) &
+ 0x);

   //
   // Check the transfer request result.
@@ -1060,6 +1062,8 @@ UfsRwAttributes (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBA_OFFSET, (UINTN)Trd &
+ 0x);
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBAU_OFFSET, ((UINTN)Trd >> 32) &
+ 0x);

   //
   // Check the transfer request result.
@@ -1184,6 +1188,8 @@ UfsRwFlags (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBA_OFFSET, (UINTN)Trd &
+ 0x);
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBAU_OFFSET, ((UINTN)Trd >> 32) &
+ 0x);

   //
   // Check the transfer request result.
@@ -1351,6 +1357,8 @@ UfsExecNopCmds (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBA_OFFSET, (UINTN)Trd &
+ 0x);
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBAU_OFFSET, ((UINTN)Trd >> 32) &
+ 0x);

   //
   // Check the transfer request result.
@@ -1473,6 +1481,8 @@ UfsExecScsiCmds (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBA_OFFSET, (UINTN)TransReq->Trd &
+ 0x);
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBAU_OFFSET, ((UINTN)TransReq->Trd
+ >> 32) & 0x);

   TransReq->CmdDescSize = TransReq->Trd->PrdtO * sizeof (UINT32) + 
TransReq->Trd->PrdtL * sizeof (UTP_TR_PRD);

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


Re: [edk2] [PATCH 6/9] Ufs: add PhyInit

2017-01-06 Thread Tian, Feng
Yes, I am thinking moving UFS HC enable to lower layer, this way should be able 
to eliminate interface change...

Thanks
Feng

-Original Message-
From: Haojian Zhuang [mailto:haojian.zhu...@linaro.org] 
Sent: Friday, January 6, 2017 4:22 PM
To: Tian, Feng <feng.t...@intel.com>
Cc: leif.lindh...@linaro.org; ard.biesheu...@linaro.org; edk2-devel@lists.01.org
Subject: Re: [edk2] [PATCH 6/9] Ufs: add PhyInit

It's a bit hard to implement it in lower layer. Since PhyInit () should be 
executed between UFS controller enabled and UicDmeLinkStartup command.

Best Regards
Haojian

On 6 January 2017 at 15:27, Tian, Feng <feng.t...@intel.com> wrote:
> Could this be done at lower layer rather than changing existing interface?
>
> Thanks
> Feng
>
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Haojian Zhuang
> Sent: Friday, January 6, 2017 2:52 PM
> To: Tian, Feng <feng.t...@intel.com>; leif.lindh...@linaro.org; 
> ard.biesheu...@linaro.org; edk2-devel@lists.01.org
> Cc: Haojian Zhuang <haojian.zhu...@linaro.org>
> Subject: [edk2] [PATCH 6/9] Ufs: add PhyInit
>
> Add PhyInit() to support designware UFS controller.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Haojian Zhuang <haojian.zhu...@linaro.org>
> ---
>  MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c| 2 ++
>  MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 8 
>  MdeModulePkg/Include/Protocol/UfsHostController.h| 7 +++
>  3 files changed, 17 insertions(+)
>
> diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c 
> b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
> index 7c831e9..761dc8e 100644
> --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
> +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
> @@ -853,6 +853,8 @@ UfsPassThruDriverBindingStart (
>  goto Error;
>}
>
> +  MicroSecondDelay (10);
> +
>//
>// Get Ufs Device's Lun Info by reading Configuration Descriptor.
>//
> diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c 
> b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
> index 218e9f5..7c01d57 100644
> --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
> +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
> @@ -2089,6 +2089,7 @@ UfsControllerInit (
>)
>  {
>EFI_STATUS Status;
> +  EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc;
>
>Status = UfsEnableHostController (Private);
>if (EFI_ERROR (Status)) {
> @@ -2096,6 +2097,13 @@ UfsControllerInit (
>  return Status;
>}
>
> +  UfsHc  = Private->UfsHostController;  Status = UfsHc->PhyInit 
> + (UfsHc);  if (EFI_ERROR (Status)) {
> +DEBUG ((EFI_D_ERROR, "UfsControllerInit: Phy Init Fails, Status = %r\n", 
> Status));
> +return Status;
> +  }
> +
>Status = UfsDeviceDetection (Private);
>if (EFI_ERROR (Status)) {
>  DEBUG ((EFI_D_ERROR, "UfsControllerInit: Device Detection Fails, 
> Status = %r\n", Status)); diff --git 
> a/MdeModulePkg/Include/Protocol/UfsHostController.h 
> b/MdeModulePkg/Include/Protocol/UfsHostController.h
> index 909c981..1f3605f 100644
> --- a/MdeModulePkg/Include/Protocol/UfsHostController.h
> +++ b/MdeModulePkg/Include/Protocol/UfsHostController.h
> @@ -221,6 +221,12 @@ EFI_STATUS
>IN OUT VOID  *Buffer
>);
>
> +typedef
> +EFI_STATUS
> +(EFIAPI *EDKII_UFS_HC_PHY_INIT)(
> +  IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL*This
> +  );
> +
>  ///
>  ///  UFS Host Controller Protocol structure.
>  ///
> @@ -233,6 +239,7 @@ struct _EDKII_UFS_HOST_CONTROLLER_PROTOCOL {
>EDKII_UFS_HC_FLUSH  Flush;
>EDKII_UFS_HC_MMIO_READ_WRITERead;
>EDKII_UFS_HC_MMIO_READ_WRITEWrite;
> +  EDKII_UFS_HC_PHY_INIT   PhyInit;
>  };
>
>  ///
> --
> 2.7.4
>
> ___
> 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 8/9] Ufs: fix to add cache operation

2017-01-06 Thread Tian, Feng
Haojian,

The CmdDescHost is a EdkiiUfsHcOperationBusMasterCommonBuffer common buffer, 
which means Host and DMA could access this region at the same time. So there is 
no cache coherent issue:)

Thanks
Feng

-Original Message-
From: Haojian Zhuang [mailto:haojian.zhu...@linaro.org] 
Sent: Friday, January 6, 2017 2:52 PM
To: Tian, Feng <feng.t...@intel.com>; leif.lindh...@linaro.org; 
ard.biesheu...@linaro.org; edk2-devel@lists.01.org
Cc: Haojian Zhuang <haojian.zhu...@linaro.org>
Subject: [PATCH 8/9] Ufs: fix to add cache operation

Since command UPIU is initialized with virtual address that CPU accesses, need 
to add cache operation.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Haojian Zhuang <haojian.zhu...@linaro.org>
---
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h  | 1 +
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf | 1 +
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c   | 8 
 3 files changed, 10 insertions(+)

diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h 
b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
index 7fc82ba..af13757 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
@@ -26,6 +26,7 @@
 #include 
 #include   #include 

+#include 
 #include 
 #include 
 
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf 
b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf
index c90c72f..254f51a 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf
@@ -49,6 +49,7 @@
   BaseMemoryLib
   UefiLib
   BaseLib
+  CacheMaintenanceLib
   UefiDriverEntryPoint
   DebugLib
   DevicePathLib
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c 
b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index db70fb1..98a17ac 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -1449,6 +1449,7 @@ UfsExecScsiCmds (
   UTP_TR_PRD   *PrdtBase;
   EFI_TPL  OldTpl;
   UFS_PASS_THRU_TRANS_REQ  *TransReq;
+  UINTNTotalLen;
 
   TransReq   = AllocateZeroPool (sizeof (UFS_PASS_THRU_TRANS_REQ));
   if (TransReq == NULL) {
@@ -1521,6 +1522,13 @@ UfsExecScsiCmds (
   UfsInitUtpPrdt (PrdtBase, (VOID*)(UINTN)DataBufPhyAddr, DataLen);
 
   //
+  // Flush & invalidate data cache since CmdDescHost is virtual address  
+ // and Command UPIU is updated after Map ().
+  //
+  TotalLen = (TransReq->Trd->PrdtO << 2) + (TransReq->Trd->PrdtL << 2);  
+ WriteBackInvalidateDataCacheRange (TransReq->CmdDescHost, TotalLen);
+
+  //
   // Insert the async SCSI cmd to the Async I/O list
   //
   if (Event != NULL) {
--
2.7.4

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


Re: [edk2] [PATCH 4/9] Ufs: fix to set UTRLBA and UTRLBAU register

2017-01-06 Thread Tian, Feng
Hi, Haojian

If the UTRLBA & UTRLBAU gets changed like below, the doorbell location also 
should be updated. So I don't suggest to update them.

Thanks
Feng

-Original Message-
From: Haojian Zhuang [mailto:haojian.zhu...@linaro.org] 
Sent: Friday, January 6, 2017 2:52 PM
To: Tian, Feng <feng.t...@intel.com>; leif.lindh...@linaro.org; 
ard.biesheu...@linaro.org; edk2-devel@lists.01.org
Cc: Haojian Zhuang <haojian.zhu...@linaro.org>
Subject: [PATCH 4/9] Ufs: fix to set UTRLBA and UTRLBAU register

Although UfsInitTransferRequestList () assigns UTRLBA && UTRLBAU registers, 
UfsCreateScsiCommandDesc () creates a page of command buffer. It means that 
UTRLBA && UTRLBAU registers should be updated.

Always set UTRLBA && UTRLBAU registers before sending UPIU packet.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Haojian Zhuang <haojian.zhu...@linaro.org>
---
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c 
b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index e556b62..5c256a9 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -937,6 +937,8 @@ UfsRwDeviceDesc (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBA_OFFSET, (UINTN)Trd & 
+ 0x);
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBAU_OFFSET, ((UINTN)Trd >> 32) & 
+ 0x);
 
   //
   // Check the transfer request result.
@@ -1060,6 +1062,8 @@ UfsRwAttributes (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBA_OFFSET, (UINTN)Trd & 
+ 0x);
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBAU_OFFSET, ((UINTN)Trd >> 32) & 
+ 0x);
 
   //
   // Check the transfer request result.
@@ -1184,6 +1188,8 @@ UfsRwFlags (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBA_OFFSET, (UINTN)Trd & 
+ 0x);
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBAU_OFFSET, ((UINTN)Trd >> 32) & 
+ 0x);
 
   //
   // Check the transfer request result.
@@ -1351,6 +1357,8 @@ UfsExecNopCmds (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBA_OFFSET, (UINTN)Trd & 
+ 0x);
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBAU_OFFSET, ((UINTN)Trd >> 32) & 
+ 0x);
 
   //
   // Check the transfer request result.
@@ -1473,6 +1481,8 @@ UfsExecScsiCmds (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBA_OFFSET, (UINTN)TransReq->Trd & 
+ 0x);
+  UfsMmioWrite32 (Private, UFS_HC_UTRLBAU_OFFSET, ((UINTN)TransReq->Trd 
+ >> 32) & 0x);
 
   TransReq->CmdDescSize = TransReq->Trd->PrdtO * sizeof (UINT32) + 
TransReq->Trd->PrdtL * sizeof (UTP_TR_PRD);
 
--
2.7.4

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


Re: [edk2] [PATCH 9/9] ScsiDisk: retry if device detected power failure

2017-01-06 Thread Tian, Feng
Hi, Haojian

We have handled ASC code 0x29 at DetectMediaParsingSenseKeys(). TestUnitReady 
will retry if it's that case.

So I don't understand this fix.

Thanks
Feng

-Original Message-
From: Haojian Zhuang [mailto:haojian.zhu...@linaro.org] 
Sent: Friday, January 6, 2017 2:52 PM
To: Tian, Feng <feng.t...@intel.com>; leif.lindh...@linaro.org; 
ard.biesheu...@linaro.org; edk2-devel@lists.01.org
Cc: Haojian Zhuang <haojian.zhu...@linaro.org>
Subject: [PATCH 9/9] ScsiDisk: retry if device detected power failure

If device detected power failure, just retry. This operation is common in linux 
kernel.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Haojian Zhuang <haojian.zhu...@linaro.org>
---
 MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c 
b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
index b5eff25..a7b62ec 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
@@ -2251,6 +2251,12 @@ ScsiDiskTestUnitReady (
   if (SenseDataLength != 0) {
 *NumberOfSenseKeys = SenseDataLength / sizeof (EFI_SCSI_SENSE_DATA);
 *SenseDataArray= ScsiDiskDevice->SenseData;
+if (((*SenseDataArray)->Sense_Key == EFI_SCSI_SK_UNIT_ATTENTION) &&
+((*SenseDataArray)->Addnl_Sense_Code == 0x29) &&
+((*SenseDataArray)->Addnl_Sense_Code_Qualifier == 0)) {
+  *NeedRetry = TRUE;
+  return EFI_NOT_READY;
+}
 return EFI_SUCCESS;
   }
 
--
2.7.4

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


Re: [edk2] [PATCH 6/9] Ufs: add PhyInit

2017-01-05 Thread Tian, Feng
Could this be done at lower layer rather than changing existing interface? 

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Haojian 
Zhuang
Sent: Friday, January 6, 2017 2:52 PM
To: Tian, Feng <feng.t...@intel.com>; leif.lindh...@linaro.org; 
ard.biesheu...@linaro.org; edk2-devel@lists.01.org
Cc: Haojian Zhuang <haojian.zhu...@linaro.org>
Subject: [edk2] [PATCH 6/9] Ufs: add PhyInit

Add PhyInit() to support designware UFS controller.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Haojian Zhuang <haojian.zhu...@linaro.org>
---
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c| 2 ++
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 8 
 MdeModulePkg/Include/Protocol/UfsHostController.h| 7 +++
 3 files changed, 17 insertions(+)

diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c 
b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
index 7c831e9..761dc8e 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
@@ -853,6 +853,8 @@ UfsPassThruDriverBindingStart (
 goto Error;
   }
 
+  MicroSecondDelay (10);
+
   //
   // Get Ufs Device's Lun Info by reading Configuration Descriptor.
   //
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c 
b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index 218e9f5..7c01d57 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -2089,6 +2089,7 @@ UfsControllerInit (
   )
 {
   EFI_STATUS Status;
+  EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc;
 
   Status = UfsEnableHostController (Private);
   if (EFI_ERROR (Status)) {
@@ -2096,6 +2097,13 @@ UfsControllerInit (
 return Status;
   }
 
+  UfsHc  = Private->UfsHostController;
+  Status = UfsHc->PhyInit (UfsHc);
+  if (EFI_ERROR (Status)) {
+DEBUG ((EFI_D_ERROR, "UfsControllerInit: Phy Init Fails, Status = %r\n", 
Status));
+return Status;
+  }
+
   Status = UfsDeviceDetection (Private);
   if (EFI_ERROR (Status)) {
 DEBUG ((EFI_D_ERROR, "UfsControllerInit: Device Detection Fails, Status = 
%r\n", Status)); diff --git a/MdeModulePkg/Include/Protocol/UfsHostController.h 
b/MdeModulePkg/Include/Protocol/UfsHostController.h
index 909c981..1f3605f 100644
--- a/MdeModulePkg/Include/Protocol/UfsHostController.h
+++ b/MdeModulePkg/Include/Protocol/UfsHostController.h
@@ -221,6 +221,12 @@ EFI_STATUS
   IN OUT VOID  *Buffer
   );
 
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_UFS_HC_PHY_INIT)(
+  IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL*This
+  );
+
 ///
 ///  UFS Host Controller Protocol structure.
 ///
@@ -233,6 +239,7 @@ struct _EDKII_UFS_HOST_CONTROLLER_PROTOCOL {
   EDKII_UFS_HC_FLUSH  Flush;
   EDKII_UFS_HC_MMIO_READ_WRITERead;
   EDKII_UFS_HC_MMIO_READ_WRITEWrite;
+  EDKII_UFS_HC_PHY_INIT   PhyInit;
 };
 
 ///
--
2.7.4

___
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 7/9] Ufs: fix initialize OCS value to 0x0F

2017-01-05 Thread Tian, Feng
Same with previous patches, could you please fix Ufs PEI driver as well?

Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Haojian 
Zhuang
Sent: Friday, January 6, 2017 2:52 PM
To: Tian, Feng <feng.t...@intel.com>; leif.lindh...@linaro.org; 
ard.biesheu...@linaro.org; edk2-devel@lists.01.org
Cc: Haojian Zhuang <haojian.zhu...@linaro.org>
Subject: [edk2] [PATCH 7/9] Ufs: fix initialize OCS value to 0x0F

The OCS value should be initiliazed as 0x0F according to UFS spec.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Haojian Zhuang <haojian.zhu...@linaro.org>
---
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c 
b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index 7c01d57..db70fb1 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -551,6 +551,7 @@ UfsCreateScsiCommandDesc (
   Trd->Int= UFS_INTERRUPT_COMMAND;
   Trd->Dd = DataDirection;
   Trd->Ct = UFS_STORAGE_COMMAND_TYPE;
+  Trd->Ocs= 0x0F;
   Trd->UcdBa  = (UINT32)RShiftU64 ((UINT64)CmdDescPhyAddr, 7);
   Trd->UcdBaU = (UINT32)RShiftU64 ((UINT64)CmdDescPhyAddr, 32);
   Trd->RuL= (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof 
(UTP_RESPONSE_UPIU)), sizeof (UINT32));
@@ -719,6 +720,7 @@ UfsCreateNopCommandDesc (
   Trd->Int= UFS_INTERRUPT_COMMAND;
   Trd->Dd = 0x00;
   Trd->Ct = UFS_STORAGE_COMMAND_TYPE;
+  Trd->Ocs= 0x0F;
   Trd->UcdBa  = (UINT32)RShiftU64 ((UINT64)CmdDescPhyAddr, 7);
   Trd->UcdBaU = (UINT32)RShiftU64 ((UINT64)CmdDescPhyAddr, 32);
   Trd->RuL= (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof 
(UTP_NOP_IN_UPIU)), sizeof (UINT32));
-- 
2.7.4

___
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 3/9] Ufs: fix the bit in UFS_HC_UTRLDBR_OFFSET register

2017-01-05 Thread Tian, Feng
Could you please update the same bug in UfsBlockIoPei driver as well?

And please update all the log headers to: MdeModulePkg/Ufs: .

Others look good to me.

Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Haojian 
Zhuang
Sent: Friday, January 6, 2017 2:52 PM
To: Tian, Feng <feng.t...@intel.com>; leif.lindh...@linaro.org; 
ard.biesheu...@linaro.org; edk2-devel@lists.01.org
Cc: Haojian Zhuang <haojian.zhu...@linaro.org>
Subject: [edk2] [PATCH 3/9] Ufs: fix the bit in UFS_HC_UTRLDBR_OFFSET register

When UPIU packet is sent, (BIT0 << Slot) should be set according to context.  
But BIT0 is used without Slot when UfsWaitMemSet () is invoked.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Haojian Zhuang <haojian.zhu...@linaro.org>
---
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c 
b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index f160d6a..e556b62 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -954,7 +954,7 @@ UfsRwDeviceDesc (
   //
   // Wait for the completion of the transfer request.
   //
-  Status = UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0, 0, 
Packet.Timeout);
+  Status = UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0 << Slot, 
+ 0, Packet.Timeout);
   if (EFI_ERROR (Status)) {
 goto Exit;
   }
@@ -1077,7 +1077,7 @@ UfsRwAttributes (
   //
   // Wait for the completion of the transfer request.
   //
-  Status = UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0, 0, 
Packet.Timeout);
+  Status = UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0 << Slot, 
+ 0, Packet.Timeout);
   if (EFI_ERROR (Status)) {
 goto Exit;
   }
@@ -1201,7 +1201,7 @@ UfsRwFlags (
   //
   // Wait for the completion of the transfer request.
   //
-  Status = UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0, 0, 
Packet.Timeout);
+  Status = UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0 << Slot, 
+ 0, Packet.Timeout);
   if (EFI_ERROR (Status)) {
 goto Exit;
   }
@@ -1368,7 +1368,7 @@ UfsExecNopCmds (
   //
   // Wait for the completion of the transfer request.
   //
-  Status = UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0, 0, 
UFS_TIMEOUT);
+  Status = UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0 << Slot, 
+ 0, UFS_TIMEOUT);
   if (EFI_ERROR (Status)) {
 goto Exit;
   }
@@ -1534,7 +1534,7 @@ UfsExecScsiCmds (
   //
   // Wait for the completion of the transfer request.
   //
-  Status = UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0, 0, 
Packet->Timeout);
+  Status = UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0 << 
+ TransReq->Slot, 0, Packet->Timeout);
   if (EFI_ERROR (Status)) {
 goto Exit;
   }
--
2.7.4

___
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 2/9] Ufs: fix to identify 32 bits address mode

2017-01-05 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Haojian 
Zhuang
Sent: Friday, January 6, 2017 2:52 PM
To: Tian, Feng <feng.t...@intel.com>; leif.lindh...@linaro.org; 
ard.biesheu...@linaro.org; edk2-devel@lists.01.org
Cc: Haojian Zhuang <haojian.zhu...@linaro.org>
Subject: [edk2] [PATCH 2/9] Ufs: fix to identify 32 bits address mode

When UFS_HC_CAP_64ADDR bit is set, it means 64-bit address, not 32-bit address.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Haojian Zhuang <haojian.zhu...@linaro.org>
---
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c 
b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index 9b77a89..f160d6a 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -1749,9 +1749,9 @@ UfsAllocateAlignCommonBuffer (
   EDKII_UFS_HOST_CONTROLLER_PROTOCOL   *UfsHc;
 
   if ((Private->Capabilities & UFS_HC_CAP_64ADDR) == UFS_HC_CAP_64ADDR) {
-Is32BitAddr = TRUE;
-  } else {
 Is32BitAddr = FALSE;
+  } else {
+Is32BitAddr = TRUE;
   }
 
   UfsHc  = Private->UfsHostController;
--
2.7.4

___
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 1/9] Ufs: fix data direction checking

2017-01-05 Thread Tian, Feng
Haojian,

The bit 5 is Flags.U of RESPONSE UPIU, which means the Target has less data 
bytes to transfer than the Initiator requested.

That's why we use "Packet->InTransferLength -= ResTranCount;" to return actual 
transfer data length.

It's not related data direction checking.

The bit 6 is Flags.O, which means the Target has more data bytes to transfer 
than the Initiator requested. It's not designated for your below intention.

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Haojian 
Zhuang
Sent: Friday, January 6, 2017 2:52 PM
To: Tian, Feng <feng.t...@intel.com>; leif.lindh...@linaro.org; 
ard.biesheu...@linaro.org; edk2-devel@lists.01.org
Cc: Haojian Zhuang <haojian.zhu...@linaro.org>
Subject: [edk2] [PATCH 1/9] Ufs: fix data direction checking

BIT6 is used in read operation, and BIT5 is used in write operation.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Haojian Zhuang <haojian.zhu...@linaro.org>
---
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c 
b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index 3bd6dad..9b77a89 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -1564,7 +1564,7 @@ UfsExecScsiCmds (
 
   if (TransReq->Trd->Ocs == 0) {
 if (Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_READ) {
-  if ((Response->Flags & BIT5) == BIT5) {
+  if ((Response->Flags & BIT6) == BIT6) {
 ResTranCount = Response->ResTranCount;
 SwapLittleEndianToBigEndian ((UINT8*), sizeof (UINT32));
 Packet->InTransferLength -= ResTranCount; @@ -2321,7 +2321,7 @@ 
ProcessAsyncTaskList (
 
 if (TransReq->Trd->Ocs == 0) {
   if (Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_READ) {
-if ((Response->Flags & BIT5) == BIT5) {
+if ((Response->Flags & BIT6) == BIT6) {
   ResTranCount = Response->ResTranCount;
   SwapLittleEndianToBigEndian ((UINT8*), sizeof 
(UINT32));
   Packet->InTransferLength -= ResTranCount;
--
2.7.4

___
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] MdeModulePkg/StaControllerDxe: Fix coding style issue

2017-01-04 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Bi, Dandan 
Sent: Thursday, January 5, 2017 1:22 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: [patch] MdeModulePkg/StaControllerDxe: Fix coding style issue

Remove the empty line.

Cc: Feng Tian <feng.t...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan...@intel.com>
---
 MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf 
b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
index 5092d37..03f9fa0 100644
--- a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
+++ b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
@@ -1,8 +1,7 @@
 ## @file
-#  
-#SataController driver to manage SATA compliance IDE/AHCI host controllers.
+#  SataController driver to manage SATA compliance IDE/AHCI host controllers.
 #
 #  Copyright (c) 2011 - 2016, 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
--
1.9.5.msysgit.1

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


Re: [edk2] [PATCH 0/6] Support source debugging on DXE AP function

2016-12-27 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Fan, Jeff 
Sent: Monday, December 26, 2016 7:21 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Kinney; Kinney, Michael D 
<michael.d.kin...@intel.com>; Ni, Ruiyu <ruiyu...@intel.com>
Subject: [PATCH 0/6] Support source debugging on DXE AP function

The current DxeDebugAgentLib supports source debugging on AP function. This 
update is to update DxeMpInitLib to consume Debug Agent Library by 
DEBUG_AGENT_INIT_DXE_AP flag. Thus, we could source debugging AP function 
invoked by CPU MP Protocol.

However, current SecPeiDebugAgentLib does not support source debugging on AP 
function invoked by CPU MP PPI. I have submitted one bugzilla to add this 
support at https://bugzilla.tianocore.org/show_bug.cgi?id=308.

We also fixed some bugs during switching BSP, when source debugging feature 
enabled. 

Cc: Feng Tian <feng.t...@intel.com>
Cc: Kinney, Michael D <michael.d.kin...@intel.com>
Cc: Ruiyu Ni <ruiyu...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>

Jeff Fan (6):
  UefiCpuPkg/DxeMpInitLib: Support source debugging on AP function
  UefiCpuPkg/MpInitLib: Sync BSP's local APIC timer settings to APs
  UefiCpuPkg/MpInitLib: Move save/restore interrupt to SwitchBSPWorker()
  UefiCpuPkg/MpInitLib: Swap local APIC timer interrupt state
  UefiCpuPkg/MpInitLib: Disable and restore system timer interrupt
  UefiCpuPkg/MpInitLib: Set new AP to idle state after switching BSP

 UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf |  5 ++
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c   | 58 -
 UefiCpuPkg/Library/MpInitLib/MpLib.c  | 91 ++-
 UefiCpuPkg/Library/MpInitLib/MpLib.h  | 15 +
 UefiCpuPkg/Library/MpInitLib/PeiMpLib.c   | 12 
 5 files changed, 164 insertions(+), 17 deletions(-)

--
2.9.3.windows.2

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


Re: [edk2] [PATCH 0/2] Handle NULL capsule name in record.

2016-12-22 Thread Tian, Feng
Reviewed-by: Feng Tian 

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Jiewen 
Yao
Sent: Thursday, December 22, 2016 1:48 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH 0/2] Handle NULL capsule name in record.

According to UEFI spec, capsule report variable should include a null 
terminator for capsule name and capsule target, if they are not present.

Jiewen Yao (2):
  MdeModulePkg/CapsuleLib: Add NULL capsule name in record.
  MdeModulePkg/CapsuleApp: Dump capsule name in record.

 MdeModulePkg/Application/CapsuleApp/CapsuleDump.c   | 16 

 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 11 ---
 2 files changed, 16 insertions(+), 11 deletions(-)

--
2.7.4.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] MdeModulePkg/CapsuleLib: remove ImageIndex check.

2016-12-22 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Jiewen 
Yao
Sent: Thursday, December 22, 2016 11:45 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Zeng, Star <star.z...@intel.com>
Subject: [edk2] [PATCH] MdeModulePkg/CapsuleLib: remove ImageIndex check.

UEFI specification does not require ImageIndex check, it only requires 
ImageTypeId check.

Cc: Feng Tian <feng.t...@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen@intel.com>
---
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c 
b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
index 3ba3b9c..af08886 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
@@ -1013,8 +1013,7 @@ ProcessFmpCapsuleImage (
 continue;
   }
 
-  if (CompareGuid(>UpdateImageTypeId, 
>ImageTypeId) &&
-  ImageHeader->UpdateImageIndex == TempFmpImageInfo->ImageIndex) {
+  if (CompareGuid(>UpdateImageTypeId, 
+ >ImageTypeId)) {
 AbortReason = NULL;
 if (ImageHeader->Version >= 
EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) {
   if(ImageHeader->UpdateHardwareInstance != 0){
--
2.7.4.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 7/8] MdeModulePkg/SataControllerDxe: Fix coding style issue

2016-12-19 Thread Tian, Feng
Could you help add some specific descriptions like below to the INF file?

SataController driver to manage SATA compliance IDE/AHCI host controllers.

Others look good to me

Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Bi, Dandan 
Sent: Monday, December 19, 2016 3:20 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: [patch 7/8] MdeModulePkg/SataControllerDxe: Fix coding style issue

Cc: Feng Tian <feng.t...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan...@intel.com>
---
 MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf 
b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
index e24b2a0..39cdffc 100644
--- a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
+++ b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
@@ -1,8 +1,8 @@
 ## @file
 #  
-#Component description file for the Sata Controller driver.
+#Component Description File for the Sata Controller driver.
 #
 #  Copyright (c) 2011 - 2016, 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
--
1.9.5.msysgit.1

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


Re: [edk2] [patch 6/8] MdeModulePkg/TerminalDxe: Initialize variable after declaration

2016-12-19 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Bi, Dandan 
Sent: Monday, December 19, 2016 3:20 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: [patch 6/8] MdeModulePkg/TerminalDxe: Initialize variable after 
declaration

Cc: Feng Tian <feng.t...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan...@intel.com>
---
 MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c 
b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
index 9625f4d..c9b4ffc 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
@@ -186,10 +186,11 @@ TerminalConOutOutputString (
   UTF8_CHAR   Utf8Char;
   CHAR8   GraphicChar;
   CHAR8   AsciiChar;
   EFI_STATUS  Status;
   UINT8   ValidBytes;
+  CHAR8   CrLfStr[2];
   //
   //  flag used to indicate whether condition happens which will cause
   //  return EFI_WARN_UNKNOWN_GLYPH
   //
   BOOLEAN Warning;
@@ -324,11 +325,12 @@ TerminalConOutOutputString (
   // the next character, but the driver thinks it has wrapped
   // already.  Print CR LF to synchronize the terminal with
   // the driver, but only if we're not in the middle of
   // printing an escape sequence.
   //
-  CHAR8 CrLfStr[] = {'\r', '\n'};
+  CrLfStr[0] = '\r';
+  CrLfStr[1] = '\n';
 
   Length = sizeof(CrLfStr);
 
   Status = TerminalDevice->SerialIo->Write (
 TerminalDevice->SerialIo,
-- 
1.9.5.msysgit.1

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


Re: [edk2] [patch] MdeModulePkg: Fix assert in iSCSI.

2016-12-06 Thread Tian, Feng
Reviewed-by: Feng Tian 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Zhang 
Lubo
Sent: Thursday, December 1, 2016 2:59 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Wu, Jiaxin 

Subject: [edk2] [patch] MdeModulePkg: Fix assert in iSCSI.

The bug is caused by using already freed memory.
If there is already an attempt and execute 'reconnect -r' command, all the 
ConfigFormEntry structure will be freed in IScsiDriverBindingStop, but the
mCallbackInfo->Current is not configured as null and
this pointer will be used again in IScsiFormExtractConfig.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c 
b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
index 77ccd67..ea727af 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
@@ -1074,10 +1074,11 @@ IScsiConfigUpdateForm (
 ASSERT (EntryExisted);
 
 mNumberOfIScsiDevices--;
 RemoveEntryList (>Link);
 FreePool (ConfigFormEntry);
+mCallbackInfo->Current = NULL;
   }
   //
   // Allocate space for creation of Buffer
   //
 
--
1.9.5.msysgit.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] UefiCpuPkg/PiSmmCpuDxeSmm: Always initialze PSD

2016-12-05 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Kinney, Michael D 
Sent: Tuesday, December 6, 2016 11:57 AM
To: edk2-devel@lists.01.org
Cc: Yao, Jiewen <jiewen@intel.com>; Fan, Jeff <jeff....@intel.com>; Tian, 
Feng <feng.t...@intel.com>
Subject: [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Always initialze PSD

The following commit moved the initialization of the default 
PROCESSOR_SMM_DESCRIPTOR from MpService.c to SmramSaveState.c and made this 
initialization conditional on the value returned by the
SmmCpuFeaturesGetSmiHandlerSize() library function.

https://github.com/tianocore/edk2/commit/f12367a0b1de7838f1cb8e0839e168ed7b862333

This changed the behavior of the PiSmmCpuDxeSmm module.
The initialization of the PROCESSOR_SMM_DESCRIPTOR is moved before the call to 
SmmCpuFeaturesGetSmiHandlerSize() to preserve the previous behavior.

Cc: Jiewen Yao <jiewen@intel.com>
Cc: Jeff Fan <jeff@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kin...@intel.com>
Reviewed-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c
index c37e9e8..b4bc0ec 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c
@@ -687,6 +687,14 @@ InstallSmiHandler (  {
   PROCESSOR_SMM_DESCRIPTOR  *Psd;
 
+  //
+  // Initialize PROCESSOR_SMM_DESCRIPTOR  //  Psd = 
+ (PROCESSOR_SMM_DESCRIPTOR *)(VOID *)(UINTN)(SmBase + SMM_PSD_OFFSET);  
+ CopyMem (Psd, , sizeof (gcPsd));  Psd->SmmGdtPtr = 
+ (UINT64)GdtBase;  Psd->SmmGdtSize = (UINT32)GdtSize;
+
   if (SmmCpuFeaturesGetSmiHandlerSize () != 0) {
 //
 // Install SMI handler provided by library @@ -706,14 +714,6 @@ 
InstallSmiHandler (
   }
 
   //
-  // Initialize PROCESSOR_SMM_DESCRIPTOR
-  //
-  Psd = (PROCESSOR_SMM_DESCRIPTOR *)(VOID *)(UINTN)(SmBase + SMM_PSD_OFFSET);
-  CopyMem (Psd, , sizeof (gcPsd));
-  Psd->SmmGdtPtr = (UINT64)GdtBase;
-  Psd->SmmGdtSize = (UINT32)GdtSize;
-
-  //
   // Initialize values in template before copy
   //
   gSmiStack = (UINT32)((UINTN)SmiStack + StackSize - sizeof 
(UINTN));
--
2.6.3.windows.1

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


Re: [edk2] [PATCH] MdeModulePkg/CapsuleApp: add Internal for function name.

2016-12-01 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Yao, Jiewen 
Sent: Thursday, December 1, 2016 4:51 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Fan, Jeff <jeff@intel.com>
Subject: [PATCH] MdeModulePkg/CapsuleApp: add Internal for function name.

To prevent potential build failure.

Cc: Feng Tian <feng.t...@intel.com>
Cc: Jeff Fan <jeff@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen@intel.com>
---
 MdeModulePkg/Application/CapsuleApp/AppSupport.c | 8   
MdeModulePkg/Application/CapsuleApp/CapsuleApp.c | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Application/CapsuleApp/AppSupport.c 
b/MdeModulePkg/Application/CapsuleApp/AppSupport.c
index 6aea76a..a5fd0ca 100644
--- a/MdeModulePkg/Application/CapsuleApp/AppSupport.c
+++ b/MdeModulePkg/Application/CapsuleApp/AppSupport.c
@@ -74,7 +74,7 @@ GetArg (
 
 **/
 EFI_STATUS
-StrToBuf (
+InternalStrToBuf (
   OUT UINT8*Buf,
   IN  UINTNBufferLength,
   IN  CHAR16   *Str
@@ -135,7 +135,7 @@ StrToBuf (
 
 **/
 EFI_STATUS
-StrToGuid (
+InternalStrToGuid (
   IN  CHAR16   *Str,
   OUT EFI_GUID *Guid
   )
@@ -185,7 +185,7 @@ StrToGuid (
   //
   // Get the following 8 bytes data
   //
-  StrToBuf (>Data4[0], 2, Str);
+  InternalStrToBuf (>Data4[0], 2, Str);
   //
   // Skip 2 byte hex chars
   //
@@ -196,7 +196,7 @@ StrToGuid (
   } else {
 return EFI_UNSUPPORTED;
   }
-  StrToBuf (>Data4[2], 6, Str);
+  InternalStrToBuf (>Data4[2], 6, Str);
 
   return EFI_SUCCESS;
 }
diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c 
b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
index 5137259..5b8c147 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
@@ -155,7 +155,7 @@ WriteFileFromBuffer (
 
 **/
 EFI_STATUS
-StrToGuid (
+InternalStrToGuid (
   IN  CHAR16   *Str,
   OUT EFI_GUID *Guid
   );
@@ -782,7 +782,7 @@ UefiMain (
 //
 // FMP->GetImage()
 //
-Status = StrToGuid(Argv[3], );
+Status = InternalStrToGuid(Argv[3], );
 if (EFI_ERROR(Status)) {
   Print (L"Invalid ImageTypeId - %s\n", Argv[3]);
   return Status;
--
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 0/3] mReservedVectors is not set

2016-11-30 Thread Tian, Feng
Reviewed-by: Feng Tian 

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Jeff Fan
Sent: Wednesday, November 30, 2016 3:23 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH 0/3] mReservedVectors is not set

mReservedVectors is used by ArchSaveExceptionContext() and
ArchRestoreExceptionContext() to support HOOK_AFTER capability.
But it is not set to correct pointer. This is one regression issue when we add 
PeiExcpetionHandlerLib.inf.

The fix is to add parameter ExceptionHandlerData for thoese 2 APIs and not to 
use mReservedVectors.

Jeff Fan (3):
  UefiCpuPkg: Add ExceptionHandlerData for ArchSaveExceptionContext()
  UefiCpuPkg: Add ExceptionHandlerData for ArchRestoreExceptionContext()
  UefiCpuPkg/CpuExceptionHandlerLib: remove un-used mReservedVectors

 .../CpuExceptionHandlerLib/CpuExceptionCommon.c|  5 +-
 .../CpuExceptionHandlerLib/CpuExceptionCommon.h| 23 -
 .../Ia32/ArchExceptionHandler.c| 47 +++
 .../CpuExceptionHandlerLib/PeiDxeSmmCpuException.c |  4 +-
 .../X64/ArchExceptionHandler.c | 54 +-
 5 files changed, 76 insertions(+), 57 deletions(-)

--
2.9.3.windows.2

___
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 0/2] UefiCpuPkg/PiSmmCpuDxeSmm: Reduce use of PSD

2016-11-30 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Fan, Jeff 
Sent: Thursday, December 1, 2016 12:58 PM
To: Kinney, Michael D <michael.d.kin...@intel.com>; edk2-devel@lists.01.org
Cc: Yao, Jiewen <jiewen....@intel.com>; Tian, Feng <feng.t...@intel.com>
Subject: RE: [Patch 0/2] UefiCpuPkg/PiSmmCpuDxeSmm: Reduce use of PSD

Reviewed-by: Jeff Fan <jeff@intel.com> on serials.

-Original Message-
From: Kinney, Michael D 
Sent: Wednesday, November 30, 2016 3:07 PM
To: edk2-devel@lists.01.org
Cc: Yao, Jiewen; Fan, Jeff; Tian, Feng
Subject: [Patch 0/2] UefiCpuPkg/PiSmmCpuDxeSmm: Reduce use of PSD

https://bugzilla.tianocore.org/show_bug.cgi?id=277

Remove MtrrBaseMaskPtr field from PSD and move MTRR to a global variable since 
all CPUs use the same MTRR settings.
Reduce use of PSD to allow alternate SmmCpuFeaturesLib implementations to use 
their own PSD layouts.

Cc: Jiewen Yao <jiewen@intel.com>
Cc: Jeff Fan <jeff@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kin...@intel.com>

Michael Kinney (2):
  UefiCpuPkg/PiSmmCpuDxeSmm: Remove MTRRs from PSD structure
  UefiCpuPkg/PiSmmCpuDxeSmm: Remove PSD layout assumptions

 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S  |  3 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm|  3 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm   |  3 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c  | 33 --
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 15 
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 26 --
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c |  2 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 40 +-
 8 files changed, 64 insertions(+), 61 deletions(-)

--
2.6.3.windows.1

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


Re: [edk2] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Clear some semaphores on S3 boot path

2016-11-30 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Wednesday, November 30, 2016 4:48 PM
To: Fan, Jeff <jeff@intel.com>; edk2-de...@ml01.01.org
Cc: Kinney, Michael D <michael.d.kin...@intel.com>; Tian, Feng 
<feng.t...@intel.com>; Yao, Jiewen <jiewen@intel.com>
Subject: Re: [edk2] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Clear some semaphores on 
S3 boot path

On 11/30/16 01:43, Fan, Jeff wrote:
> Laszlo,
> 
> Thanks your comments. I added my comments as below in [Jeff]

Thanks for your answers.

Acked-by: Laszlo Ersek <ler...@redhat.com>
Tested-by: Laszlo Ersek <ler...@redhat.com>

Cheers
Laszlo

> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Wednesday, November 30, 2016 4:49 AM
> To: Fan, Jeff; edk2-de...@ml01.01.org
> Cc: Kinney, Michael D; Yao, Jiewen; Tian, Feng
> Subject: Re: [edk2] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Clear some 
> semaphores on S3 boot path
> 
> On 11/29/16 08:51, Jeff Fan wrote:
>> Some semaphores are not cleared on S3 boot path. For example,
>> mSmmMpSyncData->CpuData[CpuIndex].Present. It may still keeps the 
>> mSmmMpSyncData->value set at
>> SMM runtime during S3 resume. It may causes BSP have the wrong 
>> judgement on SMM AP's present state.
>>
>> We have one related fix at e78a2a49ee6b0c0d7c6997c87ace31d7761cf636. 
>> But that is not completed.
>>
>> This fix is to clear Busy/Run/Present semaphores in InitializeMpSyncData().
>>
>> Cc: Laszlo Ersek <ler...@redhat.com>
>> Cc: Feng Tian <feng.t...@intel.com>
>> Cc: Jiewen Yao <jiewen@intel.com>
>> Cc: Michael D Kinney <michael.d.kin...@intel.com>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Jeff Fan <jeff@intel.com>
>> ---
>>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
>> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
>> index cfbf59e..a873b68 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
>> @@ -1357,6 +1357,9 @@ InitializeMpSyncData (
>>  (UINT32 *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Run + 
>> mSemaphoreSize * CpuIndex);
>>mSmmMpSyncData->CpuData[CpuIndex].Present =
>>  (BOOLEAN *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Present + 
>> mSemaphoreSize * CpuIndex);
>> +  *(mSmmMpSyncData->CpuData[CpuIndex].Busy)= 0;
>> +  *(mSmmMpSyncData->CpuData[CpuIndex].Run) = 0;
>> +  *(mSmmMpSyncData->CpuData[CpuIndex].Present) = FALSE;
>>  }
>>}
>>  }
>>
> 
> Even after this patch, the values pointed-to by the following fields of 
> SemaphoreGlobal are not cleared: PFLock, CodeAccessCheckLock, 
> MemoryMappedLock. Is that okay?
> 
> The values pointed-to by the following fields of SemaphoreMsr are not cleared 
> either: Msr, AvailableCounter. Is that okay?
> 
> [Jeff] We need to clear the data in 
> SMM_CPU_DATA_BLOCK/SMM_DISPATCHER_MP_SYNC_DATA and semaphores pointed by the 
> field in those 2 structures.  However, the other spinlock located in 
> SemaphoreBlock needn't to be cleared.
> 
> Can we imitate e78a2a49ee6b0c0d7c6997c87ace31d7761cf636 here; namely, 
> can we save "SemaphoreBlock" and "TotalSize" from
> InitializeSmmCpuSemaphores() in global variables (in SMRAM), and then just do 
> another ZeroMem() here? That would cover the currently listed objects 
> (*Counter, *InsideSmm, *AllCpusInSync), and everything else too, in a 
> future-proof way.
> 
> [Jeff] This issue is that ZeroMem only clear all the fields in structure and 
> needn't o clear the buffer pointed by these fields.
> 
> In fact, I wonder if the ZeroMem() could be moved into
> InitializeMpSyncData() from InitializeSmmCpuSemaphores().
> 
>  [Jeff] If we cleared all semaphores(including Spinlock), we need to 
> re-initialize them again. I do not think there is some reasonable usage case 
> to let spinlock keep the garbage value.
> 
> Of course, if some pointed-to objects must not be cleared, then the
> ZeroMem() is not appropriate.
> 
> [Jeff]  Agree.
> 
> 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


Re: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Replace deprecated debug level macros

2016-11-29 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

I will help push it into EDKII trunk.

Thanks
Feng

-Original Message-
From: Marcin Wojtas [mailto:m...@semihalf.com] 
Sent: Tuesday, November 29, 2016 9:52 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>; Gao, Liming <liming@intel.com>; 
leif.lindh...@linaro.org; ard.biesheu...@linaro.org; m...@semihalf.com; 
j...@semihalf.com
Subject: [PATCH] MdeModulePkg/SdMmcPciHcDxe: Replace deprecated debug level 
macros

From: Jan Dąbroś <j...@semihalf.com>

EFI_D_INFO, EFI_D_VERBOSE, EFI_D_WARN and EFI_D_ERROR are replaced with 
currently recommended values.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jan Dabros <j...@semihalf.com>
Signed-off-by: Marcin Wojtas <m...@semihalf.com>
---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c| 36 +-
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c  | 40 +--
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 22 +++---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c   | 78 +++---
 4 files changed, 88 insertions(+), 88 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
index 61d3517..3f73194 100755
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
@@ -533,7 +533,7 @@ EmmcTuningClkForHs200 (
   do {
 Status = EmmcSendTuningBlk (PassThru, Slot, BusWidth);
 if (EFI_ERROR (Status)) {
-  DEBUG ((EFI_D_ERROR, "EmmcTuningClkForHs200: Send tuning block fails 
with %r\n", Status));
+  DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block 
+ fails with %r\n", Status));
   return Status;
 }
 
@@ -551,7 +551,7 @@ EmmcTuningClkForHs200 (
 }
   } while (++Retry < 40);
 
-  DEBUG ((EFI_D_ERROR, "EmmcTuningClkForHs200: Send tuning block fails at %d 
times with HostCtrl2 %02x\n", Retry, HostCtrl2));
+  DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block fails 
+ at %d times with HostCtrl2 %02x\n", Retry, HostCtrl2));
   //
   // Abort the tuning procedure and reset the tuning circuit.
   //
@@ -618,20 +618,20 @@ EmmcSwitchBusWidth (
   CmdSet = 0;
   Status = EmmcSwitch (PassThru, Slot, Access, Index, Value, CmdSet);
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchBusWidth: Switch to bus width %d fails 
with %r\n", BusWidth, Status));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchBusWidth: Switch to bus width %d 
+ fails with %r\n", BusWidth, Status));
 return Status;
   }
 
   Status = EmmcSendStatus (PassThru, Slot, Rca, );
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchBusWidth: Send status fails with %r\n", 
Status));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchBusWidth: Send status fails with 
+ %r\n", Status));
 return Status;
   }
   //
   // Check the switch operation is really successful or not.
   //
   if ((DevStatus & BIT7) != 0) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchBusWidth: The switch operation fails as 
DevStatus is 0x%08x\n", DevStatus));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchBusWidth: The switch operation 
+ fails as DevStatus is 0x%08x\n", DevStatus));
 return EFI_DEVICE_ERROR;
   }
 
@@ -686,20 +686,20 @@ EmmcSwitchClockFreq (
 
   Status = EmmcSwitch (PassThru, Slot, Access, Index, Value, CmdSet);
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchClockFreq: Switch to hstiming %d fails 
with %r\n", HsTiming, Status));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: Switch to hstiming %d 
+ fails with %r\n", HsTiming, Status));
 return Status;
   }
 
   Status = EmmcSendStatus (PassThru, Slot, Rca, );
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchClockFreq: Send status fails with %r\n", 
Status));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: Send status fails with 
+ %r\n", Status));
 return Status;
   }
   //
   // Check the switch operation is really successful or not.
   //
   if ((DevStatus & BIT7) != 0) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchClockFreq: The switch operation fails as 
DevStatus is 0x%08x\n", DevStatus));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: The switch operation 
+ fails as DevStatus is 0x%08x\n", DevStatus));
 return EFI_DEVICE_ERROR;
   }
   //
@@ -995,13 +995,13 @@ EmmcSetBusMode (
 
   Status = EmmcGetCsd (PassThru, Slot, Rca, );
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSetBusMode: GetCsd fails with %r\n", Status));
+DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: GetCsd fails with %r\n", 
+ Status));
 return Status;
   }
 
   Status = EmmcSelect (PassThru, Slot, Rca);
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSet

Re: [edk2] [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci

2016-11-24 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Do you want me to push it into EDKII trunk?

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Marcin 
Wojtas
Sent: Thursday, November 24, 2016 3:55 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; ard.biesheu...@linaro.org; 
leif.lindh...@linaro.org; Gao, Liming <liming@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>
Subject: [edk2] [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is 
always set in Ahci

According to AHCI Spec 1.3 GHC.AE bit description:
"The implementation of this bit is dependent upon the value of the CAP.SAM bit. 
If CAP.SAM is '0', then GHC.AE shall be read-write and shall have a reset value 
of '0'. If CAP.SAM is '1', then AE shall be read-only and shall have a reset 
value of '1'."

Being in AhciMode, for proper operation it is required, that GHC.AE bit is 
always set, before any other AHCI registers are written to. Current AhciMode 
implementation, both in AhciReset() and AhciModeInitialization() functions, set 
GHC.AE bit only depending on 'CAP.SAM == 0' condition, assuming (according to 
the AHCI spec), that otherwise it has to be set anyway. It may however happen, 
that even if 'CAP.SAM == 1', GHC.AE requires updating by software.

This patch enables in AhciMode setting GHC.AE in case its initial value is '0'. 
It fixes AHCI support for Marvell Armada 70x0 and 80x0 SoC families. The change 
is transparent to all other platforms.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Marcin Wojtas <m...@semihalf.com>
Signed-off-by: Jan Dabros <j...@semihalf.com>

---
Changelog:
v1 -> v2

* Instead of doing it uncoditionally, enable setting GHC.AE bit only in
  case its initial value is '0'

---
 MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c 
b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
index 533d201..4d01c1d 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
@@ -1451,17 +1451,13 @@ AhciReset (
 {
   UINT64 Delay;
   UINT32 Value;
-  UINT32 Capability;
 
   //
-  // Collect AHCI controller information
-  //
-  Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
-
-  //
-  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only 
is not set
+  // Make sure that GHC.AE bit is set before accessing any AHCI registers.
   //
-  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
+  Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
+
+  if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
 AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
   }
 
@@ -2252,6 +2248,7 @@ AhciModeInitialization (
   EFI_ATA_COLLECTIVE_MODE  *SupportedModes;
   EFI_ATA_TRANSFER_MODETransferMode;
   UINT32   PhyDetectDelay;
+  UINT32   Value;
 
   if (Instance == NULL) {
 return EFI_INVALID_PARAMETER;
@@ -2270,11 +2267,13 @@ AhciModeInitialization (
   // Collect AHCI controller information
   //
   Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
-  
+
   //
-  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only 
is not set
+  // Make sure that GHC.AE bit is set before accessing any AHCI registers.
   //
-  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
+  Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
+
+  if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
 AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
   }
 
--
1.8.3.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] MdeModulePkg/AtaAtapiPassThru: Set GHC.AE bit unconditionally for Ahci

2016-11-23 Thread Tian, Feng
Marcin

I am ok with removing CAP.SAM check. But the logic will always set GHC.AE bit. 
Shall we set GHC.AE only if it's 0?

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Marcin 
Wojtas
Sent: Wednesday, November 23, 2016 10:59 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; ard.biesheu...@linaro.org; 
leif.lindh...@linaro.org; Gao, Liming <liming@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>
Subject: [edk2] [PATCH] MdeModulePkg/AtaAtapiPassThru: Set GHC.AE bit 
unconditionally for Ahci

According to AHCI Spec 1.3 GHC.AE bit description:
"The implementation of this bit is dependent upon the value of the CAP.SAM bit. 
If CAP.SAM is '0', then GHC.AE shall be read-write and shall have a reset value 
of '0'. If CAP.SAM is '1', then AE shall be read-only and shall have a reset 
value of '1'."

Being in AhciMode, for proper operation it is required, that GHC.AE bit is 
always set, before any other AHCI registers are written to. Current AhciMode 
implementation, both in AhciReset() and AhciModeInitialization() functions, set 
GHC.AE bit only depending on 'CAP.SAM == 0' condition, assuming (according to 
the AHCI spec), that otherwise it has to be set anyway. It may however happen, 
that even if 'CAP.SAM == 1', GHC.AE requires updating by software.

This patch enables setting GHC.AE bit unconditionally in AhciMode, which fixes 
AHCI support for Marvell Armada 70x0 and 80x0 SoC families. The change is 
transparent to all other platforms.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Marcin Wojtas <m...@semihalf.com>
Signed-off-by: Jan Dabros <j...@semihalf.com>
---
 MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 18 --
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c 
b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
index 533d201..6266ff3 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
@@ -1451,19 +1451,11 @@ AhciReset (
 {
   UINT64 Delay;
   UINT32 Value;
-  UINT32 Capability;
 
   //
-  // Collect AHCI controller information
-  //
-  Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
-  
+  // Enable AE before accessing any AHCI registers.
   //
-  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only 
is not set
-  //
-  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
-AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
-  }
+  AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
 
   AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_RESET);
 
@@ -2272,11 +2264,9 @@ AhciModeInitialization (
   Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
   
   //
-  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only 
is not set
+  // Enable AE before accessing any AHCI registers.
   //
-  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
-AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
-  }
+  AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
 
   //
   // Enable 64-bit DMA support in the PCI layer if this controller
--
1.8.3.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 v3 1/5] MdeModulePkg: introduce non-discoverable device protocol

2016-11-18 Thread Tian, Feng
The simplest way I can think is

+struct _NON_DISCOVERABLE_DEVICE {
+  //
+  // The type of device
+  //
+  NON_DISCOVERABLE_DEVICE_TYPEType; -> change it to UINT8 Type; //Type 
is the subtype of corresponding device, such as SATA is MSG_SATA_DP(0x12)
+  //
+  // Whether this device is DMA coherent
+  //
+  NON_DISCOVERABLE_DEVICE_DMA_TYPEDmaType;
+  //
+  // Initialization function for the device
+  //
+  NON_DISCOVERABLE_DEVICE_INITInitialize;
+  //
+  // The MMIO and I/O regions owned by the device
+  //
+  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR   *Resources;
+};

Thanks
Feng

-Original Message-
From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org] 
Sent: Friday, November 18, 2016 2:57 PM
To: Tian, Feng <feng.t...@intel.com>
Cc: Ni, Ruiyu <ruiyu...@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>; edk2-devel@lists.01.org; Gao, Liming 
<liming@intel.com>; af...@apple.com; Leif Lindholm 
<leif.lindh...@linaro.org>
Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-discoverable 
device protocol

On 18 November 2016 at 05:24, Tian, Feng <feng.t...@intel.com> wrote:
> Ard,
>
> I have another question.
>
> Is it the only way to specify device type in below enum? Looks like it will 
> be changed often. Is it possible to make use of DevicePath node? Of course, I 
> have no good idea to handle AMBA controller...
>

How would you use a device path node to do that? I think we will always need a 
mapping somewhere in the code between numbers and AHCI/EHCI/etc types, given 
that the device itself cannot be interrogated to provide this information. If 
we can do the same with a device path, I'm happy to investigate, but I will 
need some help understanding how that would work

> +//
> +// Data Types
> +//
> +typedef enum {
> +  NonDiscoverableDeviceTypeAmba,
> +  NonDiscoverableDeviceTypeOhci,
> +  NonDiscoverableDeviceTypeUhci,
> +  NonDiscoverableDeviceTypeEhci,
> +  NonDiscoverableDeviceTypeXhci,
> +  NonDiscoverableDeviceTypeAhci,
> +  NonDiscoverableDeviceTypeSdhci,
> +  NonDiscoverableDeviceTypeUfs,
> +  NonDiscoverableDeviceTypeNvme,
> +  NonDiscoverableDeviceTypeMax,
> +} NON_DISCOVERABLE_DEVICE_TYPE;
>
> Thanks
> Feng
>
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Ard Biesheuvel
> Sent: Friday, November 18, 2016 12:59 PM
> To: Ni, Ruiyu <ruiyu...@intel.com>
> Cc: Kinney, Michael D <michael.d.kin...@intel.com>; 
> edk2-devel@lists.01.org; Gao, Liming <liming@intel.com>; 
> af...@apple.com; Leif Lindholm <leif.lindh...@linaro.org>
> Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce 
> non-discoverable device protocol
>
> On 18 November 2016 at 02:11, Ni, Ruiyu <ruiyu...@intel.com> wrote:
>>
>>
>> Regards,
>> Ray
>>
>>>-Original Message-
>>>From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
>>>Sent: Thursday, November 17, 2016 6:43 PM
>>>To: Ni, Ruiyu <ruiyu...@intel.com>
>>>Cc: Kinney, Michael D <michael.d.kin...@intel.com>; 
>>>edk2-devel@lists.01.org; Gao, Liming <liming@intel.com>; 
>>>af...@apple.com; Leif Lindholm <leif.lindh...@linaro.org>
>>>Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce 
>>>non-discoverable device protocol
>>>
>>>
>>>> On 17 Nov 2016, at 08:52, Ni, Ruiyu <ruiyu...@intel.com> wrote:
>>>>
>>>>
>>>>
>>>> Thanks/Ray
>>>>
>>>>> -Original Message-
>>>>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On 
>>>>> Behalf Of Ard Biesheuvel
>>>>> Sent: Thursday, November 17, 2016 2:07 PM
>>>>> To: Ni, Ruiyu <ruiyu...@intel.com>
>>>>> Cc: Kinney, Michael D <michael.d.kin...@intel.com>; edk2- 
>>>>> de...@lists.01.org; Gao, Liming <liming@intel.com>; 
>>>>> af...@apple.com; Leif Lindholm <leif.lindh...@linaro.org>
>>>>> Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non- 
>>>>> discoverable device protocol
>>>>>
>>>>>
>>>>>
>>>>>> On 17 Nov 2016, at 02:53, Ni, Ruiyu <ruiyu...@intel.com> wrote:
>>>>>>
>>>>>> Ard,
>>>>>> I have two comments in below.
>>>>>>
>>>>>> Thanks/Ray
>>>>>>
>>>>>>> -Original Message-
>>>>>>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On 
>>>>>>> Behalf

Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-discoverable device protocol

2016-11-17 Thread Tian, Feng
Ard,

I have another question.

Is it the only way to specify device type in below enum? Looks like it will be 
changed often. Is it possible to make use of DevicePath node? Of course, I have 
no good idea to handle AMBA controller...

+//
+// Data Types
+//
+typedef enum {
+  NonDiscoverableDeviceTypeAmba,
+  NonDiscoverableDeviceTypeOhci,
+  NonDiscoverableDeviceTypeUhci,
+  NonDiscoverableDeviceTypeEhci,
+  NonDiscoverableDeviceTypeXhci,
+  NonDiscoverableDeviceTypeAhci,
+  NonDiscoverableDeviceTypeSdhci,
+  NonDiscoverableDeviceTypeUfs,
+  NonDiscoverableDeviceTypeNvme,
+  NonDiscoverableDeviceTypeMax,
+} NON_DISCOVERABLE_DEVICE_TYPE;

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ard 
Biesheuvel
Sent: Friday, November 18, 2016 12:59 PM
To: Ni, Ruiyu 
Cc: Kinney, Michael D ; edk2-devel@lists.01.org; 
Gao, Liming ; af...@apple.com; Leif Lindholm 

Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-discoverable 
device protocol

On 18 November 2016 at 02:11, Ni, Ruiyu  wrote:
>
>
> Regards,
> Ray
>
>>-Original Message-
>>From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
>>Sent: Thursday, November 17, 2016 6:43 PM
>>To: Ni, Ruiyu 
>>Cc: Kinney, Michael D ; 
>>edk2-devel@lists.01.org; Gao, Liming ; 
>>af...@apple.com; Leif Lindholm 
>>Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce 
>>non-discoverable device protocol
>>
>>
>>> On 17 Nov 2016, at 08:52, Ni, Ruiyu  wrote:
>>>
>>>
>>>
>>> Thanks/Ray
>>>
 -Original Message-
 From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf 
 Of Ard Biesheuvel
 Sent: Thursday, November 17, 2016 2:07 PM
 To: Ni, Ruiyu 
 Cc: Kinney, Michael D ; edk2- 
 de...@lists.01.org; Gao, Liming ; 
 af...@apple.com; Leif Lindholm 
 Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non- 
 discoverable device protocol



> On 17 Nov 2016, at 02:53, Ni, Ruiyu  wrote:
>
> Ard,
> I have two comments in below.
>
> Thanks/Ray
>
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On 
>> Behalf Of Leif Lindholm
>> Sent: Thursday, November 17, 2016 1:49 AM
>> To: Ard Biesheuvel 
>> Cc: Ni, Ruiyu ; edk2-devel@lists.01.org; 
>> af...@apple.com; Gao, Liming ; Kinney, 
>> Michael D 
>> Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non- 
>> discoverable device protocol
>>
>>> On Wed, Nov 16, 2016 at 04:59:27PM +, Ard Biesheuvel wrote:
>>> Introduce a protocol that can be exposed by a platform for 
>>> devices that are not discoverable, usually because they are 
>>> wired straight to the memory bus rather than to an enumerable bus like 
>>> PCI or USB.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: Ard Biesheuvel 
>>> ---
>>> MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h | 90
>> 
>>> MdeModulePkg/MdeModulePkg.dec |  3 +
>>> 2 files changed, 93 insertions(+)
>>>
>>> diff --git 
>>> a/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
>>> b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
>>> new file mode 100644
>>> index ..47ed841b407b
>>> --- /dev/null
>>> +++ b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
>>> @@ -0,0 +1,90 @@
>>> +/** @file
>>> +  Protocol to describe devices that are not on a discoverable 
>>> +bus
>>> +
>>> +  Copyright (c) 2016, 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 __NON_DISCOVERABLE_DEVICE_H__ #define 
>>> +__NON_DISCOVERABLE_DEVICE_H__
>>> +
>>> +#include 
>>> +
>>> +#define EDKII_NON_DISCOVERABLE_DEVICE_PROTOCOL_GUID \
>>> +  { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 
>>> +0x8d, 0x51, 0x4a 

Re: [edk2] [PATCH 0/6] UefiCpuPkg/MpInitLib: Program AP stack in fixed address

2016-11-16 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Fan, Jeff 
Sent: Monday, November 14, 2016 11:47 AM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Wu, Hao A <hao.a...@intel.com>; Kinney, 
Michael D <michael.d.kin...@intel.com>
Subject: [PATCH 0/6] UefiCpuPkg/MpInitLib: Program AP stack in fixed address

Currently, MpInitLib will program AP stack in dynamic address. Each processor 
will calculate its stack address by adding stack size based on the last stack 
address. That means AP may have the different stack address everytime it is 
wakeup by INIT-SIPI-SIPI.

When all APs have wakeup to execute AP task, each each has been assigned one 
stack address. Once the timeout happened on some of APs, BSP will send INIT- 
SIPI-SIPI to wake up APs. We need to re-assign stack for APs. Based on the 
current implementation, we might assign one stack address used by other APs.
It will cause the unexpected stack overlapped issue.

This fix changed the stack assignment policy. We will record the stack address 
assigned to AP at first time AP wakeup. When AP failed on AP task, BSP could 
reassigned the same stack for it.

Cc: Feng Tian <feng.t...@intel.com>
Cc: Hao Wu <hao.a...@intel.com>
Cc: Michael D Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>

Jeff Fan (6):
  UefiCpuPkg/MpInitLib: Fixed offset error on Cr3Location
  UefiCpuPkg/MpInitLib: Force sending INIT-SIPI-SIPI to reset APs
  UefiCpuPkg/MpInitLib: Remove CPU information from CPU_AP_DATA
  UefiCpuPkg/MpInitLib: Add InitFlag and CpuInfo in MP_CPU_EXCHANGE_INFO
  UefiCpuPkg/MpInitLib: Program AP stack in fixed address
  UefiCpuPkg/MpInitLib: Update AP information when BSP switched

 UefiCpuPkg/Library/MpInitLib/Ia32/MpEqu.inc|  4 +-
 UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm | 65 +++---
 UefiCpuPkg/Library/MpInitLib/MpLib.c   | 95 +++---
 UefiCpuPkg/Library/MpInitLib/MpLib.h   |  7 +-
 UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc |  4 +-
 UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm  | 68 ++
 6 files changed, 176 insertions(+), 67 deletions(-)

--
2.9.3.windows.2

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


Re: [edk2] USB hub port reset

2016-11-15 Thread Tian, Feng
I would prefer to keep the logic in UsbHubResetPort() unchanged to avoid bring 
other device identification impacts.

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Anbazhagan, Baraneedharan
Sent: Wednesday, November 16, 2016 7:56 AM
To: Tian, Feng <feng.t...@intel.com>; edk2-devel@lists.01.org
Subject: Re: [edk2] USB hub port reset

Feng,
Below change solves the problem with a device behind the hub. Do we still need 
the 10ms delay in UsbHubResetPort function for manual port reset in case of 
XHCI?

Thanks,
Baranee

-Original Message-
From: Tian, Feng [mailto:feng.t...@intel.com]
Sent: Monday, November 14, 2016 10:28 PM
To: Anbazhagan, Baraneedharan <anbazha...@hp.com>; edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: RE: USB hub port reset

Baranee

Supposing are using latest usb code in EdkII trunk.

We send ADDRESS DEVICE CMD in XhcInitializeDeviceSlot(), which will cause XHC 
issue a USB SET_ADDRESS request to the USB Device.

There are two possible paths:
1. Reset_Change bit gets set after connection without manually port reset.
UsbHubGetPortStatus()->XhcPollPortStatusChange()->(if RESET_C bit is 
set)->XhcInitializeDeviceSlot() 2. Reset_Change bit gets set after manually 
Reset Port operation.
UsbHubResetPort()->UsbHubSetPortFeature()->Stall(20)-> 
UsbHubGetPortStatus()->(invoke above code in XHCI)->(if RESET_C bit is 
set)->Stall(10)

According to your info, it looks like we need add 10ms delay to 
XhcInitializeDeviceSlot() like below:

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c 
b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
index e37f674..bb68f34 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
@@ -2115,6 +2115,7 @@ XhcInitializeDeviceSlot (
   // 8) Issue an Address Device Command for the Device Slot, where the command 
points to the Input
   //Context data structure described above.
   //
+  gBS->Stall (10 * 1000);
   ZeroMem (, sizeof (CmdTrbAddr));
   PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, 
Xhc->UsbDevContext[SlotId].InputContext, sizeof (INPUT_CONTEXT));
   CmdTrbAddr.PtrLo= XHC_LOW_32BIT (PhyAddr);
@@ -2321,6 +2322,7 @@ XhcInitializeDeviceSlot64 (
   // 8) Issue an Address Device Command for the Device Slot, where the command 
points to the Input
   //Context data structure described above.
   //
+  gBS->Stall (10 * 1000);
   ZeroMem (, sizeof (CmdTrbAddr));
   PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, 
Xhc->UsbDevContext[SlotId].InputContext, sizeof (INPUT_CONTEXT_64));
   CmdTrbAddr.PtrLo= XHC_LOW_32BIT (PhyAddr);

Could you please have a try to see if it solves your problem?

Thanks
Feng

-Original Message-
From: Anbazhagan, Baraneedharan [mailto:anbazha...@hp.com]
Sent: Monday, November 14, 2016 9:46 PM
To: Tian, Feng <feng.t...@intel.com>; edk2-devel@lists.01.org
Subject: RE: USB hub port reset

In case of XHCI, TRB_TYPE_ADDRESS_DEV/SetAddress occurs within 
XhcPollPortStatusChange. Seem we don't have 10ms/TRSTRCY for the devices behind 
hub connected to XHCI or am missing something here?

In EDK2, 10ms(TRSTRCY) delay occurs before clear port status and in case of 
Linux TRSTRCY delay is after clearing port status.

Thanks
Baranee


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Tian, Feng
> Sent: Sunday, November 13, 2016 10:38 PM
> To: Anbazhagan, Baraneedharan <anbazha...@hp.com>; edk2- 
> de...@lists.01.org
> Cc: Tian, Feng <feng.t...@intel.com>
> Subject: Re: [edk2] USB hub port reset
> 
> I don't catch what you mean. We have had 10ms delay for port reset. 
> Which line of UsbHub.c do you think there is problem?
> 
> Quote from USB2.0 spec:
> "Hubs must be able to accept all hub requests and devices must be able 
> to accept a
> SetAddress() request (refer to Section 11.24.2 and Section 9.4
> respectively) after the reset recovery time 10 ms (TRSTRCY) after the reset 
> is removed."
> 
> Thanks
> Feng
> 
> -Original Message-
> From: Anbazhagan, Baraneedharan [mailto:anbazha...@hp.com]
> Sent: Monday, November 14, 2016 11:33 AM
> To: Tian, Feng <feng.t...@intel.com>; edk2-devel@lists.01.org
> Subject: RE: USB hub port reset
> 
> I didn't mean to have extra delays. Am asking whether EDKII have to be 
> updated for 10ms reset recovery time regardless of port status to align with 
> spec?
> 
> 
> >From: Tian, Feng [mailto:feng.t...@intel.com]
> >Sent: Sunday, November 13, 2016 7:46 PM
> >To: Anbazhagan, Baraneedharan <anbazha...@hp.com>; 
> >edk2-devel@lists.01.org
> >Cc: Tian, Feng <feng.t...@intel.com>
> >Subject: RE: USB hub port reset
> >
> >Hi, Baranee
> >

Re: [edk2] [PATCH] UefiCpuPkg/SecCore: Use %x to print stack information

2016-11-15 Thread Tian, Feng
Reviewed-by: Feng Tian <feng.t...@intel.com>

Thanks
Feng

-Original Message-
From: Fan, Jeff 
Sent: Tuesday, November 15, 2016 4:32 PM
To: edk2-de...@ml01.01.org
Cc: Tian, Feng <feng.t...@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>
Subject: [PATCH] UefiCpuPkg/SecCore: Use %x to print stack information

SecCoreData->StackBase is VOID * type and SecCoreData->StackSize is UINTN type.
We should use %x to dump their value instead of %lx.

Cast pointer type to UINTN before print it.

Cc: Feng Tian <feng.t...@intel.com>
Cc: Michael D Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff@intel.com>
---
 UefiCpuPkg/SecCore/SecMain.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/SecCore/SecMain.c b/UefiCpuPkg/SecCore/SecMain.c index 
2ebbc22..4d08f48 100644
--- a/UefiCpuPkg/SecCore/SecMain.c
+++ b/UefiCpuPkg/SecCore/SecMain.c
@@ -239,9 +239,9 @@ SecStartupPhase2(
 
   DEBUG ((
 DEBUG_INFO,
-"%a() Stack Base: 0x%lx, Stack Size: 0x%lx\n",
+"%a() Stack Base: 0x%x, Stack Size: 0x%x\n",
 __FUNCTION__,
-SecCoreData->StackBase,
+(UINTN) SecCoreData->StackBase,
 SecCoreData->StackSize
 ));
 
--
2.9.3.windows.2

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


Re: [edk2] USB hub port reset

2016-11-14 Thread Tian, Feng
Baranee

Supposing are using latest usb code in EdkII trunk.

We send ADDRESS DEVICE CMD in XhcInitializeDeviceSlot(), which will cause XHC 
issue a USB SET_ADDRESS request to the USB Device.

There are two possible paths:
1. Reset_Change bit gets set after connection without manually port reset.
UsbHubGetPortStatus()->XhcPollPortStatusChange()->(if RESET_C bit is 
set)->XhcInitializeDeviceSlot()
2. Reset_Change bit gets set after manually Reset Port operation.
UsbHubResetPort()->UsbHubSetPortFeature()->Stall(20)-> 
UsbHubGetPortStatus()->(invoke above code in XHCI)->(if RESET_C bit is 
set)->Stall(10)

According to your info, it looks like we need add 10ms delay to 
XhcInitializeDeviceSlot() like below:

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c 
b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
index e37f674..bb68f34 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
@@ -2115,6 +2115,7 @@ XhcInitializeDeviceSlot (
   // 8) Issue an Address Device Command for the Device Slot, where the command 
points to the Input
   //Context data structure described above.
   //
+  gBS->Stall (10 * 1000);
   ZeroMem (, sizeof (CmdTrbAddr));
   PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, 
Xhc->UsbDevContext[SlotId].InputContext, sizeof (INPUT_CONTEXT));
   CmdTrbAddr.PtrLo= XHC_LOW_32BIT (PhyAddr);
@@ -2321,6 +2322,7 @@ XhcInitializeDeviceSlot64 (
   // 8) Issue an Address Device Command for the Device Slot, where the command 
points to the Input
   //Context data structure described above.
   //
+  gBS->Stall (10 * 1000);
   ZeroMem (, sizeof (CmdTrbAddr));
   PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, 
Xhc->UsbDevContext[SlotId].InputContext, sizeof (INPUT_CONTEXT_64));
   CmdTrbAddr.PtrLo= XHC_LOW_32BIT (PhyAddr);

Could you please have a try to see if it solves your problem?

Thanks
Feng

-Original Message-
From: Anbazhagan, Baraneedharan [mailto:anbazha...@hp.com] 
Sent: Monday, November 14, 2016 9:46 PM
To: Tian, Feng <feng.t...@intel.com>; edk2-devel@lists.01.org
Subject: RE: USB hub port reset

In case of XHCI, TRB_TYPE_ADDRESS_DEV/SetAddress occurs within 
XhcPollPortStatusChange. Seem we don't have 10ms/TRSTRCY for the devices behind 
hub connected to XHCI or am missing something here?

In EDK2, 10ms(TRSTRCY) delay occurs before clear port status and in case of 
Linux TRSTRCY delay is after clearing port status.

Thanks
Baranee


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Tian, Feng
> Sent: Sunday, November 13, 2016 10:38 PM
> To: Anbazhagan, Baraneedharan <anbazha...@hp.com>; edk2- 
> de...@lists.01.org
> Cc: Tian, Feng <feng.t...@intel.com>
> Subject: Re: [edk2] USB hub port reset
> 
> I don't catch what you mean. We have had 10ms delay for port reset. 
> Which line of UsbHub.c do you think there is problem?
> 
> Quote from USB2.0 spec:
> "Hubs must be able to accept all hub requests and devices must be able 
> to accept a
> SetAddress() request (refer to Section 11.24.2 and Section 9.4 
> respectively) after the reset recovery time 10 ms (TRSTRCY) after the reset 
> is removed."
> 
> Thanks
> Feng
> 
> -Original Message-
> From: Anbazhagan, Baraneedharan [mailto:anbazha...@hp.com]
> Sent: Monday, November 14, 2016 11:33 AM
> To: Tian, Feng <feng.t...@intel.com>; edk2-devel@lists.01.org
> Subject: RE: USB hub port reset
> 
> I didn't mean to have extra delays. Am asking whether EDKII have to be 
> updated for 10ms reset recovery time regardless of port status to align with 
> spec?
> 
> 
> >From: Tian, Feng [mailto:feng.t...@intel.com]
> >Sent: Sunday, November 13, 2016 7:46 PM
> >To: Anbazhagan, Baraneedharan <anbazha...@hp.com>; 
> >edk2-devel@lists.01.org
> >Cc: Tian, Feng <feng.t...@intel.com>
> >Subject: RE: USB hub port reset
> >
> >Hi, Baranee
> >
> >Linux wait 10 + 40 ms (TRSTRCY = 10 ms, plus extra 40 ms). Do you 
> >mean EDKII
> should be same with linux to wait more time?
> >
> >Thanks
> >Feng
> >
> >From: Anbazhagan, Baraneedharan [mailto:anbazha...@hp.com]
> >Sent: Sunday, November 13, 2016 11:53 AM
> >To: mailto:edk2-devel@lists.01.org; Tian, Feng 
> ><mailto:feng.t...@intel.com>
> >Subject: USB hub port reset
> >
> >EDK2 have reset recovery time of 10ms for hub port based on port 
> >status reset bit
> but USB spec doesn't mention that port status can be used for t6/reset 
> recovery time. Could you please clarify?
> >
> >USB vendor mentions EDK2 doesn't have reset recovery time on hub port 
> >reset and also highlighting EDK2 hub port reset differs from
> >https://g

Re: [edk2] USB hub port reset

2016-11-13 Thread Tian, Feng
I don't catch what you mean. We have had 10ms delay for port reset. Which line 
of UsbHub.c do you think there is problem? 

Quote from USB2.0 spec:
"Hubs must be able to accept all hub requests and devices must be able to 
accept a SetAddress() request (refer to
Section 11.24.2 and Section 9.4 respectively) after the reset recovery time 10 
ms (TRSTRCY) after the reset is
removed."

Thanks
Feng

-Original Message-
From: Anbazhagan, Baraneedharan [mailto:anbazha...@hp.com] 
Sent: Monday, November 14, 2016 11:33 AM
To: Tian, Feng <feng.t...@intel.com>; edk2-devel@lists.01.org
Subject: RE: USB hub port reset

I didn't mean to have extra delays. Am asking whether EDKII have to be updated 
for 10ms reset recovery time regardless of port status to align with spec?


>From: Tian, Feng [mailto:feng.t...@intel.com] 
>Sent: Sunday, November 13, 2016 7:46 PM
>To: Anbazhagan, Baraneedharan <anbazha...@hp.com>; edk2-devel@lists.01.org
>Cc: Tian, Feng <feng.t...@intel.com>
>Subject: RE: USB hub port reset
>
>Hi, Baranee
>
>Linux wait 10 + 40 ms (TRSTRCY = 10 ms, plus extra 40 ms). Do you mean EDKII 
>should be same with linux to wait more time?
>
>Thanks
>Feng
>
>From: Anbazhagan, Baraneedharan [mailto:anbazha...@hp.com] 
>Sent: Sunday, November 13, 2016 11:53 AM
>To: mailto:edk2-devel@lists.01.org; Tian, Feng <mailto:feng.t...@intel.com>
>Subject: USB hub port reset
>
>EDK2 have reset recovery time of 10ms for hub port based on port status reset 
>bit but USB spec doesn't mention that port status can be used for t6/reset 
>recovery time. Could you please clarify?
>
>USB vendor mentions EDK2 doesn't have reset recovery time on hub port reset 
>and also highlighting EDK2 hub port reset differs from 
>https://github.com/torvalds/linux/blob/master/drivers/usb/core/hub.c#L2789
>
>-Baranee
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] USB hub port reset

2016-11-13 Thread Tian, Feng
Hi, Baranee

Linux wait 10 + 40 ms (TRSTRCY = 10 ms, plus extra 40 ms). Do you mean EDKII 
should be same with linux to wait more time?

Thanks
Feng

From: Anbazhagan, Baraneedharan [mailto:anbazha...@hp.com]
Sent: Sunday, November 13, 2016 11:53 AM
To: edk2-devel@lists.01.org; Tian, Feng <feng.t...@intel.com>
Subject: USB hub port reset

EDK2 have reset recovery time of 10ms for hub port based on port status reset 
bit but USB spec doesn't mention that port status can be used for t6/reset 
recovery time. Could you please clarify?

USB vendor mentions EDK2 doesn't have reset recovery time on hub port reset and 
also highlighting EDK2 hub port reset differs from 
https://github.com/torvalds/linux/blob/master/drivers/usb/core/hub.c#L2789

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


  1   2   3   4   >