blob: 8bc86717021c111452337c3812f259c8985129fa [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001#ifndef _BLACKFIN_PAGE_H
2#define _BLACKFIN_PAGE_H
3
4/* PAGE_SHIFT determines the page size */
5
6#define PAGE_SHIFT 12
Mike Frysinger520473b2007-07-12 12:20:20 +08007#ifdef __ASSEMBLY__
8#define PAGE_SIZE (1 << PAGE_SHIFT)
9#else
Bryan Wu1394f032007-05-06 14:50:22 -070010#define PAGE_SIZE (1UL << PAGE_SHIFT)
Mike Frysinger520473b2007-07-12 12:20:20 +080011#endif
Bryan Wu1394f032007-05-06 14:50:22 -070012#define PAGE_MASK (~(PAGE_SIZE-1))
13
14#ifdef __KERNEL__
15
16#include <asm/setup.h>
17
18#ifndef __ASSEMBLY__
19
20#define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
21#define free_user_page(page, addr) free_page(addr)
22
23#define clear_page(page) memset((page), 0, PAGE_SIZE)
24#define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
25
26#define clear_user_page(page, vaddr,pg) clear_page(page)
27#define copy_user_page(to, from, vaddr,pg) copy_page(to, from)
28
29/*
30 * These are used to make use of C type-checking..
31 */
32typedef struct {
33 unsigned long pte;
34} pte_t;
35typedef struct {
36 unsigned long pmd[16];
37} pmd_t;
38typedef struct {
39 unsigned long pgd;
40} pgd_t;
41typedef struct {
42 unsigned long pgprot;
43} pgprot_t;
44
45#define pte_val(x) ((x).pte)
46#define pmd_val(x) ((&x)->pmd[0])
47#define pgd_val(x) ((x).pgd)
48#define pgprot_val(x) ((x).pgprot)
49
50#define __pte(x) ((pte_t) { (x) } )
51#define __pmd(x) ((pmd_t) { (x) } )
52#define __pgd(x) ((pgd_t) { (x) } )
53#define __pgprot(x) ((pgprot_t) { (x) } )
54
55/* to align the pointer to the (next) page boundary */
56#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
57
58extern unsigned long memory_start;
59extern unsigned long memory_end;
60
61#endif /* !__ASSEMBLY__ */
62
63#include <asm/page_offset.h>
64#include <asm/io.h>
65
66#define PAGE_OFFSET (PAGE_OFFSET_RAW)
67
68#ifndef __ASSEMBLY__
69
70#define __pa(vaddr) virt_to_phys((void *)(vaddr))
71#define __va(paddr) phys_to_virt((unsigned long)(paddr))
72
73#define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
74
75#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
76#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
77#define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
78#define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
79#define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
80
81#define pfn_to_page(pfn) virt_to_page(pfn_to_virt(pfn))
82#define page_to_pfn(page) virt_to_pfn(page_to_virt(page))
83#define pfn_valid(pfn) ((pfn) < max_mapnr)
84
85#define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
86 ((void *)(kaddr) < (void *)memory_end))
87
88#include <asm-generic/page.h>
89
90#endif /* __ASSEMBLY__ */
91#endif /* __KERNEL__ */
92
93#endif /* _BLACKFIN_PAGE_H */