agp.c (209793) | agp.c (214603) |
---|---|
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> | 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 209793 2010-07-08 08:39:02Z kib $"); | 28__FBSDID("$FreeBSD: head/sys/dev/agp/agp.c 214603 2010-10-31 18:27:05Z nwhitehorn $"); |
29 30#include "opt_agp.h" 31#include "opt_bus.h" 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/malloc.h> 36#include <sys/kernel.h> --- 177 unchanged lines hidden (view full) --- 214 struct agp_softc *sc = device_get_softc(dev); 215 int i; 216 u_int memsize; 217 218 /* 219 * Find and map the aperture, RF_SHAREABLE for DRM but not RF_ACTIVE 220 * because the kernel doesn't need to map it. 221 */ | 29 30#include "opt_agp.h" 31#include "opt_bus.h" 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/malloc.h> 36#include <sys/kernel.h> --- 177 unchanged lines hidden (view full) --- 214 struct agp_softc *sc = device_get_softc(dev); 215 int i; 216 u_int memsize; 217 218 /* 219 * Find and map the aperture, RF_SHAREABLE for DRM but not RF_ACTIVE 220 * because the kernel doesn't need to map it. 221 */ |
222 if (sc->as_aperture_rid == 0) 223 sc->as_aperture_rid = AGP_APBASE; | |
224 | 222 |
225 sc->as_aperture = bus_alloc_resource_any(dev, SYS_RES_MEMORY, 226 &sc->as_aperture_rid, RF_SHAREABLE); 227 if (!sc->as_aperture) 228 return ENOMEM; | 223 if (sc->as_aperture_rid != -1) { 224 if (sc->as_aperture_rid == 0) 225 sc->as_aperture_rid = AGP_APBASE; |
229 | 226 |
227 sc->as_aperture = bus_alloc_resource_any(dev, SYS_RES_MEMORY, 228 &sc->as_aperture_rid, RF_SHAREABLE); 229 if (!sc->as_aperture) 230 return ENOMEM; 231 } 232 |
|
230 /* 231 * Work out an upper bound for agp memory allocation. This 232 * uses a heurisitc table from the Linux driver. 233 */ 234 memsize = ptoa(Maxmem) >> 20; 235 for (i = 0; i < agp_max_size; i++) { 236 if (memsize <= agp_max[i][0]) 237 break; --- 29 unchanged lines hidden (view full) --- 267 destroy_dev(sc->as_devnode); 268} 269 270void 271agp_free_res(device_t dev) 272{ 273 struct agp_softc *sc = device_get_softc(dev); 274 | 233 /* 234 * Work out an upper bound for agp memory allocation. This 235 * uses a heurisitc table from the Linux driver. 236 */ 237 memsize = ptoa(Maxmem) >> 20; 238 for (i = 0; i < agp_max_size; i++) { 239 if (memsize <= agp_max[i][0]) 240 break; --- 29 unchanged lines hidden (view full) --- 270 destroy_dev(sc->as_devnode); 271} 272 273void 274agp_free_res(device_t dev) 275{ 276 struct agp_softc *sc = device_get_softc(dev); 277 |
275 bus_release_resource(dev, SYS_RES_MEMORY, sc->as_aperture_rid, 276 sc->as_aperture); | 278 if (sc->as_aperture != NULL) 279 bus_release_resource(dev, SYS_RES_MEMORY, sc->as_aperture_rid, 280 sc->as_aperture); |
277 mtx_destroy(&sc->as_lock); 278 agp_flush_cache(); 279} 280 281int 282agp_generic_detach(device_t dev) 283{ 284 --- 439 unchanged lines hidden (view full) --- 724agp_info_user(device_t dev, agp_info *info) 725{ 726 struct agp_softc *sc = device_get_softc(dev); 727 728 bzero(info, sizeof *info); 729 info->bridge_id = pci_get_devid(dev); 730 info->agp_mode = 731 pci_read_config(dev, agp_find_caps(dev) + AGP_STATUS, 4); | 281 mtx_destroy(&sc->as_lock); 282 agp_flush_cache(); 283} 284 285int 286agp_generic_detach(device_t dev) 287{ 288 --- 439 unchanged lines hidden (view full) --- 728agp_info_user(device_t dev, agp_info *info) 729{ 730 struct agp_softc *sc = device_get_softc(dev); 731 732 bzero(info, sizeof *info); 733 info->bridge_id = pci_get_devid(dev); 734 info->agp_mode = 735 pci_read_config(dev, agp_find_caps(dev) + AGP_STATUS, 4); |
732 info->aper_base = rman_get_start(sc->as_aperture); | 736 if (sc->as_aperture) 737 info->aper_base = rman_get_start(sc->as_aperture); 738 else 739 info->aper_base = 0; |
733 info->aper_size = AGP_GET_APERTURE(dev) >> 20; 734 info->pg_total = info->pg_system = sc->as_maxmem >> AGP_PAGE_SHIFT; 735 info->pg_used = sc->as_allocated >> AGP_PAGE_SHIFT; 736 737 return 0; 738} 739 740static int --- 130 unchanged lines hidden (view full) --- 871agp_mmap(struct cdev *kdev, vm_ooffset_t offset, vm_paddr_t *paddr, 872 int prot, vm_memattr_t *memattr) 873{ 874 device_t dev = kdev->si_drv1; 875 struct agp_softc *sc = device_get_softc(dev); 876 877 if (offset > AGP_GET_APERTURE(dev)) 878 return -1; | 740 info->aper_size = AGP_GET_APERTURE(dev) >> 20; 741 info->pg_total = info->pg_system = sc->as_maxmem >> AGP_PAGE_SHIFT; 742 info->pg_used = sc->as_allocated >> AGP_PAGE_SHIFT; 743 744 return 0; 745} 746 747static int --- 130 unchanged lines hidden (view full) --- 878agp_mmap(struct cdev *kdev, vm_ooffset_t offset, vm_paddr_t *paddr, 879 int prot, vm_memattr_t *memattr) 880{ 881 device_t dev = kdev->si_drv1; 882 struct agp_softc *sc = device_get_softc(dev); 883 884 if (offset > AGP_GET_APERTURE(dev)) 885 return -1; |
886 if (sc->as_aperture == NULL) 887 return -1; |
|
879 *paddr = rman_get_start(sc->as_aperture) + offset; 880 return 0; 881} 882 883/* Implementation of the kernel api */ 884 885device_t 886agp_find_device() --- 25 unchanged lines hidden (view full) --- 912 913void 914agp_get_info(device_t dev, struct agp_info *info) 915{ 916 struct agp_softc *sc = device_get_softc(dev); 917 918 info->ai_mode = 919 pci_read_config(dev, agp_find_caps(dev) + AGP_STATUS, 4); | 888 *paddr = rman_get_start(sc->as_aperture) + offset; 889 return 0; 890} 891 892/* Implementation of the kernel api */ 893 894device_t 895agp_find_device() --- 25 unchanged lines hidden (view full) --- 921 922void 923agp_get_info(device_t dev, struct agp_info *info) 924{ 925 struct agp_softc *sc = device_get_softc(dev); 926 927 info->ai_mode = 928 pci_read_config(dev, agp_find_caps(dev) + AGP_STATUS, 4); |
920 info->ai_aperture_base = rman_get_start(sc->as_aperture); 921 info->ai_aperture_size = rman_get_size(sc->as_aperture); | 929 if (sc->as_aperture != NULL) 930 info->ai_aperture_base = rman_get_start(sc->as_aperture); 931 else 932 info->ai_aperture_base = 0; 933 info->ai_aperture_size = AGP_GET_APERTURE(dev); |
922 info->ai_memory_allowed = sc->as_maxmem; 923 info->ai_memory_used = sc->as_allocated; 924} 925 926int 927agp_acquire(device_t dev) 928{ 929 return agp_acquire_helper(dev, AGP_ACQUIRE_KERNEL); --- 47 unchanged lines hidden --- | 934 info->ai_memory_allowed = sc->as_maxmem; 935 info->ai_memory_used = sc->as_allocated; 936} 937 938int 939agp_acquire(device_t dev) 940{ 941 return agp_acquire_helper(dev, AGP_ACQUIRE_KERNEL); --- 47 unchanged lines hidden --- |