Index: etc/etc.i386/MAKEDEV.md =================================================================== RCS file: /cvs/src/etc/etc.i386/MAKEDEV.md,v retrieving revision 1.35 diff -u -d -p -r1.35 MAKEDEV.md --- etc/etc.i386/MAKEDEV.md 16 Apr 2006 11:34:02 -0000 1.35 +++ etc/etc.i386/MAKEDEV.md 19 Apr 2006 20:25:42 -0000 @@ -19,6 +19,7 @@ dnl dnl __devitem(apm, apm, Power management device)dnl __devitem(acpi, acpi, Advanced Configuration and Power Interface)dnl +__devitem(agp, agp, Accelerated Graphics Port)dnl __devitem(nvram, nvram, NVRAM access)dnl _mkdev(nvram, nvram, {-M nvram c major_nvram_c 0 440 kmem-})dnl _TITLE(make) @@ -69,6 +70,7 @@ _DEV(uscan, 77) _TITLE(spec) _DEV(apm, 21) _DEV(acpi, 85) +_DEV(agp, 86) _DEV(au, 42) _DEV(bio, 79) _DEV(bktr, 49) Index: etc/etc.i386/fbtab =================================================================== RCS file: /cvs/src/etc/etc.i386/fbtab,v retrieving revision 1.10 diff -u -d -p -r1.10 fbtab --- etc/etc.i386/fbtab 3 Feb 2005 19:28:01 -0000 1.10 +++ etc/etc.i386/fbtab 19 Apr 2006 20:25:42 -0000 @@ -1,2 +1,2 @@ -/dev/ttyC0 0600 /dev/console:/dev/wskbd:/dev/wskbd0:/dev/wsmouse:/dev/wsmouse0:/dev/ttyCcfg +/dev/ttyC0 0600 /dev/console:/dev/wskbd:/dev/wskbd0:/dev/wsmouse:/dev/wsmouse0:/dev/ttyCcfg:/dev/agp /dev/X0 0600 /dev/wsmouse:/dev/wsmouse0 Index: share/man/man4/agp.4 =================================================================== RCS file: share/man/man4/agp.4 diff -N share/man/man4/agp.4 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ share/man/man4/agp.4 19 Apr 2006 20:26:43 -0000 @@ -0,0 +1,151 @@ +.\" $OpenBSD$ +.\" +.\" Copyright (c) 2001 Yar Tikhiy +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD: /repoman/r/ncvs/src/share/man/man4/agp.4,v 1.10 2006/02/17 06:29:51 brueffer Exp $ +.Dd April 19, 2006 +.Dt AGP 4 +.Os +.Sh NAME +.Nm agp +.Nd "generic interface to the Accelerated Graphics Port (AGP)" +.Sh SYNOPSIS +.Cd "device agp" +.Sh DESCRIPTION +The +.Nm +driver provides uniform, abstract methods for controlling the AGP GART through +.Xr ioctl 2 , +which is used by the X server on some architectures. +.Pp +The following +.Xr ioctl 2 +operations can be performed on +.Pa /dev/agp , +and are defined in +.Aq Pa sys/agpio.h : +.Bl -tag -width indent +.It Dv AGPIOC_INFO +Returns information about the AGP subsystem. +The result is a pointer to the following structure: +.Bd -literal +typedef struct _agp_info { + agp_version version; /* version of driver (unused) */ + u_int32_t bridge_id; /* bridge vendor/device */ + u_int32_t agp_mode; /* mode info of bridge */ + off_t aper_base; /* base of aperture */ + size_t aper_size; /* size of aperture */ + size_t pg_total; /* max pages (swap + system) */ + size_t pg_system; /* max pages (system) */ + size_t pg_used; /* current pages used */ +} agp_info; +.Ed +.It Dv AGPIOC_ACQUIRE +Acquire control of the AGP chipset for use by this client. +Returns +.Er EBUSY +if the AGP chipset is already acquired by another client. +.It Dv AGPIOC_RELEASE +Release control of the AGP chipset. +This does not unbind or free any allocated memory, which is the +responsibility of the client to handle if necessary. +.It Dv AGPIOC_SETUP +Enable the AGP hardware with the relevant mode. +This +.Xr ioctl 2 +takes the following structure: +.Bd -literal +typedef struct _agp_setup { + u_int32_t agp_mode; /* mode info of bridge */ +} agp_setup; +.Ed +.Pp +The mode bits are defined in +.Aq Pa sys/agpio.h . +.It Dv AGPIOC_ALLOCATE +Allocate physical memory suitable for mapping into the AGP aperture. +This +.Xr ioctl 2 +takes the following structure: +.Bd -literal +typedef struct _agp_allocate { + int key; /* tag of allocation */ + size_t pg_count; /* number of pages */ + u_int32_t type; /* 0 == normal, other devspec */ + u_int32_t physical; /* device specific (some devices + * need a phys address of the + * actual page behind the gatt + * table) */ +} agp_allocate; +.Ed +.Pp +It returns a handle to the allocated memory. +.It Dv AGPIOC_DEALLOCATE +Free the previously allocated memory associated with the handle passed. +.It Dv AGPIOC_BIND +Bind the allocated memory at given offset with the AGP aperture. +Returns +.Er EINVAL +if the memory is already bound or the offset is not at AGP page boundary. +This +.Xr ioctl 2 +takes the following structure: +.Bd -literal +typedef struct _agp_bind { + int key; /* tag of allocation */ + off_t pg_start; /* starting page to populate */ +} agp_bind; +.Ed +.Pp +The tag of allocation is the handle returned by +.Dv AGPIOC_ALLOCATE . +.It Dv AGPIOC_UNBIND +Unbind memory from the AGP aperture. +Returns +.Er EINVAL +if the memory is not bound. +This +.Xr ioctl 2 +takes the following structure: +.Bd -literal +typedef struct _agp_unbind { + int key; /* tag of allocation */ + u_int32_t priority; /* priority for paging out */ +} agp_unbind; +.Ed +.El +.Sh FILES +.Bl -tag -width ".Pa /dev/agp" -compact +.It Pa /dev/agp +AGP device node. +.El +.Sh SEE ALSO +.Xr ioctl 2 , +.Xr X 7 +.Sh HISTORY +The +.Nm +driver first appeared in +.Ox 3.9 . Index: share/man/man4/options.4 =================================================================== RCS file: /cvs/src/share/man/man4/options.4,v retrieving revision 1.176 diff -u -d -p -r1.176 options.4 --- share/man/man4/options.4 14 Apr 2006 21:57:40 -0000 1.176 +++ share/man/man4/options.4 19 Apr 2006 20:26:46 -0000 @@ -655,16 +655,6 @@ server on some architectures. See .Xr pci 4 for details. -.It Cd option PCIAGP -Enables -.Xr ioctl 2 -access to the AGP GART on the supported chipsets. -It's used by the -.Xr Xorg 1 -server on some architectures. -See -.Xr vga 4 -for details. .It Cd option MULTIPROCESSOR On those architectures that have it, this enables multiprocessor support. .It Cd option USER_LDT Index: share/man/man4/vga.4 =================================================================== RCS file: /cvs/src/share/man/man4/vga.4,v retrieving revision 1.13 diff -u -d -p -r1.13 vga.4 --- share/man/man4/vga.4 23 Mar 2006 10:47:34 -0000 1.13 +++ share/man/man4/vga.4 19 Apr 2006 20:26:46 -0000 @@ -35,7 +35,6 @@ .Cd "vga0 at isa?" .Cd "vga* at pci?" .Cd "wsdisplay* at vga?" -.Cd "option PCIAGP" .Sh DESCRIPTION This driver handles VGA graphics hardware within the .Xr wscons 4 @@ -119,110 +118,7 @@ This is only useful with the .Dq *bf screen types; a font containing the ASCII range of characters must be available too on this screen. -.Sh AGP SUPPORT -.Ic option PCIAGP -enables support for programming the AGP GART through -.Xr ioctl 2 , -which is used by the X server on some architectures. -.Pp -The following -.Xr ioctl 2 -operations can be performed on -.Pa /dev/ttyC0 , -and are defined in -.Aq Pa sys/agpio.h : -.Bl -tag -width indent -.It Dv AGPIOC_INFO -Returns information about the AGP subsystem. -The result is a pointer to the following structure: -.Bd -literal -typedef struct _agp_info { - agp_version version; /* version of driver (unused) */ - u_int32_t bridge_id; /* bridge vendor/device */ - u_int32_t agp_mode; /* mode info of bridge */ - off_t aper_base; /* base of aperture */ - size_t aper_size; /* size of aperture */ - size_t pg_total; /* max pages (swap + system) */ - size_t pg_system; /* max pages (system) */ - size_t pg_used; /* current pages used */ -} agp_info; -.Ed -.It Dv AGPIOC_ACQUIRE -Acquire control of the AGP chipset for use by this client. -Returns -.Er EBUSY -if the AGP chipset is already acquired by another client. -.It Dv AGPIOC_RELEASE -Release control of the AGP chipset. -This does not unbind or free any allocated memory, which is the -responsibility of the client to handle if necessary. -.It Dv AGPIOC_SETUP -Enable the AGP hardware with the relevant mode. -This -.Xr ioctl 2 -takes the following structure: -.Bd -literal -typedef struct _agp_setup { - u_int32_t agp_mode; /* mode info of bridge */ -} agp_setup; -.Ed -.Pp -The mode bits are defined in -.Aq Pa sys/agpio.h . -.It Dv AGPIOC_ALLOCATE -Allocate physical memory suitable for mapping into the AGP aperture. -This -.Xr ioctl 2 -takes the following structure: -.Bd -literal -typedef struct _agp_allocate { - int key; /* tag of allocation */ - size_t pg_count; /* number of pages */ - u_int32_t type; /* 0 == normal, other devspec */ - u_int32_t physical; /* device specific (some devices - * need a phys address of the - * actual page behind the gatt - * table) */ -} agp_allocate; -.Ed -.Pp -It returns a handle to the allocated memory. -.It Dv AGPIOC_DEALLOCATE -Free the previously allocated memory associated with the handle passed. -.It Dv AGPIOC_BIND -Bind the allocated memory at given offset with the AGP aperture. -Returns -.Er EINVAL -if the memory is already bound or the offset is not at AGP page boundary. -This -.Xr ioctl 2 -takes the following structure: -.Bd -literal -typedef struct _agp_bind { - int key; /* tag of allocation */ - off_t pg_start; /* starting page to populate */ -} agp_bind; -.Ed -.Pp -The tag of allocation is the handle returned by -.Dv AGPIOC_ALLOCATE . -.It Dv AGPIOC_UNBIND -Unbind memory from the AGP aperture. -Returns -.Er EINVAL -if the memory is not bound. -This -.Xr ioctl 2 -takes the following structure: -.Bd -literal -typedef struct _agp_unbind { - int key; /* tag of allocation */ - u_int32_t priority; /* priority for paging out */ -} agp_unbind; -.Ed -.El .Sh SEE ALSO -.Xr ioctl 2 , .Xr intro 4 , .Xr isa 4 , .Xr pcdisplay 4 , Index: sys/arch/i386/conf/GENERIC =================================================================== RCS file: /cvs/src/sys/arch/i386/conf/GENERIC,v retrieving revision 1.483 diff -u -d -p -r1.483 GENERIC --- sys/arch/i386/conf/GENERIC 14 Apr 2006 21:52:47 -0000 1.483 +++ sys/arch/i386/conf/GENERIC 19 Apr 2006 20:26:52 -0000 @@ -251,8 +251,8 @@ pckbd* at pckbc? # PC keyboard pms* at pckbc? # PS/2 mouse for wsmouse pmsi* at pckbc? # PS/2 "Intelli"mouse for wsmouse vga0 at isa? -option PCIAGP vga* at pci? +agp0 at vga? pcdisplay0 at isa? # CGA, MDA, EGA, HGA wsdisplay* at vga? wsdisplay* at pcdisplay? Index: sys/arch/i386/conf/files.i386 =================================================================== RCS file: /cvs/src/sys/arch/i386/conf/files.i386,v retrieving revision 1.144 diff -u -d -p -r1.144 files.i386 --- sys/arch/i386/conf/files.i386 4 Mar 2006 16:27:03 -0000 1.144 +++ sys/arch/i386/conf/files.i386 19 Apr 2006 20:26:52 -0000 @@ -97,13 +97,13 @@ file arch/i386/i386/mainbus.c mainbus include "../../../dev/pci/files.pci" file arch/i386/pci/pci_machdep.c pci -file arch/i386/pci/agp_machdep.c pciagp -file dev/pci/agp_ali.c pciagp -file dev/pci/agp_amd.c pciagp -file dev/pci/agp_i810.c pciagp -file dev/pci/agp_intel.c pciagp -file dev/pci/agp_sis.c pciagp -file dev/pci/agp_via.c pciagp +file arch/i386/pci/agp_machdep.c agp +file dev/pci/agp_ali.c agp +file dev/pci/agp_amd.c agp +file dev/pci/agp_i810.c agp +file dev/pci/agp_intel.c agp +file dev/pci/agp_sis.c agp +file dev/pci/agp_via.c agp file arch/i386/pci/pciide_machdep.c pciide file arch/i386/pci/pcic_pci_machdep.c pcic_pci Index: sys/arch/i386/i386/conf.c =================================================================== RCS file: /cvs/src/sys/arch/i386/i386/conf.c,v retrieving revision 1.112 diff -u -d -p -r1.112 conf.c --- sys/arch/i386/i386/conf.c 31 Dec 2005 22:40:37 -0000 1.112 +++ sys/arch/i386/i386/conf.c 19 Apr 2006 20:26:52 -0000 @@ -193,6 +193,8 @@ cdev_decl(cztty); #include "gpr.h" #include "nvram.h" cdev_decl(nvram); +#include "agp.h" +cdev_decl(agp); /* XXX -- this needs to be supported by config(8)! */ #if (NCOM > 0) && (NPCCOM > 0) @@ -325,6 +327,7 @@ struct cdevsw cdevsw[] = cdev_gpio_init(NGPIO,gpio), /* 83: GPIO interface */ cdev_nvram_init(NNVRAM,nvram), /* 84: NVRAM interface */ cdev_acpi_init(NACPI,acpi), /* 85: ACPI */ + cdev_agp_init(NAGP,agp), /* 86: AGP */ }; int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]); Index: sys/arch/i386/pci/pchb.c =================================================================== RCS file: /cvs/src/sys/arch/i386/pci/pchb.c,v retrieving revision 1.52 diff -u -d -p -r1.52 pchb.c --- sys/arch/i386/pci/pchb.c 13 Mar 2006 20:10:49 -0000 1.52 +++ sys/arch/i386/pci/pchb.c 19 Apr 2006 20:26:52 -0000 @@ -78,6 +78,8 @@ #include +#include "agp.h" + #define PCISET_INTEL_BRIDGETYPE_MASK 0x3 #define PCISET_INTEL_TYPE_COMPAT 0x1 #define PCISET_INTEL_TYPE_AUX 0x2 @@ -197,7 +199,7 @@ pchbattach(parent, self, aux) */ switch (PCI_VENDOR(pa->pa_id)) { -#ifdef PCIAGP +#if NAGP > 0 case PCI_VENDOR_ALI: case PCI_VENDOR_SIS: case PCI_VENDOR_VIATECH: @@ -206,7 +208,7 @@ pchbattach(parent, self, aux) #endif case PCI_VENDOR_AMD: switch (PCI_PRODUCT(pa->pa_id)) { -#ifdef PCIAGP +#if NAGP > 0 case PCI_PRODUCT_AMD_SC751_SC: case PCI_PRODUCT_AMD_762_PCHB: pciagp_set_pchb(pa); @@ -244,7 +246,7 @@ pchbattach(parent, self, aux) config_found(self, &pba, pchb_print); break; case PCI_VENDOR_INTEL: -#ifdef PCIAGP +#if NAGP > 0 pciagp_set_pchb(pa); #endif switch (PCI_PRODUCT(pa->pa_id)) { Index: sys/conf/files =================================================================== RCS file: /cvs/src/sys/conf/files,v retrieving revision 1.369 diff -u -d -p -r1.369 files --- sys/conf/files 6 Apr 2006 20:25:14 -0000 1.369 +++ sys/conf/files 19 Apr 2006 20:26:55 -0000 @@ -94,8 +94,11 @@ file dev/ic/pcdisplay_chars.c pcdisplayo define mk48txx file dev/ic/mk48txx.c mk48txx +# AGP attachment +define agpbus {} + # VGA graphics -device vga: wsemuldisplaydev, pcdisplayops +device vga: wsemuldisplaydev, pcdisplayops, agpbus file dev/ic/vga.c vga & (vga_pci | vga_isa) needs-flag file dev/ic/vga_subr.c vga & (vga_pci | vga_isa) needs-flag Index: sys/dev/ic/vga.c =================================================================== RCS file: /cvs/src/sys/dev/ic/vga.c,v retrieving revision 1.38 diff -u -d -p -r1.38 vga.c --- sys/dev/ic/vga.c 31 Jan 2005 06:41:27 -0000 1.38 +++ sys/dev/ic/vga.c 19 Apr 2006 20:26:55 -0000 @@ -587,13 +587,6 @@ vga_ioctl(v, cmd, data, flag, p) struct proc *p; { struct vga_config *vc = v; -#if NVGA_PCI > 0 - int error; - - if (vc->vc_type == WSDISPLAY_TYPE_PCIVGA && - (error = vga_pci_ioctl(v, cmd, data, flag, p)) != ENOTTY) - return (error); -#endif switch (cmd) { case WSDISPLAYIO_GTYPE: Index: sys/dev/pci/agp.c =================================================================== RCS file: /cvs/src/sys/dev/pci/agp.c,v retrieving revision 1.1 diff -u -d -p -r1.1 agp.c --- sys/dev/pci/agp.c 16 Mar 2006 21:32:34 -0000 1.1 +++ sys/dev/pci/agp.c 19 Apr 2006 20:26:55 -0000 @@ -45,23 +45,60 @@ #include #include -struct agp_memory *agp_find_memory(struct vga_pci_softc *sc, int id); -const struct agp_product *agp_lookup(struct pci_attach_args *pa); +#ifdef APERTURE +extern int allowaperture; +#endif + +int agp_match(struct device *, void *, void *); +void agp_attach(struct device *, struct device *, void *); + +struct cfattach agp_ca = { + sizeof(struct agp_softc), agp_match, agp_attach, +}; + +struct cfdriver agp_cd = { + NULL, "agp", DV_DULL +}; + +int agpopen(dev_t, int, int, struct proc *); +int agpclose(dev_t, int, int, struct proc *); +int agpioctl(dev_t, u_long, caddr_t, int, struct proc *); +paddr_t agpmmap(dev_t, off_t, int); + +void agp_cleanup(struct agp_softc *); +struct agp_memory *agp_find_memory(struct agp_softc *, int); +const struct agp_product *agp_lookup(struct pci_attach_args *); struct pci_attach_args agp_pchb_pa; int agp_pchb_pa_set = 0; +int agp_open_count = 0; + +int +agp_match(struct device *parent, void *match, void *aux) +{ + struct pci_attach_args *pa = aux; + + if (!agp_pchb_pa_set) + return (0); + agp_pchb_pa_set = 0; + + if (agp_lookup(pa) == NULL) + return (0); + + return (1); +} void agp_attach(struct device *parent, struct device *self, void *aux) { struct pci_attach_args *pa = aux; - struct vga_pci_softc *sc = (struct vga_pci_softc *)self; + struct agp_softc *sc = (struct agp_softc *)self; const struct agp_product *ap; u_int memsize; int i, ret; ap = agp_lookup(pa); - if (ap) { + if (ap != NULL) { static const int agp_max[][2] = { {0, 0}, {32, 4}, @@ -113,30 +150,66 @@ agp_attach(struct device *parent, struct sc->sc_chipc = NULL; printf(": AGP GART"); } + } else { + sc->sc_chipc = NULL; + printf("\nagp_attach: impossible"); } } +int +agpopen(dev_t dev, int flag, int fmt, struct proc *p) +{ + struct agp_softc *sc; + + if (agp_cd.cd_ndevs == 0 || minor(dev) != 0 || + (sc = agp_cd.cd_devs[minor(dev)]) == NULL || + sc->sc_chipc == NULL) + return (ENXIO); + +#ifndef APERTURE + if ((flag & FWRITE) != 0 && securelevel > 0) + return (EPERM); +#else + if ((flag & FWRITE) != 0 && securelevel > 0 && allowaperture == 0) + return (EPERM); +#endif + if (agp_open_count > 0) + return (EBUSY); + agp_open_count++; + + return (0); +} + +int +agpclose(dev_t dev, int flag, int fmt, struct proc *p) +{ + struct agp_softc *sc = agp_cd.cd_devs[minor(dev)]; + + if (sc->sc_state == AGP_ACQUIRE_USER) + agp_cleanup(sc); + agp_open_count--; + + return (0); +} + paddr_t -agp_mmap(void *v, off_t off, int prot) +agpmmap(dev_t dev, off_t off, int prot) { - struct vga_config* vs = (struct vga_config*) v; - struct vga_pci_softc* sc = (struct vga_pci_softc *)vs->vc_softc; + struct agp_softc *sc = agp_cd.cd_devs[minor(dev)]; - if (sc->sc_apaddr) { + if (sc->sc_apaddr == 0) + return (-1); - if (off > AGP_GET_APERTURE(sc)) - return (-1); + if (off < 0 || off > AGP_GET_APERTURE(sc)) + return (-1); - return atop(sc->sc_apaddr + off); - } - return -1; + return (atop(sc->sc_apaddr + off)); } int -agp_ioctl(void *v, u_long cmd, caddr_t addr, int flag, struct proc *pb) +agpioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) { - struct vga_config *vc = v; - struct vga_pci_softc *sc = (struct vga_pci_softc *)vc->vc_softc; + struct agp_softc *sc = agp_cd.cd_devs[minor(dev)]; struct agp_memory *mem; agp_info *info; agp_setup *setup; @@ -194,18 +267,7 @@ agp_ioctl(void *v, u_long cmd, caddr_t a break; } - /* - * Clear out the aperture and free any - * outstanding memory blocks. - */ - TAILQ_FOREACH(mem, &sc->sc_memory, am_link) { - if (mem->am_is_bound) { - printf("agp_release_helper: mem %d is bound\n", - mem->am_id); - AGP_UNBIND_MEMORY(sc, mem); - } - } - sc->sc_state = AGP_ACQUIRE_FREE; + agp_cleanup(sc); break; case AGPIOC_SETUP: @@ -261,12 +323,9 @@ agp_ioctl(void *v, u_long cmd, caddr_t a return (error); } -#ifdef notyet void -agp_close(void *v) +agp_cleanup(struct agp_softc *sc) { - struct vga_config *vc = v; - struct vga_pci_softc *sc = (struct vga_pci_softc *)vc->vc_softc; struct agp_memory *mem; /* @@ -286,10 +345,9 @@ agp_close(void *v) sc->sc_state = AGP_ACQUIRE_FREE; } -#endif struct agp_memory * -agp_find_memory(struct vga_pci_softc *sc, int id) +agp_find_memory(struct agp_softc *sc, int id) { struct agp_memory *mem; @@ -307,10 +365,6 @@ agp_lookup(struct pci_attach_args *pa) { const struct agp_product *ap; - if (!agp_pchb_pa_set) - return (NULL); - agp_pchb_pa_set = 0; - /* First find the vendor. */ for (ap = agp_products; ap->ap_attach != NULL; ap++) if (ap->ap_vendor == PCI_VENDOR(pa->pa_id)) @@ -347,7 +401,7 @@ pciagp_set_pchb(struct pci_attach_args * } int -agp_map_aperture(struct vga_pci_softc *sc) +agp_map_aperture(struct agp_softc *sc) { /* * Find and the aperture. Don't map it (yet), this would @@ -362,7 +416,7 @@ agp_map_aperture(struct vga_pci_softc *s } struct agp_gatt * -agp_alloc_gatt(struct vga_pci_softc *sc) +agp_alloc_gatt(struct agp_softc *sc) { u_int32_t apsize = AGP_GET_APERTURE(sc); u_int32_t entries = apsize >> AGP_PAGE_SHIFT; @@ -388,7 +442,7 @@ agp_alloc_gatt(struct vga_pci_softc *sc) } void -agp_free_gatt(struct vga_pci_softc *sc, struct agp_gatt *gatt) +agp_free_gatt(struct agp_softc *sc, struct agp_gatt *gatt) { agp_free_dmamem(sc->sc_dmat, gatt->ag_size, gatt->ag_dmamap, (caddr_t)gatt->ag_virtual, &gatt->ag_dmaseg, 1); @@ -396,7 +450,7 @@ agp_free_gatt(struct vga_pci_softc *sc, } int -agp_generic_detach(struct vga_pci_softc *sc) +agp_generic_detach(struct agp_softc *sc) { lockmgr(&sc->sc_lock, LK_DRAIN, NULL); agp_flush_cache(); @@ -404,7 +458,7 @@ agp_generic_detach(struct vga_pci_softc } int -agp_generic_enable(struct vga_pci_softc *sc, u_int32_t mode) +agp_generic_enable(struct agp_softc *sc, u_int32_t mode) { pcireg_t tstatus, mstatus; pcireg_t command; @@ -462,7 +516,7 @@ agp_generic_enable(struct vga_pci_softc } struct agp_memory * -agp_generic_alloc_memory(struct vga_pci_softc *sc, int type, vsize_t size) +agp_generic_alloc_memory(struct agp_softc *sc, int type, vsize_t size) { struct agp_memory *mem; @@ -494,7 +548,7 @@ agp_generic_alloc_memory(struct vga_pci_ } int -agp_generic_free_memory(struct vga_pci_softc *sc, struct agp_memory *mem) +agp_generic_free_memory(struct agp_softc *sc, struct agp_memory *mem) { if (mem->am_is_bound) return EBUSY; @@ -507,7 +561,7 @@ agp_generic_free_memory(struct vga_pci_s } int -agp_generic_bind_memory(struct vga_pci_softc *sc, struct agp_memory *mem, +agp_generic_bind_memory(struct agp_softc *sc, struct agp_memory *mem, off_t offset) { bus_dma_segment_t *segs, *seg; @@ -646,7 +700,7 @@ agp_generic_bind_memory(struct vga_pci_s } int -agp_generic_unbind_memory(struct vga_pci_softc *sc, struct agp_memory *mem) +agp_generic_unbind_memory(struct agp_softc *sc, struct agp_memory *mem) { int i; Index: sys/dev/pci/agp_ali.c =================================================================== RCS file: /cvs/src/sys/dev/pci/agp_ali.c,v retrieving revision 1.2 diff -u -d -p -r1.2 agp_ali.c --- sys/dev/pci/agp_ali.c 25 Jul 2002 23:31:04 -0000 1.2 +++ sys/dev/pci/agp_ali.c 19 Apr 2006 20:26:55 -0000 @@ -44,7 +44,6 @@ #include #include -#include #include #include @@ -55,11 +54,11 @@ struct agp_ali_softc { struct agp_gatt *gatt; }; -u_int32_t agp_ali_get_aperture(struct vga_pci_softc *); -int agp_ali_set_aperture(struct vga_pci_softc *sc, u_int32_t); -int agp_ali_bind_page(struct vga_pci_softc *, off_t, bus_addr_t); -int agp_ali_unbind_page(struct vga_pci_softc *, off_t); -void agp_ali_flush_tlb(struct vga_pci_softc *); +u_int32_t agp_ali_get_aperture(struct agp_softc *); +int agp_ali_set_aperture(struct agp_softc *sc, u_int32_t); +int agp_ali_bind_page(struct agp_softc *, off_t, bus_addr_t); +int agp_ali_unbind_page(struct agp_softc *, off_t); +void agp_ali_flush_tlb(struct agp_softc *); struct agp_methods agp_ali_methods = { agp_ali_get_aperture, @@ -75,7 +74,7 @@ struct agp_methods agp_ali_methods = { }; int -agp_ali_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, +agp_ali_attach(struct agp_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *pchb_pa) { struct agp_ali_softc *asc; @@ -130,7 +129,7 @@ agp_ali_attach(struct vga_pci_softc *sc, #if 0 int -agp_ali_detach(struct vga_pci_softc *sc) +agp_ali_detach(struct agp_softc *sc) { int error; pcireg_t reg; @@ -175,7 +174,7 @@ static const u_int32_t agp_ali_table[] = #define agp_ali_table_size (sizeof(agp_ali_table) / sizeof(agp_ali_table[0])) u_int32_t -agp_ali_get_aperture(struct vga_pci_softc *sc) +agp_ali_get_aperture(struct agp_softc *sc) { int i; @@ -191,7 +190,7 @@ agp_ali_get_aperture(struct vga_pci_soft } int -agp_ali_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) +agp_ali_set_aperture(struct agp_softc *sc, u_int32_t aperture) { int i; pcireg_t reg; @@ -210,7 +209,7 @@ agp_ali_set_aperture(struct vga_pci_soft } int -agp_ali_bind_page(struct vga_pci_softc *sc, off_t offset, bus_addr_t physical) +agp_ali_bind_page(struct agp_softc *sc, off_t offset, bus_addr_t physical) { struct agp_ali_softc *asc = sc->sc_chipc; @@ -222,7 +221,7 @@ agp_ali_bind_page(struct vga_pci_softc * } int -agp_ali_unbind_page(struct vga_pci_softc *sc, off_t offset) +agp_ali_unbind_page(struct agp_softc *sc, off_t offset) { struct agp_ali_softc *asc = sc->sc_chipc; @@ -234,7 +233,7 @@ agp_ali_unbind_page(struct vga_pci_softc } void -agp_ali_flush_tlb(struct vga_pci_softc *sc) +agp_ali_flush_tlb(struct agp_softc *sc) { pcireg_t reg; Index: sys/dev/pci/agp_amd.c =================================================================== RCS file: /cvs/src/sys/dev/pci/agp_amd.c,v retrieving revision 1.2 diff -u -d -p -r1.2 agp_amd.c --- sys/dev/pci/agp_amd.c 25 Jul 2002 23:31:04 -0000 1.2 +++ sys/dev/pci/agp_amd.c 19 Apr 2006 20:26:55 -0000 @@ -44,7 +44,6 @@ #include #include -#include #include #include @@ -74,11 +73,11 @@ struct agp_amd_softc { bus_space_tag_t iot; }; -static u_int32_t agp_amd_get_aperture(struct vga_pci_softc *); -static int agp_amd_set_aperture(struct vga_pci_softc *, u_int32_t); -static int agp_amd_bind_page(struct vga_pci_softc *, off_t, bus_addr_t); -static int agp_amd_unbind_page(struct vga_pci_softc *, off_t); -static void agp_amd_flush_tlb(struct vga_pci_softc *); +static u_int32_t agp_amd_get_aperture(struct agp_softc *); +static int agp_amd_set_aperture(struct agp_softc *, u_int32_t); +static int agp_amd_bind_page(struct agp_softc *, off_t, bus_addr_t); +static int agp_amd_unbind_page(struct agp_softc *, off_t); +static void agp_amd_flush_tlb(struct agp_softc *); struct agp_methods agp_amd_methods = { @@ -96,7 +95,7 @@ struct agp_methods agp_amd_methods = { static struct agp_amd_gatt * -agp_amd_alloc_gatt(struct vga_pci_softc *sc) +agp_amd_alloc_gatt(struct agp_softc *sc) { u_int32_t apsize = AGP_GET_APERTURE(sc); u_int32_t entries = apsize >> AGP_PAGE_SHIFT; @@ -145,7 +144,7 @@ agp_amd_alloc_gatt(struct vga_pci_softc #if 0 static void -agp_amd_free_gatt(struct vga_pci_softc *sc, struct agp_amd_gatt *gatt) +agp_amd_free_gatt(struct agp_softc *sc, struct agp_amd_gatt *gatt) { agp_free_dmamem(sc->sc_dmat, gatt->ag_size, gatt->ag_dmamap, (caddr_t)gatt->ag_virtual, &gatt->ag_dmaseg, @@ -155,7 +154,7 @@ agp_amd_free_gatt(struct vga_pci_softc * #endif int -agp_amd_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *pchb_pa) +agp_amd_attach(struct agp_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *pchb_pa) { struct agp_amd_softc *asc; struct agp_amd_gatt *gatt; @@ -222,7 +221,7 @@ agp_amd_attach(struct vga_pci_softc *sc, #if 0 static int -agp_amd_detach(struct vga_pci_softc *sc) +agp_amd_detach(struct agp_softc *sc) { pcireg_t reg; struct agp_amd_softc *asc = sc->sc_chipc; @@ -251,7 +250,7 @@ agp_amd_detach(struct vga_pci_softc *sc) #endif static u_int32_t -agp_amd_get_aperture(struct vga_pci_softc *sc) +agp_amd_get_aperture(struct agp_softc *sc) { int vas; @@ -265,7 +264,7 @@ agp_amd_get_aperture(struct vga_pci_soft } static int -agp_amd_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) +agp_amd_set_aperture(struct agp_softc *sc, u_int32_t aperture) { int vas; pcireg_t reg; @@ -289,7 +288,7 @@ agp_amd_set_aperture(struct vga_pci_soft } static int -agp_amd_bind_page(struct vga_pci_softc *sc, off_t offset, bus_addr_t physical) +agp_amd_bind_page(struct agp_softc *sc, off_t offset, bus_addr_t physical) { struct agp_amd_softc *asc = sc->sc_chipc; @@ -301,7 +300,7 @@ agp_amd_bind_page(struct vga_pci_softc * } static int -agp_amd_unbind_page(struct vga_pci_softc *sc, off_t offset) +agp_amd_unbind_page(struct agp_softc *sc, off_t offset) { struct agp_amd_softc *asc = sc->sc_chipc; @@ -313,7 +312,7 @@ agp_amd_unbind_page(struct vga_pci_softc } static void -agp_amd_flush_tlb(struct vga_pci_softc *sc) +agp_amd_flush_tlb(struct agp_softc *sc) { struct agp_amd_softc *asc = sc->sc_chipc; Index: sys/dev/pci/agp_i810.c =================================================================== RCS file: /cvs/src/sys/dev/pci/agp_i810.c,v retrieving revision 1.12 diff -u -d -p -r1.12 agp_i810.c --- sys/dev/pci/agp_i810.c 16 Feb 2006 19:40:43 -0000 1.12 +++ sys/dev/pci/agp_i810.c 19 Apr 2006 20:26:55 -0000 @@ -46,7 +46,6 @@ #include #include #include -#include #include @@ -83,18 +82,18 @@ struct agp_i810_softc { struct pci_attach_args bridge_pa; }; -u_int32_t agp_i810_get_aperture(struct vga_pci_softc *); -int agp_i810_set_aperture(struct vga_pci_softc *, u_int32_t); -int agp_i810_bind_page(struct vga_pci_softc *, off_t, bus_addr_t); -int agp_i810_unbind_page(struct vga_pci_softc *, off_t); -void agp_i810_flush_tlb(struct vga_pci_softc *); -int agp_i810_enable(struct vga_pci_softc *, u_int32_t mode); +u_int32_t agp_i810_get_aperture(struct agp_softc *); +int agp_i810_set_aperture(struct agp_softc *, u_int32_t); +int agp_i810_bind_page(struct agp_softc *, off_t, bus_addr_t); +int agp_i810_unbind_page(struct agp_softc *, off_t); +void agp_i810_flush_tlb(struct agp_softc *); +int agp_i810_enable(struct agp_softc *, u_int32_t mode); struct agp_memory * - agp_i810_alloc_memory(struct vga_pci_softc *, int, vsize_t); -int agp_i810_free_memory(struct vga_pci_softc *, struct agp_memory *); -int agp_i810_bind_memory(struct vga_pci_softc *, struct agp_memory *, + agp_i810_alloc_memory(struct agp_softc *, int, vsize_t); +int agp_i810_free_memory(struct agp_softc *, struct agp_memory *); +int agp_i810_bind_memory(struct agp_softc *, struct agp_memory *, off_t); -int agp_i810_unbind_memory(struct vga_pci_softc *, struct agp_memory *); +int agp_i810_unbind_memory(struct agp_softc *, struct agp_memory *); struct agp_methods agp_i810_methods = { agp_i810_get_aperture, @@ -110,7 +109,7 @@ struct agp_methods agp_i810_methods = { }; int -agp_i810_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, +agp_i810_attach(struct agp_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *pchb_pa) { struct agp_i810_softc *isc; @@ -350,7 +349,7 @@ agp_i810_attach(struct vga_pci_softc *sc } u_int32_t -agp_i810_get_aperture(struct vga_pci_softc *sc) +agp_i810_get_aperture(struct agp_softc *sc) { struct agp_i810_softc *isc = sc->sc_chipc; pcireg_t reg; @@ -390,7 +389,7 @@ agp_i810_get_aperture(struct vga_pci_sof } int -agp_i810_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) +agp_i810_set_aperture(struct agp_softc *sc, u_int32_t aperture) { struct agp_i810_softc *isc = sc->sc_chipc; pcireg_t reg; @@ -467,7 +466,7 @@ agp_i810_set_aperture(struct vga_pci_sof } int -agp_i810_bind_page(struct vga_pci_softc *sc, off_t offset, bus_addr_t physical) +agp_i810_bind_page(struct agp_softc *sc, off_t offset, bus_addr_t physical) { struct agp_i810_softc *isc = sc->sc_chipc; @@ -494,7 +493,7 @@ agp_i810_bind_page(struct vga_pci_softc } int -agp_i810_unbind_page(struct vga_pci_softc *sc, off_t offset) +agp_i810_unbind_page(struct agp_softc *sc, off_t offset) { struct agp_i810_softc *isc = sc->sc_chipc; @@ -518,18 +517,18 @@ agp_i810_unbind_page(struct vga_pci_soft * Writing via memory mapped registers already flushes all TLBs. */ void -agp_i810_flush_tlb(struct vga_pci_softc *sc) +agp_i810_flush_tlb(struct agp_softc *sc) { } int -agp_i810_enable(struct vga_pci_softc *sc, u_int32_t mode) +agp_i810_enable(struct agp_softc *sc, u_int32_t mode) { return (0); } struct agp_memory * -agp_i810_alloc_memory(struct vga_pci_softc *sc, int type, vsize_t size) +agp_i810_alloc_memory(struct agp_softc *sc, int type, vsize_t size) { struct agp_i810_softc *isc = sc->sc_chipc; struct agp_memory *mem; @@ -601,7 +600,7 @@ agp_i810_alloc_memory(struct vga_pci_sof } int -agp_i810_free_memory(struct vga_pci_softc *sc, struct agp_memory *mem) +agp_i810_free_memory(struct agp_softc *sc, struct agp_memory *mem) { if (mem->am_is_bound) return (EBUSY); @@ -619,7 +618,7 @@ agp_i810_free_memory(struct vga_pci_soft } int -agp_i810_bind_memory(struct vga_pci_softc *sc, struct agp_memory *mem, +agp_i810_bind_memory(struct agp_softc *sc, struct agp_memory *mem, off_t offset) { struct agp_i810_softc *isc = sc->sc_chipc; @@ -665,7 +664,7 @@ agp_i810_bind_memory(struct vga_pci_soft } int -agp_i810_unbind_memory(struct vga_pci_softc *sc, struct agp_memory *mem) +agp_i810_unbind_memory(struct agp_softc *sc, struct agp_memory *mem) { struct agp_i810_softc *isc = sc->sc_chipc; u_int32_t i; Index: sys/dev/pci/agp_intel.c =================================================================== RCS file: /cvs/src/sys/dev/pci/agp_intel.c,v retrieving revision 1.3 diff -u -d -p -r1.3 agp_intel.c --- sys/dev/pci/agp_intel.c 1 Oct 2004 04:08:46 -0000 1.3 +++ sys/dev/pci/agp_intel.c 19 Apr 2006 20:26:55 -0000 @@ -43,7 +43,6 @@ #include #include -#include #include #include @@ -55,11 +54,11 @@ struct agp_intel_softc { }; -static u_int32_t agp_intel_get_aperture(struct vga_pci_softc *); -static int agp_intel_set_aperture(struct vga_pci_softc *, u_int32_t); -static int agp_intel_bind_page(struct vga_pci_softc *, off_t, bus_addr_t); -static int agp_intel_unbind_page(struct vga_pci_softc *, off_t); -static void agp_intel_flush_tlb(struct vga_pci_softc *); +static u_int32_t agp_intel_get_aperture(struct agp_softc *); +static int agp_intel_set_aperture(struct agp_softc *, u_int32_t); +static int agp_intel_bind_page(struct agp_softc *, off_t, bus_addr_t); +static int agp_intel_unbind_page(struct agp_softc *, off_t); +static void agp_intel_flush_tlb(struct agp_softc *); struct agp_methods agp_intel_methods = { agp_intel_get_aperture, @@ -75,7 +74,7 @@ struct agp_methods agp_intel_methods = { }; int -agp_intel_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, +agp_intel_attach(struct agp_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *pchb_pa) { struct agp_intel_softc *isc; @@ -140,7 +139,7 @@ agp_intel_attach(struct vga_pci_softc *s #if 0 static int -agp_intel_detach(struct vga_pci_softc *sc) +agp_intel_detach(struct agp_softc *sc) { int error; pcireg_t reg; @@ -163,7 +162,7 @@ agp_intel_detach(struct vga_pci_softc *s #endif static u_int32_t -agp_intel_get_aperture(struct vga_pci_softc *sc) +agp_intel_get_aperture(struct agp_softc *sc) { u_int32_t apsize; @@ -181,7 +180,7 @@ agp_intel_get_aperture(struct vga_pci_so } static int -agp_intel_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) +agp_intel_set_aperture(struct agp_softc *sc, u_int32_t aperture) { u_int32_t apsize; pcireg_t reg; @@ -205,7 +204,7 @@ agp_intel_set_aperture(struct vga_pci_so } static int -agp_intel_bind_page(struct vga_pci_softc *sc, off_t offset, bus_addr_t physical) +agp_intel_bind_page(struct agp_softc *sc, off_t offset, bus_addr_t physical) { struct agp_intel_softc *isc = sc->sc_chipc; @@ -217,7 +216,7 @@ agp_intel_bind_page(struct vga_pci_softc } static int -agp_intel_unbind_page(struct vga_pci_softc *sc, off_t offset) +agp_intel_unbind_page(struct agp_softc *sc, off_t offset) { struct agp_intel_softc *isc = sc->sc_chipc; @@ -229,7 +228,7 @@ agp_intel_unbind_page(struct vga_pci_sof } static void -agp_intel_flush_tlb(struct vga_pci_softc *sc) +agp_intel_flush_tlb(struct agp_softc *sc) { pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_AGPCTRL, 0x2200); pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_AGPCTRL, 0x2280); Index: sys/dev/pci/agp_sis.c =================================================================== RCS file: /cvs/src/sys/dev/pci/agp_sis.c,v retrieving revision 1.2 diff -u -d -p -r1.2 agp_sis.c --- sys/dev/pci/agp_sis.c 25 Jul 2002 23:31:04 -0000 1.2 +++ sys/dev/pci/agp_sis.c 19 Apr 2006 20:26:55 -0000 @@ -42,7 +42,6 @@ #include #include -#include #include #include @@ -53,11 +52,11 @@ struct agp_sis_softc { struct agp_gatt *gatt; }; -static u_int32_t agp_sis_get_aperture(struct vga_pci_softc *); -static int agp_sis_set_aperture(struct vga_pci_softc *, u_int32_t); -static int agp_sis_bind_page(struct vga_pci_softc *, off_t, bus_addr_t); -static int agp_sis_unbind_page(struct vga_pci_softc *, off_t); -static void agp_sis_flush_tlb(struct vga_pci_softc *); +static u_int32_t agp_sis_get_aperture(struct agp_softc *); +static int agp_sis_set_aperture(struct agp_softc *, u_int32_t); +static int agp_sis_bind_page(struct agp_softc *, off_t, bus_addr_t); +static int agp_sis_unbind_page(struct agp_softc *, off_t); +static void agp_sis_flush_tlb(struct agp_softc *); struct agp_methods agp_sis_methods = { agp_sis_get_aperture, @@ -74,7 +73,7 @@ struct agp_methods agp_sis_methods = { int -agp_sis_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, +agp_sis_attach(struct agp_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *pchb_pa) { struct agp_sis_softc *ssc; @@ -128,7 +127,7 @@ agp_sis_attach(struct vga_pci_softc *sc, #if 0 static int -agp_sis_detach(struct vga_pci_softc *sc) +agp_sis_detach(struct agp_softc *sc) { struct agp_sis_softc *ssc = sc->sc_chipc; pcireg_t reg; @@ -152,7 +151,7 @@ agp_sis_detach(struct vga_pci_softc *sc) #endif static u_int32_t -agp_sis_get_aperture(struct vga_pci_softc *sc) +agp_sis_get_aperture(struct agp_softc *sc) { int gws; @@ -165,7 +164,7 @@ agp_sis_get_aperture(struct vga_pci_soft } static int -agp_sis_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) +agp_sis_set_aperture(struct agp_softc *sc, u_int32_t aperture) { int gws; pcireg_t reg; @@ -190,7 +189,7 @@ agp_sis_set_aperture(struct vga_pci_soft } static int -agp_sis_bind_page(struct vga_pci_softc *sc, off_t offset, bus_addr_t physical) +agp_sis_bind_page(struct agp_softc *sc, off_t offset, bus_addr_t physical) { struct agp_sis_softc *ssc = sc->sc_chipc; @@ -202,7 +201,7 @@ agp_sis_bind_page(struct vga_pci_softc * } static int -agp_sis_unbind_page(struct vga_pci_softc *sc, off_t offset) +agp_sis_unbind_page(struct agp_softc *sc, off_t offset) { struct agp_sis_softc *ssc = sc->sc_chipc; @@ -214,7 +213,7 @@ agp_sis_unbind_page(struct vga_pci_softc } static void -agp_sis_flush_tlb(struct vga_pci_softc *sc) +agp_sis_flush_tlb(struct agp_softc *sc) { pcireg_t reg; Index: sys/dev/pci/agp_via.c =================================================================== RCS file: /cvs/src/sys/dev/pci/agp_via.c,v retrieving revision 1.2 diff -u -d -p -r1.2 agp_via.c --- sys/dev/pci/agp_via.c 25 Jul 2002 23:31:04 -0000 1.2 +++ sys/dev/pci/agp_via.c 19 Apr 2006 20:26:55 -0000 @@ -42,17 +42,16 @@ #include #include -#include #include #include #include -static u_int32_t agp_via_get_aperture(struct vga_pci_softc *); -static int agp_via_set_aperture(struct vga_pci_softc *, u_int32_t); -static int agp_via_bind_page(struct vga_pci_softc *, off_t, bus_addr_t); -static int agp_via_unbind_page(struct vga_pci_softc *, off_t); -static void agp_via_flush_tlb(struct vga_pci_softc *); +static u_int32_t agp_via_get_aperture(struct agp_softc *); +static int agp_via_set_aperture(struct agp_softc *, u_int32_t); +static int agp_via_bind_page(struct agp_softc *, off_t, bus_addr_t); +static int agp_via_unbind_page(struct agp_softc *, off_t); +static void agp_via_flush_tlb(struct agp_softc *); struct agp_methods agp_via_methods = { agp_via_get_aperture, @@ -74,7 +73,7 @@ struct agp_via_softc { int -agp_via_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, +agp_via_attach(struct agp_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *pchb_pa) { struct agp_via_softc *asc; @@ -126,7 +125,7 @@ agp_via_attach(struct vga_pci_softc *sc, #if 0 static int -agp_via_detach(struct vga_pci_softc *sc) +agp_via_detach(struct agp_softc *sc) { struct agp_via_softc *asc = sc->sc_chipc; int error; @@ -145,7 +144,7 @@ agp_via_detach(struct vga_pci_softc *sc) #endif static u_int32_t -agp_via_get_aperture(struct vga_pci_softc *sc) +agp_via_get_aperture(struct agp_softc *sc) { u_int32_t apsize; @@ -163,7 +162,7 @@ agp_via_get_aperture(struct vga_pci_soft } static int -agp_via_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) +agp_via_set_aperture(struct agp_softc *sc, u_int32_t aperture) { u_int32_t apsize; pcireg_t reg; @@ -188,7 +187,7 @@ agp_via_set_aperture(struct vga_pci_soft } static int -agp_via_bind_page(struct vga_pci_softc *sc, off_t offset, bus_addr_t physical) +agp_via_bind_page(struct agp_softc *sc, off_t offset, bus_addr_t physical) { struct agp_via_softc *asc = sc->sc_chipc; @@ -200,7 +199,7 @@ agp_via_bind_page(struct vga_pci_softc * } static int -agp_via_unbind_page(struct vga_pci_softc *sc, off_t offset) +agp_via_unbind_page(struct agp_softc *sc, off_t offset) { struct agp_via_softc *asc = sc->sc_chipc; @@ -212,7 +211,7 @@ agp_via_unbind_page(struct vga_pci_softc } static void -agp_via_flush_tlb(struct vga_pci_softc *sc) +agp_via_flush_tlb(struct agp_softc *sc) { pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_VIA_GARTCTRL, 0x8f); pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_VIA_GARTCTRL, 0x0f); Index: sys/dev/pci/agpvar.h =================================================================== RCS file: /cvs/src/sys/dev/pci/agpvar.h,v retrieving revision 1.4 diff -u -d -p -r1.4 agpvar.h --- sys/dev/pci/agpvar.h 10 Mar 2006 21:52:02 -0000 1.4 +++ sys/dev/pci/agpvar.h 19 Apr 2006 20:27:02 -0000 @@ -33,7 +33,17 @@ #define _PCI_AGPVAR_H_ #include -#include + +/* + * The AGP chipset can be acquired by user or kernel code. If the + * chipset has already been acquired, it cannot be acquired by another + * user until the previous user has released it. + */ +enum agp_acquire_state { + AGP_ACQUIRE_FREE, + AGP_ACQUIRE_USER, + AGP_ACQUIRE_KERNEL +}; /* #define AGP_DEBUG */ #ifdef AGP_DEBUG @@ -47,19 +57,39 @@ #define AGPUNIT(x) minor(x) +/* + * Data structure to describe an AGP memory allocation. + */ +TAILQ_HEAD(agp_memory_list, agp_memory); +struct agp_memory { + TAILQ_ENTRY(agp_memory) am_link; /* wiring for the tailq */ + int am_id; /* unique id for block */ + vsize_t am_size; /* number of bytes allocated */ + int am_type; /* chipset specific type */ + off_t am_offset; /* page offset if bound */ + int am_is_bound; /* non-zero if bound */ + bus_addr_t am_physical; + caddr_t am_virtual; + bus_dmamap_t am_dmamap; + int am_nseg; + bus_dma_segment_t *am_dmaseg; +}; + +struct agp_softc; + struct agp_methods { - u_int32_t (*get_aperture)(struct vga_pci_softc *); - int (*set_aperture)(struct vga_pci_softc *, u_int32_t); - int (*bind_page)(struct vga_pci_softc *, off_t, bus_addr_t); - int (*unbind_page)(struct vga_pci_softc *, off_t); - void (*flush_tlb)(struct vga_pci_softc *); - int (*enable)(struct vga_pci_softc *, u_int32_t mode); + u_int32_t (*get_aperture)(struct agp_softc *); + int (*set_aperture)(struct agp_softc *, u_int32_t); + int (*bind_page)(struct agp_softc *, off_t, bus_addr_t); + int (*unbind_page)(struct agp_softc *, off_t); + void (*flush_tlb)(struct agp_softc *); + int (*enable)(struct agp_softc *, u_int32_t); struct agp_memory * - (*alloc_memory)(struct vga_pci_softc *, int, vsize_t); - int (*free_memory)(struct vga_pci_softc *, struct agp_memory *); - int (*bind_memory)(struct vga_pci_softc *, struct agp_memory *, + (*alloc_memory)(struct agp_softc *, int, vsize_t); + int (*free_memory)(struct agp_softc *, struct agp_memory *); + int (*bind_memory)(struct agp_softc *, struct agp_memory *, off_t); - int (*unbind_memory)(struct vga_pci_softc *, struct agp_memory *); + int (*unbind_memory)(struct agp_softc *, struct agp_memory *); }; #define AGP_GET_APERTURE(sc) ((sc)->sc_methods->get_aperture(sc)) @@ -76,6 +106,33 @@ struct agp_methods { /* * All chipset drivers must have this at the start of their softc. */ +struct agp_softc { + struct device sc_dev; + + bus_space_tag_t sc_bt; + bus_space_tag_t sc_memt; + bus_space_handle_t sc_bh; + bus_addr_t sc_apaddr; + bus_size_t sc_apsize; + bus_dma_tag_t sc_dmat; + struct lock sc_lock; /* lock for access to GATT */ + pcitag_t sc_pcitag; /* PCI tag, in case we need it. */ + pcireg_t sc_id; + pci_chipset_tag_t sc_pc; + + struct agp_methods *sc_methods; + void *sc_chipc; /* chipset-dependent state */ + + int sc_opened; + int sc_capoff; + int sc_apflags; + int sc_nextid; /* next memory block id */ + + u_int32_t sc_maxmem; /* allocation upper bound */ + u_int32_t sc_allocated; /* amount allocated */ + enum agp_acquire_state sc_state; + struct agp_memory_list sc_memory; /* list of allocated memory */ +}; struct agp_gatt { u_int32_t ag_entries; @@ -86,38 +143,47 @@ struct agp_gatt { size_t ag_size; }; +struct agp_product { + int ap_vendor; + int ap_product; + int (*ap_attach)(struct agp_softc *, + struct pci_attach_args *, struct pci_attach_args *); +}; +/* MD-defined */ +extern const struct agp_product agp_products[]; + /* * Functions private to the AGP code. */ int agp_find_caps(pci_chipset_tag_t, pcitag_t); -int agp_map_aperture(struct vga_pci_softc *); +int agp_map_aperture(struct agp_softc *); struct agp_gatt * - agp_alloc_gatt(struct vga_pci_softc *); -void agp_free_gatt(struct vga_pci_softc *, struct agp_gatt *); + agp_alloc_gatt(struct agp_softc *); +void agp_free_gatt(struct agp_softc *, struct agp_gatt *); void agp_flush_cache(void); -int agp_generic_attach(struct vga_pci_softc *); -int agp_generic_detach(struct vga_pci_softc *); -int agp_generic_enable(struct vga_pci_softc *, u_int32_t); +int agp_generic_attach(struct agp_softc *); +int agp_generic_detach(struct agp_softc *); +int agp_generic_enable(struct agp_softc *, u_int32_t); struct agp_memory * - agp_generic_alloc_memory(struct vga_pci_softc *, int, vsize_t size); -int agp_generic_free_memory(struct vga_pci_softc *, struct agp_memory *); -int agp_generic_bind_memory(struct vga_pci_softc *, struct agp_memory *, + agp_generic_alloc_memory(struct agp_softc *, int, vsize_t); +int agp_generic_free_memory(struct agp_softc *, struct agp_memory *); +int agp_generic_bind_memory(struct agp_softc *, struct agp_memory *, off_t); -int agp_generic_unbind_memory(struct vga_pci_softc *, struct agp_memory *); +int agp_generic_unbind_memory(struct agp_softc *, struct agp_memory *); -int agp_ali_attach(struct vga_pci_softc *, struct pci_attach_args *, +int agp_ali_attach(struct agp_softc *, struct pci_attach_args *, struct pci_attach_args *); -int agp_amd_attach(struct vga_pci_softc *, struct pci_attach_args *, +int agp_amd_attach(struct agp_softc *, struct pci_attach_args *, struct pci_attach_args *); -int agp_i810_attach(struct vga_pci_softc *, struct pci_attach_args *, +int agp_i810_attach(struct agp_softc *, struct pci_attach_args *, struct pci_attach_args *); -int agp_intel_attach(struct vga_pci_softc *, struct pci_attach_args *, +int agp_intel_attach(struct agp_softc *, struct pci_attach_args *, struct pci_attach_args *); -int agp_via_attach(struct vga_pci_softc *, struct pci_attach_args *, +int agp_via_attach(struct agp_softc *, struct pci_attach_args *, struct pci_attach_args *); -int agp_sis_attach(struct vga_pci_softc *, struct pci_attach_args *, +int agp_sis_attach(struct agp_softc *, struct pci_attach_args *, struct pci_attach_args *); int agp_alloc_dmamem(bus_dma_tag_t, size_t, int, bus_dmamap_t *, Index: sys/dev/pci/files.pci =================================================================== RCS file: /cvs/src/sys/dev/pci/files.pci,v retrieving revision 1.202 diff -u -d -p -r1.202 files.pci --- sys/dev/pci/files.pci 6 Apr 2006 20:25:14 -0000 1.202 +++ sys/dev/pci/files.pci 19 Apr 2006 20:27:02 -0000 @@ -15,7 +15,11 @@ file dev/pci/pci_subr.c pci # Generic VGA attach vga at pci with vga_pci file dev/pci/vga_pci.c vga_pci -file dev/pci/agp.c vga_pci & pciagp + +# AGP +device agp +attach agp at agpbus +file dev/pci/agp.c agp needs-flag device tga: wsemuldisplaydev, rasops8, rasops32 attach tga at pci Index: sys/dev/pci/vga_pci.c =================================================================== RCS file: /cvs/src/sys/dev/pci/vga_pci.c,v retrieving revision 1.23 diff -u -d -p -r1.23 vga_pci.c --- sys/dev/pci/vga_pci.c 16 Mar 2006 21:32:34 -0000 1.23 +++ sys/dev/pci/vga_pci.c 19 Apr 2006 20:27:02 -0000 @@ -69,7 +69,6 @@ #include #include #include -#include #include @@ -89,9 +88,21 @@ #include #include +#include "agp.h" +#if NAGP > 0 +#include +#endif + +struct vga_pci_softc { + struct device sc_dev; + +#if 0 + struct vga_config *sc_vc; /* VGA configuration */ +#endif +}; + int vga_pci_match(struct device *, void *, void *); void vga_pci_attach(struct device *, struct device *, void *); -paddr_t vga_pci_mmap(void* v, off_t off, int prot); struct cfattach vga_pci_ca = { sizeof(struct vga_pci_softc), vga_pci_match, vga_pci_attach, @@ -107,7 +118,7 @@ vga_pci_match(struct device *parent, voi /* * If it's prehistoric/vga or display/vga, we might match. - * For the console device, this is jut a sanity check. + * For the console device, this is just a sanity check. */ if (PCI_CLASS(pa->pa_class) == PCI_CLASS_PREHISTORIC && PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_PREHISTORIC_VGA) @@ -143,62 +154,18 @@ vga_pci_attach(struct device *parent, st { struct pci_attach_args *pa = aux; -#ifdef PCIAGP - agp_attach(parent, self, aux); +#if NAGP > 0 + printf("\n"); + config_found(self, pa, NULL); #endif printf("\n"); vga_common_attach(self, pa->pa_iot, pa->pa_memt, WSDISPLAY_TYPE_PCIVGA); } -paddr_t -vga_pci_mmap(void *v, off_t off, int prot) -{ -#ifdef PCIAGP - return agp_mmap(v, off, prot); -#else - return -1; -#endif -} - int vga_pci_cnattach(bus_space_tag_t iot, bus_space_tag_t memt, pci_chipset_tag_t pc, int bus, int device, int function) { return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_PCIVGA, 0)); } - -int -vga_pci_ioctl(void *v, u_long cmd, caddr_t addr, int flag, struct proc *pb) -{ - int error = 0; - - switch (cmd) { -#ifdef PCIAGP - case AGPIOC_INFO: - case AGPIOC_ACQUIRE: - case AGPIOC_RELEASE: - case AGPIOC_SETUP: - case AGPIOC_ALLOCATE: - case AGPIOC_DEALLOCATE: - case AGPIOC_BIND: - case AGPIOC_UNBIND: - error = agp_ioctl(v, cmd, addr, flag, pb); - break; -#endif - default: - error = ENOTTY; - } - - return (error); -} - -#ifdef notyet -void -vga_pci_close(void *v) -{ -#ifdef PCIAGP - agp_close(v); -#endif -} -#endif Index: sys/dev/pci/vga_pcivar.h =================================================================== RCS file: /cvs/src/sys/dev/pci/vga_pcivar.h,v retrieving revision 1.6 diff -u -d -p -r1.6 vga_pcivar.h --- sys/dev/pci/vga_pcivar.h 16 Mar 2006 21:32:34 -0000 1.6 +++ sys/dev/pci/vga_pcivar.h 19 Apr 2006 20:27:02 -0000 @@ -37,78 +37,6 @@ (PCI_CLASS(class) == PCI_CLASS_PREHISTORIC && \ PCI_SUBCLASS(class) == PCI_SUBCLASS_PREHISTORIC_VGA)) ? 1 : 0) -enum agp_acquire_state { - AGP_ACQUIRE_FREE, - AGP_ACQUIRE_USER, - AGP_ACQUIRE_KERNEL -}; - -/* - * Data structure to describe an AGP memory allocation. - */ -TAILQ_HEAD(agp_memory_list, agp_memory); -struct agp_memory { - TAILQ_ENTRY(agp_memory) am_link; /* wiring for the tailq */ - int am_id; /* unique id for block */ - vsize_t am_size; /* number of bytes allocated */ - int am_type; /* chipset specific type */ - off_t am_offset; /* page offset if bound */ - int am_is_bound; /* non-zero if bound */ - bus_addr_t am_physical; - caddr_t am_virtual; - bus_dmamap_t am_dmamap; - int am_nseg; - bus_dma_segment_t *am_dmaseg; -}; - -struct vga_pci_softc { - struct device sc_dev; - -#if 0 - struct vga_config *sc_vc; /* VGA configuration */ -#endif -#ifdef PCIAGP - /* agp stuff */ - bus_space_tag_t sc_bt, sc_memt; - bus_space_handle_t sc_bh; - bus_addr_t sc_apaddr; - bus_size_t sc_apsize; - bus_dma_tag_t sc_dmat; - struct lock sc_lock; /* lock for access to GATT */ - pcitag_t sc_pcitag; /* PCI tag, in case we need it. */ - pcireg_t sc_id; - pci_chipset_tag_t sc_pc; - - struct agp_methods *sc_methods; - void *sc_chipc; /* chipset-dependent state */ - - int sc_opened; - int sc_capoff; - int sc_apflags; - int sc_nextid; /* next memory block id */ - - u_int32_t sc_maxmem; /* allocation upper bound */ - u_int32_t sc_allocated; /* amount allocated */ - enum agp_acquire_state sc_state; - struct agp_memory_list sc_memory; /* list of allocated memory */ -#endif -}; - -#ifdef PCIAGP -struct agp_product { - int ap_vendor; - int ap_product; - int (*ap_attach)(struct vga_pci_softc *, - struct pci_attach_args *, struct pci_attach_args *); -}; -/* MD-defined */ -extern const struct agp_product agp_products[]; - -void agp_attach(struct device *, struct device *, void *); -paddr_t agp_mmap(void *, off_t, int); -int agp_ioctl(void *, u_long, caddr_t, int, struct proc *); -#endif /* PCIAGP */ - int vga_pci_cnattach(bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t, int, int, int); Index: sys/sys/agpio.h =================================================================== RCS file: /cvs/src/sys/sys/agpio.h,v retrieving revision 1.1 diff -u -d -p -r1.1 agpio.h --- sys/sys/agpio.h 12 Jul 2002 20:17:03 -0000 1.1 +++ sys/sys/agpio.h 19 Apr 2006 20:27:02 -0000 @@ -31,7 +31,7 @@ #ifndef _SYS_AGPIO_H_ #define _SYS_AGPIO_H_ -#define AGP_DEVICE "/dev/ttyC0" +#define AGP_DEVICE "/dev/agp" /* * The AGP gatt uses 4k pages irrespective of the host page size. Index: sys/sys/conf.h =================================================================== RCS file: /cvs/src/sys/sys/conf.h,v retrieving revision 1.78 diff -u -d -p -r1.78 conf.h --- sys/sys/conf.h 31 Dec 2005 21:22:35 -0000 1.78 +++ sys/sys/conf.h 19 Apr 2006 20:27:02 -0000 @@ -475,6 +475,13 @@ void randomattach(void); (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ (dev_type_mmap((*))) enodev } +/* open, close, ioctl, mmap */ +#define cdev_agp_init(c,n) { \ + dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ + (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ + (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + dev_init(c,n,mmap) } + /* symbolic sleep message strings */ extern char devopn[], devio[], devwait[], devin[], devout[]; extern char devioc[], devcls[];