Lines Matching +full:sata +full:- +full:cold
29 #include "libqos/libqos-pc.h"
31 #include "libqos/pci-pc.h"
34 #include "qemu/host-utils.h"
72 while (bytes--) { in string_bswap16()
88 ahci_fingerprint = qpci_config_readl(ahci->dev, PCI_VENDOR_ID); in verify_state()
89 g_assert_cmphex(ahci_fingerprint, ==, ahci->fingerprint); in verify_state()
92 if (!ahci->enabled) { in verify_state()
96 hba_base = (uint64_t)qpci_config_readl(ahci->dev, PCI_BASE_ADDRESS_5); in verify_state()
99 g_assert_cmphex(ahci_rreg(ahci, AHCI_CAP), ==, ahci->cap); in verify_state()
100 g_assert_cmphex(ahci_rreg(ahci, AHCI_CAP2), ==, ahci->cap2); in verify_state()
104 ahci->port[i].fb); in verify_state()
106 ahci->port[i].clb); in verify_state()
109 g_assert_cmphex(cmd.prdtl, ==, ahci->port[i].prdtl[j]); in verify_state()
110 g_assert_cmphex(cmd.ctba, ==, ahci->port[i].ctba[j]); in verify_state()
117 QOSState *tmp = to->parent; in ahci_migrate()
118 QPCIDevice *dev = to->dev; in ahci_migrate()
127 hba_old = (uint64_t)qpci_config_readl(from->dev, PCI_BASE_ADDRESS_5); in ahci_migrate()
130 migrate(from->parent, to->parent, uri); in ahci_migrate()
136 to->parent = tmp; in ahci_migrate()
137 to->dev = dev; in ahci_migrate()
139 tmp = from->parent; in ahci_migrate()
140 dev = from->dev; in ahci_migrate()
142 from->parent = tmp; in ahci_migrate()
143 from->dev = dev; in ahci_migrate()
160 s->parent = qtest_pc_vboot(cli, ap); in ahci_vboot()
161 alloc_set_flags(&s->parent->alloc, ALLOC_LEAK_ASSERT); in ahci_vboot()
164 s->dev = get_ahci_device(s->parent->qts, &s->fingerprint); in ahci_vboot()
183 cli = "-drive if=none,id=drive0,file=%s,cache=writeback,format=%s" in ahci_boot()
184 " -M q35 " in ahci_boot()
185 "-device ide-hd,drive=drive0 " in ahci_boot()
186 "-global ide-hd.serial=%s " in ahci_boot()
187 "-global ide-hd.ver=%s"; in ahci_boot()
199 QOSState *qs = ahci->parent; in ahci_shutdown()
202 free_ahci_device(ahci->dev); in ahci_shutdown()
255 data = qpci_config_readw(ahci->dev, PCI_COMMAND); in ahci_test_pci_spec()
267 data = qpci_config_readw(ahci->dev, PCI_STATUS); in ahci_test_pci_spec()
280 datal = qpci_config_readl(ahci->dev, PCI_CLASS_REVISION); in ahci_test_pci_spec()
282 /* AHCI 1.3 specifies that at-boot, the RID should reset to 0x00, in ahci_test_pci_spec()
303 datab = qpci_config_readb(ahci->dev, PCI_CACHE_LINE_SIZE); in ahci_test_pci_spec()
306 datab = qpci_config_readb(ahci->dev, PCI_LATENCY_TIMER); in ahci_test_pci_spec()
310 datab = qpci_config_readb(ahci->dev, PCI_HEADER_TYPE); in ahci_test_pci_spec()
314 datab = qpci_config_readb(ahci->dev, PCI_BIST); in ahci_test_pci_spec()
317 /* BARS 0-4 do not have a boot spec, but ABAR/BAR5 must be clean. */ in ahci_test_pci_spec()
318 datal = qpci_config_readl(ahci->dev, PCI_BASE_ADDRESS_5); in ahci_test_pci_spec()
321 qpci_config_writel(ahci->dev, PCI_BASE_ADDRESS_5, 0xFFFFFFFF); in ahci_test_pci_spec()
322 datal = qpci_config_readl(ahci->dev, PCI_BASE_ADDRESS_5); in ahci_test_pci_spec()
323 /* ABAR must be 32-bit, memory mapped, non-prefetchable and in ahci_test_pci_spec()
324 * must be >= 512 bytes. To that end, bits 0-8 must be off. */ in ahci_test_pci_spec()
328 datal = qpci_config_readl(ahci->dev, PCI_CAPABILITY_LIST); in ahci_test_pci_spec()
334 data = qpci_config_readw(ahci->dev, datal); in ahci_test_pci_spec()
336 switch (ahci->fingerprint) { in ahci_test_pci_spec()
342 /* AHCI 1.3, Section 2.1.14 -- CAP must point to PMCAP. */ in ahci_test_pci_spec()
349 datal = qpci_config_readl(ahci->dev, PCI_CAPABILITY_LIST + 4); in ahci_test_pci_spec()
353 datab = qpci_config_readb(ahci->dev, PCI_INTERRUPT_LINE); in ahci_test_pci_spec()
384 ahci_test_pci_caps(ahci, qpci_config_readw(ahci->dev, next), next); in ahci_test_pci_caps()
389 * Test SATA PCI capabilitity for AHCI specification adherence.
399 dataw = qpci_config_readw(ahci->dev, offset + 2); in ahci_test_satacap()
403 datal = qpci_config_readw(ahci->dev, offset + 4); in ahci_test_satacap()
433 dataw = qpci_config_readw(ahci->dev, offset + PCI_MSI_FLAGS); in ahci_test_msicap()
438 datal = qpci_config_readl(ahci->dev, offset + PCI_MSI_ADDRESS_LO); in ahci_test_msicap()
443 datal = qpci_config_readl(ahci->dev, offset + PCI_MSI_ADDRESS_HI); in ahci_test_msicap()
445 dataw = qpci_config_readw(ahci->dev, offset + PCI_MSI_DATA_64); in ahci_test_msicap()
449 dataw = qpci_config_readw(ahci->dev, offset + PCI_MSI_DATA_32); in ahci_test_msicap()
463 dataw = qpci_config_readw(ahci->dev, offset + PCI_PM_PMC); in ahci_test_pmcap()
469 dataw = qpci_config_readw(ahci->dev, offset + PCI_PM_CTRL); in ahci_test_pmcap()
488 * CAP.SSS - Support for staggered spin-up (t/f) in ahci_test_hba_spec()
489 * CAP.SMPS - Support for mechanical presence switches (t/f) in ahci_test_hba_spec()
490 * PI - Ports Implemented (1-32) in ahci_test_hba_spec()
491 * PxCMD.HPCP - Hot Plug Capable Port in ahci_test_hba_spec()
492 * PxCMD.MPSP - Mechanical Presence Switch Present in ahci_test_hba_spec()
493 * PxCMD.CPD - Cold Presence Detection support in ahci_test_hba_spec()
497 * -PxCMD.ST, PxCMD.CR, PxCMD.FRE, PxCMD.FR, PxSCTL.DET are 0 in ahci_test_hba_spec()
498 * -PxCLB/U and PxFB/U are set to valid regions in memory in ahci_test_hba_spec()
499 * -PxSUD is set to 1. in ahci_test_hba_spec()
500 * -PxSSTS.DET is polled for presence; if detected, we continue: in ahci_test_hba_spec()
501 * -PxSERR is cleared with 1's. in ahci_test_hba_spec()
502 * -If PxTFD.STS.BSY, PxTFD.STS.DRQ, and PxTFD.STS.ERR are all zero, in ahci_test_hba_spec()
506 /* 1 CAP - Capabilities Register */ in ahci_test_hba_spec()
507 ahci->cap = ahci_rreg(ahci, AHCI_CAP); in ahci_test_hba_spec()
508 ASSERT_BIT_CLEAR(ahci->cap, AHCI_CAP_RESERVED); in ahci_test_hba_spec()
510 /* 2 GHC - Global Host Control */ in ahci_test_hba_spec()
515 if (BITSET(ahci->cap, AHCI_CAP_SAM)) { in ahci_test_hba_spec()
516 g_test_message("Supports AHCI-Only Mode: GHC_AE is Read-Only."); in ahci_test_hba_spec()
523 /* 3 IS - Interrupt Status */ in ahci_test_hba_spec()
527 /* 4 PI - Ports Implemented */ in ahci_test_hba_spec()
529 /* Ports Implemented must be non-zero. */ in ahci_test_hba_spec()
533 g_assert_cmpuint(((AHCI_CAP_NP & ahci->cap) + 1), >=, nports_impl); in ahci_test_hba_spec()
538 g_assert_cmphex(ahci->barsize, >, 0); in ahci_test_hba_spec()
539 maxports = (ahci->barsize - HBA_DATA_REGION_SIZE) / HBA_PORT_DATA_SIZE; in ahci_test_hba_spec()
540 /* e.g, 30 ports for 4K of memory. (4096 - 256) / 128 = 30 */ in ahci_test_hba_spec()
558 if (BITSET(ahci->cap, AHCI_CAP_CCCS)) { in ahci_test_hba_spec()
574 if (BITCLR(ahci->cap, AHCI_CAP_EMS)) { in ahci_test_hba_spec()
580 if (BITSET(ahci->cap, AHCI_CAP_EMS)) { in ahci_test_hba_spec()
589 /* 10 CAP2 -- Capabilities Extended */ in ahci_test_hba_spec()
590 ahci->cap2 = ahci_rreg(ahci, AHCI_CAP2); in ahci_test_hba_spec()
591 ASSERT_BIT_CLEAR(ahci->cap2, AHCI_CAP2_RESERVED); in ahci_test_hba_spec()
593 /* 11 BOHC -- Bios/OS Handoff Control */ in ahci_test_hba_spec()
597 /* 12 -- 23: Reserved */ in ahci_test_hba_spec()
604 /* 24 -- 39: NVMHCI */ in ahci_test_hba_spec()
605 if (BITCLR(ahci->cap2, AHCI_CAP2_NVMP)) { in ahci_test_hba_spec()
613 /* 40 -- 63: Vendor */ in ahci_test_hba_spec()
620 /* 64 -- XX: Port Space */ in ahci_test_hba_spec()
630 "(reg [%u-%u]) is empty.", in ahci_test_hba_spec()
631 i, low, high - 1); in ahci_test_hba_spec()
653 if (BITCLR(ahci->cap, AHCI_CAP_S64A)) { in ahci_test_port_spec()
663 if (BITCLR(ahci->cap, AHCI_CAP_S64A)) { in ahci_test_port_spec()
699 if (BITCLR(ahci->cap, AHCI_CAP_SMPS)) { in ahci_test_port_spec()
710 if (BITCLR(ahci->cap, AHCI_CAP_FBSS)) { in ahci_test_port_spec()
734 * so we cannot expect a value here. AHCI 1.3, sec 3.3.9, pp 27-28 */ in ahci_test_port_spec()
770 if (BITSET(ahci->cap, AHCI_CAP_FBSS)) { in ahci_test_port_spec()
771 /* if Port-Multiplier FIS-based switching avail, ADO must >= 2 */ in ahci_test_port_spec()
775 /* [17 -- 27] RESERVED */ in ahci_test_port_spec()
781 /* [28 -- 31] Vendor-Specific */ in ahci_test_port_spec()
785 g_test_message("INFO: Vendor register %u non-empty", i); in ahci_test_port_spec()
810 * (3) Construct an FIS host-to-device command structure, and write it to in ahci_test_identify()
837 * Since we copy byte-for-byte in ahci-test, on both LE and BE, we need to in ahci_test_identify()
838 * unchunk this data. By contrast, ide-test copies 2 bytes at a time, and in ahci_test_identify()
874 qtest_bufwrite(ahci->parent->qts, ptr, tx, bufsize); in ahci_test_io_rw_simple()
878 qtest_memset(ahci->parent->qts, ptr, 0x00, bufsize); in ahci_test_io_rw_simple()
882 qtest_bufread(ahci->parent->qts, ptr, rx, bufsize); in ahci_test_io_rw_simple()
914 uint64_t config_sect = mb_to_sectors(test_image_size_mb) - 1; in ahci_test_max()
923 qtest_memread(ahci->parent->qts, ahci->port[port].fb + 0x40, d2h, 0x20); in ahci_test_max()
924 nsect = (uint64_t)d2h->lba_hi[2] << 40 | in ahci_test_max()
925 (uint64_t)d2h->lba_hi[1] << 32 | in ahci_test_max()
926 (uint64_t)d2h->lba_hi[0] << 24 | in ahci_test_max()
927 (uint64_t)d2h->lba_lo[2] << 16 | in ahci_test_max()
928 (uint64_t)d2h->lba_lo[1] << 8 | in ahci_test_max()
929 (uint64_t)d2h->lba_lo[0]; in ahci_test_max()
951 * Ensure that the PCI configuration space for the AHCI device is in-line with
1039 ptr = guest_alloc(&ahci->parent->alloc, bufsize); in test_dma_fragmented()
1041 qtest_bufwrite(ahci->parent->qts, ptr, tx, bufsize); in test_dma_fragmented()
1058 qtest_bufread(ahci->parent->qts, ptr, rx, bufsize); in test_dma_fragmented()
1059 guest_free(&ahci->parent->alloc, ptr); in test_dma_fragmented()
1108 ahci = ahci_boot_and_enable("-drive file=blkdebug:%s:%s,if=none,id=drive0," in test_flush_retry()
1111 "-M q35 " in test_flush_retry()
1112 "-device ide-hd,drive=drive0 ", in test_flush_retry()
1137 src = ahci_boot("-m 384 -M q35 " in test_migrate_sanity()
1138 "-drive if=ide,file=%s,format=%s ", tmp_path, imgfmt); in test_migrate_sanity()
1139 dst = ahci_boot("-m 384 -M q35 " in test_migrate_sanity()
1140 "-drive if=ide,file=%s,format=%s " in test_migrate_sanity()
1141 "-incoming %s", tmp_path, imgfmt, uri); in test_migrate_sanity()
1162 src = ahci_boot_and_enable("-m 384 -M q35 " in ahci_migrate_simple()
1163 "-drive if=ide,format=%s,file=%s ", in ahci_migrate_simple()
1165 dst = ahci_boot("-m 384 -M q35 " in ahci_migrate_simple()
1166 "-drive if=ide,format=%s,file=%s " in ahci_migrate_simple()
1167 "-incoming %s", imgfmt, tmp_path, uri); in ahci_migrate_simple()
1220 ahci = ahci_boot_and_enable("-drive file=blkdebug:%s:%s,if=none,id=drive0," in ahci_halted_io_test()
1223 "-M q35 " in ahci_halted_io_test()
1224 "-device ide-hd,drive=drive0 ", in ahci_halted_io_test()
1236 qtest_memwrite(ahci->parent->qts, ptr, tx, bufsize); in ahci_halted_io_test()
1286 src = ahci_boot_and_enable("-drive file=blkdebug:%s:%s,if=none,id=drive0," in ahci_migrate_halted_io()
1289 "-M q35 " in ahci_migrate_halted_io()
1290 "-device ide-hd,drive=drive0 ", in ahci_migrate_halted_io()
1294 dst = ahci_boot("-drive file=%s,if=none,id=drive0," in ahci_migrate_halted_io()
1297 "-M q35 " in ahci_migrate_halted_io()
1298 "-device ide-hd,drive=drive0 " in ahci_migrate_halted_io()
1299 "-incoming %s", in ahci_migrate_halted_io()
1310 qtest_memwrite(src->parent->qts, ptr, tx, bufsize); in ahci_migrate_halted_io()
1355 src = ahci_boot_and_enable("-drive file=blkdebug:%s:%s,if=none,id=drive0," in test_flush_migrate()
1358 "-M q35 " in test_flush_migrate()
1359 "-device ide-hd,drive=drive0 ", in test_flush_migrate()
1361 dst = ahci_boot("-drive file=%s,if=none,id=drive0," in test_flush_migrate()
1364 "-M q35 " in test_flush_migrate()
1365 "-device ide-hd,drive=drive0 " in test_flush_migrate()
1366 "-incoming %s", tmp_path, imgfmt, uri); in test_flush_migrate()
1378 qtest_qmp_eventwait(src->parent->qts, "STOP"); in test_flush_migrate()
1384 qtest_qmp_send(dst->parent->qts, "{'execute':'cont' }"); in test_flush_migrate()
1385 qtest_qmp_eventwait(dst->parent->qts, "RESUME"); in test_flush_migrate()
1446 ahci = ahci_boot_and_enable("-drive if=none,id=drive0,file=%s," in test_reset_pending_callback()
1448 "throttling.bps-write=%d " in test_reset_pending_callback()
1449 "-M q35 " in test_reset_pending_callback()
1450 "-device ide-hd,drive=drive0 ", in test_reset_pending_callback()
1467 qtest_bufwrite(ahci->parent->qts, ptr1, tx1, bufsize); in test_reset_pending_callback()
1468 qtest_bufwrite(ahci->parent->qts, ptr2, tx2, bufsize); in test_reset_pending_callback()
1495 qtest_bufread(ahci->parent->qts, ptr1, rx1, bufsize); in test_reset_pending_callback()
1499 qtest_bufread(ahci->parent->qts, ptr2, rx2, bufsize); in test_reset_pending_callback()
1528 g_assert(fd != -1); in prepare_iso()
1553 unsigned char *tx = opts->opaque; in ahci_cb_cmp_buff()
1556 if (!opts->size) { in ahci_cb_cmp_buff()
1560 rx = g_malloc0(opts->size); in ahci_cb_cmp_buff()
1561 qtest_bufread(ahci->parent->qts, opts->buffer, rx, opts->size); in ahci_cb_cmp_buff()
1562 g_assert_cmphex(memcmp(tx, rx, opts->size), ==, 0); in ahci_cb_cmp_buff()
1589 /* Standard startup wonkery, but use ide-cd and our special iso file */ in ahci_test_cdrom()
1590 ahci = ahci_boot_and_enable("-drive if=none,id=drive0,file=%s,format=raw " in ahci_test_cdrom()
1591 "-M q35 " in ahci_test_cdrom()
1592 "-device ide-cd,drive=drive0 ", iso); in ahci_test_cdrom()
1638 QDict *rsp = qtest_qmp_eventwait_ref(ahci->parent->qts, in atapi_wait_tray()
1642 g_assert(qdict_get_bool(data, "tray-open")); in atapi_wait_tray()
1644 g_assert(!qdict_get_bool(data, "tray-open")); in atapi_wait_tray()
1660 ahci = ahci_boot_and_enable("-blockdev node-name=drive0,driver=file,filename=%s " in test_atapi_tray()
1661 "-M q35 " in test_atapi_tray()
1662 "-device ide-cd,id=cd0,drive=drive0 ", iso); in test_atapi_tray()
1672 qtest_qmp_send(ahci->parent->qts, "{'execute': 'blockdev-open-tray', " in test_atapi_tray()
1675 rsp = qtest_qmp_receive(ahci->parent->qts); in test_atapi_tray()
1678 qtest_qmp_assert_success(ahci->parent->qts, in test_atapi_tray()
1679 "{'execute': 'blockdev-remove-medium', " in test_atapi_tray()
1689 /* Re-insert media */ in test_atapi_tray()
1691 ahci->parent->qts, in test_atapi_tray()
1692 "{'execute': 'blockdev-add', " in test_atapi_tray()
1693 "'arguments': {'node-name': 'node0', " in test_atapi_tray()
1698 ahci->parent->qts, in test_atapi_tray()
1699 "{'execute': 'blockdev-insert-medium'," in test_atapi_tray()
1701 "'node-name': 'node0' }}"); in test_atapi_tray()
1704 qtest_qmp_send(ahci->parent->qts, "{'execute': 'blockdev-close-tray', " in test_atapi_tray()
1707 rsp = qtest_qmp_receive(ahci->parent->qts); in test_atapi_tray()
1809 ceil = MIN(ceil, mb_to_sectors(test_image_size_mb) - 1); in offset_sector()
1811 return ceil - nsectors + 1; in offset_sector()
1864 switch (opts->length) { in test_io_interface()
1881 sector = offset_sector(opts->offset, opts->address_type, bufsize); in test_io_interface()
1882 test_io_rw_interface(opts->address_type, opts->io_type, bufsize, sector); in test_io_interface()
1894 opts->length = len; in create_ahci_io_test()
1895 opts->address_type = addr; in create_ahci_io_test()
1896 opts->io_type = type; in create_ahci_io_test()
1897 opts->offset = offset; in create_ahci_io_test()
1937 if (c == -1) { in main()
1941 case -1: in main()
1955 g_test_message("Skipping test for non-x86"); in main()
1981 g_test_message("QTEST_QEMU_IMG not set or qemu-img missing; " in main()
1982 "skipping LBA48 high-sector tests"); in main()
1991 debug_path = g_strdup_printf("%s/qtest-blkdebug.XXXXXX", base); in main()
1997 fd = g_file_open_tmp("qtest-migration.XXXXXX", &mig_socket, NULL); in main()