Changeset 185 for trunk


Ignore:
Timestamp:
Dec 20, 2016, 9:35:27 PM (9 years ago)
Author:
David Azarewicz
Message:

Fix for sparse port hardware

Location:
trunk/src/os2ahci
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/os2ahci/Makefile

    r184 r185  
    156156  cd ..
    157157
    158 release: $(O)\os2ahci.add $(O)\os2ahci.sym .symbolic
     158release: .symbolic
    159159  @if exist $(WPIFILE) @del $(WPIFILE)
    160160  @!rm -rf $(ZIPDIR)
     
    163163
    164164  @md $(ZIPDIR)\pkg1
    165   @copy /b $(ROOT)\src\os2ahci\$(O)\os2ahci.add $(ZIPDIR)\pkg1 >NUL
    166   @copy /b $(ROOT)\src\os2ahci\$(O)\os2ahci.sym $(ZIPDIR)\pkg1 >NUL
     165  copy /b $(ROOT)\src\os2ahci\$(O)\os2ahci.add $(ZIPDIR)\pkg1 >NUL
     166  copy /b $(ROOT)\src\os2ahci\$(O)\os2ahci.sym $(ZIPDIR)\pkg1 >NUL
    167167
    168168  @md $(ZIPDIR)\pkg2
  • trunk/src/os2ahci/ReadMe.txt

    r180 r185  
    118118                       [Intel] AHCI controller was found to be
    119119                       initialized by the BIOS in SATA mode, ports will
    120                        always be reset even when /!R was specified
     120                       always be reset even when /!R is specified
    121121
    122122/A:n                   Set adapter to n for adapter-specific options
  • trunk/src/os2ahci/ahci.c

    r184 r185  
    295295    /* more ports in port_map than in HOST_CAP & 0x1f */
    296296    ports = ai->hw_ports;
    297     DPRINTF(1,"implemented port map (0x%x) contains more ports than nr_ports (%d), using nr_ports\n", ai->port_map, ports);
     297    DPRINTF(1,"implemented port map (0x%x) contains more ports than hw_ports (%d), using hw_ports\n", ai->port_map, ports);
    298298    ai->port_map = (1UL << ports) - 1UL;
    299299  }
     
    371371    int p;
    372372
    373     for (p = 0; p < AHCI_MAX_PORTS; p++)
     373    for (p = 0; p <= ai->port_max; p++)
    374374    {
    375375      if (ai->port_map & (1UL << p))
     
    729729   * enough if a previously detected device has problems.
    730730   */
    731   for (p = 0; p < AHCI_MAX_PORTS; p++)
     731  for (p = 0; p <= ai->port_max; p++)
    732732  {
    733733    if (ai->port_map & (1UL << p))
     
    17911791  HDEVICE dh;
    17921792  char dev_name[RM_MAX_PREFIX_LEN+ATA_ID_PROD_LEN+1];
     1793  char *pDevName;
    17931794  static u8 total_dev_cnt;
    17941795
     
    18041805  ai->ports[p].devs[d].removable = (id_buf[ATA_ID_CONFIG] & 0x0080U) != 0;
    18051806  ai->ports[p].devs[d].dev_type  = UIB_TYPE_DISK;
     1807  pDevName = ai->ports[p].devs[d].dev_name;
     1808  strncpy(pDevName, ata_dev_name(id_buf), sizeof(ai->ports[0].devs[0].dev_name));
    18061809
    18071810  if (id_buf[ATA_ID_CONFIG] & 0x8000U)
     
    18471850  adj.AdjType             = ADJ_ADD_UNIT;
    18481851  adj.Add_Unit.ADDHandle  = rm_drvh;
    1849   adj.Add_Unit.UnitHandle = (USHORT) total_dev_cnt;
     1852  adj.Add_Unit.UnitHandle = (USHORT)total_dev_cnt;
    18501853
    18511854  /* create Resource Manager device key string;
     
    18541857  if (ai->ports[p].devs[d].removable)
    18551858  {
    1856     sprintf(dev_name, RM_CD_PREFIX "%s", p, d, ata_dev_name(id_buf));
     1859    sprintf(dev_name, RM_CD_PREFIX "%s", p, d, pDevName);
    18571860  }
    18581861  else
    18591862  {
    1860     sprintf(dev_name, RM_HD_PREFIX "%s", p, d, ata_dev_name(id_buf));
     1863    sprintf(dev_name, RM_HD_PREFIX "%s", p, d, pDevName);
    18611864  }
    18621865
     
    18731876  /* try to detect virtualbox environment to enable a hack for IRQ routing */
    18741877  if (ai == ad_infos && ai->pci_vendor == 0x8086 && ai->pci_device == 0x2829 &&
    1875       !memcmp(ata_dev_name(id_buf), "VBOX HARDDISK", 13))
     1878      !memcmp(pDevName, "VBOX HARDDISK", 13))
    18761879  {
    18771880    /* running inside virtualbox */
  • trunk/src/os2ahci/ahci.h

    r183 r185  
    5959#define AHCI_PCI_BAR            5
    6060#define AHCI_MAX_PORTS          16 /* Spec says 32, but we only support 16 */
    61 #define AHCI_MAX_DEVS           8
     61#define AHCI_MAX_DEVS           1 /* was 8. we only support 1 drive per port */
    6262#define AHCI_MAX_SG             48 /* hardware max is 64K */
    6363#define AHCI_MAX_SG_ELEMENT_LEN (1UL << 22)
    6464#define AHCI_MAX_CMDS           32
    6565#define AHCI_RX_FIS_SZ          256
     66#define AHCI_DEV_NAME_LEN       40
    6667
    6768/* port-specific DMA scratch buffer aligned to 1024 bytes */
  • trunk/src/os2ahci/ata.c

    r184 r185  
    272272      if ((sg_addr & 1) || (chunk & 1))
    273273      {
    274         dprintf(0,"error: ata_cmd() called with unaligned S/G element(s)\n");
     274        dprintf(1,"error: ata_cmd() called with unaligned S/G element(s)\n");
    275275        return(ATA_CMD_UNALIGNED_ADDR);
    276276      }
  • trunk/src/os2ahci/ata.h

    r178 r185  
    491491/* -------------------------- function prototypes -------------------------- */
    492492
    493 extern int       ata_cmd                  (AD_INFO *ai, int port, int device,
    494                                            int slot, int cmd, ...);
    495 extern int       v_ata_cmd                (AD_INFO *ai, int port, int device,
    496                                            int slot, int cmd, va_list va);
    497 extern void      ata_cmd_to_fis           (u8 *fis, ATA_CMD *cmd,
    498                                            int device);
    499 extern USHORT    ata_get_sg_indx          (IORB_EXECUTEIO *io);
    500 extern void      ata_max_sg_cnt           (IORB_EXECUTEIO *io,
    501                                            USHORT sg_indx, USHORT sg_max,
    502                                            USHORT *sg_cnt,
    503                                            USHORT *sector_cnt);
     493extern int ata_cmd(AD_INFO *ai, int port, int device, int slot, int cmd, ...);
     494extern int v_ata_cmd(AD_INFO *ai, int port, int device, int slot, int cmd, va_list va);
     495extern void ata_cmd_to_fis(u8 *fis, ATA_CMD *cmd, int device);
     496extern USHORT ata_get_sg_indx(IORB_EXECUTEIO *io);
     497extern void ata_max_sg_cnt(IORB_EXECUTEIO *io, USHORT sg_indx, USHORT sg_max, USHORT *sg_cnt, USHORT *sector_cnt);
    504498
    505499extern int ata_get_geometry(IORBH FAR16DATA *iorb, IORBH *pIorb, int slot);
     
    517511extern int ata_req_sense(IORBH FAR16DATA *vIorb, IORBH *pIorb, int slot);
    518512
    519 extern char     *ata_dev_name             (u16 *id_buf);
    520 
     513extern char *ata_dev_name(u16 *id_buf);
     514
  • trunk/src/os2ahci/os2ahci.c

    r184 r185  
    13661366    if (_vIorb == vIorb)
    13671367    {
    1368 
    13691368      /* found the IORB to be removed */
    13701369      if (_vPrev != NULL)
  • trunk/src/os2ahci/os2ahci.h

    r184 r185  
    243243/* port information structure */
    244244typedef struct {
    245   IORB_QUEUE    iorb_queue;            /* IORB queue for this port */
    246   unsigned      dev_max     : 4;       /* maximum device number on this port (0..AHCI_MAX_DEVS-1) */
    247   unsigned      cmd_slot    : 5;       /* current command slot index (using round-
    248                                         * robin indexes to prevent starvation) */
    249 
    250   volatile u32  ncq_cmds;              /* bitmap for NCQ commands issued */
    251   volatile u32  reg_cmds;              /* bitmap for regular commands issued */
    252   u32           dma_buf_phys;          /* physical address of DMA scratch buffer */
    253   u8           *dma_buf;               /* DMA scatch buffers */
    254 
    255   struct {
     245  IORB_QUEUE    iorb_queue;            /* 00 IORB queue for this port */
     246  unsigned      dev_max     : 4;       /* 08 maximum device number on this port (0..AHCI_MAX_DEVS-1) */
     247  unsigned      cmd_slot    : 5;       /*    current command slot index (using round-
     248                                        *    robin indexes to prevent starvation) */
     249
     250  volatile u32  ncq_cmds;              /* 0c bitmap for NCQ commands issued */
     251  volatile u32  reg_cmds;              /* 10 bitmap for regular commands issued */
     252  u32           dma_buf_phys;          /* 14 physical address of DMA scratch buffer */
     253  u8           *dma_buf;               /* 18 DMA scatch buffers */
     254
     255  struct {                             /* 1c */
    256256    unsigned allocated :1;        /* if != 0, device is allocated */
    257257    unsigned present   :1;        /* if != 0, device is present */
     
    264264    UNITINFO *unit_info;          /* pointer to modified unit info */
    265265    DEV_INFO dev_info;
     266    char dev_name[AHCI_DEV_NAME_LEN];
    266267  } devs[AHCI_MAX_DEVS];
    267268
     
    272273/* adapter information structure */
    273274typedef struct {
    274   PCI_ID       *pci;                   /* pointer to corresponding PCI ID */
    275 
    276   unsigned      port_max : 5;          /* maximum port number (0..AHCI_MAX_PORTS-1) */
    277   unsigned      cmd_max : 5;           /* maximum cmd slot number (0-31) */
    278   unsigned      port_scan_done : 1;    /* if != 0, port scan already done */
    279   unsigned      busy : 1;              /* if != 0, adapter is busy */
    280 
    281   unsigned      hw_ports : 6;          /* number of ports as reported by the hardware */
    282 
    283   u32           port_map;              /* bitmap of active ports */
    284   u16           pci_vendor;
    285   u16           pci_device;
     275  PCI_ID       *pci;                   /* 00 pointer to corresponding PCI ID */
     276
     277  unsigned      port_max : 5;          /* 04 maximum port number (0..AHCI_MAX_PORTS-1) */
     278  unsigned      cmd_max : 5;           /*    maximum cmd slot number (0-31) */
     279  unsigned      port_scan_done : 1;    /*    if != 0, port scan already done */
     280  unsigned      busy : 1;              /*    if != 0, adapter is busy */
     281  unsigned      hw_ports : 6;          /*    number of ports as reported by the hardware */
     282
     283  u32           port_map;              /* 08   bitmap of active ports */
     284  u16           pci_vendor;            /* 0c */
     285  u16           pci_device;            /* 0e */
    286286
    287287  /* initial adapter configuration from BIOS */
    288   u32           bios_config[HOST_CAP2 / sizeof(u32) + 1];
    289 
    290   u32           cap;                   /* working copy of CAP register */
    291   u32           cap2;                  /* working copy of CAP2 register */
    292   u32           flags;                 /* adapter flags */
    293 
    294   HRESOURCE     rm_adh;                /* resource handle for adapter */
    295   HRESOURCE     rm_bars[6];            /* resource handle for MMIO and I/O BARs */
    296   HRESOURCE     rm_irq;                /* resource handle for IRQ */
    297 
    298   u16           bus_dev_func;          /* PCI bus number PCI device and function number */
    299   u16           irq;                   /* interrupt number */
    300 
    301   u32           mmio_phys;             /* physical address of MMIO region */
    302   u32           mmio_size;             /* size of MMIO region */
    303   u8           *mmio;                  /* pointer to this adapter's MMIO region */
    304 
    305   P_INFO        ports[AHCI_MAX_PORTS]; /* SATA ports on this adapter */
     288  u32           bios_config[HOST_CAP2 / sizeof(u32) + 1];  /* 10  0x24 / 4 + 1 = 0x0a dwords = 0x28 bytes*/
     289
     290  u32           cap;                   /* 38 working copy of CAP register */
     291  u32           cap2;                  /* 3c working copy of CAP2 register */
     292  u32           flags;                 /* 40 adapter flags */
     293
     294  HRESOURCE     rm_adh;                /* 44 resource handle for adapter */
     295  HRESOURCE     rm_bars[6];            /* 48 resource handle for MMIO and I/O BARs */
     296  HRESOURCE     rm_irq;                /* 60 resource handle for IRQ */
     297
     298  u16           bus_dev_func;          /* 64 PCI bus number PCI device and function number */
     299  u16           irq;                   /* 66 interrupt number */
     300
     301  u32           mmio_phys;             /* 68 physical address of MMIO region */
     302  u32           mmio_size;             /* 6c size of MMIO region */
     303  u8           *mmio;                  /* 70 pointer to this adapter's MMIO region */
     304
     305  P_INFO        ports[AHCI_MAX_PORTS]; /* 74 SATA ports on this adapter */
    306306} AD_INFO;
    307307
  • trunk/src/os2ahci/pci.c

    r184 r185  
    631631  #ifndef DAZ_NEW_CODE
    632632  /* fill in DMA scratch buffer addresses in adapter info */
    633   for (i = 0; i < ad_info->hw_ports; i++)
    634   {
     633  for (i = 0; i < AHCI_MAX_PORTS; i++)
     634  {
     635    if (!(ad_info->port_map & (1UL << i))) continue;
     636
    635637    ad_info->ports[i].dma_buf = MemAllocAlign(AHCI_PORT_PRIV_DMA_SZ, 1024);
    636638    ad_info->ports[i].dma_buf_phys = MemPhysAdr(ad_info->ports[i].dma_buf);
  • trunk/src/os2ahci/trace.c

    r184 r185  
    11/******************************************************************************
    2  * trace.c - code for our internal trace ring buffer
    32 *
    4  * Copyright (c) 2011 thi.guten Software Development
    5  * Copyright (c) 2011 Mensys B.V.
    63 * Copyright (c) 2013-2016 David Azarewicz
    74 *
    8  * Authors: Christian Mueller, Markus Thielen
    9  *
    10  * Parts copied from/inspired by the Linux AHCI driver;
    11  * those parts are (c) Linux AHCI/ATA maintainers
    12  *
    13  *  This program is free software; you can redistribute it and/or modify
    14  *  it under the terms of the GNU General Public License as published by
    15  *  the Free Software Foundation; either version 2 of the License, or
    16  *  (at your option) any later version.
    17  *
    18  *  This program is distributed in the hope that it will be useful,
    19  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    20  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    21  *  GNU General Public License for more details.
    22  *
    23  *  You should have received a copy of the GNU General Public License
    24  *  along with this program; if not, write to the Free Software
    25  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    265 */
    276
     
    5837      ai->bios_config[HOST_VERSION / sizeof(u32)]);
    5938
    60     for (p = 0; p < ai->hw_ports; p++)
     39    for (p = 0; p <= ai->port_max; p++)
    6140    {
    6241      P_INFO *pi = &ai->ports[p];
     
    8059          }
    8160          dprintf(0,"\n");
     61          dprintf(0,"             Model: %s\n", pi->devs[d].dev_name);
    8262        } /* if */
    8363      } /* for d */
Note: See TracChangeset for help on using the changeset viewer.