4 #include <linux/config.h>
7 /* PAGE_SHIFT determines the page size */
9 #define PAGE_SIZE (1UL << PAGE_SHIFT)
10 #define PAGE_MASK (~(PAGE_SIZE-1))
14 #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
15 #define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
17 #define clear_user_page(page, vaddr) clear_page(page)
18 #define copy_user_page(to, from, vaddr) copy_page(to, from)
20 #define STRICT_MM_TYPECHECKS
22 #ifdef STRICT_MM_TYPECHECKS
24 * These are used to make use of C type-checking..
26 typedef struct { unsigned long pte; } pte_t;
27 typedef struct { unsigned long pmd; } pmd_t;
28 typedef struct { unsigned long pgd; } pgd_t;
29 typedef struct { unsigned long pgprot; } pgprot_t;
31 #define pte_val(x) ((x).pte)
32 #define pmd_val(x) ((x).pmd)
33 #define pgd_val(x) ((x).pgd)
34 #define pgprot_val(x) ((x).pgprot)
36 #define __pte(x) ((pte_t) { (x) } )
37 #define __pmd(x) ((pmd_t) { (x) } )
38 #define __pgd(x) ((pgd_t) { (x) } )
39 #define __pgprot(x) ((pgprot_t) { (x) } )
43 * .. while these make it easier on the compiler
45 typedef unsigned long pte_t;
46 typedef unsigned long pmd_t;
47 typedef unsigned long pgd_t;
48 typedef unsigned long pgprot_t;
50 #define pte_val(x) (x)
51 #define pmd_val(x) (x)
52 #define pgd_val(x) (x)
53 #define pgprot_val(x) (x)
58 #define __pgprot(x) (x)
62 /* to align the pointer to the (next) page boundary */
63 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
65 /* This handles the memory map.. */
67 #ifdef CONFIG_CRIS_LOW_MAP
68 #define PAGE_OFFSET KSEG_6 /* kseg_6 is mapped to physical ram */
70 #define PAGE_OFFSET KSEG_C /* kseg_c is mapped to physical ram */
76 printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
79 #define PAGE_BUG(page) do { \
83 /* Pure 2^n version of get_order */
84 static __inline__ int get_order(unsigned long size)
88 size = (size-1) >> (PAGE_SHIFT-1);
97 #endif /* __ASSEMBLY__ */
99 /* macros to convert between really physical and virtual addresses
100 * by stripping a selected bit, we can convert between KSEG_x and 0x40000000 where
101 * the DRAM really resides
104 #ifdef CONFIG_CRIS_LOW_MAP
105 /* we have DRAM virtually at 0x6 */
106 #define __pa(x) ((unsigned long)(x) & 0xdfffffff)
107 #define __va(x) ((void *)((unsigned long)(x) | 0x20000000))
109 /* we have DRAM virtually at 0xc */
110 #define __pa(x) ((unsigned long)(x) & 0x7fffffff)
111 #define __va(x) ((void *)((unsigned long)(x) | 0x80000000))
114 /* to index into the page map. our pages all start at physical addr PAGE_OFFSET so
115 * we can let the map start there. notice that we subtract PAGE_OFFSET because
116 * we start our mem_map there - in other ports they map mem_map physically and
117 * use __pa instead. in our system both the physical and virtual address of DRAM
118 * is too high to let mem_map start at 0, so we do it this way instead (similar
119 * to arm and m68k I think)
122 #define virt_to_page(kaddr) (mem_map + (((unsigned long)kaddr - PAGE_OFFSET) >> PAGE_SHIFT))
123 #define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
125 /* from linker script */
127 extern unsigned long dram_start, dram_end;
129 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
130 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
132 #endif /* __KERNEL__ */
134 #endif /* _CRIS_PAGE_H */