Changeset 154 for trunk/src/os2ahci/ata.c
- Timestamp:
- Apr 10, 2013, 6:47:05 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/ata.c
r153 r154 442 442 443 443 /****************************************************************************** 444 * Try to read LVM information from the disk. If found, use the LVM geometry. 445 * This function will only work at init time. A better strategy would be to 446 * calculate the geometry during ahci_scan_ports and save it away and then just 447 * return the saved values when ata_get_geometry() is called. 448 */ 449 int is_lvm_geometry(IORBH _far *iorb) 450 { 451 ADD_WORKSPACE _far *aws = add_workspace(iorb); 452 AD_INFO *ai = ad_infos + iorb_unit_adapter(iorb); 453 GEOMETRY _far *geometry = ((IORB_GEOMETRY _far *) iorb)->pGeometry; 454 PDLA_Table_Sector pDLA; 455 int p = iorb_unit_port(iorb); 456 int d = iorb_unit_device(iorb); 457 int rc; 458 ULONG sector; 459 460 if (init_complete) return 0; /* We cannot use ahci_exec_polled_cmd() after init_complete */ 461 462 if (use_lvm_info) { 463 ddprintf("is_lvm_geometry (%d.%d.%d)\n", ad_no(ai), p, d); 464 465 for (sector = 255; sector >= 63; sector >>= 1) { 466 rc = ahci_exec_polled_cmd(ai, p, 0, 500, ATA_CMD_READ, 467 AP_SECTOR_28, (u32) sector-1, 468 AP_COUNT, (u16) 1, 469 AP_VADDR, (void _far *) aws->buf, 512, 470 AP_DEVICE, 0x40, 471 AP_END); 472 if (rc) continue; 473 474 pDLA = (PDLA_Table_Sector)aws->buf; 475 ddphex(pDLA, sizeof(DLA_Table_Sector), "DLA sector %d:\n", sector-1); 476 477 if ((pDLA->DLA_Signature1 == DLA_TABLE_SIGNATURE1) && (pDLA->DLA_Signature2 == DLA_TABLE_SIGNATURE2)) { 478 ddprintf("is_lvm_geometry found at sector %d\n", sector); 479 geometry->TotalCylinders = pDLA->Cylinders; 480 geometry->NumHeads = pDLA->Heads_Per_Cylinder; 481 geometry->SectorsPerTrack = pDLA->Sectors_Per_Track; 482 return 1; 483 } 484 } 485 } 486 487 return 0; 488 } 489 490 /****************************************************************************** 444 491 * Post processing function for ata_get_geometry(): convert the ATA identify 445 492 * information to OS/2 IOCC_GEOMETRY information. … … 452 499 int a = iorb_unit_adapter(iorb); 453 500 int p = iorb_unit_port(iorb); 501 char *Method; 454 502 455 503 /* Fill-in geometry information; the ATA-8 spec declares the geometry … … 500 548 } 501 549 550 Method = "None"; 502 551 /* fabricate the remaining geometry fields */ 503 552 if (track_size[a][p] != 0) { … … 511 560 ((u32) geometry->NumHeads * 512 561 (u32) geometry->SectorsPerTrack); 513 562 Method = "Custom"; 514 563 } else if (CUR_HEADS(id_buf) > 0 && CUR_CYLS(id_buf) > 0 && 515 564 CUR_SECTORS(id_buf) > 0 && … … 521 570 geometry->SectorsPerTrack = CUR_SECTORS(id_buf); 522 571 geometry->TotalCylinders = CUR_CYLS(id_buf); 523 572 Method = "BIOS"; 524 573 } else if (ATA_HEADS(id_buf) > 0 && ATA_CYLS(id_buf) > 0 && 525 574 ATA_SECTORS(id_buf) > 0) { … … 528 577 geometry->SectorsPerTrack = ATA_SECTORS(id_buf); 529 578 geometry->TotalCylinders = ATA_CYLS(id_buf); 530 579 Method = "ATA"; 531 580 } else { 532 581 /* use typical SCSI geometry */ … … 536 585 ((u32) geometry->NumHeads * 537 586 (u32) geometry->SectorsPerTrack); 538 } 587 Method = "SCSI"; 588 } 589 590 if (is_lvm_geometry(iorb)) Method = "LVM"; 539 591 540 592 if (debug) { 541 printf("geometry information:\n"); 542 printf(" heads: %d\n", (u16) geometry->NumHeads); 543 printf(" sectors: %d\n", (u16) geometry->SectorsPerTrack); 544 printf(" cylinders: %d\n", (u16) geometry->TotalCylinders); 545 printf(" capacity: %ldMB\n", (u32) (geometry->TotalSectors / 2048)); 593 printf("Drive geometry: %d cylinders, %d heads, %d sectors per track (%ldMB) (%s)\n", 594 (u16) geometry->TotalCylinders, (u16) geometry->NumHeads, (u16) geometry->SectorsPerTrack, 595 (u32) (geometry->TotalSectors / 2048), Method); 546 596 } 547 597
Note:
See TracChangeset
for help on using the changeset viewer.