x86 boot cleanups
cover x86 boot cleanups
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(-)
PATCH 1/3 x86, boot: Use common ELF header defines
<linux/elf.h> defines elfhdr and elf_phdr appropriately for 32-bit and 64-bit.
--- arch/x86/boot/compressed/misc.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)
arch/x86/boot/compressed/misc.c +2 -7
@@ -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;
Signature · 1 line
1.7.4
Re: [PATCH 1/3] x86, boot: Use common ELF header defines
Quoted 4 lines · Brian Gerst
<
linux/elf.h> defines elfhdr andelf_phdrappropriately for 32-bit and 64-bit.Signed-off-by Brian Gerst <[email protected]>
PATCH 2/3 x86, boot: Remove memptr
In reply to Brian GerstUse unsigned long for free memory pointers for both 32-bit and 64-bit.
--- arch/x86/boot/compressed/misc.c | 12 +++--------- 1 files changed, 3 insertions(+), 9 deletions(-)
arch/x86/boot/compressed/misc.c +3 -9
@@ -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)
Signature · 1 line
1.7.4
Re: [PATCH 2/3] x86, boot: Remove memptr
Quoted 3 lines · Brian Gerst
Use unsigned long for free memory pointers for both 32-bit and 64-bit.
Signed-off-by Brian Gerst <[email protected]>
PATCH 3/3 x86, boot: merge memcpy()
In reply to Brian GerstMerge the 32-bit and 64-bit memcpy functions.
--- arch/x86/boot/compressed/misc.c | 23 +++++------------------ 1 files changed, 5 insertions(+), 18 deletions(-)
arch/x86/boot/compressed/misc.c +5 -18
@@ -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; - asmvolatile ( -"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; asmvolatile ( -"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) {
Signature · 1 line
1.7.4
Re: [PATCH 3/3] x86, boot: merge memcpy()
Quoted 3 lines · Brian Gerst
Merge the 32-bit and 64-bit memcpy functions.
Signed-off-by Brian Gerst <[email protected]>