agp.c (163614) | agp.c (171433) |
---|---|
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 163614 2006-10-22 21:18:48Z alc $"); | 28__FBSDID("$FreeBSD: head/sys/dev/agp/agp.c 171433 2007-07-13 16:28:12Z anholt $"); |
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> --- 151 unchanged lines hidden (view full) --- 188 {256, 204}, 189 {512, 440}, 190 {1024, 942}, 191 {2048, 1920}, 192 {4096, 3932} 193}; 194#define agp_max_size (sizeof(agp_max) / sizeof(agp_max[0])) 195 | 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> --- 151 unchanged lines hidden (view full) --- 188 {256, 204}, 189 {512, 440}, 190 {1024, 942}, 191 {2048, 1920}, 192 {4096, 3932} 193}; 194#define agp_max_size (sizeof(agp_max) / sizeof(agp_max[0])) 195 |
196/** 197 * Sets the PCI resource which represents the AGP aperture. 198 * 199 * If not called, the default AGP aperture resource of AGP_APBASE will 200 * be used. Must be called before agp_generic_attach(). 201 */ 202void 203agp_set_aperture_resource(device_t dev, int rid) 204{ 205 struct agp_softc *sc = device_get_softc(dev); 206 207 sc->as_aperture_rid = rid; 208} 209 |
|
196int 197agp_generic_attach(device_t dev) 198{ 199 struct agp_softc *sc = device_get_softc(dev); | 210int 211agp_generic_attach(device_t dev) 212{ 213 struct agp_softc *sc = device_get_softc(dev); |
200 int rid, i; | 214 int i; |
201 u_int memsize; 202 203 /* | 215 u_int memsize; 216 217 /* |
204 * Find and map the aperture. | 218 * Find and map the aperture, RF_SHAREABLE for DRM but not RF_ACTIVE 219 * because the kernel doesn't need to map it. |
205 */ | 220 */ |
206 rid = AGP_APBASE; 207 sc->as_aperture = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, 0); | 221 if (sc->as_aperture_rid == 0) 222 sc->as_aperture_rid = AGP_APBASE; 223 224 sc->as_aperture = bus_alloc_resource_any(dev, SYS_RES_MEMORY, 225 &sc->as_aperture_rid, RF_SHAREABLE); |
208 if (!sc->as_aperture) 209 return ENOMEM; 210 211 /* 212 * Work out an upper bound for agp memory allocation. This 213 * uses a heurisitc table from the Linux driver. 214 */ 215 memsize = ptoa(Maxmem) >> 20; --- 28 unchanged lines hidden (view full) --- 244} 245 246int 247agp_generic_detach(device_t dev) 248{ 249 struct agp_softc *sc = device_get_softc(dev); 250 251 destroy_dev(sc->as_devnode); | 226 if (!sc->as_aperture) 227 return ENOMEM; 228 229 /* 230 * Work out an upper bound for agp memory allocation. This 231 * uses a heurisitc table from the Linux driver. 232 */ 233 memsize = ptoa(Maxmem) >> 20; --- 28 unchanged lines hidden (view full) --- 262} 263 264int 265agp_generic_detach(device_t dev) 266{ 267 struct agp_softc *sc = device_get_softc(dev); 268 269 destroy_dev(sc->as_devnode); |
252 bus_release_resource(dev, SYS_RES_MEMORY, AGP_APBASE, sc->as_aperture); | 270 bus_release_resource(dev, SYS_RES_MEMORY, sc->as_aperture_rid, 271 sc->as_aperture); |
253 mtx_destroy(&sc->as_lock); 254 agp_flush_cache(); 255 return 0; 256} 257 | 272 mtx_destroy(&sc->as_lock); 273 agp_flush_cache(); 274 return 0; 275} 276 |
277/** 278 * Default AGP aperture size detection which simply returns the size of 279 * the aperture's PCI resource. 280 */ 281int 282agp_generic_get_aperture(device_t dev) 283{ 284 struct agp_softc *sc = device_get_softc(dev); 285 286 return rman_get_size(sc->as_aperture); 287} 288 289/** 290 * Default AGP aperture size setting function, which simply doesn't allow 291 * changes to resource size. 292 */ 293int 294agp_generic_set_aperture(device_t dev, u_int32_t aperture) 295{ 296 u_int32_t current_aperture; 297 298 current_aperture = AGP_GET_APERTURE(dev); 299 if (current_aperture != aperture) 300 return EINVAL; 301 else 302 return 0; 303} 304 |
|
258/* 259 * This does the enable logic for v3, with the same topology 260 * restrictions as in place for v2 -- one bus, one device on the bus. 261 */ 262static int 263agp_v3_enable(device_t dev, device_t mdev, u_int32_t mode) 264{ 265 u_int32_t tstatus, mstatus; --- 648 unchanged lines hidden --- | 305/* 306 * This does the enable logic for v3, with the same topology 307 * restrictions as in place for v2 -- one bus, one device on the bus. 308 */ 309static int 310agp_v3_enable(device_t dev, device_t mdev, u_int32_t mode) 311{ 312 u_int32_t tstatus, mstatus; --- 648 unchanged lines hidden --- |