blob: a4a8f8b93463f000970baae167c1199ceb0005f5 [file] [log] [blame]
Paul Mundt26ff6c12006-09-27 15:13:36 +09001/*
2 * This file contains the functions and defines necessary to modify and
3 * use the SuperH page table tree.
4 *
5 * Copyright (C) 1999 Niibe Yutaka
Paul Mundt249cfea2007-11-19 18:26:19 +09006 * Copyright (C) 2002 - 2007 Paul Mundt
Paul Mundt26ff6c12006-09-27 15:13:36 +09007 *
8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file "COPYING" in the main directory of this
10 * archive for more details.
11 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#ifndef __ASM_SH_PGTABLE_H
13#define __ASM_SH_PGTABLE_H
14
Paul Mundt26ff6c12006-09-27 15:13:36 +090015#include <asm-generic/pgtable-nopmd.h>
16#include <asm/page.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#ifndef __ASSEMBLY__
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/addrspace.h>
20#include <asm/fixmap.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Linus Torvalds1da177e2005-04-16 15:20:36 -070022/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 * ZERO_PAGE is a global shared page that is always zero: used
24 * for zero-mapped memory areas etc..
25 */
Paul Mundt26ff6c12006-09-27 15:13:36 +090026extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
28
29#endif /* !__ASSEMBLY__ */
30
Paul Mundt21440cf2006-11-20 14:30:26 +090031/*
Paul Mundt36bcd392007-11-10 19:16:55 +090032 * Effective and physical address definitions, to aid with sign
33 * extension.
34 */
35#define NEFF 32
36#define NEFF_SIGN (1LL << (NEFF - 1))
37#define NEFF_MASK (-1LL << NEFF)
38
39#ifdef CONFIG_29BIT
40#define NPHYS 29
41#else
42#define NPHYS 32
43#endif
44
45#define NPHYS_SIGN (1LL << (NPHYS - 1))
46#define NPHYS_MASK (-1LL << NPHYS)
47
48/*
Paul Mundt21440cf2006-11-20 14:30:26 +090049 * traditional two-level paging structure
50 */
51/* PTE bits */
Paul Mundt55183e92007-11-21 16:19:12 +090052#if defined(CONFIG_X2TLB) || defined(CONFIG_SUPERH64)
Paul Mundt21440cf2006-11-20 14:30:26 +090053# define PTE_MAGNITUDE 3 /* 64-bit PTEs on extended mode SH-X2 TLB */
54#else
55# define PTE_MAGNITUDE 2 /* 32-bit PTEs */
56#endif
57#define PTE_SHIFT PAGE_SHIFT
58#define PTE_BITS (PTE_SHIFT - PTE_MAGNITUDE)
59
60/* PGD bits */
61#define PGDIR_SHIFT (PTE_SHIFT + PTE_BITS)
Paul Mundtdb2e1fa2007-02-14 14:13:10 +090062#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#define PGDIR_MASK (~(PGDIR_SIZE-1))
64
Paul Mundt21440cf2006-11-20 14:30:26 +090065/* Entries per level */
Paul Mundt7a847f82006-12-26 15:29:19 +090066#define PTRS_PER_PTE (PAGE_SIZE / (1 << PTE_MAGNITUDE))
Paul Mundtd04a0f72007-09-21 11:55:03 +090067#define PTRS_PER_PGD (PAGE_SIZE / sizeof(pgd_t))
Paul Mundt21440cf2006-11-20 14:30:26 +090068
Linus Torvalds1da177e2005-04-16 15:20:36 -070069#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
Hugh Dickinsd455a362005-04-19 13:29:23 -070070#define FIRST_USER_ADDRESS 0
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Stuart Menefyd02b08f2007-11-30 17:52:53 +090072#ifdef CONFIG_32BIT
73#define PHYS_ADDR_MASK 0xffffffff
74#else
75#define PHYS_ADDR_MASK 0x1fffffff
76#endif
77
78#define PTE_PHYS_MASK (PHYS_ADDR_MASK & PAGE_MASK)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
Paul Mundt0468b4b2007-11-10 20:39:06 +090080#ifdef CONFIG_SUPERH32
Paul Mundtf0b859e2007-07-25 10:43:47 +090081#define VMALLOC_START (P3SEG)
Paul Mundt0468b4b2007-11-10 20:39:06 +090082#else
83#define VMALLOC_START (0xf0000000)
84#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070085#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
86
Paul Mundt249cfea2007-11-19 18:26:19 +090087#if defined(CONFIG_SUPERH32)
88#include <asm/pgtable_32.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070089#else
Paul Mundt249cfea2007-11-19 18:26:19 +090090#include <asm/pgtable_64.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070091#endif
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093/*
Paul Mundt21440cf2006-11-20 14:30:26 +090094 * SH-X and lower (legacy) SuperH parts (SH-3, SH-4, some SH-4A) can't do page
95 * protection for execute, and considers it the same as a read. Also, write
96 * permission implies read permission. This is the closest we can get..
97 *
98 * SH-X2 (SH7785) and later parts take this to the opposite end of the extreme,
99 * not only supporting separate execute, read, and write bits, but having
100 * completely separate permission bits for user and kernel space.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 */
Paul Mundt21440cf2006-11-20 14:30:26 +0900102 /*xwr*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103#define __P000 PAGE_NONE
104#define __P001 PAGE_READONLY
105#define __P010 PAGE_COPY
106#define __P011 PAGE_COPY
Paul Mundt21440cf2006-11-20 14:30:26 +0900107#define __P100 PAGE_EXECREAD
108#define __P101 PAGE_EXECREAD
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109#define __P110 PAGE_COPY
110#define __P111 PAGE_COPY
111
112#define __S000 PAGE_NONE
113#define __S001 PAGE_READONLY
Paul Mundt21440cf2006-11-20 14:30:26 +0900114#define __S010 PAGE_WRITEONLY
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115#define __S011 PAGE_SHARED
Paul Mundt21440cf2006-11-20 14:30:26 +0900116#define __S100 PAGE_EXECREAD
117#define __S101 PAGE_EXECREAD
118#define __S110 PAGE_RWX
119#define __S111 PAGE_RWX
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121typedef pte_t *pte_addr_t;
122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123#define kern_addr_valid(addr) (1)
124
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
126 remap_pfn_range(vma, vaddr, pfn, size, prot)
127
Paul Mundt249cfea2007-11-19 18:26:19 +0900128#define pte_pfn(x) ((unsigned long)(((x).pte_low >> PAGE_SHIFT)))
Tim Schmielau8c65b4a2005-11-07 00:59:43 -0800129
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130/*
131 * No page table caches to initialise
132 */
133#define pgtable_cache_init() do { } while (0)
134
Paul Mundte7bd34a2007-07-31 17:07:28 +0900135#if !defined(CONFIG_CACHE_OFF) && (defined(CONFIG_CPU_SH4) || \
136 defined(CONFIG_SH7705_CACHE_32KB))
Paul Mundt249cfea2007-11-19 18:26:19 +0900137struct mm_struct;
Paul Mundt39e688a2007-03-05 19:46:47 +0900138#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
Paul Mundt249cfea2007-11-19 18:26:19 +0900139pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
Paul Mundt39e688a2007-03-05 19:46:47 +0900140#endif
141
Paul Mundt249cfea2007-11-19 18:26:19 +0900142struct vm_area_struct;
143extern void update_mmu_cache(struct vm_area_struct * vma,
144 unsigned long address, pte_t pte);
Paul Mundt21440cf2006-11-20 14:30:26 +0900145extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
146extern void paging_init(void);
Paul Mundt9acb98f2007-12-17 10:52:11 +0900147extern void page_table_range_init(unsigned long start, unsigned long end,
148 pgd_t *pgd);
Paul Mundt21440cf2006-11-20 14:30:26 +0900149
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150#include <asm-generic/pgtable.h>
151
Paul Mundt249cfea2007-11-19 18:26:19 +0900152#endif /* __ASM_SH_PGTABLE_H */