Re: [edk2-devel] [PATCH] MdeModulePkg/XhciDxe: Add a parameter to indicate whether the memory allocation is for TRB Ring or not.

2022-10-19 Thread Wu, Hao A
Merged via:
PR - https://github.com/tianocore/edk2/pull/3504
Commit - 
https://github.com/tianocore/edk2/commit/c6720db5ddffec747bb0b2830e528511b1a4bfb2

Best Regards,
Hao Wu

From: Wu, Hao A
Sent: Tuesday, October 18, 2022 1:42 PM
To: devel@edk2.groups.io; jdzh...@kunluntech.com.cn
Subject: RE: [edk2-devel] [PATCH] MdeModulePkg/XhciDxe: Add a parameter to 
indicate whether the memory allocation is for TRB Ring or not.

Thanks.
Will rename the commit title to “MdeModulePkg/XhciDxe: Add boundary check for 
TRB ring allocation” to pass the CI test.

Reviewed-by: Hao A Wu mailto:hao.a...@intel.com>>
Will wait a couple of days before merging to see if comments from other 
reviewers.

Best Regards,
Hao Wu

From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of Jiading Zhang
Sent: Tuesday, October 18, 2022 11:07 AM
To: Jiading Zhang 
mailto:jdzh...@kunluntech.com.cn>>; 
devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/XhciDxe: Add a parameter to 
indicate whether the memory allocation is for TRB Ring or not.

Hi,
   I renamed the parameter from ‘AllocationForTrbRing’ to ‘AllocationForRing’ 
in UsbHcAllocMemFromBlock, which matchs the description comment. And the 
attachment is the updated patch file.


According the Xhci Spec, TRB Rings may be larger than a Page, however they 
shall not cross a 64K byte boundary, so add a parameter to indicate whether the 
memory allocation is for TRB Rings or not. It will ensure the allocation not 
crossing 64K boundary in UsbHcAllocMemFromBlock if the memory is allocated for 
TRB Rings.

Signed-off-by: jdzhang 
mailto:jdzh...@kunluntech.com.cn>>
---
 MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c  | 37 +++-
 MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.h  | 10 +--
 MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 16 +-
 3 files changed, 44 insertions(+), 19 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c 
b/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c
index 99fb3521d5..4373b2c99e 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c
@@ -132,8 +132,9 @@ UsbHcFreeMemBlock (
 /**
   Alloc some memory from the block.

-  @param  Block  The memory block to allocate memory from.
-  @param  Units  Number of memory units to allocate.
+  @param  BlockThe memory block to allocate memory from.
+  @param  UnitsNumber of memory units to allocate.
+  @param  AllocationForRingThe allocated memory is for Ring or not.

   @return The pointer to the allocated memory. If couldn't allocate the needed 
memory,
   the return value is NULL.
@@ -142,7 +143,8 @@ UsbHcFreeMemBlock (
 VOID *
 UsbHcAllocMemFromBlock (
   IN  USBHC_MEM_BLOCK  *Block,
-  IN  UINTNUnits
+  IN  UINTNUnits,
+  IN  BOOLEAN  AllocationForRing
   )
 {
   UINTN  Byte;
@@ -151,12 +153,15 @@ UsbHcAllocMemFromBlock (
   UINT8  StartBit;
   UINTN  Available;
   UINTN  Count;
+  UINTN  MemUnitAddr;
+  UINTN  AlignmentMask;

   ASSERT ((Block != 0) && (Units != 0));

   StartByte = 0;
   StartBit  = 0;
   Available = 0;
+  AlignmentMask = ~((UINTN)USBHC_MEM_TRB_RINGS_BOUNDARY - 1);

   for (Byte = 0, Bit = 0; Byte < Block->BitsLen;) {
 //
@@ -165,6 +170,20 @@ UsbHcAllocMemFromBlock (
 // Available counts the consective number of zero bit.
 //
 if (!USB_HC_BIT_IS_SET (Block->Bits[Byte], Bit)) {
+  if (AllocationForRing && (Available != 0)) {
+MemUnitAddr = (UINTN)Block->BufHost + (Byte * 8 + Bit) * 
USBHC_MEM_UNIT;
+if ((MemUnitAddr & AlignmentMask) != ((MemUnitAddr - USBHC_MEM_UNIT) & 
AlignmentMask)) {
+  //
+  // If the TRB Ring memory cross 64K-byte boundary, then restart the
+  // search starting at current memory unit.
+  // Doing so is to meet the TRB Ring boundary requirement in XHCI 
spec.
+  //
+  Available = 0;
+  StartByte = Byte;
+  StartBit  = Bit;
+}
+  }
+
   Available++;

   if (Available >= Units) {
@@ -438,8 +457,9 @@ UsbHcFreeMemPool (
   Allocate some memory from the host controller's memory pool
   which can be used to communicate with host controller.

-  @param  Pool   The host controller's memory pool.
-  @param  Size   Size of the memory to allocate.
+  @param  Pool The host controller's memory pool.
+  @param  Size Size of the memory to allocate.
+  @param  AllocationForRingThe allocated memory is for Ring or not.

   @return The allocated memory or NULL.

@@ -447,7 +467,8 @@ UsbHcFreeMemPool (
 VOID *
 UsbHcAllocateMem (
   IN  USBHC_MEM_POOL  *Pool,
-  IN  UINTN   Size
+  IN  UINTN   Size,
+  IN  BOOLEAN AllocationForRing
   )
 {
   USBHC_MEM_BLOCK  *Head;
@@ -466,7 +487,7 @@ UsbHcAllocateMem (
   // First check whether current memory blocks can satisfy the 

[edk2-devel] [PATCH v2] edk2Platforms-Silicon:Add VAB FIT record types support in FitGen.c

2022-10-19 Thread Hv, Pavamana
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4086

This commit adds support for new FIT record type for
Vendor Authorized Boot (VAB) security technology(FIT spec revision 1.4).
VAB defines 3 new following types
Vendor Authorized Boot Provisioning Table (Type 0x1A)
Vendor Authorized Boot Image Manifest (Type 0x1B)
Vendor Authorized Boot Key Manifest (Type 0x1C)
The code has been updated to align these binaries on 64 byte boundary
and not to overlap with other regions, similar to Key manifest,
Boot Policy manifest and other optional types.

Also added macros to define FIT spec Major and Minor version numbers and
print the same instead of hardcoded string.

Signed-off-by: Pavamana Holavanahalli 
---
 Silicon/Intel/Tools/FitGen/FitGen.c | 61 +++--
 Silicon/Intel/Tools/FitGen/FitGen.h |  5 ++-
 2 files changed, 44 insertions(+), 22 deletions(-)

diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c 
b/Silicon/Intel/Tools/FitGen/FitGen.c
index 21dfcf1ebb..87123f9922 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.c
+++ b/Silicon/Intel/Tools/FitGen/FitGen.c
@@ -234,20 +234,24 @@ typedef struct {
 #define FLASH_TO_MEMORY(Address, FvBuffer, FvSize)  \
  (VOID *)(UINTN)((UINTN)(FvBuffer) + (UINTN)(FvSize) - 
(TOP_FLASH_ADDRESS - (UINTN)(Address)))
 
-#define FIT_TABLE_TYPE_HEADER 0
-#define FIT_TABLE_TYPE_MICROCODE  1
-#define FIT_TABLE_TYPE_STARTUP_ACM2
-#define FIT_TABLE_TYPE_DIAGNST_ACM3
-#define FIT_TABLE_TYPE_BIOS_MODULE7
-#define FIT_TABLE_TYPE_TPM_POLICY 8
-#define FIT_TABLE_TYPE_BIOS_POLICY9
-#define FIT_TABLE_TYPE_TXT_POLICY 10
-#define FIT_TABLE_TYPE_KEY_MANIFEST   11
-#define FIT_TABLE_TYPE_BOOT_POLICY_MANIFEST   12
-#define FIT_TABLE_TYPE_BIOS_DATA_AREA 13
-#define FIT_TABLE_TYPE_CSE_SECURE_BOOT16
-#define FIT_TABLE_SUBTYPE_FIT_PATCH_MANIFEST  12
-#define FIT_TABLE_SUBTYPE_ACM_MANIFEST13
+#define FIT_TABLE_TYPE_HEADER  0
+#define FIT_TABLE_TYPE_MICROCODE   1
+#define FIT_TABLE_TYPE_STARTUP_ACM 2
+#define FIT_TABLE_TYPE_DIAGNST_ACM 3
+#define FIT_TABLE_TYPE_BIOS_MODULE 7
+#define FIT_TABLE_TYPE_TPM_POLICY  8
+#define FIT_TABLE_TYPE_BIOS_POLICY 9
+#define FIT_TABLE_TYPE_TXT_POLICY  10
+#define FIT_TABLE_TYPE_KEY_MANIFEST11
+#define FIT_TABLE_TYPE_BOOT_POLICY_MANIFEST12
+#define FIT_TABLE_TYPE_BIOS_DATA_AREA  13
+#define FIT_TABLE_TYPE_CSE_SECURE_BOOT 16
+#define FIT_TABLE_SUBTYPE_FIT_PATCH_MANIFEST   12
+#define FIT_TABLE_SUBTYPE_ACM_MANIFEST 13
+#define FIT_TABLE_TYPE_VAB_PROVISION_TABLE 26
+#define FIT_TABLE_TYPE_VAB_BOOT_IMAGE_MANIFEST 27
+#define FIT_TABLE_TYPE_VAB_BOOT_KEY_MANIFEST   28
+
 
 //
 // With OptionalModule Address isn't known until free space has been
@@ -322,8 +326,10 @@ Returns:
 --*/
 {
   printf (
-"%s - Tiano IA32/X64 FIT table generation Utility for FIT spec revision 
1.2."" Version %i.%i\n\n",
+"%s - Tiano IA32/X64 FIT table generation Utility for FIT spec revision 
%i.%i."" Version %i.%i\n\n",
 UTILITY_NAME,
+FIT_SPEC_VERSION_MAJOR,
+FIT_SPEC_VERSION_MINOR,
 UTILITY_MAJOR_VERSION,
 UTILITY_MINOR_VERSION
 );
@@ -1956,7 +1962,10 @@ Returns:
 (gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_KEY_MANIFEST) ||
 (gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_BOOT_POLICY_MANIFEST) ||
 (gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_BIOS_DATA_AREA) ||
-(gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_CSE_SECURE_BOOT)) {
+(gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_CSE_SECURE_BOOT) ||
+(gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_VAB_PROVISION_TABLE) ||
+(gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_VAB_BOOT_IMAGE_MANIFEST) ||
+(gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_VAB_BOOT_KEY_MANIFEST)) {
   // NOTE: It might be virtual address now. Just put a place holder.
   FitEntryNumber ++;
 }
@@ -2154,8 +2163,11 @@ Returns:
   (gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_KEY_MANIFEST) ||
   (gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_BOOT_POLICY_MANIFEST) ||
   (gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_BIOS_DATA_AREA) ||
-  (gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_CSE_SECURE_BOOT)) {
-// Let it 64 byte align
+  (gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_CSE_SECURE_BOOT) ||
+  (gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_VAB_PROVISION_TABLE) ||
+  

Re: [edk2-devel] Python368.efi failed to run in shell environment

2022-10-19 Thread Jayaprakash, N
That's perfect. Great to know that you were able to build and run it 
successfully.

Please let's know if you are interested in contributing to any of the open bugs 
as given below:

3781
EDK2
Code
unassig...@tianocore.org
UNCO
---
edk2-libc: Enhance Py3 UEFI interpreter with the ARM architecture 
support
2022-01-04
3782
EDK2
Code
unassig...@tianocore.org
UNCO
---
edk2-libc: Enhance Py3 UEFI interpreter with the AARCH 64 architecture 
support
2022-01-04
3783
EDK2
Code
unassig...@tianocore.org
UNCO
---
edk2-libc: Enhance Py3 UEFI interpreter with the RISC V 64 architecture 
support
2022-02-22
3784
EDK2
Code
n.jayaprak...@intel.com
CONF
---
edk2-libc : Upstreaming UEFI changes to Python 
project
2022-01-04
3785
Tianocor
Code
n.jayaprak...@intel.com
CONF
---
edk2-libc : Py3 UEFI port add pip install 
support
2022-02-15
3786
EDK2
Code
n.jayaprak...@intel.com
CONF
---
edk2-libc : Enhance Py3 UEFI port to provide access to System Firmware Tables 
from Python scripts


Regards,
JP

From: Yoshinoya 
Sent: 20 October 2022 08:36
To: Jayaprakash, N 
Cc: Kinney, Michael D ; devel@edk2.groups.io
Subject: Re:RE: Re:RE: Re:RE: [edk2-devel] Python368.efi failed to run in shell 
environment

Hi, JP:
Thanks a lot!
It works.

And using create_python368_pkg.sh to create U disk image, and it runs ok in 
shell.




best wishes,







At 2022-10-19 21:16:47, "Jayaprakash, N" 
mailto:n.jayaprak...@intel.com>> wrote:
You may follow instructions provided in 
https://github.com/tianocore/edk2-libc/blob/master/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst

Regards,
JP

From: Yoshinoya mailto:yoshinoyat...@163.com>>
Sent: 19 October 2022 14:01
To: Jayaprakash, N mailto:n.jayaprak...@intel.com>>
Cc: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; 
devel@edk2.groups.io
Subject: Re:RE: Re:RE: [edk2-devel] Python368.efi failed to run in shell 
environment

Hi, JP:
I followed Py368ReadMe.txt to compile Python368 app in Ubuntu 22.04 environment.
The steps is:
1. execute srcprep.py
2. add this module to AppPkg/AppPkg.dsc
3. execute "build -a X64 -p AppPkg\AppPkg.dsc"

but it failed, the tips is:
In file included from 
/home/yoshi/edk2/AppPkg/Applications/Python/Python-3.6.8/Modules/_bisectmodule.c:7:
/home/yoshi/edk2/AppPkg/Applications/Python/Python-3.6.8/Include/Python.h:44:10:
 fatal error: crypt.h: No such file or directory
   44 | #include 
  |  ^
compilation terminated.




Thanks







At 2022-10-18 17:04:42, "Jayaprakash, N" 
mailto:n.jayaprak...@intel.com>> wrote:
Hi Yoshinoya,

Could you provide some details about the platform on which you are trying to 
run?
What tools you used for building the Python interpreter?

If you could raise a bug with relevant details, we can take a look at this 
issue.

Regards,
JP

From: Yoshinoya mailto:yoshinoyat...@163.com>>
Sent: 11 October 2022 15:51
To: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Cc: devel@edk2.groups.io; Jayaprakash, N 
mailto:n.jayaprak...@intel.com>>
Subject: Re:RE: [edk2-devel] Python368.efi failed to run in shell environment

Hi, JP:
It seems PyImport_ImportModule("encoding.utf_8") failed.
Do you have any suggestions?

THank you very much!



best wishes,







At 2022-10-06 00:28:46, "Kinney, Michael D" 
mailto:michael.d.kin...@intel.com>> wrote:
+JP

Mike

From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of Yoshinoya
Sent: Wednesday, October 5, 2022 4:32 AM
To: devel@edk2.groups.io
Subject: [edk2-devel] Python368.efi failed to run in shell environment

Hi
I tried to run Python368.efi in shell environment.
but failed, the tips was;
Fatal Python error: Py_Initialize: can't initialize sys standard streams

Does anybody have ever met this error?

Python368.efi is a sample python app in AppPkg\Applications\Python\Python-3.6.8

Thanks



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95415): https://edk2.groups.io/g/devel/message/95415
Mute This Topic: https://groups.io/mt/94136700/21656
Group Owner: 

[edk2-devel] [PATCH] UefiCpuPkg: Restore HpetTimer after CpuExceptionHandlerLib test

2022-10-19 Thread duntan
Disable/Restore HpetTimer before and after running the Dxe
CpuExceptionHandlerLib unit test module. During the UnitTest, a
new Idt is initialized for the test. There is no handler for timer
intrrupt in this new idt. After the test module, HpetTimer does
not work any more since the comparator value register and main
counter value register for timer does not match. To fix this issue,
disable/restore HpetTimer before and after Unit Test if HpetTimer
driver has been dispatched. Besides, send Apic EOI before restore
HpetTimer.

Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
---
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerLibUnitTest.inf
 |  2 ++
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerUnitTest.c
  | 33 -
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerLibUnitTest.inf
 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerLibUnitTest.inf
index e3dbe7b9ab..24f905936c 100644
--- 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerLibUnitTest.inf
+++ 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerLibUnitTest.inf
@@ -43,6 +43,7 @@
   HobLib
   UefiBootServicesTableLib
   CpuPageTableLib
+  LocalApicLib
 
 [Guids]
   gEfiHobMemoryAllocStackGuid
@@ -53,6 +54,7 @@
 
 [Protocols]
   gEfiMpServiceProtocolGuid
+  gEfiTimerArchProtocolGuid
 
 [Depex]
   gEfiMpServiceProtocolGuid
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerUnitTest.c
 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerUnitTest.c
index 917fc549bf..045f39fa00 100644
--- 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerUnitTest.c
+++ 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerUnitTest.c
@@ -8,6 +8,8 @@
 
 #include "CpuExceptionHandlerTest.h"
 #include 
