Skip to content

Commit cbd15b3

Browse files
author
Ley Foon Tan
committed
nios2: Page table management
This patch adds support for page table management. Signed-off-by: Ley Foon Tan <lftan@altera.com>
1 parent 862674d commit cbd15b3

4 files changed

Lines changed: 505 additions & 0 deletions

File tree

‎arch/nios2/include/asm/pgalloc.h‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* This file is subject to the terms and conditions of the GNU General Public
3+
* License. See the file "COPYING" in the main directory of this archive
4+
* for more details.
5+
*
6+
* Copyright (C) 1994 - 2001, 2003 by Ralf Baechle
7+
* Copyright (C) 1999, 2000, 2001 Silicon Graphics, Inc.
8+
*/
9+
10+
#ifndef _ASM_NIOS2_PGALLOC_H
11+
#define _ASM_NIOS2_PGALLOC_H
12+
13+
#include <linux/mm.h>
14+
15+
static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
16+
pte_t *pte)
17+
{
18+
set_pmd(pmd, __pmd((unsigned long)pte));
19+
}
20+
21+
static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
22+
pgtable_t pte)
23+
{
24+
set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
25+
}
26+
#define pmd_pgtable(pmd) pmd_page(pmd)
27+
28+
/*
29+
* Initialize a new pmd table with invalid pointers.
30+
*/
31+
extern void pmd_init(unsigned long page, unsigned long pagetable);
32+
33+
extern pgd_t *pgd_alloc(struct mm_struct *mm);
34+
35+
static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
36+
{
37+
free_pages((unsigned long)pgd, PGD_ORDER);
38+
}
39+
40+
static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
41+
unsigned long address)
42+
{
43+
pte_t *pte;
44+
45+
pte = (pte_t *) __get_free_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO,
46+
PTE_ORDER);
47+
48+
return pte;
49+
}
50+
51+
static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
52+
unsigned long address)
53+
{
54+
struct page *pte;
55+
56+
pte = alloc_pages(GFP_KERNEL | __GFP_REPEAT, PTE_ORDER);
57+
if (pte) {
58+
if (!pgtable_page_ctor(pte)) {
59+
__free_page(pte);
60+
return NULL;
61+
}
62+
clear_highpage(pte);
63+
}
64+
return pte;
65+
}
66+
67+
static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
68+
{
69+
free_pages((unsigned long)pte, PTE_ORDER);
70+
}
71+
72+
static inline void pte_free(struct mm_struct *mm, struct page *pte)
73+
{
74+
pgtable_page_dtor(pte);
75+
__free_pages(pte, PTE_ORDER);
76+
}
77+
78+
#define __pte_free_tlb(tlb, pte, addr) \
79+
do { \
80+
pgtable_page_dtor(pte); \
81+
tlb_remove_page((tlb), (pte)); \
82+
} while (0)
83+
84+
#define check_pgt_cache() do { } while (0)
85+
86+
#endif /* _ASM_NIOS2_PGALLOC_H */
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
3+
* Copyright (C) 2009 Wind River Systems Inc
4+
*
5+
* This file is subject to the terms and conditions of the GNU General Public
6+
* License. See the file "COPYING" in the main directory of this archive
7+
* for more details.
8+
*/
9+
10+
#ifndef _ASM_NIOS2_PGTABLE_BITS_H
11+
#define _ASM_NIOS2_PGTABLE_BITS_H
12+
13+
/*
14+
* These are actual hardware defined protection bits in the tlbacc register
15+
* which looks like this:
16+
*
17+
* 31 30 ... 26 25 24 23 22 21 20 19 18 ... 1 0
18+
* ignored........ C R W X G PFN............
19+
*/
20+
#define _PAGE_GLOBAL (1<<20)
21+
#define _PAGE_EXEC (1<<21)
22+
#define _PAGE_WRITE (1<<22)
23+
#define _PAGE_READ (1<<23)
24+
#define _PAGE_CACHED (1<<24) /* C: data access cacheable */
25+
26+
/*
27+
* Software defined bits. They are ignored by the hardware and always read back
28+
* as zero, but can be written as non-zero.
29+
*/
30+
#define _PAGE_PRESENT (1<<25) /* PTE contains a translation */
31+
#define _PAGE_ACCESSED (1<<26) /* page referenced */
32+
#define _PAGE_DIRTY (1<<27) /* dirty page */
33+
#define _PAGE_FILE (1<<28) /* PTE used for file mapping or swap */
34+
35+
#endif /* _ASM_NIOS2_PGTABLE_BITS_H */

0 commit comments

Comments
 (0)