Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / xen / include / xen3-public / sysctl.h
bloba09ae3890226d6c09815b75965777db3541bbac5
1 /* $NetBSD: sysctl.h,v 1.3 2008/05/04 19:56:28 cegger Exp $ */
2 /******************************************************************************
3 * sysctl.h
4 *
5 * System management operations. For use by node control stack.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to
9 * deal in the Software without restriction, including without limitation the
10 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
25 * Copyright (c) 2002-2006, K Fraser
28 #ifndef __XEN_PUBLIC_SYSCTL_H__
29 #define __XEN_PUBLIC_SYSCTL_H__
31 #if !defined(__XEN__) && !defined(__XEN_TOOLS__)
32 #error "sysctl operations are intended for use by node control tools only"
33 #endif
35 #include "xen.h"
36 #include "domctl.h"
38 #define XEN_SYSCTL_INTERFACE_VERSION 0x00000006
41 * Read console content from Xen buffer ring.
43 #define XEN_SYSCTL_readconsole 1
44 struct xen_sysctl_readconsole {
45 /* IN: Non-zero -> clear after reading. */
46 uint8_t clear;
47 /* IN: Non-zero -> start index specified by @index field. */
48 uint8_t incremental;
49 uint8_t pad0, pad1;
51 * IN: Start index for consuming from ring buffer (if @incremental);
52 * OUT: End index after consuming from ring buffer.
54 uint32_t index;
55 /* IN: Virtual address to write console data. */
56 XEN_GUEST_HANDLE_64(char) buffer;
57 /* IN: Size of buffer; OUT: Bytes written to buffer. */
58 uint32_t count;
60 typedef struct xen_sysctl_readconsole xen_sysctl_readconsole_t;
61 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_readconsole_t);
63 /* Get trace buffers machine base address */
64 #define XEN_SYSCTL_tbuf_op 2
65 struct xen_sysctl_tbuf_op {
66 /* IN variables */
67 #define XEN_SYSCTL_TBUFOP_get_info 0
68 #define XEN_SYSCTL_TBUFOP_set_cpu_mask 1
69 #define XEN_SYSCTL_TBUFOP_set_evt_mask 2
70 #define XEN_SYSCTL_TBUFOP_set_size 3
71 #define XEN_SYSCTL_TBUFOP_enable 4
72 #define XEN_SYSCTL_TBUFOP_disable 5
73 uint32_t cmd;
74 /* IN/OUT variables */
75 struct xenctl_cpumap cpu_mask;
76 uint32_t evt_mask;
77 /* OUT variables */
78 uint64_aligned_t buffer_mfn;
79 uint32_t size;
81 typedef struct xen_sysctl_tbuf_op xen_sysctl_tbuf_op_t;
82 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_tbuf_op_t);
85 * Get physical information about the host machine
87 #define XEN_SYSCTL_physinfo 3
88 /* (x86) The platform supports HVM guests. */
89 #define _XEN_SYSCTL_PHYSCAP_hvm 0
90 #define XEN_SYSCTL_PHYSCAP_hvm (1u<<_XEN_SYSCTL_PHYSCAP_hvm)
91 /* (x86) The platform supports HVM-guest direct access to I/O devices. */
92 #define _XEN_SYSCTL_PHYSCAP_hvm_directio 1
93 #define XEN_SYSCTL_PHYSCAP_hvm_directio (1u<<_XEN_SYSCTL_PHYSCAP_hvm_directio)
94 struct xen_sysctl_physinfo {
95 /* IN variables. */
96 uint32_t threads_per_core;
97 uint32_t cores_per_socket;
98 uint32_t nr_cpus;
99 uint32_t nr_nodes;
100 uint32_t cpu_khz;
101 uint64_aligned_t total_pages;
102 uint64_aligned_t free_pages;
103 uint64_aligned_t scrub_pages;
104 uint32_t hw_cap[8];
107 * IN: maximum addressable entry in the caller-provided cpu_to_node array.
108 * OUT: largest cpu identifier in the system.
109 * If OUT is greater than IN then the cpu_to_node array is truncated!
111 uint32_t max_cpu_id;
113 * If not NULL, this array is filled with node identifier for each cpu.
114 * If a cpu has no node information (e.g., cpu not present) then the
115 * sentinel value ~0u is written.
116 * The size of this array is specified by the caller in @max_cpu_id.
117 * If the actual @max_cpu_id is smaller than the array then the trailing
118 * elements of the array will not be written by the sysctl.
120 XEN_GUEST_HANDLE_64(uint32) cpu_to_node;
122 /* XEN_SYSCTL_PHYSCAP_??? */
123 uint32_t capabilities;
125 typedef struct xen_sysctl_physinfo xen_sysctl_physinfo_t;
126 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_physinfo_t);
129 * Get the ID of the current scheduler.
131 #define XEN_SYSCTL_sched_id 4
132 struct xen_sysctl_sched_id {
133 /* OUT variable */
134 uint32_t sched_id;
136 typedef struct xen_sysctl_sched_id xen_sysctl_sched_id_t;
137 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_sched_id_t);
139 /* Interface for controlling Xen software performance counters. */
140 #define XEN_SYSCTL_perfc_op 5
141 /* Sub-operations: */
142 #define XEN_SYSCTL_PERFCOP_reset 1 /* Reset all counters to zero. */
143 #define XEN_SYSCTL_PERFCOP_query 2 /* Get perfctr information. */
144 struct xen_sysctl_perfc_desc {
145 char name[80]; /* name of perf counter */
146 uint32_t nr_vals; /* number of values for this counter */
148 typedef struct xen_sysctl_perfc_desc xen_sysctl_perfc_desc_t;
149 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t);
150 typedef uint32_t xen_sysctl_perfc_val_t;
151 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_val_t);
153 struct xen_sysctl_perfc_op {
154 /* IN variables. */
155 uint32_t cmd; /* XEN_SYSCTL_PERFCOP_??? */
156 /* OUT variables. */
157 uint32_t nr_counters; /* number of counters description */
158 uint32_t nr_vals; /* number of values */
159 /* counter information (or NULL) */
160 XEN_GUEST_HANDLE_64(xen_sysctl_perfc_desc_t) desc;
161 /* counter values (or NULL) */
162 XEN_GUEST_HANDLE_64(xen_sysctl_perfc_val_t) val;
164 typedef struct xen_sysctl_perfc_op xen_sysctl_perfc_op_t;
165 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_op_t);
167 #define XEN_SYSCTL_getdomaininfolist 6
168 struct xen_sysctl_getdomaininfolist {
169 /* IN variables. */
170 domid_t first_domain;
171 uint32_t max_domains;
172 XEN_GUEST_HANDLE_64(xen_domctl_getdomaininfo_t) buffer;
173 /* OUT variables. */
174 uint32_t num_domains;
176 typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
177 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
179 /* Inject debug keys into Xen. */
180 #define XEN_SYSCTL_debug_keys 7
181 struct xen_sysctl_debug_keys {
182 /* IN variables. */
183 XEN_GUEST_HANDLE_64(char) keys;
184 uint32_t nr_keys;
186 typedef struct xen_sysctl_debug_keys xen_sysctl_debug_keys_t;
187 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_debug_keys_t);
189 /* Get physical CPU information. */
190 #define XEN_SYSCTL_getcpuinfo 8
191 struct xen_sysctl_cpuinfo {
192 uint64_aligned_t idletime;
194 typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;
195 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t);
196 struct xen_sysctl_getcpuinfo {
197 /* IN variables. */
198 uint32_t max_cpus;
199 XEN_GUEST_HANDLE_64(xen_sysctl_cpuinfo_t) info;
200 /* OUT variables. */
201 uint32_t nr_cpus;
203 typedef struct xen_sysctl_getcpuinfo xen_sysctl_getcpuinfo_t;
204 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getcpuinfo_t);
206 #define XEN_SYSCTL_availheap 9
207 struct xen_sysctl_availheap {
208 /* IN variables. */
209 uint32_t min_bitwidth; /* Smallest address width (zero if don't care). */
210 uint32_t max_bitwidth; /* Largest address width (zero if don't care). */
211 int32_t node; /* NUMA node of interest (-1 for all nodes). */
212 /* OUT variables. */
213 uint64_aligned_t avail_bytes;/* Bytes available in the specified region. */
215 typedef struct xen_sysctl_availheap xen_sysctl_availheap_t;
216 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_availheap_t);
218 #define XEN_SYSCTL_get_pmstat 10
219 struct pm_px_val {
220 uint64_aligned_t freq; /* Px core frequency */
221 uint64_aligned_t residency; /* Px residency time */
222 uint64_aligned_t count; /* Px transition count */
224 typedef struct pm_px_val pm_px_val_t;
225 DEFINE_XEN_GUEST_HANDLE(pm_px_val_t);
227 struct pm_px_stat {
228 uint8_t total; /* total Px states */
229 uint8_t usable; /* usable Px states */
230 uint8_t last; /* last Px state */
231 uint8_t cur; /* current Px state */
232 XEN_GUEST_HANDLE_64(uint64) trans_pt; /* Px transition table */
233 XEN_GUEST_HANDLE_64(pm_px_val_t) pt;
235 typedef struct pm_px_stat pm_px_stat_t;
236 DEFINE_XEN_GUEST_HANDLE(pm_px_stat_t);
238 struct pm_cx_stat {
239 uint32_t nr; /* entry nr in triggers & residencies, including C0 */
240 uint32_t last; /* last Cx state */
241 uint64_aligned_t idle_time; /* idle time from boot */
242 XEN_GUEST_HANDLE_64(uint64) triggers; /* Cx trigger counts */
243 XEN_GUEST_HANDLE_64(uint64) residencies; /* Cx residencies */
246 struct xen_sysctl_get_pmstat {
247 #define PMSTAT_CATEGORY_MASK 0xf0
248 #define PMSTAT_PX 0x10
249 #define PMSTAT_CX 0x20
250 #define PMSTAT_get_max_px (PMSTAT_PX | 0x1)
251 #define PMSTAT_get_pxstat (PMSTAT_PX | 0x2)
252 #define PMSTAT_reset_pxstat (PMSTAT_PX | 0x3)
253 #define PMSTAT_get_max_cx (PMSTAT_CX | 0x1)
254 #define PMSTAT_get_cxstat (PMSTAT_CX | 0x2)
255 #define PMSTAT_reset_cxstat (PMSTAT_CX | 0x3)
256 uint32_t type;
257 uint32_t cpuid;
258 union {
259 struct pm_px_stat getpx;
260 struct pm_cx_stat getcx;
261 /* other struct for tx, etc */
262 } u;
264 typedef struct xen_sysctl_get_pmstat xen_sysctl_get_pmstat_t;
265 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_get_pmstat_t);
267 struct xen_sysctl {
268 uint32_t cmd;
269 uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
270 union {
271 struct xen_sysctl_readconsole readconsole;
272 struct xen_sysctl_tbuf_op tbuf_op;
273 struct xen_sysctl_physinfo physinfo;
274 struct xen_sysctl_sched_id sched_id;
275 struct xen_sysctl_perfc_op perfc_op;
276 struct xen_sysctl_getdomaininfolist getdomaininfolist;
277 struct xen_sysctl_debug_keys debug_keys;
278 struct xen_sysctl_getcpuinfo getcpuinfo;
279 struct xen_sysctl_availheap availheap;
280 struct xen_sysctl_get_pmstat get_pmstat;
281 uint8_t pad[128];
282 } u;
284 typedef struct xen_sysctl xen_sysctl_t;
285 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_t);
287 #endif /* __XEN_PUBLIC_SYSCTL_H__ */
290 * Local variables:
291 * mode: C
292 * c-set-style: "BSD"
293 * c-basic-offset: 4
294 * tab-width: 4
295 * indent-tabs-mode: nil
296 * End: