ia64/xen-unstable

view xen/arch/powerpc/iommu.c @ 12932:0379ac3367b2

[XEN][POWERPC] Use gmfn_to_mfn() over pfn2mfn()
Should only use pfn2mfn() if you care about the type of memory.
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 Mon Oct 02 21:40:26 2006 -0400 (2006-10-02)
parents 4fdf5151b187
children 4a2a96e72076
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 #undef DEBUG
23 #include <xen/config.h>
24 #include <xen/types.h>
25 #include <xen/sched.h>
26 #include <xen/init.h>
27 #include <xen/mm.h>
28 #include <asm/current.h>
29 #include <asm/papr.h>
30 #include <asm/hcalls.h>
31 #include <public/xen.h>
32 #include "tce.h"
33 #include "iommu.h"
35 struct iommu_funcs {
36 int (*iommu_put)(ulong, union tce);
37 };
39 /* individual host bridges */
40 static struct iommu_funcs iommu_phbs[16];
41 static u32 iommu_phbs_num = ARRAY_SIZE(iommu_phbs);
43 int iommu_put(u32 buid, ulong ioba, union tce tce)
44 {
45 struct vcpu *v = get_current();
46 struct domain *d = v->domain;
48 if (buid < iommu_phbs_num && iommu_phbs[buid].iommu_put != NULL) {
49 ulong gpfn;
50 ulong mfn;
52 gpfn = tce.tce_bits.tce_rpn;
53 mfn = gmfn_to_mfn(d, gpfn);
54 if (mfn != INVALID_MFN) {
55 #ifdef DEBUG
56 printk("%s: ioba=0x%lx pfn=0x%lx mfn=0x%lx\n", __func__,
57 ioba, pfn, mfn);
58 #endif
59 tce.tce_bits.tce_rpn = mfn;
60 return iommu_phbs[buid].iommu_put(ioba, tce);
61 }
62 }
63 return -1;
64 }
66 int iommu_register(u32 buid, int (*put)(ulong ioba, union tce ltce))
67 {
69 if (buid < iommu_phbs_num && iommu_phbs[buid].iommu_put == NULL) {
70 iommu_phbs[0].iommu_put = put;
71 return 0;
72 }
73 panic("bad IOMMU registration\n");
74 return -1;
75 }