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

 memhotplug-dave/arch/ppc64/mm/init.c |   77 +++++++++++++++++++++++++++++++++++
 mm/nonlinear.c                       |    0 
 2 files changed, 77 insertions(+)

diff -puN arch/ppc64/mm/init.c~O-memhotplug-ppc64-onlinefuncs arch/ppc64/mm/init.c
--- memhotplug/arch/ppc64/mm/init.c~O-memhotplug-ppc64-onlinefuncs	2004-11-12 16:52:11.000000000 -0800
+++ memhotplug-dave/arch/ppc64/mm/init.c	2004-11-12 16:52:11.000000000 -0800
@@ -916,3 +916,80 @@ pgd_t *__pgd_alloc(struct mm_struct *mm,
 	return kmem_cache_alloc(zero_cache, GFP_KERNEL);
 }
 
+void online_page(struct page *page)
+{
+	ClearPageReserved(page);
+	set_page_count(page, 1);
+	totalram_pages++;
+
+	/* see note in mm/memory_hotplug.c
+	 * this needs to be fixed properly
+	 */
+	/* zone->present_pages++; */
+}
+
+/*
+ * This works only for the non-NUMA case.  Later, we'll need a lookup
+ * to convert from real physical addresses to nid, that doesn't use
+ * pfn_to_nid().
+ */
+int __devinit add_memory(u64 start, u64 size, unsigned long attr)
+{
+	struct pglist_data *pgdata = NODE_DATA(0);
+	struct zone *zone;
+	unsigned long start_pfn = start >> PAGE_SHIFT;
+	unsigned long nr_pages = size >> PAGE_SHIFT;
+
+	/* this should work for most non-highmem platforms */
+	zone = pgdata->node_zones;
+
+	return __add_pages(zone, start_pfn, nr_pages, attr);
+
+	return 0;
+}
+
+/*
+ * exact copy of the i386 one (the is_highmem() check will always fail)
+ */
+int __devinit remove_memory(u64 start, u64 size, unsigned long attr)
+{
+	struct zone *zone;
+	unsigned long start_pfn, end_pfn, nr_pages;
+
+	start_pfn = start >> PAGE_SHIFT;
+	nr_pages = size >> PAGE_SHIFT;
+	end_pfn = start_pfn + nr_pages;
+
+	/*
+	 * check to see which zone the page range is in. If
+	 * not in a zone where we allow hotplug (i.e. highmem),
+	 * just fail it right now.
+	 */
+	zone = page_zone(pfn_to_page(start_pfn));
+
+	printk("%s(): memory will be removed from "
+			"the %s zone\n", __func__, zone->name);
+
+	/*
+	 * not handling removing memory ranges that
+	 * overlap multiple zones yet
+	 */
+	if (end_pfn > (zone->zone_start_pfn + zone->spanned_pages))
+		goto overlap;
+
+	/* make sure it is in highmem */
+	if (!is_highmem(zone)) {
+		printk("%s(): range to be removed must be in highmem!\n",
+			__func__);
+		goto not_highmem;
+	}
+
+	return __remove_pages(zone, start_pfn, nr_pages, attr);
+
+overlap:
+	printk("%s(): memory range to be removed overlaps "
+		"multiple zones!!!\n", __func__);
+not_highmem:
+	return -1;
+}
+
diff -puN mm/memory_hotplug.c~O-memhotplug-ppc64-onlinefuncs mm/memory_hotplug.c
diff -puN include/linux/nonlinear.h~O-memhotplug-ppc64-onlinefuncs include/linux/nonlinear.h
diff -puN arch/i386/mm/init.c~O-memhotplug-ppc64-onlinefuncs arch/i386/mm/init.c
diff -puN drivers/base/memory.c~O-memhotplug-ppc64-onlinefuncs drivers/base/memory.c
diff -puN mm/nonlinear.c~O-memhotplug-ppc64-onlinefuncs mm/nonlinear.c
_
