Changeset 82 for trunk/src/os2ahci/ata.c
- Timestamp:
- Mar 2, 2011, 11:48:03 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/ata.c
r80 r82 137 137 /* ATA device byte; note that this byte contains the highest 138 138 * 4 bits of LBA-28 address; we have to leave them alone here. */ 139 ata_cmd.device |= (va_arg(va, u16) & 0xf000U) >> 8;139 ata_cmd.device |= va_arg(va, u16) & 0xf0U; 140 140 break; 141 141 … … 202 202 memset(cmd_hdr, 0x00, sizeof(*cmd_hdr)); 203 203 cmd_hdr->options = ((d & 0x0f) << 12); 204 cmd_hdr->options |= ahci_flags; /* AHCI comma and flags */204 cmd_hdr->options |= ahci_flags; /* AHCI command flags */ 205 205 cmd_hdr->options |= 5; /* length of command FIS in 32-bit words */ 206 206 cmd_hdr->tbl_addr = dma_base_phys + offsetof(AHCI_PORT_DMA, cmd_tbl[slot]); … … 435 435 USHORT geometry_len = ((IORB_GEOMETRY _far *) iorb)->GeometryLen; 436 436 u16 *id_buf = add_workspace(iorb)->buf; 437 int a = iorb_unit_adapter(iorb); 438 int p = iorb_unit_port(iorb); 437 439 438 440 /* Fill-in geometry information; the ATA-8 spec declares the geometry … … 444 446 * - 512 bytes per sector 445 447 * - 255 heads 446 * - 63 sectors per track 448 * - 63 sectors per track (or 56 with the parameter "/4") 447 449 * - x cylinders (calculated) 448 450 * 449 * Please note that os2ahci currently does not support ATA sectors larger450 * than 512 bytes, therefore relies on the translation logic built into the451 * corresponding ATA disks. In theory, partitions should be aligned to the452 * large sectors to prevent needless mapping all over the place but HPFS453 * uses logical block sizes smaller than the typical large sectors found on454 * modern hard disks so this won't make much of a difference. Large sector455 * support will be evaluated at a later time (it's unclear right now whether456 * HPFS would even support anything larger than 512 bytes).451 * Please note that os2ahci currently does not natively support ATA sectors 452 * larger than 512 bytes, therefore relies on the translation logic built 453 * into the corresponding ATA disks. In order to prevent file systems that 454 * use block sizes larger than 512 bytes (FAT, JFS, ...) from ending up on 455 * incorrectly aligned physical sector accesses, hence using more physical 456 * I/Os than necessary, the command line parameter "/4" can be used to force 457 * a track size of 56 sectors. This way, partitions will start on 4K 458 * boundaries. 457 459 * 458 460 * Another limitation is that OS/2 has a 32-bit variable for the total number … … 464 466 */ 465 467 memset(geometry, 0x00, geometry_len); 466 geometry->BytesPerSector = 512;468 geometry->BytesPerSector = ATA_SECTOR_SIZE; 467 469 468 470 /* extract total number of sectors */ … … 483 485 } 484 486 485 /* see whether the "current" (read: BIOS-supplied) geometry looks OK */ 486 if (CUR_HEADS(id_buf) > 0 && CUR_CYLS(id_buf) > 0 && 487 CUR_SECTORS(id_buf) > 0 && 488 CUR_CAPACITY(id_buf) == CUR_HEADS(id_buf) * 489 CUR_CYLS(id_buf) * 490 CUR_SECTORS(id_buf)) { 491 /* use BIOS-supplied values for geometry */ 487 /* fabricate the remaining geometry fields */ 488 if (track_size[a][p] != 0) { 489 /* A specific track size has been requested for this port; this is 490 * typically done for disks with 4K sectors to make sure partitions 491 * start on 8-sector boundaries (parameter "/4"). 492 */ 493 geometry->NumHeads = 255; 494 geometry->SectorsPerTrack = track_size[a][p]; 495 geometry->TotalCylinders = geometry->TotalSectors / 496 ((u32) geometry->NumHeads * 497 (u32) geometry->SectorsPerTrack); 498 499 } else if (CUR_HEADS(id_buf) > 0 && CUR_CYLS(id_buf) > 0 && 500 CUR_SECTORS(id_buf) > 0 && 501 CUR_CAPACITY(id_buf) == CUR_HEADS(id_buf) * 502 CUR_CYLS(id_buf) * 503 CUR_SECTORS(id_buf)) { 504 /* BIOS-supplied (aka "current") geometry values look valid */ 492 505 geometry->NumHeads = CUR_HEADS(id_buf); 493 506 geometry->SectorsPerTrack = CUR_SECTORS(id_buf); … … 496 509 } else if (ATA_HEADS(id_buf) > 0 && ATA_CYLS(id_buf) > 0 && 497 510 ATA_SECTORS(id_buf) > 0) { 498 /* use ATA-supplied values for geometry*/511 /* ATA-supplied values for geometry look valid */ 499 512 geometry->NumHeads = ATA_HEADS(id_buf); 500 513 geometry->SectorsPerTrack = ATA_SECTORS(id_buf); … … 549 562 int d = iorb_unit_device(iorb); 550 563 int rc; 564 565 /* Kludge: some I/O commands during boot use excessive S/G buffer lengths 566 * which cause NCQ commands to lock up. If there's only one S/G element 567 * and this element is already larger than what we can derive from the sector 568 * count, we'll adjust that element. 569 */ 570 if (io->BlocksXferred == 0 && io->cSGList == 1 && 571 io->pSGList[0].XferBufLen > io->BlockCount * io->BlockSize) { 572 io->pSGList[0].XferBufLen = io->BlockCount * io->BlockSize; 573 } 551 574 552 575 /* prepare read command while keeping an eye on S/G count limitations */ … … 568 591 AP_COUNT, (u16) (slot << 3), /* tag = slot */ 569 592 AP_SGLIST, io->pSGList + sg_indx, (u16) sg_cnt, 570 AP_DEVICE, 0x40 00,593 AP_DEVICE, 0x40, 571 594 AP_END); 572 595 } else { … … 575 598 AP_COUNT, (u16) count, 576 599 AP_SGLIST, io->pSGList + sg_indx, (u16) sg_cnt, 577 AP_DEVICE, 0x40 00,600 AP_DEVICE, 0x40, 578 601 AP_END); 579 602 } … … 584 607 AP_COUNT, (u16) count & 0xffU, 585 608 AP_SGLIST, io->pSGList + sg_indx, (u16) sg_cnt, 586 AP_DEVICE, 0x40 00,609 AP_DEVICE, 0x40, 587 610 AP_END); 588 611 } … … 650 673 AP_SECTOR_48, (u32) io->RBA, (u16) 0, 651 674 AP_COUNT, (u16) io->BlockCount, 652 AP_DEVICE, 0x40 00,675 AP_DEVICE, 0x40, 653 676 AP_END); 654 677 } else { … … 695 718 AP_COUNT, (u16) (slot << 3), /* tag = slot */ 696 719 AP_SGLIST, io->pSGList + sg_indx, (u16) sg_cnt, 697 AP_DEVICE, 0x40 00,720 AP_DEVICE, 0x40, 698 721 AP_DEVICE, (io->Flags & XIO_DISABLE_HW_WRITE_CACHE) ? 699 0x80 00: 0, /* force unit access */722 0x80 : 0, /* force unit access */ 700 723 AP_WRITE, 1, 701 724 AP_END); … … 705 728 AP_COUNT, (u16) count, 706 729 AP_SGLIST, io->pSGList + sg_indx, (u16) sg_cnt, 707 AP_DEVICE, 0x40 00,730 AP_DEVICE, 0x40, 708 731 AP_WRITE, 1, 709 732 AP_END); … … 715 738 AP_COUNT, (u16) count & 0xffU, 716 739 AP_SGLIST, io->pSGList + sg_indx, (u16) sg_cnt, 717 AP_DEVICE, 0x40 00,740 AP_DEVICE, 0x40, 718 741 AP_WRITE, 1, 719 742 AP_END); … … 826 849 iorb_seterr(iorb, IOERR_DEVICE_NONSPECIFIC); 827 850 } 851 } else { 852 /* this function only gets called when we received an error interrupt */ 853 iorb_seterr(iorb, IOERR_DEVICE_NONSPECIFIC); 828 854 } 829 855
Note:
See TracChangeset
for help on using the changeset viewer.