socsvn commit: r305334 - soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve
iateaca at FreeBSD.org
iateaca at FreeBSD.org
Sat Jun 18 15:21:09 UTC 2016
Author: iateaca
Date: Sat Jun 18 15:21:08 2016
New Revision: 305334
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=305334
Log:
start to implement the start_stream procedure: construct the BDL array
M bhyve/pci_hda.c
Modified:
soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c
Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c
==============================================================================
--- soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Sat Jun 18 13:44:10 2016 (r305333)
+++ soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Sat Jun 18 15:21:08 2016 (r305334)
@@ -17,6 +17,7 @@
#define HDA_LAST_OFFSET (0x80 + ((HDA_ISS_NO) * 0x20) + ((HDA_OSS_NO) * 0x20))
#define HDA_CORB_ENTRY_LEN 0x04
#define HDA_RIRB_ENTRY_LEN 0x08
+#define HDA_BDL_ENTRY_LEN 0x10
#define HDA_STREAM_TAGS_CNT 0x10
#define HDA_STREAM_REGS_BASE 0x80
#define HDA_STREAM_REGS_LEN 0x20
@@ -99,6 +100,8 @@
hda_reset_regs(struct hda_softc *sc);
static void
hda_reset_stream(struct hda_softc *sc, uint8_t stream_ind);
+static int
+hda_start_stream(struct hda_softc *sc, uint8_t stream_ind);
static uint32_t
hda_read(struct hda_softc *sc, uint32_t offset);
static int
@@ -408,6 +411,68 @@
return;
}
+static int
+hda_start_stream(struct hda_softc *sc, uint8_t stream_ind)
+{
+ struct hda_stream_desc *st = &sc->streams[stream_ind];
+ struct hda_bdle_desc *bdle_desc = NULL;
+ struct hda_bdle *bdle = NULL;
+ uint32_t lvi = 0;
+ uint32_t bdl_cnt = 0;
+ uint64_t bdpl = 0;
+ uint64_t bdpu = 0;
+ uint64_t bdl_paddr = 0;
+ void *bdl_vaddr = NULL;
+ uint32_t bdle_sz = 0;
+ uint64_t bdle_addrl = 0;
+ uint64_t bdle_addrh = 0;
+ uint64_t bdle_paddr = 0;
+ void *bdle_vaddr = NULL;
+ uint32_t off = hda_get_offset_stream(stream_ind);
+ int i;
+
+ assert(!st->run);
+
+ lvi = hda_get_reg_by_offset(sc, off + HDAC_SDLVI);
+ bdpl = hda_get_reg_by_offset(sc, off + HDAC_SDBDPL);
+ bdpu = hda_get_reg_by_offset(sc, off + HDAC_SDBDPU);
+
+ bdl_cnt = lvi + 1;
+ assert(bdl_cnt <= HDA_BDL_MAX_LEN);
+
+ bdl_paddr = bdpl | (bdpu << 32);
+ bdl_vaddr = hda_dma_get_vaddr(sc, bdl_paddr, HDA_BDL_ENTRY_LEN * bdl_cnt);
+ if (!bdl_vaddr) {
+ DPRINTF("Fail to get the guest virtual address\n");
+ return -1;
+ }
+
+ DPRINTF("stream: 0x%x bdl_cnt: 0x%x bdl_paddr: 0x%lx\n", stream_ind, bdl_cnt, bdl_paddr);
+
+ st->bdl_cnt = bdl_cnt;
+
+ bdle = (struct hda_bdle *)bdl_vaddr;
+ for (i = 0; i < bdl_cnt; i++, bdle++) {
+ bdle_sz = bdle->len;
+ bdle_addrl = bdle->addrl;
+ bdle_addrh = bdle->addrh;
+
+ bdle_paddr = bdle_addrl | (bdle_addrh << 32);
+ bdle_vaddr = hda_dma_get_vaddr(sc, bdle_paddr, bdle_sz);
+ if (!bdle_vaddr) {
+ DPRINTF("Fail to get the guest virtual address\n");
+ return -1;
+ }
+
+ bdle_desc = &st->bdl[i];
+ bdle_desc->addr = bdle_vaddr;
+ bdle_desc->len = bdle_sz;
+ bdle_desc->ioc = bdle->ioc;
+ }
+
+ return 0;
+}
+
static uint32_t
hda_read(struct hda_softc *sc, uint32_t offset)
{
@@ -648,6 +713,7 @@
{
uint8_t stream_ind = hda_get_stream_by_offsets(offset, HDAC_SDCTL0);
uint32_t value = hda_get_reg_by_offset(sc, offset);
+ int err;
DPRINTF("stream_ind: 0x%x old: 0x%x\n", stream_ind, old);
@@ -655,6 +721,11 @@
hda_reset_stream(sc, stream_ind);
}
+ if (value & HDAC_SDCTL_RUN) {
+ err = hda_start_stream(sc, stream_ind);
+ assert(!err);
+ }
+
return;
}
More information about the svn-soc-all
mailing list