direct-io.hg

view xen/include/asm-powerpc/current.h @ 11487:4fdf5151b187

[POWERPC] merge with xen-unstable.hg
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author hollisb@localhost
date Mon Sep 18 12:48:56 2006 -0500 (2006-09-18)
parents 1ef82dd7f66b
children
line source
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 *
16 * Copyright (C) IBM Corp. 2005, 2006
17 *
18 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
19 */
21 #ifndef _ASM_CURRENT_H_
22 #define _ASM_CURRENT_H_
24 #include <public/xen.h>
25 #include <asm/processor.h>
26 #include <asm/powerpc64/procarea.h>
28 struct vcpu;
30 extern volatile struct processor_area * volatile global_cpu_table[];
31 register volatile struct processor_area *parea asm("r13");
32 static inline struct vcpu *get_current(void)
33 {
34 return parea->cur_vcpu;
35 }
36 #define current get_current()
38 static inline void set_current(struct vcpu *v)
39 {
40 parea->cur_vcpu = v;
41 }
43 /* The *currently running* guest's register state has been saved at the top of
44 * this processor's hypervisor stack. */
45 static inline struct cpu_user_regs *guest_cpu_user_regs(void)
46 {
47 ulong stack_top = (ulong)parea->hyp_stack_base;
49 return (struct cpu_user_regs *)(stack_top - STACK_VOLATILE_AREA
50 - sizeof (struct cpu_user_regs));
51 }
53 /* XXX *#%(ing circular header dependencies force this to be a macro */
54 /* If the vcpu is running, its state is still on the stack, and the vcpu
55 * structure's copy is obsolete. If the vcpu isn't running, the vcpu structure
56 * holds the only copy. This routine always does the right thing. */
57 #define vcpu_regs(v) ({ \
58 struct cpu_user_regs *regs; \
59 if (v == current) \
60 regs = guest_cpu_user_regs(); \
61 else \
62 regs = &v->arch.ctxt; \
63 regs; \
64 })
67 static inline void reset_stack_and_jump(void (*f)(void))
68 {
69 void _reset_stack_and_jump(void (*)(void), struct cpu_user_regs *);
70 struct cpu_user_regs *regs = guest_cpu_user_regs();
72 #ifdef TRACK_RESUME
73 printk("PC: 0x%lx, MSR: 0x%lx\n", regs->pc, regs->msr);
74 #endif
76 _reset_stack_and_jump(f, regs);
77 }
79 #endif