diff options
author | Michal Simek <monstr@monstr.eu> | 2009-12-10 05:43:57 -0500 |
---|---|---|
committer | Michal Simek <monstr@monstr.eu> | 2009-12-14 02:45:10 -0500 |
commit | 2ee2ff875a4d3bdb941e2bb1173cd927c09d5a67 (patch) | |
tree | a1ec4db3055527a2814cbdb006652dbf0885b348 /arch/microblaze/include/asm/cacheflush.h | |
parent | c8983a5c6ecc5ca68a871c44bc35f714663a4dfa (diff) |
microblaze: Support for WB cache
Microblaze version 7.20.d is the first MB version which can be run
on MMU linux. Please do not used previous version because they contain
HW bug.
Based on WB support was necessary to redesign whole cache design.
Microblaze versions from 7.20.a don't need to disable IRQ and cache
before working with them that's why there are special structures for it.
Signed-off-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch/microblaze/include/asm/cacheflush.h')
-rw-r--r-- | arch/microblaze/include/asm/cacheflush.h | 140 |
1 files changed, 64 insertions, 76 deletions
diff --git a/arch/microblaze/include/asm/cacheflush.h b/arch/microblaze/include/asm/cacheflush.h index 1f04b9111454..a6edd356cd08 100644 --- a/arch/microblaze/include/asm/cacheflush.h +++ b/arch/microblaze/include/asm/cacheflush.h | |||
@@ -18,6 +18,8 @@ | |||
18 | /* Somebody depends on this; sigh... */ | 18 | /* Somebody depends on this; sigh... */ |
19 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
20 | 20 | ||
21 | /* Look at Documentation/cachetlb.txt */ | ||
22 | |||
21 | /* | 23 | /* |
22 | * Cache handling functions. | 24 | * Cache handling functions. |
23 | * Microblaze has a write-through data cache, meaning that the data cache | 25 | * Microblaze has a write-through data cache, meaning that the data cache |
@@ -27,95 +29,81 @@ | |||
27 | * instruction cache to make sure we don't fetch old, bad code. | 29 | * instruction cache to make sure we don't fetch old, bad code. |
28 | */ | 30 | */ |
29 | 31 | ||
32 | /* struct cache, d=dcache, i=icache, fl = flush, iv = invalidate, | ||
33 | * suffix r = range */ | ||
34 | struct scache { | ||
35 | /* icache */ | ||
36 | void (*ie)(void); /* enable */ | ||
37 | void (*id)(void); /* disable */ | ||
38 | void (*ifl)(void); /* flush */ | ||
39 | void (*iflr)(unsigned long a, unsigned long b); | ||
40 | void (*iin)(void); /* invalidate */ | ||
41 | void (*iinr)(unsigned long a, unsigned long b); | ||
42 | /* dcache */ | ||
43 | void (*de)(void); /* enable */ | ||
44 | void (*dd)(void); /* disable */ | ||
45 | void (*dfl)(void); /* flush */ | ||
46 | void (*dflr)(unsigned long a, unsigned long b); | ||
47 | void (*din)(void); /* invalidate */ | ||
48 | void (*dinr)(unsigned long a, unsigned long b); | ||
49 | }; | ||
50 | |||
51 | /* microblaze cache */ | ||
52 | extern struct scache *mbc; | ||
53 | |||
54 | void microblaze_cache_init(void); | ||
55 | |||
56 | #define enable_icache() mbc->ie(); | ||
57 | #define disable_icache() mbc->id(); | ||
58 | #define flush_icache() mbc->ifl(); | ||
59 | #define flush_icache_range(start, end) mbc->iflr(start, end); | ||
60 | #define invalidate_icache() mbc->iin(); | ||
61 | #define invalidate_icache_range(start, end) mbc->iinr(start, end); | ||
62 | |||
63 | |||
64 | #define flush_icache_user_range(vma, pg, adr, len) flush_icache(); | ||
65 | #define flush_icache_page(vma, pg) do { } while (0) | ||
66 | |||
67 | #define enable_dcache() mbc->de(); | ||
68 | #define disable_dcache() mbc->dd(); | ||
30 | /* FIXME for LL-temac driver */ | 69 | /* FIXME for LL-temac driver */ |
31 | #define invalidate_dcache_range(start, end) \ | 70 | #define invalidate_dcache() mbc->din(); |
32 | __invalidate_dcache_range(start, end) | 71 | #define invalidate_dcache_range(start, end) mbc->dinr(start, end); |
33 | 72 | #define flush_dcache() mbc->dfl(); | |
34 | #define flush_cache_all() __invalidate_cache_all() | 73 | #define flush_dcache_range(start, end) mbc->dflr(start, end); |
35 | #define flush_cache_mm(mm) do { } while (0) | ||
36 | #define flush_cache_range(vma, start, end) __invalidate_cache_all() | ||
37 | #define flush_cache_page(vma, vmaddr, pfn) do { } while (0) | ||
38 | 74 | ||
39 | #define flush_dcache_range(start, end) __invalidate_dcache_range(start, end) | ||
40 | #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 | 75 | #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 |
76 | /* D-cache aliasing problem can't happen - cache is between MMU and ram */ | ||
41 | #define flush_dcache_page(page) do { } while (0) | 77 | #define flush_dcache_page(page) do { } while (0) |
42 | #define flush_dcache_mmap_lock(mapping) do { } while (0) | 78 | #define flush_dcache_mmap_lock(mapping) do { } while (0) |
43 | #define flush_dcache_mmap_unlock(mapping) do { } while (0) | 79 | #define flush_dcache_mmap_unlock(mapping) do { } while (0) |
44 | 80 | ||
45 | #define flush_icache_range(start, len) __invalidate_icache_range(start, len) | ||
46 | #define flush_icache_page(vma, pg) do { } while (0) | ||
47 | |||
48 | #ifndef CONFIG_MMU | ||
49 | # define flush_icache_user_range(start, len) do { } while (0) | ||
50 | #else | ||
51 | # define flush_icache_user_range(vma, pg, adr, len) __invalidate_icache_all() | ||
52 | |||
53 | # define flush_page_to_ram(page) do { } while (0) | ||
54 | 81 | ||
55 | # define flush_icache() __invalidate_icache_all() | 82 | #define flush_cache_dup_mm(mm) do { } while (0) |
56 | # define flush_cache_sigtramp(vaddr) \ | 83 | #define flush_cache_vmap(start, end) do { } while (0) |
57 | __invalidate_icache_range(vaddr, vaddr + 8) | 84 | #define flush_cache_vunmap(start, end) do { } while (0) |
58 | 85 | #define flush_cache_mm(mm) do { } while (0) | |
59 | # define flush_dcache_mmap_lock(mapping) do { } while (0) | 86 | #define flush_cache_page(vma, vmaddr, pfn) do { } while (0) |
60 | # define flush_dcache_mmap_unlock(mapping) do { } while (0) | ||
61 | 87 | ||
62 | # define flush_cache_dup_mm(mm) do { } while (0) | 88 | /* MS: kgdb code use this macro, wrong len with FLASH */ |
89 | #if 0 | ||
90 | #define flush_cache_range(vma, start, len) { \ | ||
91 | flush_icache_range((unsigned) (start), (unsigned) (start) + (len)); \ | ||
92 | flush_dcache_range((unsigned) (start), (unsigned) (start) + (len)); \ | ||
93 | } | ||
63 | #endif | 94 | #endif |
64 | 95 | ||
65 | #define flush_cache_vmap(start, end) do { } while (0) | 96 | #define flush_cache_range(vma, start, len) do { } while (0) |
66 | #define flush_cache_vunmap(start, end) do { } while (0) | ||
67 | |||
68 | |||
69 | void _enable_icache(void); | ||
70 | void _disable_icache(void); | ||
71 | void _invalidate_icache(unsigned int addr); | ||
72 | |||
73 | #define __enable_icache() _enable_icache() | ||
74 | #define __disable_icache() _disable_icache() | ||
75 | #define __invalidate_icache(addr) _invalidate_icache(addr) | ||
76 | |||
77 | void _enable_dcache(void); | ||
78 | void _disable_dcache(void); | ||
79 | void _invalidate_dcache(unsigned int addr); | ||
80 | |||
81 | #define __enable_dcache() _enable_dcache() | ||
82 | #define __disable_dcache() _disable_dcache() | ||
83 | #define __invalidate_dcache(addr) _invalidate_dcache(addr) | ||
84 | |||
85 | struct page; | ||
86 | struct mm_struct; | ||
87 | struct vm_area_struct; | ||
88 | |||
89 | /* see arch/microblaze/kernel/cache.c */ | ||
90 | extern void __invalidate_icache_all(void); | ||
91 | extern void __invalidate_icache_range(unsigned long start, unsigned long end); | ||
92 | extern void __invalidate_icache_page(struct vm_area_struct *vma, | ||
93 | struct page *page); | ||
94 | extern void __invalidate_icache_user_range(struct vm_area_struct *vma, | ||
95 | struct page *page, | ||
96 | unsigned long adr, int len); | ||
97 | extern void __invalidate_cache_sigtramp(unsigned long addr); | ||
98 | |||
99 | extern void __invalidate_dcache_all(void); | ||
100 | extern void __invalidate_dcache_range(unsigned long start, unsigned long end); | ||
101 | extern void __invalidate_dcache_page(struct vm_area_struct *vma, | ||
102 | struct page *page); | ||
103 | extern void __invalidate_dcache_user_range(struct vm_area_struct *vma, | ||
104 | struct page *page, | ||
105 | unsigned long adr, int len); | ||
106 | |||
107 | extern inline void __invalidate_cache_all(void) | ||
108 | { | ||
109 | __invalidate_icache_all(); | ||
110 | __invalidate_dcache_all(); | ||
111 | } | ||
112 | 97 | ||
113 | #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ | 98 | #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ |
114 | do { memcpy((dst), (src), (len)); \ | 99 | do { \ |
115 | flush_icache_range((unsigned) (dst), (unsigned) (dst) + (len)); \ | 100 | memcpy((dst), (src), (len)); \ |
101 | flush_icache_range((unsigned) (dst), (unsigned) (dst) + (len)); \ | ||
116 | } while (0) | 102 | } while (0) |
117 | 103 | ||
118 | #define copy_from_user_page(vma, page, vaddr, dst, src, len) \ | 104 | #define copy_from_user_page(vma, page, vaddr, dst, src, len) \ |
119 | memcpy((dst), (src), (len)) | 105 | do { \ |
106 | memcpy((dst), (src), (len)); \ | ||
107 | } while (0) | ||
120 | 108 | ||
121 | #endif /* _ASM_MICROBLAZE_CACHEFLUSH_H */ | 109 | #endif /* _ASM_MICROBLAZE_CACHEFLUSH_H */ |