]> git.sur5r.net Git - u-boot/blob - include/asm-blackfin/page.h
[Blackfin][PATCH]: fix flash unaligned copy issue
[u-boot] / include / asm-blackfin / page.h
1 /*
2  * U-boot -  page.h
3  *
4  * Copyright (c) 2005 blackfin.uclinux.org
5  *
6  * See file CREDITS for list of people who contributed to this
7  * project.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22  * MA 02111-1307 USA
23  */
24
25 #ifndef _BLACKFIN_PAGE_H
26 #define _BLACKFIN_PAGE_H
27
28 #include <linux/config.h>
29
30 /* PAGE_SHIFT determines the page size */
31
32 #define PAGE_SHIFT                      (12)
33 #define PAGE_SIZE                       (4096)
34 #define PAGE_MASK                       (~(PAGE_SIZE-1))
35
36 #ifdef __KERNEL__
37
38 #include <asm/setup.h>
39
40 #if PAGE_SHIFT < 13
41 #define                                 KTHREAD_SIZE (8192)
42 #else
43 #define                                 KTHREAD_SIZE PAGE_SIZE
44 #endif
45
46 #ifndef __ASSEMBLY__
47
48 #define get_user_page(vaddr)            __get_free_page(GFP_KERNEL)
49 #define free_user_page(page, addr)      free_page(addr)
50
51 #define clear_page(page)                memset((page), 0, PAGE_SIZE)
52 #define copy_page(to,from)              memcpy((to), (from), PAGE_SIZE)
53
54 #define clear_user_page(page, vaddr)    clear_page(page)
55 #define copy_user_page(to, from, vaddr) copy_page(to, from)
56
57 /*
58  * These are used to make use of C type-checking..
59  */
60 typedef struct {
61         unsigned long pte;
62 } pte_t;
63 typedef struct {
64         unsigned long pmd[16];
65 } pmd_t;
66 typedef struct {
67         unsigned long pgd;
68 } pgd_t;
69 typedef struct {
70         unsigned long pgprot;
71 } pgprot_t;
72
73 #define pte_val(x)                      ((x).pte)
74 #define pmd_val(x)                      ((&x)->pmd[0])
75 #define pgd_val(x)                      ((x).pgd)
76 #define pgprot_val(x)                   ((x).pgprot)
77
78 #define __pte(x)                        ((pte_t) { (x) } )
79 #define __pmd(x)                        ((pmd_t) { (x) } )
80 #define __pgd(x)                        ((pgd_t) { (x) } )
81 #define __pgprot(x)                     ((pgprot_t) { (x) } )
82
83 /* to align the pointer to the (next) page boundary */
84 #define PAGE_ALIGN(addr)                (((addr)+PAGE_SIZE-1)&PAGE_MASK)
85
86 /* Pure 2^n version of get_order */
87 extern __inline__ int get_order(unsigned long size)
88 {
89         int order;
90
91         size = (size - 1) >> (PAGE_SHIFT - 1);
92         order = -1;
93         do {
94                 size >>= 1;
95                 order++;
96         } while (size);
97         return order;
98 }
99
100 #endif  /* !__ASSEMBLY__ */
101
102 #include <asm/page_offset.h>
103
104 #define PAGE_OFFSET                     (PAGE_OFFSET_RAW)
105
106 #ifndef __ASSEMBLY__
107
108 #define __pa(vaddr)                     virt_to_phys((void *)vaddr)
109 #define __va(paddr)                     phys_to_virt((unsigned long)paddr)
110
111 #define MAP_NR(addr)                    (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
112 #define virt_to_page(addr)              (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
113 #define VALID_PAGE(page)                ((page - mem_map) < max_mapnr)
114
115 #define PAGE_BUG(page) do       { \
116         BUG(); \
117 } while (0)
118
119 #endif
120
121 #endif
122
123 #endif