1 
2 #ifndef __XEN_DOMAIN_H__
3 #define __XEN_DOMAIN_H__
4 
5 #include <xen/types.h>
6 
7 #include <public/xen.h>
8 #include <asm/domain.h>
9 #include <asm/numa.h>
10 
11 typedef union {
12     struct vcpu_guest_context *nat;
13     struct compat_vcpu_guest_context *cmp;
14 } vcpu_guest_context_u __attribute__((__transparent_union__));
15 
16 struct vcpu *alloc_vcpu(
17     struct domain *d, unsigned int vcpu_id, unsigned int cpu_id);
18 struct vcpu *alloc_dom0_vcpu0(struct domain *dom0);
19 int vcpu_reset(struct vcpu *);
20 int vcpu_up(struct vcpu *v);
21 
22 struct xen_domctl_getdomaininfo;
23 void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info);
24 void arch_get_domain_info(const struct domain *d,
25                           struct xen_domctl_getdomaininfo *info);
26 
27 /*
28  * Arch-specifics.
29  */
30 
31 /* Allocate/free a domain structure. */
32 struct domain *alloc_domain_struct(void);
33 void free_domain_struct(struct domain *d);
34 
35 /* Allocate/free a VCPU structure. */
36 struct vcpu *alloc_vcpu_struct(void);
37 void free_vcpu_struct(struct vcpu *v);
38 
39 /* Allocate/free a PIRQ structure. */
40 #ifndef alloc_pirq_struct
41 struct pirq *alloc_pirq_struct(struct domain *);
42 #endif
43 void free_pirq_struct(void *);
44 
45 /*
46  * Initialise/destroy arch-specific details of a VCPU.
47  *  - vcpu_initialise() is called after the basic generic fields of the
48  *    VCPU structure are initialised. Many operations can be applied to the
49  *    VCPU at this point (e.g., vcpu_pause()).
50  *  - vcpu_destroy() is called only if vcpu_initialise() previously succeeded.
51  */
52 int  vcpu_initialise(struct vcpu *v);
53 void vcpu_destroy(struct vcpu *v);
54 
55 int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset);
56 void unmap_vcpu_info(struct vcpu *v);
57 
58 int arch_domain_create(struct domain *d, unsigned int domcr_flags,
59                        struct xen_arch_domainconfig *config);
60 
61 void arch_domain_destroy(struct domain *d);
62 
63 void arch_domain_shutdown(struct domain *d);
64 void arch_domain_pause(struct domain *d);
65 void arch_domain_unpause(struct domain *d);
66 
67 int arch_domain_soft_reset(struct domain *d);
68 
69 int arch_set_info_guest(struct vcpu *, vcpu_guest_context_u);
70 void arch_get_info_guest(struct vcpu *, vcpu_guest_context_u);
71 
72 int arch_initialise_vcpu(struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg);
73 int default_initialise_vcpu(struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg);
74 
75 int domain_relinquish_resources(struct domain *d);
76 
77 void dump_pageframe_info(struct domain *d);
78 
79 void arch_dump_vcpu_info(struct vcpu *v);
80 
81 void arch_dump_domain_info(struct domain *d);
82 
83 int arch_vcpu_reset(struct vcpu *);
84 
85 extern spinlock_t vcpu_alloc_lock;
86 bool_t domctl_lock_acquire(void);
87 void domctl_lock_release(void);
88 
89 /*
90  * Continue the current hypercall via func(data) on specified cpu.
91  * If this function returns 0 then the function is guaranteed to run at some
92  * point in the future. If this function returns an error code then the
93  * function has not been and will not be executed.
94  */
95 int continue_hypercall_on_cpu(
96     unsigned int cpu, long (*func)(void *data), void *data);
97 
98 extern unsigned int xen_processor_pmbits;
99 
100 extern bool_t opt_dom0_vcpus_pin;
101 
102 /* vnuma topology per domain. */
103 struct vnuma_info {
104     unsigned int nr_vnodes;
105     unsigned int nr_vmemranges;
106     unsigned int *vdistance;
107     unsigned int *vcpu_to_vnode;
108     nodeid_t *vnode_to_pnode;
109     struct xen_vmemrange *vmemrange;
110 };
111 
112 void vnuma_destroy(struct vnuma_info *vnuma);
113 
114 #endif /* __XEN_DOMAIN_H__ */
115