From 7f9ec87c124acafd09429b153911f13f35d7760b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Tigeot?= Date: Tue, 4 Dec 2012 08:16:33 +0100 Subject: [PATCH] agp: Sync with FreeBSD * Add support for AMD64 Family 10h processors. FreeBSD PR: kern/128331 * Add a few VIA bridges for Intel Core/Core 2 and VIA Nano processors * Fix AGP debugging code * Rename agp_x86_64.c to agp_amd64.c again, keeping the same file name on both DragonFly and FreeBSD * Fix prototypes to be consistent * offset parameter has vm_offset_t type * vm_offset_t is unsigned and therefore can not be negative * Use si_drv1 instead of dev2unit() inside agp(4). * i810: Aperture size and stolen memory are now printed on one line * Add pci ids for Intel Ironlake chipsets --- sys/conf/files | 2 +- sys/config/LINT | 4 ++ sys/config/LINT64 | 4 ++ sys/dev/agp/Makefile | 2 +- sys/dev/agp/agp.c | 23 +++++++----- sys/dev/agp/agp_ali.c | 8 ++-- sys/dev/agp/agp_amd.c | 8 ++-- sys/dev/agp/{agp_x86_64.c => agp_amd64.c} | 22 +++++------ sys/dev/agp/agp_ati.c | 8 ++-- sys/dev/agp/agp_i810.c | 46 ++++++++++++----------- sys/dev/agp/agp_intel.c | 8 ++-- sys/dev/agp/agp_nvidia.c | 18 ++++----- sys/dev/agp/agp_sis.c | 8 ++-- sys/dev/agp/agp_via.c | 22 ++++++++--- sys/dev/agp/agppriv.h | 2 +- sys/platform/pc32/conf/options | 3 ++ sys/platform/pc64/conf/options | 4 ++ 17 files changed, 110 insertions(+), 82 deletions(-) rename sys/dev/agp/{agp_x86_64.c => agp_amd64.c} (96%) diff --git a/sys/conf/files b/sys/conf/files index 59a44486bc..ae9eec963a 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1532,7 +1532,7 @@ dev/agp/agp_via.c optional agp dev/agp/agp_sis.c optional agp dev/agp/agp_ali.c optional agp dev/agp/agp_amd.c optional agp -dev/agp/agp_x86_64.c optional agp +dev/agp/agp_amd64.c optional agp dev/agp/agp_i810.c optional agp dev/agp/agp_ati.c optional agp dev/agp/agp_if.m optional agp diff --git a/sys/config/LINT b/sys/config/LINT index 2751170b39..63da46a76d 100644 --- a/sys/config/LINT +++ b/sys/config/LINT @@ -1593,6 +1593,10 @@ options COMPAT_OLDPCI #FreeBSD 2.2 and 3.x compatibility shims # device agp +# +# AGP debugging. +# +options AGP_DEBUG # The `ahc' device provides support for the Adaptec 29/3940(U)(W) # and motherboard based AIC7870/AIC7880 adapters. diff --git a/sys/config/LINT64 b/sys/config/LINT64 index 5789a940d7..06d1137c00 100644 --- a/sys/config/LINT64 +++ b/sys/config/LINT64 @@ -1389,6 +1389,10 @@ options COMPAT_OLDPCI #FreeBSD 2.2 and 3.x compatibility shims # device agp +# +# AGP debugging. +# +options AGP_DEBUG # The `ahc' device provides support for the Adaptec 29/3940(U)(W) # and motherboard based AIC7870/AIC7880 adapters. diff --git a/sys/dev/agp/Makefile b/sys/dev/agp/Makefile index b008333e83..a38825200d 100644 --- a/sys/dev/agp/Makefile +++ b/sys/dev/agp/Makefile @@ -2,7 +2,7 @@ KMOD = agp SRCS = agp.c -SRCS += agp_i810.c agp_ali.c agp_amd.c agp_x86_64.c agp_ati.c agp_nvidia.c +SRCS += agp_i810.c agp_ali.c agp_amd.c agp_amd64.c agp_ati.c agp_nvidia.c SRCS += agp_intel.c agp_sis.c agp_via.c SRCS += agp_if.c device_if.h bus_if.h agp_if.h pci_if.h MFILES = kern/device_if.m kern/bus_if.m dev/agp/agp_if.m bus/pci/pci_if.m diff --git a/sys/dev/agp/agp.c b/sys/dev/agp/agp.c index 71ef88d12a..13d7f685f3 100644 --- a/sys/dev/agp/agp.c +++ b/sys/dev/agp/agp.c @@ -23,9 +23,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/agp/agp.c,v 1.58 2007/11/12 21:51:36 jhb Exp $ + * $FreeBSD: src/sys/dev/agp/agp.c,v 1.62 2009/02/06 20:57:10 wkoszek Exp $ */ +#include "opt_agp.h" + #include #include #include @@ -70,7 +72,6 @@ static struct dev_ops agp_ops = { }; static devclass_t agp_devclass; -#define KDEV2DEV(kdev) devclass_get_device(agp_devclass, minor(kdev)) /* Helper functions for implementing chipset mini drivers. */ @@ -238,6 +239,7 @@ agp_generic_attach(device_t dev) make_dev(&agp_ops, device_get_unit(dev), UID_ROOT, GID_WHEEL, 0600, "agpgart"); + sc->as_devnode->si_drv1 = dev; return 0; } @@ -270,7 +272,7 @@ agp_generic_detach(device_t dev) * Default AGP aperture size detection which simply returns the size of * the aperture's PCI resource. */ -int +u_int32_t agp_generic_get_aperture(device_t dev) { struct agp_softc *sc = device_get_softc(dev); @@ -514,6 +516,7 @@ agp_generic_bind_memory(device_t dev, struct agp_memory *mem, return EINVAL; } + /* Do some sanity checks first. */ if (offset < 0 || (offset & (AGP_PAGE_SIZE - 1)) != 0 || offset + mem->am_size > AGP_GET_APERTURE(dev)) { @@ -540,7 +543,7 @@ agp_generic_bind_memory(device_t dev, struct agp_memory *mem, m = vm_page_grab(mem->am_obj, OFF_TO_IDX(i), VM_ALLOC_NORMAL | VM_ALLOC_ZERO | VM_ALLOC_RETRY); - AGP_DPF("found page pa=%#x\n", VM_PAGE_TO_PHYS(m)); + AGP_DPF("found page pa=%#jx\n", (uintmax_t)VM_PAGE_TO_PHYS(m)); vm_page_wire(m); /* @@ -552,8 +555,8 @@ agp_generic_bind_memory(device_t dev, struct agp_memory *mem, for (j = 0; j < PAGE_SIZE && i + j < mem->am_size; j += AGP_PAGE_SIZE) { vm_offset_t pa = VM_PAGE_TO_PHYS(m) + j; - AGP_DPF("binding offset %#x to pa %#x\n", - offset + i + j, pa); + AGP_DPF("binding offset %#jx to pa %#jx\n", + (uintmax_t)offset + i + j, (uintmax_t)pa); error = AGP_BIND_PAGE(dev, offset + i + j, pa); if (error) { /* @@ -765,7 +768,7 @@ static int agp_open(struct dev_open_args *ap) { cdev_t kdev = ap->a_head.a_dev; - device_t dev = KDEV2DEV(kdev); + device_t dev = kdev->si_drv1; struct agp_softc *sc = device_get_softc(dev); if (!sc->as_isopen) { @@ -780,7 +783,7 @@ static int agp_close(struct dev_close_args *ap) { cdev_t kdev = ap->a_head.a_dev; - device_t dev = KDEV2DEV(kdev); + device_t dev = kdev->si_drv1; struct agp_softc *sc = device_get_softc(dev); struct agp_memory *mem; @@ -806,7 +809,7 @@ static int agp_ioctl(struct dev_ioctl_args *ap) { cdev_t kdev = ap->a_head.a_dev; - device_t dev = KDEV2DEV(kdev); + device_t dev = kdev->si_drv1; switch (ap->a_cmd) { case AGPIOC_INFO: @@ -842,7 +845,7 @@ static int agp_mmap(struct dev_mmap_args *ap) { cdev_t kdev = ap->a_head.a_dev; - device_t dev = KDEV2DEV(kdev); + device_t dev = kdev->si_drv1; struct agp_softc *sc = device_get_softc(dev); if (ap->a_offset > AGP_GET_APERTURE(dev)) diff --git a/sys/dev/agp/agp_ali.c b/sys/dev/agp/agp_ali.c index 61cb626f80..8f6aa71af9 100644 --- a/sys/dev/agp/agp_ali.c +++ b/sys/dev/agp/agp_ali.c @@ -202,11 +202,11 @@ agp_ali_set_aperture(device_t dev, u_int32_t aperture) } static int -agp_ali_bind_page(device_t dev, int offset, vm_offset_t physical) +agp_ali_bind_page(device_t dev, vm_offset_t offset, vm_offset_t physical) { struct agp_ali_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical; @@ -214,11 +214,11 @@ agp_ali_bind_page(device_t dev, int offset, vm_offset_t physical) } static int -agp_ali_unbind_page(device_t dev, int offset) +agp_ali_unbind_page(device_t dev, vm_offset_t offset) { struct agp_ali_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; diff --git a/sys/dev/agp/agp_amd.c b/sys/dev/agp/agp_amd.c index e376fbaf10..fb826068ec 100644 --- a/sys/dev/agp/agp_amd.c +++ b/sys/dev/agp/agp_amd.c @@ -321,11 +321,11 @@ agp_amd_set_aperture(device_t dev, u_int32_t aperture) } static int -agp_amd_bind_page(device_t dev, int offset, vm_offset_t physical) +agp_amd_bind_page(device_t dev, vm_offset_t offset, vm_offset_t physical) { struct agp_amd_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical | 1; @@ -336,11 +336,11 @@ agp_amd_bind_page(device_t dev, int offset, vm_offset_t physical) } static int -agp_amd_unbind_page(device_t dev, int offset) +agp_amd_unbind_page(device_t dev, vm_offset_t offset) { struct agp_amd_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; diff --git a/sys/dev/agp/agp_x86_64.c b/sys/dev/agp/agp_amd64.c similarity index 96% rename from sys/dev/agp/agp_x86_64.c rename to sys/dev/agp/agp_amd64.c index 10c20dd6d6..2b640bd44b 100644 --- a/sys/dev/agp/agp_x86_64.c +++ b/sys/dev/agp/agp_amd64.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/agp/agp_amd64.c,v 1.16 2007/11/12 21:51:36 jhb Exp $ + * $FreeBSD: src/sys/dev/agp/agp_amd64.c,v 1.17 2009/01/12 16:07:03 jkim Exp $ */ #include @@ -161,14 +161,16 @@ agp_amd64_attach(device_t dev) { struct agp_amd64_softc *sc = device_get_softc(dev); struct agp_gatt *gatt; + uint32_t devid; int i, n, error; - for (i = 0, n = 0; i < PCI_SLOTMAX && n < AMD64_MAX_MCTRL; i++) - if (pci_cfgregread(0, i, 3, 0, 4) == 0x11031022) { + for (i = 0, n = 0; i < PCI_SLOTMAX && n < AMD64_MAX_MCTRL; i++) { + devid = pci_cfgregread(0, i, 3, 0, 4); + if (devid == 0x11031022 || devid == 0x12031022) { sc->mctrl[n] = i; n++; } - + } if (n == 0) return (ENXIO); @@ -182,10 +184,6 @@ agp_amd64_attach(device_t dev) return (error); sc->initial_aperture = AGP_GET_APERTURE(dev); - if (sc->initial_aperture == 0) { - device_printf(dev, "bad initial aperture size, disabling\n"); - return ENXIO; - } for (;;) { gatt = agp_alloc_gatt(dev); @@ -328,11 +326,11 @@ agp_amd64_set_aperture(device_t dev, uint32_t aperture) } static int -agp_amd64_bind_page(device_t dev, int offset, vm_offset_t physical) +agp_amd64_bind_page(device_t dev, vm_offset_t offset, vm_offset_t physical) { struct agp_amd64_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return (EINVAL); sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = @@ -342,11 +340,11 @@ agp_amd64_bind_page(device_t dev, int offset, vm_offset_t physical) } static int -agp_amd64_unbind_page(device_t dev, int offset) +agp_amd64_unbind_page(device_t dev, vm_offset_t offset) { struct agp_amd64_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return (EINVAL); sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; diff --git a/sys/dev/agp/agp_ati.c b/sys/dev/agp/agp_ati.c index 39a4003150..c4238b0134 100644 --- a/sys/dev/agp/agp_ati.c +++ b/sys/dev/agp/agp_ati.c @@ -315,11 +315,11 @@ agp_ati_set_aperture(device_t dev, u_int32_t aperture) } static int -agp_ati_bind_page(device_t dev, int offset, vm_offset_t physical) +agp_ati_bind_page(device_t dev, vm_offset_t offset, vm_offset_t physical) { struct agp_ati_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; sc->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical | 1; @@ -328,11 +328,11 @@ agp_ati_bind_page(device_t dev, int offset, vm_offset_t physical) } static int -agp_ati_unbind_page(device_t dev, int offset) +agp_ati_unbind_page(device_t dev, vm_offset_t offset) { struct agp_ati_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; sc->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; diff --git a/sys/dev/agp/agp_i810.c b/sys/dev/agp/agp_i810.c index d052787674..9e544e21ce 100644 --- a/sys/dev/agp/agp_i810.c +++ b/sys/dev/agp/agp_i810.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/agp/agp_i810.c,v 1.43 2007/11/12 21:51:36 jhb Exp $ + * $FreeBSD: src/sys/dev/agp/agp_i810.c,v 1.56 2010/03/12 21:34:23 rnoland Exp $ */ /* @@ -69,7 +69,7 @@ enum { CHIP_I915, /* 915G/915GM */ CHIP_I965, /* G965 */ CHIP_G33, /* G33/Q33/Q35 */ - CHIP_IGD, /* G33 like IGD */ + CHIP_IGD, /* Pineview */ CHIP_G4X, /* G45/Q45 */ }; @@ -163,6 +163,10 @@ static const struct agp_i810_match { "Intel G33 SVGA controller"}, {0x29D28086, CHIP_G33, 0x00020000, "Intel Q33 SVGA controller"}, + {0xA0018086, CHIP_IGD, 0x00010000, + "Intel Pineview SVGA controller"}, + {0xA0118086, CHIP_IGD, 0x00010000, + "Intel Pineview (M) SVGA controller"}, {0x2A028086, CHIP_I965, 0x00020000, "Intel GM965 SVGA controller"}, {0x2A128086, CHIP_I965, 0x00020000, @@ -170,17 +174,17 @@ static const struct agp_i810_match { {0x2A428086, CHIP_G4X, 0x00020000, "Intel GM45 SVGA controller"}, {0x2E028086, CHIP_G4X, 0x00020000, - "Intel 4 Series SVGA controller"}, + "Intel Eaglelake SVGA controller"}, {0x2E128086, CHIP_G4X, 0x00020000, "Intel Q45 SVGA controller"}, {0x2E228086, CHIP_G4X, 0x00020000, "Intel G45 SVGA controller"}, {0x2E328086, CHIP_G4X, 0x00020000, "Intel G41 SVGA controller"}, - {0xA0018086, CHIP_IGD, 0x00010000, - "Intel IGD SVGA controller"}, - {0xA0118086, CHIP_IGD, 0x00010000, - "Intel IGD SVGA controller"}, + {0x00428086, CHIP_G4X, 0x00020000, + "Intel Ironlake (D) SVGA controller"}, + {0x00468086, CHIP_G4X, 0x00020000, + "Intel Ironlake (M) SVGA controller"}, {0, 0, 0, NULL} }; @@ -484,12 +488,6 @@ agp_i810_attach(device_t dev) agp_generic_detach(dev); return EINVAL; } - if (sc->stolen > 0) { - device_printf(dev, "detected %dk stolen memory\n", - sc->stolen * 4); - } - device_printf(dev, "aperture size is %dM\n", - sc->initial_aperture / 1024 / 1024); /* GATT address is already in there, make sure it's enabled */ pgtblctl = bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL); @@ -679,9 +677,6 @@ agp_i810_attach(device_t dev) gtt_size += 4; sc->stolen = (stolen - gtt_size) * 1024 / 4096; - if (sc->stolen > 0) - device_printf(dev, "detected %dk stolen memory\n", sc->stolen * 4); - device_printf(dev, "aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); /* GATT address is already in there, make sure it's enabled */ pgtblctl = bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL); @@ -691,6 +686,13 @@ agp_i810_attach(device_t dev) gatt->ag_physical = pgtblctl & ~1; } + device_printf(dev, "aperture size is %dM", + sc->initial_aperture / 1024 / 1024); + if (sc->stolen > 0) + kprintf(", detected %dk stolen memory\n", sc->stolen * 4); + else + kprintf("\n"); + if (0) agp_i810_dump_regs(dev); @@ -853,12 +855,12 @@ agp_i810_write_gtt_entry(device_t dev, int offset, vm_offset_t physical, } static int -agp_i810_bind_page(device_t dev, int offset, vm_offset_t physical) +agp_i810_bind_page(device_t dev, vm_offset_t offset, vm_offset_t physical) { struct agp_i810_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) { - device_printf(dev, "failed: offset is 0x%08x, shift is %d, entries is %d\n", offset, AGP_PAGE_SHIFT, sc->gatt->ag_entries); + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) { + device_printf(dev, "failed: offset is 0x%08jx, shift is %d, entries is %d\n", (intmax_t)offset, AGP_PAGE_SHIFT, sc->gatt->ag_entries); return EINVAL; } @@ -875,11 +877,11 @@ agp_i810_bind_page(device_t dev, int offset, vm_offset_t physical) } static int -agp_i810_unbind_page(device_t dev, int offset) +agp_i810_unbind_page(device_t dev, vm_offset_t offset) { struct agp_i810_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; if ( sc->chiptype != CHIP_I810 ) { @@ -1034,7 +1036,7 @@ agp_i810_bind_memory(device_t dev, struct agp_memory *mem, vm_offset_t i; /* Do some sanity checks first. */ - if (offset < 0 || (offset & (AGP_PAGE_SIZE - 1)) != 0 || + if ((offset & (AGP_PAGE_SIZE - 1)) != 0 || offset + mem->am_size > AGP_GET_APERTURE(dev)) { device_printf(dev, "binding memory at bad offset %#x\n", (int)offset); diff --git a/sys/dev/agp/agp_intel.c b/sys/dev/agp/agp_intel.c index 505ad4fa68..d29005580e 100644 --- a/sys/dev/agp/agp_intel.c +++ b/sys/dev/agp/agp_intel.c @@ -364,13 +364,13 @@ agp_intel_set_aperture(device_t dev, u_int32_t aperture) } static int -agp_intel_bind_page(device_t dev, int offset, vm_offset_t physical) +agp_intel_bind_page(device_t dev, vm_offset_t offset, vm_offset_t physical) { struct agp_intel_softc *sc; sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return (EINVAL); sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical | 0x17; @@ -378,13 +378,13 @@ agp_intel_bind_page(device_t dev, int offset, vm_offset_t physical) } static int -agp_intel_unbind_page(device_t dev, int offset) +agp_intel_unbind_page(device_t dev, vm_offset_t offset) { struct agp_intel_softc *sc; sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return (EINVAL); sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; diff --git a/sys/dev/agp/agp_nvidia.c b/sys/dev/agp/agp_nvidia.c index 58bad6da12..218accdaf3 100644 --- a/sys/dev/agp/agp_nvidia.c +++ b/sys/dev/agp/agp_nvidia.c @@ -74,8 +74,8 @@ static int agp_nvidia_attach(device_t); static int agp_nvidia_detach(device_t); static u_int32_t agp_nvidia_get_aperture(device_t); static int agp_nvidia_set_aperture(device_t, u_int32_t); -static int agp_nvidia_bind_page(device_t, int, vm_offset_t); -static int agp_nvidia_unbind_page(device_t, int); +static int agp_nvidia_bind_page(device_t, vm_offset_t, vm_offset_t); +static int agp_nvidia_unbind_page(device_t, vm_offset_t); static int nvidia_init_iorr(u_int32_t, u_int32_t); @@ -301,12 +301,12 @@ agp_nvidia_set_aperture(device_t dev, u_int32_t aperture) } static int -agp_nvidia_bind_page(device_t dev, int offset, vm_offset_t physical) +agp_nvidia_bind_page(device_t dev, vm_offset_t offset, vm_offset_t physical) { struct agp_nvidia_softc *sc = device_get_softc(dev); u_int32_t index; - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return (EINVAL); index = (sc->pg_offset + offset) >> AGP_PAGE_SHIFT; @@ -316,12 +316,12 @@ agp_nvidia_bind_page(device_t dev, int offset, vm_offset_t physical) } static int -agp_nvidia_unbind_page(device_t dev, int offset) +agp_nvidia_unbind_page(device_t dev, vm_offset_t offset) { struct agp_nvidia_softc *sc = device_get_softc(dev); u_int32_t index; - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return (EINVAL); index = (sc->pg_offset + offset) >> AGP_PAGE_SHIFT; @@ -330,8 +330,8 @@ agp_nvidia_unbind_page(device_t dev, int offset) return (0); } -static int -agp_nvidia_flush_tlb (device_t dev, int offset) +static void +agp_nvidia_flush_tlb (device_t dev) { struct agp_nvidia_softc *sc; u_int32_t wbc_reg, temp; @@ -367,8 +367,6 @@ agp_nvidia_flush_tlb (device_t dev, int offset) temp = ag_virtual[i * PAGE_SIZE / sizeof(u_int32_t)]; for(i = 0; i < pages; i++) temp = ag_virtual[i * PAGE_SIZE / sizeof(u_int32_t)]; - - return (0); } #define SYSCFG 0xC0010010 diff --git a/sys/dev/agp/agp_sis.c b/sys/dev/agp/agp_sis.c index 602b337c75..263eaeb3ad 100644 --- a/sys/dev/agp/agp_sis.c +++ b/sys/dev/agp/agp_sis.c @@ -222,11 +222,11 @@ agp_sis_set_aperture(device_t dev, u_int32_t aperture) } static int -agp_sis_bind_page(device_t dev, int offset, vm_offset_t physical) +agp_sis_bind_page(device_t dev, vm_offset_t offset, vm_offset_t physical) { struct agp_sis_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical; @@ -234,11 +234,11 @@ agp_sis_bind_page(device_t dev, int offset, vm_offset_t physical) } static int -agp_sis_unbind_page(device_t dev, int offset) +agp_sis_unbind_page(device_t dev, vm_offset_t offset) { struct agp_sis_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; diff --git a/sys/dev/agp/agp_via.c b/sys/dev/agp/agp_via.c index e47890a0e6..8f6c645aa8 100644 --- a/sys/dev/agp/agp_via.c +++ b/sys/dev/agp/agp_via.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/agp/agp_via.c,v 1.26 2007/11/12 21:51:37 jhb Exp $ + * $FreeBSD: src/sys/dev/agp/agp_via.c,v 1.27 2009/01/23 17:48:18 jkim Exp $ */ #include @@ -79,6 +79,14 @@ agp_via_match(device_t dev) return ("VIA 3296 (P4M800) host to PCI bridge"); case 0x03051106: return ("VIA 82C8363 (Apollo KT133x/KM133) host to PCI bridge"); + case 0x03141106: + return ("VIA 3314 (P4M800CE) host to PCI bridge"); + case 0x03241106: + return ("VIA VT3324 (CX700) host to PCI bridge"); + case 0x03271106: + return ("VIA 3327 (P4M890) host to PCI bridge"); + case 0x03641106: + return ("VIA 3364 (P4M900) host to PCI bridge"); case 0x03911106: return ("VIA 8371 (Apollo KX133) host to PCI bridge"); case 0x05011106: @@ -161,6 +169,10 @@ agp_via_attach(device_t dev) case 0x02591106: case 0x02691106: case 0x02961106: + case 0x03141106: + case 0x03241106: + case 0x03271106: + case 0x03641106: case 0x31231106: case 0x31681106: case 0x31891106: @@ -286,11 +298,11 @@ agp_via_set_aperture(device_t dev, u_int32_t aperture) } static int -agp_via_bind_page(device_t dev, int offset, vm_offset_t physical) +agp_via_bind_page(device_t dev, vm_offset_t offset, vm_offset_t physical) { struct agp_via_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical; @@ -298,11 +310,11 @@ agp_via_bind_page(device_t dev, int offset, vm_offset_t physical) } static int -agp_via_unbind_page(device_t dev, int offset) +agp_via_unbind_page(device_t dev, vm_offset_t offset) { struct agp_via_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; diff --git a/sys/dev/agp/agppriv.h b/sys/dev/agp/agppriv.h index 28e98d3bdd..669597aa71 100644 --- a/sys/dev/agp/agppriv.h +++ b/sys/dev/agp/agppriv.h @@ -96,7 +96,7 @@ void agp_free_gatt(struct agp_gatt *gatt); void agp_free_res(device_t dev); int agp_generic_attach(device_t dev); int agp_generic_detach(device_t dev); -int agp_generic_get_aperture(device_t dev); +u_int32_t agp_generic_get_aperture(device_t dev); int agp_generic_set_aperture(device_t dev, u_int32_t aperture); int agp_generic_enable(device_t dev, u_int32_t mode); diff --git a/sys/platform/pc32/conf/options b/sys/platform/pc32/conf/options index 63533bd041..079d54d457 100644 --- a/sys/platform/pc32/conf/options +++ b/sys/platform/pc32/conf/options @@ -101,6 +101,9 @@ PSM_HOOKRESUME opt_psm.h PSM_RESETAFTERSUSPEND opt_psm.h PSM_DEBUG opt_psm.h +# AGP debugging support +AGP_DEBUG opt_agp.h + ATKBD_DFLT_KEYMAP opt_atkbd.h KBD_DISABLE_KEYMAP_LOAD opt_kbd.h diff --git a/sys/platform/pc64/conf/options b/sys/platform/pc64/conf/options index b149a4e0af..8920a95fc7 100644 --- a/sys/platform/pc64/conf/options +++ b/sys/platform/pc64/conf/options @@ -52,6 +52,10 @@ PSM_HOOKRESUME opt_psm.h PSM_RESETAFTERSUSPEND opt_psm.h PSM_DEBUG opt_psm.h + +# AGP debugging support +AGP_DEBUG opt_agp.h + ATKBD_DFLT_KEYMAP opt_atkbd.h KBD_DISABLE_KEYMAP_LOAD opt_kbd.h -- 2.41.0