Changeset 190 for trunk


Ignore:
Timestamp:
Jul 17, 2017, 4:31:51 AM (8 years ago)
Author:
David Azarewicz
Message:

Added MSI support.

Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/os2ahci/Makefile

    r188 r190  
    1212# Define default build version if not specified in environment
    1313BLD_MAJOR=2
    14 BLD_MINOR=02 # must be 2 digits
     14BLD_MINOR=03 # must be 2 digits
    1515BLD_REV=0 # not used at this time
    1616
  • trunk/src/os2ahci/ReadMe.txt

    r186 r190  
    1 AHCI Driver for OS/2 v2.01
     1AHCI Driver for OS/2 v2.03
    22
    33
     
    357357   DSKSP_GEN_GET_COUNTERS IOCTL request.
    358358
     359Known Issues and Limitations
     360============================
     361
     362Hot swap is not supported.
     363
    359364
    360365Manual Installation
     
    384389Change Log
    385390==========
     391
     392v.2.03 15-Jul-2017 - David Azarewicz
     393  Added MSI support.
     394
     395v.2.02 07-Jun-2017 - David Azarewicz
     396  Fixed interrupt handler issue for multiple adapters.
    386397
    387398v.2.01 01-Oct-2016 - David Azarewicz
  • trunk/src/os2ahci/ahci.c

    r188 r190  
    661661  DPRINTF(1,"ahci_complete_init: completing initialization of adapter #%d\n", ad_no(ai));
    662662
    663   /* register IRQ handlers; each IRQ level is registered only once */
    664   for (i = 0; i < irq_used_cnt; i++)
    665   {
    666     if (irq_used[i] == ai->irq) break; /* we already have this IRQ registered */
    667   }
    668   if (i >= irq_used_cnt)
    669   {
    670     if (i >= MAX_IRQ_HANDLERS) return -1; /* no more handlers available */
    671     DPRINTF(2,"registering interrupt #%d\n", ai->irq);
    672     if (Dev32Help_SetIRQ(ahci_intr, ai->irq, 1, ai->irq) != 0)
    673     {
    674       DPRINTF(0,"failed to register shared interrupt\n");
    675       if (Dev32Help_SetIRQ(ahci_intr, ai->irq, 0, ai->irq) != 0)
     663  if (!ai->int_set)
     664  {
     665    /* register IRQ handler; each IRQ level is registered only once */
     666    p = 1; /* int count */
     667    if (!(ai->flags & AHCI_HFLAG_NO_MSI))
     668    {
     669      if (PsdMsiAlloc(ai->bus_dev_func, &p, &ai->irq)) p = 1; /* shared flag */
     670      else
    676671      {
    677         dprintf(0,"failed to register interrupt %d\n", ai->irq);
     672        /* we have an msi interrupt */
     673        ai->irq_pin = 0;
     674        p = 0; /* exclusive flag */
     675      }
     676    }
     677    for (i = 0; i < irq_used_cnt; i++)
     678    {
     679      if (irq_used[i] == ai->irq) break; /* we already have this IRQ registered */
     680    }
     681    if (i >= irq_used_cnt)
     682    {
     683      if (i >= MAX_IRQ_HANDLERS) return -1; /* no more handlers available */
     684      DPRINTF(2,"registering interrupt #%d\n", ai->irq);
     685
     686      rc = Dev32Help_SetIRQ(ahci_intr, ai->irq, p, ai->irq);
     687      if (rc && p) /* if failed and was shared */
     688      {
     689        p = 0; /* try exclusive */
     690        rc = Dev32Help_SetIRQ(ahci_intr, ai->irq, p, ai->irq);
     691      }
     692      if (rc)
     693      {
     694       dprintf(0,"failed to register interrupt %d\n", ai->irq);
    678695        return(-1);
    679696      }
    680     }
    681     irq_used[irq_used_cnt++] = ai->irq;
     697      irq_used[irq_used_cnt++] = ai->irq;
     698      ai->int_set = 1;
     699      RmUpdateAddIrq(rm_drvh, ai->rm_adh, ai->irq, ai->irq_pin, p?RS_IRQ_SHARED:RS_IRQ_EXCLUSIVE);
     700    }
    682701  }
    683702
     
    13961415 */
    13971416#pragma aux ahci_intr parm [eax]
    1398 int ahci_intr(u16 irq)
     1417int ahci_intr(u32 irq)
    13991418{
    14001419  u32 irq_stat;
     
    15701589
    15711590    vNext = pIorb->pNxtIORB;
     1591
    15721592    iorb_complete(vIorb, pIorb);
    15731593  }
     
    17681788  ai->ports[p].devs[d].dev_type  = UIB_TYPE_DISK;
    17691789  pDevName = ai->ports[p].devs[d].dev_name;
    1770   strncpy(pDevName, ata_dev_name(id_buf), sizeof(ai->ports[0].devs[0].dev_name));
     1790  strlcpy(pDevName, ata_dev_name(id_buf), sizeof(ai->ports[0].devs[0].dev_name));
    17711791
    17721792  if (id_buf[ATA_ID_CONFIG] & 0x8000U)
     
    17971817  }
    17981818
    1799   DPRINTF(2,"found device %d.%d.%d: removable = %d, dev_type = %d, atapi = %d, "
    1800           "ncq_max = %d\n", ad_no(ai), p, d,
     1819  DPRINTF(2,"found device %d.%d.%d: removable=%d dev_type=%d atapi=%d ncq_max=%d\n",
     1820          ad_no(ai), p, d,
    18011821          ai->ports[p].devs[d].removable,
    18021822          ai->ports[p].devs[d].dev_type,
     
    18191839  if (ai->ports[p].devs[d].removable)
    18201840  {
    1821     sprintf(dev_name, RM_CD_PREFIX "%s", p, d, pDevName);
     1841    snprintf(dev_name, sizeof(dev_name), RM_CD_PREFIX "%s", p, d, pDevName);
    18221842  }
    18231843  else
    18241844  {
    1825     sprintf(dev_name, RM_HD_PREFIX "%s", p, d, pDevName);
     1845    snprintf(dev_name, sizeof(dev_name), RM_HD_PREFIX "%s", p, d, pDevName);
    18261846  }
    18271847
  • trunk/src/os2ahci/ata.c

    r188 r190  
    885885
    886886  io->BlocksXferred += add_workspace(pIorb)->blocks;
    887   DPRINTF(7,"ata_read_pp(): blocks transferred = %d\n", io->BlocksXferred);
     887  DPRINTF(7,__func__": blocks transferred = %d\n", io->BlocksXferred);
    888888
    889889  if (io->BlocksXferred >= io->BlockCount)
     
    13921392      if (Dev32Help_PhysToLin(phys_addr, l, (PVOID) &p))
    13931393      {
    1394         panic("sg_memcpy(): DevHelp_PhysToLin() failed");
     1394        panic(__func__": DevHelp_PhysToLin() failed");
    13951395      }
    13961396      if (dir == SG_TO_BUF)
  • trunk/src/os2ahci/os2ahci.c

    r186 r190  
    11031103
    11041104      pPtr->AdapterDevBus = AI_DEVBUS_ST506 | AI_DEVBUS_32BIT;
    1105       sprintf(pPtr->AdapterName, "AHCI_%d", dta);
     1105      snprintf(pPtr->AdapterName, sizeof(pPtr->AdapterName), "AHCI_%d", dta);
    11061106
    11071107      if (!ad_info->port_scan_done)
     
    11621162      /* set adapter name and bus type to mimic a SCSI controller */
    11631163      pPtr->AdapterDevBus = AI_DEVBUS_SCSI_2 | AI_DEVBUS_16BIT;
    1164       sprintf(pPtr->AdapterName, "AHCI_SCSI_0");
     1164      snprintf(pPtr->AdapterName, sizeof(pPtr->AdapterName), "AHCI_SCSI_0");
    11651165
    11661166      /* add all ATAPI units to be emulated by this virtual adaper */
  • trunk/src/os2ahci/os2ahci.h

    r185 r190  
    280280  unsigned      busy : 1;              /*    if != 0, adapter is busy */
    281281  unsigned      hw_ports : 6;          /*    number of ports as reported by the hardware */
     282  unsigned      int_set:1;             /* interrupt has been set */
    282283
    283284  u32           port_map;              /* 08   bitmap of active ports */
     
    294295  HRESOURCE     rm_adh;                /* 44 resource handle for adapter */
    295296  HRESOURCE     rm_bars[6];            /* 48 resource handle for MMIO and I/O BARs */
    296   HRESOURCE     rm_irq;                /* 60 resource handle for IRQ */
    297297
    298298  u16           bus_dev_func;          /* 64 PCI bus number PCI device and function number */
    299   u16           irq;                   /* 66 interrupt number */
     299  u8            irq;                   /* 66 interrupt number */
     300  u8            irq_pin;               /* 67 irq pin */
    300301
    301302  u32           mmio_phys;             /* 68 physical address of MMIO region */
     
    424425extern int ahci_flush_cache(AD_INFO *ai, int p, int d);
    425426
    426 extern int ahci_intr(u16 irq);
     427extern int ahci_intr(u32 irq);
    427428extern void ahci_port_intr(AD_INFO *ai, int p);
    428429extern void ahci_error_intr(AD_INFO *ai, int p, u32 irq_stat);
  • trunk/src/os2ahci/pci.c

    r188 r190  
    513513  rc_list->NumResource = 0;
    514514
    515   /* Register IRQ with resource manager */
    516   ret = RmAddIrq(rm_drvh, &ad_info->rm_irq, irq, pin);
    517   if (ret)
    518   {
    519     if (ret == RMRC_RES_ALREADY_CLAIMED)
    520     {
    521       ciiprintf("Device already claimed.");
    522     }
    523     else
    524     {
    525       iprintf("%s: couldn't register IRQ %d (rc = %s)", drv_name, irq, rmerr(ret));
    526     }
    527     return;
    528   }
    529   rc_list->hResource[rc_list->NumResource++] = ad_info->rm_irq;
    530 
    531515  /* Allocate all I/O and MMIO addresses offered by this device. In theory,
    532516   * we need only BAR #5, the AHCI MMIO BAR, but in order to prevent any
     
    600584  ad_info->bus_dev_func = BusDevFunc;
    601585  ad_info->irq = irq;
     586  ad_info->irq_pin = pin;
    602587
    603588  ad_info->mmio = MapPhysToLin(ad_info->mmio_phys, ad_info->mmio_size);
     
    612597
    613598  memset(&adapter, 0x00, sizeof(adapter));
    614   sprintf(tmp, "AHCI_%d Controller", ad_info_cnt);
     599  snprintf(tmp, sizeof(tmp), "AHCI_%d Controller", ad_info_cnt);
    615600  adapter.AdaptDescriptName = tmp;
    616601  adapter.AdaptFlags        = 0;
     
    650635  return;
    651636
    652 
    653637add_pci_fail:
    654638  /* something went wrong; try to clean up as far as possible */
     
    657641    if (ad_info->rm_bars[i] != 0) RMDeallocResource(rm_drvh, ad_info->rm_bars[i]);
    658642  }
    659   if (ad_info->rm_irq != 0) RMDeallocResource(rm_drvh, ad_info->rm_irq);
    660643}
    661644
  • trunk/tools/AddToFile.cmd

    r179 r190  
    1111call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
    1212call SysLoadFuncs
    13 parse arg OutFile','String','Function','Parm1','Parm2','Parm3','Parm4;
     13parse arg OutFile','String','Function','Parm1','Parm2','Parm3','Parm4','Parm5;
    1414
    1515if (OutFile='') then do
     
    3333  rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd);
    3434  call 'AddToFile.cmd' MyCmd;
    35   MyCmd=MyFile||',option description,BLDLEVEL,Vendor,1.2.3,Description,Fixpack';
     35  MyCmd=MyFile||',option description,BLDLEVEL,Vendor,1.2.3,Description,Fixpack,Asd';
    3636  rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd);
    3737  call 'AddToFile.cmd' MyCmd;
     
    9292    /* get fixpack from SVN version */
    9393    if (Parm4='SVN') then Parm4='SVN'||SvnVersion();
     94    if (Parm2='DATE') then Parm2=SUBSTR(DATE('S'), 1, 4)||'.'||SUBSTR(DATE('S'), 5, 2)||'.'||SUBSTR(DATE('S'), 7, 2);
    9495
    9596    parse var Parm2 major'.'minor'.'ProjVersion;
     
    100101    end
    101102
    102     NewStr='@#'||Parm1||':'||Parm2||'#@##1## '||ProjString||'::::'||ProjVersion||'::'||Parm4||'@@'||Parm3;
     103    NewStr='@#'||Parm1||':'||Parm2||'#@##1## '||ProjString||':'||Parm5||':::'||ProjVersion||'::'||Parm4||'@@'||Parm3;
    103104    if (Type='2') then do
    104105      /*OutStr=String||' "@#'||Parm1||':'||Parm2||'#@##1## '||ProjString||'::::'||ProjVersion||'::'||Parm4||'@@'||Parm3||'"';*/
     
    134135  when (Function='DATEDAY') then do
    135136    NewStr=FORMAT(SUBSTR(DATE('S'), 7, 2));
     137    RepLoc=Pos('%A', String);
     138    if (RepLoc>0) then OutStr=Substr(String,1,RepLoc-1)||NewStr||Substr(String,RepLoc+2);
     139    else OutStr=String||' '||NewStr;
     140    rc=lineout(OutFile, OutStr);
     141    rc=lineout(OutFile);
     142  end
     143
     144  when (Function='DATE1') then do
     145    parse value Date('N') with MyDay MyMonth MyYear;
     146    NewStr=MyYear||'-'||MyMonth||'-'||Right(MyDay, 2, 0);
    136147    RepLoc=Pos('%A', String);
    137148    if (RepLoc>0) then OutStr=Substr(String,1,RepLoc-1)||NewStr||Substr(String,RepLoc+2);
Note: See TracChangeset for help on using the changeset viewer.