Skip to contentSkip to conversation

minios: add ioremap/iounmap

PATCH In review Rolf Neugebauer 3 participants 6 messages Feb 19, 2009 – Mar 2, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 minios: add ioremap/iounmap

Add ioremap and iounmap functions to minios. Also move some unmapping code from and clean up mem_test.

---

extras/mini-os/arch/ia64/mm.c +6 -0
diff -r 11c2a7e44ee6 extras/mini-os/arch/ia64/mm.c
@@ -156,6 +156,12 @@
 	return (void*) __va(frames[0] << PAGE_SHIFT);
 }
 
+int unmap_frames(unsigned long virt_addr, unsigned long num_frames)
+{
+    /* TODO */
+    ASSERT(0);
+}
+
 void arch_init_p2m(unsigned long max_pfn)
 {
     printk("Warn: p2m map not implemented.\n");
extras/mini-os/arch/x86/ioremap.c new file +93 -0

93 lines not on this page · raw message

extras/mini-os/arch/x86/mm.c +113 -14

156 lines not on this page · raw message

extras/mini-os/include/ioremap.h new file +45 -0

45 lines not on this page · raw message

extras/mini-os/include/mm.h +1 -0
diff -r 11c2a7e44ee6 extras/mini-os/include/mm.h
@@ -71,6 +71,7 @@
 void do_map_frames(unsigned long addr,
         unsigned long *f, unsigned long n, unsigned long stride,
 	unsigned long increment, domid_t id, int may_fail, unsigned long prot);
+int unmap_frames(unsigned long va, unsigned long num_frames);
 #ifdef HAVE_LIBC
 extern unsigned long heap, brk, heap_mapped, heap_end;
 #endif
extras/mini-os/include/x86/arch_mm.h +0 -0
diff -r 11c2a7e44ee6 extras/mini-os/include/x86/arch_mm.h
@@ -222,5 +222,6 @@
 #define do_map_zero(start, n) do_map_frames(start, &mfn_zero, n, 0, 0, 

DOMID_SELF, 0, L1_PROT_RO)

pgentry_t *need_pgt(unsigned long addr);
+int mfn_is_ram(unsigned long mfn);

#endif /* _ARCH_MM_H_ */

extras/mini-os/lib/sys.c +5 -37

52 lines not on this page · raw message

#1 lore raw
Quoted 3 lines · Rolf Neugebauer, le Thu 19 Feb 2009 18:04:41 +0000, a écrit :

+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy

The lines of the patch got wrapped.

Quoted 4 lines
extras/mini-os/arch/x86/ioremap.c new file +4 -0
+    /* create a list of MFNs to map */
+    mfns = xmalloc_array(unsigned long, num_pages);
+    for ( i = 0; i < num_pages; i++, mfn++ )
+    {

extras/mini-os/arch/x86/ioremap.c line 59

Quoted 10 lines
extras/mini-os/arch/x86/ioremap.c new file +10 -0
+        if ( mfn_is_ram(mfn) )
+        {
+            printk("ioremap: mfn 0x%ulx is RAM\n", mfn);
+            goto mfn_invalid;
+        }
+
+        mfns[i] = mfn;
+    }
+    va = (unsigned long)map_frames_ex(mfns, num_pages, 1, 0, 1,
+                                      DOMID_IO, 0, prot);

Instead of allocating an array, why not using the incr parameter of map_frames_ex?

extras/mini-os/include/ioremap.h line 37

Quoted 11 lines
extras/mini-os/include/ioremap.h new file +11 -0
+/* Maybe these should be defined in the respective arch_mm.h */
+#if defined(__i386__) || defined(__x86_64__)
+#define IO_PROT (L1_PROT)
+#define IO_PROT_NOCACHE (L1_PROT | _PAGE_PCD)
+#elif defined(__ia64__)
+/* XXX IA64 needs to define these as appropriate. */
+#define IO_PROT 0
+#define IO_PROT_NOCACHE 0
+#else
+#error "Unsupported architecture"
+#endif

Shouldn't these go to include/<arch>/arch_mm.h?

Samuel

