1 /******************************************************************************
2 * arch/ia64/kernel/paravirt.c
4 * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>
5 * VA Linux Systems Japan K.K.
6 * Yaozu (Eddie) Dong <eddie.dong@intel.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <linux/init.h>
26 #include <linux/compiler.h>
28 #include <linux/irq.h>
29 #include <linux/module.h>
30 #include <linux/types.h>
32 #include <asm/iosapic.h>
33 #include <asm/paravirt.h>
35 /***************************************************************************
38 struct pv_info pv_info
= {
40 .paravirt_enabled
= 0,
41 .name
= "bare hardware"
44 /***************************************************************************
46 * initialization hooks.
49 struct pv_init_ops pv_init_ops
;
51 /***************************************************************************
56 /* ia64_native_xxx are macros so that we have to make them real functions */
58 #define DEFINE_VOID_FUNC1(name) \
60 ia64_native_ ## name ## _func(unsigned long arg) \
62 ia64_native_ ## name(arg); \
65 #define DEFINE_VOID_FUNC2(name) \
67 ia64_native_ ## name ## _func(unsigned long arg0, \
70 ia64_native_ ## name(arg0, arg1); \
73 #define DEFINE_FUNC0(name) \
74 static unsigned long \
75 ia64_native_ ## name ## _func(void) \
77 return ia64_native_ ## name(); \
80 #define DEFINE_FUNC1(name, type) \
81 static unsigned long \
82 ia64_native_ ## name ## _func(type arg) \
84 return ia64_native_ ## name(arg); \
87 DEFINE_VOID_FUNC1(fc);
88 DEFINE_VOID_FUNC1(intrin_local_irq_restore
);
90 DEFINE_VOID_FUNC2(ptcga
);
91 DEFINE_VOID_FUNC2(set_rr
);
93 DEFINE_FUNC0(get_psr_i
);
95 DEFINE_FUNC1(thash
, unsigned long);
96 DEFINE_FUNC1(get_cpuid
, int);
97 DEFINE_FUNC1(get_pmd
, int);
98 DEFINE_FUNC1(get_rr
, unsigned long);
101 ia64_native_ssm_i_func(void)
103 ia64_native_ssm(IA64_PSR_I
);
107 ia64_native_rsm_i_func(void)
109 ia64_native_rsm(IA64_PSR_I
);
113 ia64_native_set_rr0_to_rr4_func(unsigned long val0
, unsigned long val1
,
114 unsigned long val2
, unsigned long val3
,
117 ia64_native_set_rr0_to_rr4(val0
, val1
, val2
, val3
, val4
);
120 #define CASE_GET_REG(id) \
121 case _IA64_REG_ ## id: \
122 res = ia64_native_getreg(_IA64_REG_ ## id); \
124 #define CASE_GET_AR(id) CASE_GET_REG(AR_ ## id)
125 #define CASE_GET_CR(id) CASE_GET_REG(CR_ ## id)
128 ia64_native_getreg_func(int regnum
)
130 unsigned long res
= -1;
148 CASE_GET_AR(BSPSTORE
);
194 printk(KERN_CRIT
"wrong_getreg %d\n", regnum
);
200 #define CASE_SET_REG(id) \
201 case _IA64_REG_ ## id: \
202 ia64_native_setreg(_IA64_REG_ ## id, val); \
204 #define CASE_SET_AR(id) CASE_SET_REG(AR_ ## id)
205 #define CASE_SET_CR(id) CASE_SET_REG(CR_ ## id)
208 ia64_native_setreg_func(int regnum
, unsigned long val
)
211 case _IA64_REG_PSR_L
:
212 ia64_native_setreg(_IA64_REG_PSR_L
, val
);
213 ia64_dv_serialize_data();
228 CASE_SET_AR(BSPSTORE
);
273 printk(KERN_CRIT
"wrong setreg %d\n", regnum
);
278 struct pv_cpu_ops pv_cpu_ops
= {
279 .fc
= ia64_native_fc_func
,
280 .thash
= ia64_native_thash_func
,
281 .get_cpuid
= ia64_native_get_cpuid_func
,
282 .get_pmd
= ia64_native_get_pmd_func
,
283 .ptcga
= ia64_native_ptcga_func
,
284 .get_rr
= ia64_native_get_rr_func
,
285 .set_rr
= ia64_native_set_rr_func
,
286 .set_rr0_to_rr4
= ia64_native_set_rr0_to_rr4_func
,
287 .ssm_i
= ia64_native_ssm_i_func
,
288 .getreg
= ia64_native_getreg_func
,
289 .setreg
= ia64_native_setreg_func
,
290 .rsm_i
= ia64_native_rsm_i_func
,
291 .get_psr_i
= ia64_native_get_psr_i_func
,
292 .intrin_local_irq_restore
293 = ia64_native_intrin_local_irq_restore_func
,
295 EXPORT_SYMBOL(pv_cpu_ops
);
297 /******************************************************************************
298 * replacement of hand written assembly codes.
302 paravirt_cpu_asm_init(const struct pv_cpu_asm_switch
*cpu_asm_switch
)
304 extern unsigned long paravirt_switch_to_targ
;
305 extern unsigned long paravirt_leave_syscall_targ
;
306 extern unsigned long paravirt_work_processed_syscall_targ
;
307 extern unsigned long paravirt_leave_kernel_targ
;
309 paravirt_switch_to_targ
= cpu_asm_switch
->switch_to
;
310 paravirt_leave_syscall_targ
= cpu_asm_switch
->leave_syscall
;
311 paravirt_work_processed_syscall_targ
=
312 cpu_asm_switch
->work_processed_syscall
;
313 paravirt_leave_kernel_targ
= cpu_asm_switch
->leave_kernel
;
316 /***************************************************************************
318 * iosapic read/write hooks.
322 ia64_native_iosapic_read(char __iomem
*iosapic
, unsigned int reg
)
324 return __ia64_native_iosapic_read(iosapic
, reg
);
328 ia64_native_iosapic_write(char __iomem
*iosapic
, unsigned int reg
, u32 val
)
330 __ia64_native_iosapic_write(iosapic
, reg
, val
);
333 struct pv_iosapic_ops pv_iosapic_ops
= {
334 .pcat_compat_init
= ia64_native_iosapic_pcat_compat_init
,
335 .get_irq_chip
= ia64_native_iosapic_get_irq_chip
,
337 .__read
= ia64_native_iosapic_read
,
338 .__write
= ia64_native_iosapic_write
,
341 /***************************************************************************
346 struct pv_irq_ops pv_irq_ops
= {
347 .register_ipi
= ia64_native_register_ipi
,
349 .assign_irq_vector
= ia64_native_assign_irq_vector
,
350 .free_irq_vector
= ia64_native_free_irq_vector
,
351 .register_percpu_irq
= ia64_native_register_percpu_irq
,
353 .resend_irq
= ia64_native_resend_irq
,
356 /***************************************************************************
362 ia64_native_do_steal_accounting(unsigned long *new_itm
)
367 struct pv_time_ops pv_time_ops
= {
368 .do_steal_accounting
= ia64_native_do_steal_accounting
,