From mboxrd@z Thu Jan 1 00:00:00 1970 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 2E7A5C52D7C for ; Wed, 21 Aug 2024 16:57:11 +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: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TDEB1FKAM2Y8YE7SLS2ScLrjTEbs5qdDi8pbOmdEgFs=; b=4Du/Gm5G8+bTuKObr8iQfk42S6 ILS4CqizeE6i1XqB4KUrTxaqJAbKx2RbgMIus/+2jnzV4gExVqygDBggnin4tIfFbZAP7UhSpud93 D9zSvPP+mWvRmFvZq2J7yHz8EgBwvHTUIZo36+89J5328I0FBTHOWDAkcSOgOOiIiTqu8m6j+R/PE zJq16YPcq688ahl2GjDEtUJB3A1Dgwe+8LpsZLkbEKARnmoYCcUZaHbdc0vLNBjEjofVmnEb5UsAw rtCN//Q6IF6YeeJkKaiTzd7SZXyYDrFrFGjVrpY3meMBthdTX7E0q374SkEj6Rxwm3tlZsPv9u9bY JUg6J8MQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgodn-00000009pqh-2Ynl; Wed, 21 Aug 2024 16:56:59 +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 1sgocT-00000009pXP-3v8v for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 16:55:39 +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 38FBADA7; Wed, 21 Aug 2024 09:56:03 -0700 (PDT) Received: from donnerap.manchester.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3BF913F66E; Wed, 21 Aug 2024 09:55:36 -0700 (PDT) Date: Wed, 21 Aug 2024 17:55:33 +0100 From: Andre Przywara To: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, akos.denke@arm.com, luca.fancellu@arm.com, maz@kernel.org Subject: Re: [BOOT-WRAPPER v2 09/10] Add printing functions Message-ID: <20240821175533.4d3f9954@donnerap.manchester.arm.com> In-Reply-To: <20240812101555.3558589-10-mark.rutland@arm.com> References: <20240812101555.3558589-1-mark.rutland@arm.com> <20240812101555.3558589-10-mark.rutland@arm.com> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_095538_060977_A848CEBA X-CRM114-Status: GOOD ( 16.94 ) 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 On Mon, 12 Aug 2024 11:15:54 +0100 Mark Rutland wrote: Hi, > 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 Cheers, Andre > --- > 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); >