[edk2-devel] HII Keyword utility

2024-05-13 Thread Jeff Brasen via groups.io
I have a UEFI shell application that can set/get UEFI x-UEFI HII Keyword 
values. edk2-nvidia/Silicon/NVIDIA/Application/HiiKeywordUtil at main · 
NVIDIA/edk2-nvidia (github.com) ( 
https://github.com/NVIDIA/edk2-nvidia/tree/main/Silicon/NVIDIA/Application/HiiKeywordUtil
 )

I have used this to configure iSCSI from the shell. Is this something that is 
desired to be in the main edk2 repo? If so, what package should this go under?

If this is generally useful I'll do some cleanup and make a push request after 
the stable202405 release is out.

-Jeff Brasen


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




[edk2-devel] [PATCH v3 1/1] MdePkg: Add FdtLib gmock support

2024-01-23 Thread Jeff Brasen via groups.io
Add Google Mock Library for FdtLib

Signed-off-by: Jeff Brasen 
---
 MdePkg/Test/MdePkgHostTest.dsc|   1 +
 .../GoogleTest/MockFdtLib/MockFdtLib.inf  |  28 +++
 .../Include/GoogleTest/Library/MockFdtLib.h   | 164 ++
 .../GoogleTest/MockFdtLib/MockFdtLib.cpp  |  34 
 4 files changed, 227 insertions(+)
 create mode 100644 
MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
 create mode 100644 MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
 create mode 100644 
MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp

diff --git a/MdePkg/Test/MdePkgHostTest.dsc b/MdePkg/Test/MdePkgHostTest.dsc
index 583f8fc0ddd8..e36b7c55 100644
--- a/MdePkg/Test/MdePkgHostTest.dsc
+++ b/MdePkg/Test/MdePkgHostTest.dsc
@@ -45,3 +45,4 @@ [Components]
   
MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.inf
   MdePkg/Test/Mock/Library/GoogleTest/MockPeiServicesLib/MockPeiServicesLib.inf
   MdePkg/Test/Mock/Library/GoogleTest/MockHobLib/MockHobLib.inf
+  MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf 
b/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
new file mode 100644
index ..b227bcbae963
--- /dev/null
+++ b/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
@@ -0,0 +1,28 @@
+## @file
+# Google Test mocks for FdtLib
+#
+# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# Copyright (c) 2023, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = MockFdtLib
+  FILE_GUID  = 0f5471bc-fc2c-4cf4-b9f7-c1396d32831c
+  MODULE_TYPE= HOST_APPLICATION
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = FdtLib
+
+[Sources]
+  MockFdtLib.cpp
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+  GoogleTestLib
+
+[BuildOptions]
+  MSFT:*_*_*_CC_FLAGS = /EHsc /bigobj
diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h 
b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
new file mode 100644
index ..5b21b232b7c7
--- /dev/null
+++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
@@ -0,0 +1,164 @@
+/** @file
+  Google Test mocks for FdtLib
+
+  Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef MOCK_FDT_LIB_H_
+#define MOCK_FDT_LIB_H_
+
+#include 
+#include 
+extern "C" {
+  #include 
+  #include 
+}
+
+struct MockFdtLib {
+  MOCK_INTERFACE_DECLARATION (MockFdtLib);
+
+  MOCK_FUNCTION_DECLARATION (
+UINT16,
+Fdt16ToCpu,
+(IN UINT16 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT16,
+CpuToFdt16,
+(IN UINT16 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT32,
+Fdt32ToCpu,
+(IN UINT32 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT32,
+CpuToFdt32,
+(IN UINT32 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT64,
+Fdt64ToCpu,
+(IN UINT64 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT64,
+CpuToFdt64,
+(IN UINT64 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtCheckHeader,
+(IN CONST VOID  *Fdt)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtCreateEmptyTree,
+(IN VOID*Buffer,
+ IN UINT32  BufferSize)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtNextNode,
+(IN CONST VOID  *Fdt,
+ IN INT32   Offset,
+ IN INT32   *Depth)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtFirstSubnode,
+(IN CONST VOID  *Fdt,
+ IN INT32   Offset)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtNextSubnode,
+(IN CONST VOID  *Fdt,
+ IN INT32   Offset)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtSubnodeOffsetNameLen,
+(IN CONST VOID   *Fdt,
+ IN INT32ParentOffset,
+ IN CONST CHAR8  *Name,
+ IN INT32NameLength)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtNodeOffsetByPropValue,
+(IN CONST VOID   *Fdt,
+ IN INT32StartOffset,
+ IN CONST CHAR8  *PropertyName,
+ IN CONST VOID   *PropertyValue,
+ IN INT32PropertyLength)
+);
+  MOCK_FUNCTION_DECLARATION (
+CONST FDT_PROPERTY *,
+FdtGetProperty,
+(IN CONST VOID   *Fdt,
+ IN INT32NodeOffset,
+ IN CONST CHAR8  *Name,
+ IN INT32*Length)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtFirstPropertyOffset,
+(IN CONST VOID  *Fdt,
+ IN INT32   NodeOffset)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtNextPropertyOffset,
+(IN CONST VOID  *Fdt,
+   

Re: [edk2-devel] [PATCH v2 1/1] MdePkg: Add FdtLib gmock support

2024-01-23 Thread Jeff Brasen via groups.io
Oops not sure how that happened will fix and push a v3.

-Jeff



> -Original Message-
> From: Kinney, Michael D 
> Sent: Tuesday, January 23, 2024 4:52 PM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: gaolim...@byosoft.com.cn; Liu, Zhiguang ;
> Kinney, Michael D 
> Subject: RE: [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
> 
> External email: Use caution opening links or attachments
> 
> 
> Hi Jeff,
> 
> I just noticed that the DSC file in MdePkg/Test has not been updated to make
> sure this mock lib always builds.  I added as part of PR to run EDK II CI.
> 
> EDK II CI did fail.
> 
> https://github.com/tianocore/edk2/pull/5293
> https://github.com/tianocore/edk2/pull/5293/checks?check_run_id=207950
> 99585
> https://dev.azure.com/tianocore/edk2-
> ci/_build/results?buildId=115123=logs=9701361e-2546-5093-
> 77e5-58c75d95b7ce=9701361e-2546-5093-77e5-
> 58c75d95b7ce=27131ef8-75e1-57c3-3236-d806181f2f1f
> 
> Comment below that details the failure.
> 
> Please fix and send V3 with MdePkg/Test DSC update and the
> FdtGetName() fix.
> 
> Thanks,
> 
> Mike
> 
> > -Original Message-
> > From: Kinney, Michael D 
> > Sent: Tuesday, January 23, 2024 3:19 PM
> > To: Jeff Brasen ; devel@edk2.groups.io
> > Cc: gaolim...@byosoft.com.cn; Liu, Zhiguang ;
> > Kinney, Michael D 
> > Subject: RE: [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
> >
> > Reviewed-by: Michael D Kinney 
> >
> > > -Original Message-
> > > From: Jeff Brasen 
> > > Sent: Tuesday, January 23, 2024 3:13 PM
> > > To: devel@edk2.groups.io
> > > Cc: gaolim...@byosoft.com.cn; Kinney, Michael D
> > > ; Liu, Zhiguang
> > > ; Jeff Brasen 
> > > Subject: [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
> > >
> > > Add Google Mock Library for FdtLib
> > >
> > > Signed-off-by: Jeff Brasen 
> > > ---
> > >  .../GoogleTest/MockFdtLib/MockFdtLib.inf  |  28 +++
> > >  .../Include/GoogleTest/Library/MockFdtLib.h   | 164
> > ++
> > >  .../GoogleTest/MockFdtLib/MockFdtLib.cpp  |  34 
> > >  3 files changed, 226 insertions(+)
> > >  create mode 100644
> > > MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
> > >  create mode 100644
> > > MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
> > >  create mode 100644
> > > MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp
> > >
> > > diff --git
> > > a/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
> > > b/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
> > > new file mode 100644
> > > index ..b227bcbae963
> > > --- /dev/null
> > > +++
> b/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
> > > @@ -0,0 +1,28 @@
> > > +## @file
> > > +# Google Test mocks for FdtLib
> > > +#
> > > +# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights
> > > reserved.
> > > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
> > > +# SPDX-License-Identifier: BSD-2-Clause-Patent ##
> > > +
> > > +[Defines]
> > > +  INF_VERSION= 0x00010005
> > > +  BASE_NAME  = MockFdtLib
> > > +  FILE_GUID  = 0f5471bc-fc2c-4cf4-b9f7-
> > c1396d32831c
> > > +  MODULE_TYPE= HOST_APPLICATION
> > > +  VERSION_STRING = 1.0
> > > +  LIBRARY_CLASS  = FdtLib
> > > +
> > > +[Sources]
> > > +  MockFdtLib.cpp
> > > +
> > > +[Packages]
> > > +  MdePkg/MdePkg.dec
> > > +  UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
> > > +
> > > +[LibraryClasses]
> > > +  GoogleTestLib
> > > +
> > > +[BuildOptions]
> > > +  MSFT:*_*_*_CC_FLAGS = /EHsc /bigobj
> > > diff --git
> > > a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
> > > b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
> > > new file mode 100644
> > > index ..73da571910df
> > > --- /dev/null
> > > +++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
> > > @@ -0,0 +1,164 @@
> > > +/** @file
> > > +  Google Test mocks for FdtLib
> > > +
> > > +  Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights
> > > reserved.
> > > +  Copyright (c) 2023, Intel Corporation. All rights reserved.
> > > +  SPDX-License-Identifier: BSD-2-Clause-Patent **/
> > > +
> > > +#ifndef MOCK_FDT_LIB_H_
> > > +#define MOCK_FDT_LIB_H_
> > > +
> > > +#include 
> > > +#include  extern "C" {
> > > +  #include 
> > > +  #include 
> > > +}
> > > +
> > > +struct MockFdtLib {
> > > +  MOCK_INTERFACE_DECLARATION (MockFdtLib);
> > > +
> > > +  MOCK_FUNCTION_DECLARATION (
> > > +UINT16,
> > > +Fdt16ToCpu,
> > > +(IN UINT16 Value)
> > > +);
> > > +  MOCK_FUNCTION_DECLARATION (
> > > +UINT16,
> > > +CpuToFdt16,
> > > +(IN UINT16 Value)
> > > +);
> > > +  MOCK_FUNCTION_DECLARATION (
> > > +UINT32,
> > > +Fdt32ToCpu,
> > > +(IN UINT32 Value)
> > > +);
> > > +  MOCK_FUNCTION_DECLARATION (
> > > +UINT32,
> > > +CpuToFdt32,
> > > +(IN UINT32 Value)
> > > +);
> > > +  

[edk2-devel] [PATCH v2 1/1] MdePkg/BaseFdtLib: Rename standard functions

2024-01-23 Thread Jeff Brasen via groups.io
Rename the standard functions in the LibFdtSupport to remove conflicts
with other libraries that define them.

Signed-off-by: Jeff Brasen 
---
 MdePkg/Library/BaseFdtLib/LibFdtSupport.h |  7 +--
 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 25 ++-
 2 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/MdePkg/Library/BaseFdtLib/LibFdtSupport.h 
b/MdePkg/Library/BaseFdtLib/LibFdtSupport.h
index 393019324b73..8a26fbfc3251 100644
--- a/MdePkg/Library/BaseFdtLib/LibFdtSupport.h
+++ b/MdePkg/Library/BaseFdtLib/LibFdtSupport.h
@@ -63,13 +63,13 @@ strchr (
   );
 
 char *
-strrchr(
+fdt_strrchr(
   const char *,
   int
   );
 
 unsigned long
-strtoul (
+fdt_strtoul (
   const char *,
   char **,
   int
@@ -93,7 +93,10 @@ strcpy (
 #define strnlen(str, count) (size_t)(AsciiStrnLenS(str, count))
 #define strncpy(strDest, strSource, count)  AsciiStrnCpyS(strDest, 
MAX_STRING_SIZE, strSource, (UINTN)count)
 #define strcat(strDest, strSource)  AsciiStrCatS(strDest, 
MAX_STRING_SIZE, strSource)
+#define strchr(str, ch) ScanMem8(str, AsciiStrSize (str), 
(UINT8)ch)
 #define strcmp(string1, string2, count) (int)(AsciiStrCmp(string1, 
string2))
 #define strncmp(string1, string2, count)(int)(AsciiStrnCmp(string1, 
string2, (UINTN)(count)))
+#define strrchr(str, ch)fdt_strrchr(str, ch)
+#define strtoul(ptr, end_ptr, base) fdt_strtoul(ptr, end_ptr, base)
 
 #endif /* FDT_LIB_SUPPORT_H_ */
diff --git a/MdePkg/Library/BaseFdtLib/LibFdtWrapper.c 
b/MdePkg/Library/BaseFdtLib/LibFdtWrapper.c
index ef6452914f5b..1a4cd573fdaf 100644
--- a/MdePkg/Library/BaseFdtLib/LibFdtWrapper.c
+++ b/MdePkg/Library/BaseFdtLib/LibFdtWrapper.c
@@ -18,28 +18,7 @@
 // so the code gets a bit clunky to handle that case specifically.
 
 char *
-strchr (
-  const char  *Str,
-  int Char
-  )
-{
-  char  *S;
-
-  S = (char *)Str;
-
-  for ( ; ; S++) {
-if (*S == Char) {
-  return S;
-}
-
-if (*S == '\0') {
-  return NULL;
-}
-  }
-}
-
-char *
-strrchr (
+fdt_strrchr (
   const char  *Str,
   int Char
   )
@@ -71,7 +50,7 @@ __isspace (
 }
 
 unsigned long
-strtoul (
+fdt_strtoul (
   const char  *Nptr,
   char**EndPtr,
   int Base
-- 
2.34.1



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




[edk2-devel] [PATCH v2 1/1] MdePkg: Add FdtLib gmock support

2024-01-23 Thread Jeff Brasen via groups.io
Add Google Mock Library for FdtLib

Signed-off-by: Jeff Brasen 
---
 .../GoogleTest/MockFdtLib/MockFdtLib.inf  |  28 +++
 .../Include/GoogleTest/Library/MockFdtLib.h   | 164 ++
 .../GoogleTest/MockFdtLib/MockFdtLib.cpp  |  34 
 3 files changed, 226 insertions(+)
 create mode 100644 
MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
 create mode 100644 MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
 create mode 100644 
MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp

diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf 
b/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
new file mode 100644
index ..b227bcbae963
--- /dev/null
+++ b/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
@@ -0,0 +1,28 @@
+## @file
+# Google Test mocks for FdtLib
+#
+# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# Copyright (c) 2023, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = MockFdtLib
+  FILE_GUID  = 0f5471bc-fc2c-4cf4-b9f7-c1396d32831c
+  MODULE_TYPE= HOST_APPLICATION
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = FdtLib
+
+[Sources]
+  MockFdtLib.cpp
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+  GoogleTestLib
+
+[BuildOptions]
+  MSFT:*_*_*_CC_FLAGS = /EHsc /bigobj
diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h 
b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
new file mode 100644
index ..73da571910df
--- /dev/null
+++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
@@ -0,0 +1,164 @@
+/** @file
+  Google Test mocks for FdtLib
+
+  Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef MOCK_FDT_LIB_H_
+#define MOCK_FDT_LIB_H_
+
+#include 
+#include 
+extern "C" {
+  #include 
+  #include 
+}
+
+struct MockFdtLib {
+  MOCK_INTERFACE_DECLARATION (MockFdtLib);
+
+  MOCK_FUNCTION_DECLARATION (
+UINT16,
+Fdt16ToCpu,
+(IN UINT16 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT16,
+CpuToFdt16,
+(IN UINT16 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT32,
+Fdt32ToCpu,
+(IN UINT32 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT32,
+CpuToFdt32,
+(IN UINT32 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT64,
+Fdt64ToCpu,
+(IN UINT64 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT64,
+CpuToFdt64,
+(IN UINT64 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtCheckHeader,
+(IN CONST VOID  *Fdt)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtCreateEmptyTree,
+(IN VOID*Buffer,
+ IN UINT32  BufferSize)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtNextNode,
+(IN CONST VOID  *Fdt,
+ IN INT32   Offset,
+ IN INT32   *Depth)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtFirstSubnode,
+(IN CONST VOID  *Fdt,
+ IN INT32   Offset)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtNextSubnode,
+(IN CONST VOID  *Fdt,
+ IN INT32   Offset)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtSubnodeOffsetNameLen,
+(IN CONST VOID   *Fdt,
+ IN INT32ParentOffset,
+ IN CONST CHAR8  *Name,
+ IN INT32NameLength)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtNodeOffsetByPropValue,
+(IN CONST VOID   *Fdt,
+ IN INT32StartOffset,
+ IN CONST CHAR8  *PropertyName,
+ IN CONST VOID   *PropertyValue,
+ IN INT32PropertyLength)
+);
+  MOCK_FUNCTION_DECLARATION (
+CONST FDT_PROPERTY *,
+FdtGetProperty,
+(IN CONST VOID   *Fdt,
+ IN INT32NodeOffset,
+ IN CONST CHAR8  *Name,
+ IN INT32*Length)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtFirstPropertyOffset,
+(IN CONST VOID  *Fdt,
+ IN INT32   NodeOffset)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtNextPropertyOffset,
+(IN CONST VOID  *Fdt,
+ IN INT32   NodeOffset)
+);
+  MOCK_FUNCTION_DECLARATION (
+CONST FDT_PROPERTY *,
+FdtGetPropertyByOffset,
+(IN CONST VOID  *Fdt,
+ IN INT32   Offset,
+ IN INT32   *Length)
+);
+  MOCK_FUNCTION_DECLARATION (
+CONST CHAR8 *,
+FdtGetString,
+(IN CONST VOID  *Fdt,
+ IN INT32   StrOffset,
+ IN INT32   *LengthOPTIONAL)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtAddSubnode,
+(IN VOID *Fdt,
+ IN INT32ParentOffset,
+ IN CONST CHAR8  *Name)
+);
+  MOCK_FUNCTION_DECLARATION (

Re: [edk2-devel] [PATCH] MdePkg: Add FdtLib gmock support

2024-01-23 Thread Jeff Brasen via groups.io
Any comments on this patch?

Thanks,
Jeff


> -Original Message-
> From: Jeff Brasen 
> Sent: Monday, December 11, 2023 8:43 AM
> To: devel@edk2.groups.io
> Cc: gaolim...@byosoft.com.cn; michael.d.kin...@intel.com;
> zhiguang@intel.com; Jeff Brasen 
> Subject: [PATCH] MdePkg: Add FdtLib gmock support
> 
> Add Google Mock Library for FdtLib
> 
> Signed-off-by: Jeff Brasen 
> ---
>  .../Include/GoogleTest/Library/MockFdtLib.h   | 165 ++
>  .../GoogleTest/MockFdtLib/MockFdtLib.cpp  |  34 
>  .../GoogleTest/MockFdtLib/MockFdtLib.inf  |  28 +++
>  3 files changed, 227 insertions(+)
>  create mode 100644
> MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
>  create mode 100644
> MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp
>  create mode 100644
> MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
> 
> diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
> b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
> new file mode 100644
> index 00..c0aeaa25c0
> --- /dev/null
> +++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
> @@ -0,0 +1,165 @@
> +/** @file
> +  Google Test mocks for FdtLib
> +
> +  Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> +  Copyright (c) 2023, Intel Corporation. All rights reserved.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +#ifndef MOCK_FDT_LIB_H_
> +#define MOCK_FDT_LIB_H_
> +
> +#include 
> +#include 
> +extern "C" {
> +#include 
> +#include 
> +#include 
> +}
> +
> +struct MockFdtLib {
> +  MOCK_INTERFACE_DECLARATION (MockFdtLib);
> +
> +  MOCK_FUNCTION_DECLARATION (
> +UINT16,
> +Fdt16ToCpu,
> +(IN UINT16 Value)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +UINT16,
> +CpuToFdt16,
> +(IN UINT16 Value)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +UINT32,
> +Fdt32ToCpu,
> +(IN UINT32 Value)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +UINT32,
> +CpuToFdt32,
> +(IN UINT32 Value)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +UINT64,
> +Fdt64ToCpu,
> +(IN UINT64 Value)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +UINT64,
> +CpuToFdt64,
> +(IN UINT64 Value)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +INT32,
> +FdtCheckHeader,
> +(IN CONST VOID  *Fdt)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +INT32,
> +FdtCreateEmptyTree,
> +(IN VOID*Buffer,
> + IN UINT32  BufferSize)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +INT32,
> +FdtNextNode,
> +(IN CONST VOID  *Fdt,
> + IN INT32   Offset,
> + IN INT32   *Depth)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +INT32,
> +FdtFirstSubnode,
> +(IN CONST VOID  *Fdt,
> + IN INT32   Offset)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +INT32,
> +FdtNextSubnode,
> +(IN CONST VOID  *Fdt,
> + IN INT32   Offset)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +INT32,
> +FdtSubnodeOffsetNameLen,
> +(IN CONST VOID   *Fdt,
> + IN INT32ParentOffset,
> + IN CONST CHAR8  *Name,
> + IN INT32NameLength)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +INT32,
> +FdtNodeOffsetByPropValue,
> +(IN CONST VOID   *Fdt,
> + IN INT32StartOffset,
> + IN CONST CHAR8  *PropertyName,
> + IN CONST VOID   *PropertyValue,
> + IN INT32PropertyLength)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +CONST FDT_PROPERTY *,
> +FdtGetProperty,
> +(IN CONST VOID   *Fdt,
> + IN INT32NodeOffset,
> + IN CONST CHAR8  *Name,
> + IN INT32*Length)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +INT32,
> +FdtFirstPropertyOffset,
> +(IN CONST VOID  *Fdt,
> + IN INT32   NodeOffset)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +INT32,
> +FdtNextPropertyOffset,
> +(IN CONST VOID  *Fdt,
> + IN INT32   NodeOffset)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +CONST FDT_PROPERTY *,
> +FdtGetPropertyByOffset,
> +(IN CONST VOID  *Fdt,
> + IN INT32   Offset,
> + IN INT32   *Length)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +CONST CHAR8 *,
> +FdtGetString,
> +(IN CONST VOID  *Fdt,
> + IN INT32   StrOffset,
> + IN INT32   *LengthOPTIONAL)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +INT32,
> +FdtAddSubnode,
> +(IN VOID *Fdt,
> + IN INT32ParentOffset,
> + IN CONST CHAR8  *Name)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +INT32,
> +FdtSetProp,
> +(IN VOID *Fdt,
> + IN INT32NodeOffset,
> + IN CONST CHAR8  *Name,
> + IN CONST VOID   *Value,
> + IN UINT32   Length)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +CONST CHAR8 *,
> +FdtGetName,
> +(IN VOID*Fdt,
> + IN INT32   NodeOffset,
> + IN UINT32  *Length)
> +);
> +  MOCK_FUNCTION_DECLARATION (
> +

Re: [edk2-devel] [PATCH] MdePkg/BaseFdtLib: Rename standard functions

2024-01-23 Thread Jeff Brasen via groups.io
CC the maintainers which I missed in the email on this originally.

> -Original Message-
> From: Jeff Brasen 
> Sent: Monday, December 11, 2023 9:53 AM
> To: Pedro Falcato ; devel@edk2.groups.io
> Subject: RE: [edk2-devel] [PATCH] MdePkg/BaseFdtLib: Rename standard
> functions
> 
> Hit send before adding the cc on this one. (Would probably be good to get
> that added to here
> (https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-
> Development-Process) so copy paste doesn't get folks .
> 
> I sent them as different patch series as I thought this one might cause some
> discussion and wanted to separate it from that.
> 
> This issue I was seeing is if you both include FdtLib and BaseCryptLib they
> both contain implementations of these standard functions with other
> functions in the same c files. This results in a link error as the linker 
> won't
> discard part of a compilation unit if it is used so if you have
> 
> Foo.c has functions func1 and func2
> Bar.c has functions func3 and func2
> 
> If func3 and func1 are both used externally that will cause both objects to be
> included and the linker to complain that func2 is defined twice.
> 
> We could move these to c files with just 1 function each in both libraries but
> that seemed like a bigger change than this.
> 
> -Jeff
> 
> 
> > -Original Message-
> > From: Pedro Falcato 
> > Sent: Monday, December 11, 2023 9:00 AM
> > To: devel@edk2.groups.io; Jeff Brasen 
> > Subject: Re: [edk2-devel] [PATCH] MdePkg/BaseFdtLib: Rename standard
> > functions
> >
> > External email: Use caution opening links or attachments
> >
> >
> > On Mon, Dec 11, 2023 at 3:40 PM Jeff Brasen via groups.io
> >  wrote:
> > >
> >
> > Jeff,
> >
> > You're missing CC's on this patch. Also, you should probably send the
> > 3 patches in a single series, since they're all related.
> >
> > > Rename the standard functions in the LibFdtSupport to remove
> > > conflicts with other libraries that define them.
> >
> > This is a funny problem. What error were you seeing? As far as I can
> > tell, you can totally define your local C library functions, it
> > shouldn't result in any linker errors (even if, IIRC, deemed UB by the C
> spec).
> >
> > --
> > Pedro


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




[edk2-devel] [PATCH v2 3/3] EmbeddedPkg: Add DtPlatformLoaderLib gmock support

2023-12-28 Thread Jeff Brasen via groups.io
Add Google Mock Library for DtPlatformLoaderDtbLib

Signed-off-by: Jeff Brasen 
---
 EmbeddedPkg/EmbeddedPkg.dec   |  1 +
 .../MockDtPlatformDtbLoaderLib.inf| 29 +
 .../Library/MockDtPlatformDtbLoaderLib.h  | 31 +++
 .../MockDtPlatformDtbLoaderLib.cpp| 13 
 4 files changed, 74 insertions(+)
 create mode 100644 
EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.inf
 create mode 100644 
EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtbLoaderLib.h
 create mode 100644 
EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.cpp

diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec
index 94dc3c9b76ca..b4834e8b4f88 100644
--- a/EmbeddedPkg/EmbeddedPkg.dec
+++ b/EmbeddedPkg/EmbeddedPkg.dec
@@ -28,6 +28,7 @@ [Defines]
 

 [Includes.common]
   Include# Root include for the package
+  Test/Mock/Include
 
 [LibraryClasses.common]
   PrePiLib|Include/Library/PrePiLib.h
diff --git 
a/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.inf
 
b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.inf
new file mode 100644
index ..9618efd86470
--- /dev/null
+++ 
b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.inf
@@ -0,0 +1,29 @@
+## @file
+# Google Test mocks for MockDtPlatformDtbLoaderLib
+#
+# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# Copyright (c) 2023, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = MockDtPlatformDtbLoaderLib
+  FILE_GUID  = 34c05e81-3c56-4c78-b4b7-a39be19163a4
+  MODULE_TYPE= HOST_APPLICATION
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = DtPlatformDtbLoaderLib
+
+[Sources]
+MockDtPlatformDtbLoaderLib.cpp
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+  UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+  GoogleTestLib
+
+[BuildOptions]
+  MSFT:*_*_*_CC_FLAGS = /EHsc
diff --git 
a/EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtbLoaderLib.h 
b/EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtbLoaderLib.h
new file mode 100644
index ..ce0fca2c3293
--- /dev/null
+++ 
b/EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtbLoaderLib.h
@@ -0,0 +1,31 @@
+/** @file
+  Google Test mocks for DtPlatformDtbLoaderLib
+
+  Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef MOCK_DT_PLATFORM_DTB_LOADER_LIB_H_
+#define MOCK_DT_PLATFORM_DTB_LOADER_LIB_H_
+
+#include 
+#include 
+extern "C" {
+  #include 
+  #include 
+  #include 
+}
+
+struct MockDtPlatformDtbLoaderLib {
+  MOCK_INTERFACE_DECLARATION (MockDtPlatformDtbLoaderLib);
+
+  MOCK_FUNCTION_DECLARATION (
+EFI_STATUS,
+DtPlatformLoadDtb,
+(OUT   VOID   **Dtb,
+ OUT   UINTN  *DtbSize)
+);
+};
+
+#endif
diff --git 
a/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.cpp
 
b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.cpp
new file mode 100644
index ..a5db68e59a09
--- /dev/null
+++ 
b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.cpp
@@ -0,0 +1,13 @@
+/** @file
+  Google Test mocks for MockDtPlatformDtbLoaderLib
+
+  Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include 
+
+MOCK_INTERFACE_DEFINITION (MockDtPlatformDtbLoaderLib);
+
+MOCK_FUNCTION_DEFINITION (MockDtPlatformDtbLoaderLib, DtPlatformLoadDtb, 2, 
EFIAPI);
-- 
2.34.1



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




[edk2-devel] [PATCH v2 1/3] EmbeddedPkg/PrePiMemoryAllocationLib: Add ReallocatePool

2023-12-28 Thread Jeff Brasen via groups.io
Add implementation of ReallocatePool which is defined in the
MemoryAllocationLib header file to allow components to not
need special handling for PrePi module types.

Signed-off-by: Jeff Brasen 
---
 .../MemoryAllocationLib.c | 57 +++
 1 file changed, 57 insertions(+)

diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c 
b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
index 08a0add340cf..fa81cc9d595a 100644
--- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
+++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
@@ -269,3 +269,60 @@ FreePool (
 {
   // Not implemented yet
 }
+
+/**
+  Reallocates a buffer of type EfiBootServicesData.
+
+  Allocates and zeros the number bytes specified by NewSize from memory of type
+  EfiBootServicesData.  If OldBuffer is not NULL, then the smaller of OldSize 
and
+  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
+  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.
+  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not
+  enough memory remaining to satisfy the request, then NULL is returned.
+
+  If the allocation of the new buffer is successful and the smaller of NewSize 
and OldSize
+  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
+
+  @param  OldSizeThe size, in bytes, of OldBuffer.
+  @param  NewSizeThe size, in bytes, of the buffer to reallocate.
+  @param  OldBuffer  The buffer to copy to the allocated buffer.  This is 
an optional
+ parameter that may be NULL.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+ReallocatePool (
+  IN UINTN  OldSize,
+  IN UINTN  NewSize,
+  IN VOID   *OldBuffer  OPTIONAL
+  )
+{
+  VOID  *NewBuffer;
+
+  // Validate the OldBuffer is HobAllocated.
+  DEBUG_CODE_BEGIN ();
+  EFI_HOB_HANDOFF_INFO_TABLE  *HandOffHob;
+
+  if (OldBuffer != NULL) {
+HandOffHob = GetHobList ();
+ASSERT (((EFI_PHYSICAL_ADDRESS)(UINTN)OldBuffer >= 
HandOffHob->EfiMemoryBottom));
+ASSERT (((EFI_PHYSICAL_ADDRESS)(UINTN)(OldBuffer + OldSize) <= 
HandOffHob->EfiFreeMemoryBottom));
+  }
+
+  DEBUG_CODE_END ();
+
+  // If new buffer would be smaller just return old buffer as FreePool isn't 
supported.
+  if ((OldBuffer != NULL) && (OldSize >= NewSize)) {
+return OldBuffer;
+  }
+
+  NewBuffer = AllocateZeroPool (NewSize);
+  if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
+CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
+FreePool (OldBuffer);
+  }
+
+  return NewBuffer;
+}
-- 
2.34.1



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




[edk2-devel] [PATCH v2 2/3] EmbeddedPkg: Add host based dependency to ci

2023-12-28 Thread Jeff Brasen via groups.io
Add UnitTestFrameworkPkg to AcceptableDependencies-HOST_APPLICATION list

Signed-off-by: Jeff Brasen 
---
 EmbeddedPkg/EmbeddedPkg.ci.yaml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/EmbeddedPkg/EmbeddedPkg.ci.yaml b/EmbeddedPkg/EmbeddedPkg.ci.yaml
index 96a60a6f8b4d..6d042fc721ab 100644
--- a/EmbeddedPkg/EmbeddedPkg.ci.yaml
+++ b/EmbeddedPkg/EmbeddedPkg.ci.yaml
@@ -50,7 +50,9 @@
 "MdePkg/MdePkg.dec"
 ],
 # For host based unit tests
-"AcceptableDependencies-HOST_APPLICATION":[],
+"AcceptableDependencies-HOST_APPLICATION":[
+"UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec"
+],
 # For UEFI shell based apps
 "AcceptableDependencies-UEFI_APPLICATION":[],
 "IgnoreInf": []
-- 
2.34.1



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




[edk2-devel] [PATCH v2 0/3] EmbeddedPkg ReallocatePool and Mock changes

2023-12-28 Thread Jeff Brasen via groups.io
Adding Mock support for DtPlatformLoaderLib and changing ci.yaml to support this
Adding ReallocatePool support to PrePi Library.

Passing CI in https://github.com/tianocore/edk2/pull/5197

Change log
v2 -
  Fix uncrustify errors
  Fix ci allowed packages entries
  Fix cast on 32-bit systems

Jeff Brasen (3):
  EmbeddedPkg/PrePiMemoryAllocationLib: Add ReallocatePool
  EmbeddedPkg: Add host based dependency to ci
  EmbeddedPkg: Add DtPlatformLoaderLib gmock support

 EmbeddedPkg/EmbeddedPkg.dec   |  1 +
 .../MockDtPlatformDtbLoaderLib.inf| 29 ++
 .../Library/MockDtPlatformDtbLoaderLib.h  | 31 ++
 .../MemoryAllocationLib.c | 57 +++
 EmbeddedPkg/EmbeddedPkg.ci.yaml   |  4 +-
 .../MockDtPlatformDtbLoaderLib.cpp| 13 +
 6 files changed, 134 insertions(+), 1 deletion(-)
 create mode 100644 
EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.inf
 create mode 100644 
EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtbLoaderLib.h
 create mode 100644 
EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.cpp

-- 
2.34.1



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




Re: [edk2-devel] [PATCH] EmbeddedPkg/PrePiMemoryAllocationLib: Add ReallocatePool

2023-12-28 Thread Jeff Brasen via groups.io
Looks like I missed an UINTN cast will fix and push a v2.


> -Original Message-
> From: Ard Biesheuvel 
> Sent: Thursday, December 21, 2023 7:54 AM
> To: Chang, Abner 
> Cc: Jeff Brasen ; devel@edk2.groups.io;
> ardb+tianoc...@kernel.org; quic_llind...@quicinc.com
> Subject: Re: [PATCH] EmbeddedPkg/PrePiMemoryAllocationLib: Add
> ReallocatePool
> 
> External email: Use caution opening links or attachments
> 
> 
> On Thu, 21 Dec 2023 at 15:39, Ard Biesheuvel  wrote:
> >
> > On Mon, 18 Dec 2023 at 03:23, Chang, Abner 
> wrote:
> > >
> > > [AMD Official Use Only - General]
> > >
> > > Reviewed-by: Abner Chang 
> > >
> >
> > I've queued this up, along with the mock one - thanks.
> >
> 
> Rejected by CI:
> https://github.com/tianocore/edk2/pull/5184


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




Re: [edk2-devel] [PATCH] MdePkg/BaseFdtLib: Rename standard functions

2023-12-11 Thread Jeff Brasen via groups.io
Hit send before adding the cc on this one. (Would probably be good to get that 
added to here 
(https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Development-Process)
 so copy paste doesn't get folks .

I sent them as different patch series as I thought this one might cause some 
discussion and wanted to separate it from that. 

This issue I was seeing is if you both include FdtLib and BaseCryptLib they 
both contain implementations of these standard functions with other functions 
in the same c files. This results in a link error as the linker won't discard 
part of a compilation unit if it is used so if you have

Foo.c has functions func1 and func2
Bar.c has functions func3 and func2

If func3 and func1 are both used externally that will cause both objects to be 
included and the linker to complain that func2 is defined twice.

We could move these to c files with just 1 function each in both libraries but 
that seemed like a bigger change than this.

-Jeff


> -Original Message-
> From: Pedro Falcato 
> Sent: Monday, December 11, 2023 9:00 AM
> To: devel@edk2.groups.io; Jeff Brasen 
> Subject: Re: [edk2-devel] [PATCH] MdePkg/BaseFdtLib: Rename standard
> functions
> 
> External email: Use caution opening links or attachments
> 
> 
> On Mon, Dec 11, 2023 at 3:40 PM Jeff Brasen via groups.io
>  wrote:
> >
> 
> Jeff,
> 
> You're missing CC's on this patch. Also, you should probably send the
> 3 patches in a single series, since they're all related.
> 
> > Rename the standard functions in the LibFdtSupport to remove conflicts
> > with other libraries that define them.
> 
> This is a funny problem. What error were you seeing? As far as I can tell, you
> can totally define your local C library functions, it shouldn't result in any 
> linker
> errors (even if, IIRC, deemed UB by the C spec).
> 
> --
> Pedro


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




[edk2-devel] [PATCH] EmbeddedPkg/PrePiMemoryAllocationLib: Add ReallocatePool

2023-12-11 Thread Jeff Brasen via groups.io
Add implementation of ReallocatePool which is defined in the
MemoryAllocationLib header file to allow components to not
need special handling for PrePi module types.

Signed-off-by: Jeff Brasen 
---
 .../MemoryAllocationLib.c | 57 +++
 1 file changed, 57 insertions(+)

diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c 
b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
index 08a0add340..39fbe243dd 100644
--- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
+++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
@@ -269,3 +269,60 @@ FreePool (
 {
   // Not implemented yet
 }
+
+/**
+  Reallocates a buffer of type EfiBootServicesData.
+
+  Allocates and zeros the number bytes specified by NewSize from memory of type
+  EfiBootServicesData.  If OldBuffer is not NULL, then the smaller of OldSize 
and
+  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
+  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.
+  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not
+  enough memory remaining to satisfy the request, then NULL is returned.
+
+  If the allocation of the new buffer is successful and the smaller of NewSize 
and OldSize
+  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
+
+  @param  OldSizeThe size, in bytes, of OldBuffer.
+  @param  NewSizeThe size, in bytes, of the buffer to reallocate.
+  @param  OldBuffer  The buffer to copy to the allocated buffer.  This is 
an optional
+ parameter that may be NULL.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+ReallocatePool (
+  IN UINTN  OldSize,
+  IN UINTN  NewSize,
+  IN VOID   *OldBuffer  OPTIONAL
+  )
+{
+  VOID  *NewBuffer;
+
+  // Validate the OldBuffer is HobAllocated.
+  DEBUG_CODE_BEGIN ();
+  EFI_HOB_HANDOFF_INFO_TABLE  *HandOffHob;
+
+  if (OldBuffer != NULL) {
+HandOffHob = GetHobList ();
+ASSERT (((EFI_PHYSICAL_ADDRESS)OldBuffer >= HandOffHob->EfiMemoryBottom));
+ASSERT (((EFI_PHYSICAL_ADDRESS)(OldBuffer + OldSize) <= 
HandOffHob->EfiFreeMemoryBottom));
+  }
+
+  DEBUG_CODE_END ();
+
+  // If new buffer would be smaller just return old buffer as FreePool isn't 
supported.
+  if ((OldBuffer != NULL) && (OldSize >= NewSize)) {
+return OldBuffer;
+  }
+
+  NewBuffer = AllocateZeroPool (NewSize);
+  if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
+CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
+FreePool (OldBuffer);
+  }
+
+  return NewBuffer;
+}
-- 
2.34.1



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




[edk2-devel] [PATCH] EmbeddedPkg: Add DtPlatformLoaderLib gmock support

2023-12-11 Thread Jeff Brasen via groups.io
Add Google Mock Library for DtPlatformLoaderDtbLib

Signed-off-by: Jeff Brasen 
---
 EmbeddedPkg/EmbeddedPkg.dec   |  1 +
 .../Library/MockDtPlatformDtbLoaderLib.h  | 31 +++
 .../MockDtPlatformDtbLoaderLib.cpp| 13 
 .../MockDtPlatformDtbLoaderLib.inf| 29 +
 4 files changed, 74 insertions(+)
 create mode 100644 
EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtbLoaderLib.h
 create mode 100644 
EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.cpp
 create mode 100644 
EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.inf

diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec
index 94dc3c9b76..b4834e8b4f 100644
--- a/EmbeddedPkg/EmbeddedPkg.dec
+++ b/EmbeddedPkg/EmbeddedPkg.dec
@@ -28,6 +28,7 @@
 

 [Includes.common]
   Include# Root include for the package
+  Test/Mock/Include
 
 [LibraryClasses.common]
   PrePiLib|Include/Library/PrePiLib.h
diff --git 
a/EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtbLoaderLib.h 
b/EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtbLoaderLib.h
new file mode 100644
index 00..23dab21668
--- /dev/null
+++ 
b/EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtbLoaderLib.h
@@ -0,0 +1,31 @@
+/** @file
+  Google Test mocks for DtPlatformDtbLoaderLib
+
+  Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef MOCK_DT_PLATFORM_DTB_LOADER_LIB_H_
+#define MOCK_DT_PLATFORM_DTB_LOADER_LIB_H_
+
+#include 
+#include 
+extern "C" {
+#include 
+#include 
+#include 
+}
+
+struct MockDtPlatformDtbLoaderLib {
+  MOCK_INTERFACE_DECLARATION (MockDtPlatformDtbLoaderLib);
+
+  MOCK_FUNCTION_DECLARATION (
+EFI_STATUS,
+DtPlatformLoadDtb,
+(OUT   VOID   **Dtb,
+ OUT   UINTN  *DtbSize)
+);
+};
+
+#endif
diff --git 
a/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.cpp
 
b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.cpp
new file mode 100644
index 00..a5db68e59a
--- /dev/null
+++ 
b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.cpp
@@ -0,0 +1,13 @@
+/** @file
+  Google Test mocks for MockDtPlatformDtbLoaderLib
+
+  Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include 
+
+MOCK_INTERFACE_DEFINITION (MockDtPlatformDtbLoaderLib);
+
+MOCK_FUNCTION_DEFINITION (MockDtPlatformDtbLoaderLib, DtPlatformLoadDtb, 2, 
EFIAPI);
diff --git 
a/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.inf
 
b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.inf
new file mode 100644
index 00..9618efd864
--- /dev/null
+++ 
b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.inf
@@ -0,0 +1,29 @@
+## @file
+# Google Test mocks for MockDtPlatformDtbLoaderLib
+#
+# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# Copyright (c) 2023, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = MockDtPlatformDtbLoaderLib
+  FILE_GUID  = 34c05e81-3c56-4c78-b4b7-a39be19163a4
+  MODULE_TYPE= HOST_APPLICATION
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = DtPlatformDtbLoaderLib
+
+[Sources]
+MockDtPlatformDtbLoaderLib.cpp
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+  UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+  GoogleTestLib
+
+[BuildOptions]
+  MSFT:*_*_*_CC_FLAGS = /EHsc
-- 
2.34.1



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




[edk2-devel] [PATCH] MdePkg: Add FdtLib gmock support

2023-12-11 Thread Jeff Brasen via groups.io
Add Google Mock Library for FdtLib

Signed-off-by: Jeff Brasen 
---
 .../Include/GoogleTest/Library/MockFdtLib.h   | 165 ++
 .../GoogleTest/MockFdtLib/MockFdtLib.cpp  |  34 
 .../GoogleTest/MockFdtLib/MockFdtLib.inf  |  28 +++
 3 files changed, 227 insertions(+)
 create mode 100644 MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
 create mode 100644 
MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp
 create mode 100644 
MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf

diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h 
b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
new file mode 100644
index 00..c0aeaa25c0
--- /dev/null
+++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
@@ -0,0 +1,165 @@
+/** @file
+  Google Test mocks for FdtLib
+
+  Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef MOCK_FDT_LIB_H_
+#define MOCK_FDT_LIB_H_
+
+#include 
+#include 
+extern "C" {
+#include 
+#include 
+#include 
+}
+
+struct MockFdtLib {
+  MOCK_INTERFACE_DECLARATION (MockFdtLib);
+
+  MOCK_FUNCTION_DECLARATION (
+UINT16,
+Fdt16ToCpu,
+(IN UINT16 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT16,
+CpuToFdt16,
+(IN UINT16 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT32,
+Fdt32ToCpu,
+(IN UINT32 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT32,
+CpuToFdt32,
+(IN UINT32 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT64,
+Fdt64ToCpu,
+(IN UINT64 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+UINT64,
+CpuToFdt64,
+(IN UINT64 Value)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtCheckHeader,
+(IN CONST VOID  *Fdt)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtCreateEmptyTree,
+(IN VOID*Buffer,
+ IN UINT32  BufferSize)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtNextNode,
+(IN CONST VOID  *Fdt,
+ IN INT32   Offset,
+ IN INT32   *Depth)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtFirstSubnode,
+(IN CONST VOID  *Fdt,
+ IN INT32   Offset)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtNextSubnode,
+(IN CONST VOID  *Fdt,
+ IN INT32   Offset)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtSubnodeOffsetNameLen,
+(IN CONST VOID   *Fdt,
+ IN INT32ParentOffset,
+ IN CONST CHAR8  *Name,
+ IN INT32NameLength)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtNodeOffsetByPropValue,
+(IN CONST VOID   *Fdt,
+ IN INT32StartOffset,
+ IN CONST CHAR8  *PropertyName,
+ IN CONST VOID   *PropertyValue,
+ IN INT32PropertyLength)
+);
+  MOCK_FUNCTION_DECLARATION (
+CONST FDT_PROPERTY *,
+FdtGetProperty,
+(IN CONST VOID   *Fdt,
+ IN INT32NodeOffset,
+ IN CONST CHAR8  *Name,
+ IN INT32*Length)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtFirstPropertyOffset,
+(IN CONST VOID  *Fdt,
+ IN INT32   NodeOffset)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtNextPropertyOffset,
+(IN CONST VOID  *Fdt,
+ IN INT32   NodeOffset)
+);
+  MOCK_FUNCTION_DECLARATION (
+CONST FDT_PROPERTY *,
+FdtGetPropertyByOffset,
+(IN CONST VOID  *Fdt,
+ IN INT32   Offset,
+ IN INT32   *Length)
+);
+  MOCK_FUNCTION_DECLARATION (
+CONST CHAR8 *,
+FdtGetString,
+(IN CONST VOID  *Fdt,
+ IN INT32   StrOffset,
+ IN INT32   *LengthOPTIONAL)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtAddSubnode,
+(IN VOID *Fdt,
+ IN INT32ParentOffset,
+ IN CONST CHAR8  *Name)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtSetProp,
+(IN VOID *Fdt,
+ IN INT32NodeOffset,
+ IN CONST CHAR8  *Name,
+ IN CONST VOID   *Value,
+ IN UINT32   Length)
+);
+  MOCK_FUNCTION_DECLARATION (
+CONST CHAR8 *,
+FdtGetName,
+(IN VOID*Fdt,
+ IN INT32   NodeOffset,
+ IN UINT32  *Length)
+);
+  MOCK_FUNCTION_DECLARATION (
+INT32,
+FdtNodeDepth,
+(IN CONST VOID  *Fdt,
+ IN INT32   NodeOffset)
+);
+};
+
+#endif
diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp 
b/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp
new file mode 100644
index 00..a955780d23
--- /dev/null
+++ b/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp
@@ -0,0 +1,34 @@
+/** @file
+  Google Test mocks for FdtLib
+
+  Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include 
+

[edk2-devel] [PATCH] MdePkg/BaseFdtLib: Rename standard functions

2023-12-11 Thread Jeff Brasen via groups.io
Rename the standard functions in the LibFdtSupport to remove conflicts
with other libraries that define them.

Signed-off-by: Jeff Brasen 
---
 MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 16 +++
 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 25 ++-
 2 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/MdePkg/Library/BaseFdtLib/LibFdtSupport.h 
b/MdePkg/Library/BaseFdtLib/LibFdtSupport.h
index 393019324b..47beac9fac 100644
--- a/MdePkg/Library/BaseFdtLib/LibFdtSupport.h
+++ b/MdePkg/Library/BaseFdtLib/LibFdtSupport.h
@@ -68,6 +68,12 @@ strrchr(
   int
   );
 
+char *
+fdt_strrchr(
+  const char *,
+  int
+  );
+
 unsigned long
 strtoul (
   const char *,
@@ -75,6 +81,13 @@ strtoul (
   int
   );
 
+unsigned long
+fdt_strtoul (
+  const char *,
+  char **,
+  int
+  );
+
 char *
 strcpy (
   char*strDest,
@@ -93,7 +106,10 @@ strcpy (
 #define strnlen(str, count) (size_t)(AsciiStrnLenS(str, count))
 #define strncpy(strDest, strSource, count)  AsciiStrnCpyS(strDest, 
MAX_STRING_SIZE, strSource, (UINTN)count)
 #define strcat(strDest, strSource)  AsciiStrCatS(strDest, 
MAX_STRING_SIZE, strSource)
+#define strchr(str, ch) ScanMem8(str, AsciiStrSize (str), 
(UINT8)ch)
 #define strcmp(string1, string2, count) (int)(AsciiStrCmp(string1, 
string2))
 #define strncmp(string1, string2, count)(int)(AsciiStrnCmp(string1, 
string2, (UINTN)(count)))
+#define strrchr(str, ch)fdt_strrchr(str, ch)
+#define strtoul(ptr, end_ptr, base) fdt_strtoul(ptr, end_ptr, base)
 
 #endif /* FDT_LIB_SUPPORT_H_ */
diff --git a/MdePkg/Library/BaseFdtLib/LibFdtWrapper.c 
b/MdePkg/Library/BaseFdtLib/LibFdtWrapper.c
index ef6452914f..1a4cd573fd 100644
--- a/MdePkg/Library/BaseFdtLib/LibFdtWrapper.c
+++ b/MdePkg/Library/BaseFdtLib/LibFdtWrapper.c
@@ -18,28 +18,7 @@
 // so the code gets a bit clunky to handle that case specifically.
 
 char *
-strchr (
-  const char  *Str,
-  int Char
-  )
-{
-  char  *S;
-
-  S = (char *)Str;
-
-  for ( ; ; S++) {
-if (*S == Char) {
-  return S;
-}
-
-if (*S == '\0') {
-  return NULL;
-}
-  }
-}
-
-char *
-strrchr (
+fdt_strrchr (
   const char  *Str,
   int Char
   )
@@ -71,7 +50,7 @@ __isspace (
 }
 
 unsigned long
-strtoul (
+fdt_strtoul (
   const char  *Nptr,
   char**EndPtr,
   int Base
-- 
2.34.1



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




Re: [edk2-devel] [PATCH v2 0/2] dp command without ACPI

2023-10-30 Thread Jeff Brasen via groups.io
Anything else needed to get this merged as the November stable release is 
coming up.

Thanks,
Jeff

> -Original Message-
> From: Gao, Zhichao 
> Sent: Monday, October 16, 2023 8:39 PM
> To: Jeff Brasen ; Gao, Liming
> ; devel@edk2.groups.io
> Cc: Wang, Jian J ; Bi, Dandan
> 
> Subject: RE: [PATCH v2 0/2] dp command without ACPI
> 
> External email: Use caution opening links or attachments
> 
> 
> Hi Liming,
> 
> This patch set is already reviewed. Can you help on the merge?
> 
> Thanks,
> Zhichao
> 
> > -Original Message-
> > From: Jeff Brasen 
> > Sent: Wednesday, October 4, 2023 10:37 PM
> > To: Gao, Liming ; devel@edk2.groups.io
> > Cc: Wang, Jian J ; Bi, Dandan
> > ; Gao, Zhichao 
> > Subject: RE: [PATCH v2 0/2] dp command without ACPI
> >
> > Anything else needed on this to get it merged?
> >
> > Thanks,
> > Jeff
> >
> > > -Original Message-
> > > From: gaoliming 
> > > Sent: Tuesday, September 12, 2023 6:59 AM
> > > To: Jeff Brasen ; devel@edk2.groups.io
> > > Cc: jian.j.w...@intel.com; dandan...@intel.com;
> > > zhichao@intel.com
> > > Subject: 回复: [PATCH v2 0/2] dp command without ACPI
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > For the change in MdeModulePkg, Reviewed-by: Liming Gao
> > > 
> > >
> > > > -邮件原件-
> > > > 发件人: Jeff Brasen 
> > > > 发送时间: 2023年9月12日 4:39
> > > > 收件人: devel@edk2.groups.io
> > > > 抄送: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> > > > dandan...@intel.com; zhichao@intel.com
> > > > 主题: RE: [PATCH v2 0/2] dp command without ACPI
> > > >
> > > >
> > > > Any additional thoughts/feedback on this patch series?
> > > >
> > > > Thanks,
> > > > Jeff
> > > >
> > > >
> > > > > -Original Message-
> > > > > From: Jeff Brasen 
> > > > > Sent: Friday, June 30, 2023 11:30 AM
> > > > > To: devel@edk2.groups.io
> > > > > Cc: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> > > > dandan...@intel.com;
> > > > > zhichao@intel.com; Jeff Brasen 
> > > > > Subject: [PATCH v2 0/2] dp command without ACPI
> > > > >
> > > > > Systems that do not boot with ACPI (system that use device tree
> > > > > for
> > > > example)
> > > > > can not use the shell dp command. This patch adds this to the
> > > configuration
> > > > > table so that dp command can get this without the FPDT table.
> > > > >
> > > > > I am open to other ways for this to be passed if desired
> > > > > (Installed
> > > protocol,
> > > > > handler of the status code, etc) but wanted to post this to at
> > > > > least get thoughts on this.
> > > > >
> > > > > Change Log
> > > > > v2 - Fix missing cast for IA32 builds
> > > > >
> > > > > -Jeff
> > > > >
> > > > > Jeff Brasen (2):
> > > > >   MdeModulePkg/DxeCorePerformanceLib: Install BPDT in config
> table
> > > > >   ShellPkg/Dp: Allow dp command to work without ACPI
> > > > >
> > > > >  ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf|  1 +
> > > > >  .../DpDynamicCommand/DpDynamicCommand.inf |  1 +
> > > > >  .../DxeCorePerformanceLib/DxeCorePerformanceLib.c |  2 ++
> > > > >  ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 11
> > > > -
> > > > > --
> > > > >  4 files changed, 12 insertions(+), 3 deletions(-)
> > > > >
> > > > > --
> > > > > 2.25.1
> > >
> > >



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




Re: [edk2-devel] [PATCH] MdeModulePkg/DxeCore: Allow relocation of images with large address

2023-10-30 Thread Jeff Brasen via groups.io
Anything else needed to get this merged would as the November stable release is 
coming up.

Thanks,
Jeff

> -Original Message-
> From: gaoliming 
> Sent: Friday, October 6, 2023 11:23 PM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: jian.j.w...@intel.com; dandan...@intel.com; Ashish Singhal
> ; michael.d.kin...@intel.com
> Subject: 回复: [PATCH] MdeModulePkg/DxeCore: Allow relocation of
> images with large address
> 
> External email: Use caution opening links or attachments
> 
> 
> Jeff:
>   I have no better solution than your proposal for this problem. So, this 
> patch
> is good to me. Reviewed-by: Liming Gao 
> 
> Thanks
> Liming
> > -邮件原件-
> > 发件人: Jeff Brasen 
> > 发送时间: 2023年9月12日 4:14
> > 收件人: devel@edk2.groups.io
> > 抄送: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> > dandan...@intel.com; Ashish Singhal 
> > 主题: RE: [PATCH] MdeModulePkg/DxeCore: Allow relocation of images
> with
> > large address
> >
> > Any  thoughts/feedback on this patch?
> >
> > Thanks,
> > Jeff
> >
> >
> > > -Original Message-
> > > From: Jeff Brasen 
> > > Sent: Monday, May 15, 2023 5:49 PM
> > > To: devel@edk2.groups.io
> > > Cc: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> > dandan...@intel.com;
> > > Jeff Brasen ; Ashish Singhal
> > > 
> > > Subject: [PATCH] MdeModulePkg/DxeCore: Allow relocation of images
> > > with large address
> > >
> > > Add PCD to control if modules with start addresses in PE/COFF >
> > > 0x10 attempt to load at specified address.
> > > If a module has an address in this range and there is untested
> > > memory DxeCore will attempt to promote all memory to tested which
> > > bypasses any memory testing that would occur later in boot.
> > >
> > > There are several existing AARCH64 option roms that have base
> > > addresses
> > of
> > > 0x18000.
> > >
> > > Signed-off-by: Jeff Brasen 
> > > Reviewed-by: Ashish Singhal 
> > > ---
> > >  MdeModulePkg/Core/Dxe/DxeMain.inf   | 1 +
> > >  MdeModulePkg/Core/Dxe/Image/Image.c | 4 +++-
> > >  MdeModulePkg/MdeModulePkg.dec   | 7 +++
> > >  3 files changed, 11 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf
> > > b/MdeModulePkg/Core/Dxe/DxeMain.inf
> > > index 35d5bf0dee..16871f2021 100644
> > > --- a/MdeModulePkg/Core/Dxe/DxeMain.inf
> > > +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
> > > @@ -187,6 +187,7 @@
> > >gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask
> > > ## CONSUMES
> > >gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard
> > ##
> > > CONSUMES
> > >
> >
> gEfiMdeModulePkgTokenSpaceGuid.PcdFwVolDxeMaxEncapsulationDepth
> > > ## CONSUMES
> > > +  gEfiMdeModulePkgTokenSpaceGuid.PcdImageLargeAddressLoad
> > > ## CONSUMES
> > >
> > >  # [Hob]
> > >  # RESOURCE_DESCRIPTOR   ## CONSUMES
> > > diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c
> > > b/MdeModulePkg/Core/Dxe/Image/Image.c
> > > index 9dbfb2a1fa..6bc3a549ae 100644
> > > --- a/MdeModulePkg/Core/Dxe/Image/Image.c
> > > +++ b/MdeModulePkg/Core/Dxe/Image/Image.c
> > > @@ -680,7 +680,9 @@ CoreLoadPeImage (
> > > );
> > >}
> > >  } else {
> > > -  if ((Image->ImageContext.ImageAddress >= 0x10) || Image-
> > > >ImageContext.RelocationsStripped) {
> > > +  if ((PcdGetBool (PcdImageLargeAddressLoad) && ((Image-
> > > >ImageContext.ImageAddress) >= 0x10)) ||
> > > +  Image->ImageContext.RelocationsStripped)
> > > +  {
> > >  Status = CoreAllocatePages (
> > > AllocateAddress,
> > > (EFI_MEMORY_TYPE)(Image-
> > > >ImageContext.ImageCodeMemoryType),
> > > diff --git a/MdeModulePkg/MdeModulePkg.dec
> > > b/MdeModulePkg/MdeModulePkg.dec index 95dd077e19..6fd1bd7b8f
> > > 100644
> > > --- a/MdeModulePkg/MdeModulePkg.dec
> > > +++ b/MdeModulePkg/MdeModulePkg.dec
> > > @@ -1116,6 +1116,13 @@
> > ># @Prompt Output MMIO address of Trace Hub message.
> > >
> > >
> >
> gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugMmioAddress|0|UI
> N
> > > T64|0x30001058
> > >
> > > +  ## Indicates if images with large load address (>0x10) should
> > > attempted to load at specified location.
> > > +  #  If enabled, attempt to allocate at specfied location will be
> attempted
> > with
> > > a fall back to any address.
> > > +  #   TRUE  - UEFI will attempt to load at specified location.
> > > +  #   FALSE - UEFI will load at any address
> > > +  # @Prompt Enable large address image loading.
> > > +
> > > +
> > >
> >
> gEfiMdeModulePkgTokenSpaceGuid.PcdImageLargeAddressLoad|TRUE|BO
> O
> > L
> > > EAN|0
> > > + x30001059
> > > +
> > >  [PcdsFixedAtBuild, PcdsPatchableInModule]
> > >## Dynamic type PCD can be registered callback function for Pcd
> setting
> > > action.
> > >#  PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum
> > > number of callback function
> > > --
> > > 2.25.1
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110333): 

Re: [edk2-devel] [PATCH] MdeModulePkg/DxeCore: Allow relocation of images with large address

2023-10-04 Thread Jeff Brasen via groups.io
Anyone have any thoughts on this patch?

Thanks,
Jeff


> -Original Message-
> From: Jeff Brasen 
> Sent: Monday, September 11, 2023 2:14 PM
> To: devel@edk2.groups.io
> Cc: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> dandan...@intel.com; Ashish Singhal 
> Subject: RE: [PATCH] MdeModulePkg/DxeCore: Allow relocation of images
> with large address
> 
> Any  thoughts/feedback on this patch?
> 
> Thanks,
> Jeff
> 
> 
> > -Original Message-
> > From: Jeff Brasen 
> > Sent: Monday, May 15, 2023 5:49 PM
> > To: devel@edk2.groups.io
> > Cc: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> > dandan...@intel.com; Jeff Brasen ; Ashish Singhal
> > 
> > Subject: [PATCH] MdeModulePkg/DxeCore: Allow relocation of images
> with
> > large address
> >
> > Add PCD to control if modules with start addresses in PE/COFF >
> > 0x10 attempt to load at specified address.
> > If a module has an address in this range and there is untested memory
> > DxeCore will attempt to promote all memory to tested which bypasses
> > any memory testing that would occur later in boot.
> >
> > There are several existing AARCH64 option roms that have base
> > addresses of 0x18000.
> >
> > Signed-off-by: Jeff Brasen 
> > Reviewed-by: Ashish Singhal 
> > ---
> >  MdeModulePkg/Core/Dxe/DxeMain.inf   | 1 +
> >  MdeModulePkg/Core/Dxe/Image/Image.c | 4 +++-
> >  MdeModulePkg/MdeModulePkg.dec   | 7 +++
> >  3 files changed, 11 insertions(+), 1 deletion(-)
> >
> > diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf
> > b/MdeModulePkg/Core/Dxe/DxeMain.inf
> > index 35d5bf0dee..16871f2021 100644
> > --- a/MdeModulePkg/Core/Dxe/DxeMain.inf
> > +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
> > @@ -187,6 +187,7 @@
> >gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask
> > ## CONSUMES
> >gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard  
> >  ##
> > CONSUMES
> >
> gEfiMdeModulePkgTokenSpaceGuid.PcdFwVolDxeMaxEncapsulationDepth
> > ## CONSUMES
> > +  gEfiMdeModulePkgTokenSpaceGuid.PcdImageLargeAddressLoad
> > ## CONSUMES
> >
> >  # [Hob]
> >  # RESOURCE_DESCRIPTOR   ## CONSUMES
> > diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c
> > b/MdeModulePkg/Core/Dxe/Image/Image.c
> > index 9dbfb2a1fa..6bc3a549ae 100644
> > --- a/MdeModulePkg/Core/Dxe/Image/Image.c
> > +++ b/MdeModulePkg/Core/Dxe/Image/Image.c
> > @@ -680,7 +680,9 @@ CoreLoadPeImage (
> > );
> >}
> >  } else {
> > -  if ((Image->ImageContext.ImageAddress >= 0x10) || Image-
> > >ImageContext.RelocationsStripped) {
> > +  if ((PcdGetBool (PcdImageLargeAddressLoad) && ((Image-
> > >ImageContext.ImageAddress) >= 0x10)) ||
> > +  Image->ImageContext.RelocationsStripped)
> > +  {
> >  Status = CoreAllocatePages (
> > AllocateAddress,
> > (EFI_MEMORY_TYPE)(Image-
> > >ImageContext.ImageCodeMemoryType),
> > diff --git a/MdeModulePkg/MdeModulePkg.dec
> > b/MdeModulePkg/MdeModulePkg.dec index 95dd077e19..6fd1bd7b8f
> > 100644
> > --- a/MdeModulePkg/MdeModulePkg.dec
> > +++ b/MdeModulePkg/MdeModulePkg.dec
> > @@ -1116,6 +1116,13 @@
> ># @Prompt Output MMIO address of Trace Hub message.
> >
> >
> gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugMmioAddress|0|UI
> N
> > T64|0x30001058
> >
> > +  ## Indicates if images with large load address (>0x10) should
> > attempted to load at specified location.
> > +  #  If enabled, attempt to allocate at specfied location will be
> > + attempted with
> > a fall back to any address.
> > +  #   TRUE  - UEFI will attempt to load at specified location.
> > +  #   FALSE - UEFI will load at any address
> > +  # @Prompt Enable large address image loading.
> > +
> > +
> >
> gEfiMdeModulePkgTokenSpaceGuid.PcdImageLargeAddressLoad|TRUE|BO
> OL
> > EAN|0
> > + x30001059
> > +
> >  [PcdsFixedAtBuild, PcdsPatchableInModule]
> >## Dynamic type PCD can be registered callback function for Pcd
> > setting action.
> >#  PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum
> > number of callback function
> > --
> > 2.25.1



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




Re: [edk2-devel] [PATCH] ArmPkg/ArmPsciMpServices Add EFI_NOT_READY return

2023-10-04 Thread Jeff Brasen via groups.io
Anything else needed on this to get it merged?

Thanks,
Jeff

> -Original Message-
> From: Ard Biesheuvel 
> Sent: Thursday, September 7, 2023 8:17 AM
> To: devel@edk2.groups.io; Jeff Brasen 
> Cc: quic_llind...@quicinc.com; ardb+tianoc...@kernel.org;
> rebe...@bsdio.com
> Subject: Re: [edk2-devel] [PATCH] ArmPkg/ArmPsciMpServices Add
> EFI_NOT_READY return
> 
> External email: Use caution opening links or attachments
> 
> 
> On Thu, 29 Jun 2023 at 22:47, Jeff Brasen via groups.io
>  wrote:
> >
> > Add EFI_NOT_READY return if the CPU can not be enabled if the
> > processor is already on.
> >
> > This can occur in normal use if the CPU is still being turned off from
> > a previous call when this is called again.
> >
> > Signed-off-by: Jeff Brasen 
> 
> Acked-by: Ard Biesheuvel 
> 
> I'll queue this up - thanks.
> 
> > ---
> >  ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.c | 4
> +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git
> > a/ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.c
> > b/ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.c
> > index f822a9877c..e7f4223513 100644
> > --- a/ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.c
> > +++ b/ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.c
> > @@ -103,7 +103,9 @@ DispatchCpu (
> >
> >ArmCallSmc ();
> >
> > -  if (Args.Arg0 != ARM_SMC_PSCI_RET_SUCCESS) {
> > +  if (Args.Arg0 == ARM_SMC_PSCI_RET_ALREADY_ON) {
> > +Status = EFI_NOT_READY;
> > +  } else if (Args.Arg0 != ARM_SMC_PSCI_RET_SUCCESS) {
> >  DEBUG ((DEBUG_ERROR, "PSCI_CPU_ON call failed: %d\n", Args.Arg0));
> >  Status = EFI_DEVICE_ERROR;
> >}
> > --
> > 2.25.1
> >
> >
> > 
> >
> >


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




Re: [edk2-devel] [PATCH v2 0/2] dp command without ACPI

2023-10-04 Thread Jeff Brasen via groups.io
Anything else needed on this to get it merged?

Thanks,
Jeff

> -Original Message-
> From: gaoliming 
> Sent: Tuesday, September 12, 2023 6:59 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: jian.j.w...@intel.com; dandan...@intel.com; zhichao@intel.com
> Subject: 回复: [PATCH v2 0/2] dp command without ACPI
> 
> External email: Use caution opening links or attachments
> 
> 
> For the change in MdeModulePkg, Reviewed-by: Liming Gao
> 
> 
> > -邮件原件-
> > 发件人: Jeff Brasen 
> > 发送时间: 2023年9月12日 4:39
> > 收件人: devel@edk2.groups.io
> > 抄送: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> > dandan...@intel.com; zhichao@intel.com
> > 主题: RE: [PATCH v2 0/2] dp command without ACPI
> >
> >
> > Any additional thoughts/feedback on this patch series?
> >
> > Thanks,
> > Jeff
> >
> >
> > > -Original Message-
> > > From: Jeff Brasen 
> > > Sent: Friday, June 30, 2023 11:30 AM
> > > To: devel@edk2.groups.io
> > > Cc: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> > dandan...@intel.com;
> > > zhichao@intel.com; Jeff Brasen 
> > > Subject: [PATCH v2 0/2] dp command without ACPI
> > >
> > > Systems that do not boot with ACPI (system that use device tree for
> > example)
> > > can not use the shell dp command. This patch adds this to the
> configuration
> > > table so that dp command can get this without the FPDT table.
> > >
> > > I am open to other ways for this to be passed if desired (Installed
> protocol,
> > > handler of the status code, etc) but wanted to post this to at least
> > > get thoughts on this.
> > >
> > > Change Log
> > > v2 - Fix missing cast for IA32 builds
> > >
> > > -Jeff
> > >
> > > Jeff Brasen (2):
> > >   MdeModulePkg/DxeCorePerformanceLib: Install BPDT in config table
> > >   ShellPkg/Dp: Allow dp command to work without ACPI
> > >
> > >  ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf|  1 +
> > >  .../DpDynamicCommand/DpDynamicCommand.inf |  1 +
> > >  .../DxeCorePerformanceLib/DxeCorePerformanceLib.c |  2 ++
> > >  ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 11
> > -
> > > --
> > >  4 files changed, 12 insertions(+), 3 deletions(-)
> > >
> > > --
> > > 2.25.1
> 
> 



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




Re: [edk2-devel] [PATCH 1/1] DynamicTablesPkg/AmlLib: Define an enum for IsaRanges

2023-09-22 Thread Jeff Brasen via groups.io
Reviewed-by: Jeff Brasen 

> -Original Message-
> From: pierre.gond...@arm.com 
> Sent: Friday, September 22, 2023 8:18 AM
> To: devel@edk2.groups.io
> Cc: Sami Mujawar ; Leif Lindholm
> ; Jeff Brasen 
> Subject: [PATCH 1/1] DynamicTablesPkg/AmlLib: Define an enum for
> IsaRanges
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Pierre Gondois 
> 
> The IsaRange parameter in:
> - AmlCodeGenRdDWordIo()
> - AmlCodeGenRdQWordIo()
> is an hard-coded value. Define an enum for IsarRanges and use it.
> 
> Suggested-by: Leif Lindholm 
> Signed-off-by: Pierre Gondois 
> ---
>  .../Include/Library/AmlLib/AmlLib.h   | 28 +++
>  .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c|  2 +-
>  .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   | 28 +++
>  3 files changed, 27 insertions(+), 31 deletions(-)
> 
> diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> index 8e24cecdd77b..ce81f5876681 100644
> --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> @@ -59,6 +59,18 @@ typedef void *AML_DATA_NODE_HANDLE;
> 
>  #endif // AML_HANDLE
> 
> +/** Enum for ISA Ranges.
> +
> +  See ACPI 6.4 spec, s19.6.34 for more.
> +*/
> +typedef enum {
> +  EAmlIsaRangeReserved = 0,   ///< Reserved.
> +  EAmlIsaRangeNonIsaOnly, ///< NonIsaOnly.
> +  EAmlIsaRangeIsaOnly,///< IsaOnly.
> +  EAmlIsaRangeEntireRange,///< EntireRange.
> +  EAmlIsaRangeMax,///< Max.
> +} EAML_ISA_RANGE;
> +
>  /** Parse the definition block.
> 
>The function parses the whole AML blob. It starts with the ACPI DSDT/SSDT
> @@ -471,11 +483,7 @@ AmlUpdateRdQWord (
>@param [in]  IsMinFixed   Minimum address is fixed.
>@param [in]  IsMaxFixed   Maximum address is fixed.
>@param [in]  IsPosDecode  Decode parameter
> -  @param [in]  IsaRangesPossible values are:
> - 0-Reserved
> - 1-NonISAOnly
> - 2-ISAOnly
> - 3-EntireRange
> +  @param [in]  IsaRangesIsa Range.
>@param [in]  AddressGranularity   Address granularity.
>@param [in]  AddressMinimum   Minimum address.
>@param [in]  AddressMaximum   Maximum address.
> @@ -505,7 +513,7 @@ AmlCodeGenRdDWordIo (
>INBOOLEAN IsMinFixed,
>INBOOLEAN IsMaxFixed,
>INBOOLEAN IsPosDecode,
> -  INUINT8 IsaRanges,
> +  INEAML_ISA_RANGE IsaRanges,
>INUINT32 AddressGranularity,
>INUINT32 AddressMinimum,
>INUINT32 AddressMaximum,
> @@ -702,11 +710,7 @@ AmlCodeGenRdWordBusNumber (
>@param [in]  IsMinFixed   Minimum address is fixed.
>@param [in]  IsMaxFixed   Maximum address is fixed.
>@param [in]  IsPosDecode  Decode parameter
> -  @param [in]  IsaRangesPossible values are:
> - 0-Reserved
> - 1-NonISAOnly
> - 2-ISAOnly
> - 3-EntireRange
> +  @param [in]  IsaRangesIsa Range.
>@param [in]  AddressGranularity   Address granularity.
>@param [in]  AddressMinimum   Minimum address.
>@param [in]  AddressMaximum   Maximum address.
> @@ -736,7 +740,7 @@ AmlCodeGenRdQWordIo (
>INBOOLEAN IsMinFixed,
>INBOOLEAN IsMaxFixed,
>INBOOLEAN IsPosDecode,
> -  INUINT8 IsaRanges,
> +  INEAML_ISA_RANGE IsaRanges,
>INUINT64 AddressGranularity,
>INUINT64 AddressMinimum,
>INUINT64 AddressMaximum,
> diff --git
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera
> tor.c
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera
> tor.c
> index 9ddaddc198fa..87b426ccfe07 100644
> ---
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera
> tor.c
> +++
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGener
> +++ ator.c
> @@ -545,7 +545,7 @@ GeneratePciCrs (
> TRUE,
> TRUE,
> IsPosDecode,
> -   3,
> +   EAmlIsaRangeEntireRange,
> 0,
> AddrMapInfo->PciAddress,
> AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1, 
> diff --
> git
> a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataC
> odeGen.c
> b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataC
> odeGen.c
> index 9c6700b9e08c..707e8182b4c0 100644
> ---
> a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataC
> odeGen.c
> +++
> b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataC
> ode
> +++ Gen.c
> @@ -121,13 +121,13 @@ 

Re: [edk2-devel] [PATCH v4 2/4] DynamicTablesPkg: Add support for simple method invocation.

2023-09-21 Thread Jeff Brasen via groups.io
I see you swapped the order of the functions, that looks good and avoids 
special handling for that case. That looks good to me.

Thanks,

Jeff
From: Sami Mujawar 
Sent: Thursday, September 21, 2023 2:07 PM
To: Jeff Brasen ; devel@edk2.groups.io
Cc: Pierre Gondois ; Swatisri Kantamsetti 
; Ashish Singhal ; nd 

Subject: Re: [PATCH v4 2/4] DynamicTablesPkg: Add support for simple method 
invocation.

External email: Use caution opening links or attachments

Hi Jeff,

Yes, I recorded the integer node and data node creation.

Regards,

Sami Mujawar



From: Jeff Brasen mailto:jbra...@nvidia.com>>
Sent: 21 September 2023 18:38
To: Sami Mujawar mailto:sami.muja...@arm.com>>; 
devel@edk2.groups.io 
mailto:devel@edk2.groups.io>>
Cc: Pierre Gondois mailto:pierre.gond...@arm.com>>; 
Swatisri Kantamsetti mailto:swatis...@nvidia.com>>; 
Ashish Singhal mailto:ashishsin...@nvidia.com>>; nd 
mailto:n...@arm.com>>
Subject: RE: [PATCH v4 2/4] DynamicTablesPkg: Add support for simple method 
invocation.


Only thing I see is if AmlCodeGenInteger fails we don't delete DataNode right?



From: Sami Mujawar mailto:sami.muja...@arm.com>>
Sent: Thursday, September 21, 2023 10:49 AM
To: Jeff Brasen mailto:jbra...@nvidia.com>>; 
devel@edk2.groups.io
Cc: pierre.gond...@arm.com; Swatisri Kantamsetti 
mailto:swatis...@nvidia.com>>; Ashish Singhal 
mailto:ashishsin...@nvidia.com>>; 
n...@arm.com
Subject: Re: [PATCH v4 2/4] DynamicTablesPkg: Add support for simple method 
invocation.



External email: Use caution opening links or attachments



Hi Jeff,

Thank you for this patch.

Please see my response inline marked [SAMI].

Regards,

Sami Mujawar

On 18/09/2023 04:46 pm, Jeff Brasen wrote:

Add support to add Return objects via AML that pass a single integer



argument to the named method.







Signed-off-by: Jeff Brasen 



---



 .../Include/Library/AmlLib/AmlLib.h   |  54 



 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 244 ++



 2 files changed, 298 insertions(+)







diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h



index d201ae9499..b82c7a3ce8 100644



--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h



+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h



@@ -1194,6 +1194,60 @@ AmlCodeGenMethodRetInteger (



   OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNodeOPTIONAL



   );







+/** AML code generation for a method returning a NameString that takes an



+integer argument.



+



+  AmlCodeGenMethodRetNameStringIntegerArgument (



+"MET0", "MET1", 1, TRUE, 3, 5, ParentNode, NewObjectNode



+);



+  is equivalent of the following ASL code:



+Method(MET0, 1, Serialized, 3) {



+  Return (MET1 (5))



+}



+



+  The ASL parameters "ReturnType" and "ParameterTypes" are not asked



+  in this function. They are optional parameters in ASL.



+



+  @param [in]  MethodNameString The new Method's name.



+Must be a NULL-terminated ASL NameString



+e.g.: "MET0", "_SB.MET0", etc.



+The input string is copied.



+  @param [in]  ReturnedNameString   The name of the object returned by the



+method. Optional parameter, can be:



+ - NULL (ignored).



+ - A NULL-terminated ASL NameString.



+   e.g.: "MET0", "_SB.MET0", etc.



+   The input string is copied.



+  @param [in]  NumArgs  Number of arguments.



+Must be 0 <= NumArgs <= 6.



+  @param [in]  IsSerialized TRUE is equivalent to Serialized.



+FALSE is equivalent to NotSerialized.



+Default is NotSerialized in ASL spec.



+  @param [in]  SyncLevelSynchronization level for the method.



+Must be 0 <= SyncLevel <= 15.



+Default is 0 in ASL.



+  @param [in]  IntegerArgument  Argument to pass to the NameString.



+  @param [in]  ParentNode   If provided, set ParentNode as the parent



+of the node created.



+  @param [out] NewObjectNodeIf success, contains the created node.



+



+  @retval EFI_SUCCESS Success.



+  @retval EFI_INVALID_PARAMETER   Invalid parameter.



+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.



+**/



+EFI_STATUS



+EFIAPI



+AmlCodeGenMethodRetNameStringIntegerArgument (



+  IN  CONST CHAR8   

[edk2-devel] [PATCH v2 1/2] DynamicTablesPkg: AML Code generation for I/O ranges

2023-09-21 Thread Jeff Brasen via groups.io
From: Vidya Sagar 

Add helper functions to generate AML Resource Data describing I/O
ranges of four words long. API AmlCodeGenRdQWordIo () is exposed.

Signed-off-by: Jeff Brasen 
---
 .../Include/Library/AmlLib/AmlLib.h   | 67 ++
 .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   | 90 +++
 2 files changed, 157 insertions(+)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 9210c5091548..8e24cecdd77b 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -683,6 +683,73 @@ AmlCodeGenRdWordBusNumber (
   OUT   AML_DATA_NODE_HANDLE*NewRdNode  OPTIONAL
   );
 
+/** Code generation for the "QWordIO ()" ASL function.
+
+  The Resource Data effectively created is a QWord Address Space Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.1 "QWord Address Space Descriptor".
+   - s19.6.109 "QWordIO".
+
+  The created resource data node can be:
+   - appended to the list of resource data elements of the NameOpNode.
+ In such case NameOpNode must be defined by a the "Name ()" ASL statement
+ and initially contain a "ResourceTemplate ()".
+   - returned through the NewRdNode parameter.
+
+  See ACPI 6.4 spec, s19.6.109 for more.
+
+  @param [in]  IsResourceConsumer   ResourceUsage parameter.
+  @param [in]  IsMinFixed   Minimum address is fixed.
+  @param [in]  IsMaxFixed   Maximum address is fixed.
+  @param [in]  IsPosDecode  Decode parameter
+  @param [in]  IsaRangesPossible values are:
+ 0-Reserved
+ 1-NonISAOnly
+ 2-ISAOnly
+ 3-EntireRange
+  @param [in]  AddressGranularity   Address granularity.
+  @param [in]  AddressMinimum   Minimum address.
+  @param [in]  AddressMaximum   Maximum address.
+  @param [in]  AddressTranslation   Address translation.
+  @param [in]  RangeLength  Range length.
+  @param [in]  ResourceSourceIndex  Resource Source index.
+Unused. Must be 0.
+  @param [in]  ResourceSource   Resource Source.
+Unused. Must be NULL.
+  @param [in]  IsDenseTranslation   TranslationDensity parameter.
+  @param [in]  IsTypeStatic TranslationType parameter.
+  @param [in]  NameOpNode   NameOp object node defining a named object.
+If provided, append the new resource data
+node to the list of resource data elements
+of this node.
+  @param [out] NewRdNodeIf provided and success,
+contain the created node.
+
+  @retval EFI_SUCCESS The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESCould not allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenRdQWordIo (
+  INBOOLEAN IsResourceConsumer,
+  INBOOLEAN IsMinFixed,
+  INBOOLEAN IsMaxFixed,
+  INBOOLEAN IsPosDecode,
+  INUINT8 IsaRanges,
+  INUINT64 AddressGranularity,
+  INUINT64 AddressMinimum,
+  INUINT64 AddressMaximum,
+  INUINT64 AddressTranslation,
+  INUINT64 RangeLength,
+  INUINT8 ResourceSourceIndex,
+  IN  CONST CHAR8 *ResourceSource,
+  INBOOLEAN IsDenseTranslation,
+  INBOOLEAN IsTypeStatic,
+  INAML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
+  OUT   AML_DATA_NODE_HANDLE*NewRdNode  OPTIONAL
+  );
+
 /** Code generation for the "QWordMemory ()" ASL function.
 
   The Resource Data effectively created is a QWord Address Space Resource
diff --git 
a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
index 4ca63ccd2396..9c6700b9e08c 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
@@ -1012,6 +1012,96 @@ AmlCodeGenRdQWordSpace (
   return LinkRdNode (RdNode, NameOpNode, NewRdNode);
 }
 
+/** Code generation for the "QWordIO ()" ASL function.
+
+  The Resource Data effectively created is a QWord Address Space Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.1 "QWord Address Space Descriptor".
+   - s19.6.109 "QWordIO".
+
+  The created resource data node can be:
+   - appended to the list of resource data elements of the NameOpNode.
+ In such case NameOpNode must be defined by a the "Name ()" ASL statement
+ and initially contain a "ResourceTemplate ()".
+   - returned through the NewRdNode parameter.
+
+  See ACPI 6.4 spec, s19.6.109 for more.
+
+  @param [in]  IsResourceConsumer   ResourceUsage parameter.
+  @param [in]  

[edk2-devel] [PATCH v2 2/2] DynamicTablesPkg: AcpiSsdtPcieLibArm: Use QWord todescribe I/O range

2023-09-21 Thread Jeff Brasen via groups.io
From: Vidya Sagar 

Use AmlCodeGenRdQWordIo() to generate the I/O range in _CRS instead of
AmlCodeGenRdDWordIo() to cater to the scenarios where 64-bit addresses
can be used to generate I/O packets over the PCIe bus.

Signed-off-by: Jeff Brasen 
---
 .../Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
index c54ae6f551f6..9ddaddc198fa 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
@@ -540,7 +540,7 @@ GeneratePciCrs (
 
 switch (AddrMapInfo->SpaceCode) {
   case PCI_SS_IO:
-Status = AmlCodeGenRdDWordIo (
+Status = AmlCodeGenRdQWordIo (
FALSE,
TRUE,
TRUE,
-- 
2.25.1



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




[edk2-devel] [PATCH v2 0/2] Add support for PCI IO using Qword resources

2023-09-21 Thread Jeff Brasen via groups.io
Use AmlCodeGenRdQWordIo() to generate the I/O range in _CRS instead of
AmlCodeGenRdDWordIo() to cater to the scenarios where 64-bit 
addresses can be used to generate I/O packets over the PCIe bus.

Changes:
v2 - Rebased and set transferEncoding = 8bit

Vidya Sagar (2):
  DynamicTablesPkg: AML Code generation for I/O ranges
  DynamicTablesPkg: AcpiSsdtPcieLibArm: Use QWord todescribe I/O range

 .../Include/Library/AmlLib/AmlLib.h   | 67 ++
 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c|  2 +-
 .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   | 90 +++
 3 files changed, 158 insertions(+), 1 deletion(-)

-- 
2.25.1



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




Re: [edk2-devel] [PATCH v4 2/4] DynamicTablesPkg: Add support for simple method invocation.

2023-09-21 Thread Jeff Brasen via groups.io
Only thing I see is if AmlCodeGenInteger fails we don’t delete DataNode right?

From: Sami Mujawar 
Sent: Thursday, September 21, 2023 10:49 AM
To: Jeff Brasen ; devel@edk2.groups.io
Cc: pierre.gond...@arm.com; Swatisri Kantamsetti ; Ashish 
Singhal ; n...@arm.com
Subject: Re: [PATCH v4 2/4] DynamicTablesPkg: Add support for simple method 
invocation.

External email: Use caution opening links or attachments


Hi Jeff,

Thank you for this patch.

Please see my response inline marked [SAMI].

Regards,

Sami Mujawar
On 18/09/2023 04:46 pm, Jeff Brasen wrote:

Add support to add Return objects via AML that pass a single integer



argument to the named method.







Signed-off-by: Jeff Brasen 



---



 .../Include/Library/AmlLib/AmlLib.h   |  54 



 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 244 ++



 2 files changed, 298 insertions(+)







diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h



index d201ae9499..b82c7a3ce8 100644



--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h



+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h



@@ -1194,6 +1194,60 @@ AmlCodeGenMethodRetInteger (



   OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNodeOPTIONAL



   );







+/** AML code generation for a method returning a NameString that takes an



+integer argument.



+



+  AmlCodeGenMethodRetNameStringIntegerArgument (



+"MET0", "MET1", 1, TRUE, 3, 5, ParentNode, NewObjectNode



+);



+  is equivalent of the following ASL code:



+Method(MET0, 1, Serialized, 3) {



+  Return (MET1 (5))



+}



+



+  The ASL parameters "ReturnType" and "ParameterTypes" are not asked



+  in this function. They are optional parameters in ASL.



+



+  @param [in]  MethodNameString The new Method's name.



+Must be a NULL-terminated ASL NameString



+e.g.: "MET0", "_SB.MET0", etc.



+The input string is copied.



+  @param [in]  ReturnedNameString   The name of the object returned by the



+method. Optional parameter, can be:



+ - NULL (ignored).



+ - A NULL-terminated ASL NameString.



+   e.g.: "MET0", "_SB.MET0", etc.



+   The input string is copied.



+  @param [in]  NumArgs  Number of arguments.



+Must be 0 <= NumArgs <= 6.



+  @param [in]  IsSerialized TRUE is equivalent to Serialized.



+FALSE is equivalent to NotSerialized.



+Default is NotSerialized in ASL spec.



+  @param [in]  SyncLevelSynchronization level for the method.



+Must be 0 <= SyncLevel <= 15.



+Default is 0 in ASL.



+  @param [in]  IntegerArgument  Argument to pass to the NameString.



+  @param [in]  ParentNode   If provided, set ParentNode as the parent



+of the node created.



+  @param [out] NewObjectNodeIf success, contains the created node.



+



+  @retval EFI_SUCCESS Success.



+  @retval EFI_INVALID_PARAMETER   Invalid parameter.



+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.



+**/



+EFI_STATUS



+EFIAPI



+AmlCodeGenMethodRetNameStringIntegerArgument (



+  IN  CONST CHAR8   *MethodNameString,



+  IN  CONST CHAR8   *ReturnedNameString   OPTIONAL,



+  INUINT8   NumArgs,



+  INBOOLEAN IsSerialized,



+  INUINT8   SyncLevel,



+  INUINT64  IntegerArgument,



+  INAML_NODE_HANDLE ParentNode   OPTIONAL,



+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNodeOPTIONAL



+  );



+



 /** Create a _LPI name.







   AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, ) is



diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c



index 88537b7e2d..ea519d1aa8 100644



--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c



+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c



@@ -1881,6 +1881,138 @@ AmlCodeGenReturnInteger (



   return Status;



 }







+/** AML code generation for a Return object node,



+returning the object as an input NameString with a integer argument.



+



+  AmlCodeGenReturn ("NAM1", 6, ParentNode, NewObjectNode) is



+  equivalent of the following ASL code:



+Return(NAM1 (6))



+



+  The ACPI 6.3 specification, s20.2.5.3 "Type 1 Opcodes 

Re: [edk2-devel] [PATCH v4 3/4] DynamicTablesPkg: Add support to add Strings to package

2023-09-21 Thread Jeff Brasen via groups.io
Hi Sami,

  That sounds good.

Thanks,
Jeff

> -Original Message-
> From: Sami Mujawar 
> Sent: Thursday, September 21, 2023 10:50 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: pierre.gond...@arm.com; Swatisri Kantamsetti ;
> Ashish Singhal ; n...@arm.com
> Subject: Re: [PATCH v4 3/4] DynamicTablesPkg: Add support to add Strings to
> package
> 
> External email: Use caution opening links or attachments
> 
> 
> Hi Jeff,
> 
> Thank you for this patch.
> 
> Please see my response inline marked [SAMI].
> 
> Regards,
> 
> Sami Mujawar
> 
> On 18/09/2023 04:46 pm, Jeff Brasen wrote:
> > Add API to add a String to a package created with NamedPackage API.
> >
> >
> >
> > Signed-off-by: Jeff Brasen 
> >
> > ---
> >
> >   .../Include/Library/AmlLib/AmlLib.h   | 17 
> >
> >   .../Common/AmlLib/CodeGen/AmlCodeGen.c| 88
> +++
> >
> >   2 files changed, 105 insertions(+)
> >
> >
> >
> > diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> > b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> >
> > index b82c7a3ce8..f4a4908753 100644
> >
> > --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> >
> > +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> >
> > @@ -1472,4 +1472,21 @@ AmlCreateCpcNode (
> >
> > OUT AML_OBJECT_NODE_HANDLE  *NewCpcNode   OPTIONAL
> >
> > );
> >
> >
> >
> > +/** AML code generation to add a NameString to the package in a named
> node.
> >
> > +
> >
> > +
> >
> > +  @param [in]  NameString NameString to add
> >
> > +  @param [in]  NamedNode  Node to add the string to the included
> package.
> >
> > +
> >
> > +  @retval EFI_SUCCESS Success.
> >
> > +  @retval EFI_INVALID_PARAMETER   Invalid parameter.
> >
> > +  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
> >
> > +**/
> >
> > +EFI_STATUS
> >
> > +EFIAPI
> >
> > +AmlAddNameStringToNamedPackage (
> >
> > +  IN CHAR8   *NameString,
> >
> > +  IN AML_OBJECT_NODE_HANDLE  NamedNode
> >
> > +  );
> >
> > +
> >
> >   #endif // AML_LIB_H_
> >
> > diff --git
> > a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> > b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> >
> > index ea519d1aa8..2afd405750 100644
> >
> > ---
> a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> >
> > +++
> b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> >
> > @@ -3685,3 +3685,91 @@ error_handler:
> >
> > AmlDeleteTree ((AML_NODE_HANDLE)CpcNode);
> >
> > return Status;
> >
> >   }
> >
> > +
> >
> > +/** AML code generation to add a NameString to the package in a named
> node.
> >
> > +
> >
> > +
> >
> > +  @param [in]  NameString NameString to add
> >
> > +  @param [in]  NamedNode  Node to add the string to the included
> package.
> >
> > +
> >
> > +  @retval EFI_SUCCESS Success.
> >
> > +  @retval EFI_INVALID_PARAMETER   Invalid parameter.
> >
> > +  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
> >
> > +**/
> >
> > +EFI_STATUS
> >
> > +EFIAPI
> >
> > +AmlAddNameStringToNamedPackage (
> >
> > +  IN CHAR8   *NameString,
> >
> > +  IN AML_OBJECT_NODE_HANDLE  NamedNode
> >
> > +  )
> >
> > +{
> >
> > +  EFI_STATUS  Status;
> >
> > +  AML_DATA_NODE   *DataNode;
> >
> > +  CHAR8   *AmlNameString;
> >
> > +  UINT32  AmlNameStringSize;
> >
> > +  AML_OBJECT_NODE_HANDLE  PackageNode;
> >
> > +
> >
> > +  DataNode = NULL;
> >
> > +
> >
> > +  if ((NamedNode == NULL)  ||
> >
> > +  (AmlGetNodeType ((AML_NODE_HANDLE)NamedNode) !=
> EAmlNodeObject)
> > + ||
> >
> > +  (!AmlNodeHasOpCode (NamedNode, AML_NAME_OP, 0)))
> >
> > +  {
> >
> > +ASSERT (0);
> >
> > +return EFI_INVALID_PARAMETER;
> >
> > +  }
> >
> > +
> >
> > +  PackageNode = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument (
> >
> > +  NamedNode,
> >
> > +  EAmlParseIndexTerm1
> >
> > +  );
> >
> > +  if ((PackageNode == NULL) ||
> >
> > +  (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) !=
> > + EAmlNodeObject) ||
> >
> > +  (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0)))
> >
> > +  {
> >
> > +ASSERT (0);
> >
> > +return EFI_INVALID_PARAMETER;
> >
> > +  }
> >
> > +
> >
> > +  Status = ConvertAslNameToAmlName (NameString, );
> >
> > +  if (EFI_ERROR (Status)) {
> >
> > +ASSERT (0);
> >
> > +return Status;
> >
> > +  }
> >
> > +
> >
> > +  Status = AmlGetNameStringSize (AmlNameString, );
> >
> > +  if (EFI_ERROR (Status)) {
> >
> > +ASSERT (0);
> >
> > +goto exit_handler;
> >
> > +  }
> >
> > +
> >
> > +  Status = AmlCreateDataNode (
> >
> > + EAmlNodeDataTypeNameString,
> >
> > + (UINT8 *)AmlNameString,
> >
> > + AmlNameStringSize,
> >
> > + 
> >
> 

[edk2-devel] [PATCH v4 4/4] DynamicTablesPkg: Add Aml NameUnicodeString API

2023-09-18 Thread Jeff Brasen via groups.io
Add API to generate a Name that contains a Unicode string buffer.



Signed-off-by: Jeff Brasen 

---

 .../Include/Library/AmlLib/AmlLib.h   | 31 +++

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 86 +++

 2 files changed, 117 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index f4a4908753..e0dc1340ab 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -958,6 +958,37 @@ AmlCodeGenNameResourceTemplate (

   OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

   );

 

+/** AML code generation for a Name object node, containing a String.

+

+  AmlCodeGenNameUnicodeString ("_STR", L"String", ParentNode, NewObjectNode) is

+  equivalent of the following ASL code:

+Name(_STR, Unicode ("String"))

+

+  @ingroup CodeGenApis

+

+  @param  [in] NameString The new variable name.

+  Must be a NULL-terminated ASL NameString

+  e.g.: "DEV0", "DV15.DEV0", etc.

+  The input string is copied.

+  @param [in]  String NULL terminated Unicode String to associate to 
the

+  NameString.

+  @param [in]  ParentNode If provided, set ParentNode as the parent

+  of the node created.

+  @param [out] NewObjectNode  If success, contains the created node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenNameUnicodeString (

+  IN  CONST CHAR8   *NameString,

+  INCHAR16  *String,

+  INAML_NODE_HANDLE ParentNode  OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

+  );

+

 /** Add a _PRT entry.

 

   AmlCodeGenPrtEntry (0x0, 0, "LNKA", 0, PrtNameNode) is

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index 2afd405750..51eece5958 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -869,6 +869,92 @@ AmlCodeGenNameResourceTemplate (

   return Status;

 }

 

+/** AML code generation for a Name object node, containing a String.

+

+ AmlCodeGenNameUnicodeString ("_STR", L"String", ParentNode, NewObjectNode) is

+ equivalent of the following ASL code:

+   Name(_STR, Unicode ("String"))

+

+ @ingroup CodeGenApis

+

+ @param  [in] NameString The new variable name.

+ Must be a NULL-terminated ASL NameString

+ e.g.: "DEV0", "DV15.DEV0", etc.

+ The input string is copied.

+ @param [in]  String NULL terminated Unicode String to associate to the

+ NameString.

+ @param [in]  ParentNode If provided, set ParentNode as the parent

+ of the node created.

+ @param [out] NewObjectNode  If success, contains the created node.

+

+ @retval EFI_SUCCESS Success.

+ @retval EFI_INVALID_PARAMETER   Invalid parameter.

+ @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenNameUnicodeString (

+  IN  CONST CHAR8   *NameString,

+  INCHAR16  *String,

+  INAML_NODE_HANDLE ParentNode  OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

+  )

+{

+  EFI_STATUS   Status;

+  AML_OBJECT_NODE  *ObjectNode;

+  AML_DATA_NODE*DataNode;

+

+  if ((NameString == NULL)  ||

+  (String == NULL)  ||

+  ((ParentNode == NULL) && (NewObjectNode == NULL)))

+  {

+ASSERT (0);

+return EFI_INVALID_PARAMETER;

+  }

+

+  Status = AmlCodeGenBuffer (NULL, 0, );

+  if (EFI_ERROR (Status)) {

+ASSERT_EFI_ERROR (Status);

+return Status;

+  }

+

+  Status = AmlCreateDataNode (

+ EAmlNodeDataTypeRaw,

+ (CONST UINT8 *)String,

+ StrSize (String),

+ 

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT_EFI_ERROR (Status);

+AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);

+return Status;

+  }

+

+  Status = AmlVarListAddTail (

+ (AML_NODE_HEADER *)ObjectNode,

+ (AML_NODE_HEADER *)DataNode

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT_EFI_ERROR (Status);

+AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);

+AmlDeleteTree ((AML_NODE_HANDLE)DataNode);

+return Status;

+  }

+

+  Status = AmlCodeGenName (

+ NameString,

+ ObjectNode,

+ ParentNode,

+ NewObjectNode

+ );

+  if 

[edk2-devel] [PATCH v4 3/4] DynamicTablesPkg: Add support to add Strings to package

2023-09-18 Thread Jeff Brasen via groups.io
Add API to add a String to a package created with NamedPackage API.



Signed-off-by: Jeff Brasen 

---

 .../Include/Library/AmlLib/AmlLib.h   | 17 

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 88 +++

 2 files changed, 105 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index b82c7a3ce8..f4a4908753 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1472,4 +1472,21 @@ AmlCreateCpcNode (

   OUT AML_OBJECT_NODE_HANDLE  *NewCpcNode   OPTIONAL

   );

 

+/** AML code generation to add a NameString to the package in a named node.

+

+

+  @param [in]  NameString NameString to add

+  @param [in]  NamedNode  Node to add the string to the included package.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddNameStringToNamedPackage (

+  IN CHAR8   *NameString,

+  IN AML_OBJECT_NODE_HANDLE  NamedNode

+  );

+

 #endif // AML_LIB_H_

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index ea519d1aa8..2afd405750 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -3685,3 +3685,91 @@ error_handler:

   AmlDeleteTree ((AML_NODE_HANDLE)CpcNode);

   return Status;

 }

+

+/** AML code generation to add a NameString to the package in a named node.

+

+

+  @param [in]  NameString NameString to add

+  @param [in]  NamedNode  Node to add the string to the included package.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddNameStringToNamedPackage (

+  IN CHAR8   *NameString,

+  IN AML_OBJECT_NODE_HANDLE  NamedNode

+  )

+{

+  EFI_STATUS  Status;

+  AML_DATA_NODE   *DataNode;

+  CHAR8   *AmlNameString;

+  UINT32  AmlNameStringSize;

+  AML_OBJECT_NODE_HANDLE  PackageNode;

+

+  DataNode = NULL;

+

+  if ((NamedNode == NULL)  ||

+  (AmlGetNodeType ((AML_NODE_HANDLE)NamedNode) != EAmlNodeObject)  ||

+  (!AmlNodeHasOpCode (NamedNode, AML_NAME_OP, 0)))

+  {

+ASSERT (0);

+return EFI_INVALID_PARAMETER;

+  }

+

+  PackageNode = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument (

+  NamedNode,

+  EAmlParseIndexTerm1

+  );

+  if ((PackageNode == NULL) ||

+  (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) != EAmlNodeObject) ||

+  (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0)))

+  {

+ASSERT (0);

+return EFI_INVALID_PARAMETER;

+  }

+

+  Status = ConvertAslNameToAmlName (NameString, );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+return Status;

+  }

+

+  Status = AmlGetNameStringSize (AmlNameString, );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto exit_handler;

+  }

+

+  Status = AmlCreateDataNode (

+ EAmlNodeDataTypeNameString,

+ (UINT8 *)AmlNameString,

+ AmlNameStringSize,

+ 

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto exit_handler;

+  }

+

+  Status = AmlVarListAddTail (

+ (AML_NODE_HANDLE)PackageNode,

+ (AML_NODE_HANDLE)DataNode

+ );

+  ASSERT_EFI_ERROR (Status);

+

+exit_handler:

+  if (AmlNameString != NULL) {

+FreePool (AmlNameString);

+  }

+

+  if (EFI_ERROR (Status)) {

+if (DataNode != NULL) {

+  AmlDeleteTree ((AML_NODE_HANDLE)DataNode);

+}

+  }

+

+  return Status;

+}

-- 

2.25.1





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




[edk2-devel] [PATCH v4 2/4] DynamicTablesPkg: Add support for simple method invocation.

2023-09-18 Thread Jeff Brasen via groups.io
Add support to add Return objects via AML that pass a single integer

argument to the named method.



Signed-off-by: Jeff Brasen 

---

 .../Include/Library/AmlLib/AmlLib.h   |  54 

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 244 ++

 2 files changed, 298 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index d201ae9499..b82c7a3ce8 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1194,6 +1194,60 @@ AmlCodeGenMethodRetInteger (

   OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNodeOPTIONAL

   );

 

+/** AML code generation for a method returning a NameString that takes an

+integer argument.

+

+  AmlCodeGenMethodRetNameStringIntegerArgument (

+"MET0", "MET1", 1, TRUE, 3, 5, ParentNode, NewObjectNode

+);

+  is equivalent of the following ASL code:

+Method(MET0, 1, Serialized, 3) {

+  Return (MET1 (5))

+}

+

+  The ASL parameters "ReturnType" and "ParameterTypes" are not asked

+  in this function. They are optional parameters in ASL.

+

+  @param [in]  MethodNameString The new Method's name.

+Must be a NULL-terminated ASL NameString

+e.g.: "MET0", "_SB.MET0", etc.

+The input string is copied.

+  @param [in]  ReturnedNameString   The name of the object returned by the

+method. Optional parameter, can be:

+ - NULL (ignored).

+ - A NULL-terminated ASL NameString.

+   e.g.: "MET0", "_SB.MET0", etc.

+   The input string is copied.

+  @param [in]  NumArgs  Number of arguments.

+Must be 0 <= NumArgs <= 6.

+  @param [in]  IsSerialized TRUE is equivalent to Serialized.

+FALSE is equivalent to NotSerialized.

+Default is NotSerialized in ASL spec.

+  @param [in]  SyncLevelSynchronization level for the method.

+Must be 0 <= SyncLevel <= 15.

+Default is 0 in ASL.

+  @param [in]  IntegerArgument  Argument to pass to the NameString.

+  @param [in]  ParentNode   If provided, set ParentNode as the parent

+of the node created.

+  @param [out] NewObjectNodeIf success, contains the created node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenMethodRetNameStringIntegerArgument (

+  IN  CONST CHAR8   *MethodNameString,

+  IN  CONST CHAR8   *ReturnedNameString   OPTIONAL,

+  INUINT8   NumArgs,

+  INBOOLEAN IsSerialized,

+  INUINT8   SyncLevel,

+  INUINT64  IntegerArgument,

+  INAML_NODE_HANDLE ParentNode   OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNodeOPTIONAL

+  );

+

 /** Create a _LPI name.

 

   AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, ) is

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index 88537b7e2d..ea519d1aa8 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -1881,6 +1881,138 @@ AmlCodeGenReturnInteger (

   return Status;

 }

 

+/** AML code generation for a Return object node,

+returning the object as an input NameString with a integer argument.

+

+  AmlCodeGenReturn ("NAM1", 6, ParentNode, NewObjectNode) is

+  equivalent of the following ASL code:

+Return(NAM1 (6))

+

+  The ACPI 6.3 specification, s20.2.5.3 "Type 1 Opcodes Encoding" states:

+DefReturn := ReturnOp ArgObject

+ReturnOp := 0xA4

+ArgObject := TermArg => DataRefObject

+

+  Thus, the ReturnNode must be evaluated as a DataRefObject. It can

+  be a NameString referencing an object. As this CodeGen Api doesn't

+  do semantic checking, it is strongly advised to check the AML bytecode

+  generated by this function against an ASL compiler.

+

+  The ReturnNode must be generated inside a Method body scope.

+

+  @param [in]  NameString The object referenced by this NameString

+  is returned by the Return ASL statement.

+  Must be a NULL-terminated ASL NameString

+  e.g.: "NAM1", "_SB.NAM1", etc.

+

[edk2-devel] [PATCH v4 0/4] Add support for generating ACPI ThermalZones

2023-09-18 Thread Jeff Brasen via groups.io
Add APIs needed to create thermal zones dynamically.
Does not add a generator for this as creating the TMP method generically may
be difficult.

Change log:

v4 - Fixed an additional error handling path
v3 - Fixed a couple error handling paths
v2 - renamed NameString function and added goto dones in a couple error cases

Jeff Brasen (4):
  DynamicTablesPkg: Add ThermalZone CodeGen function
  DynamicTablesPkg: Add support for simple method invocation.
  DynamicTablesPkg: Add support to add Strings to package
  DynamicTablesPkg: Add Aml NameUnicodeString API

 .../Include/Library/AmlLib/AmlLib.h   | 130 +
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 534 ++
 2 files changed, 664 insertions(+)

-- 
2.25.1



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




[edk2-devel] [PATCH v4 1/4] DynamicTablesPkg: Add ThermalZone CodeGen function

2023-09-18 Thread Jeff Brasen via groups.io
Add API to generate a ThermalZone object to AmlLib.



Signed-off-by: Jeff Brasen 

---

 .../Include/Library/AmlLib/AmlLib.h   |  28 +

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 116 ++

 2 files changed, 144 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index 9210c50915..d201ae9499 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1038,6 +1038,34 @@ AmlCodeGenDevice (

   OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

   );

 

+/** AML code generation for a ThermalZone object node.

+

+  AmlCodeGenThermalZone ("TZ00", ParentNode, NewObjectNode) is

+  equivalent of the following ASL code:

+ThermalZone(TZ00) {}

+

+  @ingroup CodeGenApis

+

+  @param  [in] NameString The new ThermalZone's name.

+  Must be a NULL-terminated ASL NameString

+  e.g.: "DEV0", "DV15.DEV0", etc.

+  The input string is copied.

+  @param [in]  ParentNode If provided, set ParentNode as the parent

+  of the node created.

+  @param [out] NewObjectNode  If success, contains the created node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenThermalZone (

+  IN  CONST CHAR8   *NameString,

+  INAML_NODE_HANDLE ParentNode  OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

+  );

+

 /** AML code generation for a Scope object node.

 

   AmlCodeGenScope ("_SB", ParentNode, NewObjectNode) is

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index 0b223379fa..88537b7e2d 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -1218,6 +1218,122 @@ error_handler1:

   return Status;

 }

 

+/** AML code generation for a ThermalZone object node.

+

+  AmlCodeGenThermalZone ("TZ00", ParentNode, NewObjectNode) is

+  equivalent of the following ASL code:

+ThermalZone(TZ00) {}

+

+  @ingroup CodeGenApis

+

+  @param  [in] NameString The new ThermalZone's name.

+  Must be a NULL-terminated ASL NameString

+  e.g.: "DEV0", "DV15.DEV0", etc.

+  The input string is copied.

+  @param [in]  ParentNode If provided, set ParentNode as the parent

+  of the node created.

+  @param [out] NewObjectNode  If success, contains the created node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenThermalZone (

+  IN  CONST CHAR8   *NameString,

+  INAML_NODE_HANDLE ParentNode  OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

+  )

+{

+  EFI_STATUS   Status;

+  AML_OBJECT_NODE  *ObjectNode;

+  AML_DATA_NODE*DataNode;

+  CHAR8*AmlNameString;

+  UINT32   AmlNameStringSize;

+

+  if ((NameString == NULL)  ||

+  ((ParentNode == NULL) && (NewObjectNode == NULL)))

+  {

+ASSERT (0);

+return EFI_INVALID_PARAMETER;

+  }

+

+  ObjectNode= NULL;

+  DataNode  = NULL;

+  AmlNameString = NULL;

+

+  Status = ConvertAslNameToAmlName (NameString, );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+return Status;

+  }

+

+  Status = AmlGetNameStringSize (AmlNameString, );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto error_handler1;

+  }

+

+  Status = AmlCreateObjectNode (

+ AmlGetByteEncodingByOpCode (AML_EXT_OP, AML_EXT_THERMAL_ZONE_OP),

+ AmlNameStringSize + AmlComputePkgLengthWidth (AmlNameStringSize),

+ 

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto error_handler1;

+  }

+

+  Status = AmlCreateDataNode (

+ EAmlNodeDataTypeNameString,

+ (UINT8 *)AmlNameString,

+ AmlNameStringSize,

+ 

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto error_handler2;

+  }

+

+  Status = AmlSetFixedArgument (

+ ObjectNode,

+ EAmlParseIndexTerm0,

+ (AML_NODE_HEADER *)DataNode

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+AmlDeleteTree ((AML_NODE_HEADER *)DataNode);

+goto error_handler2;

+  }

+

+  Status = LinkNode (

+ ObjectNode,

+ ParentNode,

+ NewObjectNode

+ );

+  if 

Re: [edk2-devel] [PATCH 1/2] DynamicTablesPkg: AML Code generation for I/O ranges

2023-09-12 Thread Jeff Brasen via groups.io
Regarding the signed-off-by I wasn't sure the right way to handle this. Vidya 
was the author of this patch and applied the signed off on our internal repo 
during development. I was upstreaming it on his behalf. I was unsure if I 
should just replace his as I assumed just leaving his from this wouldn't be 
ideal as I figured we would want the signed-off by the submitter to the devel 
list.

Here is the copy of the patch on our edk2 fork as well. 
https://github.com/NVIDIA/edk2/commit/0171b6c1f60500c5e5178ef3521fa14bcacd3488





> -Original Message-
> From: Leif Lindholm 
> Sent: Tuesday, September 12, 2023 3:36 AM
> To: Jeff Brasen 
> Cc: devel@edk2.groups.io; ardb+tianoc...@kernel.org;
> sami.muja...@arm.com; pierre.gond...@arm.com; Vidya Sagar
> ; Shanker Donthineni 
> Subject: Re: [PATCH 1/2] DynamicTablesPkg: AML Code generation for I/O
> ranges
> 
> External email: Use caution opening links or attachments
> 
> 
> Hi Jeff,
> 
> On Mon, Sep 11, 2023 at 23:48:57 +, Jeff Brasen wrote:
> > From: Vidya Sagar 
> >
> > Add helper functions to generate AML Resource Data describing I/O
> > ranges of four words long. API AmlCodeGenRdQWordIo () is exposed.
> >
> > Reviewed-by: Shanker Donthineni 
> 
> The above isn't really applicable to upstream.
> Although I feel less strongly about that than
> 
> > Signed-off-by: Vidya Sagar 
> 
> The DCO is a statement that you have performed basic legal due diligence on
> the provenance of the change. I'm uncomfortable with people making such
> statements on behalf of others.
> 
> If this is being upstreamed from a downstream repository, such that the
> review trail is available there, then both of these could be fine.
> But I think it would be useful to include a link to the patch in that 
> repository in
> the commit message in that case.
> 
> One technical, but not necessarily for this set (it just made me spot it), 
> note
> below.
> 
> > Signed-off-by: Jeff Brasen 
> > ---
> >  .../Include/Library/AmlLib/AmlLib.h   | 67 ++
> >  .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   | 90
> +++
> >  2 files changed, 157 insertions(+)
> >
> > diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> > b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> > index 9210c5091548..8e24cecdd77b 100644
> > --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> > +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> > @@ -683,6 +683,73 @@ AmlCodeGenRdWordBusNumber (
> >OUT   AML_DATA_NODE_HANDLE*NewRdNode  OPTIONAL
> >);
> >
> > +/** Code generation for the "QWordIO ()" ASL function.
> > +
> > +  The Resource Data effectively created is a QWord Address Space
> > + Resource  Data. Cf ACPI 6.4:
> > +   - s6.4.3.5.1 "QWord Address Space Descriptor".
> > +   - s19.6.109 "QWordIO".
> > +
> > +  The created resource data node can be:
> > +   - appended to the list of resource data elements of the NameOpNode.
> > + In such case NameOpNode must be defined by a the "Name ()" ASL
> statement
> > + and initially contain a "ResourceTemplate ()".
> > +   - returned through the NewRdNode parameter.
> > +
> > +  See ACPI 6.4 spec, s19.6.109 for more.
> > +
> > +  @param [in]  IsResourceConsumer   ResourceUsage parameter.
> > +  @param [in]  IsMinFixed   Minimum address is fixed.
> > +  @param [in]  IsMaxFixed   Maximum address is fixed.
> > +  @param [in]  IsPosDecode  Decode parameter
> > +  @param [in]  IsaRangesPossible values are:
> > + 0-Reserved
> > + 1-NonISAOnly
> > + 2-ISAOnly
> > + 3-EntireRange
> 
> This is an existing antipattern which this patch (rightly) adheres to when
> adding an additional variant of an existing API. But this also pushes the 
> count
> to three functions in the same file where we're doing enum-but-in-doxygen
> and then keep magic values in the code.
> 
> I think someone should rewrite this as an enum and get rid of the magic values
> in the callers.
> 
> An additional antipattern is that because the doxygen stanza becomes
> exessively bulky, it leaves out actually documenting the parameter at all.
> 
> But as I said, that's not the fault of this set, and does not need to be 
> fixed by it.
> 
> /
> Leif
> 
> > +  @param [in]  AddressGranularity   Address granularity.
> > +  @param [in]  AddressMinimum   Minimum address.
> > +  @param [in]  AddressMaximum   Maximum address.
> > +  @param [in]  AddressTranslation   Address translation.
> > +  @param [in]  RangeLength  Range length.
> > +  @param [in]  ResourceSourceIndex  Resource Source index.
> > +Unused. Must be 0.
> > +  @param [in]  ResourceSource   Resource Source.
> > +Unused. Must be NULL.
> > +  @param [in]  IsDenseTranslation   TranslationDensity parameter.
> 

[edk2-devel] [PATCH 0/2] Add support for PCI IO using Qword resources

2023-09-11 Thread Jeff Brasen via groups.io
Use AmlCodeGenRdQWordIo() to generate the I/O range in _CRS instead of
AmlCodeGenRdDWordIo() to cater to the scenarios where 64-bit addresses
can be used to generate I/O packets over the PCIe bus.

Vidya Sagar (2):
  DynamicTablesPkg: AML Code generation for I/O ranges
  DynamicTablesPkg: AcpiSsdtPcieLibArm: Use QWord to describe I/O range

 .../Include/Library/AmlLib/AmlLib.h   | 67 ++
 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c|  2 +-
 .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   | 90 +++
 3 files changed, 158 insertions(+), 1 deletion(-)

-- 
2.25.1



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




[edk2-devel] [PATCH 2/2] DynamicTablesPkg: AcpiSsdtPcieLibArm: Use QWord to describe I/O range

2023-09-11 Thread Jeff Brasen via groups.io
From: Vidya Sagar 

Use AmlCodeGenRdQWordIo() to generate the I/O range in _CRS instead of
AmlCodeGenRdDWordIo() to cater to the scenarios where 64-bit addresses
can be used to generate I/O packets over the PCIe bus.

Reviewed-by: Shanker Donthineni 
Signed-off-by: Vidya Sagar 
Signed-off-by: Jeff Brasen 
---
 .../Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
index c54ae6f551f6..9ddaddc198fa 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
@@ -540,7 +540,7 @@ GeneratePciCrs (
 
 switch (AddrMapInfo->SpaceCode) {
   case PCI_SS_IO:
-Status = AmlCodeGenRdDWordIo (
+Status = AmlCodeGenRdQWordIo (
FALSE,
TRUE,
TRUE,
-- 
2.25.1



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




[edk2-devel] [PATCH 1/2] DynamicTablesPkg: AML Code generation for I/O ranges

2023-09-11 Thread Jeff Brasen via groups.io
From: Vidya Sagar 

Add helper functions to generate AML Resource Data describing I/O
ranges of four words long. API AmlCodeGenRdQWordIo () is exposed.

Reviewed-by: Shanker Donthineni 
Signed-off-by: Vidya Sagar 
Signed-off-by: Jeff Brasen 
---
 .../Include/Library/AmlLib/AmlLib.h   | 67 ++
 .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   | 90 +++
 2 files changed, 157 insertions(+)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 9210c5091548..8e24cecdd77b 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -683,6 +683,73 @@ AmlCodeGenRdWordBusNumber (
   OUT   AML_DATA_NODE_HANDLE*NewRdNode  OPTIONAL
   );
 
+/** Code generation for the "QWordIO ()" ASL function.
+
+  The Resource Data effectively created is a QWord Address Space Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.1 "QWord Address Space Descriptor".
+   - s19.6.109 "QWordIO".
+
+  The created resource data node can be:
+   - appended to the list of resource data elements of the NameOpNode.
+ In such case NameOpNode must be defined by a the "Name ()" ASL statement
+ and initially contain a "ResourceTemplate ()".
+   - returned through the NewRdNode parameter.
+
+  See ACPI 6.4 spec, s19.6.109 for more.
+
+  @param [in]  IsResourceConsumer   ResourceUsage parameter.
+  @param [in]  IsMinFixed   Minimum address is fixed.
+  @param [in]  IsMaxFixed   Maximum address is fixed.
+  @param [in]  IsPosDecode  Decode parameter
+  @param [in]  IsaRangesPossible values are:
+ 0-Reserved
+ 1-NonISAOnly
+ 2-ISAOnly
+ 3-EntireRange
+  @param [in]  AddressGranularity   Address granularity.
+  @param [in]  AddressMinimum   Minimum address.
+  @param [in]  AddressMaximum   Maximum address.
+  @param [in]  AddressTranslation   Address translation.
+  @param [in]  RangeLength  Range length.
+  @param [in]  ResourceSourceIndex  Resource Source index.
+Unused. Must be 0.
+  @param [in]  ResourceSource   Resource Source.
+Unused. Must be NULL.
+  @param [in]  IsDenseTranslation   TranslationDensity parameter.
+  @param [in]  IsTypeStatic TranslationType parameter.
+  @param [in]  NameOpNode   NameOp object node defining a named object.
+If provided, append the new resource data
+node to the list of resource data elements
+of this node.
+  @param [out] NewRdNodeIf provided and success,
+contain the created node.
+
+  @retval EFI_SUCCESS The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESCould not allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenRdQWordIo (
+  INBOOLEAN IsResourceConsumer,
+  INBOOLEAN IsMinFixed,
+  INBOOLEAN IsMaxFixed,
+  INBOOLEAN IsPosDecode,
+  INUINT8 IsaRanges,
+  INUINT64 AddressGranularity,
+  INUINT64 AddressMinimum,
+  INUINT64 AddressMaximum,
+  INUINT64 AddressTranslation,
+  INUINT64 RangeLength,
+  INUINT8 ResourceSourceIndex,
+  IN  CONST CHAR8 *ResourceSource,
+  INBOOLEAN IsDenseTranslation,
+  INBOOLEAN IsTypeStatic,
+  INAML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
+  OUT   AML_DATA_NODE_HANDLE*NewRdNode  OPTIONAL
+  );
+
 /** Code generation for the "QWordMemory ()" ASL function.
 
   The Resource Data effectively created is a QWord Address Space Resource
diff --git 
a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
index 4ca63ccd2396..9c6700b9e08c 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
@@ -1012,6 +1012,96 @@ AmlCodeGenRdQWordSpace (
   return LinkRdNode (RdNode, NameOpNode, NewRdNode);
 }
 
+/** Code generation for the "QWordIO ()" ASL function.
+
+  The Resource Data effectively created is a QWord Address Space Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.1 "QWord Address Space Descriptor".
+   - s19.6.109 "QWordIO".
+
+  The created resource data node can be:
+   - appended to the list of resource data elements of the NameOpNode.
+ In such case NameOpNode must be defined by a the "Name ()" ASL statement
+ and initially contain a "ResourceTemplate ()".
+   - returned through the NewRdNode parameter.
+
+  See ACPI 6.4 spec, s19.6.109 for more.
+
+  @param [in]  

[edk2-devel] [PATCH v3 1/4] DynamicTablesPkg: Add ThermalZone CodeGen function

2023-09-11 Thread Jeff Brasen via groups.io
Add API to generate a ThermalZone object to AmlLib.



Bug 4063340



Signed-off-by: Jeff Brasen 

Reviewed-by: Swatisri Kantamsetti 

Reviewed-by: Ashish Singhal 

---

 .../Include/Library/AmlLib/AmlLib.h   |  28 +

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 116 ++

 2 files changed, 144 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index 9210c50915..d201ae9499 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1038,6 +1038,34 @@ AmlCodeGenDevice (

   OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

   );

 

+/** AML code generation for a ThermalZone object node.

+

+  AmlCodeGenThermalZone ("TZ00", ParentNode, NewObjectNode) is

+  equivalent of the following ASL code:

+ThermalZone(TZ00) {}

+

+  @ingroup CodeGenApis

+

+  @param  [in] NameString The new ThermalZone's name.

+  Must be a NULL-terminated ASL NameString

+  e.g.: "DEV0", "DV15.DEV0", etc.

+  The input string is copied.

+  @param [in]  ParentNode If provided, set ParentNode as the parent

+  of the node created.

+  @param [out] NewObjectNode  If success, contains the created node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenThermalZone (

+  IN  CONST CHAR8   *NameString,

+  INAML_NODE_HANDLE ParentNode  OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

+  );

+

 /** AML code generation for a Scope object node.

 

   AmlCodeGenScope ("_SB", ParentNode, NewObjectNode) is

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index 0b223379fa..88537b7e2d 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -1218,6 +1218,122 @@ error_handler1:

   return Status;

 }

 

+/** AML code generation for a ThermalZone object node.

+

+  AmlCodeGenThermalZone ("TZ00", ParentNode, NewObjectNode) is

+  equivalent of the following ASL code:

+ThermalZone(TZ00) {}

+

+  @ingroup CodeGenApis

+

+  @param  [in] NameString The new ThermalZone's name.

+  Must be a NULL-terminated ASL NameString

+  e.g.: "DEV0", "DV15.DEV0", etc.

+  The input string is copied.

+  @param [in]  ParentNode If provided, set ParentNode as the parent

+  of the node created.

+  @param [out] NewObjectNode  If success, contains the created node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenThermalZone (

+  IN  CONST CHAR8   *NameString,

+  INAML_NODE_HANDLE ParentNode  OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

+  )

+{

+  EFI_STATUS   Status;

+  AML_OBJECT_NODE  *ObjectNode;

+  AML_DATA_NODE*DataNode;

+  CHAR8*AmlNameString;

+  UINT32   AmlNameStringSize;

+

+  if ((NameString == NULL)  ||

+  ((ParentNode == NULL) && (NewObjectNode == NULL)))

+  {

+ASSERT (0);

+return EFI_INVALID_PARAMETER;

+  }

+

+  ObjectNode= NULL;

+  DataNode  = NULL;

+  AmlNameString = NULL;

+

+  Status = ConvertAslNameToAmlName (NameString, );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+return Status;

+  }

+

+  Status = AmlGetNameStringSize (AmlNameString, );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto error_handler1;

+  }

+

+  Status = AmlCreateObjectNode (

+ AmlGetByteEncodingByOpCode (AML_EXT_OP, AML_EXT_THERMAL_ZONE_OP),

+ AmlNameStringSize + AmlComputePkgLengthWidth (AmlNameStringSize),

+ 

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto error_handler1;

+  }

+

+  Status = AmlCreateDataNode (

+ EAmlNodeDataTypeNameString,

+ (UINT8 *)AmlNameString,

+ AmlNameStringSize,

+ 

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto error_handler2;

+  }

+

+  Status = AmlSetFixedArgument (

+ ObjectNode,

+ EAmlParseIndexTerm0,

+ (AML_NODE_HEADER *)DataNode

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+AmlDeleteTree ((AML_NODE_HEADER *)DataNode);

+goto error_handler2;

+  }

+

+  Status = LinkNode (

+ ObjectNode,

[edk2-devel] [PATCH v3 2/4] DynamicTablesPkg: Add support for simple method invocation.

2023-09-11 Thread Jeff Brasen via groups.io
Add support to add Return objects via AML that pass a single integer

argument to the named method.



Bug 4063340



Signed-off-by: Jeff Brasen 

Reviewed-by: Swatisri Kantamsetti 

Reviewed-by: Ashish Singhal 

---

 .../Include/Library/AmlLib/AmlLib.h   |  54 

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 236 ++

 2 files changed, 290 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index d201ae9499..b82c7a3ce8 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1194,6 +1194,60 @@ AmlCodeGenMethodRetInteger (

   OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNodeOPTIONAL

   );

 

+/** AML code generation for a method returning a NameString that takes an

+integer argument.

+

+  AmlCodeGenMethodRetNameStringIntegerArgument (

+"MET0", "MET1", 1, TRUE, 3, 5, ParentNode, NewObjectNode

+);

+  is equivalent of the following ASL code:

+Method(MET0, 1, Serialized, 3) {

+  Return (MET1 (5))

+}

+

+  The ASL parameters "ReturnType" and "ParameterTypes" are not asked

+  in this function. They are optional parameters in ASL.

+

+  @param [in]  MethodNameString The new Method's name.

+Must be a NULL-terminated ASL NameString

+e.g.: "MET0", "_SB.MET0", etc.

+The input string is copied.

+  @param [in]  ReturnedNameString   The name of the object returned by the

+method. Optional parameter, can be:

+ - NULL (ignored).

+ - A NULL-terminated ASL NameString.

+   e.g.: "MET0", "_SB.MET0", etc.

+   The input string is copied.

+  @param [in]  NumArgs  Number of arguments.

+Must be 0 <= NumArgs <= 6.

+  @param [in]  IsSerialized TRUE is equivalent to Serialized.

+FALSE is equivalent to NotSerialized.

+Default is NotSerialized in ASL spec.

+  @param [in]  SyncLevelSynchronization level for the method.

+Must be 0 <= SyncLevel <= 15.

+Default is 0 in ASL.

+  @param [in]  IntegerArgument  Argument to pass to the NameString.

+  @param [in]  ParentNode   If provided, set ParentNode as the parent

+of the node created.

+  @param [out] NewObjectNodeIf success, contains the created node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenMethodRetNameStringIntegerArgument (

+  IN  CONST CHAR8   *MethodNameString,

+  IN  CONST CHAR8   *ReturnedNameString   OPTIONAL,

+  INUINT8   NumArgs,

+  INBOOLEAN IsSerialized,

+  INUINT8   SyncLevel,

+  INUINT64  IntegerArgument,

+  INAML_NODE_HANDLE ParentNode   OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNodeOPTIONAL

+  );

+

 /** Create a _LPI name.

 

   AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, ) is

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index 88537b7e2d..53c537e2d3 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -1881,6 +1881,130 @@ AmlCodeGenReturnInteger (

   return Status;

 }

 

+/** AML code generation for a Return object node,

+returning the object as an input NameString with a integer argument.

+

+  AmlCodeGenReturn ("NAM1", 6, ParentNode, NewObjectNode) is

+  equivalent of the following ASL code:

+Return(NAM1 (6))

+

+  The ACPI 6.3 specification, s20.2.5.3 "Type 1 Opcodes Encoding" states:

+DefReturn := ReturnOp ArgObject

+ReturnOp := 0xA4

+ArgObject := TermArg => DataRefObject

+

+  Thus, the ReturnNode must be evaluated as a DataRefObject. It can

+  be a NameString referencing an object. As this CodeGen Api doesn't

+  do semantic checking, it is strongly advised to check the AML bytecode

+  generated by this function against an ASL compiler.

+

+  The ReturnNode must be generated inside a Method body scope.

+

+  @param [in]  NameString The object referenced by this NameString

+  is returned by the Return ASL statement.

+  Must be a NULL-terminated ASL NameString

[edk2-devel] [PATCH v3 3/4] DynamicTablesPkg: Add support to add Strings to package

2023-09-11 Thread Jeff Brasen via groups.io
Add API to add a String to a package created with NamedPackage API.



Bug 4063340



Signed-off-by: Jeff Brasen 

Reviewed-by: Swatisri Kantamsetti 

Reviewed-by: Ashish Singhal 

---

 .../Include/Library/AmlLib/AmlLib.h   | 17 

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 88 +++

 2 files changed, 105 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index b82c7a3ce8..f4a4908753 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1472,4 +1472,21 @@ AmlCreateCpcNode (

   OUT AML_OBJECT_NODE_HANDLE  *NewCpcNode   OPTIONAL

   );

 

+/** AML code generation to add a NameString to the package in a named node.

+

+

+  @param [in]  NameString NameString to add

+  @param [in]  NamedNode  Node to add the string to the included package.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddNameStringToNamedPackage (

+  IN CHAR8   *NameString,

+  IN AML_OBJECT_NODE_HANDLE  NamedNode

+  );

+

 #endif // AML_LIB_H_

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index 53c537e2d3..d7fec859ef 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -3677,3 +3677,91 @@ error_handler:

   AmlDeleteTree ((AML_NODE_HANDLE)CpcNode);

   return Status;

 }

+

+/** AML code generation to add a NameString to the package in a named node.

+

+

+  @param [in]  NameString NameString to add

+  @param [in]  NamedNode  Node to add the string to the included package.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddNameStringToNamedPackage (

+  IN CHAR8   *NameString,

+  IN AML_OBJECT_NODE_HANDLE  NamedNode

+  )

+{

+  EFI_STATUS  Status;

+  AML_DATA_NODE   *DataNode;

+  CHAR8   *AmlNameString;

+  UINT32  AmlNameStringSize;

+  AML_OBJECT_NODE_HANDLE  PackageNode;

+

+  DataNode = NULL;

+

+  if ((NamedNode == NULL)  ||

+  (AmlGetNodeType ((AML_NODE_HANDLE)NamedNode) != EAmlNodeObject)  ||

+  (!AmlNodeHasOpCode (NamedNode, AML_NAME_OP, 0)))

+  {

+ASSERT (0);

+return EFI_INVALID_PARAMETER;

+  }

+

+  PackageNode = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument (

+  NamedNode,

+  EAmlParseIndexTerm1

+  );

+  if ((PackageNode == NULL) ||

+  (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) != EAmlNodeObject) ||

+  (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0)))

+  {

+ASSERT (0);

+return EFI_INVALID_PARAMETER;

+  }

+

+  Status = ConvertAslNameToAmlName (NameString, );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+return Status;

+  }

+

+  Status = AmlGetNameStringSize (AmlNameString, );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto exit_handler;

+  }

+

+  Status = AmlCreateDataNode (

+ EAmlNodeDataTypeNameString,

+ (UINT8 *)AmlNameString,

+ AmlNameStringSize,

+ 

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto exit_handler;

+  }

+

+  Status = AmlVarListAddTail (

+ (AML_NODE_HANDLE)PackageNode,

+ (AML_NODE_HANDLE)DataNode

+ );

+  ASSERT_EFI_ERROR (Status);

+

+exit_handler:

+  if (AmlNameString != NULL) {

+FreePool (AmlNameString);

+  }

+

+  if (EFI_ERROR (Status)) {

+if (DataNode != NULL) {

+  AmlDeleteTree ((AML_NODE_HANDLE)DataNode);

+}

+  }

+

+  return Status;

+}

-- 

2.25.1





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




[edk2-devel] [PATCH v3 4/4] DynamicTablesPkg: Add Aml NameUnicodeString API

2023-09-11 Thread Jeff Brasen via groups.io
Add API to generate a Name that contains a Unicode string buffer.



Bug 4063340



Signed-off-by: Jeff Brasen 

Reviewed-by: Swatisri Kantamsetti 

Reviewed-by: Ashish Singhal 

---

 .../Include/Library/AmlLib/AmlLib.h   | 31 +++

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 86 +++

 2 files changed, 117 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index f4a4908753..e0dc1340ab 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -958,6 +958,37 @@ AmlCodeGenNameResourceTemplate (

   OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

   );

 

+/** AML code generation for a Name object node, containing a String.

+

+  AmlCodeGenNameUnicodeString ("_STR", L"String", ParentNode, NewObjectNode) is

+  equivalent of the following ASL code:

+Name(_STR, Unicode ("String"))

+

+  @ingroup CodeGenApis

+

+  @param  [in] NameString The new variable name.

+  Must be a NULL-terminated ASL NameString

+  e.g.: "DEV0", "DV15.DEV0", etc.

+  The input string is copied.

+  @param [in]  String NULL terminated Unicode String to associate to 
the

+  NameString.

+  @param [in]  ParentNode If provided, set ParentNode as the parent

+  of the node created.

+  @param [out] NewObjectNode  If success, contains the created node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenNameUnicodeString (

+  IN  CONST CHAR8   *NameString,

+  INCHAR16  *String,

+  INAML_NODE_HANDLE ParentNode  OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

+  );

+

 /** Add a _PRT entry.

 

   AmlCodeGenPrtEntry (0x0, 0, "LNKA", 0, PrtNameNode) is

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index d7fec859ef..0eba254193 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -869,6 +869,92 @@ AmlCodeGenNameResourceTemplate (

   return Status;

 }

 

+/** AML code generation for a Name object node, containing a String.

+

+ AmlCodeGenNameUnicodeString ("_STR", L"String", ParentNode, NewObjectNode) is

+ equivalent of the following ASL code:

+   Name(_STR, Unicode ("String"))

+

+ @ingroup CodeGenApis

+

+ @param  [in] NameString The new variable name.

+ Must be a NULL-terminated ASL NameString

+ e.g.: "DEV0", "DV15.DEV0", etc.

+ The input string is copied.

+ @param [in]  String NULL terminated Unicode String to associate to the

+ NameString.

+ @param [in]  ParentNode If provided, set ParentNode as the parent

+ of the node created.

+ @param [out] NewObjectNode  If success, contains the created node.

+

+ @retval EFI_SUCCESS Success.

+ @retval EFI_INVALID_PARAMETER   Invalid parameter.

+ @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenNameUnicodeString (

+  IN  CONST CHAR8   *NameString,

+  INCHAR16  *String,

+  INAML_NODE_HANDLE ParentNode  OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

+  )

+{

+  EFI_STATUS   Status;

+  AML_OBJECT_NODE  *ObjectNode;

+  AML_DATA_NODE*DataNode;

+

+  if ((NameString == NULL)  ||

+  (String == NULL)  ||

+  ((ParentNode == NULL) && (NewObjectNode == NULL)))

+  {

+ASSERT (0);

+return EFI_INVALID_PARAMETER;

+  }

+

+  Status = AmlCodeGenBuffer (NULL, 0, );

+  if (EFI_ERROR (Status)) {

+ASSERT_EFI_ERROR (Status);

+return Status;

+  }

+

+  Status = AmlCreateDataNode (

+ EAmlNodeDataTypeRaw,

+ (CONST UINT8 *)String,

+ StrSize (String),

+ 

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT_EFI_ERROR (Status);

+AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);

+return Status;

+  }

+

+  Status = AmlVarListAddTail (

+ (AML_NODE_HEADER *)ObjectNode,

+ (AML_NODE_HEADER *)DataNode

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT_EFI_ERROR (Status);

+AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);

+AmlDeleteTree ((AML_NODE_HANDLE)DataNode);

+return Status;

+  }

+

+  Status = AmlCodeGenName (

+ NameString,

+ ObjectNode,

+   

[edk2-devel] [PATCH v3 0/4] Add support for generating ACPI ThermalZones

2023-09-11 Thread Jeff Brasen via groups.io
Add APIs needed to create thermal zones dynamically.
Does not add a generator for this as creating the TMP method generically may
be difficult.

Change log:

v3 - Fixed a couple error handling paths
v2 - renamed NameString function and added goto dones in a couple error cases

Jeff Brasen (4):
  DynamicTablesPkg: Add ThermalZone CodeGen function
  DynamicTablesPkg: Add support for simple method invocation.
  DynamicTablesPkg: Add support to add Strings to package
  DynamicTablesPkg: Add Aml NameUnicodeString API

 .../Include/Library/AmlLib/AmlLib.h   | 130 +
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 526 ++
 2 files changed, 656 insertions(+)

-- 
2.25.1



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




Re: [edk2-devel] [PATCH v2 0/2] dp command without ACPI

2023-09-11 Thread Jeff Brasen via groups.io


Any additional thoughts/feedback on this patch series?

Thanks,
Jeff


> -Original Message-
> From: Jeff Brasen 
> Sent: Friday, June 30, 2023 11:30 AM
> To: devel@edk2.groups.io
> Cc: jian.j.w...@intel.com; gaolim...@byosoft.com.cn; dandan...@intel.com;
> zhichao@intel.com; Jeff Brasen 
> Subject: [PATCH v2 0/2] dp command without ACPI
> 
> Systems that do not boot with ACPI (system that use device tree for example)
> can not use the shell dp command. This patch adds this to the configuration
> table so that dp command can get this without the FPDT table.
> 
> I am open to other ways for this to be passed if desired (Installed protocol,
> handler of the status code, etc) but wanted to post this to at least get
> thoughts on this.
> 
> Change Log
> v2 - Fix missing cast for IA32 builds
> 
> -Jeff
> 
> Jeff Brasen (2):
>   MdeModulePkg/DxeCorePerformanceLib: Install BPDT in config table
>   ShellPkg/Dp: Allow dp command to work without ACPI
> 
>  ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf|  1 +
>  .../DpDynamicCommand/DpDynamicCommand.inf |  1 +
>  .../DxeCorePerformanceLib/DxeCorePerformanceLib.c |  2 ++
>  ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 11 -
> --
>  4 files changed, 12 insertions(+), 3 deletions(-)
> 
> --
> 2.25.1



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




Re: [edk2-devel] [PATCH] MdeModulePkg/DxeCore: Allow relocation of images with large address

2023-09-11 Thread Jeff Brasen via groups.io
Any  thoughts/feedback on this patch?

Thanks,
Jeff


> -Original Message-
> From: Jeff Brasen 
> Sent: Monday, May 15, 2023 5:49 PM
> To: devel@edk2.groups.io
> Cc: jian.j.w...@intel.com; gaolim...@byosoft.com.cn; dandan...@intel.com;
> Jeff Brasen ; Ashish Singhal
> 
> Subject: [PATCH] MdeModulePkg/DxeCore: Allow relocation of images with
> large address
> 
> Add PCD to control if modules with start addresses in PE/COFF > 0x10
> attempt to load at specified address.
> If a module has an address in this range and there is untested memory
> DxeCore will attempt to promote all memory to tested which bypasses any
> memory testing that would occur later in boot.
> 
> There are several existing AARCH64 option roms that have base addresses of
> 0x18000.
> 
> Signed-off-by: Jeff Brasen 
> Reviewed-by: Ashish Singhal 
> ---
>  MdeModulePkg/Core/Dxe/DxeMain.inf   | 1 +
>  MdeModulePkg/Core/Dxe/Image/Image.c | 4 +++-
>  MdeModulePkg/MdeModulePkg.dec   | 7 +++
>  3 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf
> b/MdeModulePkg/Core/Dxe/DxeMain.inf
> index 35d5bf0dee..16871f2021 100644
> --- a/MdeModulePkg/Core/Dxe/DxeMain.inf
> +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
> @@ -187,6 +187,7 @@
>gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask
> ## CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard   
> ##
> CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdFwVolDxeMaxEncapsulationDepth
> ## CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdImageLargeAddressLoad
> ## CONSUMES
> 
>  # [Hob]
>  # RESOURCE_DESCRIPTOR   ## CONSUMES
> diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c
> b/MdeModulePkg/Core/Dxe/Image/Image.c
> index 9dbfb2a1fa..6bc3a549ae 100644
> --- a/MdeModulePkg/Core/Dxe/Image/Image.c
> +++ b/MdeModulePkg/Core/Dxe/Image/Image.c
> @@ -680,7 +680,9 @@ CoreLoadPeImage (
> );
>}
>  } else {
> -  if ((Image->ImageContext.ImageAddress >= 0x10) || Image-
> >ImageContext.RelocationsStripped) {
> +  if ((PcdGetBool (PcdImageLargeAddressLoad) && ((Image-
> >ImageContext.ImageAddress) >= 0x10)) ||
> +  Image->ImageContext.RelocationsStripped)
> +  {
>  Status = CoreAllocatePages (
> AllocateAddress,
> (EFI_MEMORY_TYPE)(Image-
> >ImageContext.ImageCodeMemoryType),
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec index 95dd077e19..6fd1bd7b8f
> 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -1116,6 +1116,13 @@
># @Prompt Output MMIO address of Trace Hub message.
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugMmioAddress|0|UIN
> T64|0x30001058
> 
> +  ## Indicates if images with large load address (>0x10) should
> attempted to load at specified location.
> +  #  If enabled, attempt to allocate at specfied location will be attempted 
> with
> a fall back to any address.
> +  #   TRUE  - UEFI will attempt to load at specified location.
> +  #   FALSE - UEFI will load at any address
> +  # @Prompt Enable large address image loading.
> +
> +
> gEfiMdeModulePkgTokenSpaceGuid.PcdImageLargeAddressLoad|TRUE|BOOL
> EAN|0
> + x30001059
> +
>  [PcdsFixedAtBuild, PcdsPatchableInModule]
>## Dynamic type PCD can be registered callback function for Pcd setting
> action.
>#  PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum
> number of callback function
> --
> 2.25.1



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




Re: [edk2-devel] [PATCH] MdeModulePkg/PciHostBridge: Add support for driver binding

2023-07-11 Thread Jeff Brasen via groups.io
Ray,

  Would you prefer this sort of use would be done by an extra dispatch after 
the wait for everything being completed and the connect controller call in BDS 
as opposed to the driver binding approach?  Basically using a depex on the 
library as we are currently doing. 

-Jeff


> -Original Message-
> From: Jeff Brasen 
> Sent: Friday, June 30, 2023 9:57 AM
> To: Ni, Ray ; devel@edk2.groups.io
> Cc: Wang, Jian J ; Gao, Liming
> ; Wu, Hao A 
> Subject: RE: [PATCH] MdeModulePkg/PciHostBridge: Add support for driver
> binding
> 
> 
> 
> > -Original Message-
> > From: Ni, Ray 
> > Sent: Thursday, June 29, 2023 9:59 PM
> > To: Jeff Brasen ; devel@edk2.groups.io
> > Cc: Wang, Jian J ; Gao, Liming
> > ; Wu, Hao A 
> > Subject: RE: [PATCH] MdeModulePkg/PciHostBridge: Add support for
> > driver binding
> >
> > External email: Use caution opening links or attachments
> >
> >
> > > -Original Message-
> > > From: Jeff Brasen 
> > > Sent: Friday, June 30, 2023 11:21 AM
> > > To: Ni, Ray ; devel@edk2.groups.io
> > > Cc: Wang, Jian J ; Gao, Liming
> > > ; Wu, Hao A 
> > > Subject: RE: [PATCH] MdeModulePkg/PciHostBridge: Add support for
> > > driver binding
> > >
> > > Not sure why the patch failed to apply I'll see if there is
> > > something wrong with my gitconfig tomorrow. The path you suggested
> > > below is exactly what our current implementation does. However, I am
> > > trying to make our pcie controller driver do async initialization so
> > > that using a depex is less ideal as we may have to postpone driver
> > > load to after end of dxe instead of just the connection. It seemed
> > > that a driver binding
> > type approach was a good approach for this.
> >
> > I am curious how the pcie root (root complex) initialization is done
> > in async way?
> > Does it use a timer callback to poll the initialization status every
> > certain interval?
> >
> 
> [JB] That is correct, we use a timer when we expect sleeps or polling loops.
> 
> > On the other hand, even you make PciHostBridge as a UEFI driver-model
> > driver, you still require some code to initiate the
> > "ConnectController()". How is that done?
> >
> > Comparing the two paths (today's = my proposal, new way = your patch),
> > both require some code to explicitly call "ConnectController()".
> >
> 
> [JB] We have a sync point in BDS prior to the ConnectController call that is
> made. I could put that and a dispatch call prior to EndOfDxe signal but was
> hoping to not trigger any of the driver seen but not loaded debug messages
> from the main dispatch loop if possible as that can be a useful message to
> trigger something might be wrong.
> 
> > >
> > > On a less important implementation if the pieces that live under the
> > > library are driver binding we have to reject any stop requests as
> > > there is no driver linkage between the two layers.
> >
> > In x86, root complex (pcie root) is almost the root of all
> > peripherals. I cannot see a value to Stop () the pcie root.
> > If you check the PciBus implementation, it supports Stop() but the
> > Stop() only succeeds when all upper layer drivers succeed to Stop().
> > (usually it's not the
> > case.) And even PciBus.Stop() succeeds, the resource(MMIO/IO/BUS)
> > allocation is not un-done. It's only the PciIo handles that are
> > destroyed in software level.
> >
> 
> [JB] Yeah, not allowing stop to work on this isn't a big deal (and what we
> currently have implemented) but it was something we noticed a while ago is
> that we couldn't implement this even if we wanted to as there was no way to
> stop the host bridge driver.
> 
> > Thanks,
> > Ray
> >
> >
> > >
> > > -Jeff
> > >
> > >
> > > -Original Message-
> > > From: Ni, Ray 
> > > Sent: Thursday, June 29, 2023 8:29 PM
> > > To: Jeff Brasen ; devel@edk2.groups.io
> > > Cc: Wang, Jian J ; Gao, Liming
> > > ; Wu, Hao A 
> > > Subject: RE: [PATCH] MdeModulePkg/PciHostBridge: Add support for
> > > driver binding
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > I failed to apply the patch in my local tree.
> > >
> > > It seems you invented a new EdkiiRootBridgeIo protocol and a certain
> > > proprietary driver would produce this protocol instance.
> > > Then the open source PciHostBridge driver starts on that.
> > >
> > > Then, why not implement your own PciHostBridgeLib and let it depends
> > > on some "AllRootBridgeIoInformationIsReady" protocol.
> > > So that the PciHostBridge driver could still call PciHostBridgeLib
> > > and all your implementation in this patch can be in that lib.
> > >
> > > Thanks,
> > > Ray
> > >
> > > > -Original Message-
> > > > From: Jeff Brasen 
> > > > Sent: Friday, June 30, 2023 4:54 AM
> > > > To: devel@edk2.groups.io
> > > > Cc: Wang, Jian J ; Gao, Liming
> > > > ; Wu, Hao A ; Ni,
> > > > Ray ; Jeff Brasen 
> > > > Subject: [PATCH] MdeModulePkg/PciHostBridge: Add support for
> > > > driver binding
> > > >
> > > > If the platform does not 

[edk2-devel] [PATCH v2 4/4] DynamicTablesPkg: Add Aml NameUnicodeString API

2023-07-10 Thread Jeff Brasen via groups.io
Add API to generate a Name that contains a Unicode string buffer.

Signed-off-by: Jeff Brasen 
Reviewed-by: Swatisri Kantamsetti 
Reviewed-by: Ashish Singhal 
---
 .../Include/Library/AmlLib/AmlLib.h   | 31 +++
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 86 +++
 2 files changed, 117 insertions(+)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index f4a490875365..e0dc1340ab50 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -958,6 +958,37 @@ AmlCodeGenNameResourceTemplate (
   OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL
   );
 
+/** AML code generation for a Name object node, containing a String.
+
+  AmlCodeGenNameUnicodeString ("_STR", L"String", ParentNode, NewObjectNode) is
+  equivalent of the following ASL code:
+Name(_STR, Unicode ("String"))
+
+  @ingroup CodeGenApis
+
+  @param  [in] NameString The new variable name.
+  Must be a NULL-terminated ASL NameString
+  e.g.: "DEV0", "DV15.DEV0", etc.
+  The input string is copied.
+  @param [in]  String NULL terminated Unicode String to associate to 
the
+  NameString.
+  @param [in]  ParentNode If provided, set ParentNode as the parent
+  of the node created.
+  @param [out] NewObjectNode  If success, contains the created node.
+
+  @retval EFI_SUCCESS Success.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenNameUnicodeString (
+  IN  CONST CHAR8   *NameString,
+  INCHAR16  *String,
+  INAML_NODE_HANDLE ParentNode  OPTIONAL,
+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL
+  );
+
 /** Add a _PRT entry.
 
   AmlCodeGenPrtEntry (0x0, 0, "LNKA", 0, PrtNameNode) is
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index a2009d9805b5..ffc809ba1b0a 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -869,6 +869,92 @@ AmlCodeGenNameResourceTemplate (
   return Status;
 }
 
+/** AML code generation for a Name object node, containing a String.
+
+ AmlCodeGenNameUnicodeString ("_STR", L"String", ParentNode, NewObjectNode) is
+ equivalent of the following ASL code:
+   Name(_STR, Unicode ("String"))
+
+ @ingroup CodeGenApis
+
+ @param  [in] NameString The new variable name.
+ Must be a NULL-terminated ASL NameString
+ e.g.: "DEV0", "DV15.DEV0", etc.
+ The input string is copied.
+ @param [in]  String NULL terminated Unicode String to associate to the
+ NameString.
+ @param [in]  ParentNode If provided, set ParentNode as the parent
+ of the node created.
+ @param [out] NewObjectNode  If success, contains the created node.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER   Invalid parameter.
+ @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenNameUnicodeString (
+  IN  CONST CHAR8   *NameString,
+  INCHAR16  *String,
+  INAML_NODE_HANDLE ParentNode  OPTIONAL,
+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL
+  )
+{
+  EFI_STATUS   Status;
+  AML_OBJECT_NODE  *ObjectNode;
+  AML_DATA_NODE*DataNode;
+
+  if ((NameString == NULL)  ||
+  (String == NULL)  ||
+  ((ParentNode == NULL) && (NewObjectNode == NULL)))
+  {
+ASSERT (0);
+return EFI_INVALID_PARAMETER;
+  }
+
+  Status = AmlCodeGenBuffer (NULL, 0, );
+  if (EFI_ERROR (Status)) {
+ASSERT_EFI_ERROR (Status);
+return Status;
+  }
+
+  Status = AmlCreateDataNode (
+ EAmlNodeDataTypeRaw,
+ (CONST UINT8 *)String,
+ StrSize (String),
+ 
+ );
+  if (EFI_ERROR (Status)) {
+ASSERT_EFI_ERROR (Status);
+AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
+return Status;
+  }
+
+  Status = AmlVarListAddTail (
+ (AML_NODE_HEADER *)ObjectNode,
+ (AML_NODE_HEADER *)DataNode
+ );
+  if (EFI_ERROR (Status)) {
+ASSERT_EFI_ERROR (Status);
+AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
+AmlDeleteTree ((AML_NODE_HANDLE)DataNode);
+return Status;
+  }
+
+  Status = AmlCodeGenName (
+ NameString,
+ ObjectNode,
+ ParentNode,
+ NewObjectNode
+ );
+  if (EFI_ERROR (Status)) {
+ASSERT (0);
+AmlDeleteTree 

[edk2-devel] [PATCH v2 3/4] DynamicTablesPkg: Add support to add Strings to package

2023-07-10 Thread Jeff Brasen via groups.io
Add API to add a String to a package created with NamedPackage API.

Signed-off-by: Jeff Brasen 
Reviewed-by: Swatisri Kantamsetti 
Reviewed-by: Ashish Singhal 
---
 .../Include/Library/AmlLib/AmlLib.h   | 17 
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 82 +++
 2 files changed, 99 insertions(+)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index b82c7a3ce874..f4a490875365 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -1472,4 +1472,21 @@ AmlCreateCpcNode (
   OUT AML_OBJECT_NODE_HANDLE  *NewCpcNode   OPTIONAL
   );
 
+/** AML code generation to add a NameString to the package in a named node.
+
+
+  @param [in]  NameString NameString to add
+  @param [in]  NamedNode  Node to add the string to the included package.
+
+  @retval EFI_SUCCESS Success.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+AmlAddNameStringToNamedPackage (
+  IN CHAR8   *NameString,
+  IN AML_OBJECT_NODE_HANDLE  NamedNode
+  );
+
 #endif // AML_LIB_H_
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index d31a86e98c4c..a2009d9805b5 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -3665,3 +3665,85 @@ AmlCreateCpcNode (
   AmlDeleteTree ((AML_NODE_HANDLE)CpcNode);
   return Status;
 }
+
+/** AML code generation to add a NameString to the package in a named node.
+
+
+  @param [in]  NameString NameString to add
+  @param [in]  NamedNode  Node to add the string to the included package.
+
+  @retval EFI_SUCCESS Success.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+AmlAddNameStringToNamedPackage (
+  IN CHAR8   *NameString,
+  IN AML_OBJECT_NODE_HANDLE  NamedNode
+  )
+{
+  EFI_STATUS  Status;
+  AML_DATA_NODE   *DataNode;
+  CHAR8   *AmlNameString;
+  UINT32  AmlNameStringSize;
+  AML_OBJECT_NODE_HANDLE  PackageNode;
+
+  DataNode = NULL;
+
+  if ((NamedNode == NULL)  ||
+  (AmlGetNodeType ((AML_NODE_HANDLE)NamedNode) != EAmlNodeObject)  ||
+  (!AmlNodeHasOpCode (NamedNode, AML_NAME_OP, 0)))
+  {
+ASSERT (0);
+return EFI_INVALID_PARAMETER;
+  }
+
+  PackageNode = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument (
+  NamedNode,
+  EAmlParseIndexTerm1
+  );
+  if ((PackageNode == NULL) ||
+  (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) != EAmlNodeObject) ||
+  (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0)))
+  {
+ASSERT (0);
+return EFI_INVALID_PARAMETER;
+  }
+
+  Status = ConvertAslNameToAmlName (NameString, );
+  if (EFI_ERROR (Status)) {
+ASSERT (0);
+return Status;
+  }
+
+  Status = AmlGetNameStringSize (AmlNameString, );
+  if (EFI_ERROR (Status)) {
+ASSERT (0);
+goto exit_handler;
+  }
+
+  Status = AmlCreateDataNode (
+ EAmlNodeDataTypeNameString,
+ (UINT8 *)AmlNameString,
+ AmlNameStringSize,
+ 
+ );
+  if (EFI_ERROR (Status)) {
+ASSERT (0);
+goto exit_handler;
+  }
+
+  Status = AmlVarListAddTail (
+ (AML_NODE_HANDLE)PackageNode,
+ (AML_NODE_HANDLE)DataNode
+ );
+  ASSERT_EFI_ERROR (Status);
+
+exit_handler:
+  if (AmlNameString != NULL) {
+FreePool (AmlNameString);
+  }
+
+  return Status;
+}
-- 
2.25.1



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




[edk2-devel] [PATCH v2 2/4] DynamicTablesPkg: Add support for simple method invocation.

2023-07-10 Thread Jeff Brasen via groups.io
Add support to add Return objects via AML that pass a single integer
argument to the named method.

Reviewed-by: Swatisri Kantamsetti 
Reviewed-by: Ashish Singhal 
---
 .../Include/Library/AmlLib/AmlLib.h   |  54 +
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 224 ++
 2 files changed, 278 insertions(+)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index d201ae9499fa..b82c7a3ce874 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -1194,6 +1194,60 @@ AmlCodeGenMethodRetInteger (
   OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNodeOPTIONAL
   );
 
+/** AML code generation for a method returning a NameString that takes an
+integer argument.
+
+  AmlCodeGenMethodRetNameStringIntegerArgument (
+"MET0", "MET1", 1, TRUE, 3, 5, ParentNode, NewObjectNode
+);
+  is equivalent of the following ASL code:
+Method(MET0, 1, Serialized, 3) {
+  Return (MET1 (5))
+}
+
+  The ASL parameters "ReturnType" and "ParameterTypes" are not asked
+  in this function. They are optional parameters in ASL.
+
+  @param [in]  MethodNameString The new Method's name.
+Must be a NULL-terminated ASL NameString
+e.g.: "MET0", "_SB.MET0", etc.
+The input string is copied.
+  @param [in]  ReturnedNameString   The name of the object returned by the
+method. Optional parameter, can be:
+ - NULL (ignored).
+ - A NULL-terminated ASL NameString.
+   e.g.: "MET0", "_SB.MET0", etc.
+   The input string is copied.
+  @param [in]  NumArgs  Number of arguments.
+Must be 0 <= NumArgs <= 6.
+  @param [in]  IsSerialized TRUE is equivalent to Serialized.
+FALSE is equivalent to NotSerialized.
+Default is NotSerialized in ASL spec.
+  @param [in]  SyncLevelSynchronization level for the method.
+Must be 0 <= SyncLevel <= 15.
+Default is 0 in ASL.
+  @param [in]  IntegerArgument  Argument to pass to the NameString.
+  @param [in]  ParentNode   If provided, set ParentNode as the parent
+of the node created.
+  @param [out] NewObjectNodeIf success, contains the created node.
+
+  @retval EFI_SUCCESS Success.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenMethodRetNameStringIntegerArgument (
+  IN  CONST CHAR8   *MethodNameString,
+  IN  CONST CHAR8   *ReturnedNameString   OPTIONAL,
+  INUINT8   NumArgs,
+  INBOOLEAN IsSerialized,
+  INUINT8   SyncLevel,
+  INUINT64  IntegerArgument,
+  INAML_NODE_HANDLE ParentNode   OPTIONAL,
+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNodeOPTIONAL
+  );
+
 /** Create a _LPI name.
 
   AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, ) is
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index 88537b7e2d27..d31a86e98c4c 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -1881,6 +1881,118 @@ AmlCodeGenReturnInteger (
   return Status;
 }
 
+/** AML code generation for a Return object node,
+returning the object as an input NameString with a integer argument.
+
+  AmlCodeGenReturn ("NAM1", 6, ParentNode, NewObjectNode) is
+  equivalent of the following ASL code:
+Return(NAM1 (6))
+
+  The ACPI 6.3 specification, s20.2.5.3 "Type 1 Opcodes Encoding" states:
+DefReturn := ReturnOp ArgObject
+ReturnOp := 0xA4
+ArgObject := TermArg => DataRefObject
+
+  Thus, the ReturnNode must be evaluated as a DataRefObject. It can
+  be a NameString referencing an object. As this CodeGen Api doesn't
+  do semantic checking, it is strongly advised to check the AML bytecode
+  generated by this function against an ASL compiler.
+
+  The ReturnNode must be generated inside a Method body scope.
+
+  @param [in]  NameString The object referenced by this NameString
+  is returned by the Return ASL statement.
+  Must be a NULL-terminated ASL NameString
+  e.g.: "NAM1", "_SB.NAM1", etc.
+  The input string is copied.
+  @param [in]  

[edk2-devel] [PATCH v2 0/4] Add support for generating ACPI ThermalZones

2023-07-10 Thread Jeff Brasen via groups.io
Add APIs needed to create thermal zones dynamically.
Does not add a generator for this as creating the TMP method generically may
be difficult.

Change log:

v2 - renamed NameString function and added goto dones in a couple error cases

Jeff Brasen (4):
  DynamicTablesPkg: Add ThermalZone CodeGen function
  DynamicTablesPkg: Add support for simple method invocation.
  DynamicTablesPkg: Add support to add Strings to package
  DynamicTablesPkg: Add Aml NameUnicodeString API

 .../Include/Library/AmlLib/AmlLib.h   | 130 +
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 508 ++
 2 files changed, 638 insertions(+)

-- 
2.25.1



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




[edk2-devel] [PATCH v2 1/4] DynamicTablesPkg: Add ThermalZone CodeGen function

2023-07-10 Thread Jeff Brasen via groups.io
Add API to generate a ThermalZone object to AmlLib.

Reviewed-by: Swatisri Kantamsetti 
Reviewed-by: Ashish Singhal 
---
 .../Include/Library/AmlLib/AmlLib.h   |  28 +
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 116 ++
 2 files changed, 144 insertions(+)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 9210c5091548..d201ae9499fa 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -1038,6 +1038,34 @@ AmlCodeGenDevice (
   OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL
   );
 
+/** AML code generation for a ThermalZone object node.
+
+  AmlCodeGenThermalZone ("TZ00", ParentNode, NewObjectNode) is
+  equivalent of the following ASL code:
+ThermalZone(TZ00) {}
+
+  @ingroup CodeGenApis
+
+  @param  [in] NameString The new ThermalZone's name.
+  Must be a NULL-terminated ASL NameString
+  e.g.: "DEV0", "DV15.DEV0", etc.
+  The input string is copied.
+  @param [in]  ParentNode If provided, set ParentNode as the parent
+  of the node created.
+  @param [out] NewObjectNode  If success, contains the created node.
+
+  @retval EFI_SUCCESS Success.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenThermalZone (
+  IN  CONST CHAR8   *NameString,
+  INAML_NODE_HANDLE ParentNode  OPTIONAL,
+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL
+  );
+
 /** AML code generation for a Scope object node.
 
   AmlCodeGenScope ("_SB", ParentNode, NewObjectNode) is
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index 0b223379fa4b..88537b7e2d27 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -1218,6 +1218,122 @@ AmlCodeGenDevice (
   return Status;
 }
 
+/** AML code generation for a ThermalZone object node.
+
+  AmlCodeGenThermalZone ("TZ00", ParentNode, NewObjectNode) is
+  equivalent of the following ASL code:
+ThermalZone(TZ00) {}
+
+  @ingroup CodeGenApis
+
+  @param  [in] NameString The new ThermalZone's name.
+  Must be a NULL-terminated ASL NameString
+  e.g.: "DEV0", "DV15.DEV0", etc.
+  The input string is copied.
+  @param [in]  ParentNode If provided, set ParentNode as the parent
+  of the node created.
+  @param [out] NewObjectNode  If success, contains the created node.
+
+  @retval EFI_SUCCESS Success.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenThermalZone (
+  IN  CONST CHAR8   *NameString,
+  INAML_NODE_HANDLE ParentNode  OPTIONAL,
+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL
+  )
+{
+  EFI_STATUS   Status;
+  AML_OBJECT_NODE  *ObjectNode;
+  AML_DATA_NODE*DataNode;
+  CHAR8*AmlNameString;
+  UINT32   AmlNameStringSize;
+
+  if ((NameString == NULL)  ||
+  ((ParentNode == NULL) && (NewObjectNode == NULL)))
+  {
+ASSERT (0);
+return EFI_INVALID_PARAMETER;
+  }
+
+  ObjectNode= NULL;
+  DataNode  = NULL;
+  AmlNameString = NULL;
+
+  Status = ConvertAslNameToAmlName (NameString, );
+  if (EFI_ERROR (Status)) {
+ASSERT (0);
+return Status;
+  }
+
+  Status = AmlGetNameStringSize (AmlNameString, );
+  if (EFI_ERROR (Status)) {
+ASSERT (0);
+goto error_handler1;
+  }
+
+  Status = AmlCreateObjectNode (
+ AmlGetByteEncodingByOpCode (AML_EXT_OP, AML_EXT_THERMAL_ZONE_OP),
+ AmlNameStringSize + AmlComputePkgLengthWidth (AmlNameStringSize),
+ 
+ );
+  if (EFI_ERROR (Status)) {
+ASSERT (0);
+goto error_handler1;
+  }
+
+  Status = AmlCreateDataNode (
+ EAmlNodeDataTypeNameString,
+ (UINT8 *)AmlNameString,
+ AmlNameStringSize,
+ 
+ );
+  if (EFI_ERROR (Status)) {
+ASSERT (0);
+goto error_handler2;
+  }
+
+  Status = AmlSetFixedArgument (
+ ObjectNode,
+ EAmlParseIndexTerm0,
+ (AML_NODE_HEADER *)DataNode
+ );
+  if (EFI_ERROR (Status)) {
+ASSERT (0);
+AmlDeleteTree ((AML_NODE_HEADER *)DataNode);
+goto error_handler2;
+  }
+
+  Status = LinkNode (
+ ObjectNode,
+ ParentNode,
+ NewObjectNode
+ );
+  if (EFI_ERROR (Status)) {
+ASSERT (0);
+goto error_handler2;
+  }
+
+  // Free AmlNameString 

[edk2-devel] [PATCH v2 2/2] ShellPkg/Dp: Allow dp command to work without ACPI

2023-06-30 Thread Jeff Brasen via groups.io
If the system does not have ACPI setup use the configuration table
to get the performance info.

Signed-off-by: Jeff Brasen 
---
 ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf|  1 +
 .../DpDynamicCommand/DpDynamicCommand.inf |  1 +
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 11 ---
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf 
b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
index 4a58286b8c1a..d9e1c23a1ee7 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
@@ -54,6 +54,7 @@ [LibraryClasses]
 
 [Guids]
   gPerformanceProtocolGuid## CONSUMES ## 
SystemTable
+  gEdkiiFpdtExtendedFirmwarePerformanceGuid   ## CONSUMES ## 
SystemTable
 
 [Protocols]
   gEfiLoadedImageProtocolGuid ## CONSUMES
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf 
b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
index 013bdbd4a07e..2723fee7066e 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
@@ -55,6 +55,7 @@ [LibraryClasses]
 
 [Guids]
   gPerformanceProtocolGuid## CONSUMES ## 
SystemTable
+  gEdkiiFpdtExtendedFirmwarePerformanceGuid   ## CONSUMES ## 
SystemTable
 
 [Protocols]
   gEfiLoadedImageProtocolGuid ## CONSUMES
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c 
b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index 512a146da6dd..98c84d2ef938 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -129,17 +129,22 @@ EFI_STATUS
 GetBootPerformanceTable (
   )
 {
+  EFI_STATUS  Status;
   FIRMWARE_PERFORMANCE_TABLE  *FirmwarePerformanceTable;
 
   FirmwarePerformanceTable = (FIRMWARE_PERFORMANCE_TABLE 
*)EfiLocateFirstAcpiTable (
  
EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
  );
   if (FirmwarePerformanceTable == NULL) {
-ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_ACPI_FPDT_FAIL), 
mDpHiiHandle);
-return EFI_NOT_FOUND;
+Status = EfiGetSystemConfigurationTable 
(, (VOID **));
+if (EFI_ERROR (Status)) {
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_ACPI_FPDT_FAIL), 
mDpHiiHandle);
+  return EFI_NOT_FOUND;
+}
+  } else {
+mBootPerformanceTable = (UINT8 
*)(UINTN)FirmwarePerformanceTable->BootPointerRecord.BootPerformanceTablePointer;
   }
 
-  mBootPerformanceTable = (UINT8 
*)(UINTN)FirmwarePerformanceTable->BootPointerRecord.BootPerformanceTablePointer;
   mBootPerformanceTableSize = ((BOOT_PERFORMANCE_TABLE 
*)mBootPerformanceTable)->Header.Length;
 
   return EFI_SUCCESS;
-- 
2.25.1



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




[edk2-devel] [PATCH v2 1/2] MdeModulePkg/DxeCorePerformanceLib: Install BPDT in config table

2023-06-30 Thread Jeff Brasen via groups.io
Install the performance table into the UEFI configuration table.
This will allow the shell application to get this if the system
is not using ACPI.

Signed-off-by: Jeff Brasen 
---
 .../Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c   | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c 
b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index ef14bc073810..57792ba44e7f 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -1403,6 +1403,8 @@ ReportFpdtRecordBuffer (
 ,
 sizeof (UINT64)
 );
+  Status = gBS->InstallConfigurationTable 
(, (VOID *)(UINTN)BPDTAddr);
+  ASSERT_EFI_ERROR (Status);
 }
 
 //
-- 
2.25.1



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




[edk2-devel] [PATCH v2 0/2] dp command without ACPI

2023-06-30 Thread Jeff Brasen via groups.io
Systems that do not boot with ACPI (system that use device tree for example)
can not use the shell dp command. This patch adds this to the configuration
table so that dp command can get this without the FPDT table.

I am open to other ways for this to be passed if desired (Installed protocol,
handler of the status code, etc) but wanted to post this to at least get 
thoughts
on this.

Change Log
v2 - Fix missing cast for IA32 builds

-Jeff

Jeff Brasen (2):
  MdeModulePkg/DxeCorePerformanceLib: Install BPDT in config table
  ShellPkg/Dp: Allow dp command to work without ACPI

 ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf|  1 +
 .../DpDynamicCommand/DpDynamicCommand.inf |  1 +
 .../DxeCorePerformanceLib/DxeCorePerformanceLib.c |  2 ++
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 11 ---
 4 files changed, 12 insertions(+), 3 deletions(-)

-- 
2.25.1



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




Re: [edk2-devel] [PATCH] MdeModulePkg/PciHostBridge: Add support for driver binding

2023-06-30 Thread Jeff Brasen via groups.io



> -Original Message-
> From: Ni, Ray 
> Sent: Thursday, June 29, 2023 9:59 PM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: Wang, Jian J ; Gao, Liming
> ; Wu, Hao A 
> Subject: RE: [PATCH] MdeModulePkg/PciHostBridge: Add support for driver
> binding
> 
> External email: Use caution opening links or attachments
> 
> 
> > -Original Message-
> > From: Jeff Brasen 
> > Sent: Friday, June 30, 2023 11:21 AM
> > To: Ni, Ray ; devel@edk2.groups.io
> > Cc: Wang, Jian J ; Gao, Liming
> > ; Wu, Hao A 
> > Subject: RE: [PATCH] MdeModulePkg/PciHostBridge: Add support for
> > driver binding
> >
> > Not sure why the patch failed to apply I'll see if there is something
> > wrong with my gitconfig tomorrow. The path you suggested below is
> > exactly what our current implementation does. However, I am trying to
> > make our pcie controller driver do async initialization so that using
> > a depex is less ideal as we may have to postpone driver load to after
> > end of dxe instead of just the connection. It seemed that a driver binding
> type approach was a good approach for this.
> 
> I am curious how the pcie root (root complex) initialization is done in async
> way?
> Does it use a timer callback to poll the initialization status every certain
> interval?
> 

[JB] That is correct, we use a timer when we expect sleeps or polling loops.

> On the other hand, even you make PciHostBridge as a UEFI driver-model
> driver, you still require some code to initiate the "ConnectController()". 
> How is
> that done?
> 
> Comparing the two paths (today's = my proposal, new way = your patch),
> both require some code to explicitly call "ConnectController()".
> 

[JB] We have a sync point in BDS prior to the ConnectController call that is 
made. I could put that and a dispatch call prior to EndOfDxe signal but was 
hoping to not trigger any of the driver seen but not loaded debug messages from 
the main dispatch loop if possible as that can be a useful message to trigger 
something might be wrong. 

> >
> > On a less important implementation if the pieces that live under the
> > library are driver binding we have to reject any stop requests as
> > there is no driver linkage between the two layers.
> 
> In x86, root complex (pcie root) is almost the root of all peripherals. I 
> cannot
> see a value to Stop () the pcie root.
> If you check the PciBus implementation, it supports Stop() but the Stop() only
> succeeds when all upper layer drivers succeed to Stop(). (usually it's not the
> case.) And even PciBus.Stop() succeeds, the resource(MMIO/IO/BUS)
> allocation is not un-done. It's only the PciIo handles that are destroyed in
> software level.
> 

[JB] Yeah, not allowing stop to work on this isn't a big deal (and what we 
currently have implemented) but it was something we noticed a while ago is that 
we couldn't implement this even if we wanted to as there was no way to stop the 
host bridge driver.

> Thanks,
> Ray
> 
> 
> >
> > -Jeff
> >
> >
> > -Original Message-
> > From: Ni, Ray 
> > Sent: Thursday, June 29, 2023 8:29 PM
> > To: Jeff Brasen ; devel@edk2.groups.io
> > Cc: Wang, Jian J ; Gao, Liming
> > ; Wu, Hao A 
> > Subject: RE: [PATCH] MdeModulePkg/PciHostBridge: Add support for
> > driver binding
> >
> > External email: Use caution opening links or attachments
> >
> >
> > I failed to apply the patch in my local tree.
> >
> > It seems you invented a new EdkiiRootBridgeIo protocol and a certain
> > proprietary driver would produce this protocol instance.
> > Then the open source PciHostBridge driver starts on that.
> >
> > Then, why not implement your own PciHostBridgeLib and let it depends
> > on some "AllRootBridgeIoInformationIsReady" protocol.
> > So that the PciHostBridge driver could still call PciHostBridgeLib and
> > all your implementation in this patch can be in that lib.
> >
> > Thanks,
> > Ray
> >
> > > -Original Message-
> > > From: Jeff Brasen 
> > > Sent: Friday, June 30, 2023 4:54 AM
> > > To: devel@edk2.groups.io
> > > Cc: Wang, Jian J ; Gao, Liming
> > > ; Wu, Hao A ; Ni, Ray
> > > ; Jeff Brasen 
> > > Subject: [PATCH] MdeModulePkg/PciHostBridge: Add support for driver
> > > binding
> > >
> > > If the platform does not support any PCIe devices using the library
> > >
> > > method allow devices to connect to host bridge via driver binding.
> > >
> > >
> > >
> > > Signed-off-by: Jeff Brasen 
> > >
> > > ---
> > >
> > >  .../Bus/Pci/PciHostBridgeDxe/PciHostBridge.c  | 649
> > > ++
> > >
> > >  .../Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf |   1 +
> > >
> > >  .../Bus/Pci/PciHostBridgeDxe/PciRootBridge.h  |  13 +
> > >
> > >  .../Pci/PciHostBridgeDxe/PciRootBridgeIo.c|  24 +
> > >
> > >  MdeModulePkg/MdeModulePkg.dec |   4 +
> > >
> > >  5 files changed, 562 insertions(+), 129 deletions(-)
> > >
> > >
> > >
> > > diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
> > > b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
> 

Re: [edk2-devel] [PATCH] MdeModulePkg/PciHostBridge: Add support for driver binding

2023-06-29 Thread Jeff Brasen via groups.io
Not sure why the patch failed to apply I'll see if there is something wrong 
with my gitconfig tomorrow. The path you suggested below is exactly what our 
current implementation does. However, I am trying to make our pcie controller 
driver do async initialization so that using a depex is less ideal as we may 
have to postpone driver load to after end of dxe instead of just the 
connection. It seemed that a driver binding type approach was a good approach 
for this.

On a less important implementation if the pieces that live under the library 
are driver binding we have to reject any stop requests as there is no driver 
linkage between the two layers.

-Jeff


-Original Message-
From: Ni, Ray  
Sent: Thursday, June 29, 2023 8:29 PM
To: Jeff Brasen ; devel@edk2.groups.io
Cc: Wang, Jian J ; Gao, Liming 
; Wu, Hao A 
Subject: RE: [PATCH] MdeModulePkg/PciHostBridge: Add support for driver binding

External email: Use caution opening links or attachments


I failed to apply the patch in my local tree.

It seems you invented a new EdkiiRootBridgeIo protocol and a certain 
proprietary  driver would produce this protocol instance.
Then the open source PciHostBridge driver starts on that.

Then, why not implement your own PciHostBridgeLib and let it depends on some 
"AllRootBridgeIoInformationIsReady" protocol.
So that the PciHostBridge driver could still call PciHostBridgeLib and all your 
implementation in this patch can be in that lib.

Thanks,
Ray

> -Original Message-
> From: Jeff Brasen 
> Sent: Friday, June 30, 2023 4:54 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J ; Gao, Liming 
> ; Wu, Hao A ; Ni, Ray 
> ; Jeff Brasen 
> Subject: [PATCH] MdeModulePkg/PciHostBridge: Add support for driver 
> binding
>
> If the platform does not support any PCIe devices using the library
>
> method allow devices to connect to host bridge via driver binding.
>
>
>
> Signed-off-by: Jeff Brasen 
>
> ---
>
>  .../Bus/Pci/PciHostBridgeDxe/PciHostBridge.c  | 649 
> ++
>
>  .../Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf |   1 +
>
>  .../Bus/Pci/PciHostBridgeDxe/PciRootBridge.h  |  13 +
>
>  .../Pci/PciHostBridgeDxe/PciRootBridgeIo.c|  24 +
>
>  MdeModulePkg/MdeModulePkg.dec |   4 +
>
>  5 files changed, 562 insertions(+), 129 deletions(-)
>
>
>
> diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
> b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
>
> index d573e532ba..506c6660ae 100644
>
> --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
>
> +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
>
> @@ -422,167 +422,320 @@ IoMmuProtocolCallback (
>
>  }
>
>
>
>  /**
>
> +  PCI Root Bridge Memory setup.
>
>
>
> -  Entry point of this driver.
>
> +  @param  RootBridgeRoot Bridge instance.
>
>
>
> -  @param ImageHandle  Image handle of this driver.
>
> -  @param SystemTable  Pointer to standard EFI system table.
>
> -
>
> -  @retval EFI_SUCCESS   Succeed.
>
> -  @retval EFI_DEVICE_ERROR  Fail to install PCI_ROOT_BRIDGE_IO protocol.
>
> +  @retval EFI_SUCCESS   Memory was setup correctly
>
> +  @retval othersError in setup
>
>
>
>  **/
>
>  EFI_STATUS
>
>  EFIAPI
>
> -InitializePciHostBridge (
>
> -  IN EFI_HANDLEImageHandle,
>
> -  IN EFI_SYSTEM_TABLE  *SystemTable
>
> +PciRootBridgeMemorySetup (
>
> +  IN PCI_ROOT_BRIDGE  *RootBridge
>
>)
>
>  {
>
>EFI_STATUSStatus;
>
> -  PCI_HOST_BRIDGE_INSTANCE  *HostBridge;
>
> -  PCI_ROOT_BRIDGE_INSTANCE  *RootBridge;
>
> -  PCI_ROOT_BRIDGE   *RootBridges;
>
> -  UINTN RootBridgeCount;
>
> -  UINTN Index;
>
> +  UINT64HostAddress;
>
>PCI_ROOT_BRIDGE_APERTURE  *MemApertures[4];
>
>UINTN MemApertureIndex;
>
> -  BOOLEAN   ResourceAssigned;
>
> -  LIST_ENTRY*Link;
>
> -  UINT64HostAddress;
>
>
>
> -  RootBridges = PciHostBridgeGetRootBridges ();
>
> -  if ((RootBridges == NULL) || (RootBridgeCount == 0)) {
>
> -return EFI_UNSUPPORTED;
>
> -  }
>
> -
>
> -  Status = gBS->LocateProtocol (, NULL, (VOID 
> **));
>
> -  ASSERT_EFI_ERROR (Status);
>
> -
>
> -  //
>
> -  // Most systems in the world including complex servers have only 
> one Host Bridge.
>
> -  //
>
> -  HostBridge = AllocateZeroPool (sizeof (PCI_HOST_BRIDGE_INSTANCE));
>
> -  ASSERT (HostBridge != NULL);
>
> -
>
> -  HostBridge->Signature= PCI_HOST_BRIDGE_SIGNATURE;
>
> -  HostBridge->CanRestarted = TRUE;
>
> -  InitializeListHead (>RootBridges);
>
> -  ResourceAssigned = FALSE;
>
> -
>
> -  //
>
> -  // Create Root Bridge Device Handle in this Host Bridge
>
> -  //
>
> -  for (Index = 0; Index < RootBridgeCount; Index++) {
>
> +  if (RootBridge->Io.Base <= RootBridge->Io.Limit) {
>
>  //
>
> -// Create Root Bridge Handle Instance
>
> +// Base and Limit in PCI_ROOT_BRIDGE_APERTURE are device address.
>
> +

[edk2-devel] [PATCH 3/4] DynamicTablesPkg: Add support to add Strings to package

2023-06-29 Thread Jeff Brasen via groups.io
Add API to add a String to a package created with NamedPackage API.



Signed-off-by: Jeff Brasen 

Reviewed-by: Swatisri Kantamsetti 

Reviewed-by: Ashish Singhal 

---

 .../Include/Library/AmlLib/AmlLib.h   | 17 

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 82 +++

 2 files changed, 99 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index b82c7a3ce8..043e7ee901 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1472,4 +1472,21 @@ AmlCreateCpcNode (

   OUT AML_OBJECT_NODE_HANDLE  *NewCpcNode   OPTIONAL

   );

 

+/** AML code generation to add a string to the package in a named node.

+

+

+  @param [in]  String String to add

+  @param [in]  NamedNode  Node to add the string to the included package.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddStringToNamedPackage (

+  IN CHAR8   *String,

+  IN AML_OBJECT_NODE_HANDLE  NamedNode

+  );

+

 #endif // AML_LIB_H_

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index 2b95839e4c..a0d01032d5 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -3665,3 +3665,85 @@ error_handler:

   AmlDeleteTree ((AML_NODE_HANDLE)CpcNode);

   return Status;

 }

+

+/** AML code generation to add a string to the package in a named node.

+

+

+  @param [in]  Name   String to add

+  @param [in]  NamedNode  Node to add the string to the included package.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddStringToNamedPackage (

+  IN CHAR8   *String,

+  IN AML_OBJECT_NODE_HANDLE  NamedNode

+  )

+{

+  EFI_STATUS  Status;

+  AML_DATA_NODE   *DataNode;

+  CHAR8   *AmlNameString;

+  UINT32  AmlNameStringSize;

+  AML_OBJECT_NODE_HANDLE  PackageNode;

+

+  DataNode = NULL;

+

+  if ((NamedNode == NULL)  ||

+  (AmlGetNodeType ((AML_NODE_HANDLE)NamedNode) != EAmlNodeObject)  ||

+  (!AmlNodeHasOpCode (NamedNode, AML_NAME_OP, 0)))

+  {

+ASSERT (0);

+return EFI_INVALID_PARAMETER;

+  }

+

+  PackageNode = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument (

+  NamedNode,

+  EAmlParseIndexTerm1

+  );

+  if ((PackageNode == NULL) ||

+  (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) != EAmlNodeObject) ||

+  (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0)))

+  {

+ASSERT (0);

+return EFI_INVALID_PARAMETER;

+  }

+

+  Status = ConvertAslNameToAmlName (String, );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+return Status;

+  }

+

+  Status = AmlGetNameStringSize (AmlNameString, );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto exit_handler;

+  }

+

+  Status = AmlCreateDataNode (

+ EAmlNodeDataTypeNameString,

+ (UINT8 *)AmlNameString,

+ AmlNameStringSize,

+ 

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto exit_handler;

+  }

+

+  Status = AmlVarListAddTail (

+ (AML_NODE_HANDLE)PackageNode,

+ (AML_NODE_HANDLE)DataNode

+ );

+  ASSERT_EFI_ERROR (Status);

+

+exit_handler:

+  if (AmlNameString != NULL) {

+FreePool (AmlNameString);

+  }

+

+  return Status;

+}

-- 

2.25.1





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




[edk2-devel] [PATCH 4/4] DynamicTablesPkg: Add Aml NameUnicodeString API

2023-06-29 Thread Jeff Brasen via groups.io
Add API to generate a Name that contains a Unicode string buffer.



Change-Id: I0116b2921cbbbecc3420ff7a42a7ab6e01852534

Reviewed-by: Swatisri Kantamsetti 

Reviewed-by: Ashish Singhal 

---

 .../Include/Library/AmlLib/AmlLib.h   | 31 +++

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 86 +++

 2 files changed, 117 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index 043e7ee901..5150aa4870 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -958,6 +958,37 @@ AmlCodeGenNameResourceTemplate (

   OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

   );

 

+/** AML code generation for a Name object node, containing a String.

+

+  AmlCodeGenNameUnicodeString ("_STR", L"String", ParentNode, NewObjectNode) is

+  equivalent of the following ASL code:

+Name(_STR, Unicode ("String"))

+

+  @ingroup CodeGenApis

+

+  @param  [in] NameString The new variable name.

+  Must be a NULL-terminated ASL NameString

+  e.g.: "DEV0", "DV15.DEV0", etc.

+  The input string is copied.

+  @param [in]  String NULL terminated Unicode String to associate to 
the

+  NameString.

+  @param [in]  ParentNode If provided, set ParentNode as the parent

+  of the node created.

+  @param [out] NewObjectNode  If success, contains the created node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenNameUnicodeString (

+  IN  CONST CHAR8   *NameString,

+  INCHAR16  *String,

+  INAML_NODE_HANDLE ParentNode  OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

+  );

+

 /** Add a _PRT entry.

 

   AmlCodeGenPrtEntry (0x0, 0, "LNKA", 0, PrtNameNode) is

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index a0d01032d5..20ddad031d 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -869,6 +869,92 @@ AmlCodeGenNameResourceTemplate (

   return Status;

 }

 

+/** AML code generation for a Name object node, containing a String.

+

+ AmlCodeGenNameUnicodeString ("_STR", L"String", ParentNode, NewObjectNode) is

+ equivalent of the following ASL code:

+   Name(_STR, Unicode ("String"))

+

+ @ingroup CodeGenApis

+

+ @param  [in] NameString The new variable name.

+ Must be a NULL-terminated ASL NameString

+ e.g.: "DEV0", "DV15.DEV0", etc.

+ The input string is copied.

+ @param [in]  String NULL terminated Unicode String to associate to the

+ NameString.

+ @param [in]  ParentNode If provided, set ParentNode as the parent

+ of the node created.

+ @param [out] NewObjectNode  If success, contains the created node.

+

+ @retval EFI_SUCCESS Success.

+ @retval EFI_INVALID_PARAMETER   Invalid parameter.

+ @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenNameUnicodeString (

+  IN  CONST CHAR8   *NameString,

+  INCHAR16  *String,

+  INAML_NODE_HANDLE ParentNode  OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

+  )

+{

+  EFI_STATUS   Status;

+  AML_OBJECT_NODE  *ObjectNode;

+  AML_DATA_NODE*DataNode;

+

+  if ((NameString == NULL)  ||

+  (String == NULL)  ||

+  ((ParentNode == NULL) && (NewObjectNode == NULL)))

+  {

+ASSERT (0);

+return EFI_INVALID_PARAMETER;

+  }

+

+  Status = AmlCodeGenBuffer (NULL, 0, );

+  if (EFI_ERROR (Status)) {

+ASSERT_EFI_ERROR (Status);

+return Status;

+  }

+

+  Status = AmlCreateDataNode (

+ EAmlNodeDataTypeRaw,

+ (CONST UINT8 *)String,

+ StrSize (String),

+ 

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT_EFI_ERROR (Status);

+AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);

+return Status;

+  }

+

+  Status = AmlVarListAddTail (

+ (AML_NODE_HEADER *)ObjectNode,

+ (AML_NODE_HEADER *)DataNode

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT_EFI_ERROR (Status);

+AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);

+AmlDeleteTree ((AML_NODE_HANDLE)DataNode);

+return Status;

+  }

+

+  Status = AmlCodeGenName (

+ NameString,

+ 

[edk2-devel] [PATCH 2/4] DynamicTablesPkg: Add support for simple method invocation.

2023-06-29 Thread Jeff Brasen via groups.io
Add support to add Return objects via AML that pass a single integer

argument to the named method.



Signed-off-by: Jeff Brasen 

Reviewed-by: Swatisri Kantamsetti 

Reviewed-by: Ashish Singhal 

---

 .../Include/Library/AmlLib/AmlLib.h   |  54 +

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 224 ++

 2 files changed, 278 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index d201ae9499..b82c7a3ce8 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1194,6 +1194,60 @@ AmlCodeGenMethodRetInteger (

   OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNodeOPTIONAL

   );

 

+/** AML code generation for a method returning a NameString that takes an

+integer argument.

+

+  AmlCodeGenMethodRetNameStringIntegerArgument (

+"MET0", "MET1", 1, TRUE, 3, 5, ParentNode, NewObjectNode

+);

+  is equivalent of the following ASL code:

+Method(MET0, 1, Serialized, 3) {

+  Return (MET1 (5))

+}

+

+  The ASL parameters "ReturnType" and "ParameterTypes" are not asked

+  in this function. They are optional parameters in ASL.

+

+  @param [in]  MethodNameString The new Method's name.

+Must be a NULL-terminated ASL NameString

+e.g.: "MET0", "_SB.MET0", etc.

+The input string is copied.

+  @param [in]  ReturnedNameString   The name of the object returned by the

+method. Optional parameter, can be:

+ - NULL (ignored).

+ - A NULL-terminated ASL NameString.

+   e.g.: "MET0", "_SB.MET0", etc.

+   The input string is copied.

+  @param [in]  NumArgs  Number of arguments.

+Must be 0 <= NumArgs <= 6.

+  @param [in]  IsSerialized TRUE is equivalent to Serialized.

+FALSE is equivalent to NotSerialized.

+Default is NotSerialized in ASL spec.

+  @param [in]  SyncLevelSynchronization level for the method.

+Must be 0 <= SyncLevel <= 15.

+Default is 0 in ASL.

+  @param [in]  IntegerArgument  Argument to pass to the NameString.

+  @param [in]  ParentNode   If provided, set ParentNode as the parent

+of the node created.

+  @param [out] NewObjectNodeIf success, contains the created node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenMethodRetNameStringIntegerArgument (

+  IN  CONST CHAR8   *MethodNameString,

+  IN  CONST CHAR8   *ReturnedNameString   OPTIONAL,

+  INUINT8   NumArgs,

+  INBOOLEAN IsSerialized,

+  INUINT8   SyncLevel,

+  INUINT64  IntegerArgument,

+  INAML_NODE_HANDLE ParentNode   OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNodeOPTIONAL

+  );

+

 /** Create a _LPI name.

 

   AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, ) is

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index 88537b7e2d..2b95839e4c 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -1881,6 +1881,118 @@ AmlCodeGenReturnInteger (

   return Status;

 }

 

+/** AML code generation for a Return object node,

+returning the object as an input NameString with a integer argument.

+

+  AmlCodeGenReturn ("NAM1", 6, ParentNode, NewObjectNode) is

+  equivalent of the following ASL code:

+Return(NAM1 (6))

+

+  The ACPI 6.3 specification, s20.2.5.3 "Type 1 Opcodes Encoding" states:

+DefReturn := ReturnOp ArgObject

+ReturnOp := 0xA4

+ArgObject := TermArg => DataRefObject

+

+  Thus, the ReturnNode must be evaluated as a DataRefObject. It can

+  be a NameString referencing an object. As this CodeGen Api doesn't

+  do semantic checking, it is strongly advised to check the AML bytecode

+  generated by this function against an ASL compiler.

+

+  The ReturnNode must be generated inside a Method body scope.

+

+  @param [in]  NameString The object referenced by this NameString

+  is returned by the Return ASL statement.

+  Must be a NULL-terminated ASL NameString

+

[edk2-devel] [PATCH 0/4] Add support for generating ACPI ThermalZones

2023-06-29 Thread Jeff Brasen via groups.io
Add APIs needed to create thermal zones dynamically.
Does not add a generator for this as creating the TMP method generically may
be difficult.

Jeff Brasen (4):
  DynamicTablesPkg: Add ThermalZone CodeGen function
  DynamicTablesPkg: Add support for simple method invocation.
  DynamicTablesPkg: Add support to add Strings to package
  DynamicTablesPkg: Add Aml NameUnicodeString API

 .../Include/Library/AmlLib/AmlLib.h   | 130 +
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 508 ++
 2 files changed, 638 insertions(+)

-- 
2.25.1



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




[edk2-devel] [PATCH 1/4] DynamicTablesPkg: Add ThermalZone CodeGen function

2023-06-29 Thread Jeff Brasen via groups.io
Add API to generate a ThermalZone object to AmlLib.



Signed-off-by: Jeff Brasen 

Reviewed-by: Swatisri Kantamsetti 

Reviewed-by: Ashish Singhal 

---

 .../Include/Library/AmlLib/AmlLib.h   |  28 +

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 116 ++

 2 files changed, 144 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index 9210c50915..d201ae9499 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1038,6 +1038,34 @@ AmlCodeGenDevice (

   OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

   );

 

+/** AML code generation for a ThermalZone object node.

+

+  AmlCodeGenThermalZone ("TZ00", ParentNode, NewObjectNode) is

+  equivalent of the following ASL code:

+ThermalZone(TZ00) {}

+

+  @ingroup CodeGenApis

+

+  @param  [in] NameString The new ThermalZone's name.

+  Must be a NULL-terminated ASL NameString

+  e.g.: "DEV0", "DV15.DEV0", etc.

+  The input string is copied.

+  @param [in]  ParentNode If provided, set ParentNode as the parent

+  of the node created.

+  @param [out] NewObjectNode  If success, contains the created node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenThermalZone (

+  IN  CONST CHAR8   *NameString,

+  INAML_NODE_HANDLE ParentNode  OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

+  );

+

 /** AML code generation for a Scope object node.

 

   AmlCodeGenScope ("_SB", ParentNode, NewObjectNode) is

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index 0b223379fa..88537b7e2d 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -1218,6 +1218,122 @@ error_handler1:

   return Status;

 }

 

+/** AML code generation for a ThermalZone object node.

+

+  AmlCodeGenThermalZone ("TZ00", ParentNode, NewObjectNode) is

+  equivalent of the following ASL code:

+ThermalZone(TZ00) {}

+

+  @ingroup CodeGenApis

+

+  @param  [in] NameString The new ThermalZone's name.

+  Must be a NULL-terminated ASL NameString

+  e.g.: "DEV0", "DV15.DEV0", etc.

+  The input string is copied.

+  @param [in]  ParentNode If provided, set ParentNode as the parent

+  of the node created.

+  @param [out] NewObjectNode  If success, contains the created node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCodeGenThermalZone (

+  IN  CONST CHAR8   *NameString,

+  INAML_NODE_HANDLE ParentNode  OPTIONAL,

+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL

+  )

+{

+  EFI_STATUS   Status;

+  AML_OBJECT_NODE  *ObjectNode;

+  AML_DATA_NODE*DataNode;

+  CHAR8*AmlNameString;

+  UINT32   AmlNameStringSize;

+

+  if ((NameString == NULL)  ||

+  ((ParentNode == NULL) && (NewObjectNode == NULL)))

+  {

+ASSERT (0);

+return EFI_INVALID_PARAMETER;

+  }

+

+  ObjectNode= NULL;

+  DataNode  = NULL;

+  AmlNameString = NULL;

+

+  Status = ConvertAslNameToAmlName (NameString, );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+return Status;

+  }

+

+  Status = AmlGetNameStringSize (AmlNameString, );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto error_handler1;

+  }

+

+  Status = AmlCreateObjectNode (

+ AmlGetByteEncodingByOpCode (AML_EXT_OP, AML_EXT_THERMAL_ZONE_OP),

+ AmlNameStringSize + AmlComputePkgLengthWidth (AmlNameStringSize),

+ 

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto error_handler1;

+  }

+

+  Status = AmlCreateDataNode (

+ EAmlNodeDataTypeNameString,

+ (UINT8 *)AmlNameString,

+ AmlNameStringSize,

+ 

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto error_handler2;

+  }

+

+  Status = AmlSetFixedArgument (

+ ObjectNode,

+ EAmlParseIndexTerm0,

+ (AML_NODE_HEADER *)DataNode

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+AmlDeleteTree ((AML_NODE_HEADER *)DataNode);

+goto error_handler2;

+  }

+

+  Status = LinkNode (

+ ObjectNode,

+ 

[edk2-devel] [PATCH 0/2] dp command without ACPI

2023-06-29 Thread Jeff Brasen via groups.io
Systems that do not boot with ACPI (system that use device tree for example)
can not use the shell dp command. This patch adds this to the configuration
table so that dp command can get this without the FPDT table.

I am open to other ways for this to be passed if desired (Installed protocol, 
handler of the status code, etc) but wanted to post this to at least get 
thoughts
on this.

-Jeff

Jeff Brasen (2):
  MdeModulePkg/DxeCorePerformanceLib: Install BPDT in config table
  ShellPkg/Dp: Allow dp command to work without ACPI

 .../DxeCorePerformanceLib/DxeCorePerformanceLib.c |  2 ++
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 11 ---
 ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf|  1 +
 .../DpDynamicCommand/DpDynamicCommand.inf |  1 +
 4 files changed, 12 insertions(+), 3 deletions(-)

-- 
2.25.1



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




[edk2-devel] [PATCH 1/2] MdeModulePkg/DxeCorePerformanceLib: Install BPDT in config table

2023-06-29 Thread Jeff Brasen via groups.io
Install the performance table into the UEFI configuration table.
This will allow the shell application to get this if the system
is not using ACPI.

Signed-off-by: Jeff Brasen 
---
 .../Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c   | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c 
b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index ef14bc0738..e72b04794a 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -1403,6 +1403,8 @@ ReportFpdtRecordBuffer (
 ,
 sizeof (UINT64)
 );
+  Status = gBS->InstallConfigurationTable 
(, (VOID *)BPDTAddr);
+  ASSERT_EFI_ERROR (Status);
 }
 
 //
-- 
2.25.1



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




[edk2-devel] [PATCH 2/2] ShellPkg/Dp: Allow dp command to work without ACPI

2023-06-29 Thread Jeff Brasen via groups.io
If the system does not have ACPI setup use the configuration table

to get the performance info.



Signed-off-by: Jeff Brasen 

---

 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 11 ---

 ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf|  1 +

 .../DpDynamicCommand/DpDynamicCommand.inf |  1 +

 3 files changed, 10 insertions(+), 3 deletions(-)



diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c 
b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c

index 512a146da6..98c84d2ef9 100644

--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c

+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c

@@ -129,17 +129,22 @@ EFI_STATUS

 GetBootPerformanceTable (

   )

 {

+  EFI_STATUS  Status;

   FIRMWARE_PERFORMANCE_TABLE  *FirmwarePerformanceTable;

 

   FirmwarePerformanceTable = (FIRMWARE_PERFORMANCE_TABLE 
*)EfiLocateFirstAcpiTable (

  
EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE

  );

   if (FirmwarePerformanceTable == NULL) {

-ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_ACPI_FPDT_FAIL), 
mDpHiiHandle);

-return EFI_NOT_FOUND;

+Status = EfiGetSystemConfigurationTable 
(, (VOID **));

+if (EFI_ERROR (Status)) {

+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_ACPI_FPDT_FAIL), 
mDpHiiHandle);

+  return EFI_NOT_FOUND;

+}

+  } else {

+mBootPerformanceTable = (UINT8 
*)(UINTN)FirmwarePerformanceTable->BootPointerRecord.BootPerformanceTablePointer;

   }

 

-  mBootPerformanceTable = (UINT8 
*)(UINTN)FirmwarePerformanceTable->BootPointerRecord.BootPerformanceTablePointer;

   mBootPerformanceTableSize = ((BOOT_PERFORMANCE_TABLE 
*)mBootPerformanceTable)->Header.Length;

 

   return EFI_SUCCESS;

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf 
b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf

index 4a58286b8c..d9e1c23a1e 100644

--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf

+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf

@@ -54,6 +54,7 @@

 

 [Guids]

   gPerformanceProtocolGuid## CONSUMES ## 
SystemTable

+  gEdkiiFpdtExtendedFirmwarePerformanceGuid   ## CONSUMES ## 
SystemTable

 

 [Protocols]

   gEfiLoadedImageProtocolGuid ## CONSUMES

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf 
b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf

index 013bdbd4a0..2723fee706 100644

--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf

+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf

@@ -55,6 +55,7 @@

 

 [Guids]

   gPerformanceProtocolGuid## CONSUMES ## 
SystemTable

+  gEdkiiFpdtExtendedFirmwarePerformanceGuid   ## CONSUMES ## 
SystemTable

 

 [Protocols]

   gEfiLoadedImageProtocolGuid ## CONSUMES

-- 

2.25.1





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




[edk2-devel] [PATCH] MdeModulePkg/PciHostBridge: Add support for driver binding

2023-06-29 Thread Jeff Brasen via groups.io
If the platform does not support any PCIe devices using the library

method allow devices to connect to host bridge via driver binding.



Signed-off-by: Jeff Brasen 

---

 .../Bus/Pci/PciHostBridgeDxe/PciHostBridge.c  | 649 ++

 .../Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf |   1 +

 .../Bus/Pci/PciHostBridgeDxe/PciRootBridge.h  |  13 +

 .../Pci/PciHostBridgeDxe/PciRootBridgeIo.c|  24 +

 MdeModulePkg/MdeModulePkg.dec |   4 +

 5 files changed, 562 insertions(+), 129 deletions(-)



diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c 
b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c

index d573e532ba..506c6660ae 100644

--- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c

+++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c

@@ -422,167 +422,320 @@ IoMmuProtocolCallback (

 }

 

 /**

+  PCI Root Bridge Memory setup.

 

-  Entry point of this driver.

+  @param  RootBridgeRoot Bridge instance.

 

-  @param ImageHandle  Image handle of this driver.

-  @param SystemTable  Pointer to standard EFI system table.

-

-  @retval EFI_SUCCESS   Succeed.

-  @retval EFI_DEVICE_ERROR  Fail to install PCI_ROOT_BRIDGE_IO protocol.

+  @retval EFI_SUCCESS   Memory was setup correctly

+  @retval othersError in setup

 

 **/

 EFI_STATUS

 EFIAPI

-InitializePciHostBridge (

-  IN EFI_HANDLEImageHandle,

-  IN EFI_SYSTEM_TABLE  *SystemTable

+PciRootBridgeMemorySetup (

+  IN PCI_ROOT_BRIDGE  *RootBridge

   )

 {

   EFI_STATUSStatus;

-  PCI_HOST_BRIDGE_INSTANCE  *HostBridge;

-  PCI_ROOT_BRIDGE_INSTANCE  *RootBridge;

-  PCI_ROOT_BRIDGE   *RootBridges;

-  UINTN RootBridgeCount;

-  UINTN Index;

+  UINT64HostAddress;

   PCI_ROOT_BRIDGE_APERTURE  *MemApertures[4];

   UINTN MemApertureIndex;

-  BOOLEAN   ResourceAssigned;

-  LIST_ENTRY*Link;

-  UINT64HostAddress;

 

-  RootBridges = PciHostBridgeGetRootBridges ();

-  if ((RootBridges == NULL) || (RootBridgeCount == 0)) {

-return EFI_UNSUPPORTED;

-  }

-

-  Status = gBS->LocateProtocol (, NULL, (VOID 
**));

-  ASSERT_EFI_ERROR (Status);

-

-  //

-  // Most systems in the world including complex servers have only one Host 
Bridge.

-  //

-  HostBridge = AllocateZeroPool (sizeof (PCI_HOST_BRIDGE_INSTANCE));

-  ASSERT (HostBridge != NULL);

-

-  HostBridge->Signature= PCI_HOST_BRIDGE_SIGNATURE;

-  HostBridge->CanRestarted = TRUE;

-  InitializeListHead (>RootBridges);

-  ResourceAssigned = FALSE;

-

-  //

-  // Create Root Bridge Device Handle in this Host Bridge

-  //

-  for (Index = 0; Index < RootBridgeCount; Index++) {

+  if (RootBridge->Io.Base <= RootBridge->Io.Limit) {

 //

-// Create Root Bridge Handle Instance

+// Base and Limit in PCI_ROOT_BRIDGE_APERTURE are device address.

+// For GCD resource manipulation, we need to use host address.

 //

-RootBridge = CreateRootBridge ([Index]);

-ASSERT (RootBridge != NULL);

-if (RootBridge == NULL) {

-  continue;

+HostAddress = TO_HOST_ADDRESS (

+RootBridge->Io.Base,

+RootBridge->Io.Translation

+);

+

+Status = AddIoSpace (

+   HostAddress,

+   RootBridge->Io.Limit - RootBridge->Io.Base + 1

+   );

+ASSERT_EFI_ERROR (Status);

+if (EFI_ERROR (Status)) {

+  return Status;

 }

 

-//

-// Make sure all root bridges share the same ResourceAssigned value.

-//

-if (Index == 0) {

-  ResourceAssigned = RootBridges[Index].ResourceAssigned;

-} else {

-  ASSERT (ResourceAssigned == RootBridges[Index].ResourceAssigned);

+if (RootBridge->ResourceAssigned) {

+  Status = gDS->AllocateIoSpace (

+  EfiGcdAllocateAddress,

+  EfiGcdIoTypeIo,

+  0,

+  RootBridge->Io.Limit - RootBridge->Io.Base + 1,

+  ,

+  gImageHandle,

+  NULL

+  );

+  ASSERT_EFI_ERROR (Status);

+  if (EFI_ERROR (Status)) {

+return Status;

+  }

 }

+  }

+

+  //

+  // Add all the Mem/PMem aperture to GCD

+  // Mem/PMem shouldn't overlap with each other

+  // Root bridge which needs to combine MEM and PMEM should only report

+  // the MEM aperture in Mem

+  //

+  MemApertures[0] = >Mem;

+  MemApertures[1] = >MemAbove4G;

+  MemApertures[2] = >PMem;

+  MemApertures[3] = >PMemAbove4G;

 

-if (RootBridges[Index].Io.Base <= RootBridges[Index].Io.Limit) {

+  for (MemApertureIndex = 0; MemApertureIndex < ARRAY_SIZE (MemApertures); 
MemApertureIndex++) {

+if (MemApertures[MemApertureIndex]->Base <= 
MemApertures[MemApertureIndex]->Limit) {

   

[edk2-devel] [PATCH] ArmPkg/ArmPsciMpServices Add EFI_NOT_READY return

2023-06-29 Thread Jeff Brasen via groups.io
Add EFI_NOT_READY return if the CPU can not be enabled if the
processor is already on.

This can occur in normal use if the CPU is still being turned off from
a previous call when this is called again.

Signed-off-by: Jeff Brasen 
---
 ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.c 
b/ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.c
index f822a9877c..e7f4223513 100644
--- a/ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.c
+++ b/ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.c
@@ -103,7 +103,9 @@ DispatchCpu (
 
   ArmCallSmc ();
 
-  if (Args.Arg0 != ARM_SMC_PSCI_RET_SUCCESS) {
+  if (Args.Arg0 == ARM_SMC_PSCI_RET_ALREADY_ON) {
+Status = EFI_NOT_READY;
+  } else if (Args.Arg0 != ARM_SMC_PSCI_RET_SUCCESS) {
 DEBUG ((DEBUG_ERROR, "PSCI_CPU_ON call failed: %d\n", Args.Arg0));
 Status = EFI_DEVICE_ERROR;
   }
-- 
2.25.1


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




[edk2-devel] [PATCH] MdeModulePkg/DxeCore: Allow relocation of images with large address

2023-05-15 Thread Jeff Brasen via groups.io
Add PCD to control if modules with start addresses in PE/COFF > 0x10
attempt to load at specified address.
If a module has an address in this range and there is untested memory
DxeCore will attempt to promote all memory to tested which bypasses any
memory testing that would occur later in boot.

There are several existing AARCH64 option roms that have base addresses
of 0x18000.

Signed-off-by: Jeff Brasen 
Reviewed-by: Ashish Singhal 
---
 MdeModulePkg/Core/Dxe/DxeMain.inf   | 1 +
 MdeModulePkg/Core/Dxe/Image/Image.c | 4 +++-
 MdeModulePkg/MdeModulePkg.dec   | 7 +++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf 
b/MdeModulePkg/Core/Dxe/DxeMain.inf
index 35d5bf0dee..16871f2021 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.inf
+++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
@@ -187,6 +187,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask   ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard   ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdFwVolDxeMaxEncapsulationDepth   ## 
CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdImageLargeAddressLoad   ## 
CONSUMES
 
 # [Hob]
 # RESOURCE_DESCRIPTOR   ## CONSUMES
diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c 
b/MdeModulePkg/Core/Dxe/Image/Image.c
index 9dbfb2a1fa..6bc3a549ae 100644
--- a/MdeModulePkg/Core/Dxe/Image/Image.c
+++ b/MdeModulePkg/Core/Dxe/Image/Image.c
@@ -680,7 +680,9 @@ CoreLoadPeImage (
);
   }
 } else {
-  if ((Image->ImageContext.ImageAddress >= 0x10) || 
Image->ImageContext.RelocationsStripped) {
+  if ((PcdGetBool (PcdImageLargeAddressLoad) && 
((Image->ImageContext.ImageAddress) >= 0x10)) ||
+  Image->ImageContext.RelocationsStripped)
+  {
 Status = CoreAllocatePages (
AllocateAddress,
(EFI_MEMORY_TYPE)(Image->ImageContext.ImageCodeMemoryType),
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 95dd077e19..6fd1bd7b8f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1116,6 +1116,13 @@
   # @Prompt Output MMIO address of Trace Hub message.
   
gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugMmioAddress|0|UINT64|0x30001058
 
+  ## Indicates if images with large load address (>0x10) should attempted 
to load at specified location.
+  #  If enabled, attempt to allocate at specfied location will be attempted 
with a fall back to any address.
+  #   TRUE  - UEFI will attempt to load at specified location.
+  #   FALSE - UEFI will load at any address
+  # @Prompt Enable large address image loading.
+  
gEfiMdeModulePkgTokenSpaceGuid.PcdImageLargeAddressLoad|TRUE|BOOLEAN|0x30001059
+
 [PcdsFixedAtBuild, PcdsPatchableInModule]
   ## Dynamic type PCD can be registered callback function for Pcd setting 
action.
   #  PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of 
callback function
-- 
2.25.1



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




[edk2-devel] [PATCH] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Fix SetQueueAlignment.

2023-03-23 Thread Jeff Brasen via groups.io
Nothing to do here for virtio 1.0 devices

Signed-off-by: Jeff Brasen 
---
 .../Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c 
b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
index 8bdf1e1fc3..de2c5fa2a6 100644
--- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
@@ -144,7 +144,9 @@ VirtioMmioSetQueueAlignment (
 
   Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
 
-  VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_ALIGN, Alignment);
+  if (Device->Version == VIRTIO_MMIO_DEVICE_VERSION_0_95) {
+VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_ALIGN, Alignment);
+  }
 
   return EFI_SUCCESS;
 }
-- 
2.25.1



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




Re: [edk2-devel] [PATCH 1/1] DynamicTablesPkg/SsdtCpuTopology: Allow multi-packages topologies

2023-03-10 Thread Jeff Brasen via groups.io
Reviewed-by: Jeff Brasen 

> -Original Message-
> From: pierre.gond...@arm.com 
> Sent: Thursday, March 9, 2023 8:33 AM
> To: devel@edk2.groups.io
> Cc: Sami Mujawar ; Alexei Fedorov
> ; Jeff Brasen 
> Subject: [PATCH 1/1] DynamicTablesPkg/SsdtCpuTopology: Allow multi-
> packages topologies
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Pierre Gondois 
> 
> The topology of a platform is represented in ACPI using the PPTT table. It is
> possible to append information to CPUs/processor containers using their
> associated AML nodes in a SSDT table.
> A platform might have multiple 'physical packages' (or top-level
> nodes) in their PPTT topology representation. It can be assumed from [1]
> that a 'physical packages' is always a 'top-level node', and conversely.
> 
> The SSDT topology generator doesn't support having multiple top-level
> nodes. The top-level node is also not generated in the SSDT topology
> representation.
> Add support to generate multiple top-level nodes in the SSDT topology
> generator and generate an AML node for this top-level node. This will allow
> to have matching PPTT and SSDT topology representations. Prior to this
> patch, this top-level AML node was not generated.
> 
> Also factorize the flag checking in CheckProcNode() and add more checks.
> 
> This patch takes inspiration from the discussion at:
> - v1:
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk
> 2.groups.io%2Fg%2Fdevel%2Fmessage%2F99410=05%7C01%7Cjbrasen
> %40nvidia.com%7C0f68dac1cbf245e37eb608db20b39c00%7C43083d15727340
> c1b7db39efd9ccc17a%7C0%7C0%7C638139728016125186%7CUnknown%7CT
> WFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLC
> JXVCI6Mn0%3D%7C3000%7C%7C%7C=tqQD5RycnMUh%2BuqTG%2F
> %2BJW9fK7gw1KZwA%2BMNoi55IS%2BY%3D=0
> - v2:
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk
> 2.groups.io%2Fg%2Fdevel%2Fmessage%2F99615=05%7C01%7Cjbrasen
> %40nvidia.com%7C0f68dac1cbf245e37eb608db20b39c00%7C43083d15727340
> c1b7db39efd9ccc17a%7C0%7C0%7C638139728016125186%7CUnknown%7CT
> WFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLC
> JXVCI6Mn0%3D%7C3000%7C%7C%7C=dG6YaTCQSThzTG47yZPRU7lCZ
> ADzeFFmy6fDFKZInwI%3D=0
> 
> [1]
> ACPI 6.5, 5.2.30.1 Processor hierarchy node structure (Type 0):
> - "Multiple trees may be described, covering for example multiple
>   packages. For the root of a tree, the parent pointer should be 0.""
> - "Each valid processor must belong to exactly one package. That is,
>   the leaf must itself be a physical package or have an ancestor
>   marked as a physical package."
> 
> Change-Id: I48452e623906628f44b7e2c69a34ed7b30276e92
> Suggested-by: Jeff Brasen 
> Signed-off-by: Pierre Gondois 
> ---
>  .../SsdtCpuTopologyGenerator.c| 131 +++---
>  .../SsdtCpuTopologyGenerator.h|   4 +
>  2 files changed, 84 insertions(+), 51 deletions(-)
> 
> diff --git
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uTopologyGenerator.c
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uTopologyGenerator.c
> index c24da8ec71ad..6fb131b66482 100644
> ---
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uTopologyGenerator.c
> +++
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> +++ uTopologyGenerator.c
> @@ -805,6 +805,57 @@ CreateAmlProcessorContainer (
>return Status;
>  }
> 
> +/** Check flags and topology of a ProcNode.
> +
> +  @param [in]  NodeFlagsFlags of the ProcNode to check.
> +  @param [in]  IsLeaf   The ProcNode is a leaf.
> +  @param [in]  NodeTokenNodeToken of the ProcNode.
> +  @param [in]  ParentNodeToken  Parent NodeToken of the ProcNode.
> +
> +  @retval EFI_SUCCESS Success.
> +  @retval EFI_INVALID_PARAMETER   Invalid parameter.
> +**/
> +STATIC
> +EFI_STATUS
> +EFIAPI
> +CheckProcNode (
> +  UINT32   NodeFlags,
> +  BOOLEAN  IsLeaf,
> +  CM_OBJECT_TOKEN  NodeToken,
> +  CM_OBJECT_TOKEN  ParentNodeToken
> +  )
> +{
> +  BOOLEAN  InvalidFlags;
> +  BOOLEAN  HasPhysicalPackageBit;
> +  BOOLEAN  IsTopLevelNode;
> +
> +  HasPhysicalPackageBit = (NodeFlags &
> EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL) ==
> +  EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL;
> +  IsTopLevelNode = (ParentNodeToken == CM_NULL_TOKEN);
> +
> +  // A top-level node is a Physical Package and conversely.
> +  InvalidFlags = HasPhysicalPackageBit ^ IsTopLevelNode;
> +
> +  // Check Leaf specific flags.
> +  if (IsLeaf) {
> +InvalidFlags |= ((NodeFlags & PPTT_LEAF_MASK) != PPTT_LEAF_MASK);
> + } else {
> +InvalidFlags |= ((NodeFlags & PPTT_LEAF_MASK) != 0);  }
> +
> +  if (InvalidFlags) {
> +DEBUG ((
> +  DEBUG_ERROR,
> +  "ERROR: SSDT-CPU-TOPOLOGY: Invalid flags for ProcNode: 0x%p.\n",
> +  (VOID *)NodeToken
> +  ));
> +ASSERT (0);
> +return EFI_INVALID_PARAMETER;
> +  }
> +
> +  return 

Re: [edk2-devel] [PATCH v2] DynamicTablesPkg: Allow multiple top level physical nodes

2023-02-13 Thread Jeff Brasen via groups.io
The changes on your branch seem pretty good to me

> -Original Message-
> From: Pierre Gondois 
> Sent: Monday, February 6, 2023 2:28 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com;
> quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> Subject: Re: [PATCH v2] DynamicTablesPkg: Allow multiple top level physical
> nodes
> 
> External email: Use caution opening links or attachments
> 
> 
> Hello Jeff,
> Thanks for the v2. Also cf the first discussion at:
> 
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk
> 2.groups.io%2Fg%2Fdevel%2Ftopic%2F96680589%2399612=05%7C01%
> 7Cjbrasen%40nvidia.com%7Ccee1a4886a754ba2d28508db08246448%7C43083
> d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638112724625353615%7CUnkn
> own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik
> 1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=ur6vlVCBpt%2BQdid
> 3xJKglx3trDZb4kxajkAWFXsr920%3D=0
> - I think it would be good to extract a function that does all the checks as
> there are many possibilities for the flags/parent combinations.
> - I think it would also be nice to reset the index of ProcContainers for each
> new level (i.e. not to have the same incrementing index for
> clusters/packages)
> 
> I created a branch based on your work at:
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> ub.com%2Fpierregondois%2Fedk2%2Ftree%2Fpg%2Ftop_level_pnode_Wip
> =05%7C01%7Cjbrasen%40nvidia.com%7Ccee1a4886a754ba2d28508db0
> 8246448%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C63811272462
> 5353615%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV
> 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=Ydj
> RbbboKTyVmi2rr2bvu0ARx9uey5mLYtWikbkP7Ek%3D=0
> 
> Regards,
> Pierre
> 
> On 2/3/23 19:10, Jeff Brasen wrote:
> > In SSDT CPU topology generator allow for multiple top level physical
> > nodes as would be seen with a multi-socket system. This will create a
> > top level processor container for all systems.
> >
> > Signed-off-by: Jeff Brasen 
> > ---
> >   .../SsdtCpuTopologyGenerator.c| 43 ++-
> >   1 file changed, 12 insertions(+), 31 deletions(-)
> >
> > diff --git
> >
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uT
> > opologyGenerator.c
> >
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uT
> > opologyGenerator.c
> > index c24da8ec71..46b757e0b2 100644
> > ---
> >
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uT
> > opologyGenerator.c
> > +++
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/Ssdt
> > +++ CpuTopologyGenerator.c
> > @@ -814,7 +814,8 @@ CreateAmlProcessorContainer (
> > Protocol Interface.
> > @param [in] NodeToken   Token of the
> CM_ARM_PROC_HIERARCHY_INFO
> > currently handled.
> > -  Cannot be CM_NULL_TOKEN.
> > +  CM_NULL_TOKEN if top level container
> > +  should be created.
> > @param [in] ParentNode  Parent node to attach the created
> > node to.
> > @param [in,out] ProcContainerIndex  Pointer to the current
> > processor container @@ -841,12 +842,12 @@ CreateAmlCpuTopologyTree
> (
> > AML_OBJECT_NODE_HANDLE  ProcContainerNode;
> > UINT32  Uid;
> > UINT16  Name;
> > +  UINT32  NodeFlags;
> >
> > ASSERT (Generator != NULL);
> > ASSERT (Generator->ProcNodeList != NULL);
> > ASSERT (Generator->ProcNodeCount != 0);
> > ASSERT (CfgMgrProtocol != NULL);
> > -  ASSERT (NodeToken != CM_NULL_TOKEN);
> > ASSERT (ParentNode != NULL);
> > ASSERT (ProcContainerIndex != NULL);
> >
> > @@ -893,8 +894,14 @@ CreateAmlCpuTopologyTree (
> > } else {
> >   // If this is not a Cpu, then this is a processor container.
> >
> > +NodeFlags = Generator->ProcNodeList[Index].Flags;
> > +// Allow physical property for top level nodes
> > +if (NodeToken == CM_NULL_TOKEN) {
> > +  NodeFlags &= ~EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL;
> > +}
> > +
> 
> I think that if (NodeToken == CM_NULL_TOKEN) and doesn't have the
> Physical Package flag, no error will be triggered even though this is not a 
> valid
> configuration.
> 
> >   // Acpi processor Id for clusters is not handled.
> > -if ((Generator->ProcNodeList[Index].Flags &
> PPTT_PROCESSOR_MASK) !=
> > +if ((NodeFlags & PPTT_PROCESSOR_MASK) !=
> >   PPTT_CLUSTER_PROCESSOR_MASK)
> >   {
> > DEBUG ((
> > @@ -974,8 +981,6 @@ CreateTopologyFromProcHierarchy (
> > )
> >   {
> > EFI_STATUS  Status;
> > -  UINT32  Index;
> > -  UINT32  TopLevelProcNodeIndex;
> > UINT32  ProcContainerIndex;
> >
> > ASSERT 

Re: [edk2-devel] [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support multiple devices with 0 HardwareInstance

2023-02-10 Thread Jeff Brasen via groups.io
This is unclear in my opinion. The spec does have
This number must be unique within the namespace of the ImageTypeId GUID and 
ImageIndex. And
For implementations that will never have more than one instance a zero can be 
used.

But it also states the parameter is optional and states that zero can be used 
when if it is not able to determine a unique hardware instance number or a 
hardware instance number is not needed.

I could see reasonable arguments on both sides.

-Jeff

> -Original Message-
> From: Kinney, Michael D 
> Sent: Friday, February 10, 2023 2:17 PM
> To: devel@edk2.groups.io; Jeff Brasen ; Demeter,
> Miki 
> Cc: Kinney, Michael D 
> Subject: RE: [edk2-devel] [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support
> multiple devices with 0 HardwareInstance
> 
> External email: Use caution opening links or attachments
> 
> 
> Based on UEFI Spec, would you consider those option roms to be non-
> conformant?
> 
> Mike
> 
> > -Original Message-----
> > From: devel@edk2.groups.io  On Behalf Of Jeff
> > Brasen via groups.io
> > Sent: Friday, February 10, 2023 12:43 PM
> > To: Kinney, Michael D ;
> > devel@edk2.groups.io; Demeter, Miki 
> > Subject: Re: [edk2-devel] [PATCH v2] MdeModulePkg/EsrtFmpDxe:
> Support
> > multiple devices with 0 HardwareInstance
> >
> > It was not as we were seeing devices expose FMP via an option rom
> > driver with Version == 3 and HardwareInstance = 0. If there are multiple of
> these device it would hit the error in the EsrtCode. The patch included does
> resolve the issues we were seeing.
> >
> > -Jeff
> >
> >
> > > -Original Message-
> > > From: Kinney, Michael D 
> > > Sent: Friday, February 10, 2023 12:48 PM
> > > To: devel@edk2.groups.io; Jeff Brasen ; Demeter,
> > > Miki 
> > > Cc: Kinney, Michael D 
> > > Subject: RE: [edk2-devel] [PATCH v2] MdeModulePkg/EsrtFmpDxe:
> > > Support multiple devices with 0 HardwareInstance
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > Did your original approach work for all your use cases?
> > >
> > > Mike
> > >
> > > > -Original Message-
> > > > From: devel@edk2.groups.io  On Behalf Of
> > > > Jeff Brasen via groups.io
> > > > Sent: Friday, February 10, 2023 8:45 AM
> > > > To: Kinney, Michael D ;
> > > > devel@edk2.groups.io; Demeter, Miki 
> > > > Subject: Re: [edk2-devel] [PATCH v2] MdeModulePkg/EsrtFmpDxe:
> > > Support
> > > > multiple devices with 0 HardwareInstance
> > > >
> > > > That was my original approach when I saw this but I was seeing
> > > > this occur on a device with FmpVersion == 3. The UEFI spec isn't
> > > > completely
> > > clear but could be read that 0 is legal if this part isn't being used.
> > > >
> > > >
> > >
> https://uefi.org/specs/UEFI/2.10/23_Firmware_Update_and_Reporting.ht
> > > m
> > > l
> > > > #efi-firmware-management-protocol-getimageinfo
> > > >
> > > > It does state that this is Optional, and has a statement "A zero
> > > > means the FMP provider is not able to determine a unique hardware
> > > > instance
> > > number or a hardware instance number is not needed."
> > > >
> > > > Also, our ESRT implementation just merges all instances to one
> > > > anyways so it doesn't currently consume the hardware instance
> > > > except for this
> > > check.
> > > >
> > > > Thanks,
> > > > Jeff
> > > >
> > > > > -Original Message-
> > > > > From: Kinney, Michael D 
> > > > > Sent: Thursday, February 9, 2023 8:43 PM
> > > > > To: devel@edk2.groups.io; Jeff Brasen ;
> > > > > Demeter, Miki 
> > > > > Cc: Kinney, Michael D 
> > > > > Subject: RE: [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support
> > > > > multiple devices with 0 HardwareInstance
> > > > >
> > > > > External email: Use caution opening links or attachments
> > > > >
> > > > >
> > > > > Hi Jeff,
> > > > >
> > > > > Thank you for the reminder.
> > > > >
> > > > > I am wondering if the check should be for FmpVersion < 3 and not
> > > > > FmpHardwareInstance != 0.
> > > > >
> > > > > It is possible for an 

Re: [edk2-devel] [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support multiple devices with 0 HardwareInstance

2023-02-10 Thread Jeff Brasen via groups.io
It was not as we were seeing devices expose FMP via an option rom driver with 
Version == 3 and HardwareInstance = 0. If there are multiple of these device it 
would hit the error in the EsrtCode. The patch included does resolve the issues 
we were seeing.

-Jeff


> -Original Message-
> From: Kinney, Michael D 
> Sent: Friday, February 10, 2023 12:48 PM
> To: devel@edk2.groups.io; Jeff Brasen ; Demeter,
> Miki 
> Cc: Kinney, Michael D 
> Subject: RE: [edk2-devel] [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support
> multiple devices with 0 HardwareInstance
> 
> External email: Use caution opening links or attachments
> 
> 
> Did your original approach work for all your use cases?
> 
> Mike
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Jeff
> > Brasen via groups.io
> > Sent: Friday, February 10, 2023 8:45 AM
> > To: Kinney, Michael D ;
> > devel@edk2.groups.io; Demeter, Miki 
> > Subject: Re: [edk2-devel] [PATCH v2] MdeModulePkg/EsrtFmpDxe:
> Support
> > multiple devices with 0 HardwareInstance
> >
> > That was my original approach when I saw this but I was seeing this
> > occur on a device with FmpVersion == 3. The UEFI spec isn't completely
> clear but could be read that 0 is legal if this part isn't being used.
> >
> >
> https://uefi.org/specs/UEFI/2.10/23_Firmware_Update_and_Reporting.htm
> l
> > #efi-firmware-management-protocol-getimageinfo
> >
> > It does state that this is Optional, and has a statement "A zero means
> > the FMP provider is not able to determine a unique hardware instance
> number or a hardware instance number is not needed."
> >
> > Also, our ESRT implementation just merges all instances to one anyways
> > so it doesn't currently consume the hardware instance except for this
> check.
> >
> > Thanks,
> > Jeff
> >
> > > -Original Message-
> > > From: Kinney, Michael D 
> > > Sent: Thursday, February 9, 2023 8:43 PM
> > > To: devel@edk2.groups.io; Jeff Brasen ; Demeter,
> > > Miki 
> > > Cc: Kinney, Michael D 
> > > Subject: RE: [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support multiple
> > > devices with 0 HardwareInstance
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > Hi Jeff,
> > >
> > > Thank you for the reminder.
> > >
> > > I am wondering if the check should be for FmpVersion < 3 and not
> > > FmpHardwareInstance != 0.
> > >
> > > It is possible for an FmpInfoBuffer to have an FmpVersion >= 3 and a
> > > HardwareInstance of 0.  If more than one of these it found, then
> > > that would be an EFI_UNSUPPORTED condition.
> > >
> > > If FmpVersion >= 3, then the HardwareInstance must be filled in with
> > > a unique value.  0 can be used if there is at most 1 instance, so
> > > the duplicate check would never be triggered.  If FmpVersion >= 3
> > > and there can be more then one instance, then the HardwareInstance
> > > must be a non-zero unique value.
> > >
> > > Thanks,
> > >
> > > Mike
> > >
> > > > -Original Message-
> > > > From: devel@edk2.groups.io  On Behalf Of
> > > > Jeff Brasen via groups.io
> > > > Sent: Thursday, February 9, 2023 2:03 PM
> > > > To: Demeter, Miki 
> > > > Cc: devel@edk2.groups.io
> > > > Subject: [edk2-devel] FW: [PATCH v2] MdeModulePkg/EsrtFmpDxe:
> > > Support
> > > > multiple devices with 0 HardwareInstance
> > > >
> > > > Here is a patch that has been pending for a bit
> > > >
> > > > Thanks,
> > > > Jeff
> > > >
> > > > -Original Message-
> > > > From: Jeff Brasen
> > > > Sent: Wednesday, February 1, 2023 9:21 AM
> > > > To: devel@edk2.groups.io
> > > > Cc: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> > > > guomin.ji...@intel.com
> > > > Subject: RE: [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support multiple
> > > > devices with 0 HardwareInstance
> > > >
> > > > Any updates on this would be great to get this in for the next
> > > > stable release
> > > if possible.
> > > >
> > > > > -Original Message-
> > > > > From: Jeff Brasen 
> > > > > Sent: Monday, December 12, 2022 12:27 PM
> > > > > To: devel@edk2.groups.io
> > > > > Cc:

Re: [edk2-devel] [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support multiple devices with 0 HardwareInstance

2023-02-10 Thread Jeff Brasen via groups.io
That was my original approach when I saw this but I was seeing this occur on a 
device with FmpVersion == 3. The UEFI spec isn't completely clear but could be 
read that 0 is legal if this part isn't being used.

https://uefi.org/specs/UEFI/2.10/23_Firmware_Update_and_Reporting.html#efi-firmware-management-protocol-getimageinfo

It does state that this is Optional, and has a statement "A zero means the FMP 
provider is not able to determine a unique hardware instance number or a 
hardware instance number is not needed."

Also, our ESRT implementation just merges all instances to one anyways so it 
doesn't currently consume the hardware instance except for this check.

Thanks,
Jeff

> -Original Message-
> From: Kinney, Michael D 
> Sent: Thursday, February 9, 2023 8:43 PM
> To: devel@edk2.groups.io; Jeff Brasen ; Demeter,
> Miki 
> Cc: Kinney, Michael D 
> Subject: RE: [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support multiple
> devices with 0 HardwareInstance
> 
> External email: Use caution opening links or attachments
> 
> 
> Hi Jeff,
> 
> Thank you for the reminder.
> 
> I am wondering if the check should be for FmpVersion < 3 and not
> FmpHardwareInstance != 0.
> 
> It is possible for an FmpInfoBuffer to have an FmpVersion >= 3 and a
> HardwareInstance of 0.  If more than one of these it found, then that would
> be an EFI_UNSUPPORTED condition.
> 
> If FmpVersion >= 3, then the HardwareInstance must be filled in with a
> unique value.  0 can be used if there is at most 1 instance, so the duplicate
> check would never be triggered.  If FmpVersion >= 3 and there can be more
> then one instance, then the HardwareInstance must be a non-zero unique
> value.
> 
> Thanks,
> 
> Mike
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Jeff
> > Brasen via groups.io
> > Sent: Thursday, February 9, 2023 2:03 PM
> > To: Demeter, Miki 
> > Cc: devel@edk2.groups.io
> > Subject: [edk2-devel] FW: [PATCH v2] MdeModulePkg/EsrtFmpDxe:
> Support
> > multiple devices with 0 HardwareInstance
> >
> > Here is a patch that has been pending for a bit
> >
> > Thanks,
> > Jeff
> >
> > -Original Message-
> > From: Jeff Brasen
> > Sent: Wednesday, February 1, 2023 9:21 AM
> > To: devel@edk2.groups.io
> > Cc: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> > guomin.ji...@intel.com
> > Subject: RE: [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support multiple
> > devices with 0 HardwareInstance
> >
> > Any updates on this would be great to get this in for the next stable 
> > release
> if possible.
> >
> > > -Original Message-
> > > From: Jeff Brasen 
> > > Sent: Monday, December 12, 2022 12:27 PM
> > > To: devel@edk2.groups.io
> > > Cc: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> > > guomin.ji...@intel.com; Jeff Brasen 
> > > Subject: [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support multiple
> > > devices with 0 HardwareInstance
> > >
> > > Skip error check if HardwareInstance is 0 as this either means that
> > > FmpVersion < 3 and not supported or, "A zero means the FMP provider
> > > is not able to determine a unique hardware instance number or a
> > > hardware instance number is not needed." per UEFI specification.
> > >
> > > As the FmpInstances are merged and HardwareInstance is not used
> > > remove error check in this case.
> > >
> > >
> > > Signed-off-by: Jeff Brasen 
> > > ---
> > >  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c | 22 --
> 
> > > ---
> > >  1 file changed, 13 insertions(+), 9 deletions(-)
> > >
> > > diff --git a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
> > > b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
> > > index 4f47c55cce..5bc627461d 100644
> > > --- a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
> > > +++ b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
> > > @@ -153,16 +153,20 @@ CreateEsrtEntry (
> > >
> > >//
> > >// Check to see of FmpImageInfoBuf GUID/HardwareInstance is
> > > unique
> > > +  // Skip if HardwareInstance is 0 as this is the case if
> > > + FmpVersion <
> > > + 3  // or the device can not create a unique ID per UEFI
> > > + specification
> > >//
> > > -  for (Index = 0; Index < *NumberOfDescriptors; Index++) {
> > > -if (CompareGuid ([Index].ImageTypeGuid,
> > > >ImageTypeId)) {
> > > -  if (HardwareInstances[Index].Hardw

[edk2-devel] FW: [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support multiple devices with 0 HardwareInstance

2023-02-09 Thread Jeff Brasen via groups.io
Here is a patch that has been pending for a bit

Thanks,
Jeff

-Original Message-
From: Jeff Brasen 
Sent: Wednesday, February 1, 2023 9:21 AM
To: devel@edk2.groups.io
Cc: jian.j.w...@intel.com; gaolim...@byosoft.com.cn; guomin.ji...@intel.com
Subject: RE: [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support multiple devices with 
0 HardwareInstance

Any updates on this would be great to get this in for the next stable release 
if possible.

> -Original Message-
> From: Jeff Brasen 
> Sent: Monday, December 12, 2022 12:27 PM
> To: devel@edk2.groups.io
> Cc: jian.j.w...@intel.com; gaolim...@byosoft.com.cn; 
> guomin.ji...@intel.com; Jeff Brasen 
> Subject: [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support multiple devices 
> with 0 HardwareInstance
> 
> Skip error check if HardwareInstance is 0 as this either means that 
> FmpVersion < 3 and not supported or, "A zero means the FMP provider is 
> not able to determine a unique hardware instance number or a hardware 
> instance number is not needed." per UEFI specification.
> 
> As the FmpInstances are merged and HardwareInstance is not used remove 
> error check in this case.
> 
> 
> Signed-off-by: Jeff Brasen 
> ---
>  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c | 22 --
> ---
>  1 file changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
> b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
> index 4f47c55cce..5bc627461d 100644
> --- a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
> +++ b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
> @@ -153,16 +153,20 @@ CreateEsrtEntry (
> 
>//
>// Check to see of FmpImageInfoBuf GUID/HardwareInstance is unique
> +  // Skip if HardwareInstance is 0 as this is the case if FmpVersion 
> + <
> + 3  // or the device can not create a unique ID per UEFI 
> + specification
>//
> -  for (Index = 0; Index < *NumberOfDescriptors; Index++) {
> -if (CompareGuid ([Index].ImageTypeGuid,
> >ImageTypeId)) {
> -  if (HardwareInstances[Index].HardwareInstance ==
> FmpHardwareInstance) {
> -DEBUG ((DEBUG_ERROR, "EsrtFmpDxe: Duplicate firmware image
> descriptor with GUID %g HardwareInstance:0x%x\n", 
> >ImageTypeId, FmpHardwareInstance));
> -ASSERT (
> -  !CompareGuid ([Index].ImageTypeGuid,
> >ImageTypeId) ||
> -  HardwareInstances[Index].HardwareInstance !=
> FmpHardwareInstance
> -  );
> -return EFI_UNSUPPORTED;
> +  if (FmpHardwareInstance != 0) {
> +for (Index = 0; Index < *NumberOfDescriptors; Index++) {
> +  if (CompareGuid ([Index].ImageTypeGuid,
> >ImageTypeId)) {
> +if (HardwareInstances[Index].HardwareInstance ==
> FmpHardwareInstance) {
> +  DEBUG ((DEBUG_ERROR, "EsrtFmpDxe: Duplicate firmware image
> descriptor with GUID %g HardwareInstance:0x%x\n", 
> >ImageTypeId, FmpHardwareInstance));
> +  ASSERT (
> +!CompareGuid ([Index].ImageTypeGuid,
> >ImageTypeId) ||
> +HardwareInstances[Index].HardwareInstance !=
> FmpHardwareInstance
> +);
> +  return EFI_UNSUPPORTED;
> +}
>}
>  }
>}
> --
> 2.25.1



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




[edk2-devel] [PATCH v2] DynamicTablesPkg: Allow multiple top level physical nodes

2023-02-03 Thread Jeff Brasen via groups.io
In SSDT CPU topology generator allow for multiple top level physical

nodes as would be seen with a multi-socket system. This will create a

top level processor container for all systems.



Signed-off-by: Jeff Brasen 

---

 .../SsdtCpuTopologyGenerator.c| 43 ++-

 1 file changed, 12 insertions(+), 31 deletions(-)



diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

index c24da8ec71..46b757e0b2 100644

--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

@@ -814,7 +814,8 @@ CreateAmlProcessorContainer (

   Protocol Interface.

   @param [in] NodeToken   Token of the CM_ARM_PROC_HIERARCHY_INFO

   currently handled.

-  Cannot be CM_NULL_TOKEN.

+  CM_NULL_TOKEN if top level container

+  should be created.

   @param [in] ParentNode  Parent node to attach the created

   node to.

   @param [in,out] ProcContainerIndex  Pointer to the current processor 
container

@@ -841,12 +842,12 @@ CreateAmlCpuTopologyTree (

   AML_OBJECT_NODE_HANDLE  ProcContainerNode;

   UINT32  Uid;

   UINT16  Name;

+  UINT32  NodeFlags;

 

   ASSERT (Generator != NULL);

   ASSERT (Generator->ProcNodeList != NULL);

   ASSERT (Generator->ProcNodeCount != 0);

   ASSERT (CfgMgrProtocol != NULL);

-  ASSERT (NodeToken != CM_NULL_TOKEN);

   ASSERT (ParentNode != NULL);

   ASSERT (ProcContainerIndex != NULL);

 

@@ -893,8 +894,14 @@ CreateAmlCpuTopologyTree (

   } else {

 // If this is not a Cpu, then this is a processor container.

 

+NodeFlags = Generator->ProcNodeList[Index].Flags;

+// Allow physical property for top level nodes

+if (NodeToken == CM_NULL_TOKEN) {

+  NodeFlags &= ~EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL;

+}

+

 // Acpi processor Id for clusters is not handled.

-if ((Generator->ProcNodeList[Index].Flags & PPTT_PROCESSOR_MASK) !=

+if ((NodeFlags & PPTT_PROCESSOR_MASK) !=

 PPTT_CLUSTER_PROCESSOR_MASK)

 {

   DEBUG ((

@@ -974,8 +981,6 @@ CreateTopologyFromProcHierarchy (

   )

 {

   EFI_STATUS  Status;

-  UINT32  Index;

-  UINT32  TopLevelProcNodeIndex;

   UINT32  ProcContainerIndex;

 

   ASSERT (Generator != NULL);

@@ -984,8 +989,7 @@ CreateTopologyFromProcHierarchy (

   ASSERT (CfgMgrProtocol != NULL);

   ASSERT (ScopeNode != NULL);

 

-  TopLevelProcNodeIndex = MAX_UINT32;

-  ProcContainerIndex= 0;

+  ProcContainerIndex = 0;

 

   Status = TokenTableInitialize (Generator, Generator->ProcNodeCount);

   if (EFI_ERROR (Status)) {

@@ -993,33 +997,10 @@ CreateTopologyFromProcHierarchy (

 return Status;

   }

 

-  // It is assumed that there is one unique CM_ARM_PROC_HIERARCHY_INFO

-  // structure with no ParentToken and the EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL

-  // flag set. All other CM_ARM_PROC_HIERARCHY_INFO are non-physical and

-  // have a ParentToken.

-  for (Index = 0; Index < Generator->ProcNodeCount; Index++) {

-if ((Generator->ProcNodeList[Index].ParentToken == CM_NULL_TOKEN) &&

-(Generator->ProcNodeList[Index].Flags &

- EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL))

-{

-  if (TopLevelProcNodeIndex != MAX_UINT32) {

-DEBUG ((

-  DEBUG_ERROR,

-  "ERROR: SSDT-CPU-TOPOLOGY: Top level CM_ARM_PROC_HIERARCHY_INFO "

-  "must be unique\n"

-  ));

-ASSERT (0);

-goto exit_handler;

-  }

-

-  TopLevelProcNodeIndex = Index;

-}

-  } // for

-

   Status = CreateAmlCpuTopologyTree (

  Generator,

  CfgMgrProtocol,

- Generator->ProcNodeList[TopLevelProcNodeIndex].Token,

+ CM_NULL_TOKEN,

  ScopeNode,

  

  );

-- 

2.25.1





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




Re: [edk2-devel] [PATCH] DynamicTablesPkg: Allow multiple top level physical nodes

2023-02-03 Thread Jeff Brasen via groups.io
To solve that problem I had added support for allowing the UID/Name to come 
from the node

https://github.com/tianocore/edk2/commit/5fb3f5723a1ea9d9a93e317181e1c11468a9eb45

> -Original Message-
> From: Pierre Gondois 
> Sent: Friday, February 3, 2023 9:28 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com;
> quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> Subject: Re: [PATCH] DynamicTablesPkg: Allow multiple top level physical nodes
> 
> External email: Use caution opening links or attachments
> 
> 
> On 2/3/23 17:00, Jeff Brasen wrote:
> > I'll on an updated patch this morning that only does the new behavior. We
> can't reset the procindex as it is used for the _UID as well and we would end 
> up
> with the same value in two nodes.
> 
> Yes indeed, then maybe the name/uid selection should not be done in
> CreateAmlCpuTopologyTree() but in
> CreateAmlProcessorContainer()/CreateAmlCpuFromProcHierarchy().
> This would allow to have a static counter for the Uid in
> CreateAmlProcessorContainer() and always have incrementing names for
> packages/cluster. Otherwise the generated name will be:
> C000<- Package
> \-C0001 <- Cluster
>\-C   <- CPU
> C002<- second Package
> \-C0003 <- second Cluster
>\-C0001   <- second CPU
> 
> instead of:
> C000<- Package
> \-C0001 <- Cluster
>\-C   <- CPU
> C001<- second Package
> \-C <- second Cluster
>\-C0001   <- second CPU
> 
> Regards,
> Pierre
> 
> >
> > -Jeff
> >
> >
> >> -Original Message-
> >> From: Pierre Gondois 
> >> Sent: Friday, February 3, 2023 6:11 AM
> >> To: Jeff Brasen ; devel@edk2.groups.io
> >> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com;
> >> quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> >> Subject: Re: [PATCH] DynamicTablesPkg: Allow multiple top level
> >> physical nodes
> >>
> >> External email: Use caution opening links or attachments
> >>
> >>
> >> On 2/2/23 18:53, Jeff Brasen wrote:
> >>> There are some cases (for example the _PSL list in thermal zones)
> >>> where we need to have a reference to the node and we have been doing
> >>> that via an Extern and a reference to the node path. I am push a
> >>> patch where the effectively the PCD I added was fixed true but was
> >>> unsure if that would have unexpected issues with other vendors
> >>> platforms
> >>
> >> The current SsdtCpuTopologyGenerator doesn't generate an AML node for
> >> the top level package. Even though this seem compliant to the ACPI
> >> spec, this induces a difference between the ASL topology description
> >> and the PPTT topology description. For instance, for the Juno, the
> >> topology generated for the ACPI tables are:
> >> PPTT:
> >> (PACKAGE)
> >> \-Little Cluster
> >> \-CPU[0,3-5]
> >> \-Big Cluster
> >> \-CPU[1-2]
> >>
> >> SSDT:
> >> Little Cluster
> >> \-CPU[0,3-5]
> >> Big Cluster
> >> \-CPU[1-2]
> >>
> >> To solve your issue, to have matching topology descriptions, and
> >> after discussing with Sami, it would be better to have:
> >> SSDT:
> >> (PACKAGE)
> >> \-Little Cluster
> >> \-CPU[0,3-5]
> >> \-Big Cluster
> >> \-CPU[1-2]
> >>
> >> The Juno is the only platform that publicly uses the
> >> SsdtCpuTopologyGenerator, so I am not sure how other platforms support
> should be handled.
> >>
> >> About the code itself, I think the ProcContainerIndex should also be
> >> reset in
> >> CreateAmlCpuTopologyTree() when generating a new level of containers
> >> (if it is decided to go this way).
> >>
> >> Regards,
> >> Pierre
> >>
> >>>
> >>> -Jeff
> >>>
>  -Original Message-
>  From: Pierre Gondois 
>  Sent: Thursday, February 2, 2023 10:49 AM
>  To: Jeff Brasen ; devel@edk2.groups.io
>  Cc: sami.muja...@arm.com; alexei.fedo...@arm.com;
>  quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
>  Subject: Re: [PATCH] DynamicTablesPkg: Allow multiple top level
>  physical nodes
> 
>  External email: Use caution opening links or attachments
> 
> 
>  Hello Jeff,
>  I was assuming that no other module would rely on the AML path to
>  access an AML node and that nodes should be retrieved through their
>  characteristics instead, i.e. internal properties/Name/Uid.
>  There are currently no public API allowing to do so, but there are
>  internal APIs that could be relied on to create them.
> 
>  I'm not sure what Sami is thinking,
> 
>  Regards,
>  Pierre
> 
>  On 2/2/23 17:48, Jeff Brasen wrote:
> > Just to clarify you are suggesting that all CPU nodes generated
> > via this with have an outer processor container? I am fine with
> > that but was concerned with a change in behavior to other
> > platforms in case they are expecting the CPUs to just be under
> > \SB.C00x instead of \SB.C000.C00x
> >
> > -Jeff
> >
> >
> >> -Original Message-
> >> From: Pierre 

Re: [edk2-devel] [PATCH] DynamicTablesPkg: Allow multiple top level physical nodes

2023-02-03 Thread Jeff Brasen via groups.io
I'll on an updated patch this morning that only does the new behavior. We can't 
reset the procindex as it is used for the _UID as well and we would end up with 
the same value in two nodes.

-Jeff


> -Original Message-
> From: Pierre Gondois 
> Sent: Friday, February 3, 2023 6:11 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com;
> quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> Subject: Re: [PATCH] DynamicTablesPkg: Allow multiple top level physical nodes
> 
> External email: Use caution opening links or attachments
> 
> 
> On 2/2/23 18:53, Jeff Brasen wrote:
> > There are some cases (for example the _PSL list in thermal zones)
> > where we need to have a reference to the node and we have been doing
> > that via an Extern and a reference to the node path. I am push a patch
> > where the effectively the PCD I added was fixed true but was unsure if
> > that would have unexpected issues with other vendors platforms
> 
> The current SsdtCpuTopologyGenerator doesn't generate an AML node for the
> top level package. Even though this seem compliant to the ACPI spec, this
> induces a difference between the ASL topology description and the PPTT
> topology description. For instance, for the Juno, the topology generated for 
> the
> ACPI tables are:
> PPTT:
> (PACKAGE)
> \-Little Cluster
>\-CPU[0,3-5]
> \-Big Cluster
>\-CPU[1-2]
> 
> SSDT:
> Little Cluster
> \-CPU[0,3-5]
> Big Cluster
> \-CPU[1-2]
> 
> To solve your issue, to have matching topology descriptions, and after
> discussing with Sami, it would be better to have:
> SSDT:
> (PACKAGE)
> \-Little Cluster
>\-CPU[0,3-5]
> \-Big Cluster
>\-CPU[1-2]
> 
> The Juno is the only platform that publicly uses the SsdtCpuTopologyGenerator,
> so I am not sure how other platforms support should be handled.
> 
> About the code itself, I think the ProcContainerIndex should also be reset in
> CreateAmlCpuTopologyTree() when generating a new level of containers (if it is
> decided to go this way).
> 
> Regards,
> Pierre
> 
> >
> > -Jeff
> >
> >> -Original Message-
> >> From: Pierre Gondois 
> >> Sent: Thursday, February 2, 2023 10:49 AM
> >> To: Jeff Brasen ; devel@edk2.groups.io
> >> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com;
> >> quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> >> Subject: Re: [PATCH] DynamicTablesPkg: Allow multiple top level
> >> physical nodes
> >>
> >> External email: Use caution opening links or attachments
> >>
> >>
> >> Hello Jeff,
> >> I was assuming that no other module would rely on the AML path to
> >> access an AML node and that nodes should be retrieved through their
> >> characteristics instead, i.e. internal properties/Name/Uid.
> >> There are currently no public API allowing to do so, but there are
> >> internal APIs that could be relied on to create them.
> >>
> >> I'm not sure what Sami is thinking,
> >>
> >> Regards,
> >> Pierre
> >>
> >> On 2/2/23 17:48, Jeff Brasen wrote:
> >>> Just to clarify you are suggesting that all CPU nodes generated via
> >>> this with have an outer processor container? I am fine with that but
> >>> was concerned with a change in behavior to other platforms in case
> >>> they are expecting the CPUs to just be under \SB.C00x instead of
> >>> \SB.C000.C00x
> >>>
> >>> -Jeff
> >>>
> >>>
>  -Original Message-
>  From: Pierre Gondois 
>  Sent: Thursday, February 2, 2023 5:03 AM
>  To: Jeff Brasen ; devel@edk2.groups.io
>  Cc: sami.muja...@arm.com; alexei.fedo...@arm.com;
>  quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
>  Subject: Re: [PATCH] DynamicTablesPkg: Allow multiple top level
>  physical nodes
> 
>  External email: Use caution opening links or attachments
> 
> 
>  Hello Jeff,
>  I think it's ok to make this the generic case and remove the Pcd to
>  enable
> >> it.
>  Cf ACPI 6.5, 5.2.30.1 Processor hierarchy node structure (Type 0):
> 
>  "Multiple trees may be described, covering for example multiple
> >> packages.
>  For the root of a tree, the parent pointer should be 0."
>  and
>  "Each valid processor must belong to exactly one package. That is,
>  the leaf must itself be a physical package or have an ancestor
>  marked as a physical package."
> 
>  so this original comment is incorrect:
>  """
>  // It is assumed that there is one unique
> >> CM_ARM_PROC_HIERARCHY_INFO
>  // structure with no ParentToken and the
>  EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL
>  // flag set. All other CM_ARM_PROC_HIERARCHY_INFO are non-physical
>  and // have a ParentToken.
>  """
> 
>  On 2/1/23 17:42, Jeff Brasen wrote:
> > In SSDT CPU topology generator allow for multiple top level
> > physical nodes as would be seen with a multi-socket system. This
> > will be auto detected if there are more then one physical device
> > and there is a new PCD to enable forcing of 

Re: [edk2-devel] [PATCH] DynamicTablesPkg: Allow multiple top level physical nodes

2023-02-02 Thread Jeff Brasen via groups.io
There are some cases (for example the _PSL list in thermal zones) where we need 
to have a reference to the node and we have been doing that via an Extern and a 
reference to the node path. I am push a patch where the effectively the PCD I 
added was fixed true but was unsure if that would have unexpected issues with 
other vendors platforms

-Jeff

> -Original Message-
> From: Pierre Gondois 
> Sent: Thursday, February 2, 2023 10:49 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com;
> quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> Subject: Re: [PATCH] DynamicTablesPkg: Allow multiple top level physical
> nodes
> 
> External email: Use caution opening links or attachments
> 
> 
> Hello Jeff,
> I was assuming that no other module would rely on the AML path to access
> an AML node and that nodes should be retrieved through their
> characteristics instead, i.e. internal properties/Name/Uid.
> There are currently no public API allowing to do so, but there are internal
> APIs that could be relied on to create them.
> 
> I'm not sure what Sami is thinking,
> 
> Regards,
> Pierre
> 
> On 2/2/23 17:48, Jeff Brasen wrote:
> > Just to clarify you are suggesting that all CPU nodes generated via
> > this with have an outer processor container? I am fine with that but
> > was concerned with a change in behavior to other platforms in case
> > they are expecting the CPUs to just be under \SB.C00x instead of
> > \SB.C000.C00x
> >
> > -Jeff
> >
> >
> >> -Original Message-
> >> From: Pierre Gondois 
> >> Sent: Thursday, February 2, 2023 5:03 AM
> >> To: Jeff Brasen ; devel@edk2.groups.io
> >> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com;
> >> quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> >> Subject: Re: [PATCH] DynamicTablesPkg: Allow multiple top level
> >> physical nodes
> >>
> >> External email: Use caution opening links or attachments
> >>
> >>
> >> Hello Jeff,
> >> I think it's ok to make this the generic case and remove the Pcd to enable
> it.
> >> Cf ACPI 6.5, 5.2.30.1 Processor hierarchy node structure (Type 0):
> >>
> >> "Multiple trees may be described, covering for example multiple
> packages.
> >> For the root of a tree, the parent pointer should be 0."
> >> and
> >> "Each valid processor must belong to exactly one package. That is,
> >> the leaf must itself be a physical package or have an ancestor marked
> >> as a physical package."
> >>
> >> so this original comment is incorrect:
> >> """
> >> // It is assumed that there is one unique
> CM_ARM_PROC_HIERARCHY_INFO
> >> // structure with no ParentToken and the
> >> EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL
> >> // flag set. All other CM_ARM_PROC_HIERARCHY_INFO are non-physical
> >> and // have a ParentToken.
> >> """
> >>
> >> On 2/1/23 17:42, Jeff Brasen wrote:
> >>> In SSDT CPU topology generator allow for multiple top level physical
> >>> nodes as would be seen with a multi-socket system. This will be auto
> >>> detected if there are more then one physical device and there is a
> >>> new PCD to enable forcing of a top level processor container to
> >>> allow for consistency for systems that can be either single or multi
> socket.
> >>>
> >>> Signed-off-by: Jeff Brasen 
> >>> ---
> >>>DynamicTablesPkg/DynamicTablesPkg.dec |  3 +
> >>>.../SsdtCpuTopologyGenerator.c| 66 ++-
> >>>.../SsdtCpuTopologyLibArm.inf |  4 ++
> >>>3 files changed, 41 insertions(+), 32 deletions(-)
> >>>
> >>> diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec
> >>> b/DynamicTablesPkg/DynamicTablesPkg.dec
> >>> index adc2e67cbf..a061b70322 100644
> >>> --- a/DynamicTablesPkg/DynamicTablesPkg.dec
> >>> +++ b/DynamicTablesPkg/DynamicTablesPkg.dec
> >>> @@ -63,5 +63,8 @@
> >>>  # Use PCI segment numbers as UID
> >>>
> >>>
> >>
> gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdPciUseSegmentAsUid|FALSE|B
> >> OOLE
> >>> AN|0x4009
> >>>
> >>> +  # Force top level container for single socket devices
> >>> +
> >>
> gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdForceTopLevelProcessorContai
> >>> + ner|FALSE|BOOLEAN|0x400A
> >>> +
> >>>[Guids]
> >>>  gEdkiiDynamicTablesPkgTokenSpaceGuid = { 0xab226e66, 0x31d8,
> >>> 0x4613, { 0x87, 0x9d, 0xd2, 0xfa, 0xb6, 0x10, 0x26, 0x3c } } diff
> >>> --git
> >>>
> >>
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> >> uT
> >>> opologyGenerator.c
> >>>
> >>
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> >> uT
> >>> opologyGenerator.c
> >>> index c24da8ec71..58f86ff508 100644
> >>> ---
> >>>
> >>
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> >> uT
> >>> opologyGenerator.c
> >>> +++
> >> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/Ssdt
> >>> +++ CpuTopologyGenerator.c
> >>> @@ -22,6 +22,7 @@
> >>>#include 
> >>>#include 
> >>>#include 
> >>> +#include 
> >>>#include 
> >>>
> >>>#include 

Re: [edk2-devel] [PATCH] DynamicTablesPkg: Allow multiple top level physical nodes

2023-02-02 Thread Jeff Brasen via groups.io
Just to clarify you are suggesting that all CPU nodes generated via this with 
have an outer processor container? I am fine with that but was concerned with a 
change in behavior to other platforms in case they are expecting the CPUs to 
just be under \SB.C00x instead of \SB.C000.C00x

-Jeff


> -Original Message-
> From: Pierre Gondois 
> Sent: Thursday, February 2, 2023 5:03 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com;
> quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> Subject: Re: [PATCH] DynamicTablesPkg: Allow multiple top level physical
> nodes
> 
> External email: Use caution opening links or attachments
> 
> 
> Hello Jeff,
> I think it's ok to make this the generic case and remove the Pcd to enable it.
> Cf ACPI 6.5, 5.2.30.1 Processor hierarchy node structure (Type 0):
> 
> "Multiple trees may be described, covering for example multiple packages.
> For the root of a tree, the parent pointer should be 0."
> and
> "Each valid processor must belong to exactly one package. That is, the leaf
> must itself be a physical package or have an ancestor marked as a physical
> package."
> 
> so this original comment is incorrect:
> """
> // It is assumed that there is one unique CM_ARM_PROC_HIERARCHY_INFO
> // structure with no ParentToken and the
> EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL
> // flag set. All other CM_ARM_PROC_HIERARCHY_INFO are non-physical and
> // have a ParentToken.
> """
> 
> On 2/1/23 17:42, Jeff Brasen wrote:
> > In SSDT CPU topology generator allow for multiple top level physical
> > nodes as would be seen with a multi-socket system. This will be auto
> > detected if there are more then one physical device and there is a new
> > PCD to enable forcing of a top level processor container to allow for
> > consistency for systems that can be either single or multi socket.
> >
> > Signed-off-by: Jeff Brasen 
> > ---
> >   DynamicTablesPkg/DynamicTablesPkg.dec |  3 +
> >   .../SsdtCpuTopologyGenerator.c| 66 ++-
> >   .../SsdtCpuTopologyLibArm.inf |  4 ++
> >   3 files changed, 41 insertions(+), 32 deletions(-)
> >
> > diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec
> > b/DynamicTablesPkg/DynamicTablesPkg.dec
> > index adc2e67cbf..a061b70322 100644
> > --- a/DynamicTablesPkg/DynamicTablesPkg.dec
> > +++ b/DynamicTablesPkg/DynamicTablesPkg.dec
> > @@ -63,5 +63,8 @@
> > # Use PCI segment numbers as UID
> >
> >
> gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdPciUseSegmentAsUid|FALSE|B
> OOLE
> > AN|0x4009
> >
> > +  # Force top level container for single socket devices
> > +
> gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdForceTopLevelProcessorContai
> > + ner|FALSE|BOOLEAN|0x400A
> > +
> >   [Guids]
> > gEdkiiDynamicTablesPkgTokenSpaceGuid = { 0xab226e66, 0x31d8,
> > 0x4613, { 0x87, 0x9d, 0xd2, 0xfa, 0xb6, 0x10, 0x26, 0x3c } } diff
> > --git
> >
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uT
> > opologyGenerator.c
> >
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uT
> > opologyGenerator.c
> > index c24da8ec71..58f86ff508 100644
> > ---
> >
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uT
> > opologyGenerator.c
> > +++
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/Ssdt
> > +++ CpuTopologyGenerator.c
> > @@ -22,6 +22,7 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >   #include 
> >
> >   #include "SsdtCpuTopologyGenerator.h"
> > @@ -814,7 +815,8 @@ CreateAmlProcessorContainer (
> > Protocol Interface.
> > @param [in] NodeToken   Token of the
> CM_ARM_PROC_HIERARCHY_INFO
> > currently handled.
> > -  Cannot be CM_NULL_TOKEN.
> > +  CM_NULL_TOKEN if top level container
> > +  should be created.
> > @param [in] ParentNode  Parent node to attach the created
> > node to.
> > @param [in,out] ProcContainerIndex  Pointer to the current
> > processor container @@ -841,12 +843,12 @@ CreateAmlCpuTopologyTree
> (
> > AML_OBJECT_NODE_HANDLE  ProcContainerNode;
> > UINT32  Uid;
> > UINT16  Name;
> > +  UINT32  NodeFlags;
> >
> > ASSERT (Generator != NULL);
> > ASSERT (Generator->ProcNodeList != NULL);
> > ASSERT (Generator->ProcNodeCount != 0);
> > ASSERT (CfgMgrProtocol != NULL);
> > -  ASSERT (NodeToken != CM_NULL_TOKEN);
> > ASSERT (ParentNode != NULL);
> > ASSERT (ProcContainerIndex != NULL);
> >
> > @@ -893,8 +895,14 @@ CreateAmlCpuTopologyTree (
> > } else {
> >   // If this is not a Cpu, then this is a processor container.
> >
> > +NodeFlags = Generator->ProcNodeList[Index].Flags;
> > +// 

[edk2-devel] [PATCH] DynamicTablesPkg: Allow multiple top level physical nodes

2023-02-01 Thread Jeff Brasen via groups.io
In SSDT CPU topology generator allow for multiple top level physical

nodes as would be seen with a multi-socket system. This will be auto

detected if there are more then one physical device and there is a

new PCD to enable forcing of a top level processor container to allow

for consistency for systems that can be either single or multi socket.



Signed-off-by: Jeff Brasen 

---

 DynamicTablesPkg/DynamicTablesPkg.dec |  3 +

 .../SsdtCpuTopologyGenerator.c| 66 ++-

 .../SsdtCpuTopologyLibArm.inf |  4 ++

 3 files changed, 41 insertions(+), 32 deletions(-)



diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec

index adc2e67cbf..a061b70322 100644

--- a/DynamicTablesPkg/DynamicTablesPkg.dec

+++ b/DynamicTablesPkg/DynamicTablesPkg.dec

@@ -63,5 +63,8 @@

   # Use PCI segment numbers as UID

   
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdPciUseSegmentAsUid|FALSE|BOOLEAN|0x4009

 

+  # Force top level container for single socket devices

+  
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdForceTopLevelProcessorContainer|FALSE|BOOLEAN|0x400A

+

 [Guids]

   gEdkiiDynamicTablesPkgTokenSpaceGuid = { 0xab226e66, 0x31d8, 0x4613, { 0x87, 
0x9d, 0xd2, 0xfa, 0xb6, 0x10, 0x26, 0x3c } }

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

index c24da8ec71..58f86ff508 100644

--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

@@ -22,6 +22,7 @@

 #include 

 #include 

 #include 

+#include 

 #include 

 

 #include "SsdtCpuTopologyGenerator.h"

@@ -814,7 +815,8 @@ CreateAmlProcessorContainer (

   Protocol Interface.

   @param [in] NodeToken   Token of the CM_ARM_PROC_HIERARCHY_INFO

   currently handled.

-  Cannot be CM_NULL_TOKEN.

+  CM_NULL_TOKEN if top level container

+  should be created.

   @param [in] ParentNode  Parent node to attach the created

   node to.

   @param [in,out] ProcContainerIndex  Pointer to the current processor 
container

@@ -841,12 +843,12 @@ CreateAmlCpuTopologyTree (

   AML_OBJECT_NODE_HANDLE  ProcContainerNode;

   UINT32  Uid;

   UINT16  Name;

+  UINT32  NodeFlags;

 

   ASSERT (Generator != NULL);

   ASSERT (Generator->ProcNodeList != NULL);

   ASSERT (Generator->ProcNodeCount != 0);

   ASSERT (CfgMgrProtocol != NULL);

-  ASSERT (NodeToken != CM_NULL_TOKEN);

   ASSERT (ParentNode != NULL);

   ASSERT (ProcContainerIndex != NULL);

 

@@ -893,8 +895,14 @@ CreateAmlCpuTopologyTree (

   } else {

 // If this is not a Cpu, then this is a processor container.

 

+NodeFlags = Generator->ProcNodeList[Index].Flags;

+// Allow physical property for top level nodes

+if (NodeToken == CM_NULL_TOKEN) {

+  NodeFlags &= ~EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL;

+}

+

 // Acpi processor Id for clusters is not handled.

-if ((Generator->ProcNodeList[Index].Flags & PPTT_PROCESSOR_MASK) !=

+if ((NodeFlags & PPTT_PROCESSOR_MASK) !=

 PPTT_CLUSTER_PROCESSOR_MASK)

 {

   DEBUG ((

@@ -973,10 +981,10 @@ CreateTopologyFromProcHierarchy (

   INAML_OBJECT_NODE_HANDLEScopeNode

   )

 {

-  EFI_STATUS  Status;

-  UINT32  Index;

-  UINT32  TopLevelProcNodeIndex;

-  UINT32  ProcContainerIndex;

+  EFI_STATUS   Status;

+  UINT32   Index;

+  CM_OBJECT_TOKEN  TopLevelToken;

+  UINT32   ProcContainerIndex;

 

   ASSERT (Generator != NULL);

   ASSERT (Generator->ProcNodeCount != 0);

@@ -984,8 +992,8 @@ CreateTopologyFromProcHierarchy (

   ASSERT (CfgMgrProtocol != NULL);

   ASSERT (ScopeNode != NULL);

 

-  TopLevelProcNodeIndex = MAX_UINT32;

-  ProcContainerIndex= 0;

+  TopLevelToken  = CM_NULL_TOKEN;

+  ProcContainerIndex = 0;

 

   Status = TokenTableInitialize (Generator, Generator->ProcNodeCount);

   if (EFI_ERROR (Status)) {

@@ -993,33 +1001,27 @@ CreateTopologyFromProcHierarchy (

 return Status;

   }

 

-  // It is assumed that there is one unique CM_ARM_PROC_HIERARCHY_INFO

-  // structure with no ParentToken and the EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL

-  // flag set. All other CM_ARM_PROC_HIERARCHY_INFO are non-physical and

-  // have a ParentToken.

-  for (Index = 0; Index < Generator->ProcNodeCount; Index++) {

-if ((Generator->ProcNodeList[Index].ParentToken == CM_NULL_TOKEN) &&

-(Generator->ProcNodeList[Index].Flags &

- 

Re: [edk2-devel] [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support multiple devices with 0 HardwareInstance

2023-02-01 Thread Jeff Brasen via groups.io
Any updates on this would be great to get this in for the next stable release 
if possible.

> -Original Message-
> From: Jeff Brasen 
> Sent: Monday, December 12, 2022 12:27 PM
> To: devel@edk2.groups.io
> Cc: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> guomin.ji...@intel.com; Jeff Brasen 
> Subject: [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support multiple devices
> with 0 HardwareInstance
> 
> Skip error check if HardwareInstance is 0 as this either means that
> FmpVersion < 3 and not supported or, "A zero means the FMP provider is not
> able to determine a unique hardware instance number or a hardware
> instance number is not needed." per UEFI specification.
> 
> As the FmpInstances are merged and HardwareInstance is not used remove
> error check in this case.
> 
> 
> Signed-off-by: Jeff Brasen 
> ---
>  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c | 22 --
> ---
>  1 file changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
> b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
> index 4f47c55cce..5bc627461d 100644
> --- a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
> +++ b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
> @@ -153,16 +153,20 @@ CreateEsrtEntry (
> 
>//
>// Check to see of FmpImageInfoBuf GUID/HardwareInstance is unique
> +  // Skip if HardwareInstance is 0 as this is the case if FmpVersion <
> + 3  // or the device can not create a unique ID per UEFI specification
>//
> -  for (Index = 0; Index < *NumberOfDescriptors; Index++) {
> -if (CompareGuid ([Index].ImageTypeGuid,
> >ImageTypeId)) {
> -  if (HardwareInstances[Index].HardwareInstance ==
> FmpHardwareInstance) {
> -DEBUG ((DEBUG_ERROR, "EsrtFmpDxe: Duplicate firmware image
> descriptor with GUID %g HardwareInstance:0x%x\n", 
> >ImageTypeId, FmpHardwareInstance));
> -ASSERT (
> -  !CompareGuid ([Index].ImageTypeGuid,
> >ImageTypeId) ||
> -  HardwareInstances[Index].HardwareInstance !=
> FmpHardwareInstance
> -  );
> -return EFI_UNSUPPORTED;
> +  if (FmpHardwareInstance != 0) {
> +for (Index = 0; Index < *NumberOfDescriptors; Index++) {
> +  if (CompareGuid ([Index].ImageTypeGuid,
> >ImageTypeId)) {
> +if (HardwareInstances[Index].HardwareInstance ==
> FmpHardwareInstance) {
> +  DEBUG ((DEBUG_ERROR, "EsrtFmpDxe: Duplicate firmware image
> descriptor with GUID %g HardwareInstance:0x%x\n", 
> >ImageTypeId, FmpHardwareInstance));
> +  ASSERT (
> +!CompareGuid ([Index].ImageTypeGuid,
> >ImageTypeId) ||
> +HardwareInstances[Index].HardwareInstance !=
> FmpHardwareInstance
> +);
> +  return EFI_UNSUPPORTED;
> +}
>}
>  }
>}
> --
> 2.25.1



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




[edk2-devel] [PATCH v2] MdeModulePkg/EsrtFmpDxe: Support multiple devices with 0 HardwareInstance

2022-12-12 Thread Jeff Brasen via groups.io
Skip error check if HardwareInstance is 0 as this either means that
FmpVersion < 3 and not supported or,
"A zero means the FMP provider is not able to determine a
unique hardware instance number or a hardware instance number
is not needed." per UEFI specification.

As the FmpInstances are merged and HardwareInstance is not used
remove error check in this case.


Signed-off-by: Jeff Brasen 
---
 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c | 22 -
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c 
b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
index 4f47c55cce..5bc627461d 100644
--- a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
+++ b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
@@ -153,16 +153,20 @@ CreateEsrtEntry (
 
   //
   // Check to see of FmpImageInfoBuf GUID/HardwareInstance is unique
+  // Skip if HardwareInstance is 0 as this is the case if FmpVersion < 3
+  // or the device can not create a unique ID per UEFI specification
   //
-  for (Index = 0; Index < *NumberOfDescriptors; Index++) {
-if (CompareGuid ([Index].ImageTypeGuid, 
>ImageTypeId)) {
-  if (HardwareInstances[Index].HardwareInstance == FmpHardwareInstance) {
-DEBUG ((DEBUG_ERROR, "EsrtFmpDxe: Duplicate firmware image descriptor 
with GUID %g HardwareInstance:0x%x\n", >ImageTypeId, 
FmpHardwareInstance));
-ASSERT (
-  !CompareGuid ([Index].ImageTypeGuid, 
>ImageTypeId) ||
-  HardwareInstances[Index].HardwareInstance != FmpHardwareInstance
-  );
-return EFI_UNSUPPORTED;
+  if (FmpHardwareInstance != 0) {
+for (Index = 0; Index < *NumberOfDescriptors; Index++) {
+  if (CompareGuid ([Index].ImageTypeGuid, 
>ImageTypeId)) {
+if (HardwareInstances[Index].HardwareInstance == FmpHardwareInstance) {
+  DEBUG ((DEBUG_ERROR, "EsrtFmpDxe: Duplicate firmware image 
descriptor with GUID %g HardwareInstance:0x%x\n", 
>ImageTypeId, FmpHardwareInstance));
+  ASSERT (
+!CompareGuid ([Index].ImageTypeGuid, 
>ImageTypeId) ||
+HardwareInstances[Index].HardwareInstance != FmpHardwareInstance
+);
+  return EFI_UNSUPPORTED;
+}
   }
 }
   }
-- 
2.25.1



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




[edk2-devel] [PATCH] DynamicTablesPkg/EsrtFmpDxe: Support multiple devices with 0 HardwareInstance

2022-11-16 Thread Jeff Brasen via groups.io
Skip error check if HardwareInstance is 0 as this either means that
FmpVersion < 3 and not supported or,
"A zero means the FMP provider is not able to determine a
unique hardware instance number or a hardware instance number
is not needed." per UEFI specification.

As the FmpInstances are merged and HardwareInstance is not used
remove error check in this case.

Signed-off-by: Jeff Brasen 
---
 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c | 22 -
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c 
b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
index 4f47c55cce..5bc627461d 100644
--- a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
+++ b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
@@ -153,16 +153,20 @@ CreateEsrtEntry (
 
   //
   // Check to see of FmpImageInfoBuf GUID/HardwareInstance is unique
+  // Skip if HardwareInstance is 0 as this is the case if FmpVersion < 3
+  // or the device can not create a unique ID per UEFI specification
   //
-  for (Index = 0; Index < *NumberOfDescriptors; Index++) {
-if (CompareGuid ([Index].ImageTypeGuid, 
>ImageTypeId)) {
-  if (HardwareInstances[Index].HardwareInstance == FmpHardwareInstance) {
-DEBUG ((DEBUG_ERROR, "EsrtFmpDxe: Duplicate firmware image descriptor 
with GUID %g HardwareInstance:0x%x\n", >ImageTypeId, 
FmpHardwareInstance));
-ASSERT (
-  !CompareGuid ([Index].ImageTypeGuid, 
>ImageTypeId) ||
-  HardwareInstances[Index].HardwareInstance != FmpHardwareInstance
-  );
-return EFI_UNSUPPORTED;
+  if (FmpHardwareInstance != 0) {
+for (Index = 0; Index < *NumberOfDescriptors; Index++) {
+  if (CompareGuid ([Index].ImageTypeGuid, 
>ImageTypeId)) {
+if (HardwareInstances[Index].HardwareInstance == FmpHardwareInstance) {
+  DEBUG ((DEBUG_ERROR, "EsrtFmpDxe: Duplicate firmware image 
descriptor with GUID %g HardwareInstance:0x%x\n", 
>ImageTypeId, FmpHardwareInstance));
+  ASSERT (
+!CompareGuid ([Index].ImageTypeGuid, 
>ImageTypeId) ||
+HardwareInstances[Index].HardwareInstance != FmpHardwareInstance
+);
+  return EFI_UNSUPPORTED;
+}
   }
 }
   }
-- 
2.25.1



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




[edk2-devel] [PATCH] DynamicTablesPkg: SSDT _LPI revision is incorrect

2022-11-15 Thread Jeff Brasen via groups.io
_LPI Revision should be 0 per the ACPI 6.5 specification.
"The revision number of the _LPI object. Current revision is 0."

Signed-off-by: Jeff Brasen 
---
 .../Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
index d06c7615fb..91199c4af2 100644
--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
@@ -482,7 +482,7 @@ GenerateLpiStates (
 }
 
 // We do not support the LevelId field for now, let it to 0.
-Status = AmlCreateLpiNode (AslName, 1, 0, ScopeNode, );
+Status = AmlCreateLpiNode (AslName, 0, 0, ScopeNode, );
 if (EFI_ERROR (Status)) {
   ASSERT (0);
   return Status;
-- 
2.25.1



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




Re: [edk2-devel] [PATCH] DynamicTablesPkg: Allow for specified CPU names

2022-11-07 Thread Jeff Brasen via groups.io
This was the simplest approach that I had to solve this issue, but not sure if 
it would be better to do something smarter. A couple other ideas I had where:
- Specify the affinity level that CPUs use and use the levels above that for 
the containers.
- Have a new object that has the container levels and affinity mapping. This 
wouldn't support unbalanced layouts.
- I can't think of a good way to auto detect the cpu level affinity level but 
that would be nice. 

-Jeff


> -Original Message-
> From: Jeff Brasen 
> Sent: Monday, November 7, 2022 8:57 AM
> To: devel@edk2.groups.io
> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com;
> pierre.gond...@arm.com; quic_llind...@quicinc.com;
> ardb+tianoc...@kernel.org; Jeff Brasen 
> Subject: [PATCH] DynamicTablesPkg: Allow for specified CPU names
> 
> Allow object to specify the name of processor and processor container
> 
> nodes and the UID of processor containers.
> 
> 
> 
> This allows these to be more accurately referenced from other tables.
> 
> For example for the _PSL method or the UID in the APMT table.
> 
> 
> 
> The UID and Name for processor container may be different as if the
> 
> intention is to set names as the corresponding affinity level the UID
> 
> may need to be different if there are multiple levels of containers.
> 
> 
> 
> Signed-off-by: Jeff Brasen 
> 
> ---
> 
>  .../Include/ArmNameSpaceObjects.h | 11 +
> 
>  .../SsdtCpuTopologyGenerator.c| 40 ++-
> 
>  .../ConfigurationManagerObjectParser.c|  3 ++
> 
>  3 files changed, 43 insertions(+), 11 deletions(-)
> 
> 
> 
> diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
> b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
> 
> index 6aafd41a2e..19098609de 100644
> 
> --- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
> 
> +++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
> 
> @@ -768,6 +768,17 @@ typedef struct CmArmProcHierarchyInfo {
> 
>/// Token identifying a CM_ARM_OBJ_REF structure, itself referencing
> 
>/// CM_ARM_LPI_INFO objects.
> 
>CM_OBJECT_TOKENLpiToken;
> 
> +  /// Set to TRUE if UID should override index for name and _UID
> 
> +  /// for processor container nodes and name of processors.
> 
> +  /// This should be consistently set for containers or processors to avoid
> 
> +  /// duplicate values
> 
> +  BOOLEANOverrideNameUidEnabled;
> 
> +  /// If OverrideNameUidEnabled is TRUE then this value will be used for
> name of
> 
> +  /// processors and processor containers.
> 
> +  UINT16 OverrideName;
> 
> +  /// If OverrideNameUidEnabled is TRUE then this value will be used for
> 
> +  /// the UID of processor containers.
> 
> +  UINT32 OverrideUid;
> 
>  } CM_ARM_PROC_HIERARCHY_INFO;
> 
> 
> 
>  /** A structure that describes the Cache Type Structure (Type 1) in PPTT
> 
> diff --git
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uTopologyGenerator.c
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uTopologyGenerator.c
> 
> index d06c7615fb..92fa904103 100644
> 
> ---
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uTopologyGenerator.c
> 
> +++
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uTopologyGenerator.c
> 
> @@ -553,7 +553,7 @@ GenerateLpiStates (
> 
>@param [in]  GeneratorThe SSDT Cpu Topology generator.
> 
>@param [in]  ParentNode   Parent node to attach the Cpu node to.
> 
>@param [in]  GicCInfo CM_ARM_GICC_INFO object used to create the
> node.
> 
> -  @param [in]  CpuIndex Index used to generate the node name.
> 
> +  @param [in]  CpuName  Value used to generate the node name.
> 
>@param [out] CpuNodePtr   If not NULL, return the created Cpu node.
> 
> 
> 
>@retval EFI_SUCCESS Success.
> 
> @@ -567,7 +567,7 @@ CreateAmlCpu (
> 
>IN   ACPI_CPU_TOPOLOGY_GENERATOR  *Generator,
> 
>IN   AML_NODE_HANDLE  ParentNode,
> 
>IN   CM_ARM_GICC_INFO *GicCInfo,
> 
> -  IN   UINT32   CpuIndex,
> 
> +  IN   UINT32   CpuName,
> 
>OUT  AML_OBJECT_NODE_HANDLE   *CpuNodePtr OPTIONAL
> 
>)
> 
>  {
> 
> @@ -579,7 +579,7 @@ CreateAmlCpu (
> 
>ASSERT (ParentNode != NULL);
> 
>ASSERT (GicCInfo != NULL);
> 
> 
> 
> -  Status = WriteAslName ('C', CpuIndex, AslName);
> 
> +  Status = WriteAslName ('C', CpuName, AslName);
> 
>if (EFI_ERROR (Status)) {
> 
>  ASSERT (0);
> 
>  return Status;
> 
> @@ -628,7 +628,7 @@ CreateAmlCpu (
> 
>@param [in]  CfgMgrProtocol Pointer to the Configuration Manager
> 
>Protocol Interface.
> 
>@param [in]  ParentNode Parent node to attach the Cpu node to.
> 
> -  @param [in]  CpuIndex   Index used to generate the node name.
> 
> +  @param [in]  CpuNameValue used to generate the node name.
> 
> 

[edk2-devel] [PATCH] DynamicTablesPkg: Allow for specified CPU names

2022-11-07 Thread Jeff Brasen via groups.io
Allow object to specify the name of processor and processor container

nodes and the UID of processor containers.



This allows these to be more accurately referenced from other tables.

For example for the _PSL method or the UID in the APMT table.



The UID and Name for processor container may be different as if the

intention is to set names as the corresponding affinity level the UID

may need to be different if there are multiple levels of containers.



Signed-off-by: Jeff Brasen 

---

 .../Include/ArmNameSpaceObjects.h | 11 +

 .../SsdtCpuTopologyGenerator.c| 40 ++-

 .../ConfigurationManagerObjectParser.c|  3 ++

 3 files changed, 43 insertions(+), 11 deletions(-)



diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

index 6aafd41a2e..19098609de 100644

--- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

@@ -768,6 +768,17 @@ typedef struct CmArmProcHierarchyInfo {

   /// Token identifying a CM_ARM_OBJ_REF structure, itself referencing

   /// CM_ARM_LPI_INFO objects.

   CM_OBJECT_TOKENLpiToken;

+  /// Set to TRUE if UID should override index for name and _UID

+  /// for processor container nodes and name of processors.

+  /// This should be consistently set for containers or processors to avoid

+  /// duplicate values

+  BOOLEANOverrideNameUidEnabled;

+  /// If OverrideNameUidEnabled is TRUE then this value will be used for name 
of

+  /// processors and processor containers.

+  UINT16 OverrideName;

+  /// If OverrideNameUidEnabled is TRUE then this value will be used for

+  /// the UID of processor containers.

+  UINT32 OverrideUid;

 } CM_ARM_PROC_HIERARCHY_INFO;

 

 /** A structure that describes the Cache Type Structure (Type 1) in PPTT

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

index d06c7615fb..92fa904103 100644

--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

@@ -553,7 +553,7 @@ GenerateLpiStates (

   @param [in]  GeneratorThe SSDT Cpu Topology generator.

   @param [in]  ParentNode   Parent node to attach the Cpu node to.

   @param [in]  GicCInfo CM_ARM_GICC_INFO object used to create the node.

-  @param [in]  CpuIndex Index used to generate the node name.

+  @param [in]  CpuName  Value used to generate the node name.

   @param [out] CpuNodePtr   If not NULL, return the created Cpu node.

 

   @retval EFI_SUCCESS Success.

@@ -567,7 +567,7 @@ CreateAmlCpu (

   IN   ACPI_CPU_TOPOLOGY_GENERATOR  *Generator,

   IN   AML_NODE_HANDLE  ParentNode,

   IN   CM_ARM_GICC_INFO *GicCInfo,

-  IN   UINT32   CpuIndex,

+  IN   UINT32   CpuName,

   OUT  AML_OBJECT_NODE_HANDLE   *CpuNodePtr OPTIONAL

   )

 {

@@ -579,7 +579,7 @@ CreateAmlCpu (

   ASSERT (ParentNode != NULL);

   ASSERT (GicCInfo != NULL);

 

-  Status = WriteAslName ('C', CpuIndex, AslName);

+  Status = WriteAslName ('C', CpuName, AslName);

   if (EFI_ERROR (Status)) {

 ASSERT (0);

 return Status;

@@ -628,7 +628,7 @@ CreateAmlCpu (

   @param [in]  CfgMgrProtocol Pointer to the Configuration Manager

   Protocol Interface.

   @param [in]  ParentNode Parent node to attach the Cpu node to.

-  @param [in]  CpuIndex   Index used to generate the node name.

+  @param [in]  CpuNameValue used to generate the node name.

   @param [in]  ProcHierarchyNodeInfo  CM_ARM_PROC_HIERARCHY_INFO describing

   the Cpu.

 

@@ -643,7 +643,7 @@ CreateAmlCpuFromProcHierarchy (

   INACPI_CPU_TOPOLOGY_GENERATOR   *Generator,

   IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

   INAML_NODE_HANDLE   ParentNode,

-  INUINT32CpuIndex,

+  INUINT32CpuName,

   INCM_ARM_PROC_HIERARCHY_INFO
*ProcHierarchyNodeInfo

   )

 {

@@ -668,7 +668,7 @@ CreateAmlCpuFromProcHierarchy (

 return Status;

   }

 

-  Status = CreateAmlCpu (Generator, ParentNode, GicCInfo, CpuIndex, );

+  Status = CreateAmlCpu (Generator, ParentNode, GicCInfo, CpuName, );

   if (EFI_ERROR (Status)) {

 ASSERT (0);

 return Status;

@@ -735,7 +735,8 @@ CreateAmlProcessorContainer (

   IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

   INAML_NODE_HANDLE   ParentNode,

 

[edk2-devel] [PATCH v2 1/2] MdePkg/IndustryStandard: add definitions for ACPI APMT

2022-11-04 Thread Jeff Brasen via groups.io
This adds #defines and struct typedefs for the various node types in

the  ACPI Arm Performance Monitoring Unit (APMT) table.



Signed-off-by: Jeff Brasen 

---

 MdePkg/Include/IndustryStandard/Acpi64.h  |  5 ++

 .../ArmPerformanceMonitoringUnitTable.h   | 69 +++

 2 files changed, 74 insertions(+)

 create mode 100644 
MdePkg/Include/IndustryStandard/ArmPerformanceMonitoringUnitTable.h



diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h 
b/MdePkg/Include/IndustryStandard/Acpi64.h

index fe5ebfac2b..575ca0430c 100644

--- a/MdePkg/Include/IndustryStandard/Acpi64.h

+++ b/MdePkg/Include/IndustryStandard/Acpi64.h

@@ -2847,6 +2847,11 @@ typedef struct {

 ///

 #define EFI_ACPI_6_4_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE  
SIGNATURE_32('A', 'P', 'I', 'C')

 

+///

+/// "APMT" Arm Performance Monitoring Unit Table

+///

+#define EFI_ACPI_6_4_ARM_PERFORMANCE_MONITORING_UNIT_TABLE_SIGNATURE  
SIGNATURE_32('A', 'P', 'M', 'T')

+

 ///

 /// "BERT" Boot Error Record Table

 ///

diff --git 
a/MdePkg/Include/IndustryStandard/ArmPerformanceMonitoringUnitTable.h 
b/MdePkg/Include/IndustryStandard/ArmPerformanceMonitoringUnitTable.h

new file mode 100644

index 00..fe7084cffd

--- /dev/null

+++ b/MdePkg/Include/IndustryStandard/ArmPerformanceMonitoringUnitTable.h

@@ -0,0 +1,69 @@

+/** @file

+  ACPI Arm Performance Monitoring Unit (APMT) table

+  as specified in ARM spec DEN0117

+

+  Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.

+  Copyright (c) 2022, ARM Limited. All rights reserved.

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

+**/

+

+#ifndef ARM_PERFORMANCE_MONITORING_UNIT_TABLE_H_

+#define ARM_PERFORMANCE_MONITORING_UNIT_TABLE_H_

+

+#include 

+

+#pragma pack(1)

+

+///

+/// Arm Performance Monitoring Unit (APMT) tabl

+///

+typedef struct {

+  EFI_ACPI_DESCRIPTION_HEADERHeader;

+} EFI_ACPI_ARM_PERFORMANCE_MONITORING_UNIT_TABLE_HEADER;

+

+///

+/// APMT Revision (as defined in DEN0117.)

+///

+#define EFI_ACPI_ARM_PERFORMANCE_MONITORING_UNIT_TABLE_REVISION  0x00

+

+///

+/// Arm PMU Node Structure

+///

+

+// Node Flags

+#define EFI_ACPI_APMT_DUAL_PAGE_EXTENSION_SUPPORTED  BIT0

+#define EFI_ACPI_APMT_PROCESSOR_AFFINITY_TYPE_CONTAINER  BIT1

+#define EFI_ACPI_APMT_PROCESSOR_AFFINITY_TYPE_PROCESSOR  0 // BIT 1

+#define EFI_ACPI_APMT_64BIT_SINGLE_COPY_ATOMICITY_SUPPORTED  BIT2

+

+// Interrupt Flags

+#define EFI_ACPI_APMT_INTERRUPT_MODE_EDGE_TRIGGERED   BIT0

+#define EFI_ACPI_APMT_INTERRUPT_MODE_LEVEL_TRIGGERED  0 // BIT 0

+#define EFI_ACPI_APMT_INTERRUPT_TYPE_WIRED0 // BIT 1

+

+// Node Type

+#define EFI_ACPI_APMT_NODE_TYPE_MEMORY_CONTROLLER  0x00

+#define EFI_ACPI_APMT_NODE_TYPE_SMMU   0x01

+#define EFI_ACPI_APMT_NODE_TYPE_PCIE_ROOT_COMPLEX  0x02

+#define EFI_ACPI_APMT_NODE_TYPE_ACPI_DEVICE0x03

+#define EFI_ACPI_APMT_NODE_TYPE_CPU_CACHE  0x04

+

+typedef struct {

+  UINT16Length;

+  UINT8 NodeFlags;

+  UINT8 NodeType;

+  UINT32Identifier;

+  UINT64NodeInstancePrimary;

+  UINT32NodeInstanceSecondary;

+  UINT64BaseAddress0;

+  UINT64BaseAddress1;

+  UINT32OverflowInterrupt;

+  UINT32Reserved1;

+  UINT32OverflowInterruptFlags;

+  UINT32ProcessorAffinity;

+  UINT32ImplementationId;

+} EFI_ACPI_ARM_PERFORMANCE_MONITORING_UNIT_NODE;

+

+#pragma pack()

+

+#endif

-- 

2.25.1





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




[edk2-devel] [PATCH v2 2/2] ShellPkg/AcpiView: APMT Parser

2022-11-04 Thread Jeff Brasen via groups.io
Add a new parser for the Arm Performance Monitoring Unit Table.

The APMT table describes the properties of PMU support

implemented by components in an Arm-based system.



Signed-off-by: Jeff Brasen 

---

 .../UefiShellAcpiViewCommandLib/AcpiParser.h  |  21 

 .../Parsers/Apmt/ApmtParser.c | 106 ++

 .../UefiShellAcpiViewCommandLib.c |   1 +

 .../UefiShellAcpiViewCommandLib.inf   |   1 +

 .../UefiShellAcpiViewCommandLib.uni   |   1 +

 5 files changed, 130 insertions(+)

 create mode 100644 
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c



diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

index db8c88f6df..6a1de4e12b 100644

--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

@@ -531,6 +531,27 @@ ParseAcpiAest (

   IN UINT8AcpiTableRevision

   );

 

+/**

+  This function parses the ACPI APMT table.

+  When trace is enabled this function parses the APMT table and

+  traces the ACPI table fields.

+

+  This function also performs validation of the ACPI table fields.

+

+  @param [in] Trace  If TRUE, trace the ACPI fields.

+  @param [in] PtrPointer to the start of the buffer.

+  @param [in] AcpiTableLengthLength of the ACPI table.

+  @param [in] AcpiTableRevision  Revision of the ACPI table.

+**/

+VOID

+EFIAPI

+ParseAcpiApmt (

+  IN BOOLEAN  Trace,

+  IN UINT8*Ptr,

+  IN UINT32   AcpiTableLength,

+  IN UINT8AcpiTableRevision

+  );

+

 /**

   This function parses the ACPI BGRT table.

   When trace is enabled this function parses the BGRT table and

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c

new file mode 100644

index 00..ad64adbb0a

--- /dev/null

+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c

@@ -0,0 +1,106 @@

+/** @file

+  APMT table parser

+

+  Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.

+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.

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

+

+  @par Reference(s):

+- ACPI 6.2 Specification - Errata A, September 2017

+**/

+

+#include 

+#include 

+#include 

+#include "AcpiParser.h"

+#include "AcpiTableParser.h"

+

+// Local variables

+STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;

+STATIC CONST UINT16  *NodeLength;

+

+/**

+  An ACPI_PARSER array describing the ACPI APMT Table.

+**/

+STATIC CONST ACPI_PARSER  ApmtParser[] = {

+  PARSE_ACPI_HEADER ()

+};

+

+/**

+  An ACPI_PARSER array describing the ACPI Arm PMU Node.

+**/

+STATIC CONST ACPI_PARSER  ArmPmuNodeParser[] = {

+  { L"Length",   2, 0,  L"0x%x",  NULL, (VOID **), 
NULL, NULL },

+  { L"Node flags",   1, 2,  L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Node type",1, 3,  L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Identifier",   4, 4,  L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Node Instance primary",8, 8,  L"0x%lx", NULL, NULL, 
NULL, NULL },

+  { L"Node Instance secondary",  4, 16, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Base address 0",   8, 20, L"0x%lx", NULL, NULL, 
NULL, NULL },

+  { L"Base address 1",   8, 28, L"0x%lx", NULL, NULL, 
NULL, NULL },

+  { L"Overflow interrupt",   4, 36, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Reserved1",4, 40, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Overflow interrupt flags", 4, 44, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Processor affinity",   4, 48, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Implementation ID",4, 52, L"0x%x",  NULL, NULL, 
NULL, NULL }

+};

+

+/**

+  This function parses the ACPI APMT table.

+  When trace is enabled this function parses the APMT table and

+  traces the ACPI table fields.

+

+  This function also performs validation of the ACPI table fields.

+

+  @param [in] Trace  If TRUE, trace the ACPI fields.

+  @param [in] PtrPointer to the start of the buffer.

+  @param [in] AcpiTableLengthLength of the ACPI table.

+  @param [in] AcpiTableRevision  Revision of the ACPI table.

+**/

+VOID

+EFIAPI

+ParseAcpiApmt (

+  IN BOOLEAN  Trace,

+  IN UINT8*Ptr,

+  IN UINT32   AcpiTableLength,

+  IN UINT8AcpiTableRevision

+  )

+{

+  UINT32  Offset;

+

+  if (!Trace) {

+return;

+  }

+

+  ParseAcpi (

+Trace,

+0,

+"APMT",

+Ptr,

+AcpiTableLength,

+PARSER_PARAMS (ApmtParser)

+);

+  

[edk2-devel] [PATCH 1/2] MdePkg/IndustryStandard: add definitions for ACPI APMT

2022-10-27 Thread Jeff Brasen via groups.io
This adds #defines and struct typedefs for the various node types in

the  ACPI Arm Performance Monitoring Unit (APMT) table.



Signed-off-by: Jeff Brasen 

---

 MdePkg/Include/IndustryStandard/Acpi64.h  |  5 ++

 .../ArmPerformanceMonitoringUnitTable.h   | 69 +++

 2 files changed, 74 insertions(+)

 create mode 100644 
MdePkg/Include/IndustryStandard/ArmPerformanceMonitoringUnitTable.h



diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h 
b/MdePkg/Include/IndustryStandard/Acpi64.h

index fe5ebfac2b..575ca0430c 100644

--- a/MdePkg/Include/IndustryStandard/Acpi64.h

+++ b/MdePkg/Include/IndustryStandard/Acpi64.h

@@ -2847,6 +2847,11 @@ typedef struct {

 ///

 #define EFI_ACPI_6_4_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE  
SIGNATURE_32('A', 'P', 'I', 'C')

 

+///

+/// "APMT" Arm Performance Monitoring Unit Table

+///

+#define EFI_ACPI_6_4_ARM_PERFORMANCE_MONITORING_UNIT_TABLE_SIGNATURE  
SIGNATURE_32('A', 'P', 'M', 'T')

+

 ///

 /// "BERT" Boot Error Record Table

 ///

diff --git 
a/MdePkg/Include/IndustryStandard/ArmPerformanceMonitoringUnitTable.h 
b/MdePkg/Include/IndustryStandard/ArmPerformanceMonitoringUnitTable.h

new file mode 100644

index 00..fe7084cffd

--- /dev/null

+++ b/MdePkg/Include/IndustryStandard/ArmPerformanceMonitoringUnitTable.h

@@ -0,0 +1,69 @@

+/** @file

+  ACPI Arm Performance Monitoring Unit (APMT) table

+  as specified in ARM spec DEN0117

+

+  Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.

+  Copyright (c) 2022, ARM Limited. All rights reserved.

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

+**/

+

+#ifndef ARM_PERFORMANCE_MONITORING_UNIT_TABLE_H_

+#define ARM_PERFORMANCE_MONITORING_UNIT_TABLE_H_

+

+#include 

+

+#pragma pack(1)

+

+///

+/// Arm Performance Monitoring Unit (APMT) tabl

+///

+typedef struct {

+  EFI_ACPI_DESCRIPTION_HEADERHeader;

+} EFI_ACPI_ARM_PERFORMANCE_MONITORING_UNIT_TABLE_HEADER;

+

+///

+/// APMT Revision (as defined in DEN0117.)

+///

+#define EFI_ACPI_ARM_PERFORMANCE_MONITORING_UNIT_TABLE_REVISION  0x00

+

+///

+/// Arm PMU Node Structure

+///

+

+// Node Flags

+#define EFI_ACPI_APMT_DUAL_PAGE_EXTENSION_SUPPORTED  BIT0

+#define EFI_ACPI_APMT_PROCESSOR_AFFINITY_TYPE_CONTAINER  BIT1

+#define EFI_ACPI_APMT_PROCESSOR_AFFINITY_TYPE_PROCESSOR  0 // BIT 1

+#define EFI_ACPI_APMT_64BIT_SINGLE_COPY_ATOMICITY_SUPPORTED  BIT2

+

+// Interrupt Flags

+#define EFI_ACPI_APMT_INTERRUPT_MODE_EDGE_TRIGGERED   BIT0

+#define EFI_ACPI_APMT_INTERRUPT_MODE_LEVEL_TRIGGERED  0 // BIT 0

+#define EFI_ACPI_APMT_INTERRUPT_TYPE_WIRED0 // BIT 1

+

+// Node Type

+#define EFI_ACPI_APMT_NODE_TYPE_MEMORY_CONTROLLER  0x00

+#define EFI_ACPI_APMT_NODE_TYPE_SMMU   0x01

+#define EFI_ACPI_APMT_NODE_TYPE_PCIE_ROOT_COMPLEX  0x02

+#define EFI_ACPI_APMT_NODE_TYPE_ACPI_DEVICE0x03

+#define EFI_ACPI_APMT_NODE_TYPE_CPU_CACHE  0x04

+

+typedef struct {

+  UINT16Length;

+  UINT8 NodeFlags;

+  UINT8 NodeType;

+  UINT32Identifier;

+  UINT64NodeInstancePrimary;

+  UINT32NodeInstanceSecondary;

+  UINT64BaseAddress0;

+  UINT64BaseAddress1;

+  UINT32OverflowInterrupt;

+  UINT32Reserved1;

+  UINT32OverflowInterruptFlags;

+  UINT32ProcessorAffinity;

+  UINT32ImplementationId;

+} EFI_ACPI_ARM_PERFORMANCE_MONITORING_UNIT_NODE;

+

+#pragma pack()

+

+#endif

-- 

2.25.1





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




[edk2-devel] [PATCH 2/2] ShellPkg/AcpiView: APMT Parser

2022-10-27 Thread Jeff Brasen via groups.io
Add a new parser for the Arm Performance Monitoring Unit Table.

The APMT table describes the properties of PMU support

implemented by components in an Arm-based system.



Signed-off-by: Jeff Brasen 

---

 .../UefiShellAcpiViewCommandLib/AcpiParser.h  |  21 

 .../Parsers/Apmt/ApmtParser.c | 105 ++

 .../UefiShellAcpiViewCommandLib.c |   1 +

 .../UefiShellAcpiViewCommandLib.inf   |   1 +

 4 files changed, 128 insertions(+)

 create mode 100644 
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c



diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

index db8c88f6df..6a1de4e12b 100644

--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

@@ -531,6 +531,27 @@ ParseAcpiAest (

   IN UINT8AcpiTableRevision

   );

 

+/**

+  This function parses the ACPI APMT table.

+  When trace is enabled this function parses the APMT table and

+  traces the ACPI table fields.

+

+  This function also performs validation of the ACPI table fields.

+

+  @param [in] Trace  If TRUE, trace the ACPI fields.

+  @param [in] PtrPointer to the start of the buffer.

+  @param [in] AcpiTableLengthLength of the ACPI table.

+  @param [in] AcpiTableRevision  Revision of the ACPI table.

+**/

+VOID

+EFIAPI

+ParseAcpiApmt (

+  IN BOOLEAN  Trace,

+  IN UINT8*Ptr,

+  IN UINT32   AcpiTableLength,

+  IN UINT8AcpiTableRevision

+  );

+

 /**

   This function parses the ACPI BGRT table.

   When trace is enabled this function parses the BGRT table and

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c

new file mode 100644

index 00..b036cd12d3

--- /dev/null

+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c

@@ -0,0 +1,105 @@

+/** @file

+  APMT table parser

+

+  Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.

+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.

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

+

+  @par Reference(s):

+- ACPI 6.2 Specification - Errata A, September 2017

+**/

+

+#include 

+#include 

+#include 

+#include "AcpiParser.h"

+#include "AcpiTableParser.h"

+

+// Local variables

+STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;

+STATIC CONST UINT16  *NodeLength;

+

+/**

+  An ACPI_PARSER array describing the ACPI APMT Table.

+**/

+STATIC CONST ACPI_PARSER  ApmtParser[] = {

+  PARSE_ACPI_HEADER ()

+};

+

+/**

+  An ACPI_PARSER array describing the ACPI Arm PMU Node.

+**/

+STATIC CONST ACPI_PARSER  ArmPmuNodeParser[] = {

+  { L"Length",   2, 0,  L"0x%x",  NULL, (VOID **), 
NULL, NULL },

+  { L"Node flags",   1, 2,  L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Node type",1, 3,  L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Identifier",   4, 4,  L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Node Instance primary",8, 8,  L"0x%lx", NULL, NULL, 
NULL, NULL },

+  { L"Node Instance secondary",  4, 16, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Base address 0",   8, 20, L"0x%lx", NULL, NULL, 
NULL, NULL },

+  { L"Base address 1",   8, 28, L"0x%lx", NULL, NULL, 
NULL, NULL },

+  { L"Overflow interrupt",   4, 36, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Reserved1",4, 40, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Overflow interrupt flags", 4, 44, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Processor affinity",   4, 48, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Implementation ID",4, 52, L"0x%x",  NULL, NULL, 
NULL, NULL }

+};

+

+/**

+  This function parses the ACPI APMT table.

+  When trace is enabled this function parses the APMT table and

+  traces the ACPI table fields.

+

+  This function also performs validation of the ACPI table fields.

+

+  @param [in] Trace  If TRUE, trace the ACPI fields.

+  @param [in] PtrPointer to the start of the buffer.

+  @param [in] AcpiTableLengthLength of the ACPI table.

+  @param [in] AcpiTableRevision  Revision of the ACPI table.

+**/

+VOID

+EFIAPI

+ParseAcpiApmt (

+  IN BOOLEAN  Trace,

+  IN UINT8*Ptr,

+  IN UINT32   AcpiTableLength,

+  IN UINT8AcpiTableRevision

+  )

+{

+  UINT32  Offset;

+

+  if (!Trace) {

+return;

+  }

+

+  ParseAcpi (

+Trace,

+0,

+"APMT",

+Ptr,

+AcpiTableLength,

+PARSER_PARAMS (ApmtParser)

+);

+  Offset = sizeof (EFI_ACPI_DESCRIPTION_HEADER);

+

+  while 

[edk2-devel] [PATCH v2] MdeModulePkg/UefiBootManagerLib: Add Disk Info support for Ufs

2022-10-06 Thread Jeff Brasen via groups.io
Add support for getting disk info from UFS devices.

Signed-off-by: Jeff Brasen 
---
 MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c   | 4 +++-
 .../Library/UefiBootManagerLib/UefiBootManagerLib.inf | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
index fac33b9ee9..030b2ee3ec 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
@@ -195,7 +195,9 @@ BmGetDescriptionFromDiskInfo (
 
   BmEliminateExtraSpaces (Description);
 }
-  } else if (CompareGuid (>Interface, 
)) {
+  } else if (CompareGuid (>Interface, 
) ||
+ CompareGuid (>Interface, ))
+  {
 BufferSize = sizeof (EFI_SCSI_INQUIRY_DATA);
 Status = DiskInfo->Inquiry (
  DiskInfo,
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf 
b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
index fe05d5f1cc..2fc0a80a4e 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
+++ b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
@@ -85,6 +85,7 @@
   gEfiDiskInfoIdeInterfaceGuid  ## SOMETIMES_CONSUMES ## GUID
   gEfiDiskInfoScsiInterfaceGuid ## SOMETIMES_CONSUMES ## GUID
   gEfiDiskInfoSdMmcInterfaceGuid## SOMETIMES_CONSUMES ## GUID
+  gEfiDiskInfoUfsInterfaceGuid  ## SOMETIMES_CONSUMES ## GUID
 
 [Protocols]
   gEfiPciRootBridgeIoProtocolGuid   ## CONSUMES
-- 
2.25.1



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




Re: [edk2-devel] [PATCH] MdeModulePkg/UefiBootManagerLib: Add Disk Info support for Ufs

2022-10-06 Thread Jeff Brasen via groups.io
Any additional thoughts on this patch?

> -Original Message-
> From: Jeff Brasen
> Sent: Tuesday, July 19, 2022 9:14 AM
> To: gaoliming ; devel@edk2.groups.io
> Cc: jian.j.w...@intel.com; zhichao@intel.com; ray...@intel.com
> Subject: RE: [edk2-devel] [PATCH] MdeModulePkg/UefiBootManagerLib:
> Add Disk Info support for Ufs
> 
> Yes, Universal Flash Storage is based on the SCSI architectural model and
> installs gEfiExtScsiPassThruProtocolGuid to function.
> 
> Thanks,
> Jeff
> 
> > -Original Message-
> > From: gaoliming 
> > Sent: Monday, July 18, 2022 7:44 PM
> > To: devel@edk2.groups.io; Jeff Brasen 
> > Cc: jian.j.w...@intel.com; zhichao@intel.com; ray...@intel.com
> > Subject: 回复: [edk2-devel] [PATCH]
> MdeModulePkg/UefiBootManagerLib:
> > Add Disk Info support for Ufs
> >
> > External email: Use caution opening links or attachments
> >
> >
> > Jeff:
> >   I want to confirm why UFS apply the same rule to SCSI. Does UFS
> > follows SCSI spec?
> >
> > Thanks
> > Liming
> > > -邮件原件-
> > > 发件人: devel@edk2.groups.io  代表 Jeff
> Brasen
> > via
> > > groups.io
> > > 发送时间: 2022年6月15日 1:54
> > > 收件人: devel@edk2.groups.io
> > > 抄送: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> > > zhichao@intel.com; ray...@intel.com; Jeff Brasen
> > > 
> > > 主题: [edk2-devel] [PATCH] MdeModulePkg/UefiBootManagerLib: Add
> > Disk
> > > Info support for Ufs
> > >
> > > Add support for getting disk info from UFS devices.
> > >
> > > Signed-off-by: Jeff Brasen 
> > > ---
> > >  MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c| 3
> > > ++-
> > >  MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf |
> 1
> > +
> > >  2 files changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git
> > > a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> > > b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> > > index fac33b9ee9..87b82f299f 100644
> > > --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> > > +++
> b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> > > @@ -195,7 +195,8 @@ BmGetDescriptionFromDiskInfo (
> > >
> > >
> > >BmEliminateExtraSpaces (Description);
> > >
> > >  }
> > >
> > > -  } else if (CompareGuid (>Interface,
> > > )) {
> > >
> > > +  } else if (CompareGuid (>Interface,
> > > ) ||
> > >
> > > + CompareGuid (>Interface,
> > > )) {
> > >
> > >  BufferSize = sizeof (EFI_SCSI_INQUIRY_DATA);
> > >
> > >  Status = DiskInfo->Inquiry (
> > >
> > >   DiskInfo,
> > >
> > > diff --git
> > > a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> > > b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> > > index fe05d5f1cc..2fc0a80a4e 100644
> > > ---
> > a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> > > +++
> > b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> > > @@ -85,6 +85,7 @@
> > >gEfiDiskInfoIdeInterfaceGuid  ##
> > > SOMETIMES_CONSUMES ## GUID
> > >
> > >gEfiDiskInfoScsiInterfaceGuid ##
> > > SOMETIMES_CONSUMES ## GUID
> > >
> > >gEfiDiskInfoSdMmcInterfaceGuid##
> > > SOMETIMES_CONSUMES ## GUID
> > >
> > > +  gEfiDiskInfoUfsInterfaceGuid  ##
> > > SOMETIMES_CONSUMES ## GUID
> > >
> > >
> > >
> > >  [Protocols]
> > >
> > >gEfiPciRootBridgeIoProtocolGuid   ## CONSUMES
> > >
> > > --
> > > 2.25.1
> > >
> > >
> > >
> > > 
> > >
> > >
> >
> >



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




Re: [edk2-devel] [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer

2022-09-29 Thread Jeff Brasen via groups.io
MdeModulePkg maintainers, Any comments on this?

> -Original Message-
> From: Ard Biesheuvel 
> Sent: Wednesday, September 21, 2022 10:32 AM
> To: devel@edk2.groups.io; Jeff Brasen 
> Cc: hao.a...@intel.com; ray...@intel.com; quic_llind...@quicinc.com;
> ardb+tianoc...@kernel.org
> Subject: Re: [edk2-devel] [PATCH v2]
> MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer
> 
> External email: Use caution opening links or attachments
> 
> 
> On Wed, 21 Sept 2022 at 18:27, Jeff Brasen via groups.io
>  wrote:
> >
> > Anything else needed to get this merged?
> >
> 
> That is up to the MdeModulePkg maintainers.
> 
> > > -Original Message-
> > > From: Ard Biesheuvel 
> > > Sent: Thursday, September 8, 2022 9:55 AM
> > > To: Jeff Brasen 
> > > Cc: devel@edk2.groups.io; hao.a...@intel.com; ray...@intel.com;
> > > quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> > > Subject: Re: [edk2-devel] [PATCH v2]
> > > MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > On Thu, 8 Sept 2022 at 17:39, Jeff Brasen  wrote:
> > > >
> > > >
> > > >
> > > > > -Original Message-
> > > > > From: Ard Biesheuvel 
> > > > > Sent: Monday, August 15, 2022 8:42 AM
> > > > > To: devel@edk2.groups.io; Jeff Brasen 
> > > > > Cc: hao.a...@intel.com; ray...@intel.com;
> > > > > quic_llind...@quicinc.com;
> > > > > ardb+tianoc...@kernel.org
> > > > > Subject: Re: [edk2-devel] [PATCH v2]
> > > > > MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial
> > > > > FreeBuffer
> > > > >
> > > > > External email: Use caution opening links or attachments
> > > > >
> > > > >
> > > > > On Fri, 5 Aug 2022 at 18:56, Jeff Brasen via groups.io
> > > > >  wrote:
> > > > > >
> > > > > >
> > > > > >
> > > > > > > -Original Message-
> > > > > > > From: Ard Biesheuvel 
> > > > > > > Sent: Tuesday, August 2, 2022 10:51 AM
> > > > > > > To: Jeff Brasen 
> > > > > > > Cc: devel@edk2.groups.io; hao.a...@intel.com;
> > > > > > > ray...@intel.com; quic_llind...@quicinc.com;
> > > > > > > ardb+tianoc...@kernel.org
> > > > > > > Subject: Re: [PATCH v2]
> MdeModulePkg/NonDiscoverablePciDeviceDxe:
> > > > > > > Allow partial FreeBuffer
> > > > > > >
> > > > > > > External email: Use caution opening links or attachments
> > > > > > >
> > > > > > >
> > > > > > > On Tue, 2 Aug 2022 at 17:32, Jeff Brasen 
> wrote:
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > > -Original Message-
> > > > > > > > > From: Ard Biesheuvel 
> > > > > > > > > Sent: Friday, July 29, 2022 9:48 AM
> > > > > > > > > To: Jeff Brasen 
> > > > > > > > > Cc: devel@edk2.groups.io; hao.a...@intel.com;
> > > > > > > > > ray...@intel.com; quic_llind...@quicinc.com;
> > > > > > > > > ardb+tianoc...@kernel.org
> > > > > > > > > Subject: Re: [PATCH v2]
> > > MdeModulePkg/NonDiscoverablePciDeviceDxe:
> > > > > > > > > Allow partial FreeBuffer
> > > > > > > > >
> > > > > > > > > External email: Use caution opening links or attachments
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On Thu, 28 Jul 2022 at 13:25, Jeff Brasen
> > > > > > > > > 
> > > wrote:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Adding Leif/Ard to CC incase they have any comments on
> this patch.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > This generally looks ok to me. I just wonder if it
> > > > > > > > > wouldn't be simpler

Re: [edk2-devel] [PATCH v5 0/3] DynamicTablesPkg: _CPC support

2022-09-23 Thread Jeff Brasen via groups.io
Those changes look good to me.

Thanks,
Jeff

> -Original Message-
> From: Sami Mujawar 
> Sent: Friday, September 23, 2022 10:55 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: ardb+tianoc...@kernel.org; alexei.fedo...@arm.com;
> pierre.gond...@arm.com; n...@arm.com
> Subject: Re: [PATCH v5 0/3] DynamicTablesPkg: _CPC support
> 
> External email: Use caution opening links or attachments
> 
> 
> Hi Jeff,
> 
> Thank you for the updated patch series.
> 
> I have made some minor changes:
> 
> 1. Move DynamicTablesPkg/Include/Library/AmlCpcInfo.h to
> DynamicTablesPkg/Include/AmlCpcInfo.h to stop edk2 CI from complaining.
> 
> 2. Minor update to the documentation for CpcToken in
> CM_ARM_GICC_INFO.
> 
> I have scheduled a pull request
> (https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> ub.com%2Fsamimujawar%2Fedk2%2Fpull%2Fnew%2FREVIEW_2369_dynami
> c_cpc_support_v5data=05%7C01%7Cjbrasen%40nvidia.com%7Cfa438c
> 463975467b580908da9d84760a%7C43083d15727340c1b7db39efd9ccc17a%7C0
> %7C0%7C637995489497585332%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC
> 4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%
> 7C%7C%7Csdata=hwqiwMp1xW4hu1uTcJMiHhCpMnHCYh6jjmRDi1allx
> Q%3Dreserved=0)
> for checking that edk2 CI is happy with the changes.
> 
> Please let me know if you are ok with the above changes, and I will push
> these changes.
> 
> For this series:
> 
> Reviewed-by: Sami Mujawar 
> 
> Regards,
> 
> Sami Mujawar
> 
> On 22/09/2022 09:36 pm, Jeff Brasen wrote:
> > Add generator for creating the _CPC object for CPU nodes.
> >
> > If viewing this review by a pull request is helpful one exists here:
> >
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> >
> ub.com%2FNVIDIA%2Fedk2%2Fpull%2F12data=05%7C01%7Cjbrasen%
> 40nvidia
> >
> .com%7Cfa438c463975467b580908da9d84760a%7C43083d15727340c1b7db39
> efd9cc
> >
> c17a%7C0%7C0%7C637995489497585332%7CUnknown%7CTWFpbGZsb3d8ey
> JWIjoiMC4w
> >
> LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C
> %7C%7C
> >
> sdata=7gI38kSJx1GjNPVikW1UX8nT8D2KIADcyta8MM4TI5c%3D
> reserved
> > =0
> >
> > Change Log:
> > v1 - Initial Revision
> > v2 - Added revision to object, improved error handling, changed to ACPI 6.4
> structures.
> > v3 - Minor review feedback
> > v4 - Convert CpcInfo to structure and use that for APIs
> > v5 - Cleanup parameter checks, add token to parser
> >
> > Jeff Brasen (3):
> >DynamicTablesPkg: Add CM_ARM_CPC_INFO object
> >DynamicTablesPkg: AML Code generation to add _CPC entries
> >DynamicTablesPkg: SSDT CPU _CPC generator
> >
> >   .../Include/ArmNameSpaceObjects.h |  60 ++-
> >   DynamicTablesPkg/Include/Library/AmlCpcInfo.h | 124 +
> >   .../Include/Library/AmlLib/AmlLib.h   |  54 ++
> >   .../SsdtCpuTopologyGenerator.c| 133 -
> >   .../Common/AmlLib/CodeGen/AmlCodeGen.c| 475
> ++
> >   .../ConfigurationManagerObjectParser.c| 115 -
> >   6 files changed, 921 insertions(+), 40 deletions(-)
> >   create mode 100644 DynamicTablesPkg/Include/Library/AmlCpcInfo.h
> >


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




[edk2-devel] [PATCH v3] EmbeddedPkg/PrePiMemoryAllocationLib: Add check for space on offset allocation

2022-09-23 Thread Jeff Brasen via groups.io
Update check for enough space to occur prior to alignment offset.

This prevents cases where EfiFreeMemoryTop < EfiFreeMemoryBottom.



Signed-off-by: Jeff Brasen 

---

 .../MemoryAllocationLib.c | 48 ---

 1 file changed, 21 insertions(+), 27 deletions(-)



diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c 
b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

index 2cc2a71121..08a0add340 100644

--- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

+++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

@@ -23,41 +23,35 @@ InternalAllocatePages (

   )

 {

   EFI_PEI_HOB_POINTERS  Hob;

-  EFI_PHYSICAL_ADDRESS  Offset;

+  EFI_PHYSICAL_ADDRESS  NewTop;

 

   Hob.Raw = GetHobList ();

 

-  // Check to see if on 4k boundary

-  Offset = Hob.HandoffInformationTable->EfiFreeMemoryTop & 0xFFF;

-  if (Offset != 0) {

-// If not aligned, make the allocation aligned.

-Hob.HandoffInformationTable->EfiFreeMemoryTop -= Offset;

-  }

+  NewTop  = Hob.HandoffInformationTable->EfiFreeMemoryTop & 
~(EFI_PHYSICAL_ADDRESS)EFI_PAGE_MASK;

+  NewTop -= Pages * EFI_PAGE_SIZE;

 

   //

   // Verify that there is sufficient memory to satisfy the allocation

   //

-  if (Hob.HandoffInformationTable->EfiFreeMemoryTop - ((Pages * EFI_PAGE_SIZE) 
+ sizeof (EFI_HOB_MEMORY_ALLOCATION)) < 
Hob.HandoffInformationTable->EfiFreeMemoryBottom) {

-return 0;

-  } else {

-//

-// Update the PHIT to reflect the memory usage

-//

-Hob.HandoffInformationTable->EfiFreeMemoryTop -= Pages * EFI_PAGE_SIZE;

-

-// This routine used to create a memory allocation HOB a la PEI, but 
that's not

-// necessary for us.

-

-//

-// Create a memory allocation HOB.

-//

-BuildMemoryAllocationHob (

-  Hob.HandoffInformationTable->EfiFreeMemoryTop,

-  Pages * EFI_PAGE_SIZE,

-  MemoryType

-  );

-return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;

+  if (NewTop < (Hob.HandoffInformationTable->EfiFreeMemoryBottom + sizeof 
(EFI_HOB_MEMORY_ALLOCATION))) {

+return NULL;

   }

+

+  //

+  // Update the PHIT to reflect the memory usage

+  //

+  Hob.HandoffInformationTable->EfiFreeMemoryTop = NewTop;

+

+  //

+  // Create a memory allocation HOB.

+  //

+  BuildMemoryAllocationHob (

+Hob.HandoffInformationTable->EfiFreeMemoryTop,

+Pages * EFI_PAGE_SIZE,

+MemoryType

+);

+

+  return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;

 }

 

 /**

-- 

2.25.1





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




[edk2-devel] [PATCH v3] EmbeddedPkg/PrePiMemoryAllocationLib: Add check for space on offset allocation

2022-09-22 Thread Jeff Brasen via groups.io
Update check for enough space to occur prior to alignment offset.

This prevents cases where EfiFreeMemoryTop < EfiFreeMemoryBottom.



Change-Id: I58c5d378523c881a4afc655e7ace4c009130c781

---

 .../MemoryAllocationLib.c | 48 ---

 1 file changed, 21 insertions(+), 27 deletions(-)



diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c 
b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

index 2cc2a71121..08a0add340 100644

--- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

+++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

@@ -23,41 +23,35 @@ InternalAllocatePages (

   )

 {

   EFI_PEI_HOB_POINTERS  Hob;

-  EFI_PHYSICAL_ADDRESS  Offset;

+  EFI_PHYSICAL_ADDRESS  NewTop;

 

   Hob.Raw = GetHobList ();

 

-  // Check to see if on 4k boundary

-  Offset = Hob.HandoffInformationTable->EfiFreeMemoryTop & 0xFFF;

-  if (Offset != 0) {

-// If not aligned, make the allocation aligned.

-Hob.HandoffInformationTable->EfiFreeMemoryTop -= Offset;

-  }

+  NewTop  = Hob.HandoffInformationTable->EfiFreeMemoryTop & 
~(EFI_PHYSICAL_ADDRESS)EFI_PAGE_MASK;

+  NewTop -= Pages * EFI_PAGE_SIZE;

 

   //

   // Verify that there is sufficient memory to satisfy the allocation

   //

-  if (Hob.HandoffInformationTable->EfiFreeMemoryTop - ((Pages * EFI_PAGE_SIZE) 
+ sizeof (EFI_HOB_MEMORY_ALLOCATION)) < 
Hob.HandoffInformationTable->EfiFreeMemoryBottom) {

-return 0;

-  } else {

-//

-// Update the PHIT to reflect the memory usage

-//

-Hob.HandoffInformationTable->EfiFreeMemoryTop -= Pages * EFI_PAGE_SIZE;

-

-// This routine used to create a memory allocation HOB a la PEI, but 
that's not

-// necessary for us.

-

-//

-// Create a memory allocation HOB.

-//

-BuildMemoryAllocationHob (

-  Hob.HandoffInformationTable->EfiFreeMemoryTop,

-  Pages * EFI_PAGE_SIZE,

-  MemoryType

-  );

-return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;

+  if (NewTop < (Hob.HandoffInformationTable->EfiFreeMemoryBottom + sizeof 
(EFI_HOB_MEMORY_ALLOCATION))) {

+return NULL;

   }

+

+  //

+  // Update the PHIT to reflect the memory usage

+  //

+  Hob.HandoffInformationTable->EfiFreeMemoryTop = NewTop;

+

+  //

+  // Create a memory allocation HOB.

+  //

+  BuildMemoryAllocationHob (

+Hob.HandoffInformationTable->EfiFreeMemoryTop,

+Pages * EFI_PAGE_SIZE,

+MemoryType

+);

+

+  return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;

 }

 

 /**

-- 

2.25.1





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




[edk2-devel] [PATCH v5 2/3] DynamicTablesPkg: AML Code generation to add _CPC entries

2022-09-22 Thread Jeff Brasen via groups.io
_CPC entries can describe CPU performance information.

The object is described in ACPI 6.4 s8.4.7.1.

"_CPC (Continuous Performance Control)".



Add AmlCreateCpcNode() helper function to add _CPC entries to an

existing CPU object.



Signed-off-by: Jeff Brasen 

---

 .../Include/Library/AmlLib/AmlLib.h   |  54 ++

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 475 ++

 2 files changed, 529 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index 39968660f2..ebaccba811 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -37,6 +37,7 @@

 */

 

 #include 

+#include 

 

 #ifndef AML_HANDLE

 

@@ -1336,6 +1337,59 @@ AmlAddNameIntegerPackage (

   IN AML_OBJECT_NODE_HANDLE  PackageNode

   );

 

+/** Create a _CPC node.

+

+  Creates and optionally adds the following node

+   Name(_CPC, Package()

+   {

+NumEntries,  // Integer

+Revision,// Integer

+HighestPerformance,  // Integer or Buffer (Resource 
Descriptor)

+NominalPerformance,  // Integer or Buffer (Resource 
Descriptor)

+LowestNonlinearPerformance,  // Integer or Buffer (Resource 
Descriptor)

+LowestPerformance,   // Integer or Buffer (Resource 
Descriptor)

+GuaranteedPerformanceRegister,   // Buffer (Resource Descriptor)

+DesiredPerformanceRegister , // Buffer (Resource Descriptor)

+MinimumPerformanceRegister , // Buffer (Resource Descriptor)

+MaximumPerformanceRegister , // Buffer (Resource Descriptor)

+PerformanceReductionToleranceRegister,   // Buffer (Resource Descriptor)

+TimeWindowRegister,  // Buffer (Resource Descriptor)

+CounterWraparoundTime,   // Integer or Buffer (Resource 
Descriptor)

+ReferencePerformanceCounterRegister, // Buffer (Resource Descriptor)

+DeliveredPerformanceCounterRegister, // Buffer (Resource Descriptor)

+PerformanceLimitedRegister,  // Buffer (Resource Descriptor)

+CPPCEnableRegister   // Buffer (Resource Descriptor)

+AutonomousSelectionEnable,   // Integer or Buffer (Resource 
Descriptor)

+AutonomousActivityWindowRegister,// Buffer (Resource Descriptor)

+EnergyPerformancePreferenceRegister, // Buffer (Resource Descriptor)

+ReferencePerformance // Integer or Buffer (Resource 
Descriptor)

+LowestFrequency, // Integer or Buffer (Resource 
Descriptor)

+NominalFrequency // Integer or Buffer (Resource 
Descriptor)

+  })

+

+  If resource buffer is NULL then integer will be used.

+

+  Cf. ACPI 6.4, s8.4.7.1 _CPC (Continuous Performance Control)

+

+  @ingroup CodeGenApis

+

+  @param [in]  CpcInfo   CpcInfo object

+  @param [in]  ParentNodeIf provided, set ParentNode as the parent

+ of the node created.

+  @param [out] NewCpcNodeIf success and provided, contains the 
created node.

+

+  @retval EFI_SUCCESS The function completed successfully.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCreateCpcNode (

+  IN  AML_CPC_INFO*CpcInfo,

+  IN  AML_NODE_HANDLE ParentNode   OPTIONAL,

+  OUT AML_OBJECT_NODE_HANDLE  *NewCpcNode   OPTIONAL

+  );

+

 // DEPRECATED APIS

 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES

 

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index 5fb39d077b..4dc810c034 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -14,6 +14,7 @@

 #include 

 #include 

 #include 

+#include 

 #include 

 #include 

 #include 

@@ -2850,3 +2851,477 @@ error_handler:

 

   return Status;

 }

+

+/** Adds a register to the package

+

+  @ingroup CodeGenApis

+

+  @param [in]  Register If provided, register that will be added to 
package.

+otherwise NULL register will be added

+  @param [in]  PackageNode  Package to add value to

+

+  @retval EFI_SUCCESS The function completed successfully.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+AmlAddRegisterToPackage (

+  IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  *Register OPTIONAL,

+  IN AML_OBJECT_NODE_HANDLE  PackageNode

+  )

+{

+  EFI_STATUS  Status;

+  

[edk2-devel] [PATCH v5 3/3] DynamicTablesPkg: SSDT CPU _CPC generator

2022-09-22 Thread Jeff Brasen via groups.io
Add code to use a token attached to GICC to generate _CPC object on cpus.



Signed-off-by: Jeff Brasen 

---

 .../SsdtCpuTopologyGenerator.c| 133 +-

 1 file changed, 127 insertions(+), 6 deletions(-)



diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

index 8561f48e1f..22422aef75 100644

--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

@@ -76,6 +76,16 @@ GET_OBJECT_LIST (

   CM_ARM_LPI_INFO

   );

 

+/**

+  This macro expands to a function that retrieves the CPC

+  information from the Configuration Manager.

+*/

+GET_OBJECT_LIST (

+  EObjNameSpaceArm,

+  EArmObjCpcInfo,

+  CM_ARM_CPC_INFO

+  );

+

 /** Initialize the TokenTable.

 

   One entry should be allocated for each CM_ARM_PROC_HIERARCHY_INFO

@@ -229,6 +239,93 @@ WriteAslName (

   return EFI_SUCCESS;

 }

 

+/** Create and add an _CPC Node to Cpu Node.

+

+  For instance, transform an AML node from:

+  Device (C002)

+  {

+  Name (_UID, 2)

+  Name (_HID, "ACPI0007")

+  }

+

+  To:

+  Device (C002)

+  {

+  Name (_UID, 2)

+  Name (_HID, "ACPI0007")

+  Name(_CPC, Package()

+  {

+NumEntries,  // Integer

+Revision,// Integer

+HighestPerformance,  // Integer or Buffer 
(Resource Descriptor)

+NominalPerformance,  // Integer or Buffer 
(Resource Descriptor)

+LowestNonlinearPerformance,  // Integer or Buffer 
(Resource Descriptor)

+LowestPerformance,   // Integer or Buffer 
(Resource Descriptor)

+GuaranteedPerformanceRegister,   // Buffer (Resource 
Descriptor)

+DesiredPerformanceRegister , // Buffer (Resource 
Descriptor)

+MinimumPerformanceRegister , // Buffer (Resource 
Descriptor)

+MaximumPerformanceRegister , // Buffer (Resource 
Descriptor)

+PerformanceReductionToleranceRegister,   // Buffer (Resource 
Descriptor)

+TimeWindowRegister,  // Buffer (Resource 
Descriptor)

+CounterWraparoundTime,   // Integer or Buffer 
(Resource Descriptor)

+ReferencePerformanceCounterRegister, // Buffer (Resource 
Descriptor)

+DeliveredPerformanceCounterRegister, // Buffer (Resource 
Descriptor)

+PerformanceLimitedRegister,  // Buffer (Resource 
Descriptor)

+CPPCEnableRegister   // Buffer (Resource 
Descriptor)

+AutonomousSelectionEnable,   // Integer or Buffer 
(Resource Descriptor)

+AutonomousActivityWindowRegister,// Buffer (Resource 
Descriptor)

+EnergyPerformancePreferenceRegister, // Buffer (Resource 
Descriptor)

+ReferencePerformance // Integer or Buffer 
(Resource Descriptor)

+LowestFrequency, // Integer or Buffer 
(Resource Descriptor)

+NominalFrequency // Integer or Buffer 
(Resource Descriptor)

+  })

+  }

+

+  @param [in]  Generator  The SSDT Cpu Topology generator.

+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager

+  Protocol Interface.

+  @param [in]  ProcHierarchyNodeInfo  CM_ARM_PROC_HIERARCHY_INFO describing

+  the Cpu.

+  @param [in]  Node   CPU Node to which the _CPC node is

+  attached.

+

+  @retval EFI_SUCCESS The function completed successfully.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+CreateAmlCpcNode (

+  IN  ACPI_CPU_TOPOLOGY_GENERATOR *Generator,

+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  INCM_ARM_GICC_INFO  *GicCInfo,

+  IN  AML_OBJECT_NODE_HANDLE  *Node

+  )

+{

+  EFI_STATUS   Status;

+  CM_ARM_CPC_INFO  *CpcInfo;

+

+  Status = GetEArmObjCpcInfo (

+ CfgMgrProtocol,

+ GicCInfo->CpcToken,

+ ,

+ NULL

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+return Status;

+  }

+

+  Status = AmlCreateCpcNode (

+ CpcInfo,

+ Node,

+ NULL

+ );

+  ASSERT_EFI_ERROR (Status);

+  return Status;

+}

+

 /** Create and add an _LPI method to Cpu/Cluster Node.

 

   For instance, transform an AML 

[edk2-devel] [PATCH v5 1/3] DynamicTablesPkg: Add CM_ARM_CPC_INFO object

2022-09-22 Thread Jeff Brasen via groups.io
Introduce the CM_ARM_CPC_INFO CmObj in the ArmNameSpaceObjects.

This allows to describe CPC information, as described in ACPI 6.4,

s8.4.7.1 "_CPC (Continuous Performance Control)".



Signed-off-by: Jeff Brasen 

---

 .../Include/ArmNameSpaceObjects.h |  60 ++---

 DynamicTablesPkg/Include/Library/AmlCpcInfo.h | 124 ++

 .../ConfigurationManagerObjectParser.c| 115 +---

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

 create mode 100644 DynamicTablesPkg/Include/Library/AmlCpcInfo.h



diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

index 102e0f96be..ea5bf81070 100644

--- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

@@ -14,6 +14,7 @@

 #define ARM_NAMESPACE_OBJECTS_H_

 

 #include 

+#include 

 

 #pragma pack(1)

 

@@ -63,6 +64,7 @@ typedef enum ArmObjectID {

   EArmObjPciInterruptMapInfo,  ///< 39 - Pci Interrupt Map Info

   EArmObjRmr,  ///< 40 - Reserved Memory Range Node

   EArmObjMemoryRangeDescriptor,///< 41 - Memory Range Descriptor

+  EArmObjCpcInfo,  ///< 42 - Continuous Performance 
Control Info

   EArmObjMax

 } EARM_OBJECT_ID;

 

@@ -97,99 +99,105 @@ typedef struct CmArmPowerManagementProfileInfo {

 */

 typedef struct CmArmGicCInfo {

   /// The GIC CPU Interface number.

-  UINT32CPUInterfaceNumber;

+  UINT32 CPUInterfaceNumber;

 

   /** The ACPI Processor UID. This must match the

   _UID of the CPU Device object information described

   in the DSDT/SSDT for the CPU.

   */

-  UINT32AcpiProcessorUid;

+  UINT32 AcpiProcessorUid;

 

   /** The flags field as described by the GICC structure

   in the ACPI Specification.

   */

-  UINT32Flags;

+  UINT32 Flags;

 

   /** The parking protocol version field as described by

 the GICC structure in the ACPI Specification.

   */

-  UINT32ParkingProtocolVersion;

+  UINT32 ParkingProtocolVersion;

 

   /** The Performance Interrupt field as described by

   the GICC structure in the ACPI Specification.

   */

-  UINT32PerformanceInterruptGsiv;

+  UINT32 PerformanceInterruptGsiv;

 

   /** The CPU Parked address field as described by

   the GICC structure in the ACPI Specification.

   */

-  UINT64ParkedAddress;

+  UINT64 ParkedAddress;

 

   /** The base address for the GIC CPU Interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64PhysicalBaseAddress;

+  UINT64 PhysicalBaseAddress;

 

   /** The base address for GICV interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICV;

+  UINT64 GICV;

 

   /** The base address for GICH interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICH;

+  UINT64 GICH;

 

   /** The GICV maintenance interrupt

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT32VGICMaintenanceInterrupt;

+  UINT32 VGICMaintenanceInterrupt;

 

   /** The base address for GICR interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICRBaseAddress;

+  UINT64 GICRBaseAddress;

 

   /** The MPIDR for the CPU

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64MPIDR;

+  UINT64 MPIDR;

 

   /** The Processor Power Efficiency class

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT8 ProcessorPowerEfficiencyClass;

+  UINT8  ProcessorPowerEfficiencyClass;

 

   /** Statistical Profiling Extension buffer overflow GSIV. Zero if

   unsupported by this processor. This field was introduced in

   ACPI 6.3 (MADT revision 5) and is therefore ignored when

   generating MADT revision 4 or lower.

   */

-  UINT16SpeOverflowInterrupt;

+  UINT16 SpeOverflowInterrupt;

 

   /** The proximity domain to which the logical processor belongs.

   This field is used to populate the GICC affinity structure

   in the SRAT table.

   */

-  UINT32ProximityDomain;

+  UINT32 ProximityDomain;

 

   /** The clock domain to which the logical processor belongs.

   This field is used to populate the GICC affinity structure

   in the SRAT table.

   */

-  UINT32ClockDomain;

+  UINT32 ClockDomain;

 

   /** The GICC Affinity flags field as described by the GICC Affinity structure

   in the SRAT table.

   */

-  UINT32AffinityFlags;

+  UINT32 AffinityFlags;

+

+  /** Optional field: Reference Token for the Cpc info of this 

[edk2-devel] [PATCH v5 0/3] DynamicTablesPkg: _CPC support

2022-09-22 Thread Jeff Brasen via groups.io
Add generator for creating the _CPC object for CPU nodes.

If viewing this review by a pull request is helpful one exists here:
https://github.com/NVIDIA/edk2/pull/12

Change Log:
v1 - Initial Revision
v2 - Added revision to object, improved error handling, changed to ACPI 6.4 
structures.
v3 - Minor review feedback
v4 - Convert CpcInfo to structure and use that for APIs
v5 - Cleanup parameter checks, add token to parser

Jeff Brasen (3):
  DynamicTablesPkg: Add CM_ARM_CPC_INFO object
  DynamicTablesPkg: AML Code generation to add _CPC entries
  DynamicTablesPkg: SSDT CPU _CPC generator

 .../Include/ArmNameSpaceObjects.h |  60 ++-
 DynamicTablesPkg/Include/Library/AmlCpcInfo.h | 124 +
 .../Include/Library/AmlLib/AmlLib.h   |  54 ++
 .../SsdtCpuTopologyGenerator.c| 133 -
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 475 ++
 .../ConfigurationManagerObjectParser.c| 115 -
 6 files changed, 921 insertions(+), 40 deletions(-)
 create mode 100644 DynamicTablesPkg/Include/Library/AmlCpcInfo.h

-- 
2.25.1



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




  1   2   3   >