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::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-Google-Smtp-Source: ALg8bN6+l1TtqGDy+oGErDrXtt1vf4BnE6vYuHw1IM9l+xP8GQ45n4kZA8eNOp2CcqIu3ssnoQdPAQ== 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 Cc: leif.lindholm@linaro.org, lersek@redhat.com, Ard Biesheuvel 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: [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: , X-List-Received-Date: Tue, 15 Jan 2019 08:23:57 -0000 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(-) 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 -- 2.17.1