From patchwork Tue Jan 15 08:23:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155642 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4610561jaa; Tue, 15 Jan 2019 00:24:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN6W92MmFEY0qmLJOp6/QlHylffdB2o4Pwa3b0VzxCGVBpn7xd9car7E8JW/L+Hieqr1vDB6 X-Received: by 2002:a17:902:2868:: with SMTP id e95mr2833603plb.317.1547540648032; Tue, 15 Jan 2019 00:24:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547540648; cv=none; d=google.com; s=arc-20160816; b=h7c4bISv/XGFzfQJkVptughp0mRbtj5SxcDfx4ybntl705TDDdB2Wg3f0ANnc3SaKJ RH/9MY1/IMT/hSleMhXvvpjWWATAXik7lyIkya0UMaJjpska0XrvW+QEeKLIFyfXWH3t nMqcItkky+Ee6Lmir4vbaAGC7UQ6/P/gI84tjhuJSBJGRYHnstVQt277ZqakR/h6+szj ZTCA2NB+gPcTqkWWg5fL4uKy0bvLB+5lnjCkXA9DRL16xGeDntlGlmY+4sIP3cY8JLkV NS68d0KthhFcnt0FBFnm1+bFrJ6eZX0T2QOLEGtzV2h4pC2143enVgESp8Hifh3ICxqm aUzA== 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; bh=SLe6HRXOWnculvGTjywzr3cj3Sa3e8qKF7EHx5j/o7w=; b=eZz8jFt18PhXvr/53JJZb9MopZlsMLK8rbxchDEIqiQNASv5VGVFpSmMn1hc9gCEPD 6X4+EtqDspnEtM0Jf3zcYl5ONKa/eExBBrkd6ot/6MsCAsF//f6vLOni5dlY2mBJJWut E8ZOa529rkQlyZIT/qc4UfQiXE6lWufZ3PcMRJ2rl6xTKgT0HN1V/DAjM2pEfKwG0loK QrysVRyga9zoPCvb0bemXwmK8pU9Nt9pruRk63BjB8XT5A+mB2mz4c39sMPExILI7wI0 nbD2SlGAGRff1cB8vut262kCNxvxoo0e4keVWLxJ8mjYlX245+aUoBVugFkF7VnTqa5N S6kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=dqDFbgFq; 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 37si2800417pgw.590.2019.01.15.00.24.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 00:24:08 -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=dqDFbgFq; 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 D6BA7211B76BD; Tue, 15 Jan 2019 00:23:58 -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:4864:20::341; helo=mail-wm1-x341.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (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 7DC74211B76A7 for ; Tue, 15 Jan 2019 00:23:57 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id d15so2308446wmb.3 for ; Tue, 15 Jan 2019 00:23:57 -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=YiypyNMMmOSf8bB5ZyIMVodp+7p6fxpofMHLnAaOZ3c=; b=dqDFbgFqKMWr4m7FyH+S6NJ+igd2DLUM28/idDAKzV4NbxiWcAxh5ojdGFI7Zk/q/j YEuC0y8sn77razcELu6t4Y7m6Dk5x0BELdIbGlpJF6y94ocVNWOGwsg+rVjpU8ERgUAA Zf6e21dXiNmKtGjL+GdxAnItH+dALvY+eonC8= 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=YiypyNMMmOSf8bB5ZyIMVodp+7p6fxpofMHLnAaOZ3c=; b=Kf3KNPV65sOAX9UigbR9GG0QGngt5WuHc6Um0s+KjZ842WgYCS5sc4g6JeF1swYOb1 YJyJckW4t9eik0I7/16bZWceQ8JBgbaySndzEP563esWFz0TgPOZg4awHgcyaVCspii0 zBwgFpcI4kGYP53q+Lkq6jgAeLnc4rFG7QAWgFMWsrsYDuzEALv75eM67h6CQAdRJ4f6 Hvqq0N4qbiaX5lcx4nDclwJCnG9t77GBe+zmBnySXpIFRhkXoNJcJHA7Yc9qBYbPOqDP xPFpyTSMUej0MTbU61buWys9Kx0KJtGu5Y7uVAwm0jnBtSPImto0UZzP2ELM3/i3O27W JLmQ== X-Gm-Message-State: AJcUukcLcTZlicam+OFO7Tofe2RvugLK7DBq3Cc6QVa1BvzfXuH17RI1 0aYcTfzV1jIupZiiiCNYAQmqMEn5JxKy5w== X-Received: by 2002:a1c:b687:: with SMTP id g129mr2265181wmf.59.1547540635649; Tue, 15 Jan 2019 00:23:55 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:c8d1:b905:1bdd:adb6]) by smtp.gmail.com with ESMTPSA id 67sm120697983wra.37.2019.01.15.00.23.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 00:23:54 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Tue, 15 Jan 2019 09:23:45 +0100 Message-Id: <20190115082345.3711-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190115082345.3711-1-ard.biesheuvel@linaro.org> References: <20190115082345.3711-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 5/5] ArmPkg/DefaultExceptionHandlerLib: use console if available X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lersek@redhat.com MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Print the minimal 'exception occurred' message to the console instead of straight to the serial port if the console is available. This makes such messages visible on systems where the console is graphical and the serial is not connected. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c | 12 ++++++++++-- ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c | 7 ++++++- ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Acked-by: Laszlo Ersek diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c index 1024bf48c63d..362acd5ba6d2 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -159,14 +160,21 @@ DefaultExceptionHandler ( INT32 Offset; if (mRecursiveException) { - CharCount = AsciiSPrint (Buffer, sizeof (Buffer),"\nRecursive exception occurred while dumping the CPU state\n"); - SerialPortWrite ((UINT8 *) Buffer, CharCount); + STATIC CHAR8 CONST Message[] = "\nRecursive exception occurred while dumping the CPU state\n"; + + SerialPortWrite ((UINT8 *)Message, AsciiStrLen (Message)); + if (gST->ConOut != NULL) { + AsciiPrint (Message); + } CpuDeadLoop (); } mRecursiveException = TRUE; CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n\n%a Exception at 0x%016lx\n", gExceptionTypeString[ExceptionType], SystemContext.SystemContextAArch64->ELR); SerialPortWrite ((UINT8 *) Buffer, CharCount); + if (gST->ConOut != NULL) { + AsciiPrint (Buffer); + } DEBUG_CODE_BEGIN (); CHAR8 *Pdb, *PrevPdb; diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c index cc79cb2fa301..a79f73725aed 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -194,7 +195,11 @@ DefaultExceptionHandler ( CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n%a Exception PC at 0x%08x CPSR 0x%08x ", gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR); - SerialPortWrite ((UINT8 *) Buffer, CharCount); + if (gST->ConOut != NULL) { + AsciiPrint (Buffer); + } else { + SerialPortWrite ((UINT8 *)Buffer, CharCount); + } DEBUG_CODE_BEGIN (); CHAR8 *Pdb; diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf index 7609f82d89a1..6bc48714c9dc 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf @@ -42,6 +42,7 @@ [LibraryClasses] PeCoffGetEntryPointLib ArmDisassemblerLib SerialPortLib + UefiBootServicesTableLib [Guids] gEfiDebugImageInfoTableGuid