Date: Sat, 12 Apr 2008 16:59:34 GMT From: Oleksandr Tymoshenko <gonzo@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 139911 for review Message-ID: <200804121659.m3CGxYo1093231@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=139911 Change 139911 by gonzo@gonzo_jeeves on 2008/04/12 16:58:46 o Add proper implementation of pmap_mapdev for physical addresses greater then 512M. Implementation and comment come from arm/arm/pmap.c Affected files ... .. //depot/projects/mips2-jnpr/src/sys/mips/mips/pmap.c#27 edit Differences ... ==== //depot/projects/mips2-jnpr/src/sys/mips/mips/pmap.c#27 (text+ko) ==== @@ -2758,13 +2758,38 @@ */ /* - * Note I don't know if any of this will work if pa is above - * 512Meg. + * Map a set of physical memory pages into the kernel virtual + * address space. Return a pointer to where it is mapped. This + * routine is intended to be used for mapping device memory, + * NOT real memory. */ void * pmap_mapdev(vm_offset_t pa, vm_size_t size) { - return ((void *)(MIPS_PHYS_TO_UNCACHED(pa))); + vm_offset_t va, tmpva, offset; + + /* + * KSEG1 maps only first 512M of phys address space. For + * pa > 0x20000000 we should make proper mapping * using pmap_kenter. + */ + if (pa + size < MIPS_KSEG0_LARGEST_PHYS) + return (void *)MIPS_PHYS_TO_KSEG1(pa); + else { + offset = pa & PAGE_MASK; + size = roundup(size, PAGE_SIZE); + + va = kmem_alloc_nofault(kernel_map, size); + if (!va) + panic("pmap_mapdev: Couldn't alloc kernel virtual memory"); + for (tmpva = va; size > 0;) { + pmap_kenter(tmpva, pa); + size -= PAGE_SIZE; + tmpva += PAGE_SIZE; + pa += PAGE_SIZE; + } + } + + return ((void *)(va + offset)); } void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200804121659.m3CGxYo1093231>