diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2007-04-20 07:10:57 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2007-04-20 07:10:57 +0000 |
commit | 2c569ece288bd18f0d382a17deb045a65e00d34f (patch) | |
tree | 1b794747434b4aac661a1fc886aa4e9f011922af /sys/dev | |
parent | c11b258953a5f3ed1e1d506eefb44ea1ab90733b (diff) |
implement reads from a fifo.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/if_tht.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/sys/dev/pci/if_tht.c b/sys/dev/pci/if_tht.c index 1b07c4b418e..22c05a4bd58 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.32 2007/04/20 05:14:32 dlg Exp $ */ +/* $OpenBSD: if_tht.c,v 1.33 2007/04/20 07:10:56 dlg Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -387,6 +387,8 @@ size_t tht_fifo_ready(struct tht_softc *, struct tht_fifo *); void tht_fifo_pre(struct tht_softc *, struct tht_fifo *); +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_post(struct tht_softc *, @@ -740,6 +742,29 @@ tht_fifo_pre(struct tht_softc *sc, struct tht_fifo *tf) } void +tht_fifo_read(struct tht_softc *sc, struct tht_fifo *tf, + void *buf, size_t buflen) +{ + u_int8_t *fifo = THT_DMA_KVA(tf->tf_mem); + u_int8_t *desc = buf; + size_t len; + + len = tf->tf_len - tf->tf_rptr; + + if (len < buflen) { + bcopy(fifo + tf->tf_rptr, desc, len); + + buflen -= len; + desc += len; + + tf->tf_rptr = 0; + } + + bcopy(fifo + tf->tf_rptr, desc, buflen); + tf->tf_rptr += buflen; +} + +void tht_fifo_write(struct tht_softc *sc, struct tht_fifo *tf, void *buf, size_t buflen) { |