socsvn commit: r255437 - soc2013/zcore/head/usr.sbin/bhyve
zcore at FreeBSD.org
zcore at FreeBSD.org
Fri Aug 2 00:31:25 UTC 2013
Author: zcore
Date: Fri Aug 2 00:31:24 2013
New Revision: 255437
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255437
Log:
add command list and prdt support
Modified:
soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c
Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c
==============================================================================
--- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Thu Aug 1 23:51:20 2013 (r255436)
+++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Fri Aug 2 00:31:24 2013 (r255437)
@@ -57,7 +57,7 @@
*/
static FILE *dbg;
#define dprintf(format, arg...) do{fprintf(dbg, format, ##arg);fflush(dbg);}while(0)
-#define DPRINTF(params) dprintf params
+#define DPRINTF(params) printf params
#define WPRINTF(params) printf params
struct ahci_ioreq {
@@ -72,6 +72,7 @@
struct ahci_port {
struct blockif_ctxt *bctx;
struct pci_ahci_softc *pr_sc;
+ uint64_t cmd_lst;
uint32_t clb;
uint32_t clbu;
uint32_t fb;
@@ -107,6 +108,12 @@
uint32_t reserved[4];
};
+struct ahci_prdt_entry {
+ uint64_t dba;
+ uint32_t reserved;
+ uint32_t dbc;
+};
+
struct pci_ahci_softc {
struct pci_devinst *asc_pi;
pthread_mutex_t mtx;
@@ -124,6 +131,7 @@
uint32_t bohc;
struct ahci_port port[AHCI_MAX_PORTS];
};
+#define ahci_ctx(sc) ((sc)->asc_pi->pi_vmctx)
/*
* generate HBA intr depending on whether or not ports within
@@ -228,17 +236,49 @@
static void
handle_slot(struct ahci_port *p, int slot)
{
- /* TODO */
+ uint8_t *cfis;
+ int cfl, i;
+ struct ahci_cmd_hdr *hdr;
+ struct ahci_prdt_entry *prdt;
+ struct pci_ahci_softc *sc;
+
+ sc = p->pr_sc;
+ hdr = p->cmd_lst + slot * AHCI_CL_SIZE;
+ cfl = (hdr->flags & 0x1f) * 4;
+ dprintf("cfis length:%d prdt entries: %d\n", cfl, hdr->prdtl);
+ cfis = paddr_guest2host(ahci_ctx(sc), hdr->ctba, cfl);
+ prdt = paddr_guest2host(ahci_ctx(sc), hdr->ctba + 0x80, hdr->prdtl * 16);
+
+ /* dump cfis, will be removed latter */
+ for (i = 0; i < cfl; i++) {
+ if (i % 10 == 0)
+ dprintf("\n");
+ dprintf("%02x ", cfis[i]);
+ }
+ dprintf("\n");
+
+ /* dump prdt, will be removed latter */
+ for (i = 0; i < hdr->prdtl; i++) {
+ dprintf("%d@%08lx, %d\n", prdt->dbc & 0x3fffff, prdt->dba, (prdt->dbc >> 31) & 0x1);
+ prdt++;
+ }
}
static void
handle_cmd(struct ahci_port *p)
{
int i;
+ struct pci_ahci_softc *sc;
+ uint64_t clb;
if (!(p->cmd & AHCI_P_CMD_ST) || !p->ci)
return;
+ sc = p->pr_sc;
+ clb = (uint64_t)p->clbu << 32 | p->clb;
+ p->cmd_lst = paddr_guest2host(ahci_ctx(sc), clb,
+ AHCI_CL_SIZE * AHCI_MAX_SLOTS);
+
for (i = 0; (i < 32) && p->ci; i++) {
if (p->ci & (1 << i)) {
handle_slot(p, i);
More information about the svn-soc-all
mailing list