2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 1994 - 1999, 2000 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
12 #include <linux/config.h>
14 /* PAGE_SHIFT determines the page size */
16 #define PAGE_SIZE (1UL << PAGE_SHIFT)
17 #define PAGE_MASK (~(PAGE_SIZE-1))
23 #define BUG() do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; } while (0)
24 #define PAGE_BUG(page) do { BUG(); } while (0)
27 * Prototypes for clear_page / copy_page variants with processor dependant
30 void sb1_clear_page(void * page);
31 void sb1_copy_page(void * to, void * from);
33 extern void (*_clear_page)(void * page);
34 extern void (*_copy_page)(void * to, void * from);
35 extern void mips64_clear_page_dc(unsigned long page);
36 extern void mips64_clear_page_sc(unsigned long page);
37 extern void mips64_copy_page_dc(unsigned long to, unsigned long from);
38 extern void mips64_copy_page_sc(unsigned long to, unsigned long from);
40 #define clear_page(page) _clear_page(page)
41 #define copy_page(to, from) _copy_page(to, from)
42 #define clear_user_page(page, vaddr) clear_page(page)
43 #define copy_user_page(to, from, vaddr) copy_page(to, from)
46 * These are used to make use of C type-checking..
48 typedef struct { unsigned long pte; } pte_t;
49 typedef struct { unsigned long pmd; } pmd_t;
50 typedef struct { unsigned long pgd; } pgd_t;
51 typedef struct { unsigned long pgprot; } pgprot_t;
53 #define pte_val(x) ((x).pte)
54 #define pmd_val(x) ((x).pmd)
55 #define pgd_val(x) ((x).pgd)
56 #define pgprot_val(x) ((x).pgprot)
58 #define ptep_buddy(x) ((pte_t *)((unsigned long)(x) ^ sizeof(pte_t)))
60 #define __pte(x) ((pte_t) { (x) } )
61 #define __pmd(x) ((pmd_t) { (x) } )
62 #define __pgd(x) ((pgd_t) { (x) } )
63 #define __pgprot(x) ((pgprot_t) { (x) } )
65 /* Pure 2^n version of get_order */
66 extern __inline__ int get_order(unsigned long size)
70 size = (size-1) >> (PAGE_SHIFT-1);
79 #endif /* !__ASSEMBLY__ */
81 /* to align the pointer to the (next) page boundary */
82 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
85 * This handles the memory map.
86 * We handle pages at KSEG0 for kernels with upto 512mb of memory,
87 * at XKPHYS with a suitable caching mode for kernels with more than that.
89 #if defined(CONFIG_SGI_IP22) || defined(CONFIG_MIPS_ATLAS) || \
90 defined(CONFIG_MIPS_MALTA)
91 #define PAGE_OFFSET 0xffffffff80000000UL
92 #define UNCAC_BASE 0xffffffffa0000000UL
94 #if defined(CONFIG_SGI_IP32)
95 #define PAGE_OFFSET 0x9800000000000000UL
96 #define UNCAC_BASE 0x9000000000000000UL
98 #if defined(CONFIG_SGI_IP27)
99 #define PAGE_OFFSET 0xa800000000000000UL
100 #define UNCAC_BASE 0x9000000000000000UL
102 #if defined(CONFIG_SIBYTE_SB1250)
103 #define PAGE_OFFSET 0xa800000000000000UL
106 #define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
107 #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
108 #ifndef CONFIG_DISCONTIGMEM
109 #define virt_to_page(kaddr) (mem_map + (__pa(kaddr) >> PAGE_SHIFT))
110 #define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
113 #define UNCAC_ADDR(addr) ((addr) - PAGE_OFFSET + UNCAC_BASE)
114 #define CAC_ADDR(addr) ((addr) - UNCAC_BASE + PAGE_OFFSET)
116 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
117 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
119 #endif /* defined (__KERNEL__) */
121 #endif /* _ASM_PAGE_H */