+#include 
+#include 
 
 /**
   Initialize Bsp Idt with a new Idt table and return the IA32_DESCRIPTOR 
buffer.
@@ -162,8 +164,12 @@ CpuExceptionHandlerTestEntry (
 {
   EFI_STATUS  Status;
   UNIT_TEST_FRAMEWORK_HANDLE  Framework;
+  EFI_TIMER_ARCH_PROTOCOL *TimerArchProtocol;
+  UINT64  TimerPeriod;
 
-  Framework = NULL;
+  Framework = NULL;
+  TimerArchProtocol = NULL;
+  TimerPeriod   = 0;
 
   DEBUG ((DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION));
 
@@ -182,11 +188,36 @@ CpuExceptionHandlerTestEntry (
 goto EXIT;
   }
 
+  //
+  // If HpetTimer driver has been dispatched, disable HpetTimer before Unit 
Test.
+  //
+  gBS->LocateProtocol (, NULL, (VOID 
**));
+  if (TimerArchProtocol != NULL) {
+Status = TimerArchProtocol->GetTimerPeriod (TimerArchProtocol, 
);
+ASSERT_EFI_ERROR (Status);
+if (TimerPeriod > 0) {
+  DEBUG ((DEBUG_INFO, "HpetTimer has been dispatched. Disable 
HpetTimer.\n"));
+  Status = TimerArchProtocol->SetTimerPeriod (TimerArchProtocol, 0);
+  ASSERT_EFI_ERROR (Status);
+}
+  }
+
   //
   // Execute the tests.
   //
   Status = RunAllTestSuites (Framework);
 
+  //
+  // Restore HpetTimer after Unit Test.
+  // Send APIC EOI before SetTimerPeriod.
+  //
+  if ((TimerArchProtocol != NULL) && (TimerPeriod > 0)) {
+DEBUG ((DEBUG_INFO, "Restore HpetTimer after DxeCpuExceptionHandlerLib 
UnitTest.\n"));
+SendApicEoi ();
+Status = TimerArchProtocol->SetTimerPeriod (TimerArchProtocol, 
TimerPeriod);
+ASSERT_EFI_ERROR (Status);
+  }
+
 EXIT:
   if (Framework) {
 FreeUnitTestFramework (Framework);
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95414): https://edk2.groups.io/g/devel/message/95414
Mute This Topic: https://groups.io/mt/94446624/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

2022-10-19 Thread Nickle Wang via groups.io
This library follows Redfish Host Interface specification and use IPMI
command to get bootstrap account credential(NetFn 2Ch, Command 02h) from
BMC. RedfishHostInterfaceDxe will use this credential for the following
communication between BIOS and BMC.

Cc: Abner Chang 
Cc: Nick Ramirez 
Signed-off-by: Nickle Wang 
---
 .../RedfishPlatformCredentialLib.c| 273 ++
 .../RedfishPlatformCredentialLib.h|  75 +
 .../RedfishPlatformCredentialLib.inf  |  37 +++
 3 files changed, 385 insertions(+)
 create mode 100644 
RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.c
 create mode 100644 
RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.h
 create mode 100644 
RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.inf

diff --git 
a/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.c
 
b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.c
new file mode 100644
index 00..23a15ab1fa
--- /dev/null
+++ 
b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.c
@@ -0,0 +1,273 @@
+/** @file
+*
+*  Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+*
+*  SPDX-License-Identifier: BSD-2-Clause-Patent
+*
+**/
+
+#include "RedfishPlatformCredentialLib.h"
+
+//
+// Global flag of controlling credential service
+//
+BOOLEAN  mRedfishServiceStopped = FALSE;
+
+/**
+  Notify the Redfish service provide to stop provide configuration service to 
this platform.
+
+  This function should be called when the platfrom is about to leave the safe 
environment.
+  It will notify the Redfish service provider to abort all logined session, 
and prohibit
+  further login with original auth info. GetAuthInfo() will return 
EFI_UNSUPPORTED once this
+  function is returned.
+
+  @param[in]   ThisPointer to 
EDKII_REDFISH_CREDENTIAL_PROTOCOL instance.
+  @param[in]   ServiceStopType Reason of stopping Redfish service.
+
+  @retval EFI_SUCCESS  Service has been stoped successfully.
+  @retval EFI_INVALID_PARAMETERThis is NULL.
+  @retval Others   Some error happened.
+
+**/
+EFI_STATUS
+EFIAPI
+LibStopRedfishService (
+  IN EDKII_REDFISH_CREDENTIAL_PROTOCOL   *This,
+  IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE  ServiceStopType
+  )
+{
+  EFI_STATUS  Status;
+
+  if ((ServiceStopType <= ServiceStopTypeNone) || (ServiceStopType >= 
ServiceStopTypeMax)) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // Raise flag first
+  //
+  mRedfishServiceStopped = TRUE;
+
+  //
+  // Notify BMC to disable credential bootstrapping support.
+  //
+  Status = GetBootstrapAccountCredentials (TRUE, NULL, NULL);
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "%a: fail to disable bootstrap credential: %r\n", 
__FUNCTION__, Status));
+return Status;
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Notification of Exit Boot Service.
+
+  @param[in]  ThisPointer to EDKII_REDFISH_CREDENTIAL_PROTOCOL.
+**/
+VOID
+EFIAPI
+LibCredentialExitBootServicesNotify (
+  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
+  )
+{
+  //
+  // Stop the credential support when system is about to enter OS.
+  //
+  LibStopRedfishService (This, ServiceStopTypeExitBootService);
+}
+
+/**
+  Notification of End of DXe.
+
+  @param[in]  ThisPointer to EDKII_REDFISH_CREDENTIAL_PROTOCOL.
+**/
+VOID
+EFIAPI
+LibCredentialEndOfDxeNotify (
+  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
+  )
+{
+  //
+  // Do nothing now.
+  // We can stop credential support when system reach end-of-dxe for security 
reason.
+  //
+}
+
+/**
+  Function to retrieve temporary use credentials for the UEFI redfish client
+
+  @param[in]  DisableBootstrapControl
+  TRUE - Tell the BMC to disable the 
bootstrap credential
+ service to ensure no one else 
gains credentials
+  FALSE  Allow the bootstrap credential 
service to continue
+  @param[out] BootstrapUsername
+  A pointer to a UTF-8 encoded string for 
the credential username
+  When DisableBootstrapControl is TRUE, 
this pointer can be NULL
+
+  @param[out] BootstrapPassword
+  A pointer to a UTF-8 encoded string for 
the credential password
+  When DisableBootstrapControl is TRUE, 
this pointer can be NULL
+
+  @retval  EFI_SUCCESSCredentials were successfully fetched 
and returned
+  @retval  EFI_INVALID_PARAMETER  BootstrapUsername or BootstrapPassword 
is NULL when DisableBootstrapControl
+  is set to FALSE
+  @retval  EFI_DEVICE_ERROR   An IPMI failure occurred
+**/
+EFI_STATUS
+GetBootstrapAccountCredentials (
+  IN BOOLEAN 

[edk2-devel] Event: TianoCore Community Meeting - APAC/NAMO - 10/20/2022 #cal-reminder

2022-10-19 Thread Group Notification
*Reminder: TianoCore Community Meeting - APAC/NAMO*

*When:*
10/20/2022
7:30pm to 8:30pm
(UTC-07:00) America/Los Angeles

*Where:*
https://teams.microsoft.com/l/meetup-join/19%3ameeting_Y2M1NDE3ODYtN2M3Yy00MDMxLTk3OWYtMTlkNjhlNWFlMjA2%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%226e4ce4c4-1242-431b-9a51-92cd01a5df3c%22%7d

*Organizer:* Miki Demeter

View Event ( https://edk2.groups.io/g/devel/viewevent?eventid=1624384 )

*Description:*



Microsoft Teams meeting

*Join on your computer or mobile app*

Click here to join the meeting ( 
https://teams.microsoft.com/l/meetup-join/19%3ameeting_Y2M1NDE3ODYtN2M3Yy00MDMxLTk3OWYtMTlkNjhlNWFlMjA2%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%226e4ce4c4-1242-431b-9a51-92cd01a5df3c%22%7d
 )

Meeting ID: 283 318 374 436
Passcode: 633zLo

Download Teams ( https://www.microsoft.com/en-us/microsoft-teams/download-app ) 
| Join on the web ( https://www.microsoft.com/microsoft-teams/join-a-meeting )

*Join with a video conferencing device*

te...@conf.intel.com

Video Conference ID: 119 493 012 8

Alternate VTC instructions ( 
https://conf.intel.com/teams/?conf=1194930128=teams=conf.intel.com=test_call
 )

Learn More ( https://aka.ms/JoinTeamsMeeting ) | Meeting options ( 
https://teams.microsoft.com/meetingOptions/?organizerId=6e4ce4c4-1242-431b-9a51-92cd01a5df3c=46c98d88-e344-4ed4-8496-4ed7712e255d=19_meeting_Y2M1NDE3ODYtN2M3Yy00MDMxLTk3OWYtMTlkNjhlNWFlMjA2@thread.v2=0=en-US
 )




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95412): https://edk2.groups.io/g/devel/message/95412
Mute This Topic: https://groups.io/mt/94446235/21656
Mute #cal-reminder:https://edk2.groups.io/g/devel/mutehashtag/cal-reminder
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH edk2-platforms] Platform: Remove ComCast RDK

2022-10-19 Thread Michael D Kinney
Acked-by: Michael D Kinney 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ard Biesheuvel
> Sent: Wednesday, October 19, 2022 5:01 AM
> To: devel@edk2.groups.io
> Cc: quic_llind...@quicinc.com; Ard Biesheuvel 
> Subject: [edk2-devel] [PATCH edk2-platforms] Platform: Remove ComCast RDK
> 
> The Comcast RDK platform was contributed years ago, but since then,
> nobody has expressed any interest in it, leaving it to the maintainers
> to keep it in shape. As it turns out, the maintainers can think of
> better ways to spend their time, so let's just drop it.
> 
> Signed-off-by: Ard Biesheuvel 
> ---
>  .../RdkBootManagerLib/RdkBootManagerLib.dec   |  44 --
>  Platform/Comcast/RDKQemu/RDKQemu.dsc  | 421 --
>  Platform/Comcast/RDKQemu/RDKQemu.fdf  | 122 -
>  Platform/Comcast/Application/Dri/Dri.inf  |  37 --
>  .../DriSecureBoot/DriSecureBoot.inf   |  37 --
>  .../Application/SecureBoot/SecureBoot.inf |  37 --
>  .../RdkBootManagerLib/RdkBootManagerLib.inf   |  70 ---
>  .../RdkBootManagerLib/RdkBootManagerLib.h |  92 
>  Platform/Comcast/Application/Dri/Dri.c|  20 -
>  .../Application/DriSecureBoot/DriSecureBoot.c |  26 -
>  .../Application/SecureBoot/SecureBoot.c   |  24 -
>  .../Library/RdkBootManagerLib/DiskIo.c| 378 -
>  .../Library/RdkBootManagerLib/HttpBoot.c  | 344 
>  .../Library/RdkBootManagerLib/RdkFile.c   | 387 -
>  .../Library/RdkBootManagerLib/SecureBoot.c| 517 --
>  Platform/Comcast/RDKQemu/README   |  73 ---
>  16 files changed, 2629 deletions(-)
>  delete mode 100644 
> Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec
>  delete mode 100644 Platform/Comcast/RDKQemu/RDKQemu.dsc
>  delete mode 100644 Platform/Comcast/RDKQemu/RDKQemu.fdf
>  delete mode 100644 Platform/Comcast/Application/Dri/Dri.inf
>  delete mode 100644 
> Platform/Comcast/Application/DriSecureBoot/DriSecureBoot.inf
>  delete mode 100644 Platform/Comcast/Application/SecureBoot/SecureBoot.inf
>  delete mode 100644 
> Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.inf
>  delete mode 100644 
> Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.h
>  delete mode 100644 Platform/Comcast/Application/Dri/Dri.c
>  delete mode 100644 Platform/Comcast/Application/DriSecureBoot/DriSecureBoot.c
>  delete mode 100644 Platform/Comcast/Application/SecureBoot/SecureBoot.c
>  delete mode 100644 Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c
>  delete mode 100644 Platform/Comcast/Library/RdkBootManagerLib/HttpBoot.c
>  delete mode 100644 Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c
>  delete mode 100644 Platform/Comcast/Library/RdkBootManagerLib/SecureBoot.c
>  delete mode 100644 Platform/Comcast/RDKQemu/README
> 
> diff --git a/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec
> b/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec
> deleted file mode 100644
> index e83fc0e556ec..
> --- a/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec
> +++ /dev/null
> @@ -1,44 +0,0 @@
> -#
> 
> -#  Copyright (c) 2014-2018, Linaro Limited. All rights reserved.
> 
> -#
> 
> -#  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> -#
> 
> -
> 
> -[Defines]
> 
> -  DEC_SPECIFICATION  = 0x00010019
> 
> -  PACKAGE_NAME   = RdkPkg
> 
> -  PACKAGE_GUID   = 2f1f2d5e-d9e1-4aa1-8eb9-fed94682e140
> 
> -  PACKAGE_VERSION= 0.1
> 
> -
> 
> -
> 
> -#
> 
> -# Include Section - list of Include Paths that are provided by this package.
> 
> -#   Comments are used for Keywords and Module Types.
> 
> -#
> 
> -# Supported Module Types:
> 
> -#  BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER 
> DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
> 
> -#
> 
> -
> 
> -[Includes.common]
> 
> -#  Include# Root include for the package
> 
> -
> 
> -[Guids.common]
> 
> -  gRdkTokenSpaceGuid=  { 0x408c1892, 0xf11a, 0x40c7, { 0xaa, 
> 0x5f, 0x0d, 0x16, 0xc8, 0xb2, 0x52, 0x59 } }
> 
> -  gRdkGlobalVariableGuid=  { 0xc3253c90, 0xa24f, 0x4599, { 0xa6, 
> 0x64, 0x1f, 0x88, 0x13, 0x77, 0x8f, 0xc9 } }
> 
> -
> 
> -[PcdsFixedAtBuild.common]
> 
> -  # Rdk Library
> 
> -  gRdkTokenSpaceGuid.PcdRdkSystemPartitionName|""|VOID*|0x0203
> 
> -  gRdkTokenSpaceGuid.PcdRdkConfFileName|""|VOID*|0x0204
> 
> -  gRdkTokenSpaceGuid.PcdRdkCmdLineArgs|""|VOID*|0x0213
> 
> -  gRdkTokenSpaceGuid.PcdRdkConfFileDevicePath|L""|VOID*|0x0214
> 
> -  gRdkTokenSpaceGuid.PcdDtbAvailable|FALSE|BOOLEAN|0x00300014
> 
> -
> 
> -  # GUID of RdkSecureBootLoader
> 
> -  gRdkTokenSpaceGuid.PcdRdkSecureBootFile|{ 0x0f, 0x93, 0xc7, 0xb2, 0xef, 
> 

Re: [edk2-devel] [PATCH edk2-platforms 0/4] Platform/ARM: clone ArmPlatformPkg's NorFlashDxe

2022-10-19 Thread Ard Biesheuvel
On Wed, 19 Oct 2022 at 12:36, Ard Biesheuvel  wrote:
>
> NorFlashDxe in ArmPlatformPkg is used in two different ways:
> - by emulated QEMU based platforms that use its NOR flash emulation
>   which is based on versatile express
> - by physical ARM platforms under Platform/ARM in edk2-platforms.
>
> In order to improve support for the former use case, let's first split
> off the latter and give them their own version of the driver.
>
> Cc: Leif Lindholm 
> Cc: Thomas Abraham 
> Cc: Sami Mujawar 
>
> Ard Biesheuvel (4):
>   Platform/ARM/BootMonFs: drop spurious dependency on ArmPlatformPkg
>   Platform/ARM: create local definition of NorFlashPlatformLib
>   Platform/ARM: clone NorFlashDxe from ArmPlatformPkg
>   Platform/ARM: switch to local version of NorFlashDxe drivers
>

Series pushed as 85280b124e5a..0286233f3bfa

Thanks all


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95410): https://edk2.groups.io/g/devel/message/95410
Mute This Topic: https://groups.io/mt/94427741/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] Event: TianoCore Community Meeting EMEA/NAMO - 10/20/2022 #cal-reminder

2022-10-19 Thread Group Notification
*Reminder: TianoCore Community Meeting EMEA/NAMO*

*When:*
10/20/2022
8:00am to 9:00am
(UTC-07:00) America/Los Angeles

*Where:*
Microsoft Teams meeting Join on your computer or mobile app Click here to join 
the meeting Meeting ID: 226 323 011 029 Passcode: hMRCj6 Download Teams | Join 
on the web Join with a video conferencing device te...@conf.intel.com Video 
Conference ID: 112 716 814 3 Alternate VTC instructions Learn More | Meeting 
options

*Organizer:* Miki Demeter

View Event ( https://edk2.groups.io/g/devel/viewevent?eventid=1624375 )

*Description:*



Microsoft Teams meeting

*Join on your computer or mobile app*

Click here to join the meeting ( 
https://teams.microsoft.com/l/meetup-join/19%3ameeting_MTAyZGJhNjMtYzQ4Mi00MTUxLWFlMWMtOGU0MWNlZDk4NjY5%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%226e4ce4c4-1242-431b-9a51-92cd01a5df3c%22%7d
 )

Meeting ID: 226 323 011 029
Passcode: hMRCj6

Download Teams ( https://www.microsoft.com/en-us/microsoft-teams/download-app ) 
| Join on the web ( https://www.microsoft.com/microsoft-teams/join-a-meeting )

*Join with a video conferencing device*

te...@conf.intel.com

Video Conference ID: 112 716 814 3

Alternate VTC instructions ( 
https://conf.intel.com/teams/?conf=1127168143=teams=conf.intel.com=test_call
 )

Learn More ( https://aka.ms/JoinTeamsMeeting ) | Meeting options ( 
https://teams.microsoft.com/meetingOptions/?organizerId=6e4ce4c4-1242-431b-9a51-92cd01a5df3c=46c98d88-e344-4ed4-8496-4ed7712e255d=19_meeting_MTAyZGJhNjMtYzQ4Mi00MTUxLWFlMWMtOGU0MWNlZDk4NjY5@thread.v2=0=en-US
 )




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95409): https://edk2.groups.io/g/devel/message/95409
Mute This Topic: https://groups.io/mt/94433010/21656
Mute #cal-reminder:https://edk2.groups.io/g/devel/mutehashtag/cal-reminder
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH edk2-platforms] Silicon/SynQuacer: Drop dependency on NorFlashPlatformLib

2022-10-19 Thread Ard Biesheuvel
On Wed, 19 Oct 2022 at 15:50, Leif Lindholm  wrote:
>
> On Wed, Oct 19, 2022 at 13:51:36 +0200, Ard Biesheuvel wrote:
> > Fip006Dxe is part of the SynQuacer platform, which is its only user, and
> > yet, it relies on NorFlashPlatformLib to carry the platform specific NOR
> > geometry. This library is tied to ArmPlatformPkg's NorFlashDxe, which
> > will be going away, so let's stop using it.
> >
> > Since the abstraction serves no purpose here, let's just merge the
> > library with its only user.
> >
> > Signed-off-by: Ard Biesheuvel 
>
> Reviewed-by: Leif Lindholm 
>


Thanks

Pushed as cf45696d243a..85280b124e5a


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95408): https://edk2.groups.io/g/devel/message/95408
Mute This Topic: https://groups.io/mt/94428762/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH edk2-platforms] Platform: Remove ComCast RDK

2022-10-19 Thread Ard Biesheuvel
On Wed, 19 Oct 2022 at 15:51, Leif Lindholm  wrote:
>
> On Wed, Oct 19, 2022 at 14:01:00 +0200, Ard Biesheuvel wrote:
> > The Comcast RDK platform was contributed years ago, but since then,
> > nobody has expressed any interest in it, leaving it to the maintainers
> > to keep it in shape. As it turns out, the maintainers can think of
> > better ways to spend their time, so let's just drop it.
> >
> > Signed-off-by: Ard Biesheuvel 
>
> Reviewed-by: Leif Lindholm 
>

Thanks.

Merged as 4f16f918c33d..cf45696d243a with the hunk below added

--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -113,11 +113,6 @@ F: Silicon/TexasInstruments/
 R: Ard Biesheuvel 
 M: Leif Lindholm 

-Comcast
-F: Platform/Comcast/
-M: Ard Biesheuvel 
-M: Leif Lindholm 
-
 OptionRomPkg
 F: Drivers/OptionRomPkg/
 W: https://github.com/tianocore/tianocore.github.io/wiki/OptionRomPkg


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95407): https://edk2.groups.io/g/devel/message/95407
Mute This Topic: https://groups.io/mt/94428903/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v8 00/19] Add Raw algorithm support using Arm FW-TRNG interface

2022-10-19 Thread PierreGondois

Hello,
I finally found back the message from Liming on the v4:
https://edk2.groups.io/g/devel/message/91800

There has been some changes to the patches affecting the MdePkg,
but it should not be significant changes:
- Renamed FID_TRNG_* macros to ARM_SMC_ID_TRNG_*.
- Added RISCV64 to the list of VALID_ARCHITECTURES for BaseTrngLibNull
- Dropped patch: 'MdePkg/BaseRngLib: Rename ArmReadIdIsar0() to
  ArmGetFeatRng()'
- Removed references in Trnglib.h to 'Special Publication'
  800-90A and 800-90C, and only reference 'Arm True Random
  Number Generator Firmware, Interface 1.0' in the Arm
  implementation of the TrngLib.

Liming's Rb is not currently added to the MdePkg patches.

Regards,
Pierre

On 10/18/22 15:20, PierreGondois via groups.io wrote:

From: Pierre Gondois 

Bugzilla: Bug 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3668)

The Arm True Random Number Generator Firmware, Interface 1.0, specification
defines an interface between an Operating System (OS) executing at EL1 and
Firmware (FW) exposing a conditioned entropy source that is provided by a
TRNG back end.
This patch-set:
- defines a TRNG library class that provides an interface to access the
   entropy source on a platform.
- implements a TRNG library instance that uses the Arm FW-TRNG interface.
- Adds RawAlgorithm support to RngDxe for Arm architecture using the Arm
   FW-TRNG interface.
- Enables RNG support using FW-TRNG interface for Kvmtool Guest/Virtual
   firmware.

This patch-set is based on the v2 from Sami Mujawar:
[PATCH v2 0/8] Add Raw algorithm support using Arm FW-TRNG interface
v2:
https://edk2.groups.io/g/devel/message/83775
v3:
https://edk2.groups.io/g/devel/message/90845
https://github.com/PierreARM/edk2/tree/Arm_Trng_v3
v4:
https://github.com/PierreARM/edk2/tree/Arm_Trng_v4
v5:
https://github.com/PierreARM/edk2/tree/Arm_Trng_v5
v6:
https://github.com/PierreARM/edk2/tree/Arm_Trng_v6
v7:
https://github.com/PierreARM/edk2/tree/Arm_Trng_v7
v8:
https://github.com/PierreARM/edk2/tree/Arm_Trng_v8

v8:
  - Added Reviewed-by/Acked-by from Leif on ArmPkg/SecurityPkg
patches. [Leif]
  - Renamed FID_TRNG_* macros to ARM_SMC_ID_TRNG_*. [Leif]
v7:
  - Removed Reviewed-by from Leif.
  - Remove Sami's Signed-off.
V6:
  - Added my signed-off on patches authored by Sami. [Leif]
  - New patch to make it easier to add new libraries in alphabetical
order: ArmPkg: Sort HVC/SMC section alphbetically in ArmPkg.dsc [Leif]
  - Renmaed ArmHvcNullLib to ArmHvcLibNull. [Leif]
  - Added RISCV64 to the list of VALID_ARCHITECTURES for BaseTrngLibNull. [Leif]
  - Removed unnecessary space in function parameter documentation
('[in, out]'). [Rebecca]
  - Updated INF_VERSION to latest spec (1.29) for new libraries. [Rebecca]
  - Dropped the following patches [Leif]:
   - ArmPkg/ArmLib: Add ArmHasRngExt()
   - ArmPkg/ArmLib: Add ArmReadIdIsar0() helper
   - MdePkg/BaseRngLib: Rename ArmReadIdIsar0() to ArmGetFeatRng()
V5:
  - Removed references in Trnglib.h to 'Special Publication'
800-90A and 800-90C, and only reference 'Arm True Random
Number Generator Firmware, Interface 1.0' in the Arm
implementation of the TrngLib. [Jiewen]
V4:
  - Removed dependencies on ArmPkg and dropped patch:
 [PATCH v3 12/22] SecurityPkg: Update Securitypkg.ci.yaml
[Jiewen]
  - Use a dynamically allocated array to hold available algorithms.
The array is freed in a new UNLOAD_IMAGE function and
allocated in arch specific implementations of
GetAvailableAlgorithms(), available in AArch64/AArch64Algo.c
and Arm/ArmAlgo.c.
  - Correctly reference gEfiRngAlgorithmSp80090Ctr256Guid
Guid by copying its address (add missing '&'). [Jiewen]
V3:
  - Address Leif's comment (moving definitions, optimizations, ...)
  - Add ArmMonitorLib to choose Hvc/Smc conduit depending on a Pcd.
  - Re-factor some parts of SecurityPkg/RngDxe/ to ease the addition
of new algorithms.
  - Add ArmHasRngExt() function to check Arm's FEAT_RNG extension.
V2:
  - Updates TrngLib definitions to use RETURN_STATUS as the return type
from the interface functions as TrngLib is base type library.
  - Drops the patch "MdePkg: Add definition for NULL GUID" as there is
already an equivalent definition provided by gZeroGuid. Thus, the
use of gNullGuid has been replaced with gZeroGuid.

Pierre Gondois (11):
   ArmPkg/ArmMonitorLib: Definition for ArmMonitorLib library class
   ArmPkg/ArmMonitorLib: Add ArmMonitorLib
   ArmPkg: Sort HVC/SMC section alphbetically in ArmPkg.dsc
   ArmPkg/ArmHvcLibNull: Add NULL instance of ArmHvcLib
   SecurityPkg/RngDxe: Replace Pcd with Sp80090Ctr256Guid
   SecurityPkg/RngDxe: Remove ArchGetSupportedRngAlgorithms()
   SecurityPkg/RngDxe: Documentation/include/parameter cleanup
   SecurityPkg/RngDxe: Check before advertising Cpu Rng algo
   SecurityPkg/RngDxe: Add debug warning for NULL
 PcdCpuRngSupportedAlgorithm
   SecurityPkg/RngDxe: Rename AArch64/RngDxe.c
   SecurityPkg/RngDxe: Add Arm support of RngDxe

Sami 

Re: [edk2-devel] [PATCH edk2-platforms] Platform: Remove ComCast RDK

2022-10-19 Thread Leif Lindholm
On Wed, Oct 19, 2022 at 14:01:00 +0200, Ard Biesheuvel wrote:
> The Comcast RDK platform was contributed years ago, but since then,
> nobody has expressed any interest in it, leaving it to the maintainers
> to keep it in shape. As it turns out, the maintainers can think of
> better ways to spend their time, so let's just drop it.
> 
> Signed-off-by: Ard Biesheuvel 

