ia64/xen-unstable

view tools/debugger/pdb/pdb_xen.c @ 6435:b4b3f6be5226

merge?
author cl349@firebug.cl.cam.ac.uk
date Thu Aug 25 17:27:49 2005 +0000 (2005-08-25)
parents 0610add7c3fe 6e899a3840b2
children 8799d14bef77 9312a3e8a6f8
line source
1 /*
2 * pdb_xen.c
3 *
4 * alex ho
5 * http://www.cl.cam.ac.uk/netos/pdb
6 *
7 * PDB interface library for accessing Xen
8 */
10 #include <xenctrl.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <errno.h>
14 #include <string.h>
15 #include <sys/mman.h>
17 int
18 pdb_open ()
19 {
20 int xc_handle = xc_interface_open();
22 if ( xc_handle < 0 )
23 {
24 fprintf(stderr, "(pdb) error opening xc interface: %d (%s)\n",
25 errno, strerror(errno));
26 }
27 return xc_handle;
28 }
30 int
31 pdb_close (int xc_handle)
32 {
33 int rc;
36 if ( (rc = xc_interface_close(xc_handle)) < 0 )
37 {
38 fprintf(stderr, "(pdb) error closing xc interface: %d (%s)\n",
39 errno, strerror(errno));
40 }
41 return rc;
42 }
45 #include <sys/ioctl.h>
47 /* /dev/xen/evtchn ioctls */
48 #define EVTCHN_RESET _IO('E', 1) /* clear & reinit buffer */
49 #define EVTCHN_BIND _IO('E', 2) /* bind to event channel */
50 #define EVTCHN_UNBIND _IO('E', 3) /* unbind from event channel */
52 int
53 xen_evtchn_bind (int evtchn_fd, int idx)
54 {
55 if ( ioctl(evtchn_fd, EVTCHN_BIND, idx) != 0 )
56 return -errno;
58 return 0;
59 }
61 int
62 xen_evtchn_unbind (int evtchn_fd, int idx)
63 {
64 if ( ioctl(evtchn_fd, EVTCHN_UNBIND, idx) != 0 )
65 return -errno;
67 return 0;
68 }
71 /*
72 * Local variables:
73 * mode: C
74 * c-set-style: "BSD"
75 * c-basic-offset: 4
76 * tab-width: 4
77 * indent-tabs-mode: nil
78 * End:
79 */