[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [IA64] clean up ioports_{permit, deny}_access()



# HG changeset patch
# User Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
# Date 1224234965 -32400
# Node ID 07558e1876e451290bdfd0947fce7c91a5db7818
# Parent  f27787b9f8d7131918cb763acfe7d33e12e6b6e9
[IA64] clean up ioports_{permit, deny}_access()

eliminate code duplication in those functions
by introducing helper functions.

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
---
 xen/arch/ia64/xen/mm.c |   59 +++++++++++++++++++++++++------------------------
 1 files changed, 31 insertions(+), 28 deletions(-)

diff -r f27787b9f8d7 -r 07558e1876e4 xen/arch/ia64/xen/mm.c
--- a/xen/arch/ia64/xen/mm.c    Fri Oct 17 17:40:15 2008 +0900
+++ b/xen/arch/ia64/xen/mm.c    Fri Oct 17 18:16:05 2008 +0900
@@ -983,6 +983,32 @@ assign_domain_page(struct domain *d,
                                ASSIGN_writable | ASSIGN_pgc_allocated);
 }
 
+static void
+ioports_get_mmio_addr(const struct io_space *space,
+                      unsigned long fp, unsigned long lp,
+                      unsigned long *mmio_start, unsigned long *mmio_end)
+{
+    if (space->sparse) {
+        *mmio_start = IO_SPACE_SPARSE_ENCODING(fp) & PAGE_MASK;
+        *mmio_end = PAGE_ALIGN(IO_SPACE_SPARSE_ENCODING(lp));
+    } else {
+        *mmio_start = fp & PAGE_MASK;
+        *mmio_end = PAGE_ALIGN(lp);
+    }
+}
+
+static unsigned long
+ioports_get_mmio_base(const struct io_space *space, struct domain *d)
+{
+    if (VMX_DOMAIN(d->vcpu[0]))
+        return LEGACY_IO_START;
+
+    if (space == &io_space[0] && d != dom0)
+        return IO_PORTS_PADDR;
+
+    return __pa(space->mmio_base);
+}
+
 /* 
  * Inpurt
  * fgp: first guest port
@@ -1025,13 +1051,7 @@ ioports_permit_access(struct domain *d, 
     fmp = IO_SPACE_PORT(fmp);
     lmp = IO_SPACE_PORT(lmp);
 
-    if (space->sparse) {
-        mach_start = IO_SPACE_SPARSE_ENCODING(fmp) & PAGE_MASK;
-        mach_end = PAGE_ALIGN(IO_SPACE_SPARSE_ENCODING(lmp));
-    } else {
-        mach_start = fmp & PAGE_MASK;
-        mach_end = PAGE_ALIGN(lmp);
-    }
+    ioports_get_mmio_addr(space, fmp, lmp, &mach_start, &mach_end);
 
     /*
      * The "machine first port" is not necessarily identity mapped
@@ -1041,13 +1061,7 @@ ioports_permit_access(struct domain *d, 
     mach_end = mach_end | __pa(space->mmio_base);
 
     mmio_start = IO_SPACE_SPARSE_ENCODING(fgp) & PAGE_MASK;
-
-    if (VMX_DOMAIN(d->vcpu[0]))
-        mmio_start |= LEGACY_IO_START;
-    else if (space == &io_space[0])
-        mmio_start |= IO_PORTS_PADDR;
-    else
-        mmio_start |= __pa(space->mmio_base);
+    mmio_start |= ioports_get_mmio_base(space, d);
 
     while (mach_start < mach_end) {
         (void)__assign_domain_page(d, mmio_start, mach_start, ASSIGN_nocache); 
@@ -1090,20 +1104,9 @@ ioports_deny_access(struct domain *d, un
     fp_base = IO_SPACE_PORT(fp);
     lp_base = IO_SPACE_PORT(lp);
 
-    if (space->sparse) {
-        mmio_start = IO_SPACE_SPARSE_ENCODING(fp_base) & PAGE_MASK;
-        mmio_end = PAGE_ALIGN(IO_SPACE_SPARSE_ENCODING(lp_base));
-    } else {
-        mmio_start = fp_base & PAGE_MASK;
-        mmio_end = PAGE_ALIGN(lp_base);
-    }
-
-    if (VMX_DOMAIN(d->vcpu[0]))
-        mmio_base = LEGACY_IO_START;
-    else if (space == &io_space[0] && d != dom0)
-        mmio_base = IO_PORTS_PADDR;
-    else
-        mmio_base = __pa(space->mmio_base);
+    ioports_get_mmio_addr(space, fp_base, lp_base, &mmio_start, &mmio_end);
+
+    mmio_base = ioports_get_mmio_base(space, d);
 
     for (; mmio_start < mmio_end; mmio_start += PAGE_SIZE) {
         unsigned int port, range;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.