Reviewed-by: Leif Lindholm 

/
Leif

> ---
>  .../RdkBootManagerLib/RdkBootManagerLib.dec   |  44 --
>  Platform/Comcast/RDKQemu/RDKQemu.dsc  | 421 --
>  Platform/Comcast/RDKQemu/RDKQemu.fdf  | 122 -
>  Platform/Comcast/Application/Dri/Dri.inf  |  37 --
>  .../DriSecureBoot/DriSecureBoot.inf   |  37 --
>  .../Application/SecureBoot/SecureBoot.inf |  37 --
>  .../RdkBootManagerLib/RdkBootManagerLib.inf   |  70 ---
>  .../RdkBootManagerLib/RdkBootManagerLib.h |  92 
>  Platform/Comcast/Application/Dri/Dri.c|  20 -
>  .../Application/DriSecureBoot/DriSecureBoot.c |  26 -
>  .../Application/SecureBoot/SecureBoot.c   |  24 -
>  .../Library/RdkBootManagerLib/DiskIo.c| 378 -
>  .../Library/RdkBootManagerLib/HttpBoot.c  | 344 
>  .../Library/RdkBootManagerLib/RdkFile.c   | 387 -
>  .../Library/RdkBootManagerLib/SecureBoot.c| 517 --
>  Platform/Comcast/RDKQemu/README   |  73 ---
>  16 files changed, 2629 deletions(-)
>  delete mode 100644 
> Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec
>  delete mode 100644 Platform/Comcast/RDKQemu/RDKQemu.dsc
>  delete mode 100644 Platform/Comcast/RDKQemu/RDKQemu.fdf
>  delete mode 100644 Platform/Comcast/Application/Dri/Dri.inf
>  delete mode 100644 
> Platform/Comcast/Application/DriSecureBoot/DriSecureBoot.inf
>  delete mode 100644 Platform/Comcast/Application/SecureBoot/SecureBoot.inf
>  delete mode 100644 
> Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.inf
>  delete mode 100644 
> Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.h
>  delete mode 100644 Platform/Comcast/Application/Dri/Dri.c
>  delete mode 100644 Platform/Comcast/Application/DriSecureBoot/DriSecureBoot.c
>  delete mode 100644 Platform/Comcast/Application/SecureBoot/SecureBoot.c
>  delete mode 100644 Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c
>  delete mode 100644 Platform/Comcast/Library/RdkBootManagerLib/HttpBoot.c
>  delete mode 100644 Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c
>  delete mode 100644 Platform/Comcast/Library/RdkBootManagerLib/SecureBoot.c
>  delete mode 100644 Platform/Comcast/RDKQemu/README



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95405): https://edk2.groups.io/g/devel/message/95405
Mute This Topic: https://groups.io/mt/94428903/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH edk2-platforms] Silicon/SynQuacer: Drop dependency on NorFlashPlatformLib

2022-10-19 Thread Leif Lindholm
On Wed, Oct 19, 2022 at 13:51:36 +0200, Ard Biesheuvel wrote:
> Fip006Dxe is part of the SynQuacer platform, which is its only user, and
> yet, it relies on NorFlashPlatformLib to carry the platform specific NOR
> geometry. This library is tied to ArmPlatformPkg's NorFlashDxe, which
> will be going away, so let's stop using it.
> 
> Since the abstraction serves no purpose here, let's just merge the
> library with its only user.
> 
> Signed-off-by: Ard Biesheuvel 

Reviewed-by: Leif Lindholm 

/
Leif

> ---
>  .../SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf |  3 +-
>  .../Drivers/Fip006Dxe/Fip006StandaloneMm.inf  |  2 +-
>  .../NorFlashSynQuacerLib.inf  | 35 --
>  .../SynQuacer/Drivers/Fip006Dxe/NorFlash.h| 14 +++-
>  .../SynQuacer/Drivers/Fip006Dxe/NorFlash.c| 44 +
>  .../SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.c |  7 --
>  .../SynQuacer/Drivers/Fip006Dxe/NorFlashSmm.c |  7 --
>  .../NorFlashSynQuacerLib/NorFlashSynQuacer.c  | 64 ---
>  8 files changed, 59 insertions(+), 117 deletions(-)
>  delete mode 100644 
> Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacerLib.inf
>  delete mode 100644 
> Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacer.c
> 
> diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf 
> b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf
> index f91fdcfbc46d..6c7ce663d8b0 100644
> --- a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf
> +++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf
> @@ -24,11 +24,11 @@ [Sources]
>NorFlashFvb.c
>  
>  [Packages]
> -  ArmPlatformPkg/ArmPlatformPkg.dec
>EmbeddedPkg/EmbeddedPkg.dec
>MdeModulePkg/MdeModulePkg.dec
>MdePkg/MdePkg.dec
>Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.dec
> +  Silicon/Socionext/SynQuacer/SynQuacer.dec
>  
>  [LibraryClasses]
>BaseLib
> @@ -40,7 +40,6 @@ [LibraryClasses]
>IoLib
>MemoryAllocationLib
>NorFlashInfoLib
> -  NorFlashPlatformLib
>UefiBootServicesTableLib
>UefiDriverEntryPoint
>UefiLib
> diff --git 
> a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006StandaloneMm.inf 
> b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006StandaloneMm.inf
> index 8f4184dcbd8b..014ad791defc 100644
> --- a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006StandaloneMm.inf
> +++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006StandaloneMm.inf
> @@ -30,6 +30,7 @@ [Packages]
>MdeModulePkg/MdeModulePkg.dec
>MdePkg/MdePkg.dec
>Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.dec
> +  Silicon/Socionext/SynQuacer/SynQuacer.dec
>StandaloneMmPkg/StandaloneMmPkg.dec
>  
>  [LibraryClasses]
> @@ -40,7 +41,6 @@ [LibraryClasses]
>MemoryAllocationLib
>MmServicesTableLib
>NorFlashInfoLib
> -  NorFlashPlatformLib
>StandaloneMmDriverEntryPoint
>  
>  [Guids]
> diff --git 
> a/Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacerLib.inf
>  
> b/Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacerLib.inf
> deleted file mode 100644
> index c1ed3c4d1ca8..
> --- 
> a/Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacerLib.inf
> +++ /dev/null
> @@ -1,35 +0,0 @@
> -#/** @file
> -#
> -#  Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
> -#  SPDX-License-Identifier: BSD-2-Clause-Patent
> -#
> -#**/
> -
> -[Defines]
> -  INF_VERSION= 0x0001001A
> -  BASE_NAME  = NorFlashSynQuacerLib
> -  FILE_GUID  = 8279227C-C555-4D75-B439-D8A959635CDD
> -  MODULE_TYPE= BASE
> -  VERSION_STRING = 1.0
> -  LIBRARY_CLASS  = NorFlashPlatformLib
> -
> -[Sources]
> -  NorFlashSynQuacer.c
> -
> -[Packages]
> -  ArmPlatformPkg/ArmPlatformPkg.dec
> -  ArmPkg/ArmPkg.dec
> -  MdeModulePkg/MdeModulePkg.dec
> -  MdePkg/MdePkg.dec
> -  Silicon/Socionext/SynQuacer/SynQuacer.dec
> -
> -[LibraryClasses]
> -  BaseLib
> -
> -[FixedPcd]
> -  gArmTokenSpaceGuid.PcdFdBaseAddress
> -  gArmTokenSpaceGuid.PcdFdSize
> -  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
> -  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
> -  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
> -  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
> diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlash.h 
> b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlash.h
> index 3cb86ab588e0..a287b9e396fb 100644
> --- a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlash.h
> +++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlash.h
> @@ -22,7 +22,6 @@
>  
>  #include 
>  #include 
> -#include 
>  
>  #include "Fip006Reg.h"
>  
> @@ -291,6 +290,19 @@ NorFlashReadID (
>OUT UINT8   JedecId[3]
>);
>  
> +typedef struct {
> +  UINTNDeviceBaseAddress;   // Start address 

Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH 25/29] OvmfPkg: Add NorFlashQemuLib library

2022-10-19 Thread Leif Lindholm
On Wed, Oct 19, 2022 at 14:19:28 +0100, Sami Mujawar wrote:
> > > Considering this, should QemuNorFlashDxe be called OvmfNorFlashDxe?
> > > 
> > > [/SAMI]
> > > 
> > Ah yes, good point. So using Qemu as a prefix is slightly problematic.
> > 
> > My intent is for this driver to be optimized towards NOR flash
> > emulation the way QEMU implements it. The main difference between the
> > platforms is that some of them (notably, ArmVirtQemu.dsc) also execute
> > from the emulated region, which requires an executable (read-only)
> > memslot in KVM, as instruction fetches (as opposed to explicit loads
> > and stores) cannot be emulated by KVM. KvmTool only uses the NOR flash
> > for variables, so it doesn't really care how the emulation is
> > implemented, as long as the loads and stores are carried out in the
> > expected way.
> > 
> > I don't think the Ovmf prefix makes sense here either - OVMF is still
> > primarily x86, which uses a different flash emulation altogether.
> > Maybe VirtNorFlashDxe, to emphasize that it does not expect to be
> > dealing with actual NOR flash?
> 
> VirtNorFlashDxe sounds good to me.

Sounds good to me too.

/
Leif


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95403): https://edk2.groups.io/g/devel/message/95403
Mute This Topic: https://groups.io/mt/94233036/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH edk2-platforms 2/4] Platform/ARM: create local definition of NorFlashPlatformLib

2022-10-19 Thread Sunil V L
On Wed, Oct 19, 2022 at 02:56:39PM +0200, Ard Biesheuvel wrote:
> On Wed, 19 Oct 2022 at 14:52, Sami Mujawar  wrote:
> >
> > Hi Ard,
> >
> > Thank you for this patch.
> >
> > The patch at 'https://edk2.groups.io/g/devel/message/95239' is moving
> > the NorFlashPlatformLib.h to
> > MdePkg/Include/Library/NorFlashPlatformLib.h. Is the plan to drop
> > Platform/ARM/Include/Library/NorFlashPlatformLib.h once the MdePkg patch
> > is merged?
> >
> 
> MdePkg is not the place for this - it only carries things that are
> defined in PI, UEFI, or other industry standard specifications.
> 
> NorFlashPlatformLib is tightly coupled to NorFlashDxe. We will be
> moving the latter into OvmfPkg/ so the library definition should move
> there as well, most probably.
> 

Okay. I will drop MdePkg changes then and add it in OvmfPkg.

Thanks
Sunil



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95402): https://edk2.groups.io/g/devel/message/95402
Mute This Topic: https://groups.io/mt/94427743/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH 25/29] OvmfPkg: Add NorFlashQemuLib library

2022-10-19 Thread Sami Mujawar

Hi Ard,


On 19/10/2022 02:14 pm, Ard Biesheuvel wrote:

On Wed, 19 Oct 2022 at 15:06, Sami Mujawar  wrote:

Hi Ard,

Please see my query inline marked [SAMI].

Regards,

Sami Mujawar

On 19/10/2022 01:19 pm, Ard Biesheuvel via groups.io wrote:

On Mon, 10 Oct 2022 at 12:13, Sunil V L  wrote:

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

This is copied from ArmVirtPkg since it is required for
other architectures also.

It also adds the instance for single flash drive which has
both code and variables. This is copied from SbsaQemu.

Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Cc: Daniel Schaefer 
Signed-off-by: Sunil V L 

Let's call these

QemuNorFlashPlatformLib [for the library class]

QemuNorFlashDeviceTreeLib
QemuNorFlashStaticLib

and for the driver

QemuNorFlashDxe

[SAMI] We use the NorFlashDxe for the Kvmtool guest firmware, see
https://github.com/tianocore/edk2/blob/master/ArmVirtPkg/ArmVirtKvmTool.dsc#L294

Considering this, should QemuNorFlashDxe be called OvmfNorFlashDxe?

[/SAMI]


Ah yes, good point. So using Qemu as a prefix is slightly problematic.

My intent is for this driver to be optimized towards NOR flash
emulation the way QEMU implements it. The main difference between the
platforms is that some of them (notably, ArmVirtQemu.dsc) also execute
from the emulated region, which requires an executable (read-only)
memslot in KVM, as instruction fetches (as opposed to explicit loads
and stores) cannot be emulated by KVM. KvmTool only uses the NOR flash
for variables, so it doesn't really care how the emulation is
implemented, as long as the loads and stores are carried out in the
expected way.

I don't think the Ovmf prefix makes sense here either - OVMF is still
primarily x86, which uses a different flash emulation altogether.
Maybe VirtNorFlashDxe, to emphasize that it does not expect to be
dealing with actual NOR flash?


VirtNorFlashDxe sounds good to me.

Regards,

Sami Mujawar



Suggestions welcome :-)



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95401): https://edk2.groups.io/g/devel/message/95401
Mute This Topic: https://groups.io/mt/94233036/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] Python368.efi failed to run in shell environment

2022-10-19 Thread Jayaprakash, N
You may follow instructions provided in 
https://github.com/tianocore/edk2-libc/blob/master/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst

Regards,
JP

From: Yoshinoya 
Sent: 19 October 2022 14:01
To: Jayaprakash, N 
Cc: Kinney, Michael D ; devel@edk2.groups.io
Subject: Re:RE: Re:RE: [edk2-devel] Python368.efi failed to run in shell 
environment

Hi, JP:
I followed Py368ReadMe.txt to compile Python368 app in Ubuntu 22.04 environment.
The steps is:
1. execute srcprep.py
2. add this module to AppPkg/AppPkg.dsc
3. execute "build -a X64 -p AppPkg\AppPkg.dsc"

but it failed, the tips is:
In file included from 
/home/yoshi/edk2/AppPkg/Applications/Python/Python-3.6.8/Modules/_bisectmodule.c:7:
/home/yoshi/edk2/AppPkg/Applications/Python/Python-3.6.8/Include/Python.h:44:10:
 fatal error: crypt.h: No such file or directory
   44 | #include 
  |  ^
compilation terminated.




Thanks







At 2022-10-18 17:04:42, "Jayaprakash, N" 
mailto:n.jayaprak...@intel.com>> wrote:
Hi Yoshinoya,

Could you provide some details about the platform on which you are trying to 
run?
What tools you used for building the Python interpreter?

If you could raise a bug with relevant details, we can take a look at this 
issue.

Regards,
JP

From: Yoshinoya mailto:yoshinoyat...@163.com>>
Sent: 11 October 2022 15:51
To: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Cc: devel@edk2.groups.io; Jayaprakash, N 
mailto:n.jayaprak...@intel.com>>
Subject: Re:RE: [edk2-devel] Python368.efi failed to run in shell environment

Hi, JP:
It seems PyImport_ImportModule("encoding.utf_8") failed.
Do you have any suggestions?

THank you very much!



best wishes,







At 2022-10-06 00:28:46, "Kinney, Michael D" 
mailto:michael.d.kin...@intel.com>> wrote:
+JP

Mike

From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of Yoshinoya
Sent: Wednesday, October 5, 2022 4:32 AM
To: devel@edk2.groups.io
Subject: [edk2-devel] Python368.efi failed to run in shell environment

Hi
I tried to run Python368.efi in shell environment.
but failed, the tips was;
Fatal Python error: Py_Initialize: can't initialize sys standard streams

Does anybody have ever met this error?

Python368.efi is a sample python app in AppPkg\Applications\Python\Python-3.6.8

Thanks



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95400): https://edk2.groups.io/g/devel/message/95400
Mute This Topic: https://groups.io/mt/94136700/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH 25/29] OvmfPkg: Add NorFlashQemuLib library

2022-10-19 Thread Ard Biesheuvel
On Wed, 19 Oct 2022 at 15:06, Sami Mujawar  wrote:
>
> Hi Ard,
>
> Please see my query inline marked [SAMI].
>
> Regards,
>
> Sami Mujawar
>
> On 19/10/2022 01:19 pm, Ard Biesheuvel via groups.io wrote:
> > On Mon, 10 Oct 2022 at 12:13, Sunil V L  wrote:
> >> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076
> >>
> >> This is copied from ArmVirtPkg since it is required for
> >> other architectures also.
> >>
> >> It also adds the instance for single flash drive which has
> >> both code and variables. This is copied from SbsaQemu.
> >>
> >> Cc: Ard Biesheuvel 
> >> Cc: Jiewen Yao 
> >> Cc: Jordan Justen 
> >> Cc: Gerd Hoffmann 
> >> Cc: Daniel Schaefer 
> >> Signed-off-by: Sunil V L 
> > Let's call these
> >
> > QemuNorFlashPlatformLib [for the library class]
> >
> > QemuNorFlashDeviceTreeLib
> > QemuNorFlashStaticLib
> >
> > and for the driver
> >
> > QemuNorFlashDxe
>
> [SAMI] We use the NorFlashDxe for the Kvmtool guest firmware, see
> https://github.com/tianocore/edk2/blob/master/ArmVirtPkg/ArmVirtKvmTool.dsc#L294
>
> Considering this, should QemuNorFlashDxe be called OvmfNorFlashDxe?
>
> [/SAMI]
>

Ah yes, good point. So using Qemu as a prefix is slightly problematic.

My intent is for this driver to be optimized towards NOR flash
emulation the way QEMU implements it. The main difference between the
platforms is that some of them (notably, ArmVirtQemu.dsc) also execute
from the emulated region, which requires an executable (read-only)
memslot in KVM, as instruction fetches (as opposed to explicit loads
and stores) cannot be emulated by KVM. KvmTool only uses the NOR flash
for variables, so it doesn't really care how the emulation is
implemented, as long as the loads and stores are carried out in the
expected way.

I don't think the Ovmf prefix makes sense here either - OVMF is still
primarily x86, which uses a different flash emulation altogether.
Maybe VirtNorFlashDxe, to emphasize that it does not expect to be
dealing with actual NOR flash?

Suggestions welcome :-)


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95399): https://edk2.groups.io/g/devel/message/95399
Mute This Topic: https://groups.io/mt/94233036/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH 25/29] OvmfPkg: Add NorFlashQemuLib library

2022-10-19 Thread Sami Mujawar

Hi Ard,

Please see my query inline marked [SAMI].

Regards,

Sami Mujawar

On 19/10/2022 01:19 pm, Ard Biesheuvel via groups.io wrote:

On Mon, 10 Oct 2022 at 12:13, Sunil V L  wrote:

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

This is copied from ArmVirtPkg since it is required for
other architectures also.

It also adds the instance for single flash drive which has
both code and variables. This is copied from SbsaQemu.

Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Cc: Daniel Schaefer 
Signed-off-by: Sunil V L 

Let's call these

QemuNorFlashPlatformLib [for the library class]

QemuNorFlashDeviceTreeLib
QemuNorFlashStaticLib

and for the driver

QemuNorFlashDxe


[SAMI] We use the NorFlashDxe for the Kvmtool guest firmware, see 
https://github.com/tianocore/edk2/blob/master/ArmVirtPkg/ArmVirtKvmTool.dsc#L294


Considering this, should QemuNorFlashDxe be called OvmfNorFlashDxe?

[/SAMI]




i sent out some patches for edk2-platforms to eliminate the dependency
on ArmPlatformPkg's NorFlashDxe and NorFlashPlatformLib definitions.
Once we move everything in OvmfPkg over to these ones, we can drop the
old one altogether.




---
  OvmfPkg/OvmfPkg.dec   |   8 ++
  .../NorFlashQemuLib/NorFlashQemuLib.inf   |  40 ++
  .../NorFlashQemuUnifiedLib.inf|  30 
  OvmfPkg/Include/Library/NorFlashPlatformLib.h |  30 
  .../Library/NorFlashQemuLib/NorFlashQemuLib.c | 136 ++
  .../NorFlashQemuLib/NorFlashQemuUnifiedLib.c  |  40 ++
  6 files changed, 284 insertions(+)
  create mode 100644 OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
  create mode 100644 OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.inf
  create mode 100644 OvmfPkg/Include/Library/NorFlashPlatformLib.h
  create mode 100644 OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c
  create mode 100644 OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.c

diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index 7d2acc5ea0e0..0697c91c6836 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -129,6 +129,10 @@ [LibraryClasses]
#
HardwareInfoLib|Include/Library/HardwareInfoLib.h

+  ##  @libraryclass  NorFlashQemuLib
+  #
+  NorFlashPlatformLib|Include/Library/NorFlashPlatformLib.h
+
  [Guids]
gUefiOvmfPkgTokenSpaceGuid= {0x93bb96af, 0xb9f2, 0x4eb8, {0x94, 
0x62, 0xe0, 0xba, 0x74, 0x56, 0x42, 0x36}}
gEfiXenInfoGuid   = {0xd3b46f3b, 0xd441, 0x1244, {0x9a, 
0x12, 0x0, 0x12, 0x27, 0x3f, 0xc1, 0x4d}}
@@ -405,6 +409,10 @@ [PcdsFixedAtBuild]
#  check to decide whether to abort dispatch of the driver it is linked 
into.
gUefiOvmfPkgTokenSpaceGuid.PcdEntryPointOverrideFwCfgVarName|""|VOID*|0x68

+  ## The base address and size of the FVMAIN
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvBaseAddress|0|UINT64|0x71
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvSize|0|UINT32|0x72
+
  [PcdsDynamic, PcdsDynamicEx]
gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10
diff --git a/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf 
b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
new file mode 100644
index ..ecd8059b3508
--- /dev/null
+++ b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
@@ -0,0 +1,40 @@
+#/** @file
+#
+#  Component description file for NorFlashQemuLib module
+#
+#  Copyright (c) 2014, Linaro Ltd. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = NorFlashQemuLib
+  FILE_GUID  = 42C30D8E-BFAD-4E77-9041-E7DAAE88DF7A
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = NorFlashPlatformLib
+
+[Sources.common]
+  NorFlashQemuLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+  UefiBootServicesTableLib
+
+[Protocols]
+  gFdtClientProtocolGuid  ## CONSUMES
+
+[Depex]
+  gFdtClientProtocolGuid
+
+[Pcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvBaseAddress
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvSize
diff --git a/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.inf 
b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.inf
new file mode 100644
index ..91d1406fc3e7
--- /dev/null
+++ b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.inf
@@ -0,0 +1,30 @@
+#/** @file
+#
+#  Component description file for NorFlashQemuLib module
+#
+#  Copyright (c) 2014, Linaro Ltd. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = NorFlashQemuUnifiedLib
+  FILE_GUID  = 064742F1-E531-4D7D-A154-22315889CC23
+  MODULE_TYPE  

Re: [edk2-devel] [PATCH edk2-platforms 2/4] Platform/ARM: create local definition of NorFlashPlatformLib

2022-10-19 Thread Ard Biesheuvel
On Wed, 19 Oct 2022 at 14:52, Sami Mujawar  wrote:
>
> Hi Ard,
>
> Thank you for this patch.
>
> The patch at 'https://edk2.groups.io/g/devel/message/95239' is moving
> the NorFlashPlatformLib.h to
> MdePkg/Include/Library/NorFlashPlatformLib.h. Is the plan to drop
> Platform/ARM/Include/Library/NorFlashPlatformLib.h once the MdePkg patch
> is merged?
>

MdePkg is not the place for this - it only carries things that are
defined in PI, UEFI, or other industry standard specifications.

NorFlashPlatformLib is tightly coupled to NorFlashDxe. We will be
moving the latter into OvmfPkg/ so the library definition should move
there as well, most probably.

> Other than that, these changes look good to me.
>
> Reviewed-by: Sami Mujawar 
>
> Regards,
>
> Sami Mujawar
>
> On 19/10/2022 11:35 am, Ard Biesheuvel wrote:
> > The version of NorFlashPlatformLib defined in ArmPlatformPkg will go
> > away once we retire its version of NorFlashDxe, so switch to a local
> > Platform/ARM version instead.
> >
> > Signed-off-by: Ard Biesheuvel 
> > ---
> >   Platform/ARM/ARM.dec|  1 +
> >   Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf|  2 
> > +-
> >   Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf |  2 
> > +-
> >   Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf |  2 
> > +-
> >   Platform/ARM/Include/Library/NorFlashPlatformLib.h  | 30 
> > 
> >   5 files changed, 34 insertions(+), 3 deletions(-)
> >
> > diff --git a/Platform/ARM/ARM.dec b/Platform/ARM/ARM.dec
> > index 5175b313f95a..cf1c8ef04742 100644
> > --- a/Platform/ARM/ARM.dec
> > +++ b/Platform/ARM/ARM.dec
> > @@ -17,6 +17,7 @@ [Includes]
> >
> >
> >   [LibraryClasses]
> >
> > BdsLib|Include/Library/BdsLib.h
> >
> > +  NorFlashPlatformLib|Include/Library/NorFlashPlatformLib.h
> >
> >
> >
> >   [Guids]
> >
> > gArmBootMonFsFileInfoGuid   = { 0x41e26b9c, 0xada6, 0x45b3, { 0x80, 
> > 0x8e, 0x23, 0x57, 0xa3, 0x5b, 0x60, 0xd6 } }
> >
> > diff --git 
> > a/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf 
> > b/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf
> > index e5e5628de387..1a38bf81b349 100644
> > --- a/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf
> > +++ b/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf
> > @@ -17,8 +17,8 @@ [Sources.common]
> > NorFlashJuno.c
> >
> >
> >
> >   [Packages]
> >
> > -  ArmPlatformPkg/ArmPlatformPkg.dec
> >
> > MdePkg/MdePkg.dec
> >
> > +  Platform/ARM/ARM.dec
> >
> > Platform/ARM/JunoPkg/ArmJuno.dec
> >
> >
> >
> >   [LibraryClasses]
> >
> > diff --git a/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf 
> > b/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
> > index 74486eacd009..06068db0e4f3 100644
> > --- a/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
> > +++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
> > @@ -18,8 +18,8 @@ [Sources.common]
> > NorFlashLib.c
> >
> >
> >
> >   [Packages]
> >
> > -  ArmPlatformPkg/ArmPlatformPkg.dec
> >
> > MdePkg/MdePkg.dec
> >
> > +  Platform/ARM/ARM.dec
> >
> > Platform/ARM/SgiPkg/SgiPlatform.dec
> >
> >
> >
> >   [LibraryClasses]
> >
> > diff --git 
> > a/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf 
> > b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
> > index 96bbf1e42313..54b3cb041645 100644
> > --- a/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
> > +++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
> > @@ -19,8 +19,8 @@ [Sources.common]
> > StandaloneMmNorFlashLib.c
> >
> >
> >
> >   [Packages]
> >
> > -  ArmPlatformPkg/ArmPlatformPkg.dec
> >
> > MdePkg/MdePkg.dec
> >
> > +  Platform/ARM/ARM.dec
> >
> > Platform/ARM/SgiPkg/SgiPlatform.dec
> >
> >
> >
> >   [LibraryClasses]
> >
> > diff --git a/Platform/ARM/Include/Library/NorFlashPlatformLib.h 
> > b/Platform/ARM/Include/Library/NorFlashPlatformLib.h
> > new file mode 100644
> > index ..6ef5b70e9948
> > --- /dev/null
> > +++ b/Platform/ARM/Include/Library/NorFlashPlatformLib.h
> > @@ -0,0 +1,30 @@
> > +/** @file
> >
> > +
> >
> > + Copyright (c) 2011-2012, ARM Ltd. All rights reserved.
> >
> > +
> >
> > + SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > +
> >
> > + **/
> >
> > +
> >
> > +#ifndef _NORFLASHPLATFORMLIB_H_
> >
> > +#define _NORFLASHPLATFORMLIB_H_
> >
> > +
> >
> > +typedef struct {
> >
> > +  UINTNDeviceBaseAddress;   // Start address of the Device Base 
> > Address (DBA)
> >
> > +  UINTNRegionBaseAddress;   // Start address of one single region
> >
> > +  UINTNSize;
> >
> > +  UINTNBlockSize;
> >
> > +} NOR_FLASH_DESCRIPTION;
> >
> > +
> >
> > +EFI_STATUS
> >
> > +NorFlashPlatformInitialization (
> >
> > +  VOID
> >
> > +  );
> >
> > +
> >
> > +EFI_STATUS
> >
> > +NorFlashPlatformGetDevices (
> >
> > +  

Re: [edk2-devel] [PATCH edk2-platforms 4/4] Platform/ARM: switch to local version of NorFlashDxe drivers

2022-10-19 Thread Sami Mujawar

Hi Ard,

Thank you for this patch. These changes look good to me.

Reviewed-by: Sami Mujawar 

Regards,

Sami Mujawar

On 19/10/2022 11:35 am, Ard Biesheuvel wrote:

Drop the dependency on the ArmPlatformPkg version of NorFlashDxe and
NorFlashStandaloneMm, which will be going away soon. Instead, depend on
the local version under Platform/ARM.

Signed-off-by: Ard Biesheuvel 
---
  Platform/ARM/SgiPkg/SgiPlatform.dsc.inc  | 2 +-
  Platform/ARM/SgiPkg/SgiPlatformMm.dsc.inc| 2 +-
  Platform/ARM/JunoPkg/ArmJuno.dsc | 2 +-
  Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc| 2 +-
  Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc | 2 +-
  Platform/ARM/JunoPkg/ArmJuno.fdf | 2 +-
  Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf | 2 +-
  Platform/ARM/SgiPkg/SgiPlatform.fdf  | 2 +-
  Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.fdf| 2 +-
  Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf | 2 +-
  10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc 
b/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc
index 2f5dadfaefc6..81764368a0b7 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc
@@ -256,7 +256,7 @@ [Components.common]
  !if $(ENABLE_GOP) == TRUE

ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf

  !endif

-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf

+  Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf

EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf

EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf

MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf

diff --git a/Platform/ARM/SgiPkg/SgiPlatformMm.dsc.inc 
b/Platform/ARM/SgiPkg/SgiPlatformMm.dsc.inc
index 68fc3ad93a5f..ae0ff7247a6a 100644
--- a/Platform/ARM/SgiPkg/SgiPlatformMm.dsc.inc
+++ b/Platform/ARM/SgiPkg/SgiPlatformMm.dsc.inc
@@ -122,7 +122,7 @@ [Components.common]
  [Components.AARCH64]

StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf

  !if $(SECURE_STORAGE_ENABLE) == TRUE

-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf

+  Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf


MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf

MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf {

  

diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc b/Platform/ARM/JunoPkg/ArmJuno.dsc
index f7ce397633f6..a00b866c5e9a 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.dsc
+++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
@@ -277,7 +277,7 @@ [Components.common]
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf

  


ArmPkg/Drivers/ArmGic/ArmGicDxe.inf

-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf

+  Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf

ArmPkg/Drivers/TimerDxe/TimerDxe.inf

ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf

  


diff --git a/Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc 
b/Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc
index cb9d2d4287e3..9c5e78d6275d 100644
--- a/Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc
+++ b/Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc
@@ -229,7 +229,7 @@ [Components.common]
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf

  


ArmPkg/Drivers/ArmGic/ArmGicDxe.inf

-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf

+  Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf

ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf

ArmPkg/Drivers/TimerDxe/TimerDxe.inf

ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf

diff --git a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc 
b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
index 8561c21fab5a..dc081794cf98 100644
--- a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
+++ b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
@@ -289,7 +289,7 @@ [Components.common]
}

  


ArmPkg/Drivers/ArmGic/ArmGicDxe.inf

-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf

+  Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf

ArmPkg/Drivers/TimerDxe/TimerDxe.inf

  !ifdef EDK2_ENABLE_PL111

ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf

diff --git a/Platform/ARM/JunoPkg/ArmJuno.fdf b/Platform/ARM/JunoPkg/ArmJuno.fdf
index c9d51c65ffdb..fca5a78cee6c 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.fdf
+++ b/Platform/ARM/JunoPkg/ArmJuno.fdf
@@ -136,7 +136,7 @@ [FV.FvMain]
INF ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf

  


# NOR Flash driver

-  INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf

+  INF Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf

  


# Versatile Express FileSystem

INF Platform/ARM/Drivers/BootMonFs/BootMonFs.inf

diff --git a/Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf 
b/Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf
index c1c24b747fa5..653aae8285a6 100644
--- 

Re: [edk2-devel] [PATCH edk2-platforms 3/4] Platform/ARM: clone NorFlashDxe from ArmPlatformPkg

2022-10-19 Thread Sami Mujawar

Hi Ard,

Thank you for this patch.

Reviewed-by: Sami Mujawar 

Regards,

Sami Mujawar

On 19/10/2022 11:35 am, Ard Biesheuvel wrote:

The ArmPlatformPkg version of NorFlashDxe and NorFlashStandaloneMm will
be going away, so clone them into Platform/ARM where the ARM platforms
that rely on this driver can keep using it.

Other than updating the INF version, refreshing the file GUIDs and
reorganizing the various INF sections, no changes have been made to the
driver.

Signed-off-by: Ard Biesheuvel 
---
  Platform/ARM/ARM.dec  |   4 +
  Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf  |  71 ++
  Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf |  66 ++
  Platform/ARM/Drivers/NorFlashDxe/NorFlash.h   | 422 +
  Platform/ARM/Drivers/NorFlashDxe/NorFlash.c   | 991 

  Platform/ARM/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c | 123 +++
  Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c| 506 ++
  Platform/ARM/Drivers/NorFlashDxe/NorFlashFvb.c| 777 
+++
  Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c   | 383 
  9 files changed, 3343 insertions(+)

diff --git a/Platform/ARM/ARM.dec b/Platform/ARM/ARM.dec
index cf1c8ef04742..be7e6dc83fde 100644
--- a/Platform/ARM/ARM.dec
+++ b/Platform/ARM/ARM.dec
@@ -20,4 +20,8 @@ [LibraryClasses]
NorFlashPlatformLib|Include/Library/NorFlashPlatformLib.h

  


  [Guids]

+  gPlatformArmTokenSpaceGuid  = { 0x7a5e0def, 0xd3c3, 0x44f3, { 0x8d, 0x69, 
0x70, 0xfc, 0x8f, 0xd6, 0x4f, 0xdf } }

gArmBootMonFsFileInfoGuid   = { 0x41e26b9c, 0xada6, 0x45b3, { 0x80, 0x8e, 
0x23, 0x57, 0xa3, 0x5b, 0x60, 0xd6 } }

+

+[PcdsFeatureFlag.common]

+  
gPlatformArmTokenSpaceGuid.PcdNorFlashCheckBlockLocked|FALSE|BOOLEAN|0x001

diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf 
b/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf
new file mode 100644
index ..cdf1f5c27f35
--- /dev/null
+++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf
@@ -0,0 +1,71 @@
+#/** @file

+#

+#  Component description file for NorFlashDxe module

+#

+#  Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.

+#

+#  SPDX-License-Identifier: BSD-2-Clause-Patent

+#

+#**/

+

+[Defines]

+  INF_VERSION= 1.29

+  BASE_NAME  = NorFlashDxe

+  FILE_GUID  = de6ae758-d662-4e17-a97c-4c5964da4c41

+  MODULE_TYPE= DXE_RUNTIME_DRIVER

+  VERSION_STRING = 1.0

+  ENTRY_POINT= NorFlashInitialise

+

+[Sources.common]

+  NorFlash.c

+  NorFlash.h

+  NorFlashBlockIoDxe.c

+  NorFlashDxe.c

+  NorFlashFvb.c

+

+[Packages]

+  EmbeddedPkg/EmbeddedPkg.dec

+  MdePkg/MdePkg.dec

+  MdeModulePkg/MdeModulePkg.dec

+  Platform/ARM/ARM.dec

+

+[LibraryClasses]

+  BaseLib

+  DebugLib

+  DxeServicesTableLib

+  HobLib

+  IoLib

+  NorFlashPlatformLib

+  UefiBootServicesTableLib

+  UefiDriverEntryPoint

+  UefiLib

+  UefiRuntimeLib

+

+[Guids]

+  gEdkiiNvVarStoreFormattedGuid ## PRODUCES ## PROTOCOL

+  gEfiAuthenticatedVariableGuid

+  gEfiEventVirtualAddressChangeGuid

+  gEfiSystemNvDataFvGuid

+  gEfiVariableGuid

+

+[Protocols]

+  gEfiBlockIoProtocolGuid

+  gEfiDevicePathProtocolGuid

+  gEfiDiskIoProtocolGuid

+  gEfiFirmwareVolumeBlockProtocolGuid

+

+[Pcd.common]

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize

+

+  gPlatformArmTokenSpaceGuid.PcdNorFlashCheckBlockLocked

+

+[Depex]

+  gEfiCpuArchProtocolGuid

diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf 
b/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf
new file mode 100644
index ..001f281220f2
--- /dev/null
+++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf
@@ -0,0 +1,66 @@
+#/** @file

+#

+#  Component description file for NorFlashStandaloneMm module

+#

+#  Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.

+#  Copyright (c) 2020, Linaro, Ltd. All rights reserved.

+#

+#  SPDX-License-Identifier: BSD-2-Clause-Patent

+#

+#**/

+

+[Defines]

+  INF_VERSION= 1.29

+  BASE_NAME  = NorFlashStandaloneMm

+  FILE_GUID  = a87c67d2-f183-415c-993d-11431fc478ee

+  MODULE_TYPE= MM_STANDALONE

+  VERSION_STRING = 1.0

+  PI_SPECIFICATION_VERSION 

Re: [edk2-devel] [PATCH edk2-platforms 2/4] Platform/ARM: create local definition of NorFlashPlatformLib

2022-10-19 Thread Sami Mujawar

Hi Ard,

Thank you for this patch.

The patch at 'https://edk2.groups.io/g/devel/message/95239' is moving 
the NorFlashPlatformLib.h to 
MdePkg/Include/Library/NorFlashPlatformLib.h. Is the plan to drop 
Platform/ARM/Include/Library/NorFlashPlatformLib.h once the MdePkg patch 
is merged?


Other than that, these changes look good to me.

Reviewed-by: Sami Mujawar 

Regards,

Sami Mujawar

On 19/10/2022 11:35 am, Ard Biesheuvel wrote:

The version of NorFlashPlatformLib defined in ArmPlatformPkg will go
away once we retire its version of NorFlashDxe, so switch to a local
Platform/ARM version instead.

Signed-off-by: Ard Biesheuvel 
---
  Platform/ARM/ARM.dec|  1 +
  Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf|  2 +-
  Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf |  2 +-
  Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf |  2 +-
  Platform/ARM/Include/Library/NorFlashPlatformLib.h  | 30 

  5 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/Platform/ARM/ARM.dec b/Platform/ARM/ARM.dec
index 5175b313f95a..cf1c8ef04742 100644
--- a/Platform/ARM/ARM.dec
+++ b/Platform/ARM/ARM.dec
@@ -17,6 +17,7 @@ [Includes]
  


  [LibraryClasses]

BdsLib|Include/Library/BdsLib.h

+  NorFlashPlatformLib|Include/Library/NorFlashPlatformLib.h

  


  [Guids]

gArmBootMonFsFileInfoGuid   = { 0x41e26b9c, 0xada6, 0x45b3, { 0x80, 0x8e, 
0x23, 0x57, 0xa3, 0x5b, 0x60, 0xd6 } }

diff --git a/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf 
b/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf
index e5e5628de387..1a38bf81b349 100644
--- a/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf
+++ b/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf
@@ -17,8 +17,8 @@ [Sources.common]
NorFlashJuno.c

  


  [Packages]

-  ArmPlatformPkg/ArmPlatformPkg.dec

MdePkg/MdePkg.dec

+  Platform/ARM/ARM.dec

Platform/ARM/JunoPkg/ArmJuno.dec

  


  [LibraryClasses]

diff --git a/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf 
b/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
index 74486eacd009..06068db0e4f3 100644
--- a/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
+++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
@@ -18,8 +18,8 @@ [Sources.common]
NorFlashLib.c

  


  [Packages]

-  ArmPlatformPkg/ArmPlatformPkg.dec

MdePkg/MdePkg.dec

+  Platform/ARM/ARM.dec

Platform/ARM/SgiPkg/SgiPlatform.dec

  


  [LibraryClasses]

diff --git 
a/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf 
b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
index 96bbf1e42313..54b3cb041645 100644
--- a/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
+++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
@@ -19,8 +19,8 @@ [Sources.common]
StandaloneMmNorFlashLib.c

  


  [Packages]

-  ArmPlatformPkg/ArmPlatformPkg.dec

MdePkg/MdePkg.dec

+  Platform/ARM/ARM.dec

Platform/ARM/SgiPkg/SgiPlatform.dec

  


  [LibraryClasses]

diff --git a/Platform/ARM/Include/Library/NorFlashPlatformLib.h 
b/Platform/ARM/Include/Library/NorFlashPlatformLib.h
new file mode 100644
index ..6ef5b70e9948
--- /dev/null
+++ b/Platform/ARM/Include/Library/NorFlashPlatformLib.h
@@ -0,0 +1,30 @@
+/** @file

+

+ Copyright (c) 2011-2012, ARM Ltd. All rights reserved.

+

+ SPDX-License-Identifier: BSD-2-Clause-Patent

+

+ **/

+

+#ifndef _NORFLASHPLATFORMLIB_H_

+#define _NORFLASHPLATFORMLIB_H_

+

+typedef struct {

+  UINTNDeviceBaseAddress;   // Start address of the Device Base 
Address (DBA)

+  UINTNRegionBaseAddress;   // Start address of one single region

+  UINTNSize;

+  UINTNBlockSize;

+} NOR_FLASH_DESCRIPTION;

+

+EFI_STATUS

+NorFlashPlatformInitialization (

+  VOID

+  );

+

+EFI_STATUS

+NorFlashPlatformGetDevices (

+  OUT NOR_FLASH_DESCRIPTION  **NorFlashDescriptions,

+  OUT UINT32 *Count

+  );

+

+#endif /* _NORFLASHPLATFORMLIB_H_ */




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95394): https://edk2.groups.io/g/devel/message/95394
Mute This Topic: https://groups.io/mt/94427743/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH edk2-platforms 2/4] Platform/ARM: create local definition of NorFlashPlatformLib

2022-10-19 Thread Sunil V L
On Wed, Oct 19, 2022 at 12:35:53PM +0200, Ard Biesheuvel wrote:
> The version of NorFlashPlatformLib defined in ArmPlatformPkg will go
> away once we retire its version of NorFlashDxe, so switch to a local
> Platform/ARM version instead.
> 
> Signed-off-by: Ard Biesheuvel 
> ---
>  Platform/ARM/ARM.dec|  1 +
>  Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf|  2 +-
>  Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf |  2 +-
>  Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf |  2 +-
>  Platform/ARM/Include/Library/NorFlashPlatformLib.h  | 30 
> 
>  5 files changed, 34 insertions(+), 3 deletions(-)
> 
> diff --git a/Platform/ARM/ARM.dec b/Platform/ARM/ARM.dec
> index 5175b313f95a..cf1c8ef04742 100644
> --- a/Platform/ARM/ARM.dec
> +++ b/Platform/ARM/ARM.dec
> @@ -17,6 +17,7 @@ [Includes]
>  
>  [LibraryClasses]
>BdsLib|Include/Library/BdsLib.h
> +  NorFlashPlatformLib|Include/Library/NorFlashPlatformLib.h
>  
>  [Guids]
>gArmBootMonFsFileInfoGuid   = { 0x41e26b9c, 0xada6, 0x45b3, { 0x80, 0x8e, 
> 0x23, 0x57, 0xa3, 0x5b, 0x60, 0xd6 } }
> diff --git a/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf 
> b/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf
> index e5e5628de387..1a38bf81b349 100644
> --- a/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf
> +++ b/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf
> @@ -17,8 +17,8 @@ [Sources.common]
>NorFlashJuno.c
>  
>  [Packages]
> -  ArmPlatformPkg/ArmPlatformPkg.dec
>MdePkg/MdePkg.dec
> +  Platform/ARM/ARM.dec
>Platform/ARM/JunoPkg/ArmJuno.dec
>  
>  [LibraryClasses]
> diff --git a/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf 
> b/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
> index 74486eacd009..06068db0e4f3 100644
> --- a/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
> +++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
> @@ -18,8 +18,8 @@ [Sources.common]
>NorFlashLib.c
>  
>  [Packages]
> -  ArmPlatformPkg/ArmPlatformPkg.dec
>MdePkg/MdePkg.dec
> +  Platform/ARM/ARM.dec
>Platform/ARM/SgiPkg/SgiPlatform.dec
>  
>  [LibraryClasses]
> diff --git 
> a/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf 
> b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
> index 96bbf1e42313..54b3cb041645 100644
> --- a/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
> +++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
> @@ -19,8 +19,8 @@ [Sources.common]
>StandaloneMmNorFlashLib.c
>  
>  [Packages]
> -  ArmPlatformPkg/ArmPlatformPkg.dec
>MdePkg/MdePkg.dec
> +  Platform/ARM/ARM.dec
>Platform/ARM/SgiPkg/SgiPlatform.dec
>  
>  [LibraryClasses]
> diff --git a/Platform/ARM/Include/Library/NorFlashPlatformLib.h 
> b/Platform/ARM/Include/Library/NorFlashPlatformLib.h
> new file mode 100644
> index ..6ef5b70e9948
> --- /dev/null
> +++ b/Platform/ARM/Include/Library/NorFlashPlatformLib.h
> @@ -0,0 +1,30 @@
> +/** @file
> +
> + Copyright (c) 2011-2012, ARM Ltd. All rights reserved.
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> + **/
> +
> +#ifndef _NORFLASHPLATFORMLIB_H_
> +#define _NORFLASHPLATFORMLIB_H_
> +
> +typedef struct {
> +  UINTNDeviceBaseAddress;   // Start address of the Device Base 
> Address (DBA)
> +  UINTNRegionBaseAddress;   // Start address of one single region
> +  UINTNSize;
> +  UINTNBlockSize;
> +} NOR_FLASH_DESCRIPTION;
> +
> +EFI_STATUS
> +NorFlashPlatformInitialization (
> +  VOID
> +  );
> +
> +EFI_STATUS
> +NorFlashPlatformGetDevices (
> +  OUT NOR_FLASH_DESCRIPTION  **NorFlashDescriptions,
> +  OUT UINT32 *Count
> +  );
> +
> +#endif /* _NORFLASHPLATFORMLIB_H_ */
Hi Ard,

I had moved NorFlashPlatformLib.h to MdePkg (patch 25/34) thinking it can be 
used by
both Ovmf and real platforms. Is there an issue with that approach?

Thanks
Sunil


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95393): https://edk2.groups.io/g/devel/message/95393
Mute This Topic: https://groups.io/mt/94427743/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH edk2-platforms 1/4] Platform/ARM/BootMonFs: drop spurious dependency on ArmPlatformPkg

