* better
[mascara-docs.git] / i386 / linux-2.3.21 / arch / m68k / sun3 / dvma.c
blobd12ff43acaabbf8da56288096b811419f91a699b
2 /* dvma support routines */
4 #include <linux/kernel.h>
5 #include <linux/mm.h>
6 #include <asm/page.h>
7 #include <asm/pgtable.h>
8 #include <asm/sun3mmu.h>
9 #include <asm/dvma.h>
11 unsigned long dvma_next_free = DVMA_START;
13 /* get needed number of free dma pages, or panic if not enough */
15 void *sun3_dvma_malloc(int len)
17 unsigned long vaddr;
19 /* if the next free pages have been accessed, skip them */
20 while((dvma_next_free < DVMA_END) &&
21 (sun3_get_pte(dvma_next_free) & SUN3_PAGE_ACCESSED))
22 dvma_next_free += SUN3_PTE_SIZE;
24 if((dvma_next_free + len) > DVMA_END)
25 panic("sun3_dvma_malloc: out of dvma pages");
27 vaddr = dvma_next_free;
28 dvma_next_free = PAGE_ALIGN(dvma_next_free + len);
30 return (void *)vaddr;