提交 95a71a45 编写于 作者: Y Yinghai Lu 提交者: Ingo Molnar

x86: cleanup machine_specific_memory_setup, v2

1. let 64bit support 88 and e801 too
2. introduce default_machine_specific_memory_setup, and reuse it
   for voyager

v2: fix 64 bit compiling
Signed-off-by: NYinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 66a6f8d5
...@@ -1029,7 +1029,7 @@ void __init e820_reserve_resources(void) ...@@ -1029,7 +1029,7 @@ void __init e820_reserve_resources(void)
} }
} }
char *__init __attribute__((weak)) machine_specific_memory_setup(void) char *__init default_machine_specific_memory_setup(void)
{ {
char *who = "BIOS-e820"; char *who = "BIOS-e820";
int new_nr; int new_nr;
...@@ -1045,10 +1045,7 @@ char *__init __attribute__((weak)) machine_specific_memory_setup(void) ...@@ -1045,10 +1045,7 @@ char *__init __attribute__((weak)) machine_specific_memory_setup(void)
&new_nr); &new_nr);
boot_params.e820_entries = new_nr; boot_params.e820_entries = new_nr;
if (copy_e820_map(boot_params.e820_map, boot_params.e820_entries) < 0) { if (copy_e820_map(boot_params.e820_map, boot_params.e820_entries) < 0) {
#ifdef CONFIG_X86_64 u64 mem_size;
early_panic("Cannot find a valid memory map");
#else
unsigned long mem_size;
/* compare results from other methods and take the greater */ /* compare results from other methods and take the greater */
if (boot_params.alt_mem_k if (boot_params.alt_mem_k
...@@ -1063,13 +1060,17 @@ char *__init __attribute__((weak)) machine_specific_memory_setup(void) ...@@ -1063,13 +1060,17 @@ char *__init __attribute__((weak)) machine_specific_memory_setup(void)
e820.nr_map = 0; e820.nr_map = 0;
e820_add_region(0, LOWMEMSIZE(), E820_RAM); e820_add_region(0, LOWMEMSIZE(), E820_RAM);
e820_add_region(HIGH_MEMORY, mem_size << 10, E820_RAM); e820_add_region(HIGH_MEMORY, mem_size << 10, E820_RAM);
#endif
} }
/* In case someone cares... */ /* In case someone cares... */
return who; return who;
} }
char *__init __attribute__((weak)) machine_specific_memory_setup(void)
{
return default_machine_specific_memory_setup();
}
/* Overridden in paravirt.c if CONFIG_PARAVIRT */ /* Overridden in paravirt.c if CONFIG_PARAVIRT */
char * __init __attribute__((weak)) memory_setup(void) char * __init __attribute__((weak)) memory_setup(void)
{ {
......
...@@ -104,35 +104,5 @@ char *__init machine_specific_memory_setup(void) ...@@ -104,35 +104,5 @@ char *__init machine_specific_memory_setup(void)
return who; return who;
} }
who = "BIOS-e820"; return default_machine_specific_memory_setup();
/*
* Try to copy the BIOS-supplied E820-map.
*
* Otherwise fake a memory map; one section from 0k->640k,
* the next section from 1mb->appropriate_mem_k
*/
new_nr = boot_params.e820_entries;
sanitize_e820_map(boot_params.e820_map,
ARRAY_SIZE(boot_params.e820_map),
&new_nr);
boot_params.e820_entries = new_nr;
if (copy_e820_map(boot_params.e820_map, boot_params.e820_entries)
< 0) {
unsigned long mem_size;
/* compare results from other methods and take the greater */
if (boot_params.alt_mem_k < boot_params.screen_info.ext_mem_k) {
mem_size = boot_params.screen_info.ext_mem_k;
who = "BIOS-88";
} else {
mem_size = boot_params.alt_mem_k;
who = "BIOS-e801";
}
e820.nr_map = 0;
e820_add_region(0, LOWMEMSIZE(), E820_RAM);
e820_add_region(HIGH_MEMORY, mem_size << 10, E820_RAM);
}
return who;
} }
...@@ -102,6 +102,7 @@ extern u64 e820_hole_size(u64 start, u64 end); ...@@ -102,6 +102,7 @@ extern u64 e820_hole_size(u64 start, u64 end);
extern void finish_e820_parsing(void); extern void finish_e820_parsing(void);
extern void e820_reserve_resources(void); extern void e820_reserve_resources(void);
extern void setup_memory_map(void); extern void setup_memory_map(void);
extern char *default_machine_specific_memory_setup(void);
extern char *machine_specific_memory_setup(void); extern char *machine_specific_memory_setup(void);
extern char *memory_setup(void); extern char *memory_setup(void);
...@@ -116,9 +117,7 @@ extern char *memory_setup(void); ...@@ -116,9 +117,7 @@ extern char *memory_setup(void);
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/ioport.h> #include <linux/ioport.h>
#ifdef CONFIG_X86_32
#define HIGH_MEMORY (1024*1024) #define HIGH_MEMORY (1024*1024)
#endif
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* __ASM_E820_H */ #endif /* __ASM_E820_H */
...@@ -42,13 +42,14 @@ void vsmp_init(void); ...@@ -42,13 +42,14 @@ void vsmp_init(void);
*/ */
extern struct boot_params boot_params; extern struct boot_params boot_params;
#ifdef __i386__
/* /*
* Do NOT EVER look at the BIOS memory size location. * Do NOT EVER look at the BIOS memory size location.
* It does not work on many machines. * It does not work on many machines.
*/ */
#define LOWMEMSIZE() (0x9f000) #define LOWMEMSIZE() (0x9f000)
#ifdef __i386__
void __init i386_start_kernel(void); void __init i386_start_kernel(void);
extern unsigned long init_pg_tables_start; extern unsigned long init_pg_tables_start;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册