2022-10-19 Thread Sami Mujawar

Hi Ard,

Thank you for this patch.

Reviewed-by: Sami Mujawar 

Regards,

Sami Mujawar

On 19/10/2022 11:35 am, Ard Biesheuvel wrote:

Don't include NorFlashPlatformLib.h unnecessarily from BootMonFs, and
drop the reference to ArmPlatformPkg.dec, which isn't needed after that
either.

Signed-off-by: Ard Biesheuvel 
---
  Platform/ARM/Drivers/BootMonFs/BootMonFs.inf | 1 -
  Platform/ARM/Drivers/BootMonFs/BootMonFsImages.c | 1 -
  2 files changed, 2 deletions(-)

diff --git a/Platform/ARM/Drivers/BootMonFs/BootMonFs.inf 
b/Platform/ARM/Drivers/BootMonFs/BootMonFs.inf
index 7c2e2161869e..d9824c8b4fcd 100644
--- a/Platform/ARM/Drivers/BootMonFs/BootMonFs.inf
+++ b/Platform/ARM/Drivers/BootMonFs/BootMonFs.inf
@@ -25,7 +25,6 @@ [Sources]
BootMonFsUnsupported.c

  


  [Packages]

-  ArmPlatformPkg/ArmPlatformPkg.dec

MdePkg/MdePkg.dec

MdeModulePkg/MdeModulePkg.dec

Platform/ARM/ARM.dec

diff --git a/Platform/ARM/Drivers/BootMonFs/BootMonFsImages.c 
b/Platform/ARM/Drivers/BootMonFs/BootMonFsImages.c
index 16bef8e3b1cd..114e937b7a46 100644
--- a/Platform/ARM/Drivers/BootMonFs/BootMonFsImages.c
+++ b/Platform/ARM/Drivers/BootMonFs/BootMonFsImages.c
@@ -7,7 +7,6 @@
  **/

  


  #include 

-#include 

  #include 

  #include 

  




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95392): https://edk2.groups.io/g/devel/message/95392
Mute This Topic: https://groups.io/mt/94427742/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V4 29/34] OvmfPkg: Add Qemu NOR flash DXE driver

2022-10-19 Thread Sunil V L
On Wed, Oct 19, 2022 at 11:00:30AM +0200, Ard Biesheuvel wrote:
> On Fri, 14 Oct 2022 at 18:50, Sunil V L  wrote:
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076
> >
> > RISC-V needs NorFlashDxe driver for qemu virt machine. The
> > ArmPlatformPkg has this driver but migrating it to generic
> > package like MdeModulePkg introduces circular dependencies.
> > So, add NorFlashDxe driver in OvmfPkg which is mostly the
> > copy of the driver in ArmPlatformPkg except the support
> > for PcdNorFlashCheckBlockLocked feature. This approach also
> > allows to optimize the driver for virtual platforms.
> >
> > Cc: Ard Biesheuvel 
> > Cc: Jiewen Yao 
> > Cc: Jordan Justen 
> > Cc: Gerd Hoffmann 
> > Signed-off-by: Sunil V L 
> > ---
> >  OvmfPkg/Drivers/NorFlashDxe/NorFlashDxe.inf  |  67 ++
> >  OvmfPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf |  61 ++
> 
> I don't think we need the StandaloneMm variant here

Sure. Will remove it in the next version.

Thanks
Sunil


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95391): https://edk2.groups.io/g/devel/message/95391
Mute This Topic: https://groups.io/mt/94330865/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH 25/29] OvmfPkg: Add NorFlashQemuLib library

2022-10-19 Thread Sunil V L
On Wed, Oct 19, 2022 at 02:19:28PM +0200, Ard Biesheuvel wrote:
> On Mon, 10 Oct 2022 at 12:13, Sunil V L  wrote:
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076
> >
> > This is copied from ArmVirtPkg since it is required for
> > other architectures also.
> >
> > It also adds the instance for single flash drive which has
> > both code and variables. This is copied from SbsaQemu.
> >
> > Cc: Ard Biesheuvel 
> > Cc: Jiewen Yao 
> > Cc: Jordan Justen 
> > Cc: Gerd Hoffmann 
> > Cc: Daniel Schaefer 
> > Signed-off-by: Sunil V L 
> 
> Let's call these
> 
> QemuNorFlashPlatformLib [for the library class]
> 
> QemuNorFlashDeviceTreeLib
> QemuNorFlashStaticLib
> 
> and for the driver
> 
> QemuNorFlashDxe

Sure. I will make these changes when I send next version.
> 
> 
> i sent out some patches for edk2-platforms to eliminate the dependency
> on ArmPlatformPkg's NorFlashDxe and NorFlashPlatformLib definitions.
> Once we move everything in OvmfPkg over to these ones, we can drop the
> old one altogether.

Sure.

Thanks!
Sunil


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95390): https://edk2.groups.io/g/devel/message/95390
Mute This Topic: https://groups.io/mt/94233036/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH 25/29] OvmfPkg: Add NorFlashQemuLib library

2022-10-19 Thread Ard Biesheuvel
On Mon, 10 Oct 2022 at 12:13, Sunil V L  wrote:
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076
>
> This is copied from ArmVirtPkg since it is required for
> other architectures also.
>
> It also adds the instance for single flash drive which has
> both code and variables. This is copied from SbsaQemu.
>
> Cc: Ard Biesheuvel 
> Cc: Jiewen Yao 
> Cc: Jordan Justen 
> Cc: Gerd Hoffmann 
> Cc: Daniel Schaefer 
> Signed-off-by: Sunil V L 

Let's call these

QemuNorFlashPlatformLib [for the library class]

QemuNorFlashDeviceTreeLib
QemuNorFlashStaticLib

and for the driver

QemuNorFlashDxe


i sent out some patches for edk2-platforms to eliminate the dependency
on ArmPlatformPkg's NorFlashDxe and NorFlashPlatformLib definitions.
Once we move everything in OvmfPkg over to these ones, we can drop the
old one altogether.



> ---
>  OvmfPkg/OvmfPkg.dec   |   8 ++
>  .../NorFlashQemuLib/NorFlashQemuLib.inf   |  40 ++
>  .../NorFlashQemuUnifiedLib.inf|  30 
>  OvmfPkg/Include/Library/NorFlashPlatformLib.h |  30 
>  .../Library/NorFlashQemuLib/NorFlashQemuLib.c | 136 ++
>  .../NorFlashQemuLib/NorFlashQemuUnifiedLib.c  |  40 ++
>  6 files changed, 284 insertions(+)
>  create mode 100644 OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
>  create mode 100644 OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.inf
>  create mode 100644 OvmfPkg/Include/Library/NorFlashPlatformLib.h
>  create mode 100644 OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c
>  create mode 100644 OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.c
>
> diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
> index 7d2acc5ea0e0..0697c91c6836 100644
> --- a/OvmfPkg/OvmfPkg.dec
> +++ b/OvmfPkg/OvmfPkg.dec
> @@ -129,6 +129,10 @@ [LibraryClasses]
>#
>HardwareInfoLib|Include/Library/HardwareInfoLib.h
>
> +  ##  @libraryclass  NorFlashQemuLib
> +  #
> +  NorFlashPlatformLib|Include/Library/NorFlashPlatformLib.h
> +
>  [Guids]
>gUefiOvmfPkgTokenSpaceGuid= {0x93bb96af, 0xb9f2, 0x4eb8, 
> {0x94, 0x62, 0xe0, 0xba, 0x74, 0x56, 0x42, 0x36}}
>gEfiXenInfoGuid   = {0xd3b46f3b, 0xd441, 0x1244, 
> {0x9a, 0x12, 0x0, 0x12, 0x27, 0x3f, 0xc1, 0x4d}}
> @@ -405,6 +409,10 @@ [PcdsFixedAtBuild]
>#  check to decide whether to abort dispatch of the driver it is linked 
> into.
>gUefiOvmfPkgTokenSpaceGuid.PcdEntryPointOverrideFwCfgVarName|""|VOID*|0x68
>
> +  ## The base address and size of the FVMAIN
> +  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvBaseAddress|0|UINT64|0x71
> +  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvSize|0|UINT32|0x72
> +
>  [PcdsDynamic, PcdsDynamicEx]
>gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
>gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10
> diff --git a/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf 
> b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
> new file mode 100644
> index ..ecd8059b3508
> --- /dev/null
> +++ b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
> @@ -0,0 +1,40 @@
> +#/** @file
> +#
> +#  Component description file for NorFlashQemuLib module
> +#
> +#  Copyright (c) 2014, Linaro Ltd. All rights reserved.
> +#
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#**/
> +
> +[Defines]
> +  INF_VERSION= 0x00010005
> +  BASE_NAME  = NorFlashQemuLib
> +  FILE_GUID  = 42C30D8E-BFAD-4E77-9041-E7DAAE88DF7A
> +  MODULE_TYPE= DXE_DRIVER
> +  VERSION_STRING = 1.0
> +  LIBRARY_CLASS  = NorFlashPlatformLib
> +
> +[Sources.common]
> +  NorFlashQemuLib.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  OvmfPkg/OvmfPkg.dec
> +  EmbeddedPkg/EmbeddedPkg.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +  DebugLib
> +  UefiBootServicesTableLib
> +
> +[Protocols]
> +  gFdtClientProtocolGuid  ## CONSUMES
> +
> +[Depex]
> +  gFdtClientProtocolGuid
> +
> +[Pcd]
> +  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvBaseAddress
> +  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvSize
> diff --git a/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.inf 
> b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.inf
> new file mode 100644
> index ..91d1406fc3e7
> --- /dev/null
> +++ b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.inf
> @@ -0,0 +1,30 @@
> +#/** @file
> +#
> +#  Component description file for NorFlashQemuLib module
> +#
> +#  Copyright (c) 2014, Linaro Ltd. All rights reserved.
> +#
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#**/
> +
> +[Defines]
> +  INF_VERSION= 0x00010005
> +  BASE_NAME  = NorFlashQemuUnifiedLib
> +  FILE_GUID  = 064742F1-E531-4D7D-A154-22315889CC23
> +  MODULE_TYPE= DXE_DRIVER
> +  VERSION_STRING = 1.0
> +  LIBRARY_CLASS  = NorFlashPlatformLib
> +
> 

[edk2-devel] [PATCH edk2-platforms] Platform: Remove ComCast RDK

2022-10-19 Thread Ard Biesheuvel
The Comcast RDK platform was contributed years ago, but since then,
nobody has expressed any interest in it, leaving it to the maintainers
to keep it in shape. As it turns out, the maintainers can think of
better ways to spend their time, so let's just drop it.

Signed-off-by: Ard Biesheuvel 
---
 .../RdkBootManagerLib/RdkBootManagerLib.dec   |  44 --
 Platform/Comcast/RDKQemu/RDKQemu.dsc  | 421 --
 Platform/Comcast/RDKQemu/RDKQemu.fdf  | 122 -
 Platform/Comcast/Application/Dri/Dri.inf  |  37 --
 .../DriSecureBoot/DriSecureBoot.inf   |  37 --
 .../Application/SecureBoot/SecureBoot.inf |  37 --
 .../RdkBootManagerLib/RdkBootManagerLib.inf   |  70 ---
 .../RdkBootManagerLib/RdkBootManagerLib.h |  92 
 Platform/Comcast/Application/Dri/Dri.c|  20 -
 .../Application/DriSecureBoot/DriSecureBoot.c |  26 -
 .../Application/SecureBoot/SecureBoot.c   |  24 -
 .../Library/RdkBootManagerLib/DiskIo.c| 378 -
 .../Library/RdkBootManagerLib/HttpBoot.c  | 344 
 .../Library/RdkBootManagerLib/RdkFile.c   | 387 -
 .../Library/RdkBootManagerLib/SecureBoot.c| 517 --
 Platform/Comcast/RDKQemu/README   |  73 ---
 16 files changed, 2629 deletions(-)
 delete mode 100644 
Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec
 delete mode 100644 Platform/Comcast/RDKQemu/RDKQemu.dsc
 delete mode 100644 Platform/Comcast/RDKQemu/RDKQemu.fdf
 delete mode 100644 Platform/Comcast/Application/Dri/Dri.inf
 delete mode 100644 Platform/Comcast/Application/DriSecureBoot/DriSecureBoot.inf
 delete mode 100644 Platform/Comcast/Application/SecureBoot/SecureBoot.inf
 delete mode 100644 
Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.inf
 delete mode 100644 
Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.h
 delete mode 100644 Platform/Comcast/Application/Dri/Dri.c
 delete mode 100644 Platform/Comcast/Application/DriSecureBoot/DriSecureBoot.c
 delete mode 100644 Platform/Comcast/Application/SecureBoot/SecureBoot.c
 delete mode 100644 Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c
 delete mode 100644 Platform/Comcast/Library/RdkBootManagerLib/HttpBoot.c
 delete mode 100644 Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c
 delete mode 100644 Platform/Comcast/Library/RdkBootManagerLib/SecureBoot.c
 delete mode 100644 Platform/Comcast/RDKQemu/README

diff --git a/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec 
b/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec
deleted file mode 100644
index e83fc0e556ec..
--- a/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-#  Copyright (c) 2014-2018, Linaro Limited. All rights reserved.
-#
-#  SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-
-[Defines]
-  DEC_SPECIFICATION  = 0x00010019
-  PACKAGE_NAME   = RdkPkg
-  PACKAGE_GUID   = 2f1f2d5e-d9e1-4aa1-8eb9-fed94682e140
-  PACKAGE_VERSION= 0.1
-
-
-#
-# Include Section - list of Include Paths that are provided by this package.
-#   Comments are used for Keywords and Module Types.
-#
-# Supported Module Types:
-#  BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER 
DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
-#
-
-[Includes.common]
-#  Include# Root include for the package
-
-[Guids.common]
-  gRdkTokenSpaceGuid=  { 0x408c1892, 0xf11a, 0x40c7, { 0xaa, 0x5f, 
0x0d, 0x16, 0xc8, 0xb2, 0x52, 0x59 } }
-  gRdkGlobalVariableGuid=  { 0xc3253c90, 0xa24f, 0x4599, { 0xa6, 0x64, 
0x1f, 0x88, 0x13, 0x77, 0x8f, 0xc9 } }
-
-[PcdsFixedAtBuild.common]
-  # Rdk Library
-  gRdkTokenSpaceGuid.PcdRdkSystemPartitionName|""|VOID*|0x0203
-  gRdkTokenSpaceGuid.PcdRdkConfFileName|""|VOID*|0x0204
-  gRdkTokenSpaceGuid.PcdRdkCmdLineArgs|""|VOID*|0x0213
-  gRdkTokenSpaceGuid.PcdRdkConfFileDevicePath|L""|VOID*|0x0214
-  gRdkTokenSpaceGuid.PcdDtbAvailable|FALSE|BOOLEAN|0x00300014
-
-  # GUID of RdkSecureBootLoader
-  gRdkTokenSpaceGuid.PcdRdkSecureBootFile|{ 0x0f, 0x93, 0xc7, 0xb2, 0xef, 
0x07, 0x05, 0x43, 0xac, 0x4e, 0x1c, 0xe2, 0x08, 0x5a, 0x70, 0x31 
}|VOID*|0x0100
-
-  # GUID of RdkDri
-  gRdkTokenSpaceGuid.PcdRdkDriFile|{ 0x8a, 0xa1, 0x1b, 0x08, 0x1e, 0xd7, 0xa7, 
0x40, 0x99, 0xa9, 0xcd, 0xb8, 0x64, 0x63, 0x96, 0x6d }|VOID*|0x1000
-
-  # GUID of RdkDriSecureBootLoader
-  gRdkTokenSpaceGuid.PcdRdkDriSecureBootFile|{ 0xd7, 0xd1, 0x52, 0xdd, 0xe2, 
0x0d, 0x52, 0x45, 0x98, 0xe0, 0x8d, 0xbe, 0xe4, 0x58, 0xa5, 0x02 
}|VOID*|0x0010
diff --git a/Platform/Comcast/RDKQemu/RDKQemu.dsc 
b/Platform/Comcast/RDKQemu/RDKQemu.dsc
deleted file mode 100644
index 5d14fd8cb8d7..
--- 

[edk2-devel] [PATCH edk2-platforms] Silicon/SynQuacer: Drop dependency on NorFlashPlatformLib

2022-10-19 Thread Ard Biesheuvel
Fip006Dxe is part of the SynQuacer platform, which is its only user, and
yet, it relies on NorFlashPlatformLib to carry the platform specific NOR
geometry. This library is tied to ArmPlatformPkg's NorFlashDxe, which
will be going away, so let's stop using it.

Since the abstraction serves no purpose here, let's just merge the
library with its only user.

Signed-off-by: Ard Biesheuvel 
---
 .../SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf |  3 +-
 .../Drivers/Fip006Dxe/Fip006StandaloneMm.inf  |  2 +-
 .../NorFlashSynQuacerLib.inf  | 35 --
 .../SynQuacer/Drivers/Fip006Dxe/NorFlash.h| 14 +++-
 .../SynQuacer/Drivers/Fip006Dxe/NorFlash.c| 44 +
 .../SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.c |  7 --
 .../SynQuacer/Drivers/Fip006Dxe/NorFlashSmm.c |  7 --
 .../NorFlashSynQuacerLib/NorFlashSynQuacer.c  | 64 ---
 8 files changed, 59 insertions(+), 117 deletions(-)
 delete mode 100644 
Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacerLib.inf
 delete mode 100644 
Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacer.c

diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf 
b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf
index f91fdcfbc46d..6c7ce663d8b0 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf
+++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf
@@ -24,11 +24,11 @@ [Sources]
   NorFlashFvb.c
 
 [Packages]
-  ArmPlatformPkg/ArmPlatformPkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
   MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
   Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.dec
+  Silicon/Socionext/SynQuacer/SynQuacer.dec
 
 [LibraryClasses]
   BaseLib
@@ -40,7 +40,6 @@ [LibraryClasses]
   IoLib
   MemoryAllocationLib
   NorFlashInfoLib
-  NorFlashPlatformLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
   UefiLib
diff --git 
a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006StandaloneMm.inf 
b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006StandaloneMm.inf
index 8f4184dcbd8b..014ad791defc 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006StandaloneMm.inf
+++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006StandaloneMm.inf
@@ -30,6 +30,7 @@ [Packages]
   MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
   Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.dec
+  Silicon/Socionext/SynQuacer/SynQuacer.dec
   StandaloneMmPkg/StandaloneMmPkg.dec
 
 [LibraryClasses]
@@ -40,7 +41,6 @@ [LibraryClasses]
   MemoryAllocationLib
   MmServicesTableLib
   NorFlashInfoLib
-  NorFlashPlatformLib
   StandaloneMmDriverEntryPoint
 
 [Guids]
diff --git 
a/Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacerLib.inf
 
b/Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacerLib.inf
deleted file mode 100644
index c1ed3c4d1ca8..
--- 
a/Silicon/Socionext/SynQuacer/Library/NorFlashSynQuacerLib/NorFlashSynQuacerLib.inf
+++ /dev/null
@@ -1,35 +0,0 @@
-#/** @file
-#
-#  Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
-#  SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
-  INF_VERSION= 0x0001001A
-  BASE_NAME  = NorFlashSynQuacerLib
-  FILE_GUID  = 8279227C-C555-4D75-B439-D8A959635CDD
-  MODULE_TYPE= BASE
-  VERSION_STRING = 1.0
-  LIBRARY_CLASS  = NorFlashPlatformLib
-
-[Sources]
-  NorFlashSynQuacer.c
-
-[Packages]
-  ArmPlatformPkg/ArmPlatformPkg.dec
-  ArmPkg/ArmPkg.dec
-  MdeModulePkg/MdeModulePkg.dec
-  MdePkg/MdePkg.dec
-  Silicon/Socionext/SynQuacer/SynQuacer.dec
-
-[LibraryClasses]
-  BaseLib
-
-[FixedPcd]
-  gArmTokenSpaceGuid.PcdFdBaseAddress
-  gArmTokenSpaceGuid.PcdFdSize
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlash.h 
b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlash.h
index 3cb86ab588e0..a287b9e396fb 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlash.h
+++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlash.h
@@ -22,7 +22,6 @@
 
 #include 
 #include 
