From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (EUR04-DB3-obe.outbound.protection.outlook.com [40.107.6.83]) by mx.groups.io with SMTP id smtpd.web11.8260.1620383900120056340 for ; Fri, 07 May 2021 03:38:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=oFY114MW; spf=pass (domain: arm.com, ip: 40.107.6.83, 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=AH3T5znk9v3EoB8tanjC5q0mP5vhwGilzAwH0C8GrNo=; b=oFY114MW3WJN5jLuzo8j0lpnBOwZGBAnrRYpHVCtB9IgH96FoY2GEG/MF1dZGkVi/RnBeHOQ3uSyDd80GDA9ws3igCTT/uy/LUi5Nv8yAkzDf//VSPEM8n/XXHoC5S5HdOPIITjeKYjCYMvZUrcE0FS3DgYljQfo3jGjPqj15ls= Received: from AM6PR05CA0023.eurprd05.prod.outlook.com (2603:10a6:20b:2e::36) by VI1PR08MB3791.eurprd08.prod.outlook.com (2603:10a6:803:c0::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Fri, 7 May 2021 10:38:17 +0000 Received: from AM5EUR03FT064.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2e:cafe::c9) by AM6PR05CA0023.outlook.office365.com (2603:10a6:20b:2e::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Fri, 7 May 2021 10:38:16 +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 AM5EUR03FT064.mail.protection.outlook.com (10.152.17.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Fri, 7 May 2021 10:38:16 +0000 Received: ("Tessian outbound 1e34f83e4964:v91"); Fri, 07 May 2021 10:38:16 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c43e000225b91e70 X-CR-MTA-TID: 64aa7808 Received: from f21d2d26a897.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 02C10E9A-4527-4468-8170-2FB6A9CDF8F8.1; Fri, 07 May 2021 10:38:09 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f21d2d26a897.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 07 May 2021 10:38:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cF0PtHciQLz9HHQcAXjU68vBQB11BCv1fLsHasA54+tbEpIgNpNOg3Z622KuudJzNEi+tyHHYtaAXERHleqZs1iU7wpiweP1Bf8fBkY+YkjNUvrqNC3DYSFRiKLjxHTvilvNnXHPPqfYW0vJcLxbtzNUFKLo+nc/imAsNY07Z5z+854nRSWt22SiV9OSCZXOfUo48SNL7XTyyPt5hvZ7NeeTQ1pKXJQdVlugtdihavDFQUlXLiK1L++AKDs0eFsnMRQn2LZYkf2pB4kJ3J7umWTURwFg2SpsEh9L/6mFh4mUNzuEfvxlzhugwoI7ngCSTT2eLhhwKCPV29vfgdmNLQ== 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-SenderADCheck; bh=AH3T5znk9v3EoB8tanjC5q0mP5vhwGilzAwH0C8GrNo=; b=awQ5Jp6vJMLBpFPiaZvsUNo2h7uMOXp6MglxqMZKIBFirwwQYJrSxt65ovkBENMhQErsZKH5v4IMdQLZnqhrOGRkviAe8F1ztm3U86XUdcIJCCBMBw5UyFaam/AJ94KnFjB3lSgosC8cTkook3zddhpxJvHxMzYT62DVCTEVehcrhsr0uyekiYSIQGdziEmt7DVRki4DmpZIHkZ8m86m1WqHWmaBY8d03TyJHlmZgA2qRDApXiEdDLTvRUP4oq6uCkeQOZp0Axrv8Rx/JPvTwKVKM4CNggUKZMgDK7RXq1NNDUmXf3PHJ5YYwSqvFGZDUk7z3PN/japxXAMJkWiCNA== 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=AH3T5znk9v3EoB8tanjC5q0mP5vhwGilzAwH0C8GrNo=; b=oFY114MW3WJN5jLuzo8j0lpnBOwZGBAnrRYpHVCtB9IgH96FoY2GEG/MF1dZGkVi/RnBeHOQ3uSyDd80GDA9ws3igCTT/uy/LUi5Nv8yAkzDf//VSPEM8n/XXHoC5S5HdOPIITjeKYjCYMvZUrcE0FS3DgYljQfo3jGjPqj15ls= Received: from AM6P194CA0060.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:84::37) by VE1PR08MB5854.eurprd08.prod.outlook.com (2603:10a6:800:1b0::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.27; Fri, 7 May 2021 10:38:08 +0000 Received: from AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:84:cafe::86) by AM6P194CA0060.outlook.office365.com (2603:10a6:209:84::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Fri, 7 May 2021 10:38: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 AM5EUR03FT018.mail.protection.outlook.com (10.152.16.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4108.25 via Frontend Transport; Fri, 7 May 2021 10:38:07 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Fri, 7 May 2021 10:38:06 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 7 May 2021 10:38:06 +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.2176.2 via Frontend Transport; Fri, 7 May 2021 10:38:05 +0000 From: "Joey Gouly" To: CC: , , , , Subject: [PATCH v1 5/5] ShellPkg: add PPTT dot file genration Date: Fri, 7 May 2021 11:38:04 +0100 Message-ID: <20210507103804.8131-6-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210507103804.8131-1-joey.gouly@arm.com> References: <20210507103804.8131-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 11a48d06-24b7-495c-579b-08d91144394d X-MS-TrafficTypeDiagnostic: VE1PR08MB5854:|VI1PR08MB3791: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3173;OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: qV0g2ZupU3TmRUVCm4AToWaoHK/w3FdBCIOzXunzpvt4uuJJc4zkklYYjaJ3+BalVvoafuDe/qr8m+lfcDODm6tMRdwHST0Bfvq4qkWVH/qhdbCzIIak+kh67j3fZBMLAxEcbagmBV7SL7AgTN6L5CNIdoYbhSeaA0uJM4xjN38giGJMF3F2Z3qMNKecw7h+PMTOu0vWjUU26SvFJgjLeAipRLZD+6FgITpRi8WMI/mKskpDQH5BlBK3L58psVxnEDiTK5lOfiUuag+61frkg0ccOdSDs7oNxTM4FP/YSklcYzneAy8rYU5nHaMz42s+A8pDJ9flUnGgO9MLD3efO7PMRuATxtdF0EWMaIrfiU+jbyTeqZteA4dG/BWg4qJIQO+sg7Qz/dOuiypOOcgqhr3aaM1Knepc8cBjc5KjojN4xfyng0b5d9aVv+IF17txiMpGa/pCOEUshb9SJ6H6l5tg06SKnmwDXResq5W9ZSExDEYl3fQ0WqEiZX8vBSFYWj2TaVnHsZxBaufYWy5qDKMWyIoP3kCNogJFTnXjf+FRcKVdCSRORt2QtFdqNB4KM6amlIrtTZsibtYklCLZcscAHTZcQXMyZKdQejGj3rjOHNoPKJfBYpLOgvgQEOesTVq4Bn6MmqRdXLviL/PFCDvMl4UQe8KFbPBipPhAFmMHf8STAIoZyu0V+yLzZ6Ys2vFJLh+7wRljx+Cjb05/H+8NKCLfKeWTAkymbDcoFs6N1zngBJWaBPObbE8CCpIUOUSWUhavN69XY0LffdNNHQ== 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)(396003)(136003)(39850400004)(346002)(376002)(36840700001)(46966006)(82310400003)(336012)(1076003)(6916009)(426003)(4326008)(2906002)(47076005)(316002)(2616005)(36860700001)(82740400003)(81166007)(356005)(5660300002)(26005)(186003)(70586007)(7696005)(478600001)(83380400001)(44832011)(54906003)(36756003)(86362001)(8936002)(70206006)(8676002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5854 Return-Path: Joey.Gouly@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT064.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 981938d4-4465-42ba-353d-08d9114433e6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MNfQO6bf9Kth5moh7eyfm1iMQSGozIpp3vqpQw9MNq4mbnXkFaXtpKBaV6i85x3QqQFnXHMBeJBQkycq7x6H06dPZ+AXl9OL2ZVsDisyBDPHO8Ct+Xss9YCAt8t/Y5iEwh/tLRg87GGaeIJYLeID61UQxPzzcveMSymG6wRQzUlfCkbWnNGyM+RPdvLF4kKqthMRk8oGBbTZpbrmmhPQj+vwxnF83o/U7iNKE+N8oGGJeVeQlPJr6riNgKVm2jylHggdvjfzIB2CNra3MGlFsqekK1+ZlxgW0SHoweAcObS5m87OCKUSAuD1YvfzrjfFCbf3QyShIVXTjnNaIeBdTlEonX/wGJoX5HuufW0B6dm5UjBQJ90dJDtPjWhWoRYxUVJk3wZ0mvEBfI66vvDDNmalePxVInxBxntY1UlDSN3UJFGU5/NYhNG4szQv1BS+IjxyWgsNnPsUyMoL2dpPbn/l2ekgXnzHgDTRwe9IM4+iJmQcYkbOsuuDu2rDtodRLArT1IA3ufO/KfEpc3WBDV5X2cxyghKkzBdLdVKzOvkRhcw0OLcGhzpYvhx4pSlc0YI1zI0NlB9z0k4gncsxFnTMgj7TCYggIaw2suzD27oAEzXlCAKWMF97ofptPztMuIWLEcRYgKBtMJPn7vmI+7YeA2KXuOE8k6EVmAxLbat2gNyIzR/rUh7y84rv1Tg1VFATaXOrZbYBNasPkLgk9ODzzQHrQ5+wI2rp/ikcbxY= 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)(39850400004)(376002)(396003)(36840700001)(46966006)(82740400003)(7696005)(44832011)(70586007)(70206006)(4326008)(478600001)(47076005)(426003)(83380400001)(81166007)(8676002)(336012)(1076003)(6916009)(26005)(2616005)(86362001)(8936002)(2906002)(5660300002)(82310400003)(54906003)(36860700001)(316002)(186003)(36756003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 10:38:16.5704 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 11a48d06-24b7-495c-579b-08d91144394d 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: AM5EUR03FT064.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3791 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: Marc Moisson-Franckhauser 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")