#2 lore raw
Quoted 39 lines · Samuel Thibault
Quoted 3 lines · Rolf Neugebauer, le Thu 19 Feb 2009 18:04:41 +0000, a écrit :

+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy

The lines of the patch got wrapped.

Quoted 4 lines
(quoted diff) +4 -0
+    /* create a list of MFNs to map */
+    mfns = xmalloc_array(unsigned long, num_pages);
+    for ( i = 0; i < num_pages; i++, mfn++ )
+    {

Review

Quoted 10 lines
(quoted diff) +10 -0
+        if ( mfn_is_ram(mfn) )
+        {
+            printk("ioremap: mfn 0x%ulx is RAM\n", mfn);
+            goto mfn_invalid;
+        }
+
+        mfns[i] = mfn;
+    }
+    va = (unsigned long)map_frames_ex(mfns, num_pages, 1, 0, 1,
+                                      DOMID_IO, 0, prot);

Instead of allocating an array, why not using the incr parameter of map_frames_ex?

Review

Quoted 11 lines
(quoted diff) +11 -0
+/* Maybe these should be defined in the respective arch_mm.h */
+#if defined(__i386__) || defined(__x86_64__)
+#define IO_PROT (L1_PROT)
+#define IO_PROT_NOCACHE (L1_PROT | _PAGE_PCD)
+#elif defined(__ia64__)
+/* XXX IA64 needs to define these as appropriate. */
+#define IO_PROT 0
+#define IO_PROT_NOCACHE 0
+#else
+#error "Unsupported architecture"
+#endif

Shouldn't these go to include/<arch>/arch_mm.h?

Quoted 1 line

Samuel

Thanks for your comments. An updated patch is attached (hopefully without my mailer wrapping the line)

rolf

Add ioremap and iounmap functions to minios. Also move some unmapping code from and clean up mem_test.

---

extras/mini-os/arch/ia64/mm.c +6 -0
diff -r 13688a8401c1 extras/mini-os/arch/ia64/mm.c
@@ -156,6 +156,12 @@
 	return (void*) __va(frames[0] << PAGE_SHIFT);
 }
 
+int unmap_frames(unsigned long virt_addr, unsigned long num_frames)
+{
+    /* TODO */
+    ASSERT(0);
+}
+
 void arch_init_p2m(unsigned long max_pfn)
 {
     printk("Warn: p2m map not implemented.\n");
extras/mini-os/arch/x86/ioremap.c new file +88 -0

88 lines not on this page · raw message

extras/mini-os/arch/x86/mm.c +113 -14

156 lines not on this page · raw message

extras/mini-os/include/ioremap.h new file +33 -0
diff -r 13688a8401c1 extras/mini-os/include/ioremap.h
@@ -0,0 +1,33 @@
+/**
+ * Copyright (C) 2009 Netronome Systems, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef _IOREMAP_H_
+#define _IOREMAP_H_
+
+void *ioremap(unsigned long phys_addr, unsigned long size);
+void *ioremap_nocache(unsigned long phys_addr, unsigned long size);
+void iounmap(void *virt_addr, unsigned long size);
+
+#endif /* _IOREMAP_H_ */
+
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4 indent-tabs-mode:nil -*- */
extras/mini-os/include/mm.h +1 -0
diff -r 13688a8401c1 extras/mini-os/include/mm.h
@@ -71,6 +71,7 @@
 void do_map_frames(unsigned long addr,
         unsigned long *f, unsigned long n, unsigned long stride,
 	unsigned long increment, domid_t id, int may_fail, unsigned long prot);
+int unmap_frames(unsigned long va, unsigned long num_frames);
 #ifdef HAVE_LIBC
 extern unsigned long heap, brk, heap_mapped, heap_end;
 #endif
extras/mini-os/include/x86/arch_mm.h +0 -0
diff -r 13688a8401c1 extras/mini-os/include/x86/arch_mm.h
@@ -133,6 +133,10 @@
 #define L4_PROT 

(_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
#endif /* __i386__ || __x86_64__ */

+/* flags for ioremap */
+#define IO_PROT (L1_PROT)
+#define IO_PROT_NOCACHE (L1_PROT | _PAGE_PCD)
+
#include "arch_limits.h"
#define PAGE_SIZE __PAGE_SIZE
#define PAGE_SHIFT __PAGE_SHIFT
@@ -222,5 +226,6 @@
#define do_map_zero(start, n) do_map_frames(start, &mfn_zero, n, 0, 0,
DOMID_SELF, 0, L1_PROT_RO)

pgentry_t *need_pgt(unsigned long addr);
+int mfn_is_ram(unsigned long mfn);

#endif /* _ARCH_MM_H_ */

extras/mini-os/lib/sys.c +5 -37

52 lines not on this page · raw message

#4 lore raw
In reply to Rolf Neugebauer
Quoted 7 lines · Rolf Neugebauer

Thanks for your comments. An updated patch is attached (hopefully without my mailer wrapping the line)

rolf

Add ioremap and iounmap functions to minios. Also move some unmapping code from and clean up mem_test.

This patch still has line wraps and so still does not apply. In fact all your patches have line wraps, so I threw them all away. Please re-send as attachments, each with changeset comment and sign-off and Samuel's acked-by.

-- Keir

#5 lore raw

PATCH 1/3 minios: add ioremap/iounmap [resend]

In reply to Rolf Neugebauer

Add ioremap and iounmap functions to minios. Also move some unmapping code from and clean up mem_test.

---

extras/mini-os/arch/ia64/mm.c +6 -0
diff -r 13688a8401c1 extras/mini-os/arch/ia64/mm.c
@@ -156,6 +156,12 @@
 	return (void*) __va(frames[0] << PAGE_SHIFT);
 }
 
