Here are three small patches that merge 32 and 64 bit code in the boot code.
[PATCH 1/3] x86, boot: Use common ELF header defines
[PATCH 2/3] x86, boot: Remove memptr
[PATCH 3/3] x86, boot: merge memcpy()
arch/x86/boot/compressed/misc.c | 44 ++++++++------------------------------
1 files changed, 10 insertions(+), 34 deletions(-)
Use unsigned long for free memory pointers for both 32-bit and 64-bit.
Signed-off-by: Brian Gerst <[email protected]>
---
arch/x86/boot/compressed/misc.c | 12 +++---------
1 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 2d57c97..c13b5e9 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -114,14 +114,8 @@ static int debug;
void *memset(void *s, int c, size_t n);
void *memcpy(void *dest, const void *src, size_t n);
-#ifdef CONFIG_X86_64
-#define memptr long
-#else
-#define memptr unsigned
-#endif
-
-static memptr free_mem_ptr;
-static memptr free_mem_end_ptr;
+static unsigned long free_mem_ptr;
+static unsigned long free_mem_end_ptr;
static char *vidmem;
static int vidport;
@@ -318,7 +312,7 @@ static void parse_elf(void *output)
}
}
-asmlinkage void decompress_kernel(void *rmode, memptr heap,
+asmlinkage void decompress_kernel(void *rmode, unsigned long heap,
unsigned char *input_data,
unsigned long input_len,
unsigned char *output)
--
1.7.4
Merge the 32-bit and 64-bit memcpy functions.
Signed-off-by: Brian Gerst <[email protected]>
---
arch/x86/boot/compressed/misc.c | 23 +++++------------------
1 files changed, 5 insertions(+), 18 deletions(-)
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index c13b5e9..704bec1 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -10,6 +10,7 @@
*/
#include "misc.h"
+#include <asm/asm.h>
/* WARNING!!
* This code is compiled with -fPIC and it is relocated dynamically
@@ -227,35 +228,21 @@ void *memset(void *s, int c, size_t n)
ss[i] = c;
return s;
}
-#ifdef CONFIG_X86_32
-void *memcpy(void *dest, const void *src, size_t n)
-{
- int d0, d1, d2;
- asm volatile(
- "rep ; movsl\n\t"
- "movl %4,%%ecx\n\t"
- "rep ; movsb\n\t"
- : "=&c" (d0), "=&D" (d1), "=&S" (d2)
- : "0" (n >> 2), "g" (n & 3), "1" (dest), "2" (src)
- : "memory");
- return dest;
-}
-#else
void *memcpy(void *dest, const void *src, size_t n)
{
long d0, d1, d2;
asm volatile(
- "rep ; movsq\n\t"
- "movq %4,%%rcx\n\t"
+ "rep ; " __ASM_SIZE(movs) "\n\t"
+ "mov %4,%0\n\t"
"rep ; movsb\n\t"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
- : "0" (n >> 3), "g" (n & 7), "1" (dest), "2" (src)
+ : "0" (n / sizeof(long)), "g" (n & (sizeof(long) - 1)),
+ "1" (dest), "2" (src)
: "memory");
return dest;
}
-#endif
static void error(char *x)
{
--
1.7.4
<linux/elf.h> defines elfhdr and elf_phdr appropriately for 32-bit
and 64-bit.
Signed-off-by: Brian Gerst <[email protected]>
---
arch/x86/boot/compressed/misc.c | 9 ++-------
1 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 3a19d04..2d57c97 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -275,13 +275,8 @@ static void error(char *x)
static void parse_elf(void *output)
{
-#ifdef CONFIG_X86_64
- Elf64_Ehdr ehdr;
- Elf64_Phdr *phdrs, *phdr;
-#else
- Elf32_Ehdr ehdr;
- Elf32_Phdr *phdrs, *phdr;
-#endif
+ struct elfhdr ehdr;
+ struct elf_phdr *phdrs, *phdr;
void *dest;
int i;
--
1.7.4
On Sat, Feb 26, 2011 at 7:54 PM, Brian Gerst <[email protected]> wrote:
> <linux/elf.h> defines elfhdr and elf_phdr appropriately for 32-bit
> and 64-bit.
>
> Signed-off-by: Brian Gerst <[email protected]>
Reviewed-by: Pekka Enberg <[email protected]>
On Sat, Feb 26, 2011 at 7:54 PM, Brian Gerst <[email protected]> wrote:
> Use unsigned long for free memory pointers for both 32-bit and 64-bit.
>
> Signed-off-by: Brian Gerst <[email protected]>
Reviewed-by: Pekka Enberg <[email protected]>
On Sat, Feb 26, 2011 at 7:54 PM, Brian Gerst <[email protected]> wrote:
> Merge the 32-bit and 64-bit memcpy functions.
>
> Signed-off-by: Brian Gerst <[email protected]>
Reviewed-by: Pekka Enberg <[email protected]>