Lines Matching full:mem

496 	struct agp_memory *mem;  in agp_generic_alloc_memory()  local
510 mem = malloc(sizeof *mem, M_AGP, M_WAITOK); in agp_generic_alloc_memory()
511 mem->am_id = sc->as_nextid++; in agp_generic_alloc_memory()
512 mem->am_size = size; in agp_generic_alloc_memory()
513 mem->am_type = 0; in agp_generic_alloc_memory()
514 mem->am_obj = vm_object_allocate(OBJT_SWAP, atop(round_page(size))); in agp_generic_alloc_memory()
515 mem->am_physical = 0; in agp_generic_alloc_memory()
516 mem->am_offset = 0; in agp_generic_alloc_memory()
517 mem->am_is_bound = 0; in agp_generic_alloc_memory()
518 TAILQ_INSERT_TAIL(&sc->as_memory, mem, am_link); in agp_generic_alloc_memory()
521 return mem; in agp_generic_alloc_memory()
525 agp_generic_free_memory(device_t dev, struct agp_memory *mem) in agp_generic_free_memory() argument
529 if (mem->am_is_bound) in agp_generic_free_memory()
532 sc->as_allocated -= mem->am_size; in agp_generic_free_memory()
533 TAILQ_REMOVE(&sc->as_memory, mem, am_link); in agp_generic_free_memory()
534 vm_object_deallocate(mem->am_obj); in agp_generic_free_memory()
535 free(mem, M_AGP); in agp_generic_free_memory()
540 agp_generic_bind_memory(device_t dev, struct agp_memory *mem, in agp_generic_bind_memory() argument
551 offset + mem->am_size > AGP_GET_APERTURE(dev)) { in agp_generic_bind_memory()
562 VM_OBJECT_WLOCK(mem->am_obj); in agp_generic_bind_memory()
563 for (i = 0; i < mem->am_size; i += PAGE_SIZE) { in agp_generic_bind_memory()
571 m = vm_page_grab(mem->am_obj, OFF_TO_IDX(i), in agp_generic_bind_memory()
575 VM_OBJECT_WUNLOCK(mem->am_obj); in agp_generic_bind_memory()
576 vm_page_iter_init(&pages, mem->am_obj); in agp_generic_bind_memory()
579 if (mem->am_is_bound) { in agp_generic_bind_memory()
582 VM_OBJECT_WLOCK(mem->am_obj); in agp_generic_bind_memory()
591 VM_OBJECT_WLOCK(mem->am_obj); in agp_generic_bind_memory()
592 for (i = 0; i < mem->am_size; i += PAGE_SIZE) { in agp_generic_bind_memory()
597 * AGP_PAGE_SIZE < PAGE_SIZE and mem->am_size is not in agp_generic_bind_memory()
601 for (j = 0; j < PAGE_SIZE && i + j < mem->am_size; in agp_generic_bind_memory()
619 VM_OBJECT_WUNLOCK(mem->am_obj); in agp_generic_bind_memory()
626 mem->am_offset = offset; in agp_generic_bind_memory()
627 mem->am_is_bound = 1; in agp_generic_bind_memory()
634 VM_OBJECT_ASSERT_WLOCKED(mem->am_obj); in agp_generic_bind_memory()
635 for (k = 0; k < mem->am_size; k += PAGE_SIZE) { in agp_generic_bind_memory()
641 VM_OBJECT_WUNLOCK(mem->am_obj); in agp_generic_bind_memory()
647 agp_generic_unbind_memory(device_t dev, struct agp_memory *mem) in agp_generic_unbind_memory() argument
656 if (!mem->am_is_bound) { in agp_generic_unbind_memory()
666 for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE) in agp_generic_unbind_memory()
667 AGP_UNBIND_PAGE(dev, mem->am_offset + i); in agp_generic_unbind_memory()
671 vm_page_iter_init(&pages, mem->am_obj); in agp_generic_unbind_memory()
672 VM_OBJECT_WLOCK(mem->am_obj); in agp_generic_unbind_memory()
673 for (i = 0; i < mem->am_size; i += PAGE_SIZE) { in agp_generic_unbind_memory()
677 VM_OBJECT_WUNLOCK(mem->am_obj); in agp_generic_unbind_memory()
679 mem->am_offset = 0; in agp_generic_unbind_memory()
680 mem->am_is_bound = 0; in agp_generic_unbind_memory()
720 struct agp_memory *mem; in agp_find_memory() local
723 TAILQ_FOREACH(mem, &sc->as_memory, am_link) { in agp_find_memory()
724 AGP_DPF("considering memory block %d\n", mem->am_id); in agp_find_memory()
725 if (mem->am_id == id) in agp_find_memory()
726 return mem; in agp_find_memory()
762 struct agp_memory *mem; in agp_allocate_user() local
764 mem = AGP_ALLOC_MEMORY(dev, in agp_allocate_user()
767 if (mem) { in agp_allocate_user()
768 alloc->key = mem->am_id; in agp_allocate_user()
769 alloc->physical = mem->am_physical; in agp_allocate_user()
779 struct agp_memory *mem = agp_find_memory(dev, id); in agp_deallocate_user() local
781 if (mem) { in agp_deallocate_user()
782 AGP_FREE_MEMORY(dev, mem); in agp_deallocate_user()
792 struct agp_memory *mem = agp_find_memory(dev, bind->key); in agp_bind_user() local
794 if (!mem) in agp_bind_user()
797 return AGP_BIND_MEMORY(dev, mem, bind->pg_start << AGP_PAGE_SHIFT); in agp_bind_user()
803 struct agp_memory *mem = agp_find_memory(dev, unbind->key); in agp_unbind_user() local
805 if (!mem) in agp_unbind_user()
808 return AGP_UNBIND_MEMORY(dev, mem); in agp_unbind_user()
837 struct agp_memory *mem; in agp_close() local
842 while ((mem = TAILQ_FIRST(&sc->as_memory)) != NULL) { in agp_close()
843 if (mem->am_is_bound) in agp_close()
844 AGP_UNBIND_MEMORY(dev, mem); in agp_close()
845 AGP_FREE_MEMORY(dev, mem); in agp_close()
978 struct agp_memory *mem = (struct agp_memory *) handle; in agp_free_memory() local
979 AGP_FREE_MEMORY(dev, mem); in agp_free_memory()
984 struct agp_memory *mem = (struct agp_memory *) handle; in agp_bind_memory() local
985 return AGP_BIND_MEMORY(dev, mem, offset); in agp_bind_memory()
990 struct agp_memory *mem = (struct agp_memory *) handle; in agp_unbind_memory() local
991 return AGP_UNBIND_MEMORY(dev, mem); in agp_unbind_memory()
997 struct agp_memory *mem = (struct agp_memory *) handle; in agp_memory_info() local
999 mi->ami_size = mem->am_size; in agp_memory_info()
1000 mi->ami_physical = mem->am_physical; in agp_memory_info()
1001 mi->ami_offset = mem->am_offset; in agp_memory_info()
1002 mi->ami_is_bound = mem->am_is_bound; in agp_memory_info()