Changeset 181 for trunk


Ignore:
Timestamp:
Dec 13, 2016, 3:07:49 AM (9 years ago)
Author:
David Azarewicz
Message:

Debugging changes

Location:
trunk/src/os2ahci
Files:
8 edited

Legend:

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

    r178 r181  
    207207#endif
    208208
     209int AllocPortData(AD_INFO *ai, int p)
     210{
     211  if (ai->ports[p]) return 0;
     212  ai->ports[p] = MemAlloc(sizeof(P_INFO));
     213  if (ai->ports[p] == NULL) return 1;
     214  memset(ai->ports[p], 0, sizeof(P_INFO));
     215  return 0;
     216}
     217
     218FreePortData(AD_INFO *ai, int p)
     219{
     220}
     221
    209222/******************************************************************************
    210223 * Save BIOS configuration of AHCI adapter. As a side effect, this also saves
     
    605618    if (port_ignore[ad_no(ai)][p]) continue;
    606619
     620    // DAZ allocate port structure here
     621
    607622    DPRINTF(3,"ahci_scan_ports: Wait till not busy on port %d\n", p);
    608623    /* wait until all active commands have completed on this port */
     
    629644      rc = ahci_start_port(ai, p, 0);
    630645    }
    631     if (rc)
    632     {
    633       /* no device attached to this port */
    634       ai->port_map &= ~(1UL << p);
    635       goto restore_port_config;
    636     }
    637 
    638     /* this port seems to have a device attached and ready for commands */
    639     DPRINTF(1,"ahci_scan_ports: port %d seems to be attached to a device; probing...\n", p);
    640 
    641     /* Get ATA(PI) identity. The so-called signature gives us a hint whether
    642      * this is an ATA or an ATAPI device but we'll try both in either case;
    643      * the signature will merely determine whether we're going to probe for
    644      * an ATA or ATAPI device, first, in order to reduce the chance of sending
    645      * the wrong command (which would result in a port reset given the way
    646      * ahci_exec_polled_cmd() was implemented).
    647      */
    648     is_ata = readl(port_base(ai, p) + PORT_SIG) == 0x00000101UL;
    649     for (i = 0; i < 2; i++)
    650     {
    651       rc = ahci_exec_polled_cmd(ai, p, 0, 500,
    652                                 (is_ata) ? ATA_CMD_ID_ATA : ATA_CMD_ID_ATAPI,
    653                                 AP_VADDR, (void *) id_buf, ATA_ID_WORDS * sizeof(u16),
    654                                 AP_END);
    655       if (rc == 0) break;
    656 
    657       /* try again with ATA/ATAPI swapped */
    658       is_ata = !is_ata;
     646
     647    if (rc == 0)
     648    {
     649      /* this port seems to have a device attached and ready for commands */
     650      DPRINTF(1,"ahci_scan_ports: port %d seems to be attached to a device; probing...\n", p);
     651
     652      /* Get ATA(PI) identity. The so-called signature gives us a hint whether
     653       * this is an ATA or an ATAPI device but we'll try both in either case;
     654       * the signature will merely determine whether we're going to probe for
     655       * an ATA or ATAPI device, first, in order to reduce the chance of sending
     656       * the wrong command (which would result in a port reset given the way
     657       * ahci_exec_polled_cmd() was implemented).
     658       */
     659      is_ata = readl(port_base(ai, p) + PORT_SIG) == 0x00000101UL;
     660      for (i = 0; i < 2; i++)
     661      {
     662        rc = ahci_exec_polled_cmd(ai, p, 0, 500,
     663                                  (is_ata) ? ATA_CMD_ID_ATA : ATA_CMD_ID_ATAPI,
     664                                  AP_VADDR, (void *) id_buf, ATA_ID_WORDS * sizeof(u16),
     665                                  AP_END);
     666        if (rc == 0) break;
     667
     668        /* try again with ATA/ATAPI swapped */
     669        is_ata = !is_ata;
     670      }
    659671    }
    660672
     
    669681      /* no device attached to this port */
    670682      ai->port_map &= ~(1UL << p);
    671     }
    672 
    673   restore_port_config:
    674     if (pc != NULL) {
    675       ahci_restore_port_config(ai, p, pc);
    676     }
     683      // DAZ free port structure here
     684    }
     685
     686    if (pc != NULL) ahci_restore_port_config(ai, p, pc);
    677687  }
    678688
     
    10961106  }
    10971107
    1098   DPRINTF(1,"---------- ahci_exec_iorb: iorb=%x\n", vIorb);
     1108  DPRINTF(7,"---------- ahci_exec_iorb: iorb=%x\n", vIorb);
    10991109
    11001110  /* Enable AHCI mode; apparently, the AHCI mode may end up becoming
     
    11221132      cmd_max = ai->cmd_max;
    11231133    }
    1124     DPRINTF(3,"NCQ command; cmd_max = %d->%d\n", ai->cmd_max, cmd_max);
     1134    DPRINTF(8,"NCQ command; cmd_max = %d->%d\n", ai->cmd_max, cmd_max);
    11251135  }
    11261136
     
    11751185        aws->cmd_slot = port->cmd_slot;
    11761186
    1177         DPRINTF(1,"Issuing command Slot=%d cmds=%x\n", port->cmd_slot, *cmds);
     1187        DPRINTF(7,"Issuing command Slot=%d cmds=%x\n", port->cmd_slot, *cmds);
    11781188        if (aws->is_ncq)
    11791189        {
     
    14321442 * queues, ...)
    14331443 */
    1434 u32 DazCount = 0;
    1435 
    14361444int ahci_intr(u16 irq)
    14371445{
     
    14401448  int a;
    14411449  int p;
    1442 
    1443   DPRINTF(1,"AI=%x",DazCount++);
    14441450
    14451451  /* find adapter(s) with pending interrupts */
     
    15301536  readl(port_mmio + PORT_IRQ_STAT); /* flush */
    15311537
    1532   DPRINTF(3,"port interrupt A=%d Port=%d stat=%x\n", ad_no(ai), p, irq_stat);
    15331538  memset(&done_queue, 0x00, sizeof(done_queue));
    15341539
     
    15561561    active_cmds = readl(port_mmio + PORT_SCR_ACT);
    15571562    done_mask = ai->ports[p].ncq_cmds ^ active_cmds;
    1558     DPRINTF(1,"[ncq_cmds]: active_cmds=0x%08x done_mask=0x%08x\n", active_cmds, done_mask);
     1563    DPRINTF(7,"[ncq_cmds]: active_cmds=0x%08x done_mask=0x%08x\n", active_cmds, done_mask);
    15591564  }
    15601565  else
     
    15621567    active_cmds = readl(port_mmio + PORT_CMD_ISSUE);
    15631568    done_mask = ai->ports[p].reg_cmds ^ active_cmds;
    1564     DPRINTF(1,"[reg_cmds]: active_cmds=0x%08x  done_mask=0x%08x\n", active_cmds, done_mask);
     1569    DPRINTF(7,"[reg_cmds]: active_cmds=0x%08x  done_mask=0x%08x\n", active_cmds, done_mask);
    15651570  }
    15661571
     
    16811686{
    16821687  #ifdef DEBUG
    1683   DPRINTF(2,"ahci_get_geometry(%d.%d.%d)\n", iorb_unit_adapter(pIorb),
     1688  DPRINTF(7,"ahci_get_geometry(%d.%d.%d)\n", iorb_unit_adapter(pIorb),
    16841689          iorb_unit_port(pIorb), iorb_unit_device(pIorb));
    16851690  #endif
     
    16941699{
    16951700  #ifdef DEBUG
    1696   DPRINTF(2,"ahci_unit_ready(%d.%d.%d)\n", iorb_unit_adapter(pIorb),
     1701  DPRINTF(7,"ahci_unit_ready(%d.%d.%d)\n", iorb_unit_adapter(pIorb),
    16971702          iorb_unit_port(pIorb), iorb_unit_device(pIorb));
    16981703  #endif
     
    17071712{
    17081713  #ifdef DEBUG
    1709   DPRINTF(2,"ahci_read(%d.%d.%d, %d, %d)\n", iorb_unit_adapter(vIorb),
     1714  DPRINTF(7,"ahci_read(%d.%d.%d, %d, %d)\n", iorb_unit_adapter(vIorb),
    17101715          iorb_unit_port(pIorb), iorb_unit_device(pIorb),
    17111716          ((IORB_EXECUTEIO *) pIorb)->RBA,
     
    17221727{
    17231728  #ifdef DEBUG
    1724   DPRINTF(2,"ahci_verify(%d.%d.%d, %d, %d)\n", iorb_unit_adapter(pIorb),
     1729  DPRINTF(7,"ahci_verify(%d.%d.%d, %d, %d)\n", iorb_unit_adapter(pIorb),
    17251730          iorb_unit_port(pIorb), iorb_unit_device(pIorb),
    17261731          ((IORB_EXECUTEIO *)pIorb)->RBA,
     
    17371742{
    17381743  #ifdef DEBUG
    1739   DPRINTF(2,"ahci_write(%d.%d.%d, %d, %d)\n", iorb_unit_adapter(pIorb),
     1744  DPRINTF(7,"ahci_write(%d.%d.%d, %d, %d)\n", iorb_unit_adapter(pIorb),
    17401745          iorb_unit_port(pIorb), iorb_unit_device(pIorb),
    17411746          ((IORB_EXECUTEIO *)pIorb)->RBA,
  • trunk/src/os2ahci/ata.c

    r178 r181  
    287287  cmd_hdr->options |= n << 16;
    288288
    289   if (D32g_DbgLevel >= 2)
    290   {
    291     DPRINTF(2,"ATA command for %d.%d.%d, slot %d:\n", ad_no(ai), p, d, slot);
     289  if (D32g_DbgLevel >= 7)
     290  {
     291    DPRINTF(0,"ATA command for %d.%d.%d, slot %d:\n", ad_no(ai), p, d, slot);
    292292    dHexDump(0,cmd_hdr, offsetof(AHCI_CMD_HDR, reserved), "cmd_hdr: ");
    293293    dHexDump(0,&ata_cmd, sizeof(ata_cmd), "ata_cmd: ");
     
    834834  int rc;
    835835
    836   DPRINTF(3,"ata_read_unaligned(%d.%d.%d, %d)\n", ad_no(ai), p, d, sector);
     836  DPRINTF(7,"ata_read_unaligned(%d.%d.%d, %d)\n", ad_no(ai), p, d, sector);
    837837
    838838  /* allocate transfer buffer */
     
    883883
    884884  io->BlocksXferred += add_workspace(pIorb)->blocks;
    885   DPRINTF(3,"ata_read_pp(): blocks transferred = %d\n", io->BlocksXferred);
     885  DPRINTF(7,"ata_read_pp(): blocks transferred = %d\n", io->BlocksXferred);
    886886
    887887  if (io->BlocksXferred >= io->BlockCount)
     
    10201020  int rc;
    10211021
    1022   DPRINTF(3,"ata_write_unaligned(%d.%d.%d, %d)\n", ad_no(ai), p, d, sector);
     1022  DPRINTF(7,"ata_write_unaligned(%d.%d.%d, %d)\n", ad_no(ai), p, d, sector);
    10231023
    10241024  /* allocate transfer buffer */
     
    10681068
    10691069  io->BlocksXferred += add_workspace(pIorb)->blocks;
    1070   DPRINTF(3,"ata_write_pp(): blocks transferred = %d\n", io->BlocksXferred);
     1070  DPRINTF(7,"ata_write_pp(): blocks transferred = %d\n", io->BlocksXferred);
    10711071
    10721072  if (io->BlocksXferred >= io->BlockCount)
  • trunk/src/os2ahci/atapi.c

    r178 r181  
    3131
    3232/* need this for the SCSI status block */
    33 #include <scsi.h>
     33#include <Dev32scsi.h>
    3434
    3535/* -------------------------- macros and constants ------------------------- */
     
    5151int atapi_get_geometry(IORBH FAR16DATA *vIorb, IORBH *pIorb, int slot)
    5252{
    53   DPRINTF(2,"atapi_get_geometry called\n");
     53  DPRINTF(4,"atapi_get_geometry called\n");
    5454  iorb_seterr(pIorb, IOERR_CMD_NOT_SUPPORTED);
    5555  return(-1);
     
    6161int atapi_unit_ready(IORBH FAR16DATA *vIorb, IORBH *pIorb, int slot)
    6262{
    63   DPRINTF(2,"atapi_unit_ready called\n");
     63  DPRINTF(4,"atapi_unit_ready called\n");
    6464  iorb_seterr(pIorb, IOERR_CMD_NOT_SUPPORTED);
    6565  return(-1);
     
    102102  SET_CDB_32(cdb.lba, io->RBA + io->BlocksXferred);
    103103
     104  DPRINTF(4, "atapi_read\n");
     105
    104106  do {
    105107    /* update sector count (might have been updated due to S/G limitations) */
     
    173175  SET_CDB_32(cdb.trans_len, 1UL);
    174176
     177  DPRINTF(4, "atapi_read_unaligned\n");
     178
    175179  /* allocate transfer buffer */
    176180  if ((aws->buf = MemAlloc(io->BlockSize)) == NULL)
     
    212216int atapi_verify(IORBH FAR16DATA *vIorb, IORBH *pIorb, int slot)
    213217{
    214   DPRINTF(3,"atapi_verify called\n");
     218  DPRINTF(4,"atapi_verify called\n");
    215219  iorb_seterr(pIorb, IOERR_CMD_NOT_SUPPORTED);
    216220  return(-1);
     
    222226int atapi_write(IORBH FAR16DATA *vIorb, IORBH *pIorb, int slot)
    223227{
    224   DPRINTF(3,"atapi_write called\n");
     228  DPRINTF(4,"atapi_write called\n");
    225229  iorb_seterr(pIorb, IOERR_CMD_NOT_SUPPORTED);
    226230  return(-1);
     
    244248  }
    245249  /* AHCI requires 12 or 16 byte commands */
    246   atapi_pad_cdb(Far16ToFlat(pt->pControllerCmd), pt->ControllerCmdLen,
    247                 (u8 *) cdb, (u16 *) &cdb_len);
     250  atapi_pad_cdb(Far16ToFlat(pt->pControllerCmd), pt->ControllerCmdLen, cdb, &cdb_len);
    248251
    249252  if (cdb[0] == 0x12 || cdb[0] == 0x5a)
     
    293296  size_t sense_buf_len = ATAPI_SENSE_LEN;
    294297
    295   DPRINTF(2,"atapi_req_sense\n");
     298  DPRINTF(4,"atapi_req_sense\n");
    296299
    297300  if ((pIorb->RequestControl & IORB_REQ_STATUSBLOCK) &&
     
    386389    if (ssb->SenseData != NULL)
    387390    {
    388       memcpy(ssb->SenseData, psd, ssb->ReqSenseLen);
     391      memcpy(Far16ToFlat(ssb->SenseData), psd, ssb->ReqSenseLen);
    389392      ssb->Flags |= STATUS_SENSEDATA_VALID;
    390393    }
  • trunk/src/os2ahci/ctxhook.c

    r178 r181  
    102102  int p;
    103103
    104   DPRINTF(2,"restart_ctxhook() started\n");
     104  D32ThunkStackTo32();
     105
     106  DPRINTF(8,"restart_ctxhook() started\n");
    105107  memset(&done_queue, 0x00, sizeof(done_queue));
    106108
     
    129131        need_reset = 0;
    130132
    131         DPRINTF(2,"port %d, TF_DATA: 0x%x\n", p, readl(port_mmio + PORT_TFDATA));
     133        DPRINTF(8,"port %d, TF_DATA: 0x%x\n", p, readl(port_mmio + PORT_TFDATA));
    132134
    133135        /* get "current command slot"; only valid if there are no NCQ cmds */
    134136        ccs = (int) ((readl(port_mmio + PORT_CMD) >> 8) & 0x1f);
    135         DPRINTF(3," PORT_CMD      = 0x%x\n", ccs);
     137        DPRINTF(8," PORT_CMD      = 0x%x\n", ccs);
    136138
    137139        for (vIorb = ai->ports[p].iorb_queue.vRoot; vIorb != NULL; vIorb = vNext)
     
    283285  spin_unlock(drv_lock);
    284286
    285   DPRINTF(2,"restart_ctxhook() completed\n");
     287  DPRINTF(8,"restart_ctxhook() completed\n");
    286288
    287289  /* Check whether we have to rearm ourselves because some adapters were busy
     
    293295    KernArmHook(restart_ctxhook_h, 0, 0);
    294296  }
     297  KernThunkStackTo16();
    295298}
    296299
     
    331334  int p;
    332335
    333   DPRINTF(2,"reset_ctxhook() started\n");
     336  D32ThunkStackTo32();
     337
     338  DPRINTF(8,"reset_ctxhook() started\n");
    334339  memset(&done_queue, 0x00, sizeof(done_queue));
    335340
     
    455460  spin_unlock(drv_lock);
    456461
    457   DPRINTF(2,"reset_ctxhook() completed\n");
     462  DPRINTF(8,"reset_ctxhook() completed\n");
    458463
    459464  /* Check whether we have to rearm ourselves because some adapters were busy
     
    465470    KernArmHook(reset_ctxhook_h, 0, 0);
    466471  }
     472
     473  KernThunkStackTo16();
    467474}
    468475
     
    478485  int i;
    479486
    480   DPRINTF(2,"engine_ctxhook() started\n");
     487  D32ThunkStackTo32();
     488
     489  DPRINTF(8,"engine_ctxhook() started\n");
    481490  if (resume_sleep_flag)
    482491  {
     
    492501  spin_unlock(drv_lock);
    493502
    494   DPRINTF(2,"engine_ctxhook() completed\n");
     503  DPRINTF(8,"engine_ctxhook() completed\n");
    495504
    496505  if (iorbs_sent != 0)
     
    500509    KernArmHook(engine_ctxhook_h, 0, 0);
    501510  }
     511
     512  KernThunkStackTo16();
    502513}
    503514
  • trunk/src/os2ahci/ioctl.c

    r179 r181  
    3131#include "ioctl.h"
    3232
    33 #include <scsi.h>
     33#include <Dev32scsi.h>
    3434
    3535#pragma pack(1)
     
    191191    ic->iorb.iorbh.pStatusBlock     = CastFar16ToULONG(MemFar16Adr(&ic->ssb));
    192192    ic->iorb.iorbh.StatusBlockLen   = sizeof(ic->ssb);
    193     ic->ssb.SenseData               = (SCSI_REQSENSE_DATA *) ic->sense;
     193    ic->ssb.SenseData               = MemFar16Adr(ic->sense);
    194194    ic->ssb.ReqSenseLen             = sizeof(ic->sense);
    195195    ic->iorb.iorbh.RequestControl  |= IORB_REQ_STATUSBLOCK;
     
    268268        (ic->ssb.Flags | STATUS_SENSEDATA_VALID))
    269269    {
    270       memcpy(sense_buf, ic->ssb.SenseData, min(ic->ssb.ReqSenseLen, req->sense_len));
     270      memcpy(sense_buf, ic->sense, min(ic->ssb.ReqSenseLen, req->sense_len));
    271271    }
    272272
  • trunk/src/os2ahci/os2ahci.c

    r178 r181  
    606606     * link in 'vNext'.
    607607     */
    608     vNext = (pIorb->RequestControl | IORB_CHAIN) ? pIorb->pNxtIORB : NULL;
     608    if (pIorb->RequestControl & IORB_CHAIN) vNext = pIorb->pNxtIORB;
     609    else vNext = (IORBH FAR16DATA *)0;
    609610
    610611    pIorb->Status = 0;
     
    13171318     */
    13181319    char *queue_type;
    1319     int min_debug = 1;
     1320    int min_debug = 7;
    13201321
    13211322    if ((u32)queue >> 16 == (u32)&queue >> 16) /* DAZ this is bogus */
     
    13231324      /* this queue is on the stack */
    13241325      queue_type = "local";
    1325       min_debug = 2;
     1326      min_debug = 8;
    13261327
    13271328    }
     
    13341335    {
    13351336      queue_type = "abort";
    1336       min_debug = 2;
     1337      min_debug = 8;
    13371338
    13381339    }
     
    13861387  if (found)
    13871388  {
    1388     DPRINTF(3,"IORB %x removed (queue = %x)\n", vIorb, queue);
     1389    DPRINTF(8,"IORB %x removed (queue = %x)\n", vIorb, queue);
    13891390  }
    13901391  else
     
    14581459  pIorb->Status |= IORB_DONE;
    14591460
    1460   DPRINTF(1,"IORB %x complete status=0x%04x error=0x%04x\n",
     1461  DPRINTF(7,"IORB %x complete status=0x%04x error=0x%04x\n",
    14611462          vIorb, pIorb->Status, pIorb->ErrorCode);
    14621463
  • trunk/src/os2ahci/os2ahci.h

    r178 r181  
    301301
    302302  u32           dma_buf_phys[AHCI_MAX_PORTS];          /* physical address of DMA scratch buffer */
    303   u8         *dma_buf[AHCI_MAX_PORTS]; /* DMA scatch buffers */
     303  u8           *dma_buf[AHCI_MAX_PORTS]; /* DMA scatch buffers */
    304304
    305305  P_INFO        ports[AHCI_MAX_PORTS]; /* SATA ports on this adapter */
  • trunk/src/os2ahci/trace.c

    r178 r181  
    7878              pi->devs[d].dev_info.Cylinders, pi->devs[d].dev_info.HeadsPerCylinder, pi->devs[d].dev_info.SectorsPerTrack,
    7979              pi->devs[d].dev_info.TotalSectors/2048, pi->devs[d].dev_info.Method);
    80           } else NTPRINTF(" Drive present but no information available.");
     80          }
    8181          NTPRINTF("\n");
    8282        } /* if */
Note: See TracChangeset for help on using the changeset viewer.