Subversion Repositories shark

Rev

Rev 440 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 1
#ifndef _I386_PAGE_H
2
#define _I386_PAGE_H
3
 
4
/* PAGE_SHIFT determines the page size */
5
#define PAGE_SHIFT      12
6
#define PAGE_SIZE       (1UL << PAGE_SHIFT)
7
#define PAGE_MASK       (~(PAGE_SIZE-1))
8
 
9
#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
10
#define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
11
 
12
#ifdef __KERNEL__
13
#ifndef __ASSEMBLY__
14
 
15
#include <linux/config.h>
16
 
17
#ifdef CONFIG_X86_USE_3DNOW
18
 
19
#include <asm/mmx.h>
20
 
21
#define clear_page(page)        mmx_clear_page((void *)(page))
22
#define copy_page(to,from)      mmx_copy_page(to,from)
23
 
24
#else
25
 
26
/*
27
 *      On older X86 processors it's not a win to use MMX here it seems.
28
 *      Maybe the K6-III ?
29
 */
30
 
31
#define clear_page(page)        memset((void *)(page), 0, PAGE_SIZE)
32
#define copy_page(to,from)      memcpy((void *)(to), (void *)(from), PAGE_SIZE)
33
 
34
#endif
35
 
36
#define clear_user_page(page, vaddr, pg)        clear_page(page)
37
#define copy_user_page(to, from, vaddr, pg)     copy_page(to, from)
38
 
39
/*
40
 * These are used to make use of C type-checking..
41
 */
42
#ifdef CONFIG_X86_PAE
43
typedef struct { unsigned long pte_low, pte_high; } pte_t;
44
typedef struct { unsigned long long pmd; } pmd_t;
45
typedef struct { unsigned long long pgd; } pgd_t;
46
#define pte_val(x)      ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
47
#define HPAGE_SHIFT     21
48
#else
49
typedef struct { unsigned long pte_low; } pte_t;
50
typedef struct { unsigned long pmd; } pmd_t;
51
typedef struct { unsigned long pgd; } pgd_t;
52
#define boot_pte_t pte_t /* or would you rather have a typedef */
53
#define pte_val(x)      ((x).pte_low)
54
#define HPAGE_SHIFT     22
55
#endif
56
#define PTE_MASK        PAGE_MASK
57
 
58
#ifdef CONFIG_HUGETLB_PAGE
59
#define HPAGE_SIZE      ((1UL) << HPAGE_SHIFT)
60
#define HPAGE_MASK      (~(HPAGE_SIZE - 1))
61
#define HUGETLB_PAGE_ORDER      (HPAGE_SHIFT - PAGE_SHIFT)
62
#endif
63
 
64
typedef struct { unsigned long pgprot; } pgprot_t;
65
 
66
#define pmd_val(x)      ((x).pmd)
67
#define pgd_val(x)      ((x).pgd)
68
#define pgprot_val(x)   ((x).pgprot)
69
 
70
#define __pte(x) ((pte_t) { (x) } )
71
#define __pmd(x) ((pmd_t) { (x) } )
72
#define __pgd(x) ((pgd_t) { (x) } )
73
#define __pgprot(x)     ((pgprot_t) { (x) } )
74
 
75
#endif /* !__ASSEMBLY__ */
76
 
77
/* to align the pointer to the (next) page boundary */
78
#define PAGE_ALIGN(addr)        (((addr)+PAGE_SIZE-1)&PAGE_MASK)
79
 
80
/*
81
 * This handles the memory map.. We could make this a config
82
 * option, but too many people screw it up, and too few need
83
 * it.
84
 *
85
 * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
86
 * a virtual address space of one gigabyte, which limits the
87
 * amount of physical memory you can use to about 950MB.
88
 *
89
 * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
90
 * and CONFIG_HIGHMEM64G options in the kernel configuration.
91
 */
92
 
93
/*
94
 * This much address space is reserved for vmalloc() and iomap()
95
 * as well as fixmap mappings.
96
 */
97
#define __VMALLOC_RESERVE       (128 << 20)
98
 
99
#ifndef __ASSEMBLY__
100
 
101
/* Pure 2^n version of get_order */
102
static __inline__ int get_order(unsigned long size)
103
{
104
        int order;
105
 
106
        size = (size-1) >> (PAGE_SHIFT-1);
107
        order = -1;
108
        do {
109
                size >>= 1;
110
                order++;
111
        } while (size);
112
        return order;
113
}
114
 
115
#endif /* __ASSEMBLY__ */
116
 
117
#ifdef __ASSEMBLY__
118
#define __PAGE_OFFSET           (0xC0000000)
119
#else
440 giacomo 120
#define __PAGE_OFFSET           (0x00000000UL)
422 giacomo 121
#endif
122
 
123
 
124
#define PAGE_OFFSET             ((unsigned long)__PAGE_OFFSET)
125
#define VMALLOC_RESERVE         ((unsigned long)__VMALLOC_RESERVE)
126
#define MAXMEM                  (-__PAGE_OFFSET-__VMALLOC_RESERVE)
127
#define __pa(x)                 ((unsigned long)(x)-PAGE_OFFSET)
128
#define __va(x)                 ((void *)((unsigned long)(x)+PAGE_OFFSET))
129
#define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
130
#ifndef CONFIG_DISCONTIGMEM
131
#define pfn_to_page(pfn)        (mem_map + (pfn))
132
#define page_to_pfn(page)       ((unsigned long)((page) - mem_map))
133
#define pfn_valid(pfn)          ((pfn) < max_mapnr)
134
#endif /* !CONFIG_DISCONTIGMEM */
135
#define virt_to_page(kaddr)     pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
136
 
137
#define virt_addr_valid(kaddr)  pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
138
 
139
#define VM_DATA_DEFAULT_FLAGS   (VM_READ | VM_WRITE | VM_EXEC | \
140
                                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
141
 
142
#endif /* __KERNEL__ */
143
 
144
#endif /* _I386_PAGE_H */