direct-io.hg

view xen/arch/powerpc/dom0_ops.c @ 11366:883e3dc47926

[XEN][POWERPC] Xen shadow ops, mostly skeleton code
Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Sun Aug 20 13:28:45 2006 -0400 (2006-08-20)
parents 86d26e6ec89b
children 18ce855ff594
line source
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 *
16 * Copyright (C) IBM Corp. 2005
17 *
18 * Authors: Jimi Xenidis <jimix@watson.ibm.com>
19 */
21 #include <xen/config.h>
22 #include <xen/types.h>
23 #include <xen/lib.h>
24 #include <xen/sched.h>
25 #include <xen/guest_access.h>
26 #include <xen/shadow.h>
27 #include <public/xen.h>
28 #include <public/domctl.h>
29 #include <public/sysctl.h>
31 void arch_getdomaininfo_ctxt(struct vcpu *v, vcpu_guest_context_t *c)
32 {
33 memcpy(&c->user_regs, &v->arch.ctxt, sizeof(struct cpu_user_regs));
34 /* XXX fill in rest of vcpu_guest_context_t */
35 }
37 long arch_do_domctl(struct xen_domctl *domctl,
38 XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
39 {
40 long ret = 0;
42 switch (domctl->cmd) {
43 case XEN_DOMCTL_getmemlist:
44 {
45 int i;
46 struct domain *d = find_domain_by_id(domctl->domain);
47 unsigned long max_pfns = domctl->u.getmemlist.max_pfns;
48 xen_pfn_t mfn;
49 struct list_head *list_ent;
51 ret = -EINVAL;
52 if ( d != NULL )
53 {
54 ret = 0;
56 spin_lock(&d->page_alloc_lock);
57 list_ent = d->page_list.next;
58 for ( i = 0; (i < max_pfns) && (list_ent != &d->page_list); i++ )
59 {
60 mfn = page_to_mfn(list_entry(
61 list_ent, struct page_info, list));
62 if ( copy_to_guest_offset(domctl->u.getmemlist.buffer,
63 i, &mfn, 1) )
64 {
65 ret = -EFAULT;
66 break;
67 }
68 list_ent = mfn_to_page(mfn)->list.next;
69 }
70 spin_unlock(&d->page_alloc_lock);
72 domctl->u.getmemlist.num_pfns = i;
73 copy_to_guest(u_domctl, domctl, 1);
75 put_domain(d);
76 }
77 }
78 break;
80 default:
81 ret = -ENOSYS;
82 break;
83 }
85 return ret;
86 }
88 long arch_do_sysctl(struct xen_sysctl *sysctl,
89 XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
90 {
91 long ret = 0;
93 switch (sysctl->cmd) {
94 case XEN_SYSCTL_physinfo:
95 {
96 xen_sysctl_physinfo_t *pi = &sysctl->u.physinfo;
98 pi->threads_per_core = 1;
99 pi->cores_per_socket = 1;
100 pi->sockets_per_node = 1;
101 pi->nr_nodes = 1;
102 pi->total_pages = total_pages;
103 pi->free_pages = avail_domheap_pages();
104 pi->cpu_khz = cpu_khz;
105 memset(pi->hw_cap, 0, sizeof(pi->hw_cap));
106 ret = 0;
107 if ( copy_to_guest(u_sysctl, sysctl, 1) )
108 ret = -EFAULT;
109 }
110 break;
111 case DOM0_SHADOW_CONTROL:
112 {
113 struct domain *d;
114 ret = -ESRCH;
115 d = find_domain_by_id(op->u.shadow_control.domain);
116 if ( d != NULL )
117 {
118 ret = shadow_control_op(d, &op->u.shadow_control, u_dom0_op);
119 put_domain(d);
120 copy_to_guest(u_dom0_op, op, 1);
121 }
122 }
123 break;
125 default:
126 printk("%s: unsupported op: 0x%x\n", __func__, (op->cmd));
127 ret = -ENOSYS;
128 break;
129 }
131 return ret;
132 }