1 /* $Id: page.h,v 1.39 2002/02/09 19:49:31 davem Exp $ */
3 #ifndef _SPARC64_PAGE_H
4 #define _SPARC64_PAGE_H
6 #include <linux/config.h>
10 /* I have my suspicions... -DaveM */
11 #define PAGE_SIZE (1UL << PAGE_SHIFT)
13 #define PAGE_SIZE (1 << PAGE_SHIFT)
16 #define PAGE_MASK (~(PAGE_SIZE-1))
23 /* Sparc64 is slow at multiplication, we prefer to use some extra space. */
24 #define WANT_PAGE_VIRTUAL 1
26 extern void _clear_page(void *page);
27 #define clear_page(X) _clear_page((void *)(X))
29 extern void clear_user_page(void *addr, unsigned long vaddr, struct page *page);
30 #define copy_page(X,Y) __memcpy((void *)(X), (void *)(Y), PAGE_SIZE)
31 extern void copy_user_page(void *to, void *from, unsigned long vaddr, struct page *topage);
33 /* GROSS, defining this makes gcc pass these types as aggregates,
34 * and thus on the stack, turn this crap off... -DaveM
37 /* #define STRICT_MM_TYPECHECKS */
39 #ifdef STRICT_MM_TYPECHECKS
40 /* These are used to make use of C type-checking.. */
41 typedef struct { unsigned long pte; } pte_t;
42 typedef struct { unsigned long iopte; } iopte_t;
43 typedef struct { unsigned int pmd; } pmd_t;
44 typedef struct { unsigned int pgd; } pgd_t;
45 typedef struct { unsigned long ctxd; } ctxd_t;
46 typedef struct { unsigned long pgprot; } pgprot_t;
47 typedef struct { unsigned long iopgprot; } iopgprot_t;
49 #define pte_val(x) ((x).pte)
50 #define iopte_val(x) ((x).iopte)
51 #define pmd_val(x) ((x).pmd)
52 #define pgd_val(x) ((x).pgd)
53 #define ctxd_val(x) ((x).ctxd)
54 #define pgprot_val(x) ((x).pgprot)
55 #define iopgprot_val(x) ((x).iopgprot)
57 #define __pte(x) ((pte_t) { (x) } )
58 #define __iopte(x) ((iopte_t) { (x) } )
59 #define __pmd(x) ((pmd_t) { (x) } )
60 #define __pgd(x) ((pgd_t) { (x) } )
61 #define __ctxd(x) ((ctxd_t) { (x) } )
62 #define __pgprot(x) ((pgprot_t) { (x) } )
63 #define __iopgprot(x) ((iopgprot_t) { (x) } )
66 /* .. while these make it easier on the compiler */
67 typedef unsigned long pte_t;
68 typedef unsigned long iopte_t;
69 typedef unsigned int pmd_t;
70 typedef unsigned int pgd_t;
71 typedef unsigned long ctxd_t;
72 typedef unsigned long pgprot_t;
73 typedef unsigned long iopgprot_t;
75 #define pte_val(x) (x)
76 #define iopte_val(x) (x)
77 #define pmd_val(x) (x)
78 #define pgd_val(x) (x)
79 #define ctxd_val(x) (x)
80 #define pgprot_val(x) (x)
81 #define iopgprot_val(x) (x)
84 #define __iopte(x) (x)
88 #define __pgprot(x) (x)
89 #define __iopgprot(x) (x)
91 #endif /* (STRICT_MM_TYPECHECKS) */
93 #if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
94 #define HPAGE_SHIFT 22
95 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K)
96 #define HPAGE_SHIFT 19
97 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
98 #define HPAGE_SHIFT 16
101 #ifdef CONFIG_HUGETLB_PAGE
102 #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
103 #define HPAGE_MASK (~(HPAGE_SIZE - 1UL))
104 #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
107 #define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \
108 (0x0000000070000000UL) : (PAGE_OFFSET))
110 #endif /* !(__ASSEMBLY__) */
112 /* to align the pointer to the (next) page boundary */
113 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
115 /* We used to stick this into a hard-coded global register (%g4)
116 * but that does not make sense anymore.
118 #define PAGE_OFFSET 0xFFFFF80000000000
120 #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET)
121 #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
123 /* PFNs are real physical page numbers. However, mem_map only begins to record
124 * per-page information starting at pfn_base. This is to handle systems where
125 * the first physical page in the machine is at some huge physical address, such
126 * as 4GB. This is common on a partitioned E10000, for example.
129 #define pfn_to_page(pfn) (mem_map + ((pfn)-(pfn_base)))
130 #define page_to_pfn(page) ((unsigned long)(((page) - mem_map) + pfn_base))
131 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr)>>PAGE_SHIFT)
133 #define pfn_valid(pfn) (((pfn)-(pfn_base)) < max_mapnr)
134 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
136 #define virt_to_phys __pa
137 #define phys_to_virt __va
141 /* The following structure is used to hold the physical
142 * memory configuration of the machine. This is filled in
143 * probe_memory() and is later used by mem_init() to set up
144 * mem_map[]. We statically allocate SPARC_PHYS_BANKS of
145 * these structs, this is arbitrary. The entry after the
146 * last valid one has num_bytes==0.
149 struct sparc_phys_banks {
150 unsigned long base_addr;
151 unsigned long num_bytes;
154 #define SPARC_PHYS_BANKS 32
156 extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
158 /* Pure 2^n version of get_order */
159 static __inline__ int get_order(unsigned long size)
163 size = (size-1) >> (PAGE_SHIFT-1);
172 #endif /* !(__ASSEMBLY__) */
174 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
175 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
177 #endif /* !(__KERNEL__) */
179 #endif /* !(_SPARC64_PAGE_H) */