ia64/xen-unstable

changeset 12943:4a2a96e72076

[POWERPC][XEN] Alloc IOMMU to map a Foreign page
VIO to a physical device reulsts in the granted page getting mapped
into the IOMMU.
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 Sat Oct 07 15:38:27 2006 -0400 (2006-10-07)
parents 0f4c73a1e92a
children 067bf06057cc
files xen/arch/powerpc/iommu.c
line diff
     1.1 --- a/xen/arch/powerpc/iommu.c	Wed Oct 04 14:06:14 2006 -0400
     1.2 +++ b/xen/arch/powerpc/iommu.c	Sat Oct 07 15:38:27 2006 -0400
     1.3 @@ -32,6 +32,12 @@
     1.4  #include "tce.h"
     1.5  #include "iommu.h"
     1.6  
     1.7 +#ifdef DEBUG
     1.8 +#define DBG(fmt...) printk(fmt)
     1.9 +#else
    1.10 +#define DBG(fmt...)
    1.11 +#endif
    1.12 +
    1.13  struct iommu_funcs {
    1.14      int (*iommu_put)(ulong, union tce);
    1.15  };
    1.16 @@ -46,16 +52,31 @@ int iommu_put(u32 buid, ulong ioba, unio
    1.17      struct domain *d = v->domain;
    1.18  
    1.19      if (buid < iommu_phbs_num && iommu_phbs[buid].iommu_put != NULL) {
    1.20 -        ulong gpfn;
    1.21 +        ulong gmfn;
    1.22          ulong mfn;
    1.23 +        int mtype;
    1.24 +
    1.25 +        gmfn = tce.tce_bits.tce_rpn;
    1.26  
    1.27 -        gpfn = tce.tce_bits.tce_rpn;
    1.28 -        mfn = gmfn_to_mfn(d, gpfn);
    1.29 +        
    1.30 +        mfn = pfn2mfn(d, gmfn, &mtype);
    1.31          if (mfn != INVALID_MFN) {
    1.32 -#ifdef DEBUG
    1.33 -            printk("%s: ioba=0x%lx pfn=0x%lx mfn=0x%lx\n", __func__,
    1.34 -                   ioba, pfn, mfn);
    1.35 -#endif
    1.36 +            switch (mtype) {
    1.37 +            case PFN_TYPE_RMA:
    1.38 +            case PFN_TYPE_LOGICAL:
    1.39 +                break;
    1.40 +            case PFN_TYPE_FOREIGN:
    1.41 +                DBG("%s: assigning to Foriegn page: "
    1.42 +                    "gmfn: 0x%lx mfn: 0x%lx\n",  __func__, gmfn, mfn);
    1.43 +                break;
    1.44 +            default:
    1.45 +                printk("%s: unsupported type[%d]: gmfn: 0x%lx mfn: 0x%lx\n",
    1.46 +                       __func__, mtype, gmfn, mfn);
    1.47 +                return -1;
    1.48 +            break;
    1.49 +            }
    1.50 +            DBG("%s: ioba=0x%lx gmfn=0x%lx mfn=0x%lx\n", __func__,
    1.51 +                ioba, gmfn, mfn);
    1.52              tce.tce_bits.tce_rpn = mfn;
    1.53              return iommu_phbs[buid].iommu_put(ioba, tce);
    1.54          }