patch-2.1.31 linux/arch/i386/mm/ioremap.c

Next file: linux/arch/m68k/Makefile
Previous file: linux/arch/i386/kernel/time.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.30/linux/arch/i386/mm/ioremap.c linux/arch/i386/mm/ioremap.c
@@ -9,11 +9,10 @@
  */
 
 #include <linux/vmalloc.h>
-
 #include <asm/io.h>
 
 static inline void remap_area_pte(pte_t * pte, unsigned long address, unsigned long size,
-	unsigned long phys_addr)
+	unsigned long phys_addr, unsigned long flags)
 {
 	unsigned long end;
 
@@ -24,7 +23,8 @@
 	do {
 		if (!pte_none(*pte))
 			printk("remap_area_pte: page already exists\n");
-		set_pte(pte, mk_pte_phys(phys_addr, PAGE_KERNEL));
+		set_pte(pte, mk_pte_phys(phys_addr, __pgprot(_PAGE_PRESENT | _PAGE_RW | 
+					_PAGE_DIRTY | _PAGE_ACCESSED | flags)));
 		address += PAGE_SIZE;
 		phys_addr += PAGE_SIZE;
 		pte++;
@@ -32,7 +32,7 @@
 }
 
 static inline int remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned long size,
-	unsigned long phys_addr)
+	unsigned long phys_addr, unsigned long flags)
 {
 	unsigned long end;
 
@@ -45,14 +45,15 @@
 		pte_t * pte = pte_alloc_kernel(pmd, address);
 		if (!pte)
 			return -ENOMEM;
-		remap_area_pte(pte, address, end - address, address + phys_addr);
+		remap_area_pte(pte, address, end - address, address + phys_addr, flags);
 		address = (address + PMD_SIZE) & PMD_MASK;
 		pmd++;
 	} while (address < end);
 	return 0;
 }
 
-static int remap_area_pages(unsigned long address, unsigned long phys_addr, unsigned long size)
+static int remap_area_pages(unsigned long address, unsigned long phys_addr,
+				 unsigned long size, unsigned long flags)
 {
 	pgd_t * dir;
 	unsigned long end = address + size;
@@ -64,7 +65,8 @@
 		pmd_t *pmd = pmd_alloc_kernel(dir, address);
 		if (!pmd)
 			return -ENOMEM;
-		if (remap_area_pmd(pmd, address, end - address, phys_addr + address))
+		if (remap_area_pmd(pmd, address, end - address,
+					 phys_addr + address, flags))
 			return -ENOMEM;
 		set_pgdir(address, *dir);
 		address = (address + PGDIR_SIZE) & PGDIR_MASK;
@@ -75,11 +77,15 @@
 }
 
 /*
+ * Generic mapping function (not visible outside):
+ */
+
+/*
  * Remap an arbitrary physical address space into the kernel virtual
  * address space. Needed when the kernel wants to access high addresses
  * directly.
  */
-void * ioremap(unsigned long phys_addr, unsigned long size)
+void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
 {
 	void * addr;
 	struct vm_struct * area;
@@ -95,7 +101,7 @@
 	if (!area)
 		return NULL;
 	addr = area->addr;
-	if (remap_area_pages(VMALLOC_VMADDR(addr), phys_addr, size)) {
+	if (remap_area_pages(VMALLOC_VMADDR(addr), phys_addr, size, flags)) {
 		vfree(addr);
 		return NULL;
 	}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov