diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2007-04-23 09:54:43 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2007-04-23 09:54:43 +0000 |
commit | bb00d5f906a11312cd8911f44e53a76074f50d68 (patch) | |
tree | c460467a1041f5f23fe23c427c458ea81407cd44 /sys | |
parent | 50640ab12b82c614a71a8bd1d71eb8c7ded5233c (diff) |
add tht_write_dmap, and tht_write_pad.
tht_write_dmap will walk a loaded bus_dmamap_t and write the appropriate
pbd's to the fifo.
tht_write_pad will take the length of the whole descriptor and add a 4 byte
pad to the descriptor if necessary.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/if_tht.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/sys/dev/pci/if_tht.c b/sys/dev/pci/if_tht.c index 52dcc2d3946..7048529c78e 100644 --- a/sys/dev/pci/if_tht.c +++ b/sys/dev/pci/if_tht.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tht.c,v 1.52 2007/04/22 13:14:11 dlg Exp $ */ +/* $OpenBSD: if_tht.c,v 1.53 2007/04/23 09:54:42 dlg Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -471,6 +471,10 @@ void tht_fifo_read(struct tht_softc *, struct tht_fifo *, void *, size_t); void tht_fifo_write(struct tht_softc *, struct tht_fifo *, void *, size_t); +void tht_fifo_write_dmap(struct tht_softc *, + struct tht_fifo *, bus_dmamap_t); +void tht_fifo_write_pad(struct tht_softc *, + struct tht_fifo *, int); void tht_fifo_post(struct tht_softc *, struct tht_fifo *); @@ -1305,6 +1309,35 @@ tht_fifo_write(struct tht_softc *sc, struct tht_fifo *tf, } void +tht_fifo_write_dmap(struct tht_softc *sc, struct tht_fifo *tf, + bus_dmamap_t dmap) +{ + struct tht_pbd pbd; + u_int64_t dva; + int i; + + for (i = 0; i < dmap->dm_nsegs; i++) { + dva = dmap->dm_segs[i].ds_addr; + + pbd.addr_lo = htole32(dva); + pbd.addr_hi = htole32(dva >> 32); + pbd.len = htole32(dmap->dm_segs[i].ds_len); + + tht_fifo_write(sc, tf, &pbd, sizeof(pbd)); + } +} + +void +tht_fifo_write_pad(struct tht_softc *sc, struct tht_fifo *tf, int bc) +{ + const static u_int32_t pad = 0x0; + + /* this assumes you'll only ever be writing multiples of 4 bytes */ + if (bc % 8) + tht_fifo_write(sc, tf, (void *)&pad, sizeof(pad)); +} + +void tht_fifo_post(struct tht_softc *sc, struct tht_fifo *tf) { bus_dmamap_sync(sc->sc_thtc->sc_dmat, THT_DMA_MAP(tf->tf_mem), |