1
2
3
4
5
6
7
8
9
10
11#include <linux/export.h>
12#include <linux/bootmem.h>
13#include <linux/memblock.h>
14#include <linux/mm.h>
15#include <linux/numa.h>
16#include <linux/pfn.h>
17#include <asm/sections.h>
18
19struct pglist_data *node_data[MAX_NUMNODES] __read_mostly;
20EXPORT_SYMBOL_GPL(node_data);
21
22extern char _heap_start[];
23
24
25
26
27
28
29
30void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
31{
32 unsigned long bootmap_pages, bootmem_paddr;
33 unsigned long start_pfn, end_pfn;
34 unsigned long pgdat_paddr;
35
36
37 BUG_ON(nid >= MAX_NUMNODES || nid <= 0);
38
39 start_pfn = start >> PAGE_SHIFT;
40 end_pfn = end >> PAGE_SHIFT;
41
42 memblock_add(start, end - start);
43
44 memblock_set_node(PFN_PHYS(start_pfn),
45 PFN_PHYS(end_pfn - start_pfn),
46 &memblock.memory, nid);
47
48
49 pgdat_paddr = memblock_alloc_base(sizeof(struct pglist_data),
50 SMP_CACHE_BYTES, end);
51 NODE_DATA(nid) = __va(pgdat_paddr);
52 memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
53
54 NODE_DATA(nid)->bdata = &bootmem_node_data[nid];
55 NODE_DATA(nid)->node_start_pfn = start_pfn;
56 NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn;
57
58
59 bootmap_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
60 bootmem_paddr = memblock_alloc_base(bootmap_pages << PAGE_SHIFT,
61 PAGE_SIZE, end);
62 init_bootmem_node(NODE_DATA(nid), bootmem_paddr >> PAGE_SHIFT,
63 start_pfn, end_pfn);
64
65 free_bootmem_with_active_regions(nid, end_pfn);
66
67
68 reserve_bootmem_node(NODE_DATA(nid), pgdat_paddr & PAGE_MASK,
69 sizeof(struct pglist_data), BOOTMEM_DEFAULT);
70 reserve_bootmem_node(NODE_DATA(nid), bootmem_paddr,
71 bootmap_pages << PAGE_SHIFT, BOOTMEM_DEFAULT);
72
73
74 node_set_online(nid);
75
76
77 sparse_memory_present_with_active_regions(nid);
78}
79
80void __init __weak soc_mem_setup(void)
81{
82}
83