1/* $Id: pgalloc.h,v 1.1.1.1 2008/10/15 03:29:17 james26_jang Exp $ */
2#ifndef _SPARC_PGALLOC_H
3#define _SPARC_PGALLOC_H
4
5#include <linux/config.h>
6#include <linux/kernel.h>
7#include <linux/sched.h>
8
9#include <asm/page.h>
10#include <asm/btfixup.h>
11
12/* Fine grained cache/tlb flushing. */
13#ifdef CONFIG_SMP
14BTFIXUPDEF_CALL(void, local_flush_cache_all, void)
15BTFIXUPDEF_CALL(void, local_flush_cache_mm, struct mm_struct *)
16BTFIXUPDEF_CALL(void, local_flush_cache_range, struct mm_struct *, unsigned long, unsigned long)
17BTFIXUPDEF_CALL(void, local_flush_cache_page, struct vm_area_struct *, unsigned long)
18
19#define local_flush_cache_all() BTFIXUP_CALL(local_flush_cache_all)()
20#define local_flush_cache_mm(mm) BTFIXUP_CALL(local_flush_cache_mm)(mm)
21#define local_flush_cache_range(mm,start,end) BTFIXUP_CALL(local_flush_cache_range)(mm,start,end)
22#define local_flush_cache_page(vma,addr) BTFIXUP_CALL(local_flush_cache_page)(vma,addr)
23
24BTFIXUPDEF_CALL(void, local_flush_tlb_all, void)
25BTFIXUPDEF_CALL(void, local_flush_tlb_mm, struct mm_struct *)
26BTFIXUPDEF_CALL(void, local_flush_tlb_range, struct mm_struct *, unsigned long, unsigned long)
27BTFIXUPDEF_CALL(void, local_flush_tlb_page, struct vm_area_struct *, unsigned long)
28
29#define local_flush_tlb_all() BTFIXUP_CALL(local_flush_tlb_all)()
30#define local_flush_tlb_mm(mm) BTFIXUP_CALL(local_flush_tlb_mm)(mm)
31#define local_flush_tlb_range(mm,start,end) BTFIXUP_CALL(local_flush_tlb_range)(mm,start,end)
32#define local_flush_tlb_page(vma,addr) BTFIXUP_CALL(local_flush_tlb_page)(vma,addr)
33
34BTFIXUPDEF_CALL(void, local_flush_page_to_ram, unsigned long)
35BTFIXUPDEF_CALL(void, local_flush_sig_insns, struct mm_struct *, unsigned long)
36
37#define local_flush_page_to_ram(addr) BTFIXUP_CALL(local_flush_page_to_ram)(addr)
38#define local_flush_sig_insns(mm,insn_addr) BTFIXUP_CALL(local_flush_sig_insns)(mm,insn_addr)
39
40extern void smp_flush_cache_all(void);
41extern void smp_flush_cache_mm(struct mm_struct *mm);
42extern void smp_flush_cache_range(struct mm_struct *mm,
43				  unsigned long start,
44				  unsigned long end);
45extern void smp_flush_cache_page(struct vm_area_struct *vma, unsigned long page);
46
47extern void smp_flush_tlb_all(void);
48extern void smp_flush_tlb_mm(struct mm_struct *mm);
49extern void smp_flush_tlb_range(struct mm_struct *mm,
50				  unsigned long start,
51				  unsigned long end);
52extern void smp_flush_tlb_page(struct vm_area_struct *mm, unsigned long page);
53extern void smp_flush_page_to_ram(unsigned long page);
54extern void smp_flush_sig_insns(struct mm_struct *mm, unsigned long insn_addr);
55#endif
56
57BTFIXUPDEF_CALL(void, flush_cache_all, void)
58BTFIXUPDEF_CALL(void, flush_cache_mm, struct mm_struct *)
59BTFIXUPDEF_CALL(void, flush_cache_range, struct mm_struct *, unsigned long, unsigned long)
60BTFIXUPDEF_CALL(void, flush_cache_page, struct vm_area_struct *, unsigned long)
61
62#define flush_cache_all() BTFIXUP_CALL(flush_cache_all)()
63#define flush_cache_mm(mm) BTFIXUP_CALL(flush_cache_mm)(mm)
64#define flush_cache_range(mm,start,end) BTFIXUP_CALL(flush_cache_range)(mm,start,end)
65#define flush_cache_page(vma,addr) BTFIXUP_CALL(flush_cache_page)(vma,addr)
66#define flush_icache_range(start, end)		do { } while (0)
67
68BTFIXUPDEF_CALL(void, flush_tlb_all, void)
69BTFIXUPDEF_CALL(void, flush_tlb_mm, struct mm_struct *)
70BTFIXUPDEF_CALL(void, flush_tlb_range, struct mm_struct *, unsigned long, unsigned long)
71BTFIXUPDEF_CALL(void, flush_tlb_page, struct vm_area_struct *, unsigned long)
72
73extern __inline__ void flush_tlb_pgtables(struct mm_struct *mm, unsigned long start, unsigned long end)
74{
75}
76
77#define flush_tlb_all() BTFIXUP_CALL(flush_tlb_all)()
78#define flush_tlb_mm(mm) BTFIXUP_CALL(flush_tlb_mm)(mm)
79#define flush_tlb_range(mm,start,end) BTFIXUP_CALL(flush_tlb_range)(mm,start,end)
80#define flush_tlb_page(vma,addr) BTFIXUP_CALL(flush_tlb_page)(vma,addr)
81
82BTFIXUPDEF_CALL(void, __flush_page_to_ram, unsigned long)
83BTFIXUPDEF_CALL(void, flush_sig_insns, struct mm_struct *, unsigned long)
84
85#define __flush_page_to_ram(addr) BTFIXUP_CALL(__flush_page_to_ram)(addr)
86#define flush_sig_insns(mm,insn_addr) BTFIXUP_CALL(flush_sig_insns)(mm,insn_addr)
87
88extern void flush_page_to_ram(struct page *page);
89
90#define flush_dcache_page(page)			do { } while (0)
91
92extern struct pgtable_cache_struct {
93	unsigned long *pgd_cache;
94	unsigned long *pte_cache;
95	unsigned long pgtable_cache_sz;
96	unsigned long pgd_cache_sz;
97} pgt_quicklists;
98#define pgd_quicklist           (pgt_quicklists.pgd_cache)
99#define pmd_quicklist           ((unsigned long *)0)
100#define pte_quicklist           (pgt_quicklists.pte_cache)
101#define pgtable_cache_size      (pgt_quicklists.pgtable_cache_sz)
102#define pgd_cache_size		(pgt_quicklists.pgd_cache_sz)
103
104BTFIXUPDEF_CALL(int,	 do_check_pgt_cache, int, int)
105#define do_check_pgt_cache(low,high) BTFIXUP_CALL(do_check_pgt_cache)(low,high)
106
107BTFIXUPDEF_CALL(pgd_t *, get_pgd_fast, void)
108#define get_pgd_fast()		BTFIXUP_CALL(get_pgd_fast)()
109
110BTFIXUPDEF_CALL(void, free_pgd_fast, pgd_t *)
111#define free_pgd_fast(pgd)	BTFIXUP_CALL(free_pgd_fast)(pgd)
112
113#define pgd_free(pgd)	free_pgd_fast(pgd)
114#define pgd_alloc(mm)	get_pgd_fast()
115
116#define pgd_populate(MM, PGD, PMD)      pgd_set(PGD, PMD)
117
118static __inline__ pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
119{
120	return 0;
121}
122
123BTFIXUPDEF_CALL(pmd_t *, pmd_alloc_one_fast, struct mm_struct *, unsigned long)
124#define pmd_alloc_one_fast(mm, address)	BTFIXUP_CALL(pmd_alloc_one_fast)(mm, address)
125
126BTFIXUPDEF_CALL(void, free_pmd_fast, pmd_t *)
127#define free_pmd_fast(pmd)	BTFIXUP_CALL(free_pmd_fast)(pmd)
128
129#define pmd_free(pmd)           free_pmd_fast(pmd)
130
131#define pmd_populate(MM, PMD, PTE)      pmd_set(PMD, PTE)
132
133BTFIXUPDEF_CALL(pte_t *, pte_alloc_one, struct mm_struct *, unsigned long)
134#define pte_alloc_one(mm, address)	BTFIXUP_CALL(pte_alloc_one)(mm, address)
135
136BTFIXUPDEF_CALL(pte_t *, pte_alloc_one_fast, struct mm_struct *, unsigned long)
137#define pte_alloc_one_fast(mm, address)	BTFIXUP_CALL(pte_alloc_one_fast)(mm, address)
138
139BTFIXUPDEF_CALL(void, free_pte_fast, pte_t *)
140#define free_pte_fast(pte)	BTFIXUP_CALL(free_pte_fast)(pte)
141
142#define pte_free(pte)		free_pte_fast(pte)
143
144#endif /* _SPARC_PGALLOC_H */
145