Changeset 181 for trunk/src/os2ahci/ahci.c
- Timestamp:
- Dec 13, 2016, 3:07:49 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/ahci.c
r178 r181 207 207 #endif 208 208 209 int AllocPortData(AD_INFO *ai, int p) 210 { 211 if (ai->ports[p]) return 0; 212 ai->ports[p] = MemAlloc(sizeof(P_INFO)); 213 if (ai->ports[p] == NULL) return 1; 214 memset(ai->ports[p], 0, sizeof(P_INFO)); 215 return 0; 216 } 217 218 FreePortData(AD_INFO *ai, int p) 219 { 220 } 221 209 222 /****************************************************************************** 210 223 * Save BIOS configuration of AHCI adapter. As a side effect, this also saves … … 605 618 if (port_ignore[ad_no(ai)][p]) continue; 606 619 620 // DAZ allocate port structure here 621 607 622 DPRINTF(3,"ahci_scan_ports: Wait till not busy on port %d\n", p); 608 623 /* wait until all active commands have completed on this port */ … … 629 644 rc = ahci_start_port(ai, p, 0); 630 645 } 631 if (rc) 632 { 633 /* no device attached to this port */ 634 ai->port_map &= ~(1UL << p); 635 goto restore_port_config; 636 } 637 638 /* this port seems to have a device attached and ready for commands */ 639 DPRINTF(1,"ahci_scan_ports: port %d seems to be attached to a device; probing...\n", p); 640 641 /* Get ATA(PI) identity. The so-called signature gives us a hint whether 642 * this is an ATA or an ATAPI device but we'll try both in either case; 643 * the signature will merely determine whether we're going to probe for 644 * an ATA or ATAPI device, first, in order to reduce the chance of sending 645 * the wrong command (which would result in a port reset given the way 646 * ahci_exec_polled_cmd() was implemented). 647 */ 648 is_ata = readl(port_base(ai, p) + PORT_SIG) == 0x00000101UL; 649 for (i = 0; i < 2; i++) 650 { 651 rc = ahci_exec_polled_cmd(ai, p, 0, 500, 652 (is_ata) ? ATA_CMD_ID_ATA : ATA_CMD_ID_ATAPI, 653 AP_VADDR, (void *) id_buf, ATA_ID_WORDS * sizeof(u16), 654 AP_END); 655 if (rc == 0) break; 656 657 /* try again with ATA/ATAPI swapped */ 658 is_ata = !is_ata; 646 647 if (rc == 0) 648 { 649 /* this port seems to have a device attached and ready for commands */ 650 DPRINTF(1,"ahci_scan_ports: port %d seems to be attached to a device; probing...\n", p); 651 652 /* Get ATA(PI) identity. The so-called signature gives us a hint whether 653 * this is an ATA or an ATAPI device but we'll try both in either case; 654 * the signature will merely determine whether we're going to probe for 655 * an ATA or ATAPI device, first, in order to reduce the chance of sending 656 * the wrong command (which would result in a port reset given the way 657 * ahci_exec_polled_cmd() was implemented). 658 */ 659 is_ata = readl(port_base(ai, p) + PORT_SIG) == 0x00000101UL; 660 for (i = 0; i < 2; i++) 661 { 662 rc = ahci_exec_polled_cmd(ai, p, 0, 500, 663 (is_ata) ? ATA_CMD_ID_ATA : ATA_CMD_ID_ATAPI, 664 AP_VADDR, (void *) id_buf, ATA_ID_WORDS * sizeof(u16), 665 AP_END); 666 if (rc == 0) break; 667 668 /* try again with ATA/ATAPI swapped */ 669 is_ata = !is_ata; 670 } 659 671 } 660 672 … … 669 681 /* no device attached to this port */ 670 682 ai->port_map &= ~(1UL << p); 671 } 672 673 restore_port_config: 674 if (pc != NULL) { 675 ahci_restore_port_config(ai, p, pc); 676 } 683 // DAZ free port structure here 684 } 685 686 if (pc != NULL) ahci_restore_port_config(ai, p, pc); 677 687 } 678 688 … … 1096 1106 } 1097 1107 1098 DPRINTF( 1,"---------- ahci_exec_iorb: iorb=%x\n", vIorb);1108 DPRINTF(7,"---------- ahci_exec_iorb: iorb=%x\n", vIorb); 1099 1109 1100 1110 /* Enable AHCI mode; apparently, the AHCI mode may end up becoming … … 1122 1132 cmd_max = ai->cmd_max; 1123 1133 } 1124 DPRINTF( 3,"NCQ command; cmd_max = %d->%d\n", ai->cmd_max, cmd_max);1134 DPRINTF(8,"NCQ command; cmd_max = %d->%d\n", ai->cmd_max, cmd_max); 1125 1135 } 1126 1136 … … 1175 1185 aws->cmd_slot = port->cmd_slot; 1176 1186 1177 DPRINTF( 1,"Issuing command Slot=%d cmds=%x\n", port->cmd_slot, *cmds);1187 DPRINTF(7,"Issuing command Slot=%d cmds=%x\n", port->cmd_slot, *cmds); 1178 1188 if (aws->is_ncq) 1179 1189 { … … 1432 1442 * queues, ...) 1433 1443 */ 1434 u32 DazCount = 0;1435 1436 1444 int ahci_intr(u16 irq) 1437 1445 { … … 1440 1448 int a; 1441 1449 int p; 1442 1443 DPRINTF(1,"AI=%x",DazCount++);1444 1450 1445 1451 /* find adapter(s) with pending interrupts */ … … 1530 1536 readl(port_mmio + PORT_IRQ_STAT); /* flush */ 1531 1537 1532 DPRINTF(3,"port interrupt A=%d Port=%d stat=%x\n", ad_no(ai), p, irq_stat);1533 1538 memset(&done_queue, 0x00, sizeof(done_queue)); 1534 1539 … … 1556 1561 active_cmds = readl(port_mmio + PORT_SCR_ACT); 1557 1562 done_mask = ai->ports[p].ncq_cmds ^ active_cmds; 1558 DPRINTF( 1,"[ncq_cmds]: active_cmds=0x%08x done_mask=0x%08x\n", active_cmds, done_mask);1563 DPRINTF(7,"[ncq_cmds]: active_cmds=0x%08x done_mask=0x%08x\n", active_cmds, done_mask); 1559 1564 } 1560 1565 else … … 1562 1567 active_cmds = readl(port_mmio + PORT_CMD_ISSUE); 1563 1568 done_mask = ai->ports[p].reg_cmds ^ active_cmds; 1564 DPRINTF( 1,"[reg_cmds]: active_cmds=0x%08x done_mask=0x%08x\n", active_cmds, done_mask);1569 DPRINTF(7,"[reg_cmds]: active_cmds=0x%08x done_mask=0x%08x\n", active_cmds, done_mask); 1565 1570 } 1566 1571 … … 1681 1686 { 1682 1687 #ifdef DEBUG 1683 DPRINTF( 2,"ahci_get_geometry(%d.%d.%d)\n", iorb_unit_adapter(pIorb),1688 DPRINTF(7,"ahci_get_geometry(%d.%d.%d)\n", iorb_unit_adapter(pIorb), 1684 1689 iorb_unit_port(pIorb), iorb_unit_device(pIorb)); 1685 1690 #endif … … 1694 1699 { 1695 1700 #ifdef DEBUG 1696 DPRINTF( 2,"ahci_unit_ready(%d.%d.%d)\n", iorb_unit_adapter(pIorb),1701 DPRINTF(7,"ahci_unit_ready(%d.%d.%d)\n", iorb_unit_adapter(pIorb), 1697 1702 iorb_unit_port(pIorb), iorb_unit_device(pIorb)); 1698 1703 #endif … … 1707 1712 { 1708 1713 #ifdef DEBUG 1709 DPRINTF( 2,"ahci_read(%d.%d.%d, %d, %d)\n", iorb_unit_adapter(vIorb),1714 DPRINTF(7,"ahci_read(%d.%d.%d, %d, %d)\n", iorb_unit_adapter(vIorb), 1710 1715 iorb_unit_port(pIorb), iorb_unit_device(pIorb), 1711 1716 ((IORB_EXECUTEIO *) pIorb)->RBA, … … 1722 1727 { 1723 1728 #ifdef DEBUG 1724 DPRINTF( 2,"ahci_verify(%d.%d.%d, %d, %d)\n", iorb_unit_adapter(pIorb),1729 DPRINTF(7,"ahci_verify(%d.%d.%d, %d, %d)\n", iorb_unit_adapter(pIorb), 1725 1730 iorb_unit_port(pIorb), iorb_unit_device(pIorb), 1726 1731 ((IORB_EXECUTEIO *)pIorb)->RBA, … … 1737 1742 { 1738 1743 #ifdef DEBUG 1739 DPRINTF( 2,"ahci_write(%d.%d.%d, %d, %d)\n", iorb_unit_adapter(pIorb),1744 DPRINTF(7,"ahci_write(%d.%d.%d, %d, %d)\n", iorb_unit_adapter(pIorb), 1740 1745 iorb_unit_port(pIorb), iorb_unit_device(pIorb), 1741 1746 ((IORB_EXECUTEIO *)pIorb)->RBA,
Note:
See TracChangeset
for help on using the changeset viewer.