diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2002-07-25 23:31:05 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2002-07-25 23:31:05 +0000 |
commit | 9a336ab45a116f9670bb929a2d0c2fdd66556376 (patch) | |
tree | 5bab6bc40157b680ab347cd8f43fef91e210a1d7 | |
parent | 2aa603263e6066ec4521ba3b50b3441404e4c8e9 (diff) |
- some KNF.
- comment out debugging printf for i810.
- remove checks for failure if malloc is used with M_WAITOK.
mickey@ ok.
-rw-r--r-- | sys/dev/pci/agp_ali.c | 42 | ||||
-rw-r--r-- | sys/dev/pci/agp_amd.c | 43 | ||||
-rw-r--r-- | sys/dev/pci/agp_i810.c | 107 | ||||
-rw-r--r-- | sys/dev/pci/agp_intel.c | 34 | ||||
-rw-r--r-- | sys/dev/pci/agp_sis.c | 35 | ||||
-rw-r--r-- | sys/dev/pci/agp_via.c | 38 | ||||
-rw-r--r-- | sys/dev/pci/agpvar.h | 81 |
7 files changed, 196 insertions, 184 deletions
diff --git a/sys/dev/pci/agp_ali.c b/sys/dev/pci/agp_ali.c index 58cec9ee1c3..c11447de57c 100644 --- a/sys/dev/pci/agp_ali.c +++ b/sys/dev/pci/agp_ali.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_ali.c,v 1.1 2002/07/12 20:17:03 mickey Exp $ */ +/* $OpenBSD: agp_ali.c,v 1.2 2002/07/25 23:31:04 fgsch Exp $ */ /* $NetBSD: agp_ali.c,v 1.2 2001/09/15 00:25:00 thorpej Exp $ */ @@ -56,10 +56,10 @@ struct agp_ali_softc { }; 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 *); +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 *); struct agp_methods agp_ali_methods = { agp_ali_get_aperture, @@ -75,7 +75,8 @@ struct agp_methods agp_ali_methods = { }; int -agp_ali_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *pchb_pa) +agp_ali_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, + struct pci_attach_args *pchb_pa) { struct agp_ali_softc *asc; struct agp_gatt *gatt; @@ -84,7 +85,7 @@ agp_ali_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ asc = malloc(sizeof *asc, M_DEVBUF, M_NOWAIT); if (asc == NULL) { printf(": failed to allocate softc\n"); - return ENOMEM; + return (ENOMEM); } sc->sc_chipc = asc; sc->sc_methods = &agp_ali_methods; @@ -92,7 +93,7 @@ agp_ali_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ if (agp_map_aperture(sc) != 0) { printf(": failed to map aperture\n"); free(asc, M_DEVBUF); - return ENXIO; + return (ENXIO); } asc->initial_aperture = agp_ali_get_aperture(sc); @@ -109,7 +110,7 @@ agp_ali_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ if (AGP_SET_APERTURE(sc, AGP_GET_APERTURE(sc) / 2)) { agp_generic_detach(sc); printf(": failed to set aperture\n"); - return ENOMEM; + return (ENOMEM); } } asc->gatt = gatt; @@ -124,7 +125,7 @@ agp_ali_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ reg = (reg & ~0xff) | 0x10; pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_ALI_TLBCTRL, reg); - return 0; + return (0); } #if 0 @@ -137,7 +138,7 @@ agp_ali_detach(struct vga_pci_softc *sc) error = agp_generic_detach(sc); if (error) - return error; + return (error); /* Disable the TLB.. */ reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_ALI_TLBCTRL); @@ -152,7 +153,7 @@ agp_ali_detach(struct vga_pci_softc *sc) pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_ALI_ATTBASE, reg); agp_free_gatt(sc, asc->gatt); - return 0; + return (0); } #endif @@ -182,10 +183,11 @@ agp_ali_get_aperture(struct vga_pci_softc *sc) * The aperture size is derived from the low bits of attbase. * I'm not sure this is correct.. */ - i = (int)pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_ALI_ATTBASE) & 0xff; + i = (int)pci_conf_read(sc->sc_pc, sc->sc_pcitag, + AGP_ALI_ATTBASE) & 0xff; if (i >= agp_ali_table_size) - return 0; - return agp_ali_table[i]; + return (0); + return (agp_ali_table[i]); } int @@ -204,7 +206,7 @@ agp_ali_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) reg &= ~0xff; reg |= i; pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_ALI_ATTBASE, reg); - return 0; + return (0); } int @@ -213,10 +215,10 @@ agp_ali_bind_page(struct vga_pci_softc *sc, off_t offset, bus_addr_t physical) struct agp_ali_softc *asc = sc->sc_chipc; if (offset < 0 || offset >= (asc->gatt->ag_entries << AGP_PAGE_SHIFT)) - return EINVAL; + return (EINVAL); asc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical; - return 0; + return (0); } int @@ -225,10 +227,10 @@ agp_ali_unbind_page(struct vga_pci_softc *sc, off_t offset) struct agp_ali_softc *asc = sc->sc_chipc; if (offset < 0 || offset >= (asc->gatt->ag_entries << AGP_PAGE_SHIFT)) - return EINVAL; + return (EINVAL); asc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; - return 0; + return (0); } void diff --git a/sys/dev/pci/agp_amd.c b/sys/dev/pci/agp_amd.c index c17a49f045b..f5d77a43062 100644 --- a/sys/dev/pci/agp_amd.c +++ b/sys/dev/pci/agp_amd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_amd.c,v 1.1 2002/07/12 20:17:03 mickey Exp $ */ +/* $OpenBSD: agp_amd.c,v 1.2 2002/07/25 23:31:04 fgsch Exp $ */ /* $NetBSD: agp_amd.c,v 1.6 2001/10/06 02:48:50 thorpej Exp $ */ @@ -106,7 +106,7 @@ agp_amd_alloc_gatt(struct vga_pci_softc *sc) gatt = malloc(sizeof(struct agp_amd_gatt), M_DEVBUF, M_NOWAIT); if (!gatt) - return 0; + return (0); if (agp_alloc_dmamem(sc->sc_dmat, AGP_PAGE_SIZE + entries * sizeof(u_int32_t), 0, @@ -114,7 +114,7 @@ agp_amd_alloc_gatt(struct vga_pci_softc *sc) &gatt->ag_dmaseg, 1, &gatt->ag_nseg) != 0) { printf("failed to allocate GATT\n"); free(gatt, M_DEVBUF); - return NULL; + return (NULL); } gatt->ag_vdir = (u_int32_t *)vdir; @@ -140,7 +140,7 @@ agp_amd_alloc_gatt(struct vga_pci_softc *sc) */ agp_flush_cache(); - return gatt; + return (gatt); } #if 0 @@ -166,7 +166,7 @@ agp_amd_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ if (asc == NULL) { printf(": can't allocate softc\n"); /* agp_generic_detach(sc) */ - return ENOMEM; + return (ENOMEM); } memset(asc, 0, sizeof *asc); @@ -175,14 +175,14 @@ agp_amd_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ if (error != 0) { printf(": can't map AGP registers\n"); agp_generic_detach(sc); - return error; + return (error); } if (agp_map_aperture(sc) != 0) { printf(": can't map aperture\n"); agp_generic_detach(sc); free(asc, M_DEVBUF); - return ENXIO; + return (ENXIO); } sc->sc_methods = &agp_amd_methods; sc->sc_chipc = asc; @@ -199,7 +199,7 @@ agp_amd_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ */ if (AGP_SET_APERTURE(sc, AGP_GET_APERTURE(sc) / 2)) { printf(": can't set aperture\n"); - return ENOMEM; + return (ENOMEM); } } asc->gatt = gatt; @@ -214,10 +214,10 @@ agp_amd_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_AMD751_MODECTRL, reg); /* Enable the TLB and flush */ WRITE2(AGP_AMD751_STATUS, - READ2(AGP_AMD751_STATUS) | AGP_AMD751_STATUS_GCE); + READ2(AGP_AMD751_STATUS) | AGP_AMD751_STATUS_GCE); AGP_FLUSH_TLB(sc); - return 0; + return (0); } #if 0 @@ -229,7 +229,7 @@ agp_amd_detach(struct vga_pci_softc *sc) /* Disable the TLB.. */ WRITE2(AGP_AMD751_STATUS, - READ2(AGP_AMD751_STATUS) & ~AGP_AMD751_STATUS_GCE); + READ2(AGP_AMD751_STATUS) & ~AGP_AMD751_STATUS_GCE); /* Disable host-agp sync */ reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_AMD751_MODECTRL); @@ -246,7 +246,7 @@ agp_amd_detach(struct vga_pci_softc *sc) /* XXXfvdl no pci_mapreg_unmap */ - return 0; + return (0); } #endif @@ -255,12 +255,13 @@ agp_amd_get_aperture(struct vga_pci_softc *sc) { int vas; - vas = (pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_AMD751_APCTRL) & 0x06); + vas = (pci_conf_read(sc->sc_pc, sc->sc_pcitag, + AGP_AMD751_APCTRL) & 0x06); vas >>= 1; /* * The aperture size is equal to 32M<<vas. */ - return (32*1024*1024) << vas; + return ((32 * 1024 * 1024) << vas); } static int @@ -276,7 +277,7 @@ agp_amd_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) if (aperture & (aperture - 1) || aperture < 32*1024*1024 || aperture > 2U*1024*1024*1024) - return EINVAL; + return (EINVAL); vas = ffs(aperture / 32*1024*1024) - 1; @@ -284,7 +285,7 @@ agp_amd_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) reg = (reg & ~0x06) | (vas << 1); pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_AMD751_APCTRL, reg); - return 0; + return (0); } static int @@ -293,10 +294,10 @@ agp_amd_bind_page(struct vga_pci_softc *sc, off_t offset, bus_addr_t physical) struct agp_amd_softc *asc = sc->sc_chipc; if (offset < 0 || offset >= (asc->gatt->ag_entries << AGP_PAGE_SHIFT)) - return EINVAL; + return (EINVAL); asc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical | 1; - return 0; + return (0); } static int @@ -305,10 +306,10 @@ agp_amd_unbind_page(struct vga_pci_softc *sc, off_t offset) struct agp_amd_softc *asc = sc->sc_chipc; if (offset < 0 || offset >= (asc->gatt->ag_entries << AGP_PAGE_SHIFT)) - return EINVAL; + return (EINVAL); asc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; - return 0; + return (0); } static void @@ -322,5 +323,3 @@ agp_amd_flush_tlb(struct vga_pci_softc *sc) DELAY(1); } while (READ4(AGP_AMD751_TLBCTRL)); } - - diff --git a/sys/dev/pci/agp_i810.c b/sys/dev/pci/agp_i810.c index 60f14d5c6a9..21170125048 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.2 2002/07/15 13:23:48 mickey Exp $ */ +/* $OpenBSD: agp_i810.c,v 1.3 2002/07/25 23:31:04 fgsch Exp $ */ /* $NetBSD: agp_i810.c,v 1.8 2001/09/20 20:00:16 fvdl Exp $ */ /*- @@ -63,15 +63,17 @@ struct agp_i810_softc { }; 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); -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 *, off_t); -int agp_i810_unbind_memory(struct vga_pci_softc *, struct agp_memory *); +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); +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 *, + off_t); +int agp_i810_unbind_memory(struct vga_pci_softc *, struct agp_memory *); struct agp_methods agp_i810_methods = { agp_i810_get_aperture, @@ -88,7 +90,8 @@ struct agp_methods agp_i810_methods = { int -agp_i810_attach(struct vga_pci_softc* sc, struct pci_attach_args *pa, struct pci_attach_args *pchb_pa) +agp_i810_attach(struct vga_pci_softc* sc, struct pci_attach_args *pa, + struct pci_attach_args *pchb_pa) { struct agp_i810_softc *isc; struct agp_gatt *gatt; @@ -97,7 +100,7 @@ agp_i810_attach(struct vga_pci_softc* sc, struct pci_attach_args *pa, struct pci isc = malloc(sizeof *isc, M_DEVBUF, M_NOWAIT); if (isc == NULL) { printf(": can't allocate chipset-specific softc\n"); - return ENOMEM; + return (ENOMEM); } memset(isc, 0, sizeof *isc); sc->sc_chipc = isc; @@ -107,14 +110,14 @@ agp_i810_attach(struct vga_pci_softc* sc, struct pci_attach_args *pa, struct pci if ((error = agp_map_aperture(sc))) { printf(": can't map aperture\n"); free(isc, M_DEVBUF); - return error; + return (error); } error = pci_mapreg_map(pa, AGP_I810_MMADR, PCI_MAPREG_TYPE_MEM, 0, &isc->bst, &isc->bsh, NULL, NULL, 0); if (error != 0) { printf(": can't map mmadr registers\n"); - return error; + return (error); } isc->initial_aperture = AGP_GET_APERTURE(sc); @@ -135,7 +138,7 @@ agp_i810_attach(struct vga_pci_softc* sc, struct pci_attach_args *pa, struct pci */ if (AGP_SET_APERTURE(sc, AGP_GET_APERTURE(sc) / 2)) { agp_generic_detach(sc); - return ENOMEM; + return (ENOMEM); } } isc->gatt = gatt; @@ -148,7 +151,7 @@ agp_i810_attach(struct vga_pci_softc* sc, struct pci_attach_args *pa, struct pci */ agp_flush_cache(); - return 0; + return (0); } u_int32_t @@ -158,9 +161,9 @@ agp_i810_get_aperture(struct vga_pci_softc *sc) miscc = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_I810_SMRAM) >> 16; if ((miscc & AGP_I810_MISCC_WINSIZE) == AGP_I810_MISCC_WINSIZE_32) - return 32 * 1024 * 1024; + return (32 * 1024 * 1024); else - return 64 * 1024 * 1024; + return (64 * 1024 * 1024); } int @@ -173,7 +176,7 @@ agp_i810_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) */ if (aperture != 32 * 1024 * 1024 && aperture != 64 * 1024 * 1024) { printf("AGP: bad aperture size %d\n", aperture); - return EINVAL; + return (EINVAL); } reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_I810_SMRAM); @@ -188,7 +191,7 @@ agp_i810_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) reg |= (miscc << 16); pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_I810_SMRAM, miscc); - return 0; + return (0); } int @@ -197,12 +200,12 @@ agp_i810_bind_page(struct vga_pci_softc *sc, off_t offset, bus_addr_t pa) struct agp_i810_softc *isc = sc->sc_chipc; if (offset < 0 || offset >= (isc->gatt->ag_entries << AGP_PAGE_SHIFT)) - return EINVAL; + return (EINVAL); WRITE4(AGP_I810_GTT + (u_int32_t)(offset >> AGP_PAGE_SHIFT) * 4, pa | 1); - return 0; + return (0); } int @@ -211,10 +214,10 @@ agp_i810_unbind_page(struct vga_pci_softc *sc, off_t offset) struct agp_i810_softc *isc = sc->sc_chipc; if (offset < 0 || offset >= (isc->gatt->ag_entries << AGP_PAGE_SHIFT)) - return EINVAL; + return (EINVAL); WRITE4(AGP_I810_GTT + (u_int32_t)(offset >> AGP_PAGE_SHIFT) * 4, 0); - return 0; + return (0); } /* @@ -228,8 +231,7 @@ agp_i810_flush_tlb(struct vga_pci_softc *sc) int agp_i810_enable(struct vga_pci_softc *sc, u_int32_t mode) { - - return 0; + return (0); } struct agp_memory * @@ -244,57 +246,54 @@ agp_i810_alloc_memory(struct vga_pci_softc *sc, int type, vsize_t size) * Mapping local DRAM into GATT. */ if (size != isc->dcache_size) - return NULL; + return (NULL); } else if (type == 2) { /* * Bogus mapping of a single page for the hardware cursor. */ if (size != AGP_PAGE_SIZE) - return NULL; + return (NULL); } - if ((mem = malloc(sizeof *mem, M_DEVBUF, M_WAITOK)) == NULL) - return NULL; + mem = malloc(sizeof *mem, M_DEVBUF, M_WAITOK); bzero(mem, sizeof *mem); mem->am_id = sc->sc_nextid++; mem->am_size = size; mem->am_type = type; if (type == 2) { - mem->am_dmaseg = malloc(sizeof *mem->am_dmaseg, M_DEVBUF, M_WAITOK); - if (mem->am_dmaseg == NULL) { - free(mem, M_DEVBUF); -printf("agp: no memory for the segments\n"); - return NULL; - } + mem->am_dmaseg = malloc(sizeof *mem->am_dmaseg, M_DEVBUF, + M_WAITOK); + if ((error = agp_alloc_dmamem(sc->sc_dmat, size, 0, &mem->am_dmamap, &mem->am_virtual, &mem->am_physical, mem->am_dmaseg, 1, &mem->am_nseg)) != 0) { free(mem, M_DEVBUF); free(mem->am_dmaseg, M_DEVBUF); -printf("agp: agp_alloc_dmamem(%d)\n", error); - return NULL; + printf("agp: agp_alloc_dmamem(%d)\n", error); + return (NULL); } } else if (type != 1) { - if ((error = bus_dmamap_create(sc->sc_dmat, size, size / PAGE_SIZE + 1, - size, 0, BUS_DMA_NOWAIT, &mem->am_dmamap)) != 0) { + if ((error = bus_dmamap_create(sc->sc_dmat, size, + size / PAGE_SIZE + 1, size, 0, BUS_DMA_NOWAIT, + &mem->am_dmamap)) != 0) { free(mem, M_DEVBUF); -printf("agp: bus_dmamap_create(%d)\n", error); - return NULL; + printf("agp: bus_dmamap_create(%d)\n", error); + return (NULL); } } TAILQ_INSERT_TAIL(&sc->sc_memory, mem, am_link); sc->sc_allocated += size; - return mem; + return (mem); } int agp_i810_free_memory(struct vga_pci_softc *sc, struct agp_memory *mem) { if (mem->am_is_bound) - return EBUSY; + return (EBUSY); if (mem->am_type == 2) { agp_free_dmamem(sc->sc_dmat, mem->am_size, mem->am_dmamap, @@ -305,7 +304,7 @@ agp_i810_free_memory(struct vga_pci_softc *sc, struct agp_memory *mem) sc->sc_allocated -= mem->am_size; TAILQ_REMOVE(&sc->sc_memory, mem, am_link); free(mem, M_DEVBUF); - return 0; + return (0); } int @@ -323,18 +322,20 @@ agp_i810_bind_memory(struct vga_pci_softc *sc, struct agp_memory *mem, */ regval = bus_space_read_4(isc->bst, isc->bsh, AGP_I810_PGTBL_CTL); if (regval != (isc->gatt->ag_physical | 1)) { +#if 0 printf("agp_i810_bind_memory: PGTBL_CTL is 0x%x - fixing\n", - regval); + regval); +#endif bus_space_write_4(isc->bst, isc->bsh, AGP_I810_PGTBL_CTL, - isc->gatt->ag_physical | 1); + isc->gatt->ag_physical | 1); } if (mem->am_type == 2) { WRITE4(AGP_I810_GTT + (u_int32_t)(offset >> AGP_PAGE_SHIFT) * 4, - mem->am_physical | 1); + mem->am_physical | 1); mem->am_offset = offset; mem->am_is_bound = 1; - return 0; + return (0); } if (mem->am_type != 1) @@ -344,7 +345,7 @@ agp_i810_bind_memory(struct vga_pci_softc *sc, struct agp_memory *mem, WRITE4(AGP_I810_GTT + (u_int32_t)(offset >> AGP_PAGE_SHIFT) * 4, i | 3); - return 0; + return (0); } int @@ -358,14 +359,14 @@ agp_i810_unbind_memory(struct vga_pci_softc *sc, struct agp_memory *mem) (u_int32_t)(mem->am_offset >> AGP_PAGE_SHIFT) * 4, 0); mem->am_offset = 0; mem->am_is_bound = 0; - return 0; + return (0); } if (mem->am_type != 1) - return agp_generic_unbind_memory(sc, mem); + return (agp_generic_unbind_memory(sc, mem)); for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE) WRITE4(AGP_I810_GTT + (i >> AGP_PAGE_SHIFT) * 4, 0); - return 0; + return (0); } diff --git a/sys/dev/pci/agp_intel.c b/sys/dev/pci/agp_intel.c index 653adaf4c9e..2a4449715b7 100644 --- a/sys/dev/pci/agp_intel.c +++ b/sys/dev/pci/agp_intel.c @@ -75,7 +75,8 @@ struct agp_methods agp_intel_methods = { }; int -agp_intel_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *pchb_pa) +agp_intel_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, + struct pci_attach_args *pchb_pa) { struct agp_intel_softc *isc; struct agp_gatt *gatt; @@ -84,7 +85,7 @@ agp_intel_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pc isc = malloc(sizeof *isc, M_DEVBUF, M_NOWAIT); if (isc == NULL) { printf(": can't allocate chipset-specific softc\n"); - return ENOMEM; + return (ENOMEM); } memset(isc, 0, sizeof *isc); @@ -95,7 +96,7 @@ agp_intel_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pc printf(": can't map aperture\n"); free(isc, M_DEVBUF); sc->sc_chipc = NULL; - return ENXIO; + return (ENXIO); } isc->initial_aperture = AGP_GET_APERTURE(sc); @@ -112,7 +113,7 @@ agp_intel_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pc if (AGP_SET_APERTURE(sc, AGP_GET_APERTURE(sc) / 2)) { agp_generic_detach(sc); printf(": failed to set aperture\n"); - return ENOMEM; + return (ENOMEM); } } isc->gatt = gatt; @@ -134,7 +135,7 @@ agp_intel_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pc reg |= (7 << 16); pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_STS, reg); - return 0; + return (0); } #if 0 @@ -147,7 +148,7 @@ agp_intel_detach(struct vga_pci_softc *sc) error = agp_generic_detach(sc); if (error) - return error; + return (error); reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_NBXCFG); reg &= ~(1 << 9); @@ -157,7 +158,7 @@ agp_intel_detach(struct vga_pci_softc *sc) AGP_SET_APERTURE(sc, isc->initial_aperture); agp_free_gatt(sc, isc->gatt); - return 0; + return (0); } #endif @@ -166,7 +167,8 @@ agp_intel_get_aperture(struct vga_pci_softc *sc) { u_int32_t apsize; - apsize = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_APSIZE) & 0x1f; + apsize = pci_conf_read(sc->sc_pc, sc->sc_pcitag, + AGP_INTEL_APSIZE) & 0x1f; /* * The size is determined by the number of low bits of @@ -175,7 +177,7 @@ agp_intel_get_aperture(struct vga_pci_softc *sc) * field just read forces the corresponding bit in the 27:22 * to be zero. We calculate the aperture size accordingly. */ - return (((apsize ^ 0x1f) << 22) | ((1 << 22) - 1)) + 1; + return ((((apsize ^ 0x1f) << 22) | ((1 << 22) - 1)) + 1); } static int @@ -193,13 +195,13 @@ agp_intel_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) * Double check for sanity. */ if ((((apsize ^ 0x1f) << 22) | ((1 << 22) - 1)) + 1 != aperture) - return EINVAL; + return (EINVAL); reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_APSIZE); reg = (reg & 0xffffff00) | apsize; pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_INTEL_APSIZE, reg); - return 0; + return (0); } static int @@ -208,10 +210,10 @@ agp_intel_bind_page(struct vga_pci_softc *sc, off_t offset, bus_addr_t physical) struct agp_intel_softc *isc = sc->sc_chipc; if (offset < 0 || offset >= (isc->gatt->ag_entries << AGP_PAGE_SHIFT)) - return EINVAL; + return (EINVAL); isc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical | 0x17; - return 0; + return (0); } static int @@ -220,10 +222,10 @@ agp_intel_unbind_page(struct vga_pci_softc *sc, off_t offset) struct agp_intel_softc *isc = sc->sc_chipc; if (offset < 0 || offset >= (isc->gatt->ag_entries << AGP_PAGE_SHIFT)) - return EINVAL; + return (EINVAL); isc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; - return 0; + return (0); } static void @@ -232,5 +234,3 @@ agp_intel_flush_tlb(struct vga_pci_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); } - - diff --git a/sys/dev/pci/agp_sis.c b/sys/dev/pci/agp_sis.c index bf510cffd9f..e1c5b215e1f 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.1 2002/07/12 20:17:03 mickey Exp $ */ +/* $OpenBSD: agp_sis.c,v 1.2 2002/07/25 23:31:04 fgsch Exp $ */ /* $NetBSD: agp_sis.c,v 1.2 2001/09/15 00:25:00 thorpej Exp $ */ /*- @@ -74,7 +74,8 @@ struct agp_methods agp_sis_methods = { int -agp_sis_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *pchb_pa) +agp_sis_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, + struct pci_attach_args *pchb_pa) { struct agp_sis_softc *ssc; struct agp_gatt *gatt; @@ -83,7 +84,7 @@ agp_sis_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ ssc = malloc(sizeof *ssc, M_DEVBUF, M_NOWAIT); if (ssc == NULL) { printf(": can't allocate chipset-specific softc\n"); - return ENOMEM; + return (ENOMEM); } sc->sc_methods = &agp_sis_methods; sc->sc_chipc = ssc; @@ -91,7 +92,7 @@ agp_sis_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ if (agp_map_aperture(sc) != 0) { printf(": can't map aperture\n"); free(ssc, M_DEVBUF); - return ENXIO; + return (ENXIO); } ssc->initial_aperture = AGP_GET_APERTURE(sc); @@ -108,7 +109,7 @@ agp_sis_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ if (AGP_SET_APERTURE(sc, AGP_GET_APERTURE(sc) / 2)) { agp_generic_detach(sc); printf(": failed to set aperture\n"); - return ENOMEM; + return (ENOMEM); } } ssc->gatt = gatt; @@ -122,7 +123,7 @@ agp_sis_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ reg |= (0x05 << 24) | 3; pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_SIS_WINCTRL, reg); - return 0; + return (0); } #if 0 @@ -135,7 +136,7 @@ agp_sis_detach(struct vga_pci_softc *sc) error = agp_generic_detach(sc); if (error) - return error; + return (error); reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_SIS_WINCTRL); reg &= ~3; @@ -146,7 +147,7 @@ agp_sis_detach(struct vga_pci_softc *sc) AGP_SET_APERTURE(sc, ssc->initial_aperture); agp_free_gatt(sc, ssc->gatt); - return 0; + return (0); } #endif @@ -158,8 +159,9 @@ agp_sis_get_aperture(struct vga_pci_softc *sc) /* * The aperture size is equal to 4M<<gws. */ - gws = (pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_SIS_WINCTRL)&0x70) >> 4; - return (4*1024*1024) << gws; + gws = (pci_conf_read(sc->sc_pc, sc->sc_pcitag, + AGP_SIS_WINCTRL)&0x70) >> 4; + return ((4 * 1024 * 1024) << gws); } static int @@ -175,7 +177,7 @@ agp_sis_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) if (aperture & (aperture - 1) || aperture < 4*1024*1024 || aperture > 256*1024*1024) - return EINVAL; + return (EINVAL); gws = ffs(aperture / 4*1024*1024) - 1; @@ -184,7 +186,7 @@ agp_sis_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) reg |= gws << 4; pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_SIS_WINCTRL, reg); - return 0; + return (0); } static int @@ -193,10 +195,10 @@ agp_sis_bind_page(struct vga_pci_softc *sc, off_t offset, bus_addr_t physical) struct agp_sis_softc *ssc = sc->sc_chipc; if (offset < 0 || offset >= (ssc->gatt->ag_entries << AGP_PAGE_SHIFT)) - return EINVAL; + return (EINVAL); ssc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical; - return 0; + return (0); } static int @@ -205,10 +207,10 @@ agp_sis_unbind_page(struct vga_pci_softc *sc, off_t offset) struct agp_sis_softc *ssc = sc->sc_chipc; if (offset < 0 || offset >= (ssc->gatt->ag_entries << AGP_PAGE_SHIFT)) - return EINVAL; + return (EINVAL); ssc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; - return 0; + return (0); } static void @@ -221,4 +223,3 @@ agp_sis_flush_tlb(struct vga_pci_softc *sc) reg |= 0x02; pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_SIS_TLBFLUSH, reg); } - diff --git a/sys/dev/pci/agp_via.c b/sys/dev/pci/agp_via.c index dd5e7dc4cf1..02d00474c8d 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.1 2002/07/12 20:17:03 mickey Exp $ */ +/* $OpenBSD: agp_via.c,v 1.2 2002/07/25 23:31:04 fgsch Exp $ */ /* $NetBSD: agp_via.c,v 1.2 2001/09/15 00:25:00 thorpej Exp $ */ /*- @@ -74,7 +74,8 @@ struct agp_via_softc { int -agp_via_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *pchb_pa) +agp_via_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, + struct pci_attach_args *pchb_pa) { struct agp_via_softc *asc; struct agp_gatt *gatt; @@ -82,7 +83,7 @@ agp_via_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ asc = malloc(sizeof *asc, M_DEVBUF, M_NOWAIT); if (asc == NULL) { printf(": can't allocate chipset-specific softc\n"); - return ENOMEM; + return (ENOMEM); } memset(asc, 0, sizeof *asc); sc->sc_chipc = asc; @@ -91,7 +92,7 @@ agp_via_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ if (agp_map_aperture(sc) != 0) { printf(": can't map aperture\n"); free(asc, M_DEVBUF); - return ENXIO; + return (ENXIO); } asc->initial_aperture = AGP_GET_APERTURE(sc); @@ -108,19 +109,19 @@ agp_via_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ if (AGP_SET_APERTURE(sc, AGP_GET_APERTURE(sc) / 2)) { agp_generic_detach(sc); printf(": can't set aperture size\n"); - return ENOMEM; + return (ENOMEM); } } asc->gatt = gatt; /* Install the gatt. */ pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_VIA_ATTBASE, - gatt->ag_physical | 3); + gatt->ag_physical | 3); /* Enable the aperture. */ pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_VIA_GARTCTRL, 0x0000000f); - return 0; + return (0); } #if 0 @@ -132,14 +133,14 @@ agp_via_detach(struct vga_pci_softc *sc) error = agp_generic_detach(sc); if (error) - return error; + return (error); pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_VIA_GARTCTRL, 0); pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_VIA_ATTBASE, 0); AGP_SET_APERTURE(sc, asc->initial_aperture); agp_free_gatt(sc, asc->gatt); - return 0; + return (0); } #endif @@ -148,7 +149,8 @@ agp_via_get_aperture(struct vga_pci_softc *sc) { u_int32_t apsize; - apsize = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_VIA_APSIZE) & 0x1f; + apsize = pci_conf_read(sc->sc_pc, sc->sc_pcitag, + AGP_VIA_APSIZE) & 0x1f; /* * The size is determined by the number of low bits of @@ -157,7 +159,7 @@ agp_via_get_aperture(struct vga_pci_softc *sc) * field just read forces the corresponding bit in the 27:20 * to be zero. We calculate the aperture size accordingly. */ - return (((apsize ^ 0xff) << 20) | ((1 << 20) - 1)) + 1; + return ((((apsize ^ 0xff) << 20) | ((1 << 20) - 1)) + 1); } static int @@ -175,14 +177,14 @@ agp_via_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture) * Double check for sanity. */ if ((((apsize ^ 0xff) << 20) | ((1 << 20) - 1)) + 1 != aperture) - return EINVAL; + return (EINVAL); reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_VIA_APSIZE); reg &= ~0xff; reg |= apsize; pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_VIA_APSIZE, reg); - return 0; + return (0); } static int @@ -191,10 +193,10 @@ agp_via_bind_page(struct vga_pci_softc *sc, off_t offset, bus_addr_t physical) struct agp_via_softc *asc = sc->sc_chipc; if (offset < 0 || offset >= (asc->gatt->ag_entries << AGP_PAGE_SHIFT)) - return EINVAL; + return (EINVAL); asc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical; - return 0; + return (0); } static int @@ -203,10 +205,10 @@ agp_via_unbind_page(struct vga_pci_softc *sc, off_t offset) struct agp_via_softc *asc = sc->sc_chipc; if (offset < 0 || offset >= (asc->gatt->ag_entries << AGP_PAGE_SHIFT)) - return EINVAL; + return (EINVAL); asc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; - return 0; + return (0); } static void @@ -215,5 +217,3 @@ agp_via_flush_tlb(struct vga_pci_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); } - - diff --git a/sys/dev/pci/agpvar.h b/sys/dev/pci/agpvar.h index 38629c3f113..8eebfd4db24 100644 --- a/sys/dev/pci/agpvar.h +++ b/sys/dev/pci/agpvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: agpvar.h,v 1.2 2002/07/15 13:23:48 mickey Exp $ */ +/* $OpenBSD: agpvar.h,v 1.3 2002/07/25 23:31:04 fgsch Exp $ */ /* $NetBSD: agpvar.h,v 1.4 2001/10/01 21:54:48 fvdl Exp $ */ /*- @@ -68,15 +68,17 @@ struct agp_memory_info { 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); - 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 *, off_t); - int (*unbind_memory)(struct vga_pci_softc *, struct agp_memory *); + 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); + 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 *, + off_t); + int (*unbind_memory)(struct vga_pci_softc *, struct agp_memory *); }; #define AGP_GET_APERTURE(sc) ((sc)->sc_methods->get_aperture(sc)) @@ -108,31 +110,38 @@ struct agp_gatt { * Functions private to the AGP code. */ -int agp_find_caps(pci_chipset_tag_t pct, pcitag_t pt); -int agp_map_aperture(struct vga_pci_softc *sc); -struct agp_gatt *agp_alloc_gatt(struct vga_pci_softc *sc); -void agp_free_gatt(struct vga_pci_softc *sc, struct agp_gatt *gatt); -void agp_flush_cache(void); -int agp_generic_attach(struct vga_pci_softc *sc); -int agp_generic_detach(struct vga_pci_softc *sc); -int agp_generic_enable(struct vga_pci_softc *sc, u_int32_t mode); -struct agp_memory *agp_generic_alloc_memory(struct vga_pci_softc *sc, int type, - vsize_t size); -int agp_generic_free_memory(struct vga_pci_softc *sc, struct agp_memory *mem); -int agp_generic_bind_memory(struct vga_pci_softc *sc, struct agp_memory *mem, - off_t offset); -int agp_generic_unbind_memory(struct vga_pci_softc *sc, struct agp_memory *mem); - -int agp_ali_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *p); -int agp_amd_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *p); -int agp_i810_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *p); -int agp_intel_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *p); -int agp_via_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *p); -int agp_sis_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_attach_args *p); - -int agp_alloc_dmamem(bus_dma_tag_t, size_t, int, bus_dmamap_t *, caddr_t *, - bus_addr_t *, bus_dma_segment_t *, int, int *); -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) ; +int agp_find_caps(pci_chipset_tag_t, pcitag_t); +int agp_map_aperture(struct vga_pci_softc *); +struct agp_gatt * + agp_alloc_gatt(struct vga_pci_softc *); +void agp_free_gatt(struct vga_pci_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); +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 *, + off_t); +int agp_generic_unbind_memory(struct vga_pci_softc *, struct agp_memory *); + +int agp_ali_attach(struct vga_pci_softc *, struct pci_attach_args *, + struct pci_attach_args *); +int agp_amd_attach(struct vga_pci_softc *, struct pci_attach_args *, + struct pci_attach_args *); +int agp_i810_attach(struct vga_pci_softc *, struct pci_attach_args *, + struct pci_attach_args *); +int agp_intel_attach(struct vga_pci_softc *, struct pci_attach_args *, + struct pci_attach_args *); +int agp_via_attach(struct vga_pci_softc *, struct pci_attach_args *, + struct pci_attach_args *); +int agp_sis_attach(struct vga_pci_softc *, struct pci_attach_args *, + struct pci_attach_args *); + +int agp_alloc_dmamem(bus_dma_tag_t, size_t, int, bus_dmamap_t *, + caddr_t *, bus_addr_t *, bus_dma_segment_t *, int, int *); +void agp_free_dmamem(bus_dma_tag_t, size_t, bus_dmamap_t, + caddr_t, bus_dma_segment_t *, int nseg) ; #endif /* !_PCI_AGPVAR_H_ */ |