From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-fw-80006.amazon.com (smtp-fw-80006.amazon.com [99.78.197.217]) by mx.groups.io with SMTP id smtpd.web11.3218.1653619433155395947 for ; Thu, 26 May 2022 19:43:53 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=UBt5KGyN; spf=pass (domain: amazon.de, ip: 99.78.197.217, mailfrom: prvs=139655964=graf@amazon.de) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1653619434; x=1685155434; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1pkTQNWZZYcr32eAewBcW2o5lK5u1ecKBssICV0xbc4=; b=UBt5KGyNv/5b0iWDpFGMFzuuM8m1FGAODWuMR22hQbc5ze7ra/3tIkRA Qu5eipWMLp5e7+7bEZRCFpaTzYQY0eyS/lqCiTBoOxY/ic3ZeEGcoNp6X tjx6JHO7lttQf3t/HDJRTProysL1O+lEKu63mOdtlOrd1xvnblYQl/HdX c=; X-IronPort-AV: E=Sophos;i="5.91,254,1647302400"; d="scan'208";a="92377777" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1d-ca048aa0.us-east-1.amazon.com) ([10.25.36.214]) by smtp-border-fw-80006.pdx80.corp.amazon.com with ESMTP; 27 May 2022 02:43:38 +0000 Received: from EX13MTAUWC002.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1d-ca048aa0.us-east-1.amazon.com (Postfix) with ESMTPS id 03BA282217; Fri, 27 May 2022 02:43:35 +0000 (UTC) Received: from EX13D20UWC001.ant.amazon.com (10.43.162.244) by EX13MTAUWC002.ant.amazon.com (10.43.162.240) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Fri, 27 May 2022 02:43:33 +0000 Received: from u79c5a0a55de558.ant.amazon.com (10.43.162.202) by EX13D20UWC001.ant.amazon.com (10.43.162.244) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Fri, 27 May 2022 02:43:32 +0000 From: "Alexander Graf" To: CC: Ard Biesheuvel , Leif Lindholm , Dandan Bi , Zhichao Gao , Liming Gao Subject: [PATCH 04/12] MdePkg: Add X86 timer support for BaseDebugBootlog Date: Fri, 27 May 2022 04:43:09 +0200 Message-ID: <20220527024317.13476-5-graf@amazon.com> X-Mailer: git-send-email 2.28.0.394.ge197136389 In-Reply-To: <20220527024317.13476-1-graf@amazon.com> References: <20220527024317.13476-1-graf@amazon.com> MIME-Version: 1.0 X-Originating-IP: [10.43.162.202] X-ClientProxiedBy: EX13D35UWB003.ant.amazon.com (10.43.161.65) To EX13D20UWC001.ant.amazon.com (10.43.162.244) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This patch adds time stamp infrastructure using the TSC. It attempts to determine TSC frequency inside virtual machines, but not on read hardware. Signed-off-by: Alexander Graf --- .../BaseDebugBootlog/DebugBootlogX86.c | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 MdePkg/Library/BaseDebugBootlog/DebugBootlogX86.c diff --git a/MdePkg/Library/BaseDebugBootlog/DebugBootlogX86.c b/MdePkg/Library/BaseDebugBootlog/DebugBootlogX86.c new file mode 100644 index 0000000000..1b6f677ce8 --- /dev/null +++ b/MdePkg/Library/BaseDebugBootlog/DebugBootlogX86.c @@ -0,0 +1,50 @@ +/** @file + Base Debug library instance for a RAM based boot log + It provides functions to store debug messages in RAM and make them available as + Bootlog Configuration Table. + + Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2022, Amazon Development Center Germany GmbH.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "BaseDebugBootlog.h" + +UINT64 +EFIAPI +BaseDebugLibBootlogTicksPerSecond ( + VOID + ) +{ + UINT32 MaxLeaf = 0; + UINT32 TscKhz = 0; + + /* Look up VMware's TSC leaf first */ + AsmCpuid (0x40000000, &MaxLeaf, NULL, NULL, NULL); + if (MaxLeaf >= 0x40000010 && MaxLeaf < 0x50000000) { + /* We're in a VM that supports the TSC leaf. */ + AsmCpuid (0x40000010, &TscKhz, NULL, NULL, NULL); + + return (UINT64)TscKhz * 1000; + } + + /* + * The natural fallback path here would be to leverage TimerLib's + * GetPerformanceCounterProperties(), but TimerLib uses DebugLib + * so we can not use it. Let's leave TSC frequency extraction to + * post processing for now. + */ + + return 0; +} + +UINT64 +EFIAPI +BaseDebugLibBootlogTicks ( + VOID + ) +{ + return AsmReadTsc(); +} + -- 2.28.0.394.ge197136389 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879