1 /******************************************************************************
2 * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>
3 * VA Linux Systems Japan K.K.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef _ASM_IA64_PARAVIRT_PRIVOP_H
22 #define _ASM_IA64_PARAVIRT_PRIVOP_H
24 #ifdef CONFIG_PARAVIRT
28 #include <linux/types.h>
29 #include <asm/kregs.h> /* for IA64_PSR_I */
31 /******************************************************************************
32 * replacement of intrinsics operations.
36 void (*fc)(unsigned long addr);
37 unsigned long (*thash)(unsigned long addr);
38 unsigned long (*get_cpuid)(int index);
39 unsigned long (*get_pmd)(int index);
40 unsigned long (*getreg)(int reg);
41 void (*setreg)(int reg, unsigned long val);
42 void (*ptcga)(unsigned long addr, unsigned long size);
43 unsigned long (*get_rr)(unsigned long index);
44 void (*set_rr)(unsigned long index, unsigned long val);
45 void (*set_rr0_to_rr4)(unsigned long val0, unsigned long val1,
46 unsigned long val2, unsigned long val3,
50 unsigned long (*get_psr_i)(void);
51 void (*intrin_local_irq_restore)(unsigned long flags);
54 extern struct pv_cpu_ops pv_cpu_ops;
56 extern void ia64_native_setreg_func(int regnum, unsigned long val);
57 extern unsigned long ia64_native_getreg_func(int regnum);
59 /************************************************/
60 /* Instructions paravirtualized for performance */
61 /************************************************/
63 /* mask for ia64_native_ssm/rsm() must be constant.("i" constraing).
64 * static inline function doesn't satisfy it. */
65 #define paravirt_ssm(mask) \
67 if ((mask) == IA64_PSR_I) \
70 ia64_native_ssm(mask); \
73 #define paravirt_rsm(mask) \
75 if ((mask) == IA64_PSR_I) \
78 ia64_native_rsm(mask); \
81 /* returned ip value should be the one in the caller,
82 * not in __paravirt_getreg() */
83 #define paravirt_getreg(reg) \
86 BUILD_BUG_ON(!__builtin_constant_p(reg)); \
87 if ((reg) == _IA64_REG_IP) \
88 res = ia64_native_getreg(_IA64_REG_IP); \
90 res = pv_cpu_ops.getreg(reg); \
94 /******************************************************************************
95 * replacement of hand written assembly codes.
97 struct pv_cpu_asm_switch {
98 unsigned long switch_to;
99 unsigned long leave_syscall;
100 unsigned long work_processed_syscall;
101 unsigned long leave_kernel;
103 void paravirt_cpu_asm_init(const struct pv_cpu_asm_switch *cpu_asm_switch);
105 #endif /* __ASSEMBLY__ */
107 #define IA64_PARAVIRT_ASM_FUNC(name) paravirt_ ## name
111 /* fallback for native case */
112 #define IA64_PARAVIRT_ASM_FUNC(name) ia64_native_ ## name
114 #endif /* CONFIG_PARAVIRT */
116 /* these routines utilize privilege-sensitive or performance-sensitive
117 * privileged instructions so the code must be replaced with
118 * paravirtualized versions */
119 #define ia64_switch_to IA64_PARAVIRT_ASM_FUNC(switch_to)
120 #define ia64_leave_syscall IA64_PARAVIRT_ASM_FUNC(leave_syscall)
121 #define ia64_work_processed_syscall \
122 IA64_PARAVIRT_ASM_FUNC(work_processed_syscall)
123 #define ia64_leave_kernel IA64_PARAVIRT_ASM_FUNC(leave_kernel)
125 #endif /* _ASM_IA64_PARAVIRT_PRIVOP_H */