WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [PATCH]clean up ioports_{permit, deny}_access()

To: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [PATCH]clean up ioports_{permit, deny}_access()
From: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Date: Fri, 17 Oct 2008 18:04:35 +0900
Cc:
Delivery-date: Fri, 17 Oct 2008 02:04:39 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.6i
[IA64] clean up ioports_{permit, deny}_access()

eliminate code duplication in those functions
by introducing helper functions.

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>

diff -r f27787b9f8d7 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:04:57 2008 +0900
@@ -983,6 +983,32 @@
                                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 @@
     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 @@
     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 @@
     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);
-    }
+    ioports_get_mmio_addr(space, fp_base, lp_base, &mmio_start, &mmio_end);
 
-    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);
+    mmio_base = ioports_get_mmio_base(space, d);
 
     for (; mmio_start < mmio_end; mmio_start += PAGE_SIZE) {
         unsigned int port, range;


-- 
yamahata

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-ia64-devel] [PATCH]clean up ioports_{permit, deny}_access(), Isaku Yamahata <=