]> git.karo-electronics.de Git - linux-beck.git/commitdiff
x86, boot: Create a separate string.h file to provide standard string functions
authorVivek Goyal <vgoyal@redhat.com>
Tue, 18 Mar 2014 19:26:37 +0000 (15:26 -0400)
committerH. Peter Anvin <hpa@linux.intel.com>
Wed, 19 Mar 2014 22:43:45 +0000 (15:43 -0700)
Create a separate arch/x86/boot/string.h file to provide declaration of
some of the common string functions.

By default memcpy, memset and memcmp functions will default to gcc
builtin functions. If code wants to use an optimized version of any
of these functions, they need to #undef the respective macro and link
against a local file providing definition of undefed function.

For example, arch/x86/boot/* code links against copy.S to get memcpy()
and memcmp() definitions. arch/86/boot/compressed/* links against
compressed/string.c.

There are quite a few places in arch/x86/ where these functions are
used. Idea is to try to consilidate  their declaration and possibly
definitions so that it can be reused.

I am planning to reuse boot/string.h in arch/x86/purgatory/ and use
gcc builtin functions for memcpy, memset and memcmp.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Link: http://lkml.kernel.org/r/1395170800-11059-3-git-send-email-vgoyal@redhat.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
arch/x86/boot/boot.h
arch/x86/boot/cpucheck.c
arch/x86/boot/edd.c
arch/x86/boot/main.c
arch/x86/boot/regs.c
arch/x86/boot/string.h [new file with mode: 0644]
arch/x86/boot/video-vesa.c

index 50f8c5e0f37e1d2dd7030da9d72c5be21e2ee282..bed9665cc7e0a9370fc502d2b69ccebda6b66c03 100644 (file)
@@ -228,11 +228,6 @@ void copy_to_fs(addr_t dst, void *src, size_t len);
 void *copy_from_fs(void *dst, addr_t src, size_t len);
 void copy_to_gs(addr_t dst, void *src, size_t len);
 void *copy_from_gs(void *dst, addr_t src, size_t len);
-void *memcpy(void *dst, void *src, size_t len);
-void *memset(void *dst, int c, size_t len);
-
-#define memcpy(d,s,l) __builtin_memcpy(d,s,l)
-#define memset(d,c,l) __builtin_memset(d,c,l)
 
 /* a20.c */
 int enable_a20(void);
index 100a9a10076a649e7e7008a3579867391ca16fa4..086c4f4ff741b32f9178db05e95588de60bd6127 100644 (file)
@@ -27,6 +27,7 @@
 #include <asm/processor-flags.h>
 #include <asm/required-features.h>
 #include <asm/msr-index.h>
+#include "string.h"
 
 static u32 err_flags[NCAPINTS];
 
index c501a5b466f8495c26d3eff4de1cddb97613fca4..223e42527077d26c818d7e0ec7259d98717dbd61 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "boot.h"
 #include <linux/edd.h>
+#include "string.h"
 
 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
 
index cf6083d444f4710ff79b8f41b2cdc65113c83eb0..fd6c9f236996d8c8dac84d6a14120804b13ae3fd 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include "boot.h"
+#include "string.h"
 
 struct boot_params boot_params __attribute__((aligned(16)));
 
index 958019b1cfa5b42b11f9863b644e8d21eb96df5d..c0fb356a3092e55f9f70aba1eea1bd8db74d77ae 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include "boot.h"
+#include "string.h"
 
 void initregs(struct biosregs *reg)
 {
diff --git a/arch/x86/boot/string.h b/arch/x86/boot/string.h
new file mode 100644 (file)
index 0000000..10939d8
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef BOOT_STRING_H
+#define BOOT_STRING_H
+
+/* Undef any of these macros coming from string_32.h. */
+#undef memcpy
+#undef memset
+#undef memcmp
+
+void *memcpy(void *dst, const void *src, size_t len);
+void *memset(void *dst, int c, size_t len);
+
+/*
+ * Access builtin version by default. If one needs to use optimized version,
+ * do "undef memcpy" in .c file and link against right string.c
+ */
+#define memcpy(d,s,l) __builtin_memcpy(d,s,l)
+#define memset(d,c,l) __builtin_memset(d,c,l)
+
+#endif /* BOOT_STRING_H */
index 11e8c6eb80a1014b4f0df92d15ccca32d29c6625..ba3e100654db0239622a3f23f5d9d64855ebffd0 100644 (file)
@@ -16,6 +16,7 @@
 #include "boot.h"
 #include "video.h"
 #include "vesa.h"
+#include "string.h"
 
 /* VESA information */
 static struct vesa_general_info vginfo;