public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Cc: sjg@chromium.org, trini@konsulko.com
Subject: [PATCH v1 1/5] lib/string: Add memset_simple()
Date: Fri,  6 Aug 2021 15:38:39 +0200	[thread overview]
Message-ID: <20210806133843.3642916-2-sr@denx.de> (raw)
In-Reply-To: <20210806133843.3642916-1-sr@denx.de>

The optimized memset() ARM64 implementation cannot be used very early
on, since caches need to be enabled for this function to work. Otherwise
an exception occurs (only printed with very early DEBUG_UART enabled).

This patch now implements a very simple memset() version, which will be
used in a few selected places in the ARM64 early boot process.

Signed-off-by: Stefan Roese <sr@denx.de>
---

 include/linux/string.h |  2 ++
 lib/string.c           | 10 ++++++++++
 2 files changed, 12 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index dd255f21633a..0ab1c557da3d 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -129,6 +129,8 @@ extern void * memchr(const void *,int,__kernel_size_t);
 void *memchr_inv(const void *, int, size_t);
 #endif
 
+void *memset_simple(void *s, int c, size_t count);
+
 unsigned long ustrtoul(const char *cp, char **endp, unsigned int base);
 unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base);
 
diff --git a/lib/string.c b/lib/string.c
index ba176fb08f73..7092181f831f 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -543,6 +543,16 @@ __used void * memset(void * s,int c,size_t count)
 }
 #endif
 
+void *memset_simple(void *s, int c, size_t count)
+{
+	char *s8 = (char *)s;
+
+	while (count--)
+		*s8++ = c;
+
+	return s;
+}
+
 #ifndef __HAVE_ARCH_MEMCPY
 /**
  * memcpy - Copy one area of memory to another
-- 
2.32.0


  reply	other threads:[~2021-08-06 13:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-06 13:38 [PATCH v1 0/5] arm64: Add optimized memset/memcpy functions Stefan Roese
2021-08-06 13:38 ` Stefan Roese [this message]
2021-08-06 15:36   ` [PATCH v1 1/5] lib/string: Add memset_simple() Wolfgang Denk
2021-08-06 16:13     ` Heinrich Schuchardt
2021-08-07 15:18       ` Wolfgang Denk
2021-08-07 15:34         ` Tom Rini
2021-08-06 13:38 ` [PATCH v1 2/5] board_init: Use memset_simple() in board_init_f_init_reserve() Stefan Roese
2021-08-09  7:52   ` Rasmus Villemoes
2021-08-09 13:17     ` Stefan Roese
2021-08-06 13:38 ` [PATCH v1 3/5] arm64: cache_v8: Use memset_simple() in create_table() Stefan Roese
2021-08-06 13:38 ` [PATCH v1 4/5] arm64: arch/arm/lib: Add optimized memset/memcpy functions Stefan Roese
2021-08-06 14:43   ` Tom Rini
2021-08-06 14:45     ` Stefan Roese
2021-08-06 15:41   ` Wolfgang Denk
2021-08-06 13:38 ` [PATCH v1 5/5] arm64: Kconfig: Enable usage of optimized memset/memcpy Stefan Roese
2021-08-06 14:24 ` [PATCH v1 0/5] arm64: Add optimized memset/memcpy functions Tom Rini
2021-08-06 14:44   ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210806133843.3642916-2-sr@denx.de \
    --to=sr@denx.de \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox