blob: c53fc63149e8312437fe4109e8070495ba39d90a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _PARISC_PAGE_H
2#define _PARISC_PAGE_H
3
Sam Ravnborg1c593572007-10-18 00:04:34 -07004#include <linux/const.h>
5
Helge Deller2fd83032006-04-20 20:40:23 +00006#if defined(CONFIG_PARISC_PAGE_SIZE_4KB)
Matthew Wilcoxac7fb272006-09-18 20:12:27 -07007# define PAGE_SHIFT 12
Helge Deller2fd83032006-04-20 20:40:23 +00008#elif defined(CONFIG_PARISC_PAGE_SIZE_16KB)
Matthew Wilcoxac7fb272006-09-18 20:12:27 -07009# define PAGE_SHIFT 14
Helge Deller2fd83032006-04-20 20:40:23 +000010#elif defined(CONFIG_PARISC_PAGE_SIZE_64KB)
Matthew Wilcoxac7fb272006-09-18 20:12:27 -070011# define PAGE_SHIFT 16
Helge Deller2fd83032006-04-20 20:40:23 +000012#else
13# error "unknown default kernel page size"
14#endif
Sam Ravnborg1c593572007-10-18 00:04:34 -070015#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
Helge Deller2fd83032006-04-20 20:40:23 +000016#define PAGE_MASK (~(PAGE_SIZE-1))
17
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#ifndef __ASSEMBLY__
20
21#include <asm/types.h>
22#include <asm/cache.h>
23
John David Anglin76334532013-02-03 22:59:09 +000024#define clear_page(page) clear_page_asm((void *)(page))
25#define copy_page(to, from) copy_page_asm((void *)(to), (void *)(from))
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27struct page;
28
John David Anglin76334532013-02-03 22:59:09 +000029void clear_page_asm(void *page);
30void copy_page_asm(void *to, void *from);
John David Anglinf8dae002014-01-05 21:25:00 -050031#define clear_user_page(vto, vaddr, page) clear_page_asm(vto)
32#define copy_user_page(vto, vfrom, vaddr, page) copy_page_asm(vto, vfrom)
John David Anglin76334532013-02-03 22:59:09 +000033
34/* #define CONFIG_PARISC_TMPALIAS */
35
36#ifdef CONFIG_PARISC_TMPALIAS
37void clear_user_highpage(struct page *page, unsigned long vaddr);
38#define clear_user_highpage clear_user_highpage
39struct vm_area_struct;
40void copy_user_highpage(struct page *to, struct page *from,
41 unsigned long vaddr, struct vm_area_struct *vma);
42#define __HAVE_ARCH_COPY_USER_HIGHPAGE
43#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45/*
46 * These are used to make use of C type-checking..
47 */
Helge Dellerb31059f2006-03-23 15:48:15 -070048#define STRICT_MM_TYPECHECKS
49#ifdef STRICT_MM_TYPECHECKS
Helge Deller48d27cb2009-01-18 19:16:16 +010050typedef struct { unsigned long pte; } pte_t; /* either 32 or 64bit */
Helge Dellerb31059f2006-03-23 15:48:15 -070051
Linus Torvalds1da177e2005-04-16 15:20:36 -070052/* NOTE: even on 64 bits, these entries are __u32 because we allocate
53 * the pmd and pgd in ZONE_DMA (i.e. under 4GB) */
54typedef struct { __u32 pmd; } pmd_t;
55typedef struct { __u32 pgd; } pgd_t;
56typedef struct { unsigned long pgprot; } pgprot_t;
57
58#define pte_val(x) ((x).pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -070059/* These do not work lvalues, so make sure we don't use them as such. */
60#define pmd_val(x) ((x).pmd + 0)
61#define pgd_val(x) ((x).pgd + 0)
62#define pgprot_val(x) ((x).pgprot)
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#define __pte(x) ((pte_t) { (x) } )
65#define __pmd(x) ((pmd_t) { (x) } )
66#define __pgd(x) ((pgd_t) { (x) } )
67#define __pgprot(x) ((pgprot_t) { (x) } )
68
Helge Dellerb31059f2006-03-23 15:48:15 -070069#define __pmd_val_set(x,n) (x).pmd = (n)
70#define __pgd_val_set(x,n) (x).pgd = (n)
71
72#else
73/*
74 * .. while these make it easier on the compiler
75 */
76typedef unsigned long pte_t;
77typedef __u32 pmd_t;
78typedef __u32 pgd_t;
79typedef unsigned long pgprot_t;
80
81#define pte_val(x) (x)
82#define pmd_val(x) (x)
83#define pgd_val(x) (x)
84#define pgprot_val(x) (x)
85
86#define __pte(x) (x)
87#define __pmd(x) (x)
88#define __pgd(x) (x)
89#define __pgprot(x) (x)
90
91#define __pmd_val_set(x,n) (x) = (n)
92#define __pgd_val_set(x,n) (x) = (n)
93
94#endif /* STRICT_MM_TYPECHECKS */
95
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080096typedef struct page *pgtable_t;
Helge Dellerb31059f2006-03-23 15:48:15 -070097
Linus Torvalds1da177e2005-04-16 15:20:36 -070098typedef struct __physmem_range {
99 unsigned long start_pfn;
100 unsigned long pages; /* PAGE_SIZE pages */
101} physmem_range_t;
102
103extern physmem_range_t pmem_ranges[];
104extern int npmem_ranges;
105
106#endif /* !__ASSEMBLY__ */
107
108/* WARNING: The definitions below must match exactly to sizeof(pte_t)
109 * etc
110 */
Helge Deller513e7ec2007-01-28 15:09:20 +0100111#ifdef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112#define BITS_PER_PTE_ENTRY 3
113#define BITS_PER_PMD_ENTRY 2
114#define BITS_PER_PGD_ENTRY 2
115#else
Helge Deller48d27cb2009-01-18 19:16:16 +0100116#define BITS_PER_PTE_ENTRY 2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117#define BITS_PER_PMD_ENTRY 2
118#define BITS_PER_PGD_ENTRY BITS_PER_PMD_ENTRY
119#endif
120#define PGD_ENTRY_SIZE (1UL << BITS_PER_PGD_ENTRY)
121#define PMD_ENTRY_SIZE (1UL << BITS_PER_PMD_ENTRY)
122#define PTE_ENTRY_SIZE (1UL << BITS_PER_PTE_ENTRY)
123
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124#define LINUX_GATEWAY_SPACE 0
125
126/* This governs the relationship between virtual and physical addresses.
127 * If you alter it, make sure to take care of our various fixed mapping
128 * segments in fixmap.h */
Kyle McMartincaa451f2006-10-16 00:29:47 -0400129#ifdef CONFIG_64BIT
130#define __PAGE_OFFSET (0x40000000) /* 1GB */
131#else
132#define __PAGE_OFFSET (0x10000000) /* 256MB */
133#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
135#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
136
137/* The size of the gateway page (we leave lots of room for expansion) */
138#define GATEWAY_PAGE_SIZE 0x4000
139
140/* The start of the actual kernel binary---used in vmlinux.lds.S
141 * Leave some space after __PAGE_OFFSET for detecting kernel null
142 * ptr derefs */
143#define KERNEL_BINARY_TEXT_START (__PAGE_OFFSET + 0x100000)
144
145/* These macros don't work for 64-bit C code -- don't allow in C at all */
146#ifdef __ASSEMBLY__
147# define PA(x) ((x)-__PAGE_OFFSET)
148# define VA(x) ((x)+__PAGE_OFFSET)
149#endif
150#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
151#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
152
153#ifndef CONFIG_DISCONTIGMEM
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154#define pfn_valid(pfn) ((pfn) < max_mapnr)
155#endif /* CONFIG_DISCONTIGMEM */
156
Helge Dellere8b736c2006-01-10 20:47:55 -0500157#ifdef CONFIG_HUGETLB_PAGE
158#define HPAGE_SHIFT 22 /* 4MB (is this fixed?) */
159#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
160#define HPAGE_MASK (~(HPAGE_SIZE - 1))
161#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
162#endif
163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
165
166#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
167#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
168
169#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
170 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
171
KAMEZAWA Hiroyuki0d833b42006-03-27 01:15:43 -0800172#include <asm-generic/memory_model.h>
Arnd Bergmann5b17e1c2009-05-13 22:56:30 +0000173#include <asm-generic/getorder.h>
Rolf Eike Beer4a8a0782012-05-10 23:08:17 +0200174#include <asm/pdc.h>
175
176#define PAGE0 ((struct zeropage *)__PAGE_OFFSET)
177
178/* DEFINITION OF THE ZERO-PAGE (PAG0) */
179/* based on work by Jason Eckhardt (jason@equator.com) */
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -0700180
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181#endif /* _PARISC_PAGE_H */