Chen Liqin | 6bc9a39 | 2009-06-12 22:01:00 +0800 | [diff] [blame] | 1 | #ifndef _ASM_SCORE_PAGE_H |
| 2 | #define _ASM_SCORE_PAGE_H |
| 3 | |
| 4 | #include <linux/pfn.h> |
| 5 | |
| 6 | /* PAGE_SHIFT determines the page size */ |
| 7 | #define PAGE_SHIFT (12) |
| 8 | #define PAGE_SIZE (1UL << PAGE_SHIFT) |
| 9 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
| 10 | |
| 11 | #ifdef __KERNEL__ |
| 12 | |
| 13 | #ifndef __ASSEMBLY__ |
| 14 | |
| 15 | #define PAGE_UP(addr) (((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1))) |
| 16 | #define PAGE_DOWN(addr) ((addr)&(~((PAGE_SIZE)-1))) |
| 17 | |
| 18 | /* align addr on a size boundary - adjust address up/down if needed */ |
| 19 | #define _ALIGN_UP(addr, size) (((addr)+((size)-1))&(~((size)-1))) |
| 20 | #define _ALIGN_DOWN(addr, size) ((addr)&(~((size)-1))) |
| 21 | |
| 22 | /* align addr on a size boundary - adjust address up if needed */ |
| 23 | #define _ALIGN(addr, size) _ALIGN_UP(addr, size) |
| 24 | |
| 25 | /* |
| 26 | * PAGE_OFFSET -- the first address of the first page of memory. When not |
| 27 | * using MMU this corresponds to the first free page in physical memory (aligned |
| 28 | * on a page boundary). |
| 29 | */ |
| 30 | #define PAGE_OFFSET (0xA0000000UL) |
| 31 | |
| 32 | #define clear_page(pgaddr) memset((pgaddr), 0, PAGE_SIZE) |
| 33 | #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE) |
| 34 | |
| 35 | #define clear_user_page(pgaddr, vaddr, page) memset((pgaddr), 0, PAGE_SIZE) |
| 36 | #define copy_user_page(vto, vfrom, vaddr, topg) \ |
| 37 | memcpy((vto), (vfrom), PAGE_SIZE) |
| 38 | |
| 39 | /* |
| 40 | * These are used to make use of C type-checking.. |
| 41 | */ |
| 42 | |
| 43 | typedef struct { unsigned long pte; } pte_t; /* page table entry */ |
| 44 | typedef struct { unsigned long pgd; } pgd_t; /* PGD table entry */ |
| 45 | typedef struct { unsigned long pgprot; } pgprot_t; |
| 46 | typedef struct page *pgtable_t; |
| 47 | |
| 48 | #define pte_val(x) ((x).pte) |
| 49 | #define pgd_val(x) ((x).pgd) |
| 50 | #define pgprot_val(x) ((x).pgprot) |
| 51 | |
| 52 | #define __pte(x) ((pte_t) { (x) }) |
| 53 | #define __pgd(x) ((pgd_t) { (x) }) |
| 54 | #define __pgprot(x) ((pgprot_t) { (x) }) |
| 55 | |
| 56 | extern unsigned long max_low_pfn; |
| 57 | extern unsigned long min_low_pfn; |
| 58 | extern unsigned long max_pfn; |
| 59 | |
Chen Liqin | ffa818b | 2009-08-30 12:30:16 +0800 | [diff] [blame] | 60 | #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET) |
| 61 | #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET)) |
Chen Liqin | 6bc9a39 | 2009-06-12 22:01:00 +0800 | [diff] [blame] | 62 | |
| 63 | #define phys_to_pfn(phys) (PFN_DOWN(phys)) |
| 64 | #define pfn_to_phys(pfn) (PFN_PHYS(pfn)) |
| 65 | |
| 66 | #define virt_to_pfn(vaddr) (phys_to_pfn((__pa(vaddr)))) |
| 67 | #define pfn_to_virt(pfn) __va(pfn_to_phys((pfn))) |
| 68 | |
| 69 | #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr))) |
| 70 | #define page_to_virt(page) (pfn_to_virt(page_to_pfn(page))) |
| 71 | |
| 72 | #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page))) |
| 73 | #define page_to_bus(page) (page_to_phys(page)) |
| 74 | #define phys_to_page(paddr) (pfn_to_page(phys_to_pfn(paddr))) |
| 75 | |
| 76 | #define pfn_valid(pfn) ((pfn) >= min_low_pfn && (pfn) < max_mapnr) |
| 77 | |
| 78 | #define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT) |
| 79 | |
| 80 | #endif /* __ASSEMBLY__ */ |
| 81 | |
| 82 | #define virt_addr_valid(vaddr) (pfn_valid(virt_to_pfn(vaddr))) |
| 83 | |
| 84 | #endif /* __KERNEL__ */ |
| 85 | |
| 86 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ |
| 87 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) |
| 88 | |
| 89 | #include <asm-generic/memory_model.h> |
| 90 | #include <asm-generic/getorder.h> |
| 91 | |
| 92 | #endif /* _ASM_SCORE_PAGE_H */ |