[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/11] ahci: fix signature generation
From: |
John Snow |
Subject: |
[Qemu-devel] [PULL 09/11] ahci: fix signature generation |
Date: |
Fri, 18 Sep 2015 11:04:39 -0400 |
The initial register device-to-host FIS no longer needs to specially
set certain fields, as these can be handled generically by setting those
fields explicitly with the signatures we want at port reset time.
(1) Signatures are decomposed into their four component registers and
set upon (AHCI) port reset.
(2) the signature cache register is no longer set manually per-each
device type, but instead just once during ahci_init_d2h.
Signed-off-by: John Snow <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Message-id: address@hidden
---
hw/ide/ahci.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 0c699a7..b86347d 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -540,20 +540,31 @@ static void ahci_init_d2h(AHCIDevice *ad)
{
uint8_t init_fis[20];
IDEState *ide_state = &ad->port.ifs[0];
+ AHCIPortRegs *pr = &ad->port_regs;
memset(init_fis, 0, sizeof(init_fis));
- init_fis[4] = 1;
- init_fis[12] = 1;
-
- if (ide_state->drive_kind == IDE_CD) {
- init_fis[5] = ide_state->lcyl;
- init_fis[6] = ide_state->hcyl;
- }
+ /* We're emulating receiving the first Reg H2D Fis from the device;
+ * Update the SIG register, but otherwise proceed as normal. */
+ pr->sig = (ide_state->hcyl << 24) |
+ (ide_state->lcyl << 16) |
+ (ide_state->sector << 8) |
+ (ide_state->nsector & 0xFF);
ahci_write_fis_d2h(ad, init_fis);
}
+static void ahci_set_signature(AHCIDevice *ad, uint32_t sig)
+{
+ IDEState *s = &ad->port.ifs[0];
+ s->hcyl = sig >> 24 & 0xFF;
+ s->lcyl = sig >> 16 & 0xFF;
+ s->sector = sig >> 8 & 0xFF;
+ s->nsector = sig & 0xFF;
+
+ DPRINTF(ad->port_no, "set hcyl:lcyl:sect:nsect = 0x%08x\n", sig);
+}
+
static void ahci_reset_port(AHCIState *s, int port)
{
AHCIDevice *d = &s->dev[port];
@@ -603,13 +614,10 @@ static void ahci_reset_port(AHCIState *s, int port)
s->dev[port].port_state = STATE_RUN;
if (ide_state->drive_kind == IDE_CD) {
- pr->sig = SATA_SIGNATURE_CDROM;
- ide_state->lcyl = 0x14;
- ide_state->hcyl = 0xeb;
- DPRINTF(port, "set lcyl = %d\n", ide_state->lcyl);
+ ahci_set_signature(d, SATA_SIGNATURE_CDROM);\
ide_state->status = SEEK_STAT | WRERR_STAT | READY_STAT;
} else {
- pr->sig = SATA_SIGNATURE_DISK;
+ ahci_set_signature(d, SATA_SIGNATURE_DISK);
ide_state->status = SEEK_STAT | WRERR_STAT;
}
--
2.4.3
- [Qemu-devel] [PULL 00/11] Ide patches, John Snow, 2015/09/18
- [Qemu-devel] [PULL 08/11] ahci: remove dead reset code, John Snow, 2015/09/18
- [Qemu-devel] [PULL 05/11] ide-test: add cdrom dma test, John Snow, 2015/09/18
- [Qemu-devel] [PULL 01/11] ide: unify io_buffer_offset increments, John Snow, 2015/09/18
- [Qemu-devel] [PULL 02/11] qtest/ahci: use generate_pattern everywhere, John Snow, 2015/09/18
- [Qemu-devel] [PULL 10/11] ahci: remove cmd_fis argument from write_fis_d2h, John Snow, 2015/09/18
- [Qemu-devel] [PULL 09/11] ahci: fix signature generation,
John Snow <=
- [Qemu-devel] [PULL 07/11] atapi: abort transfers with 0 byte limits, John Snow, 2015/09/18
- [Qemu-devel] [PULL 06/11] ide: fix ATAPI command permissions, John Snow, 2015/09/18
- [Qemu-devel] [PULL 11/11] ahci: clean up initial d2h semantics, John Snow, 2015/09/18
- [Qemu-devel] [PULL 04/11] ide-test: add cdrom pio test, John Snow, 2015/09/18
- [Qemu-devel] [PULL 03/11] qtest/ahci: export generate_pattern, John Snow, 2015/09/18
- Re: [Qemu-devel] [PULL 00/11] Ide patches, Peter Maydell, 2015/09/18