From ad15140ee7f4ec4908ca3a9a6d9ce618981b03eb Mon Sep 17 00:00:00 2001 From: Peter Grehan Date: Tue, 15 Jul 2014 00:27:08 +0000 Subject: [PATCH] Use the blockif CHS routine to create fake CHS values, and then populate them in the identity page. This fixes a divide-by-zero error at probe time with NetBSD. MFC after: 1 week. --- usr.sbin/bhyve/pci_ahci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/usr.sbin/bhyve/pci_ahci.c b/usr.sbin/bhyve/pci_ahci.c index 9f6110730b0..52724bb7936 100644 --- a/usr.sbin/bhyve/pci_ahci.c +++ b/usr.sbin/bhyve/pci_ahci.c @@ -598,10 +598,16 @@ handle_identify(struct ahci_port *p, int slot, uint8_t *cfis) } else { uint16_t buf[256]; uint64_t sectors; + uint16_t cyl; + uint8_t sech, heads; sectors = blockif_size(p->bctx) / blockif_sectsz(p->bctx); + blockif_chs(p->bctx, &cyl, &heads, &sech); memset(buf, 0, sizeof(buf)); buf[0] = 0x0040; + buf[1] = cyl; + buf[3] = heads; + buf[6] = sech; /* TODO emulate different serial? */ ata_string((uint8_t *)(buf+10), "123456", 20); ata_string((uint8_t *)(buf+23), "001", 8);