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

[Xen-devel] [RFC for-4.8 2/6] xen/arm: Add an optional map function to the device descriptor



From: "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxxx>

Add an optional map function to the device descriptor. If
registered, the map function will be called to do custom
device specific mappings of the device. If not registered,
the generic DT version (handle_device) will be used.

This is in preparation for adding support for "mmio-sram"
memory that needs to be mapped as MEMORY and not DEVICE.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xxxxxxxxxx>
---
 xen/arch/arm/domain_build.c  | 13 ++++++++++++-
 xen/include/asm-arm/device.h | 10 ++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 00dc07a..15b6dbe 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1212,6 +1212,7 @@ static int handle_node(struct domain *d, struct 
kernel_info *kinfo,
         DT_MATCH_PATH("/hypervisor"),
         { /* sentinel */ },
     };
+    const struct device_desc *desc;
     struct dt_device_node *child;
     int res;
     const char *name;
@@ -1233,6 +1234,8 @@ static int handle_node(struct domain *d, struct 
kernel_info *kinfo,
         return 0;
     }
 
+    desc = device_get_desc(node);
+
     /*
      * Replace these nodes with our own. Note that the original may be
      * used_by DOMID_XEN so this check comes first.
@@ -1268,7 +1271,15 @@ static int handle_node(struct domain *d, struct 
kernel_info *kinfo,
                "WARNING: Path %s is reserved, skip the node as we may re-use 
the path.\n",
                path);
 
-    res = handle_device(d, node);
+    if ( desc && desc->map )
+    {
+        res = desc->map(d, node);
+    }
+    else
+    {
+        res = handle_device(d, node);
+    }
+
     if ( res)
         return res;
 
diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h
index 1a40a02..98b9fe1 100644
--- a/xen/include/asm-arm/device.h
+++ b/xen/include/asm-arm/device.h
@@ -48,6 +48,16 @@ struct device_desc {
     const struct dt_device_match *dt_match;
     /* Device initialization */
     int (*init)(struct dt_device_node *dev, const void *data);
+
+    /**
+     *  map - Custom map function to map a devices memory regions and IRQs
+     *  @d: Domain to map device into
+     *  @dev: Device tree node representing the device
+     *
+     *  OPTIONAL: If not set the generic DT code will take care of creating
+     *  the mappings.
+     */
+    int (*map)(struct domain *d, struct dt_device_node *dev);
 };
 
 struct acpi_device_desc {
-- 
2.5.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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