]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/xen/xen-public/sysctl.h
bcm: flush out early boot messages on uart and screen initialization
[plan9front.git] / sys / src / 9 / xen / xen-public / sysctl.h
1 /******************************************************************************
2  * sysctl.h
3  * 
4  * System management operations. For use by node control stack.
5  * 
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  *
24  * Copyright (c) 2002-2006, K Fraser
25  */
26
27 #ifndef __XEN_PUBLIC_SYSCTL_H__
28 #define __XEN_PUBLIC_SYSCTL_H__
29
30 #if !defined(__XEN__) && !defined(__XEN_TOOLS__)
31 #error "sysctl operations are intended for use by node control tools only"
32 #endif
33
34 #include "xen.h"
35 #include "domctl.h"
36
37 #define XEN_SYSCTL_INTERFACE_VERSION 0x0000000A
38
39 /*
40  * Read console content from Xen buffer ring.
41  */
42 /* XEN_SYSCTL_readconsole */
43 struct xen_sysctl_readconsole {
44     /* IN: Non-zero -> clear after reading. */
45     uint8_t clear;
46     /* IN: Non-zero -> start index specified by @index field. */
47     uint8_t incremental;
48     uint8_t pad0, pad1;
49     /*
50      * IN:  Start index for consuming from ring buffer (if @incremental);
51      * OUT: End index after consuming from ring buffer.
52      */
53     uint32_t index; 
54     /* IN: Virtual address to write console data. */
55     XEN_GUEST_HANDLE_64(char) buffer;
56     /* IN: Size of buffer; OUT: Bytes written to buffer. */
57     uint32_t count;
58 };
59 typedef struct xen_sysctl_readconsole xen_sysctl_readconsole_t;
60 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_readconsole_t);
61
62 /* Get trace buffers machine base address */
63 /* XEN_SYSCTL_tbuf_op */
64 struct xen_sysctl_tbuf_op {
65     /* IN variables */
66 #define XEN_SYSCTL_TBUFOP_get_info     0
67 #define XEN_SYSCTL_TBUFOP_set_cpu_mask 1
68 #define XEN_SYSCTL_TBUFOP_set_evt_mask 2
69 #define XEN_SYSCTL_TBUFOP_set_size     3
70 #define XEN_SYSCTL_TBUFOP_enable       4
71 #define XEN_SYSCTL_TBUFOP_disable      5
72     uint32_t cmd;
73     /* IN/OUT variables */
74     struct xenctl_bitmap cpu_mask;
75     uint32_t             evt_mask;
76     /* OUT variables */
77     uint64_aligned_t buffer_mfn;
78     uint32_t size;  /* Also an IN variable! */
79 };
80 typedef struct xen_sysctl_tbuf_op xen_sysctl_tbuf_op_t;
81 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_tbuf_op_t);
82
83 /*
84  * Get physical information about the host machine
85  */
86 /* XEN_SYSCTL_physinfo */
87  /* (x86) The platform supports HVM guests. */
88 #define _XEN_SYSCTL_PHYSCAP_hvm          0
89 #define XEN_SYSCTL_PHYSCAP_hvm           (1u<<_XEN_SYSCTL_PHYSCAP_hvm)
90  /* (x86) The platform supports HVM-guest direct access to I/O devices. */
91 #define _XEN_SYSCTL_PHYSCAP_hvm_directio 1
92 #define XEN_SYSCTL_PHYSCAP_hvm_directio  (1u<<_XEN_SYSCTL_PHYSCAP_hvm_directio)
93 struct xen_sysctl_physinfo {
94     uint32_t threads_per_core;
95     uint32_t cores_per_socket;
96     uint32_t nr_cpus;     /* # CPUs currently online */
97     uint32_t max_cpu_id;  /* Largest possible CPU ID on this host */
98     uint32_t nr_nodes;    /* # nodes currently online */
99     uint32_t max_node_id; /* Largest possible node ID on this host */
100     uint32_t cpu_khz;
101     uint64_aligned_t total_pages;
102     uint64_aligned_t free_pages;
103     uint64_aligned_t scrub_pages;
104     uint64_aligned_t outstanding_pages;
105     uint32_t hw_cap[8];
106
107     /* XEN_SYSCTL_PHYSCAP_??? */
108     uint32_t capabilities;
109 };
110 typedef struct xen_sysctl_physinfo xen_sysctl_physinfo_t;
111 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_physinfo_t);
112
113 /*
114  * Get the ID of the current scheduler.
115  */
116 /* XEN_SYSCTL_sched_id */
117 struct xen_sysctl_sched_id {
118     /* OUT variable */
119     uint32_t sched_id;
120 };
121 typedef struct xen_sysctl_sched_id xen_sysctl_sched_id_t;
122 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_sched_id_t);
123
124 /* Interface for controlling Xen software performance counters. */
125 /* XEN_SYSCTL_perfc_op */
126 /* Sub-operations: */
127 #define XEN_SYSCTL_PERFCOP_reset 1   /* Reset all counters to zero. */
128 #define XEN_SYSCTL_PERFCOP_query 2   /* Get perfctr information. */
129 struct xen_sysctl_perfc_desc {
130     char         name[80];             /* name of perf counter */
131     uint32_t     nr_vals;              /* number of values for this counter */
132 };
133 typedef struct xen_sysctl_perfc_desc xen_sysctl_perfc_desc_t;
134 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t);
135 typedef uint32_t xen_sysctl_perfc_val_t;
136 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_val_t);
137
138 struct xen_sysctl_perfc_op {
139     /* IN variables. */
140     uint32_t       cmd;                /*  XEN_SYSCTL_PERFCOP_??? */
141     /* OUT variables. */
142     uint32_t       nr_counters;       /*  number of counters description  */
143     uint32_t       nr_vals;           /*  number of values  */
144     /* counter information (or NULL) */
145     XEN_GUEST_HANDLE_64(xen_sysctl_perfc_desc_t) desc;
146     /* counter values (or NULL) */
147     XEN_GUEST_HANDLE_64(xen_sysctl_perfc_val_t) val;
148 };
149 typedef struct xen_sysctl_perfc_op xen_sysctl_perfc_op_t;
150 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_op_t);
151
152 /* XEN_SYSCTL_getdomaininfolist */
153 struct xen_sysctl_getdomaininfolist {
154     /* IN variables. */
155     domid_t               first_domain;
156     uint32_t              max_domains;
157     XEN_GUEST_HANDLE_64(xen_domctl_getdomaininfo_t) buffer;
158     /* OUT variables. */
159     uint32_t              num_domains;
160 };
161 typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
162 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
163
164 /* Inject debug keys into Xen. */
165 /* XEN_SYSCTL_debug_keys */
166 struct xen_sysctl_debug_keys {
167     /* IN variables. */
168     XEN_GUEST_HANDLE_64(char) keys;
169     uint32_t nr_keys;
170 };
171 typedef struct xen_sysctl_debug_keys xen_sysctl_debug_keys_t;
172 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_debug_keys_t);
173
174 /* Get physical CPU information. */
175 /* XEN_SYSCTL_getcpuinfo */
176 struct xen_sysctl_cpuinfo {
177     uint64_aligned_t idletime;
178 };
179 typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;
180 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t); 
181 struct xen_sysctl_getcpuinfo {
182     /* IN variables. */
183     uint32_t max_cpus;
184     XEN_GUEST_HANDLE_64(xen_sysctl_cpuinfo_t) info;
185     /* OUT variables. */
186     uint32_t nr_cpus;
187 }; 
188 typedef struct xen_sysctl_getcpuinfo xen_sysctl_getcpuinfo_t;
189 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getcpuinfo_t); 
190
191 /* XEN_SYSCTL_availheap */
192 struct xen_sysctl_availheap {
193     /* IN variables. */
194     uint32_t min_bitwidth;  /* Smallest address width (zero if don't care). */
195     uint32_t max_bitwidth;  /* Largest address width (zero if don't care). */
196     int32_t  node;          /* NUMA node of interest (-1 for all nodes). */
197     /* OUT variables. */
198     uint64_aligned_t avail_bytes;/* Bytes available in the specified region. */
199 };
200 typedef struct xen_sysctl_availheap xen_sysctl_availheap_t;
201 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_availheap_t);
202
203 /* XEN_SYSCTL_get_pmstat */
204 struct pm_px_val {
205     uint64_aligned_t freq;        /* Px core frequency */
206     uint64_aligned_t residency;   /* Px residency time */
207     uint64_aligned_t count;       /* Px transition count */
208 };
209 typedef struct pm_px_val pm_px_val_t;
210 DEFINE_XEN_GUEST_HANDLE(pm_px_val_t);
211
212 struct pm_px_stat {
213     uint8_t total;        /* total Px states */
214     uint8_t usable;       /* usable Px states */
215     uint8_t last;         /* last Px state */
216     uint8_t cur;          /* current Px state */
217     XEN_GUEST_HANDLE_64(uint64) trans_pt;   /* Px transition table */
218     XEN_GUEST_HANDLE_64(pm_px_val_t) pt;
219 };
220 typedef struct pm_px_stat pm_px_stat_t;
221 DEFINE_XEN_GUEST_HANDLE(pm_px_stat_t);
222
223 struct pm_cx_stat {
224     uint32_t nr;    /* entry nr in triggers & residencies, including C0 */
225     uint32_t last;  /* last Cx state */
226     uint64_aligned_t idle_time;                 /* idle time from boot */
227     XEN_GUEST_HANDLE_64(uint64) triggers;    /* Cx trigger counts */
228     XEN_GUEST_HANDLE_64(uint64) residencies; /* Cx residencies */
229     uint64_aligned_t pc2;
230     uint64_aligned_t pc3;
231     uint64_aligned_t pc6;
232     uint64_aligned_t pc7;
233     uint64_aligned_t cc3;
234     uint64_aligned_t cc6;
235     uint64_aligned_t cc7;
236 };
237
238 struct xen_sysctl_get_pmstat {
239 #define PMSTAT_CATEGORY_MASK 0xf0
240 #define PMSTAT_PX            0x10
241 #define PMSTAT_CX            0x20
242 #define PMSTAT_get_max_px    (PMSTAT_PX | 0x1)
243 #define PMSTAT_get_pxstat    (PMSTAT_PX | 0x2)
244 #define PMSTAT_reset_pxstat  (PMSTAT_PX | 0x3)
245 #define PMSTAT_get_max_cx    (PMSTAT_CX | 0x1)
246 #define PMSTAT_get_cxstat    (PMSTAT_CX | 0x2)
247 #define PMSTAT_reset_cxstat  (PMSTAT_CX | 0x3)
248     uint32_t type;
249     uint32_t cpuid;
250     union {
251         struct pm_px_stat getpx;
252         struct pm_cx_stat getcx;
253         /* other struct for tx, etc */
254     } u;
255 };
256 typedef struct xen_sysctl_get_pmstat xen_sysctl_get_pmstat_t;
257 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_get_pmstat_t);
258
259 /* XEN_SYSCTL_cpu_hotplug */
260 struct xen_sysctl_cpu_hotplug {
261     /* IN variables */
262     uint32_t cpu;   /* Physical cpu. */
263 #define XEN_SYSCTL_CPU_HOTPLUG_ONLINE  0
264 #define XEN_SYSCTL_CPU_HOTPLUG_OFFLINE 1
265     uint32_t op;    /* hotplug opcode */
266 };
267 typedef struct xen_sysctl_cpu_hotplug xen_sysctl_cpu_hotplug_t;
268 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpu_hotplug_t);
269
270 /*
271  * Get/set xen power management, include 
272  * 1. cpufreq governors and related parameters
273  */
274 /* XEN_SYSCTL_pm_op */
275 struct xen_userspace {
276     uint32_t scaling_setspeed;
277 };
278 typedef struct xen_userspace xen_userspace_t;
279
280 struct xen_ondemand {
281     uint32_t sampling_rate_max;
282     uint32_t sampling_rate_min;
283
284     uint32_t sampling_rate;
285     uint32_t up_threshold;
286 };
287 typedef struct xen_ondemand xen_ondemand_t;
288
289 /* 
290  * cpufreq para name of this structure named 
291  * same as sysfs file name of native linux
292  */
293 #define CPUFREQ_NAME_LEN 16
294 struct xen_get_cpufreq_para {
295     /* IN/OUT variable */
296     uint32_t cpu_num;
297     uint32_t freq_num;
298     uint32_t gov_num;
299
300     /* for all governors */
301     /* OUT variable */
302     XEN_GUEST_HANDLE_64(uint32) affected_cpus;
303     XEN_GUEST_HANDLE_64(uint32) scaling_available_frequencies;
304     XEN_GUEST_HANDLE_64(char)   scaling_available_governors;
305     char scaling_driver[CPUFREQ_NAME_LEN];
306
307     uint32_t cpuinfo_cur_freq;
308     uint32_t cpuinfo_max_freq;
309     uint32_t cpuinfo_min_freq;
310     uint32_t scaling_cur_freq;
311
312     char scaling_governor[CPUFREQ_NAME_LEN];
313     uint32_t scaling_max_freq;
314     uint32_t scaling_min_freq;
315
316     /* for specific governor */
317     union {
318         struct  xen_userspace userspace;
319         struct  xen_ondemand ondemand;
320     } u;
321
322     int32_t turbo_enabled;
323 };
324
325 struct xen_set_cpufreq_gov {
326     char scaling_governor[CPUFREQ_NAME_LEN];
327 };
328
329 struct xen_set_cpufreq_para {
330     #define SCALING_MAX_FREQ           1
331     #define SCALING_MIN_FREQ           2
332     #define SCALING_SETSPEED           3
333     #define SAMPLING_RATE              4
334     #define UP_THRESHOLD               5
335
336     uint32_t ctrl_type;
337     uint32_t ctrl_value;
338 };
339
340 struct xen_sysctl_pm_op {
341     #define PM_PARA_CATEGORY_MASK      0xf0
342     #define CPUFREQ_PARA               0x10
343
344     /* cpufreq command type */
345     #define GET_CPUFREQ_PARA           (CPUFREQ_PARA | 0x01)
346     #define SET_CPUFREQ_GOV            (CPUFREQ_PARA | 0x02)
347     #define SET_CPUFREQ_PARA           (CPUFREQ_PARA | 0x03)
348     #define GET_CPUFREQ_AVGFREQ        (CPUFREQ_PARA | 0x04)
349
350     /* set/reset scheduler power saving option */
351     #define XEN_SYSCTL_pm_op_set_sched_opt_smt    0x21
352
353     /* cpuidle max_cstate access command */
354     #define XEN_SYSCTL_pm_op_get_max_cstate       0x22
355     #define XEN_SYSCTL_pm_op_set_max_cstate       0x23
356
357     /* set scheduler migration cost value */
358     #define XEN_SYSCTL_pm_op_set_vcpu_migration_delay   0x24
359     #define XEN_SYSCTL_pm_op_get_vcpu_migration_delay   0x25
360
361     /* enable/disable turbo mode when in dbs governor */
362     #define XEN_SYSCTL_pm_op_enable_turbo               0x26
363     #define XEN_SYSCTL_pm_op_disable_turbo              0x27
364
365     uint32_t cmd;
366     uint32_t cpuid;
367     union {
368         struct xen_get_cpufreq_para get_para;
369         struct xen_set_cpufreq_gov  set_gov;
370         struct xen_set_cpufreq_para set_para;
371         uint64_aligned_t get_avgfreq;
372         uint32_t                    set_sched_opt_smt;
373         uint32_t                    get_max_cstate;
374         uint32_t                    set_max_cstate;
375         uint32_t                    get_vcpu_migration_delay;
376         uint32_t                    set_vcpu_migration_delay;
377     } u;
378 };
379
380 /* XEN_SYSCTL_page_offline_op */
381 struct xen_sysctl_page_offline_op {
382     /* IN: range of page to be offlined */
383 #define sysctl_page_offline     1
384 #define sysctl_page_online      2
385 #define sysctl_query_page_offline  3
386     uint32_t cmd;
387     uint32_t start;
388     uint32_t end;
389     /* OUT: result of page offline request */
390     /*
391      * bit 0~15: result flags
392      * bit 16~31: owner
393      */
394     XEN_GUEST_HANDLE(uint32) status;
395 };
396
397 #define PG_OFFLINE_STATUS_MASK    (0xFFUL)
398
399 /* The result is invalid, i.e. HV does not handle it */
400 #define PG_OFFLINE_INVALID   (0x1UL << 0)
401
402 #define PG_OFFLINE_OFFLINED  (0x1UL << 1)
403 #define PG_OFFLINE_PENDING   (0x1UL << 2)
404 #define PG_OFFLINE_FAILED    (0x1UL << 3)
405 #define PG_OFFLINE_AGAIN     (0x1UL << 4)
406
407 #define PG_ONLINE_FAILED     PG_OFFLINE_FAILED
408 #define PG_ONLINE_ONLINED    PG_OFFLINE_OFFLINED
409
410 #define PG_OFFLINE_STATUS_OFFLINED              (0x1UL << 1)
411 #define PG_OFFLINE_STATUS_ONLINE                (0x1UL << 2)
412 #define PG_OFFLINE_STATUS_OFFLINE_PENDING       (0x1UL << 3)
413 #define PG_OFFLINE_STATUS_BROKEN                (0x1UL << 4)
414
415 #define PG_OFFLINE_MISC_MASK    (0xFFUL << 4)
416
417 /* valid when PG_OFFLINE_FAILED or PG_OFFLINE_PENDING */
418 #define PG_OFFLINE_XENPAGE   (0x1UL << 8)
419 #define PG_OFFLINE_DOM0PAGE  (0x1UL << 9)
420 #define PG_OFFLINE_ANONYMOUS (0x1UL << 10)
421 #define PG_OFFLINE_NOT_CONV_RAM   (0x1UL << 11)
422 #define PG_OFFLINE_OWNED     (0x1UL << 12)
423
424 #define PG_OFFLINE_BROKEN    (0x1UL << 13)
425 #define PG_ONLINE_BROKEN     PG_OFFLINE_BROKEN
426
427 #define PG_OFFLINE_OWNER_SHIFT 16
428
429 /* XEN_SYSCTL_lockprof_op */
430 /* Sub-operations: */
431 #define XEN_SYSCTL_LOCKPROF_reset 1   /* Reset all profile data to zero. */
432 #define XEN_SYSCTL_LOCKPROF_query 2   /* Get lock profile information. */
433 /* Record-type: */
434 #define LOCKPROF_TYPE_GLOBAL      0   /* global lock, idx meaningless */
435 #define LOCKPROF_TYPE_PERDOM      1   /* per-domain lock, idx is domid */
436 #define LOCKPROF_TYPE_N           2   /* number of types */
437 struct xen_sysctl_lockprof_data {
438     char     name[40];     /* lock name (may include up to 2 %d specifiers) */
439     int32_t  type;         /* LOCKPROF_TYPE_??? */
440     int32_t  idx;          /* index (e.g. domain id) */
441     uint64_aligned_t lock_cnt;     /* # of locking succeeded */
442     uint64_aligned_t block_cnt;    /* # of wait for lock */
443     uint64_aligned_t lock_time;    /* nsecs lock held */
444     uint64_aligned_t block_time;   /* nsecs waited for lock */
445 };
446 typedef struct xen_sysctl_lockprof_data xen_sysctl_lockprof_data_t;
447 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockprof_data_t);
448 struct xen_sysctl_lockprof_op {
449     /* IN variables. */
450     uint32_t       cmd;               /* XEN_SYSCTL_LOCKPROF_??? */
451     uint32_t       max_elem;          /* size of output buffer */
452     /* OUT variables (query only). */
453     uint32_t       nr_elem;           /* number of elements available */
454     uint64_aligned_t time;            /* nsecs of profile measurement */
455     /* profile information (or NULL) */
456     XEN_GUEST_HANDLE_64(xen_sysctl_lockprof_data_t) data;
457 };
458 typedef struct xen_sysctl_lockprof_op xen_sysctl_lockprof_op_t;
459 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockprof_op_t);
460
461 /* XEN_SYSCTL_topologyinfo */
462 #define INVALID_TOPOLOGY_ID  (~0U)
463 struct xen_sysctl_topologyinfo {
464     /*
465      * IN: maximum addressable entry in the caller-provided arrays.
466      * OUT: largest cpu identifier in the system.
467      * If OUT is greater than IN then the arrays are truncated!
468      * If OUT is leass than IN then the array tails are not written by sysctl.
469      */
470     uint32_t max_cpu_index;
471
472     /*
473      * If not NULL, these arrays are filled with core/socket/node identifier
474      * for each cpu.
475      * If a cpu has no core/socket/node information (e.g., cpu not present) 
476      * then the sentinel value ~0u is written to each array.
477      * The number of array elements written by the sysctl is:
478      *   min(@max_cpu_index_IN,@max_cpu_index_OUT)+1
479      */
480     XEN_GUEST_HANDLE_64(uint32) cpu_to_core;
481     XEN_GUEST_HANDLE_64(uint32) cpu_to_socket;
482     XEN_GUEST_HANDLE_64(uint32) cpu_to_node;
483 };
484 typedef struct xen_sysctl_topologyinfo xen_sysctl_topologyinfo_t;
485 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_topologyinfo_t);
486
487 /* XEN_SYSCTL_numainfo */
488 #define INVALID_NUMAINFO_ID (~0U)
489 struct xen_sysctl_numainfo {
490     /*
491      * IN: maximum addressable entry in the caller-provided arrays.
492      * OUT: largest node identifier in the system.
493      * If OUT is greater than IN then the arrays are truncated!
494      */
495     uint32_t max_node_index;
496
497     /* NB. Entries are 0 if node is not present. */
498     XEN_GUEST_HANDLE_64(uint64) node_to_memsize;
499     XEN_GUEST_HANDLE_64(uint64) node_to_memfree;
500
501     /*
502      * Array, of size (max_node_index+1)^2, listing memory access distances
503      * between nodes. If an entry has no node distance information (e.g., node 
504      * not present) then the value ~0u is written.
505      * 
506      * Note that the array rows must be indexed by multiplying by the minimum 
507      * of the caller-provided max_node_index and the returned value of
508      * max_node_index. That is, if the largest node index in the system is
509      * smaller than the caller can handle, a smaller 2-d array is constructed
510      * within the space provided by the caller. When this occurs, trailing
511      * space provided by the caller is not modified. If the largest node index
512      * in the system is larger than the caller can handle, then a 2-d array of
513      * the maximum size handleable by the caller is constructed.
514      */
515     XEN_GUEST_HANDLE_64(uint32) node_to_node_distance;
516 };
517 typedef struct xen_sysctl_numainfo xen_sysctl_numainfo_t;
518 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_numainfo_t);
519
520 /* XEN_SYSCTL_cpupool_op */
521 #define XEN_SYSCTL_CPUPOOL_OP_CREATE                1  /* C */
522 #define XEN_SYSCTL_CPUPOOL_OP_DESTROY               2  /* D */
523 #define XEN_SYSCTL_CPUPOOL_OP_INFO                  3  /* I */
524 #define XEN_SYSCTL_CPUPOOL_OP_ADDCPU                4  /* A */
525 #define XEN_SYSCTL_CPUPOOL_OP_RMCPU                 5  /* R */
526 #define XEN_SYSCTL_CPUPOOL_OP_MOVEDOMAIN            6  /* M */
527 #define XEN_SYSCTL_CPUPOOL_OP_FREEINFO              7  /* F */
528 #define XEN_SYSCTL_CPUPOOL_PAR_ANY     0xFFFFFFFF
529 struct xen_sysctl_cpupool_op {
530     uint32_t op;          /* IN */
531     uint32_t cpupool_id;  /* IN: CDIARM OUT: CI */
532     uint32_t sched_id;    /* IN: C      OUT: I  */
533     uint32_t domid;       /* IN: M              */
534     uint32_t cpu;         /* IN: AR             */
535     uint32_t n_dom;       /*            OUT: I  */
536     struct xenctl_bitmap cpumap; /*     OUT: IF */
537 };
538 typedef struct xen_sysctl_cpupool_op xen_sysctl_cpupool_op_t;
539 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpupool_op_t);
540
541 #define ARINC653_MAX_DOMAINS_PER_SCHEDULE   64
542 /*
543  * This structure is used to pass a new ARINC653 schedule from a
544  * privileged domain (ie dom0) to Xen.
545  */
546 struct xen_sysctl_arinc653_schedule {
547     /* major_frame holds the time for the new schedule's major frame
548      * in nanoseconds. */
549     uint64_aligned_t     major_frame;
550     /* num_sched_entries holds how many of the entries in the
551      * sched_entries[] array are valid. */
552     uint8_t     num_sched_entries;
553     /* The sched_entries array holds the actual schedule entries. */
554     struct {
555         /* dom_handle must match a domain's UUID */
556         xen_domain_handle_t dom_handle;
557         /* If a domain has multiple VCPUs, vcpu_id specifies which one
558          * this schedule entry applies to. It should be set to 0 if
559          * there is only one VCPU for the domain. */
560         unsigned int vcpu_id;
561         /* runtime specifies the amount of time that should be allocated
562          * to this VCPU per major frame. It is specified in nanoseconds */
563         uint64_aligned_t runtime;
564     } sched_entries[ARINC653_MAX_DOMAINS_PER_SCHEDULE];
565 };
566 typedef struct xen_sysctl_arinc653_schedule xen_sysctl_arinc653_schedule_t;
567 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_arinc653_schedule_t);
568
569 struct xen_sysctl_credit_schedule {
570     /* Length of timeslice in milliseconds */
571 #define XEN_SYSCTL_CSCHED_TSLICE_MAX 1000
572 #define XEN_SYSCTL_CSCHED_TSLICE_MIN 1
573     unsigned tslice_ms;
574     /* Rate limit (minimum timeslice) in microseconds */
575 #define XEN_SYSCTL_SCHED_RATELIMIT_MAX 500000
576 #define XEN_SYSCTL_SCHED_RATELIMIT_MIN 100
577     unsigned ratelimit_us;
578 };
579 typedef struct xen_sysctl_credit_schedule xen_sysctl_credit_schedule_t;
580 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_credit_schedule_t);
581
582 /* XEN_SYSCTL_scheduler_op */
583 /* Set or get info? */
584 #define XEN_SYSCTL_SCHEDOP_putinfo 0
585 #define XEN_SYSCTL_SCHEDOP_getinfo 1
586 struct xen_sysctl_scheduler_op {
587     uint32_t cpupool_id; /* Cpupool whose scheduler is to be targetted. */
588     uint32_t sched_id;   /* XEN_SCHEDULER_* (domctl.h) */
589     uint32_t cmd;        /* XEN_SYSCTL_SCHEDOP_* */
590     union {
591         struct xen_sysctl_sched_arinc653 {
592             XEN_GUEST_HANDLE_64(xen_sysctl_arinc653_schedule_t) schedule;
593         } sched_arinc653;
594         struct xen_sysctl_credit_schedule sched_credit;
595     } u;
596 };
597 typedef struct xen_sysctl_scheduler_op xen_sysctl_scheduler_op_t;
598 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_scheduler_op_t);
599
600 /* XEN_SYSCTL_coverage_op */
601 /*
602  * Get total size of information, to help allocate
603  * the buffer. The pointer points to a 32 bit value.
604  */
605 #define XEN_SYSCTL_COVERAGE_get_total_size 0
606
607 /*
608  * Read coverage information in a single run
609  * You must use a tool to split them.
610  */
611 #define XEN_SYSCTL_COVERAGE_read           1
612
613 /*
614  * Reset all the coverage counters to 0
615  * No parameters.
616  */
617 #define XEN_SYSCTL_COVERAGE_reset          2
618
619 /*
620  * Like XEN_SYSCTL_COVERAGE_read but reset also
621  * counters to 0 in a single call.
622  */
623 #define XEN_SYSCTL_COVERAGE_read_and_reset 3
624
625 struct xen_sysctl_coverage_op {
626     uint32_t cmd;        /* XEN_SYSCTL_COVERAGE_* */
627     union {
628         uint32_t total_size; /* OUT */
629         XEN_GUEST_HANDLE_64(uint8)  raw_info;   /* OUT */
630     } u;
631 };
632 typedef struct xen_sysctl_coverage_op xen_sysctl_coverage_op_t;
633 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_coverage_op_t);
634
635
636 struct xen_sysctl {
637     uint32_t cmd;
638 #define XEN_SYSCTL_readconsole                    1
639 #define XEN_SYSCTL_tbuf_op                        2
640 #define XEN_SYSCTL_physinfo                       3
641 #define XEN_SYSCTL_sched_id                       4
642 #define XEN_SYSCTL_perfc_op                       5
643 #define XEN_SYSCTL_getdomaininfolist              6
644 #define XEN_SYSCTL_debug_keys                     7
645 #define XEN_SYSCTL_getcpuinfo                     8
646 #define XEN_SYSCTL_availheap                      9
647 #define XEN_SYSCTL_get_pmstat                    10
648 #define XEN_SYSCTL_cpu_hotplug                   11
649 #define XEN_SYSCTL_pm_op                         12
650 #define XEN_SYSCTL_page_offline_op               14
651 #define XEN_SYSCTL_lockprof_op                   15
652 #define XEN_SYSCTL_topologyinfo                  16 
653 #define XEN_SYSCTL_numainfo                      17
654 #define XEN_SYSCTL_cpupool_op                    18
655 #define XEN_SYSCTL_scheduler_op                  19
656 #define XEN_SYSCTL_coverage_op                   20
657     uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
658     union {
659         struct xen_sysctl_readconsole       readconsole;
660         struct xen_sysctl_tbuf_op           tbuf_op;
661         struct xen_sysctl_physinfo          physinfo;
662         struct xen_sysctl_topologyinfo      topologyinfo;
663         struct xen_sysctl_numainfo          numainfo;
664         struct xen_sysctl_sched_id          sched_id;
665         struct xen_sysctl_perfc_op          perfc_op;
666         struct xen_sysctl_getdomaininfolist getdomaininfolist;
667         struct xen_sysctl_debug_keys        debug_keys;
668         struct xen_sysctl_getcpuinfo        getcpuinfo;
669         struct xen_sysctl_availheap         availheap;
670         struct xen_sysctl_get_pmstat        get_pmstat;
671         struct xen_sysctl_cpu_hotplug       cpu_hotplug;
672         struct xen_sysctl_pm_op             pm_op;
673         struct xen_sysctl_page_offline_op   page_offline;
674         struct xen_sysctl_lockprof_op       lockprof_op;
675         struct xen_sysctl_cpupool_op        cpupool_op;
676         struct xen_sysctl_scheduler_op      scheduler_op;
677         struct xen_sysctl_coverage_op       coverage_op;
678         uint8_t                             pad[128];
679     } u;
680 };
681 typedef struct xen_sysctl xen_sysctl_t;
682 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_t);
683
684 #endif /* __XEN_PUBLIC_SYSCTL_H__ */
685
686 /*
687  * Local variables:
688  * mode: C
689  * c-file-style: "BSD"
690  * c-basic-offset: 4
691  * tab-width: 4
692  * indent-tabs-mode: nil
693  * End:
694  */