From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web10.114969.1683568195998700814 for ; Mon, 08 May 2023 10:49:56 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=I+GKiS+I; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: michael.d.kinney@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683568195; x=1715104195; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=e1KrMS6xWmAtZo2ARVARpqw5oFUQ5F6dy3ZM0saCcvA=; b=I+GKiS+IimsgQuT2Jg66XvP/YcT93SH/qz0xdHdMursbL5vgLFsWAafy kJepTteqhuaQm0sbAsqZQa2GJ6/PBnDEyXc1stLsgxlzm4+tJiW8Grfjm aKOPruRj3N9a25/htJTuCoHjtfQJ5Yabs4bHTbncnt4FAhpJB2OWJP5uT 0Nj1K+Fx1XhV0/yR1MfgJkOkXhliyhgwey51Ve/sqRF28Wih8fT9F78+H 6klolxNrUOtZ9hpyX6nNpOsFQwj9iUheGwF/RqnH45yhkxvn+32JVMcJc U3wAEb/Gap0+5qf41dIQUtaiLJAOSDLiDQh3SOefAWHmASTqtx/2qEukO Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="436034841" X-IronPort-AV: E=Sophos;i="5.99,259,1677571200"; d="scan'208";a="436034841" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2023 10:49:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="944947466" X-IronPort-AV: E=Sophos;i="5.99,259,1677571200"; d="scan'208";a="944947466" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga006.fm.intel.com with ESMTP; 08 May 2023 10:49:55 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 8 May 2023 10:49:54 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Mon, 8 May 2023 10:49:54 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.101) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Mon, 8 May 2023 10:49:54 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W+ZACezjekArflo0lMil616YDxtuyTjdSnCG/qVjxnBaJvGnZVwtgMJr5F+m+LCjGzzPf+9MvCPpUOJ4FoSFkZon2EvL8buUgy9+YGv3AuD1FhpSSdjZWL7pn1wM6Rn5CiEB8c8aZC5F89NhIDU89oFop/v1MAcq0diSqTutKLPBP2WCI/WWMlYQr1bZ0M2JPjU51r7wUQY27O8zKxYPrJ4gGSWNkGkrt5w+xBSi+mrdN4SozV7R4nznXCWdruUvzBMEkTKu903tgd42Ps65sBctYImfzVlBVrhOTMPWuNsodAJmJq2zK8L7ODbPmXZU5vWJXIXMXhHdFWJCWrSj+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SFqWHBssUlSXK+XXUrBzn9/q3+EXbPiJInBu77HAZyU=; b=lJtN/ru6E4epz+Sm2oRXBvYtLmVYUxAi6TUgyeH3n9pw68FjXUP5OBJclt+sfBCgpyCEaZ7DguEGvkFEfmWwvvWZpMWBPQpkeqNTqNI9vSFnMCthcZH3akqlURxIWoRcAgqceviithwaKB5ETETt6ZL5vMb94Gt+kcMiV5n/TEOQSgf3eZMuODkrgCoMsg8Ip77/ef2BeofcmcM50ZTogbfkSxelkI7JHNoBYPD4YyvWQd/d742hf2nldxr0nBGh2L9vCYZcgGTGLpfqmW8GnPa8BqoDOumb+jlfO3kWveLIqjvBCg+4nZorXqBUUbZ+WlND/RnNbdTAC7A/ozNBGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from CO1PR11MB4929.namprd11.prod.outlook.com (2603:10b6:303:6d::19) by CY5PR11MB6116.namprd11.prod.outlook.com (2603:10b6:930:2b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Mon, 8 May 2023 17:49:51 +0000 Received: from CO1PR11MB4929.namprd11.prod.outlook.com ([fe80::9b1e:23e9:53e:291]) by CO1PR11MB4929.namprd11.prod.outlook.com ([fe80::9b1e:23e9:53e:291%7]) with mapi id 15.20.6363.032; Mon, 8 May 2023 17:49:50 +0000 From: "Michael D Kinney" To: "Hsu, VictorX" , "devel@edk2.groups.io" , "Kinney, Michael D" CC: "Guo, Gua" , "Chan, Laura" , "Prakashan, Krishnadas Veliyathuparambil" , "K N, Karthik" , "Kinney, Michael D" Subject: Re: [PATCH 2/4] MdeModulePkg: Add TraceHubDebugSysTLib library Thread-Topic: [PATCH 2/4] MdeModulePkg: Add TraceHubDebugSysTLib library Thread-Index: AQHZgW6GvmU+4pwjX0+OWBOqqyoyXK9QpROg Date: Mon, 8 May 2023 17:49:49 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CO1PR11MB4929:EE_|CY5PR11MB6116:EE_ x-ms-office365-filtering-correlation-id: f3fcdfa0-1b9e-49b1-b960-08db4fec9ee2 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: oZ0nk83/VKooxovpTpItFNuC6S6gmNredMmbL1UOpYUkQkKwD6jM97uGFisvJDidKnK/NG5mbB+DIO2rIA5sjNDj3Na2nK1W3wQBwMAFo56z3L0f72huA85PZfypOFfNlLo2I+iwF+bPKcE3GQ4G1CcipGRJtBehIWsAljl3BriwylmWbqwIYO0pRs8cm/7TuwgtEjWEH8LmooQmwjzpnbjvQzKrksSTKkVAsbdXu0p0xgIuxGp9ereuqDzsR7koMabDayBBqs8+g/y5z/er26WJNFJa0X8mrVe3qU9XmwnMmo7QNlEaafTJfsITkqInQ1vHu/K32ljlaREJJGYNz47glH0xUz5gEWAVUDKfpBqaKjP53ZVfV5lFp2BVB9ZUdcoPSdJqhohMS55YLIomcPY9jrN6Hvnhww5QTaH/yf97Ko5PGyy5gA+wBFDudoxA0FFByNwmtld+x8TmemVr2vi6p67rGyLw72Ary7D5vD9AIBiMoQxXuUWEu23jsZyj7jZ5j3c0E0KNKan6rOQ6ujMeR7If6vqcKa7T/ZTrjaR4ghzUA62hPH9f987wXXrkm/08AxJVvvXrEIRY2LqUpswj3rJyQYK/hPMqWY/CClk= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR11MB4929.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(136003)(376002)(366004)(39860400002)(346002)(451199021)(966005)(66556008)(66446008)(64756008)(4326008)(76116006)(66946007)(316002)(478600001)(7696005)(19627235002)(110136005)(54906003)(86362001)(66476007)(33656002)(83380400001)(6506007)(26005)(107886003)(9686003)(53546011)(71200400001)(52536014)(5660300002)(8936002)(30864003)(41300700001)(8676002)(2906002)(55016003)(38100700002)(122000001)(82960400001)(186003)(38070700005)(559001)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?2RxGnH6221JN9CH8/3E5IOvIeKfuWWjxBqSVsGnkDK+JC6mUxd5c2yww7XN/?= =?us-ascii?Q?Air4FfMB8l2fQyPbE3wzpW7cq5ZlesuwfhtEXkyEUftSqsetzqcsNdSEfM+O?= =?us-ascii?Q?FqR9Vq+7NSCMxGvJfeKzgTMkdyhNuIQ2CZIIGzwkxD/4+5QWB+v/hVIPkhAQ?= =?us-ascii?Q?hn/JHbsq09imSvfsr3OH/LOddPESy+WADeq2etwnMqyhgE0+M00rDfthvxka?= =?us-ascii?Q?jWqD7mDCOxWKX/nBH8k7JG1AS3HvbnLBB1+BwUFvevPAjmzkiOV+qvlXMtmG?= =?us-ascii?Q?QIsaqPrLBDCNAwx2kTsvaqSp1ZZkZLopN3zrRUhgCSpMivIHdQm2BNCkXIbD?= =?us-ascii?Q?HLTW4zfp8GbESK8uTi4/puyGIWyu5MzuNmOzvHBzeTxE9LF+X1QjocEMqE95?= =?us-ascii?Q?Y7R/NYyqOmZnKVOaknKlugimIeE7+1ZviZKxKXgjD6eTwx7jI9QAG5UoolYO?= =?us-ascii?Q?TdqND4U5a0PtaqbT2YeR7J9cpK08J4Ay0ZDPxfQx7F9py9aPwb8qs+HS2a6m?= =?us-ascii?Q?qHtVMDWhaIias+Ul5Hlz4WEqPUT+m2JSNwvisOHvddxPaRAQK5Me0jb8Vk28?= =?us-ascii?Q?KiAzx42r7CzXMS5uNrSwbcmnOC0fR1Yjje4Mho4FKF+cOvDbRnGfwdWttEHu?= =?us-ascii?Q?AX14u/4icdYIGZOZFMzBLLPpo962+Qx7Nu0MislsWo3akCiO0r+guVeDOU8h?= =?us-ascii?Q?fWEWW7su/fEQ/SgwPjc2kmwX3p5CZwlXCPhPUoEkqZBbBXCV9DL4ufcyNVR/?= =?us-ascii?Q?3jRMP/p7BI2TuDLqE/I4ksvMv615WOHKgiKVfy/INNQ/XhAZ53H09cw967co?= =?us-ascii?Q?3neREb3RTWOXfJ8RwGfccuppSs6heRAt3I+w6Ss28X8Zf69K6tMIxSNooQZj?= =?us-ascii?Q?gyIJtXj7Q0wDK3iXG9z74AV76ySeK9IW76B8WLH51tYqg0aYnShpHNRTYbmJ?= =?us-ascii?Q?6tvqQ78KrIukFJEetbNCCoOmrC4w6M7OlWsdR6+GvyoQpSaLD9waChEbs7U/?= =?us-ascii?Q?M63gAfPtEDxrk50ZoTaKHrilQqZ5C5ikp9dTQOstWmNKVpkiXXlL/pqEGpSb?= =?us-ascii?Q?Bwn8FnfYKGm6dsekM0MymfMm5U5xhTQBOBOZbWFBq5x9T4K8b/Ekoy+bA4P1?= =?us-ascii?Q?3L5d80QKRJg21k9J5/2P2abUnTTzvRGab99Kc3nr4rdT1bEuOc4Fh6AvRIT8?= =?us-ascii?Q?RolslMtf0ksQ1gQuAl0t9bF+4bd04yk4YsFv93LQChclKQAIfSxaabAt4wMK?= =?us-ascii?Q?zXxutxmmIYVfiQYCh2PuXp2PZsknwnlRW/yQQAfcQ54jRmbcaVM9StPuWbgs?= =?us-ascii?Q?BSc8tg5REHbv8zQogzGtY58i3KF712X+4i/oEYRgirlwhQ7SiAU4icNPXP0x?= =?us-ascii?Q?BZREFEj8DlsDYUqsGL2gPXQ1S1Bx3XnmXh6DcP5/mPVNsJenAiIs1Z6VMj84?= =?us-ascii?Q?PiJHxoN9bJftRQscFjDQRi8r55JLKHL9yTORvhHLbr/Vsgk54xxwZ1glDoV6?= =?us-ascii?Q?5M8W7tDCKf7m9P3R1Hj5ZmchtvQT1pE7L5JuTI4jWz3wGizlToy5hNuKbqKC?= =?us-ascii?Q?2E0gJvi8S30HaGzkQSDLGZUFCYhrnXItvJLOOE+mbcOgFIiiRCYhPRXjUb3/?= =?us-ascii?Q?ug=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4929.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3fcdfa0-1b9e-49b1-b960-08db4fec9ee2 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 May 2023 17:49:49.9573 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: YtGZMqK4ScpVosqLdRRMKiCTmyrPVledYFgOkVHoegx1lzd++5rIUVmkEBj4UxtlcP/nIAKd3XDMR4LtgKUUVNMhKsMuUvzjz55aNq+W1s0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6116 Return-Path: michael.d.kinney@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Victor, Comment on SwapBytesGuid() API below. I believe there is a significant log= ic issues and an opportunity to simplify. Please let me know if you found = a different algorithm to perform GUID LE <-> BE conversions. A second comment on the limit on max instances being 5. Why is 5 selected?= The HOB list can support any number of instances and the consumers that n= eed to cache the HOB state can do dynamical allocation using AllocatePool()= to allocate space for the number of HOBs detected. Mike > -----Original Message----- > From: Hsu, VictorX > Sent: Sunday, May 7, 2023 10:32 PM > To: devel@edk2.groups.io > Cc: Hsu, VictorX ; Kinney, Michael D > ; Guo, Gua ; Chan, Laura > ; Prakashan, Krishnadas Veliyathuparambil > ; K N, Karthik > > Subject: [PATCH 2/4] MdeModulePkg: Add TraceHubDebugSysTLib library >=20 > From: VictorX Hsu >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4144 >=20 > This Library provides API to dump Trace Hub message. >=20 > Cc: Michael D Kinney > Cc: Guo Gua > Cc: Chan Laura > Cc: Prakashan Krishnadas Veliyathuparambil > > Cc: K N Karthik > Signed-off-by: VictorX Hsu > --- > .../Include/Guid/TraceHubDebugInfoHob.h | 25 ++ > .../BaseTraceHubDebugSysTLib.c | 251 +++++++++++++++ > .../BaseTraceHubDebugSysTLib.inf | 44 +++ > .../DxeSmmTraceHubDebugSysTLib.c | 247 +++++++++++++++ > .../DxeSmmTraceHubDebugSysTLib.inf | 50 +++ > .../InternalTraceHubApi.c | 82 +++++ > .../InternalTraceHubApi.h | 46 +++ > .../InternalTraceHubApiCommon.c | 208 +++++++++++++ > .../InternalTraceHubApiCommon.h | 119 +++++++ > .../PeiTraceHubDebugSysTLib.c | 290 ++++++++++++++++++ > .../PeiTraceHubDebugSysTLib.inf | 50 +++ > .../Library/TraceHubDebugSysTLib/Readme.md | 30 ++ > MdeModulePkg/MdeModulePkg.dec | 21 ++ > MdeModulePkg/MdeModulePkg.dsc | 3 + > MdeModulePkg/MdeModulePkg.uni | 18 ++ > MdePkg/Include/Library/TraceHubDebugSysTLib.h | 81 +++++ > MdePkg/MdePkg.dec | 4 + > 17 files changed, 1569 insertions(+) > create mode 100644 MdeModulePkg/Include/Guid/TraceHubDebugInfoHob.h > create mode 100644 > MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib.c > create mode 100644 > MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib.i > nf > create mode 100644 > MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSysTL > ib.c > create mode 100644 > MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSysTL > ib.inf > create mode 100644 > MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.c > create mode 100644 > MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.h > create mode 100644 > MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApiCommon > .c > create mode 100644 > MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApiCommon > .h > create mode 100644 > MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.c > create mode 100644 > MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.inf > create mode 100644 > MdeModulePkg/Library/TraceHubDebugSysTLib/Readme.md > create mode 100644 MdePkg/Include/Library/TraceHubDebugSysTLib.h >=20 > diff --git a/MdeModulePkg/Include/Guid/TraceHubDebugInfoHob.h > b/MdeModulePkg/Include/Guid/TraceHubDebugInfoHob.h > new file mode 100644 > index 0000000000..3a8fcc3d21 > --- /dev/null > +++ b/MdeModulePkg/Include/Guid/TraceHubDebugInfoHob.h > @@ -0,0 +1,25 @@ > +/** @file >=20 > +This header file declares Trace Hub related structure. >=20 > + >=20 > +Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > + >=20 > +SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > +**/ >=20 > + >=20 > +#ifndef TRACE_HUB_DEBUG_INFO_HOB_H_ >=20 > +#define TRACE_HUB_DEBUG_INFO_HOB_H_ >=20 > + >=20 > +#define TRACEHUB_DEBUG_INFO_HOB_REVISION 1 >=20 > +#define MAX_TRACE_HUB_DEBUG_INSTANCE 5 Why is this hard coded to 5 instances? Can't all consumers use the number = of instances of this GUIDed HOB that are present in the HOB list? >=20 > + >=20 > +typedef struct { >=20 > + UINT16 Revision; // Structure revision >=20 > + BOOLEAN Flag; // Flag to enable or disable Trace Hub= debug > message. >=20 > + UINT8 DebugLevel; // Debug level for Trace Hub. >=20 > + UINT8 Rvsd[4]; // Reserved for future use >=20 > + UINT64 TraceHubMmioAddress; // MMIO address where Trace Hub > debug message output to. >=20 > +} TRACEHUB_DEBUG_INFO_HOB; >=20 > + >=20 > +extern GUID gTraceHubDebugInfoHobGuid; >=20 > + >=20 > +#endif // TRACE_HUB_DEBUG_INFO_HOB_H_ >=20 > diff --git > a/MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib > .c > b/MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib > .c > new file mode 100644 > index 0000000000..fbf1cc2a9e > --- /dev/null > +++ > b/MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib > .c > @@ -0,0 +1,251 @@ > +/** @file >=20 > +System prints Trace Hub message in SEC/PEI/DXE/SMM based on fixed PCDs. >=20 > +Only support single Trace Hub debug instance. >=20 > + >=20 > +Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > + >=20 > +SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include "InternalTraceHubApiCommon.h" >=20 > +#include "InternalTraceHubApi.h" >=20 > + >=20 > +/** >=20 > + Write debug string to specified Trace Hub MMIO address. >=20 > + >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + @param[in] Buffer A pointer to the data buffer. >=20 > + @param[in] NumberOfBytes The size of data buffer. >=20 > + >=20 > + @retval RETURN_SUCCESS Data was written to Trace Hub. >=20 > + @retval Other Failed to output Trace Hub message. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +TraceHubSysTDebugWrite ( >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType, >=20 > + IN UINT8 *Buffer, >=20 > + IN UINTN NumberOfBytes >=20 > + ) >=20 > +{ >=20 > + MIPI_SYST_HANDLE MipiSystHandle; >=20 > + MIPI_SYST_HEADER MipiSystHeader; >=20 > + RETURN_STATUS Status; >=20 > + UINT32 DbgInstCount; >=20 > + UINT16 Index; >=20 > + >=20 > + DbgInstCount =3D 0; >=20 > + >=20 > + if (NumberOfBytes =3D=3D 0) { >=20 > + // >=20 > + // No data need to be written to Trace Hub >=20 > + // >=20 > + return RETURN_ABORTED; >=20 > + } >=20 > + >=20 > + if (Buffer =3D=3D NULL) { >=20 > + return RETURN_INVALID_PARAMETER; >=20 > + } >=20 > + >=20 > + DbgInstCount =3D CountThDebugInstance (); >=20 > + >=20 > + ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE)); >=20 > + MipiSystHandle.systh_header =3D &MipiSystHeader; >=20 > + >=20 > + Status =3D InitMipiSystHandle (&MipiSystHandle); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > + for (Index =3D 0; Index < DbgInstCount; Index++) { >=20 > + Status =3D CheckWhetherToOutputMsg ( >=20 > + &MipiSystHandle, >=20 > + NULL, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + TraceHubDebugType >=20 > + ); >=20 > + if (!RETURN_ERROR (Status)) { >=20 > + Status =3D MipiSystWriteDebug ( >=20 > + &MipiSystHandle, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + (UINT16)NumberOfBytes, >=20 > + (CHAR8 *)Buffer >=20 > + ); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + break; >=20 > + } >=20 > + } >=20 > + } >=20 > + >=20 > + return Status; >=20 > +} >=20 > + >=20 > +/** >=20 > + Write catalog status code message to specified Trace Hub MMIO address. >=20 > + >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + @param[in] Id Catalog ID. >=20 > + @param[in] Guid Driver Guid. >=20 > + >=20 > + @retval RETURN_SUCCESS Data was written to Trace Hub. >=20 > + @retval Other Failed to output Trace Hub message. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +TraceHubSysTWriteCataLog64StatusCode ( >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType, >=20 > + IN UINT64 Id, >=20 > + IN GUID *Guid >=20 > + ) >=20 > +{ >=20 > + MIPI_SYST_HANDLE MipiSystHandle; >=20 > + MIPI_SYST_HEADER MipiSystHeader; >=20 > + RETURN_STATUS Status; >=20 > + UINT32 DbgInstCount; >=20 > + UINT16 Index; >=20 > + GUID ConvertedGuid; >=20 > + >=20 > + DbgInstCount =3D 0; >=20 > + >=20 > + if (Guid =3D=3D NULL) { >=20 > + return RETURN_INVALID_PARAMETER; >=20 > + } >=20 > + >=20 > + DbgInstCount =3D CountThDebugInstance (); >=20 > + >=20 > + MipiSystHandle.systh_header =3D &MipiSystHeader; >=20 > + >=20 > + ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE)); >=20 > + Status =3D InitMipiSystHandle (&MipiSystHandle); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > + ConvertedGuid =3D SwapBytesGuid (Guid); >=20 > + CopyMem (&MipiSystHandle.systh_guid, &ConvertedGuid, sizeof (GUID)); >=20 > + MipiSystHandle.systh_tag.et_guid =3D 1; >=20 > + >=20 > + for (Index =3D 0; Index < DbgInstCount; Index++) { >=20 > + Status =3D CheckWhetherToOutputMsg ( >=20 > + &MipiSystHandle, >=20 > + NULL, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + TraceHubCatalogType >=20 > + ); >=20 > + if (!RETURN_ERROR (Status)) { >=20 > + Status =3D MipiSystWriteCatalog ( >=20 > + &MipiSystHandle, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + Id >=20 > + ); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + break; >=20 > + } >=20 > + } >=20 > + } >=20 > + >=20 > + return Status; >=20 > +} >=20 > + >=20 > +/** >=20 > + Write catalog message to specified Trace Hub MMIO address. >=20 > + >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + @param[in] Id Catalog ID. >=20 > + @param[in] NumberOfParams Number of entries in argument list. >=20 > + @param[in] ... Catalog message parameters. >=20 > + >=20 > + @retval RETURN_SUCCESS Data was written to Trace Hub. >=20 > + @retval Other Failed to output Trace Hub message. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +TraceHubSysTWriteCataLog64 ( >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType, >=20 > + IN UINT64 Id, >=20 > + IN UINTN NumberOfParams, >=20 > + ... >=20 > + ) >=20 > +{ >=20 > + MIPI_SYST_HANDLE MipiSystHandle; >=20 > + MIPI_SYST_HEADER MipiSystHeader; >=20 > + VA_LIST Args; >=20 > + UINTN Index; >=20 > + RETURN_STATUS Status; >=20 > + UINT32 DbgInstCount; >=20 > + >=20 > + DbgInstCount =3D 0; >=20 > + >=20 > + if (NumberOfParams > sizeof (MipiSystHandle.systh_param) / sizeof > (UINT32)) { >=20 > + return RETURN_INVALID_PARAMETER; >=20 > + } >=20 > + >=20 > + DbgInstCount =3D CountThDebugInstance (); >=20 > + >=20 > + MipiSystHandle.systh_header =3D &MipiSystHeader; >=20 > + >=20 > + ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE)); >=20 > + Status =3D InitMipiSystHandle (&MipiSystHandle); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > + MipiSystHandle.systh_param_count =3D (UINT32)NumberOfParams; >=20 > + VA_START (Args, NumberOfParams); >=20 > + for (Index =3D 0; Index < NumberOfParams; Index++) { >=20 > + MipiSystHandle.systh_param[Index] =3D VA_ARG (Args, UINT32); >=20 > + } >=20 > + >=20 > + VA_END (Args); >=20 > + >=20 > + for (Index =3D 0; Index < DbgInstCount; Index++) { >=20 > + Status =3D CheckWhetherToOutputMsg ( >=20 > + &MipiSystHandle, >=20 > + NULL, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + TraceHubCatalogType >=20 > + ); >=20 > + if (!RETURN_ERROR (Status)) { >=20 > + Status =3D MipiSystWriteCatalog ( >=20 > + &MipiSystHandle, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + Id >=20 > + ); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + break; >=20 > + } >=20 > + } >=20 > + } >=20 > + >=20 > + return Status; >=20 > +} >=20 > + >=20 > +/** >=20 > + Collect the total number of Trace Hub debug instance in the system. >=20 > + >=20 > + @retval UINT32 The total number of Trace Hub debug instance in th= e > system. >=20 > +**/ >=20 > +UINT32 >=20 > +EFIAPI >=20 > +CountThDebugInstance ( >=20 > + VOID >=20 > + ) >=20 > +{ >=20 > + UINT32 DbgInstCount; >=20 > + >=20 > + // >=20 > + // 1 from PCD. >=20 > + // >=20 > + DbgInstCount =3D 1; >=20 > + >=20 > + return DbgInstCount; >=20 > +} >=20 > diff --git > a/MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib > .inf > b/MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib > .inf > new file mode 100644 > index 0000000000..3edc4e8fd8 > --- /dev/null > +++ > b/MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib > .inf > @@ -0,0 +1,44 @@ > +## @file >=20 > +# Debug library to output Trace Hub message. >=20 > +# Support SEC/PEI/DXE/SMM phase TraceHub debug message based on > fixed settings. >=20 > +# >=20 > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > +# >=20 > +# SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > +# >=20 > +## >=20 > + >=20 > +[Defines] >=20 > + INF_VERSION =3D 0x00010005 >=20 > + BASE_NAME =3D BaseTraceHubDebugSysTLib >=20 > + FILE_GUID =3D 336DA571-AD65-423C-9A43-E0056E5B2D8= D >=20 > + MODULE_TYPE =3D BASE >=20 > + VERSION_STRING =3D 1.0 >=20 > + LIBRARY_CLASS =3D TraceHubDebugSysTLib >=20 > + >=20 > +# >=20 > +# The following information is for reference only and not required by th= e > build tools. >=20 > +# >=20 > +# VALID_ARCHITECTURES =3D IA32 X64 >=20 > +# >=20 > + >=20 > +[LibraryClasses] >=20 > + BaseLib >=20 > + PcdLib >=20 > + BaseMemoryLib >=20 > + MipiSysTLib >=20 > + >=20 > +[Packages] >=20 > + MdePkg/MdePkg.dec >=20 > + MdeModulePkg/MdeModulePkg.dec >=20 > + >=20 > +[Sources] >=20 > + BaseTraceHubDebugSysTLib.c >=20 > + InternalTraceHubApiCommon.c >=20 > + InternalTraceHubApiCommon.h >=20 > + InternalTraceHubApi.h >=20 > + >=20 > +[Pcd] >=20 > + gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugLevel >=20 > + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableTraceHubDebugMsg >=20 > + gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugMmioAddress >=20 > diff --git > a/MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSys > TLib.c > b/MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSys > TLib.c > new file mode 100644 > index 0000000000..626e86c880 > --- /dev/null > +++ > b/MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSys > TLib.c > @@ -0,0 +1,247 @@ > +/** @file >=20 > +System prints Trace Hub message in DXE/SMM based on fixed PCDs and HOB. >=20 > +Support at most MAX_TRACE_HUB_DEBUG_INSTANCE of Trace Hub debug > instances >=20 > +in the system. >=20 > +Trace Hub PCDs will be applied if no HOB exist. >=20 > + >=20 > +Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > + >=20 > +SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include "InternalTraceHubApiCommon.h" >=20 > +#include "InternalTraceHubApi.h" >=20 > + >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED TRACEHUB_DEBUG_INFO_HOB > mThDebugInstArray[MAX_TRACE_HUB_DEBUG_INSTANCE]; >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mDbgInstCount =3D= 0; >=20 > + >=20 > +/** >=20 > + Write debug string to specified Trace Hub MMIO address. >=20 > + >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + @param[in] Buffer A pointer to the data buffer. >=20 > + @param[in] NumberOfBytes The size of data buffer. >=20 > + >=20 > + @retval RETURN_SUCCESS Data was written to Trace Hub. >=20 > + @retval Other Failed to output Trace Hub message. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +TraceHubSysTDebugWrite ( >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType, >=20 > + IN UINT8 *Buffer, >=20 > + IN UINTN NumberOfBytes >=20 > + ) >=20 > +{ >=20 > + MIPI_SYST_HANDLE MipiSystHandle; >=20 > + MIPI_SYST_HEADER MipiSystHeader; >=20 > + RETURN_STATUS Status; >=20 > + UINT16 Index; >=20 > + >=20 > + if (NumberOfBytes =3D=3D 0) { >=20 > + // >=20 > + // No data need to be written to Trace Hub >=20 > + // >=20 > + return RETURN_ABORTED; >=20 > + } >=20 > + >=20 > + if (Buffer =3D=3D NULL) { >=20 > + return RETURN_INVALID_PARAMETER; >=20 > + } >=20 > + >=20 > + if (mDbgInstCount =3D=3D 0) { >=20 > + mDbgInstCount =3D CountThDebugInstance (); >=20 > + } >=20 > + >=20 > + if (mThDebugInstArray[0].TraceHubMmioAddress =3D=3D 0) { >=20 > + PackThDebugInstance (&mThDebugInstArray[0], mDbgInstCount); >=20 > + } >=20 > + >=20 > + ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE)); >=20 > + MipiSystHandle.systh_header =3D &MipiSystHeader; >=20 > + >=20 > + Status =3D InitMipiSystHandle (&MipiSystHandle); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > + for (Index =3D 0; Index < mDbgInstCount; Index++) { >=20 > + Status =3D CheckWhetherToOutputMsg ( >=20 > + &MipiSystHandle, >=20 > + (UINT8 *)&mThDebugInstArray[Index], >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + TraceHubDebugType >=20 > + ); >=20 > + if (!RETURN_ERROR (Status)) { >=20 > + Status =3D MipiSystWriteDebug ( >=20 > + &MipiSystHandle, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + (UINT16)NumberOfBytes, >=20 > + (CHAR8 *)Buffer >=20 > + ); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + break; >=20 > + } >=20 > + } >=20 > + } >=20 > + >=20 > + return Status; >=20 > +} >=20 > + >=20 > +/** >=20 > + Write catalog status code message to specified Trace Hub MMIO address. >=20 > + >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + @param[in] Id Catalog ID. >=20 > + @param[in] Guid Driver Guid. >=20 > + >=20 > + @retval RETURN_SUCCESS Data was written to Trace Hub. >=20 > + @retval Other Failed to output Trace Hub message. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +TraceHubSysTWriteCataLog64StatusCode ( >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType, >=20 > + IN UINT64 Id, >=20 > + IN GUID *Guid >=20 > + ) >=20 > +{ >=20 > + MIPI_SYST_HANDLE MipiSystHandle; >=20 > + MIPI_SYST_HEADER MipiSystHeader; >=20 > + UINTN Index; >=20 > + RETURN_STATUS Status; >=20 > + GUID ConvertedGuid; >=20 > + >=20 > + if (mDbgInstCount =3D=3D 0) { >=20 > + mDbgInstCount =3D CountThDebugInstance (); >=20 > + } >=20 > + >=20 > + if (mThDebugInstArray[0].TraceHubMmioAddress =3D=3D 0) { >=20 > + PackThDebugInstance (&mThDebugInstArray[0], mDbgInstCount); >=20 > + } >=20 > + >=20 > + MipiSystHandle.systh_header =3D &MipiSystHeader; >=20 > + >=20 > + ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE)); >=20 > + Status =3D InitMipiSystHandle (&MipiSystHandle); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > + if (Guid !=3D NULL) { >=20 > + ConvertedGuid =3D SwapBytesGuid (Guid); >=20 > + CopyMem (&MipiSystHandle.systh_guid, &ConvertedGuid, sizeof (GUID)); >=20 > + MipiSystHandle.systh_tag.et_guid =3D 1; >=20 > + } else { >=20 > + MipiSystHandle.systh_tag.et_modunit =3D 2; >=20 > + MipiSystHandle.systh_tag.et_guid =3D 0; >=20 > + } >=20 > + >=20 > + for (Index =3D 0; Index < mDbgInstCount; Index++) { >=20 > + Status =3D CheckWhetherToOutputMsg ( >=20 > + &MipiSystHandle, >=20 > + (UINT8 *)&mThDebugInstArray[Index], >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + TraceHubCatalogType >=20 > + ); >=20 > + if (!RETURN_ERROR (Status)) { >=20 > + Status =3D MipiSystWriteCatalog ( >=20 > + &MipiSystHandle, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + Id >=20 > + ); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + break; >=20 > + } >=20 > + } >=20 > + } >=20 > + >=20 > + return Status; >=20 > +} >=20 > + >=20 > +/** >=20 > + Write catalog message to specified Trace Hub MMIO address. >=20 > + >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + @param[in] Id Catalog ID. >=20 > + @param[in] NumberOfParams Number of entries in argument list. >=20 > + @param[in] ... Catalog message parameters. >=20 > + >=20 > + @retval RETURN_SUCCESS Data was written to Trace Hub. >=20 > + @retval Other Failed to output Trace Hub message. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +TraceHubSysTWriteCataLog64 ( >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType, >=20 > + IN UINT64 Id, >=20 > + IN UINTN NumberOfParams, >=20 > + ... >=20 > + ) >=20 > +{ >=20 > + MIPI_SYST_HANDLE MipiSystHandle; >=20 > + MIPI_SYST_HEADER MipiSystHeader; >=20 > + VA_LIST Args; >=20 > + UINTN Index; >=20 > + RETURN_STATUS Status; >=20 > + >=20 > + if (NumberOfParams > sizeof (MipiSystHandle.systh_param) / sizeof > (UINT32)) { >=20 > + return RETURN_INVALID_PARAMETER; >=20 > + } >=20 > + >=20 > + if (mDbgInstCount =3D=3D 0) { >=20 > + mDbgInstCount =3D CountThDebugInstance (); >=20 > + } >=20 > + >=20 > + if (mThDebugInstArray[0].TraceHubMmioAddress =3D=3D 0) { >=20 > + PackThDebugInstance (&mThDebugInstArray[0], mDbgInstCount); >=20 > + } >=20 > + >=20 > + MipiSystHandle.systh_header =3D &MipiSystHeader; >=20 > + >=20 > + ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE)); >=20 > + Status =3D InitMipiSystHandle (&MipiSystHandle); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > + MipiSystHandle.systh_param_count =3D (UINT32)NumberOfParams; >=20 > + VA_START (Args, NumberOfParams); >=20 > + for (Index =3D 0; Index < NumberOfParams; Index++) { >=20 > + MipiSystHandle.systh_param[Index] =3D VA_ARG (Args, UINT32); >=20 > + } >=20 > + >=20 > + VA_END (Args); >=20 > + >=20 > + for (Index =3D 0; Index < mDbgInstCount; Index++) { >=20 > + Status =3D CheckWhetherToOutputMsg ( >=20 > + &MipiSystHandle, >=20 > + (UINT8 *)&mThDebugInstArray[Index], >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + TraceHubCatalogType >=20 > + ); >=20 > + if (!RETURN_ERROR (Status)) { >=20 > + Status =3D MipiSystWriteCatalog ( >=20 > + &MipiSystHandle, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + Id >=20 > + ); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + break; >=20 > + } >=20 > + } >=20 > + } >=20 > + >=20 > + return Status; >=20 > +} >=20 > diff --git > a/MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSys > TLib.inf > b/MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSys > TLib.inf > new file mode 100644 > index 0000000000..9ba1b9c42f > --- /dev/null > +++ > b/MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSys > TLib.inf > @@ -0,0 +1,50 @@ > +## @file >=20 > +# Debug library to output Trace Hub message. >=20 > +# Support DXE/SMM phase TraceHub debug message based on fixed or > dynamic settings. >=20 > +# >=20 > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > +# >=20 > +# SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > +# >=20 > +## >=20 > + >=20 > +[Defines] >=20 > + INF_VERSION =3D 0x00010005 >=20 > + BASE_NAME =3D DxeSmmTraceHubDebugSysTLib >=20 > + FILE_GUID =3D A9B7B825-7902-4616-8556-085DA4DFEC7= 2 >=20 > + MODULE_TYPE =3D DXE_DRIVER >=20 > + VERSION_STRING =3D 1.0 >=20 > + LIBRARY_CLASS =3D TraceHubDebugSysTLib|DXE_CORE DXE_D= RIVER > SMM_CORE DXE_SMM_DRIVER UEFI_DRIVER UEFI_APPLICATION >=20 > + >=20 > +# >=20 > +# The following information is for reference only and not required by th= e > build tools. >=20 > +# >=20 > +# VALID_ARCHITECTURES =3D IA32 X64 >=20 > +# >=20 > + >=20 > +[LibraryClasses] >=20 > + BaseLib >=20 > + PcdLib >=20 > + HobLib >=20 > + BaseMemoryLib >=20 > + MemoryAllocationLib >=20 > + MipiSysTLib >=20 > + >=20 > +[Packages] >=20 > + MdePkg/MdePkg.dec >=20 > + MdeModulePkg/MdeModulePkg.dec >=20 > + >=20 > +[Sources] >=20 > + DxeSmmTraceHubDebugSysTLib.c >=20 > + InternalTraceHubApiCommon.c >=20 > + InternalTraceHubApiCommon.h >=20 > + InternalTraceHubApi.h >=20 > + InternalTraceHubApi.c >=20 > + >=20 > +[Guids] >=20 > + gTraceHubDebugInfoHobGuid >=20 > + >=20 > +[Pcd] >=20 > + gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugLevel >=20 > + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableTraceHubDebugMsg >=20 > + gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugMmioAddress >=20 > diff --git > a/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.c > b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.c > new file mode 100644 > index 0000000000..4f2dd0f2e5 > --- /dev/null > +++ b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.c > @@ -0,0 +1,82 @@ > +/** @file >=20 > +Functions implementation in this file are not common for all type of > TraceHubDebugSysTLib. >=20 > + >=20 > +Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > + >=20 > +SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include "InternalTraceHubApi.h" >=20 > + >=20 > +/** >=20 > + Count the total number of Trace Hub debug instance in the system. >=20 > + >=20 > + @retval UINT32 The total number of Trace Hub debug instance in th= e > system. >=20 > +**/ >=20 > +UINT32 >=20 > +EFIAPI >=20 > +CountThDebugInstance ( >=20 > + VOID >=20 > + ) >=20 > +{ >=20 > + UINT8 *DgbContext; >=20 > + UINT32 DbgInstCount; >=20 > + >=20 > + DbgInstCount =3D 0; >=20 > + >=20 > + DgbContext =3D (UINT8 *)GetFirstGuidHob (&gTraceHubDebugInfoHobGuid); >=20 > + if (DgbContext !=3D NULL) { >=20 > + while (DgbContext !=3D NULL) { >=20 > + DbgInstCount++; >=20 > + DgbContext =3D (UINT8 *)GetNextGuidHob > (&gTraceHubDebugInfoHobGuid, GET_NEXT_HOB (DgbContext)); >=20 > + } >=20 > + } else { >=20 > + DbgInstCount++; >=20 > + } >=20 > + >=20 > + // >=20 > + // Trace Hub HOB larger than MAX_TRACE_HUB_DEBUG_INSTANCE won't > be processed. >=20 > + // >=20 > + if (DbgInstCount > MAX_TRACE_HUB_DEBUG_INSTANCE) { >=20 > + DbgInstCount =3D MAX_TRACE_HUB_DEBUG_INSTANCE; >=20 > + } >=20 > + >=20 > + return DbgInstCount; >=20 > +} >=20 > + >=20 > +/** >=20 > + Pack Trace Hub debug instances in the system. >=20 > + >=20 > + @param[in, out] ThPtr A pointer to TRACEHUB_DEBUG_INFO_HOB > structure. >=20 > + @param[in] Count Number of Trace Hub HOBs. >=20 > +**/ >=20 > +VOID >=20 > +EFIAPI >=20 > +PackThDebugInstance ( >=20 > + IN OUT TRACEHUB_DEBUG_INFO_HOB *ThPtr, >=20 > + IN UINT32 Count >=20 > + ) >=20 > +{ >=20 > + UINT8 *DgbContext; >=20 > + UINT16 Index; >=20 > + >=20 > + ZeroMem (ThPtr, sizeof (TRACEHUB_DEBUG_INFO_HOB) * > MAX_TRACE_HUB_DEBUG_INSTANCE); >=20 > + DgbContext =3D GetFirstGuidHob (&gTraceHubDebugInfoHobGuid); >=20 > + if (DgbContext !=3D NULL) { >=20 > + for (Index =3D 0; Index < Count; Index++) { >=20 > + CopyMem (&ThPtr[Index], GET_GUID_HOB_DATA (DgbContext), sizeof > (TRACEHUB_DEBUG_INFO_HOB)); >=20 > + DgbContext =3D GetNextGuidHob (&gTraceHubDebugInfoHobGuid, > GET_NEXT_HOB (DgbContext)); >=20 > + } >=20 > + } else { >=20 > + for (Index =3D 0; Index < Count; Index++) { >=20 > + ThPtr[Index].TraceHubMmioAddress =3D FixedPcdGet64 > (PcdTraceHubDebugMmioAddress); >=20 > + ThPtr[Index].Flag =3D FixedPcdGetBool > (PcdEnableTraceHubDebugMsg); >=20 > + ThPtr[Index].DebugLevel =3D FixedPcdGet8 (PcdTraceHubDebu= gLevel); >=20 > + } >=20 > + } >=20 > +} >=20 > diff --git > a/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.h > b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.h > new file mode 100644 > index 0000000000..a185c17d8c > --- /dev/null > +++ b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.h > @@ -0,0 +1,46 @@ > +/** @file >=20 > +This header file declares functions that are not for common use. >=20 > + >=20 > +Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > + >=20 > +SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#ifndef INTERNAL_TRACE_HUB_API_H_ >=20 > +#define INTERNAL_TRACE_HUB_API_H_ >=20 > + >=20 > +/** >=20 > + Count the total number of Trace Hub debug instance in the system. >=20 > + >=20 > + @retval UINT32 The total number of Trace Hub debug instance in th= e > system. >=20 > +**/ >=20 > +UINT32 >=20 > +EFIAPI >=20 > +CountThDebugInstance ( >=20 > + VOID >=20 > + ); >=20 > + >=20 > +/** >=20 > + Pack Trace Hub debug instances in the system. >=20 > + >=20 > + @param[in, out] ThPtr A pointer to TRACEHUB_DEBUG_INFO_HOB > structure. >=20 > + @param[in] Count Number of Trace Hub HOBs. >=20 > +**/ >=20 > +VOID >=20 > +EFIAPI >=20 > +PackThDebugInstance ( >=20 > + IN OUT TRACEHUB_DEBUG_INFO_HOB *ThPtr, >=20 > + IN UINT32 Count >=20 > + ); >=20 > + >=20 > +/** >=20 > + Convert physical address to virtual address for the pointer to > TRACEHUB_DEBUG_INFO_HOB structure. >=20 > +**/ >=20 > +VOID >=20 > +EFIAPI >=20 > +InternalCreateThExitBootSvcEvent ( >=20 > + VOID >=20 > + ); >=20 > + >=20 > +#endif // INTERNAL_TRACE_HUB_API_H_ >=20 > diff --git > a/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApiComm > on.c > b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApiComm > on.c > new file mode 100644 > index 0000000000..f32eb43192 > --- /dev/null > +++ > b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApiComm > on.c > @@ -0,0 +1,208 @@ > +/** @file >=20 > +Functions implementation defined in this file are common for all type of > TraceHubDebugSysTLib >=20 > + >=20 > +Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > + >=20 > +SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include "InternalTraceHubApiCommon.h" >=20 > +#include "InternalTraceHubApi.h" >=20 > + >=20 > +/** >=20 > + Conditionally determine whether to enable Trace Hub message. >=20 > + >=20 > + @param[in] Flag Flag to enable or disable Trace Hub messag= e. >=20 > + @param[in] DbgLevel Debug Level of Trace Hub. >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + >=20 > + @retval TRUE Enable trace hub message. >=20 > + @retval FALSE Disable trace hub message. >=20 > +**/ >=20 > +BOOLEAN >=20 > +EFIAPI >=20 > +TraceHubDataEnabled ( >=20 > + IN BOOLEAN Flag, >=20 > + IN UINT8 DbgLevel, >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType >=20 > + ) >=20 > +{ >=20 > + if (Flag =3D=3D TraceHubRoutingDisable) { >=20 > + return FALSE; >=20 > + } >=20 > + >=20 > + if (DbgLevel =3D=3D TraceHubDebugLevelError) { >=20 > + if (((SeverityType =3D=3D SeverityFatal) || (SeverityType =3D=3D Sev= erityError))) { >=20 > + return TRUE; >=20 > + } >=20 > + } else if (DbgLevel =3D=3D TraceHubDebugLevelErrorWarning) { >=20 > + if (((SeverityType =3D=3D SeverityFatal) || (SeverityType =3D=3D Sev= erityError) || > (SeverityType =3D=3D SeverityWarning))) { >=20 > + return TRUE; >=20 > + } >=20 > + } else if (DbgLevel =3D=3D TraceHubDebugLevelErrorWarningInfo) { >=20 > + if (((SeverityType =3D=3D SeverityFatal) || (SeverityType =3D=3D Sev= erityError) || > (SeverityType =3D=3D SeverityWarning) || (SeverityType =3D=3D SeverityNor= mal))) { >=20 > + return TRUE; >=20 > + } >=20 > + } else if (DbgLevel =3D=3D TraceHubDebugLevelErrorWarningInfoVerbose) = { >=20 > + return TRUE; >=20 > + } >=20 > + >=20 > + return FALSE; >=20 > +} >=20 > + >=20 > +/** >=20 > + Convert GUID from LE to BE or BE to LE. >=20 > + >=20 > + @param[in] Guid GUID to be converted. >=20 > + >=20 > + @retval RETURN_SUCCESS Operation is successful. >=20 > +**/ >=20 > +GUID >=20 > +EFIAPI >=20 > +SwapBytesGuid ( >=20 > + IN GUID *Guid >=20 > + ) >=20 > +{ >=20 > + GUID ConvertedGuid; >=20 > + UINT64 GuidData4; >=20 > + >=20 > + ZeroMem (&ConvertedGuid, sizeof (GUID)); >=20 > + ConvertedGuid.Data1 =3D SwapBytes32 (Guid->Data1); >=20 > + ConvertedGuid.Data2 =3D SwapBytes16 (Guid->Data2); >=20 > + ConvertedGuid.Data3 =3D SwapBytes16 (Guid->Data3); >=20 > + CopyMem (&GuidData4, Guid->Data4, sizeof (Guid->Data4)); >=20 > + GuidData4 =3D SwapBytes64 (GuidData4); >=20 > + CopyMem (ConvertedGuid.Data4, &GuidData4, sizeof (GuidData4)); >=20 > + >=20 > + return ConvertedGuid; >=20 > +} I do not think the algorithm in this API is correct. I used python uuid mo= dule to generate a GUID and dump it as little endian and big endian. The U= INT32 and UINT16 fields are swapped, but the 8 byte array GuideData4 is lef= t alone. >>> [int(x) for x in a.bytes] [157, 128, 47, 218, 201, 182, 17, 237, 164, 194, 84, 225, 173, 59, 241, 52] >>> [int(x) for x in a.bytes_le] [218, 47, 128, 157, 182, 201, 237, 17, 164, 194, 84, 225, 173, 59, 241, 52] I think the following should be the simplified and correct version of this = API. RETURN_STATUS EFIAPI SwapBytesGuid ( IN OUT GUID *Guid ) { Guid->Data1 =3D SwapBytes32 (Guid->Data1); Guid->Data2 =3D SwapBytes16 (Guid->Data2); Guid->Data3 =3D SwapBytes16 (Guid->Data3); return RETURN_SUCCESS; } >=20 > + >=20 > +/** >=20 > + Check whether to output Trace Hub message according to some conditions= . >=20 > + Trace Hub message will be disabled if TraceHubDataEnabled() return FAL= SE >=20 > + or Trace Hub MMIO address is 0. >=20 > + >=20 > + @param[in, out] MipiSystHandle A pointer to MIPI_SYST_HANDLE > structure. >=20 > + @param[in] DgbContext A pointer to Trace Hub debug instanc= e. >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + @param[in] PrintType Either catalog print or debug print. >=20 > + >=20 > + @retval RETURN_SUCCESS Current Trace Hub message need to be > output. >=20 > + @retval Other Current Trace Hub message will be disabled= . >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +CheckWhetherToOutputMsg ( >=20 > + IN OUT MIPI_SYST_HANDLE *MipiSystHandle, >=20 > + IN UINT8 *DgbContext, >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType, >=20 > + IN TRACEHUB_PRINTTYPE PrintType >=20 > + ) >=20 > +{ >=20 > + UINT8 DbgLevel; >=20 > + BOOLEAN Flag; >=20 > + UINT64 Addr; >=20 > + RETURN_STATUS Status; >=20 > + >=20 > + if (MipiSystHandle =3D=3D NULL) { >=20 > + return RETURN_INVALID_PARAMETER; >=20 > + } >=20 > + >=20 > + if (PrintType =3D=3D TraceHubDebugType) { >=20 > + Status =3D GetTraceHubMsgVisibility (DgbContext, &Flag, &DbgLevel); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > + if (!TraceHubDataEnabled (Flag, DbgLevel, SeverityType)) { >=20 > + return RETURN_ABORTED; >=20 > + } >=20 > + } >=20 > + >=20 > + Status =3D GetTraceHubMmioAddress (DgbContext, &Addr); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > + MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAddr =3D Addr; >=20 > + if (MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAddr =3D= =3D 0) > { >=20 > + return RETURN_ABORTED; >=20 > + } >=20 > + >=20 > + return RETURN_SUCCESS; >=20 > +} >=20 > + >=20 > +/** >=20 > + Get Trace Hub MMIO Address. >=20 > + >=20 > + @param[in] DgbContext A pointer to Trace Hub debug instanc= e. >=20 > + @param[in, out] TraceAddress Trace Hub MMIO Address. >=20 > + >=20 > + @retval RETURN_SUCCESS Operation is successfully. >=20 > + @retval Other Operation is failed. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +GetTraceHubMmioAddress ( >=20 > + IN UINT8 *DgbContext, >=20 > + IN OUT UINT64 *TraceAddress >=20 > + ) >=20 > +{ >=20 > + TRACEHUB_DEBUG_INFO_HOB *ThDbgContext; >=20 > + >=20 > + if (TraceAddress =3D=3D NULL) { >=20 > + return RETURN_INVALID_PARAMETER; >=20 > + } >=20 > + >=20 > + if (DgbContext !=3D NULL) { >=20 > + ThDbgContext =3D (TRACEHUB_DEBUG_INFO_HOB *)DgbContext; >=20 > + *TraceAddress =3D ThDbgContext->TraceHubMmioAddress; >=20 > + } else { >=20 > + *TraceAddress =3D FixedPcdGet64 (PcdTraceHubDebugMmioAddress); >=20 > + } >=20 > + >=20 > + return RETURN_SUCCESS; >=20 > +} >=20 > + >=20 > +/** >=20 > + Get visibility of Trace Hub Msg. >=20 > + >=20 > + @param[in] DgbContext A pointer to Trace Hub debug instance. >=20 > + @param[in, out] Flag Flag to enable or disable Trace Hub me= ssage. >=20 > + @param[in, out] DbgLevel Debug Level of Trace Hub. >=20 > + >=20 > + @retval RETURN_SUCCESS Operation is successfully. >=20 > + @retval Other Operation is failed. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +GetTraceHubMsgVisibility ( >=20 > + IN UINT8 *DgbContext, >=20 > + IN OUT BOOLEAN *Flag, >=20 > + IN OUT UINT8 *DbgLevel >=20 > + ) >=20 > +{ >=20 > + TRACEHUB_DEBUG_INFO_HOB *ThDbgContext; >=20 > + >=20 > + if ((Flag =3D=3D NULL) || (DbgLevel =3D=3D NULL)) { >=20 > + return RETURN_INVALID_PARAMETER; >=20 > + } >=20 > + >=20 > + if (DgbContext !=3D NULL) { >=20 > + ThDbgContext =3D (TRACEHUB_DEBUG_INFO_HOB *)DgbContext; >=20 > + *Flag =3D ThDbgContext->Flag; >=20 > + *DbgLevel =3D ThDbgContext->DebugLevel; >=20 > + } else { >=20 > + *DbgLevel =3D FixedPcdGet8 (PcdTraceHubDebugLevel); >=20 > + *Flag =3D FixedPcdGetBool (PcdEnableTraceHubDebugMsg); >=20 > + } >=20 > + >=20 > + return RETURN_SUCCESS; >=20 > +} >=20 > diff --git > a/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApiComm > on.h > b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApiComm > on.h > new file mode 100644 > index 0000000000..771c4400af > --- /dev/null > +++ > b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApiComm > on.h > @@ -0,0 +1,119 @@ > +/** @file >=20 > +This header file declares functions and type for common use. >=20 > + >=20 > +Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > + >=20 > +SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#ifndef INTERNAL_TRACE_HUB_API_COMMON_H_ >=20 > +#define INTERNAL_TRACE_HUB_API_COMMON_H_ >=20 > + >=20 > +typedef enum { >=20 > + TraceHubDebugType =3D 0, >=20 > + TraceHubCatalogType >=20 > +} TRACEHUB_PRINTTYPE; >=20 > + >=20 > +typedef enum { >=20 > + TraceHubRoutingDisable =3D 0, >=20 > + TraceHubRoutingEnable, >=20 > + TraceHubRoutingMax >=20 > +} TRACE_HUB_ROUTING; >=20 > + >=20 > +typedef enum { >=20 > + TraceHubDebugLevelError =3D 0, >=20 > + TraceHubDebugLevelErrorWarning, >=20 > + TraceHubDebugLevelErrorWarningInfo, >=20 > + TraceHubDebugLevelErrorWarningInfoVerbose, >=20 > + TraceHubDebugLevelMax >=20 > +} TRACE_HUB_DEBUG_LEVEL; >=20 > + >=20 > +/** >=20 > + Conditionally determine whether to enable Trace Hub message. >=20 > + >=20 > + @param[in] Flag Flag to enable or disable Trace Hub messag= e. >=20 > + @param[in] DbgLevel Debug Level of Trace Hub. >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + >=20 > + @retval TRUE Enable trace hub message. >=20 > + @retval FALSE Disable trace hub message. >=20 > +**/ >=20 > +BOOLEAN >=20 > +EFIAPI >=20 > +TraceHubDataEnabled ( >=20 > + IN BOOLEAN Flag, >=20 > + IN UINT8 DbgLevel, >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType >=20 > + ); >=20 > + >=20 > +/** >=20 > + Convert GUID from LE to BE or BE to LE. >=20 > + >=20 > + @param[in] Guid GUID to be converted. >=20 > + >=20 > + @retval RETURN_SUCCESS Operation is successful. >=20 > +**/ >=20 > +GUID >=20 > +EFIAPI >=20 > +SwapBytesGuid ( >=20 > + IN OUT GUID *Guid >=20 > + ); >=20 > + >=20 > +/** >=20 > + Check whether to output Trace Hub message according to some conditions= . >=20 > + Trace Hub message will be disabled if TraceHubDataEnabled() return FAL= SE >=20 > + or Trace Hub MMIO address is 0. >=20 > + >=20 > + @param[in, out] MipiSystHandle A pointer to MIPI_SYST_HANDLE > structure. >=20 > + @param[in] DgbContext A pointer to Trace Hub debug instanc= e. >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + @param[in] PrintType Either catalog print or debug print. >=20 > + >=20 > + @retval RETURN_SUCCESS Current Trace Hub message need to be > output. >=20 > + @retval Other Current Trace Hub message will be disabled= . >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +CheckWhetherToOutputMsg ( >=20 > + IN OUT MIPI_SYST_HANDLE *MipiSystHandle, >=20 > + IN UINT8 *DgbContext, >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType, >=20 > + IN TRACEHUB_PRINTTYPE PrintType >=20 > + ); >=20 > + >=20 > +/** >=20 > + Get Trace Hub MMIO Address. >=20 > + >=20 > + @param[in] DgbContext A pointer to Trace Hub debug instanc= e. >=20 > + @param[in, out] TraceAddress Trace Hub MMIO Address. >=20 > + >=20 > + @retval RETURN_SUCCESS Operation is successfully. >=20 > + @retval Other Operation is failed. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +GetTraceHubMmioAddress ( >=20 > + IN UINT8 *DgbContext, >=20 > + IN OUT UINT64 *TraceAddress >=20 > + ); >=20 > + >=20 > +/** >=20 > + Get visibility of Trace Hub Msg. >=20 > + >=20 > + @param[in] DgbContext A pointer to Trace Hub debug instance. >=20 > + @param[in, out] Flag Flag to enable or disable Trace Hub me= ssage. >=20 > + @param[in, out] DbgLevel Debug Level of Trace Hub. >=20 > + >=20 > + @retval RETURN_SUCCESS Operation is successfully. >=20 > + @retval Other Operation is failed. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +GetTraceHubMsgVisibility ( >=20 > + IN UINT8 *DgbContext, >=20 > + IN OUT BOOLEAN *Flag, >=20 > + IN OUT UINT8 *DbgLevel >=20 > + ); >=20 > + >=20 > +#endif // INTERNAL_TRACE_HUB_API_COMMON_H_ >=20 > diff --git > a/MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.c > b/MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.c > new file mode 100644 > index 0000000000..fafd651499 > --- /dev/null > +++ > b/MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.c > @@ -0,0 +1,290 @@ > +/** @file >=20 > +System prints Trace Hub message in PEI based on fixed PCDs and HOB. >=20 > +System applies Trace Hub HOB once it detect gTraceHubDebugInfoHobGuid > HOB. >=20 > +Support at most MAX_TRACE_HUB_DEBUG_INSTANCE of Trace Hub debug > instances >=20 > +in the system. >=20 > +Trace Hub PCDs will be applied if no HOB exist. >=20 > + >=20 > +Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > + >=20 > +SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include "InternalTraceHubApiCommon.h" >=20 > +#include "InternalTraceHubApi.h" >=20 > + >=20 > +/** >=20 > + Write debug string to specified Trace Hub MMIO address. >=20 > + >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + @param[in] Buffer A pointer to the data buffer. >=20 > + @param[in] NumberOfBytes The size of data buffer. >=20 > + >=20 > + @retval RETURN_SUCCESS Data was written to Trace Hub. >=20 > + @retval Other Failed to output Trace Hub message. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +TraceHubSysTDebugWrite ( >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType, >=20 > + IN UINT8 *Buffer, >=20 > + IN UINTN NumberOfBytes >=20 > + ) >=20 > +{ >=20 > + MIPI_SYST_HANDLE MipiSystHandle; >=20 > + MIPI_SYST_HEADER MipiSystHeader; >=20 > + RETURN_STATUS Status; >=20 > + UINT8 *DgbContext; >=20 > + UINTN Index; >=20 > + UINT32 DbgInstCount; >=20 > + UINT8 *ThDebugInfo; >=20 > + >=20 > + DbgInstCount =3D 0; >=20 > + >=20 > + if (NumberOfBytes =3D=3D 0) { >=20 > + // >=20 > + // No data need to be written to Trace Hub >=20 > + // >=20 > + return RETURN_ABORTED; >=20 > + } >=20 > + >=20 > + if (Buffer =3D=3D NULL) { >=20 > + return RETURN_INVALID_PARAMETER; >=20 > + } >=20 > + >=20 > + DbgInstCount =3D CountThDebugInstance (); >=20 > + >=20 > + ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE)); >=20 > + MipiSystHandle.systh_header =3D &MipiSystHeader; >=20 > + >=20 > + Status =3D InitMipiSystHandle (&MipiSystHandle); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > + DgbContext =3D (UINT8 *)GetFirstGuidHob (&gTraceHubDebugInfoHobGuid); >=20 > + if (DgbContext !=3D NULL) { >=20 > + ThDebugInfo =3D GET_GUID_HOB_DATA (DgbContext); >=20 > + } else { >=20 > + ThDebugInfo =3D NULL; >=20 > + } >=20 > + >=20 > + for (Index =3D 0; Index < DbgInstCount; Index++) { >=20 > + Status =3D CheckWhetherToOutputMsg ( >=20 > + &MipiSystHandle, >=20 > + ThDebugInfo, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + TraceHubDebugType >=20 > + ); >=20 > + if (!RETURN_ERROR (Status)) { >=20 > + Status =3D MipiSystWriteDebug ( >=20 > + &MipiSystHandle, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + (UINT16)NumberOfBytes, >=20 > + (CHAR8 *)Buffer >=20 > + ); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + break; >=20 > + } >=20 > + } >=20 > + >=20 > + if (DgbContext !=3D NULL) { >=20 > + DgbContext =3D (UINT8 *)GetNextGuidHob > (&gTraceHubDebugInfoHobGuid, GET_NEXT_HOB (DgbContext)); >=20 > + if (DgbContext =3D=3D NULL) { >=20 > + break; >=20 > + } >=20 > + >=20 > + ThDebugInfo =3D GET_GUID_HOB_DATA (DgbContext); >=20 > + } >=20 > + } >=20 > + >=20 > + return Status; >=20 > +} >=20 > + >=20 > +/** >=20 > + Write catalog status code message to specified Trace Hub MMIO address. >=20 > + >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + @param[in] Id Catalog ID. >=20 > + @param[in] Guid Driver Guid. >=20 > + >=20 > + @retval RETURN_SUCCESS Data was written to Trace Hub. >=20 > + @retval Other Failed to output Trace Hub message. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +TraceHubSysTWriteCataLog64StatusCode ( >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType, >=20 > + IN UINT64 Id, >=20 > + IN GUID *Guid >=20 > + ) >=20 > +{ >=20 > + MIPI_SYST_HANDLE MipiSystHandle; >=20 > + MIPI_SYST_HEADER MipiSystHeader; >=20 > + UINT32 DbgInstCount; >=20 > + UINT8 *DgbContext; >=20 > + RETURN_STATUS Status; >=20 > + UINTN Index; >=20 > + UINT8 *ThDebugInfo; >=20 > + GUID ConvertedGuid; >=20 > + >=20 > + DbgInstCount =3D 0; >=20 > + >=20 > + DbgInstCount =3D CountThDebugInstance (); >=20 > + >=20 > + MipiSystHandle.systh_header =3D &MipiSystHeader; >=20 > + >=20 > + ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE)); >=20 > + Status =3D InitMipiSystHandle (&MipiSystHandle); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > + if (Guid !=3D NULL) { >=20 > + ConvertedGuid =3D SwapBytesGuid (Guid); >=20 > + CopyMem (&MipiSystHandle.systh_guid, &ConvertedGuid, sizeof (GUID)); >=20 > + MipiSystHandle.systh_tag.et_guid =3D 1; >=20 > + } else { >=20 > + MipiSystHandle.systh_tag.et_modunit =3D 2; >=20 > + MipiSystHandle.systh_tag.et_guid =3D 0; >=20 > + } >=20 > + >=20 > + DgbContext =3D (UINT8 *)GetFirstGuidHob (&gTraceHubDebugInfoHobGuid); >=20 > + if (DgbContext !=3D NULL) { >=20 > + ThDebugInfo =3D GET_GUID_HOB_DATA (DgbContext); >=20 > + } else { >=20 > + ThDebugInfo =3D NULL; >=20 > + } >=20 > + >=20 > + for (Index =3D 0; Index < DbgInstCount; Index++) { >=20 > + Status =3D CheckWhetherToOutputMsg ( >=20 > + &MipiSystHandle, >=20 > + ThDebugInfo, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + TraceHubCatalogType >=20 > + ); >=20 > + if (!RETURN_ERROR (Status)) { >=20 > + Status =3D MipiSystWriteCatalog ( >=20 > + &MipiSystHandle, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + Id >=20 > + ); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + break; >=20 > + } >=20 > + } >=20 > + >=20 > + if (DgbContext !=3D NULL) { >=20 > + DgbContext =3D (UINT8 *)GetNextGuidHob > (&gTraceHubDebugInfoHobGuid, GET_NEXT_HOB (DgbContext)); >=20 > + if (DgbContext =3D=3D NULL) { >=20 > + break; >=20 > + } >=20 > + >=20 > + ThDebugInfo =3D GET_GUID_HOB_DATA (DgbContext); >=20 > + } >=20 > + } >=20 > + >=20 > + return Status; >=20 > +} >=20 > + >=20 > +/** >=20 > + Write catalog message to specified Trace Hub MMIO address. >=20 > + >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + @param[in] Id Catalog ID. >=20 > + @param[in] NumberOfParams Number of entries in argument list. >=20 > + @param[in] ... Catalog message parameters. >=20 > + >=20 > + @retval RETURN_SUCCESS Data was written to Trace Hub. >=20 > + @retval Other Failed to output Trace Hub message. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +TraceHubSysTWriteCataLog64 ( >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType, >=20 > + IN UINT64 Id, >=20 > + IN UINTN NumberOfParams, >=20 > + ... >=20 > + ) >=20 > +{ >=20 > + MIPI_SYST_HANDLE MipiSystHandle; >=20 > + MIPI_SYST_HEADER MipiSystHeader; >=20 > + VA_LIST Args; >=20 > + UINTN Index; >=20 > + UINT32 DbgInstCount; >=20 > + UINT8 *DgbContext; >=20 > + RETURN_STATUS Status; >=20 > + UINT8 *ThDebugInfo; >=20 > + >=20 > + DbgInstCount =3D 0; >=20 > + >=20 > + if (NumberOfParams > sizeof (MipiSystHandle.systh_param) / sizeof > (UINT32)) { >=20 > + return RETURN_INVALID_PARAMETER; >=20 > + } >=20 > + >=20 > + DbgInstCount =3D CountThDebugInstance (); >=20 > + >=20 > + MipiSystHandle.systh_header =3D &MipiSystHeader; >=20 > + >=20 > + ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE)); >=20 > + Status =3D InitMipiSystHandle (&MipiSystHandle); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > + MipiSystHandle.systh_param_count =3D (UINT32)NumberOfParams; >=20 > + VA_START (Args, NumberOfParams); >=20 > + for (Index =3D 0; Index < NumberOfParams; Index++) { >=20 > + MipiSystHandle.systh_param[Index] =3D VA_ARG (Args, UINT32); >=20 > + } >=20 > + >=20 > + VA_END (Args); >=20 > + >=20 > + DgbContext =3D (UINT8 *)GetFirstGuidHob (&gTraceHubDebugInfoHobGuid); >=20 > + if (DgbContext !=3D NULL) { >=20 > + ThDebugInfo =3D GET_GUID_HOB_DATA (DgbContext); >=20 > + } else { >=20 > + ThDebugInfo =3D NULL; >=20 > + } >=20 > + >=20 > + for (Index =3D 0; Index < DbgInstCount; Index++) { >=20 > + Status =3D CheckWhetherToOutputMsg ( >=20 > + &MipiSystHandle, >=20 > + ThDebugInfo, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + TraceHubCatalogType >=20 > + ); >=20 > + if (!RETURN_ERROR (Status)) { >=20 > + Status =3D MipiSystWriteCatalog ( >=20 > + &MipiSystHandle, >=20 > + (MIPI_SYST_SEVERITY)SeverityType, >=20 > + Id >=20 > + ); >=20 > + if (RETURN_ERROR (Status)) { >=20 > + break; >=20 > + } >=20 > + } >=20 > + >=20 > + if (DgbContext !=3D NULL) { >=20 > + DgbContext =3D (UINT8 *)GetNextGuidHob > (&gTraceHubDebugInfoHobGuid, GET_NEXT_HOB (DgbContext)); >=20 > + if (DgbContext =3D=3D NULL) { >=20 > + break; >=20 > + } >=20 > + >=20 > + ThDebugInfo =3D GET_GUID_HOB_DATA (DgbContext); >=20 > + } >=20 > + } >=20 > + >=20 > + return Status; >=20 > +} >=20 > diff --git > a/MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.i > nf > b/MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.i > nf > new file mode 100644 > index 0000000000..2a8184d927 > --- /dev/null > +++ > b/MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.i > nf > @@ -0,0 +1,50 @@ > +## @file >=20 > +# Debug library to output Trace Hub message. >=20 > +# Support PEI phase TraceHub debug message based on fixed or dynamic > settings. >=20 > +# >=20 > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > +# >=20 > +# SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > +# >=20 > +## >=20 > + >=20 > +[Defines] >=20 > + INF_VERSION =3D 0x00010005 >=20 > + BASE_NAME =3D PeiTraceHubDebugSysTLib >=20 > + FILE_GUID =3D C61E8C2E-0935-4E3D-BCBB-5ED84AFD9FD= 1 >=20 > + MODULE_TYPE =3D PEIM >=20 > + VERSION_STRING =3D 1.0 >=20 > + LIBRARY_CLASS =3D TraceHubDebugSysTLib|PEI_CORE PEIM >=20 > + >=20 > +# >=20 > +# The following information is for reference only and not required by th= e > build tools. >=20 > +# >=20 > +# VALID_ARCHITECTURES =3D IA32 X64 >=20 > +# >=20 > + >=20 > +[LibraryClasses] >=20 > + BaseLib >=20 > + PcdLib >=20 > + HobLib >=20 > + BaseMemoryLib >=20 > + MemoryAllocationLib >=20 > + MipiSysTLib >=20 > + >=20 > +[Packages] >=20 > + MdePkg/MdePkg.dec >=20 > + MdeModulePkg/MdeModulePkg.dec >=20 > + >=20 > +[Sources] >=20 > + PeiTraceHubDebugSysTLib.c >=20 > + InternalTraceHubApiCommon.c >=20 > + InternalTraceHubApiCommon.h >=20 > + InternalTraceHubApi.h >=20 > + InternalTraceHubApi.c >=20 > + >=20 > +[Guids] >=20 > + gTraceHubDebugInfoHobGuid >=20 > + >=20 > +[Pcd] >=20 > + gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugLevel >=20 > + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableTraceHubDebugMsg >=20 > + gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugMmioAddress >=20 > diff --git a/MdeModulePkg/Library/TraceHubDebugSysTLib/Readme.md > b/MdeModulePkg/Library/TraceHubDebugSysTLib/Readme.md > new file mode 100644 > index 0000000000..24253eb223 > --- /dev/null > +++ b/MdeModulePkg/Library/TraceHubDebugSysTLib/Readme.md > @@ -0,0 +1,30 @@ > +## Introduction of TrcaceHubDebugSysTLib ## >=20 > +TrcaceHubDebugSysTLib library is a top level library for dumping Trace H= ub > messages. >=20 > +It provides Trace Hub related APIs to dump Trace Hub message via MIPI SY= S- > T submodule. >=20 > +User need to properly configure following Trace Hub related PCDs and HOB= . >=20 > + (See MdeModulePkg.dec to get detailed definition for PCDs below) >=20 > + - PcdTraceHubDebugLevel >=20 > + - PcdEnableTraceHubDebugMsg >=20 > + - PcdTraceHubDebugMmioAddress >=20 > + (See TraceHubDebugInfoHob.h to get detailed definition for HOB below) >=20 > + - gTraceHubDebugInfoHobGuid >=20 > + >=20 > +## BaseTraceHubDebugSysTLib.inf ## >=20 > +System prints Trace Hub message in SEC/PEI/DXE/SMM based on fixed PCDs. >=20 > +Only support single Trace Hub debug instance. >=20 > + >=20 > +## PeiTraceHubDebugSysTLib.inf ## >=20 > +System prints Trace Hub message in PEI based on fixed PCDs and HOB. >=20 > +System applies Trace Hub HOB once it detect gTraceHubDebugInfoHobGuid > HOB. >=20 > +Support at most MAX_TRACE_HUB_DEBUG_INSTANCE of Trace Hub debug > instances >=20 > +in the system. >=20 > +Trace Hub PCDs will be applied if no HOB exist. >=20 > + >=20 > +## DxeSmmTraceHubDebugSysTLib.inf ## >=20 > +System prints Trace Hub message in DXE/SMM based on fixed PCDs and HOB. >=20 > +Support at most MAX_TRACE_HUB_DEBUG_INSTANCE of Trace Hub debug > instances >=20 > +in the system. >=20 > +Trace Hub PCDs will be applied if no HOB exist. >=20 > + >=20 > +## Note ## >=20 > +Trace Hub debug library not support DXE_RUNTIME_DRIVER type of module > currently. >=20 > diff --git a/MdeModulePkg/MdeModulePkg.dec > b/MdeModulePkg/MdeModulePkg.dec > index 3eb4a79bf7..42a1a8e338 100644 > --- a/MdeModulePkg/MdeModulePkg.dec > +++ b/MdeModulePkg/MdeModulePkg.dec > @@ -438,6 +438,9 @@ > ## Include/UniversalPayload/SerialPortInfo.h >=20 > gUniversalPayloadSerialPortInfoGuid =3D { 0xaa7e190d, 0xbe21, 0x4409, = { > 0x8e, 0x67, 0xa2, 0xcd, 0xf, 0x61, 0xe1, 0x70 } } >=20 >=20 >=20 > + ## Include/Guid/TraceHubDebugInfoHob.h >=20 > + gTraceHubDebugInfoHobGuid =3D { 0xf88c9c23, 0x646c, 0x4f6c, { 0x8e, 0x= 3d, > 0x36, 0xa9, 0x43, 0xc1, 0x08, 0x35 } } >=20 > + >=20 > ## GUID used for Boot Discovery Policy FormSet guid and related variab= les. >=20 > gBootDiscoveryPolicyMgrFormsetGuid =3D { 0x5b6f7107, 0xbb3c, 0x4660, { > 0x92, 0xcd, 0x54, 0x26, 0x90, 0x28, 0x0b, 0xbd } } >=20 >=20 >=20 > @@ -1094,6 +1097,24 @@ > # @Prompt Enable UEFI Stack Guard. >=20 >=20 > gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30 > 001055 >=20 >=20 >=20 > + ## Indicate debug level of Trace Hub. >=20 > + # 0x0 - TraceHubDebugLevelError.
>=20 > + # 0x1 - TraceHubDebugLevelErrorWarning.
>=20 > + # 0x2 - TraceHubDebugLevelErrorWarningInfo.
>=20 > + # 0x3 - TraceHubDebugLevelErrorWarningInfoVerbose.
>=20 > + # @Prompt Debug level of Trace Hub. >=20 > + > gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugLevel|0|UINT8|0x3000 > 1056 >=20 > + >=20 > + ## Flag to enable or disable Trace Hub message. >=20 > + # FALSE - Disable Trace Hub debug message.
>=20 > + # TRUE - Enable Trace Hub debug message.
>=20 > + # @Prompt Enable or Disable Trace Hub message. >=20 > + > gEfiMdeModulePkgTokenSpaceGuid.PcdEnableTraceHubDebugMsg|0|BOOLEA > N|0x30001057 >=20 > + >=20 > + ## Indicate MMIO address where Trace Hub message output to. >=20 > + # @Prompt Output MMIO address of Trace Hub message. >=20 > + > gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugMmioAddress|0|UINT > 64|0x30001058 >=20 > + >=20 > [PcdsFixedAtBuild, PcdsPatchableInModule] >=20 > ## Dynamic type PCD can be registered callback function for Pcd settin= g > action. >=20 > # PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum > number of callback function >=20 > diff --git a/MdeModulePkg/MdeModulePkg.dsc > b/MdeModulePkg/MdeModulePkg.dsc > index 1014598f31..5b1f50e9c0 100644 > --- a/MdeModulePkg/MdeModulePkg.dsc > +++ b/MdeModulePkg/MdeModulePkg.dsc > @@ -515,6 +515,9 @@ > MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf >=20 >=20 > MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicatio > nBufferDxe.inf >=20 > MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf >=20 > + > MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib.i > nf >=20 > + > MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.inf >=20 > + > MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSysTL > ib.inf >=20 >=20 >=20 > [Components.X64] >=20 > MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf >=20 > diff --git a/MdeModulePkg/MdeModulePkg.uni > b/MdeModulePkg/MdeModulePkg.uni > index 33ce9f6198..a17d34d60b 100644 > --- a/MdeModulePkg/MdeModulePkg.uni > +++ b/MdeModulePkg/MdeModulePkg.uni > @@ -1290,6 +1290,24 @@ > = " TRUE - UEFI Stack Guard > will be enabled.
\n" >=20 > = " FALSE - UEFI Stack Guard > will be disabled.
" >=20 >=20 >=20 > +#string > STR_gEfiMdeModulePkgTokenSpaceGuid_PcdTraceHubDebugLevel_PROMPT > #language en-US "Debug level of Trace Hub." >=20 > + >=20 > +#string > STR_gEfiMdeModulePkgTokenSpaceGuid_PcdTraceHubDebugLevel_HELP > #language en-US "Indicate debug level of Trace Hub" >=20 > + = " 0x0 - > TraceHubDebugLevelError.
" >=20 > + = " 0x1 - > TraceHubDebugLevelErrorWarning.
" >=20 > + = " 0x2 - > TraceHubDebugLevelErrorWarningInfo.
" >=20 > + = " 0x3 - > TraceHubDebugLevelErrorWarningInfoVerbose.
" >=20 > + >=20 > +#string > STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEnableTraceHubDebugMsg_PRO > MPT #language en-US "Flag to enable or disable Trace Hub message" >=20 > + >=20 > +#string > STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEnableTraceHubDebugMsg_HELP > #language en-US "Enable or Disable Trace Hub message" >=20 > + = " FALSE - Disable > Trace Hub debug message.
" >=20 > + = " TRUE - Enable > Trace Hub debug message.
" >=20 > + >=20 > +#string > STR_gEfiMdeModulePkgTokenSpaceGuid_PcdTraceHubDebugMmioAddress_P > ROMPT #language en-US "Output MMIO address of Trace Hub message" >=20 > + >=20 > +#string > STR_gEfiMdeModulePkgTokenSpaceGuid_PcdTraceHubDebugMmioAddress_H > ELP #language en-US "Indicate MMIO address where Trace Hub message > output to." >=20 > + >=20 > #string > STR_gEfiMdeModulePkgTokenSpaceGuid_PcdSetNvStoreDefaultId_PROMPT > #language en-US "NV Storage DefaultId" >=20 >=20 >=20 > #string > STR_gEfiMdeModulePkgTokenSpaceGuid_PcdSetNvStoreDefaultId_HELP > #language en-US "This dynamic PCD enables the default variable setting.\n= " >=20 > diff --git a/MdePkg/Include/Library/TraceHubDebugSysTLib.h > b/MdePkg/Include/Library/TraceHubDebugSysTLib.h > new file mode 100644 > index 0000000000..7df20e67d6 > --- /dev/null > +++ b/MdePkg/Include/Library/TraceHubDebugSysTLib.h > @@ -0,0 +1,81 @@ > +/** @file >=20 > +This header file declares Trace Hub related top level APIs. >=20 > + >=20 > +Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > + >=20 > +SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#ifndef TRACE_HUB_DEBUG_SYST_LIB_H_ >=20 > +#define TRACE_HUB_DEBUG_SYST_LIB_H_ >=20 > + >=20 > +typedef enum { >=20 > + SeverityNone =3D 0, >=20 > + SeverityFatal =3D 1, >=20 > + SeverityError =3D 2, >=20 > + SeverityWarning =3D 3, >=20 > + SeverityNormal =3D 4, >=20 > + SeverityUser1 =3D 5, >=20 > + SeverityUser2 =3D 6, >=20 > + SeverityUser3 =3D 7, >=20 > + SeverityMax >=20 > +} TRACE_HUB_SEVERITY_TYPE; >=20 > + >=20 > +/** >=20 > + Write debug string to specified Trace Hub MMIO address. >=20 > + >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + @param[in] Buffer A pointer to the data buffer. >=20 > + @param[in] NumberOfBytes The size of data buffer. >=20 > + >=20 > + @retval RETURN_SUCCESS Data was written to Trace Hub. >=20 > + @retval Other Failed to output Trace Hub message. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +TraceHubSysTDebugWrite ( >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType, >=20 > + IN UINT8 *Buffer, >=20 > + IN UINTN NumberOfBytes >=20 > + ); >=20 > + >=20 > +/** >=20 > + Write catalog status code message to specified Trace Hub MMIO address. >=20 > + >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + @param[in] Id Catalog ID. >=20 > + @param[in] Guid Driver Guid. >=20 > + >=20 > + @retval RETURN_SUCCESS Data was written to Trace Hub. >=20 > + @retval Other Failed to output Trace Hub message. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +TraceHubSysTWriteCataLog64StatusCode ( >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType, >=20 > + IN UINT64 Id, >=20 > + IN GUID *Guid >=20 > + ); >=20 > + >=20 > +/** >=20 > + Write catalog message to specified Trace Hub MMIO address. >=20 > + >=20 > + @param[in] SeverityType Severity type of input message. >=20 > + @param[in] Id Catalog ID. >=20 > + @param[in] NumberOfParams Number of entries in argument list. >=20 > + @param[in] ... Catalog message parameters. >=20 > + >=20 > + @retval RETURN_SUCCESS Data was written to Trace Hub. >=20 > + @retval Other Failed to output Trace Hub message. >=20 > +**/ >=20 > +RETURN_STATUS >=20 > +EFIAPI >=20 > +TraceHubSysTWriteCataLog64 ( >=20 > + IN TRACE_HUB_SEVERITY_TYPE SeverityType, >=20 > + IN UINT64 Id, >=20 > + IN UINTN NumberOfParams, >=20 > + ... >=20 > + ); >=20 > + >=20 > +#endif // TRACE_HUB_DEBUG_SYST_LIB_H_ >=20 > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec > index d68ed988c0..597f4f7137 100644 > --- a/MdePkg/MdePkg.dec > +++ b/MdePkg/MdePkg.dec > @@ -298,6 +298,10 @@ > # >=20 > MipiSysTLib|Include/Library/MipiSysTLib.h >=20 >=20 >=20 > + ## @libraryclass Provides API to output Trace Hub debug message. >=20 > + # >=20 > + TraceHubDebugSysTLib|Include/Library/TraceHubDebugSysTLib.h >=20 > + >=20 > [LibraryClasses.IA32, LibraryClasses.X64, LibraryClasses.AARCH64] >=20 > ## @libraryclass Provides services to generate random number. >=20 > # >=20 > -- > 2.40.0.windows.1