blob: bb5c2ac4055d3728d47467873161d1255a3ccfc1 [file] [log] [blame]
Sam Ravnborgf5e706a2008-07-17 21:55:51 -07001/*
2 * page.h: Various defines and such for MMU operations on the Sparc for
3 * the Linux kernel.
4 *
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */
7
8#ifndef _SPARC_PAGE_H
9#define _SPARC_PAGE_H
10
Sam Ravnborga4b4f432011-12-29 15:04:38 +010011#include <linux/const.h>
Adrian Bunk5110bd22008-08-31 20:59:37 -070012
Sam Ravnborga4b4f432011-12-29 15:04:38 +010013#define PAGE_SHIFT 12
14#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070015#define PAGE_MASK (~(PAGE_SIZE-1))
16
17#include <asm/btfixup.h>
18
19#ifndef __ASSEMBLY__
20
21#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
22#define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
23#define clear_user_page(addr, vaddr, page) \
24 do { clear_page(addr); \
25 sparc_flush_page_to_ram(page); \
26 } while (0)
27#define copy_user_page(to, from, vaddr, page) \
28 do { copy_page(to, from); \
29 sparc_flush_page_to_ram(page); \
30 } while (0)
31
32/* The following structure is used to hold the physical
33 * memory configuration of the machine. This is filled in
34 * prom_meminit() and is later used by mem_init() to set up
35 * mem_map[]. We statically allocate SPARC_PHYS_BANKS+1 of
36 * these structs, this is arbitrary. The entry after the
37 * last valid one has num_bytes==0.
38 */
39struct sparc_phys_banks {
40 unsigned long base_addr;
41 unsigned long num_bytes;
42};
43
44#define SPARC_PHYS_BANKS 32
45
46extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS+1];
47
48/* Cache alias structure. Entry is valid if context != -1. */
49struct cache_palias {
50 unsigned long vaddr;
51 int context;
52};
53
54/* passing structs on the Sparc slow us down tremendously... */
55
56/* #define STRICT_MM_TYPECHECKS */
57
58#ifdef STRICT_MM_TYPECHECKS
59/*
60 * These are used to make use of C type-checking..
61 */
62typedef struct { unsigned long pte; } pte_t;
63typedef struct { unsigned long iopte; } iopte_t;
64typedef struct { unsigned long pmdv[16]; } pmd_t;
65typedef struct { unsigned long pgd; } pgd_t;
66typedef struct { unsigned long ctxd; } ctxd_t;
67typedef struct { unsigned long pgprot; } pgprot_t;
68typedef struct { unsigned long iopgprot; } iopgprot_t;
69
70#define pte_val(x) ((x).pte)
71#define iopte_val(x) ((x).iopte)
72#define pmd_val(x) ((x).pmdv[0])
73#define pgd_val(x) ((x).pgd)
74#define ctxd_val(x) ((x).ctxd)
75#define pgprot_val(x) ((x).pgprot)
76#define iopgprot_val(x) ((x).iopgprot)
77
78#define __pte(x) ((pte_t) { (x) } )
79#define __iopte(x) ((iopte_t) { (x) } )
80/* #define __pmd(x) ((pmd_t) { (x) } ) */ /* XXX procedure with loop */
81#define __pgd(x) ((pgd_t) { (x) } )
82#define __ctxd(x) ((ctxd_t) { (x) } )
83#define __pgprot(x) ((pgprot_t) { (x) } )
84#define __iopgprot(x) ((iopgprot_t) { (x) } )
85
86#else
87/*
88 * .. while these make it easier on the compiler
89 */
90typedef unsigned long pte_t;
91typedef unsigned long iopte_t;
92typedef struct { unsigned long pmdv[16]; } pmd_t;
93typedef unsigned long pgd_t;
94typedef unsigned long ctxd_t;
95typedef unsigned long pgprot_t;
96typedef unsigned long iopgprot_t;
97
98#define pte_val(x) (x)
99#define iopte_val(x) (x)
100#define pmd_val(x) ((x).pmdv[0])
101#define pgd_val(x) (x)
102#define ctxd_val(x) (x)
103#define pgprot_val(x) (x)
104#define iopgprot_val(x) (x)
105
106#define __pte(x) (x)
107#define __iopte(x) (x)
108/* #define __pmd(x) (x) */ /* XXX later */
109#define __pgd(x) (x)
110#define __ctxd(x) (x)
111#define __pgprot(x) (x)
112#define __iopgprot(x) (x)
113
114#endif
115
116typedef struct page *pgtable_t;
117
118extern unsigned long sparc_unmapped_base;
119
120BTFIXUPDEF_SETHI(sparc_unmapped_base)
121
122#define TASK_UNMAPPED_BASE BTFIXUP_SETHI(sparc_unmapped_base)
123
124#else /* !(__ASSEMBLY__) */
125
126#define __pgprot(x) (x)
127
128#endif /* !(__ASSEMBLY__) */
129
Sam Ravnborgf5e706a2008-07-17 21:55:51 -0700130#define PAGE_OFFSET 0xf0000000
131#ifndef __ASSEMBLY__
132extern unsigned long phys_base;
133extern unsigned long pfn_base;
134#endif
135#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + phys_base)
136#define __va(x) ((void *)((unsigned long) (x) - phys_base + PAGE_OFFSET))
137
138#define virt_to_phys __pa
139#define phys_to_virt __va
140
141#define ARCH_PFN_OFFSET (pfn_base)
David S. Miller86541642010-01-14 03:14:53 -0800142#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
Sam Ravnborgf5e706a2008-07-17 21:55:51 -0700143
144#define pfn_valid(pfn) (((pfn) >= (pfn_base)) && (((pfn)-(pfn_base)) < max_mapnr))
145#define virt_addr_valid(kaddr) ((((unsigned long)(kaddr)-PAGE_OFFSET)>>PAGE_SHIFT) < max_mapnr)
146
147#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
148 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
149
150#include <asm-generic/memory_model.h>
Arnd Bergmann5b17e1c2009-05-13 22:56:30 +0000151#include <asm-generic/getorder.h>
Sam Ravnborgf5e706a2008-07-17 21:55:51 -0700152
153#endif /* _SPARC_PAGE_H */