1 #ifndef __ARM_CURRENT_H__ 2 #define __ARM_CURRENT_H__ 3 4 #include <xen/percpu.h> 5 #include <public/xen.h> 6 7 #include <asm/percpu.h> 8 #include <asm/processor.h> 9 10 #ifndef __ASSEMBLY__ 11 12 struct vcpu; 13 14 /* Which VCPU is "current" on this PCPU. */ 15 DECLARE_PER_CPU(struct vcpu *, curr_vcpu); 16 17 #define current (this_cpu(curr_vcpu)) 18 #define set_current(vcpu) do { current = (vcpu); } while (0) 19 20 /* Per-VCPU state that lives at the top of the stack */ 21 struct cpu_info { 22 struct cpu_user_regs guest_cpu_user_regs; 23 unsigned long elr; 24 unsigned int pad; 25 }; 26 get_cpu_info(void)27static inline struct cpu_info *get_cpu_info(void) 28 { 29 register unsigned long sp asm ("sp"); 30 return (struct cpu_info *)((sp & ~(STACK_SIZE - 1)) + STACK_SIZE - sizeof(struct cpu_info)); 31 } 32 33 #define guest_cpu_user_regs() (&get_cpu_info()->guest_cpu_user_regs) 34 35 #define switch_stack_and_jump(stack, fn) \ 36 asm volatile ("mov sp,%0; b " STR(fn) : : "r" (stack) : "memory" ) 37 38 #define reset_stack_and_jump(fn) switch_stack_and_jump(get_cpu_info(), fn) 39 40 #endif 41 42 #endif /* __ARM_CURRENT_H__ */ 43 /* 44 * Local variables: 45 * mode: C 46 * c-file-style: "BSD" 47 * c-basic-offset: 4 48 * indent-tabs-mode: nil 49 * End: 50 */ 51