+int unmap_frames(unsigned long virt_addr, unsigned long num_frames)
+{  
+    /* TODO */
+    ASSERT(0);
+}
+
 void arch_init_p2m(unsigned long max_pfn)
 {
     printk("Warn: p2m map not implemented.\n");
extras/mini-os/arch/x86/ioremap.c new file +88 -0

88 lines not on this page · raw message

extras/mini-os/arch/x86/mm.c +113 -14

156 lines not on this page · raw message

extras/mini-os/include/ioremap.h new file +33 -0
diff -r 13688a8401c1 extras/mini-os/include/ioremap.h
@@ -0,0 +1,33 @@
+/**
+ * Copyright (C) 2009 Netronome Systems, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef _IOREMAP_H_
+#define _IOREMAP_H_
+
+void *ioremap(unsigned long phys_addr, unsigned long size);
+void *ioremap_nocache(unsigned long phys_addr, unsigned long size);
+void iounmap(void *virt_addr, unsigned long size);
+
+#endif /* _IOREMAP_H_ */
+
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4 indent-tabs-mode:nil -*- */
extras/mini-os/include/mm.h +1 -0
diff -r 13688a8401c1 extras/mini-os/include/mm.h
@@ -71,6 +71,7 @@
 void do_map_frames(unsigned long addr,
         unsigned long *f, unsigned long n, unsigned long stride,
 	unsigned long increment, domid_t id, int may_fail, unsigned long prot);
+int unmap_frames(unsigned long va, unsigned long num_frames);
 #ifdef HAVE_LIBC
 extern unsigned long heap, brk, heap_mapped, heap_end;
 #endif
extras/mini-os/include/x86/arch_mm.h +5 -0
diff -r 13688a8401c1 extras/mini-os/include/x86/arch_mm.h
@@ -133,6 +133,10 @@
 #define L4_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
 #endif /* __i386__ || __x86_64__ */
 
+/* flags for ioremap */
+#define IO_PROT (L1_PROT)
+#define IO_PROT_NOCACHE (L1_PROT | _PAGE_PCD)
+
 #include "arch_limits.h"
 #define PAGE_SIZE       __PAGE_SIZE
 #define PAGE_SHIFT      __PAGE_SHIFT
@@ -222,5 +226,6 @@
 #define do_map_zero(start, n) do_map_frames(start, &mfn_zero, n, 0, 0, DOMID_SELF, 0, L1_PROT_RO)
 
 pgentry_t *need_pgt(unsigned long addr);
+int mfn_is_ram(unsigned long mfn);
 
 #endif /* _ARCH_MM_H_ */
extras/mini-os/lib/sys.c +5 -37

52 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel