diff options
Diffstat (limited to 'arch/x86/boot')
-rw-r--r-- | arch/x86/boot/boot.h | 13 | ||||
-rw-r--r-- | arch/x86/boot/compressed/misc.c | 51 | ||||
-rw-r--r-- | arch/x86/boot/compressed/string.c | 46 | ||||
-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.c | 14 | ||||
-rw-r--r-- | arch/x86/boot/string.h | 21 | ||||
-rw-r--r-- | arch/x86/boot/video-vesa.c | 1 |
10 files changed, 88 insertions, 62 deletions
diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h index 50f8c5e0f37e..bd49ec61255c 100644 --- a/arch/x86/boot/boot.h +++ b/arch/x86/boot/boot.h | |||
@@ -177,14 +177,6 @@ static inline void wrgs32(u32 v, addr_t addr) | |||
177 | } | 177 | } |
178 | 178 | ||
179 | /* Note: these only return true/false, not a signed return value! */ | 179 | /* Note: these only return true/false, not a signed return value! */ |
180 | static inline int memcmp(const void *s1, const void *s2, size_t len) | ||
181 | { | ||
182 | u8 diff; | ||
183 | asm("repe; cmpsb; setnz %0" | ||
184 | : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len)); | ||
185 | return diff; | ||
186 | } | ||
187 | |||
188 | static inline int memcmp_fs(const void *s1, addr_t s2, size_t len) | 180 | static inline int memcmp_fs(const void *s1, addr_t s2, size_t len) |
189 | { | 181 | { |
190 | u8 diff; | 182 | u8 diff; |
@@ -228,11 +220,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); | 220 | 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); | 221 | 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); | 222 | 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 | 223 | ||
237 | /* a20.c */ | 224 | /* a20.c */ |
238 | int enable_a20(void); | 225 | int enable_a20(void); |
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index 196eaf373a06..17684615374b 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c | |||
@@ -10,6 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include "misc.h" | 12 | #include "misc.h" |
13 | #include "../string.h" | ||
13 | 14 | ||
14 | /* WARNING!! | 15 | /* WARNING!! |
15 | * This code is compiled with -fPIC and it is relocated dynamically | 16 | * This code is compiled with -fPIC and it is relocated dynamically |
@@ -97,8 +98,14 @@ | |||
97 | */ | 98 | */ |
98 | #define STATIC static | 99 | #define STATIC static |
99 | 100 | ||
100 | #undef memset | ||
101 | #undef memcpy | 101 | #undef memcpy |
102 | |||
103 | /* | ||
104 | * Use a normal definition of memset() from string.c. There are already | ||
105 | * included header files which expect a definition of memset() and by | ||
106 | * the time we define memset macro, it is too late. | ||
107 | */ | ||
108 | #undef memset | ||
102 | #define memzero(s, n) memset((s), 0, (n)) | 109 | #define memzero(s, n) memset((s), 0, (n)) |
103 | 110 | ||
104 | 111 | ||
@@ -109,9 +116,6 @@ static void error(char *m); | |||
109 | */ | 116 | */ |
110 | struct boot_params *real_mode; /* Pointer to real-mode data */ | 117 | struct boot_params *real_mode; /* Pointer to real-mode data */ |
111 | 118 | ||
112 | void *memset(void *s, int c, size_t n); | ||
113 | void *memcpy(void *dest, const void *src, size_t n); | ||
114 | |||
115 | memptr free_mem_ptr; | 119 | memptr free_mem_ptr; |
116 | memptr free_mem_end_ptr; | 120 | memptr free_mem_end_ptr; |
117 | 121 | ||
@@ -216,45 +220,6 @@ void __putstr(const char *s) | |||
216 | outb(0xff & (pos >> 1), vidport+1); | 220 | outb(0xff & (pos >> 1), vidport+1); |
217 | } | 221 | } |
218 | 222 | ||
219 | void *memset(void *s, int c, size_t n) | ||
220 | { | ||
221 | int i; | ||
222 | char *ss = s; | ||
223 | |||
224 | for (i = 0; i < n; i++) | ||
225 | ss[i] = c; | ||
226 | return s; | ||
227 | } | ||
228 | #ifdef CONFIG_X86_32 | ||
229 | void *memcpy(void *dest, const void *src, size_t n) | ||
230 | { | ||
231 | int d0, d1, d2; | ||
232 | asm volatile( | ||
233 | "rep ; movsl\n\t" | ||
234 | "movl %4,%%ecx\n\t" | ||
235 | "rep ; movsb\n\t" | ||
236 | : "=&c" (d0), "=&D" (d1), "=&S" (d2) | ||
237 | : "0" (n >> 2), "g" (n & 3), "1" (dest), "2" (src) | ||
238 | : "memory"); | ||
239 | |||
240 | return dest; | ||
241 | } | ||
242 | #else | ||
243 | void *memcpy(void *dest, const void *src, size_t n) | ||
244 | { | ||
245 | long d0, d1, d2; | ||
246 | asm volatile( | ||
247 | "rep ; movsq\n\t" | ||
248 | "movq %4,%%rcx\n\t" | ||
249 | "rep ; movsb\n\t" | ||
250 | : "=&c" (d0), "=&D" (d1), "=&S" (d2) | ||
251 | : "0" (n >> 3), "g" (n & 7), "1" (dest), "2" (src) | ||
252 | : "memory"); | ||
253 | |||
254 | return dest; | ||
255 | } | ||
256 | #endif | ||
257 | |||
258 | static void error(char *x) | 223 | static void error(char *x) |
259 | { | 224 | { |
260 | error_putstr("\n\n"); | 225 | error_putstr("\n\n"); |
diff --git a/arch/x86/boot/compressed/string.c b/arch/x86/boot/compressed/string.c index ffb9c5c9d748..f3c57e341402 100644 --- a/arch/x86/boot/compressed/string.c +++ b/arch/x86/boot/compressed/string.c | |||
@@ -1,11 +1,45 @@ | |||
1 | #include "misc.h" | 1 | #include "misc.h" |
2 | #include "../string.c" | ||
3 | |||
4 | /* misc.h might pull in string_32.h which has a macro for memcpy. undef that */ | ||
5 | #undef memcpy | ||
2 | 6 | ||
3 | int memcmp(const void *s1, const void *s2, size_t len) | 7 | #ifdef CONFIG_X86_32 |
8 | void *memcpy(void *dest, const void *src, size_t n) | ||
4 | { | 9 | { |
5 | u8 diff; | 10 | int d0, d1, d2; |
6 | asm("repe; cmpsb; setnz %0" | 11 | asm volatile( |
7 | : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len)); | 12 | "rep ; movsl\n\t" |
8 | return diff; | 13 | "movl %4,%%ecx\n\t" |
14 | "rep ; movsb\n\t" | ||
15 | : "=&c" (d0), "=&D" (d1), "=&S" (d2) | ||
16 | : "0" (n >> 2), "g" (n & 3), "1" (dest), "2" (src) | ||
17 | : "memory"); | ||
18 | |||
19 | return dest; | ||
9 | } | 20 | } |
21 | #else | ||
22 | void *memcpy(void *dest, const void *src, size_t n) | ||
23 | { | ||
24 | long d0, d1, d2; | ||
25 | asm volatile( | ||
26 | "rep ; movsq\n\t" | ||
27 | "movq %4,%%rcx\n\t" | ||
28 | "rep ; movsb\n\t" | ||
29 | : "=&c" (d0), "=&D" (d1), "=&S" (d2) | ||
30 | : "0" (n >> 3), "g" (n & 7), "1" (dest), "2" (src) | ||
31 | : "memory"); | ||
10 | 32 | ||
11 | #include "../string.c" | 33 | return dest; |
34 | } | ||
35 | #endif | ||
36 | |||
37 | void *memset(void *s, int c, size_t n) | ||
38 | { | ||
39 | int i; | ||
40 | char *ss = s; | ||
41 | |||
42 | for (i = 0; i < n; i++) | ||
43 | ss[i] = c; | ||
44 | return s; | ||
45 | } | ||
diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c index f0d0b20fe149..1fd7d575092e 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.c b/arch/x86/boot/string.c index 574dedfe2890..5339040ef86e 100644 --- a/arch/x86/boot/string.c +++ b/arch/x86/boot/string.c | |||
@@ -14,6 +14,20 @@ | |||
14 | 14 | ||
15 | #include "boot.h" | 15 | #include "boot.h" |
16 | 16 | ||
17 | /* | ||
18 | * This file gets included in compressed/string.c which might pull in | ||
19 | * string_32.h and which in turn maps memcmp to __builtin_memcmp(). Undo | ||
20 | * that first. | ||
21 | */ | ||
22 | #undef memcmp | ||
23 | int memcmp(const void *s1, const void *s2, size_t len) | ||
24 | { | ||
25 | u8 diff; | ||
26 | asm("repe; cmpsb; setnz %0" | ||
27 | : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len)); | ||
28 | return diff; | ||
29 | } | ||
30 | |||
17 | int strcmp(const char *str1, const char *str2) | 31 | int strcmp(const char *str1, const char *str2) |
18 | { | 32 | { |
19 | const unsigned char *s1 = (const unsigned char *)str1; | 33 | const unsigned char *s1 = (const unsigned char *)str1; |
diff --git a/arch/x86/boot/string.h b/arch/x86/boot/string.h new file mode 100644 index 000000000000..725e820602b1 --- /dev/null +++ b/arch/x86/boot/string.h | |||
@@ -0,0 +1,21 @@ | |||
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 | int memcmp(const void *s1, const void *s2, size_t len); | ||
12 | |||
13 | /* | ||
14 | * Access builtin version by default. If one needs to use optimized version, | ||
15 | * do "undef memcpy" in .c file and link against right string.c | ||
16 | */ | ||
17 | #define memcpy(d,s,l) __builtin_memcpy(d,s,l) | ||
18 | #define memset(d,c,l) __builtin_memset(d,c,l) | ||
19 | #define memcmp __builtin_memcmp | ||
20 | |||
21 | #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; |