aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/boot/compressed/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/boot/compressed/misc.c')
-rw-r--r--arch/x86/boot/compressed/misc.c53
1 files changed, 9 insertions, 44 deletions
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 196eaf373a06..57ab74df7eea 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 */
110struct boot_params *real_mode; /* Pointer to real-mode data */ 117struct boot_params *real_mode; /* Pointer to real-mode data */
111 118
112void *memset(void *s, int c, size_t n);
113void *memcpy(void *dest, const void *src, size_t n);
114
115memptr free_mem_ptr; 119memptr free_mem_ptr;
116memptr free_mem_end_ptr; 120memptr 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
219void *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
229void *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
243void *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
258static void error(char *x) 223static void error(char *x)
259{ 224{
260 error_putstr("\n\n"); 225 error_putstr("\n\n");
@@ -389,7 +354,7 @@ static void parse_elf(void *output)
389 free(phdrs); 354 free(phdrs);
390} 355}
391 356
392asmlinkage void *decompress_kernel(void *rmode, memptr heap, 357asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap,
393 unsigned char *input_data, 358 unsigned char *input_data,
394 unsigned long input_len, 359 unsigned long input_len,
395 unsigned char *output, 360 unsigned char *output,