vm_machdep.c (257200) | vm_machdep.c (257201) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986 The Regents of the University of California. 3 * Copyright (c) 1989, 1990 William Jolitz 4 * Copyright (c) 1994 John Dyson 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * the Systems Programming Group of the University of Utah Computer --- 27 unchanged lines hidden (view full) --- 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 40 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ 41 */ 42 43#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986 The Regents of the University of California. 3 * Copyright (c) 1989, 1990 William Jolitz 4 * Copyright (c) 1994 John Dyson 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * the Systems Programming Group of the University of Utah Computer --- 27 unchanged lines hidden (view full) --- 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 40 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ 41 */ 42 43#include <sys/cdefs.h> |
44__FBSDID("$FreeBSD: head/sys/arm/arm/vm_machdep.c 257200 2013-10-27 01:34:10Z ian $"); | 44__FBSDID("$FreeBSD: head/sys/arm/arm/vm_machdep.c 257201 2013-10-27 03:13:26Z ian $"); |
45 46#include <sys/param.h> 47#include <sys/systm.h> 48#include <sys/kernel.h> 49#include <sys/malloc.h> 50#include <sys/mbuf.h> 51#include <sys/proc.h> 52#include <sys/socketvar.h> --- 424 unchanged lines hidden (view full) --- 477 busdma_swi(); 478} 479 480void 481cpu_exit(struct thread *td) 482{ 483} 484 | 45 46#include <sys/param.h> 47#include <sys/systm.h> 48#include <sys/kernel.h> 49#include <sys/malloc.h> 50#include <sys/mbuf.h> 51#include <sys/proc.h> 52#include <sys/socketvar.h> --- 424 unchanged lines hidden (view full) --- 477 busdma_swi(); 478} 479 480void 481cpu_exit(struct thread *td) 482{ 483} 484 |
485#define BITS_PER_INT (8 * sizeof(int)) 486vm_offset_t arm_nocache_startaddr; 487static int arm_nocache_allocated[ARM_NOCACHE_KVA_SIZE / (PAGE_SIZE * 488 BITS_PER_INT)]; 489 490/* 491 * Functions to map and unmap memory non-cached into KVA the kernel won't try 492 * to allocate. The goal is to provide uncached memory to busdma, to honor 493 * BUS_DMA_COHERENT. 494 * We can allocate at most ARM_NOCACHE_KVA_SIZE bytes. 495 * The allocator is rather dummy, each page is represented by a bit in 496 * a bitfield, 0 meaning the page is not allocated, 1 meaning it is. 497 * As soon as it finds enough contiguous pages to satisfy the request, 498 * it returns the address. 499 */ 500void * 501arm_remap_nocache(void *addr, vm_size_t size) 502{ 503 int i, j; 504 505 size = round_page(size); 506 for (i = 0; i < ARM_NOCACHE_KVA_SIZE / PAGE_SIZE; i++) { 507 if (!(arm_nocache_allocated[i / BITS_PER_INT] & (1 << (i % 508 BITS_PER_INT)))) { 509 for (j = i; j < i + (size / (PAGE_SIZE)); j++) 510 if (arm_nocache_allocated[j / BITS_PER_INT] & 511 (1 << (j % BITS_PER_INT))) 512 break; 513 if (j == i + (size / (PAGE_SIZE))) 514 break; 515 } 516 } 517 if (i < ARM_NOCACHE_KVA_SIZE / PAGE_SIZE) { 518 vm_offset_t tomap = arm_nocache_startaddr + i * PAGE_SIZE; 519 void *ret = (void *)tomap; 520 vm_paddr_t physaddr = vtophys((vm_offset_t)addr); 521 vm_offset_t vaddr = (vm_offset_t) addr; 522 523 vaddr = vaddr & ~PAGE_MASK; 524 for (; tomap < (vm_offset_t)ret + size; tomap += PAGE_SIZE, 525 vaddr += PAGE_SIZE, physaddr += PAGE_SIZE, i++) { 526 cpu_idcache_wbinv_range(vaddr, PAGE_SIZE); 527#ifdef ARM_L2_PIPT 528 cpu_l2cache_wbinv_range(physaddr, PAGE_SIZE); 529#else 530 cpu_l2cache_wbinv_range(vaddr, PAGE_SIZE); 531#endif 532 pmap_kenter_nocache(tomap, physaddr); 533 cpu_tlb_flushID_SE(vaddr); 534 arm_nocache_allocated[i / BITS_PER_INT] |= 1 << (i % 535 BITS_PER_INT); 536 } 537 return (ret); 538 } 539 540 return (NULL); 541} 542 543void 544arm_unmap_nocache(void *addr, vm_size_t size) 545{ 546 vm_offset_t raddr = (vm_offset_t)addr; 547 int i; 548 549 size = round_page(size); 550 i = (raddr - arm_nocache_startaddr) / (PAGE_SIZE); 551 for (; size > 0; size -= PAGE_SIZE, i++) { 552 arm_nocache_allocated[i / BITS_PER_INT] &= ~(1 << (i % 553 BITS_PER_INT)); 554 pmap_kremove(raddr); 555 raddr += PAGE_SIZE; 556 } 557} 558 | |
559#ifdef ARM_USE_SMALL_ALLOC 560 561static TAILQ_HEAD(,arm_small_page) pages_normal = 562 TAILQ_HEAD_INITIALIZER(pages_normal); 563static TAILQ_HEAD(,arm_small_page) pages_wt = 564 TAILQ_HEAD_INITIALIZER(pages_wt); 565static TAILQ_HEAD(,arm_small_page) free_pgdesc = 566 TAILQ_HEAD_INITIALIZER(free_pgdesc); --- 183 unchanged lines hidden --- | 485#ifdef ARM_USE_SMALL_ALLOC 486 487static TAILQ_HEAD(,arm_small_page) pages_normal = 488 TAILQ_HEAD_INITIALIZER(pages_normal); 489static TAILQ_HEAD(,arm_small_page) pages_wt = 490 TAILQ_HEAD_INITIALIZER(pages_wt); 491static TAILQ_HEAD(,arm_small_page) free_pgdesc = 492 TAILQ_HEAD_INITIALIZER(free_pgdesc); --- 183 unchanged lines hidden --- |