debuggers.hg

view tools/libxc/xc_misc.c @ 10991:7924b6bd728a

Change DOM0_PERFCCONTROL: remove array limit.

Descriptors and values are passed by two distinct buffers.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author kaf24@firebug.cl.cam.ac.uk
date Mon Aug 07 15:53:06 2006 +0100 (2006-08-07)
parents 24dbb153ab39
children 61eea55dce65
line source
1 /******************************************************************************
2 * xc_misc.c
3 *
4 * Miscellaneous control interface functions.
5 */
7 #include "xc_private.h"
9 int xc_readconsolering(int xc_handle,
10 char **pbuffer,
11 unsigned int *pnr_chars,
12 int clear)
13 {
14 int ret;
15 DECLARE_DOM0_OP;
16 char *buffer = *pbuffer;
17 unsigned int nr_chars = *pnr_chars;
19 op.cmd = DOM0_READCONSOLE;
20 set_xen_guest_handle(op.u.readconsole.buffer, buffer);
21 op.u.readconsole.count = nr_chars;
22 op.u.readconsole.clear = clear;
24 if ( (ret = mlock(buffer, nr_chars)) != 0 )
25 return ret;
27 if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
28 *pnr_chars = op.u.readconsole.count;
30 safe_munlock(buffer, nr_chars);
32 return ret;
33 }
35 int xc_physinfo(int xc_handle,
36 xc_physinfo_t *put_info)
37 {
38 int ret;
39 DECLARE_DOM0_OP;
41 op.cmd = DOM0_PHYSINFO;
42 op.interface_version = DOM0_INTERFACE_VERSION;
44 if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
45 return ret;
47 memcpy(put_info, &op.u.physinfo, sizeof(*put_info));
49 return 0;
50 }
52 int xc_sched_id(int xc_handle,
53 int *sched_id)
54 {
55 int ret;
56 DECLARE_DOM0_OP;
58 op.cmd = DOM0_SCHED_ID;
59 op.interface_version = DOM0_INTERFACE_VERSION;
61 if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
62 return ret;
64 *sched_id = op.u.sched_id.sched_id;
66 return 0;
67 }
69 int xc_perfc_control(int xc_handle,
70 uint32_t opcode,
71 xc_perfc_desc_t *desc,
72 xc_perfc_val_t *val,
73 int *nbr_desc,
74 int *nbr_val)
75 {
76 int rc;
77 DECLARE_DOM0_OP;
79 op.cmd = DOM0_PERFCCONTROL;
80 op.u.perfccontrol.op = opcode;
81 set_xen_guest_handle(op.u.perfccontrol.desc, desc);
82 set_xen_guest_handle(op.u.perfccontrol.val, val);
84 rc = do_dom0_op(xc_handle, &op);
86 if (nbr_desc)
87 *nbr_desc = op.u.perfccontrol.nr_counters;
88 if (nbr_val)
89 *nbr_val = op.u.perfccontrol.nr_vals;
91 return rc;
92 }
94 long long xc_msr_read(int xc_handle, int cpu_mask, int msr)
95 {
96 int rc;
97 DECLARE_DOM0_OP;
99 op.cmd = DOM0_MSR;
100 op.u.msr.write = 0;
101 op.u.msr.msr = msr;
102 op.u.msr.cpu_mask = cpu_mask;
104 rc = do_dom0_op(xc_handle, &op);
106 return (((unsigned long long)op.u.msr.out2)<<32) | op.u.msr.out1 ;
107 }
109 int xc_msr_write(int xc_handle, int cpu_mask, int msr, unsigned int low,
110 unsigned int high)
111 {
112 int rc;
113 DECLARE_DOM0_OP;
115 op.cmd = DOM0_MSR;
116 op.u.msr.write = 1;
117 op.u.msr.msr = msr;
118 op.u.msr.cpu_mask = cpu_mask;
119 op.u.msr.in1 = low;
120 op.u.msr.in2 = high;
122 rc = do_dom0_op(xc_handle, &op);
124 return rc;
125 }
128 /*
129 * Local variables:
130 * mode: C
131 * c-set-style: "BSD"
132 * c-basic-offset: 4
133 * tab-width: 4
134 * indent-tabs-mode: nil
135 * End:
136 */