linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] resource.c: find the end of a E820 memory region
@ 2011-12-18 20:45 Philip Prindeville
  0 siblings, 0 replies; only message in thread
From: Philip Prindeville @ 2011-12-18 20:45 UTC (permalink / raw)
  To: Ed Wildgoose, Andrew Morton, linux-geode, Andres Salomon
  Cc: Nathan Williams, Guy Ellis, David Woodhouse, Patrick Georgi,
	Carl-Daniel Hailfinger, linux-mm

From: Philip Prindeville <philipp@redfish-solutions.com>

Add support for finding the end-boundary of an E820 region given an
address falling in one such region. This is precursory functionality
for Coreboot loader support.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Reviewed-by: Ed Wildgoose <ed@wildgooses.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andres Salomon <dilinger@queued.net>
Cc: Nathan Williams <nathan@traverse.com.au>
Cc: Guy Ellis <guy@traverse.com.au>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Patrick Georgi <patrick.georgi@secunet.com>
Cc: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Cc: linux-geode@lists.infradead.org
Cc: linux-mm@kvack.org
---
 include/linux/ioport.h |    1 +
 kernel/resource.c      |   29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 9d57a71..962d5a5 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -223,6 +223,7 @@ extern struct resource * __devm_request_region(struct device *dev,
 extern void __devm_release_region(struct device *dev, struct resource *parent,
 				  resource_size_t start, resource_size_t n);
 extern int iomem_map_sanity_check(resource_size_t addr, unsigned long size);
+extern resource_size_t iomem_map_find_boundary(resource_size_t addr, int *mapped);
 extern int iomem_is_exclusive(u64 addr);
 
 extern int
diff --git a/kernel/resource.c b/kernel/resource.c
index 7640b3a..58e4fce 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -1057,6 +1057,35 @@ static int __init reserve_setup(char *str)
 __setup("reserve=", reserve_setup);
 
 /*
+ * Find the upper boundary for the region that this address falls in, and
+ * whether it's currently mapped or not.
+ */
+
+resource_size_t iomem_map_find_boundary(resource_size_t addr, int *mapped)
+{
+	struct resource *p = &iomem_resource;
+	resource_size_t upper = 0;
+	loff_t l;
+
+	read_lock(&resource_lock);
+	for (p = p->child; p ; p = r_next(NULL, p, &l)) {
+		if (p->start > addr)
+			continue;
+		if (p->end < addr)
+			continue;
+		upper = p->end;
+		*mapped = ((p->flags & IORESOURCE_BUSY) != 0);
+		break;
+	}
+	read_unlock(&resource_lock);
+
+	return upper;
+}
+
+EXPORT_SYMBOL(iomem_map_find_boundary);
+
+
+/*
  * Check if the requested addr and size spans more than any slot in the
  * iomem resource tree.
  */
-- 
1.7.7.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-12-18 20:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-18 20:45 [PATCH 1/4] resource.c: find the end of a E820 memory region Philip Prindeville

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox