2 * baget.c: Baget low level stuff
4 * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
9 #include <linux/kernel.h>
11 #include <asm/system.h>
12 #include <asm/bootinfo.h>
13 #include <asm/mipsregs.h>
14 #include <asm/pgtable.h>
15 #include <asm/pgalloc.h>
17 #include <asm/baget/baget.h>
20 * Following code is based on routines from 'mm/vmalloc.c'
21 * Additional parameters ioaddr is needed to iterate across real I/O address.
23 static inline int alloc_area_pte(pte_t * pte, unsigned long address,
24 unsigned long size, unsigned long ioaddr)
32 while (address < end) {
35 printk("kseg2_alloc_io: page already exists\n");
37 * For MIPS looks pretty to have transparent mapping
38 * for KSEG2 areas -- user can't access one, and no
39 * problems with virtual <--> physical translation.
41 page = ioaddr & PAGE_MASK;
43 set_pte(pte, __pte(page | pgprot_val(PAGE_USERIO) |
44 _PAGE_GLOBAL | __READABLE | __WRITEABLE));
52 static inline int alloc_area_pmd(pmd_t * pmd, unsigned long address,
53 unsigned long size, unsigned long ioaddr)
57 address &= ~PGDIR_MASK;
61 while (address < end) {
62 pte_t * pte = pte_alloc_kernel(pmd, address);
65 if (alloc_area_pte(pte, address, end - address, ioaddr))
67 address = (address + PMD_SIZE) & PMD_MASK;
74 int kseg2_alloc_io (unsigned long address, unsigned long size)
77 unsigned long end = address + size;
79 dir = pgd_offset_k(address);
81 while (address < end) {
85 pmd = pmd_alloc_kernel(dir, address);
88 if (alloc_area_pmd(pmd, address, end - address, address))
90 if (pgd_val(olddir) != pgd_val(*dir))
91 set_pgdir(address, *dir);
92 address = (address + PGDIR_SIZE) & PGDIR_MASK;