From patchwork Mon Aug 12 10:15:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 13760399 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F3BDCC52D7C for ; Mon, 12 Aug 2024 10:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=S7o4Rl2UIW86+gFsCLnt0xYqFAQn1m2xa6u2qiZlsLc=; b=V9Tw2Hv9R1VbQkTCwKJngrqBI5 50TnTSNU6fFNjN5do6CDZz1ChecgtlzqBCJjsm06gOjX4ugrPdlqzecv+aCVs42ypyaSOAIzAuu+w qnD0WiWIddUoVRsTCmufOrHPOb5sUfQf1d2Vx37UuM9UKvC5qpaHywCW9MCRUCJuGKvoNBfAndo+M yeXsaPUb/Mnm9AbBzqJS7fm7B6NlV1j0u3tU0cKuRVy/uFFuv1YsDo4rUPrdvGsK3wuNaT+aMxOSm uBjOX19parhOJgbh7tbabwfF6Lxxn3fZt0ZwaEfnOm85qUfCR8vCqPC6pQH6Z+gDBavCOJSvROHZn NyWNos3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdSC0-0000000Has3-01aN; Mon, 12 Aug 2024 10:22:24 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdS62-0000000HZjK-0LsE for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 10:16:15 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C4750FEC; Mon, 12 Aug 2024 03:16:39 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1427D3F6A8; Mon, 12 Aug 2024 03:16:12 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: akos.denke@arm.com, andre.przywara@arm.com, luca.fancellu@arm.com, mark.rutland@arm.com, maz@kernel.org Subject: [BOOT-WRAPPER v2 09/10] Add printing functions Date: Mon, 12 Aug 2024 11:15:54 +0100 Message-Id: <20240812101555.3558589-10-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240812101555.3558589-1-mark.rutland@arm.com> References: <20240812101555.3558589-1-mark.rutland@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_031614_194429_46A8D2B5 X-CRM114-Status: GOOD ( 10.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In subsequent patches we'll want to log messages from specific CPUs. Add helpers to make this simpler. Signed-off-by: Mark Rutland Acked-by: Marc Zyngier Cc: Akos Denke Cc: Andre Przywara Cc: Luca Fancellu Reviewed-by: Andre Przywara --- common/platform.c | 35 +++++++++++++++++++++++++++++++++++ include/platform.h | 4 ++++ 2 files changed, 39 insertions(+) diff --git a/common/platform.c b/common/platform.c index 1607ee6..4e390e1 100644 --- a/common/platform.c +++ b/common/platform.c @@ -65,6 +65,41 @@ void print_ulong_hex(unsigned long val) } } +// 2^32 is 4,294,967,296 +#define DEC_CHARS_PER_UINT 10 + +void print_uint_dec(unsigned int val) +{ + char digits[DEC_CHARS_PER_UINT]; + int d = 0; + + do { + digits[d] = val % 10; + val /= 10; + d++; + } while (val); + + while (d--) { + print_char('0' + digits[d]); + } +} + +void print_cpu_warn(unsigned int cpu, const char *str) +{ + print_string("CPU"); + print_uint_dec(cpu); + print_string(" WARNING: "); + print_string(str); +} + +void print_cpu_msg(unsigned int cpu, const char *str) +{ + print_string("CPU"); + print_uint_dec(cpu); + print_string(": "); + print_string(str); +} + void init_uart(void) { /* diff --git a/include/platform.h b/include/platform.h index c88e124..09712b1 100644 --- a/include/platform.h +++ b/include/platform.h @@ -12,6 +12,10 @@ void print_char(char c); void print_string(const char *str); void print_ulong_hex(unsigned long val); +void print_uint_dec(unsigned int val); + +void print_cpu_warn(unsigned int cpu, const char *str); +void print_cpu_msg(unsigned int cpu, const char *str); void init_uart(void);