From bb00d5f906a11312cd8911f44e53a76074f50d68 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Mon, 23 Apr 2007 09:54:43 +0000 Subject: 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. --- sys/dev/pci/if_tht.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'sys') 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 @@ -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 *); @@ -1304,6 +1308,35 @@ tht_fifo_write(struct tht_softc *sc, struct tht_fifo *tf, tf->tf_wptr += buflen; } +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) { -- cgit v1.2.3