ia64/xen-unstable

view tools/libxc/xc_misc.c @ 1921:24ecc060e9d7

bitkeeper revision 1.1108.21.1 (41062740xHG36OEbpVAmVX5N9WCaNw)

make vmlinuz really stripped
author cl349@freefall.cl.cam.ac.uk
date Tue Jul 27 09:58:24 2004 +0000 (2004-07-27)
parents 236a9f2698a3
children a5c335665fd6 3f929065a1d1 0a4b76b6b5a0
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 }
23 #define CONSOLE_RING_CLEAR 1
25 int xc_readconsolering(int xc_handle,
26 char *str,
27 unsigned int max_chars,
28 int clear)
29 {
30 int ret;
31 dom0_op_t op;
33 op.cmd = DOM0_READCONSOLE;
34 op.u.readconsole.str = (unsigned long)str;
35 op.u.readconsole.count = max_chars;
36 op.u.readconsole.cmd = clear ? CONSOLE_RING_CLEAR : 0;
38 if ( (ret = mlock(str, max_chars)) != 0 )
39 return ret;
41 if ( (ret = do_dom0_op(xc_handle, &op)) >= 0 )
42 str[ret] = '\0';
44 (void)munlock(str, max_chars);
46 return ret;
47 }
50 int xc_physinfo(int xc_handle,
51 xc_physinfo_t *put_info)
52 {
53 int ret;
54 dom0_op_t op;
55 dom0_physinfo_t *got_info = &op.u.physinfo;
57 op.cmd = DOM0_PHYSINFO;
58 op.interface_version = DOM0_INTERFACE_VERSION;
60 if((ret = do_dom0_op(xc_handle, &op))) return ret;
62 put_info->ht_per_core = got_info->ht_per_core;
63 put_info->cores = got_info->cores;
64 put_info->total_pages = got_info->total_pages;
65 put_info->free_pages = got_info->free_pages;
66 put_info->cpu_khz = got_info->cpu_khz;
68 return 0;
69 }
72 int xc_sched_id(int xc_handle,
73 int *sched_id)
74 {
75 int ret;
76 dom0_op_t op;
78 op.cmd = DOM0_SCHED_ID;
79 op.interface_version = DOM0_INTERFACE_VERSION;
81 if((ret = do_dom0_op(xc_handle, &op))) return ret;
83 *sched_id = op.u.sched_id.sched_id;
85 return 0;
86 }