From nobody Fri May 17 05:50:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+88634+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+88634+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1649418762; cv=none; d=zohomail.com; s=zohoarc; b=iwzAyoURrpQXuRM8138y/ZUHMTOno9YX5j/zqM4C3nq6fb9G9lDZLhX9xkenqwTSKZUqwvWhR9+QyHbZc9uPPD8KbgZxB4V6qR/kmNs867ai8nKngXLZsLOG/dUS95Iy5ctgyw4WNlodT4eqP6B8YRdWfdfZqvBzligDRelIXA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649418762; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=k/gTUALRmKI3YjBDPDwQX1B2y6kO+HJvdUjA3KuCvv4=; b=Ku+TUDBFGh7STDETjtAINec94ecjqPsA0qlI5/P9KL8Q7KbqD/WGlHdydQa8GtQj1zk6Zm9YZFuosrpwixzXojfC4DxN/GIw+PrieaOXpfAqRC9VPI+XHRUqOc6M/UVKhB1jj7WK5MeiDKZYSsQZ7NHXZ3oquP5OxeCyQUoH4Mw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+88634+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1649418762157435.47512121230386; Fri, 8 Apr 2022 04:52:42 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id kCkzYY1788612x2rujj15qgB; Fri, 08 Apr 2022 04:52:41 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.4778.1649418756521314522 for ; Fri, 08 Apr 2022 04:52:40 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10310"; a="348013978" X-IronPort-AV: E=Sophos;i="5.90,244,1643702400"; d="scan'208";a="348013978" X-Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 04:52:39 -0700 X-IronPort-AV: E=Sophos;i="5.90,244,1643702400"; d="scan'208";a="524751326" X-Received: from njayapra-mobl1.gar.corp.intel.com ([10.213.111.252]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 04:52:38 -0700 From: "Jayaprakash, N" 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 Date: Fri, 8 Apr 2022 17:22:09 +0530 Message-Id: <20220408115209.2002-2-n.jayaprakash@intel.com> In-Reply-To: <20220408115209.2002-1-n.jayaprakash@intel.com> References: <20220408115209.2002-1-n.jayaprakash@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,n.jayaprakash@intel.com X-Gm-Message-State: 8TUJSVbySQlE2N5smVwUeo8Ox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1649418761; bh=nGlxS1veZVoAEGLWT5ui5yBiVNSpML91wevtGNcmueE=; h=Date:From:Reply-To:Subject:To; b=JYjrq3+z4q6oD6GLy4P3owUXCdfxvxTWnseGoU1VdDZoeNAAL4Vl3PCYmk5fAjLcdnZ 7f82yTYkBIiRXpJOn6djLoQFPE/wyo9KlFvNy1OyvGPPEoDrKK9vM8AD+1NV7vURQ7CGO MpGcil9lsytfIVsYeWLduvxEnxqznzbdB2c= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1649418764211100002 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3899 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/A= pplications/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') =20 + # Thanks to Thomas Heller for ctypes and for his help with its use here. =20 # If ctypes is available, use it to find system routines for UUID generati= on. # XXX This makes the module non-thread-safe! _uuid_generate_time =3D _UuidCreate =3D 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 =3D ['uuid'] - if not sys.platform.startswith('win'): - _libnames.append('c') - for libname in _libnames: - try: - lib =3D ctypes.CDLL(ctypes.util.find_library(libname)) - except Exception: - continue - if hasattr(lib, 'uuid_generate_time'): - _uuid_generate_time =3D 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 =3D=3D 'darwin': - if int(os.uname().release.split('.')[0]) >=3D 9: - _uuid_generate_time =3D 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 !=3D 'edk2': + # This code is not meant to run on UEFI environment try: - lib =3D ctypes.windll.rpcrt4 + import ctypes, ctypes.util + import sys + =20 + # The uuid_generate_* routines are provided by libuuid on at least + # Linux and FreeBSD, and provided by libc on Mac OS X. + _libnames =3D ['uuid'] + if not sys.platform.startswith('win'): + _libnames.append('c') + for libname in _libnames: + try: + lib =3D ctypes.CDLL(ctypes.util.find_library(libname)) + except Exception: + continue + if hasattr(lib, 'uuid_generate_time'): + _uuid_generate_time =3D lib.uuid_generate_time + break + del _libnames + =20 + # The uuid_generate_* functions are broken on MacOS X 10.5, as not= ed + # 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 onw= ard, + # the test can be adjusted when a later version is fixed. + if sys.platform =3D=3D 'darwin': + if int(os.uname().release.split('.')[0]) >=3D 9: + _uuid_generate_time =3D None + =20 + # 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 runtim= e. + # NOTE: at least on Tim's WinXP Pro SP2 desktop box, while the la= st + # 6 bytes returned by UuidCreateSequential are fixed, they don't a= ppear + # to bear any relationship to the MAC address of any network device + # on the box. + try: + lib =3D ctypes.windll.rpcrt4 + except: + lib =3D None + _UuidCreate =3D getattr(lib, 'UuidCreateSequential', + getattr(lib, 'UuidCreate', None)) except: - lib =3D None - _UuidCreate =3D getattr(lib, 'UuidCreateSequential', - getattr(lib, 'UuidCreate', None)) -except: - pass + pass + =20 def _unixdll_getnode(): """Get the hardware address on Unix using ctypes.""" @@ -563,6 +567,8 @@ def getnode(): import sys if sys.platform =3D=3D 'win32': getters =3D _NODE_GETTERS_WIN32 + elif sys.platform =3D=3D 'uefi': + getters =3D [] else: getters =3D _NODE_GETTERS_UNIX =20 --=20 2.32.0.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#88634): https://edk2.groups.io/g/devel/message/88634 Mute This Topic: https://groups.io/mt/90333425/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-