From patchwork Thu Dec 20 17:31:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 154352 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6456824ljp; Thu, 20 Dec 2018 09:31:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/WOX2T+H6UH7r77zaNxBZ9Fb6RUBh0PMRIFDNhBsWTBGHIkS3heJ+SGYt6r7EB6h6O4igJD X-Received: by 2002:a62:1e87:: with SMTP id e129mr24943059pfe.221.1545327084098; Thu, 20 Dec 2018 09:31:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545327084; cv=none; d=google.com; s=arc-20160816; b=Yxh+h3HslHJKKbMQFL1LUzseh/lJJ4pJaPRoDbjXApVNnr4JEwepmGuDEgfjbsfF4m J/WRZyO995JM99AFinn6bUmUKiXDBkUWFXTyWyRK22PVoHp4l/OGXaej4p4vNIknJ3Qn s5DmDzdqM+0BsR75t1K9qNOvneM1KxNJH8qeW7AsV4k75g/41elZDnBTzl58pBJe0ewE ATrOsNgUu2VFXxSovm5gPQW/r8+uhdAC/6qXCDYPQhQYMA2bwwhmoRSIzp2/qOOvAmqq LpzzdqOqtq0oI0WqPAHEAqPETzf1igEQp9i2/gmwB+B+biNsx7nrLryLNLeg3AS6epHe vQkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=U2/L0pfjx9V72MGxM+zqLuIcPyVWMr57bX0XqY9YGQw=; b=GmgV1dAa5209YbxR304uwVua0E+0snRfXHDzNEuHxRZopoBEZrqH+zOaCzaZDDU+iO Yd7xzikg+rlcTj9avUrF90/vZ3zMFSKJlkndsBYYtm1c6GNosjtQMHt/LzJK17Cf18qD tdCo8iKgaZQ/wkhMsslN86DVlx4etbMGumiG1IUy7LUAC0udkNYldl7PB/83CUWEA3aB EIjXLMt/5uP+ejnpaQ+r0aietieJiUv2xaKn2XQ8e3RX1342GhWoRpBLkPfOnvAw3HJo XNszHBz8Q0jOU8fHTCrsNCzWbyTykhTvnlijFZ3aWW98ynprNfSj7ljw/vZXollTij+7 NCaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZKdAa1JH; 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 p4si16900972pga.514.2018.12.20.09.31.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 09:31:24 -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=ZKdAa1JH; 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 9A2F1211A4592; Thu, 20 Dec 2018 09:31:17 -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::343; helo=mail-wm1-x343.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (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 D8459211A458F for ; Thu, 20 Dec 2018 09:31:15 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id y139so2859528wmc.5 for ; Thu, 20 Dec 2018 09:31:15 -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 :mime-version:content-transfer-encoding; bh=ZNleVR4l2uNP6RGv5dyG8m7SUyZ3p/kOKp2WRg8cqpk=; b=ZKdAa1JH7oJAFUet/eqcNsVzzV5i3UP8Sekz7kAjBAAlVovQwfAAtAgmIop/atitG3 rP3Mp1YEJnWtjBcyLCTTBIYNozMJOhphhOHLBMwleXS60ckm+gLrkmmv3ZNQx86Zm28t wQqdXsfidIjBwzLqgkzR9mhsxUksCBPC/F0m0= 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:mime-version:content-transfer-encoding; bh=ZNleVR4l2uNP6RGv5dyG8m7SUyZ3p/kOKp2WRg8cqpk=; b=eYd7X5aeZOFKFwPvCyjQC0sdiYGeZ6mYerNSD0wEBu1zMr3WbWYHB3rPljcQhGHw63 06Ma6lCV2Mw62jWtwuHZJ1aIMCcCOXOkchQqzcOIjePH9c0L4bfWQmfj2ucbQ4D3cSOO JuxGu53tMHw9gmt1vuw6uKosAhkhHvPRnarl/EXbfSI/CM3UMJUUn5MrX7QabNDvPUA3 y65zKpWmGyxveW19V/a/fbRgLy+VSowP08Aeu2AD+5M/hV1wyOAmSFH+rMhhdmEBeQRv m50RoQjajYAbNMSjfsQUnuQj+8rDQZuH58HVvlw98o27OKt3I5GwLKcxiBeonkouvjFM pelA== X-Gm-Message-State: AA+aEWbMKm4FTVL9aszTjMb89QHULy03tyJF/24QiOKFxOh1VKmEKg4T 3Wv7VLzwHFKhCAcW5J+1vg8XJTVaARxKCA== X-Received: by 2002:a1c:35ca:: with SMTP id c193mr12203960wma.146.1545327074110; Thu, 20 Dec 2018 09:31:14 -0800 (PST) Received: from localhost.localdomain (aputeaux-683-1-2-211.w90-86.abo.wanadoo.fr. [90.86.101.211]) by smtp.gmail.com with ESMTPSA id x12sm6826131wrt.20.2018.12.20.09.31.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 09:31:13 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 20 Dec 2018 18:31:04 +0100 Message-Id: <20181220173104.11481-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181220173104.11481-1-ard.biesheuvel@linaro.org> References: <20181220173104.11481-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH 4/4] 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 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 --- ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c | 16 +++++++++++++--- ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c | 7 ++++++- ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf | 1 + 3 files changed, 20 insertions(+), 4 deletions(-) -- 2.19.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c index 1024bf48c63d..1aaf3c88f21e 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,23 @@ 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"; + + if (gST->ConOut != NULL) { + AsciiPrint (Message); + } else { + SerialPortWrite ((UINT8 *)Message, AsciiStrLen (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); + } else { + SerialPortWrite ((UINT8 *)Buffer, CharCount); + } DEBUG_CODE_BEGIN (); CHAR8 *Pdb, *PrevPdb; diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c index 0b9da031b47d..9159b579da6f 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 @@ PeCoffGetEntryPointLib ArmDisassemblerLib SerialPortLib + UefiBootServicesTableLib [Guids] gEfiDebugImageInfoTableGuid