From patchwork Fri Oct 27 18:26:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 159105 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp805052vqb; Fri, 27 Oct 2023 11:31:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE39SvVpe5HKZhFhrkxAlaPjN2fhLQ3mKajjHVka0H4cV6wGAehexwaCLbiXTDQ/R2Zh4Ii X-Received: by 2002:a05:6830:4d6:b0:6bd:93e:460b with SMTP id s22-20020a05683004d600b006bd093e460bmr3385185otd.19.1698431462670; Fri, 27 Oct 2023 11:31:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698431462; cv=none; d=google.com; s=arc-20160816; b=dVK+vftcTfgNtiN4GHkas0L7+VvDYGBAtIiIRRB00LJgv9A0B6UMs+IzlUZVolDVWK iEonUr09Tyl1LSkyx6JPOO4bHbvLTOF79oyNurM2RGKE2eGMiMf4VuW9G2rm2r1KoQ2+ QO05dNJGQsYUcTnc6HfnIy91ENN4iA8Iwooy2lvI5MS2WgQA8zS6/Z2mj/XGoNv7cp3S gOQZqgws1DssFZVHUVWobyiF/MnFFOL61GfkRnXHc4MFNfEVqHsQ1IZRii02QwhfSW1q mqvfqInb/78to9wlr8xfbb+7nblsYnB2q8MVuTz74QRJGJLDIrTgbrADs4dT/1LNInaH xGGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=DsEFHXOmV/vlMNorRiSfNz2hmb8DBQjO66z36QC0Uz4=; fh=2THP7SIVSTHYjaZ+qoFRou3s/8abGq7E8rX+Q6jzkpQ=; b=irTgSPDwA7LCCAZeiPpz48vPANaiozzIQ+w5OkK6mYezVwRpY4DuVdKa6b9KXeKzSb LQSAIGYbTynNjYLqiwEtPnjdz6riQCx8pC10BZ4kN90k8n3Rn9MW5dU8AQ+UlM4wnI0V AC+Hl1cowaJ1A9btLUu+fMgum/9tLX+OvFA4xGswDRRwAchABViArk+1Lk/PQUvIgX7J I4UlUB9/zlC83VLzmNyqtndq6g1bbslDoFeTnR8OsTyDhu0nhLZE49FkBiL4emtULdf4 +a6rEV3t8HhXDk2x0yUK1RH7kgMtssgo5of7RLLEYBJpqv/wc8OFOOAtz4rZtNqn3QLW MSBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=cDaSv6h3; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="f/pDHJyB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id z71-20020a0dd74a000000b005a7afbfc65csi3187515ywd.126.2023.10.27.11.31.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 11:31:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=cDaSv6h3; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="f/pDHJyB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id BD04F81C9A6A; Fri, 27 Oct 2023 11:30:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232781AbjJ0Sak (ORCPT + 25 others); Fri, 27 Oct 2023 14:30:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235227AbjJ0Sab (ORCPT ); Fri, 27 Oct 2023 14:30:31 -0400 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DF4B47AC; Fri, 27 Oct 2023 11:29:53 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id E047C3200928; Fri, 27 Oct 2023 14:27:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 27 Oct 2023 14:27:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1698431224; x= 1698517624; bh=DsEFHXOmV/vlMNorRiSfNz2hmb8DBQjO66z36QC0Uz4=; b=c DaSv6h34dyBQZGk4Q+R3dbVsKnW++9bGUVJ3l53Wu5LT3cW4gcV5DiRw5ia9zDnD r5nRbcsFpOSihlrtbp+Q4fDgsD+vhS2NkrLUIGw4KHlxOEL8yLObz0g8LZ3XOgtM 8aHjXrqb96quA4MLXTJO5cWdEYkYFxq0O/GNtQpVhbnl6f6+6e2vpeAaWPdhsvVD v9mfkv8QSiIqBC7sonZHwc8DrKXK3b48w9EmVNre7azIQfRkKUbCkaUD07aJVRnq 2jOxjiYh+gWkGoT+mvqx0VnSOdQTj+vCUdPGIgK0TteJinFcQ5Jy7zPkU5NFPUmW KLTPDkkU5E1rizYoMbLhA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1698431224; x= 1698517624; bh=DsEFHXOmV/vlMNorRiSfNz2hmb8DBQjO66z36QC0Uz4=; b=f /pDHJyBrHQhfKMoGWAE209vCCOy6IGMd7jbSc/HYt1N8E9itRb8z5paNtGxRA++0 Rmict7v2r2JSO/r55Iyn6GAUMY2NXsP1u81924Xi5M66Qo/AeQ3RIFG04mVAlkMy l3z2DWPioiVI2Mpmw9BjdIAndSIjsojv63zkCkQldAkQbW5DvofNJbqEndN5VyFf vjC0aeMAhaFngekVUPv1LehYzChkqFZTTjBGGgSo1lbWGC4s9rHsESR5CM8OovQ5 1XTQ9ZdHJgOMKbkG/Fw1GmV3Hqu+GjTowRJtBy0Akxv7yBI5IaSI/gVZcWPwYCda z7oOPDWM6BdgoI+EqEv9Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrleeggdduvdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghn ghesfhhlhihgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepfeeludefheegvdeuvd dvgeekgfdvtdettdelieeihfegtedugeekhfdvhfejfedtnecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Oct 2023 14:27:03 -0400 (EDT) From: Jiaxun Yang To: linux-mips@vger.kernel.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, tsbogend@alpha.franken.de, gregkh@linuxfoundation.org, jirislaby@kernel.org, Jiaxun Yang Subject: [PATCH 2/3] MIPS: zboot: Add UHI semihosting debug print support Date: Fri, 27 Oct 2023 19:26:45 +0100 Message-Id: <20231027182650.281405-3-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231027182650.281405-1-jiaxun.yang@flygoat.com> References: <20231027182650.281405-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 27 Oct 2023 11:30:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780934469488950861 X-GMAIL-MSGID: 1780934469488950861 Support print debug message via MIPS UHI semihosting Plog functions. Signed-off-by: Jiaxun Yang --- arch/mips/Kconfig.debug | 11 +++++++++++ arch/mips/boot/compressed/Makefile | 1 + arch/mips/boot/compressed/dbg-uhi.c | 11 +++++++++++ arch/mips/boot/compressed/dbg.c | 4 ++-- arch/mips/boot/compressed/decompress.c | 4 ++++ 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 arch/mips/boot/compressed/dbg-uhi.c diff --git a/arch/mips/Kconfig.debug b/arch/mips/Kconfig.debug index f4ae7900fcd3..1393bdb33f5c 100644 --- a/arch/mips/Kconfig.debug +++ b/arch/mips/Kconfig.debug @@ -98,6 +98,17 @@ config DEBUG_ZBOOT to reduce the kernel image size and speed up the booting procedure a little. +config ZBOOT_DBG_UHI + bool "Enable UHI debugging" + depends on DEBUG_ZBOOT + default n + help + Enable this option to debug compressed kernel support via UHI. + Logs will be outputed to the host machine via UHI Plog function. + You MUST connect system to a debugger with UHI semihosting support + or use a boot montor implemented UHI exceptions, otherwise the + system will hang. + config ZBOOT_INGENIC_UART int "UART to use for compressed kernel debugging" depends on DEBUG_ZBOOT && MACH_INGENIC_SOC diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile index 6cc28173bee8..5667597c3584 100644 --- a/arch/mips/boot/compressed/Makefile +++ b/arch/mips/boot/compressed/Makefile @@ -45,6 +45,7 @@ vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj)/bswaps ifdef CONFIG_DEBUG_ZBOOT vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o +vmlinuzobjs-$(CONFIG_ZBOOT_DBG_UHI) += $(obj)/dbg-uhi.o vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o diff --git a/arch/mips/boot/compressed/dbg-uhi.c b/arch/mips/boot/compressed/dbg-uhi.c new file mode 100644 index 000000000000..7daa8de717b0 --- /dev/null +++ b/arch/mips/boot/compressed/dbg-uhi.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * zboot debug output for MIPS UHI semihosting + */ + +#include + +void puts(const char *s) +{ + uhi_plog(s, 0); +} diff --git a/arch/mips/boot/compressed/dbg.c b/arch/mips/boot/compressed/dbg.c index f6728a8fd1c3..7fa5242e2b7d 100644 --- a/arch/mips/boot/compressed/dbg.c +++ b/arch/mips/boot/compressed/dbg.c @@ -4,7 +4,7 @@ * * NOTE: putc() is board specific, if your board have a 16550 compatible uart, * please select SYS_SUPPORTS_ZBOOT_UART16550 for your machine. othewise, you - * need to implement your own putc(). + * need to implement your own putc() or puts(). */ #include #include @@ -13,7 +13,7 @@ void __weak putc(char c) { } -void puts(const char *s) +void __weak puts(const char *s) { char c; while ((c = *s++) != '\0') { diff --git a/arch/mips/boot/compressed/decompress.c b/arch/mips/boot/compressed/decompress.c index c5dd415254d3..f4e69dfe2923 100644 --- a/arch/mips/boot/compressed/decompress.c +++ b/arch/mips/boot/compressed/decompress.c @@ -17,6 +17,7 @@ #include #include +#include #include /* @@ -46,6 +47,9 @@ void error(char *x) puts(x); puts("\n\n -- System halted"); +#ifdef CONFIG_ZBOOT_DBG_UHI + uhi_bootfailure(0); +#endif while (1) ; /* Halt */ }