summaryrefslogtreecommitdiff
path: root/i386
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-05-02 21:33:01 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2014-07-06 15:45:55 +0200
commit3bb2b68bc84b9cb11aae7b46eeec3c5eb3363f54 (patch)
tree07e24c48536e0db45278c35132658acb770f9c3a /i386
parentdc1631b7dc508cb67fa6983007ddba3a2314d6bf (diff)
i386: add io_map_cached
io_map_cached is like io_map, but reuses the old mapping if it is applicable. * i386/i386/io_map.c: Add io_map_cached.
Diffstat (limited to 'i386')
-rw-r--r--i386/i386/io_map.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/i386/i386/io_map.c b/i386/i386/io_map.c
index 74e0b47..03d7152 100644
--- a/i386/i386/io_map.c
+++ b/i386/i386/io_map.c
@@ -58,3 +58,32 @@ io_map(
VM_PROT_READ|VM_PROT_WRITE);
return (start);
}
+
+/*
+ * Allocate and map memory for devices that may need to be mapped before
+ * Mach VM is running.
+ *
+ * This maps the all pages containing [PHYS_ADDR:PHYS_ADDR + SIZE].
+ * For contiguous requests to those pages will reuse the previously
+ * established mapping.
+ */
+vm_offset_t
+io_map_cached(
+ vm_offset_t phys_addr,
+ vm_size_t size)
+{
+ static vm_offset_t base;
+ static vm_size_t length;
+ static vm_offset_t map;
+
+ if (! map
+ || (phys_addr < base)
+ || (base + length < phys_addr + size))
+ {
+ base = trunc_page(phys_addr);
+ length = round_page(phys_addr - base + size);
+ map = io_map(base, length);
+ }
+
+ return map + (phys_addr - base);
+}