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>
9 #if defined(CONFIG_SPARC64_PAGE_SIZE_8KB)
11 #elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB)
13 #elif defined(CONFIG_SPARC64_PAGE_SIZE_512KB)
15 #elif defined(CONFIG_SPARC64_PAGE_SIZE_4MB)
18 #error No page size specified in kernel configuration
21 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
22 #define PAGE_MASK (~(PAGE_SIZE-1))
28 extern void _clear_page(void *page
);
29 #define clear_page(X) _clear_page((void *)(X))
31 extern void clear_user_page(void *addr
, unsigned long vaddr
, struct page
*page
);
32 #define copy_page(X,Y) memcpy((void *)(X), (void *)(Y), PAGE_SIZE)
33 extern void copy_user_page(void *to
, void *from
, unsigned long vaddr
, struct page
*topage
);
35 /* Unlike sparc32, sparc64's parameter passing API is more
36 * sane in that structures which as small enough are passed
37 * in registers instead of on the stack. Thus, setting
38 * STRICT_MM_TYPECHECKS does not generate worse code so
39 * let's enable it to get the type checking.
42 #define STRICT_MM_TYPECHECKS
44 #ifdef STRICT_MM_TYPECHECKS
45 /* These are used to make use of C type-checking.. */
46 typedef struct { unsigned long pte
; } pte_t
;
47 typedef struct { unsigned long iopte
; } iopte_t
;
48 typedef struct { unsigned int pmd
; } pmd_t
;
49 typedef struct { unsigned int pgd
; } pgd_t
;
50 typedef struct { unsigned long pgprot
; } pgprot_t
;
52 #define pte_val(x) ((x).pte)
53 #define iopte_val(x) ((x).iopte)
54 #define pmd_val(x) ((x).pmd)
55 #define pgd_val(x) ((x).pgd)
56 #define pgprot_val(x) ((x).pgprot)
58 #define __pte(x) ((pte_t) { (x) } )
59 #define __iopte(x) ((iopte_t) { (x) } )
60 #define __pmd(x) ((pmd_t) { (x) } )
61 #define __pgd(x) ((pgd_t) { (x) } )
62 #define __pgprot(x) ((pgprot_t) { (x) } )
65 /* .. while these make it easier on the compiler */
66 typedef unsigned long pte_t
;
67 typedef unsigned long iopte_t
;
68 typedef unsigned int pmd_t
;
69 typedef unsigned int pgd_t
;
70 typedef unsigned long pgprot_t
;
72 #define pte_val(x) (x)
73 #define iopte_val(x) (x)
74 #define pmd_val(x) (x)
75 #define pgd_val(x) (x)
76 #define pgprot_val(x) (x)
79 #define __iopte(x) (x)
82 #define __pgprot(x) (x)
84 #endif /* (STRICT_MM_TYPECHECKS) */
86 #if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
87 #define HPAGE_SHIFT 22
88 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K)
89 #define HPAGE_SHIFT 19
90 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
91 #define HPAGE_SHIFT 16
94 #ifdef CONFIG_HUGETLB_PAGE
95 #define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
96 #define HPAGE_MASK (~(HPAGE_SIZE - 1UL))
97 #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
100 #define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \
101 (_AC(0x0000000070000000,UL)) : (PAGE_OFFSET))
103 #endif /* !(__ASSEMBLY__) */
105 /* to align the pointer to the (next) page boundary */
106 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
108 /* We used to stick this into a hard-coded global register (%g4)
109 * but that does not make sense anymore.
111 #define PAGE_OFFSET _AC(0xFFFFF80000000000,UL)
115 #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET)
116 #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
118 /* PFNs are real physical page numbers. However, mem_map only begins to record
119 * per-page information starting at pfn_base. This is to handle systems where
120 * the first physical page in the machine is at some huge physical address,
121 * such as 4GB. This is common on a partitioned E10000, for example.
123 extern struct page
*pfn_to_page(unsigned long pfn
);
124 extern unsigned long page_to_pfn(struct page
*);
126 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr)>>PAGE_SHIFT)
128 #define pfn_valid(pfn) (((pfn)-(pfn_base)) < max_mapnr)
129 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
131 #define virt_to_phys __pa
132 #define phys_to_virt __va
134 /* The following structure is used to hold the physical
135 * memory configuration of the machine. This is filled in
136 * probe_memory() and is later used by mem_init() to set up
137 * mem_map[]. We statically allocate SPARC_PHYS_BANKS of
138 * these structs, this is arbitrary. The entry after the
139 * last valid one has num_bytes==0.
142 struct sparc_phys_banks
{
143 unsigned long base_addr
;
144 unsigned long num_bytes
;
147 #define SPARC_PHYS_BANKS 32
149 extern struct sparc_phys_banks sp_banks
[SPARC_PHYS_BANKS
];
151 /* Pure 2^n version of get_order */
152 static __inline__
int get_order(unsigned long size
)
156 size
= (size
-1) >> (PAGE_SHIFT
-1);
165 #endif /* !(__ASSEMBLY__) */
167 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
168 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
170 #endif /* !(__KERNEL__) */
172 #endif /* !(_SPARC64_PAGE_H) */