From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.73]) by mx.groups.io with SMTP id smtpd.web11.217.1631803581407471109 for ; Thu, 16 Sep 2021 07:46:22 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=Hm0+O7xX; spf=pass (domain: arm.com, ip: 40.107.21.73, mailfrom: joey.gouly@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bXA/WPvXA3ykdduPnGKcsSwGpadpQnUPXpbmlsFtgxc=; b=Hm0+O7xXR/Yq/HG1q7dtEVPv37s28E7KKdIJuzqYfAgVnixBrlLewZIxOS+J8KSUy+nwmYjw2lSKMrjc0FvizfRfYElQfY4Utk/mdKacTIP2f5VGrXeJgzVMUNTlmUoNu72yFXepXPs+zJwu8/lIuulyvxAEvwni9M87AqBQCpc= Received: from DB6PR0201CA0022.eurprd02.prod.outlook.com (2603:10a6:4:3f::32) by AM6PR08MB4568.eurprd08.prod.outlook.com (2603:10a6:20b:ac::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Thu, 16 Sep 2021 14:46:17 +0000 Received: from DB5EUR03FT006.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:3f:cafe::e) by DB6PR0201CA0022.outlook.office365.com (2603:10a6:4:3f::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16 via Frontend Transport; Thu, 16 Sep 2021 14:46:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT006.mail.protection.outlook.com (10.152.20.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 14:46:17 +0000 Received: ("Tessian outbound 8e26f7114b75:v103"); Thu, 16 Sep 2021 14:46:17 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6d455b6d52a69a1d X-CR-MTA-TID: 64aa7808 Received: from cdda5c2bdc9c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 638D2CB9-3925-4986-B9E9-95F9B09762BC.1; Thu, 16 Sep 2021 14:46:10 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cdda5c2bdc9c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 16 Sep 2021 14:46:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gQXsWkd7zzDelrHOl3I0SyVTZDUnS7dn4rY2QLBcVWRxDnNHU9d0XV9q028tU9wWoJiDVcLHoIX4GSXL0nMYqXN1OQvg/mT5pzfzePL7v8FPtLOVno7kYTBvb7vLJSN8ZfCg9ZHLZ58/JWYosJ1dFW7vnR7zlcVlOUP33xx34BZ41kZ+ibj1Tcpklwv+th62CJ4bHbmjsaWur37K/BWCxUkwZP+ulYjcKyfrm1Vqr2jff/lO950pLA+aotoY0JxJu9CNH5DHcCL6CFVGF8s8qhDu5RbTDRfct9E1barACXvU8G21rz90BC/solMsckRbF1YqSk4PPH5y0CuCp8c60w== 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; bh=bXA/WPvXA3ykdduPnGKcsSwGpadpQnUPXpbmlsFtgxc=; b=D887ybOWRli0qUPkO9O+q58iHCAIQjsprW91E5JWCOuRo8bMGUEF+8Cc5pxi6MgUdUettlG0SY9bnAjkDvWv7ky11EBTv2eJo+T4wHVjP7r+DmflygMYv97ag+CPbuZQMIPCteCEKn7C9f5iJCrWSSYRcodcUwoiMjpeCNjJVxaaoDtDKVoQhT1mIrqC1YXNeXJiLYr7kM4gSwp3d6R0G0iqcDrQZ9dHdN3Z3N8GoBaT+Q403/wqHU9KYAAuLP0E3xNigzm5Nt8JEq8GcCzeMfM69FzMTJn7sNBnEDJXCgNKLGQBvn/l60FSZqMz5QnEQxWHfKgj0EO+yncOcYe0Nw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bXA/WPvXA3ykdduPnGKcsSwGpadpQnUPXpbmlsFtgxc=; b=Hm0+O7xXR/Yq/HG1q7dtEVPv37s28E7KKdIJuzqYfAgVnixBrlLewZIxOS+J8KSUy+nwmYjw2lSKMrjc0FvizfRfYElQfY4Utk/mdKacTIP2f5VGrXeJgzVMUNTlmUoNu72yFXepXPs+zJwu8/lIuulyvxAEvwni9M87AqBQCpc= Received: from DU2PR04CA0222.eurprd04.prod.outlook.com (2603:10a6:10:2b1::17) by AS8PR08MB5909.eurprd08.prod.outlook.com (2603:10a6:20b:297::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.17; Thu, 16 Sep 2021 14:46:08 +0000 Received: from DB5EUR03FT020.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2b1:cafe::64) by DU2PR04CA0222.outlook.office365.com (2603:10a6:10:2b1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 14:46:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT020.mail.protection.outlook.com (10.152.20.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 14:46:08 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Thu, 16 Sep 2021 14:46:15 +0000 Received: from e124191.cambridge.arm.com (10.11.7.12) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2308.14 via Frontend Transport; Thu, 16 Sep 2021 14:46:15 +0000 From: "Joey Gouly" To: CC: , , , , Subject: [PATCH v2 5/5] ShellPkg: add PPTT dot file genration Date: Thu, 16 Sep 2021 15:46:05 +0100 Message-ID: <20210916144605.42071-6-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210916144605.42071-1-joey.gouly@arm.com> References: <20210916144605.42071-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 302585de-3221-46e3-24e0-08d97920bd82 X-MS-TrafficTypeDiagnostic: AS8PR08MB5909:|AM6PR08MB4568: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3173;OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: jrYnaHe+HFG1vepuDyt3qhzDh/Ug6mpv7MSzIgcGgQX9bpdws7tjpTJ8wmbmjHlAyvL4DIi+pevM2q6UNWLddyiowNBt7kPcj9D/A7z8bYPRbEKYmiYaJTCfpDcC7nB2tJiDjzh6CKzW9Bj3XILNszP0tTBgD0JExX/6dBlUduUT6I1WoNkANL8p4R3rcVspbIDqfMTr5ABgp+K9/DnviXG3os9KMbBGQ6eJzA8BlxlRrPsL1sLIQGqdBEIjHtx76gAa5VGdE9yG3ud5/Trwq4CavkTh67ZxWzAqt5KWVqovonX2lphvz580gWpnI1wHI7w9N4fGkUm3Z5v9TR05m7r+tzBfj4uuNi2PAG5ChyI+jmLk/ZxmyjQKWDTfatFw3t8evaMCrRJb+MIg0+am1C01D0kjRFs3B1VSh65s0n8luZ90WSm7Exi11mJCmXC277FfC3OREZvO1F3PLYS9ECowgfXs5YqUueCqcOQWK2GulKxHgQdoPgx2djK2bHVcIdzOAlmtpd9EzALxJ4/3V/u4FCjlgsNPq82LgxVAGaZ58aQhORnlma21Ms/O2NlifSdXYTuqwqDuvNwFjZJ/Y9EEt7ckM63IoBXraIhUXOpGUXhwmmRO3g9eY0cmdGux4Llpry9H6NfXqdfGze5t+fzRSlPLA9RJ6ypxIqh2D+hwr7aoJOwzCS3xZfq02jE2MSAHCRjpbVI6eVfUHx4/UmD5hyocNq21IUQqTqe9tHnvZnA5ObwiH1I8oHB1q38l3V0ABR9M+xIiApeSo/1D/GcT181Vh6iXNBEL7pZuBwVAxENfWo37Ui8T+76Vo4wk X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(376002)(136003)(39860400002)(396003)(346002)(36840700001)(46966006)(70206006)(7696005)(83380400001)(426003)(54906003)(47076005)(5660300002)(6666004)(6916009)(4326008)(2906002)(8676002)(82310400003)(478600001)(36756003)(186003)(336012)(8936002)(44832011)(36860700001)(26005)(316002)(356005)(86362001)(1076003)(70586007)(2616005)(82740400003)(81166007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5909 Return-Path: Joey.Gouly@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT006.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: c8822fbf-6499-4ea5-3a35-08d97920b835 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vF8vXlQAPKUaiRm42KQ95cjHLy+XnN2bLfqV/mQHEL4uNyDPLtU7wJ8c2tHSPhaZPmC8WnqrN+o6or91hfA9IGENkOT+6E1VvDFJUj0hHu4sPsGh3YSOJPU+TMtdT8cD6T3WQhSdoENhTA+wS2oe6YcqgXUk57tQipLdttHaQKvvhjC7fsN98BA7d2kA269GFATLh55b98We3TTed+snTMerKsF8YlINbshsk2RoFYpGuAe57xAgDCjpcSgqmV41YQkcIciFp/FOFcZYRR/buDISpc8zf1yNeoDsQbm30NrhDS8TBHTkeCAy0gO3hT7PV2Ww1CHvdvZ2QUBwKSUZiP1lH/5N2XMMzq4UqMtEfWNi1T6xCtWweGjIzM04fkeoaQ19RXO5MSZ+V+Md2/JRTjc4spezK1hqYLU7rpWWARGkGnG1kWO9VZ5JyAn98L1v8Ef9g8ezUg2iQl5eH7KpskkC20M2GYQpGYgLbz2iYYyovEGh8sCnVvxfaRjpe2yTKQcCgQl4H0RydQdze/RHk0eIdq7wdC3jkurDwNuBUTyNpFbPSPG+jSCJZSRwP6IkQpgz+wZyFEEoFcLpaa/9Bsod1O6H0NB4O8Sv8poz0f6V1ouYHeCkV/AV8LYVns9COynQ0I+XB5+y3HISKEZ5zTcWWRgNhghX+IY/P7dEkEHHju5Iugjjoi32dva1HITlNDBpezRqYpNdmuXxIgzg/7BYAZE5jK9JYkRLPe3slOC5XB5yEh+Yqxv80morq/3e3hKIcjnzWgKLeg+y81226XJKOzyFdNaRCAM2gVpC1II= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(346002)(136003)(39860400002)(376002)(396003)(46966006)(36840700001)(6916009)(8676002)(4326008)(47076005)(44832011)(2906002)(7696005)(316002)(6666004)(83380400001)(8936002)(54906003)(81166007)(186003)(5660300002)(26005)(1076003)(478600001)(336012)(70206006)(426003)(2616005)(70586007)(36756003)(82310400003)(36860700001)(82740400003)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 14:46:17.4903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 302585de-3221-46e3-24e0-08d97920bd82 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT006.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4568 Content-Type: text/plain From: Marc Moisson-Franckhauser Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378) This generates a dot file from the PPTT table that can be used to visualise the topology of the CPUs and Caches. Signed-off-by: Joey Gouly --- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c | 240 ++++++++++++++++++-- 1 file changed, 218 insertions(+), 22 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c index 538b6a69350d75ccbf36b86fff115255e77437c7..b52bd532b846b9cec0ca315b043beff95df40bd5 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c @@ -15,11 +15,23 @@ #include "AcpiView.h" #include "AcpiViewConfig.h" #include "PpttParser.h" +#include "DotGenerator.h" // Local variables STATIC CONST UINT8* ProcessorTopologyStructureType; STATIC CONST UINT8* ProcessorTopologyStructureLength; + STATIC CONST UINT32* NumberOfPrivateResources; +STATIC CONST UINT32* ProcessorHierarchyParent; +STATIC CONST EFI_ACPI_6_3_PPTT_STRUCTURE_PROCESSOR_FLAGS* ProcStructFlags; +STATIC CONST UINT32* NextLevelOfCache; +STATIC CONST EFI_ACPI_6_3_PPTT_STRUCTURE_CACHE_ATTRIBUTES* CacheAttributes; +STATIC CONST UINT32* CacheSize; + +STATIC CONST UINT8* PpttStartPointer; + +STATIC SHELL_FILE_HANDLE mDotFileHandle; + STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; /** @@ -198,8 +210,9 @@ STATIC CONST ACPI_PARSER ProcessorHierarchyNodeStructureParser[] = { {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL}, {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, - {L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, - {L"Parent", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Flags", 4, 4, L"0x%x", NULL, (VOID**)&ProcStructFlags, NULL, NULL}, + {L"Parent", 4, 8, L"0x%x", NULL, + (VOID**)&ProcessorHierarchyParent, NULL, NULL}, {L"ACPI Processor ID", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}, {L"Number of private resources", 4, 16, L"%d", NULL, (VOID**)&NumberOfPrivateResources, NULL, NULL} @@ -214,11 +227,13 @@ STATIC CONST ACPI_PARSER CacheTypeStructureParser[] = { {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, {L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, - {L"Next Level of Cache", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, - {L"Size", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Next Level of Cache", 4, 8, L"0x%x", NULL, + (VOID**)&NextLevelOfCache, NULL, NULL}, + {L"Size", 4, 12, L"0x%x", NULL, (VOID**)&CacheSize, NULL, NULL}, {L"Number of sets", 4, 16, L"%d", NULL, NULL, ValidateCacheNumberOfSets, NULL}, {L"Associativity", 1, 20, L"%d", NULL, NULL, ValidateCacheAssociativity, NULL}, - {L"Attributes", 1, 21, L"0x%x", NULL, NULL, ValidateCacheAttributes, NULL}, + {L"Attributes", 1, 21, L"0x%x", NULL, (VOID**)&CacheAttributes, + ValidateCacheAttributes, NULL}, {L"Line size", 2, 22, L"%d", NULL, NULL, ValidateCacheLineSize, NULL} }; @@ -257,6 +272,7 @@ DumpProcessorHierarchyNodeStructure ( UINT32 Offset; UINT32 Index; CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH]; + CONST UINT8* TypePtr; Offset = ParseAcpi ( IS_TRACE_FLAG_SET (ParseFlags), @@ -291,26 +307,67 @@ DumpProcessorHierarchyNodeStructure ( return; } - Index = 0; + if (IS_GRAPH_FLAG_SET (ParseFlags)) { + if (ProcStructFlags->ProcessorIsAThread) { + UnicodeSPrint(Buffer, sizeof (Buffer), L"Thread"); + } else if (ProcStructFlags->NodeIsALeaf) { + UnicodeSPrint(Buffer, sizeof (Buffer), L"Core"); + } else if (ProcStructFlags->PhysicalPackage) { + UnicodeSPrint(Buffer, sizeof (Buffer), L"Physical\\nPackage"); + } else { + UnicodeSPrint(Buffer, sizeof (Buffer), L"Cluster"); + } + + DotAddNode ( + mDotFileHandle, + (UINT32)(Ptr - PpttStartPointer), + DOT_BOX_SQUARE | DOT_COLOR_BLUE | DOT_BOX_ADD_ID_TO_LABEL, + Buffer + ); + + // Add link to parent node. + if (*ProcessorHierarchyParent != 0) { + DotAddLink ( + mDotFileHandle, + (UINT32)(Ptr - PpttStartPointer), + *ProcessorHierarchyParent, + 0x0 + ); + } + } // Parse the specified number of private resource references or the Processor // Hierarchy Node length. Whichever is minimum. - while (Index < *NumberOfPrivateResources) { - UnicodeSPrint ( - Buffer, - sizeof (Buffer), - L"Private resources [%d]", - Index - ); + for (Index = 0; Index < *NumberOfPrivateResources; Index++) { + if (IS_TRACE_FLAG_SET (ParseFlags)) { + UnicodeSPrint ( + Buffer, + sizeof (Buffer), + L"Private resources [%d]", + Index + ); - PrintFieldName (4, Buffer); - Print ( - L"0x%x\n", - *((UINT32*)(Ptr + Offset)) - ); + PrintFieldName (4, Buffer); + Print ( + L"0x%x\n", + *((UINT32*)(Ptr + Offset)) + ); + } + + if (IS_GRAPH_FLAG_SET (ParseFlags)) { + TypePtr = PpttStartPointer + *((UINT32*)(Ptr + Offset)); + if (*TypePtr == EFI_ACPI_6_2_PPTT_TYPE_ID) { + continue; + } + DotAddLink ( + mDotFileHandle, + *((UINT32*)(Ptr + Offset)), + (UINT32)(Ptr - PpttStartPointer), + DOT_ARROW_RANK_REVERSE + ); + } Offset += sizeof (UINT32); - Index++; } } @@ -329,6 +386,8 @@ DumpCacheTypeStructure ( IN UINT8 Length ) { + CHAR16 LabelBuffer[64]; + ParseAcpi ( IS_TRACE_FLAG_SET (ParseFlags), 2, @@ -337,6 +396,88 @@ DumpCacheTypeStructure ( Length, PARSER_PARAMS (CacheTypeStructureParser) ); + + if (IS_GRAPH_FLAG_SET (ParseFlags)) { + // Create cache node + + // Start node label with type of cache + switch (CacheAttributes->CacheType) { + case EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_DATA: + UnicodeSPrint ( + LabelBuffer, + sizeof (LabelBuffer), + L"D-Cache\\n" + ); + break; + case EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_INSTRUCTION: + UnicodeSPrint ( + LabelBuffer, + sizeof (LabelBuffer), + L"I-Cache\\n" + ); + break; + default: + UnicodeSPrint ( + LabelBuffer, + sizeof (LabelBuffer), + L"Unified Cache\\n" + ); + } + + // Add size of cache to node label + if (((*CacheSize) & 0xfff00000) != 0) { + UnicodeSPrint ( + LabelBuffer, + sizeof (LabelBuffer), + L"%s%dMiB", + LabelBuffer, + *CacheSize >> 20 + ); + } + if ((*CacheSize & 0xffc00) != 0) { + UnicodeSPrint ( + LabelBuffer, + sizeof (LabelBuffer), + L"%s%dkiB", + LabelBuffer, + (*CacheSize >> 10) & 0x3ff + ); + } + if ((*CacheSize & 0x3ff) != 0) { + UnicodeSPrint ( + LabelBuffer, + sizeof (LabelBuffer), + L"%s%dB", + LabelBuffer, + *CacheSize & 0x3ff + ); + } + if (*CacheSize == 0) { + UnicodeSPrint ( + LabelBuffer, + sizeof (LabelBuffer), + L"%s0B", + LabelBuffer + ); + } + + //Add node to dot file + DotAddNode ( + mDotFileHandle, + (UINT32)(Ptr - PpttStartPointer), + DOT_BOX_SQUARE | DOT_COLOR_YELLOW | DOT_BOX_ADD_ID_TO_LABEL, + LabelBuffer + ); + + if (*NextLevelOfCache != 0) { + DotAddLink ( + mDotFileHandle, + *NextLevelOfCache, + (UINT32)(Ptr - PpttStartPointer), + DOT_ARROW_RANK_REVERSE | DOT_COLOR_GRAY + ); + } + } } /** @@ -390,13 +531,46 @@ ParseAcpiPptt ( IN UINT8 AcpiTableRevision ) { - UINT32 Offset; - UINT8* ProcessorTopologyStructurePtr; + EFI_STATUS Status; + UINT32 Offset; + UINT8* ProcessorTopologyStructurePtr; + CHAR16 Buffer[128]; + CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN]; - if (!IS_TRACE_FLAG_SET (ParseFlags)) { + if (!IS_TRACE_FLAG_SET (ParseFlags) && + !IS_GRAPH_FLAG_SET (ParseFlags)) { return; } + if (IS_GRAPH_FLAG_SET (ParseFlags)) { + Status = GetNewFileName ( + L"PPTT", + L"dot", + FileNameBuffer, + sizeof (FileNameBuffer) + ); + + if (EFI_ERROR (Status)) { + Print ( + L"Error: Could not open dot file for PPTT table:\n" + L"Could not get a file name." + ); + // Abandonning creation of dot graph by unsetting the flag. + // We continue parsing in case trace is set. + ParseFlags &= ~PARSE_FLAGS_GRAPH; + } else { + mDotFileHandle = DotOpenNewFile (FileNameBuffer); + if (mDotFileHandle == NULL) { + Print (L"ERROR: Could not open dot file for PPTT table.\n"); + // Abandonning creation of dot graph by unsetting the flag. + // We continue parsing in case trace is set. + ParseFlags &= ~PARSE_FLAGS_GRAPH; + } + } + } + + PpttStartPointer = Ptr; + Offset = ParseAcpi ( IS_TRACE_FLAG_SET (ParseFlags), 0, @@ -406,6 +580,24 @@ ParseAcpiPptt ( PARSER_PARAMS (PpttParser) ); + if (*(AcpiHdrInfo.Revision) < 2 && + IS_GRAPH_FLAG_SET (ParseFlags)) { + Print (L"\nWARNING: Dot output may not be consistent for PPTT revisions < 2\n"); + UnicodeSPrint ( + Buffer, + sizeof (Buffer), + L"WARNING: PPTT table revision is %u.\\n" \ + L"Revisions lower than 2 might lead to incorrect labelling", + *(AcpiHdrInfo.Revision) + ); + DotAddNode ( + mDotFileHandle, + 0, + DOT_COLOR_RED | DOT_BOX_SQUARE, + Buffer + ); + } + ProcessorTopologyStructurePtr = Ptr + Offset; while (Offset < AcpiTableLength) { @@ -486,4 +678,8 @@ ParseAcpiPptt ( ProcessorTopologyStructurePtr += *ProcessorTopologyStructureLength; Offset += *ProcessorTopologyStructureLength; } // while + + if (IS_GRAPH_FLAG_SET (ParseFlags)) { + DotCloseFile (mDotFileHandle); + } } -- Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")