[PATCH v1 1/5] lib/string: Add memset_simple()

From
Stefan Roese <sr@denx.de>
Date
2021-08-06 13:38:55
Reply to
Stefan Roese, 2021-08-06
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
Thread (17 messages) 17 messages, 5 authors, last reply 2021-08-09
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help