Re: [PATCH 06/20] early_res: seperate common memmap func from e820.c to fw_memmap.c

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Yinghai Lu
Date: Sunday, March 21, 2010 - 8:56 pm

On 03/21/2010 07:37 PM, Benjamin Herrenschmidt wrote:
at this point, kernel/early_res.c and kernel/fw_memmap.c is protected with HAVE_EARLY_RES

obj-$(CONFIG_HAVE_EARLY_RES) += early_res.o fw_memmap.o

so it will not increase size that doesn't support early_res/bootmem yet.
 

not all of the e820 code. arch/x86/kernel/e820.c are still there.

linux-2.6> wc -l  arch/x86/kernel/e820.c
690 arch/x86/kernel/e820.c
linux-2.6> wc -l kernel/fw_memmap.c
625 kernel/fw_memmap.c

and interface header file

yhlu@linux-siqj:~/xx/xx/kernel/tip/linux-2.6> cat include/linux/fw_memmap.h 
#ifndef _LINUX_FW_MEMMAP_H
#define _LINUX_FW_MEMMAP_H
#define E820MAX	128		/* number of entries in E820MAP */

#define FW_MEMMAP_RAM	1
#define FW_MEMMAP_RESERVED	2

#define E820_RAM	FW_MEMMAP_RAM
#define E820_RESERVED	FW_MEMMAP_RESERVED

#define E820_ACPI	3
#define E820_NVS	4
#define E820_UNUSABLE	5

#ifndef __ASSEMBLY__
#include <linux/types.h>
struct e820entry {
	__u64 addr;	/* start of memory segment */
	__u64 size;	/* size of memory segment */
	__u32 type;	/* type of memory segment */
} __attribute__((packed));

#ifdef __KERNEL__

void fw_memmap_add_region(u64 start, u64 size, int type);
void fw_memmap_print_map(char *who);
int sanitize_fw_memmap(void);
void finish_fw_memmap_parsing(void);

#include <linux/early_res.h>

unsigned long fw_memmap_end_of_ram_pfn(void);
void fw_memmap_register_active_regions(int nid, unsigned long start_pfn,
					 unsigned long end_pfn);
u64 fw_memmap_hole_size(u64 start, u64 end);

#endif /* __KERNEL__ */
#endif /* __ASSEMBLY__ */

#endif /* _LINUX_FW_MEMMAP_H */

and new arch that support early_res/bootmem, will normally only need to call those six functions
like

+void __init setup_memory_map(void)
+{
+       int i;
+       unsigned long phys_base;
+       /* Find available physical memory...
+        *
+        * Read it twice in order to work around a bug in openfirmware.
+        * The call to grab this table itself can cause openfirmware to
+        * allocate memory, which in turn can take away some space from
+        * the list of available memory.  Reading it twice makes sure
+        * we really do get the final value.
+        */
+       read_obp_translations();
+       read_obp_memory("reg", &pall[0], &pall_ents);
+       read_obp_memory("available", &pavail[0], &pavail_ents);
+       read_obp_memory("available", &pavail[0], &pavail_ents);
+
+       phys_base = 0xffffffffffffffffUL;
+       for (i = 0; i < pavail_ents; i++) {
+               phys_base = min(phys_base, pavail[i].phys_addr);
+               fw_memmap_add_region(pavail[i].phys_addr, pavail[i].reg_size,
+                                FW_MEMMAP_RAM);
+       }
+
+       sanitize_fw_memmap();
+
+       fw_memmap_print_map("obp memmap:");



e820/early_res is more complicated than lmb. to make x86, we still need to keep e820 related code.
and early_res already can be used to replace bootmem code.

maybe we should find other user other than previous lmb users at first.

attached is the one for sparc64/lmb converting...- i have no chance to debug it.
qemu seems doesn't support sparc64 well yet.


Yinghai
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/20] x86: early_res and irq_desc, Yinghai Lu, (Sun Mar 21, 12:13 am)
[PATCH 01/20] x86: add find_e820_area_node, Yinghai Lu, (Sun Mar 21, 12:13 am)
[PATCH 02/20] x86: add get_centaur_ram_top, Yinghai Lu, (Sun Mar 21, 12:13 am)
[PATCH 03/20] x86: make e820 to be static, Yinghai Lu, (Sun Mar 21, 12:13 am)
[PATCH 05/20] x86: make e820 to be initdata, Yinghai Lu, (Sun Mar 21, 12:13 am)
[PATCH 08/20] x86: fix out of order of gsi - full, Yinghai Lu, (Sun Mar 21, 12:13 am)
[PATCH 10/20] x86: kill smpboot_hooks.h, Yinghai Lu, (Sun Mar 21, 12:13 am)
[PATCH 18/20] x86: remove arch_probe_nr_irqs, Yinghai Lu, (Sun Mar 21, 12:13 am)
Re: [PATCH 00/20] x86: early_res and irq_desc, Benjamin Herrenschmidt, (Sun Mar 21, 7:35 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Sun Mar 21, 7:37 pm)
Questions about SMP bootup control, Zhu, Yijun (NSN - CN ..., (Sun Mar 21, 7:46 pm)
Re: [PATCH 00/20] x86: early_res and irq_desc, Yinghai Lu, (Sun Mar 21, 8:26 pm)
Re: Questions about SMP bootup control, Andi Kleen, (Sun Mar 21, 8:29 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Yinghai Lu, (Sun Mar 21, 8:56 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Sun Mar 21, 10:12 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Eric W. Biederman, (Mon Mar 22, 12:05 am)
RE: Questions about SMP bootup control, Zhu, Yijun (NSN - CN ..., (Mon Mar 22, 12:45 am)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Mon Mar 22, 1:47 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Mon Mar 22, 2:01 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Mon Mar 22, 2:04 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Mon Mar 22, 2:07 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Mon Mar 22, 2:08 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Mon Mar 22, 2:52 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Mon Mar 22, 2:54 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Geert Uytterhoeven, (Tue Mar 23, 1:53 am)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Tue Mar 23, 9:24 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Tue Mar 23, 9:29 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Tue Mar 23, 9:44 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Tue Mar 23, 9:50 pm)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Wed Mar 24, 12:43 am)
Re: [PATCH 06/20] early_res: seperate common memmap func f ..., Benjamin Herrenschmidt, (Wed Mar 24, 2:32 am)