diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2007-12-07 17:35:23 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2007-12-07 17:35:23 +0000 |
commit | 9684dae2c9b088048c76fd5938bb23b1b27e4462 (patch) | |
tree | dc3409663752a95ccab7aae24729762fd2604c3f /sys/dev | |
parent | 106b22cd31c4471de08bf5941e7db57fcbd8fe24 (diff) |
KNF, no binary change.
Looked over by a few people.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/agp.c | 88 | ||||
-rw-r--r-- | sys/dev/pci/agp_amd.c | 13 | ||||
-rw-r--r-- | sys/dev/pci/agp_i810.c | 22 | ||||
-rw-r--r-- | sys/dev/pci/agp_intel.c | 42 | ||||
-rw-r--r-- | sys/dev/pci/agp_sis.c | 10 | ||||
-rw-r--r-- | sys/dev/pci/agp_via.c | 30 | ||||
-rw-r--r-- | sys/dev/pci/agpreg.h | 114 | ||||
-rw-r--r-- | sys/dev/pci/agpvar.h | 75 |
8 files changed, 198 insertions, 196 deletions
diff --git a/sys/dev/pci/agp.c b/sys/dev/pci/agp.c index 144d33220a2..28a39a30ce6 100644 --- a/sys/dev/pci/agp.c +++ b/sys/dev/pci/agp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp.c,v 1.13 2007/12/07 14:48:50 oga Exp $ */ +/* $OpenBSD: agp.c,v 1.14 2007/12/07 17:35:22 oga Exp $ */ /*- * Copyright (c) 2000 Doug Rabson * All rights reserved. @@ -58,14 +58,14 @@ struct agp_memory *agp_find_memory(struct agp_softc *sc, int id); const struct agp_product *agp_lookup(struct pci_attach_args *pa); /* userland ioctl functions */ -int agp_info_user(void *, agp_info *); -int agp_setup_user(void *, agp_setup *); -int agp_allocate_user(void *, agp_allocate *); -int agp_deallocate_user(void *, int); -int agp_bind_user(void *, agp_bind *); -int agp_unbind_user(void *, agp_unbind *); -int agp_acquire_helper(void *dev, enum agp_acquire_state state); -int agp_release_helper(void *dev, enum agp_acquire_state state); +int agp_info_user(void *, agp_info *); +int agp_setup_user(void *, agp_setup *); +int agp_allocate_user(void *, agp_allocate *); +int agp_deallocate_user(void *, int); +int agp_bind_user(void *, agp_bind *); +int agp_unbind_user(void *, agp_unbind *); +int agp_acquire_helper(void *dev, enum agp_acquire_state state); +int agp_release_helper(void *dev, enum agp_acquire_state state); const struct agp_product agp_products[] = { #if NAGP_ALI > 0 @@ -217,7 +217,8 @@ agpmmap(void *v, off_t off, int prot) return (-1); } -int agpopen(dev_t dev , int oflags, int devtype, struct proc * p) +int +agpopen(dev_t dev, int oflags, int devtype, struct proc *p) { struct agp_softc *sc = (struct agp_softc *)device_lookup(&agp_cd, AGPUNIT(dev)); @@ -412,7 +413,7 @@ agp_generic_enable(struct agp_softc *sc, u_int32_t mode) int rq, sba, fw, rate, capoff; if (pci_get_capability(sc->sc_pc, sc->sc_pcitag, PCI_CAP_AGP, - &capoff, NULL) == 0) { + &capoff, NULL) == 0) { printf("agp_generic_enable: not an AGP capable device\n"); return (-1); } @@ -431,18 +432,18 @@ agp_generic_enable(struct agp_softc *sc, u_int32_t mode) /* Set SBA if all three can deal with SBA */ sba = (AGP_MODE_GET_SBA(tstatus) - & AGP_MODE_GET_SBA(mstatus) - & AGP_MODE_GET_SBA(mode)); + & AGP_MODE_GET_SBA(mstatus) + & AGP_MODE_GET_SBA(mode)); /* Similar for FW */ fw = (AGP_MODE_GET_FW(tstatus) - & AGP_MODE_GET_FW(mstatus) - & AGP_MODE_GET_FW(mode)); + & AGP_MODE_GET_FW(mstatus) + & AGP_MODE_GET_FW(mode)); /* Figure out the max rate */ rate = (AGP_MODE_GET_RATE(tstatus) - & AGP_MODE_GET_RATE(mstatus) - & AGP_MODE_GET_RATE(mode)); + & AGP_MODE_GET_RATE(mstatus) + & AGP_MODE_GET_RATE(mode)); if (rate & AGP_MODE_RATE_4x) rate = AGP_MODE_RATE_4x; else if (rate & AGP_MODE_RATE_2x) @@ -523,7 +524,7 @@ agp_generic_bind_memory(struct agp_softc *sc, struct agp_memory *mem, || (offset & (AGP_PAGE_SIZE - 1)) != 0 || offset + mem->am_size > AGP_GET_APERTURE(sc)) { printf("AGP: binding memory at bad offset %#lx\n", - (unsigned long) offset); + (unsigned long) offset); rw_exit_write(&sc->sc_lock); return (EINVAL); } @@ -579,11 +580,11 @@ agp_generic_bind_memory(struct agp_softc *sc, struct agp_memory *mem, * entries. */ for (j = 0; j < seg->ds_len && (done + j) < mem->am_size; - j += AGP_PAGE_SIZE) { + j += AGP_PAGE_SIZE) { pa = seg->ds_addr + j; AGP_DPF("binding offset %#lx to pa %#lx\n", - (unsigned long)(offset + done + j), - (unsigned long)pa); + (unsigned long)(offset + done + j), + (unsigned long)pa); error = AGP_BIND_PAGE(sc, offset + done + j, pa); if (error) { /* @@ -595,9 +596,9 @@ agp_generic_bind_memory(struct agp_softc *sc, struct agp_memory *mem, bus_dmamap_unload(sc->sc_dmat, mem->am_dmamap); bus_dmamem_unmap(sc->sc_dmat, mem->am_virtual, - mem->am_size); + mem->am_size); bus_dmamem_free(sc->sc_dmat, mem->am_dmaseg, - mem->am_nseg); + mem->am_nseg); free(mem->am_dmaseg, M_AGP); rw_exit_write(&sc->sc_lock); AGP_DPF("AGP_BIND_PAGE failed %d\n", error); @@ -666,29 +667,29 @@ agp_generic_unbind_memory(struct agp_softc *sc, struct agp_memory *mem) int agp_alloc_dmamem(bus_dma_tag_t tag, size_t size, int flags, - bus_dmamap_t *mapp, caddr_t *vaddr, bus_addr_t *baddr, - bus_dma_segment_t *seg, int nseg, int *rseg) + bus_dmamap_t *mapp, caddr_t *vaddr, bus_addr_t *baddr, + bus_dma_segment_t *seg, int nseg, int *rseg) { int error, level = 0; if ((error = bus_dmamem_alloc(tag, size, PAGE_SIZE, 0, - seg, nseg, rseg, BUS_DMA_NOWAIT)) != 0) + seg, nseg, rseg, BUS_DMA_NOWAIT)) != 0) goto out; level++; if ((error = bus_dmamem_map(tag, seg, *rseg, size, vaddr, - BUS_DMA_NOWAIT | flags)) != 0) + BUS_DMA_NOWAIT | flags)) != 0) goto out; level++; if ((error = bus_dmamap_create(tag, size, *rseg, size, 0, - BUS_DMA_NOWAIT, mapp)) != 0) + BUS_DMA_NOWAIT, mapp)) != 0) goto out; level++; if ((error = bus_dmamap_load(tag, *mapp, *vaddr, size, NULL, - BUS_DMA_NOWAIT)) != 0) + BUS_DMA_NOWAIT)) != 0) goto out; *baddr = (*mapp)->dm_segs[0].ds_addr; @@ -714,7 +715,7 @@ out: void agp_free_dmamem(bus_dma_tag_t tag, size_t size, bus_dmamap_t map, - caddr_t vaddr, bus_dma_segment_t *seg, int nseg) + caddr_t vaddr, bus_dma_segment_t *seg, int nseg) { bus_dmamap_unload(tag, map); @@ -794,6 +795,7 @@ int agp_setup_user(void *dev, agp_setup *setup) { struct agp_softc *sc = (struct agp_softc *) dev; + return (AGP_ENABLE(sc, setup->agp_mode)); } @@ -874,7 +876,7 @@ agp_get_info(void *dev, struct agp_info *info) struct agp_softc *sc = (struct agp_softc *)dev; info->ai_mode = pci_conf_read(sc->sc_pc, sc->sc_pcitag, - sc->sc_capoff + AGP_STATUS); + sc->sc_capoff + AGP_STATUS); info->ai_aperture_base = sc->sc_apaddr; info->ai_aperture_size = sc->sc_apsize; info->ai_memory_allowed = sc->sc_maxmem; @@ -885,6 +887,7 @@ int agp_acquire(void *dev) { struct agp_softc *sc = (struct agp_softc *)dev; + return (agp_acquire_helper(sc, AGP_ACQUIRE_KERNEL)); } @@ -892,6 +895,7 @@ int agp_release(void *dev) { struct agp_softc *sc = (struct agp_softc *)dev; + return (agp_release_helper(sc, AGP_ACQUIRE_KERNEL)); } @@ -899,38 +903,48 @@ int agp_enable(void *dev, u_int32_t mode) { struct agp_softc *sc = (struct agp_softc *) dev; + return (AGP_ENABLE(sc, mode)); } -void *agp_alloc_memory(void *dev, int type, vsize_t bytes) +void * +agp_alloc_memory(void *dev, int type, vsize_t bytes) { struct agp_softc *sc = (struct agp_softc *)dev; + return ((void *) AGP_ALLOC_MEMORY(sc, type, bytes)); } -void agp_free_memory(void *dev, void *handle) +void +agp_free_memory(void *dev, void *handle) { struct agp_softc *sc = (struct agp_softc *) dev; struct agp_memory *mem = (struct agp_memory *) handle; + AGP_FREE_MEMORY(sc, mem); } -int agp_bind_memory(void *dev, void *handle, off_t offset) +int +agp_bind_memory(void *dev, void *handle, off_t offset) { struct agp_softc *sc = (struct agp_softc *) dev; struct agp_memory *mem = (struct agp_memory *) handle; + return (AGP_BIND_MEMORY(sc, mem, offset)); } -int agp_unbind_memory(void *dev, void *handle) +int +agp_unbind_memory(void *dev, void *handle) { struct agp_softc *sc = (struct agp_softc *) dev; struct agp_memory *mem = (struct agp_memory *) handle; + return (AGP_UNBIND_MEMORY(sc, mem)); } -void agp_memory_info(void *dev, void *handle, struct - agp_memory_info *mi) +void +agp_memory_info(void *dev, void *handle, struct + agp_memory_info *mi) { struct agp_memory *mem = (struct agp_memory *) handle; diff --git a/sys/dev/pci/agp_amd.c b/sys/dev/pci/agp_amd.c index eaad4787dd9..1c3a3e2b31d 100644 --- a/sys/dev/pci/agp_amd.c +++ b/sys/dev/pci/agp_amd.c @@ -1,7 +1,6 @@ -/* $OpenBSD: agp_amd.c,v 1.7 2007/12/06 22:49:39 oga Exp $ */ +/* $OpenBSD: agp_amd.c,v 1.8 2007/12/07 17:35:22 oga Exp $ */ /* $NetBSD: agp_amd.c,v 1.6 2001/10/06 02:48:50 thorpej Exp $ */ - /*- * Copyright (c) 2000 Doug Rabson * All rights reserved. @@ -76,10 +75,10 @@ struct agp_amd_softc { u_int32_t agp_amd_get_aperture(struct agp_softc *); struct agp_amd_gatt * agp_amd_alloc_gatt(struct agp_softc *); -int agp_amd_set_aperture(struct agp_softc *, u_int32_t); -int agp_amd_bind_page(struct agp_softc *, off_t, bus_addr_t); -int agp_amd_unbind_page(struct agp_softc *, off_t); -void agp_amd_flush_tlb(struct agp_softc *); +int agp_amd_set_aperture(struct agp_softc *, u_int32_t); +int agp_amd_bind_page(struct agp_softc *, off_t, bus_addr_t); +int agp_amd_unbind_page(struct agp_softc *, off_t); +void agp_amd_flush_tlb(struct agp_softc *); struct agp_methods agp_amd_methods = { @@ -131,7 +130,7 @@ agp_amd_alloc_gatt(struct agp_softc *sc) * Map the pages of the GATT into the page directory. */ npages = ((entries * sizeof(u_int32_t) + AGP_PAGE_SIZE - 1) - >> AGP_PAGE_SHIFT); + >> AGP_PAGE_SHIFT); for (i = 0; i < npages; i++) gatt->ag_vdir[i] = (gatt->ag_physical + i * AGP_PAGE_SIZE) | 1; diff --git a/sys/dev/pci/agp_i810.c b/sys/dev/pci/agp_i810.c index 65297a9c9f1..b70f1240bdf 100644 --- a/sys/dev/pci/agp_i810.c +++ b/sys/dev/pci/agp_i810.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_i810.c,v 1.25 2007/12/06 22:49:39 oga Exp $ */ +/* $OpenBSD: agp_i810.c,v 1.26 2007/12/07 17:35:22 oga Exp $ */ /* $NetBSD: agp_i810.c,v 1.15 2003/01/31 00:07:39 thorpej Exp $ */ /*- @@ -69,16 +69,17 @@ enum { }; struct agp_i810_softc { - u_int32_t initial_aperture; /* aperture size at startup */ - struct agp_gatt *gatt; - int chiptype; /* i810-like or i830 */ - u_int32_t dcache_size; /* i810 only */ - u_int32_t stolen; /* number of i830/845 gtt entries + u_int32_t initial_aperture;/* aperture size at startup */ + struct agp_gatt + *gatt; + int chiptype; /* i810-like or i830 */ + u_int32_t dcache_size; /* i810 only */ + u_int32_t stolen; /* number of i830/845 gtt entries for stolen memory */ - bus_space_tag_t bst; /* bus_space tag */ + bus_space_tag_t bst; /* bus_space tag */ bus_space_handle_t bsh; /* bus_space handle */ - bus_size_t bsz; /* bus_space size */ - bus_space_tag_t gtt_bst; /* GATT bus_space tag */ + bus_size_t bsz; /* bus_space size */ + bus_space_tag_t gtt_bst; /* GATT bus_space tag */ bus_space_handle_t gtt_bsh; /* GATT bus_space handle */ struct pci_attach_args vga_pa; }; @@ -90,8 +91,7 @@ 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 agp_softc *, int, vsize_t); +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); diff --git a/sys/dev/pci/agp_intel.c b/sys/dev/pci/agp_intel.c index 05374afffe1..dc120fc4443 100644 --- a/sys/dev/pci/agp_intel.c +++ b/sys/dev/pci/agp_intel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_intel.c,v 1.8 2007/12/06 22:49:39 oga Exp $ */ +/* $OpenBSD: agp_intel.c,v 1.9 2007/12/07 17:35:22 oga Exp $ */ /* $NetBSD: agp_intel.c,v 1.3 2001/09/15 00:25:00 thorpej Exp $ */ /*- @@ -64,12 +64,12 @@ struct agp_intel_softc { }; -int agp_intel_vgamatch(struct pci_attach_args *); +int agp_intel_vgamatch(struct pci_attach_args *); u_int32_t agp_intel_get_aperture(struct agp_softc *); -int agp_intel_set_aperture(struct agp_softc *, u_int32_t); -int agp_intel_bind_page(struct agp_softc *, off_t, bus_addr_t); -int agp_intel_unbind_page(struct agp_softc *, off_t); -void agp_intel_flush_tlb(struct agp_softc *); +int agp_intel_set_aperture(struct agp_softc *, u_int32_t); +int agp_intel_bind_page(struct agp_softc *, off_t, bus_addr_t); +int agp_intel_unbind_page(struct agp_softc *, off_t); +void agp_intel_flush_tlb(struct agp_softc *); struct agp_methods agp_intel_methods = { agp_intel_get_aperture, @@ -201,50 +201,44 @@ agp_intel_attach(struct agp_softc *sc, struct pci_attach_args *pa) switch (isc->chiptype) { case CHIP_I845: case CHIP_I865: - { reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_I840_MCHCFG); reg |= MCHCFG_AAGN; pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_I840_MCHCFG, reg); break; - } case CHIP_I840: case CHIP_I850: - { reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_AGPCMD); reg |= AGPCMD_AGPEN; pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_AGPCMD, - reg); + reg); reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_I840_MCHCFG); reg |= MCHCFG_AAGN; pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_I840_MCHCFG, - reg); + reg); break; - } default: - { reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_NBXCFG); reg &= ~NBXCFG_APAE; reg |= NBXCFG_AAGN; pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_NBXCFG, reg); - } } /* Clear Error status */ switch (isc->chiptype) { case CHIP_I840: pci_conf_write(sc->sc_pc, sc->sc_pcitag, - AGP_INTEL_I8XX_ERRSTS, 0xc000); + AGP_INTEL_I8XX_ERRSTS, 0xc000); break; case CHIP_I845: case CHIP_I850: case CHIP_I865: pci_conf_write(sc->sc_pc, sc->sc_pcitag, - AGP_INTEL_I8XX_ERRSTS, 0x00ff); + AGP_INTEL_I8XX_ERRSTS, 0x00ff); break; default: pci_conf_write(sc->sc_pc, sc->sc_pcitag, - AGP_INTEL_ERRSTS, 0x70); + AGP_INTEL_ERRSTS, 0x70); } return (0); @@ -309,7 +303,7 @@ agp_intel_set_aperture(struct agp_softc *sc, u_int32_t aperture) * Double check for sanity. */ if ((((apsize ^ isc->aperture_mask) << 22) | - ((1 << 22) - 1)) + 1 != aperture) + ((1 << 22) - 1)) + 1 != aperture) return (EINVAL); pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_APSIZE, apsize); @@ -353,21 +347,17 @@ agp_intel_flush_tlb(struct agp_softc *sc) case CHIP_I845: case CHIP_I840: case CHIP_I443: - { reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_AGPCTRL); reg &= ~AGPCTRL_GTLB; pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_AGPCTRL, - reg); + reg); pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_AGPCTRL, - reg | AGPCTRL_GTLB); + reg | AGPCTRL_GTLB); break; - } default: /* XXX */ - { pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_AGPCTRL, - 0x2200); + 0x2200); pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_AGPCTRL, - 0x2280); - } + 0x2280); } } diff --git a/sys/dev/pci/agp_sis.c b/sys/dev/pci/agp_sis.c index e0fa150f62f..9a3b8a59329 100644 --- a/sys/dev/pci/agp_sis.c +++ b/sys/dev/pci/agp_sis.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_sis.c,v 1.6 2007/12/06 22:49:39 oga Exp $ */ +/* $OpenBSD: agp_sis.c,v 1.7 2007/12/07 17:35:22 oga Exp $ */ /* $NetBSD: agp_sis.c,v 1.2 2001/09/15 00:25:00 thorpej Exp $ */ /*- @@ -54,10 +54,10 @@ struct agp_sis_softc { }; u_int32_t agp_sis_get_aperture(struct agp_softc *); -int agp_sis_set_aperture(struct agp_softc *, u_int32_t); -int agp_sis_bind_page(struct agp_softc *, off_t, bus_addr_t); -int agp_sis_unbind_page(struct agp_softc *, off_t); -void agp_sis_flush_tlb(struct agp_softc *); +int agp_sis_set_aperture(struct agp_softc *, u_int32_t); +int agp_sis_bind_page(struct agp_softc *, off_t, bus_addr_t); +int agp_sis_unbind_page(struct agp_softc *, off_t); +void agp_sis_flush_tlb(struct agp_softc *); struct agp_methods agp_sis_methods = { agp_sis_get_aperture, diff --git a/sys/dev/pci/agp_via.c b/sys/dev/pci/agp_via.c index 374b8c94e81..ce4121dd6db 100644 --- a/sys/dev/pci/agp_via.c +++ b/sys/dev/pci/agp_via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_via.c,v 1.7 2007/12/06 22:49:39 oga Exp $ */ +/* $OpenBSD: agp_via.c,v 1.8 2007/12/07 17:35:22 oga Exp $ */ /* $NetBSD: agp_via.c,v 1.2 2001/09/15 00:25:00 thorpej Exp $ */ /*- @@ -49,10 +49,10 @@ #include <machine/bus.h> u_int32_t agp_via_get_aperture(struct agp_softc *); -int agp_via_set_aperture(struct agp_softc *, u_int32_t); -int agp_via_bind_page(struct agp_softc *, off_t, bus_addr_t); -int agp_via_unbind_page(struct agp_softc *, off_t); -void agp_via_flush_tlb(struct agp_softc *); +int agp_via_set_aperture(struct agp_softc *, u_int32_t); +int agp_via_bind_page(struct agp_softc *, off_t, bus_addr_t); +int agp_via_unbind_page(struct agp_softc *, off_t); +void agp_via_flush_tlb(struct agp_softc *); struct agp_methods agp_via_methods = { agp_via_get_aperture, @@ -141,20 +141,20 @@ agp_via_attach(struct agp_softc *sc, struct pci_attach_args *pa) if (asc->regs == via_v2_regs) { /* Install the gatt. */ pci_conf_write(pa->pa_pc, pa->pa_tag, asc->regs[REG_ATTBASE], - gatt->ag_physical | 3); + gatt->ag_physical | 3); /* Enable the aperture. */ pci_conf_write(pa->pa_pc, pa->pa_tag, asc->regs[REG_GARTCTRL], - 0x0000000f); + 0x0000000f); } else { pcireg_t gartctrl; /* Install the gatt. */ pci_conf_write(pa->pa_pc, pa->pa_tag, asc->regs[REG_ATTBASE], - gatt->ag_physical); + gatt->ag_physical); /* Enable the aperture. */ gartctrl = pci_conf_read(pa->pa_pc, pa->pa_tag, - asc->regs[REG_ATTBASE]); + asc->regs[REG_ATTBASE]); pci_conf_write(pa->pa_pc, pa->pa_tag, asc->regs[REG_GARTCTRL], - gartctrl | (3 << 7)); + gartctrl | (3 << 7)); } return (0); @@ -257,15 +257,15 @@ agp_via_flush_tlb(struct agp_softc *sc) if (asc->regs == via_v2_regs) { pci_conf_write(sc->sc_pc, sc->sc_pcitag, asc->regs[REG_GARTCTRL], - 0x8f); + 0x8f); pci_conf_write(sc->sc_pc, sc->sc_pcitag, asc->regs[REG_GARTCTRL], - 0x0f); + 0x0f); } else { gartctrl = pci_conf_read(sc->sc_pc, sc->sc_pcitag, - asc->regs[REG_GARTCTRL]); + asc->regs[REG_GARTCTRL]); pci_conf_write(sc->sc_pc, sc->sc_pcitag, asc->regs[REG_GARTCTRL], - gartctrl & ~(1 << 7)); + gartctrl & ~(1 << 7)); pci_conf_write(sc->sc_pc, sc->sc_pcitag, asc->regs[REG_GARTCTRL], - gartctrl); + gartctrl); } } diff --git a/sys/dev/pci/agpreg.h b/sys/dev/pci/agpreg.h index 8ae675f083d..136f10a78cf 100644 --- a/sys/dev/pci/agpreg.h +++ b/sys/dev/pci/agpreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: agpreg.h,v 1.8 2007/11/25 17:11:12 oga Exp $ */ +/* $OpenBSD: agpreg.h,v 1.9 2007/12/07 17:35:22 oga Exp $ */ /* $NetBSD: agpreg.h,v 1.1 2001/09/10 10:01:02 fvdl Exp $ */ /*- @@ -35,97 +35,97 @@ /* * Offsets for various AGP configuration registers. */ -#define AGP_APBASE 0x10 +#define AGP_APBASE 0x10 /* * Offsets from the AGP Capability pointer. */ -#define AGP_CAPID 0x02 +#define AGP_CAPID 0x02 #define AGP_CAPID_GET_MAJOR(x) (((x) & 0x00f00000U) >> 20) #define AGP_CAPID_GET_MINOR(x) (((x) & 0x000f0000U) >> 16) #define AGP_CAPID_GET_NEXT_PTR(x) (((x) & 0x0000ff00U) >> 8) #define AGP_CAPID_GET_CAP_ID(x) (((x) & 0x000000ffU) >> 0) -#define AGP_STATUS 0x4 -#define AGP_COMMAND 0x8 +#define AGP_STATUS 0x4 +#define AGP_COMMAND 0x8 /* * Config offsets for Intel AGP chipsets. */ /* i845/855PM */ -#define AGP_I845_AGPMISC 0x51 -#define AGPMISC_AAGN (1U << 1) /* Aperture AccessEN */ +#define AGP_I845_AGPMISC 0x51 +#define AGPMISC_AAGN (1U << 1) /* Aperture AccessEN */ /* i840/850/850E */ -#define AGP_I840_MCHCFG 0x50 -#define MCHCFG_AAGN (1U << 9) /* Aperture AccessEN */ +#define AGP_I840_MCHCFG 0x50 +#define MCHCFG_AAGN (1U << 9) /* Aperture AccessEN */ /* i82443LX/BX/GX */ -#define AGP_INTEL_NBXCFG 0x50 -#define AGP_INTEL_STS 0x90 -#define NBXCFG_APAE (1U << 10) /* AGPtoPCI AccessDIS */ -#define NBXCFG_AAGN (1U << 9) /* Aperture AccessEN */ +#define AGP_INTEL_NBXCFG 0x50 +#define AGP_INTEL_STS 0x90 +#define NBXCFG_APAE (1U << 10) /* AGPtoPCI AccessDIS */ +#define NBXCFG_AAGN (1U << 9) /* Aperture AccessEN */ /* Error Status for i8XX Chipset */ -#define AGP_INTEL_I8XX_ERRSTS 0xc8 +#define AGP_INTEL_I8XX_ERRSTS 0xc8 /* Common register */ -#define AGP_INTEL_ERRSTS 0x91 /* Not i8XX */ -#define AGP_INTEL_AGPCMD 0xa8 -#define AGPCMD_SBA (1U << 9) -#define AGPCMD_AGPEN (1U << 8) -#define AGPCMD_FWEN (1U << 4) -#define AGPCMD_RATE_1X (1U << 1) -#define AGPCMD_RATE_2X (1U << 2) -#define AGPCMD_RATE_4X (1U << 3) +#define AGP_INTEL_ERRSTS 0x91 /* Not i8XX */ +#define AGP_INTEL_AGPCMD 0xa8 +#define AGPCMD_SBA (1U << 9) +#define AGPCMD_AGPEN (1U << 8) +#define AGPCMD_FWEN (1U << 4) +#define AGPCMD_RATE_1X (1U << 1) +#define AGPCMD_RATE_2X (1U << 2) +#define AGPCMD_RATE_4X (1U << 3) -#define AGP_INTEL_AGPCTRL 0xb0 -#define AGPCTRL_AGPRSE (1U << 13) /* AGPRSE (82443 only)*/ -#define AGPCTRL_GTLB (1U << 7) /* GTLB EN */ +#define AGP_INTEL_AGPCTRL 0xb0 +#define AGPCTRL_AGPRSE (1U << 13) /* AGPRSE (82443 only)*/ +#define AGPCTRL_GTLB (1U << 7) /* GTLB EN */ -#define AGP_INTEL_APSIZE 0xb4 -#define APSIZE_MASK 0x3f +#define AGP_INTEL_APSIZE 0xb4 +#define APSIZE_MASK 0x3f -#define AGP_INTEL_ATTBASE 0xb8 +#define AGP_INTEL_ATTBASE 0xb8 /* * Config offsets for VIA AGP 2.x chipsets. */ -#define AGP_VIA_GARTCTRL 0x80 -#define AGP_VIA_APSIZE 0x84 -#define AGP_VIA_ATTBASE 0x88 +#define AGP_VIA_GARTCTRL 0x80 +#define AGP_VIA_APSIZE 0x84 +#define AGP_VIA_ATTBASE 0x88 /* * Config offsets for VIA AGP 3.0 chipsets. */ -#define AGP3_VIA_GARTCTRL 0x90 -#define AGP3_VIA_APSIZE 0x94 -#define AGP3_VIA_ATTBASE 0x98 -#define AGP_VIA_AGPSEL 0xfd +#define AGP3_VIA_GARTCTRL 0x90 +#define AGP3_VIA_APSIZE 0x94 +#define AGP3_VIA_ATTBASE 0x98 +#define AGP_VIA_AGPSEL 0xfd /* * Config offsets for SiS AGP chipsets. */ -#define AGP_SIS_ATTBASE 0x90 -#define AGP_SIS_WINCTRL 0x94 -#define AGP_SIS_TLBCTRL 0x97 -#define AGP_SIS_TLBFLUSH 0x98 +#define AGP_SIS_ATTBASE 0x90 +#define AGP_SIS_WINCTRL 0x94 +#define AGP_SIS_TLBCTRL 0x97 +#define AGP_SIS_TLBFLUSH 0x98 /* * Config offsets for Ali AGP chipsets. */ -#define AGP_ALI_AGPCTRL 0xb8 -#define AGP_ALI_ATTBASE 0xbc -#define AGP_ALI_TLBCTRL 0xc0 +#define AGP_ALI_AGPCTRL 0xb8 +#define AGP_ALI_ATTBASE 0xbc +#define AGP_ALI_TLBCTRL 0xc0 /* * Config offsets for the AMD 751 chipset. */ -#define AGP_AMD751_REGISTERS 0x14 -#define AGP_AMD751_APCTRL 0xac -#define AGP_AMD751_MODECTRL 0xb0 +#define AGP_AMD751_REGISTERS 0x14 +#define AGP_AMD751_APCTRL 0xac +#define AGP_AMD751_MODECTRL 0xb0 #define AGP_AMD751_MODECTRL_SYNEN 0x80 -#define AGP_AMD751_MODECTRL2 0xb2 +#define AGP_AMD751_MODECTRL2 0xb2 #define AGP_AMD751_MODECTRL2_G1LM 0x01 #define AGP_AMD751_MODECTRL2_GPDCE 0x02 #define AGP_AMD751_MODECTRL2_NGSE 0x08 @@ -133,13 +133,13 @@ /* * Memory mapped register offsets for AMD 751 chipset. */ -#define AGP_AMD751_CAPS 0x00 +#define AGP_AMD751_CAPS 0x00 #define AGP_AMD751_CAPS_EHI 0x0800 #define AGP_AMD751_CAPS_P2P 0x0400 #define AGP_AMD751_CAPS_MPC 0x0200 #define AGP_AMD751_CAPS_VBE 0x0100 #define AGP_AMD751_CAPS_REV 0x00ff -#define AGP_AMD751_STATUS 0x02 +#define AGP_AMD751_STATUS 0x02 #define AGP_AMD751_STATUS_P2PS 0x0800 #define AGP_AMD751_STATUS_GCS 0x0400 #define AGP_AMD751_STATUS_MPS 0x0200 @@ -147,20 +147,20 @@ #define AGP_AMD751_STATUS_P2PE 0x0008 #define AGP_AMD751_STATUS_GCE 0x0004 #define AGP_AMD751_STATUS_VBEE 0x0001 -#define AGP_AMD751_ATTBASE 0x04 -#define AGP_AMD751_TLBCTRL 0x0c +#define AGP_AMD751_ATTBASE 0x04 +#define AGP_AMD751_TLBCTRL 0x0c /* * Config registers for i810 device 0 */ -#define AGP_I810_SMRAM 0x70 +#define AGP_I810_SMRAM 0x70 #define AGP_I810_SMRAM_GMS 0xc0 #define AGP_I810_SMRAM_GMS_DISABLED 0x00 #define AGP_I810_SMRAM_GMS_ENABLED_0 0x40 #define AGP_I810_SMRAM_GMS_ENABLED_512 0x80 #define AGP_I810_SMRAM_GMS_ENABLED_1024 0xc0 -#define AGP_I810_MISCC 0x72 -#define AGP_I810_MISCC_WINSIZE 0x0001 +#define AGP_I810_MISCC 0x72 +#define AGP_I810_MISCC_WINSIZE 0x0001 #define AGP_I810_MISCC_WINSIZE_64 0x0000 #define AGP_I810_MISCC_WINSIZE_32 0x0001 #define AGP_I810_MISCC_PLCK 0x0008 @@ -170,18 +170,18 @@ #define AGP_I810_MISCC_WPTC_NOLIMIT 0x0000 #define AGP_I810_MISCC_WPTC_62 0x0010 #define AGP_I810_MISCC_WPTC_50 0x0020 -#define AGP_I810_MISCC_WPTC_37 0x0030 +#define AGP_I810_MISCC_WPTC_37 0x0030 #define AGP_I810_MISCC_RPTC 0x00c0 #define AGP_I810_MISCC_RPTC_NOLIMIT 0x0000 #define AGP_I810_MISCC_RPTC_62 0x0040 -#define AGP_I810_MISCC_RPTC_50 0x0080 +#define AGP_I810_MISCC_RPTC_50 0x0080 #define AGP_I810_MISCC_RPTC_37 0x00c0 /* * Config registers for i810 device 1 */ -#define AGP_I810_GMADR 0x10 -#define AGP_I810_MMADR 0x14 +#define AGP_I810_GMADR 0x10 +#define AGP_I810_MMADR 0x14 /* * Memory mapped register offsets for i810 chipset. diff --git a/sys/dev/pci/agpvar.h b/sys/dev/pci/agpvar.h index 25a28f8ae6e..ecceb70dd88 100644 --- a/sys/dev/pci/agpvar.h +++ b/sys/dev/pci/agpvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: agpvar.h,v 1.9 2007/12/07 14:48:50 oga Exp $ */ +/* $OpenBSD: agpvar.h,v 1.10 2007/12/07 17:35:22 oga Exp $ */ /* $NetBSD: agpvar.h,v 1.4 2001/10/01 21:54:48 fvdl Exp $ */ /*- @@ -125,23 +125,23 @@ struct agp_methods { struct agp_softc { struct device sc_dev; - 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 rwlock 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; + 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 rwlock 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 */ + 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 */ + 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 */ @@ -166,22 +166,21 @@ struct agp_product { struct pci_attach_args *); }; /* MD-defined */ -extern const struct agp_product agp_products[]; - -void agp_attach(struct device *, struct device *, void *); -int agp_probe(struct device *, void *, void *); -paddr_t agpmmap(void *, off_t, int); -int agpioctl(dev_t, u_long, caddr_t, int, struct proc *); -int agpopen(dev_t, int, int, struct proc *); -int agpclose(dev_t, int, int , struct proc *); +extern const struct agp_product agp_products[]; + +void agp_attach(struct device *, struct device *, void *); +int agp_probe(struct device *, void *, void *); +paddr_t agpmmap(void *, off_t, int); +int agpioctl(dev_t, u_long, caddr_t, int, struct proc *); +int agpopen(dev_t, int, int, struct proc *); +int agpclose(dev_t, int, int , struct proc *); /* * Functions private to the AGP code. */ int agp_find_caps(pci_chipset_tag_t, pcitag_t); -int -agp_map_aperture(struct pci_attach_args *, struct agp_softc *, - u_int32_t, u_int32_t); +int agp_map_aperture(struct pci_attach_args *, + struct agp_softc *, u_int32_t, u_int32_t); struct agp_gatt * agp_alloc_gatt(struct agp_softc *); void agp_free_gatt(struct agp_softc *, struct agp_gatt *); @@ -215,64 +214,64 @@ void agp_free_dmamem(bus_dma_tag_t, size_t, bus_dmamap_t, /* * Find the AGP device and return it. */ -void *agp_find_device(int); +void *agp_find_device(int); /* * Return the current owner of the AGP chipset. */ -enum agp_acquire_state agp_state(void *); +enum agp_acquire_state agp_state(void *); /* * Query the state of the AGP system. */ -void agp_get_info(void *, struct agp_info *); +void agp_get_info(void *, struct agp_info *); /* * Acquire the AGP chipset for use by the kernel. Returns EBUSY if the * AGP chipset is already acquired by another user. */ -int agp_acquire(void *); +int agp_acquire(void *); /* * Release the AGP chipset. */ -int agp_release(void *); +int agp_release(void *); /* * Enable the agp hardware with the relavent mode. The mode bits are * defined in <dev/pci/agpreg.h> */ -int agp_enable(void *, u_int32_t); +int agp_enable(void *, u_int32_t); /* * Allocate physical memory suitable for mapping into the AGP * aperture. The value returned is an opaque handle which can be * passed to agp_bind(), agp_unbind() or agp_deallocate(). */ -void *agp_alloc_memory(void *, int, vsize_t); +void *agp_alloc_memory(void *, int, vsize_t); /* * Free memory which was allocated with agp_allocate(). */ -void agp_free_memory(void *, void *); +void agp_free_memory(void *, void *); /* * Bind memory allocated with agp_allocate() at a given offset within * the AGP aperture. Returns EINVAL if the memory is already bound or * the offset is not at an AGP page boundary. */ -int agp_bind_memory(void *, void *, off_t); +int agp_bind_memory(void *, void *, off_t); /* * Unbind memory from the AGP aperture. Returns EINVAL if the memory * is not bound. */ -int agp_unbind_memory(void *, void *); +int agp_unbind_memory(void *, void *); /* * Retrieve information about a memory block allocated with * agp_alloc_memory(). */ -void agp_memory_info(void *, void *, struct agp_memory_info *); +void agp_memory_info(void *, void *, struct agp_memory_info *); #endif /* !_PCI_AGPVAR_H_ */ |