From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web10.28539.1684258792606226866 for ; Tue, 16 May 2023 10:39:52 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=XM7iMIuj; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: isaac.w.oram@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684258792; x=1715794792; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=kZLpnxEoiANxHkdtFp02Jo2fjrEyx8uyAfWw/3pXimQ=; b=XM7iMIujNbqov0yB3MNtuwROWyW3D6O2pn7xA4VHGpJ/jLP6UlJkMell RiBeeoQ7iylV+lYUCi1W/vbICiZcvfpM0AxpCbVqgN7vfDFL2iQQrsJ2D 89989JMOBqVMWQS1Js6IYbFSNQaGu8wAYBf1VFF0nhs9y4+DgP7agEvxn MWfzfmk0hTR6Q8tzqMRo5K8CzNlxnBR6Zuyp70AbmyDdOlvi2wCnzkHxD enTdlorrfxD+vYIZyhagabPxdmQenqISObz8QGvDsHwLINW8kU/fSDHC4 tMyC4EzYWJokj6IyBG1k2znB6Ef62eM2Kwp85eSeZipddVyPZGHZaN+qM g==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="349046420" X-IronPort-AV: E=Sophos;i="5.99,278,1677571200"; d="scan'208";a="349046420" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2023 10:39:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="701436886" X-IronPort-AV: E=Sophos;i="5.99,278,1677571200"; d="scan'208";a="701436886" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga002.jf.intel.com with ESMTP; 16 May 2023 10:39:26 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 16 May 2023 10:39:26 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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.2507.23 via Frontend Transport; Tue, 16 May 2023 10:39:26 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) 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.2507.23; Tue, 16 May 2023 10:39:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OdrQDBwZp0cstVI0LZrDZqqW6sbpXvHoQf0R3v/kqAY6IUu12GZn8TRoGpbR3xp6Z2WZ1rKrUrTopILm8PTSApV+qQ3O9pd/s/tmIIYMVM0TlcShjcgFayaw9IypA9Fi9ca67nwbcbynkkaNwUYrcMXoznhdli9XY/EertJq6npaicPHyCSFfGUlvfJx7VzSDhy61kM+mUB5XYL6nF7Zy7a15iA4HuERIvubkqPSkqWrM7G2OKfm1L5/5oyXTARWblgQ7v0RoRfkj2qImgpsKDHh3QAZJjizoTzu6miUVkS5F2gQ1ROSj/G8ECDaqQyr50g+aS3MOg4re/SOBFhlxQ== 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=YoxNdVLGh7OHnc5eGhvqS3GvwKOd6/d3dYS9y3epMC8=; b=gS4ELuAYJ5sr0HaYKngHXIWZAX9Epo3vzYuPJHTQIiR4h9z9/zQr5S7JxUsmgYiK0GctEIzsA37PbENdHUJEX+c8AwpWoTJ9mcOUkcK+UdGPJx2w/R68rwAmsNWVsLb4Z3HdFx+3oI5NXXlP98lnmW+Ci5ceWRe+21o0+JFO7T6zpDbtXjbAf5kHxiGlxo2cuvLBgQARYru/3fP+i+V58chzdxhSFW9zj5dGJmJ7KpIRtTuqLHUu4NjcgZbAtR78qak3jdDI2ZdtjNuqjvDfA6Ub+GQ1N89U6XRwzbZa2P3/sQm+CD2H61cRXbpddEP81VtylrO2OrNFQBu7xhdhWA== 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 SA1PR11MB5801.namprd11.prod.outlook.com (2603:10b6:806:23d::13) by SJ0PR11MB4912.namprd11.prod.outlook.com (2603:10b6:a03:2ae::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.30; Tue, 16 May 2023 17:39:23 +0000 Received: from SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::6979:a90f:e224:41c5]) by SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::6979:a90f:e224:41c5%4]) with mapi id 15.20.6387.030; Tue, 16 May 2023 17:39:23 +0000 From: "Isaac Oram" To: "devel@edk2.groups.io" , "Oram, Isaac W" CC: "Wang, Jian J" , "Gao, Liming" , "Zimmer, Vincent" , "Chiu, Chasel" Subject: Re: [edk2-devel][edk2-platforms][RFC PATCH V1 1/1] MdeModulePkg/StatusCodeHandlerSmm: Add debug strings to memory buffering Thread-Topic: [edk2-devel][edk2-platforms][RFC PATCH V1 1/1] MdeModulePkg/StatusCodeHandlerSmm: Add debug strings to memory buffering Thread-Index: AQHZiBzqpe9MVyRLIkuQFUw0FaNkvK9dKa4g Date: Tue, 16 May 2023 17:39:23 +0000 Message-ID: References: <175FB03665B4DC78.20583@groups.io> In-Reply-To: <175FB03665B4DC78.20583@groups.io> 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: SA1PR11MB5801:EE_|SJ0PR11MB4912:EE_ x-ms-office365-filtering-correlation-id: c21a7656-4709-4efe-ab98-08db56347cb7 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: Y650bFlqPZfwJBwbViMBlz7JrnmaoTXOVgKr5yJA40xoPLDqcuuqSkcuj7PKQkhO5avkVKjbVAzTgOlhw4kDE0n+tRlHVsBcui5xy0fysO4+eTPg1jU6AiNzxt5BYxMR3ZMcjzy+o0NmpqvkZUX8v3pjaWaBpqKgqhfojV+FuTXt14n8FaZ9htfd4+yzryU8suY/unzVqKAqluO/8eifioDcWaR0Nsa17QvuxUEw9E7AQASKJJiy1TyYzLC3xAYcLcQcKNw1i0yf3VRtN2in4WlOIju3rUSx1xXn9llISqbxQtdDc9NY4r7NM1NBl0hnCBjH7Myg2uwK9B/8pZ7VaHrpxTrLhA0e/ikdSkJyxarBraxeor/iu6nNOJEG/s1fNfK1atm0bR3t9JCjFphBXPd12IEsst1pLmU2Rzt3ZA79cUhClfpottsc4UZDkVLzNd2bLJ/oWZZ8YZOzcv4qT65EGAyvi0Sp8Va9BtEcYldY+wzXdn6esR4MrgHHuhUJIKjtPlWoFZ/jx5sXrKUaPs9AFI/iNf+Dnc3jHo5100wi17iEvrZOmDHumQ8VAMTkVlNrz+CT2JnQ9sTBQrj6VmLDtCsSsad4bafO+uJPP5XXM83mi8A6cRLUuwpufa4d2r8CvsKFHUhvDCrnGOdSkw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR11MB5801.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(366004)(376002)(136003)(346002)(396003)(451199021)(966005)(186003)(41300700001)(38100700002)(7696005)(71200400001)(107886003)(53546011)(6506007)(9686003)(26005)(83380400001)(55016003)(478600001)(54906003)(110136005)(66899021)(66556008)(4326008)(66476007)(64756008)(66446008)(82960400001)(76116006)(122000001)(66946007)(316002)(5660300002)(8936002)(8676002)(52536014)(86362001)(33656002)(2906002)(38070700005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?v9qwHTicLCVHRVNCTC7IkKynWDHxaZlrIrjg+I50hMK0zqiv4CXEwjG2e58m?= =?us-ascii?Q?q1Vj9CaYcdpBswQ9eneppVBpPWhZ/lKZbLH/bF3NgZESUY5kn2TvbRL86p4n?= =?us-ascii?Q?rTxeH0uAOBAisNPXQwnkUK3X7jatVAZ72G0wCdOsiazuBBpsrwja4Xml+4wD?= =?us-ascii?Q?5osRFu1+GcH17ffylKMzUWpe3L2YAIHCNNhcYRrRyelbGtHcyQrim3XmU1lx?= =?us-ascii?Q?4cTDZXF99X1XVVS7Ve0/jPVa1ogVTpP+5aAJG4CoBPWm0B9pfs2pSl9Gbmmc?= =?us-ascii?Q?FACFC9Z6ZLvkLm/2Lr0EKTbMfE8wNoNQiGEGomuZiSedNr77coE2Fmz/RMUD?= =?us-ascii?Q?MJwYEBPlYT/pyQ6+o9I/ySCPwWZAm9UQU0mKqvskwwfS1kez6TSdy2m+pJQx?= =?us-ascii?Q?+5VeE1nkten9vGl+Qhth+WFIUkX8Hzl83WnTky/89GpYxv80MbhCAx5145uy?= =?us-ascii?Q?Tndj15FxVjwESplaX5QOyCaeGMSfaYnxtTkVKmVG2KgP4S5I9DKdnW3LS1l+?= =?us-ascii?Q?uNVwWZR4gzcLEgxsPiycH/hti0zv5xCc//kToDLa1tgDbdtmsH726vKeptbT?= =?us-ascii?Q?9aTq3mYewBCdTl0JF6npO9d0e6cbsMYuV51xOfFYL/g582mQh+7zq4T48oev?= =?us-ascii?Q?2Eg2F8VLZ9iOWVH14knQG0nMwvxLjB5A6ypC2+oS3pOHyzumklwNryB7rHWj?= =?us-ascii?Q?QByBhFUcGWVhBLSIENImQD3b/gczoXSE8jq3DJ8j1CHlqme4UV7AGcxfpWru?= =?us-ascii?Q?/gMcA8uAnC2Hpg88EI9hsCHfd4kCW4x3Z5CckEjKDxACqoRTvnYqWlWeJ6zQ?= =?us-ascii?Q?eCfecZoGTGoHANhMtEhabp/iIkCVcYmzvXtpABRHneZ+1GL9vaP7sAXY1qEv?= =?us-ascii?Q?hJ7t/4dw7/HDXFQeHwb62KCrq71uYbDEryuRa7B8MXyNXmiygzC6xvGpGlWp?= =?us-ascii?Q?hOsch/Q+qjc2lvLlQ6mDWUHolZ4zvyGeE4n/Le2VS5OlIEVqv/L8x5vzxyXY?= =?us-ascii?Q?1Ms2DJTIqBun5+o8JuUo6WUusp0V2irCci04+ixpXdMlQc4C6PRm0EzvB/4O?= =?us-ascii?Q?AvutiXlL35xhiRp/LZcTbllJkFk3jsqXupfr8uFhcKswJTRR23Urcgo1YFAp?= =?us-ascii?Q?oMJyNOHFEj/qLJkW1DxgP9sFyyobetBJun9rmrSrSig7Loaq2LrVBgtwoImn?= =?us-ascii?Q?BM6JfomoqvMLjTXcJxiujgoS74YUZTNaPJlIjBb39bVbQheQXlAsQY2rcb7R?= =?us-ascii?Q?UtbtbncmHkHK8hODt7P8D1n0KShq9ZftVj8vA+5wIyu7Ypw7glNAxxf26M5q?= =?us-ascii?Q?IVD6HId/bDS2Nex7sh3N0MKvpX+qEhTozgr1ON0+k/tFkEMqMVBhdmd33/rY?= =?us-ascii?Q?qgXcTsRVOHtY1DubW1S4KnBRcyD/e01YRBUvR4BLynMvBvxZQ6eCtnluevtX?= =?us-ascii?Q?R4T7zp/ID4wll1oBIUOQkWrH2WQRVHXfob3+/INwQMBHgjsgLWQOGY0I0IXK?= =?us-ascii?Q?fOzFy1Cqw9A4EgZBOnPmTo6V98gf0iw9NPqkKsXs9Hxt3Mww06nWYMEK7uye?= =?us-ascii?Q?H/cAYJ4qZ/I9MwiiNyLlupkLJcU/CX/OevevWXK6?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA1PR11MB5801.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c21a7656-4709-4efe-ab98-08db56347cb7 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 May 2023 17:39:23.3438 (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: 462+K52752yVOtEQWc2sRPMa5C3tmllSsYIpikNKdhuPywEWd4W/t6seC7qug5a4PjfwIiV1bEtVg8EXnHNpVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4912 Return-Path: isaac.w.oram@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Apologies, this is edk2 scope, not edk2-platforms. This is an RFC to see if this kind of feature is widely interesting and if = someone wants to explore this in depth. =20 This is not a complete or mature implementation. I didn't fully decipher t= he extended data format. Regards, Isaac -----Original Message----- From: devel@edk2.groups.io On Behalf Of Isaac Oram Sent: Tuesday, May 16, 2023 10:35 AM To: devel@edk2.groups.io Cc: Oram, Isaac W ; Wang, Jian J ; Gao, Liming Subject: [edk2-devel][edk2-platforms][RFC PATCH V1 1/1] MdeModulePkg/Status= CodeHandlerSmm: Add debug strings to memory buffering Extend the MemoryStatusCodeWorker functionality to log the debug strings. In the event of an assert, dump the strings to serial port. The rationale is that SMI latency is very important. This provides a means= to log messages quickly (to memory) and dump them in the event of an asser= t. Cc: Jian J Wang Cc: Liming Gao Signed-off-by: Isaac Oram --- .../Include/Guid/MemoryStatusCodeRecord.h | 7 + .../Smm/MemoryStatusCodeWorker.c | 199 ++++++++++++++++++ 2 files changed, 206 insertions(+) diff --git a/MdeModulePkg/Include/Guid/MemoryStatusCodeRecord.h b/MdeModule= Pkg/Include/Guid/MemoryStatusCodeRecord.h index a924c592c9..d37b6304c6 100644 --- a/MdeModulePkg/Include/Guid/MemoryStatusCodeRecord.h +++ b/MdeModulePkg/Include/Guid/MemoryStatusCodeRecord.h @@ -10,6 +10,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef __M= EMORY_STATUS_CODE_RECORD_H__ #define __MEMORY_STATUS_CODE_RECORD_H__ =20 +#include + /// /// Global ID used to identify GUIDed HOBs that start with a structure of = type /// MEMORY_STATUSCODE_PACKET_HEADER, followed by an array of structur= es of type @@ -90,6 +92,11 @@ typedef struct { /// the system. Valid instance numbers start with the number 1. /// UINT32 Instance; + + // + // Extra data + // + UINT64 Data[(MAX_EXTENDED_DATA_SIZE / sizeof (UINT64))= + 1]; } MEMORY_STATUSCODE_RECORD; =20 extern EFI_GUID gMemoryStatusCodeRecordGuid; diff --git a/MdeModulePkg/Un= iversal/StatusCodeHandler/Smm/MemoryStatusCodeWorker.c b/MdeModulePkg/Unive= rsal/StatusCodeHandler/Smm/MemoryStatusCodeWorker.c index 80c94e4682..c482c4bd9a 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/Smm/MemoryStatusCodeWorker.c +++ b/MdeModulePkg/Universal/StatusCodeHandler/Smm/MemoryStatusCodeWorke +++ r.c @@ -11,6 +11,141 @@ =20 RUNTIME_MEMORY_STATUSCODE_HEADER *mMmMemoryStatusCodeTable; =20 +VOID +DumpBufferToSerial ( + VOID + ); + +EFI_STATUS +EFIAPI +DumpRecordToSerial ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID *CallerId, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ) +{ + CHAR8 *Filename; + CHAR8 *Description; + CHAR8 *Format; + CHAR8 Buffer[MAX_EXTENDED_DATA_SIZE + sizeof (UINT64)]; + UINT32 ErrorLevel; + UINT32 LineNumber; + UINTN CharCount; + BASE_LIST Marker; + + Buffer[0] =3D '\0'; + + if ((Data !=3D NULL) && + ReportStatusCodeExtractAssertInfo (CodeType, Value, Data,=20 + &Filename, &Description, &LineNumber)) { + // + // Print ASSERT() information into output buffer. + // + CharCount =3D AsciiSPrint ( + Buffer, + sizeof (Buffer), + "\n\rDXE_ASSERT!: %a (%d): %a\n\r", + Filename, + LineNumber, + Description + ); + } else if ((Data !=3D NULL) && + ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel,=20 + &Marker, &Format)) { + // + // Print DEBUG() information into output buffer. + // + CharCount =3D AsciiBSPrint ( + Buffer, + sizeof (Buffer), + Format, + Marker + ); + } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) =3D=3D EFI_ERROR_CODE)= { + // + // Print ERROR information into output buffer. + // + CharCount =3D AsciiSPrint ( + Buffer, + sizeof (Buffer), + "ERROR: C%08x:V%08x I%x", + CodeType, + Value, + Instance + ); + ASSERT (CharCount > 0); + + if (CallerId !=3D NULL) { + CharCount +=3D AsciiSPrint ( + &Buffer[CharCount], + (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)), + " %g", + CallerId + ); + } + + if (Data !=3D NULL) { + CharCount +=3D AsciiSPrint ( + &Buffer[CharCount], + (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)), + " %x", + Data + ); + } + + CharCount +=3D AsciiSPrint ( + &Buffer[CharCount], + (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)), + "\n\r" + ); + } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) =3D=3D EFI_PROGRESS_CO= DE) { + // + // Print PROGRESS information into output buffer. + // + CharCount =3D AsciiSPrint ( + Buffer, + sizeof (Buffer), + "PROGRESS CODE: V%08x I%x\n\r", + Value, + Instance + ); + } else if ((Data !=3D NULL) && + CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeStringGuid) = && + (((EFI_STATUS_CODE_STRING_DATA *)Data)->StringType =3D=3D=20 + EfiStringAscii)) { + // + // EFI_STATUS_CODE_STRING_DATA + // + CharCount =3D AsciiSPrint ( + Buffer, + sizeof (Buffer), + "%a", + ((EFI_STATUS_CODE_STRING_DATA *)Data)->String.Ascii + ); + } else { + // + // Code type is not defined. + // + CharCount =3D AsciiSPrint ( + Buffer, + sizeof (Buffer), + "Undefined: C%08x:V%08x I%x\n\r", + CodeType, + Value, + Instance + ); + } + + // + // Call SerialPort Lib function to do print. + // + SerialPortWrite ((UINT8 *)Buffer, CharCount); + + return EFI_SUCCESS; +} + /** Initialize MM memory status code table as initialization for memory stat= us code worker =20 @@ -69,6 +204,9 @@ MemoryStatusCodeReportWorker ( ) { MEMORY_STATUSCODE_RECORD *Record; + CHAR8 *Filename; + CHAR8 *Description; + UINT32 LineNumber; =20 // // Locate current record buffer. @@ -82,6 +220,7 @@ MemoryStatusCodeReportWorker ( Record->CodeType =3D CodeType; Record->Value =3D Value; Record->Instance =3D Instance; + CopyMem (&Record->Data, Data, (Data->HeaderSize + Data->Size)); =20 // // If record index equals to max record number, then wrap around record = index to zero. @@ -99,5 +238,65 @@ MemoryStatusCodeReportWorker ( mMmMemoryStatusCodeTable->RecordIndex =3D 0; } =20 + if ((Data !=3D NULL) && ReportStatusCodeExtractAssertInfo (CodeType, Val= ue, Data, &Filename, &Description, &LineNumber)) { + // Found an assert, dump the buffer + DumpBufferToSerial (); + } + return EFI_SUCCESS; } + +VOID +DumpBufferToSerial ( + VOID + ) +{ + MEMORY_STATUSCODE_RECORD *CurrentRecord; + UINT32 CurrentIndex; + UINT32 RecordsToPrint; + CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; + UINTN CharCount; + + CharCount =3D AsciiSPrint (Buffer, sizeof (Buffer), "Begin dump of SMM= =20 + debug messages\n"); SerialPortWrite ((UINT8 *)Buffer, CharCount); + + // + // Determine number of records to print // + + RecordsToPrint =3D mMmMemoryStatusCodeTable->NumberOfRecords; + + // + // Determine first record in case we rolled over. + // + if (mMmMemoryStatusCodeTable->NumberOfRecords >=3D mMmMemoryStatusCodeTa= ble->MaxRecordsNumber) { + RecordsToPrint =3D mMmMemoryStatusCodeTable->MaxRecordsNumber; + CurrentIndex =3D mMmMemoryStatusCodeTable->RecordIndex; + } else { + RecordsToPrint =3D mMmMemoryStatusCodeTable->NumberOfRecords; + CurrentIndex =3D 0; + } + + + // + // Locate first record. + // + CurrentRecord =3D (MEMORY_STATUSCODE_RECORD *)(mMmMemoryStatusCodeTable= =20 + + 1); CurrentRecord =3D &CurrentRecord[CurrentIndex]; + + // + // Print records + // + while (CurrentIndex < RecordsToPrint) { + DumpRecordToSerial (CurrentRecord->CodeType, CurrentRecord->Value, Cur= rentRecord->Instance, NULL, (EFI_STATUS_CODE_DATA *)CurrentRecord->Data); + CurrentIndex++; + if (CurrentIndex =3D=3D mMmMemoryStatusCodeTable->MaxRecordsNumber) { + CurrentIndex =3D 0; + } + CurrentRecord =3D (MEMORY_STATUSCODE_RECORD *)(mMmMemoryStatusCodeTabl= e + 1); + CurrentRecord =3D &CurrentRecord[CurrentIndex]; } + + CharCount =3D AsciiSPrint (Buffer, sizeof (Buffer), "End dump of SMM=20 +debug messages\n"); + SerialPortWrite ((UINT8 *)Buffer, CharCount); } -- 2.40.0.windows.1