diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-05-10 16:57:45 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-05-10 16:57:45 +0000 |
commit | 6e40785a24faa417986e316f87006eeb096679af (patch) | |
tree | 13a754e8f047f4d6da81fb213bedbbe08c26e273 /sys/dev/pci/agp.c | |
parent | f30690eb1104dea186726aa4ff0270dc60621507 (diff) |
Change agp attach (again) so that the driver passes in the aperture size.
While the aperture size may change during attach, it never changes after
the end of the subdriver attach function, so getting this value with a
function is a waste of time. shrinks things slightly and makes the code
clearer.
Diffstat (limited to 'sys/dev/pci/agp.c')
-rw-r--r-- | sys/dev/pci/agp.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/sys/dev/pci/agp.c b/sys/dev/pci/agp.c index 9d4c7501831..a4359e9a8d4 100644 --- a/sys/dev/pci/agp.c +++ b/sys/dev/pci/agp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp.c,v 1.31 2009/05/10 15:28:45 oga Exp $ */ +/* $OpenBSD: agp.c,v 1.32 2009/05/10 16:57:44 oga Exp $ */ /*- * Copyright (c) 2000 Doug Rabson * All rights reserved. @@ -115,13 +115,14 @@ agpvga_match(struct pci_attach_args *pa) struct device * agp_attach_bus(struct pci_attach_args *pa, const struct agp_methods *methods, - bus_addr_t apaddr, struct device *dev) + bus_addr_t apaddr, bus_size_t apsize, struct device *dev) { struct agpbus_attach_args arg; arg.aa_methods = methods; arg.aa_pa = pa; arg.aa_apaddr = apaddr; + arg.aa_apsize = apsize; printf("\n"); /* newline from the driver that called us */ return (config_found(dev, &arg, agpdev_print)); @@ -149,6 +150,7 @@ agp_attach(struct device *parent, struct device *self, void *aux) sc->sc_chipc = parent; sc->sc_methods = aa->aa_methods; sc->sc_apaddr = aa->aa_apaddr; + sc->sc_apsize = aa->aa_apsize; static const int agp_max[][2] = { {0, 0}, @@ -192,7 +194,7 @@ agp_attach(struct device *parent, struct device *self, void *aux) &sc->sc_capoff, NULL); printf(": aperture at 0x%lx, size 0x%lx\n", (u_long)sc->sc_apaddr, - (u_long)sc->sc_methods->get_aperture(sc->sc_chipc)); + (u_long)sc->sc_apsize); } struct cfattach agp_ca = { @@ -211,7 +213,7 @@ agpmmap(void *v, off_t off, int prot) if (sc->sc_apaddr) { - if (off > sc->sc_methods->get_aperture(sc->sc_chipc)) + if (off > sc->sc_apsize) return (-1); /* @@ -475,9 +477,8 @@ agp_generic_bind_memory(struct agp_softc *sc, struct agp_memory *mem, return (EINVAL); } - if (offset < 0 || (offset & (AGP_PAGE_SIZE - 1)) != 0 - || offset + mem->am_size > - sc->sc_methods->get_aperture(sc->sc_chipc)) { + if (offset < 0 || (offset & (AGP_PAGE_SIZE - 1)) != 0 || + offset + mem->am_size > sc->sc_apsize) { printf("AGP: binding memory at bad offset %#lx\n", (unsigned long) offset); rw_exit_write(&sc->sc_lock); @@ -699,7 +700,7 @@ agp_info_user(void *dev, agp_info *info) else info->agp_mode = 0; /* i810 doesn't have real AGP */ info->aper_base = sc->sc_apaddr; - info->aper_size = sc->sc_methods->get_aperture(sc->sc_chipc) >> 20; + info->aper_size = sc->sc_apsize >> 20; info->pg_total = info->pg_system = sc->sc_maxmem >> AGP_PAGE_SHIFT; info->pg_used = sc->sc_allocated >> AGP_PAGE_SHIFT; @@ -799,7 +800,7 @@ agp_get_info(void *dev, struct agp_info *info) else info->ai_mode = 0; /* i810 doesn't have real AGP */ info->ai_aperture_base = sc->sc_apaddr; - info->ai_aperture_size = sc->sc_methods->get_aperture(sc->sc_chipc); + info->ai_aperture_size = sc->sc_apsize; info->ai_memory_allowed = sc->sc_maxmem; info->ai_memory_used = sc->sc_allocated; } |