2 * include/asm-xtensa/page.h
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version2 as
6 * published by the Free Software Foundation.
8 * Copyright (C) 2001 - 2007 Tensilica Inc.
11 #ifndef _XTENSA_PAGE_H
12 #define _XTENSA_PAGE_H
16 #include <asm/processor.h>
17 #include <asm/types.h>
20 * Fixed TLB translations in the processor.
23 #define XCHAL_KSEG_CACHED_VADDR 0xd0000000
24 #define XCHAL_KSEG_BYPASS_VADDR 0xd8000000
25 #define XCHAL_KSEG_PADDR 0x00000000
26 #define XCHAL_KSEG_SIZE 0x08000000
29 * PAGE_SHIFT determines the page size
30 * PAGE_ALIGN(x) aligns the pointer to the (next) page boundary
34 #define PAGE_SIZE (__XTENSA_UL_CONST(1) << PAGE_SHIFT)
35 #define PAGE_MASK (~(PAGE_SIZE-1))
36 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE - 1) & PAGE_MASK)
38 #define PAGE_OFFSET XCHAL_KSEG_CACHED_VADDR
39 #define MAX_MEM_PFN XCHAL_KSEG_SIZE
40 #define PGTABLE_START 0x80000000
44 #define __pgprot(x) (x)
49 * These are used to make use of C type-checking..
52 typedef struct { unsigned long pte; } pte_t; /* page table entry */
53 typedef struct { unsigned long pgd; } pgd_t; /* PGD table entry */
54 typedef struct { unsigned long pgprot; } pgprot_t;
56 #define pte_val(x) ((x).pte)
57 #define pgd_val(x) ((x).pgd)
58 #define pgprot_val(x) ((x).pgprot)
60 #define __pte(x) ((pte_t) { (x) } )
61 #define __pgd(x) ((pgd_t) { (x) } )
62 #define __pgprot(x) ((pgprot_t) { (x) } )
65 * Pure 2^n version of get_order
66 * Use 'nsau' instructions if supported by the processor or the generic version.
71 static inline __attribute_const__ int get_order(unsigned long size)
74 asm ("nsau %0, %1" : "=r" (lz) : "r" ((size - 1) >> PAGE_SHIFT));
80 # include <asm-generic/page.h>
85 extern void clear_page(void *page);
86 extern void copy_page(void *to, void *from);
89 * If we have cache aliasing and writeback caches, we might have to do
93 #if (DCACHE_WAY_SIZE > PAGE_SIZE)
94 void clear_user_page(void *addr, unsigned long vaddr, struct page* page);
95 void copy_user_page(void *to,void* from,unsigned long vaddr,struct page* page);
97 # define clear_user_page(page,vaddr,pg) clear_page(page)
98 # define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
102 * This handles the memory map. We handle pages at
103 * XCHAL_KSEG_CACHED_VADDR for kernels with 32 bit address space.
104 * These macros are for conversion of kernel address, not user
108 #define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
109 #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
110 #define pfn_valid(pfn) ((unsigned long)pfn < max_mapnr)
111 #ifdef CONFIG_DISCONTIGMEM
112 # error CONFIG_DISCONTIGMEM not supported
115 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
116 #define page_to_virt(page) __va(page_to_pfn(page) << PAGE_SHIFT)
117 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
118 #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
120 #define WANT_PAGE_VIRTUAL
123 #endif /* __ASSEMBLY__ */
125 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
126 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
128 #include <asm-generic/memory_model.h>
129 #endif /* __KERNEL__ */
130 #endif /* _XTENSA_PAGE_H */