direct-io.hg

view tools/libxc/xc_misc.c @ 8686:c0a0f4db5ab1

Create a block of reserved PFNs in shadow translate mode guests, and
move the shared info and grant table pfns into that block. This
allows us to remove the get_gnttablist dom0 op, and simplifies the
domain creation code slightly. Having the reserved block managed by
Xen may also make it slightly easier to handle the case where the
grant table needs to be extended at run time.

Suggested-by: kaf24
Signed-off-by: Steven Smith, sos22@cam.ac.uk
author sos22@douglas.cl.cam.ac.uk
date Thu Jan 26 19:40:13 2006 +0100 (2006-01-26)
parents 602aefe7bd48
children 1db05e589fa0
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 }
134 int xc_get_pfn_hole_start(int xc_handle, domid_t dom)
135 {
136 struct mmuext_op op = {0};
137 op.cmd = MMUEXT_PFN_HOLE_BASE;
138 return xc_mmuext_op(xc_handle, &op, 1, dom);
139 }
142 /*
143 * Local variables:
144 * mode: C
145 * c-set-style: "BSD"
146 * c-basic-offset: 4
147 * tab-width: 4
148 * indent-tabs-mode: nil
149 * End:
150 */