[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/3] i386: add io_map_cached
From: |
Justus Winter |
Subject: |
[PATCH 2/3] i386: add io_map_cached |
Date: |
Fri, 2 May 2014 21:33:01 +0200 |
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.
---
i386/i386/io_map.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
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);
+}
--
1.9.2
Re: [PATCH 1/3] ddb: add "halt" command, Samuel Thibault, 2014/05/02