2 * arch/sh/mm/numa.c - Multiple node support for SH machines
4 * Copyright (C) 2007 Paul Mundt
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
10 #include <linux/module.h>
11 #include <linux/bootmem.h>
13 #include <linux/numa.h>
14 #include <linux/pfn.h>
15 #include <asm/sections.h>
17 struct pglist_data *node_data[MAX_NUMNODES] __read_mostly;
18 EXPORT_SYMBOL_GPL(node_data);
21 * On SH machines the conventional approach is to stash system RAM
22 * in node 0, and other memory blocks in to node 1 and up, ordered by
23 * latency. Each node's pgdat is node-local at the beginning of the node,
24 * immediately followed by the node mem map.
26 void __init setup_memory(void)
28 unsigned long free_pfn = PFN_UP(__pa(_end));
31 * Node 0 sets up its pgdat at the first available pfn,
32 * and bumps it up before setting up the bootmem allocator.
34 NODE_DATA(0) = pfn_to_kaddr(free_pfn);
35 memset(NODE_DATA(0), 0, sizeof(struct pglist_data));
36 free_pfn += PFN_UP(sizeof(struct pglist_data));
37 NODE_DATA(0)->bdata = &bootmem_node_data[0];
40 setup_bootmem_allocator(free_pfn);
42 /* Give the platforms a chance to hook up their nodes */
46 void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
48 unsigned long bootmap_pages, bootmap_start, bootmap_size;
49 unsigned long start_pfn, free_pfn, end_pfn;
51 /* Don't allow bogus node assignment */
52 BUG_ON(nid > MAX_NUMNODES || nid == 0);
55 * The free pfn starts at the beginning of the range, and is
56 * advanced as necessary for pgdat and node map allocations.
58 free_pfn = start_pfn = start >> PAGE_SHIFT;
59 end_pfn = end >> PAGE_SHIFT;
61 __add_active_range(nid, start_pfn, end_pfn);
63 /* Node-local pgdat */
64 NODE_DATA(nid) = pfn_to_kaddr(free_pfn);
65 free_pfn += PFN_UP(sizeof(struct pglist_data));
66 memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
68 NODE_DATA(nid)->bdata = &bootmem_node_data[nid];
69 NODE_DATA(nid)->node_start_pfn = start_pfn;
70 NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn;
72 /* Node-local bootmap */
73 bootmap_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
74 bootmap_start = (unsigned long)pfn_to_kaddr(free_pfn);
75 bootmap_size = init_bootmem_node(NODE_DATA(nid), free_pfn, start_pfn,
78 free_bootmem_with_active_regions(nid, end_pfn);
80 /* Reserve the pgdat and bootmap space with the bootmem allocator */
81 reserve_bootmem_node(NODE_DATA(nid), start_pfn << PAGE_SHIFT,
82 sizeof(struct pglist_data), BOOTMEM_DEFAULT);
83 reserve_bootmem_node(NODE_DATA(nid), free_pfn << PAGE_SHIFT,
84 bootmap_pages << PAGE_SHIFT, BOOTMEM_DEFAULT);
90 sparse_memory_present_with_active_regions(nid);