diff options
author | Vivek Goyal <vgoyal@redhat.com> | 2014-03-18 15:26:37 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2014-03-19 18:43:45 -0400 |
commit | c041b5ad8640dd89ccf1411cd2636ef7c1cfee92 (patch) | |
tree | 43a8092f7ce876ee2b3f9d076b2d160f0f3e1fd5 /arch/x86/boot | |
parent | aad830938ed8ba175d8060751654f78d4115ea0a (diff) |
x86, boot: Create a separate string.h file to provide standard string functions
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>
Diffstat (limited to 'arch/x86/boot')
-rw-r--r-- | arch/x86/boot/boot.h | 5 | ||||
-rw-r--r-- | arch/x86/boot/cpucheck.c | 1 | ||||
-rw-r--r-- | arch/x86/boot/edd.c | 1 | ||||
-rw-r--r-- | arch/x86/boot/main.c | 1 | ||||
-rw-r--r-- | arch/x86/boot/regs.c | 1 | ||||
-rw-r--r-- | arch/x86/boot/string.h | 19 | ||||
-rw-r--r-- | arch/x86/boot/video-vesa.c | 1 |
7 files changed, 24 insertions, 5 deletions
diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h index 50f8c5e0f37e..bed9665cc7e0 100644 --- a/arch/x86/boot/boot.h +++ b/arch/x86/boot/boot.h | |||
@@ -228,11 +228,6 @@ void copy_to_fs(addr_t dst, void *src, size_t len); | |||
228 | void *copy_from_fs(void *dst, addr_t src, size_t len); | 228 | void *copy_from_fs(void *dst, addr_t src, size_t len); |
229 | void copy_to_gs(addr_t dst, void *src, size_t len); | 229 | void copy_to_gs(addr_t dst, void *src, size_t len); |
230 | void *copy_from_gs(void *dst, addr_t src, size_t len); | 230 | void *copy_from_gs(void *dst, addr_t src, size_t len); |
231 | void *memcpy(void *dst, void *src, size_t len); | ||
232 | void *memset(void *dst, int c, size_t len); | ||
233 | |||
234 | #define memcpy(d,s,l) __builtin_memcpy(d,s,l) | ||
235 | #define memset(d,c,l) __builtin_memset(d,c,l) | ||
236 | 231 | ||
237 | /* a20.c */ | 232 | /* a20.c */ |
238 | int enable_a20(void); | 233 | int enable_a20(void); |
diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c index 100a9a10076a..086c4f4ff741 100644 --- a/arch/x86/boot/cpucheck.c +++ b/arch/x86/boot/cpucheck.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <asm/processor-flags.h> | 27 | #include <asm/processor-flags.h> |
28 | #include <asm/required-features.h> | 28 | #include <asm/required-features.h> |
29 | #include <asm/msr-index.h> | 29 | #include <asm/msr-index.h> |
30 | #include "string.h" | ||
30 | 31 | ||
31 | static u32 err_flags[NCAPINTS]; | 32 | static u32 err_flags[NCAPINTS]; |
32 | 33 | ||
diff --git a/arch/x86/boot/edd.c b/arch/x86/boot/edd.c index c501a5b466f8..223e42527077 100644 --- a/arch/x86/boot/edd.c +++ b/arch/x86/boot/edd.c | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | #include "boot.h" | 16 | #include "boot.h" |
17 | #include <linux/edd.h> | 17 | #include <linux/edd.h> |
18 | #include "string.h" | ||
18 | 19 | ||
19 | #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE) | 20 | #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE) |
20 | 21 | ||
diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c index cf6083d444f4..fd6c9f236996 100644 --- a/arch/x86/boot/main.c +++ b/arch/x86/boot/main.c | |||
@@ -14,6 +14,7 @@ | |||
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include "boot.h" | 16 | #include "boot.h" |
17 | #include "string.h" | ||
17 | 18 | ||
18 | struct boot_params boot_params __attribute__((aligned(16))); | 19 | struct boot_params boot_params __attribute__((aligned(16))); |
19 | 20 | ||
diff --git a/arch/x86/boot/regs.c b/arch/x86/boot/regs.c index 958019b1cfa5..c0fb356a3092 100644 --- a/arch/x86/boot/regs.c +++ b/arch/x86/boot/regs.c | |||
@@ -17,6 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include "boot.h" | 19 | #include "boot.h" |
20 | #include "string.h" | ||
20 | 21 | ||
21 | void initregs(struct biosregs *reg) | 22 | void initregs(struct biosregs *reg) |
22 | { | 23 | { |
diff --git a/arch/x86/boot/string.h b/arch/x86/boot/string.h new file mode 100644 index 000000000000..10939d8da2e0 --- /dev/null +++ b/arch/x86/boot/string.h | |||
@@ -0,0 +1,19 @@ | |||
1 | #ifndef BOOT_STRING_H | ||
2 | #define BOOT_STRING_H | ||
3 | |||
4 | /* Undef any of these macros coming from string_32.h. */ | ||
5 | #undef memcpy | ||
6 | #undef memset | ||
7 | #undef memcmp | ||
8 | |||
9 | void *memcpy(void *dst, const void *src, size_t len); | ||
10 | void *memset(void *dst, int c, size_t len); | ||
11 | |||
12 | /* | ||
13 | * Access builtin version by default. If one needs to use optimized version, | ||
14 | * do "undef memcpy" in .c file and link against right string.c | ||
15 | */ | ||
16 | #define memcpy(d,s,l) __builtin_memcpy(d,s,l) | ||
17 | #define memset(d,c,l) __builtin_memset(d,c,l) | ||
18 | |||
19 | #endif /* BOOT_STRING_H */ | ||
diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c index 11e8c6eb80a1..ba3e100654db 100644 --- a/arch/x86/boot/video-vesa.c +++ b/arch/x86/boot/video-vesa.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include "boot.h" | 16 | #include "boot.h" |
17 | #include "video.h" | 17 | #include "video.h" |
18 | #include "vesa.h" | 18 | #include "vesa.h" |
19 | #include "string.h" | ||
19 | 20 | ||
20 | /* VESA information */ | 21 | /* VESA information */ |
21 | static struct vesa_general_info vginfo; | 22 | static struct vesa_general_info vginfo; |