
Originally From: Dave McCracken <dmccr@us.ibm.com>
fixes from: Keith Mannthey <kmannth@us.ibm.com>

This is the minimal set of changes needed to the i386 architecture in order
to get CONFIG_NONLINEAR to work.

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---

 memhotplug-dave/arch/i386/Kconfig              |    6 ++++++
 memhotplug-dave/arch/i386/kernel/apic.c        |    2 +-
 memhotplug-dave/arch/i386/kernel/doublefault.c |    2 +-
 memhotplug-dave/arch/i386/mm/init.c            |    2 +-
 memhotplug-dave/arch/i386/mm/pgtable.c         |    1 +
 memhotplug-dave/include/asm-i386/nonlinear.h   |   14 ++++++++++++++
 memhotplug-dave/include/asm-i386/page.h        |    6 ++++--
 7 files changed, 28 insertions(+), 5 deletions(-)

diff -puN arch/i386/Kconfig~F-nonlinear-i386 arch/i386/Kconfig
--- memhotplug/arch/i386/Kconfig~F-nonlinear-i386	2005-01-04 13:49:37.000000000 -0800
+++ memhotplug-dave/arch/i386/Kconfig	2005-01-04 13:49:37.000000000 -0800
@@ -774,6 +774,12 @@ config HAVE_ARCH_ALLOC_REMAP
 	depends on NUMA
 	default y
 
+config ARCH_HAS_BOOTPA
+	bool
+	default y
+
+source "mm/Kconfig"
+
 config HIGHPTE
 	bool "Allocate 3rd-level pagetables from highmem"
 	depends on HIGHMEM4G || HIGHMEM64G
diff -puN arch/i386/kernel/apic.c~F-nonlinear-i386 arch/i386/kernel/apic.c
--- memhotplug/arch/i386/kernel/apic.c~F-nonlinear-i386	2005-01-04 13:49:37.000000000 -0800
+++ memhotplug-dave/arch/i386/kernel/apic.c	2005-01-04 13:49:37.000000000 -0800
@@ -847,7 +847,7 @@ void __init init_apic_mappings(void)
 fake_ioapic_page:
 				ioapic_phys = (unsigned long)
 					      alloc_bootmem_pages(PAGE_SIZE);
-				ioapic_phys = __pa(ioapic_phys);
+				ioapic_phys = __boot_pa(ioapic_phys);
 			}
 			set_fixmap_nocache(idx, ioapic_phys);
 			printk(KERN_DEBUG "mapped IOAPIC to %08lx (%08lx)\n",
diff -puN arch/i386/kernel/doublefault.c~F-nonlinear-i386 arch/i386/kernel/doublefault.c
--- memhotplug/arch/i386/kernel/doublefault.c~F-nonlinear-i386	2005-01-04 13:49:37.000000000 -0800
+++ memhotplug-dave/arch/i386/kernel/doublefault.c	2005-01-04 13:49:37.000000000 -0800
@@ -61,5 +61,5 @@ struct tss_struct doublefault_tss __cach
 	.ss		= __KERNEL_DS,
 	.ds		= __USER_DS,
 
-	.__cr3		= __pa(swapper_pg_dir)
+	.__cr3		= __boot_pa(swapper_pg_dir)
 };
diff -puN arch/i386/mm/init.c~F-nonlinear-i386 arch/i386/mm/init.c
--- memhotplug/arch/i386/mm/init.c~F-nonlinear-i386	2005-01-04 13:49:37.000000000 -0800
+++ memhotplug-dave/arch/i386/mm/init.c	2005-01-04 13:49:37.000000000 -0800
@@ -565,7 +565,7 @@ void __init mem_init(void)
 	int tmp;
 	int bad_ppro;
 
-#ifndef CONFIG_DISCONTIGMEM
+#ifdef CONFIG_ARCH_HAS_CONTIGUOUS_MEM_MAP
 	if (!mem_map)
 		BUG();
 #endif
diff -puN arch/i386/mm/pgtable.c~F-nonlinear-i386 arch/i386/mm/pgtable.c
--- memhotplug/arch/i386/mm/pgtable.c~F-nonlinear-i386	2005-01-04 13:49:37.000000000 -0800
+++ memhotplug-dave/arch/i386/mm/pgtable.c	2005-01-04 13:49:37.000000000 -0800
@@ -54,6 +54,7 @@ void show_mem(void)
 	printk("%d pages shared\n",shared);
 	printk("%d pages swap cached\n",cached);
 }
+#endif
 
 /*
  * Associate a virtual page frame with a given physical page frame 
diff -puN /dev/null include/asm-i386/nonlinear.h
--- /dev/null	2004-11-08 15:18:04.000000000 -0800
+++ memhotplug-dave/include/asm-i386/nonlinear.h	2005-01-04 13:49:37.000000000 -0800
@@ -0,0 +1,14 @@
+#ifndef __I386_NONLINEAR_H_
+#define __I386_NONLINEAR_H_
+
+#define SECTION_SHIFT		27	/* Size of section - 128 Mbytes */
+#ifdef CONFIG_X86_PAE
+#define	MAX_MEM_SHIFT		36	/* Number of sections to allocate */
+#define	MAX_PHYS_SHIFT		36	/* Max phys memory in sections */
+#else
+#define	MAX_MEM_SHIFT		32
+#define	MAX_PHYS_SHIFT		32
+#endif
+
+
+#endif /* __I386_NONLINEAR_H_ */
diff -puN include/asm-i386/page.h~F-nonlinear-i386 include/asm-i386/page.h
--- memhotplug/include/asm-i386/page.h~F-nonlinear-i386	2005-01-04 13:49:37.000000000 -0800
+++ memhotplug-dave/include/asm-i386/page.h	2005-01-04 13:49:37.000000000 -0800
@@ -132,14 +132,16 @@ extern int devmem_is_allowed(unsigned lo
 #define MAXMEM			(-__PAGE_OFFSET-__VMALLOC_RESERVE)
 #define __boot_pa(x)		((unsigned long)(x)-PAGE_OFFSET)
 #define __boot_va(x)		((void *)((unsigned long)(x)+PAGE_OFFSET))
+#ifndef CONFIG_NONLINEAR
 #define __pa(x)			__boot_pa(x)
 #define __va(x)			__boot_va(x)
+#endif
 #define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
-#ifndef CONFIG_DISCONTIGMEM
+#ifdef CONFIG_CONTIGUOUS_MEM_MAP
 #define pfn_to_page(pfn)	(mem_map + (pfn))
 #define page_to_pfn(page)	((unsigned long)((page) - mem_map))
 #define pfn_valid(pfn)		((pfn) < max_mapnr)
-#endif /* !CONFIG_DISCONTIGMEM */
+#endif /* CONFIG_CONTIGUOUS_MEM_MAP */
 #define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
 
 #define virt_addr_valid(kaddr)	pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
_
