diff options
author | kaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk> | 2003-07-12 22:26:07 +0000 |
---|---|---|
committer | kaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk> | 2003-07-12 22:26:07 +0000 |
commit | 6bf073980b8479bae7c94ecd925c4cecef6e5414 (patch) | |
tree | 766f6ff4c90654e80f4f0053822b421c6524f46b /tools/internal/dom0_defs.h | |
parent | 7a68631223523fd53038da61cdf337d3f14c8593 (diff) | |
download | xen-6bf073980b8479bae7c94ecd925c4cecef6e5414.tar.gz xen-6bf073980b8479bae7c94ecd925c4cecef6e5414.tar.bz2 xen-6bf073980b8479bae7c94ecd925c4cecef6e5414.zip |
bitkeeper revision 1.339.1.1 (3f108aff8cNSEyxZFIWHZ-zZtSTT2w)
Many files:
new file
Clean up dom0 proc interfaces. Implemented ioremap and /dev/mem.
.del-dom0_block.c~63815c1974691c1c:
Delete: xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_block.c
.del-sched_ops.c~20807e5c2ed6b51:
Delete: xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/sched_ops.c
.del-xi_list~49abab167156959:
Delete: tools/internal/xi_list
.del-xl_physdisk_proc.c~49451bc26a40fcb2:
Delete: xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_physdisk_proc.c
.del-mmu.h~6bc56547519b6f96:
Delete: xenolinux-2.4.21-sparse/include/asm-xeno/mmu.h
.del-dom0.h~6fb656bb4a0c52e1:
Delete: xenolinux-2.4.21-sparse/include/asm-xeno/dom0.h
.del-dom0_ops.h~fb19960d77217740:
Delete: tools/internal/dom0_ops.h
.del-dom0_ops.h~5c52b016e619bd2d:
Delete: xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_ops.h
.del-dom0_memory.c~c72c6e5f7fd65d38:
Delete: xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_memory.c
.del-direct_map.c~d2fedc686b334f2a:
Delete: xenolinux-2.4.21-sparse/arch/xeno/mm/direct_map.c
direct_map.c:
Rename: xenolinux-2.4.21-sparse/arch/xeno/mm/get_unmapped_area.c -> xenolinux-2.4.21-sparse/arch/xeno/mm/direct_map.c
Diffstat (limited to 'tools/internal/dom0_defs.h')
-rw-r--r-- | tools/internal/dom0_defs.h | 126 |
1 files changed, 119 insertions, 7 deletions
diff --git a/tools/internal/dom0_defs.h b/tools/internal/dom0_defs.h index e79d85d417..9ef8d0645d 100644 --- a/tools/internal/dom0_defs.h +++ b/tools/internal/dom0_defs.h @@ -1,9 +1,121 @@ -#define PROC_XENO_ROOT "xeno" -#define PROC_CMD "dom0_cmd" -#define PROC_DOM_PREFIX "dom" -#define PROC_DOM_MEM "mem" -#define PROC_DOM_DATA "new_dom_data" -#define PROC_DOMAINS "domains" -#define MAX_PATH 256 +#ifndef __DOM0_DEFS_H__ +#define __DOM0_DEFS_H__ +#include <unistd.h> +#include <stdio.h> +#include <errno.h> +#include <fcntl.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <stdlib.h> +#include <sys/ioctl.h> +#include <errno.h> +#include <string.h> + +#include <asm/types.h> + +#include "mem_defs.h" +#include <asm-xeno/proc_cmd.h> +#include <hypervisor-ifs/hypervisor-if.h> +#include <hypervisor-ifs/dom0_ops.h> + +#define ERROR(_m) \ + fprintf(stderr, "ERROR: %s\n", (_m)) + +#define PERROR(_m) \ + fprintf(stderr, "ERROR: %s (%d = %s)\n", (_m), errno, strerror(errno)) + +static inline int do_privcmd(unsigned int cmd, unsigned long data) +{ + int fd; + + if ( (fd = open("/proc/xeno/privcmd", O_RDWR)) < 0 ) + { + PERROR("Could not open proc interface"); + return -1; + } + + if ( ioctl(fd, cmd, data) < 0 ) + { +#ifndef SILENT_ERRORS_FROM_XEN + PERROR("Error when executing privileged control ioctl"); +#endif + close(fd); + return -1; + } + + close(fd); + return 0; +} + +static inline int xldev_to_physdev(int xldev) +{ + return do_privcmd(IOCTL_PRIVCMD_LINDEV_TO_XENDEV, + (unsigned long)xldev); +} + +static inline int physdev_to_xldev(int physdev) +{ + return do_privcmd(IOCTL_PRIVCMD_XENDEV_TO_LINDEV, + (unsigned long)physdev); +} + +static inline int do_xen_blkmsg(privcmd_blkmsg_t *blkmsg) +{ + return do_privcmd(IOCTL_PRIVCMD_BLKMSG, (unsigned long)blkmsg); +} + +static inline int do_xen_hypercall(privcmd_hypercall_t *hypercall) +{ + return do_privcmd(IOCTL_PRIVCMD_HYPERCALL, (unsigned long)hypercall); +} + +static inline int do_dom0_op(dom0_op_t *op) +{ + int ret = -1; + privcmd_hypercall_t hypercall; + + hypercall.op = __HYPERVISOR_dom0_op; + hypercall.arg[0] = (unsigned long)op; + + if ( mlock(op, sizeof(*op)) != 0 ) + { + PERROR("Could not lock memory for Xen hypercall"); + goto out1; + } + + if ( do_xen_hypercall(&hypercall) < 0 ) + goto out2; + + ret = 0; + + out2: (void)munlock(op, sizeof(*op)); + out1: return ret; +} + +static inline int do_network_op(network_op_t *op) +{ + int ret = -1; + privcmd_hypercall_t hypercall; + + hypercall.op = __HYPERVISOR_network_op; + hypercall.arg[0] = (unsigned long)op; + + if ( mlock(op, sizeof(*op)) != 0 ) + { + PERROR("Could not lock memory for Xen hypercall"); + goto out1; + } + + if ( do_xen_hypercall(&hypercall) < 0 ) + goto out2; + + ret = 0; + + out2: (void)munlock(op, sizeof(*op)); + out1: return ret; +} + +#endif /* __DOM0_DEFS_H__ */ |