1 | /****************************************************************************** |
---|
2 | * xc_misc.c |
---|
3 | * |
---|
4 | * Miscellaneous control interface functions. |
---|
5 | */ |
---|
6 | |
---|
7 | #include "xc_private.h" |
---|
8 | #include <xen/hvm/hvm_op.h> |
---|
9 | |
---|
10 | int xc_readconsolering(int xc_handle, |
---|
11 | char **pbuffer, |
---|
12 | unsigned int *pnr_chars, |
---|
13 | int clear) |
---|
14 | { |
---|
15 | int ret; |
---|
16 | DECLARE_SYSCTL; |
---|
17 | char *buffer = *pbuffer; |
---|
18 | unsigned int nr_chars = *pnr_chars; |
---|
19 | |
---|
20 | sysctl.cmd = XEN_SYSCTL_readconsole; |
---|
21 | set_xen_guest_handle(sysctl.u.readconsole.buffer, buffer); |
---|
22 | sysctl.u.readconsole.count = nr_chars; |
---|
23 | sysctl.u.readconsole.clear = clear; |
---|
24 | |
---|
25 | if ( (ret = lock_pages(buffer, nr_chars)) != 0 ) |
---|
26 | return ret; |
---|
27 | |
---|
28 | if ( (ret = do_sysctl(xc_handle, &sysctl)) == 0 ) |
---|
29 | *pnr_chars = sysctl.u.readconsole.count; |
---|
30 | |
---|
31 | unlock_pages(buffer, nr_chars); |
---|
32 | |
---|
33 | return ret; |
---|
34 | } |
---|
35 | |
---|
36 | int xc_send_debug_keys(int xc_handle, char *keys) |
---|
37 | { |
---|
38 | int ret, len = strlen(keys); |
---|
39 | DECLARE_SYSCTL; |
---|
40 | |
---|
41 | sysctl.cmd = XEN_SYSCTL_debug_keys; |
---|
42 | set_xen_guest_handle(sysctl.u.debug_keys.keys, keys); |
---|
43 | sysctl.u.debug_keys.nr_keys = len; |
---|
44 | |
---|
45 | if ( (ret = lock_pages(keys, len)) != 0 ) |
---|
46 | return ret; |
---|
47 | |
---|
48 | ret = do_sysctl(xc_handle, &sysctl); |
---|
49 | |
---|
50 | unlock_pages(keys, len); |
---|
51 | |
---|
52 | return ret; |
---|
53 | } |
---|
54 | |
---|
55 | int xc_physinfo(int xc_handle, |
---|
56 | xc_physinfo_t *put_info) |
---|
57 | { |
---|
58 | int ret; |
---|
59 | DECLARE_SYSCTL; |
---|
60 | |
---|
61 | sysctl.cmd = XEN_SYSCTL_physinfo; |
---|
62 | |
---|
63 | if ( (ret = do_sysctl(xc_handle, &sysctl)) != 0 ) |
---|
64 | return ret; |
---|
65 | |
---|
66 | memcpy(put_info, &sysctl.u.physinfo, sizeof(*put_info)); |
---|
67 | |
---|
68 | return 0; |
---|
69 | } |
---|
70 | |
---|
71 | int xc_sched_id(int xc_handle, |
---|
72 | int *sched_id) |
---|
73 | { |
---|
74 | int ret; |
---|
75 | DECLARE_SYSCTL; |
---|
76 | |
---|
77 | sysctl.cmd = XEN_SYSCTL_sched_id; |
---|
78 | |
---|
79 | if ( (ret = do_sysctl(xc_handle, &sysctl)) != 0 ) |
---|
80 | return ret; |
---|
81 | |
---|
82 | *sched_id = sysctl.u.sched_id.sched_id; |
---|
83 | |
---|
84 | return 0; |
---|
85 | } |
---|
86 | |
---|
87 | int xc_perfc_control(int xc_handle, |
---|
88 | uint32_t opcode, |
---|
89 | xc_perfc_desc_t *desc, |
---|
90 | xc_perfc_val_t *val, |
---|
91 | int *nbr_desc, |
---|
92 | int *nbr_val) |
---|
93 | { |
---|
94 | int rc; |
---|
95 | DECLARE_SYSCTL; |
---|
96 | |
---|
97 | sysctl.cmd = XEN_SYSCTL_perfc_op; |
---|
98 | sysctl.u.perfc_op.cmd = opcode; |
---|
99 | set_xen_guest_handle(sysctl.u.perfc_op.desc, desc); |
---|
100 | set_xen_guest_handle(sysctl.u.perfc_op.val, val); |
---|
101 | |
---|
102 | rc = do_sysctl(xc_handle, &sysctl); |
---|
103 | |
---|
104 | if (nbr_desc) |
---|
105 | *nbr_desc = sysctl.u.perfc_op.nr_counters; |
---|
106 | if (nbr_val) |
---|
107 | *nbr_val = sysctl.u.perfc_op.nr_vals; |
---|
108 | |
---|
109 | return rc; |
---|
110 | } |
---|
111 | |
---|
112 | int xc_hvm_set_pci_intx_level( |
---|
113 | int xc_handle, domid_t dom, |
---|
114 | uint8_t domain, uint8_t bus, uint8_t device, uint8_t intx, |
---|
115 | unsigned int level) |
---|
116 | { |
---|
117 | DECLARE_HYPERCALL; |
---|
118 | struct xen_hvm_set_pci_intx_level arg; |
---|
119 | int rc; |
---|
120 | |
---|
121 | hypercall.op = __HYPERVISOR_hvm_op; |
---|
122 | hypercall.arg[0] = HVMOP_set_pci_intx_level; |
---|
123 | hypercall.arg[1] = (unsigned long)&arg; |
---|
124 | |
---|
125 | arg.domid = dom; |
---|
126 | arg.domain = domain; |
---|
127 | arg.bus = bus; |
---|
128 | arg.device = device; |
---|
129 | arg.intx = intx; |
---|
130 | arg.level = level; |
---|
131 | |
---|
132 | if ( (rc = lock_pages(&arg, sizeof(arg))) != 0 ) |
---|
133 | { |
---|
134 | PERROR("Could not lock memory"); |
---|
135 | return rc; |
---|
136 | } |
---|
137 | |
---|
138 | rc = do_xen_hypercall(xc_handle, &hypercall); |
---|
139 | |
---|
140 | unlock_pages(&arg, sizeof(arg)); |
---|
141 | |
---|
142 | return rc; |
---|
143 | } |
---|
144 | |
---|
145 | int xc_hvm_set_isa_irq_level( |
---|
146 | int xc_handle, domid_t dom, |
---|
147 | uint8_t isa_irq, |
---|
148 | unsigned int level) |
---|
149 | { |
---|
150 | DECLARE_HYPERCALL; |
---|
151 | struct xen_hvm_set_isa_irq_level arg; |
---|
152 | int rc; |
---|
153 | |
---|
154 | hypercall.op = __HYPERVISOR_hvm_op; |
---|
155 | hypercall.arg[0] = HVMOP_set_isa_irq_level; |
---|
156 | hypercall.arg[1] = (unsigned long)&arg; |
---|
157 | |
---|
158 | arg.domid = dom; |
---|
159 | arg.isa_irq = isa_irq; |
---|
160 | arg.level = level; |
---|
161 | |
---|
162 | if ( (rc = lock_pages(&arg, sizeof(arg))) != 0 ) |
---|
163 | { |
---|
164 | PERROR("Could not lock memory"); |
---|
165 | return rc; |
---|
166 | } |
---|
167 | |
---|
168 | rc = do_xen_hypercall(xc_handle, &hypercall); |
---|
169 | |
---|
170 | unlock_pages(&arg, sizeof(arg)); |
---|
171 | |
---|
172 | return rc; |
---|
173 | } |
---|
174 | |
---|
175 | int xc_hvm_set_pci_link_route( |
---|
176 | int xc_handle, domid_t dom, uint8_t link, uint8_t isa_irq) |
---|
177 | { |
---|
178 | DECLARE_HYPERCALL; |
---|
179 | struct xen_hvm_set_pci_link_route arg; |
---|
180 | int rc; |
---|
181 | |
---|
182 | hypercall.op = __HYPERVISOR_hvm_op; |
---|
183 | hypercall.arg[0] = HVMOP_set_pci_link_route; |
---|
184 | hypercall.arg[1] = (unsigned long)&arg; |
---|
185 | |
---|
186 | arg.domid = dom; |
---|
187 | arg.link = link; |
---|
188 | arg.isa_irq = isa_irq; |
---|
189 | |
---|
190 | if ( (rc = lock_pages(&arg, sizeof(arg))) != 0 ) |
---|
191 | { |
---|
192 | PERROR("Could not lock memory"); |
---|
193 | return rc; |
---|
194 | } |
---|
195 | |
---|
196 | rc = do_xen_hypercall(xc_handle, &hypercall); |
---|
197 | |
---|
198 | unlock_pages(&arg, sizeof(arg)); |
---|
199 | |
---|
200 | return rc; |
---|
201 | } |
---|
202 | |
---|
203 | /* |
---|
204 | * Local variables: |
---|
205 | * mode: C |
---|
206 | * c-set-style: "BSD" |
---|
207 | * c-basic-offset: 4 |
---|
208 | * tab-width: 4 |
---|
209 | * indent-tabs-mode: nil |
---|
210 | * End: |
---|
211 | */ |
---|