1/*-
2 * Copyright (c) 2000 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 11 unchanged lines hidden (view full) ---
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/agp/agp.c 186433 2008-12-23 16:04:33Z kib $");
29
30#include "opt_bus.h"
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/malloc.h>
35#include <sys/kernel.h>
36#include <sys/module.h>
37#include <sys/bus.h>
--- 511 unchanged lines hidden (view full) ---
549 * Find a page from the object and wire it
550 * down. This page will be mapped using one or more
551 * entries in the GATT (assuming that PAGE_SIZE >=
552 * AGP_PAGE_SIZE. If this is the first call to bind,
553 * the pages will be allocated and zeroed.
554 */
555 m = vm_page_grab(mem->am_obj, OFF_TO_IDX(i),
556 VM_ALLOC_WIRED | VM_ALLOC_ZERO | VM_ALLOC_RETRY);
557 AGP_DPF("found page pa=%#x\n", VM_PAGE_TO_PHYS(m));
558 }
559 VM_OBJECT_UNLOCK(mem->am_obj);
560
561 mtx_lock(&sc->as_lock);
562
563 if (mem->am_is_bound) {
564 device_printf(dev, "memory already bound\n");
565 error = EINVAL;
--- 14 unchanged lines hidden (view full) ---
580 * Install entries in the GATT, making sure that if
581 * AGP_PAGE_SIZE < PAGE_SIZE and mem->am_size is not
582 * aligned to PAGE_SIZE, we don't modify too many GATT
583 * entries.
584 */
585 for (j = 0; j < PAGE_SIZE && i + j < mem->am_size;
586 j += AGP_PAGE_SIZE) {
587 vm_offset_t pa = VM_PAGE_TO_PHYS(m) + j;
588 AGP_DPF("binding offset %#x to pa %#x\n",
589 offset + i + j, pa);
590 error = AGP_BIND_PAGE(dev, offset + i + j, pa);
591 if (error) {
592 /*
593 * Bail out. Reverse all the mappings
594 * and unwire the pages.
595 */
596 for (k = 0; k < i + j; k += AGP_PAGE_SIZE)
597 AGP_UNBIND_PAGE(dev, offset + k);
--- 381 unchanged lines hidden ---
2 * Copyright (c) 2000 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 11 unchanged lines hidden (view full) ---
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/agp/agp.c 186433 2008-12-23 16:04:33Z kib $");
29
30#include "opt_bus.h"
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/malloc.h>
35#include <sys/kernel.h>
36#include <sys/module.h>
37#include <sys/bus.h>
--- 511 unchanged lines hidden (view full) ---
549 * Find a page from the object and wire it
550 * down. This page will be mapped using one or more
551 * entries in the GATT (assuming that PAGE_SIZE >=
552 * AGP_PAGE_SIZE. If this is the first call to bind,
553 * the pages will be allocated and zeroed.
554 */
555 m = vm_page_grab(mem->am_obj, OFF_TO_IDX(i),
556 VM_ALLOC_WIRED | VM_ALLOC_ZERO | VM_ALLOC_RETRY);
557 AGP_DPF("found page pa=%#x\n", VM_PAGE_TO_PHYS(m));
558 }
559 VM_OBJECT_UNLOCK(mem->am_obj);
560
561 mtx_lock(&sc->as_lock);
562
563 if (mem->am_is_bound) {
564 device_printf(dev, "memory already bound\n");
565 error = EINVAL;
--- 14 unchanged lines hidden (view full) ---
580 * Install entries in the GATT, making sure that if
581 * AGP_PAGE_SIZE < PAGE_SIZE and mem->am_size is not
582 * aligned to PAGE_SIZE, we don't modify too many GATT
583 * entries.
584 */
585 for (j = 0; j < PAGE_SIZE && i + j < mem->am_size;
586 j += AGP_PAGE_SIZE) {
587 vm_offset_t pa = VM_PAGE_TO_PHYS(m) + j;
588 AGP_DPF("binding offset %#x to pa %#x\n",
589 offset + i + j, pa);
590 error = AGP_BIND_PAGE(dev, offset + i + j, pa);
591 if (error) {
592 /*
593 * Bail out. Reverse all the mappings
594 * and unwire the pages.
595 */
596 for (k = 0; k < i + j; k += AGP_PAGE_SIZE)
597 AGP_UNBIND_PAGE(dev, offset + k);
--- 381 unchanged lines hidden ---