From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AFSGD/X2KyrtsBVOitnXTe3T8zIZOrY5pDXD8IH17iz/U3Tsax4hWlh7dTCiGuCoYx/COKfKwDEDfQ== 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 Cc: leif.lindholm@linaro.org, philmd@redhat.com, lersek@redhat.com, Ard Biesheuvel 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: [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: , X-List-Received-Date: Thu, 20 Dec 2018 17:31:16 -0000 Content-Transfer-Encoding: 8bit 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(-) 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 -- 2.19.2