patch-2.0.21-2.1.0 linux/mm/vmalloc.c

Next file: linux/mm/vmscan.c
Previous file: linux/mm/swapfile.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file lx2.0/v2.0.21/linux/mm/vmalloc.c linux/mm/vmalloc.c
@@ -4,40 +4,14 @@
  *  Copyright (C) 1993  Linus Torvalds
  */
 
-#include <asm/system.h>
-
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/head.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/types.h>
 #include <linux/malloc.h>
-#include <linux/mm.h>
+#include <linux/vmalloc.h>
 
 #include <asm/segment.h>
-#include <asm/pgtable.h>
-
-struct vm_struct {
-	unsigned long flags;
-	void * addr;
-	unsigned long size;
-	struct vm_struct * next;
-};
+#include <asm/system.h>
 
 static struct vm_struct * vmlist = NULL;
 
-static inline void set_pgdir(unsigned long address, pgd_t entry)
-{
-	struct task_struct * p;
-
-	for_each_task(p) {
-		if (!p->mm)
-			continue;
-		*pgd_offset(p->mm,address) = entry;
-	}
-}
-
 static inline void free_area_pte(pmd_t * pmd, unsigned long address, unsigned long size)
 {
 	pte_t * pte;
@@ -172,69 +146,7 @@
 	return 0;
 }
 
-static inline void remap_area_pte(pte_t * pte, unsigned long address, unsigned long size,
-	unsigned long offset)
-{
-	unsigned long end;
-
-	address &= ~PMD_MASK;
-	end = address + size;
-	if (end > PMD_SIZE)
-		end = PMD_SIZE;
-	do {
-		if (!pte_none(*pte))
-			printk("remap_area_pte: page already exists\n");
-		set_pte(pte, mk_pte(offset, PAGE_KERNEL));
-		address += PAGE_SIZE;
-		offset += PAGE_SIZE;
-		pte++;
-	} while (address < end);
-}
-
-static inline int remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned long size,
-	unsigned long offset)
-{
-	unsigned long end;
-
-	address &= ~PGDIR_MASK;
-	end = address + size;
-	if (end > PGDIR_SIZE)
-		end = PGDIR_SIZE;
-	offset -= address;
-	do {
-		pte_t * pte = pte_alloc_kernel(pmd, address);
-		if (!pte)
-			return -ENOMEM;
-		remap_area_pte(pte, address, end - address, address + offset);
-		address = (address + PMD_SIZE) & PMD_MASK;
-		pmd++;
-	} while (address < end);
-	return 0;
-}
-
-static int remap_area_pages(unsigned long address, unsigned long offset, unsigned long size)
-{
-	pgd_t * dir;
-	unsigned long end = address + size;
-
-	offset -= address;
-	dir = pgd_offset(&init_mm, address);
-	flush_cache_all();
-	while (address < end) {
-		pmd_t *pmd = pmd_alloc_kernel(dir, address);
-		if (!pmd)
-			return -ENOMEM;
-		if (remap_area_pmd(pmd, address, end - address, offset + address))
-			return -ENOMEM;
-		set_pgdir(address, *dir);
-		address = (address + PGDIR_SIZE) & PGDIR_MASK;
-		dir++;
-	}
-	flush_tlb_all();
-	return 0;
-}
-
-static struct vm_struct * get_vm_area(unsigned long size)
+struct vm_struct * get_vm_area(unsigned long size)
 {
 	void *addr;
 	struct vm_struct **p, *tmp, *area;
@@ -283,7 +195,7 @@
 	struct vm_struct *area;
 
 	size = PAGE_ALIGN(size);
-	if (!size || size > (MAP_NR(high_memory) << PAGE_SHIFT))
+	if (!size || size > (max_mapnr << PAGE_SHIFT))
 		return NULL;
 	area = get_vm_area(size);
 	if (!area)
@@ -296,34 +208,6 @@
 	return addr;
 }
 
-/*
- * Remap an arbitrary physical address space into the kernel virtual
- * address space. Needed when the kernel wants to access high addresses
- * directly.
- */
-void * vremap(unsigned long offset, unsigned long size)
-{
-	void * addr;
-	struct vm_struct * area;
-
-	if (MAP_NR(offset) < MAP_NR(high_memory))
-		return NULL;
-	if (offset & ~PAGE_MASK)
-		return NULL;
-	size = PAGE_ALIGN(size);
-	if (!size || size > offset + size)
-		return NULL;
-	area = get_vm_area(size);
-	if (!area)
-		return NULL;
-	addr = area->addr;
-	if (remap_area_pages(VMALLOC_VMADDR(addr), offset, size)) {
-		vfree(addr);
-		return NULL;
-	}
-	return addr;
-}
-
 int vread(char *buf, char *addr, int count)
 {
 	struct vm_struct **p, *tmp;
@@ -335,7 +219,10 @@
 		while (addr < vaddr) {
 			if (count == 0)
 				goto finished;
-			put_user('\0', buf++), addr++, count--;
+			put_user('\0', buf);
+			buf++;
+			addr++;
+			count--;
 		}
 		n = tmp->size - PAGE_SIZE;
 		if (addr > vaddr)
@@ -343,7 +230,10 @@
 		while (--n >= 0) {
 			if (count == 0)
 				goto finished;
-			put_user(*addr++, buf++), count--;
+			put_user(*addr, buf);
+			buf++;
+			addr++;
+			count--;
 		}
 	}
 finished:

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