[edk2-devel] [edk2-libc Patch v2 1/1] edk2-libc : add github actions workflow to build PyUEFI using VS2019

2024-06-20 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4788

This commit adds github actions workflow to build python uefi
interpreter with visual studio 2019 tool chain.
The build-python-uefi-vs.yaml file under .github/workflows
implements the build action for building the pyuefi interpreter with
VS2019 tool chain.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .github/workflows/build-python-uefi-vs.yaml | 84 +
 1 file changed, 84 insertions(+)
 create mode 100644 .github/workflows/build-python-uefi-vs.yaml

diff --git a/.github/workflows/build-python-uefi-vs.yaml 
b/.github/workflows/build-python-uefi-vs.yaml
new file mode 100644
index 000..a8393d8
--- /dev/null
+++ b/.github/workflows/build-python-uefi-vs.yaml
@@ -0,0 +1,84 @@
+# GitHub actions workflow to build python uefi using VS2019
+#
+# Copyright (c) 2023-2024, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+name: Build Python Interpreter for UEFI using VS2019
+
+on: [push, pull_request]
+
+jobs:
+  build:
+runs-on: windows-2019
+env:
+  NASM_PREFIX: "C:\\Program Files\\NASM\\"
+defaults:
+  run:
+shell: cmd
+
+steps:
+- name: Checkout repository
+  uses: actions/checkout@v4
+
+- name: Setup Python
+  uses: actions/setup-python@v5
+  with:
+python-version: '3.10'
+
+- name: Install NASM
+  run: choco install nasm
+
+- name: VSWhere
+  run: |
+"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
+
+- name: Setup environment for Visual Studio 2019 Build Tools
+  run: |
+"C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat" x86
+set
+
+- name: Clone EDK2
+  run: |
+git clone https://github.com/tianocore/edk2.git;
+cd edk2
+git submodule update --init
+
+- name: Build EDK2 Base Tools
+  run: |
+cd edk2
+dir
+edksetup.bat ForceRebuild
+
+- name: Run srcprep.py
+  run: |
+echo switching to AppPkg\Applications\Python\Python-3.6.8\
+cd AppPkg\Applications\Python\Python-3.6.8\
+dir
+echo run srcprep.py file
+python srcprep.py
+
+- name: Build Python UEFI
+  run: |
+set PACKAGES_PATH=%CD%\edk2;%CD%;
+set EDK2_LIBC_PATH=%CD%
+cd edk2
+call edksetup.bat
+build -t VS2019 -a X64 -b RELEASE -p 
%EDK2_LIBC_PATH%\AppPkg\AppPkg.dsc -D BUILD_PYTHON368
+
+- name: Create Python UEFI package
+  run: |
+set WORKSPACE=%CD%\edk2
+set EDK2_LIBC_PATH=%CD%
+dir
+call AppPkg\Applications\Python\Python-3.6.8\create_python_pkg.bat 
VS2019 RELEASE X64 myUEFIPy
+
+- name: List build artifacts
+  run: |
+dir /S edk2\myUEFIPy
+
+- name: Upload build output as artifact
+  uses: actions/upload-artifact@v4
+  with:
+name: myUEFIPy-build-VS2019-output
+path: edk2\myUEFIPy\**\*
-- 
2.45.1.windows.1



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




[edk2-devel] [edk2-libc Patch v2 0/1] add github actions workflow to build PyUEFI using VS2019

2024-06-20 Thread Jayaprakash, N
This patch adds github actions workflow to build python uefi
interpreter with visual studio 2019 tool chain.
The build-python-uefi-vs.yaml file under .github/workflows
implements the build action for building the pyuefi interpreter with
VS2019 tool chain. Please refer to BZ4788 for more details.

Jayaprakash N (1):
  edk2-libc : add github actions workflow to build PyUEFI using VS2019

 .github/workflows/build-python-uefi-vs.yaml | 84 +
 1 file changed, 84 insertions(+)
 create mode 100644 .github/workflows/build-python-uefi-vs.yaml

-- 
2.45.1.windows.1



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




[edk2-devel] [edk2-libc Patch 0/1] update build and packaging scripts to take EDK2_LIBC_PATH

2024-06-19 Thread Jayaprakash, N
This commit adds necessary changes to build and packaging scripts
to take path to edk2-libc through an environment variable.
It also updates the build and packaging instructions in
GCCCompilationBKMs.rst file and Py368ReadMe.txt files.
The Python368.inf file is also updated to take EDK2_LIBC_PATH
instead of the current WORKSPACE path in the CC flags.
Please refer to BZ4791 for more details.

Jayaprakash N (1):
  edk2-libc : update build and packaging scripts to take EDK2_LIBC_PATH

 .../Python-3.6.8/GCCCompilationBKMs.rst   | 21 +++--
 .../Python/Python-3.6.8/Py368ReadMe.txt   | 22 --
 .../Python/Python-3.6.8/Python368.inf |  6 ++---
 .../Python/Python-3.6.8/create_python_pkg.bat | 21 ++---
 .../Python/Python-3.6.8/create_python_pkg.sh  | 23 ---
 5 files changed, 75 insertions(+), 18 deletions(-)

-- 
2.45.1.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] edk2-libc : update build and packaging scripts to take EDK2_LIBC_PATH

2024-06-19 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4791

This commit adds necessary changes to build and packaging scripts
to take path to edk2-libc through an environment variable.
It also updates the build and packaging instructions in
GCCCompilationBKMs.rst file and Py368ReadMe.txt files.
The Python368.inf file is also updated to take EDK2_LIBC_PATH
instead of the current WORKSPACE path in the CC flags.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .../Python-3.6.8/GCCCompilationBKMs.rst   | 21 +++--
 .../Python/Python-3.6.8/Py368ReadMe.txt   | 22 --
 .../Python/Python-3.6.8/Python368.inf |  6 ++---
 .../Python/Python-3.6.8/create_python_pkg.bat | 21 ++---
 .../Python/Python-3.6.8/create_python_pkg.sh  | 23 ---
 5 files changed, 75 insertions(+), 18 deletions(-)

diff --git a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst 
b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
index 0574977..667b408 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
+++ b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
@@ -136,17 +136,17 @@ Now clone the edk2-libc git repo by following / executing 
the below commands::
 
 bash$ cd ~/src
 bash$ git clone https://github.com/tianocore/edk2-libc.git
-bash$ export PACKAGES_PATH=$HOME/src/edk2:$HOME/src/edk2-libc
 
+Set the PACKAGES_PATH and EDK2_LIBC_PATH using the commands below::
+
+bash$ export PACKAGES_PATH=$HOME/src/edk2:$HOME/src/edk2-libc
+bash$ export EDK2_LIBC_PATH=$HOME/src/edk2-libc
 
 Verify that you can build the hello world application from AppPkg under 
edk2-libc by running the following commands
 Build hello.inf from edk2-libc applications::
 
-$bash build -p AppPkg/AppPkg.dsc -m AppPkg/Applications/Hello/Hello.inf
-
-Copy the contents of edk2-libc to edk2 folder::
+$bash build -p ../edk2-libc/AppPkg/AppPkg.dsc -m 
../edk2-libc/AppPkg/Applications/Hello/Hello.inf
 
-bash$ cp -rf ~/src/edk2-libc/* ~/src/edk2/
 
 2.5.  Build Python Interpreter using GCC
 
@@ -156,7 +156,8 @@ Execute the below command to build the X64 version of the 
Python 3.6.8 interpret
 bash$ cd AppPkg/Applications/Python/Python-3.6.8/
 bash$ python srcprep.py
 bash$ cd ~/src/edk2
-bash$ build -a X64 -b RELEASE -p AppPkg/AppPkg.dsc -m 
AppPkg/Applications/Python/Python-3.6.8/Python368.inf -D BUILD_PYTHON368
+bash$ build -a X64 -b RELEASE -p ../edk2-libc/AppPkg/AppPkg.dsc \
+  -m 
../edk2-libc/AppPkg/Applications/Python/Python-3.6.8/Python368.inf -D 
BUILD_PYTHON368
  or
 bash$ build -a X64 -b RELEASE -p AppPkg/AppPkg.dsc -D BUILD_PYTHON368
 
@@ -166,7 +167,13 @@ Execute the below command to build the X64 version of the 
Python 3.6.8 interpret
 
 To create an usable Python UEFI package with all the dependencies from the 
build environment,
 you can use the bash shell script create_python_pkg.sh available under 
/AppPkg/Applications/Python/Python-3.6.8
-folder.
+folder. Ensure that EDK2_LIBC_PATH environment variable to edk2-libc folder 
path.
+
+Ensure that EDK2_LIBC_PATH environment variable to edk2-libc folder path::
+
+bash$ echo $EDK2_LIBC_PATH
+
+The environment variable should be set to the folder path for the edk2-libc 
cloned repo.
 
 Use the following commands to create Python UEFI package::
 
diff --git a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt 
b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
index 91f4c24..8a0b3fe 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
+++ b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
@@ -68,7 +68,24 @@ and that you can successfully build packages within that 
distribution.
 gc  itertools   math  _operator
 time
 
-  C.  Build AppPkg using the standard "build" command:
+  C.  Set the PACKAGES_PATH and EDK2_LIBC_PATH environment variables to
+the right values. PACKAGES_PATH should be set to the folder path of
+edk2 and edk2-libc folders. EDK2_LIBC_PATH should be set to the
+folder path of edk2-libc.
+Use the below provided commands as reference to set the environment
+variables to the corresponding values
+
+set PACKAGES_PATH=;;
+   set EDK2_LIBC_PATH=
+
+where,
+ should be replaced with the absolute path to
+   edk2 folder on your development system.
+
+ should be replaced with the absolute path
+   to edk2-libc folder on your development system.
+
+  D.  Build AppPkg using the standard "build" command:
 For example, to build Python for an X64 CPU architecture:
 build -a X64 -p AppPkg\AppPkg.dsc -D BUILD_PYTHON368
 
@@ -115,7 +132,8 @@ system as 

Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc : add github actions workflow to build PyUEFI using VS2019

2024-06-18 Thread Jayaprakash, N
Hi Mike,

I am planning to split this PR into multiple patches.

The first one is for the suggestion you provided to include conditional 
compilation for Python368.inf in AppPkg.dsc and to pass a macro through -D flag 
to the build command.
I have made the necessary changes and verified them locally. 
After that created a patch and submitted for the review.
Please review and approve the same.

This PR I will use only for setting up the github actions for auto build.
Rest all the changes will be done through different PRs. 

Regards,
JP
-Original Message-
From: Kinney, Michael D  
Sent: Saturday, June 15, 2024 9:03 PM
To: Jayaprakash, N ; devel@edk2.groups.io
Cc: Rebecca Cran ; Kinney, Michael D 

Subject: RE: [edk2-libc Patch 1/1] edk2-libc : add github actions workflow to 
build PyUEFI using VS2019



> -Original Message-
> From: Jayaprakash, N 
> Sent: Saturday, June 15, 2024 1:18 AM
> To: Kinney, Michael D ; 
> devel@edk2.groups.io
> Cc: Rebecca Cran 
> Subject: RE: [edk2-libc Patch 1/1] edk2-libc : add github actions 
> workflow to build PyUEFI using VS2019
> 
> Thanks Mike for your comments.
> Please find my responses inline.
> 
> Regards,
> JP
> 
> -Original Message-
> From: Kinney, Michael D 
> Sent: Saturday, June 15, 2024 7:12 AM
> To: Jayaprakash, N ; devel@edk2.groups.io
> Cc: Rebecca Cran ; Kinney, Michael D 
> 
> Subject: RE: [edk2-libc Patch 1/1] edk2-libc : add github actions 
> workflow to build PyUEFI using VS2019
> 
> Comments below.
> 
> Mike
> 
> > -Original Message-
> > From: Jayaprakash, N 
> > Sent: Friday, June 14, 2024 10:02 AM
> > To: devel@edk2.groups.io
> > Cc: Jayaprakash, N ; Rebecca Cran 
> > ; Kinney, Michael D 
> > Subject: [edk2-libc Patch 1/1] edk2-libc : add github actions 
> > workflow to build PyUEFI using VS2019
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4788
> >
> > This commit adds github actions workflow to build python uefi 
> > interpreter with visual studio 2019 tool chain.
> > The build-python-uefi-vs.yaml file under .github/workflows 
> > implements the build action for building the pyuefi interpreter with 
> > VS2019 tool chain. There is also a supporting python script under 
> > .github/scripts folder which is used to uncomment the python uefi 
> > related .inf file in AppPkg.dsc file.
> >
> > Cc: Rebecca Cran 
> > Cc: Michael D Kinney 
> > Cc: Jayaprakash N 
> > Signed-off-by: Jayaprakash N 
> > ---
> >  .github/scripts/enable_pyuefi_apppkg.py | 31 
> >  .github/workflows/build-python-uefi-vs.yaml | 84
> > +
> >  2 files changed, 115 insertions(+)
> >  create mode 100644 .github/scripts/enable_pyuefi_apppkg.py
> >  create mode 100644 .github/workflows/build-python-uefi-vs.yaml
> >
> > diff --git a/.github/scripts/enable_pyuefi_apppkg.py
> > b/.github/scripts/enable_pyuefi_apppkg.py
> > new file mode 100644
> > index 000..37b9e0a
> > --- /dev/null
> > +++ b/.github/scripts/enable_pyuefi_apppkg.py
> > @@ -0,0 +1,31 @@
> > +'''Script to enable the build of python UEFI interpreter
> > +   in AppPkg.dsc file
> > +'''
> 
> Copyright and License missing
> <> Will add copyright and license
> 
> > +import os
> > +
> > +
> > +script_path = os.path.abspath(__file__) script_dir =
> > +os.path.dirname(script_path)
> > +
> > +# path to the AppPkg.dsc file
> > +path_to_AppPkg_dsc = os.path.join(script_dir, '..', '..', 'edk2', 
> > +'AppPkg',
> > 'AppPkg.dsc')
> > +print('Path to AppPkg dsc file : ', path_to_AppPkg_dsc)
> > +
> > +# Check if the file exists
> > +if not os.path.isfile(path_to_AppPkg_dsc):
> > +print(f"The file {path_to_AppPkg_dsc} does not exist.")
> > +else:
> > +# Read the content of the file
> > +with open(path_to_AppPkg_dsc, 'r') as file:
> > +lines = file.readlines()
> > +
> > +# Uncomment the line containing "Python368.inf"
> > +with open(path_to_AppPkg_dsc, 'w') as file:
> > +for line in lines:
> > +if 'Python368.inf' in line and line.strip().startswith('#'):
> > +# Uncomment the line
> > +file.write(line.lstrip('#'))
> > +else:
> > +file.write(line)
> 
> This is complicated to edit a DSC file.  Can this INF be uncommented 
> in this DSC file or add another DSC files that is only used for this 
> workflow to build python that has this INF uncommented.  Then this 
> extra python script can be removed.
> 
> 

[edk2-devel] [edk2-libc Patch 1/1] edk2-libc : make python368.inf compile conditionally in AppPkg.dsc

2024-06-18 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4789

This commit adds necessary changes to AppPkg.dsc file for
conditional compilation of python368.inf. To enable compilation
of python368.inf users need to pass an additional parameter
to the build command as -D BUILD_PYTHON368.
Also updated the Py368ReadMe.txt and the GCCCompilationBKMs.rst
to include this additional information for building python368.inf.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 AppPkg/AppPkg.dsc| 9 ++---
 .../Python/Python-3.6.8/GCCCompilationBKMs.rst   | 6 ++
 AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt  | 9 +++--
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/AppPkg/AppPkg.dsc b/AppPkg/AppPkg.dsc
index e5a6c5e..89f9f1d 100644
--- a/AppPkg/AppPkg.dsc
+++ b/AppPkg/AppPkg.dsc
@@ -7,7 +7,7 @@
 #   for important information about configuring this package for your
 #   environment.
 #
-#   Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved.
+#   Copyright (c) 2010 - 2024, Intel Corporation. All rights reserved.
 #   SPDX-License-Identifier: BSD-2-Clause-Patent
 ##
 
@@ -120,8 +120,11 @@
   gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80400040
   }
 
- Un-comment the following line to build Python 3.6.8.
-# AppPkg/Applications/Python/Python-3.6.8/Python368.inf
+ Conditional compilation of python368.inf by passing -D BUILD_PYTHON368
+ through build command
+  !if $(BUILD_PYTHON368)
+AppPkg/Applications/Python/Python-3.6.8/Python368.inf
+  !endif
 
  Un-comment the following line to build Lua.
 #  AppPkg/Applications/Lua/Lua.inf
diff --git a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst 
b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
index 525bef8..0574977 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
+++ b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
@@ -150,17 +150,15 @@ Copy the contents of edk2-libc to edk2 folder::
 
 2.5.  Build Python Interpreter using GCC
 
-Uncomment the line containing following inf file name in AppPkg/AppPkg.dsc file
-AppPkg/Applications/Python/Python-3.6.8/Python368.inf
 
 Execute the below command to build the X64 version of the Python 3.6.8 
interpreter using GCC tool chain::
 
 bash$ cd AppPkg/Applications/Python/Python-3.6.8/
 bash$ python srcprep.py
 bash$ cd ~/src/edk2
-bash$ build -a X64 -b RELEASE -p AppPkg/AppPkg.dsc -m 
AppPkg/Applications/Python/Python-3.6.8/Python368.inf
+bash$ build -a X64 -b RELEASE -p AppPkg/AppPkg.dsc -m 
AppPkg/Applications/Python/Python-3.6.8/Python368.inf -D BUILD_PYTHON368
  or
-bash$ build -a X64 -b RELEASE -p AppPkg/AppPkg.dsc
+bash$ build -a X64 -b RELEASE -p AppPkg/AppPkg.dsc -D BUILD_PYTHON368
 
 
 2.5  Create Python UEFI package with all dependencies
diff --git a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt 
b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
index a6e65fe..5753443 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
+++ b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
@@ -68,12 +68,9 @@ and that you can successfully build packages within that 
distribution.
 gc  itertools   math  _operator
 time
 
-  C.  Edit AppPkg/AppPkg.dsc to enable (uncomment) the Python368.inf line
-within the [Components] section.
-
-  D.  Build AppPkg using the standard "build" command:
+  C.  Build AppPkg using the standard "build" command:
 For example, to build Python for an X64 CPU architecture:
-build -a X64 -p AppPkg\AppPkg.dsc
+build -a X64 -p AppPkg\AppPkg.dsc -D BUILD_PYTHON368
 
 4. Python-related paths and files
 =
@@ -133,7 +130,7 @@ system as follows:
   2. Uncomment BsdSocketLib and EfiSocketLib LibraryClasses in Python368.inf
   3. Uncomment the statement #Modules/socketmodule.c in Python368.inf
   4. Build Python interpreter application using below command
-  build -a X64 -p AppPkg\AppPkg.dsc
+  build -a X64 -p AppPkg\AppPkg.dsc -D BUILD_PYTHON368
   5. Copy Build\AppPkg\RELEASE_VS2017\X64\Python.efi to \Efi\Tools on your
  target system. Replace "RELEASE_VS2017", in the source path, with
  values appropriate for your tool chain.
-- 
2.45.1.windows.1



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




[edk2-devel] [edk2-libc Patch 0/1] make python368.inf compile conditionally in AppPkg.dsc

2024-06-18 Thread Jayaprakash, N
This patch adds necessary changes to AppPkg.dsc file for
conditional compilation of python368.inf. To enable compilation
of python368.inf users need to pass an additional parameter
to the build command as -D BUILD_PYTHON368.
Also updated the Py368ReadMe.txt and the GCCCompilationBKMs.rst
to include this additional information for building python368.inf.
Please refer to BZ4789 for more details on the request.

Jayaprakash N (1):
  edk2-libc : make python368.inf compile conditionally in AppPkg.dsc

 AppPkg/AppPkg.dsc| 9 ++---
 .../Python/Python-3.6.8/GCCCompilationBKMs.rst   | 6 ++
 AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt  | 9 +++--
 3 files changed, 11 insertions(+), 13 deletions(-)

-- 
2.45.1.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc : add github actions workflow to build PyUEFI using VS2019

2024-06-15 Thread Jayaprakash, N
Thanks Mike for your comments.
Please find my responses inline.

Regards,
JP

-Original Message-
From: Kinney, Michael D  
Sent: Saturday, June 15, 2024 7:12 AM
To: Jayaprakash, N ; devel@edk2.groups.io
Cc: Rebecca Cran ; Kinney, Michael D 

Subject: RE: [edk2-libc Patch 1/1] edk2-libc : add github actions workflow to 
build PyUEFI using VS2019

Comments below.

Mike

> -Original Message-
> From: Jayaprakash, N 
> Sent: Friday, June 14, 2024 10:02 AM
> To: devel@edk2.groups.io
> Cc: Jayaprakash, N ; Rebecca Cran 
> ; Kinney, Michael D 
> Subject: [edk2-libc Patch 1/1] edk2-libc : add github actions workflow 
> to build PyUEFI using VS2019
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4788
> 
> This commit adds github actions workflow to build python uefi 
> interpreter with visual studio 2019 tool chain.
> The build-python-uefi-vs.yaml file under .github/workflows implements 
> the build action for building the pyuefi interpreter with VS2019 tool 
> chain. There is also a supporting python script under .github/scripts 
> folder which is used to uncomment the python uefi related .inf file in 
> AppPkg.dsc file.
> 
> Cc: Rebecca Cran 
> Cc: Michael D Kinney 
> Cc: Jayaprakash N 
> Signed-off-by: Jayaprakash N 
> ---
>  .github/scripts/enable_pyuefi_apppkg.py | 31 
>  .github/workflows/build-python-uefi-vs.yaml | 84 
> +
>  2 files changed, 115 insertions(+)
>  create mode 100644 .github/scripts/enable_pyuefi_apppkg.py
>  create mode 100644 .github/workflows/build-python-uefi-vs.yaml
> 
> diff --git a/.github/scripts/enable_pyuefi_apppkg.py
> b/.github/scripts/enable_pyuefi_apppkg.py
> new file mode 100644
> index 000..37b9e0a
> --- /dev/null
> +++ b/.github/scripts/enable_pyuefi_apppkg.py
> @@ -0,0 +1,31 @@
> +'''Script to enable the build of python UEFI interpreter
> +   in AppPkg.dsc file
> +'''

Copyright and License missing
<> Will add copyright and license

> +import os
> +
> +
> +script_path = os.path.abspath(__file__) script_dir = 
> +os.path.dirname(script_path)
> +
> +# path to the AppPkg.dsc file
> +path_to_AppPkg_dsc = os.path.join(script_dir, '..', '..', 'edk2', 
> +'AppPkg',
> 'AppPkg.dsc')
> +print('Path to AppPkg dsc file : ', path_to_AppPkg_dsc)
> +
> +# Check if the file exists
> +if not os.path.isfile(path_to_AppPkg_dsc):
> +print(f"The file {path_to_AppPkg_dsc} does not exist.")
> +else:
> +# Read the content of the file
> +with open(path_to_AppPkg_dsc, 'r') as file:
> +lines = file.readlines()
> +
> +# Uncomment the line containing "Python368.inf"
> +with open(path_to_AppPkg_dsc, 'w') as file:
> +for line in lines:
> +if 'Python368.inf' in line and line.strip().startswith('#'):
> +# Uncomment the line
> +file.write(line.lstrip('#'))
> +else:
> +file.write(line)

This is complicated to edit a DSC file.  Can this INF be uncommented in this 
DSC file or add another DSC files that is only used for this workflow to build 
python that has this INF uncommented.  Then this extra python script can be 
removed.

<> 
The reason I chose this approach is because we cannot uncomment this file by 
default in DSC file as it needs few additional steps to be done before the 
compilation.
Also adding another DSC file can lead to regular maintenance of the DSC file 
whenever there are changes to it, we need update in two files.
This custom script makes the process is and it keeps the github actions 
specific things are completely isolated from the rest of the code base. 
Would like to continue with this script rather than having a duplicate DCS file 
specifically for github actions. 

> +
> +print(f"The file {path_to_AppPkg_dsc} has been updated.")
> diff --git a/.github/workflows/build-python-uefi-vs.yaml
> b/.github/workflows/build-python-uefi-vs.yaml
> new file mode 100644
> index 000..aa5c317
> --- /dev/null
> +++ b/.github/workflows/build-python-uefi-vs.yaml
> @@ -0,0 +1,84 @@

Copyright and License missing

<> Will add and send updated patch for review.

> +name: Build Python Interpreter for UEFI using VS2019
> +
> +on: [push, pull_request]
> +
> +jobs:
> +  build:
> +runs-on: windows-2019
> +env:
> +  NASM_PREFIX: "C:\\Program Files\\NASM\\"
> +defaults:
> +  run:
> +shell: cmd
> +
> +steps:
> +- name: Checkout repository
> +  uses: actions/checkout@v4
> +
> +- name: Setup Python
> +  uses: actions/setup-python@v5
> +  with:
> +python-version: '3.10'
> +
> +- name: Install NASM
> +  run: c

[edk2-devel] [edk2-libc Patch 1/1] edk2-libc : add github actions workflow to build PyUEFI using VS2019

2024-06-14 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4788

This commit adds github actions workflow to build python uefi
interpreter with visual studio 2019 tool chain.
The build-python-uefi-vs.yaml file under .github/workflows
implements the build action for building the pyuefi interpreter
with VS2019 tool chain. There is also a supporting python script
under .github/scripts folder which is used to uncomment the python
uefi related .inf file in AppPkg.dsc file.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .github/scripts/enable_pyuefi_apppkg.py | 31 
 .github/workflows/build-python-uefi-vs.yaml | 84 +
 2 files changed, 115 insertions(+)
 create mode 100644 .github/scripts/enable_pyuefi_apppkg.py
 create mode 100644 .github/workflows/build-python-uefi-vs.yaml

diff --git a/.github/scripts/enable_pyuefi_apppkg.py 
b/.github/scripts/enable_pyuefi_apppkg.py
new file mode 100644
index 000..37b9e0a
--- /dev/null
+++ b/.github/scripts/enable_pyuefi_apppkg.py
@@ -0,0 +1,31 @@
+'''Script to enable the build of python UEFI interpreter 
+   in AppPkg.dsc file
+'''
+import os
+
+
+script_path = os.path.abspath(__file__)
+script_dir = os.path.dirname(script_path)
+
+# path to the AppPkg.dsc file
+path_to_AppPkg_dsc = os.path.join(script_dir, '..', '..', 'edk2', 'AppPkg', 
'AppPkg.dsc')
+print('Path to AppPkg dsc file : ', path_to_AppPkg_dsc)
+
+# Check if the file exists
+if not os.path.isfile(path_to_AppPkg_dsc):
+print(f"The file {path_to_AppPkg_dsc} does not exist.")
+else:
+# Read the content of the file
+with open(path_to_AppPkg_dsc, 'r') as file:
+lines = file.readlines()
+
+# Uncomment the line containing "Python368.inf"
+with open(path_to_AppPkg_dsc, 'w') as file:
+for line in lines:
+if 'Python368.inf' in line and line.strip().startswith('#'):
+# Uncomment the line
+file.write(line.lstrip('#'))
+else:
+file.write(line)
+
+print(f"The file {path_to_AppPkg_dsc} has been updated.")
diff --git a/.github/workflows/build-python-uefi-vs.yaml 
b/.github/workflows/build-python-uefi-vs.yaml
new file mode 100644
index 000..aa5c317
--- /dev/null
+++ b/.github/workflows/build-python-uefi-vs.yaml
@@ -0,0 +1,84 @@
+name: Build Python Interpreter for UEFI using VS2019
+
+on: [push, pull_request]
+
+jobs:
+  build:
+runs-on: windows-2019
+env:
+  NASM_PREFIX: "C:\\Program Files\\NASM\\"
+defaults:
+  run:
+shell: cmd
+
+steps:
+- name: Checkout repository
+  uses: actions/checkout@v4
+
+- name: Setup Python
+  uses: actions/setup-python@v5
+  with:
+python-version: '3.10'
+
+- name: Install NASM
+  run: choco install nasm
+
+- name: VSWhere
+  run: |
+"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
+
+- name: Setup environment for Visual Studio 2019 Build Tools
+  run: |
+"C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat" x86
+set
+
+- name: Clone EDK2
+  run: |
+git clone https://github.com/tianocore/edk2.git;
+cd edk2
+git submodule update --init
+
+- name: Copy edk2-libc contents to edk2
+  run: |
+dir
+cmd /c xcopy /E /I /Y AppPkg edk2\AppPkg
+cmd /c xcopy /E /I /Y StdLib edk2\StdLib
+cmd /c xcopy /E /I /Y StdLibPrivateInternalFiles 
edk2\StdLibPrivateInternalFiles
+
+- name: Build EDK2 Base Tools
+  run: |
+cd edk2
+dir
+edksetup.bat ForceRebuild
+
+- name: Enable python368.inf file in AppPkg.dsc
+  run: |
+cd .github\scripts
+dir
+python enable_pyuefi_apppkg.py
+
+- name: Build Python UEFI
+  run: |
+cd edk2
+call edksetup.bat
+cd AppPkg\Applications\Python\Python-3.6.8\
+python srcprep.py
+cd ..\..\..\..\..\
+build -t VS2019 -a X64 -b RELEASE -p AppPkg\AppPkg.dsc
+
+- name: Create Python UEFI package
+  run: |
+dir
+cd edk2\AppPkg\Applications\Python\Python-3.6.8\
+dir
+call create_python_pkg.bat VS2019 RELEASE X64 myUEFIPy
+
+- name: List build artifacts
+  run: |
+dir /S edk2\myUEFIPy
+
+- name: Upload build output as artifact
+  uses: actions/upload-artifact@v4
+  with:
+name: myUEFIPy-build-VS2019-output
+path: edk2\myUEFIPy\**\*
-- 
2.45.1.windows.1



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




[edk2-devel] [edk2-libc Patch 0/1] add github actions workflow to build Python UEFI with VS2019

2024-06-14 Thread Jayaprakash, N
This patch request enables the github actions workflow to build Python
UEFI interpreter using VS2019 tool chain. 
Please refere to BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=4788

Jayaprakash N (1):
  edk2-libc : add github actions workflow to build PyUEFI using VS2019

 .github/scripts/enable_pyuefi_apppkg.py | 31 
 .github/workflows/build-python-uefi-vs.yaml | 84 +
 2 files changed, 115 insertions(+)
 create mode 100644 .github/scripts/enable_pyuefi_apppkg.py
 create mode 100644 .github/workflows/build-python-uefi-vs.yaml

-- 
2.45.1.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: Add cpuid_ex API to execute CPUID instructions on specific CPU

2024-05-17 Thread Jayaprakash, N
Changes looks good.

Reviewed-by: Jayaprakash N 

Regards,
JP
-Original Message-
From: R, Vishal  
Sent: Friday, May 17, 2024 12:08 PM
To: devel@edk2.groups.io
Cc: R, Vishal ; Rebecca Cran ; Kinney, 
Michael D ; Jayaprakash, N 
Subject: [edk2-libc Patch 1/1] edk2-libc: Add cpuid_ex API to execute CPUID 
instructions on specific CPU

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

This commit adds cpuid_ex function to edk2module to provide capability to 
execute cpuid instruction on specific cpu.
This feature was requested via BZ 4749

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Vishal R 
---
 .../PyMod-3.6.8/Modules/edk2module.c  | 93 +++
 1 file changed, 93 insertions(+)

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
index 163fc7f..d419428 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2mo
+++ dule.c
@@ -45,6 +45,15 @@ typedef struct {
 UINT64 data; // data, to be filled by the AP function  } 
AP_FUNCTION_MSR_ARGS;
 
+typedef struct {
+UINT32 eax; // eax value
+UINT32 ecx; // ecx value
+UINT32 rax_value;   // retrun value for eax
+UINT32 rbx_value;   // return value for ebx
+UINT32 rcx_value;   // retrun value for ecx
+UINT32 rdx_value;   // return value for edx
+} AP_FUNCTION_CPUID_ARGS;
+
 #define AP_FUNCTION_EXECUTION_TIMEOUT  500   // setting the max time out 
value to be 5 seconds
 
 extern void _swsmi( unsigned int smi_code_data, unsigned int rax_value, 
unsigned int rbx_value, unsigned int rcx_value, unsigned int rdx_value, 
unsigned int rsi_value, unsigned int rdi_value ); @@ -223,6 +232,13 @@ VOID 
EFIAPI MSRWriteToRunOnAP(IN VOID *context)
 AsmWriteMsr64(msr, data);
 }
 
+// CPUID execution function to run on specific cpu core using 
+MPServices Protocol VOID EFIAPI CPUIDToRunOnAP(IN VOID *context) {
+AP_FUNCTION_CPUID_ARGS *args = (AP_FUNCTION_CPUID_ARGS *)context;
+AsmCpuidEx( args->eax, args->ecx, >rax_value, 
+>rbx_value, >rcx_value, >rdx_value); }
+
 #ifndef UEFI_C_SOURCE
 /* Return a dictionary corresponding to the POSIX environment table */  extern 
char **environ; @@ -4153,6 +4169,82 @@ edk2_cpuid(PyObject *self, PyObject 
*args)
 return Py_BuildValue("())",  (unsigned long)rax_value,  (unsigned 
long)rbx_value,  (unsigned long)rcx_value,  (unsigned long)rdx_value);  }
 
+PyDoc_STRVAR(efi_cpuid_ex__doc__,
+"cpuid_ex(cpu, eax, ecx) -> (eax:ebx:ecx:edx)\n\ Read the CPUID from a 
+specific cpu.";);
+
+static PyObject *
+edk2_cpuid_ex(PyObject *self, PyObject *args) {
+UINT32 cpu, eax, ecx, rax_value, rbx_value, rcx_value, rdx_value;
+BOOLEAN is_function_finished = FALSE;
+EFI_STATUS status = 0;
+AP_FUNCTION_CPUID_ARGS cpuid_args = {0};
+
+if (!PyArg_ParseTuple(args, "III", , , ))
+return NULL;
+Py_BEGIN_ALLOW_THREADS
+
+cpuid_args.eax = eax;
+cpuid_args.ecx = ecx;
+
+if (cpu == gCurrentBSPProcessorNumber)
+{
+// cpu provided as input is same as the current BSP processor
+// then directly call the CPUIDToRunOnAP function to execute
+// cpuid instruction on current BSP processor itself.
+CPUIDToRunOnAP(_args);
+}
+else if (cpu < gNumberOfProcessors)
+{
+// if cpu provided as input is different from the current
+// BSP processor and is less than the number of processors
+// on this system, then make use of the MPService protocols
+// StartupThisAP function to run the CPUIDToRunOnAP function on
+// specific AP indicated by cpu parameter.
+// Start the AP with the arguments structure
+
+status = gpMpService->StartupThisAP(
+gpMpService,
+CPUIDToRunOnAP, // Function to run
+cpu,// AP number
+NULL,   // WaitEvent (optional)
+AP_FUNCTION_EXECUTION_TIMEOUT,  // Timeout in microseconds
+_args,// Buffer to pass to the function
+_function_finished   // Finished (optional)
+);
+if (EFI_ERROR(status))
+{
+PyErr_SetString(PyExc_OSError, "Could not start the requested 
cpu");
+Py_INCREF(Py_None);
+return Py_None;
+}
+
+if (!is_function_finished)
+{
+PyErr_SetString(PyExc_OSError,
+"Timeout while running the cpuid instruction on 
given cpu");
+Py_INCREF(Py_None);
+return Py_None;
+}
+}
+else
+{
+// if cpu provided exeeds the number of processors
+// then set the Valu

Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & wrmsr_ex functions to read/write cpu specific msrs

2024-04-24 Thread Jayaprakash, N
Hi Mike,

I have sent an updated patch v2 for review which uses the MP Services protocol 
API StarupThisAP() to read / write MSRs specific to CPU cores.
Please review and do the needful.

Regards,
JP

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Jayaprakash, N
Sent: Thursday, April 18, 2024 11:49 AM
To: Kinney, Michael D ; devel@edk2.groups.io
Cc: Rebecca Cran 
Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & 
wrmsr_ex functions to read/write cpu specific msrs

Thanks Mike. I shall make necessary changes and submit the PR again for review.

Regards,
JP

-Original Message-
From: Kinney, Michael D 
Sent: Thursday, April 18, 2024 10:46 AM
To: Jayaprakash, N ; devel@edk2.groups.io
Cc: Rebecca Cran ; Kinney, Michael D 

Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & 
wrmsr_ex functions to read/write cpu specific msrs

Please use MP Services Protocol APIs StartupAllAPs() or StarupThisAP() to 
read/write MSRs on other logical processors.

There and many examples of this in the UefiCpuPkg to programming MSRs on all 
the logical processors.

Mike

> -Original Message-----
> From: Jayaprakash, N 
> Sent: Wednesday, April 17, 2024 8:16 PM
> To: Kinney, Michael D ; 
> devel@edk2.groups.io
> Cc: Rebecca Cran 
> Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex 
> & wrmsr_ex functions to read/write cpu specific msrs
> 
> In the validation and debug scenarios, engineers tend to read MSRs and 
> write to MSRs of different CPUs.
> So we are providing a simple mechanism through these APIs to enable 
> them to do these operations.
> 
> These APIs will be part of the edk2 module of the Python interpreter 
> and will be used during the validation and debug scenarios only.
> 
> This is not for switching the BSP for OS boot. This is only used 
> during the validation and debug use cases.
> 
> Regards,
> JP
> -Original Message-
> From: Kinney, Michael D 
> Sent: Thursday, April 18, 2024 12:08 AM
> To: Jayaprakash, N ; devel@edk2.groups.io
> Cc: Rebecca Cran ; Kinney, Michael D 
> 
> Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex 
> & wrmsr_ex functions to read/write cpu specific msrs
> 
> Hi JP,
> 
> Is there a reason switch BSP is being used.  That is not a common 
> operation and is typically used if the current BSP is not stable or 
> there is a good reason to switch the BSP for OS boot.
> 
> The MP Services can be used to execute a C function on APs to execute 
> MSR related instructions.
> 
> Mike
> 
> > -Original Message-
> > From: Jayaprakash, N 
> > Sent: Sunday, April 14, 2024 10:33 PM
> > To: devel@edk2.groups.io; Jayaprakash, N 
> > Cc: Rebecca Cran ; Kinney, Michael D 
> > 
> > Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add
> rdmsr_ex
> > & wrmsr_ex functions to read/write cpu specific msrs
> >
> > + Rebecca and Mike,
> >
> > Would you be able to review this PR?
> >
> > Regards,
> > JP
> >
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of 
> > Jayaprakash, N
> > Sent: Wednesday, April 10, 2024 11:49 AM
> > To: devel@edk2.groups.io
> > Cc: Jayaprakash, N ; Rebecca Cran 
> > ; Kinney, Michael D 
> > Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & 
> > wrmsr_ex functions to read/write cpu specific msrs
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4746
> >
> > The rdmsr_ex and wrmsr_ex are extension APIs to the rdmsr and wrmsr 
> > APIs supported in edk2 module. These extension APIs makes it
> possible
> > to read / write MSRs from specific processors and fills an existing 
> > gap in this area.
> >
> > Cc: Rebecca Cran 
> > Cc: Michael D Kinney 
> > Cc: Jayaprakash N 
> > Signed-off-by: Jayaprakash N 
> > ---
> >  .../PyMod-3.6.8/Modules/edk2module.c  | 159
> > +-
> >  .../Python/Python-3.6.8/Python368.inf |   3 +
> >  2 files changed, 158 insertions(+), 4 deletions(-)
> >
> > diff --git a/AppPkg/Applications/Python/Python-3.6.8/PyMod-
> > 3.6.8/Modules/edk2module.c b/AppPkg/Applications/Python/Python-
> > 3.6.8/PyMod-3.6.8/Modules/edk2module.c
> > index d6af8da..f1b13a6 100644
> > --- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-
> > 3.6.8/Modules/edk2module.c
> > +++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-
> > 3.6.8/Modules/edk2mo
> > +++ dule.c
> > @@ -3,7 +3,7 @@
> >  Derived from posixmodule.c in Python 2.7.2.
> >
> >  Copyright (c) 2015, Daryl McDani

[edk2-devel] [edk2-libc Patch v2 1/1] edk2-libc : add rdmsr_ex and wrmsr_ex to read/write msr from specific cpus

2024-04-24 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4746

The rdmsr_ex and wrmsr_ex are extension APIs to the rdmsr and wrmsr APIs
supported in edk2 module. These extension APIs makes it possible to
read / write MSRs from specific processors. This fills an important gap in
reading / writing these registers from specific cpu cores using python
scripts from UEFI shell.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .../PyMod-3.6.8/Modules/edk2module.c  | 258 +-
 .../Python/Python-3.6.8/Python368.inf |   3 +
 2 files changed, 252 insertions(+), 9 deletions(-)

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
index f688b51..13e5de5 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
@@ -3,7 +3,7 @@
 Derived from posixmodule.c in Python 2.7.2.
 
 Copyright (c) 2015, Daryl McDaniel. All rights reserved.
-Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2024, Intel Corporation. All rights reserved.
 This program and the accompanying materials are licensed and made 
available under
 the terms and conditions of the BSD License that accompanies this 
distribution.
 The full text of the license may be found at
@@ -22,16 +22,30 @@
 #include  
 #include  
 #include  
+#include// Needed for the definition of EFI_AP_PROCEDURE
 #include  
 #include  
 #include  
 #include  
+#include  
+#include  
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 PyTypeObject EfiGuidType;
+EFI_MP_SERVICES_PROTOCOL   *gpMpService = NULL;
+UINTN   gCurrentBSPProcessorNumber = 0;
+UINTN   gNumberOfProcessors = 0;
+UINTN   gNumberOfEnabledProcessors = 0;
+
+typedef struct {
+UINT32 msr;  // msr value
+UINT64 data; // data, to be filled by the AP function
+} AP_FUNCTION_MSR_ARGS;
+
+#define AP_FUNCTION_EXECUTION_TIMEOUT  500   // setting the max time out 
value to be 5 seconds
 
 extern void _swsmi( unsigned int smi_code_data, unsigned int rax_value, 
unsigned int rbx_value, unsigned int rcx_value, unsigned int rdx_value, 
unsigned int rsi_value, unsigned int rdi_value );
 // -- Support routines
@@ -169,6 +183,46 @@ PyDoc_STRVAR(edk2__doc__,
 /* dummy version. _PyVerify_fd() is already defined in fileobject.h */
 #define _PyVerify_fd_dup2(A, B) (1)
 
+/* MPServices Protocol wrapper function definitions */
+static EFI_STATUS
+MpServicesWhoAmI (
+  IN EFI_MP_SERVICES_PROTOCOL  *pMpService,
+  OUT UINTN*pProcessorNumber
+  )
+{
+  return pMpService->WhoAmI (pMpService, pProcessorNumber);
+}
+
+static EFI_STATUS
+MpServicesGetNumberOfProcessors (
+  IN EFI_MP_SERVICES_PROTOCOL  *pMpService,
+  OUT UINTN*pNumberOfProcessors,
+  OUT UINTN*pNumberOfEnabledProcessors
+
+  )
+{
+  return pMpService->GetNumberOfProcessors (pMpService,
+pNumberOfProcessors,
+pNumberOfEnabledProcessors);
+}
+
+// MSR read function to run on specific cpu core using MPServices Protocol
+VOID EFIAPI MSRReadToRunOnAP(IN VOID *context)
+{
+AP_FUNCTION_MSR_ARGS *args = (AP_FUNCTION_MSR_ARGS *)context;
+UINT32 msr = args->msr;
+args->data = AsmReadMsr64(msr);
+}
+
+// MSR write function to run on specific cpu core using MPServices Protocol
+VOID EFIAPI MSRWriteToRunOnAP(IN VOID *context)
+{
+AP_FUNCTION_MSR_ARGS *args = (AP_FUNCTION_MSR_ARGS *)context;
+UINT32 msr = args->msr;
+UINT64 data = args->data;
+AsmWriteMsr64(msr, data);
+}
+
 #ifndef UEFI_C_SOURCE
 /* Return a dictionary corresponding to the POSIX environment table */
 extern char **environ;
@@ -3864,6 +3918,91 @@ edk2_rdmsr(PyObject *self, PyObject *args)
   vedx = (UINT64)data >> 32;
   return Py_BuildValue("(II)", (unsigned long)veax, (unsigned long)vedx);
 }
+
+PyDoc_STRVAR(efi_rdmsr_ex__doc__,
+"rdmsr_ex(cpu, msr) -> (lower_32bits, higher_32bits)\n\
+\n\
+Read the given msr from the specific cpu and return the data as tuple,\n\
+provided the cpu number is less than the max number of processors on\n\
+this system, otherwise generates OSError/ValueError to indicate API failure.\n\
+\n\
+Parameters:\n\
+cpu - The cpu number in hex or int format\n\
+msr - The msr in hex or int format\n\
+\n\
+Return Value:\n\
+a tuple with lower and higher 32 bit values read from the msr\n\
+");
+
+static PyObject *
+edk2_rdmsr_ex(PyObject *self, PyObject *args)
+{
+unsigned int cpu, msr, veax, vedx;
+EFI_STATUS status = 0;
+UINT64   data = 0;
+BOOLEAN is_function_finished = FALSE;
+AP_FUNCTION_MSR_ARGS ap_fu

[edk2-devel] [edk2-libc Patch v2 0/1] add rdmsr_ex & wrmsr_ex functions to read/write msrs from specific cpu

2024-04-24 Thread Jayaprakash, N
This patch adds 2 new functions to read and write MSRs from specific CPUs.
rdmsr_ex and wrmsr_ex are the 2 new functions added into edk2module to provide
the read and write of CPU specific MSRs.

Jayaprakash N (1):
  edk2-libc : add rdmsr_ex and wrmsr_ex to read/write msr from specific
cpus

 .../PyMod-3.6.8/Modules/edk2module.c  | 258 +-
 .../Python/Python-3.6.8/Python368.inf |   3 +
 2 files changed, 252 insertions(+), 9 deletions(-)

-- 
2.44.0.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 2 1/1] ek2-libc: wrmsr function available in edk2module is not working as expected

2024-04-19 Thread Jayaprakash, N
Thanks Mike as suggested made the logic simpler.
Sent the updated v3 patch for review.

Regards,
JP

-Original Message-
From: Kinney, Michael D  
Sent: Friday, April 19, 2024 2:35 AM
To: Jayaprakash, N ; devel@edk2.groups.io
Cc: Rebecca Cran ; Kinney, Michael D 

Subject: RE: [edk2-libc Patch 2 1/1] ek2-libc: wrmsr function available in 
edk2module is not working as expected

The use of BitFieldOr64() is really only required when updating a portion of a 
32-bit or 64-bit value that are not aligned on a 32-bit boundary and do not 
have a 32-bit aligned width.  Since this use case is setting the lower 32-bits, 
simpler logic should be used.

  data = LShiftU64(vedx, 32) | veax;

Mike

> -Original Message-
> From: Jayaprakash, N 
> Sent: Thursday, April 18, 2024 5:55 AM
> To: devel@edk2.groups.io
> Cc: Jayaprakash, N ; Rebecca Cran 
> ; Kinney, Michael D 
> Subject: [edk2-libc Patch 2 1/1] ek2-libc: wrmsr function available in 
> edk2module is not working as expected
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4745
> 
> This commit fixes the issue reported in the BZ4745.
> The wrmsr was always writing 0 to the higher 32 bits of the msr 
> register.
> This was due to a logical flaw in the code, where the input variable 
> of type unsigned int was left shitted by 32 bits without explicitly 
> converting it to a 64 bit value.
> 
> The issue is with the below statement.
> data = vedx << 32 | veax;
> Where the vedx which is an unsigned int, after left shifting by 32 
> bits its value will be set to 0. Because of this the higher 32 bits of 
> the MSR are always set to 0. This has been fixed by this commit.
> 
> Cc: Rebecca Cran 
> Cc: Michael D Kinney 
> Cc: Jayaprakash N 
> Signed-off-by: Jayaprakash N 
> ---
>  .../Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c   | 3
> ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/AppPkg/Applications/Python/Python-3.6.8/PyMod-
> 3.6.8/Modules/edk2module.c b/AppPkg/Applications/Python/Python-
> 3.6.8/PyMod-3.6.8/Modules/edk2module.c
> index 8786df8..06bcf82 100644
> --- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-
> 3.6.8/Modules/edk2module.c
> +++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-
> 3.6.8/Modules/edk2module.c
> @@ -3886,7 +3886,8 @@ edk2_wrmsr(PyObject *self, PyObject *args)
>UINT64   data = 0;
>if (!PyArg_ParseTuple(args, "III", , , ))
>  return NULL;
> -  data = vedx << 32 | veax;
> +  data = LShiftU64(vedx, 32);
> +  data = BitFieldOr64(data, 0, 31, veax);
>Py_BEGIN_ALLOW_THREADS
>AsmWriteMsr64(vecx, data);
>Py_END_ALLOW_THREADS
> --
> 2.44.0.windows.1



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




[edk2-devel] [edk2-libc Patch v3 0/1] wrmsr function is not working as expected

2024-04-19 Thread Jayaprakash, N
The wrmsr function always writes 0s to the higher 32 bits of the msr register.
This PR fixes this issue reported through the BZ4745

Jayaprakash N (1):
  ek2-libc: wrmsr function available in edk2module is not working as
expected

 .../Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.44.0.windows.1



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




[edk2-devel] [edk2-libc Patch v3 1/1] ek2-libc: wrmsr function available in edk2module is not working as expected

2024-04-19 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4745

This commit fixes the issue reported in the BZ4745.
The wrmsr was always writing 0 to the higher 32 bits of the msr register.
This was due to a logical flaw in the code, where the input variable of
type unsigned int was left shitted by 32 bits without explicitly
converting it to a 64 bit value.

The issue is with the below statement.
data = vedx << 32 | veax;
Where the vedx which is an unsigned int, after left shifting by 32 bits
its value will be set to 0. Because of this the higher 32 bits of the MSR
are always set to 0. This has been fixed by this commit.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .../Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
index d6af8da..f688b51 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
@@ -3886,7 +3886,7 @@ edk2_wrmsr(PyObject *self, PyObject *args)
   UINT64   data = 0;
   if (!PyArg_ParseTuple(args, "III", , , ))
 return NULL;
-  data = vedx << 32 | veax;
+  data = LShiftU64(vedx, 32) | veax;
   Py_BEGIN_ALLOW_THREADS
   AsmWriteMsr64(vecx, data);
   Py_END_ALLOW_THREADS
-- 
2.44.0.windows.1



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




[edk2-devel] [edk2-libc Patch 2 1/1] ek2-libc: wrmsr function available in edk2module is not working as expected

2024-04-18 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4745

This commit fixes the issue reported in the BZ4745.
The wrmsr was always writing 0 to the higher 32 bits of the msr register.
This was due to a logical flaw in the code, where the input variable of
type unsigned int was left shitted by 32 bits without explicitly
converting it to a 64 bit value.

The issue is with the below statement.
data = vedx << 32 | veax;
Where the vedx which is an unsigned int, after left shifting by 32 bits
its value will be set to 0. Because of this the higher 32 bits of the MSR
are always set to 0. This has been fixed by this commit.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .../Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c   | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
index 8786df8..06bcf82 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
@@ -3886,7 +3886,8 @@ edk2_wrmsr(PyObject *self, PyObject *args)
   UINT64   data = 0;
   if (!PyArg_ParseTuple(args, "III", , , ))
 return NULL;
-  data = vedx << 32 | veax;
+  data = LShiftU64(vedx, 32);
+  data = BitFieldOr64(data, 0, 31, veax);
   Py_BEGIN_ALLOW_THREADS
   AsmWriteMsr64(vecx, data);
   Py_END_ALLOW_THREADS
-- 
2.44.0.windows.1



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




[edk2-devel] [edk2-libc Patch 2 0/1] wrmsr function is not working as expected.

2024-04-18 Thread Jayaprakash, N
The wrmsr function always writes 0s to the higher 32 bits of the msr register.
This PR fixes the this issue reported through the BZ4745.

Jayaprakash N (1):
  ek2-libc: wrmsr function available in edk2module is not working as
expected

 .../Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c   | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.44.0.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & wrmsr_ex functions to read/write cpu specific msrs

2024-04-18 Thread Jayaprakash, N
Thanks Mike. I shall make necessary changes and submit the PR again for review.

Regards,
JP

-Original Message-
From: Kinney, Michael D  
Sent: Thursday, April 18, 2024 10:46 AM
To: Jayaprakash, N ; devel@edk2.groups.io
Cc: Rebecca Cran ; Kinney, Michael D 

Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & 
wrmsr_ex functions to read/write cpu specific msrs

Please use MP Services Protocol APIs StartupAllAPs() or StarupThisAP() to 
read/write MSRs on other logical processors.

There and many examples of this in the UefiCpuPkg to programming MSRs on all 
the logical processors.

Mike

> -Original Message-
> From: Jayaprakash, N 
> Sent: Wednesday, April 17, 2024 8:16 PM
> To: Kinney, Michael D ; 
> devel@edk2.groups.io
> Cc: Rebecca Cran 
> Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex 
> & wrmsr_ex functions to read/write cpu specific msrs
> 
> In the validation and debug scenarios, engineers tend to read MSRs and 
> write to MSRs of different CPUs.
> So we are providing a simple mechanism through these APIs to enable 
> them to do these operations.
> 
> These APIs will be part of the edk2 module of the Python interpreter 
> and will be used during the validation and debug scenarios only.
> 
> This is not for switching the BSP for OS boot. This is only used 
> during the validation and debug use cases.
> 
> Regards,
> JP
> -Original Message-
> From: Kinney, Michael D 
> Sent: Thursday, April 18, 2024 12:08 AM
> To: Jayaprakash, N ; devel@edk2.groups.io
> Cc: Rebecca Cran ; Kinney, Michael D 
> 
> Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex 
> & wrmsr_ex functions to read/write cpu specific msrs
> 
> Hi JP,
> 
> Is there a reason switch BSP is being used.  That is not a common 
> operation and is typically used if the current BSP is not stable or 
> there is a good reason to switch the BSP for OS boot.
> 
> The MP Services can be used to execute a C function on APs to execute 
> MSR related instructions.
> 
> Mike
> 
> > -Original Message-
> > From: Jayaprakash, N 
> > Sent: Sunday, April 14, 2024 10:33 PM
> > To: devel@edk2.groups.io; Jayaprakash, N 
> > Cc: Rebecca Cran ; Kinney, Michael D 
> > 
> > Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add
> rdmsr_ex
> > & wrmsr_ex functions to read/write cpu specific msrs
> >
> > + Rebecca and Mike,
> >
> > Would you be able to review this PR?
> >
> > Regards,
> > JP
> >
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of 
> > Jayaprakash, N
> > Sent: Wednesday, April 10, 2024 11:49 AM
> > To: devel@edk2.groups.io
> > Cc: Jayaprakash, N ; Rebecca Cran 
> > ; Kinney, Michael D 
> > Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & 
> > wrmsr_ex functions to read/write cpu specific msrs
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4746
> >
> > The rdmsr_ex and wrmsr_ex are extension APIs to the rdmsr and wrmsr 
> > APIs supported in edk2 module. These extension APIs makes it
> possible
> > to read / write MSRs from specific processors and fills an existing 
> > gap in this area.
> >
> > Cc: Rebecca Cran 
> > Cc: Michael D Kinney 
> > Cc: Jayaprakash N 
> > Signed-off-by: Jayaprakash N 
> > ---
> >  .../PyMod-3.6.8/Modules/edk2module.c  | 159
> > +-
> >  .../Python/Python-3.6.8/Python368.inf |   3 +
> >  2 files changed, 158 insertions(+), 4 deletions(-)
> >
> > diff --git a/AppPkg/Applications/Python/Python-3.6.8/PyMod-
> > 3.6.8/Modules/edk2module.c b/AppPkg/Applications/Python/Python-
> > 3.6.8/PyMod-3.6.8/Modules/edk2module.c
> > index d6af8da..f1b13a6 100644
> > --- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-
> > 3.6.8/Modules/edk2module.c
> > +++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-
> > 3.6.8/Modules/edk2mo
> > +++ dule.c
> > @@ -3,7 +3,7 @@
> >  Derived from posixmodule.c in Python 2.7.2.
> >
> >  Copyright (c) 2015, Daryl McDaniel. All rights reserved.
> > -Copyright (c) 2011 - 2023, Intel Corporation. All rights
> > reserved.
> > +Copyright (c) 2011 - 2024, Intel Corporation. All rights 
> > + reserved.
> >  This program and the accompanying materials are licensed and
> made
> > available under
> >  the terms and conditions of the BSD License that accompanies
> this
> > distribution.
> >  The full text of the license may be found at @@ -22,16 +22,23
> @@
> 

Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & wrmsr_ex functions to read/write cpu specific msrs

2024-04-17 Thread Jayaprakash, N
In the validation and debug scenarios, engineers tend to read MSRs and write to 
MSRs of different CPUs.
So we are providing a simple mechanism through these APIs to enable them to do 
these operations.

These APIs will be part of the edk2 module of the Python interpreter and will 
be used during the validation and debug scenarios only.

This is not for switching the BSP for OS boot. This is only used during the 
validation and debug use cases.

Regards,
JP
-Original Message-
From: Kinney, Michael D  
Sent: Thursday, April 18, 2024 12:08 AM
To: Jayaprakash, N ; devel@edk2.groups.io
Cc: Rebecca Cran ; Kinney, Michael D 

Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & 
wrmsr_ex functions to read/write cpu specific msrs

Hi JP,

Is there a reason switch BSP is being used.  That is not a common operation and 
is typically used if the current BSP is not stable or there is a good reason to 
switch the BSP for OS boot.

The MP Services can be used to execute a C function on APs to execute MSR 
related instructions.

Mike

> -Original Message-
> From: Jayaprakash, N 
> Sent: Sunday, April 14, 2024 10:33 PM
> To: devel@edk2.groups.io; Jayaprakash, N 
> Cc: Rebecca Cran ; Kinney, Michael D 
> 
> Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex 
> & wrmsr_ex functions to read/write cpu specific msrs
> 
> + Rebecca and Mike,
> 
> Would you be able to review this PR?
> 
> Regards,
> JP
> 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of 
> Jayaprakash, N
> Sent: Wednesday, April 10, 2024 11:49 AM
> To: devel@edk2.groups.io
> Cc: Jayaprakash, N ; Rebecca Cran 
> ; Kinney, Michael D 
> Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & 
> wrmsr_ex functions to read/write cpu specific msrs
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4746
> 
> The rdmsr_ex and wrmsr_ex are extension APIs to the rdmsr and wrmsr 
> APIs supported in edk2 module. These extension APIs makes it possible 
> to read / write MSRs from specific processors and fills an existing 
> gap in this area.
> 
> Cc: Rebecca Cran 
> Cc: Michael D Kinney 
> Cc: Jayaprakash N 
> Signed-off-by: Jayaprakash N 
> ---
>  .../PyMod-3.6.8/Modules/edk2module.c  | 159
> +-
>  .../Python/Python-3.6.8/Python368.inf |   3 +
>  2 files changed, 158 insertions(+), 4 deletions(-)
> 
> diff --git a/AppPkg/Applications/Python/Python-3.6.8/PyMod-
> 3.6.8/Modules/edk2module.c b/AppPkg/Applications/Python/Python-
> 3.6.8/PyMod-3.6.8/Modules/edk2module.c
> index d6af8da..f1b13a6 100644
> --- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-
> 3.6.8/Modules/edk2module.c
> +++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-
> 3.6.8/Modules/edk2mo
> +++ dule.c
> @@ -3,7 +3,7 @@
>  Derived from posixmodule.c in Python 2.7.2.
> 
>  Copyright (c) 2015, Daryl McDaniel. All rights reserved.
> -Copyright (c) 2011 - 2023, Intel Corporation. All rights
> reserved.
> +Copyright (c) 2011 - 2024, Intel Corporation. All rights 
> + reserved.
>  This program and the accompanying materials are licensed and made 
> available under
>  the terms and conditions of the BSD License that accompanies this 
> distribution.
>  The full text of the license may be found at @@ -22,16 +22,23 @@ 
> #include#include#include  
> +#include// Needed for the definition of
> EFI_AP_PROCEDURE
>  #include  
>  #include  
>  #include  
>  #include  
> +#include  
> +#include  
> 
>  #ifdef __cplusplus
>  extern "C" {
>  #endif
> 
>  PyTypeObject EfiGuidType;
> +EFI_MP_SERVICES_PROTOCOL   *gpMpService = NULL;
> +UINTN   gBSPProcessorNumber = 0;
> +UINTN   gNumberOfProcessors = 0;
> +UINTN   gNumberOfEnabledProcessors = 0;
> 
>  extern void _swsmi( unsigned int smi_code_data, unsigned int 
> rax_value, unsigned int rbx_value, unsigned int rcx_value, unsigned 
> int rdx_value, unsigned int rsi_value, unsigned int rdi_value );  // -
> - Support routines @@ -169,6 +176,35 @@ PyDoc_STRVAR(edk2__doc__,
>  /* dummy version. _PyVerify_fd() is already defined in fileobject.h 
> */  #define _PyVerify_fd_dup2(A, B) (1)
> 
> +static EFI_STATUS
> +MpServicesWhoAmI (
> +  IN EFI_MP_SERVICES_PROTOCOL  *pMpService,
> +  OUT UINTN*pProcessorNumber
> +  )
> +{
> +  return pMpService->WhoAmI (pMpService, pProcessorNumber); }
> +
> +static EFI_STATUS
> +MpServicesGetNumberOfProcessors (
> +  IN EFI_MP_SERVICES_PROTOCOL  *pMpService,
> +  OUT UINTN*pNumberOfProcessors,
> +  OUT UINTN*pNumberOfEn

Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & wrmsr_ex functions to read/write cpu specific msrs

2024-04-14 Thread Jayaprakash, N
+ Rebecca and Mike,

Would you be able to review this PR?

Regards,
JP

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Jayaprakash, N
Sent: Wednesday, April 10, 2024 11:49 AM
To: devel@edk2.groups.io
Cc: Jayaprakash, N ; Rebecca Cran ; 
Kinney, Michael D 
Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & wrmsr_ex 
functions to read/write cpu specific msrs

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

The rdmsr_ex and wrmsr_ex are extension APIs to the rdmsr and wrmsr APIs 
supported in edk2 module. These extension APIs makes it possible to read / 
write MSRs from specific processors and fills an existing gap in this area.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .../PyMod-3.6.8/Modules/edk2module.c  | 159 +-
 .../Python/Python-3.6.8/Python368.inf |   3 +
 2 files changed, 158 insertions(+), 4 deletions(-)

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
index d6af8da..f1b13a6 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2mo
+++ dule.c
@@ -3,7 +3,7 @@
 Derived from posixmodule.c in Python 2.7.2.
 
 Copyright (c) 2015, Daryl McDaniel. All rights reserved.
-Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2024, Intel Corporation. All rights 
+ reserved.
 This program and the accompanying materials are licensed and made 
available under
 the terms and conditions of the BSD License that accompanies this 
distribution.
 The full text of the license may be found at @@ -22,16 +22,23 @@  #include 
   #include#include  
+#include// Needed for the definition of EFI_AP_PROCEDURE
 #include  
 #include  
 #include  
 #include  
+#include  
+#include  
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 PyTypeObject EfiGuidType;
+EFI_MP_SERVICES_PROTOCOL   *gpMpService = NULL;
+UINTN   gBSPProcessorNumber = 0;
+UINTN   gNumberOfProcessors = 0;
+UINTN   gNumberOfEnabledProcessors = 0;
 
 extern void _swsmi( unsigned int smi_code_data, unsigned int rax_value, 
unsigned int rbx_value, unsigned int rcx_value, unsigned int rdx_value, 
unsigned int rsi_value, unsigned int rdi_value );  // -- Support routines @@ 
-169,6 +176,35 @@ PyDoc_STRVAR(edk2__doc__,
 /* dummy version. _PyVerify_fd() is already defined in fileobject.h */  
#define _PyVerify_fd_dup2(A, B) (1)
 
+static EFI_STATUS
+MpServicesWhoAmI (
+  IN EFI_MP_SERVICES_PROTOCOL  *pMpService,
+  OUT UINTN*pProcessorNumber
+  )
+{
+  return pMpService->WhoAmI (pMpService, pProcessorNumber); }
+
+static EFI_STATUS
+MpServicesGetNumberOfProcessors (
+  IN EFI_MP_SERVICES_PROTOCOL  *pMpService,
+  OUT UINTN*pNumberOfProcessors,
+  OUT UINTN*pNumberOfEnabledProcessors
+
+  )
+{
+  return pMpService->GetNumberOfProcessors (pMpService, 
+pNumberOfProcessors, pNumberOfEnabledProcessors); }
+
+static EFI_STATUS
+MpServicesSwitchBSP (
+  IN EFI_MP_SERVICES_PROTOCOL  *pMpService,
+  IN UINTN  ProcessorNumber
+  )
+{
+  return pMpService->SwitchBSP(pMpService,  ProcessorNumber, TRUE); }
+
 #ifndef UEFI_C_SOURCE
 /* Return a dictionary corresponding to the POSIX environment table */  extern 
char **environ; @@ -3865,6 +3901,56 @@ edk2_rdmsr(PyObject *self, PyObject 
*args)
   return Py_BuildValue("(II)", (unsigned long)veax, (unsigned long)vedx);  }
 
+PyDoc_STRVAR(efi_rdmsr_ex__doc__,
+"rdmsr_ex(cpu, msr) -> (lower_32bits, higher_32bits)\n\ \n\ Read the 
+given msr by switching to cpu and return the data as tuple.\n\ \n\ 
+Parameters:\n\
+cpu - The cpu number in hex or int format\n\
+msr - The msr in hex or int format\n\ \n\ Return Value:\n\
+a tuple with lower and higher 32 bit values read from the msr\n\ 
+");
+
+static PyObject *
+edk2_rdmsr_ex(PyObject *self, PyObject *args) {
+  unsigned int cpu, vecx, veax, vedx;
+  unsigned int bsp_switched = 0;
+  EFI_STATUS status = 0;
+  UINT64   data = 0;
+
+  if (!PyArg_ParseTuple(args, "II", , ))
+return NULL;
+
+  Py_BEGIN_ALLOW_THREADS
+  if (cpu != gBSPProcessorNumber && cpu < gNumberOfProcessors)  {
+//switch the BSP to the cpu
+status = MpServicesSwitchBSP(gpMpService, cpu);
+if (!EFI_ERROR(status))
+{
+bsp_switched = 1;
+}
+  }
+
+  data = AsmReadMsr64(vecx);
+
+  if (bsp_switched)
+  {
+// switch BSP to the saved BSP processor
+MpServicesSwitchBSP(gpMpService, gBSPProcessorNumber);
+// update the saved BSP processor
+MpServicesWhoAmI(gpMpService, );
+  }
+  Py_END_ALLOW_THREADS
+  veax = (UINT32)data;
+  vedx = (UINT64)data >> 

[edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & wrmsr_ex functions to read/write cpu specific msrs

2024-04-10 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4746

The rdmsr_ex and wrmsr_ex are extension APIs to the rdmsr and wrmsr APIs
supported in edk2 module. These extension APIs makes it possible
to read / write MSRs from specific processors and fills an existing gap
in this area.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .../PyMod-3.6.8/Modules/edk2module.c  | 159 +-
 .../Python/Python-3.6.8/Python368.inf |   3 +
 2 files changed, 158 insertions(+), 4 deletions(-)

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
index d6af8da..f1b13a6 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
@@ -3,7 +3,7 @@
 Derived from posixmodule.c in Python 2.7.2.
 
 Copyright (c) 2015, Daryl McDaniel. All rights reserved.
-Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2024, Intel Corporation. All rights reserved.
 This program and the accompanying materials are licensed and made 
available under
 the terms and conditions of the BSD License that accompanies this 
distribution.
 The full text of the license may be found at
@@ -22,16 +22,23 @@
 #include  
 #include  
 #include  
+#include// Needed for the definition of EFI_AP_PROCEDURE
 #include  
 #include  
 #include  
 #include  
+#include  
+#include  
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 PyTypeObject EfiGuidType;
+EFI_MP_SERVICES_PROTOCOL   *gpMpService = NULL;
+UINTN   gBSPProcessorNumber = 0;
+UINTN   gNumberOfProcessors = 0;
+UINTN   gNumberOfEnabledProcessors = 0;
 
 extern void _swsmi( unsigned int smi_code_data, unsigned int rax_value, 
unsigned int rbx_value, unsigned int rcx_value, unsigned int rdx_value, 
unsigned int rsi_value, unsigned int rdi_value );
 // -- Support routines
@@ -169,6 +176,35 @@ PyDoc_STRVAR(edk2__doc__,
 /* dummy version. _PyVerify_fd() is already defined in fileobject.h */
 #define _PyVerify_fd_dup2(A, B) (1)
 
+static EFI_STATUS
+MpServicesWhoAmI (
+  IN EFI_MP_SERVICES_PROTOCOL  *pMpService,
+  OUT UINTN*pProcessorNumber
+  )
+{
+  return pMpService->WhoAmI (pMpService, pProcessorNumber);
+}
+
+static EFI_STATUS
+MpServicesGetNumberOfProcessors (
+  IN EFI_MP_SERVICES_PROTOCOL  *pMpService,
+  OUT UINTN*pNumberOfProcessors,
+  OUT UINTN*pNumberOfEnabledProcessors
+
+  )
+{
+  return pMpService->GetNumberOfProcessors (pMpService, pNumberOfProcessors, 
pNumberOfEnabledProcessors);
+}
+
+static EFI_STATUS
+MpServicesSwitchBSP (
+  IN EFI_MP_SERVICES_PROTOCOL  *pMpService,
+  IN UINTN  ProcessorNumber
+  )
+{
+  return pMpService->SwitchBSP(pMpService,  ProcessorNumber, TRUE);
+}
+
 #ifndef UEFI_C_SOURCE
 /* Return a dictionary corresponding to the POSIX environment table */
 extern char **environ;
@@ -3865,6 +3901,56 @@ edk2_rdmsr(PyObject *self, PyObject *args)
   return Py_BuildValue("(II)", (unsigned long)veax, (unsigned long)vedx);
 }
 
+PyDoc_STRVAR(efi_rdmsr_ex__doc__,
+"rdmsr_ex(cpu, msr) -> (lower_32bits, higher_32bits)\n\
+\n\
+Read the given msr by switching to cpu and return the data as tuple.\n\
+\n\
+Parameters:\n\
+cpu - The cpu number in hex or int format\n\
+msr - The msr in hex or int format\n\
+\n\
+Return Value:\n\
+a tuple with lower and higher 32 bit values read from the msr\n\
+");
+
+static PyObject *
+edk2_rdmsr_ex(PyObject *self, PyObject *args)
+{
+  unsigned int cpu, vecx, veax, vedx;
+  unsigned int bsp_switched = 0;
+  EFI_STATUS status = 0;
+  UINT64   data = 0;
+
+  if (!PyArg_ParseTuple(args, "II", , ))
+return NULL;
+
+  Py_BEGIN_ALLOW_THREADS
+  if (cpu != gBSPProcessorNumber && cpu < gNumberOfProcessors)
+  {
+//switch the BSP to the cpu
+status = MpServicesSwitchBSP(gpMpService, cpu);
+if (!EFI_ERROR(status))
+{
+bsp_switched = 1;
+}
+  }
+
+  data = AsmReadMsr64(vecx);
+
+  if (bsp_switched)
+  {
+// switch BSP to the saved BSP processor
+MpServicesSwitchBSP(gpMpService, gBSPProcessorNumber);
+// update the saved BSP processor
+MpServicesWhoAmI(gpMpService, );
+  }
+  Py_END_ALLOW_THREADS
+  veax = (UINT32)data;
+  vedx = (UINT64)data >> 32;
+  return Py_BuildValue("(II)", (unsigned long)veax, (unsigned long)vedx);
+}
+
 PyDoc_STRVAR(efi_wrmsr__doc__,
 "wrmsr(msr, lower_32bits, higher_32bits) -> None\n\
 \n\
@@ -3889,6 +3975,58 @@ edk2_wrmsr(PyObject *self, PyObject *args)
   data = vedx << 32 | veax;
   Py_BEGIN_ALLOW_THREADS
   AsmWriteMsr64(vecx, data);
+  Py_END_ALLOW_THREADS
+  Py_INCREF(Py_None);
+  return Py_N

[edk2-devel] [edk2-libc Patch 0/1] add rdmsr_ex & wrmsr_ex functions to read/write msrs from specific cpu

2024-04-10 Thread Jayaprakash, N
This patch adds 2 new functions to read and write msrs from specific CPUs.
rdmsr_ex and wrmsr_ex are the 2 new functions added into edk2module to
provide the read and write of CPU specific MSRs.

Jayaprakash N (1):
  edk2-libc:add rdmsr_ex & wrmsr_ex functions to read/write cpu specific
msrs

 .../PyMod-3.6.8/Modules/edk2module.c  | 159 +-
 .../Python/Python-3.6.8/Python368.inf |   3 +
 2 files changed, 158 insertions(+), 4 deletions(-)

-- 
2.40.0.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: wrmsr function available in edk2module is not working as expected

2024-04-10 Thread Jayaprakash, N
Reviewed-by : Jayaprakash N

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Jayaprakash, N
Sent: Thursday, April 4, 2024 3:14 PM
To: devel@edk2.groups.io
Cc: Jayaprakash, N ; Rebecca Cran ; 
Kinney, Michael D 
Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: wrmsr function available 
in edk2module is not working as expected

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

This commit fixes the issue reported in the BZ4745.
The wrmsr function was always writing 0 to the higher 32 bits of the msr 
register. This was due to a logical flaw in the code, where the input variable 
of type unsigned int was left shitted by 32 bits without explicitly converting 
to a 64 bit value.

Problematic statement in the function edk2_wrmsr code:
data = vedx << 32 | veax;
Where the vedx an unsigned int, after left shifting by 32 bits its value will 
be set to 0. Because of this the higher 32 bits of the MSR are always set to 0. 
This statement has been modified as below:
  data = (((UINT64)vedx) << 32) | veax;
Verified the function by making this change and could see that the wrmsr is 
working as expected.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .../Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
index d6af8da..cec4332 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2mo
+++ dule.c
@@ -3886,7 +3886,7 @@ edk2_wrmsr(PyObject *self, PyObject *args)
   UINT64   data = 0;
   if (!PyArg_ParseTuple(args, "III", , , ))
 return NULL;
-  data = vedx << 32 | veax;
+  data = (((UINT64)vedx) << 32) | veax;
   Py_BEGIN_ALLOW_THREADS
   AsmWriteMsr64(vecx, data);
   Py_END_ALLOW_THREADS
--
2.40.0.windows.1








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




[edk2-devel] [edk2-libc Patch 0/1] wrmsr function is not working as expected.

2024-04-04 Thread Jayaprakash, N
The wrmsr function always writes 0s to the higher 32 bits of the msr register.
This issue has been fixed by this PR.

Jayaprakash N (1):
  edk2-libc: wrmsr function available in edk2module is not working as
expected

 .../Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] edk2-libc: wrmsr function available in edk2module is not working as expected

2024-04-04 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4745

This commit fixes the issue reported in the BZ4745.
The wrmsr function was always writing 0 to the higher 32 bits of
the msr register. This was due to a logical flaw in the code,
where the input variable of type unsigned int was left shitted
by 32 bits without explicitly converting to a 64 bit value.

Problematic statement in the function edk2_wrmsr code:
data = vedx << 32 | veax;
Where the vedx an unsigned int, after left shifting by 32 bits its value
will be set to 0. Because of this the higher 32 bits of the MSR are
always set to 0. This statement has been modified as below:
  data = (((UINT64)vedx) << 32) | veax;
Verified the function by making this change and could see that
the wrmsr is working as expected.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .../Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
index d6af8da..cec4332 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
@@ -3886,7 +3886,7 @@ edk2_wrmsr(PyObject *self, PyObject *args)
   UINT64   data = 0;
   if (!PyArg_ParseTuple(args, "III", , , ))
 return NULL;
-  data = vedx << 32 | veax;
+  data = (((UINT64)vedx) << 32) | veax;
   Py_BEGIN_ALLOW_THREADS
   AsmWriteMsr64(vecx, data);
   Py_END_ALLOW_THREADS
-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] ek2-libc: writeio function in edk2module.c not working as expected

2023-12-09 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4619

This commit fixes the issue reported in the BZ4619.
The order of passing the parameters to IoWrite* functions
called within writeio function in edk2module.c has been corrected
Also verified the changes by writing reset command to 0xCF9 port
using writeio function in edk2module.c

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .../Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c| 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
index 8786df8..d6af8da 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
@@ -3985,9 +3985,9 @@ edk2_writeio(PyObject *self, PyObject *args)
 
   Py_BEGIN_ALLOW_THREADS
   addrs = (short)(addr & 0x);
-  if (1 == sz) IoWrite8((unsigned char)(value & 0xFF), addrs);
-  else if (2 == sz) IoWrite16((unsigned short)(value & 0x), addrs);
-  else if (4 == sz) IoWrite32(value, addrs);
+  if (1 == sz) IoWrite8(addrs, (unsigned char)(value & 0xFF));
+  else if (2 == sz) IoWrite16(addrs, (unsigned short)(value & 0x));
+  else if (4 == sz) IoWrite32(addrs, value);
   Py_END_ALLOW_THREADS
 
   Py_INCREF(Py_None);
-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 0/1] writeio() edk2module not working as expected

2023-12-09 Thread Jayaprakash, N
This commit fixes the issue reported in BZ4619.
The writeio() function in edk2module.c in
edk2-libc/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules
which uses IoWrite* functions was passing the parameters in incorrect
order. This has been fixed.

Jayaprakash N (1):
  ek2-libc: writeio function in edk2module.c not working as expected

 .../Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c| 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.40.0.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Fixed typo issues in multiple files

2023-11-24 Thread Jayaprakash, N
Reviewed-by : Jayaprakash Nevara 

-Original Message-
From: R, Vishal  
Sent: Friday, November 24, 2023 4:41 PM
To: devel@edk2.groups.io
Cc: R, Vishal ; Rebecca Cran ; Kinney, 
Michael D ; Jayaprakash, N 
Subject: [edk2-libc Patch 1/1] edk2-libc/StdLib: Fixed typo issues in multiple 
files

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

This commit fixes the various typo issues found in documentation strings in 
multiple files issue reported via the BZ4579 These changes are documentation 
updates only and does not affect the functionality of the code

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Vishal R 
---
 StdLib/BsdSocketLib/ns_addr.c  |  4 ++--
 StdLib/BsdSocketLib/res_comp.c |  2 +-
 StdLib/BsdSocketLib/res_config.h   |  2 +-
 StdLib/BsdSocketLib/res_init.c |  2 +-
 StdLib/Include/arpa/telnet.h   |  2 +-
 StdLib/Include/errno.h |  2 +-
 StdLib/Include/locale.h|  2 +-
 StdLib/Include/net/if.h|  8 
 StdLib/Include/netns/ns.h  |  2 +-
 StdLib/Include/stdio.h |  2 +-
 StdLib/Include/stdlib.h|  6 +++---
 StdLib/Include/sys/termios.h   | 14 +++---
 StdLib/Include/sys/wait.h  |  2 +-
 StdLib/LibC/Main/Arm/flt_rounds.c  |  2 +-
 StdLib/LibC/StdLib/realpath.c  |  2 +-
 StdLib/LibC/Stdio/vfscanf.c|  2 +-
 StdLib/LibC/Uefi/InteractiveIO/TerminalFunctions.c |  8 
 StdLib/LibC/Uefi/SysCalls.c|  8 
 StdLib/LibC/Wchar/String.c |  2 +-
 StdLib/LibC/gdtoa/gdtoaimp.h   |  2 +-
 StdLib/PosixLib/Gen/dirname.c  |  2 +-
 21 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/StdLib/BsdSocketLib/ns_addr.c b/StdLib/BsdSocketLib/ns_addr.c 
index 4360b0c..36fe379 100644
--- a/StdLib/BsdSocketLib/ns_addr.c
+++ b/StdLib/BsdSocketLib/ns_addr.c
@@ -72,9 +72,9 @@ ns_addr(
 
   /*
* First, figure out what he intends as a field separtor.
-   * Despite the way this routine is written, the prefered
+   * Despite the way this routine is written, the preferred
* form  2-272.AA001234H.01777, i.e. XDE standard.
-   * Great efforts are made to insure backward compatability.
+   * Great efforts are made to insure backward compatibility.
*/
   if ((hostname = strchr(buf, '#')) != NULL)
 separator = '#';
diff --git a/StdLib/BsdSocketLib/res_comp.c b/StdLib/BsdSocketLib/res_comp.c 
index 7c327fa..8e52e32 100644
--- a/StdLib/BsdSocketLib/res_comp.c
+++ b/StdLib/BsdSocketLib/res_comp.c
@@ -108,7 +108,7 @@ static char rcsid[] = "$Id: res_comp.c,v 1.1.1.1 2003/11/19 
01:51:35 kyu3 Exp $"
 
 /*
  * Expand compressed domain name 'comp_dn' to full domain name.
- * 'msg' is a pointer to the begining of the message,
+ * 'msg' is a pointer to the beginning of the message,
  * 'eomorig' points to the first location after the message,
  * 'exp_dn' is a pointer to a buffer of size 'length' for the result.
  * Return size of compressed name or -1 if there was an error.
diff --git a/StdLib/BsdSocketLib/res_config.h b/StdLib/BsdSocketLib/res_config.h
index 4f4afdf..e3128e1 100644
--- a/StdLib/BsdSocketLib/res_config.h
+++ b/StdLib/BsdSocketLib/res_config.h
@@ -1,6 +1,6 @@
 #define DEBUG   1   /* enable debugging code (needed for dig) */
 #define RESOLVSORT  /* allow sorting of addresses in gethostbyname */
-#define RFC1535 /* comply with RFC1535 (STRONGLY reccomended by vixie)*/
+#define RFC1535 /* comply with RFC1535 (STRONGLY recommended by vixie)*/
 #undef  USELOOPBACK /* res_init() bind to localhost */  #undef  SUNSECURITY /* 
verify gethostbyaddr() calls - WE DONT NEED IT  */  #define 
MULTI_PTRS_ARE_ALIASES 1 /* fold multiple PTR records into aliases */ diff 
--git a/StdLib/BsdSocketLib/res_init.c b/StdLib/BsdSocketLib/res_init.c index 
9df7d4f..449cb17 100644
--- a/StdLib/BsdSocketLib/res_init.c
+++ b/StdLib/BsdSocketLib/res_init.c
@@ -134,7 +134,7 @@ struct __res_state _res
  * there will have precedence.  Otherwise, the server address is set to
  * INADDR_ANY and the default domain name comes from the gethostname().
  *
- * An interrim version of this code (BIND 4.9, pre-4.4BSD) used 127.0.0.1
+ * An interim version of this code (BIND 4.9, pre-4.4BSD) used 
+ 127.0.0.1
  * rather than INADDR_ANY ("0.0.0.0") as the default name server address
  * since it was noted that INADDR_ANY actually meant ``the first interface
  * you "ifconfig"'d at boot time'' and if this was a SLIP or PPP interface, 
diff --git a/StdLib/Include/arpa/telnet.h b/StdLib/Include/arpa/telnet.h index 
d7c8ecb..04c4a30 100644
--- a/StdLib/Include/arpa/telnet.h
+++ b/StdLib/Include/arpa/tel

Re: [edk2-devel] [edk2-libc Patch 1/1] ek2-libc: Sample python scripts for socket client capabilities on UEFI shell

2023-11-10 Thread Jayaprakash, N
These are simple Python apps to demonstrate the usage of socket communication 
using the HTTP library. 
Reviewed-by : Jayaprakash N 

Regards,
JP
-Original Message-
From: devel@edk2.groups.io  On Behalf Of Jayaprakash, N
Sent: Friday, October 27, 2023 9:57 PM
To: devel@edk2.groups.io
Cc: Jayaprakash, N ; Rebecca Cran ; 
Kinney, Michael D 
Subject: [edk2-devel] [edk2-libc Patch 1/1] ek2-libc: Sample python scripts for 
socket client capabilities on UEFI shell

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

This BZ has been created to provide the sample python scripts to demonstrate 
the socket client capabilities using http library on UEFI shell with the help 
of Python UEFI interpreter.
The http_echo_client.py and http_echo_server.py scripts are provided as sample 
scripts to exercise the python http library from UEFI shell.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash Nevara 
---
 .../PyMod-3.6.8/Lib/http_echo_client.py   | 81 +++
 .../PyMod-3.6.8/Lib/http_echo_server.py   | 61 ++
 2 files changed, 142 insertions(+)
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_client.py
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_server.py

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_client.py 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_client.py
new file mode 100644
index 000..ea0368d
--- /dev/null
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_
+++ client.py
@@ -0,0 +1,81 @@
+"""
+This is a sample HTTP echo client sends data to the server and gets 
+echoed data from the server in response body and prints the same to the 
+console.
+
+Note: This application needs to be run from UEFI shell using the Python 
+UEFI interpreter.
+"""
+
+import sys
+import time
+from http import client
+from http.client import HTTPException
+import traceback
+
+_max_retries = 10
+_retry_count = 0
+
+
+def _print_usage():
+print("Sample http echo client application")
+print("Usage:")
+print("python.efi http_echo_client.py ")
+
+
+if len(sys.argv) != 2:
+_print_usage()
+sys.exit(0)
+
+if sys.argv[1] == "-h":
+_print_usage()
+sys.exit(0)
+
+http_server = sys.argv[1]
+while True:
+try:
+name = input("Enter the parameter name:")
+value = input("Enter parameter value:")
+print("Connecting to server to send a get request with following 
parameter")
+print("{}={}".format(name, value))
+# replace space with %20
+value = value.replace(" ", "%20")
+conn = client.HTTPConnection(http_server)
+# Send GET request with some data
+conn.request("GET", "/echo?{}={}".format(name, value))
+rsp = conn.getresponse()
+if rsp.status == 204:
+print("No content")
+break
+elif rsp.status == 200:
+data_received = rsp.read()
+# replace %20 with space character before displaying to console
+data_received = data_received.replace(b"%20", b" ")
+print("from server:{}".format(data_received))
+conn.close()
+print("Closing the connection")
+break
+else:
+print("Invalid response code {}".format(rsp.status))
+conn.close()
+print("Closing the connection")
+break
+except HTTPException as exp:
+print("Got exception while connecting to server : {}".format(exp))
+traceback.print_exc()
+break
+except ConnectionRefusedError as exp:
+print("Got exception while connecting to server : {}".format(exp))
+print("Check & start the server, if it is not started")
+print(
+"Retrying connection after 10 seconds, retry count = {}".format(
+_retry_count + 1
+)
+)
+if _retry_count == _max_retries:
+print(
+"Exceeded max retries {} exiting the 
application".format(_max_retries)
+)
+break
+time.sleep(10)
+_retry_count += 1
diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_server.py 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_server.py
new file mode 100644
index 000..eebdf33
--- /dev/null
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_
+++ server.py
@@ -0,0 +1,61 @@
+"""
+This is a sample HTTP echo server that echos the command / data coming 
+from the client.
+Here the data is received from client thro

[edk2-devel] [edk2-libc Patch 1/1] ek2-libc: Sample python scripts for socket client capabilities on UEFI shell

2023-10-27 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4580

This BZ has been created to provide the sample python scripts
to demonstrate the socket client capabilities using http library
on UEFI shell with the help of Python UEFI interpreter.
The http_echo_client.py and http_echo_server.py scripts
are provided as sample scripts to exercise the python http library
from UEFI shell.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash Nevara 
---
 .../PyMod-3.6.8/Lib/http_echo_client.py   | 81 +++
 .../PyMod-3.6.8/Lib/http_echo_server.py   | 61 ++
 2 files changed, 142 insertions(+)
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_client.py
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_server.py

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_client.py 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_client.py
new file mode 100644
index 000..ea0368d
--- /dev/null
+++ 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_client.py
@@ -0,0 +1,81 @@
+"""
+This is a sample HTTP echo client sends data to the server
+and gets echoed data from the server in response body 
+and prints the same to the console.
+
+Note: This application needs to be run from UEFI shell using
+the Python UEFI interpreter.
+"""
+
+import sys
+import time
+from http import client
+from http.client import HTTPException
+import traceback
+
+_max_retries = 10
+_retry_count = 0
+
+
+def _print_usage():
+print("Sample http echo client application")
+print("Usage:")
+print("python.efi http_echo_client.py ")
+
+
+if len(sys.argv) != 2:
+_print_usage()
+sys.exit(0)
+
+if sys.argv[1] == "-h":
+_print_usage()
+sys.exit(0)
+
+http_server = sys.argv[1]
+while True:
+try:
+name = input("Enter the parameter name:")
+value = input("Enter parameter value:")
+print("Connecting to server to send a get request with following 
parameter")
+print("{}={}".format(name, value))
+# replace space with %20
+value = value.replace(" ", "%20")
+conn = client.HTTPConnection(http_server)
+# Send GET request with some data
+conn.request("GET", "/echo?{}={}".format(name, value))
+rsp = conn.getresponse()
+if rsp.status == 204:
+print("No content")
+break
+elif rsp.status == 200:
+data_received = rsp.read()
+# replace %20 with space character before displaying to console
+data_received = data_received.replace(b"%20", b" ")
+print("from server:{}".format(data_received))
+conn.close()
+print("Closing the connection")
+break
+else:
+print("Invalid response code {}".format(rsp.status))
+conn.close()
+print("Closing the connection")
+break
+except HTTPException as exp:
+print("Got exception while connecting to server : {}".format(exp))
+traceback.print_exc()
+break
+except ConnectionRefusedError as exp:
+print("Got exception while connecting to server : {}".format(exp))
+print("Check & start the server, if it is not started")
+print(
+"Retrying connection after 10 seconds, retry count = {}".format(
+_retry_count + 1
+)
+)
+if _retry_count == _max_retries:
+print(
+"Exceeded max retries {} exiting the 
application".format(_max_retries)
+)
+break
+time.sleep(10)
+_retry_count += 1
diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_server.py 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_server.py
new file mode 100644
index 000..eebdf33
--- /dev/null
+++ 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_server.py
@@ -0,0 +1,61 @@
+"""
+This is a sample HTTP echo server that echos the command / data
+coming from the client.
+Here the data is received from client through GET request in the 
+form of parameter of GET request.
+The parameter is extracted and sent back to the client 
+in the response body.
+
+Note that this server sample application needs to be run 
+on a system booted to OS. 
+"""
+
+import os
+import socket
+import sys
+from http.server import BaseHTTPRequestHandler, HTTPServer
+from http.client import parse_headers
+
+
+class MyHTTPRequestHandler(BaseHTTPRequestHandler):
+"""HTTP request ha

[edk2-devel] [edk2-libc Patch 0/1] AppPkg/Python - Sample scripts to exercise socket functionality

2023-10-27 Thread Jayaprakash, N
This commit provides 2 sample scripts namely
http_echo_client.py and http_echo_server.py to exercise the 
socket capabilities on UEFI shell using the http library from Python UEFI
interpreter.

Jayaprakash N (1):
  ek2-libc: Sample python scripts for socket client capabilities on UEFI
shell

 .../PyMod-3.6.8/Lib/http_echo_client.py   | 81 +++
 .../PyMod-3.6.8/Lib/http_echo_server.py   | 61 ++
 2 files changed, 142 insertions(+)
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_client.py
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Lib/http_echo_server.py

-- 
2.40.0.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 0/1] fix missing nanf definition in StdLib

2023-10-26 Thread Jayaprakash, N
Reviewed-by : Jayaprakash Nevara 

Regards,
JP

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Jayaprakash, N
Sent: Thursday, October 26, 2023 9:00 PM
To: devel@edk2.groups.io
Cc: Jayaprakash, N 
Subject: [edk2-devel] [edk2-libc Patch 0/1] fix missing nanf definition in 
StdLib

This patch fixes the issue of missing definition of nanf in StdLib.
This has been extracted from the below PR submitted on edk2-libc.
https://github.com/tianocore/edk2-libc/pull/9

Jayaprakash N (1):
  ek2-libc: fix missing nanf definition in StdLib

 StdLib/LibC/LibC.inf|  1 +
 StdLib/LibC/Main/nanf_ieee754.c | 15 +++
 2 files changed, 16 insertions(+)
 create mode 100644 StdLib/LibC/Main/nanf_ieee754.c

-- 
2.40.0.windows.1








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




Re: [edk2-devel] [edk2-libc Patch 1/1] ek2-libc: realpath function signature doesn't match the standard

2023-10-26 Thread Jayaprakash, N
Reviewed-by: Jayaprakash Nevara 
It's simple fix to align the function signature as per the standards.

Regards,
JP
-Original Message-
From: Jayaprakash, N  
Sent: Thursday, October 26, 2023 7:47 PM
To: devel@edk2.groups.io
Cc: Jayaprakash, N ; Rebecca Cran ; 
Kinney, Michael D ; Kloper, Dimitry 

Subject: [edk2-libc Patch 1/1] ek2-libc: realpath function signature doesn't 
match the standard

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

This commit is for processing the below PR on edk2-libc repo
https://github.com/tianocore/edk2-libc/pull/10
The realpath function signature in stdlib of edk2-libc doesn't match signature 
as per the standard definition of this function given below 
https://pubs.opengroup.org/onlinepubs/009695399/functions/realpath.html
This patch extracted from the above pull request fixes this issue.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Kloper Dimitry 
---
 StdLib/Include/stdlib.h   | 4 ++--
 StdLib/LibC/StdLib/realpath.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/StdLib/Include/stdlib.h b/StdLib/Include/stdlib.h index 
0b9dfd3..022ddbd 100644
--- a/StdLib/Include/stdlib.h
+++ b/StdLib/Include/stdlib.h
@@ -74,7 +74,7 @@
const wchar_t * __restrict src, size_t limit);
 
   Miscelaneous functions for *nix compatibility
-char   *realpath(char *file_name, char *resolved_name);
+char   *realpath(const char *file_name, char *resolved_name);
 const char *getprogname (void);
 voidsetprogname (const char *progname);
 
@@ -875,7 +875,7 @@ size_t  wcstombs(char * __restrict Dest, const wchar_t * 
__restrict Src, size_t
 @retval NULLAn error occured.
 @retval resolved_name.
 **/
-char * realpath(char *file_name, char *resolved_name);
+char * realpath(const char *file_name, char *resolved_name);
 
 /** The getprogname() function returns the name of the program.  If the name
 has not been set yet, it will return NULL.
diff --git a/StdLib/LibC/StdLib/realpath.c b/StdLib/LibC/StdLib/realpath.c 
index 3d4118d..29abe9a 100644
--- a/StdLib/LibC/StdLib/realpath.c
+++ b/StdLib/LibC/StdLib/realpath.c
@@ -34,7 +34,7 @@
 **/
 char *
 realpath(
-  char *file_name,
+  const char *file_name,
   char *resolved_name
   )
 {
--
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 0/1] fix missing nanf definition in StdLib

2023-10-26 Thread Jayaprakash, N
This patch fixes the issue of missing definition of nanf in StdLib.
This has been extracted from the below PR submitted on edk2-libc.
https://github.com/tianocore/edk2-libc/pull/9

Jayaprakash N (1):
  ek2-libc: fix missing nanf definition in StdLib

 StdLib/LibC/LibC.inf|  1 +
 StdLib/LibC/Main/nanf_ieee754.c | 15 +++
 2 files changed, 16 insertions(+)
 create mode 100644 StdLib/LibC/Main/nanf_ieee754.c

-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] ek2-libc: fix missing nanf definition in StdLib

2023-10-26 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4576

File StdLib/Include/math.h:406 defines NAN constant as __nanf.__val.
The problem is that __nanf is never defined.
Fix is simple: define __nanf in similar way as __infinityf

This fix has been provided through the below PR on edk2-libc repo
https://github.com/tianocore/edk2-libc/pull/9.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Kloper Dimitry 
---
 StdLib/LibC/LibC.inf|  1 +
 StdLib/LibC/Main/nanf_ieee754.c | 15 +++
 2 files changed, 16 insertions(+)
 create mode 100644 StdLib/LibC/Main/nanf_ieee754.c

diff --git a/StdLib/LibC/LibC.inf b/StdLib/LibC/LibC.inf
index ad6a117..93e32e8 100644
--- a/StdLib/LibC/LibC.inf
+++ b/StdLib/LibC/LibC.inf
@@ -34,6 +34,7 @@
   Main/isnand_ieee754.c
   Main/isnanf_ieee754.c
   Main/infinityf_ieee754.c
+  Main/nanf_ieee754.c
   Main/Main.c
   Main/HtoNtoH.c
   Main/ByteSwap.c
diff --git a/StdLib/LibC/Main/nanf_ieee754.c b/StdLib/LibC/Main/nanf_ieee754.c
new file mode 100644
index 000..8e56d32
--- /dev/null
+++ b/StdLib/LibC/Main/nanf_ieee754.c
@@ -0,0 +1,15 @@
+/*
+ * IEEE-compatible nanf.c -- public domain.
+ */
+#include  
+#include 
+
+#include 
+#include 
+
+const union __float_u __nanf =
+#if BYTE_ORDER == BIG_ENDIAN
+  { { 0x7f, 0xc0, 0,0 } };
+#else
+  { {0,0,  0xc0, 0x7f } };
+#endif
-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] ek2-libc: realpath function signature doesn't match the standard

2023-10-26 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4574

This commit is for processing the below PR on edk2-libc repo
https://github.com/tianocore/edk2-libc/pull/10
The realpath function signature in stdlib of edk2-libc doesn't match
signature as per the standard definition of this function given below
https://pubs.opengroup.org/onlinepubs/009695399/functions/realpath.html
This patch extracted from the above pull request fixes this issue.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Kloper Dimitry 
---
 StdLib/Include/stdlib.h   | 4 ++--
 StdLib/LibC/StdLib/realpath.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/StdLib/Include/stdlib.h b/StdLib/Include/stdlib.h
index 0b9dfd3..022ddbd 100644
--- a/StdLib/Include/stdlib.h
+++ b/StdLib/Include/stdlib.h
@@ -74,7 +74,7 @@
const wchar_t * __restrict src, size_t limit);
 
   Miscelaneous functions for *nix compatibility
-char   *realpath(char *file_name, char *resolved_name);
+char   *realpath(const char *file_name, char *resolved_name);
 const char *getprogname (void);
 voidsetprogname (const char *progname);
 
@@ -875,7 +875,7 @@ size_t  wcstombs(char * __restrict Dest, const wchar_t * 
__restrict Src, size_t
 @retval NULLAn error occured.
 @retval resolved_name.
 **/
-char * realpath(char *file_name, char *resolved_name);
+char * realpath(const char *file_name, char *resolved_name);
 
 /** The getprogname() function returns the name of the program.  If the name
 has not been set yet, it will return NULL.
diff --git a/StdLib/LibC/StdLib/realpath.c b/StdLib/LibC/StdLib/realpath.c
index 3d4118d..29abe9a 100644
--- a/StdLib/LibC/StdLib/realpath.c
+++ b/StdLib/LibC/StdLib/realpath.c
@@ -34,7 +34,7 @@
 **/
 char *
 realpath(
-  char *file_name,
+  const char *file_name,
   char *resolved_name
   )
 {
-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 0/1] realpath function signature doesn't match standard

2023-10-26 Thread Jayaprakash, N
This patch fixes the function signature of realpath to match with the standard
defined signature. This patch bas been extracted from the  below pull request
raised on edk2-libc. 
https://github.com/tianocore/edk2-libc/pull/10

Jayaprakash N (1):
  ek2-libc: realpath function signature doesn't match the standard

 StdLib/Include/stdlib.h   | 4 ++--
 StdLib/LibC/StdLib/realpath.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.40.0.windows.1



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




Re: [edk2-devel] edk2-libc Python Build issue

2023-10-22 Thread Jayaprakash, N
You can build edk2-libc Python 3.6.8 using GCC tool chain by following the BKMs 
documented in this file
https://github.com/tianocore/edk2-libc/blob/master/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst


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




Re: [edk2-devel] [edk2-libc Patch 1/1] ek2-libc: Enhance StdLib for supporting Aarch64 and ARM

2023-10-22 Thread Jayaprakash, N
Thanks Pedro.

These are pretty old PRs and some of them have valuable contributions to 
edk2-libc. 
Not every PR owner is interested in submitting the email patch for the PRs. 
Mike and Rebecca are aware of this. We had a discussion couple of Months ago on 
processing these PRs. 
I have volunteered to send email patches on behalf of these old PRs raised on 
edk2-libc over last few years.

Regarding the patch currently under review, I have extracted the patch from PR 
https://github.com/tianocore/edk2-libc/pull/3) and submitted it for review 
without any changes of mine added to it to retain the sanctity of the original 
changes.
 
All the changes are owned by Tyler Erickson  and he 
has added his consent in the PR https://github.com/tianocore/edk2-libc/pull/3 
I agree this could have been submitted as multiple patches but since I am not 
the original author I don't wanted to make changes to this patch. 
Since the original author of the changes has already given consent through 
Signed-off-by clause in the PR, It doesn't require my signature.
Also while merging the change the commit log message would be edited to reflect 
the author correctly. 

Adding Tyler Erickson  to this review discussions 
so that he can take appropriate action on the comments. 
@Tyler Erickson Would you want to take a look at these comments and make 
changes accordingly.

Regards,
JP
-Original Message-
From: Pedro Falcato  
Sent: Saturday, October 21, 2023 1:57 AM
To: devel@edk2.groups.io; Jayaprakash, N 
Cc: Rebecca Cran ; Kinney, Michael D 
; Tyler Erickson ; Ard 
Biesheuvel ; Leif Lindholm 
Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] ek2-libc: Enhance StdLib for 
supporting Aarch64 and ARM

On Fri, Oct 20, 2023 at 3:04 PM Jayaprakash, N  wrote:
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4570
>
> This commit is for processing the below PR on edk2-libc repo
> https://github.com/tianocore/edk2-libc/pull/3
> These are the changes introduced to StdLib to build an application for 
> the UEFI shell.
> Added format macros for int types to Aarch64, ARM, and Ia32.
> Also modified the X64 macros so that everything would build when they 
> are used.
> Added some macros that can be used for compatibility that define when 
> socklen_t has been defined.
> Added getopt_long parser from OpenBSD to provide long and short option 
> parsing capability with getopt.

This patch is unreviewable. You'd think (from the subject) that it's an ARM 
centric change, but it ends up being a whole squashed up sequence of unrelated 
changes.
Please separate this into one commit per change.
>
> Cc: Rebecca Cran 
> Cc: Michael D Kinney 
> Cc: Jayaprakash N 
> Signed-off-by: Tyler Erickson 

AIUI, if this is Tyler's commit, you need a From: Tyler Erickson 
 (since this is his commit?). Also probably your 
own Signed-off-by, I'm not sure.

Lastly, you can't just take NetBSD's headers like this for one simple
reason: UNIX systems have used LP64 for ages, Windows systems use LLP64. What 
does this mean?
UNIX (and thus, code compiled using gcc or clang
linux/netbsd/whatever) has sizeof(long) = 8 for 64-bit systems, whereas in MSVC 
sizeof(long) = 4.

So macros like:
> #define PRIdPTR "ld"/* intptr_t */
> #define PRIuPTR "lu"/* uintptr_t */

etc, are not correct on MSVC.

Tip: since it's pretty safe, you can probably have two headers: 32-bit 
architectures (ILP32, should not change between MSVC and GCC/clang) and 64-bit 
architectures (LP64 on GCC/clang, LLP64 on MSVC). The same goes for the other 
type-related headers (I have *no* idea if those are correct).

--
Pedro


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




[edk2-devel] [edk2-libc Patch 1/1] ek2-libc: Enhance StdLib for supporting Aarch64 and ARM

2023-10-20 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4570

This commit is for processing the below PR on edk2-libc repo
https://github.com/tianocore/edk2-libc/pull/3
These are the changes introduced to StdLib to build
an application for the UEFI shell.
Added format macros for int types to Aarch64, ARM, and Ia32.
Also modified the X64 macros so that everything would build
when they are used.
Added some macros that can be used for compatibility that define when
socklen_t has been defined.
Added getopt_long parser from OpenBSD to provide long and
short option parsing capability with getopt.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Tyler Erickson 
---
 StdLib/Include/Aarch64/machine/int_fmtio.h | 211 +
 StdLib/Include/Arm/machine/int_fmtio.h | 211 +
 StdLib/Include/Ia32/machine/int_fmtio.h| 212 +
 StdLib/Include/X64/machine/int_fmtio.h | 324 ++---
 StdLib/Include/getopt.h|  76 +++
 StdLib/Include/inttypes.h  |   2 +-
 StdLib/Include/sys/socket.h|   6 +
 StdLib/Include/unistd.h|   7 +-
 StdLib/LibC/LibC.inf   |   1 +
 StdLib/LibC/Uefi/Uefi.inf  |   1 +
 StdLib/LibC/Uefi/compat.c  |  40 +-
 StdLib/LibC/Uefi/getopt_long.c | 523 +
 12 files changed, 1406 insertions(+), 208 deletions(-)
 create mode 100644 StdLib/Include/Aarch64/machine/int_fmtio.h
 create mode 100644 StdLib/Include/Arm/machine/int_fmtio.h
 create mode 100644 StdLib/Include/Ia32/machine/int_fmtio.h
 create mode 100644 StdLib/Include/getopt.h
 create mode 100644 StdLib/LibC/Uefi/getopt_long.c

diff --git a/StdLib/Include/Aarch64/machine/int_fmtio.h 
b/StdLib/Include/Aarch64/machine/int_fmtio.h
new file mode 100644
index 000..f091a7d
--- /dev/null
+++ b/StdLib/Include/Aarch64/machine/int_fmtio.h
@@ -0,0 +1,211 @@
+/*  $NetBSD: int_fmtio.h,v 1.10 2018/07/15 00:36:13 christos Exp $  */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _ARM_INT_FMTIO_H_
+#define _ARM_INT_FMTIO_H_
+
+/*
+ * 7.8.1 Macros for format specifiers
+ */
+
+/* fprintf macros for signed integers */
+#define PRId8   "d" /* int8_t   */
+#define PRId16  "d" /* int16_t  */
+#define PRId32  "d" /* int32_t  */
+#define PRId64  "lld"   /* int64_t  */
+#define PRIdLEAST8  "d" /* int_least8_t */
+#define PRIdLEAST16 "d" /* int_least16_t*/
+#define PRIdLEAST32 "d" /* int_least32_t*/
+#define PRIdLEAST64 "lld"   /* int_least64_t*/
+#define PRIdFAST8   "d" /* int_fast8_t  */
+#define PRIdFAST16  "d" /* int_fast16_t */
+#define PRIdFAST32  "d" /* int_fast32_t */
+#define PRIdFAST64  "lld"   /* int_fast64_t */
+#define PRIdMAX "lld"   /* intmax_t */
+#define PRIdPTR "ld"/* intptr_t */
+
+#define PRIi8   "i" /* int8_t   */
+#define PRIi16  "i" /* int16_t  */
+#define PRIi32  "i" /* int32_t  */
+#define PRIi64  "lli"   /* int64_t  */
+#define PRIiLEAST8  "i" /* int_least8_t */
+#define PRIiLEAST16 "i" /* int_least16_t*/
+#define PRIiLEAST32 "i" /* int_least32_t*/
+#define PRIiLEAST64 "lli"   /* int_least64_t*/
+#define PRIiFAST8   "i" /* int_fast8_

[edk2-devel] [edk2-libc Patch 0/1] edk2-libc - Enhancements to StdLibc

2023-10-20 Thread Jayaprakash, N
This patch request contains enhancements made to StdLibc
through BZ https://bugzilla.tianocore.org/show_bug.cgi?id=4570


Jayaprakash N (1):
  ek2-libc: Enhance StdLib for supporting Aarch64 and ARM

 StdLib/Include/Aarch64/machine/int_fmtio.h | 211 +
 StdLib/Include/Arm/machine/int_fmtio.h | 211 +
 StdLib/Include/Ia32/machine/int_fmtio.h| 212 +
 StdLib/Include/X64/machine/int_fmtio.h | 324 ++---
 StdLib/Include/getopt.h|  76 +++
 StdLib/Include/inttypes.h  |   2 +-
 StdLib/Include/sys/socket.h|   6 +
 StdLib/Include/unistd.h|   7 +-
 StdLib/LibC/LibC.inf   |   1 +
 StdLib/LibC/Uefi/Uefi.inf  |   1 +
 StdLib/LibC/Uefi/compat.c  |  40 +-
 StdLib/LibC/Uefi/getopt_long.c | 523 +
 12 files changed, 1406 insertions(+), 208 deletions(-)
 create mode 100644 StdLib/Include/Aarch64/machine/int_fmtio.h
 create mode 100644 StdLib/Include/Arm/machine/int_fmtio.h
 create mode 100644 StdLib/Include/Ia32/machine/int_fmtio.h
 create mode 100644 StdLib/Include/getopt.h
 create mode 100644 StdLib/LibC/Uefi/getopt_long.c

-- 
2.40.0.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 1/1] ek2-libc: Fix compilation instructions of socket module as builtin module

2023-09-01 Thread Jayaprakash, N
It's a documentation change.

Reviewed-by: Jayaprakash N 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Jayaprakash, N
Sent: Friday, September 1, 2023 9:48 PM
To: devel@edk2.groups.io
Cc: Jayaprakash, N ; Rebecca Cran ; 
Kinney, Michael D 
Subject: [edk2-devel] [edk2-libc Patch 1/1] ek2-libc: Fix compilation 
instructions of socket module as builtin module

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

This change fixes the insufficient documentation instructions to compile socket 
module as built in module into Python interpreter

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .../Python/Python-3.6.8/Py368ReadMe.txt | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt 
b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
index eae56b4..2b27c92 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
+++ b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
@@ -129,13 +129,14 @@ system as follows:
 
 6. Example: Enabling socket support
 ===
-  1.  enable {"_socket", init_socket}, in PyMod-3.6.8\Modules\config.c
-  2.  enable LibraryClasses BsdSocketLib and EfiSocketLib in Python368.inf
-  3.  Build Python interpreter application using below command
+  1. Uncomment the statement // {"_socket", init_socket}, in 
+ PyMod-3.6.8\Modules\config.c  2. Uncomment BsdSocketLib and 
+ EfiSocketLib LibraryClasses in Python368.inf  3. Uncomment the 
+ statement #Modules/socketmodule.c in Python368.inf  4. Build Python 
+ interpreter application using below command
   build -a X64 -p AppPkg\AppPkg.dsc
-  6.  copy Build\AppPkg\RELEASE_VS2017\X64\Python.efi to \Efi\Tools on your
-  target system. Replace "RELEASE_VS2017", in the source path, with
-  values appropriate for your tool chain.
+  5. Copy Build\AppPkg\RELEASE_VS2017\X64\Python.efi to \Efi\Tools on your
+ target system. Replace "RELEASE_VS2017", in the source path, with
+ values appropriate for your tool chain.
 
 7. Running Python
 =
--
2.40.0.windows.1








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




[edk2-devel] [edk2-libc Patch 1/1] ek2-libc: Fix compilation instructions of socket module as builtin module

2023-09-01 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4548

This change fixes the insufficient documentation instructions
to compile socket module as built in module into Python interpreter

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .../Python/Python-3.6.8/Py368ReadMe.txt | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt 
b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
index eae56b4..2b27c92 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
+++ b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
@@ -129,13 +129,14 @@ system as follows:
 
 6. Example: Enabling socket support
 ===
-  1.  enable {"_socket", init_socket}, in PyMod-3.6.8\Modules\config.c
-  2.  enable LibraryClasses BsdSocketLib and EfiSocketLib in Python368.inf
-  3.  Build Python interpreter application using below command
+  1. Uncomment the statement // {"_socket", init_socket}, in 
PyMod-3.6.8\Modules\config.c
+  2. Uncomment BsdSocketLib and EfiSocketLib LibraryClasses in Python368.inf
+  3. Uncomment the statement #Modules/socketmodule.c in Python368.inf
+  4. Build Python interpreter application using below command
   build -a X64 -p AppPkg\AppPkg.dsc
-  6.  copy Build\AppPkg\RELEASE_VS2017\X64\Python.efi to \Efi\Tools on your
-  target system. Replace "RELEASE_VS2017", in the source path, with
-  values appropriate for your tool chain.
+  5. Copy Build\AppPkg\RELEASE_VS2017\X64\Python.efi to \Efi\Tools on your
+ target system. Replace "RELEASE_VS2017", in the source path, with
+ values appropriate for your tool chain.
 
 7. Running Python
 =
-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 0/1] AppPkg - fix python socket module compilation instructions

2023-09-01 Thread Jayaprakash, N
This patch fixes the insufficient documentation issue in Py368ReadMe.txt
for compiling the socket module as builtin module of Python.
The issue is reported in BZ 4548. 

Jayaprakash N (1):
  ek2-libc: Fix compilation instructions of socket module as builtin
module

 .../Python/Python-3.6.8/Py368ReadMe.txt | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] ek2-libc: socket module of python UEFI fails to compile with GCC

2023-08-31 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4545

The compilation issues reported in the BZ are fixed by
defining below 2 macros in pyconfig.h
HAVE_ADDRINFO
HAVE_SOCKADDR_STORAGE

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .../Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h| 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h
index 3b9eceb..983cfda 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h
@@ -66,7 +66,7 @@
 #undef HAVE_ACOSH
 
 /* struct addrinfo (netdb.h) */
-#undef HAVE_ADDRINFO
+#define HAVE_ADDRINFO   1
 
 /* Define to 1 if you have the 'alarm' function. */
 #undef HAVE_ALARM
@@ -683,7 +683,7 @@
 #undef HAVE_SOCKADDR_SA_LEN
 
 /* struct sockaddr_storage (sys/socket.h) */
-#undef HAVE_SOCKADDR_STORAGE
+#define HAVE_SOCKADDR_STORAGE   1
 
 /* Define if you have the 'socketpair' function. */
 #undef HAVE_SOCKETPAIR
-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 0/1] python socket module fails with GCC compiler

2023-08-31 Thread Jayaprakash, N
This patch fixes the compilation issue of Python UEFI interpreters socket
module due to duplicate definitions of certain structures as reported 
in BZ 4545.

Jayaprakash N (1):
  ek2-libc: socket module of python UEFI fails to compile with GCC

 .../Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h| 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.40.0.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: Socket completion functions are not called on Linux Compilation

2023-08-29 Thread Jayaprakash, N


Reviewed-by: Jayaprakash N  

Regards,
JP
-Original Message-
From: devel@edk2.groups.io  On Behalf Of Jayaprakash, N
Sent: Monday, August 28, 2023 4:01 PM
To: devel@edk2.groups.io
Cc: Jayaprakash, N ; Rebecca Cran ; 
Kinney, Michael D ; Kloper, Dimitry 

Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: Socket completion 
functions are not called on Linux Compilation

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

>From the bug description:
Analysis and root cause


After some investigation and debugging I have figured out the following:

The following function is implemented in file  edk2/StdLib/EfiSocketLib/Tcp4.c

VOID
EslTcp4ListenComplete (
  IN EFI_EVENT Event,
  IN ESL_PORT * pPort
);

The function is used in EslTcp4Listen() as a callback for connection 
notification event, it is created by the following code:

Status = gBS->CreateEvent ( EVT_NOTIFY_SIGNAL,
TPL_SOCKETS,
(EFI_EVENT_NOTIFY)EslTcp4ListenComplete,
pPort,
>ListenToken.CompletionToken.Event );

And this is actually introduces a bug: the CreateEvent() third parameter is of 
type EFI_EVENT_NOTIFY which is defined as

typedef
VOID
(EFIAPI *EFI_EVENT_NOTIFY) (
   IN EFI_EVENT Event,
   IN VOID *Context
);

That EFIAPI tag is important since it defines an ABI that is used by compiler 
in order to call the callback function. Note that EslTcp4ListenComplete() is 
not marked as EFIAPI.

Thus, on Linux, where gcc defaults to SYSV ABI, there will be mismatch between 
arguments passed to EslTcp4ListenComplete() by the event dispatcher. It expects 
function with WIN64 ABI, while its code compiled with default SYSV ABI. It will 
look in wrong registers for arguments.

Specifically pPort pointer references an wrong memory location. Luckily
EslTcp4ListenComplete() performs sanity check of the pPort structure and 
discovers that it is invalid. This causes discarding of all incoming 
connections.

Proposed fix
---

The fix is trivial - mark EslTcp4ListenComplete() as EFIAPI. This is a little 
more complicated, since there are additional callback functions that suffer 
from the same problem. In addition fixing those causes some compiler warnings 
that shall be addressed. Attached patch fixes the problem for me.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Dimitry Kloper 
---
 StdLib/EfiSocketLib/Ip4.c| 11 +++
 StdLib/EfiSocketLib/Socket.c |  5 +++--  StdLib/EfiSocketLib/Socket.h | 12 
++--
 StdLib/EfiSocketLib/Tcp4.c   | 35 ---
 StdLib/EfiSocketLib/Tcp6.c   | 35 ---
 StdLib/EfiSocketLib/Udp4.c   | 10 ++
 StdLib/EfiSocketLib/Udp6.c   | 10 ++
 7 files changed, 68 insertions(+), 50 deletions(-)

diff --git a/StdLib/EfiSocketLib/Ip4.c b/StdLib/EfiSocketLib/Ip4.c index 
4b8f05b..8d25537 100644
--- a/StdLib/EfiSocketLib/Ip4.c
+++ b/StdLib/EfiSocketLib/Ip4.c
@@ -588,16 +588,17 @@ EslIp4RemoteAddressSet (
   @param [in] pIo   The address of an ::ESL_IO_MGMT structure
 
 **/
-VOID
+VOID EFIAPI
 EslIp4RxComplete (
   IN EFI_EVENT Event,
-  IN ESL_IO_MGMT * pIo
+  IN VOID *context
   )
 {
   size_t LengthInBytes;
   ESL_PACKET * pPacket;
   EFI_IP4_RECEIVE_DATA * pRxData;
   EFI_STATUS Status;
+  ESL_IO_MGMT * pIo = (ESL_IO_MGMT *)context;
 
   DBG_ENTER ( );
 
@@ -1117,10 +1118,10 @@ EslIp4TxBuffer (
   @param [in] pIo   The address of an ::ESL_IO_MGMT structure
 
 **/
-VOID
+VOID EFIAPI
 EslIp4TxComplete (
   IN EFI_EVENT Event,
-  IN ESL_IO_MGMT * pIo
+  IN VOID *context
   )
 {
   UINT32 LengthInBytes;
@@ -1128,6 +1129,7 @@ EslIp4TxComplete (
   ESL_PACKET * pPacket;
   ESL_SOCKET * pSocket;
   EFI_STATUS Status;
+  ESL_IO_MGMT * pIo = (ESL_IO_MGMT*)context;
 
   DBG_ENTER ( );
 
@@ -1341,6 +1343,7 @@ CONST ESL_PROTOCOL_API cEslIp4Api = {
   OFFSET_OF ( ESL_PORT, Context.Ip4.ModeData.ConfigData ),
   OFFSET_OF ( ESL_LAYER, pIp4List ),
   OFFSET_OF ( struct sockaddr_in, sin_zero ),
+
   sizeof ( struct sockaddr_in ),
   AF_INET,
   sizeof (((ESL_PACKET *)0 )->Op.Ip4Rx ), diff --git 
a/StdLib/EfiSocketLib/Socket.c b/StdLib/EfiSocketLib/Socket.c index 
59b8efa..ee15b62 100644
--- a/StdLib/EfiSocketLib/Socket.c
+++ b/StdLib/EfiSocketLib/Socket.c
@@ -3970,14 +3970,15 @@ EslSocketPortClose (
   @param[in]  Event The close completion event
   @param[in]  pPort Address of an ::ESL_PORT structure.
 **/
-VOID
+VOID EFIAPI
 EslSocketPortCloseComplete (
   IN EFI_EVENT Event,
-  IN ESL_PORT * pPort
+  IN VOID *context
   )
 {
   ESL_IO_MGMT * pIo;
   EFI_STATUS Status;
+  ESL_PORT * pPort = (ESL_PORT*) context;
 
   DBG_ENTER ( );
   VERIFY_AT_TPL ( TPL_SOCKETS );
diff --git a/StdLib/EfiSocketLib/Socket.h b/StdLib/EfiSocketLib/Socket.h index 
d7d55e6..81d3b2c 100644
--- a/StdLib/EfiSocketLib/Socket.h
+++ b/StdLib/EfiSocketLib/Socket.h
@@ -

[edk2-devel] [edk2-libc Patch 1/1] edk2-libc: Socket completion functions are not called on Linux Compilation

2023-08-28 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=983

>From the bug description:
Analysis and root cause


After some investigation and debugging I have figured out the following:

The following function is implemented in file  edk2/StdLib/EfiSocketLib/Tcp4.c

VOID
EslTcp4ListenComplete (
  IN EFI_EVENT Event,
  IN ESL_PORT * pPort
);

The function is used in EslTcp4Listen() as a callback for connection
notification event, it is created by the following code:

Status = gBS->CreateEvent ( EVT_NOTIFY_SIGNAL,
TPL_SOCKETS,
(EFI_EVENT_NOTIFY)EslTcp4ListenComplete,
pPort,
>ListenToken.CompletionToken.Event );

And this is actually introduces a bug: the CreateEvent() third parameter is of
type EFI_EVENT_NOTIFY which is defined as

typedef
VOID
(EFIAPI *EFI_EVENT_NOTIFY) (
   IN EFI_EVENT Event,
   IN VOID *Context
);

That EFIAPI tag is important since it defines an ABI that is used by compiler
in order to call the callback function. Note that EslTcp4ListenComplete() is
not marked as EFIAPI.

Thus, on Linux, where gcc defaults to SYSV ABI, there will be mismatch between
arguments passed to EslTcp4ListenComplete() by the event dispatcher. It expects
function with WIN64 ABI, while its code compiled with default SYSV ABI. It will
look in wrong registers for arguments.

Specifically pPort pointer references an wrong memory location. Luckily
EslTcp4ListenComplete() performs sanity check of the pPort structure and
discovers that it is invalid. This causes discarding of all incoming
connections.

Proposed fix
---

The fix is trivial - mark EslTcp4ListenComplete() as EFIAPI. This is a little
more complicated, since there are additional callback functions that suffer
from the same problem. In addition fixing those causes some compiler warnings
that shall be addressed. Attached patch fixes the problem for me.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Dimitry Kloper 
---
 StdLib/EfiSocketLib/Ip4.c| 11 +++
 StdLib/EfiSocketLib/Socket.c |  5 +++--
 StdLib/EfiSocketLib/Socket.h | 12 ++--
 StdLib/EfiSocketLib/Tcp4.c   | 35 ---
 StdLib/EfiSocketLib/Tcp6.c   | 35 ---
 StdLib/EfiSocketLib/Udp4.c   | 10 ++
 StdLib/EfiSocketLib/Udp6.c   | 10 ++
 7 files changed, 68 insertions(+), 50 deletions(-)

diff --git a/StdLib/EfiSocketLib/Ip4.c b/StdLib/EfiSocketLib/Ip4.c
index 4b8f05b..8d25537 100644
--- a/StdLib/EfiSocketLib/Ip4.c
+++ b/StdLib/EfiSocketLib/Ip4.c
@@ -588,16 +588,17 @@ EslIp4RemoteAddressSet (
   @param [in] pIo   The address of an ::ESL_IO_MGMT structure
 
 **/
-VOID
+VOID EFIAPI
 EslIp4RxComplete (
   IN EFI_EVENT Event,
-  IN ESL_IO_MGMT * pIo
+  IN VOID *context
   )
 {
   size_t LengthInBytes;
   ESL_PACKET * pPacket;
   EFI_IP4_RECEIVE_DATA * pRxData;
   EFI_STATUS Status;
+  ESL_IO_MGMT * pIo = (ESL_IO_MGMT *)context;
 
   DBG_ENTER ( );
 
@@ -1117,10 +1118,10 @@ EslIp4TxBuffer (
   @param [in] pIo   The address of an ::ESL_IO_MGMT structure
 
 **/
-VOID
+VOID EFIAPI
 EslIp4TxComplete (
   IN EFI_EVENT Event,
-  IN ESL_IO_MGMT * pIo
+  IN VOID *context
   )
 {
   UINT32 LengthInBytes;
@@ -1128,6 +1129,7 @@ EslIp4TxComplete (
   ESL_PACKET * pPacket;
   ESL_SOCKET * pSocket;
   EFI_STATUS Status;
+  ESL_IO_MGMT * pIo = (ESL_IO_MGMT*)context;
 
   DBG_ENTER ( );
 
@@ -1341,6 +1343,7 @@ CONST ESL_PROTOCOL_API cEslIp4Api = {
   OFFSET_OF ( ESL_PORT, Context.Ip4.ModeData.ConfigData ),
   OFFSET_OF ( ESL_LAYER, pIp4List ),
   OFFSET_OF ( struct sockaddr_in, sin_zero ),
+
   sizeof ( struct sockaddr_in ),
   AF_INET,
   sizeof (((ESL_PACKET *)0 )->Op.Ip4Rx ),
diff --git a/StdLib/EfiSocketLib/Socket.c b/StdLib/EfiSocketLib/Socket.c
index 59b8efa..ee15b62 100644
--- a/StdLib/EfiSocketLib/Socket.c
+++ b/StdLib/EfiSocketLib/Socket.c
@@ -3970,14 +3970,15 @@ EslSocketPortClose (
   @param[in]  Event The close completion event
   @param[in]  pPort Address of an ::ESL_PORT structure.
 **/
-VOID
+VOID EFIAPI
 EslSocketPortCloseComplete (
   IN EFI_EVENT Event,
-  IN ESL_PORT * pPort
+  IN VOID *context
   )
 {
   ESL_IO_MGMT * pIo;
   EFI_STATUS Status;
+  ESL_PORT * pPort = (ESL_PORT*) context;
 
   DBG_ENTER ( );
   VERIFY_AT_TPL ( TPL_SOCKETS );
diff --git a/StdLib/EfiSocketLib/Socket.h b/StdLib/EfiSocketLib/Socket.h
index d7d55e6..81d3b2c 100644
--- a/StdLib/EfiSocketLib/Socket.h
+++ b/StdLib/EfiSocketLib/Socket.h
@@ -591,9 +591,9 @@ EFI_STATUS
 **/
 typedef
 VOID
-(* PFN_API_IO_COMPLETE) (
+(EFIAPI * PFN_API_IO_COMPLETE) (
   IN EFI_EVENT Event,
-  IN ESL_IO_MGMT * pIo
+  IN VOID *pIo //IN ESL_IO_MGMT * pIo
   );
 
 /**
@@ -909,9 +909,9 @@ EFI_STATUS
 **/
 typedef
 VOID
-(* PFN_API_TX_COMPLETE) (
+(EFIAPI * PFN_API_TX_COMPLETE) (
   IN EFI_EVENT Event,
-  IN ESL_IO_MGMT * pIo
+  IN VOID *pIo //IN ESL_I

[edk2-devel] [edk2-libc Patch 0/1] Socket completion functions not called on Linux Compilation

2023-08-28 Thread Jayaprakash, N
This patch fixes the issue reported in BZ given below:
https://bugzilla.tianocore.org/show_bug.cgi?id=983
Patch extracted from PR https://github.com/tianocore/edk2-libc/pull/7

Jayaprakash N (1):
  edk2-libc: Socket completion functions are not called on Linux
Compilation

 StdLib/EfiSocketLib/Ip4.c| 11 +++
 StdLib/EfiSocketLib/Socket.c |  5 +++--
 StdLib/EfiSocketLib/Socket.h | 12 ++--
 StdLib/EfiSocketLib/Tcp4.c   | 35 ---
 StdLib/EfiSocketLib/Tcp6.c   | 35 ---
 StdLib/EfiSocketLib/Udp4.c   | 10 ++
 StdLib/EfiSocketLib/Udp6.c   | 10 ++
 7 files changed, 68 insertions(+), 50 deletions(-)

-- 
2.40.0.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Fix console jump to 0, 0 issue in lseek()

2023-08-25 Thread Jayaprakash, N
Reviewed the changes and it looks good.
Also verified that the fix solves the problem.

Reviewed-by : Jayaprakash N 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Jayaprakash, N
Sent: Thursday, August 24, 2023 10:04 PM
To: devel@edk2.groups.io
Cc: Jayaprakash, N ; Rebecca Cran ; 
Kinney, Michael D ; Kloper, Dimitry 

Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Fix console jump 
to 0, 0 issue in lseek()

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

Python code opens console file descriptor and uses lseek() with position == 0 
and SEEK_CUR as 'do nothing, check console is alive' operation.

Current implementation of daConsole ignores whence argument, this is wrong in 
case lseek(0, SEEK_CUR) will send cursor to (0,0).
This fix is not generic, but solves the particular situation.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Kloper Dimitry 
---
 StdLib/LibC/Uefi/Devices/Console/daConsole.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/StdLib/LibC/Uefi/Devices/Console/daConsole.c 
b/StdLib/LibC/Uefi/Devices/Console/daConsole.c
index 56571af..ba031d6 100644
--- a/StdLib/LibC/Uefi/Devices/Console/daConsole.c
+++ b/StdLib/LibC/Uefi/Devices/Console/daConsole.c
@@ -141,8 +141,16 @@ da_ConSeek(
 EFIerrno = RETURN_UNSUPPORTED;
 return -1;
   }
-  // Everything is OK to do the final verification and "seek".
+
   Proto = (EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)Stream->Dev;
+
+  if(Position == 0 && whence == SEEK_CUR) {
+CursorPos.XYpos.Column  = (UINT32)Proto->Mode->CursorColumn;
+CursorPos.XYpos.Row = (UINT32)Proto->Mode->CursorRow;
+return CursorPos.Offset;
+  }
+
+  // Everything is OK to do the final verification and "seek".
   CursorPos.Offset = Position;
 
   EFIerrno = Proto->SetCursorPosition(Proto,
--
2.40.0.windows.1








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




[edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Fix console jump to 0, 0 issue in lseek()

2023-08-24 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4531

Python code opens console file descriptor and uses lseek()
with position == 0 and SEEK_CUR as
'do nothing, check console is alive' operation.

Current implementation of daConsole ignores whence argument,
this is wrong in case lseek(0, SEEK_CUR) will send cursor to (0,0).
This fix is not generic, but solves the particular situation.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Kloper Dimitry 
---
 StdLib/LibC/Uefi/Devices/Console/daConsole.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/StdLib/LibC/Uefi/Devices/Console/daConsole.c 
b/StdLib/LibC/Uefi/Devices/Console/daConsole.c
index 56571af..ba031d6 100644
--- a/StdLib/LibC/Uefi/Devices/Console/daConsole.c
+++ b/StdLib/LibC/Uefi/Devices/Console/daConsole.c
@@ -141,8 +141,16 @@ da_ConSeek(
 EFIerrno = RETURN_UNSUPPORTED;
 return -1;
   }
-  // Everything is OK to do the final verification and "seek".
+
   Proto = (EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)Stream->Dev;
+
+  if(Position == 0 && whence == SEEK_CUR) {
+CursorPos.XYpos.Column  = (UINT32)Proto->Mode->CursorColumn;
+CursorPos.XYpos.Row = (UINT32)Proto->Mode->CursorRow;
+return CursorPos.Offset;
+  }
+
+  // Everything is OK to do the final verification and "seek".
   CursorPos.Offset = Position;
 
   EFIerrno = Proto->SetCursorPosition(Proto,
-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 0/1] Fix issue with lseek function

2023-08-24 Thread Jayaprakash, N
This patch fixes a corner case issue with the lseek function.
The issue is captured in  
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4531

Jayaprakash N (1):
  edk2-libc/StdLib: Fix console jump to 0, 0 issue in lseek()

 StdLib/LibC/Uefi/Devices/Console/daConsole.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: file descriptor leak in rename()

2023-08-21 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4529

rename() call leads to a function that makes open() for source file
to be renamed. The resulting file descriptor is never closed.
If you have to rename a couple of files this will quickly exhaust
the descriptor table.
The fix is trivial - just close the fd before returning from the function.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Kloper Dimitry 
---
 StdLib/LibC/Uefi/Devices/UefiShell/daShell.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c 
b/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c
index 861765e..06fcc3b 100644
--- a/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c
+++ b/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c
@@ -670,6 +670,7 @@ da_ShellRename(
 free(NewFileInfo);
 if(Status == EFI_SUCCESS) {
   // File has been successfully renamed.  We are DONE!
+  close(OldFd);
   return 0;
 }
 errno = EFI2errno( Status );
@@ -688,6 +689,7 @@ da_ShellRename(
 else {
   errno = ENOMEM;
 }
+close(OldFd);
   }
   return -1;
 }
-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 0/1] file descriptor leak in rename

2023-08-21 Thread Jayaprakash, N
This patch provides fix for the file descriptor leak issue in 
rename function from the LibC library of the StdLib of edk2-libc

Jayaprakash N (1):
  edk2-libc/StdLib: file descriptor leak in rename()

 StdLib/LibC/Uefi/Devices/UefiShell/daShell.c | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.40.0.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/AppPkg: Fix documentation issue with edk2module.c

2023-08-07 Thread Jayaprakash, N
Reviewed-by: Jayaprakash Nevara 


-Original Message-
From: R, Vishal  
Sent: Thursday, August 3, 2023 10:12 PM
To: devel@edk2.groups.io
Cc: R, Vishal ; Rebecca Cran ; Kinney, 
Michael D ; Jayaprakash, N 
Subject: [edk2-libc Patch 1/1] edk2-libc/AppPkg: Fix documentation issue with 
edk2module.c

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

This commit fixes the API documentation issue reported via the BZ4517 Updated 
documentation strings for rdmsr() and wrmsr()

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Vishal R 
---
 .../PyMod-3.6.8/Modules/edk2module.c  | 28 +++
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
index 9641f86..05b1a5a 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2mo
+++ dule.c
@@ -3839,8 +3839,16 @@ void WritePCICfg(  }
 
 PyDoc_STRVAR(efi_rdmsr__doc__,
-"rdmsr(ecx) -> (eax,edx)\n\
-Read the given MSR.");
+"rdmsr(msr) -> (lower_32bits, higher_32bits)\n\ \n\ Read the given msr 
+and return the data as tuple.\n\ \n\ Parameters:\n\
+msr - The msr in hex or int format\n\ \n\ Return Value:\n\
+a tuple with lower and higher 32 bit values read from the msr\n\ 
+");
 
 static PyObject *
 edk2_rdmsr(PyObject *self, PyObject *args) @@ -3857,9 +3865,19 @@ 
edk2_rdmsr(PyObject *self, PyObject *args)
   return Py_BuildValue("(II)", (unsigned long)veax, (unsigned long)vedx);  }
 
-PyDoc_STRVAR(efi_wrmsr__doc__,
-"wrmsr(ecx, eax, edx) -> None\n\
-Write edx:eax to the given MSR.");
+PyDoc_STRVAR(efi_wrmsr__doc__,
+"wrmsr(msr, lower_32bits, higher_32bits) -> None\n\ \n\ Writes 
+higher_32bits:lower_32bits to the given msr.\n\ \n\ Parameters:\n\
+msr - The msr in hex or int format\n\
+lower_32bits - The lower 32 bit data for the msr\n\
+higher_32bits - The higher 32 bit data for the msr\n\ \n\ Return 
+Value:\n\
+None\n\
+");
 
 static PyObject *
 edk2_wrmsr(PyObject *self, PyObject *args)
--
2.39.1.windows.1



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




Re: [edk2-devel] [edk2-libc Patch v2 1/1] edk2-libc/StdLib: Fix uninitialized global variable

2023-07-30 Thread Jayaprakash, N
Reviewed-by: Jayaprakash N 

Regards,
JP
-Original Message-
From: devel@edk2.groups.io  On Behalf Of Jayaprakash, N
Sent: Wednesday, July 26, 2023 9:09 PM
To: devel@edk2.groups.io
Cc: Jayaprakash, N ; Rebecca Cran ; 
Kinney, Michael D ; Kloper, Dimitry 

Subject: [edk2-devel] [edk2-libc Patch v2 1/1] edk2-libc/StdLib: Fix 
uninitialized global variable

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

res_init() is called from different places in sockets library. It depends on 
global _res variable containing a state.
The problem is that if __BIND_RES_TEXT macro is not defined, _res is not 
initialized.
Depending on compiler and build optimization this can fill the variable with 
garbage that is later used by res_init().
Fix is trivial - explicitly initialize _res.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Kloper Dimitry 
---
 StdLib/BsdSocketLib/res_init.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/StdLib/BsdSocketLib/res_init.c b/StdLib/BsdSocketLib/res_init.c 
index 613a76a..9df7d4f 100644
--- a/StdLib/BsdSocketLib/res_init.c
+++ b/StdLib/BsdSocketLib/res_init.c
@@ -121,9 +121,11 @@ static u_int32_t net_mask __P((struct in_addr));
  */
 
 struct __res_state _res
-# if defined(__BIND_RES_TEXT)
+#if defined(__BIND_RES_TEXT)
 = { RES_TIMEOUT, }  /* Motorola, et al. */ -# endif
+#else
+= {0}
+#endif
 ;
 
 
--
2.40.0.windows.1








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




[edk2-devel] [edk2-libc Patch v2 1/1] edk2-libc/StdLib: Fix uninitialized global variable

2023-07-26 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4506

res_init() is called from different places in sockets library. It depends
on global _res variable containing a state.
The problem is that if __BIND_RES_TEXT macro is not defined, _res is not
initialized.
Depending on compiler and build optimization this can fill the
variable with garbage that is later used by res_init().
Fix is trivial - explicitly initialize _res.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Kloper Dimitry 
---
 StdLib/BsdSocketLib/res_init.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/StdLib/BsdSocketLib/res_init.c b/StdLib/BsdSocketLib/res_init.c
index 613a76a..9df7d4f 100644
--- a/StdLib/BsdSocketLib/res_init.c
+++ b/StdLib/BsdSocketLib/res_init.c
@@ -121,9 +121,11 @@ static u_int32_t net_mask __P((struct in_addr));
  */
 
 struct __res_state _res
-# if defined(__BIND_RES_TEXT)
+#if defined(__BIND_RES_TEXT)
 = { RES_TIMEOUT, }  /* Motorola, et al. */
-# endif
+#else
+= {0}
+#endif
 ;
 
 
-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch v2 0/1] edk2-libc:Fix uninitialized global variable

2023-07-26 Thread Jayaprakash, N
This patch contains a fix for the uninitialized global variable 
in edk2-libc/StdLib/BsdSocketLib/res_init.c

Jayaprakash N (1):
  edk2-libc/StdLib: Fix uninitialized global variable

 StdLib/BsdSocketLib/res_init.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Fix uninitialized global variable

2023-07-25 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4506

res_init() is called from different places in sockets library. It depends
on global _res variable containing a state.

The problem is that if __BIND_RES_TEXT macro is not defined, _res is not
initialized. Depending on compiler and build optimization this can fill the
variable with garbage that is later used by res_init().

Fix is trivial - explicitly initialize _res.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Kloper Dimitry 
---
 StdLib/BsdSocketLib/res_init.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/StdLib/BsdSocketLib/res_init.c b/StdLib/BsdSocketLib/res_init.c
index 613a76a..faf2b5e 100644
--- a/StdLib/BsdSocketLib/res_init.c
+++ b/StdLib/BsdSocketLib/res_init.c
@@ -121,9 +121,11 @@ static u_int32_t net_mask __P((struct in_addr));
  */
 
 struct __res_state _res
-# if defined(__BIND_RES_TEXT)
+#if defined(__BIND_RES_TEXT)
 = { RES_TIMEOUT, }  /* Motorola, et al. */
-# endif
+#endif
+= {0}
+#endif
 ;
 
 
-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 0/1] edk2-libc/StdLib: Fix uninitialized global variable

2023-07-25 Thread Jayaprakash, N
This patch contains the fix for uninitialized global variable
in edk2-libc/StdLib/BsdSocketLib/res_init.c file.

Jayaprakash N (1):
  edk2-libc/StdLib: Fix uninitialized global variable

 StdLib/BsdSocketLib/res_init.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

-- 
2.40.0.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Uninitialized global variable

2023-07-21 Thread Jayaprakash, N


Reviewed by : Jayaprakash N 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Jayaprakash, N
Sent: Friday, July 21, 2023 9:22 PM
To: Kinney, Michael D ; devel@edk2.groups.io
Cc: Rebecca Cran ; Kloper, Dimitry 
; Kloper, Dimitry 
Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Uninitialized 
global variable

Hi Mike,

I was trying to explore with Co-authored-by tag as I simplified the patch with 
minor edits.
If it doesn't work I shall remove it.

I noticed after sending the patch. So I have sent V2 patch by removing the , in 
the names. 

I will go ahead and merge this change.

Regards,
JP
-Original Message-
From: Kinney, Michael D 
Sent: Friday, July 21, 2023 9:03 PM
To: Jayaprakash, N ; devel@edk2.groups.io
Cc: Rebecca Cran ; Kloper, Dimitry 
; Kloper, Dimitry ; Kinney, 
Michael D 
Subject: RE: [edk2-libc Patch 1/1] edk2-libc/StdLib: Uninitialized global 
variable

Hi JP,

I have not seen co-authored-by tag used before.

If Dimitry is the author, then please update git commit so Dimitry is the 
author and remove that tag.

Also, please make sure that names do not contain ','.

Should be: Dimity Kloper 

Thanks,

Mike

> -Original Message-
> From: Jayaprakash, N 
> Sent: Friday, July 21, 2023 8:27 AM
> To: devel@edk2.groups.io
> Cc: Jayaprakash, N ; Rebecca Cran 
> ; Kinney, Michael D 
> ; Kloper; Kloper, Dimitry 
> 
> Subject: [edk2-libc Patch 1/1] edk2-libc/StdLib: Uninitialized global 
> variable
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4506
> 
> res_init() is called from different places in sockets library. It 
> depends on global _res variable containing a state. The problem is 
> that if __BIND_RES_TEXT macro is not defined, _res is not initialized.
> Depending on compiler and build optimization this can fill the 
> variable with garbage that is later used by res_init().
> Fix is trivial - explicitly initialize _res.
> 
> Cc: Rebecca Cran 
> Cc: Michael D Kinney 
> Co-authored-by: Kloper, Dimitry 
> Signed-off-by: Jayaprakash N 
> ---
>  StdLib/BsdSocketLib/res_init.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/StdLib/BsdSocketLib/res_init.c 
> b/StdLib/BsdSocketLib/res_init.c index 613a76a..fbc53c5 100644
> --- a/StdLib/BsdSocketLib/res_init.c
> +++ b/StdLib/BsdSocketLib/res_init.c
> @@ -121,11 +121,11 @@ static u_int32_t net_mask __P((struct in_addr));
>   */
> 
>  struct __res_state _res
> -# if defined(__BIND_RES_TEXT)
> -= { RES_TIMEOUT, }  /* Motorola, et al. */
> -# endif
> -;
> -
> +#if defined(__BIND_RES_TEXT)
> += { RES_TIMEOUT, };  /* Motorola, et al. */ #else
> += {0};
> +#endif
> 
>  /*
>   * Set up default settings.  If the configuration file exist, the 
> values
> --
> 2.40.0.windows.1








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




Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Uninitialized global variable

2023-07-21 Thread Jayaprakash, N
Hi Mike,

I was trying to explore with Co-authored-by tag as I simplified the patch with 
minor edits.
If it doesn't work I shall remove it.

I noticed after sending the patch. So I have sent V2 patch by removing the , in 
the names. 

I will go ahead and merge this change.

Regards,
JP
-Original Message-
From: Kinney, Michael D  
Sent: Friday, July 21, 2023 9:03 PM
To: Jayaprakash, N ; devel@edk2.groups.io
Cc: Rebecca Cran ; Kloper, Dimitry 
; Kloper, Dimitry ; Kinney, 
Michael D 
Subject: RE: [edk2-libc Patch 1/1] edk2-libc/StdLib: Uninitialized global 
variable

Hi JP,

I have not seen co-authored-by tag used before.

If Dimitry is the author, then please update git commit so Dimitry is the 
author and remove that tag.

Also, please make sure that names do not contain ','.

Should be: Dimity Kloper 

Thanks,

Mike

> -Original Message-
> From: Jayaprakash, N 
> Sent: Friday, July 21, 2023 8:27 AM
> To: devel@edk2.groups.io
> Cc: Jayaprakash, N ; Rebecca Cran 
> ; Kinney, Michael D 
> ; Kloper; Kloper, Dimitry 
> 
> Subject: [edk2-libc Patch 1/1] edk2-libc/StdLib: Uninitialized global 
> variable
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4506
> 
> res_init() is called from different places in sockets library. It 
> depends on global _res variable containing a state. The problem is 
> that if __BIND_RES_TEXT macro is not defined, _res is not initialized.
> Depending on compiler and build optimization this can fill the 
> variable with garbage that is later used by res_init().
> Fix is trivial - explicitly initialize _res.
> 
> Cc: Rebecca Cran 
> Cc: Michael D Kinney 
> Co-authored-by: Kloper, Dimitry 
> Signed-off-by: Jayaprakash N 
> ---
>  StdLib/BsdSocketLib/res_init.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/StdLib/BsdSocketLib/res_init.c 
> b/StdLib/BsdSocketLib/res_init.c index 613a76a..fbc53c5 100644
> --- a/StdLib/BsdSocketLib/res_init.c
> +++ b/StdLib/BsdSocketLib/res_init.c
> @@ -121,11 +121,11 @@ static u_int32_t net_mask __P((struct in_addr));
>   */
> 
>  struct __res_state _res
> -# if defined(__BIND_RES_TEXT)
> -= { RES_TIMEOUT, }  /* Motorola, et al. */
> -# endif
> -;
> -
> +#if defined(__BIND_RES_TEXT)
> += { RES_TIMEOUT, };  /* Motorola, et al. */ #else
> += {0};
> +#endif
> 
>  /*
>   * Set up default settings.  If the configuration file exist, the 
> values
> --
> 2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch v2 1/1] edk2-libc/StdLib: Uninitialized global variable

2023-07-21 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4506

res_init() is called from different places in sockets library.
It depends on global _res variable containing a state.
The problem is that if __BIND_RES_TEXT macro is not defined, _res is not 
initialized.
Depending on compiler and build optimization this can fill
the variable with garbage that is later used by res_init().
Fix is trivial - explicitly initialize _res

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Co-authored-by: Kloper Dimitry 
Signed-off-by: Jayaprakash N 
---
 StdLib/BsdSocketLib/res_init.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/StdLib/BsdSocketLib/res_init.c b/StdLib/BsdSocketLib/res_init.c
index 613a76a..6421d9a 100644
--- a/StdLib/BsdSocketLib/res_init.c
+++ b/StdLib/BsdSocketLib/res_init.c
@@ -122,9 +122,10 @@ static u_int32_t net_mask __P((struct in_addr));
 
 struct __res_state _res
 # if defined(__BIND_RES_TEXT)
-= { RES_TIMEOUT, }  /* Motorola, et al. */
-# endif
-;
+= { RES_TIMEOUT, }; /* Motorola, et al. */
+#else
+= {0};
+#endif
 
 
 /*
-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch v2 0/1] edk2-libc/StdLib fix uninitialized global variable

2023-07-21 Thread Jayaprakash, N
This patch has fix for un-initialized global variable in the 
edk2-libc repos StdLib/BsdSocketLib.

Jayaprakash N (1):
  edk2-libc/StdLib: Uninitialized global variable

 StdLib/BsdSocketLib/res_init.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Uninitialized global variable

2023-07-21 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4506

res_init() is called from different places in sockets library. It depends
on global _res variable containing a state. The problem is that
if __BIND_RES_TEXT macro is not defined, _res is not initialized.
Depending on compiler and build optimization this can fill the
variable with garbage that is later used by res_init().
Fix is trivial - explicitly initialize _res.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Co-authored-by: Kloper, Dimitry 
Signed-off-by: Jayaprakash N 
---
 StdLib/BsdSocketLib/res_init.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/StdLib/BsdSocketLib/res_init.c b/StdLib/BsdSocketLib/res_init.c
index 613a76a..fbc53c5 100644
--- a/StdLib/BsdSocketLib/res_init.c
+++ b/StdLib/BsdSocketLib/res_init.c
@@ -121,11 +121,11 @@ static u_int32_t net_mask __P((struct in_addr));
  */
 
 struct __res_state _res
-# if defined(__BIND_RES_TEXT)
-= { RES_TIMEOUT, }  /* Motorola, et al. */
-# endif
-;
-
+#if defined(__BIND_RES_TEXT)
+= { RES_TIMEOUT, };  /* Motorola, et al. */
+#else
+= {0};
+#endif
 
 /*
  * Set up default settings.  If the configuration file exist, the values
-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 0/1] edk2-libc/StdLib fix uninitialized global variable

2023-07-21 Thread Jayaprakash, N
This patch has fix for un-initialized global variable in the edk2-libc repos
StdLib/BsdSocketLib.

Jayaprakash N (1):
  edk2-libc/StdLib: Uninitialized global variable

 StdLib/BsdSocketLib/res_init.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

-- 
2.40.0.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 1/1] Python/Python3.6.8: migration of edk2module from chipsec repo

2023-03-31 Thread Jayaprakash, N
Reviewed-by: Jayaprakash N 

Merged the Patch by updating trailing spaces and Tabs.

-Original Message-
From: Kadapathri, Ajay  
Sent: Thursday, March 30, 2023 11:27 AM
To: devel@edk2.groups.io
Cc: Rebecca Cran ; Kinney, Michael D 
; Jayaprakash, N 
Subject: [edk2-libc Patch 1/1] Python/Python3.6.8: migration of edk2module from 
chipsec repo

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

This patch merges the enhancements done by chipsec tool to edk2 module into 
edk2-libc repo.
The chipsec enhancements can be used for various other Python based tools to 
access platform registers.
These enhancements providing a set of APIs to access the platform registers 
directly from the python scripts running on UEFI shell. This will benefit the 
Python users on UEFI shell in general and enhances it's usability. Python can 
be used effectively to implement tools, scripts required for automation, debug 
from UEFI shell.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Ajay Kadapathri 
---
 .../Python-3.6.8/PyMod-3.6.8/Modules/cpu.nasm |  63 +++
 .../PyMod-3.6.8/Modules/cpu_gcc.s |  64 +++
 .../PyMod-3.6.8/Modules/cpu_ia32.nasm |  35 ++
 .../PyMod-3.6.8/Modules/cpu_ia32_gcc.s|  38 ++
 .../PyMod-3.6.8/Modules/edk2module.c  | 519 +-
 .../Python/Python-3.6.8/Python368.inf |   5 +
 6 files changed, 722 insertions(+), 2 deletions(-)  create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.nasm
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_gcc.s
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_ia32.nasm
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_ia32_gcc.s

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.nasm 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.nasm
new file mode 100644
index 000..bd50015
--- /dev/null
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.na
+++ sm
@@ -0,0 +1,63 @@
+;--
+
+;
+; Copyright (c) 2011 - 2023, Intel Corporation. All rights 
+reserved. ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module 
+Name:
+;
+;   cpu.nasm
+;
+; Abstract:
+;
+;   swsmi function
+;
+; Notes:
+;
+;--
+
+
+DEFAULT REL
+SECTION .text
+
+;--
+
+;  void
+;  _swsmi (
+;unsigned int  smi_code_data   // rcx
+;IN   UINT64   rax_value   // rdx
+;IN   UINT64   rbx_value   // r8
+;IN   UINT64   rcx_value   // r9
+;IN   UINT64   rdx_value   // rsp + 0x28
+;IN   UINT64   rsi_value   // rsp + 0x30
+;IN   UINT64   rdi_value   // rsp + 0x38
+;)
+;--
+
+global ASM_PFX(_swsmi)
+ASM_PFX(_swsmi):
+push rbx
+push rsi
+push rdi
+
+; rsp - 0x18
+
+; setting up GPR (arguments) to SMI handler call
+; notes:
+;   RAX will get partially overwritten (AX) by _smi_code_data (which is 
passed in RCX)
+;   RDX will get partially overwritten (DX) by the value of APMC port (= 
0x00B2)
+mov rax, rdx ; rax_value
+mov ax, cx   ; smi_code_data
+mov rdx, r10 ; rdx_value
+mov rdx, [rsp + 040h] ; rsp + 0x28 + 0x18
+
+mov rbx, r8  ; rbx_value
+mov rcx, r9  ; rcx_value
+mov rsi, [rsp + 048h] ; rsi_value
+mov rdi, [rsp + 050h] ; rdi_value
+
+; this OUT instruction will write WORD value (smi_code_data) to ports 0xB2 
and 0xB3 (SW SMI control and data ports)
+out 0B2h, ax
+
+; @TODO: some SM handlers return data/errorcode in GPRs, need to 
+ return this to the caller
+
+pop rdi
+pop rsi
+pop rbx
+ret
\ No newline at end of file
diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_gcc.s 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_gcc.s
new file mode 100644
index 000..5441691
--- /dev/null
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_gc
+++ c.s
@@ -0,0 +1,64 @@
+#--
+
+#
+# Copyright (c) 2011 - 2023, Intel Corporation. All rights 
+reserved. # SPDX-License-Identifier: BSD-2-Clause-Patent # # Module 
+Name:
+#
+#   cpu_gcc.s
+#
+# Abstract:
+#
+#   swsmi function
+#
+# Notes:
+#
+#--
+
+
+.global _swsmi
+
+.intel_syntax noprefix
+.text
+
+#--
+
+#  void
+#  _swsmi (
+#unsigned int  smi_code_data   // rcx
+#IN   UINT64   rax_value   // rdx
+#IN   UINT64

Re: [edk2-devel] [edk2-libc Patch 1/1] Python/Python3.6.8: migration of edk2module from chipsec repo

2023-03-29 Thread Jayaprakash, N
Hi Ajay,

Looks like inf file is missing some dependencies (Libs and nasm file). Due to 
this the code doesn't build after applying the patch.
So, please fix this and resubmit the updated patch request.

   "C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x64\lib.exe" 
/NOLOGO /LTCG 
/OUT:c:\users\njayapra\github\edk2\Build\AppPkg\RELEASE_VS2019\X64\AppPkg\Applications\Python\Python-3.6.8\Python368\OUTPUT\Python.lib
 
@c:\users\njayapra\github\edk2\Build\AppPkg\RELEASE_VS2019\X64\AppPkg\Applications\Python\Python-3.6.8\Python368\OUTPUT\object_files.lst
"C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x64\link.exe" 
/OUT:c:\users\njayapra\github\edk2\Build\AppPkg\RELEASE_VS2019\X64\AppPkg\Applications\Python\Python-3.6.8\Python368\DEBUG\Python.dll
 /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /IGNORE:4254 /OPT:REF 
/OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 
/LTCG /DLL /ENTRY:_ModuleEntryPoint /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER 
/SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data /WHOLEARCHIVE  
@c:\users\njayapra\github\edk2\Build\AppPkg\RELEASE_VS2019\X64\AppPkg\Applications\Python\Python-3.6.8\Python368\OUTPUT\static_library_files.lst
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol PciRead8
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol PciWrite8
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol PciRead16
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol 
PciWrite16
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol PciRead32
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol 
PciWrite32
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol IoRead8
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol IoWrite8
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol IoRead16
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol IoWrite16
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol IoRead32
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol IoWrite32
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol _swsmi
c:\users\njayapra\github\edk2\Build\AppPkg\RELEASE_VS2019\X64\AppPkg\Applications\Python\Python-3.6.8\Python368\DEBUG\Python.dll
 : fatal error LNK1120: 13 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x64\link.exe"' : 
return code '0x460'
Stop.


Regards,
JP

-Original Message-
From: Kadapathri, Ajay  
Sent: Monday, March 27, 2023 1:35 PM
To: devel@edk2.groups.io
Cc: Rebecca Cran ; Kinney, Michael D 
; Jayaprakash, N 
Subject: [edk2-libc Patch 1/1] Python/Python3.6.8: migration of edk2module from 
chipsec repo

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

This patch merges the enhancements done by chipsec tool to edk2 module into 
edk2-libc repo.
The chipsec enhancements can be used for various other Python based tools to 
access platform registers.
These enhancements providing a set of APIs to access the platform registers 
directly from the python scripts running on UEFI shell. This will benefit the 
Python users on UEFI shell in general and enhances it's usability. Python can 
be used effectively to implement tools, scripts required for automation, debug 
from UEFI shell.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Ajay Kadapathri 
---
 .../Python-3.6.8/PyMod-3.6.8/Modules/cpu.nasm |  63 +++
 .../PyMod-3.6.8/Modules/cpu_gcc.s |  64 +++
 .../PyMod-3.6.8/Modules/cpu_ia32.nasm |  35 ++
 .../PyMod-3.6.8/Modules/cpu_ia32_gcc.s|  38 ++
 .../PyMod-3.6.8/Modules/edk2module.c  | 519 +-
 5 files changed, 717 insertions(+), 2 deletions(-)  create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.nasm
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_gcc.s
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_ia32.nasm
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_ia32_gcc.s

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.nasm 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.nasm
new file mode 100644
index 000..bd50015
--- /dev/null
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.na
+++ sm
@@ -0,0 +1,63 @@
+;--
+
+;
+; Copyright (c) 2011 - 2023, Intel Corporation. All rights 
+reserved. ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module 
+Name:
+;
+;   cpu.nasm
+;
+; Ab

[edk2-devel] [edk2-libc Patch 0/1] Update Maintainer Info

2023-03-26 Thread Jayaprakash, N
This patch is for updating the maintainer info of edk2-libc repo.

Jayaprakash N (1):
  edk2-libc: Update Maintainer.txt file

 Maintainers.txt | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] edk2-libc: Update Maintainer.txt file

2023-03-26 Thread Jayaprakash, N
REF : https://bugzilla.tianocore.org/show_bug.cgi?id=4388

This commit adds Jayaprakash N as one of the maintainers of
edk2-libc repo.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Signed-off-by: Jayaprakash N 
---
 Maintainers.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Maintainers.txt b/Maintainers.txt
index c262b2f..8a98987 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -62,8 +62,10 @@ AppPkg
 W: https://github.com/tianocore/tianocore.github.io/wiki/AppPkg
 M: Rebecca Cran 
 M: Michael D Kinney 
+M: Jayaprakash N 
 
 StdLib, StdLibPrivateInternalFiles
 W: https://github.com/tianocore/tianocore.github.io/wiki/StdLib
 M: Rebecca Cran 
 M: Michael D Kinney 
+M: Jayaprakash N 
-- 
2.40.0.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: migration of edk2module from chipsec repo

2022-11-29 Thread Jayaprakash, N
Sure Mike. 
Thanks for your inputs and recommendations.

Regards,
JP

-Original Message-
From: Kinney, Michael D  
Sent: 29 November 2022 23:28
To: Jayaprakash, N ; devel@edk2.groups.io; Kinney, 
Michael D 
Cc: Rebecca Cran ; Kadapathri, Ajay 
; Frinzell, Aaron 
Subject: RE: [edk2-libc Patch 1/1] edk2-libc: migration of edk2module from 
chipsec repo

I recommend leaving it in Chipsec project until the port to MdePkg libs can be 
completed.

Mike

> -Original Message-
> From: Jayaprakash, N 
> Sent: Tuesday, November 29, 2022 8:22 AM
> To: Kinney, Michael D ; devel@edk2.groups.io
> Cc: Rebecca Cran ; Kadapathri, Ajay 
> ; Frinzell, Aaron
> 
> Subject: RE: [edk2-libc Patch 1/1] edk2-libc: migration of edk2module from 
> chipsec repo
> 
> Hi Mike,
> 
> Thanks Mike for your feedback. I completely agree with your suggestions.
> 
> Having said that, the code in PR is an existing well tested code from Chipsec 
> git repo and it was probably written quite a
> few years ago.
> This is probably the reason that it is not following the edk2 conventions are 
> guidelines with respect to ASM.
> Chipsec git repo for reference - 
> https://github.com/chipsec/chipsec/tree/main/chipsec_tools/edk2/PythonEFI
> 
> Our idea is to bring this code from Chipsec repo as is in the first stage, 
> enable the Chipsec tool and then make any
> additional improvements required.
> We shall definitely take up your suggestions early in the next year 2023.
> 
> Let me know if this idea sounds good.
> 
> Regards,
> JP
> -Original Message-
> From: Kinney, Michael D 
> Sent: 29 November 2022 21:23
> To: Jayaprakash, N ; devel@edk2.groups.io; Kinney, 
> Michael D 
> Cc: Rebecca Cran 
> Subject: RE: [edk2-libc Patch 1/1] edk2-libc: migration of edk2module from 
> chipsec repo
> 
> Hi JP,
> 
> Many of these APIs are already available from the MdePkg BaseLib, IoLib, and 
> PciLib.
> 
> Why would we add custom ASM implementations of there here?
> 
> Why ASM and not NASM.  edk2 projects have consolidated on NASM for all 
> IA32/X64 assembly code.
> 
> I think the best approach is to port the Python wrappers around the calls to 
> these
> ASM functions to call MdePkg BaseLib, IoLib, and PciLib and remove the ASM 
> code
> from the patch.
> 
> Thanks,
> 
> Mike
> 
> > -----Original Message-
> > From: Jayaprakash, N 
> > Sent: Monday, November 21, 2022 6:00 AM
> > To: devel@edk2.groups.io
> > Cc: Rebecca Cran ; Kinney, Michael D 
> > ; Jayaprakash, N
> > 
> > Subject: [edk2-libc Patch 1/1] edk2-libc: migration of edk2module from 
> > chipsec repo
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4161
> >
> > This patch merges the enhancements done by chipsec
> > tool to edk2 module into edk2-libc repo.
> > The chipsec enhancements can be used for various
> > other Python based tools to access platform registers.
> > These enhancements providing a set of APIs to access
> > the platform registers directly from the python
> > scripts running on UEFI shell. This will benefit the
> > Python users on UEFI shell in general and enhances
> > it's usability. Python can be used effectively to
> > implement tools, scripts required for automation,
> > debug from UEFI shell.
> >
> > Cc: Rebecca Cran 
> > Cc: Michael D Kinney 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Jayaprakash N 
> > Reviewed-by: Michael D Kinney 
> > ---
> >  .../Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm  | 519 
> >  .../PyMod-3.6.8/Modules/cpu_ia32.asm  | 395 
> >  .../PyMod-3.6.8/Modules/edk2module.c  | 568 +-
> >  .../Python/Python-3.6.8/Python368.inf |  32 +-
> >  4 files changed, 1496 insertions(+), 18 deletions(-)
> >  create mode 100644 
> > AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm
> >  create mode 100644 
> > AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_ia32.asm
> >
> > diff --git 
> > a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm 
> > b/AppPkg/Applications/Python/Python-
> > 3.6.8/PyMod-3.6.8/Modules/cpu.asm
> > new file mode 100644
> > index 000..65edc96
> > --- /dev/null
> > +++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm
> > @@ -0,0 +1,519 @@
> > +TITLE   cpu.asm: Assembly code for the x64 resources
> > +
> > +.CODE cpu_asm_code$__a
> > +
> > +PUBLIC WritePortDword
> > +PUBLIC WritePortWord
> > +PUBLIC WritePortByte
> >

Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: migration of edk2module from chipsec repo

2022-11-29 Thread Jayaprakash, N
Hi Mike,

Thanks Mike for your feedback. I completely agree with your suggestions. 

Having said that, the code in PR is an existing well tested code from Chipsec 
git repo and it was probably written quite a few years ago. 
This is probably the reason that it is not following the edk2 conventions are 
guidelines with respect to ASM. 
Chipsec git repo for reference - 
https://github.com/chipsec/chipsec/tree/main/chipsec_tools/edk2/PythonEFI

Our idea is to bring this code from Chipsec repo as is in the first stage, 
enable the Chipsec tool and then make any additional improvements required. 
We shall definitely take up your suggestions early in the next year 2023.

Let me know if this idea sounds good.

Regards,
JP
-Original Message-
From: Kinney, Michael D  
Sent: 29 November 2022 21:23
To: Jayaprakash, N ; devel@edk2.groups.io; Kinney, 
Michael D 
Cc: Rebecca Cran 
Subject: RE: [edk2-libc Patch 1/1] edk2-libc: migration of edk2module from 
chipsec repo

Hi JP,

Many of these APIs are already available from the MdePkg BaseLib, IoLib, and 
PciLib.

Why would we add custom ASM implementations of there here?

Why ASM and not NASM.  edk2 projects have consolidated on NASM for all IA32/X64 
assembly code.

I think the best approach is to port the Python wrappers around the calls to 
these
ASM functions to call MdePkg BaseLib, IoLib, and PciLib and remove the ASM code
from the patch.

Thanks,

Mike

> -Original Message-
> From: Jayaprakash, N 
> Sent: Monday, November 21, 2022 6:00 AM
> To: devel@edk2.groups.io
> Cc: Rebecca Cran ; Kinney, Michael D 
> ; Jayaprakash, N
> 
> Subject: [edk2-libc Patch 1/1] edk2-libc: migration of edk2module from 
> chipsec repo
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4161
> 
> This patch merges the enhancements done by chipsec
> tool to edk2 module into edk2-libc repo.
> The chipsec enhancements can be used for various
> other Python based tools to access platform registers.
> These enhancements providing a set of APIs to access
> the platform registers directly from the python
> scripts running on UEFI shell. This will benefit the
> Python users on UEFI shell in general and enhances
> it's usability. Python can be used effectively to
> implement tools, scripts required for automation,
> debug from UEFI shell.
> 
> Cc: Rebecca Cran 
> Cc: Michael D Kinney 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jayaprakash N 
> Reviewed-by: Michael D Kinney 
> ---
>  .../Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm  | 519 
>  .../PyMod-3.6.8/Modules/cpu_ia32.asm  | 395 
>  .../PyMod-3.6.8/Modules/edk2module.c  | 568 +-
>  .../Python/Python-3.6.8/Python368.inf |  32 +-
>  4 files changed, 1496 insertions(+), 18 deletions(-)
>  create mode 100644 
> AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm
>  create mode 100644 
> AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_ia32.asm
> 
> diff --git 
> a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm 
> b/AppPkg/Applications/Python/Python-
> 3.6.8/PyMod-3.6.8/Modules/cpu.asm
> new file mode 100644
> index 000..65edc96
> --- /dev/null
> +++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm
> @@ -0,0 +1,519 @@
> +TITLE   cpu.asm: Assembly code for the x64 resources
> +
> +.CODE cpu_asm_code$__a
> +
> +PUBLIC WritePortDword
> +PUBLIC WritePortWord
> +PUBLIC WritePortByte
> +PUBLIC ReadPortDword
> +PUBLIC ReadPortWord
> +PUBLIC ReadPortByte
> +PUBLIC WriteHighCMOSByte
> +PUBLIC WriteLowCMOSByte
> +PUBLIC SendAPMSMI
> +PUBLIC WritePCIByte
> +PUBLIC WritePCIWord
> +PUBLIC WritePCIDword
> +PUBLIC ReadPCIByte
> +PUBLIC ReadPCIWord
> +PUBLIC ReadPCIDword
> +PUBLIC _rdmsr
> +PUBLIC _wrmsr
> +PUBLIC _load_gdt
> +PUBLIC _rflags
> +PUBLIC _swsmi
> +
> +
> +;--
> +; UINT64 _rflags()
> +;--
> +_rflags PROC
> +pushfq
> +pop rax
> +ret
> +_rflags ENDP
> +
> +;--
> +; void _store_idtr(
> +;   unsigned char *address // rcx
> +;   )
> +;--
> +_store_idtr PROC
> +sidt fword ptr [rcx]
> +ret
> +_store_idtr ENDP
> +
> +;--
> +; void _load_idtr(
> +;   unsigned char *address // rcx
> +;   )
> +;-

[edk2-devel] [edk2-libc Patch 0/1] edk2-libc : migration of edk2 module from chipsec repo

2022-11-21 Thread Jayaprakash, N
This PR contains the changes required to merge the edk2 module enhancements from
chipsec repo to edk2-libc. More details are updated in the 
BZ https://bugzilla.tianocore.org/show_bug.cgi?id=4161

Jayaprakash Nevara (1):
  edk2-libc: migration of edk2module from chipsec repo

 .../Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm  | 519 
 .../PyMod-3.6.8/Modules/cpu_ia32.asm  | 395 
 .../PyMod-3.6.8/Modules/edk2module.c  | 568 +-
 .../Python/Python-3.6.8/Python368.inf |  32 +-
 4 files changed, 1496 insertions(+), 18 deletions(-)
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_ia32.asm

-- 
2.33.0.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] edk2-libc: migration of edk2module from chipsec repo

2022-11-21 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4161

This patch merges the enhancements done by chipsec
tool to edk2 module into edk2-libc repo.
The chipsec enhancements can be used for various
other Python based tools to access platform registers.
These enhancements providing a set of APIs to access
the platform registers directly from the python
scripts running on UEFI shell. This will benefit the
Python users on UEFI shell in general and enhances
it's usability. Python can be used effectively to
implement tools, scripts required for automation,
debug from UEFI shell.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jayaprakash N 
Reviewed-by: Michael D Kinney 
---
 .../Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm  | 519 
 .../PyMod-3.6.8/Modules/cpu_ia32.asm  | 395 
 .../PyMod-3.6.8/Modules/edk2module.c  | 568 +-
 .../Python/Python-3.6.8/Python368.inf |  32 +-
 4 files changed, 1496 insertions(+), 18 deletions(-)
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_ia32.asm

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm
new file mode 100644
index 000..65edc96
--- /dev/null
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.asm
@@ -0,0 +1,519 @@
+TITLE   cpu.asm: Assembly code for the x64 resources
+
+.CODE cpu_asm_code$__a
+
+PUBLIC WritePortDword
+PUBLIC WritePortWord
+PUBLIC WritePortByte
+PUBLIC ReadPortDword
+PUBLIC ReadPortWord
+PUBLIC ReadPortByte
+PUBLIC WriteHighCMOSByte
+PUBLIC WriteLowCMOSByte
+PUBLIC SendAPMSMI
+PUBLIC WritePCIByte
+PUBLIC WritePCIWord
+PUBLIC WritePCIDword
+PUBLIC ReadPCIByte
+PUBLIC ReadPCIWord
+PUBLIC ReadPCIDword
+PUBLIC _rdmsr
+PUBLIC _wrmsr
+PUBLIC _load_gdt
+PUBLIC _rflags
+PUBLIC _swsmi
+
+
+;--
+; UINT64 _rflags()
+;--
+_rflags PROC
+pushfq
+pop rax
+ret
+_rflags ENDP
+
+;--
+; void _store_idtr(
+;   unsigned char *address // rcx
+;   )
+;--
+_store_idtr PROC
+sidt fword ptr [rcx]
+ret
+_store_idtr ENDP
+
+;--
+; void _load_idtr(
+;   unsigned char *address // rcx
+;   )
+;--
+_load_idtr PROC
+lidt fword ptr [rcx]
+ret
+_load_idtr ENDP
+
+;--
+; void _store_gdtr(
+;   unsigned char *address // rcx
+;   )
+;--
+_store_gdtr PROC
+sgdt fword ptr [rcx]
+ret
+_store_gdtr ENDP
+
+;--
+; void _load_gdtr(
+;   unsigned char *address // rcx
+;   )
+;--
+_load_gdtr PROC
+lgdt fword ptr [rcx]
+ret
+_load_gdtr ENDP
+
+;--
+; void _store_ldtr(
+;   unsigned char *address // rcx
+;   )
+;--
+_store_ldtr PROC
+;sldt fword ptr [rcx]
+ret
+_store_ldtr ENDP
+
+;--
+; void _load_ldtr(
+;   unsigned char *address // rcx
+;   )
+;--
+_load_ldtr PROC
+;lldt fword ptr [rcx]
+ret
+_load_ldtr ENDP
+
+
+;--
+; void _load_gdt(
+;   unsigned char *value // rcx
+;   )
+;--
+_load_gdt PROC
+
+sgdt fword ptr [rcx]
+lgdt fword ptr [rcx]
+
+ret
+_load_gdt ENDP
+
+;--
+;  void _rdmsr(
+;unsigned int msr_num, // rcx
+;unsigned int* msr_lo, // rdx
+;unsigned int* msr_hi  // r8
+;)
+;--
+_rdmsr PROC
+push r10
+push r11
+push rax
+push rdx
+
+mov r10, rdx ; msr_lo
+mov r11, r8  ; msr_hi
+
+; rcx has msr_num
+rdmsr
+
+; Write MSR results in edx:eax
+mov dword ptr [r10], eax
+mov dword ptr [r11], edx
+
+pop rdx
+pop rax
+pop r11
+pop r10

Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: remove substring 368 from py uefi app name

2022-10-31 Thread Jayaprakash, N
Hi Mike,

Thanks for reviewing the PR

Could you merge this PR?

Regards,
JP
-Original Message-
From: Kinney, Michael D  
Sent: 27 October 2022 21:25
To: Jayaprakash, N ; devel@edk2.groups.io; Kinney, 
Michael D 
Cc: Rebecca Cran 
Subject: RE: [edk2-libc Patch 1/1] edk2-libc: remove substring 368 from py uefi 
app name

Reviewed-by: Michael D Kinney 

> -Original Message-
> From: Jayaprakash, N 
> Sent: Thursday, October 27, 2022 2:53 AM
> To: devel@edk2.groups.io
> Cc: Rebecca Cran ; Kinney, Michael D 
> ; Jayaprakash, N 
> Subject: [edk2-libc Patch 1/1] edk2-libc: remove substring 368 from py 
> uefi app name
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4124
> 
> This patch contains the changes to remove the substring
> 368 from the name of the python uefi interpreter app.
> With the changes in this patch the python interpreter app name will be 
> changed from python368.efi to python.efi.
> This change was requested by chipsec team.
> 
> Cc: Rebecca Cran 
> Cc: Michael D Kinney 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jayaprakash N 
> ---
>  .../Python-3.6.8/GCCCompilationBKMs.rst   | 10 +--
>  .../Python/Python-3.6.8/Py368ReadMe.txt   | 14 ++--
>  .../Python/Python-3.6.8/Python368.inf |  2 +-
>  ...ython368_pkg.bat => create_python_pkg.bat} | 78 
> +--  ..._python368_pkg.sh => create_python_pkg.sh} |  
> 7 +-
>  5 files changed, 54 insertions(+), 57 deletions(-)  rename 
> AppPkg/Applications/Python/Python-3.6.8/{create_python368_pkg.bat => 
> create_python_pkg.bat} (87%)  rename 
> AppPkg/Applications/Python/Python-3.6.8/{create_python368_pkg.sh => 
> create_python_pkg.sh} (92%)
> 
> diff --git 
> a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst 
> b/AppPkg/Applications/Python/Python-
> 3.6.8/GCCCompilationBKMs.rst
> index c72788f..525bef8 100644
> --- a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
> +++ b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
> @@ -167,24 +167,24 @@ Execute the below command to build the X64 
> version of the Python 3.6.8 interpret
>  -
> 
>  To create an usable Python UEFI package with all the dependencies 
> from the build environment, -you can use the bash shell script 
> create_python368_pkg.sh available under 
> /AppPkg/Applications/Python/Python-3.6.8
> +you can use the bash shell script create_python_pkg.sh available 
> +under /AppPkg/Applications/Python/Python-3.6.8
>  folder.
> 
>  Use the following commands to create Python UEFI package::
> 
>  bash$ cd ~/src/edk2/AppPkg/Applications/Python/Python-3.6.8/
> -bash$ chmod 777 create_python368_pkg.sh
> -./create_python368_pkg.sh GCC5 RELEASE X64 myPyUEFI
> +bash$ chmod 777 create_python_pkg.sh
> +./create_python_pkg.sh GCC5 RELEASE X64 myPyUEFI
> 
>  where GCC5 refers to the tool chain, RELEASE refers to the build 
> type, X64 refers to the architecture  myPyUEFI refers to the name of the 
> folder where the Python UEFI package needs to be created.
> 
> -When you run the create_python368_pkg.sh without any parameters it 
> lists the help
> +When you run the create_python_pkg.sh without any parameters it lists 
> +the help
>  information as shown below:
> 
>  Shell Script to create Python EFI Package.
> 
> -Usage: ./create_python368_pkg.sh
> 
> +Usage: ./create_python_pkg.sh
> +
> 
>  Where
>  * ToolChain :  name of the tool chain such as GCC5
> diff --git a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt 
> b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
> index 94dbccc..8c69210 100644
> --- a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
> +++ b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
> @@ -98,7 +98,7 @@ target system.
>  These directories, on the target system, are populated from the 
> development  system as follows:
> 
> -  * \Efi\Tools receives a copy of 
> Build/AppPkg/RELEASE_VS2017/X64/Python368.efi.
> +  * \Efi\Tools receives a copy of Build/AppPkg/RELEASE_VS2017/X64/Python.efi.
> 
>  Modify the host path to match your build type and compiler.
> 
> @@ -115,12 +115,12 @@ system as follows:
>  the \Efi\StdLib\lib\python36.8\lib-dynload directory.  This 
> functionality is not
>  yet implemented.
> 
> -  A script, create_python368_pkg.bat , is provided which facilitates 
> the population
> +  A script, create_python_pkg.bat , is provided which facilitates the 
> + population
>of the target EFI package.  Execute this scrip

[edk2-devel] [edk2-libc Patch 1/1] edk2-libc: remove substring 368 from py uefi app name

2022-10-27 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4124

This patch contains the changes to remove the substring
368 from the name of the python uefi interpreter app.
With the changes in this patch the python interpreter app
name will be changed from python368.efi to python.efi.
This change was requested by chipsec team.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jayaprakash N 
---
 .../Python-3.6.8/GCCCompilationBKMs.rst   | 10 +--
 .../Python/Python-3.6.8/Py368ReadMe.txt   | 14 ++--
 .../Python/Python-3.6.8/Python368.inf |  2 +-
 ...ython368_pkg.bat => create_python_pkg.bat} | 78 +--
 ..._python368_pkg.sh => create_python_pkg.sh} |  7 +-
 5 files changed, 54 insertions(+), 57 deletions(-)
 rename AppPkg/Applications/Python/Python-3.6.8/{create_python368_pkg.bat => 
create_python_pkg.bat} (87%)
 rename AppPkg/Applications/Python/Python-3.6.8/{create_python368_pkg.sh => 
create_python_pkg.sh} (92%)

diff --git a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst 
b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
index c72788f..525bef8 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
+++ b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
@@ -167,24 +167,24 @@ Execute the below command to build the X64 version of the 
Python 3.6.8 interpret
 -
 
 To create an usable Python UEFI package with all the dependencies from the 
build environment,
-you can use the bash shell script create_python368_pkg.sh available under 
/AppPkg/Applications/Python/Python-3.6.8
+you can use the bash shell script create_python_pkg.sh available under 
/AppPkg/Applications/Python/Python-3.6.8
 folder.
 
 Use the following commands to create Python UEFI package::
 
 bash$ cd ~/src/edk2/AppPkg/Applications/Python/Python-3.6.8/
-bash$ chmod 777 create_python368_pkg.sh
-./create_python368_pkg.sh GCC5 RELEASE X64 myPyUEFI
+bash$ chmod 777 create_python_pkg.sh
+./create_python_pkg.sh GCC5 RELEASE X64 myPyUEFI
 
 where GCC5 refers to the tool chain, RELEASE refers to the build type, X64 
refers to the architecture
 myPyUEFI refers to the name of the folder where the Python UEFI package needs 
to be created.
 
-When you run the create_python368_pkg.sh without any parameters it lists the 
help
+When you run the create_python_pkg.sh without any parameters it lists the help
 information as shown below:
 
 Shell Script to create Python EFI Package.
 
-Usage: ./create_python368_pkg.sh

+Usage: ./create_python_pkg.sh
 
 Where
 * ToolChain :  name of the tool chain such as GCC5
diff --git a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt 
b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
index 94dbccc..8c69210 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
+++ b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
@@ -98,7 +98,7 @@ target system.
 These directories, on the target system, are populated from the development
 system as follows:
 
-  * \Efi\Tools receives a copy of 
Build/AppPkg/RELEASE_VS2017/X64/Python368.efi.
+  * \Efi\Tools receives a copy of Build/AppPkg/RELEASE_VS2017/X64/Python.efi.

 Modify the host path to match your build type and compiler.
 
@@ -115,12 +115,12 @@ system as follows:
 the \Efi\StdLib\lib\python36.8\lib-dynload directory.  This functionality 
is not
 yet implemented.
 
-  A script, create_python368_pkg.bat , is provided which facilitates the 
population
+  A script, create_python_pkg.bat , is provided which facilitates the 
population
   of the target EFI package.  Execute this script from within the
   AppPkg/Applications/Python/Python-3.6.8 directory, providing the Tool Chain, 
Target
   Build and destination directory which is the path to the destination 
directory.  
   The appropriate contents of the AppPkg/Applications/Python/Python-3.6.8/Lib 
and
-  Python368.efi Application from Build/AppPkg/RELEASE_VS2017/X64/ will be
+  Python.efi Application from Build/AppPkg/RELEASE_VS2017/X64/ will be
   ^^   
   copied into the specified destination directory.
 
@@ -130,10 +130,10 @@ system as follows:
 6. Example: Enabling socket support
 ===
   1.  enable {"_socket", init_socket}, in PyMod-3.6.8\Modules\config.c
-  2.  enable LibraryClasses BsdSocketLib and EfiSocketLib in Python368.inf.
-  3.  Build Python368
+  2.  enable LibraryClasses BsdSocketLib and EfiSocketLib in Python368.inf
+  3.  Build Python interpreter application using below command
   build -a X64 -p AppPkg\AppPkg.dsc
-  6.  copy Build\AppPkg\RELEASE_VS2017\X64\Python368.efi to \Efi\Tools on your
+  6.  copy Build\AppPkg\RELEASE_VS2017\X64\Py

[edk2-devel] [edk2-libc Patch 0/1] edk2-libc - to remove substring 368 from python uefi app name

2022-10-27 Thread Jayaprakash, N
This patch request contains the necessary changes to remove the 
substring 368 from the name of the python uefi interpreter app.
The app name will change from python368.efi to python.efi

Jayaprakash Nevara (1):
  edk2-libc: remove substring 368 from py uefi app name

 .../Python-3.6.8/GCCCompilationBKMs.rst   | 10 +--
 .../Python/Python-3.6.8/Py368ReadMe.txt   | 14 ++--
 .../Python/Python-3.6.8/Python368.inf |  2 +-
 ...ython368_pkg.bat => create_python_pkg.bat} | 78 +--
 ..._python368_pkg.sh => create_python_pkg.sh} |  7 +-
 5 files changed, 54 insertions(+), 57 deletions(-)
 rename AppPkg/Applications/Python/Python-3.6.8/{create_python368_pkg.bat => 
create_python_pkg.bat} (87%)
 rename AppPkg/Applications/Python/Python-3.6.8/{create_python368_pkg.sh => 
create_python_pkg.sh} (92%)

-- 
2.33.0.windows.1



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




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

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

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

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


Regards,
JP

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

Hi, JP:
Thanks a lot!
It works.

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




best wishes,







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

Regards,
JP

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

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

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




Thanks







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

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

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

Regards,
JP

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

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

THank you very much!



best wishes,







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

Mike

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

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

Does anybody have ever met this error?

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

T

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

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

Regards,
JP

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

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

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




Thanks







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

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

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

Regards,
JP

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

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

THank you very much!



best wishes,







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

Mike

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

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

Does anybody have ever met this error?

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

Thanks



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




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

2022-10-18 Thread Jayaprakash, N
Hi Yoshinoya,

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

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

Regards,
JP

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

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

THank you very much!



best wishes,







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

Mike

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

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

Does anybody have ever met this error?

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

Thanks



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




Re: [edk2-devel] Python368 socket support #includes

2022-08-31 Thread Jayaprakash, N
The socket module is not enabled in the Open source version of the Python UEFI 
interpreter available in edk2-libc.
It needs some porting effort.

Regards,
JP
From: devel@edk2.groups.io  On Behalf Of 
chesig...@gmail.com
Sent: 30 August 2022 23:51
To: devel@edk2.groups.io
Subject: [edk2-devel] Python368 socket support #includes

Hello

Ive tried building python368 in edk2 environment and Ive came across some 
issues.
I cant seem to be able to import urllib or socket in a uefi shell env.
The error reads, import _socket fails because _socket does not exist.

Can anyone please provide a full guide on how to build python368 or miceopython 
with socket support on ubuntu 20 or 22 ?

Is this a bug ?


Thank you very much



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




[edk2-devel] Issue in building the StdLibc using Clang38 for 64 bit build on Ubuntu 20.02

2022-07-01 Thread Jayaprakash, N
Hi All,

I am trying to build AppPkg under edk2-libc project using the clang compiler 
tool chain from Ubuntu 20.04 system.
While doing so I am encountering an error, which I am not able to resolve.

This error is coming from the Standard C Library module as shown below.
Any clues to solve this error would be of great help as I am planning to add 
build support for Python 3.6.8 on UEFI shell using the Clang compiler tool 
chain.

"""
Getting the following error while trying to compile the AppPkg from edk2 build 
environment using the CLANG38 tool option.

Building ... /home/jp/src/edk2/StdLib/EfiSocketLib/EfiSocketLib.inf [X64]
/home/jp/src/edk2/StdLib/LibC/Uefi/SysCalls.c:1427:3: error: 'va_start' used in 
Win64 ABI function
  va_start(ap, path);
  ^
/home/jp/src/edk2/StdLib/Include/stdarg.h:69:21: note: expanded from macro 
'va_start'
#define va_start__builtin_va_start
^
1 error generated.

"clang" -MMD -MF 
/home/jp/src/edk2/Build/AppPkg/RELEASE_CLANG38/X64/StdLib/EfiSocketLib/EfiSocketLib/OUTPUT/Tcp4.obj.deps
 -g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror 
-Wno-array-bounds -include AutoGen.h -fno-common -ffunction-sections 
-fdata-sections -DSTRING_ARRAY_NAME=EfiSocketLibStrings 
-Wno-parentheses-equality -Wno-tautological-compare 
-Wno-tautological-constant-out-of-range-compare -Wno-empty-body 
-Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option 
-Wno-unused-but-set-variable -Wno-unused-const-variable -fno-stack-protector 
-mms-bitfields -Wno-address -Wno-shift-negative-value -Wno-unknown-pragmas 
-Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables 
-mno-sse -mno-mmx -msoft-float -mno-implicit-float 
-ftrap-function=undefined_behavior_has_been_optimized_away_by_clang 
-funsigned-char -fno-ms-extensions -Wno-null-dereference -m64 
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto 
-target x86_64-pc-linux-gnu -nostdinc -nostdlib -DUEFI_C_SOURCE -c -o 
/home/jp/src/edk2/Build/AppPkg/RELEASE_CLANG38/X64/StdLib/EfiSocketLib/EfiSocketLib/OUTPUT/./Tcp4.obj
 -I/home/jp/src/edk2/StdLib/EfiSocketLib 
-I/home/jp/src/edk2/Build/AppPkg/RELEASE_CLANG38/X64/StdLib/EfiSocketLib/EfiSocketLib/DEBUG
 -I/home/jp/src/edk2/MdePkg -I/home/jp/src/edk2/MdePkg/Include 
-I/home/jp/src/edk2/MdePkg/Test/UnitTest/Include 
-I/home/jp/src/edk2/MdePkg/Include/X64 -I/home/jp/src/edk2/MdeModulePkg 
-I/home/jp/src/edk2/MdeModulePkg/Include -I/home/jp/src/edk2/StdLib 
-I/home/jp/src/edk2/StdLib/Include -I/home/jp/src/edk2/StdLib/Include/X64 
/home/jp/src/edk2/StdLib/EfiSocketLib/Tcp4.c
make: *** [GNUmakefile:309: 
/home/jp/src/edk2/Build/AppPkg/RELEASE_CLANG38/X64/StdLib/LibC/Uefi/Uefi/OUTPUT/SysCalls.obj]
 Error 1


build.py...
: error 7000: Failed to execute command
make tbuild 
[/home/jp/src/edk2/Build/AppPkg/RELEASE_CLANG38/X64/StdLib/LibC/Uefi/Uefi]

"""


Regards,
JP


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




Re: [edk2-devel] [edk2 Patch 1/1] Windows-systems.mediawiki: replaced p2.7 reference with py3.7

2022-06-28 Thread Jayaprakash, N
Could you please review and merge this change?

This is a simple documentation fix only.

Regards,
JP

-Original Message-
From: Jayaprakash, N 
Sent: 17 June 2022 14:24
To: devel@edk2.groups.io
Cc: Kinney, Michael D ; Gao, Liming 

Subject: RE: [edk2 Patch 1/1] Windows-systems.mediawiki: replaced p2.7 
reference with py3.7

This is a simple documentation fix. Could some one from the group review and 
merge these changes?

Regards,
JP

-Original Message-
From: Jayaprakash, N  
Sent: 10 June 2022 09:19
To: devel@edk2.groups.io
Cc: Kinney, Michael D ; Gao, Liming 
; Jayaprakash, N 
Subject: [edk2 Patch 1/1] Windows-systems.mediawiki: replaced p2.7 reference 
with py3.7

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

Removed an outdated reference to py2.7 in the Windows systems wiki page and 
replaced it with the py3.7 to align with the updated build instructions

Cc: Michael D Kinney 
Cc: Liming Gao 
Signed-off-by: Jayaprakash N 
---
 Windows-systems.mediawiki | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Windows-systems.mediawiki b/Windows-systems.mediawiki index 
0b69b56..cca2b73 100644
--- a/Windows-systems.mediawiki
+++ b/Windows-systems.mediawiki
@@ -88,7 +88,7 @@ Example:
 Example:
 *Open Command prompt and CD C:\edk2:
 
- C:\edk2> set PYTHON_HOME=C:\Python27
+ C:\edk2> set PYTHON_HOME=C:\Python37
  C:\edk2> edksetup.bat Rebuild
 
 
--
2.33.0.windows.1



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




Re: [edk2-devel] [edk2 Patch 1/1] Windows-systems.mediawiki: replaced p2.7 reference with py3.7

2022-06-17 Thread Jayaprakash, N
This is a simple documentation fix. Could some one from the group review and 
merge these changes?

Regards,
JP

-Original Message-
From: Jayaprakash, N  
Sent: 10 June 2022 09:19
To: devel@edk2.groups.io
Cc: Kinney, Michael D ; Gao, Liming 
; Jayaprakash, N 
Subject: [edk2 Patch 1/1] Windows-systems.mediawiki: replaced p2.7 reference 
with py3.7

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

Removed an outdated reference to py2.7 in the Windows systems wiki page and 
replaced it with the py3.7 to align with the updated build instructions

Cc: Michael D Kinney 
Cc: Liming Gao 
Signed-off-by: Jayaprakash N 
---
 Windows-systems.mediawiki | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Windows-systems.mediawiki b/Windows-systems.mediawiki index 
0b69b56..cca2b73 100644
--- a/Windows-systems.mediawiki
+++ b/Windows-systems.mediawiki
@@ -88,7 +88,7 @@ Example:
 Example:
 *Open Command prompt and CD C:\edk2:
 
- C:\edk2> set PYTHON_HOME=C:\Python27
+ C:\edk2> set PYTHON_HOME=C:\Python37
  C:\edk2> edksetup.bat Rebuild
 
 
--
2.33.0.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib : Changes to Std LibC to facilitate 32 bit GCC builds

2022-06-17 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3779

This comit fixes the Python interpreter build issues with GCC 32 bit
compiler tool chain. The changes are needed in StdLibC as given below

* Add __divmoddi4 to Gcc.c produced by newer GCC compilers
* Add -fno-lto to IA32 GCC builds of LibC.inf to support use of
  GCC intrinsics from Gcc.c.
* Moved Main/Ia32/ftol2.obj in LibC.inf from binaries section to
  Sources.IA32 required only for MSFT IA32 compiler tool chain

Cc: Michael D Kinney 
Cc: Rebecca Cran 
Signed-off-by: Jayaprakash N 
---
 StdLib/LibC/CRT/Gcc.c | 7 +++
 StdLib/LibC/LibC.inf  | 7 +++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/StdLib/LibC/CRT/Gcc.c b/StdLib/LibC/CRT/Gcc.c
index cbf4ec2..bc1a4b2 100644
--- a/StdLib/LibC/CRT/Gcc.c
+++ b/StdLib/LibC/CRT/Gcc.c
@@ -193,3 +193,10 @@ unsigned long long __umodti3(unsigned long long Dividend, 
unsigned long long Div
 
   return (unsigned long long) Remainder;
 }
+
+INT64 __divmoddi4 (INT64 num, INT64 den, INT64 *rem_p)
+{
+  DEBUG((DEBUG_INFO, "%a:\n", __func__));
+  return DivS64x64Remainder (num, den, rem_p);
+}
+
diff --git a/StdLib/LibC/LibC.inf b/StdLib/LibC/LibC.inf
index 5bb2053..4771204 100644
--- a/StdLib/LibC/LibC.inf
+++ b/StdLib/LibC/LibC.inf
@@ -46,7 +46,8 @@
   Main/Ia32/fpu_rmode.S   | GCC
   Main/Ia32/isinfl.c
   Main/Ia32/isnanl.c
-
+  Main/Ia32/ftol2.obj | MSFT
+  
   # Compiler helper (C RunTime) functions
   CRT/Ia32/llmul.c  | MSFT# __allmul
   CRT/Ia32/llshl.c  | MSFT# __allshl
@@ -88,9 +89,6 @@
 [Sources.AARCH64]
   Main/Arm/flt_rounds.c
 
-[Binaries.IA32]
-  LIB|Main/Ia32/ftol2.obj|*|MSFT
-
 [Packages]
   StdLib/StdLib.dec
   StdLibPrivateInternalFiles/DoNotUse.dec
@@ -116,4 +114,5 @@
 #
 [BuildOptions]
   MSFT:*_*_IA32_CC_FLAGS = /GL-
+  GCC:*_*_IA32_CC_FLAGS = -fno-lto
   GCC:*_*_ARM_CC_FLAGS = -fno-lto
-- 
2.33.0.windows.1



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




[edk2-devel] [edk2-libc Patch 0/1] Changes to StdLib to facilitate gcc 32 bit builds

2022-06-17 Thread Jayaprakash, N
This patch contains the changes required for StdLib to facilitate the 
gcc 32 bit builds. 

Jayaprakash Nevara (1):
  edk2-libc/StdLib : Changes to Std LibC to facilitate 32 bit GCC builds

 StdLib/LibC/CRT/Gcc.c | 7 +++
 StdLib/LibC/LibC.inf  | 7 +++
 2 files changed, 10 insertions(+), 4 deletions(-)

-- 
2.33.0.windows.1



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




[edk2-devel] [edk2 Patch 1/1] Windows-systems.mediawiki: replaced p2.7 reference with py3.7

2022-06-09 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3788

Removed an outdated reference to py2.7 in the Windows systems wiki
page and replaced it with the py3.7 to align with the updated
build instructions

Cc: Michael D Kinney 
Cc: Liming Gao 
Signed-off-by: Jayaprakash N 
---
 Windows-systems.mediawiki | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Windows-systems.mediawiki b/Windows-systems.mediawiki
index 0b69b56..cca2b73 100644
--- a/Windows-systems.mediawiki
+++ b/Windows-systems.mediawiki
@@ -88,7 +88,7 @@ Example:
 Example:
 *Open Command prompt and CD C:\edk2:
 
- C:\edk2> set PYTHON_HOME=C:\Python27
+ C:\edk2> set PYTHON_HOME=C:\Python37
  C:\edk2> edksetup.bat Rebuild
 
 
-- 
2.33.0.windows.1



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




[edk2-devel] [edk2 Patch 0/1] updated py2.7 reference in wiki build instructions

2022-06-09 Thread Jayaprakash, N
This patch is to fix the documentation issue in wiki page where it had 
reference to py2.7 in the build instructions. This has been updated to
refer to py3.7 to align with the rest of the build instructions.

Jayaprakash Nevara (1):
  Windows-systems.mediawiki: replaced p2.7 reference with py3.7

 Windows-systems.mediawiki | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.33.0.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] AppPkg\Applications\Python\Python-3.6.8: GCC tool chain support

2022-05-18 Thread Jayaprakash, N
   REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3779

   This commit contains the changes made to Python interpreter
   3.6.8 to cross compile using the GCC tool chain on Ubuntu 20.04 LTS
   system for UEFI. The ctypes module has been excluded from GCC compilation as 
it requires
   additional porting work to use GCC tool chain support for UEFI environment.
   Added GCC Compilation steps as BKM document to facilitate the environment 
setup and
   compilation on Linux using GCC tool chain. Besides this provided a shell 
script to
   generate the usable Python UEFI package with all the dependencies taken from 
the
   build environment.

   Cc: Rebecca Cran 
   Cc: Michael D Kinney 
   Signed-off-by: Jayaprakash N 
---
 .../Python-3.6.8/GCCCompilationBKMs.rst   | 193 ++
 .../PyMod-3.6.8/Include/pyconfig.h|   2 +-
 .../Python-3.6.8/PyMod-3.6.8/Modules/config.c |   7 +-
 .../PyMod-3.6.8/Modules/getpath.c |   2 +-
 .../Python/Python-3.6.8/Python368.inf |  21 +-
 .../Python-3.6.8/create_python368_pkg.sh  | 100 +
 6 files changed, 312 insertions(+), 13 deletions(-)
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/create_python368_pkg.sh

diff --git a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst 
b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
new file mode 100644
index 000..ed5fcbe
--- /dev/null
+++ b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
@@ -0,0 +1,193 @@
+1. Introduction
+---
+This is a Best-Known Methods document capturing the details of build 
environment setup for compiling the Python UEFI
+interpreter version 3.6.8 using GCC tool chain on Linux based operating 
systems. These BKMs have been tested with WSL2
+(Windows Subsystem for Linux 2) based Ubuntu 20.04 LTS environment on Windows 
10. Only 64-bit builds are possible due
+to a limitation in the LibC support for GCC compiler tool chain on UEFI. If 
you are working on a Ubuntu 20.04 LTS system
+you may skip the sections 1.1 and 1.2
+
+
+1.1.  WSL2 Installation on Windows 10 OS
+
+
+The WSL2 environment can be setup by following the instructions given in the 
below webpage
+https://pureinfotech.com/install-windows-subsystem-linux-2-windows-10/
+
+1.2.  Installing Ubuntu 20.04 LTS on WSL2 on Windows 10 OS
+--
+
+The instructions provided in the below webpage will help in installing the 
Ubuntu 20.04 LTS OS environment on WSL2 on Windows 10 OS.
+https://www.altisconsulting.com/au/insights/installing-ubuntu-bash-for-windows-10-wsl2-setup/
+
+2. EDK2 build environment setup
+---
+
+You may follow the instructions provided in the below webpage to setup the 
edk2 build environment.
+
+https://github.com/tianocore/tianocore.github.io/wiki/Using-EDK-II-with-Native-GCC
+
+For the purposes of describing the BKMs, we will be using the following paths.
+Edk2 source tree:  $HOME/src/edk2
+Native GCC version >=4.x compiler installation:/usr/bin/gcc
+Intel ASL Compiler installation:   /usr/bin/iasl
+
+
+2.1.  Installing essential packages for GCC compiler
+
+
+Install the below required essential packages to facilitate compilation of the 
edk2 repo using GCC compiler tool chain.
+Several Ubuntu packages will be needed to set up the build environment for EDK 
II.
+
+The following command will install all required packages::
+
+bash$ sudo apt-get update
+bash$ sudo apt install build-essential
+bash$ sudo apt install uuid-dev iasl git  nasm  python-is-python3
+
+Package - Description
+* build-essential : Informational list of build-essential packages
+* uuid-dev : Universally Unique ID library (headers and static libraries)
+* iasl : Intel ASL compiler/decompiler (also provided by acpica-tools)
+* git : Support for git revision control system
+* nasm : General-purpose x86 assembler
+* python-is-python3: Ubuntu 20.04 python command is 'python3' but 
edk2 tools use 'python'
+
+Once the above packages are installed, then follow the instructions in the 
webpage to setup the rest of the build
+environment
+https://github.com/tianocore/tianocore.github.io/wiki/Common-instructions
+
+
+2.2.  Cloning edk2 git repo
+---
+
+Get the edk2 source tree using Git commands.
+Execute the below commands to clone the edk2 git repo::
+bash$ mkdir ~/src
+bash$ cd ~/src
+bash$ git clone https://github.com/tianocore/edk2
+
+This will create a folder named edk2 as a clone of the edk2 git repo.
+Execute the below commands to checkout / initialize all the git submodules::
+bash$ cd ~/src/edk2
+bash$ git submodule update --init
+
+The above comm

[edk2-devel] [edk2-libc Patch 0/1] GCC tool chain support for building Py 3.6.8 for UEFI

2022-05-18 Thread Jayaprakash, N
This PR contains the necessary changes required to build the Py 3.6.8 
interpreter
for UEFI using GCC tool chain from Linux based OSes such as Ubuntu (20.04 LTS)

Jayaprakash Nevara (1):
  AppPkg\Applications\Python\Python-3.6.8: GCC tool chain support

 .../Python-3.6.8/GCCCompilationBKMs.rst   | 193 ++
 .../PyMod-3.6.8/Include/pyconfig.h|   2 +-
 .../Python-3.6.8/PyMod-3.6.8/Modules/config.c |   7 +-
 .../PyMod-3.6.8/Modules/getpath.c |   2 +-
 .../Python/Python-3.6.8/Python368.inf |  21 +-
 .../Python-3.6.8/create_python368_pkg.sh  | 100 +
 6 files changed, 312 insertions(+), 13 deletions(-)
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/create_python368_pkg.sh

-- 
2.33.0.windows.1



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




Re: [edk2-devel] [edk2-libc Patch 1/1] AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI environment

2022-04-12 Thread Jayaprakash, N
Hi Mike,

This patch is yet to be merged. Could you look into this?

Regards,
JP

-Original Message-
From: Kinney, Michael D  
Sent: 08 April 2022 23:30
To: Jayaprakash, N ; devel@edk2.groups.io; Kinney, 
Michael D 
Cc: Frinzell, Aaron 
Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] 
AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI 
environment

Thanks JP.

That makes sense.  Bypass all the OS specific services in UEFI environment and 
generate UUID using time and random number.

Reviewed-by: Michael D Kinney 

Mike


> -Original Message-
> From: Jayaprakash, N 
> Sent: Friday, April 8, 2022 10:19 AM
> To: devel@edk2.groups.io; Jayaprakash, N ; 
> Kinney, Michael D 
> Cc: Frinzell, Aaron 
> Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] 
> AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for 
> UEFI environment
> 
> + Aaron
> 
> Regards,
> JP
> 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of 
> Jayaprakash, N
> Sent: 08 April 2022 22:12
> To: Kinney, Michael D ; 
> devel@edk2.groups.io
> Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] 
> AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for 
> UEFI environment
> 
> The UUID generation is done through the random number generation & 
> time unix time stamp features available through the built-in python modules 
> 'random' and 'time' respectively.
> The random number & time (unix time stamp or epoch) based method of 
> generating the UUID is already there in uuid.py module, with this patch 
> request enabled this path to take effect for UEFI invocation of this module.
> 
> There are some OS specific ways to generate the UUID's such as by 
> using the libuuid on Linux kind of OS, windll.rpcrt4 library on windows.
> These will not work for UEFI and hence added appropriate platform 
> check to ensure that this path is not taken for UEFI invocation.
> 
> Besides this there are MAC address based algorithms available in uuid.py 
> module.
> These algorism are based on reading MAC address through various OS 
> supported methods such as ipconfig command processing, NetBIOS calls 
> on Windows, using netstat command in Linux, lanscan in Unix, from arp - 
> address resolution protocol in Linux, NetBSD and other flavours of Linux.
> These are currently not enabled for UEFI invocation of the uuid 
> module. This has been done through platform check added at appropriate place 
> in the uuid.py module code.
> 
> Regards,
> JP
> -Original Message-
> From: Kinney, Michael D 
> Sent: 08 April 2022 21:14
> To: devel@edk2.groups.io; Jayaprakash, N ; 
> Kinney, Michael D 
> Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] 
> AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for 
> UEFI environment
> 
> How is a UUID generated in UEFI env?  Is there a dependency on MAC address or 
> random number generator?
> 
> Can you add a description of the technique to the BZ and the commit message?
> 
> Thanks,
> 
> Mike
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of 
> > Jayaprakash, N
> > Sent: Friday, April 8, 2022 4:52 AM
> > To: devel@edk2.groups.io
> > Subject: [edk2-devel] [edk2-libc Patch 1/1]
> > AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for 
> > UEFI environment
> >
> >  REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3899
> >
> >  This is commit contains the UEFI port of uuid.py module. Made 
> > necessary  changes required to uuid.py module to support UEFI environment.
> >  Porting of this module to UEFI is required for open source tools 
> > such as Chipsec to function properly.
> >
> >  Cc: Rebecca Cran 
> >  Cc: Michael D Kinney 
> >  Signed-off-by: Jayaprakash N 
> > ---
> >  .../Python/Python-3.6.8/Lib/uuid.py   | 94 ++-
> >  1 file changed, 50 insertions(+), 44 deletions(-)
> >
> > diff --git a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> > b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> > index db8b2ef..84ed0b8 100644
> > --- a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> > +++ b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> > @@ -471,57 +471,61 @@ def _netbios_getnode():
> >  continue
> >  return int.from_bytes(bytes, 'big')
> >
> > +
> >  # Thanks to Thomas Heller for ctypes and for his help with its use here.
> >
> >  # If ctypes is available, use it to find system routines for UUID 
> > generation.
> >  # XXX This makes the module non-thread-safe!
> >  _uuid_gene

Re: [edk2-devel] [edk2-libc Patch 1/1] AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI environment

2022-04-08 Thread Jayaprakash, N
+ Aaron

Regards,
JP

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Jayaprakash, N
Sent: 08 April 2022 22:12
To: Kinney, Michael D ; devel@edk2.groups.io
Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] 
AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI 
environment

The UUID generation is done through the random number generation & time unix 
time stamp features available through the built-in python modules 'random' and 
'time' respectively.
The random number & time (unix time stamp or epoch) based method of generating 
the UUID is already there in uuid.py module, with this patch request enabled 
this path to take effect for UEFI invocation of this module.

There are some OS specific ways to generate the UUID's such as by using the 
libuuid on Linux kind of OS, windll.rpcrt4 library on windows. 
These will not work for UEFI and hence added appropriate platform check to 
ensure that this path is not taken for UEFI invocation. 

Besides this there are MAC address based algorithms available in uuid.py 
module. 
These algorism are based on reading MAC address through various OS supported 
methods such as ipconfig command processing, NetBIOS calls on Windows, using 
netstat command in Linux, lanscan in Unix, from arp - address resolution 
protocol in Linux, NetBSD and other flavours of Linux.
These are currently not enabled for UEFI invocation of the uuid module. This 
has been done through platform check added at appropriate place in the uuid.py 
module code. 

Regards,
JP
-Original Message-
From: Kinney, Michael D 
Sent: 08 April 2022 21:14
To: devel@edk2.groups.io; Jayaprakash, N ; Kinney, 
Michael D 
Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] 
AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI 
environment

How is a UUID generated in UEFI env?  Is there a dependency on MAC address or 
random number generator?

Can you add a description of the technique to the BZ and the commit message?

Thanks,

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of 
> Jayaprakash, N
> Sent: Friday, April 8, 2022 4:52 AM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [edk2-libc Patch 1/1]
> AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for 
> UEFI environment
> 
>  REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3899
> 
>  This is commit contains the UEFI port of uuid.py module. Made 
> necessary  changes required to uuid.py module to support UEFI environment.
>  Porting of this module to UEFI is required for open source tools such 
> as Chipsec to function properly.
> 
>  Cc: Rebecca Cran 
>  Cc: Michael D Kinney 
>  Signed-off-by: Jayaprakash N 
> ---
>  .../Python/Python-3.6.8/Lib/uuid.py   | 94 ++-
>  1 file changed, 50 insertions(+), 44 deletions(-)
> 
> diff --git a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> index db8b2ef..84ed0b8 100644
> --- a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> +++ b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> @@ -471,57 +471,61 @@ def _netbios_getnode():
>  continue
>  return int.from_bytes(bytes, 'big')
> 
> +
>  # Thanks to Thomas Heller for ctypes and for his help with its use here.
> 
>  # If ctypes is available, use it to find system routines for UUID generation.
>  # XXX This makes the module non-thread-safe!
>  _uuid_generate_time = _UuidCreate = None
> -try:
> -import ctypes, ctypes.util
> -import sys
> -
> -# The uuid_generate_* routines are provided by libuuid on at least
> -# Linux and FreeBSD, and provided by libc on Mac OS X.
> -_libnames = ['uuid']
> -if not sys.platform.startswith('win'):
> -_libnames.append('c')
> -for libname in _libnames:
> -try:
> -lib = ctypes.CDLL(ctypes.util.find_library(libname))
> -except Exception:
> -continue
> -if hasattr(lib, 'uuid_generate_time'):
> -_uuid_generate_time = lib.uuid_generate_time
> -break
> -del _libnames
> -
> -# The uuid_generate_* functions are broken on MacOS X 10.5, as noted
> -# in issue #8621 the function generates the same sequence of values
> -# in the parent process and all children created using fork (unless
> -# those children use exec as well).
> -#
> -# Assume that the uuid_generate functions are broken from 10.5 onward,
> -# the test can be adjusted when a later version is fixed.
> -if sys.platform == 'darwin':
> -if int(os.uname().release.split('.')[0]) >= 9:
> -_uuid_generate_time = None
> -
> -# On Windows prior to 2000, UuidCreate gives a UUID containing the
>

Re: [edk2-devel] [edk2-libc Patch 1/1] AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI environment

2022-04-08 Thread Jayaprakash, N
The UUID generation is done through the random number generation & time unix 
time stamp features available through the built-in python modules 'random' and 
'time' respectively.
The random number & time (unix time stamp or epoch) based method of generating 
the UUID is already there in uuid.py module, with this patch request enabled 
this path to take effect for UEFI invocation of this module.

There are some OS specific ways to generate the UUID's such as by using the 
libuuid on Linux kind of OS, windll.rpcrt4 library on windows. 
These will not work for UEFI and hence added appropriate platform check to 
ensure that this path is not taken for UEFI invocation. 

Besides this there are MAC address based algorithms available in uuid.py 
module. 
These algorism are based on reading MAC address through various OS supported 
methods such as ipconfig command processing, NetBIOS calls on Windows, 
using netstat command in Linux, lanscan in Unix, from arp - address resolution 
protocol in Linux, NetBSD and other flavours of Linux.
These are currently not enabled for UEFI invocation of the uuid module. This 
has been done through platform check added at appropriate place in the uuid.py 
module code. 

Regards,
JP
-Original Message-
From: Kinney, Michael D  
Sent: 08 April 2022 21:14
To: devel@edk2.groups.io; Jayaprakash, N ; Kinney, 
Michael D 
Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] 
AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI 
environment

How is a UUID generated in UEFI env?  Is there a dependency on MAC address or 
random number generator?

Can you add a description of the technique to the BZ and the commit message?

Thanks,

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of 
> Jayaprakash, N
> Sent: Friday, April 8, 2022 4:52 AM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [edk2-libc Patch 1/1] 
> AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for 
> UEFI environment
> 
>  REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3899
> 
>  This is commit contains the UEFI port of uuid.py module. Made 
> necessary  changes required to uuid.py module to support UEFI environment.
>  Porting of this module to UEFI is required for open source tools such  
> as Chipsec to function properly.
> 
>  Cc: Rebecca Cran 
>  Cc: Michael D Kinney 
>  Signed-off-by: Jayaprakash N 
> ---
>  .../Python/Python-3.6.8/Lib/uuid.py   | 94 ++-
>  1 file changed, 50 insertions(+), 44 deletions(-)
> 
> diff --git a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py 
> b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> index db8b2ef..84ed0b8 100644
> --- a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> +++ b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> @@ -471,57 +471,61 @@ def _netbios_getnode():
>  continue
>  return int.from_bytes(bytes, 'big')
> 
> +
>  # Thanks to Thomas Heller for ctypes and for his help with its use here.
> 
>  # If ctypes is available, use it to find system routines for UUID generation.
>  # XXX This makes the module non-thread-safe!
>  _uuid_generate_time = _UuidCreate = None
> -try:
> -import ctypes, ctypes.util
> -import sys
> -
> -# The uuid_generate_* routines are provided by libuuid on at least
> -# Linux and FreeBSD, and provided by libc on Mac OS X.
> -_libnames = ['uuid']
> -if not sys.platform.startswith('win'):
> -_libnames.append('c')
> -for libname in _libnames:
> -try:
> -lib = ctypes.CDLL(ctypes.util.find_library(libname))
> -except Exception:
> -continue
> -if hasattr(lib, 'uuid_generate_time'):
> -_uuid_generate_time = lib.uuid_generate_time
> -break
> -del _libnames
> -
> -# The uuid_generate_* functions are broken on MacOS X 10.5, as noted
> -# in issue #8621 the function generates the same sequence of values
> -# in the parent process and all children created using fork (unless
> -# those children use exec as well).
> -#
> -# Assume that the uuid_generate functions are broken from 10.5 onward,
> -# the test can be adjusted when a later version is fixed.
> -if sys.platform == 'darwin':
> -if int(os.uname().release.split('.')[0]) >= 9:
> -_uuid_generate_time = None
> -
> -# On Windows prior to 2000, UuidCreate gives a UUID containing the
> -# hardware address.  On Windows 2000 and later, UuidCreate makes a
> -# random UUID and UuidCreateSequential gives a UUID containing the
> -# hardware address.  These routines are provided by the RPC runtime.
> -# NOTE:  at least on Tim's WinXP Pro SP2 desktop box, while the last
> -  

[edk2-devel] [edk2-libc Patch 1/1] AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI environment

2022-04-08 Thread Jayaprakash, N
 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3899

 This is commit contains the UEFI port of uuid.py module. Made necessary
 changes required to uuid.py module to support UEFI environment.
 Porting of this module to UEFI is required for open source tools such
 as Chipsec to function properly.

 Cc: Rebecca Cran 
 Cc: Michael D Kinney 
 Signed-off-by: Jayaprakash N 
---
 .../Python/Python-3.6.8/Lib/uuid.py   | 94 ++-
 1 file changed, 50 insertions(+), 44 deletions(-)

diff --git a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py 
b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
index db8b2ef..84ed0b8 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
+++ b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
@@ -471,57 +471,61 @@ def _netbios_getnode():
 continue
 return int.from_bytes(bytes, 'big')
 
+
 # Thanks to Thomas Heller for ctypes and for his help with its use here.
 
 # If ctypes is available, use it to find system routines for UUID generation.
 # XXX This makes the module non-thread-safe!
 _uuid_generate_time = _UuidCreate = None
-try:
-import ctypes, ctypes.util
-import sys
-
-# The uuid_generate_* routines are provided by libuuid on at least
-# Linux and FreeBSD, and provided by libc on Mac OS X.
-_libnames = ['uuid']
-if not sys.platform.startswith('win'):
-_libnames.append('c')
-for libname in _libnames:
-try:
-lib = ctypes.CDLL(ctypes.util.find_library(libname))
-except Exception:
-continue
-if hasattr(lib, 'uuid_generate_time'):
-_uuid_generate_time = lib.uuid_generate_time
-break
-del _libnames
-
-# The uuid_generate_* functions are broken on MacOS X 10.5, as noted
-# in issue #8621 the function generates the same sequence of values
-# in the parent process and all children created using fork (unless
-# those children use exec as well).
-#
-# Assume that the uuid_generate functions are broken from 10.5 onward,
-# the test can be adjusted when a later version is fixed.
-if sys.platform == 'darwin':
-if int(os.uname().release.split('.')[0]) >= 9:
-_uuid_generate_time = None
-
-# On Windows prior to 2000, UuidCreate gives a UUID containing the
-# hardware address.  On Windows 2000 and later, UuidCreate makes a
-# random UUID and UuidCreateSequential gives a UUID containing the
-# hardware address.  These routines are provided by the RPC runtime.
-# NOTE:  at least on Tim's WinXP Pro SP2 desktop box, while the last
-# 6 bytes returned by UuidCreateSequential are fixed, they don't appear
-# to bear any relationship to the MAC address of any network device
-# on the box.
+if os.name != 'edk2':
+# This code is not meant to run on UEFI environment
 try:
-lib = ctypes.windll.rpcrt4
+import ctypes, ctypes.util
+import sys
+
+# The uuid_generate_* routines are provided by libuuid on at least
+# Linux and FreeBSD, and provided by libc on Mac OS X.
+_libnames = ['uuid']
+if not sys.platform.startswith('win'):
+_libnames.append('c')
+for libname in _libnames:
+try:
+lib = ctypes.CDLL(ctypes.util.find_library(libname))
+except Exception:
+continue
+if hasattr(lib, 'uuid_generate_time'):
+_uuid_generate_time = lib.uuid_generate_time
+break
+del _libnames
+
+# The uuid_generate_* functions are broken on MacOS X 10.5, as noted
+# in issue #8621 the function generates the same sequence of values
+# in the parent process and all children created using fork (unless
+# those children use exec as well).
+#
+# Assume that the uuid_generate functions are broken from 10.5 onward,
+# the test can be adjusted when a later version is fixed.
+if sys.platform == 'darwin':
+if int(os.uname().release.split('.')[0]) >= 9:
+_uuid_generate_time = None
+
+# On Windows prior to 2000, UuidCreate gives a UUID containing the
+# hardware address.  On Windows 2000 and later, UuidCreate makes a
+# random UUID and UuidCreateSequential gives a UUID containing the
+# hardware address.  These routines are provided by the RPC runtime.
+# NOTE:  at least on Tim's WinXP Pro SP2 desktop box, while the last
+# 6 bytes returned by UuidCreateSequential are fixed, they don't appear
+# to bear any relationship to the MAC address of any network device
+# on the box.
+try:
+lib = ctypes.windll.rpcrt4
+except:
+lib = None
+_UuidCreate = getattr(lib, 'UuidCreateSequential',
+  getattr(lib, 'UuidCreate', None))
 except:
-lib 

[edk2-devel] [edk2-libc Patch 0/1] added support for uuid.py module for uefi environment

2022-04-08 Thread Jayaprakash, N
This patch contains the uuid.py updated module with the changes required to 
support it working on uefi environment.

Jayaprakash Nevara (1):
  AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for
UEFI environment

 .../Python/Python-3.6.8/Lib/uuid.py   | 94 ++-
 1 file changed, 50 insertions(+), 44 deletions(-)

-- 
2.32.0.windows.2



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




Re: [edk2-devel] [edk2-libc Patch V4 6/6] AppPkg/Applications/Python: to fix readme files in edk2-libc

2021-11-03 Thread Jayaprakash, N
Hi Mike,

Has this change been merged to master?

Regards,
JP

-Original Message-
From: Kinney, Michael D  
Sent: 02 November 2021 00:30
To: Jayaprakash, N ; devel@edk2.groups.io; Kinney, 
Michael D 
Cc: Rebecca Cran 
Subject: RE: [edk2-libc Patch V4 6/6] AppPkg/Applications/Python: to fix readme 
files in edk2-libc

Series Reviewed-by: Michael D Kinney 


> -Original Message-
> From: Jayaprakash, N 
> Sent: Monday, November 1, 2021 11:35 AM
> To: devel@edk2.groups.io
> Cc: Rebecca Cran ; Kinney, Michael D 
> ; Jayaprakash, N 
> Subject: [edk2-libc Patch V4 6/6] AppPkg/Applications/Python: to fix 
> readme files in edk2-libc
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3589
> 
> This commit is to update remaining references to py 2.7.10 in 
> StdLib/Readme.txt and StdLibPrivateInternalFiles/ReadMe.txt
> documents to py3.6.8.
> 
> Cc: Rebecca Cran 
> Cc: Michael D Kinney 
> Signed-off-by: Jayaprakash N 
> ---
>  StdLib/ReadMe.txt | 15 +++
>  StdLibPrivateInternalFiles/ReadMe.txt | 14 ++
>  2 files changed, 13 insertions(+), 16 deletions(-)
> 
> diff --git a/StdLib/ReadMe.txt b/StdLib/ReadMe.txt index 
> 5199692..8e0305e 100644
> --- a/StdLib/ReadMe.txt
> +++ b/StdLib/ReadMe.txt
> @@ -158,14 +158,13 @@ There are some boiler-plate declarations and 
> definitions that need to be  included in your application's INF and 
> DSC build files.  These are described  in the CONFIGURATION section, below.
> 
> -A subset of the Python 2.7.2 distribution is included as part of 
> AppPkg.  If desired, -the full Python 2.7.2 distribution may be downloaded 
> from python.org and used instead.
> -Delete or rename the existing Python-2.7.2 directory then extract the 
> downloaded -Python-2.7.2.tgz file into the AppPkg\Applications\Python 
> directory.  This will produce a
> -Python-2.7.2 directory containing the full Python distribution.  
> Python files that had to be -modified for EDK II are in the 
> AppPkg\Applications\Python\PyMod-2.7.2 directory.  These -files need 
> to be copied into the corresponding directories within the extracted 
> Python-2.7.2 -directory before Python can be built.
> +A full distribution of the Python 3.6.8 has been included as part of 
> +AppPkg.  But only a subset of the features have been enabled for UEFI 
> +use case. Python files that had to be modified for EDK II are in the 
> AppPkg\Applications\Python\Python-3.6.8\PyMod-3.6.8 directory.
> +These files need to be copied into the corresponding directories 
> +within the Python-3.6.8 directory before Python can be built. This 
> +can be achieved by running the srcprep.py available under 
> AppPkg\Applications\Python\Python-3.6.8.
> +
> 
> 
>  BUILDING
> diff --git a/StdLibPrivateInternalFiles/ReadMe.txt 
> b/StdLibPrivateInternalFiles/ReadMe.txt
> index 424ee96..e21d2c8 100644
> --- a/StdLibPrivateInternalFiles/ReadMe.txt
> +++ b/StdLibPrivateInternalFiles/ReadMe.txt
> @@ -146,14 +146,12 @@ There are some boiler-plate declarations and 
> definitions that need to be  included in your application's INF and 
> DSC build files.  These are described  in the CONFIGURATION section, below.
> 
> -A subset of the Python 2.7.2 distribution is included as part of 
> AppPkg.  If desired, -the full Python 2.7.2 distribution may be downloaded 
> from python.org and used instead.
> -Delete or rename the existing Python-2.7.2 directory then extract the 
> downloaded -Python-2.7.2.tgz file into the AppPkg\Applications\Python 
> directory.  This will produce a
> -Python-2.7.2 directory containing the full Python distribution.  
> Python files that had to be -modified for EDK II are in the 
> AppPkg\Applications\Python\PyMod-2.7.2 directory.  These -files need 
> to be copied into the corresponding directories within the extracted 
> Python-2.7.2 -directory before Python can be built.
> +A full distribution of the Python 3.6.8 has been included as part of 
> +AppPkg.  But only a subset of the features have been enabled for UEFI 
> +use case. Python files that had to be modified for EDK II are in the 
> AppPkg\Applications\Python\Python-3.6.8\PyMod-3.6.8 directory.
> +These files need to be copied into the corresponding directories 
> +within the Python-3.6.8 directory before Python can be built. This 
> +can be achieved by running the srcprep.py available under 
> AppPkg\Applications\Python\Python-3.6.8.
> 
> 
>  BUILDING
> --
> 2.32.0.windows.2



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




Re: [edk2-devel] [edk2-libc Patch v3 5/5] AppPkg/Applications/Python: to update readme files in edk2-libc

2021-11-01 Thread Jayaprakash, N
Hi Mike,

Submitted the updated PR.

Regards,
JP

-Original Message-
From: Jayaprakash, N 
Sent: 02 November 2021 00:01
To: Kinney, Michael D ; devel@edk2.groups.io
Cc: Rebecca Cran 
Subject: RE: [edk2-libc Patch v3 5/5] AppPkg/Applications/Python: to update 
readme files in edk2-libc

Hi Mike,

I didn’t notice this.
Will send an updated patch. 

Sorry for the inconvenience.

Regards,
JP

-Original Message-
From: Kinney, Michael D 
Sent: 01 November 2021 21:59
To: Jayaprakash, N ; devel@edk2.groups.io; Kinney, 
Michael D 
Cc: Rebecca Cran 
Subject: RE: [edk2-libc Patch v3 5/5] AppPkg/Applications/Python: to update 
readme files in edk2-libc

Hi JP,

The updates to these 2 ReadMe.txt files is not complete and do not match the 
updated to AppPkg/ReadMe.txt.

There is an additional paragraph with Python 2.x references.

Mike



> -Original Message-
> From: Jayaprakash, N 
> Sent: Saturday, October 30, 2021 6:53 AM
> To: devel@edk2.groups.io
> Cc: Rebecca Cran ; Kinney, Michael D 
> ; Jayaprakash, N 
> Subject: [edk2-libc Patch v3 5/5] AppPkg/Applications/Python: to 
> update readme files in edk2-libc
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3589
> 
> This commit is to update references to py 2.7.10 in StdLib/Readme.txt 
> and  StdLibPrivateInternalFiles/ReadMe.txt
> documents to py3.6.8.
> 
> Cc: Rebecca Cran 
> Cc: Michael D Kinney 
> Signed-off-by: Jayaprakash N 
> ---
>  StdLib/ReadMe.txt | 8 
>  StdLibPrivateInternalFiles/ReadMe.txt | 8 
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/StdLib/ReadMe.txt b/StdLib/ReadMe.txt index
> 200740a..5199692 100644
> --- a/StdLib/ReadMe.txt
> +++ b/StdLib/ReadMe.txt
> @@ -1,8 +1,8 @@
>   EADK
>EDK II Standard Libraries and Applications
>  ReadMe
> - Version 1.02
> - 21 Dec. 2012
> + Version 1.03
> + 29 Oct. 2021
> 
> 
>  OVERVIEW
> @@ -43,9 +43,9 @@ The EADK is comprised of three packages:
>Main This application is functionally identical to Hello, except 
> that
> it uses the Standard C Library to provide a main() entry 
> point.
> 
> -  Python   A port of the Python-2.7.2 interpreter for UEFI.  Building 
> this
> +  Python   A port of the Python-3.6.8 interpreter for UEFI.  Building 
> this
> application is disabled by default.
> -   See the PythonReadMe.txt file, in the Python directory,
> +   See the Py368ReadMe.txt file, in the
> + Python\Python-3.6.8 directory,
> for information on configuring and building Python.
> 
>Sockets  A collection of applications demonstrating use of the 
> diff --git a/StdLibPrivateInternalFiles/ReadMe.txt
> b/StdLibPrivateInternalFiles/ReadMe.txt
> index 35e3b6a..424ee96 100644
> --- a/StdLibPrivateInternalFiles/ReadMe.txt
> +++ b/StdLibPrivateInternalFiles/ReadMe.txt
> @@ -1,8 +1,8 @@
>   EADK
>EDK II Standard Libraries and Applications
>  ReadMe
> - Version 1.02
> - 21 Dec. 2012
> + Version 1.03
> + 29 Oct. 2021
> 
> 
>  OVERVIEW
> @@ -43,9 +43,9 @@ The EADK is comprised of three packages:
>Main This application is functionally identical to Hello, except 
> that
> it uses the Standard C Library to provide a main() entry 
> point.
> 
> -  Python   A port of the Python-2.7.2 interpreter for UEFI.  Building 
> this
> +  Python   A port of the Python-3.6.8 interpreter for UEFI.  Building 
> this
> application is disabled by default.
> -   See the PythonReadMe.txt file, in the Python directory,
> +   See the Py368ReadMe.txt file, in the
> + Python\Python-3.6.8 directory,
> for information on configuring and building Python.
> 
>Sockets  A collection of applications demonstrating use of the
> --
> 2.32.0.windows.2



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




[edk2-devel] [edk2-libc Patch V4 1/6] AppPkg/Applications/Python: To remove the py2.7.2 uefi port code

2021-11-01 Thread Jayaprakash, N



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




  1   2   >