1
2
3
4
5
6
7
8
9
10
11
12#ifndef _ASM_MICROBLAZE_PAGE_H
13#define _ASM_MICROBLAZE_PAGE_H
14
15#include <linux/pfn.h>
16#include <asm/setup.h>
17#include <asm/asm-compat.h>
18#include <linux/const.h>
19
20#ifdef __KERNEL__
21
22
23#define PAGE_SHIFT 12
24#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT)
25#define PAGE_MASK (~(PAGE_SIZE-1))
26
27#define LOAD_OFFSET ASM_CONST((CONFIG_KERNEL_START-CONFIG_KERNEL_BASE_ADDR))
28
29#define PTE_SHIFT (PAGE_SHIFT - 2)
30
31#ifndef __ASSEMBLY__
32
33
34#define ARCH_DMA_MINALIGN L1_CACHE_BYTES
35
36#define ARCH_SLAB_MINALIGN L1_CACHE_BYTES
37
38
39
40
41
42
43
44
45#define PAGE_OFFSET CONFIG_KERNEL_START
46
47
48
49
50typedef unsigned long pte_basic_t;
51#define PTE_FMT "%.8lx"
52
53# define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
54# define clear_page(pgaddr) memset((pgaddr), 0, PAGE_SIZE)
55
56# define clear_user_page(pgaddr, vaddr, page) memset((pgaddr), 0, PAGE_SIZE)
57# define copy_user_page(vto, vfrom, vaddr, topg) \
58 memcpy((vto), (vfrom), PAGE_SIZE)
59
60
61
62
63typedef struct page *pgtable_t;
64typedef struct { unsigned long pte; } pte_t;
65typedef struct { unsigned long pgprot; } pgprot_t;
66
67typedef struct { unsigned long pgd; } pgd_t;
68
69# define pte_val(x) ((x).pte)
70# define pgprot_val(x) ((x).pgprot)
71
72# define pgd_val(x) ((x).pgd)
73
74# define __pte(x) ((pte_t) { (x) })
75# define __pgd(x) ((pgd_t) { (x) })
76# define __pgprot(x) ((pgprot_t) { (x) })
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92extern unsigned long max_low_pfn;
93extern unsigned long min_low_pfn;
94extern unsigned long max_pfn;
95
96extern unsigned long memory_start;
97extern unsigned long memory_size;
98extern unsigned long lowmem_size;
99
100extern unsigned long kernel_tlb;
101
102extern int page_is_ram(unsigned long pfn);
103
104# define phys_to_pfn(phys) (PFN_DOWN(phys))
105# define pfn_to_phys(pfn) (PFN_PHYS(pfn))
106
107# define virt_to_pfn(vaddr) (phys_to_pfn((__pa(vaddr))))
108# define pfn_to_virt(pfn) __va(pfn_to_phys((pfn)))
109
110# define virt_to_page(kaddr) (pfn_to_page(__pa(kaddr) >> PAGE_SHIFT))
111# define page_to_virt(page) __va(page_to_pfn(page) << PAGE_SHIFT)
112# define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
113
114# define ARCH_PFN_OFFSET (memory_start >> PAGE_SHIFT)
115# define pfn_valid(pfn) ((pfn) < (max_mapnr + ARCH_PFN_OFFSET))
116
117# endif
118
119#define virt_addr_valid(vaddr) (pfn_valid(virt_to_pfn(vaddr)))
120
121# define __pa(x) __virt_to_phys((unsigned long)(x))
122# define __va(x) ((void *)__phys_to_virt((unsigned long)(x)))
123
124
125
126#define __virt_to_phys(addr) \
127 ((addr) + CONFIG_KERNEL_BASE_ADDR - CONFIG_KERNEL_START)
128#define __phys_to_virt(addr) \
129 ((addr) + CONFIG_KERNEL_START - CONFIG_KERNEL_BASE_ADDR)
130#define tophys(rd, rs) \
131 addik rd, rs, (CONFIG_KERNEL_BASE_ADDR - CONFIG_KERNEL_START)
132#define tovirt(rd, rs) \
133 addik rd, rs, (CONFIG_KERNEL_START - CONFIG_KERNEL_BASE_ADDR)
134
135#define TOPHYS(addr) __virt_to_phys(addr)
136
137#endif
138
139#include <asm-generic/memory_model.h>
140#include <asm-generic/getorder.h>
141
142#endif
143