-#include 
 
 #include "Fip006Reg.h"
 
@@ -291,6 +290,19 @@ NorFlashReadID (
   OUT UINT8   JedecId[3]
   );
 
+typedef struct {
+  UINTNDeviceBaseAddress;   // Start address of the Device Base 
Address (DBA)
+  UINTNRegionBaseAddress;   // Start address of one single region
+  UINTNSize;
+  UINTNBlockSize;
+} NOR_FLASH_DESCRIPTION;
+
+EFI_STATUS
+NorFlashPlatformGetDevices (
+  OUT NOR_FLASH_DESCRIPTION   **NorFlashDevices,
+  OUT UINT32  *Count
+  );
+
 #define SPINOR_SR_WIP BIT0  // Write in 

[edk2-devel] [PATCH edk2-platforms 3/4] Platform/ARM: clone NorFlashDxe from ArmPlatformPkg

2022-10-19 Thread Ard Biesheuvel
The ArmPlatformPkg version of NorFlashDxe and NorFlashStandaloneMm will
be going away, so clone them into Platform/ARM where the ARM platforms
that rely on this driver can keep using it.

Other than updating the INF version, refreshing the file GUIDs and
reorganizing the various INF sections, no changes have been made to the
driver.

Signed-off-by: Ard Biesheuvel 
---
 Platform/ARM/ARM.dec  |   4 +
 Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf  |  71 ++
 Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf |  66 ++
 Platform/ARM/Drivers/NorFlashDxe/NorFlash.h   | 422 +
 Platform/ARM/Drivers/NorFlashDxe/NorFlash.c   | 991 

 Platform/ARM/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c | 123 +++
 Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c| 506 ++
 Platform/ARM/Drivers/NorFlashDxe/NorFlashFvb.c| 777 +++
 Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c   | 383 
 9 files changed, 3343 insertions(+)

diff --git a/Platform/ARM/ARM.dec b/Platform/ARM/ARM.dec
index cf1c8ef04742..be7e6dc83fde 100644
--- a/Platform/ARM/ARM.dec
+++ b/Platform/ARM/ARM.dec
@@ -20,4 +20,8 @@ [LibraryClasses]
   NorFlashPlatformLib|Include/Library/NorFlashPlatformLib.h
 
 [Guids]
+  gPlatformArmTokenSpaceGuid  = { 0x7a5e0def, 0xd3c3, 0x44f3, { 0x8d, 0x69, 
0x70, 0xfc, 0x8f, 0xd6, 0x4f, 0xdf } }
   gArmBootMonFsFileInfoGuid   = { 0x41e26b9c, 0xada6, 0x45b3, { 0x80, 0x8e, 
0x23, 0x57, 0xa3, 0x5b, 0x60, 0xd6 } }
+
+[PcdsFeatureFlag.common]
+  
gPlatformArmTokenSpaceGuid.PcdNorFlashCheckBlockLocked|FALSE|BOOLEAN|0x001
diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf 
b/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf
new file mode 100644
index ..cdf1f5c27f35
--- /dev/null
+++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf
@@ -0,0 +1,71 @@
+#/** @file
+#
+#  Component description file for NorFlashDxe module
+#
+#  Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#**/
+
+[Defines]
+  INF_VERSION= 1.29
+  BASE_NAME  = NorFlashDxe
+  FILE_GUID  = de6ae758-d662-4e17-a97c-4c5964da4c41
+  MODULE_TYPE= DXE_RUNTIME_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= NorFlashInitialise
+
+[Sources.common]
+  NorFlash.c
+  NorFlash.h
+  NorFlashBlockIoDxe.c
+  NorFlashDxe.c
+  NorFlashFvb.c
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  Platform/ARM/ARM.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+  DxeServicesTableLib
+  HobLib
+  IoLib
+  NorFlashPlatformLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+  UefiLib
+  UefiRuntimeLib
+
+[Guids]
+  gEdkiiNvVarStoreFormattedGuid ## PRODUCES ## PROTOCOL
+  gEfiAuthenticatedVariableGuid
+  gEfiEventVirtualAddressChangeGuid
+  gEfiSystemNvDataFvGuid
+  gEfiVariableGuid
+
+[Protocols]
+  gEfiBlockIoProtocolGuid
+  gEfiDevicePathProtocolGuid
+  gEfiDiskIoProtocolGuid
+  gEfiFirmwareVolumeBlockProtocolGuid
+
+[Pcd.common]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
+
+  gPlatformArmTokenSpaceGuid.PcdNorFlashCheckBlockLocked
+
+[Depex]
+  gEfiCpuArchProtocolGuid
diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf 
b/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf
new file mode 100644
index ..001f281220f2
--- /dev/null
+++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf
@@ -0,0 +1,66 @@
+#/** @file
+#
+#  Component description file for NorFlashStandaloneMm module
+#
+#  Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.
+#  Copyright (c) 2020, Linaro, Ltd. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#**/
+
+[Defines]
+  INF_VERSION= 1.29
+  BASE_NAME  = NorFlashStandaloneMm
+  FILE_GUID  = a87c67d2-f183-415c-993d-11431fc478ee
+  MODULE_TYPE= MM_STANDALONE
+  VERSION_STRING = 1.0
+  PI_SPECIFICATION_VERSION   = 0x00010032
+  ENTRY_POINT= NorFlashInitialise
+
+[Sources.common]
+  NorFlash.c
+  NorFlash.h
+  NorFlashFvb.c
+  NorFlashStandaloneMm.c
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  

[edk2-devel] [PATCH edk2-platforms 4/4] Platform/ARM: switch to local version of NorFlashDxe drivers

2022-10-19 Thread Ard Biesheuvel
Drop the dependency on the ArmPlatformPkg version of NorFlashDxe and
NorFlashStandaloneMm, which will be going away soon. Instead, depend on
the local version under Platform/ARM.

Signed-off-by: Ard Biesheuvel 
---
 Platform/ARM/SgiPkg/SgiPlatform.dsc.inc  | 2 +-
 Platform/ARM/SgiPkg/SgiPlatformMm.dsc.inc| 2 +-
 Platform/ARM/JunoPkg/ArmJuno.dsc | 2 +-
 Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc| 2 +-
 Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc | 2 +-
 Platform/ARM/JunoPkg/ArmJuno.fdf | 2 +-
 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf | 2 +-
 Platform/ARM/SgiPkg/SgiPlatform.fdf  | 2 +-
 Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.fdf| 2 +-
 Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc 
b/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc
index 2f5dadfaefc6..81764368a0b7 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc
@@ -256,7 +256,7 @@ [Components.common]
 !if $(ENABLE_GOP) == TRUE
   ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
 !endif
-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
+  Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf
   EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
   EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
   MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
diff --git a/Platform/ARM/SgiPkg/SgiPlatformMm.dsc.inc 
b/Platform/ARM/SgiPkg/SgiPlatformMm.dsc.inc
index 68fc3ad93a5f..ae0ff7247a6a 100644
--- a/Platform/ARM/SgiPkg/SgiPlatformMm.dsc.inc
+++ b/Platform/ARM/SgiPkg/SgiPlatformMm.dsc.inc
@@ -122,7 +122,7 @@ [Components.common]
 [Components.AARCH64]
   StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf
 !if $(SECURE_STORAGE_ENABLE) == TRUE
-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf
+  Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf
   
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf {
 
diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc b/Platform/ARM/JunoPkg/ArmJuno.dsc
index f7ce397633f6..a00b866c5e9a 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.dsc
+++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
@@ -277,7 +277,7 @@ [Components.common]
   MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
 
   ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
+  Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf
   ArmPkg/Drivers/TimerDxe/TimerDxe.inf
   ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf
 
diff --git a/Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc 
b/Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc
index cb9d2d4287e3..9c5e78d6275d 100644
--- a/Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc
+++ b/Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc
@@ -229,7 +229,7 @@ [Components.common]
   MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
 
   ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
+  Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf
   ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
   ArmPkg/Drivers/TimerDxe/TimerDxe.inf
   ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf
diff --git a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc 
b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
index 8561c21fab5a..dc081794cf98 100644
--- a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
+++ b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
@@ -289,7 +289,7 @@ [Components.common]
   }
 
   ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
+  Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf
   ArmPkg/Drivers/TimerDxe/TimerDxe.inf
 !ifdef EDK2_ENABLE_PL111
   ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
diff --git a/Platform/ARM/JunoPkg/ArmJuno.fdf b/Platform/ARM/JunoPkg/ArmJuno.fdf
index c9d51c65ffdb..fca5a78cee6c 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.fdf
+++ b/Platform/ARM/JunoPkg/ArmJuno.fdf
@@ -136,7 +136,7 @@ [FV.FvMain]
   INF ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf
 
   # NOR Flash driver
-  INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
+  INF Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf
 
   # Versatile Express FileSystem
   INF Platform/ARM/Drivers/BootMonFs/BootMonFs.inf
diff --git a/Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf 
b/Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf
index c1c24b747fa5..653aae8285a6 100644
--- a/Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf
+++ b/Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf
@@ -50,7 +50,7 @@ [FV.FVMAIN_COMPACT]
 
   INF StandaloneMmPkg/Core/StandaloneMmCore.inf
 !if $(SECURE_STORAGE_ENABLE) == TRUE
-  INF 

[edk2-devel] [PATCH edk2-platforms 2/4] Platform/ARM: create local definition of NorFlashPlatformLib

2022-10-19 Thread Ard Biesheuvel
The version of NorFlashPlatformLib defined in ArmPlatformPkg will go
away once we retire its version of NorFlashDxe, so switch to a local
Platform/ARM version instead.

Signed-off-by: Ard Biesheuvel 
---
 Platform/ARM/ARM.dec|  1 +
 Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf|  2 +-
 Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf |  2 +-
 Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf |  2 +-
 Platform/ARM/Include/Library/NorFlashPlatformLib.h  | 30 

 5 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/Platform/ARM/ARM.dec b/Platform/ARM/ARM.dec
index 5175b313f95a..cf1c8ef04742 100644
--- a/Platform/ARM/ARM.dec
+++ b/Platform/ARM/ARM.dec
@@ -17,6 +17,7 @@ [Includes]
 
 [LibraryClasses]
   BdsLib|Include/Library/BdsLib.h
+  NorFlashPlatformLib|Include/Library/NorFlashPlatformLib.h
 
 [Guids]
   gArmBootMonFsFileInfoGuid   = { 0x41e26b9c, 0xada6, 0x45b3, { 0x80, 0x8e, 
0x23, 0x57, 0xa3, 0x5b, 0x60, 0xd6 } }
diff --git a/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf 
b/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf
index e5e5628de387..1a38bf81b349 100644
--- a/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf
+++ b/Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf
@@ -17,8 +17,8 @@ [Sources.common]
   NorFlashJuno.c
 
 [Packages]
-  ArmPlatformPkg/ArmPlatformPkg.dec
   MdePkg/MdePkg.dec
+  Platform/ARM/ARM.dec
   Platform/ARM/JunoPkg/ArmJuno.dec
 
 [LibraryClasses]
diff --git a/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf 
b/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
index 74486eacd009..06068db0e4f3 100644
--- a/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
+++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
@@ -18,8 +18,8 @@ [Sources.common]
   NorFlashLib.c
 
 [Packages]
-  ArmPlatformPkg/ArmPlatformPkg.dec
   MdePkg/MdePkg.dec
+  Platform/ARM/ARM.dec
   Platform/ARM/SgiPkg/SgiPlatform.dec
 
 [LibraryClasses]
diff --git 
a/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf 
b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
index 96bbf1e42313..54b3cb041645 100644
--- a/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
+++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
@@ -19,8 +19,8 @@ [Sources.common]
   StandaloneMmNorFlashLib.c
 
 [Packages]
-  ArmPlatformPkg/ArmPlatformPkg.dec
   MdePkg/MdePkg.dec
+  Platform/ARM/ARM.dec
   Platform/ARM/SgiPkg/SgiPlatform.dec
 
 [LibraryClasses]
diff --git a/Platform/ARM/Include/Library/NorFlashPlatformLib.h 
b/Platform/ARM/Include/Library/NorFlashPlatformLib.h
new file mode 100644
index ..6ef5b70e9948
--- /dev/null
+++ b/Platform/ARM/Include/Library/NorFlashPlatformLib.h
@@ -0,0 +1,30 @@
+/** @file
+
+ Copyright (c) 2011-2012, ARM Ltd. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ **/
+
+#ifndef _NORFLASHPLATFORMLIB_H_
+#define _NORFLASHPLATFORMLIB_H_
+
+typedef struct {
+  UINTNDeviceBaseAddress;   // Start address of the Device Base 
Address (DBA)
+  UINTNRegionBaseAddress;   // Start address of one single region
+  UINTNSize;
+  UINTNBlockSize;
+} NOR_FLASH_DESCRIPTION;
+
+EFI_STATUS
+NorFlashPlatformInitialization (
+  VOID
+  );
+
+EFI_STATUS
+NorFlashPlatformGetDevices (
+  OUT NOR_FLASH_DESCRIPTION  **NorFlashDescriptions,
+  OUT UINT32 *Count
+  );
+
+#endif /* _NORFLASHPLATFORMLIB_H_ */
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95384): https://edk2.groups.io/g/devel/message/95384
Mute This Topic: https://groups.io/mt/94427743/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH edk2-platforms 1/4] Platform/ARM/BootMonFs: drop spurious dependency on ArmPlatformPkg

2022-10-19 Thread Ard Biesheuvel
Don't include NorFlashPlatformLib.h unnecessarily from BootMonFs, and
drop the reference to ArmPlatformPkg.dec, which isn't needed after that
either.

Signed-off-by: Ard Biesheuvel 
---
 Platform/ARM/Drivers/BootMonFs/BootMonFs.inf | 1 -
 Platform/ARM/Drivers/BootMonFs/BootMonFsImages.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/Platform/ARM/Drivers/BootMonFs/BootMonFs.inf 
b/Platform/ARM/Drivers/BootMonFs/BootMonFs.inf
index 7c2e2161869e..d9824c8b4fcd 100644
--- a/Platform/ARM/Drivers/BootMonFs/BootMonFs.inf
+++ b/Platform/ARM/Drivers/BootMonFs/BootMonFs.inf
@@ -25,7 +25,6 @@ [Sources]
   BootMonFsUnsupported.c
 
 [Packages]
-  ArmPlatformPkg/ArmPlatformPkg.dec
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
   Platform/ARM/ARM.dec
diff --git a/Platform/ARM/Drivers/BootMonFs/BootMonFsImages.c 
b/Platform/ARM/Drivers/BootMonFs/BootMonFsImages.c
index 16bef8e3b1cd..114e937b7a46 100644
--- a/Platform/ARM/Drivers/BootMonFs/BootMonFsImages.c
+++ b/Platform/ARM/Drivers/BootMonFs/BootMonFsImages.c
@@ -7,7 +7,6 @@
 **/
 
 #include 
-#include 
 #include 
 #include 
 
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95383): https://edk2.groups.io/g/devel/message/95383
Mute This Topic: https://groups.io/mt/94427742/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH edk2-platforms 0/4] Platform/ARM: clone ArmPlatformPkg's NorFlashDxe

2022-10-19 Thread Ard Biesheuvel
NorFlashDxe in ArmPlatformPkg is used in two different ways:
- by emulated QEMU based platforms that use its NOR flash emulation
  which is based on versatile express
- by physical ARM platforms under Platform/ARM in edk2-platforms.

In order to improve support for the former use case, let's first split
off the latter and give them their own version of the driver.

Cc: Leif Lindholm 
Cc: Thomas Abraham 
Cc: Sami Mujawar 

Ard Biesheuvel (4):
  Platform/ARM/BootMonFs: drop spurious dependency on ArmPlatformPkg
  Platform/ARM: create local definition of NorFlashPlatformLib
  Platform/ARM: clone NorFlashDxe from ArmPlatformPkg
  Platform/ARM: switch to local version of NorFlashDxe drivers

 Platform/ARM/ARM.dec|   5 +
 Platform/ARM/SgiPkg/SgiPlatform.dsc.inc |   2 +-
 Platform/ARM/SgiPkg/SgiPlatformMm.dsc.inc   |   2 +-
 Platform/ARM/JunoPkg/ArmJuno.dsc|   2 +-
 Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc   |   2 +-
 Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc|   2 +-
 Platform/ARM/JunoPkg/ArmJuno.fdf|   2 +-
 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf|   2 +-
 Platform/ARM/SgiPkg/SgiPlatform.fdf |   2 +-
 Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.fdf   |   2 +-
 Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf|   2 +-
 Platform/ARM/Drivers/BootMonFs/BootMonFs.inf|   1 -
 Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf|  71 ++
 Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf   |  66 ++
 Platform/ARM/JunoPkg/Library/NorFlashJunoLib/NorFlashJunoLib.inf|   2 +-
 Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf |   2 +-
 Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf |   2 +-
 Platform/ARM/Drivers/NorFlashDxe/NorFlash.h | 422 
+
 Platform/ARM/Include/Library/NorFlashPlatformLib.h  |  30 +
 Platform/ARM/Drivers/BootMonFs/BootMonFsImages.c|   1 -
 Platform/ARM/Drivers/NorFlashDxe/NorFlash.c | 991 

 Platform/ARM/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c   | 123 +++
 Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c  | 506 
++
 Platform/ARM/Drivers/NorFlashDxe/NorFlashFvb.c  | 777 
+++
 Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c | 383 

 25 files changed, 3387 insertions(+), 15 deletions(-)
 create mode 100644 Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf
 create mode 100644 Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf
 create mode 100644 Platform/ARM/Drivers/NorFlashDxe/NorFlash.h
 create mode 100644 Platform/ARM/Include/Library/NorFlashPlatformLib.h
 create mode 100644 Platform/ARM/Drivers/NorFlashDxe/NorFlash.c
 create mode 100644 Platform/ARM/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c
 create mode 100644 Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c
 create mode 100644 Platform/ARM/Drivers/NorFlashDxe/NorFlashFvb.c
 create mode 100644 Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c

-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95382): https://edk2.groups.io/g/devel/message/95382
Mute This Topic: https://groups.io/mt/94427741/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [tianocore-docs][PATCH V2 2/2] edk II C Coding Standard: Updates 4.2 and 4.3 sections

2022-10-19 Thread Attar, AbdulLateef (Abdul Lateef) via groups.io
[AMD Official Use Only - General]

Looks good to me
Reviewed-by: Abdul Lateef Attar

-Original Message-
From: Chang, Abner 
Sent: 15 October 2022 17:18
To: devel@edk2.groups.io
Cc: Ray Ni ; Michael D Kinney ; 
Sunil V L ; Attar, AbdulLateef (Abdul Lateef) 
; Leif Lindholm 
Subject: [tianocore-docs][PATCH V2 2/2] edk II C Coding Standard: Updates 4.2 
and 4.3 sections

From: Abner Chang 

Updates 4.2 Directory names and 4.3 file names for the guidelines of module 
directory and file naming.

PR: 
https://github.com/tianocore-docs/edk2-CCodingStandardsSpecification/pull/2/files

Signed-off-by: Abner Chang 
Cc: Ray Ni 
Cc: Michael D Kinney 
Cc: Sunil V L 
Cc: Abdul Lateef Attar 
Cc: Leif Lindholm 
---
 4_naming_conventions/42_directory_names.md | 101 +++
 4_naming_conventions/43_file_names.md  | 108 -
 2 files changed, 208 insertions(+), 1 deletion(-)

diff --git a/4_naming_conventions/42_directory_names.md 
b/4_naming_conventions/42_directory_names.md
index 766ccb1..959a3c9 100644
--- a/4_naming_conventions/42_directory_names.md
+++ b/4_naming_conventions/42_directory_names.md
@@ -2,6 +2,7 @@
   4.2 Directory Names

   Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
+  Copyright (c) 2022, Intel Corporation. All rights reserved.

   Redistribution and use in source (original document form) and 'compiled'
   forms (converted to PDF, epub, HTML and other formats) with or without @@ 
-28,3 +29,103 @@
   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 -->
