Changeset 55


Ignore:
Timestamp:
Dec 14, 2010, 12:03:32 PM (15 years ago)
Author:
markus
Message:

fixed readtest to run under OS/2 Ring3 above 2GB; commented out ADD read sector dump code

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lbatest/readtest.c

    r54 r55  
    77  matches its real LBA.
    88
    9   To run the test, attach a HD to an AHCI controller with os2ahci.add loaded
    10   and run the test with the drive letter as a parameter.
     9  To run the test, run lbatest under Linux, then attach the drive to an OS/2
     10  system an create a single primary partition that stretches the entire drive.
     11  Then run readtest.exe with the drive letter as a parameter.
     12 
    1113
    1214  Author: Markus Thielen
     
    4749
    4850#define SECTOR_SIZE        512
    49 #define SECTORS_PER_WRITE  200
     51#define SECTORS_PER_READ   200
    5052
    5153
     
    6264unsigned long lba_pos;
    6365unsigned long first_wrong_sector = 0xffffffff;
    64 char mode;
     66
    6567
    6668/*--- start of code ---------------------------------------------------------*/
     
    7173int main(int argc, char **argv)
    7274{
    73   char *drv;
    7475  HFILE hf;
     76  char drv[50];
    7577
    7678  if (argc < 2) {
     
    7981  }
    8082
    81   drv = argv[1];
    82   if (drv[1] != ':' && drv[2] != '\0') {
    83     /* we want a drive letter, which is a letter and a colon */
     83  if (isalpha(argv[1][0])) {
     84    sprintf(drv, "\\\\.\\%c", toupper(argv[1][0]));
     85  } else if (isdigit(argv[1][0])) {
     86    sprintf(drv, "\\\\.\\Physical_Disk%c", argv[1][0]);
     87  } else {
    8488    usage();
    8589    return -1;
     
    99103  unsigned long action;
    100104  unsigned long cb_read;
    101   char buf[SECTOR_SIZE];
     105  char *buf;
    102106  int rc = 0;
     107  unsigned long cb_take = SECTOR_SIZE * SECTORS_PER_READ;
    103108  unsigned long err_cnt = 0;
    104109  float gbf = 1024.0 * 1024.0 * 1024.0 / 512.0;
    105   long long lba = 0;
     110  LONGLONG cbfile = {0};
     111  int s;
     112  unsigned long sectors;
     113  unsigned long val;
     114
     115  buf = calloc(SECTOR_SIZE, SECTORS_PER_READ);
    106116
    107117  /* open drive */
    108   ret = DosOpenL(drv, &hf_disk, &action, 0, 0, OPEN_ACTION_OPEN_IF_EXISTS,
    109                 OPEN_FLAGS_DASD | OPEN_FLAGS_FAIL_ON_ERROR |
    110                 OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_NO_CACHE |
    111                 OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYREADWRITE |
    112                 OPEN_ACCESS_READONLY,
    113                 NULL);
     118  ret = DosOpen(drv, &hf_disk, &action, 0, 0,
     119                OPEN_ACTION_OPEN_IF_EXISTS,
     120/*                   OPEN_FLAGS_DASD | OPEN_FLAGS_FAIL_ON_ERROR | */
     121/*                   OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_NO_CACHE | */
     122/*                   OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYREADWRITE | */
     123                OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY,
     124                NULL);
    114125  if (ret != NO_ERROR) {
    115126    fprintf(stderr, "Failed to open disk %s for reading: %d\n", drv, ret);
     
    118129
    119130  /* lock disk */
    120   ret = DosDevIOCtl(hf_disk, IOCTL_DISK, DSK_LOCKDRIVE, NULL, 0,
    121                     &action, NULL, 0, &cb_read);
    122   if (ret != NO_ERROR) {
    123     fprintf(stderr, "Failed to lock drive, code %d\n", ret);
    124     rc = -1;
    125     goto cleanup;
    126   }
     131/*    ret = DosDevIOCtl(hf_disk, IOCTL_DISK, DSK_LOCKDRIVE, NULL, 0, */
     132/*                  &action, NULL, 0, &cb_read); */
     133/*    if (ret != NO_ERROR) { */
     134/*      fprintf(stderr, "Failed to lock drive, code %d\n", ret); */
     135/*      rc = -1; */
     136/*      goto cleanup; */
     137/*    } */
    127138
    128139  /* catch Ctrl+C */
     
    131142  /* go... */
    132143  memset(buf, 0x00, sizeof(buf));
    133   for (lba = 64; ; lba++) {
    134     ret = DosRead(hf_disk, buf, SECTOR_SIZE, &cb_read);
     144  for (lba_pos = 0; ; lba_pos += SECTORS_PER_READ) {
     145    ret = DosRead(hf_disk, buf, cb_take, &cb_read);
    135146    if (ret != NO_ERROR) {
    136147      fprintf(stderr, "\nFailed to read from disk %s, code %d\n", drv, ret);
     
    139150    }
    140151
    141     if (*((long long*) buf) != lba_pos) {
    142       printf("\nWrong sector number: read %d from sector %d\n",
    143               *((long long*) buf), lba_pos);
    144       err_cnt++;
    145       if (first_wrong_sector == 0xffffffff) {
    146         first_wrong_sector = lba_pos;
     152    if (cb_read == 0) {
     153      goto cleanup;
     154    }
     155
     156    sectors = cb_read / SECTOR_SIZE;
     157
     158    for (s = 0; s < sectors; s++) {
     159
     160      if (lba_pos + s < 64) {
     161        continue;
    147162      }
     163
     164      val = *((unsigned long*) (buf + s * SECTOR_SIZE));
     165      if (val == 0xf6f6f6f6) {
     166        /* appearantly, this is the funny first partition sector
     167         * created by LVM - skip it */
     168        continue;
     169      }
     170
     171      if (val != lba_pos + s) {
     172        printf("\nWrong sector number: read 0x%08x from sector 0x%08x",
     173               val, lba_pos + s);
     174        err_cnt++;
     175        if (first_wrong_sector == 0xffffffff) {
     176          first_wrong_sector = lba_pos + s;
     177        }
     178      }
    148179    }
    149180
    150181    /* progress */
    151     if (lba_pos % 100 == 0) {
    152       printf("\r%dk sectors read (%0.02f GB)", lba_pos / 1000,
    153              (float) lba_pos / gbf);
    154     }
     182    printf("\r%dk sectors read (%0.02f GB)", lba_pos / 1000,
     183           (float) lba_pos / gbf);
    155184  }
    156185
     
    160189              NULL, 0, &cb_read);
    161190  DosClose(hf_disk);
     191  free(buf);
    162192
    163193  /* print summary */
     
    176206{
    177207  printf("LBA (read sector number) test for os2ahci.add\n"
     208         "Call with a drive letter (for logical drive) or 1-based disk number (for\n"
     209         "physical drive)\n\n"
    178210         "Usage:\n\n"
    179          "lbatest <drive letter>\n\n");
     211         "lbatest <drive letter|drive number>\n\n");
    180212}
    181213
     
    187219{
    188220
    189   if (sig_no == SIGINT && mode == 'R') {
     221  if (sig_no == SIGINT) {
    190222    /* read mode interrupted; show summary */
    191     printf("\n\nLast block read:    %u\n", lba_pos);
     223    printf("\n\nLast block read:    0x%08x\n", lba_pos);
    192224    if (first_wrong_sector != 0xffffffff) {
    193       printf("First wrong sector: %u\n", first_wrong_sector);
     225      printf("First wrong sector: 0x%08x\n", first_wrong_sector);
    194226    } else {
    195227      printf("All sectors read ok\n");
  • trunk/src/os2ahci/ahci.c

    r53 r55  
    3232                              ? atapi_##func : ata_##func
    3333
     34
     35/* #define LBATEST
     36 * uncomment to perform sector mapping test of first drive */
     37
    3438#define LBATEST_SECTORS_PER_READ     64
    3539#define LBATEST_SECTOR_SIZE         512
    3640
    37 #define LBATEST
    3841
    3942/* ------------------------ typedefs and structures ------------------------ */
     
    16541657  DevHelp_FreePhys(phys_addr);
    16551658
     1659  LBA test compiled?
     1660
    16561661}
    16571662#endif
  • trunk/src/os2ahci/ata.c

    r46 r55  
    618618{
    619619  IORB_EXECUTEIO _far *io = (IORB_EXECUTEIO _far *) iorb;
     620/*    unsigned char _far *p; */
     621/*    u16 mode_sw; */
    620622
    621623  io->BlocksXferred += add_workspace(iorb)->blocks;
     
    628630    /* requeue this IORB for next iteration */
    629631    iorb_requeue(iorb);
    630   }
     632/*      printf("MT: IORB requeued\n"); */
     633  }
     634
     635  /* MT: print hex dump of first sector read */
     636/*    if (io->cSGList) { */
     637/*      if (DevHelp_PhysToVirt(io->pSGList->ppXferBuf,  */
     638/*                             (USHORT) io->pSGList->XferBufLen,  */
     639/*                             (PVOID) &p, &mode_sw)) { */
     640/*        printf("MT: failed to convert S/G pointer to virt address\n"); */
     641/*      } else { */
     642/*        phex(p, (int) io->pSGList->XferBufLen, "sector dump, RBA=0x%08lx\n", */
     643/*             io->RBA); */
     644/*      } */
     645/*    } */
     646 
    631647}
    632648
     
    778794
    779795  rc = ata_cmd(ai, p, d, slot, 0,
    780                AP_SGLIST,   apt->pSGList, apt->ppSGLIST,
     796               AP_SGLIST,   apt->pSGList, apt->cSGList,
    781797               AP_ATA_CMD,  apt->pControllerCmd,
    782798               AP_WRITE,    !(apt->Flags & PT_DIRECTION_IN),
  • trunk/src/os2ahci/os2ahci.def

    r48 r55  
    11library os2ahci
    2 Description '$@#thi.guten (www.thiguten.de):1.00.20101202#@OS/2 AHCI Adapter Device Driver'
     2Description '$@#thi.guten (www.thiguten.de):1.00.20101214#@OS/2 AHCI Adapter Device Driver'
    33protmode
    44
Note: See TracChangeset for help on using the changeset viewer.