From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web11.31142.1684264324543670257 for ; Tue, 16 May 2023 12:12:04 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=cbl2zCuI; spf=pass (domain: intel.com, ip: 192.55.52.120, 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=1684264324; x=1715800324; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=lUfEfiu5lHveSWsdfYrQ/YcSFYe+PTt6Msntrr5wPFU=; b=cbl2zCuIUeWzJATIh+nzsDa9fih7yI9ont/UUloDdXAzUQ5Q26xwLBon zw3Vz11gJyA50o2p45L6uZCN0LO/XAnun0Tr467Qz/AtQERfnCGLzKTVm f4mPOU6oJl8hnLSHyrCq6SqgtwALO5VeL0udDrjh1QPZAJABSnLaB1szr elj3rq4Qo2nQ76gdv+DXzEGVLcuOWdpVYBcMjnwbugKQMMIn76ZmF0vKd GQeS8QBYv5H1OTdzeycK4kK+5yLlPCVmErvEM3Yzo0TlJl3zA98PwBsR6 LgDx+ZaUYBepZyqMwVFTiGulVJxRYCEfCBqD3233oDtPIi0jdOa8qYz3T w==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="350403371" X-IronPort-AV: E=Sophos;i="5.99,278,1677571200"; d="scan'208";a="350403371" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2023 12:11:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="732098562" X-IronPort-AV: E=Sophos;i="5.99,278,1677571200"; d="scan'208";a="732098562" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga008.jf.intel.com with ESMTP; 16 May 2023 12:11:54 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx601.amr.corp.intel.com (10.18.126.81) 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 12:11:54 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx612.amr.corp.intel.com (10.18.126.92) 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 12:11:54 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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 12:11:54 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.46) by edgegateway.intel.com (192.55.55.70) 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 12:11:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=duW8XNGjpHilzAd5O5uPe/kYPd6vuDogoBDm16jsI6goGKPpFP0V4RjQr6fYVXPsEpdmaTiJa/07sBNcpHvK1K5vJFxxfIrsDYFcpZnRa0WkRUIVqz3zlCKQMnfj8sS3EttUIH5F7OjsnQutsstTZgzWtx13twl+1wtL5bwHvn3t7yMMzmueF1Mw/PMBPkq7rReHJBcFbJ69johHfWPjgEsnqu9Ff8hsAK6Ifk7N+eGzUaD2EYrrtcuG+q9dqT8qAW9s6FcN0iaVNQuIP/MDJMz6BkQLp5ATBLAcYUs+LyYLGLHQTWN6UTTI9tvhUEXONRq10osf1zf+WbzR8nU52w== 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=SgD1I8rpg0vvWn2drTaGU9rJ5E5VLq3k2u0vLDeZNPw=; b=Tkar2CJVsNhKXVOEptNH/Qetfwg/fTrPpyHiS0ScP+6NKSxUWHCKF0cJpp/KkKl4m+dNQpKOQB0R85oMnckbASSET/2LyfRbgrw9iEKSA/kub1C+OrPwMpOS9/yvfT/X5B5nWvNSBxHYOSjjZATSVUzIXGgLEeM3G6hR/c1UrAJplCcmsAaDaJM53h4PESkt6+V4Vs2iUZKpMvxwzBjgnBPztlQslCMHexwtYEwTmGd01B0Dm7W45OLa3JfxYDJlz/A8Lu1iEVpWeX+P/tzwVwOzJmd3nfbXl1YlNjYHhy3zlpKAHedjQMpK6/HMIp3yQLdgDp/jhOKn/70l5lzH/A== 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 SA0PR11MB4719.namprd11.prod.outlook.com (2603:10b6:806:95::17) 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 19:11:47 +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 19:11:47 +0000 From: "Isaac Oram" To: "Kinney, Michael D" , "devel@edk2.groups.io" 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: AQHZiBzqpe9MVyRLIkuQFUw0FaNkvK9dKa4ggAAGyYCAAAGJQA== Date: Tue, 16 May 2023 19:11:46 +0000 Message-ID: References: <175FB03665B4DC78.20583@groups.io> 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: SA1PR11MB5801:EE_|SA0PR11MB4719:EE_ x-ms-office365-filtering-correlation-id: bdda8f7c-dd29-45b5-7aca-08db564164e5 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: uJOqFd6uXkouRIvGO4/A6BJefHHm9tRN6fvmAfCI6ShD0iKCaqBG9HKsKwKd0jy/4c4iAIIstwpXSQtRhdIuSuTqoQpNRJgBh+sQw8vitN1YwCdKssz6LLF3BU27J2sXKikfkvcz+DApgowYLKpAOH0YCjJlRrh2JfdHnDBGVqj0jatSUWLCXE67zV3VV4VLR/1Fo76lLZImEFb84GU9OS9AEWYqnVAE1lsrL2nQOoCkDNZXiyo5LewivzPdZV7zFmjJAlkjWSGaTEr5N/yqA5kJylc0Q1jhoJcmvcEF+ZQ8Bm280PX6mzqnVBaDicBq99JNN3NNRkmY7q1V3JK92IF25y5LvBB6QjwpYAR+oIkn9/5DIBraHBQZsBkJ8OZtZPxVaT0C5ec3k0TIzwAZ2OrgnJbXoJtDsErb6KgTKKGPxkVKv3BHiH9bF4KP/DqaVJig2piax8hM7MkcoJF1/53SuRqUskwboaBEd2qVWNb8RonxQ0RWNpwbRDW3Uhj30SeLkRpFNgIdnuxjlkH8B8fGxG8h0tMd8I8RPxsz79W2xCCYx/Za9ChYLGtPoLZbl6E+CTu167ucCUn36Tb1vDAx0QYHi4s6HHUh4Iug+lROLzhMaNuizlHJrSkxKR07rquE5MdPKJWWIik0SI6AqQ== 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)(346002)(396003)(39860400002)(376002)(366004)(136003)(451199021)(66899021)(83380400001)(38100700002)(4326008)(38070700005)(5660300002)(30864003)(2906002)(8676002)(55016003)(86362001)(316002)(64756008)(66556008)(52536014)(66446008)(122000001)(76116006)(41300700001)(82960400001)(66946007)(66476007)(8936002)(54906003)(966005)(53546011)(6506007)(33656002)(9686003)(107886003)(186003)(26005)(478600001)(7696005)(71200400001)(110136005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?0KH5Acvawti+tRqTZDQwzHxlEuppdy6n92WkbMfoQbAOx9YabhpN9Kk31ERj?= =?us-ascii?Q?XCzFX0mZcUdSoZ5NF43VFHXJnwsFmj6Fd6laOhg9ZTOlijm/8dHyRHmKU7Bx?= =?us-ascii?Q?0iR2b7v4WvsaZadhM8apjoj8dCKSacN311ogZ5S3/ifxpa/oEIcYwaY8hSyw?= =?us-ascii?Q?B9a0fDTnnVfxtdX2Ura6hjPS/ywP0eZhD/WAGsGtPUw1NfCz09/U+w8Q0J76?= =?us-ascii?Q?DvzEn2KhGHczMi2Bu4Wl1J0S03Qv7tqb0CdeFuDbp5QbVv108isjG2lNz+P5?= =?us-ascii?Q?1iD62hJyF+O7CK1HDjltMy/7ZtZUCkR59lbSo9bU/4LooqO0B0Z5o3Pter2Q?= =?us-ascii?Q?hzmh+VD0atIEu+sSf7F/EGpRN1+Xmrl04g1mmptbqklSDkyO1KVcNMNzUUEW?= =?us-ascii?Q?SR57nLLleP3oerJaOS/m00+OpOWbnlR/3jFgrrTSRfNo1W5+oPdFWWyEALkZ?= =?us-ascii?Q?K2sUi5TSUySQ/JIQ9C8l20lEvMBYlX5fhFy8Rc/+Uqiv/s1xAZfvRXX20N5q?= =?us-ascii?Q?f2yDEJBCuz1bED58lqzWRCNG1Z8VMGC96eDwWf6cN6mcdayu5ZR1ROXSnPKB?= =?us-ascii?Q?XIhb7KG75J3MfeZtjdu3VZsXGxybgw1i/aO0m9nCH8eNdgcSnDUSnrJP3K58?= =?us-ascii?Q?gPXHF20w3wmVXHFHZZm6typtwT9kTBSByEoOi+zGdfvHl/RnZihR47K7cDDP?= =?us-ascii?Q?FHIef4EqoEx1k3oalLkD5Q3hU7CW9nnkxTo3aq0EgsJJzVv2JtEyCLrMZDic?= =?us-ascii?Q?cy+d5j3nvUC02li3+0RUh/ljNnd5s/7iglEgazmOHgoujhtoItGNmeoYi+8/?= =?us-ascii?Q?D+74iRH0KbAG+Ry6mJJ6hi208ve2zRKd80L9MoZlkH2fDaMH2WD3ifDikyFq?= =?us-ascii?Q?ni/yPWgxTqObKTWMTpEOUd8hec1OQWazEAwaNDJdhTxKhxZcDKwwO9rGUDge?= =?us-ascii?Q?Gnjq9z0TgR5nCQGNIDhvst/24qHPJsa/Zy9XEj/go+2ZbnNp3jO+c/zznfsd?= =?us-ascii?Q?802m942Q4x8Cg3hSSa1r0fDo+EneIkAIr9pCE9sj3ZCmBvZGsorrDIzlIw1m?= =?us-ascii?Q?Tt8BFcMFCCC+ntNkg0Pw4B+NtUIzSbhLohVk7f/0JMNFWQwHcgJ1GlPRQM/Y?= =?us-ascii?Q?h788wCWVw8zcSHBUXDKVSfaY/IHHxUfEeVkNbOMEu1dMuiHWwM9emgtIPm4g?= =?us-ascii?Q?TcdQ8jaaa8V1JT913IOdTmnOkzeo1OFOeW41uV1ghOWFUs635sJut+k4T8uz?= =?us-ascii?Q?wnot/EWXi0GZRTMVQw2ReP0rubEz3JYo5N5ZgzLHeQHCdLAHlTMu6vyu/8qr?= =?us-ascii?Q?6rmwkmW4+buJ62CCS6qYDEn8VSAS5UAQX9F93SKYdEf5ah8G0iTxJ8tcuR27?= =?us-ascii?Q?Rj93/livSaU3Oa5yX7SUJhYbe2fGxiPuImOqgtfsutIUPWok5FEQl+ZjFOba?= =?us-ascii?Q?YqkA1RnuFN6M4LcjgyyuERRtA1YiLYJ8wJxxwcy2mNhBFWCLablL7VRK2SyA?= =?us-ascii?Q?4C8hPTyg837UvYr5H2wiLTg4BtRyv08qYz7lo5x4d43R+ReQhQIW7zpVSiCt?= =?us-ascii?Q?aZM/HYxPD/7UIKC8Zop0pvuRjfVJzIiVODndut6G?= 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: bdda8f7c-dd29-45b5-7aca-08db564164e5 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 May 2023 19:11:46.8257 (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: vU8uHfj6FcGG/gB9D3Gx/3TFv4lJiEWkSK4WFiAOYNMG9gWg/vR3r1PfXATzhb8tPtkeaKPmu8iEaWTMfvY1tg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR11MB4719 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 It is sometimes desirable to have debug logging enabled even in production = systems. But printing to serial ports on an SMI handler is slow, so SMM debug messag= e printing is typically disabled. This provides the ability to get the data via serial/BMC/production availab= le channels. =20 It should be high performance to add to the memory buffer, though I didn't = measure. It is a one time event to dump on assert. It could be extended to dump on error codes. Exceptions? It could be provided as a protocol or such to allow anyone to trigger. I just added the Data logging and connected the serial dump to ASSERT, but = again, this is more an RFC on the general capability of logging strings (SM= RAM is more plentiful than it once was, so only recording status code and v= alue seems unnecessarily frugal) and dumping them to serial port. I simply wanted to make it available and RFC seemed as good a way to do it = as any. If there is a preferred path for such topics, let me know. Regards, Isaac -----Original Message----- From: Kinney, Michael D =20 Sent: Tuesday, May 16, 2023 11:01 AM To: devel@edk2.groups.io; Oram, Isaac W Cc: Wang, Jian J ; Gao, Liming ; Zimmer, Vincent ; Chiu, Chasel ; Kinney, Michael D Subject: RE: [edk2-devel][edk2-platforms][RFC PATCH V1 1/1] MdeModulePkg/St= atusCodeHandlerSmm: Add debug strings to memory buffering Hi Isaac, Multiple status code handlers can be registered. One for memory and one fo= r serial. Why would we mix serial into memory one? Mike > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Isaac=20 > Oram > Sent: Tuesday, May 16, 2023 10:39 AM > To: devel@edk2.groups.io; Oram, Isaac W > Cc: Wang, Jian J ; Gao, Liming=20 > ; Zimmer, Vincent=20 > ; Chiu, Chasel > Subject: Re: [edk2-devel][edk2-platforms][RFC PATCH V1 1/1] > MdeModulePkg/StatusCodeHandlerSmm: Add debug strings to memory=20 > buffering >=20 > Apologies, this is edk2 scope, not edk2-platforms. >=20 > This is an RFC to see if this kind of feature is widely interesting=20 > and if someone wants to explore this in depth. > This is not a complete or mature implementation. I didn't fully=20 > decipher the extended data format. >=20 > Regards, > Isaac >=20 > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Isaac=20 > Oram > Sent: Tuesday, May 16, 2023 10:35 AM > To: devel@edk2.groups.io > Cc: Oram, Isaac W ; Wang, Jian J=20 > ; Gao, Liming > Subject: [edk2-devel][edk2-platforms][RFC PATCH V1 1/1] > MdeModulePkg/StatusCodeHandlerSmm: Add debug strings to memory=20 > buffering >=20 > 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=20 > means to log messages quickly (to memory) and dump them in the event of a= n assert. >=20 > 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(+) >=20 > diff --git a/MdeModulePkg/Include/Guid/MemoryStatusCodeRecord.h > b/MdeModulePkg/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 =20 > #ifndef __MEMORY_STATUS_CODE_RECORD_H__ #define=20 > __MEMORY_STATUS_CODE_RECORD_H__ >=20 > +#include > + > /// > /// Global ID used to identify GUIDed HOBs that start with a=20 > structure of type /// MEMORY_STATUSCODE_PACKET_HEADER, followed by an=20 > array of structures 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=20 > a/MdeModulePkg/Universal/StatusCodeHandler/Smm/MemoryStatusCodeWo > rker.c > b/MdeModulePkg/Universal/StatusCodeHandler/Smm/MemoryStatusCodeW > orker.c > index 80c94e4682..c482c4bd9a 100644 > --- > a/MdeModulePkg/Universal/StatusCodeHandler/Smm/MemoryStatusCodeWo > rker.c > +++ > b/MdeModulePkg/Universal/StatusCodeHandler/Smm/MemoryStatusCodeW > orke > +++ 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=20 > + 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_CODE) { > + // > + // 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,=20 > + &gEfiStatusCodeDataTypeStringGuid) > && > + (((EFI_STATUS_CODE_STRING_DATA *)Data)->StringType =3D=3D > + 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=20 > status 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=20 > record index to zero. > @@ -99,5 +238,65 @@ MemoryStatusCodeReportWorker ( > mMmMemoryStatusCodeTable->RecordIndex =3D 0; > } >=20 > + if ((Data !=3D NULL) && ReportStatusCodeExtractAssertInfo (CodeType,= =20 > + Value, > 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=20 > + SMM debug messages\n"); SerialPortWrite ((UINT8 *)Buffer,=20 > + CharCount); > + > + // > + // Determine number of records to print // > + > + RecordsToPrint =3D mMmMemoryStatusCodeTable->NumberOfRecords; > + > + // > + // Determine first record in case we rolled over. > + // > + if (mMmMemoryStatusCodeTable->NumberOfRecords >=3D > mMmMemoryStatusCodeTable->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 > + + 1); CurrentRecord =3D &CurrentRecord[CurrentIndex]; > + > + // > + // Print records > + // > + while (CurrentIndex < RecordsToPrint) { > + DumpRecordToSerial (CurrentRecord->CodeType,=20 > + CurrentRecord->Value, > CurrentRecord->Instance, NULL, (EFI_STATUS_CODE_DATA *)CurrentRecord- > >Data); > + CurrentIndex++; > + if (CurrentIndex =3D=3D mMmMemoryStatusCodeTable->MaxRecordsNumber) = { > + CurrentIndex =3D 0; > + } > + CurrentRecord =3D (MEMORY_STATUSCODE_RECORD > *)(mMmMemoryStatusCodeTable + 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 >=20 >=20 >=20 >=20 >=20 >=20 >=20 >=20 >=20 >=20