- Timestamp:
- Dec 13, 2016, 3:07:49 AM (9 years ago)
- Location:
- trunk/src/os2ahci
- Files:
-
- 8 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, -
trunk/src/os2ahci/ata.c
r178 r181 287 287 cmd_hdr->options |= n << 16; 288 288 289 if (D32g_DbgLevel >= 2)290 { 291 DPRINTF( 2,"ATA command for %d.%d.%d, slot %d:\n", ad_no(ai), p, d, slot);289 if (D32g_DbgLevel >= 7) 290 { 291 DPRINTF(0,"ATA command for %d.%d.%d, slot %d:\n", ad_no(ai), p, d, slot); 292 292 dHexDump(0,cmd_hdr, offsetof(AHCI_CMD_HDR, reserved), "cmd_hdr: "); 293 293 dHexDump(0,&ata_cmd, sizeof(ata_cmd), "ata_cmd: "); … … 834 834 int rc; 835 835 836 DPRINTF( 3,"ata_read_unaligned(%d.%d.%d, %d)\n", ad_no(ai), p, d, sector);836 DPRINTF(7,"ata_read_unaligned(%d.%d.%d, %d)\n", ad_no(ai), p, d, sector); 837 837 838 838 /* allocate transfer buffer */ … … 883 883 884 884 io->BlocksXferred += add_workspace(pIorb)->blocks; 885 DPRINTF( 3,"ata_read_pp(): blocks transferred = %d\n", io->BlocksXferred);885 DPRINTF(7,"ata_read_pp(): blocks transferred = %d\n", io->BlocksXferred); 886 886 887 887 if (io->BlocksXferred >= io->BlockCount) … … 1020 1020 int rc; 1021 1021 1022 DPRINTF( 3,"ata_write_unaligned(%d.%d.%d, %d)\n", ad_no(ai), p, d, sector);1022 DPRINTF(7,"ata_write_unaligned(%d.%d.%d, %d)\n", ad_no(ai), p, d, sector); 1023 1023 1024 1024 /* allocate transfer buffer */ … … 1068 1068 1069 1069 io->BlocksXferred += add_workspace(pIorb)->blocks; 1070 DPRINTF( 3,"ata_write_pp(): blocks transferred = %d\n", io->BlocksXferred);1070 DPRINTF(7,"ata_write_pp(): blocks transferred = %d\n", io->BlocksXferred); 1071 1071 1072 1072 if (io->BlocksXferred >= io->BlockCount) -
trunk/src/os2ahci/atapi.c
r178 r181 31 31 32 32 /* need this for the SCSI status block */ 33 #include < scsi.h>33 #include <Dev32scsi.h> 34 34 35 35 /* -------------------------- macros and constants ------------------------- */ … … 51 51 int atapi_get_geometry(IORBH FAR16DATA *vIorb, IORBH *pIorb, int slot) 52 52 { 53 DPRINTF( 2,"atapi_get_geometry called\n");53 DPRINTF(4,"atapi_get_geometry called\n"); 54 54 iorb_seterr(pIorb, IOERR_CMD_NOT_SUPPORTED); 55 55 return(-1); … … 61 61 int atapi_unit_ready(IORBH FAR16DATA *vIorb, IORBH *pIorb, int slot) 62 62 { 63 DPRINTF( 2,"atapi_unit_ready called\n");63 DPRINTF(4,"atapi_unit_ready called\n"); 64 64 iorb_seterr(pIorb, IOERR_CMD_NOT_SUPPORTED); 65 65 return(-1); … … 102 102 SET_CDB_32(cdb.lba, io->RBA + io->BlocksXferred); 103 103 104 DPRINTF(4, "atapi_read\n"); 105 104 106 do { 105 107 /* update sector count (might have been updated due to S/G limitations) */ … … 173 175 SET_CDB_32(cdb.trans_len, 1UL); 174 176 177 DPRINTF(4, "atapi_read_unaligned\n"); 178 175 179 /* allocate transfer buffer */ 176 180 if ((aws->buf = MemAlloc(io->BlockSize)) == NULL) … … 212 216 int atapi_verify(IORBH FAR16DATA *vIorb, IORBH *pIorb, int slot) 213 217 { 214 DPRINTF( 3,"atapi_verify called\n");218 DPRINTF(4,"atapi_verify called\n"); 215 219 iorb_seterr(pIorb, IOERR_CMD_NOT_SUPPORTED); 216 220 return(-1); … … 222 226 int atapi_write(IORBH FAR16DATA *vIorb, IORBH *pIorb, int slot) 223 227 { 224 DPRINTF( 3,"atapi_write called\n");228 DPRINTF(4,"atapi_write called\n"); 225 229 iorb_seterr(pIorb, IOERR_CMD_NOT_SUPPORTED); 226 230 return(-1); … … 244 248 } 245 249 /* AHCI requires 12 or 16 byte commands */ 246 atapi_pad_cdb(Far16ToFlat(pt->pControllerCmd), pt->ControllerCmdLen, 247 (u8 *) cdb, (u16 *) &cdb_len); 250 atapi_pad_cdb(Far16ToFlat(pt->pControllerCmd), pt->ControllerCmdLen, cdb, &cdb_len); 248 251 249 252 if (cdb[0] == 0x12 || cdb[0] == 0x5a) … … 293 296 size_t sense_buf_len = ATAPI_SENSE_LEN; 294 297 295 DPRINTF( 2,"atapi_req_sense\n");298 DPRINTF(4,"atapi_req_sense\n"); 296 299 297 300 if ((pIorb->RequestControl & IORB_REQ_STATUSBLOCK) && … … 386 389 if (ssb->SenseData != NULL) 387 390 { 388 memcpy( ssb->SenseData, psd, ssb->ReqSenseLen);391 memcpy(Far16ToFlat(ssb->SenseData), psd, ssb->ReqSenseLen); 389 392 ssb->Flags |= STATUS_SENSEDATA_VALID; 390 393 } -
trunk/src/os2ahci/ctxhook.c
r178 r181 102 102 int p; 103 103 104 DPRINTF(2,"restart_ctxhook() started\n"); 104 D32ThunkStackTo32(); 105 106 DPRINTF(8,"restart_ctxhook() started\n"); 105 107 memset(&done_queue, 0x00, sizeof(done_queue)); 106 108 … … 129 131 need_reset = 0; 130 132 131 DPRINTF( 2,"port %d, TF_DATA: 0x%x\n", p, readl(port_mmio + PORT_TFDATA));133 DPRINTF(8,"port %d, TF_DATA: 0x%x\n", p, readl(port_mmio + PORT_TFDATA)); 132 134 133 135 /* get "current command slot"; only valid if there are no NCQ cmds */ 134 136 ccs = (int) ((readl(port_mmio + PORT_CMD) >> 8) & 0x1f); 135 DPRINTF( 3," PORT_CMD = 0x%x\n", ccs);137 DPRINTF(8," PORT_CMD = 0x%x\n", ccs); 136 138 137 139 for (vIorb = ai->ports[p].iorb_queue.vRoot; vIorb != NULL; vIorb = vNext) … … 283 285 spin_unlock(drv_lock); 284 286 285 DPRINTF( 2,"restart_ctxhook() completed\n");287 DPRINTF(8,"restart_ctxhook() completed\n"); 286 288 287 289 /* Check whether we have to rearm ourselves because some adapters were busy … … 293 295 KernArmHook(restart_ctxhook_h, 0, 0); 294 296 } 297 KernThunkStackTo16(); 295 298 } 296 299 … … 331 334 int p; 332 335 333 DPRINTF(2,"reset_ctxhook() started\n"); 336 D32ThunkStackTo32(); 337 338 DPRINTF(8,"reset_ctxhook() started\n"); 334 339 memset(&done_queue, 0x00, sizeof(done_queue)); 335 340 … … 455 460 spin_unlock(drv_lock); 456 461 457 DPRINTF( 2,"reset_ctxhook() completed\n");462 DPRINTF(8,"reset_ctxhook() completed\n"); 458 463 459 464 /* Check whether we have to rearm ourselves because some adapters were busy … … 465 470 KernArmHook(reset_ctxhook_h, 0, 0); 466 471 } 472 473 KernThunkStackTo16(); 467 474 } 468 475 … … 478 485 int i; 479 486 480 DPRINTF(2,"engine_ctxhook() started\n"); 487 D32ThunkStackTo32(); 488 489 DPRINTF(8,"engine_ctxhook() started\n"); 481 490 if (resume_sleep_flag) 482 491 { … … 492 501 spin_unlock(drv_lock); 493 502 494 DPRINTF( 2,"engine_ctxhook() completed\n");503 DPRINTF(8,"engine_ctxhook() completed\n"); 495 504 496 505 if (iorbs_sent != 0) … … 500 509 KernArmHook(engine_ctxhook_h, 0, 0); 501 510 } 511 512 KernThunkStackTo16(); 502 513 } 503 514 -
trunk/src/os2ahci/ioctl.c
r179 r181 31 31 #include "ioctl.h" 32 32 33 #include < scsi.h>33 #include <Dev32scsi.h> 34 34 35 35 #pragma pack(1) … … 191 191 ic->iorb.iorbh.pStatusBlock = CastFar16ToULONG(MemFar16Adr(&ic->ssb)); 192 192 ic->iorb.iorbh.StatusBlockLen = sizeof(ic->ssb); 193 ic->ssb.SenseData = (SCSI_REQSENSE_DATA *) ic->sense;193 ic->ssb.SenseData = MemFar16Adr(ic->sense); 194 194 ic->ssb.ReqSenseLen = sizeof(ic->sense); 195 195 ic->iorb.iorbh.RequestControl |= IORB_REQ_STATUSBLOCK; … … 268 268 (ic->ssb.Flags | STATUS_SENSEDATA_VALID)) 269 269 { 270 memcpy(sense_buf, ic->s sb.SenseData, min(ic->ssb.ReqSenseLen, req->sense_len));270 memcpy(sense_buf, ic->sense, min(ic->ssb.ReqSenseLen, req->sense_len)); 271 271 } 272 272 -
trunk/src/os2ahci/os2ahci.c
r178 r181 606 606 * link in 'vNext'. 607 607 */ 608 vNext = (pIorb->RequestControl | IORB_CHAIN) ? pIorb->pNxtIORB : NULL; 608 if (pIorb->RequestControl & IORB_CHAIN) vNext = pIorb->pNxtIORB; 609 else vNext = (IORBH FAR16DATA *)0; 609 610 610 611 pIorb->Status = 0; … … 1317 1318 */ 1318 1319 char *queue_type; 1319 int min_debug = 1;1320 int min_debug = 7; 1320 1321 1321 1322 if ((u32)queue >> 16 == (u32)&queue >> 16) /* DAZ this is bogus */ … … 1323 1324 /* this queue is on the stack */ 1324 1325 queue_type = "local"; 1325 min_debug = 2;1326 min_debug = 8; 1326 1327 1327 1328 } … … 1334 1335 { 1335 1336 queue_type = "abort"; 1336 min_debug = 2;1337 min_debug = 8; 1337 1338 1338 1339 } … … 1386 1387 if (found) 1387 1388 { 1388 DPRINTF( 3,"IORB %x removed (queue = %x)\n", vIorb, queue);1389 DPRINTF(8,"IORB %x removed (queue = %x)\n", vIorb, queue); 1389 1390 } 1390 1391 else … … 1458 1459 pIorb->Status |= IORB_DONE; 1459 1460 1460 DPRINTF( 1,"IORB %x complete status=0x%04x error=0x%04x\n",1461 DPRINTF(7,"IORB %x complete status=0x%04x error=0x%04x\n", 1461 1462 vIorb, pIorb->Status, pIorb->ErrorCode); 1462 1463 -
trunk/src/os2ahci/os2ahci.h
r178 r181 301 301 302 302 u32 dma_buf_phys[AHCI_MAX_PORTS]; /* physical address of DMA scratch buffer */ 303 u8 *dma_buf[AHCI_MAX_PORTS]; /* DMA scatch buffers */303 u8 *dma_buf[AHCI_MAX_PORTS]; /* DMA scatch buffers */ 304 304 305 305 P_INFO ports[AHCI_MAX_PORTS]; /* SATA ports on this adapter */ -
trunk/src/os2ahci/trace.c
r178 r181 78 78 pi->devs[d].dev_info.Cylinders, pi->devs[d].dev_info.HeadsPerCylinder, pi->devs[d].dev_info.SectorsPerTrack, 79 79 pi->devs[d].dev_info.TotalSectors/2048, pi->devs[d].dev_info.Method); 80 } else NTPRINTF(" Drive present but no information available.");80 } 81 81 NTPRINTF("\n"); 82 82 } /* if */
Note:
See TracChangeset
for help on using the changeset viewer.