+
+## 4.2 Directory Names
+Below sections are the directory naming guidelines for EDK II modules.
+The guidelines are not just considering the the uniformity of directory
+naming, but it also provides the flexibility of directory name
+construction for the scenario of different EDK II module designs; such
+as the support for multiple processor architectures and vendors. It may
+require the further discussions between EDK II maintainers and contributors in 
order to determine the best naming of the EDK II module directory.
+
+ 4.2.1 EDKII package directory
+
+```
+Pkg
+
+REQUIRED  *
+```
+
+ 4.2.2 EDKII Module directory
+
+* The guideline below is applied to all CPU architectures support, specific 
CPU architecture and vendors support, or the implementation is shared by 
certain CPU archs:
+```
+[[]]
+  or
+[/[/]]
+
+ REQUIRED*
+   REQUIREDBase, Sec, Pei, Dxe, DxeRuntime, Mm, 
StandaloneMm, Smm,
+  Uefi.
+ OPTIONALThe  is represented with a BNF,
+   ::='Ia32' | 'X64' | 'Arm' | 'AArch64' | 
'RiscV64' |
+'LoongArch64' | 'Ebc'
+   ::= []*
+
+  Example: Ia32X64Arm or RiscV64LoongArch64
+
+  OPTIONAL*
+
+Example:
+   - SmbiosDxe/
+   - CpuDxe/# First implementation of CpuDxe.
+   - CpuDxeIa32X64Amd/  # Ia32 and X64 AMD specific implementation.
+   - CpuDxe/RiscV64/# RiscV64 specific implementation.
+   /# Common files for the RiscV64 and other archs.
+   - CpuDxe/Ia32X64/Amd/# Ia32 and X64 AMD specific implementation.
+   /# Common files for Ia32 and X64 archs.
+   /ArmAArch64/ # Arm and AArch64 implementation of CpuDxe.
+   /# Common files for the Arm, AArch64, Ia32 and 
X64.
+```
+
+* If the implementation does not have any shared code between phases (e.g.
+MdeModulePkg/Universal/PCD). The guideline below is applied to all CPU 
architectures support, specific CPU architecture and vendors support, or the 
implementation is shared by certain CPU archs:
+
+```
+/[/[/]]
+
+ REQUIRED*
+   REQUIREDBase, Sec, Pei, Dxe, DxeRuntime, Mm, 
StandaloneMm, Smm,
+  Uefi.
+ OPTIONALThe  is represented with a BNF,
+   ::='Ia32' | 'X64' | 'Arm' | 'AArch64' | 
'RiscV64' |
+'LoongArch64' | 'Ebc'
+   ::= []*
+
+  Example: Ia32X64Arm or RiscV64LoongArch64
+  OPTIONAL*
+Example:
+   Pcd/Dxe/
+```
+
+ 4.2.2 EDKII Library directory
+```
+[[]][]
+  or
+[]/[[/]]
+
+ REQUIRED Base, Sec, Pei, Dxe, DxeRuntime, Mm,
+ StandaloneMm, Smm, Uefi.
+   OPTIONAL The  is represented with a BNF,
+  ::='Ia32' | 'X64' | 'Arm' | 
'AArch64' | 'RiscV64' |
+   'LoongArch64' | 'Ebc'
+  ::= []*
+
+ Example: Ia32X64Arm or RiscV64LoongArch64
+OPTIONAL *
+  REQUIRED *
+OPTIONAL * (Typically name of PPI, Protocol, 
LibraryClass
+

Re: [edk2-devel] Python368.efi failed to run in shell environment

2022-10-19 Thread Yoshinoya
Hi, JP:
I followed Py368ReadMe.txt to compile Python368 app in Ubuntu 22.04 environment.
The steps is:
1. execute srcprep.py
2. add this module to AppPkg/AppPkg.dsc
3. execute "build -a X64 -p AppPkg\AppPkg.dsc"


but it failed, the tips is:
In file included from 
/home/yoshi/edk2/AppPkg/Applications/Python/Python-3.6.8/Modules/_bisectmodule.c:7:
/home/yoshi/edk2/AppPkg/Applications/Python/Python-3.6.8/Include/Python.h:44:10:
 fatal error: crypt.h: No such file or directory
   44 | #include 
  |  ^
compilation terminated.






Thanks










At 2022-10-18 17:04:42, "Jayaprakash, N"  wrote:

Hi Yoshinoya,

 

Could you provide some details about the platform on which you are trying to 
run?

What tools you used for building the Python interpreter?

 

If you could raise a bug with relevant details, we can take a look at this 
issue.

 

Regards,

JP

 

From: Yoshinoya 
Sent: 11 October 2022 15:51
To: Kinney, Michael D 
Cc: devel@edk2.groups.io; Jayaprakash, N 
Subject: Re:RE: [edk2-devel] Python368.efi failed to run in shell environment

 

Hi, JP:

It seems PyImport_ImportModule("encoding.utf_8") failed.

Do you have any suggestions?

 

THank you very much!

 

best wishes,

 

 

 

At 2022-10-06 00:28:46, "Kinney, Michael D"  wrote:

+JP

 

Mike

 

From:devel@edk2.groups.io  On Behalf Of Yoshinoya
Sent: Wednesday, October 5, 2022 4:32 AM
To:devel@edk2.groups.io
Subject: [edk2-devel] Python368.efi failed to run in shell environment

 

Hi

I tried to run Python368.efi in shell environment.

but failed, the tips was;

Fatal Python error: Py_Initialize: can't initialize sys standard streams

 

Does anybody have ever met this error?

 

Python368.efi is a sample python app in AppPkg\Applications\Python\Python-3.6.8

 

Thanks



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95381): https://edk2.groups.io/g/devel/message/95381
Mute This Topic: https://groups.io/mt/94136700/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 resend 10/11] ArmVirtPkg/QemuVirtMemInfoLib: use HOB not PCD to record the memory size

2022-10-19 Thread Ard Biesheuvel
Due to the way we inherited the formerly fixed PCDs to describe the
system memory base and size from ArmPlatformPkg, we ended up with a
MemoryInit PEIM that relies on dynamic PCDs to communicate the size of
system memory between the constructor of one of its library dependencies
and the core module. This is unnecessary, and forces us to incorporate
the PCD PEIM as well, for no good reason. So instead, let's use a HOB.

Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirtPkg.dec|  1 +
 ArmVirtPkg/ArmVirtQemu.dsc   |  6 
++--
 ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c | 14 
++--
 ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf   |  1 +
 ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c   | 35 
++--
 ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf |  5 
++-
 ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf  |  8 
++---
 ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibConstructor.c | 30 
++---
 8 files changed, 75 insertions(+), 25 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
index 4e165f6cd845..89d21ec3a364 100644
--- a/ArmVirtPkg/ArmVirtPkg.dec
+++ b/ArmVirtPkg/ArmVirtPkg.dec
@@ -32,6 +32,7 @@ [Guids.common]
   gArmVirtTokenSpaceGuid = { 0x0B6F5CA7, 0x4F53, 0x445A, { 0xB7, 0x6E, 0x2E, 
0x36, 0x5B, 0x80, 0x63, 0x66 } }
   gEarlyPL011BaseAddressGuid   = { 0xB199DEA9, 0xFD5C, 0x4A84, { 0x80, 
0x82, 0x2F, 0x41, 0x70, 0x78, 0x03, 0x05 } }
   gEarly16550UartBaseAddressGuid   = { 0xea67ca3e, 0x1f54, 0x436b, { 0x97, 
0x88, 0xd4, 0xeb, 0x29, 0xc3, 0x42, 0x67 } }
+  gArmVirtSystemMemorySizeGuid = { 0x504eccb9, 0x1bf0, 0x4420, { 0x86, 
0x5d, 0xdc, 0x66, 0x06, 0xd4, 0x13, 0xbf } }
 
   gArmVirtVariableGuid   = { 0x50bea1e5, 0xa2c5, 0x46e9, { 0x9b, 0x3a, 0x59, 
0x59, 0x65, 0x16, 0xb0, 0x0a } }
 
diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index c3d264077bce..43e19f605084 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -220,6 +220,9 @@ [PcdsFixedAtBuild.common]
   # Shadowing PEI modules is absolutely pointless when the NOR flash is 
emulated
   gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot|FALSE
 
+  # System Memory Size -- 128 MB initially, actual size will be fetched from DT
+  gArmTokenSpaceGuid.PcdSystemMemorySize|0x800
+
 [PcdsFixedAtBuild.AARCH64]
   # Clearing BIT0 in this PCD prevents installing a 32-bit SMBIOS entry point,
   # if the entry point version is >= 3.0. AARCH64 OSes cannot assume the
@@ -236,9 +239,6 @@ [PcdsDynamicDefault.common]
   #  enumeration to complete before installing ACPI tables.
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
 
-  # System Memory Size -- 1 MB initially, actual size will be fetched from DT
-  gArmTokenSpaceGuid.PcdSystemMemorySize|0x0010
-
   gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|0x0
   gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|0x0
   gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum|0x0
diff --git 
a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c 
b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
index 98d90ad4200d..72e5c65af79e 100644
--- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
+++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
@@ -52,10 +52,19 @@ MemoryPeim (
 {
   EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttributes;
   UINT64   SystemMemoryTop;
+  UINT64   SystemMemorySize;
+  VOID *Hob;
 
   // Ensure PcdSystemMemorySize has been set
   ASSERT (PcdGet64 (PcdSystemMemorySize) != 0);
 
+  SystemMemorySize = PcdGet64 (PcdSystemMemorySize);
+
+  Hob = GetFirstGuidHob ();
+  if (Hob != NULL) {
+SystemMemorySize = *(UINT64 *)GET_GUID_HOB_DATA (Hob);
+  }
+
   //
   // Now, the permanent memory has been installed, we can call AllocatePages()
   //
@@ -66,8 +75,7 @@ MemoryPeim (
 EFI_RESOURCE_ATTRIBUTE_TESTED
 );
 
-  SystemMemoryTop = PcdGet64 (PcdSystemMemoryBase) +
-PcdGet64 (PcdSystemMemorySize);
+  SystemMemoryTop = PcdGet64 (PcdSystemMemoryBase) + SystemMemorySize;
 
   if (SystemMemoryTop - 1 > MAX_ALLOC_ADDRESS) {
 BuildResourceDescriptorHob (
@@ -87,7 +95,7 @@ MemoryPeim (
   EFI_RESOURCE_SYSTEM_MEMORY,
   ResourceAttributes,
   PcdGet64 (PcdSystemMemoryBase),
-  PcdGet64 (PcdSystemMemorySize)
+  SystemMemorySize
   );
   }
 
diff --git 
a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf 
b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf
index 21327f79f4b9..48d9c66b22db 100644
--- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf
+++ 

[edk2-devel] [PATCH v3 resend 11/11] ArmVirtPkg/ArmVirtQemu: omit PCD PEIM unless TPM support is enabled

2022-10-19 Thread Ard Biesheuvel
The TPM discovery code relies on a dynamic PCD to communicate the TPM
base address to other components. But no other code relies on dynamic
PCDs in the PEI phase so let's drop the PCD PEIM when TPM support is not
enabled.

Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirtQemu.dsc | 22 +++-
 ArmVirtPkg/ArmVirtQemu.fdf |  2 +-
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 43e19f605084..842a298e0435 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -287,10 +287,15 @@ [PcdsDynamicDefault.common]
   #
   # TPM2 support
   #
-  gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress|0x0
 !if $(TPM2_ENABLE) == TRUE
+  gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress|0x0
   gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
   gEfiSecurityPkgTokenSpaceGuid.PcdTpm2HashMask|0
+!else
+[PcdsPatchableInModule]
+  # make this PCD patchable instead of dynamic when TPM support is not enabled
+  # this permits setting the PCD in unreachable code without pulling in 
dynamic PCD support
+  gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress|0x0
 !endif
 
 [PcdsDynamicHii]
@@ -303,6 +308,13 @@ [PcdsDynamicHii]
 
   
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|5
 
+[LibraryClasses.common.PEI_CORE, LibraryClasses.common.PEIM]
+!if $(TPM2_ENABLE) == TRUE
+  PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
+!else
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+!endif
+
 

 #
 # Components Section - list of all EDK II Modules needed by this Platform
@@ -314,10 +326,6 @@ [Components.common]
   #
   ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf
   MdeModulePkg/Core/Pei/PeiMain.inf
-  MdeModulePkg/Universal/PCD/Pei/Pcd.inf {
-
-  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
-  }
   ArmPlatformPkg/PlatformPei/PlatformPeim.inf
   ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf {
 
@@ -328,6 +336,10 @@ [Components.common]
   ArmPkg/Drivers/CpuPei/CpuPei.inf
 
 !if $(TPM2_ENABLE) == TRUE
+  MdeModulePkg/Universal/PCD/Pei/Pcd.inf {
+
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  }
   MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf {
 
   
ResetSystemLib|ArmVirtPkg/Library/ArmVirtPsciResetSystemPeiLib/ArmVirtPsciResetSystemPeiLib.inf
diff --git a/ArmVirtPkg/ArmVirtQemu.fdf b/ArmVirtPkg/ArmVirtQemu.fdf
index c85e36b185d3..764f652afd0e 100644
--- a/ArmVirtPkg/ArmVirtQemu.fdf
+++ b/ArmVirtPkg/ArmVirtQemu.fdf
@@ -109,10 +109,10 @@ [FV.FVMAIN_COMPACT]
   INF ArmPlatformPkg/PlatformPei/PlatformPeim.inf
   INF ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf
   INF ArmPkg/Drivers/CpuPei/CpuPei.inf
-  INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
   INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
 
 !if $(TPM2_ENABLE) == TRUE
+  INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
   INF MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
   INF OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
   INF SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95379): https://edk2.groups.io/g/devel/message/95379
Mute This Topic: https://groups.io/mt/94427024/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 resend 09/11] ArmVirtPkg/ArmVirtQemu: avoid shadowing PEIMs unless necessary

2022-10-19 Thread Ard Biesheuvel
Some PEIMs register for shadow execution explicitly, but others exist
that don't care and can happily execute in place. Since the emulated NOR
flash is just RAM, shadowing has no performance benefits so let's only
do this if needed.

Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirtQemu.dsc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index de34481673ea..c3d264077bce 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -217,6 +217,9 @@ [PcdsFixedAtBuild.common]
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|3
   gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x2
 
+  # Shadowing PEI modules is absolutely pointless when the NOR flash is 
emulated
+  gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot|FALSE
+
 [PcdsFixedAtBuild.AARCH64]
   # Clearing BIT0 in this PCD prevents installing a 32-bit SMBIOS entry point,
   # if the entry point version is >= 3.0. AARCH64 OSes cannot assume the
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95377): https://edk2.groups.io/g/devel/message/95377
Mute This Topic: https://groups.io/mt/94427021/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 resend 07/11] ArmVirtPkg/ArmVirtQemu: enable initial ID map at early boot

2022-10-19 Thread Ard Biesheuvel
Now that we have all the pieces in place, switch the AArch64 version of
ArmVirtQemu to a mode where the first thing it does out of reset is
enable a preliminary ID map that covers the NOR flash and sufficient
DRAM to create the UEFI page tables as usual.

The advantage of this is that no manipulation of memory occurs any
longer before the MMU is enabled, which removes the need for explicit
coherency management, which is cumbersome and bad for performance.

It also means we no longer need to build all components that may execute
with the MMU off (including BASE libraries) with strict alignment.

Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirtQemu.dsc | 17 ++---
 ArmVirtPkg/ArmVirtQemu.fdf |  2 +-
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 302c0d2a4e29..21a321e35794 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -63,8 +63,6 @@ [LibraryClasses.common]
   
QemuFwCfgSimpleParserLib|OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParserLib.inf
   
QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.inf
 
-  
ArmPlatformLib|ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf
-
   TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
   NorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
 
@@ -92,6 +90,12 @@ [LibraryClasses.common]
   
TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLibNull/PeiDxeTpmPlatformHierarchyLib.inf
 !endif
 
+[LibraryClasses.AARCH64]
+  ArmPlatformLib|ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.inf
+
+[LibraryClasses.ARM]
+  
ArmPlatformLib|ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf
+
 [LibraryClasses.common.PEIM]
   
ArmVirtMemInfoLib|ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf
 
@@ -112,6 +116,8 @@ [LibraryClasses.common.UEFI_DRIVER]
   UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
 
 [BuildOptions]
+  GCC:*_*_AARCH64_CC_XIPFLAGS = -mno-strict-align
+
 !include NetworkPkg/NetworkBuildOptions.dsc.inc
 
 

@@ -310,7 +316,12 @@ [Components.common]
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
   }
   ArmPlatformPkg/PlatformPei/PlatformPeim.inf
-  ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf
+  ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf {
+
+!if $(ARCH) == AARCH64
+  ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
+!endif
+  }
   ArmPkg/Drivers/CpuPei/CpuPei.inf
 
   MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
diff --git a/ArmVirtPkg/ArmVirtQemu.fdf b/ArmVirtPkg/ArmVirtQemu.fdf
index b5e2253295fe..7f17aeb3ad0d 100644
--- a/ArmVirtPkg/ArmVirtQemu.fdf
+++ b/ArmVirtPkg/ArmVirtQemu.fdf
@@ -107,7 +107,7 @@ [FV.FVMAIN_COMPACT]
   INF ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf
   INF MdeModulePkg/Core/Pei/PeiMain.inf
   INF ArmPlatformPkg/PlatformPei/PlatformPeim.inf
-  INF ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf
+  INF ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf
   INF ArmPkg/Drivers/CpuPei/CpuPei.inf
   INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
   INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95375): https://edk2.groups.io/g/devel/message/95375
Mute This Topic: https://groups.io/mt/94427019/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 resend 08/11] ArmVirtPkg/ArmVirtQemu: Drop unused variable PEIM

2022-10-19 Thread Ard Biesheuvel
The variable PEIM is included in the build but its runtime prerequisites
are absent so it is never dispatched. Just drop it.

Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirtQemu.dsc | 2 --
 ArmVirtPkg/ArmVirtQemu.fdf | 1 -
 2 files changed, 3 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 21a321e35794..de34481673ea 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -324,8 +324,6 @@ [Components.common]
   }
   ArmPkg/Drivers/CpuPei/CpuPei.inf
 
-  MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
-
 !if $(TPM2_ENABLE) == TRUE
   MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf {
 
diff --git a/ArmVirtPkg/ArmVirtQemu.fdf b/ArmVirtPkg/ArmVirtQemu.fdf
index 7f17aeb3ad0d..c85e36b185d3 100644
--- a/ArmVirtPkg/ArmVirtQemu.fdf
+++ b/ArmVirtPkg/ArmVirtQemu.fdf
@@ -110,7 +110,6 @@ [FV.FVMAIN_COMPACT]
   INF ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf
   INF ArmPkg/Drivers/CpuPei/CpuPei.inf
   INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
-  INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
   INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
 
 !if $(TPM2_ENABLE) == TRUE
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95376): https://edk2.groups.io/g/devel/message/95376
Mute This Topic: https://groups.io/mt/94427020/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 resend 06/11] ArmVirtPkg/ArmVirtQemu: use first 128 MiB as permanent PEI memory

2022-10-19 Thread Ard Biesheuvel
In order to allow booting with the MMU and caches enabled really early,
we need to ensure that the code that populates the page tables can
access those page tables with the statically defined ID map active.

So let's put the permanent PEI RAM in the first 128 MiB of memory, which
we will cover with this initial ID map (as it is the minimum supported
DRAM size for ArmVirtQemu).

Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c   | 104 
 ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf |  59 +++
 2 files changed, 163 insertions(+)

diff --git a/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c 
b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c
new file mode 100644
index ..ef88a9df1d62
--- /dev/null
+++ b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c
@@ -0,0 +1,104 @@
+/** @file
+
+  Copyright (c) 2011, ARM Limited. All rights reserved.
+  Copyright (c) 2022, Google LLC. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+EFI_STATUS
+EFIAPI
+MemoryPeim (
+  IN EFI_PHYSICAL_ADDRESS  UefiMemoryBase,
+  IN UINT64UefiMemorySize
+  );
+
+/**
+  Build the memory type information HOB that describes how many pages of each
+  type to preallocate when initializing the GCD memory map.
+**/
+VOID
+EFIAPI
+BuildMemoryTypeInformationHob (
+  VOID
+  )
+{
+  EFI_MEMORY_TYPE_INFORMATION  Info[10];
+
+  Info[0].Type  = EfiACPIReclaimMemory;
+  Info[0].NumberOfPages = FixedPcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory);
+  Info[1].Type  = EfiACPIMemoryNVS;
+  Info[1].NumberOfPages = FixedPcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS);
+  Info[2].Type  = EfiReservedMemoryType;
+  Info[2].NumberOfPages = FixedPcdGet32 (PcdMemoryTypeEfiReservedMemoryType);
+  Info[3].Type  = EfiRuntimeServicesData;
+  Info[3].NumberOfPages = FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesData);
+  Info[4].Type  = EfiRuntimeServicesCode;
+  Info[4].NumberOfPages = FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesCode);
+  Info[5].Type  = EfiBootServicesCode;
+  Info[5].NumberOfPages = FixedPcdGet32 (PcdMemoryTypeEfiBootServicesCode);
+  Info[6].Type  = EfiBootServicesData;
+  Info[6].NumberOfPages = FixedPcdGet32 (PcdMemoryTypeEfiBootServicesData);
+  Info[7].Type  = EfiLoaderCode;
+  Info[7].NumberOfPages = FixedPcdGet32 (PcdMemoryTypeEfiLoaderCode);
+  Info[8].Type  = EfiLoaderData;
+  Info[8].NumberOfPages = FixedPcdGet32 (PcdMemoryTypeEfiLoaderData);
+
+  // Terminator for the list
+  Info[9].Type  = EfiMaxMemoryType;
+  Info[9].NumberOfPages = 0;
+
+  BuildGuidDataHob (, , sizeof (Info));
+}
+
+/**
+  Module entry point.
+
+  @param[in]FileHandleHandle of the file being invoked.
+  @param[in]PeiServices   Describes the list of possible PEI Services.
+
+  @return   EFI_SUCCESS unless the operation failed.
+**/
+EFI_STATUS
+EFIAPI
+InitializeMemory (
+  IN   EFI_PEI_FILE_HANDLE  FileHandle,
+  IN CONST EFI_PEI_SERVICES **PeiServices
+  )
+{
+  UINTN   UefiMemoryBase;
+  EFI_STATUS  Status;
+
+  ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) < (UINT64)MAX_ALLOC_ADDRESS);
+
+  //
+  // Put the permanent PEI memory in the first 128 MiB of DRAM so that
+  // it is covered by the statically configured ID map.
+  //
+  UefiMemoryBase = (UINTN)FixedPcdGet64 (PcdSystemMemoryBase) + SIZE_128MB
+   - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
+
+  Status = PeiServicesInstallPeiMemory (
+ UefiMemoryBase,
+ FixedPcdGet32 (PcdSystemMemoryUefiRegionSize)
+ );
+  ASSERT_EFI_ERROR (Status);
+
+  Status = MemoryPeim (
+ UefiMemoryBase,
+ FixedPcdGet32 (PcdSystemMemoryUefiRegionSize)
+ );
+  ASSERT_EFI_ERROR (Status);
+
+  return Status;
+}
diff --git a/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf 
b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf
new file mode 100644
index ..2039f71a0ebe
--- /dev/null
+++ b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf
@@ -0,0 +1,59 @@
+## @file
+#  Implementation of MemoryInitPeim that uses the first 128 MiB at the base of
+#  DRAM as permanent PEI memory
+#
+#  Copyright (c) 2011-2014, ARM Ltd. All rights reserved.
+#  Copyright (c) 2022, Google LLC. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 1.27
+  BASE_NAME  = MemoryInit
+  FILE_GUID  = 0fbffd44-f98f-4e1c-9922-e9b21f13c3f8
+  MODULE_TYPE= PEIM
+  VERSION_STRING = 1.0
+  ENTRY_POINT= InitializeMemory
+
+[Sources]
+  MemoryInitPeim.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  ArmPkg/ArmPkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+
+[LibraryClasses]
+  PeimEntryPoint
+  

[edk2-devel] [PATCH v3 resend 05/11] ArmVirtPkg/ArmVirtQemu: implement ArmPlatformLib with static ID map

2022-10-19 Thread Ard Biesheuvel
To substantially reduce the amount of processing that takes place with
the MMU and caches off, implement a version of ArmPlatformLib specific
for QEMU/mach-virt in AArch64 mode that carries a statically allocated
and populated ID map that covers the NOR flash and device region, and
128 MiB of DRAM at the base of memory (0x4000_).

Note that 128 MiB has always been the minimum amount of DRAM we support
for this configuration, and the existing code already ASSERT()s in DEBUG
mode when booting with less.

Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S | 115 

 ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.c|  64 
+++
 ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.inf  |  40 +++
 ArmVirtPkg/Library/ArmPlatformLibQemu/IdMap.S |  57 
++
 4 files changed, 276 insertions(+)

diff --git a/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S 
b/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S
new file mode 100644
index ..05ccc7f9f043
--- /dev/null
+++ b/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S
@@ -0,0 +1,115 @@
+//
+//  Copyright (c) 2022, Google LLC. All rights reserved.
+//
+//  SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+//
+
+#include 
+
+  .macro mov_i, reg:req, imm:req
+  movz   \reg, :abs_g3:\imm
+  movk   \reg, :abs_g2_nc:\imm
+  movk   \reg, :abs_g1_nc:\imm
+  movk   \reg, :abs_g0_nc:\imm
+  .endm
+
+ .setMAIR_DEV_nGnRnE, 0x00
+ .setMAIR_MEM_NC, 0x44
+ .setMAIR_MEM_WT, 0xbb
+ .setMAIR_MEM_WBWA,   0xff
+ .setmairval, MAIR_DEV_nGnRnE | (MAIR_MEM_NC << 8) | (MAIR_MEM_WT << 16) | 
(MAIR_MEM_WBWA << 24)
+
+ .setTCR_TG0_4KB, 0x0 << 14
+ .setTCR_TG1_4KB, 0x2 << 30
+ .setTCR_IPS_SHIFT,   32
+ .setTCR_EPD1,0x1 << 23
+ .setTCR_SH_INNER,0x3 << 12
+ .setTCR_RGN_OWB, 0x1 << 10
+ .setTCR_RGN_IWB, 0x1 << 8
+ .settcrval, TCR_TG0_4KB | TCR_TG1_4KB | TCR_EPD1 | TCR_RGN_OWB
+ .settcrval, tcrval | TCR_RGN_IWB | TCR_SH_INNER
+
+ .setSCTLR_ELx_I, 0x1 << 12
+ .setSCTLR_ELx_SA,0x1 << 3
+ .setSCTLR_ELx_C, 0x1 << 2
+ .setSCTLR_ELx_M, 0x1 << 0
+ .setSCTLR_EL1_SPAN,  0x1 << 23
+ .setSCTLR_EL1_WXN,   0x1 << 19
+ .setSCTLR_EL1_SED,   0x1 << 8
+ .setSCTLR_EL1_ITD,   0x1 << 7
+ .setSCTLR_EL1_RES1,  (0x1 << 11) | (0x1 << 20) | (0x1 << 22) | (0x1 
<< 28) | (0x1 << 29)
+ .setsctlrval, SCTLR_ELx_M | SCTLR_ELx_C | SCTLR_ELx_SA | SCTLR_EL1_ITD | 
SCTLR_EL1_SED
+ .setsctlrval, sctlrval | SCTLR_ELx_I | SCTLR_EL1_SPAN | SCTLR_EL1_RES1
+
+
+ASM_FUNC(ArmPlatformPeiBootAction)
+  mrsx0, CurrentEL   // check current exception level
+  tbzx0, #3, 0f  // bail if above EL1
+  ret
+
+0:mov_i  x0, mairval
+  mov_i  x1, tcrval
+  adrp   x2, idmap
+  orrx2, x2, #0xff << 48 // set non-zero ASID
+  mov_i  x3, sctlrval
+
+  mrsx6, id_aa64mmfr0_el1// get the supported PA range
+  andx6, x6, #0xf// isolate PArange bits
+  cmpx6, #6  // 0b0110 == 52 bits
+  subx6, x6, #1  // subtract 1
+  cinc   x6, x6, ne  // add back 1 unless PArange == 52 bits
+  bfix1, x6, #32, #3 // copy updated PArange into TCR_EL1.IPS
+
+  cmpx6, #3  // 0b0011 == 42 bits
+  subx6, x6, #1  // subtract 1
+  cinc   x6, x6, lt  // add back 1 unless VA range >= 42
+
+  movx7, #32
+  subx6, x7, x6, lsl #2  // T0SZ for PArange != 42
+  movx7, #64 - 42// T0SZ for PArange == 42
+  csel   x6, x6, x7, ne
+  orrx1, x1, x6  // set T0SZ field in TCR
+
+  cmpx6, #64 - 40// VA size < 40 bits?
+  addx4, x2, #0x1000 // advance to level 1 descriptor
+  csel   x2, x4, x2, gt
+
+  msrmair_el1, x0// set up the 1:1 mapping
+  msrtcr_el1, x1
+  msrttbr0_el1, x2
+  isb
+
+  tlbi   vmalle1 // invalidate any cached translations
+  ic iallu   // invalidate the I-cache
+  dsbnsh
+  isb
+
+  msrsctlr_el1, x3   // enable MMU and caches
+  isb
+  ret
+
+//UINTN
+//ArmPlatformGetCorePosition (
+//  IN UINTN MpId
+//  );
+// With this function: CorePos = (ClusterId * 4) + CoreId
+ASM_FUNC(ArmPlatformGetCorePosition)
+  mov   x0, xzr
+  ret
+
+//UINTN
+//ArmPlatformGetPrimaryCoreMpId (
+//  VOID
+//  );
+ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
+  MOV32  (w0, FixedPcdGet32 (PcdArmPrimaryCore))
+  ret
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+//  IN UINTN MpId
+//  );
+ASM_FUNC(ArmPlatformIsPrimaryCore)
+  mov   x0, #1
+  ret
diff --git a/ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.c 
b/ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.c
new file 

[edk2-devel] [PATCH v3 resend 04/11] ArmVirtPkg/ArmVirtQemu: wire up timeout PCD to Timeout variable

2022-10-19 Thread Ard Biesheuvel
Use the appropriate PCD definition in the ArmVirtQemu DSC so that the
boot timeout is taken from the Timeout variable automatically, which is
what Linux tools such as efibootmgr expect.

Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirtQemu.dsc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 45c4a8fc84e0..302c0d2a4e29 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -292,6 +292,8 @@ [PcdsDynamicHii]
   
gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableRev|L"TCG2_VERSION"|gTcg2ConfigFormSetGuid|0x8|3|NV,BS
 !endif
 
+  
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|5
+
 

 #
 # Components Section - list of all EDK II Modules needed by this Platform
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95372): https://edk2.groups.io/g/devel/message/95372
Mute This Topic: https://groups.io/mt/94427015/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 resend 03/11] ArmVirtPkg: make EFI_LOADER_DATA non-executable

2022-10-19 Thread Ard Biesheuvel
When the memory protections were implemented and enabled on ArmVirtQemu
5+ years ago, we had to work around the fact that GRUB at the time
expected EFI_LOADER_DATA to be executable, as that is the memory type it
allocates when loading its modules.

This has been fixed in GRUB in August 2017, so by now, we should be able
to tighten this, and remove execute permissions from EFI_LOADER_DATA
allocations.

Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirt.dsc.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 34575585adbb..462073517a22 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -368,7 +368,7 @@ [PcdsFixedAtBuild.common]
   # reserved ones, with the exception of LoaderData regions, of which OS 
loaders
   # (i.e., GRUB) may assume that its contents are executable.
   #
-  
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy|0xC0007FD1
+  
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy|0xC0007FD5
 
 [Components.common]
   #
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95371): https://edk2.groups.io/g/devel/message/95371
Mute This Topic: https://groups.io/mt/94427014/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 resend 01/11] ArmVirtPkg: remove EbcDxe from all platforms

2022-10-19 Thread Ard Biesheuvel
The EBC interpreter is rarely, if ever, used on ARM, and is especially
pointless on virtual machines. So let's drop it from the builds.

Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirt.dsc.inc   | 5 -
 ArmVirtPkg/ArmVirtCloudHv.fdf| 5 -
 ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 5 -
 ArmVirtPkg/ArmVirtXen.fdf| 5 -
 4 files changed, 20 deletions(-)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index c39e2506a3ea..34575585adbb 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -422,8 +422,3 @@ [Components.AARCH64]
 
   NULL|EmbeddedPkg/Library/PlatformHasAcpiLib/PlatformHasAcpiLib.inf
   }
-
-  #
-  # EBC support
-  #
-  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
diff --git a/ArmVirtPkg/ArmVirtCloudHv.fdf b/ArmVirtPkg/ArmVirtCloudHv.fdf
index 81c539590a76..a5f172d79bfc 100644
--- a/ArmVirtPkg/ArmVirtCloudHv.fdf
+++ b/ArmVirtPkg/ArmVirtCloudHv.fdf
@@ -195,11 +195,6 @@ [FV.FvMain]
   INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
   INF 
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
   INF ArmVirtPkg/CloudHvAcpiPlatformDxe/CloudHvAcpiPlatformDxe.inf
-
-  #
-  # EBC support
-  #
-  INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
 !endif
 
   #
diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc 
b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
index d4df6dede0fe..787286133095 100644
--- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
+++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
@@ -146,11 +146,6 @@ [FV.FvMain]
   INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
   INF 
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
   INF OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
-
-  #
-  # EBC support
-  #
-  INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
 !endif
 
   #
diff --git a/ArmVirtPkg/ArmVirtXen.fdf b/ArmVirtPkg/ArmVirtXen.fdf
index 132480f03059..770fbf7289be 100644
--- a/ArmVirtPkg/ArmVirtXen.fdf
+++ b/ArmVirtPkg/ArmVirtXen.fdf
@@ -201,11 +201,6 @@ [FV.FvMain]
 !if $(ARCH) == AARCH64
   INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
   INF ArmVirtPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
-
-  #
-  # EBC support
-  #
-  INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
 !endif
 
  #
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95370): https://edk2.groups.io/g/devel/message/95370
Mute This Topic: https://groups.io/mt/94427013/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 resend 02/11] ArmVirtPkg: do not enable iSCSI driver by default

2022-10-19 Thread Ard Biesheuvel
The iSCSI driver slows down the boot on a pristine variable store flash
image, as it creates a couple of large EFI non-volatile variables to
preserve state between boots.

Since iSCSI boot for VMs is kind of niche anyway, let's default to
disabled. If someone needs it in their build, they can use the -D build
command option to re-enable it on the fly.

Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirtQemu.dsc   | 1 -
 ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 -
 2 files changed, 2 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 9369a88858fd..45c4a8fc84e0 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -40,7 +40,6 @@ [Defines]
   DEFINE NETWORK_SNP_ENABLE  = FALSE
   DEFINE NETWORK_TLS_ENABLE  = FALSE
   DEFINE NETWORK_ALLOW_HTTP_CONNECTIONS  = TRUE
-  DEFINE NETWORK_ISCSI_ENABLE= TRUE
 
 !if $(NETWORK_SNP_ENABLE) == TRUE
   !error "NETWORK_SNP_ENABLE is IA32/X64/EBC only"
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index 7f7d15d6eee3..66039f07f41b 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -38,7 +38,6 @@ [Defines]
   DEFINE NETWORK_SNP_ENABLE  = FALSE
   DEFINE NETWORK_TLS_ENABLE  = FALSE
   DEFINE NETWORK_ALLOW_HTTP_CONNECTIONS  = TRUE
-  DEFINE NETWORK_ISCSI_ENABLE= TRUE
 
 !if $(NETWORK_SNP_ENABLE) == TRUE
   !error "NETWORK_SNP_ENABLE is IA32/X64/EBC only"
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95369): https://edk2.groups.io/g/devel/message/95369
Mute This Topic: https://groups.io/mt/94427012/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 resend 00/11] ArmVirtPkg/ArmVirtQemu: Performance streamlining

2022-10-19 Thread Ard Biesheuvel
We currently do a substantial amount of processing before enabling the
MMU and caches, which is bad for performance, but also fragile, as it
requires cache coherency to be managed in software.

It also means that when running under virtualization, the hypervisor
must do a non-trivial amount of work to ensure that the host's cached
view of memory is consistent with the guest's uncached view.

Now that the AArch64 version of ArmMmuLib has been updated to allow it
to be invoked with the MMU already enabled, and to no longer disable the
MMU temporarily to make modifications to the page tables that require
break before make (BBM) [e.g., to split block mappings into table
mappings], we can remove all remaining manipulations of main memory that
occur with the MMU and caches disabled, by using a compile time
generated ID map that covers the first bank of NOR flash, the first MMIO
region (for the UART), and the first 128 MiB of DRAM, and switching to
it straight out of reset.

The resulting build no longer performs any non-coherent memory accesses
via the data side, and only relies on instruction fetches before the MMU
is enabled. It also avoids any cache maintenance to the PoC.

Changes since v3:
- drop ArmMmuLib changes that have since been merged

Changes since v2:
- drop shadow page table approach - it only works at EL1, and is a bit
  more intrusive than needed; instead, do a proper break-before-make
  (BBM) unless the break unmaps the page table itself or the code that
  is modifying it;
- add a couple of only tangentially related performance streamlining
  changes, to avoid dispatching and shadowing drivers that we don't need

Changes since v1:
- coding style tweaks to placate our CI overlord
- drop -mstrict-align which is no longer needed now that all C code runs
  with the MMU and caches on

Cc: Leif Lindholm 
Cc: Alexander Graf 
Cc: Gerd Hoffmann 
Cc: Sami Mujawar 

Ard Biesheuvel (11):
  ArmVirtPkg: remove EbcDxe from all platforms
  ArmVirtPkg: do not enable iSCSI driver by default
  ArmVirtPkg: make EFI_LOADER_DATA non-executable
  ArmVirtPkg/ArmVirtQemu: wire up timeout PCD to Timeout variable
  ArmVirtPkg/ArmVirtQemu: implement ArmPlatformLib with static ID map
  ArmVirtPkg/ArmVirtQemu: use first 128 MiB as permanent PEI memory
  ArmVirtPkg/ArmVirtQemu: enable initial ID map at early boot
  ArmVirtPkg/ArmVirtQemu: Drop unused variable PEIM
  ArmVirtPkg/ArmVirtQemu: avoid shadowing PEIMs unless necessary
  ArmVirtPkg/QemuVirtMemInfoLib: use HOB not PCD to record the memory
size
  ArmVirtPkg/ArmVirtQemu: omit PCD PEIM unless TPM support is enabled

 ArmVirtPkg/ArmVirt.dsc.inc 
  |   7 +-
 ArmVirtPkg/ArmVirtCloudHv.fdf  
  |   5 -
 ArmVirtPkg/ArmVirtPkg.dec  
  |   1 +
 ArmVirtPkg/ArmVirtQemu.dsc 
  |  53 ++---
 ArmVirtPkg/ArmVirtQemu.fdf 
  |   5 +-
 ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc   
  |   5 -
 ArmVirtPkg/ArmVirtQemuKernel.dsc   
  |   1 -
 ArmVirtPkg/ArmVirtXen.fdf  
  |   5 -
 ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S  
  | 115 
 ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.c 
  |  64 +++
 ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.inf   
  |  40 +++
 ArmVirtPkg/Library/ArmPlatformLibQemu/IdMap.S  
  |  57 ++
 ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c   
  |  14 ++-
 ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf 
  |   1 +
 ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c 
  |  35 +-
 ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf   
  |   5 +-
 ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf
  |   8 +-
 ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibConstructor.c   
  |  30 +++--
 ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c  
  | 104 ++
 

Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V4 29/34] OvmfPkg: Add Qemu NOR flash DXE driver

2022-10-19 Thread Ard Biesheuvel
On Fri, 14 Oct 2022 at 18:50, Sunil V L  wrote:
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076
>
> RISC-V needs NorFlashDxe driver for qemu virt machine. The
> ArmPlatformPkg has this driver but migrating it to generic
> package like MdeModulePkg introduces circular dependencies.
> So, add NorFlashDxe driver in OvmfPkg which is mostly the
> copy of the driver in ArmPlatformPkg except the support
> for PcdNorFlashCheckBlockLocked feature. This approach also
> allows to optimize the driver for virtual platforms.
>
> Cc: Ard Biesheuvel 
> Cc: Jiewen Yao 
> Cc: Jordan Justen 
> Cc: Gerd Hoffmann 
> Signed-off-by: Sunil V L 
> ---
>  OvmfPkg/Drivers/NorFlashDxe/NorFlashDxe.inf  |  67 ++
>  OvmfPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf |  61 ++

I don't think we need the StandaloneMm variant here


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95367): https://edk2.groups.io/g/devel/message/95367
Mute This Topic: https://groups.io/mt/94330865/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v7 0/7] Add safe unaccepted memory behavior

2022-10-19 Thread Ard Biesheuvel
On Fri, 14 Oct 2022 at 23:30, Dionna Glaze via groups.io
 wrote:
>
> >
> > Can OsIndicationsSupported UEFI variable provide the similar functionality?
> >
>
> Similar, but not the same. If we use a UEFI variable, its value will
> persist across boots.

That assumes the variable is non-volatile, but I suppose we could use
a volatile variable [other than OsIndications] as well.

> This can be fine if you only boot one OS, but if
> you have two where one supports unaccepted memory and the other
> doesn't then you have a problem.
> The protocol here is specific to the code that will be calling
> ExitBootServices, and thus won't mess up another OS once we reboot and
> select it.
>
> --
> -Dionna Glaze, PhD (she/her)
>
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95366): https://edk2.groups.io/g/devel/message/95366
Mute This Topic: https://groups.io/mt/94144524/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V4 26/34] EmbeddedPkg/NvVarStoreFormattedLib: Migrate to MdeModulePkg

2022-10-19 Thread Ard Biesheuvel
On Fri, 14 Oct 2022 at 18:49, Sunil V L  wrote:
>
> This library is required by NorFlashDxe. Since it will be used by
> both virtual and real platforms, migrate this library to
> MdeModulePkg.
>
> Cc: Leif Lindholm 
> Cc: Ard Biesheuvel 
> Cc: Abner Chang 
> Cc: Daniel Schaefer 
> Cc: Jian J Wang 
> Cc: Liming Gao 
> Cc: Andrew Fish 
> Cc: Michael D Kinney 
> Signed-off-by: Sunil V L 

Acked-by: Ard Biesheuvel 

Can we get an ack on this from the MdeModulePkg maintainers please?

> ---
>  EmbeddedPkg/EmbeddedPkg.dec  
>| 3 ---
>  MdeModulePkg/MdeModulePkg.dec
>| 3 +++
>  MdeModulePkg/MdeModulePkg.dsc
>| 2 ++
>  {EmbeddedPkg => 
> MdeModulePkg}/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf | 1 -
>  {EmbeddedPkg => MdeModulePkg}/Include/Guid/NvVarStoreFormatted.h 
>| 0
>  {EmbeddedPkg => 
> MdeModulePkg}/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.c   | 0
>  6 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec
> index 341ef5e6a679..b1f5654835f6 100644
> --- a/EmbeddedPkg/EmbeddedPkg.dec
> +++ b/EmbeddedPkg/EmbeddedPkg.dec
> @@ -69,9 +69,6 @@ [Guids.common]
># HII form set GUID for ConsolePrefDxe driver
>gConsolePrefFormSetGuid = { 0x2d2358b4, 0xe96c, 0x484d, { 0xb2, 0xdd, 
> 0x7c, 0x2e, 0xdf, 0xc7, 0xd5, 0x6f } }
>
> -  ## Include/Guid/NvVarStoreFormatted.h
> -  gEdkiiNvVarStoreFormattedGuid = { 0xd1a86e3f, 0x0707, 0x4c35, { 0x83, 
> 0xcd, 0xdc, 0x2c, 0x29, 0xc8, 0x91, 0xa3 } }
> -
>  [Protocols.common]
>gHardwareInterruptProtocolGuid =  { 0x2890B3EA, 0x053D, 0x1643, { 0xAD, 
> 0x0C, 0xD6, 0x48, 0x08, 0xDA, 0x3F, 0xF1 } }
>gHardwareInterrupt2ProtocolGuid = { 0x32898322, 0x2da1, 0x474a, { 0xba, 
> 0xaa, 0xf3, 0xf7, 0xcf, 0x56, 0x94, 0x70 } }
> diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
> index 58e6ab004882..492bff8b7890 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -412,6 +412,9 @@ [Guids]
>## Include/Guid/MigratedFvInfo.h
>gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4, 
> 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } }
>
> +  ## Include/Guid/NvVarStoreFormatted.h
> +  gEdkiiNvVarStoreFormattedGuid = { 0xd1a86e3f, 0x0707, 0x4c35, { 0x83, 
> 0xcd, 0xdc, 0x2c, 0x29, 0xc8, 0x91, 0xa3 } }
> +
>#
># GUID defined in UniversalPayload
>#
> diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
> index 659482ab737f..4142e1178dcd 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -104,6 +104,7 @@ [LibraryClasses]
>
> VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
>
> MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
>
> VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
> +  
> NvVarStoreFormattedLib|MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
>
>  [LibraryClasses.EBC.PEIM]
>IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf
> @@ -443,6 +444,7 @@ [Components]
>MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
>MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
>MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
> +  MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
>
>  [Components.IA32, Components.X64, Components.AARCH64]
>MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
> diff --git 
> a/EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf 
> b/MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
> similarity index 96%
> rename from 
> EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
> rename to 
> MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
> index e2eed26c5b2d..5e8cd94cc9e0 100644
> --- a/EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
> +++ b/MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
> @@ -32,7 +32,6 @@ [Sources]
>NvVarStoreFormattedLib.c
>
>  [Packages]
> -  EmbeddedPkg/EmbeddedPkg.dec
>MdeModulePkg/MdeModulePkg.dec
>MdePkg/MdePkg.dec
>
> diff --git a/EmbeddedPkg/Include/Guid/NvVarStoreFormatted.h 
> b/MdeModulePkg/Include/Guid/NvVarStoreFormatted.h
> similarity index 100%
> rename from EmbeddedPkg/Include/Guid/NvVarStoreFormatted.h
> rename to MdeModulePkg/Include/Guid/NvVarStoreFormatted.h
> diff --git 
> a/EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.c 
> b/MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.c
> similarity index 100%
> rename from 
> EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.c
>