Changeset 156 for trunk/src/os2ahci/ata.c
- Timestamp:
- May 6, 2013, 7:57:39 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/ata.c
r155 r156 441 441 } 442 442 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) 443 int check_lvm(IORBH _far *iorb, ULONG sector) 450 444 { 451 445 ADD_WORKSPACE _far *aws = add_workspace(iorb); … … 454 448 PDLA_Table_Sector pDLA; 455 449 int p = iorb_unit_port(iorb); 450 int rc; 451 452 rc = ahci_exec_polled_cmd(ai, p, 0, 500, ATA_CMD_READ, 453 AP_SECTOR_28, (u32) sector-1, 454 AP_COUNT, (u16) 1, 455 AP_VADDR, (void _far *) aws->buf, 512, 456 AP_DEVICE, 0x40, 457 AP_END); 458 if (rc) return 0; 459 460 pDLA = (PDLA_Table_Sector)aws->buf; 461 ddphex(pDLA, sizeof(DLA_Table_Sector), "DLA sector %d:\n", sector-1); 462 463 if ((pDLA->DLA_Signature1 == DLA_TABLE_SIGNATURE1) && (pDLA->DLA_Signature2 == DLA_TABLE_SIGNATURE2)) { 464 ddprintf("is_lvm_geometry found at sector %d\n", sector); 465 geometry->TotalCylinders = pDLA->Cylinders; 466 geometry->NumHeads = pDLA->Heads_Per_Cylinder; 467 geometry->SectorsPerTrack = pDLA->Sectors_Per_Track; 468 return 1; 469 } 470 471 return 0; 472 } 473 474 /****************************************************************************** 475 * Try to read LVM information from the disk. If found, use the LVM geometry. 476 * This function will only work at init time. A better strategy would be to 477 * calculate the geometry during ahci_scan_ports and save it away and then just 478 * return the saved values when ata_get_geometry() is called. 479 */ 480 int is_lvm_geometry(IORBH _far *iorb) 481 { 482 GEOMETRY _far *geometry = ((IORB_GEOMETRY _far *) iorb)->pGeometry; 483 AD_INFO *ai = ad_infos + iorb_unit_adapter(iorb); 484 int p = iorb_unit_port(iorb); 456 485 int d = iorb_unit_device(iorb); 457 int rc;458 486 ULONG sector; 459 487 … … 463 491 ddprintf("is_lvm_geometry (%d.%d.%d)\n", ad_no(ai), p, d); 464 492 493 /* First check the sector reported by the hardware */ 494 if (check_lvm(iorb, geometry->SectorsPerTrack)) return 1; 495 465 496 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 } 497 if (sector == geometry->SectorsPerTrack) continue; 498 if (check_lvm(iorb, sector)) return 1; 484 499 } 485 500 }
Note:
See TracChangeset
for help on using the changeset viewer.