1 /* $Id: generic.c,v 1.10 2000/08/09 00:00:15 davem Exp $
2 * generic.c: Generic Sparc mm routines that are not dependent upon
3 * MMU type but are Sparc specific.
5 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
8 #include <linux/kernel.h>
10 #include <linux/swap.h>
12 #include <asm/pgalloc.h>
13 #include <asm/pgtable.h>
16 static inline void forget_pte(pte_t page)
20 if (pte_present(page)) {
21 struct page *ptpage = pte_page(page);
22 if ((!VALID_PAGE(ptpage)) || PageReserved(ptpage))
25 * free_page() used to be able to clear swap cache
26 * entries. We may now have to do it manually.
28 free_page_and_swap_cache(ptpage);
31 swap_free(pte_to_swp_entry(page));
34 /* Remap IO memory, the same way as remap_page_range(), but use
35 * the obio memory space.
37 * They use a pgprot that sets PAGE_IO and does not check the
38 * mem_map table as this is independent of normal memory.
40 static inline void io_remap_pte_range(pte_t * pte, unsigned long address, unsigned long size,
41 unsigned long offset, pgprot_t prot, int space)
52 set_pte(pte, mk_pte_io(offset, prot, space));
57 } while (address < end);
60 static inline int io_remap_pmd_range(pmd_t * pmd, unsigned long address, unsigned long size,
61 unsigned long offset, pgprot_t prot, int space)
65 address &= ~PGDIR_MASK;
71 pte_t * pte = pte_alloc(pmd, address);
74 spin_lock(¤t->mm->page_table_lock);
75 io_remap_pte_range(pte, address, end - address, address + offset, prot, space);
76 spin_unlock(¤t->mm->page_table_lock);
77 address = (address + PMD_SIZE) & PMD_MASK;
79 } while (address < end);
83 int io_remap_page_range(unsigned long from, unsigned long offset, unsigned long size, pgprot_t prot, int space)
87 unsigned long beg = from;
88 unsigned long end = from + size;
90 prot = __pgprot(pg_iobits);
92 dir = pgd_offset(current->mm, from);
93 flush_cache_range(current->mm, beg, end);
95 pmd_t *pmd = pmd_alloc(dir, from);
99 error = io_remap_pmd_range(pmd, from, end - from, offset + from, prot, space);
102 from = (from + PGDIR_SIZE) & PGDIR_MASK;
105 flush_tlb_range(current->mm, beg, end);