1
2
3
4
5
6
7
8
9
10#include <linux/signal.h>
11#include <linux/sched.h>
12#include <linux/mm.h>
13#include <linux/swap.h>
14#include <linux/kernel.h>
15#include <linux/string.h>
16#include <linux/types.h>
17#include <linux/init.h>
18#include <linux/bootmem.h>
19
20#include <asm/setup.h>
21#include <asm/uaccess.h>
22#include <asm/page.h>
23#include <asm/pgtable.h>
24#include <asm/machdep.h>
25#include <asm/io.h>
26
27extern void mmu_emu_init (unsigned long bootmem_end);
28
29const char bad_pmd_string[] = "Bad pmd in pte_alloc: %08lx\n";
30
31extern unsigned long num_pages;
32
33
34
35
36void __init paging_init(void)
37{
38 pgd_t * pg_dir;
39 pte_t * pg_table;
40 int i;
41 unsigned long address;
42 unsigned long next_pgtable;
43 unsigned long bootmem_end;
44 unsigned long zones_size[MAX_NR_ZONES] = { 0, };
45 unsigned long size;
46
47#ifdef TEST_VERIFY_AREA
48 wp_works_ok = 0;
49#endif
50 empty_zero_page = alloc_bootmem_pages(PAGE_SIZE);
51
52 address = PAGE_OFFSET;
53 pg_dir = swapper_pg_dir;
54 memset (swapper_pg_dir, 0, sizeof (swapper_pg_dir));
55 memset (kernel_pg_dir, 0, sizeof (kernel_pg_dir));
56
57 size = num_pages * sizeof(pte_t);
58 size = (size + PAGE_SIZE) & ~(PAGE_SIZE-1);
59
60 next_pgtable = (unsigned long)alloc_bootmem_pages(size);
61 bootmem_end = (next_pgtable + size + PAGE_SIZE) & PAGE_MASK;
62
63
64 pg_dir += PAGE_OFFSET >> PGDIR_SHIFT;
65
66 while (address < (unsigned long)high_memory) {
67 pg_table = (pte_t *) __pa (next_pgtable);
68 next_pgtable += PTRS_PER_PTE * sizeof (pte_t);
69 pgd_val(*pg_dir) = (unsigned long) pg_table;
70 pg_dir++;
71
72
73 pg_table = (pte_t *) __va ((unsigned long) pg_table);
74 for (i=0; i<PTRS_PER_PTE; ++i, ++pg_table) {
75 pte_t pte = pfn_pte(virt_to_pfn(address), PAGE_INIT);
76 if (address >= (unsigned long)high_memory)
77 pte_val (pte) = 0;
78 set_pte (pg_table, pte);
79 address += PAGE_SIZE;
80 }
81 }
82
83 mmu_emu_init(bootmem_end);
84
85 current->mm = NULL;
86
87
88 zones_size[ZONE_DMA] = ((unsigned long)high_memory - PAGE_OFFSET) >> PAGE_SHIFT;
89
90
91
92 free_area_init_node(0, zones_size,
93 (__pa(PAGE_OFFSET) >> PAGE_SHIFT) + 1, NULL);
94
95
96}
97
98
99