blob: 67cfb7dbc28474921c607d33307bcd84f53aa1b6 [file] [log] [blame]
Arnd Bergmann5c01b462009-05-13 22:56:36 +00001#ifndef __ASM_GENERIC_PAGE_H
2#define __ASM_GENERIC_PAGE_H
3/*
4 * Generic page.h implementation, for NOMMU architectures.
5 * This provides the dummy definitions for the memory management.
6 */
7
8#ifdef CONFIG_MMU
9#error need to prove a real asm/page.h
10#endif
11
12
13/* PAGE_SHIFT determines the page size */
14
15#define PAGE_SHIFT 12
16#ifdef __ASSEMBLY__
17#define PAGE_SIZE (1 << PAGE_SHIFT)
18#else
19#define PAGE_SIZE (1UL << PAGE_SHIFT)
20#endif
21#define PAGE_MASK (~(PAGE_SIZE-1))
22
23#include <asm/setup.h>
24
25#ifndef __ASSEMBLY__
26
Arnd Bergmann5c01b462009-05-13 22:56:36 +000027#define clear_page(page) memset((page), 0, PAGE_SIZE)
28#define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
29
30#define clear_user_page(page, vaddr, pg) clear_page(page)
31#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
32
33/*
34 * These are used to make use of C type-checking..
35 */
36typedef struct {
37 unsigned long pte;
38} pte_t;
39typedef struct {
40 unsigned long pmd[16];
41} pmd_t;
42typedef struct {
43 unsigned long pgd;
44} pgd_t;
45typedef struct {
46 unsigned long pgprot;
47} pgprot_t;
48typedef struct page *pgtable_t;
49
50#define pte_val(x) ((x).pte)
51#define pmd_val(x) ((&x)->pmd[0])
52#define pgd_val(x) ((x).pgd)
53#define pgprot_val(x) ((x).pgprot)
54
55#define __pte(x) ((pte_t) { (x) } )
56#define __pmd(x) ((pmd_t) { (x) } )
57#define __pgd(x) ((pgd_t) { (x) } )
58#define __pgprot(x) ((pgprot_t) { (x) } )
59
60extern unsigned long memory_start;
61extern unsigned long memory_end;
62
63#endif /* !__ASSEMBLY__ */
64
65#ifdef CONFIG_KERNEL_RAM_BASE_ADDRESS
66#define PAGE_OFFSET (CONFIG_KERNEL_RAM_BASE_ADDRESS)
67#else
68#define PAGE_OFFSET (0)
69#endif
70
Mark Salterb7a05562011-10-04 09:24:15 -040071#ifndef ARCH_PFN_OFFSET
72#define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
73#endif
74
Arnd Bergmann5c01b462009-05-13 22:56:36 +000075#ifndef __ASSEMBLY__
76
Mark Salterb7a05562011-10-04 09:24:15 -040077#define __va(x) ((void *)((unsigned long) (x)))
78#define __pa(x) ((unsigned long) (x))
Arnd Bergmann5c01b462009-05-13 22:56:36 +000079
80#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
81#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
82
Sonic Zhang06d5e032011-10-31 17:08:31 -070083#define virt_to_page(addr) pfn_to_page(virt_to_pfn(addr))
84#define page_to_virt(page) pfn_to_virt(page_to_pfn(page))
Arnd Bergmann5c01b462009-05-13 22:56:36 +000085
86#ifndef page_to_phys
87#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
88#endif
89
Mark Salterb7a05562011-10-04 09:24:15 -040090#define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
Arnd Bergmann5c01b462009-05-13 22:56:36 +000091
92#define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
93 ((void *)(kaddr) < (void *)memory_end))
94
95#endif /* __ASSEMBLY__ */
96
97#include <asm-generic/memory_model.h>
98#include <asm-generic/getorder.h>
99
100#endif /* __ASM_GENERIC_PAGE_H */