Ignore:
Timestamp:
Apr 10, 2013, 6:47:05 PM (12 years ago)
Author:
David Azarewicz
Message:

Begin adding user info output.
Added LVM support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/os2ahci/ata.c

    r153 r154  
    442442
    443443/******************************************************************************
     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 */
     449int 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/******************************************************************************
    444491 * Post processing function for ata_get_geometry(): convert the ATA identify
    445492 * information to OS/2 IOCC_GEOMETRY information.
     
    452499  int a = iorb_unit_adapter(iorb);
    453500  int p = iorb_unit_port(iorb);
     501  char *Method;
    454502
    455503  /* Fill-in geometry information; the ATA-8 spec declares the geometry
     
    500548  }
    501549
     550  Method = "None";
    502551  /* fabricate the remaining geometry fields */
    503552  if (track_size[a][p] != 0) {
     
    511560                                 ((u32) geometry->NumHeads *
    512561                                  (u32) geometry->SectorsPerTrack);
    513 
     562    Method = "Custom";
    514563  } else if (CUR_HEADS(id_buf) > 0 && CUR_CYLS(id_buf) > 0 &&
    515564             CUR_SECTORS(id_buf) > 0 &&
     
    521570    geometry->SectorsPerTrack = CUR_SECTORS(id_buf);
    522571    geometry->TotalCylinders  = CUR_CYLS(id_buf);
    523 
     572    Method = "BIOS";
    524573  } else if (ATA_HEADS(id_buf) > 0 && ATA_CYLS(id_buf) > 0 &&
    525574             ATA_SECTORS(id_buf) > 0) {
     
    528577    geometry->SectorsPerTrack = ATA_SECTORS(id_buf);
    529578    geometry->TotalCylinders  = ATA_CYLS(id_buf);
    530 
     579    Method = "ATA";
    531580  } else {
    532581    /* use typical SCSI geometry */
     
    536585                                 ((u32) geometry->NumHeads *
    537586                                  (u32) geometry->SectorsPerTrack);
    538   }
     587    Method = "SCSI";
     588  }
     589
     590  if (is_lvm_geometry(iorb)) Method = "LVM";
    539591
    540592  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);
    546596  }
    547597
Note: See TracChangeset for help on using the changeset viewer.