ia64/xen-unstable

view tools/libxc/xc_misc.c @ 8964:8946b6dcd49e

Fix x86_64 Xen build.

event_callback_cs and failsafe_callback_cs are x86_32 only.

Signed-off-by: Ian Campbell <Ian.Campbell@XenSource.com>
author Ian.Campbell@xensource.com
date Wed Feb 22 17:26:39 2006 +0000 (2006-02-22)
parents 1db05e589fa0
children 74ee53209cca
line source
1 /******************************************************************************
2 * xc_misc.c
3 *
4 * Miscellaneous control interface functions.
5 */
7 #include "xc_private.h"
9 int xc_interface_open(void)
10 {
11 int fd = open("/proc/xen/privcmd", O_RDWR);
12 if ( fd == -1 )
13 PERROR("Could not obtain handle on privileged command interface");
14 return fd;
15 }
17 int xc_interface_close(int xc_handle)
18 {
19 return close(xc_handle);
20 }
22 int xc_readconsolering(int xc_handle,
23 char **pbuffer,
24 unsigned int *pnr_chars,
25 int clear)
26 {
27 int ret;
28 DECLARE_DOM0_OP;
29 char *buffer = *pbuffer;
30 unsigned int nr_chars = *pnr_chars;
32 op.cmd = DOM0_READCONSOLE;
33 op.u.readconsole.buffer = buffer;
34 op.u.readconsole.count = nr_chars;
35 op.u.readconsole.clear = clear;
37 if ( (ret = mlock(buffer, nr_chars)) != 0 )
38 return ret;
40 if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
41 {
42 *pbuffer = op.u.readconsole.buffer;
43 *pnr_chars = op.u.readconsole.count;
44 }
46 safe_munlock(buffer, nr_chars);
48 return ret;
49 }
51 int xc_physinfo(int xc_handle,
52 xc_physinfo_t *put_info)
53 {
54 int ret;
55 DECLARE_DOM0_OP;
57 op.cmd = DOM0_PHYSINFO;
58 op.interface_version = DOM0_INTERFACE_VERSION;
60 if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
61 return ret;
63 memcpy(put_info, &op.u.physinfo, sizeof(*put_info));
65 return 0;
66 }
68 int xc_sched_id(int xc_handle,
69 int *sched_id)
70 {
71 int ret;
72 DECLARE_DOM0_OP;
74 op.cmd = DOM0_SCHED_ID;
75 op.interface_version = DOM0_INTERFACE_VERSION;
77 if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
78 return ret;
80 *sched_id = op.u.sched_id.sched_id;
82 return 0;
83 }
85 int xc_perfc_control(int xc_handle,
86 uint32_t opcode,
87 xc_perfc_desc_t *desc)
88 {
89 int rc;
90 DECLARE_DOM0_OP;
92 op.cmd = DOM0_PERFCCONTROL;
93 op.u.perfccontrol.op = opcode;
94 op.u.perfccontrol.desc = desc;
96 rc = do_dom0_op(xc_handle, &op);
98 return (rc == 0) ? op.u.perfccontrol.nr_counters : rc;
99 }
101 long long xc_msr_read(int xc_handle, int cpu_mask, int msr)
102 {
103 int rc;
104 DECLARE_DOM0_OP;
106 op.cmd = DOM0_MSR;
107 op.u.msr.write = 0;
108 op.u.msr.msr = msr;
109 op.u.msr.cpu_mask = cpu_mask;
111 rc = do_dom0_op(xc_handle, &op);
113 return (((unsigned long long)op.u.msr.out2)<<32) | op.u.msr.out1 ;
114 }
116 int xc_msr_write(int xc_handle, int cpu_mask, int msr, unsigned int low,
117 unsigned int high)
118 {
119 int rc;
120 DECLARE_DOM0_OP;
122 op.cmd = DOM0_MSR;
123 op.u.msr.write = 1;
124 op.u.msr.msr = msr;
125 op.u.msr.cpu_mask = cpu_mask;
126 op.u.msr.in1 = low;
127 op.u.msr.in2 = high;
129 rc = do_dom0_op(xc_handle, &op);
131 return rc;
132 }
135 /*
136 * Local variables:
137 * mode: C
138 * c-set-style: "BSD"
139 * c-basic-offset: 4
140 * tab-width: 4
141 * indent-tabs-mode: nil
142 * End:
143 */