ia64/xen-unstable

view tools/libxc/ia64/xc_ia64_stubs.c @ 13608:30af6cfdb05c

Make domctl/sysctl interfaces 32-/64-bit invariant.
This kills off a fair amount of unpleasant CONFIG_COMPAT shimming and
avoids needing to keep the compat paths in sync as these interfaces
continue to develop.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Jan 24 16:33:19 2007 +0000 (2007-01-24)
parents d741e86a8766
children d1ce60b8070f
line source
1 #include "xg_private.h"
2 #include "xenguest.h"
3 #include "xc_private.h"
4 #include "xc_elf.h"
5 #include <stdlib.h>
6 #include <zlib.h>
7 #include "xen/arch-ia64.h"
8 #include <xen/hvm/ioreq.h>
10 /* this is a very ugly way of getting FPSR_DEFAULT. struct ia64_fpreg is
11 * mysteriously declared in two places: /usr/include/asm/fpu.h and
12 * /usr/include/bits/sigcontext.h. The former also defines FPSR_DEFAULT,
13 * the latter doesn't but is included (indirectly) by xg_private.h */
14 #define __ASSEMBLY__
15 #include <asm/fpu.h>
16 #undef __IA64_UL
17 #define __IA64_UL(x) ((unsigned long)(x))
18 #undef __ASSEMBLY__
20 unsigned long
21 xc_ia64_fpsr_default(void)
22 {
23 return FPSR_DEFAULT;
24 }
26 /*
27 VMM uses put_user to copy pfn_list to guest buffer, this maybe fail,
28 VMM doesn't handle this now.
29 This method will touch guest buffer to make sure the buffer's mapping
30 is tracked by VMM,
31 */
32 int
33 xc_ia64_get_pfn_list(int xc_handle, uint32_t domid, xen_pfn_t *pfn_buf,
34 unsigned int start_page, unsigned int nr_pages)
35 {
36 struct xen_domctl domctl;
37 int num_pfns,ret;
38 unsigned int __start_page, __nr_pages;
39 xen_pfn_t *__pfn_buf;
41 __start_page = start_page;
42 __nr_pages = nr_pages;
43 __pfn_buf = pfn_buf;
45 while (__nr_pages) {
46 domctl.cmd = XEN_DOMCTL_getmemlist;
47 domctl.domain = (domid_t)domid;
48 domctl.u.getmemlist.max_pfns = __nr_pages;
49 domctl.u.getmemlist.start_pfn =__start_page;
50 domctl.u.getmemlist.num_pfns = 0;
51 set_xen_guest_handle(domctl.u.getmemlist.buffer, __pfn_buf);
53 if (mlock(__pfn_buf, __nr_pages * sizeof(xen_pfn_t)) != 0) {
54 PERROR("Could not lock pfn list buffer");
55 return -1;
56 }
58 ret = do_domctl(xc_handle, &domctl);
60 (void)munlock(__pfn_buf, __nr_pages * sizeof(xen_pfn_t));
62 num_pfns = domctl.u.getmemlist.num_pfns;
63 __start_page += num_pfns;
64 __nr_pages -= num_pfns;
65 __pfn_buf += num_pfns;
67 if (ret < 0)
68 // dummy write to make sure this tlb mapping is tracked by VMM
69 *__pfn_buf = 0;
70 else
71 return nr_pages;
72 }
73 return nr_pages;
74 }
76 int
77 xc_get_pfn_list(int xc_handle, uint32_t domid, uint64_t *pfn_buf,
78 unsigned long max_pfns)
79 {
80 return xc_ia64_get_pfn_list(xc_handle, domid, (xen_pfn_t *)pfn_buf,
81 0, max_pfns);
82 }
84 long
85 xc_get_max_pages(int xc_handle, uint32_t domid)
86 {
87 struct xen_domctl domctl;
88 domctl.cmd = XEN_DOMCTL_getdomaininfo;
89 domctl.domain = (domid_t)domid;
90 return ((do_domctl(xc_handle, &domctl) < 0)
91 ? -1 : domctl.u.getdomaininfo.max_pages);
92 }
94 /*
95 * Local variables:
96 * mode: C
97 * c-set-style: "BSD"
98 * c-basic-offset: 4
99 * tab-width: 4
100 * indent-tabs-mode: nil
101 * End:
102 */