diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/alpha/mm/remap.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/alpha/mm/remap.c')
-rw-r--r-- | arch/alpha/mm/remap.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/arch/alpha/mm/remap.c b/arch/alpha/mm/remap.c new file mode 100644 index 000000000000..19817ad3d89b --- /dev/null +++ b/arch/alpha/mm/remap.c | |||
@@ -0,0 +1,90 @@ | |||
1 | #include <linux/vmalloc.h> | ||
2 | #include <asm/pgalloc.h> | ||
3 | #include <asm/cacheflush.h> | ||
4 | |||
5 | /* called with the page_table_lock held */ | ||
6 | static inline void | ||
7 | remap_area_pte(pte_t * pte, unsigned long address, unsigned long size, | ||
8 | unsigned long phys_addr, unsigned long flags) | ||
9 | { | ||
10 | unsigned long end; | ||
11 | unsigned long pfn; | ||
12 | |||
13 | address &= ~PMD_MASK; | ||
14 | end = address + size; | ||
15 | if (end > PMD_SIZE) | ||
16 | end = PMD_SIZE; | ||
17 | if (address >= end) | ||
18 | BUG(); | ||
19 | pfn = phys_addr >> PAGE_SHIFT; | ||
20 | do { | ||
21 | if (!pte_none(*pte)) { | ||
22 | printk("remap_area_pte: page already exists\n"); | ||
23 | BUG(); | ||
24 | } | ||
25 | set_pte(pte, pfn_pte(pfn, | ||
26 | __pgprot(_PAGE_VALID | _PAGE_ASM | | ||
27 | _PAGE_KRE | _PAGE_KWE | flags))); | ||
28 | address += PAGE_SIZE; | ||
29 | pfn++; | ||
30 | pte++; | ||
31 | } while (address && (address < end)); | ||
32 | } | ||
33 | |||
34 | /* called with the page_table_lock held */ | ||
35 | static inline int | ||
36 | remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned long size, | ||
37 | unsigned long phys_addr, unsigned long flags) | ||
38 | { | ||
39 | unsigned long end; | ||
40 | |||
41 | address &= ~PGDIR_MASK; | ||
42 | end = address + size; | ||
43 | if (end > PGDIR_SIZE) | ||
44 | end = PGDIR_SIZE; | ||
45 | phys_addr -= address; | ||
46 | if (address >= end) | ||
47 | BUG(); | ||
48 | do { | ||
49 | pte_t * pte = pte_alloc_kernel(&init_mm, pmd, address); | ||
50 | if (!pte) | ||
51 | return -ENOMEM; | ||
52 | remap_area_pte(pte, address, end - address, | ||
53 | address + phys_addr, flags); | ||
54 | address = (address + PMD_SIZE) & PMD_MASK; | ||
55 | pmd++; | ||
56 | } while (address && (address < end)); | ||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | int | ||
61 | __alpha_remap_area_pages(unsigned long address, unsigned long phys_addr, | ||
62 | unsigned long size, unsigned long flags) | ||
63 | { | ||
64 | pgd_t * dir; | ||
65 | int error = 0; | ||
66 | unsigned long end = address + size; | ||
67 | |||
68 | phys_addr -= address; | ||
69 | dir = pgd_offset(&init_mm, address); | ||
70 | flush_cache_all(); | ||
71 | if (address >= end) | ||
72 | BUG(); | ||
73 | spin_lock(&init_mm.page_table_lock); | ||
74 | do { | ||
75 | pmd_t *pmd; | ||
76 | pmd = pmd_alloc(&init_mm, dir, address); | ||
77 | error = -ENOMEM; | ||
78 | if (!pmd) | ||
79 | break; | ||
80 | if (remap_area_pmd(pmd, address, end - address, | ||
81 | phys_addr + address, flags)) | ||
82 | break; | ||
83 | error = 0; | ||
84 | address = (address + PGDIR_SIZE) & PGDIR_MASK; | ||
85 | dir++; | ||
86 | } while (address && (address < end)); | ||
87 | spin_unlock(&init_mm.page_table_lock); | ||
88 | return error; | ||
89 | } | ||
90 | |||