OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-armnommu/] [proc-armo/] [pgtable-flat.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
/*
2
 * linux/include/asm-arm/proc-armo/pgtable.h
3
 *
4
 * Copyright (C) 1995, 1996 Russell King
5
 */
6
#ifndef __ASM_PROC_PGTABLE_H
7
#define __ASM_PROC_PGTABLE_H
8
 
9
#include <asm/arch/mmu.h>
10
 
11
#define LIBRARY_TEXT_START 0x0c000000
12
 
13
/*
14
 * Cache flushing...
15
 */
16
#define flush_cache_all()                       do { } while (0)
17
#define flush_cache_mm(mm)                      do { } while (0)
18
#define flush_cache_range(mm,start,end)         do { } while (0)
19
#define flush_cache_page(vma,vmaddr)            do { } while (0)
20
#define flush_page_to_ram(page)                 do { } while (0)
21
 
22
/*
23
 * TLB flushing:
24
 *
25
 *  - flush_tlb() flushes the current mm struct TLBs
26
 *  - flush_tlb_all() flushes all processes TLBs
27
 *  - flush_tlb_mm(mm) flushes the specified mm context TLB's
28
 *  - flush_tlb_page(vma, vmaddr) flushes one page
29
 *  - flush_tlb_range(mm, start, end) flushes a range of pages
30
 */
31
 
32
#define flush_tlb() flush_tlb_mm(current->mm)
33
 
34
extern __inline__ void flush_tlb_all(void)
35
{
36
        struct task_struct *p;
37
 
38
        p = &init_task;
39
        do {
40
                processor.u.armv2._update_map(p);
41
                p = p->next_task;
42
        } while (p != &init_task);
43
 
44
        processor.u.armv2._remap_memc (current);
45
}
46
 
47
extern __inline__ void flush_tlb_mm(struct mm_struct *mm)
48
{
49
        struct task_struct *p;
50
 
51
        p = &init_task;
52
        do {
53
                if (p->mm == mm)
54
                        processor.u.armv2._update_map(p);
55
                p = p->next_task;
56
        } while (p != &init_task);
57
 
58
        if (current->mm == mm)
59
                processor.u.armv2._remap_memc (current);
60
}
61
 
62
#define flush_tlb_range(mm, start, end) flush_tlb_mm(mm)
63
#define flush_tlb_page(vma, vmaddr) flush_tlb_mm(vma->vm_mm)
64
 
65
#define __flush_entry_to_ram(entry)
66
 
67
/* Certain architectures need to do special things when pte's
68
 * within a page table are directly modified.  Thus, the following
69
 * hook is made available.
70
 */
71
#define set_pte(pteptr, pteval) ((*(pteptr)) = (pteval))
72
 
73
/* PMD_SHIFT determines the size of the area a second-level page table can map */
74
#define PMD_SHIFT       PAGE_SHIFT
75
#define PMD_SIZE        (1UL << PMD_SHIFT)
76
#define PMD_MASK        (~(PMD_SIZE-1))
77
 
78
/* PGDIR_SHIFT determines what a third-level page table entry can map */
79
#define PGDIR_SHIFT     PAGE_SHIFT
80
#define PGDIR_SIZE      (1UL << PGDIR_SHIFT)
81
#define PGDIR_MASK      (~(PGDIR_SIZE-1))
82
 
83
/*
84
 * entries per page directory level: the arm3 is one-level, so
85
 * we don't really have any PMD or PTE directory physically.
86
 */
87
#define PTRS_PER_PTE    1
88
#define PTRS_PER_PMD    1
89
#define PTRS_PER_PGD    1024
90
 
91
/* Just any arbitrary offset to the start of the vmalloc VM area: the
92
 * current 8MB value just means that there will be a 8MB "hole" after the
93
 * physical memory until the kernel virtual memory starts.  That means that
94
 * any out-of-bounds memory accesses will hopefully be caught.
95
 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
96
 * area for the same reason. ;)
97
 */
98
#define VMALLOC_START   0x01a00000
99
#define VMALLOC_VMADDR(x) ((unsigned long)(x))
100
 
101
#define _PAGE_PRESENT   0x001
102
#define _PAGE_RW        0x002
103
#define _PAGE_USER      0x004
104
#define _PAGE_PCD       0x010
105
#define _PAGE_ACCESSED  0x020
106
#define _PAGE_DIRTY     0x040
107
 
108
#define _PAGE_TABLE     (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
109
#define _PAGE_CHG_MASK  (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
110
 
111
#define PAGE_NONE       __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED)
112
#define PAGE_SHARED     __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED)
113
#define PAGE_COPY       __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
114
#define PAGE_READONLY   __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
115
#define PAGE_KERNEL     __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
116
 
117
/*
118
 * The arm can't do page protection for execute, and considers that the same are read.
119
 * Also, write permissions imply read permissions. This is the closest we can get..
120
 */
121
#define __P000  PAGE_NONE
122
#define __P001  PAGE_READONLY
123
#define __P010  PAGE_COPY
124
#define __P011  PAGE_COPY
125
#define __P100  PAGE_READONLY
126
#define __P101  PAGE_READONLY
127
#define __P110  PAGE_COPY
128
#define __P111  PAGE_COPY
129
 
130
#define __S000  PAGE_NONE
131
#define __S001  PAGE_READONLY
132
#define __S010  PAGE_SHARED
133
#define __S011  PAGE_SHARED
134
#define __S100  PAGE_READONLY
135
#define __S101  PAGE_READONLY
136
#define __S110  PAGE_SHARED
137
#define __S111  PAGE_SHARED
138
 
139
#undef TEST_VERIFY_AREA
140
 
141
/*
142
 * BAD_PAGE is used for a bogus page.
143
 *
144
 * ZERO_PAGE is a global shared page that is always zero: used
145
 * for zero-mapped memory areas etc..
146
 */
147
extern pte_t __bad_page(void);
148
extern unsigned long *empty_zero_page;
149
 
150
#define BAD_PAGE __bad_page()
151
#define ZERO_PAGE ((unsigned long) empty_zero_page)
152
 
153
/* number of bits that fit into a memory pointer */
154
#define BYTES_PER_PTR                   (sizeof(unsigned long))
155
#define BITS_PER_PTR                    (8*BYTES_PER_PTR)
156
 
157
/* to align the pointer to a pointer address */
158
#define PTR_MASK                        (~(sizeof(void*)-1))
159
 
160
/* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */
161
#define SIZEOF_PTR_LOG2                 2
162
 
163
/* to find an entry in a page-table */
164
#define PAGE_PTR(address) \
165
((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
166
 
167
/* to set the page-dir */
168
#define SET_PAGE_DIR(tsk,pgdir)                                         \
169
do {                                                                    \
170
        tsk->tss.memmap = (unsigned long)pgdir;                         \
171
        processor.u.armv2._update_map(tsk);                             \
172
        if ((tsk) == current)                                           \
173
                processor.u.armv2._remap_memc (current);                \
174
} while (0)
175
 
176
extern unsigned long physical_start;
177
extern unsigned long physical_end;
178
 
179
extern inline int pte_none(pte_t pte)           { return !pte_val(pte); }
180
extern inline int pte_present(pte_t pte)        { return pte_val(pte) & _PAGE_PRESENT; }
181
extern inline void pte_clear(pte_t *ptep)       { pte_val(*ptep) = 0; }
182
 
183
extern inline int pmd_none(pmd_t pmd)           { return 0; }
184
extern inline int pmd_bad(pmd_t pmd)            { return 0; }
185
extern inline int pmd_present(pmd_t pmd)        { return 1; }
186
extern inline void pmd_clear(pmd_t * pmdp)      { }
187
 
188
/*
189
 * The "pgd_xxx()" functions here are trivial for a folded two-level
190
 * setup: the pgd is never bad, and a pmd always exists (as it's folded
191
 * into the pgd entry)
192
 */
193
extern inline int pgd_none(pgd_t pgd)           { return 0; }
194
extern inline int pgd_bad(pgd_t pgd)            { return 0; }
195
extern inline int pgd_present(pgd_t pgd)        { return 1; }
196
extern inline void pgd_clear(pgd_t * pgdp)      { }
197
 
198
/*
199
 * The following only work if pte_present() is true.
200
 * Undefined behaviour if not..
201
 */
202
extern inline int pte_read(pte_t pte)           { return pte_val(pte) & _PAGE_USER; }
203
extern inline int pte_write(pte_t pte)          { return pte_val(pte) & _PAGE_RW; }
204
extern inline int pte_exec(pte_t pte)           { return pte_val(pte) & _PAGE_USER; }
205
extern inline int pte_dirty(pte_t pte)          { return pte_val(pte) & _PAGE_DIRTY; }
206
extern inline int pte_young(pte_t pte)          { return pte_val(pte) & _PAGE_ACCESSED; }
207
#define pte_cacheable(pte) 1
208
 
209
extern inline pte_t pte_nocache(pte_t pte)      { return pte; }
210
extern inline pte_t pte_wrprotect(pte_t pte)    { pte_val(pte) &= ~_PAGE_RW; return pte; }
211
extern inline pte_t pte_rdprotect(pte_t pte)    { pte_val(pte) &= ~_PAGE_USER; return pte; }
212
extern inline pte_t pte_exprotect(pte_t pte)    { pte_val(pte) &= ~_PAGE_USER; return pte; }
213
extern inline pte_t pte_mkclean(pte_t pte)      { pte_val(pte) &= ~_PAGE_DIRTY; return pte; }
214
extern inline pte_t pte_mkold(pte_t pte)        { pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
215
extern inline pte_t pte_mkwrite(pte_t pte)      { pte_val(pte) |= _PAGE_RW; return pte; }
216
extern inline pte_t pte_mkread(pte_t pte)       { pte_val(pte) |= _PAGE_USER; return pte; }
217
extern inline pte_t pte_mkexec(pte_t pte)       { pte_val(pte) |= _PAGE_USER; return pte; }
218
extern inline pte_t pte_mkdirty(pte_t pte)      { pte_val(pte) |= _PAGE_DIRTY; return pte; }
219
extern inline pte_t pte_mkyoung(pte_t pte)      { pte_val(pte) |= _PAGE_ACCESSED; return pte; }
220
 
221
/*
222
 * Conversion functions: convert a page and protection to a page entry,
223
 * and a page entry and page directory to the page they refer to.
224
 */
225
extern inline pte_t mk_pte(unsigned long page, pgprot_t pgprot)
226
{ pte_t pte; pte_val(pte) = virt_to_phys(page) | pgprot_val(pgprot); return pte; }
227
 
228
extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
229
{ pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; }
230
 
231
extern inline unsigned long pte_page(pte_t pte)
232
{ return phys_to_virt(pte_val(pte) & PAGE_MASK); }
233
 
234
extern inline unsigned long pmd_page(pmd_t pmd)
235
{ return phys_to_virt(pmd_val(pmd) & PAGE_MASK); }
236
 
237
/* to find an entry in a page-table-directory */
238
extern inline pgd_t * pgd_offset(struct mm_struct * mm, unsigned long address)
239
{
240
        return mm->pgd + (address >> PGDIR_SHIFT);
241
}
242
 
243
/* Find an entry in the second-level page table.. */
244
#define pmd_offset(dir, address) ((pmd_t *)(dir))
245
 
246
/* Find an entry in the third-level page table.. */
247
#define pte_offset(dir, address) ((pte_t *)(dir))
248
 
249
/*
250
 * Allocate and free page tables. The xxx_kernel() versions are
251
 * used to allocate a kernel page table - this turns on ASN bits
252
 * if any.
253
 */
254
extern inline void pte_free_kernel(pte_t * pte)
255
{
256
        pte_val(*pte) = 0;
257
}
258
 
259
extern inline pte_t * pte_alloc_kernel(pmd_t *pmd, unsigned long address)
260
{
261
        return (pte_t *) pmd;
262
}
263
 
264
/*
265
 * allocating and freeing a pmd is trivial: the 1-entry pmd is
266
 * inside the pgd, so has no extra memory associated with it.
267
 */
268
#define pmd_free_kernel(pmdp)
269
#define pmd_alloc_kernel(pgd,address) ((pmd_t *)(pgd))
270
 
271
#define pte_free(ptep)
272
#define pte_alloc(pmd,address) ((pte_t *)(pmd))
273
 
274
/*
275
 * allocating and freeing a pmd is trivial: the 1-entry pmd is
276
 * inside the pgd, so has no extra memory associated with it.
277
 */
278
#define pmd_free(pmd)
279
#define pmd_alloc(pgd,address) ((pmd_t *)(pgd))
280
 
281
extern inline void pgd_free(pgd_t * pgd)
282
{
283
        extern void kfree(void *);
284
        kfree((void *)pgd);
285
}
286
 
287
extern inline pgd_t * pgd_alloc(void)
288
{
289
        pgd_t *pgd;
290
        extern void *kmalloc(unsigned int, int);
291
 
292
        pgd = (pgd_t *) kmalloc(PTRS_PER_PGD * BYTES_PER_PTR, GFP_KERNEL);
293
        if (pgd)
294
                memset(pgd, 0, PTRS_PER_PGD * BYTES_PER_PTR);
295
        return pgd;
296
}
297
 
298
extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
299
 
300
#define update_mmu_cache(vma,address,pte) processor.u.armv2._update_mmu_cache(vma,address,pte)
301
 
302
#define SWP_TYPE(entry) (((entry) >> 1) & 0x7f)
303
#define SWP_OFFSET(entry) ((entry) >> 8)
304
#define SWP_ENTRY(type,offset) (((type) << 1) | ((offset) <<  8))
305
 
306
#endif /* __ASM_PROC_PAGE_H */
307
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.