blob: 1e82ebb7d6442d755266ac2b452f04964ab52b61 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _M68KNOMMU_PAGE_H
2#define _M68KNOMMU_PAGE_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004/* PAGE_SHIFT determines the page size */
5
6#define PAGE_SHIFT (12)
7#define PAGE_SIZE (1UL << PAGE_SHIFT)
8#define PAGE_MASK (~(PAGE_SIZE-1))
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <asm/setup.h>
11
12#ifndef __ASSEMBLY__
13
14#define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
15#define free_user_page(page, addr) free_page(addr)
16
17#define clear_page(page) memset((page), 0, PAGE_SIZE)
18#define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
19
20#define clear_user_page(page, vaddr, pg) clear_page(page)
21#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
22
Mel Gorman769848c2007-07-17 04:03:05 -070023#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
24 alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
26
27/*
28 * These are used to make use of C type-checking..
29 */
30typedef struct { unsigned long pte; } pte_t;
31typedef struct { unsigned long pmd[16]; } pmd_t;
32typedef struct { unsigned long pgd; } pgd_t;
33typedef struct { unsigned long pgprot; } pgprot_t;
Martin Schwidefsky941edd02008-02-09 03:11:21 -080034typedef struct page *pgtable_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
36#define pte_val(x) ((x).pte)
37#define pmd_val(x) ((&x)->pmd[0])
38#define pgd_val(x) ((x).pgd)
39#define pgprot_val(x) ((x).pgprot)
40
41#define __pte(x) ((pte_t) { (x) } )
42#define __pmd(x) ((pmd_t) { (x) } )
43#define __pgd(x) ((pgd_t) { (x) } )
44#define __pgprot(x) ((pgprot_t) { (x) } )
45
46/* to align the pointer to the (next) page boundary */
47#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
48
Linus Torvalds1da177e2005-04-16 15:20:36 -070049extern unsigned long memory_start;
50extern unsigned long memory_end;
51
52#endif /* !__ASSEMBLY__ */
53
54#include <asm/page_offset.h>
55
56#define PAGE_OFFSET (PAGE_OFFSET_RAW)
57
58#ifndef __ASSEMBLY__
59
Greg Ungerere70bd112005-09-02 10:42:52 +100060#define __pa(vaddr) virt_to_phys((void *)(vaddr))
61#define __va(paddr) phys_to_virt((unsigned long)(paddr))
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
64#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
65
66#define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
67#define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
68
69#define pfn_to_page(pfn) virt_to_page(pfn_to_virt(pfn))
70#define page_to_pfn(page) virt_to_pfn(page_to_virt(page))
Greg Ungerere70bd112005-09-02 10:42:52 +100071#define pfn_valid(pfn) ((pfn) < max_mapnr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73#define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
74 ((void *)(kaddr) < (void *)memory_end))
75
76#endif /* __ASSEMBLY__ */
77
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -070078#include <asm-generic/page.h>
79
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#endif /* _M68KNOMMU_PAGE_H */