From patchwork Thu Aug 22 10:14:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 13773185 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 1082AC3DA4A for ; Thu, 22 Aug 2024 10:19:41 +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=mu1K4LtF9KFwDSofjzztzX4U9vs/cat89j9UMFIG0Y0=; b=MXNjrk1WSVIEt2kvwY35jR+v/X ohG0Glm93RFUnzdrt9CUtkRn7zjJkpVKTuv815y9ba+BlimkPiz89IIuf+qr5+wW+So6szf21kpUF Sq39GBAJvhUdlBVyTCEvGmZza9zvxBpWxfqPqrEN5RdObHZPb3nA3nXffHsp6l5jO13Y4dEhhr3IU 63IxBihz/BOp9Sh11lcR8nhwGBwkl3W1hJhYvTShDplEQb9GdY3aGs7quvCMY5y1U0HzWsVPSah5H RYlGWjVpcqpVxl2GgOpusQRcybO1fEksm2UEgYAv9OYtsmYCuhoOslvB4+X7d0ul/71GiHag8smC5 d8Dtzsug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sh4ue-0000000COue-23ep; Thu, 22 Aug 2024 10:19:28 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sh4qj-0000000COK4-3pJ7 for linux-arm-kernel@bombadil.infradead.org; Thu, 22 Aug 2024 10:15:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=mu1K4LtF9KFwDSofjzztzX4U9vs/cat89j9UMFIG0Y0=; b=nFqYVj0RIrjH3of9BAmhnwRT/5 ngTFQZNg2aSRBYr02aRA+wh+6Tn2LWJDcscYgJwYiJotHtyPd8lf8Aaury6n/w19Wkwa+P4NlKIGo p7Zw+HhiTJSk69vwE/3MuWVc1HoSp2mQxOhzZjTamuXquYMa8yvCf9vGsInT5yeF4BxZN2Et2Z0Z0 bJgZgHuVbagpO91pr+hReSfAriJO2EMJcWAnY2dS6lvYMjXYWGsOPtubx/KnKALOKIkJbUMPjpkfC BhKsneWQsPbOQzW6giRA0AxxG75vH6UnfY6Q7L6knJsb6/5ooe8SmfMePPXHnueVPHRXKLE2GdXoT hs0VCMgw==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sh4qg-00000009u5m-0Q4m for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 10:15:24 +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 8BA7F1596; Thu, 22 Aug 2024 03:15:46 -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 2356A3F66E; Thu, 22 Aug 2024 03:15:18 -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 v3 09/10] Add printing functions Date: Thu, 22 Aug 2024 11:14:40 +0100 Message-Id: <20240822101441.251184-10-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240822101441.251184-1-mark.rutland@arm.com> References: <20240822101441.251184-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-20240822_111522_472278_F54CC595 X-CRM114-Status: UNSURE ( 9.86 ) X-CRM114-Notice: Please train this message. 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 Reviewed-by: Andre Przywara Cc: Akos Denke Cc: Luca Fancellu --- 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);