direct-io.hg

view tools/libxc/xc_tbuf.c @ 12988:e080700efa56

[TOOLS] Fix the build. Clearly demarcate PPC-specific stuff.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Dec 13 10:23:53 2006 +0000 (2006-12-13)
parents 58f28e00001e
children 1a45828882e9
line source
1 /******************************************************************************
2 * xc_tbuf.c
3 *
4 * API for manipulating and accessing trace buffer parameters
5 *
6 * Copyright (c) 2005, Rob Gardner
7 *
8 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
9 * Use is subject to license terms.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation, version 2 of the
14 * License.
15 */
17 #include "xc_private.h"
19 static int tbuf_enable(int xc_handle, int enable)
20 {
21 DECLARE_SYSCTL;
23 sysctl.cmd = XEN_SYSCTL_tbuf_op;
24 sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
25 if (enable)
26 sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_enable;
27 else
28 sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_disable;
30 return xc_sysctl(xc_handle, &sysctl);
31 }
33 int xc_tbuf_set_size(int xc_handle, unsigned long size)
34 {
35 DECLARE_SYSCTL;
37 sysctl.cmd = XEN_SYSCTL_tbuf_op;
38 sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
39 sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_set_size;
40 sysctl.u.tbuf_op.size = size;
42 return xc_sysctl(xc_handle, &sysctl);
43 }
45 int xc_tbuf_get_size(int xc_handle, unsigned long *size)
46 {
47 int rc;
48 DECLARE_SYSCTL;
50 sysctl.cmd = XEN_SYSCTL_tbuf_op;
51 sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
52 sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_get_info;
54 rc = xc_sysctl(xc_handle, &sysctl);
55 if (rc == 0)
56 *size = sysctl.u.tbuf_op.size;
57 return rc;
58 }
60 int xc_tbuf_enable(int xc_handle, unsigned long pages, unsigned long *mfn,
61 unsigned long *size)
62 {
63 DECLARE_SYSCTL;
64 int rc;
66 /*
67 * Ignore errors (at least for now) as we get an error if size is already
68 * set (since trace buffers cannot be reallocated). If we really have no
69 * buffers at all then tbuf_enable() will fail, so this is safe.
70 */
71 (void)xc_tbuf_set_size(xc_handle, pages);
73 if ( tbuf_enable(xc_handle, 1) != 0 )
74 return -1;
76 sysctl.cmd = XEN_SYSCTL_tbuf_op;
77 sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
78 sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_get_info;
80 rc = xc_sysctl(xc_handle, &sysctl);
81 if ( rc == 0 )
82 {
83 *size = sysctl.u.tbuf_op.size;
84 *mfn = sysctl.u.tbuf_op.buffer_mfn;
85 }
87 return 0;
88 }
90 int xc_tbuf_disable(int xc_handle)
91 {
92 return tbuf_enable(xc_handle, 0);
93 }
95 int xc_tbuf_set_cpu_mask(int xc_handle, uint32_t mask)
96 {
97 DECLARE_SYSCTL;
98 int ret = -1;
100 sysctl.cmd = XEN_SYSCTL_tbuf_op;
101 sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
102 sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_set_cpu_mask;
104 set_xen_guest_handle(sysctl.u.tbuf_op.cpu_mask.bitmap, (uint8_t *)&mask);
105 sysctl.u.tbuf_op.cpu_mask.nr_cpus = sizeof(mask) * 8;
107 if ( lock_pages(&mask, sizeof(mask)) != 0 )
108 {
109 PERROR("Could not lock memory for Xen hypercall");
110 goto out;
111 }
113 ret = do_sysctl(xc_handle, &sysctl);
115 unlock_pages(&mask, sizeof(mask));
117 out:
118 return ret;
119 }
121 int xc_tbuf_set_evt_mask(int xc_handle, uint32_t mask)
122 {
123 DECLARE_SYSCTL;
125 sysctl.cmd = XEN_SYSCTL_tbuf_op;
126 sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
127 sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_set_evt_mask;
128 sysctl.u.tbuf_op.evt_mask = mask;
130 return do_sysctl(xc_handle, &sysctl);
131 }