direct-io.hg

view xen/arch/powerpc/iommu.c @ 11487:4fdf5151b187

[POWERPC] merge with xen-unstable.hg
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author hollisb@localhost
date Mon Sep 18 12:48:56 2006 -0500 (2006-09-18)
parents 43ec7afa5734
children 0379ac3367b2
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 pfn;
50 ulong mfn;
51 int mtype;
53 pfn = tce.tce_bits.tce_rpn;
54 mfn = pfn2mfn(d, pfn, &mtype);
55 if (mfn != INVALID_MFN) {
56 #ifdef DEBUG
57 printk("%s: ioba=0x%lx pfn=0x%lx mfn=0x%lx\n", __func__,
58 ioba, pfn, mfn);
59 #endif
60 tce.tce_bits.tce_rpn = mfn;
61 return iommu_phbs[buid].iommu_put(ioba, tce);
62 }
63 }
64 return -1;
65 }
67 int iommu_register(u32 buid, int (*put)(ulong ioba, union tce ltce))
68 {
70 if (buid < iommu_phbs_num && iommu_phbs[buid].iommu_put == NULL) {
71 iommu_phbs[0].iommu_put = put;
72 return 0;
73 }
74 panic("bad IOMMU registration\n");
75 return -1;
76 }