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.web12.4876.1657782426238762584 for ; Thu, 14 Jul 2022 00:07:06 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=ZPjtLcSJ; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657782426; x=1689318426; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=NIoL3fuIRHHKK3i5jGCKIqefg//C6R1O1Z7ZNxMll3Y=; b=ZPjtLcSJc9nxsIjNrraXUYMwiP+Ia0dGRzszn76dQSD5y7ZY045ZkvW2 bTjluJ7ogK8x4C6MMi10vhzoHrtJErfLv8KH9QxTAzGmZt0mK9yUryCPU Mnw7izuY+w/gnbMCJRZHUWr2nUTetKIDHVvEZ+iDQewhcAf1cl81NnIVK PNLbGdnD2TLuba/hACyo5SkE54/2GaNdybUHzFZnRAfdCKBOeqsCMj3D3 ej00pMK+5h7xz7+rCRNgXp2jyr7AmZNpD05CXO0NIBsLg1yDf+FikkPAI jjE/PqrBWqzrGEDQU+z33r2JsN1yRokFdtDZIUwXIiXDD163MU3TsrweF Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10407"; a="371747520" X-IronPort-AV: E=Sophos;i="5.92,269,1650956400"; d="scan'208";a="371747520" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2022 00:07:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,269,1650956400"; d="scan'208";a="772529059" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga005.jf.intel.com with ESMTP; 14 Jul 2022 00:07:05 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 14 Jul 2022 00:07:05 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Thu, 14 Jul 2022 00:07:05 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Thu, 14 Jul 2022 00:07:04 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JlsZ+lqVmuMscPT06sgLWGbhgi16MAnbuoOva7N2a7BQO1I5+1fVEnjLLCe1fF0qyGsIdYva8xf5w67KyIak7jpVlPUai9S3zhtCByclVNJWmRpZW7WhlP4fteEe7r6ASbVxjipA7zVQYv23QzHX7Z05Yrr8nCeqyfbcyxVZhBLElR/nqVAm4EQ6BRbnn3qsv3iBRVjGOSlMW1z1rbOYOluCGAXN4jc6ImCEcJnX41QQm3xtcP0A4cqftHhWBmnjP63EtqwiHrWVeKimHmUYefTCXXaPmpYuPHR4GLiYxIuRYXl9YuKzJPrewAiZl1JPtYLk9/988Mj5c9omMMhQVw== 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=+eVikwaflZP9t0Z+ih74Mv2sEvOfQcOnC9WE1ymGh+o=; b=XaYDdYr61sCWLnrUr/jMui8AqutUw8NwrYjPMlBYBC7V5cSuAsGsSaY29RwPHkbh6ecEbcze71WDs+j5H5STrqWZ3P+Naus/h5vP5wrSW8NCxeHbJvh+sTlburhmAieKWtDvCJFpwHpEeMHBdIbm4F//mlBnYCP53jOybvIRYJ5m5ri/16j+ySASM+6uL5+Mc3Jd/wfO3HV7nn33XzkfM7wBJ7o0vGoRXnaH6HmI9700s2uzMaxMuLoTAxxwDfIoQBTHtAKueynsErkzarezGVEnV8GcYF8KIrG/8CyGWMUja5HIZbnK6n4M9h7cf2ZYYwZWdoPTYNXFaUQ/eAlxsw== 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 MWHPR11MB1631.namprd11.prod.outlook.com (2603:10b6:301:10::10) by DM6PR11MB2585.namprd11.prod.outlook.com (2603:10b6:5:ce::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.25; Thu, 14 Jul 2022 07:07:00 +0000 Received: from MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::991b:97a0:7836:5174]) by MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::991b:97a0:7836:5174%10]) with mapi id 15.20.5417.026; Thu, 14 Jul 2022 07:07:00 +0000 From: "Ni, Ray" To: "Sravanthi, K KavyaX" , "devel@edk2.groups.io" CC: "Dong, Guo" , Maurice Ma , "You, Benjamin" , "Rhodes, Sean" Subject: Re: [PATCH 1/3] UefiPayloadPkg: Implement a new DebugLib instance Thread-Topic: [PATCH 1/3] UefiPayloadPkg: Implement a new DebugLib instance Thread-Index: AQHYlzqWoXCCdoGrVkSx3/Slmkgk9K19cgcg Date: Thu, 14 Jul 2022 07:07:00 +0000 Message-ID: References: <20220714043104.1813-1-k.kavyax.sravanthi@intel.com> In-Reply-To: <20220714043104.1813-1-k.kavyax.sravanthi@intel.com> 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-office365-filtering-correlation-id: 86e3cd5e-ff7d-4d04-522c-08da65677284 x-ms-traffictypediagnostic: DM6PR11MB2585:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: jSwsxKtBZjagMaSIbDx39x8iOPxMwSh1FMaOmvGEeBZLR/wL9MMA/wMXFRuR7Jhj0ayqenCutLJoYPuDzFl2OX+HcN+qwcpYjifXeoyzwW174TYb8oUnr2p8au9iOek019k6UX/aBdZVRGY6jH1D7QeCHfLtymyjJCZ4H5Tca96BxNh3xR5n3YizXLYVoYpnxBUNyl2KmUCjiaQfhCkm3dNQtu1lCKSKCpxhZSZ198WwGNR3qPOgoznduzrl4Pg+Lx2gDZxu5f/4H5DKZ8ddDmX1k7b4NlW84WNqpi49c3HuiB6Vq6pAY6EzfK4Biiyib2ADQgJTQWQZ0o8JuLteYExdcibnLMOJ9mvhzsRd/9O5V4c6mUy5M6acw7997C5JpqoQ1QhN2GgGXlDPlMPHepDsots7SIO1lgTsNSdro9StIWtwKVi6YCrrNL5vTlBtjoc6z5iQ7hT7OtvJNZExoaLrMYmOKefuniDN/cp+uFbZVpXVN7JoDkSgLbcUSqWT0gowV9A+PKrizke0sZ1tDnXjuVrq1VVa2CtYxtweTTqn4jnm2roRb+r7fW1k2U6scWP8BXjQ+iOcQUjKVsc/S23X3MPztMDSy3ks+BsFeFbSy0XpVFmBfQl3Ao9GZTnY3hNiT4X5xImFYgIJnrPhS7f/YmYLnFxgr6C34PV+cphjcPZzjZjn1EwauqD6pWtIfqZUlf6xGlRUs637CUU4AmyZpFrBWlWWm8sdp6CzVJ91rA4lEbxfsLhYEwYm+NkKSmZWjw9ienw4jeodOPRrTGvejaXpX4wUymzN3HdHFX4++tEE3RH92OFqOQXprT78 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR11MB1631.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(376002)(366004)(136003)(396003)(346002)(39860400002)(122000001)(55016003)(30864003)(52536014)(316002)(8936002)(38100700002)(5660300002)(83380400001)(6506007)(7696005)(186003)(66476007)(4326008)(33656002)(8676002)(53546011)(76116006)(86362001)(54906003)(26005)(9686003)(110136005)(38070700005)(478600001)(64756008)(66556008)(66446008)(71200400001)(66946007)(2906002)(82960400001)(41300700001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?06haqxBxg3hFS7N3VJRNhJk67qt56dQkRD8Era2y5AQ09H70AWJHTHd2t+ED?= =?us-ascii?Q?nIPcH1z2zGfgXTfgAPgmQjiYM5daFu/z6ytKLNO0Ag413bG4kBP+jzayMrvR?= =?us-ascii?Q?MCFvtO6sr96BfQSvUmuNdMbtgkjrsmMIMOeZvsZP4zIGFuJxLBFd5yPjC1Fg?= =?us-ascii?Q?U0/CoFjYymG9W+HhiZqlpAlD8CsRqIMUCqkXPiFnA02OZuGU4mAMAbMRwx8N?= =?us-ascii?Q?tNlhZMlI+woxzYjIDJrc7X1iqbZ21gG0z3Azf8rVwGenFAsFegULvTd2eTRi?= =?us-ascii?Q?Q00uKWEux7/sQcgtfvymAaYv1gVgdwuq8wJENGiCYXYkGyI3t7ZwEamcYKGk?= =?us-ascii?Q?O8lcb0ifnlU0eUuT5vIgEPmQvp/7yTYWhZcGDlzMxGnT7GEk2+MWZ4yKibI5?= =?us-ascii?Q?9lYckuyxcVRXFiPrupP2LJ20LNs+PA87GbT0KrtpRDA36oUc8Ylg/ARttzI4?= =?us-ascii?Q?STdSC+dCtd/Vpmg9TfOMP9OVqt+gk17DY6eIIHBv/XjG8pMpamr1Ki4M8FRc?= =?us-ascii?Q?9auFzbvMjq1rZVN9lnMeeoF3gJa1B3t7ZXr2Gfq/iDLteWXhriN+9oSNHW7F?= =?us-ascii?Q?iXt+nNebqNSew1reRGfa1b7a53mXq4JEAl2x5x7kPYpetiylNTumOCgW/Od0?= =?us-ascii?Q?Y8HsAiUp+sL++mlatrjQkjWyVpGwA6km28rmdhOmt19ZrbI8LgN0gwU/t94T?= =?us-ascii?Q?4MRc3ujtLN4s/NbTrb3Hpr7Mlp/u6ulsJJtWehZ1V1jNyaiFmSNMi5E7fNcK?= =?us-ascii?Q?7mE8uWtDJsuh+4G8j3HxmvSym/doF2n2XFEMfgJFEgO1v2SeADPixo+NPR8h?= =?us-ascii?Q?Fr+j+/C5fn5jnLjHl7F2Hm4Nd9GB5vXcKxKhkXGKBMgiYJ3j1/OynrBFmArZ?= =?us-ascii?Q?awBeMZ2aM3+d67QFo+WokmGF6Kadd4NGVtqvF5DTV/0PmDVRk/hfjia71Doy?= =?us-ascii?Q?xKY3LFKJnhrq7ymbj/oW3zgPNUsdN5Q72V/f54v/xQcnKlE9V34ztK8va7sn?= =?us-ascii?Q?7qSCTvr3Yd9LXRj6MGYtPUlZR5x1PxyLG3rP0Y3R/Mo5ssPnYtapD3cBNZ6N?= =?us-ascii?Q?u7b0vYez0nFWyJ/gXSWw/6vBFtlg2xxA9c6Py+gAYzqqMb5uimdylqUdB5yB?= =?us-ascii?Q?MyJ95O43/9F3paxQ9VNpWTvMPFACZXfYnMUlDbjMsrmC8Oh8I0J3Tt1ADWch?= =?us-ascii?Q?S8u5dQ2tNERSk9/FNFtYoeI2deIvqU91n5wruenCZCo4yNwdTpTVdXQ9Thlu?= =?us-ascii?Q?qE3OOCQWyxMzDKJM6JZh5pwlM+E1JcY9Th/CAgbMyBdO93UNhnfRyZgB8btU?= =?us-ascii?Q?AJrcuDI7lBLlKBiGK6ECMxKLckGK0aRy5VYPfZWuaOeaiyg/01g9uuKpcnTE?= =?us-ascii?Q?+qvM1IRTsjZl44iJz4eGyMjgLvHyGdcSeI6Bt5qGYe+uppqsp36kLTL1aLXH?= =?us-ascii?Q?AefmewHm0KJ7c4C3AQDPozu6T+kpWodFQQvPodHRNbiiNgAEoWtAD9wClwIX?= =?us-ascii?Q?IwZ0UD00BvEaysj2kIWv06z+SY+dczup0Fjkf7vFo1zKj9nvIRt5xjgYfCvV?= =?us-ascii?Q?3b9GpVhU5AUAikEYWzoudRBmo9LdJ2pCwheuF30x?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1631.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86e3cd5e-ff7d-4d04-522c-08da65677284 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Jul 2022 07:07:00.3189 (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: BsJ2M2fRHDXxiVRbQ+BNsCMU5Njrsccf4Xl1SuP8zdm1sDvCrVrHy4tpTL0PffIIjMip8xKWClzeoq/Z47W7ew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2585 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Why need a separate DebugLib instance? > -----Original Message----- > From: Sravanthi, K KavyaX > Sent: Thursday, July 14, 2022 12:31 PM > To: devel@edk2.groups.io > Cc: Sravanthi, K KavyaX ; Dong, Guo ; Ni, Ray ; > Maurice Ma ; You, Benjamin = ; Rhodes, Sean > > Subject: [PATCH 1/3] UefiPayloadPkg: Implement a new DebugLib instance >=20 > Add new Debug library instance to support multiple channel debug message. >=20 > Cc: Guo Dong > Cc: Ray Ni > Cc: Maurice Ma > Cc: Benjamin You > Cc: Sean Rhodes > Signed-off-by: Kavya > --- > UefiPayloadPkg/Library/BaseDebugLibHob/BaseDebugLibHob.c | 295 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++++++++++ > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++++++++++ > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++++++++++ > ++++++++++++++++ > UefiPayloadPkg/Library/BaseDebugLibHob/BaseDebugLibHob.inf | 37 +++++++= ++++++++++++++++++++++++++++++ > 2 files changed, 332 insertions(+) >=20 > diff --git a/UefiPayloadPkg/Library/BaseDebugLibHob/BaseDebugLibHob.c > b/UefiPayloadPkg/Library/BaseDebugLibHob/BaseDebugLibHob.c > new file mode 100644 > index 0000000000..0fd9e795a3 > --- /dev/null > +++ b/UefiPayloadPkg/Library/BaseDebugLibHob/BaseDebugLibHob.c > @@ -0,0 +1,295 @@ > +/** @file > + Instance of Debug Library based on Serial Port Library. > + > + Copyright (c) 2022, Intel Corporation. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +// > +// Define the maximum debug and assert message length that this library = supports > +// > +#define MAX_DEBUG_MESSAGE_LENGTH 0x100 > + > +/** > + Initialize the serial device hardware. > + > + If no initialization is required, then return RETURN_SUCCESS. > + If the serial device was successfully initialized, then return RETURN_= SUCCESS. > + If the serial device could not be initialized, then return RETURN_DEVI= CE_ERROR. > + If gUniversalPayloadSerialPortInfoGuid not found, then return RETURN_N= OT_FOUND. > + > + @retval RETURN_SUCCESS The serial device was initialized. > + @retval RETURN_DEVICE_ERROR The serial device could not be initializ= ed. > + @retval RETURN_NOT_FOUND GuidHob not found. > + > +**/ > +RETURN_STATUS > +EFIAPI > +SerialPortInitialize ( > + VOID > + ); > + > +/** > + Write data from buffer to serial device. > + > + Writes NumberOfBytes data bytes from Buffer to the serial device. > + The number of bytes actually written to the serial device is returned. > + If the return value is less than NumberOfBytes, then the write operati= on failed. > + If Buffer is NULL, then return 0. > + If NumberOfBytes is zero, then return 0. > + > + @param Buffer Pointer to the data buffer to be written. > + @param NumberOfBytes Number of bytes to written to the serial devi= ce. > + > + @retval 0 NumberOfBytes is 0. > + @retval >0 The number of bytes written to the serial dev= ice. > + If this value is less than NumberOfBytes, the= n the write operation failed. > + > +**/ > +UINTN > +EFIAPI > +SerialPortWrite ( > + IN UINT8 *Buffer, > + IN UINTN NumberOfBytes > + ); > + > +/** > + Prints a debug message to the debug output device if the specified err= or level is enabled. > + > + If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib functi= on > + GetDebugPrintErrorLevel (), then print the message specified by Format= and the > + associated variable argument list to the debug output device. > + > + If Format is NULL, then ASSERT(). > + > + @param ErrorLevel The error level of the debug message. > + @param Format Format string for the debug message to print. > + @param ... Variable argument list whose contents are accessed > + based on the format string specified by Format. > + > +**/ > +VOID > +EFIAPI > +DebugPrint ( > + IN UINTN ErrorLevel, > + IN CONST CHAR8 *Format, > + ... > + ) > +{ > + CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; > + VA_LIST Marker; > + > + // > + // If Format is NULL, then ASSERT(). > + // > + ASSERT (Format !=3D NULL); > + > + // > + // Check driver debug mask value and global mask > + // > + if ((ErrorLevel & GetDebugPrintErrorLevel ()) =3D=3D 0) { > + return; > + } > + > + // > + // Convert the DEBUG() message to an ASCII String > + // > + VA_START (Marker, Format); > + AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker); > + VA_END (Marker); > + > + SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer)); > +} > + > +/** > + Prints an assert message containing a filename, line number, and descr= iption. > + This may be followed by a breakpoint or a dead loop. > + > + Print a message of the form "ASSERT (): \n" > + to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABL= ED bit of > + PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, = if > + DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is s= et then > + CpuDeadLoop() is called. If neither of these bits are set, then this = function > + returns immediately after the message is printed to the debug output d= evice. > + DebugAssert() must actively prevent recursion. If DebugAssert() is ca= lled while > + processing another DebugAssert(), then DebugAssert() must return immed= iately. > + > + If FileName is NULL, then a string of "(NULL) Filename" is = printed. > + If Description is NULL, then a string of "(NULL) Descrip= tion" is printed. > + > + @param FileName The pointer to the name of the source file that g= enerated the assert condition. > + @param LineNumber The line number in the source file that generated= the assert condition > + @param Description The pointer to the description of the assert cond= ition. > + > +**/ > +VOID > +EFIAPI > +DebugAssert ( > + IN CONST CHAR8 *FileName, > + IN UINTN LineNumber, > + IN CONST CHAR8 *Description > + ) > +{ > + CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; > + > + // > + // Generate the ASSERT() message in Ascii format > + // > + AsciiSPrint (Buffer, sizeof (Buffer), "ASSERT [%a] %a(%d): %a\n", gEfi= CallerBaseName, FileName, LineNumber, > Description); > + > + SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer)); > + > + // > + // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings > + // > + if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_= ENABLED) !=3D 0) { > + CpuBreakpoint (); > + } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEAD= LOOP_ENABLED) !=3D 0) { > + CpuDeadLoop (); > + } > +} > + > +/** > + Fills a target buffer with PcdDebugClearMemoryValue, and returns the t= arget buffer. > + > + This function fills Length bytes of Buffer with the value specified by > + PcdDebugClearMemoryValue, and returns Buffer. > + > + If Buffer is NULL, then ASSERT(). > + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). > + > + @param Buffer Pointer to the target buffer to be filled with PcdDeb= ugClearMemoryValue. > + @param Length Number of bytes in Buffer to fill with zeros PcdDebug= ClearMemoryValue. > + > + @return Buffer Pointer to the target buffer filled with PcdDebugClea= rMemoryValue. > + > +**/ > +VOID * > +EFIAPI > +DebugClearMemory ( > + OUT VOID *Buffer, > + IN UINTN Length > + ) > +{ > + ASSERT (Buffer !=3D NULL); > + > + return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue)); > +} > + > +/** > + Returns TRUE if ASSERT() macros are enabled. > + > + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED = bit of > + PcdDebugProperyMask is set. Otherwise FALSE is returned. > + > + @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDeb= ugProperyMask is set. > + @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDeb= ugProperyMask is clear. > + > +**/ > +BOOLEAN > +EFIAPI > +DebugAssertEnabled ( > + VOID > + ) > +{ > + return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBU= G_ASSERT_ENABLED) !=3D 0); > +} > + > +/** > + Returns TRUE if DEBUG() macros are enabled. > + > + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED b= it of > + PcdDebugProperyMask is set. Otherwise FALSE is returned. > + > + @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebu= gProperyMask is set. > + @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebu= gProperyMask is clear. > + > +**/ > +BOOLEAN > +EFIAPI > +DebugPrintEnabled ( > + VOID > + ) > +{ > + return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBU= G_PRINT_ENABLED) !=3D 0); > +} > + > +/** > + Returns TRUE if DEBUG_CODE() macros are enabled. > + > + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bi= t of > + PcdDebugProperyMask is set. Otherwise FALSE is returned. > + > + @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebug= ProperyMask is set. > + @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebug= ProperyMask is clear. > + > +**/ > +BOOLEAN > +EFIAPI > +DebugCodeEnabled ( > + VOID > + ) > +{ > + return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBU= G_CODE_ENABLED) !=3D 0); > +} > + > +/** > + Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled. > + > + This function returns TRUE if the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED = bit of > + PcdDebugProperyMask is set. Otherwise FALSE is returned. > + > + @retval TRUE The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDeb= ugProperyMask is set. > + @retval FALSE The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDeb= ugProperyMask is clear. > + > +**/ > +BOOLEAN > +EFIAPI > +DebugClearMemoryEnabled ( > + VOID > + ) > +{ > + return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEA= R_MEMORY_ENABLED) !=3D 0); > +} > + > +/** > + Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFi= xedDebugPrintErrorLevel. > + > + This function compares the bit mask of ErrorLevel and PcdFixedDebugPri= ntErrorLevel. > + > + @retval TRUE Current ErrorLevel is supported. > + @retval FALSE Current ErrorLevel is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +DebugPrintLevelEnabled ( > + IN CONST UINTN ErrorLevel > + ) > +{ > + return (BOOLEAN)((ErrorLevel & PcdGet32 (PcdFixedDebugPrintErrorLevel)= ) !=3D 0); > +} > + > +/** > + The constructor function to initialize Debug port Library > + > + @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. > + > +**/ > +RETURN_STATUS > +EFIAPI > +BaseDebugLibHobConstructor ( > + VOID > + ) > +{ > + return SerialPortInitialize (); > +} > diff --git a/UefiPayloadPkg/Library/BaseDebugLibHob/BaseDebugLibHob.inf > b/UefiPayloadPkg/Library/BaseDebugLibHob/BaseDebugLibHob.inf > new file mode 100644 > index 0000000000..11ed8de08b > --- /dev/null > +++ b/UefiPayloadPkg/Library/BaseDebugLibHob/BaseDebugLibHob.inf > @@ -0,0 +1,37 @@ > +## @file > +# Instance of Debug Library based on Serial Port Library. > +# > +# Copyright (c) 2022, Intel Corporation. All rights reserved.
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D BaseDebugLibHob > + FILE_GUID =3D ae4cc887-ea47-4d5c-a8f9-1d08405b5f8= b > + MODULE_TYPE =3D BASE > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D DebugLib > + CONSTRUCTOR =3D BaseDebugLibHobConstructor > + > +[Sources] > + BaseDebugLibHob.c > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + > +[LibraryClasses] > + BaseLib > + PcdLib > + DebugPrintErrorLevelLib > + BaseMemoryLib > + PrintLib > + SerialPortLib > + > +[Pcd] > + gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue > + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask > + gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel > -- > 2.30.2.windows.1