From patchwork Thu Mar 1 18:11:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 130375 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3117533edc; Thu, 1 Mar 2018 10:12:03 -0800 (PST) X-Google-Smtp-Source: AG47ELtfjN4OQhpukmmVsLd75VzNxDLX0fjx8C7n6ii+paCB8jQcjQa8Is4Jf/lzAz+X1rFEHkRl X-Received: by 10.98.152.205 with SMTP id d74mr2827167pfk.115.1519927923741; Thu, 01 Mar 2018 10:12:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519927923; cv=none; d=google.com; s=arc-20160816; b=UO3xOljGUUBT829GTYLBTRYyI5npMDnPMANqVLwRhybVZKDEAZA3d6EvBnuZyMtUKz D6pCzPIcgKJ5dJ+GcPw/V5WtEFxL0qJ5rvpneCJ0Xk/0qVPe8BCbUVKfD3F7HkOAhH96 W68+cV3d8nfBxGEaRRdjrUM+Uk13wapSgTwiScOlX/W98htrSot7Fv5EaSCOFRjLVpwJ LdXqvInur+SyKlZCDT/+NYZW9rRaPHYoMX/vXsr+tzpu1A/Iev6shguLmUA4VD7fMse9 Mzgo4LpH75UMQQp5CXk7s5bfSxbOGzxeeB298xT/S2rnXvw8/lS/PP0EYH4M7LG+ExLg mNaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=s0BSKuzXkWl+eLCk+Q0kFPXRCJV4HeTpbu890XZi2jg=; b=T1SP9b0tQw5QFwUzEcpitp55V2Ql3zvNECu0UIUBnr5X+qFFSac5CngkE2xHm1Z0c5 e3vPQSjJBb4gC4+ntpo2c1141r8s60RInAwt6rskWkreN96L7n//UiwNL93HGKF03PAf JZ2fn1bjRVrzo3anFO4hL+q8QFozlGy4AGgtk2jPUWygGg/hw0OlMumy5ba4+M9aLOJu natJZamt+rl4pU9hbHjU7uuvKmqCypM4GQiokDzRKTYOidmfdyMSSfHN4TOhYqBvXDZl nbU40HZfGgt3udQ7K5Pg/5zh0AMN2+KLPk0cp6iuHDDQD9GKvnGYNx7y1RXtj+wLLT8V HnDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RHTfD9jB; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id l9si2780901pgs.226.2018.03.01.10.12.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 10:12:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RHTfD9jB; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8002D22451181; Thu, 1 Mar 2018 10:05:54 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::241; helo=mail-wr0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1385122423858 for ; Thu, 1 Mar 2018 10:05:52 -0800 (PST) Received: by mail-wr0-x241.google.com with SMTP id v65so7526219wrc.11 for ; Thu, 01 Mar 2018 10:12:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aAhh6YnMpcRVu0w2TlO9EgVK/UmyDSD54+vuGF85LWc=; b=RHTfD9jBdYvECFzWphtOy1AWoqps3G3hDBhkMw8iELam4DDB9XAEyI6W9Wxw2EUAYw 7IZGHro9ratIZEcCn8FzZ1w33nWcrWLkYUlfEzO9wW9Awcv8So/PW+d4RUsG1tG4Cb9j 7vhmQdneDo+q7otKM7H2BXlO8MgSAbcP5tzdM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aAhh6YnMpcRVu0w2TlO9EgVK/UmyDSD54+vuGF85LWc=; b=rpuklrdKlvCUkFz3MZNLzD04OVYRkG6J52xeU5/jlm1zJZTkMPXh00aaO09okocEXL QhuQrCoE7pmD6zCr3oyOPwnvcOLADveUz4cWN9SuwtBnjccnLJg6iqziCrZsja4NKDlD un6jLMDH4sAIAtc0v3/UfYeqAUOSsVU3tvPi/rjkoX6JAYBIZgHQMneYXvbP5lNVjhQv 9NVGR4WhucJMnh0FcK2mEN1hkCAXFiAO32XdIxpIUEW2sLUbpDSwTv6AoRKIWjAaQBm+ xSM1HMEquJzvHC9tey+sXV/P+GNkOzyvtcuI+735WSrMdpC7JEUyw18S25lYhlrfdghP zCEw== X-Gm-Message-State: APf1xPDczizBLAXkiui+d1eD33WYl5Wu+1dc5/GI4qiR9K0ZlwxCnpTk FWRMCL9pIdnX3fpOoXKvPwiS1W06iPY= X-Received: by 10.223.193.69 with SMTP id w5mr2447318wre.42.1519927919570; Thu, 01 Mar 2018 10:11:59 -0800 (PST) Received: from localhost.localdomain ([196.71.216.221]) by smtp.gmail.com with ESMTPSA id w195sm78568wmw.9.2018.03.01.10.11.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 10:11:58 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 1 Mar 2018 18:11:39 +0000 Message-Id: <20180301181142.16817-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180301181142.16817-1-ard.biesheuvel@linaro.org> References: <20180301181142.16817-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 1/4] MdePkg: move DxeRuntimeDebugLibSerialPort to MdeModulePkg X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eric.dong@intel.com, Ard Biesheuvel , leif.lindholm@linaro.org, heyi.guo@linaro.org, liming.gao@intel.com, michael.d.kinney@intel.com, lersek@redhat.com, star.zeng@intel.com MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Before making enhancements to DxeRuntimeDebugLibSerialPort involving EDK2 specific protocols, move the driver from MdePkg to MdeModulePkg, which permits such EDK2 specific deviations from the PI spec. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirt.dsc.inc | 2 +- {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c | 0 {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf | 0 {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.uni | 0 4 files changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index cde514958da2..8f411fde1f8b 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -232,7 +232,7 @@ [LibraryClasses.common.DXE_RUNTIME_DRIVER] MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf !if $(TARGET) != RELEASE - DebugLib|MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf + DebugLib|MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf !endif !if $(SECURE_BOOT_ENABLE) == TRUE diff --git a/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c b/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c similarity index 100% rename from MdePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c rename to MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c diff --git a/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf b/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf similarity index 100% rename from MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf rename to MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf diff --git a/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.uni b/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.uni similarity index 100% rename from MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.uni rename to MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.uni From patchwork Thu Mar 1 18:11:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 130376 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3117588edc; Thu, 1 Mar 2018 10:12:07 -0800 (PST) X-Google-Smtp-Source: AG47ELuF5Bpa3Qxy3D3MDIKYNDTcy9PvQl6oxmhtubKDIW53trdpHFRRA90wZbqmW1+/Eq9uhGye X-Received: by 10.99.4.66 with SMTP id 63mr2227154pge.93.1519927927130; Thu, 01 Mar 2018 10:12:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519927927; cv=none; d=google.com; s=arc-20160816; b=mApKj3I/n8FkBrQZrRJAxNjEtgCNW61nReHBG2SjQ5nmMDa7N/aNS/pIEuqr+wfvLF YJWE8LaCyl09t81tRY+nqx+rb8fpWDBQ4qAtnePqj9s33Q47vSEIwzbSR85yHJ7Wc/zU h1w04T/0Z3Ue6hwkmla5foQ3XAe4t/aqnMLOM2JqJj9mzDyHZbreQQAdj4IJX5fd02Vu lk9dDfG1lGg1inZAd1QIORG48Gu6o7/oX3evnJBwpV5jtO6X0ufJFBTf1R7aSiV1V8lm 5C4UDDCu5XlD/jEt2taUZyErX2S9YTjmFaQVDIuU2zEkzXcla3nXNc49jfzkMFwoyCau qBVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=KO/+3FQwxto+yslnsdBMDq2OU1keUwUSv/b7lE+HzFQ=; b=OB+p3S4oMK5q8q/79Sm4rA84u8O2xqZ5fehDezdti5kJSCMwSGpzUlXH8qcl4cF/Qr H+BnTzBNx1VMGdPvF7dxjz6/HwzIly+ELN7hoS0OIEgLfhQ6d0OmGKGZjg9FBQs8VWaO fwReyVM4bhbCy2XwR9o/mwW+jkY7suWdRvg500HLaPJszPHaGd/4DptuhMNPR5z5KOe4 0jNd1KINsEQJvHQhJgW61IeGYdlHr4r+shuG9FUNKAMUG3KpJFGOU/jc0/XKbYNKZGpK haoUVHhI1UMZwfn1yGUi2D2SELF7YwxGjrXAkpC068KyZi9PN9xBeJdqVLnfWWqe4gX9 vsEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UK96FO3M; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id w19-v6si3311687plq.735.2018.03.01.10.12.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 10:12:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UK96FO3M; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DCC71224511A5; Thu, 1 Mar 2018 10:05:57 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::242; helo=mail-wr0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BF5BE2245119D for ; Thu, 1 Mar 2018 10:05:55 -0800 (PST) Received: by mail-wr0-x242.google.com with SMTP id l43so7573929wrc.2 for ; Thu, 01 Mar 2018 10:12:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fu8z9X4IjWt97oDD7jGUNSoYqeeX5c2xvxyJzOvpZRE=; b=UK96FO3M0E6DxxRcyGyHXuluOU+Orts2wK1BwgHgY0SS3DUIrFQQe/9GVpkzks66e/ 7eZdJ3WYr+IDK1sieVt2zB29Um3b9PMD9C7YSvrbkey4Zp7tNYBHx5oIYsGqA7HlWXfU eHfN9BAU3pz4imN8sA0gd9ZLU5+QYaxnYY858= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fu8z9X4IjWt97oDD7jGUNSoYqeeX5c2xvxyJzOvpZRE=; b=dxIP4ZRDesh6VzuABCmsaUCWdUnHxQpSgvf/C3AvteCAdbF7cX8lQ2Uc/IyoBj47nJ cX01u+IKTv/I3yoybIozpytuUoy8tY7JmlfnfIkmrksBiebNHjJZfBG770zITaAcLfBq Qsrok0754g/v+cAsKPkRZwUGAD8eTeK81zISJoTZgxl7Iva8onXJBkDAnVn5h9fUqBYG /sSUHujT2ITFZ8DiRp6h3Q1/jsc/X6S3O6TDuYjjGX3t4rIQTqQ2tfjDp2cNxwzPGw6Z I42/mmzy4AaEPogjjHVXqJqci3RLb4wc6f8n8HtiwWBdh41j4M3ZaFTWAPw60jgn9bsK Eh0A== X-Gm-Message-State: APf1xPCMpzyPGExxphXbGGBtQYUikJtxXqhAv3QtVFXXgP+RlTSr4a6/ dCmHplIxe7ym3Z8CYpaAZfQ+4Y7nzVE= X-Received: by 10.223.201.11 with SMTP id m11mr2822726wrh.146.1519927922779; Thu, 01 Mar 2018 10:12:02 -0800 (PST) Received: from localhost.localdomain ([196.71.216.221]) by smtp.gmail.com with ESMTPSA id w195sm78568wmw.9.2018.03.01.10.11.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 10:12:02 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 1 Mar 2018 18:11:40 +0000 Message-Id: <20180301181142.16817-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180301181142.16817-1-ard.biesheuvel@linaro.org> References: <20180301181142.16817-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 2/4] MdeModulePkg: introduce runtime debug output protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eric.dong@intel.com, Ard Biesheuvel , leif.lindholm@linaro.org, heyi.guo@linaro.org, liming.gao@intel.com, michael.d.kinney@intel.com, lersek@redhat.com, star.zeng@intel.com MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Introduce a EDK2 specific protocol that may be invoked to produce debug output at runtime. This may be used, e.g., by DebugLib library class implementations called from DXE_RUNTIME_DRIVER modules, which may only be able to produce debug output at boot time, and will be able to defer to this protocol to produce debug output at runtime as well. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Include/Protocol/RuntimeDebugOutput.h | 58 ++++++++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 4 ++ 2 files changed, 62 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Include/Protocol/RuntimeDebugOutput.h b/MdeModulePkg/Include/Protocol/RuntimeDebugOutput.h new file mode 100644 index 000000000000..ac6e0c27d86d --- /dev/null +++ b/MdeModulePkg/Include/Protocol/RuntimeDebugOutput.h @@ -0,0 +1,58 @@ +/** @file + Protocol for emitting debug output at runtime. May be consumed by DebugLib + implementations that can only produce output safely at boot time. + + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+ + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __EDK2_RUNTIME_DEBUG_OUTPUT_H__ +#define __EDK2_RUNTIME_DEBUG_OUTPUT_H__ + +#define EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL_GUID \ + { 0x3f4fe308, 0x2284, 0x4ca2, { 0xbe, 0x2c, 0x2d, 0xa8, 0xdf, 0x7a, 0xec, 0xd6 } } + +typedef struct _EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL; + +/** + Write data from buffer to debug output device + + Writes NumberOfBytes data bytes from Buffer to the debug output device. + The number of bytes actually written to the device is returned. + If the return value is less than NumberOfBytes, then the write operation + failed. + If NumberOfBytes is zero, then return 0. + + @param Buffer Pointer to the data buffer to be written. + @param NumberOfBytes Number of bytes to written to the device. + + @retval 0 NumberOfBytes is 0. + @retval >0 The number of bytes written to the serial device. + If this value is less than NumberOfBytes, then the + write operation failed. + +**/ +typedef +UINTN +(EFIAPI *RUNTIME_DEBUG_OUTPUT_WRITE) ( + IN EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL *This, + IN UINT8 *Buffer, + IN UINTN NumberOfBytes + ); + + +struct _EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL { + RUNTIME_DEBUG_OUTPUT_WRITE Write; +}; + +extern EFI_GUID gEdkiiRuntimeDebugOutputProtocolGuid; + +#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index ba0585936b6e..faaf189fe464 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -592,6 +592,10 @@ [Protocols] gEdkiiPlatformSpecificResetFilterProtocolGuid = { 0x695d7835, 0x8d47, 0x4c11, { 0xab, 0x22, 0xfa, 0x8a, 0xcc, 0xe7, 0xae, 0x7a } } ## Include/Protocol/PlatformSpecificResetHandler.h gEdkiiPlatformSpecificResetHandlerProtocolGuid = { 0x2df6ba0b, 0x7092, 0x440d, { 0xbd, 0x4, 0xfb, 0x9, 0x1e, 0xc3, 0xf3, 0xc1 } } + + ## Include/Protocol/RuntimeDebugOutput.h + gEdkiiRuntimeDebugOutputProtocolGuid = { 0x3f4fe308, 0x2284, 0x4ca2, { 0xbe, 0x2c, 0x2d, 0xa8, 0xdf, 0x7a, 0xec, 0xd6 } } + # # [Error.gEfiMdeModulePkgTokenSpaceGuid] # 0x80000001 | Invalid value provided. From patchwork Thu Mar 1 18:11:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 130377 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3117647edc; Thu, 1 Mar 2018 10:12:10 -0800 (PST) X-Google-Smtp-Source: AG47ELvte6Syv5WhOT0pcXTE94RfhdODNprmUFrWaOucQG8yCkfYvgIpZjMpO8zJkrpJ8rbMDAUz X-Received: by 2002:a17:902:33a5:: with SMTP id b34-v6mr2645730plc.263.1519927930444; Thu, 01 Mar 2018 10:12:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519927930; cv=none; d=google.com; s=arc-20160816; b=gHjRfy7ttPT2AJKG6oe6+SfLs5NMUeOjThUwLx5++zWUeNzpQ/MpIK2hZN2pBQSBfy gmjQHQT9+BqVamhKwQj/BeI0PNPrRadBxePMdIkhk5QhMhjSDvsJ25JMJezdTK2vmNZg cPwCufa6Y6HLDHQnM8ryvvnZxTltgB/vjns3o7waO5SkRCeE/Rd961VXLVtMbJFc6tog rK66xPB6OEpv7nog57xFc+/hcmUQ6N42DKTIS8ooeMliBkqZtodwhFRca1jYNlXwYjpG H5wAsvfGKL75zUUh8pae7SxefQsEgbsOPSOc88zgsnknLXNpASSU1QnSFp58D3eI1GD7 MDew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=OYZSIXn4ULgHgMcIt2A2F+jfqPHxCqZGR9AO9KGknnA=; b=fKRlpcrUZRqKnOUpsIpOgCQyj8Dgh5T0D2lGF2HOk9Y4pHCADqfk4Q8aenRnqsIwQ4 kR7q5NnvKlrnMai9TxviLQv0VQQllQe8ptL0xwVWGTU6eizIaFtXiDKQhx3O/J1KkWVL 2sQVjH0Ij0EUn6ih8JGd67CugKglsmz3/WKjSdVByc1RJLjtJ25wQdUZKgCg1qZOVrFL 6yblDSrgnDZjLQUP2TOM9BGHVmR2RnDgJ/8J7tjXy8q3VPXsBUQa/P+7eGlZbxEcya/V y88tXLtvVTBZeJikPxRkhohRqSvf4PbM18xCttdYyfO7tnVKSO3IMYHp8HAucRkw0lfi nzIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=i35oCirD; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id b92-v6si3359716plb.747.2018.03.01.10.12.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 10:12:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=i35oCirD; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 43E7E224511AD; Thu, 1 Mar 2018 10:06:01 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::243; helo=mail-wm0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8B3F22245119D for ; Thu, 1 Mar 2018 10:05:59 -0800 (PST) Received: by mail-wm0-x243.google.com with SMTP id 139so13960134wmn.2 for ; Thu, 01 Mar 2018 10:12:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3ygqM//nCAp++782fDBzQCvuU0N1w/DbwKSmjE8OADo=; b=i35oCirDcqAStzIb6qAQ3UP/hYxDU9OUuJu0LDn6v1gjVQi9WG9mjYRLxQOe5XoAmV Wx8nMQonKsYaK8wmINgBW6oLFetI/46VnYM/LLu1fRFwIFX3KxG+zhFICHLdyU0ytwPy WMCfC+TnY+5S5FryLz/H0Kw4flk3cCSBQzHUY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3ygqM//nCAp++782fDBzQCvuU0N1w/DbwKSmjE8OADo=; b=rq2ain9xD+HAiHbFEG7hglpANqwo/4Qx16ITsySdTS61Lw3ErMWm7a+6CqoKHKG1NW BpczFvhsRQYcluR7jwYKm8hIsMI7Vl5+tj84fYJXkveqsqQbzix9kOsQFwml2UKVOpdh PEUgzMFOHlbZrYcfba1LMHRG3eu3uMlg8LdSUP2WklKMVA+JyC8A4tUSsERPyRpd9U3r q8yan7/De3dohrsqflQoxPAHKkdcRnIrO7GemZM7MI0v5Os6nhXMSRQXpYJX+Dn4R51K B+Galm7BIlsgpz58MEEKTBiRLraLloLblqGfDKuCSDZ+dOkOS2KofrifbiIL1moeygk0 wuxg== X-Gm-Message-State: AElRT7GJOk20Y+f/hbPsX4jdvGGZtip3n5JgtA+zE0oDt5XvPjb0nd1A MMy4sRI9yIXFguaYSi+EvR1rWUELjkI= X-Received: by 10.28.220.66 with SMTP id t63mr2464678wmg.100.1519927926315; Thu, 01 Mar 2018 10:12:06 -0800 (PST) Received: from localhost.localdomain ([196.71.216.221]) by smtp.gmail.com with ESMTPSA id w195sm78568wmw.9.2018.03.01.10.12.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 10:12:05 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 1 Mar 2018 18:11:41 +0000 Message-Id: <20180301181142.16817-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180301181142.16817-1-ard.biesheuvel@linaro.org> References: <20180301181142.16817-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 3/4] MdeModulePkg/DxeRuntimeDebugLibSerialPort: invoke RuntimeDebugOutputProtocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eric.dong@intel.com, Ard Biesheuvel , leif.lindholm@linaro.org, heyi.guo@linaro.org, liming.gao@intel.com, michael.d.kinney@intel.com, lersek@redhat.com, star.zeng@intel.com MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Extend the functionality of DxeRuntimeDebugLibSerialPort by invoking any available RuntimeDebugOutputProtocol to emit debug output at runtime rather than staying silent. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c | 155 +++++++++++++++++--- MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf | 5 + 2 files changed, 143 insertions(+), 17 deletions(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c b/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c index e1266f77fa41..b5460f10ebb6 100644 --- a/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c +++ b/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c @@ -25,10 +25,16 @@ #include #include #include +#include STATIC EFI_EVENT mEfiExitBootServicesEvent; +STATIC EFI_EVENT mEfiVirtualAddressChangeEvent; +STATIC EFI_EVENT mRegisterRuntimeDebugOutputProtocolEvent; +STATIC VOID *mRegisterProtocolRegistration; STATIC BOOLEAN mEfiAtRuntime = FALSE; +STATIC EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL *mRuntimeOutput = NULL; + // // Define the maximum debug and assert message length that this library supports // @@ -53,6 +59,58 @@ ExitBootServicesEvent ( } /** + Attach to the RuntimeDebugOutputProtocol as soon as it gets registered + + @param[in] Event The Event that is being processed. + @param[in] Context The Event Context. + +**/ +STATIC +VOID +EFIAPI +RegisterRuntimeDebugOutputProtocolEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_BOOT_SERVICES *BS; + + BS = Context; + + Status = BS->LocateProtocol (&gEdkiiRuntimeDebugOutputProtocolGuid, + mRegisterProtocolRegistration, + (VOID **)&mRuntimeOutput); + if (EFI_ERROR (Status)) { + return; + } + + BS->CloseEvent (Event); +} + +/** + Fix up virtual address of the runtime debug output protocol + + @param[in] Event The Event that is being processed. + @param[in] Context The Event Context. + +**/ +STATIC +VOID +EFIAPI +VirtualAddressChangeEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_RUNTIME_SERVICES *RT; + + RT = Context; + + RT->ConvertPointer (0x0, (VOID **)&mRuntimeOutput); +} + +/** The constructor function to initialize the Serial Port library and register a callback for the ExitBootServices event. @@ -70,17 +128,64 @@ DxeRuntimeDebugLibSerialPortConstructor ( IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; + EFI_STATUS Status; + EFI_BOOT_SERVICES *BS; Status = SerialPortInitialize (); if (EFI_ERROR (Status)) { return Status; } - return SystemTable->BootServices->CreateEventEx (EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, ExitBootServicesEvent, NULL, - &gEfiEventExitBootServicesGuid, - &mEfiExitBootServicesEvent); + BS = SystemTable->BootServices; + + Status = BS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, + RegisterRuntimeDebugOutputProtocolEvent, BS, + &mRegisterRuntimeDebugOutputProtocolEvent); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Register for protocol notifications on this event + // + Status = BS->RegisterProtocolNotify (&gEdkiiRuntimeDebugOutputProtocolGuid, + mRegisterRuntimeDebugOutputProtocolEvent, + &mRegisterProtocolRegistration); + if (EFI_ERROR (Status)) { + goto CloseProtocolEvent; + } + + // + // Kick the event so we will perform an initial pass of + // current installed drivers + // + BS->SignalEvent (mRegisterRuntimeDebugOutputProtocolEvent); + + Status = BS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, + ExitBootServicesEvent, NULL, + &gEfiEventExitBootServicesGuid, + &mEfiExitBootServicesEvent); + if (EFI_ERROR (Status)) { + goto CloseProtocolEvent; + } + + Status = BS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, + VirtualAddressChangeEvent, SystemTable->RuntimeServices, + &gEfiEventVirtualAddressChangeGuid, + &mEfiVirtualAddressChangeEvent); + if (EFI_ERROR (Status)) { + goto CloseExitBootServicesEvent; + } + + return EFI_SUCCESS; + +CloseExitBootServicesEvent: + BS->CloseEvent (mEfiExitBootServicesEvent); + +CloseProtocolEvent: + BS->CloseEvent (mRegisterRuntimeDebugOutputProtocolEvent); + + return Status; } /** @@ -100,7 +205,29 @@ DxeRuntimeDebugLibSerialPortDestructor ( IN EFI_SYSTEM_TABLE *SystemTable ) { - return SystemTable->BootServices->CloseEvent (mEfiExitBootServicesEvent); + EFI_BOOT_SERVICES *BS; + + BS = SystemTable->BootServices; + + BS->CloseEvent (mRegisterRuntimeDebugOutputProtocolEvent); + BS->CloseEvent (mEfiExitBootServicesEvent); + + return EFI_SUCCESS; +} + +STATIC +UINTN +DebugWriteOutput ( + IN UINT8 *Buffer, + IN UINTN NumberOfBytes + ) +{ + if (!mEfiAtRuntime) { + return SerialPortWrite (Buffer, NumberOfBytes); + } else if (mRuntimeOutput != NULL) { + return mRuntimeOutput->Write (mRuntimeOutput, Buffer, NumberOfBytes); + } + return 0; } /** @@ -129,10 +256,6 @@ DebugPrint ( CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; VA_LIST Marker; - if (mEfiAtRuntime) { - return; - } - // // If Format is NULL, then ASSERT(). // @@ -155,7 +278,7 @@ DebugPrint ( // // Send the print string to a Serial Port // - SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer)); + DebugWriteOutput ((UINT8 *)Buffer, AsciiStrLen (Buffer)); } @@ -196,12 +319,10 @@ DebugAssert ( AsciiSPrint (Buffer, sizeof (Buffer), "ASSERT [%a] %a(%d): %a\n", gEfiCallerBaseName, FileName, LineNumber, Description); - if (!mEfiAtRuntime) { - // - // Send the print string to the Console Output device - // - SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer)); - } + // + // Send the print string to the Console Output device + // + DebugWriteOutput ((UINT8 *)Buffer, AsciiStrLen (Buffer)); // // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings diff --git a/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf b/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf index 813358096982..d2fbdde25f1d 100644 --- a/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf +++ b/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf @@ -36,6 +36,7 @@ [Sources] DebugLib.c [Packages] + MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec [LibraryClasses] @@ -48,6 +49,10 @@ [LibraryClasses] [Guids] gEfiEventExitBootServicesGuid ## CONSUMES ## Event + gEfiEventVirtualAddressChangeGuid ## CONSUMES ## Event + +[Protocols] + gEdkiiRuntimeDebugOutputProtocolGuid ## SOMETIMES_CONSUMES [Pcd] gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue ## SOMETIMES_CONSUMES From patchwork Thu Mar 1 18:11:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 130378 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3117710edc; Thu, 1 Mar 2018 10:12:14 -0800 (PST) X-Google-Smtp-Source: AG47ELvtTgq6eXFgTWDo62Q8GU1uhaWhyJV22UVruVc91s9l5GZlUMe2fkOf4vvV3ukH6bpNnssN X-Received: by 10.99.47.132 with SMTP id v126mr2284838pgv.42.1519927933886; Thu, 01 Mar 2018 10:12:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519927933; cv=none; d=google.com; s=arc-20160816; b=r2vWBxEh1IiPfaTCat/M3L6LxxPytIbu50v0DR7Y8kjvJP/1VcIErdwHhQhdMkh/yy IrVWt8MmYOlKEAJY/KRETGLODijrsaoi1zHHY265zpjua+UW7uHtVqtE++KfMC+VJP3N hVAyuFdQ4VXHMjmhNgXRL32ntB3822KJvEv530Os6tjQrlhPQqLuHKjb9HTw/Nf8iJ0E 0o3ojgvtH71EfV8GXlbbbga8ZyUNRE3HWxzRcNwgCTM6/qYS5cJ/SMTg+owNEFIKbepo kyiUj/14/ZaqnrLlKGz7r9VPGJ8sbmMToJd238PQ+Af74mqiEHH3r/9EUB6Qt5sylcbZ /STg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=gJdpRWz5RzKcDAqG9H3U7cwuUn68NydRuioLcrK+uEU=; b=ZFuGaIfFmgMofwjm55YS1BIOd/TUAoos+wUmfkZS5x1LE4LsOhYSsMwa+yw1Gw30Q1 aEPnY4cgbQpwkndPFwItY4gUoMXhjipA3fkj7bwEHoGSe1JlC2yoxxzA+GiUcCLov+wS RM70PPW5W7HB2tZnPe2sKJusejM0+PwcJCQ+hVJKfccJZLfnsJJwJaQZX86S9sOdvvkK lHgNEGgrtA6dZaPHPrSgifOIJPqo0lzIBiXucH1swRMFjpiSzSBWSLUdITw2ZeVdzkyU QZuv5M2efQIcWH7hN8yubHMVJX58hErnpTihKs+ScjSwdLkTR5BIOI88ikm1jsEY10kq 8qkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WoB1PwYp; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id n10-v6si3312389plk.255.2018.03.01.10.12.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 10:12:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WoB1PwYp; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9B395224511B1; Thu, 1 Mar 2018 10:06:04 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::241; helo=mail-wm0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F2E0B22423858 for ; Thu, 1 Mar 2018 10:06:02 -0800 (PST) Received: by mail-wm0-x241.google.com with SMTP id z9so13854174wmb.3 for ; Thu, 01 Mar 2018 10:12:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xfXEQI+MZ2WZJtzDwSAWYPZ9yP3J7+TSpRJ7XO1N6PE=; b=WoB1PwYpPSNW3AZQXcbAHn3v3pg8t9Mmgxa7GurOPMLF6sgkkRAQgNCou7leP1wbpd ZwTSZ+eaTHWmda/YuoJTRheRImtHQnGxn76z08lZRVbhdUSKr3aKwOsX4Sd9bbLdTEox yrrInJ15pQxetOuyBkjJSzHKEkMDzxmeJQ7gM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xfXEQI+MZ2WZJtzDwSAWYPZ9yP3J7+TSpRJ7XO1N6PE=; b=i8hQiJo8kwdvnSQG4H4knOJu4wwvWDcGU2+SKOhXJ3C09SWjgFPGpJp/tU5Kq2h4F5 5op+Xe7lvS4WJcXelIiBy2lEoJ7JgfDtEV5Pyx6BsT/0IFkqLnRoubYI0wkSz9OGPlO7 ZI65RS8FFUDzbBXKUY0JArvnKBYShds+oeZQ0oCZbdaf3AtDNYHCKqjHADdw4faSryig F+FWgH7DhHuhBlGUpquCoFXJnUhC1zkjfTPqTYClP+l9zkDVX04KSK5U5amQKwuuIuZT rPdwxG8Nj6VdQGfyd3AayrAwmoJrDLq0cy57Re8wdDQsICGSJWyvzQD05F+B/uL2xiTV eBmg== X-Gm-Message-State: AElRT7H1awUDJAE9R+RgC64ftx6e05nel/xydyFFYxuB/kjN2ZdfxeFn lbMqZWjgi5hE0W0kjfkEf0Nve8N/dts= X-Received: by 10.28.166.201 with SMTP id p192mr2359222wme.132.1519927929927; Thu, 01 Mar 2018 10:12:09 -0800 (PST) Received: from localhost.localdomain ([196.71.216.221]) by smtp.gmail.com with ESMTPSA id w195sm78568wmw.9.2018.03.01.10.12.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 10:12:07 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 1 Mar 2018 18:11:42 +0000 Message-Id: <20180301181142.16817-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180301181142.16817-1-ard.biesheuvel@linaro.org> References: <20180301181142.16817-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 4/4] ArmPlatformPkg: add PL011 UART runtime debug driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eric.dong@intel.com, Ard Biesheuvel , leif.lindholm@linaro.org, heyi.guo@linaro.org, liming.gao@intel.com, michael.d.kinney@intel.com, lersek@redhat.com, star.zeng@intel.com MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Implement the new runtime debug output protocol on top of a PL011 UART. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c | 144 ++++++++++++++++++++ ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf | 62 +++++++++ 2 files changed, 206 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm Reviewed-by: Leif Lindholm diff --git a/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c new file mode 100644 index 000000000000..155b2c50d463 --- /dev/null +++ b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c @@ -0,0 +1,144 @@ +/** @file + Runtime driver to produce debug output on a PL011 UART + + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+ + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include +#include +#include +#include + +STATIC UINTN mUartBase; +STATIC EFI_EVENT mVirtualAddressChangeEvent; + +/** + Write data from buffer to debug output device + + Writes NumberOfBytes data bytes from Buffer to the debug output device. + The number of bytes actually written to the device is returned. + If the return value is less than NumberOfBytes, then the write operation + failed. + If NumberOfBytes is zero, then return 0. + + @param Buffer Pointer to the data buffer to be written. + @param NumberOfBytes Number of bytes to written to the device. + + @retval 0 NumberOfBytes is 0. + @retval >0 The number of bytes written to the serial device. + If this value is less than NumberOfBytes, then the + write operation failed. + +**/ +STATIC +UINTN +PL011RuntimeDebugOutputWrite ( + IN EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL *This, + IN UINT8 *Buffer, + IN UINTN NumberOfBytes + ) +{ + return PL011UartWrite (mUartBase, Buffer, NumberOfBytes); +} + +STATIC EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL mRuntimeDebugOutput = { + PL011RuntimeDebugOutputWrite +}; + +/** + Fixup internal data so that EFI can be called in virtual mode. + + @param[in] Event The Event that is being processed + @param[in] Context Event Context +**/ +STATIC +VOID +EFIAPI +VirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EfiConvertPointer (0x0, (VOID **)&mUartBase); +} + +EFI_STATUS +EFIAPI +PL011RuntimeDebugOutputDxeEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + UINT64 BaudRate; + UINT32 ReceiveFifoDepth; + EFI_PARITY_TYPE Parity; + UINT8 DataBits; + EFI_STOP_BITS_TYPE StopBits; + + mUartBase = (UINTN)FixedPcdGet64 (PcdSerialRegisterBase); + BaudRate = FixedPcdGet64 (PcdUartDefaultBaudRate); + ReceiveFifoDepth = 0; // Use default FIFO depth + Parity = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity); + DataBits = FixedPcdGet8 (PcdUartDefaultDataBits); + StopBits = (EFI_STOP_BITS_TYPE) FixedPcdGet8 (PcdUartDefaultStopBits); + + Status = PL011UartInitializePort (mUartBase, FixedPcdGet32 (PL011UartClkInHz), + &BaudRate, &ReceiveFifoDepth, &Parity, &DataBits, &StopBits); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Register for the virtual address change event + // + Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, + VirtualNotifyEvent, NULL, &gEfiEventVirtualAddressChangeGuid, + &mVirtualAddressChangeEvent); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Declare the UART MMIO region as EFI_MEMORY_RUNTIME + // + Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, mUartBase, + SIZE_4KB, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); + if (EFI_ERROR (Status)) { + goto CloseEvent; + } + + Status = gDS->SetMemorySpaceAttributes (mUartBase, SIZE_4KB, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); + if (EFI_ERROR (Status)) { + goto CloseEvent; + } + + Handle = NULL; + Status = gBS->InstallMultipleProtocolInterfaces (&Handle, + &gEdkiiRuntimeDebugOutputProtocolGuid, &mRuntimeDebugOutput, + NULL); + if (EFI_ERROR (Status)) { + goto CloseEvent; + } + + return EFI_SUCCESS; + +CloseEvent: + gBS->CloseEvent (mVirtualAddressChangeEvent); + + return Status; +} diff --git a/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf new file mode 100644 index 000000000000..28a8e514552e --- /dev/null +++ b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf @@ -0,0 +1,62 @@ +#/** @file +# Runtime driver to produce debug output on a PL011 UART +# +# Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+# +# This program and the accompanying materials are licensed and made available +# under the terms and conditions of the BSD License which accompanies this +# distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +#**/ + +[Defines] + INF_VERSION = 0x0001001A + BASE_NAME = PL011RuntimeDebugOutputDxe + FILE_GUID = 494297ca-9205-463a-aae5-215ffd067cbb + MODULE_TYPE = DXE_RUNTIME_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = PL011RuntimeDebugOutputDxeEntry + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = AARCH64 ARM +# + +[Sources.common] + PL011RuntimeDebugOutputDxe.c + +[Packages] + ArmPlatformPkg/ArmPlatformPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + DxeServicesTableLib + PcdLib + PL011UartLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiRuntimeLib + +[Guids] + gEfiEventVirtualAddressChangeGuid ## CONSUMES # Event + +[Protocols] + gEdkiiRuntimeDebugOutputProtocolGuid ## PROTOCOL ALWAYS_PRODUCED + +[FixedPcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits + gArmPlatformTokenSpaceGuid.PL011UartClkInHz + +[Depex] + TRUE