Changeset 156


Ignore:
Timestamp:
May 6, 2013, 7:57:39 PM (12 years ago)
Author:
David Azarewicz
Message:

debugging updates

Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/os2ahci/Makefile

    r155 r156  
    3232BLD_MINOR=27 # must be 2 digits
    3333BLD_REV=0 # not used at this time
     34FIXPACK=Test Build
    3435
    3536!ifndef %WATCOM # if not defined in the environment
  • trunk/src/os2ahci/README

    r154 r156  
    9393============
    9494
    95 - Copy the driver file, OS2AHCI.ADD, to C:\OS2\BOOT
     95- Run the included update.cmd,
     96  or copy the driver file, OS2AHCI.ADD, to \OS2\BOOT on your boot disk.
    9697
    9798- Add the following line to CONFIG.SYS:
     
    106107Option                 Description
    107108------------------------------------------------------------------------------
    108 /c:<addr>              Set debug COM port base address in hex (default = 0);
    109                        if used, this option should come before any /d options.
    110                        If <addr> is set to 0, the COM port is turned off and
    111                        all output is directed to an internal trace ring buffer
    112                        that can be dumped on an OS/2 command prompt with the
    113                        command "type os2ahci$"; see the OS2AHCI project page
    114                        at http://svn.ecomstation.nl/ahci/wiki/AhciTrace
    115                        for more info. COM0=3f8, COM1=2f8
    116 /d                     Debug output on COM port/trace buffer; multiple "/d"
    117                        options will increase verbosity:
     109/b:<baud>              Initialize the COM port to the specified baud rate. Allowable
     110                       baud values are: 300, 600, 1200, 2400, 4800, 9600, 19200,
     111                       38400, 57600, and 115200. /b has no effect if /c is not also
     112                       specified. If /b is not specified, the COM port is not
     113                       initialized. For example, if you are using the kernel debugger,
     114                       the kernel debugger initializes the COM port so you should not
     115                       use this switch.
     116
     117/c:<n>                 Set debug COM port base address. Values for n can be:
     118                         1 = COM1
     119                         2 = COM2
     120                         a hex value (COM port base address) COM1=3f8, COM2=2f8
     121                       The default is 0. If set to 0 then no output goes to the COM port.
     122
     123/d[:n]                 Debug output to COM port/trace buffer. Values for n can be:
    118124                         1 = requests
    119125                         2 = detailed
    120126                         3 = verbose, including MMIO operations
    121 /v                     display adapter info during boot
     127                       If :n is not specified the debug level is incremented for
     128                       each /d specified.
     129
     130/w                     Allows the trace buffer to wrap when full.
     131
     132/v[:n]                 Display informational messages during boot. Values for n can be:
     133                         1 = Display sign on banner
     134                         2 = Display adapter information
     135                       If :n is not specified the verbosity level is incremented for
     136                       each /v specified.
     137
    122138/g:<vendor>:<device>   Add generic PCI ID to list of supported AHCI adapters
    123139                       (e.g. /g:8086:2829)
     140
    124141/t                     Perform thorough PCI ID scan; default = on, can be
    125142                       turned off with /!t to perform only a PCI class scan
     143
    126144/f                     Force the use of the HW write cache when using NCQ
    127145                       commands; see "Native Command Queuing" below for
    128146                       further explanation (default = off)
     147
    129148/r                     Reset ports during initialization (default = on)
    130149                       Can be turned off with /!r, however, when the
     
    132151                       initialized by the BIOS in SATA mode, ports will
    133152                       always be reset even when /!r was specified
    134 /a                     Set adapter for adapter-specific options
     153
     154/a:n                   Set adapter to n for adapter-specific options
    135155                       (default = -1, all adapters)
    136 /p                     Set port for port-specific options
     156
     157/p:n                   Set port to n for port-specific options
    137158                       (default = -1, all ports)
    138159
     
    149170/s                     Enable SCSI emulation for ATAPI units (default = off)
    150171                       SCSI emulation is required for tools like cdrecord.
     172
    151173/n                     Enable NCQ (Native Command Queuing) for hard disks
    152174                       (default = off)
     175
    153176/ls                    Set link speed (default = 0):
    154177                         0 = maximum,
     
    156179                         2 = limit to generation 2
    157180                         3 = limit to generation 3
     181
    158182/lp                    Set link power management (default = 0):
    159183                         0 = full power management,
    160184                         1 = transitions to "partial slumber state" disabled,
    161185                         2 = transitions to "slumber state" disabled,
    162                          3 = transitions to both partial and slumber states
    163                              disabled
     186                         3 = transitions to both partial and slumber states disabled
     187
    164188/4                     Force track size to be 56 sectors regardless of the
    165189                       reported disk geometry to optimize partition boundaries
     
    371395   DSKSP_GEN_GET_COUNTERS IOCTL request.
    372396
     397
     398Change Log
     399==========
     400
     401v.1.27 23-Apr-2013 - David Azarewicz
     402  Added LVM aware disk geometry reporting.
     403  Begin to add disk information report - not finished yet.
     404  Removed undocumented /q switch and made the driver quiet by default.
     405  Debug output improvements.
     406  Added /b switch for setting debug baud rate.
     407
     408v.1.26 26-Mar-2013 - David Azarewicz
     409  Fix spin-up / power-up issue on some hardware
     410  Reorganized and improved debug output.
     411
     412v.1.26 21-Feb-2013 - rousseau
     413  Virtual box fix
     414  Some SMP fixes
     415  Changed default for port reset to always
     416
     417v.1.25 02-Oct-2012 - markus.thi
     418  Added support for trap dumps
     419
     420v.1.24 21-May-2012 - markus.thi
     421  Fixed JFS long format hang (ticket 16)
     422
     423V.1.23 16-May-2012 - markus.thi
     424  added IDC entry point to allow switching back to BIOS mode
     425
     426v.1.22 17-Oct-2011 - markus.thi
     427  Added "IBMS506" header to accomodate broken SMART tools.
  • trunk/src/os2ahci/ahci.c

    r155 r156  
    957957  writel(port_mmio + PORT_CMD, tmp);
    958958
    959   /* wait for completion, spec says 500ms, give it 1000 */
     959  /* wait for completion, spec says 500ms, give it 1000ms */
    960960  while (timeout > 0 && (readl(port_mmio + PORT_CMD) & PORT_CMD_FIS_ON)) {
    961961    mdelay(10);
  • trunk/src/os2ahci/ata.c

    r155 r156  
    441441}
    442442
    443 /******************************************************************************
    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  */
    449 int is_lvm_geometry(IORBH _far *iorb)
     443int check_lvm(IORBH _far *iorb, ULONG sector)
    450444{
    451445  ADD_WORKSPACE _far *aws = add_workspace(iorb);
     
    454448  PDLA_Table_Sector pDLA;
    455449  int p = iorb_unit_port(iorb);
     450  int rc;
     451
     452  rc = ahci_exec_polled_cmd(ai, p, 0, 500, ATA_CMD_READ,
     453         AP_SECTOR_28, (u32) sector-1,
     454         AP_COUNT, (u16) 1,
     455         AP_VADDR, (void _far *) aws->buf, 512,
     456         AP_DEVICE, 0x40,
     457         AP_END);
     458  if (rc) return 0;
     459
     460  pDLA = (PDLA_Table_Sector)aws->buf;
     461  ddphex(pDLA, sizeof(DLA_Table_Sector), "DLA sector %d:\n", sector-1);
     462
     463  if ((pDLA->DLA_Signature1 == DLA_TABLE_SIGNATURE1) && (pDLA->DLA_Signature2 == DLA_TABLE_SIGNATURE2)) {
     464    ddprintf("is_lvm_geometry found at sector %d\n", sector);
     465    geometry->TotalCylinders = pDLA->Cylinders;
     466    geometry->NumHeads = pDLA->Heads_Per_Cylinder;
     467    geometry->SectorsPerTrack = pDLA->Sectors_Per_Track;
     468    return 1;
     469  }
     470
     471  return 0;
     472}
     473
     474/******************************************************************************
     475 * Try to read LVM information from the disk. If found, use the LVM geometry.
     476 * This function will only work at init time. A better strategy would be to
     477 * calculate the geometry during ahci_scan_ports and save it away and then just
     478 * return the saved values when ata_get_geometry() is called.
     479 */
     480int is_lvm_geometry(IORBH _far *iorb)
     481{
     482  GEOMETRY _far *geometry = ((IORB_GEOMETRY _far *) iorb)->pGeometry;
     483  AD_INFO *ai = ad_infos + iorb_unit_adapter(iorb);
     484  int p = iorb_unit_port(iorb);
    456485  int d = iorb_unit_device(iorb);
    457   int rc;
    458486  ULONG sector;
    459487
     
    463491    ddprintf("is_lvm_geometry (%d.%d.%d)\n", ad_no(ai), p, d);
    464492
     493    /* First check the sector reported by the hardware */
     494    if (check_lvm(iorb, geometry->SectorsPerTrack)) return 1;
     495
    465496    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       }
     497      if (sector == geometry->SectorsPerTrack) continue;
     498      if (check_lvm(iorb, sector)) return 1;
    484499    }
    485500  }
  • trunk/src/os2ahci/libc.c

    r154 r156  
    7575};
    7676
    77 /* COM port initialization sequence */
    7877static struct {
    79   int reg;
    80   u8  data;
    81 } com_init_sequence[] = {
    82   3, 0x80,   /* overlay divisor latch register at 0x3f8 and 0x3f9 */
    83   0, 0x01,   /* set low byte of divisor to 1 (115200 baud) */
    84   1, 0x00,   /* set high byte of divisor to 0 */
    85   3, 0x03,   /* reset divisor latch register overlay and set 8,n,1 */
    86   1, 0x00,   /* disable interrupts */
    87   4, 0x0f,   /* modem control register */
    88   -1, 0x00
     78  long Baud;
     79  u16 Data;
     80} BaudCodes[] = {
     81  115200, 0x0001,
     82  57600, 0x0002,
     83  38400, 0x0003,
     84  19200, 0x0006,
     85  9600, 0x000C,
     86  4800, 24,
     87  2400, 48,
     88  1200, 96,
     89  600, 192,
     90  300, 384,
     91  0, 0 /* end of list */
    8992};
    9093
     
    132135 *       to be fixed eventually...
    133136 */
    134 void init_com(void)
     137void init_com(long BaudRate)
    135138{
    136139  int i;
    137 
    138   if (com_base == 0) {
    139     /* no com port in use */
    140     return;
    141   }
     140  u16 RegData;
     141
     142  if (com_base == 0) return; /* no com port in use */
     143
     144  /* Find the baud code for the given baud rate */
     145  for (i = 0; BaudCodes[i].Baud; i++) if (BaudCodes[i].Baud == BaudRate) break;
     146  if (BaudCodes[i].Baud == 0) i = 0; /* default to 115200 */
     147  RegData = BaudCodes[i].Data;
    142148
    143149  spin_lock(com_lock);
    144150
    145   for (i = 0; com_init_sequence[i].reg != -1; i++) {
    146     u16 port = com_base + com_init_sequence[i].reg;
    147     u8  data = com_init_sequence[i].data;
    148     _asm {
    149       mov  dx, port;
    150       mov  al, data;
    151       out  dx, al;
    152     }
     151  __asm {
     152    mov     bx,RegData
     153    mov     dx,com_base     ; Base address
     154    cli
     155    add     dx,3            ; Line Control (+3)
     156    mov     al,10000000b    ; Set baud flag
     157    out     dx,al           ; for speed setting
     158
     159    ; Set Baud
     160    dec     dx              ; High divisor address
     161    dec     dx              ; (+1)
     162    mov     al,bh           ; High divisor value
     163    out     dx,al           ; set it
     164    dec     dx              ; Low divisor address (+0)
     165    mov     al,bl           ; Low divisor value
     166    out     dx,al           ; set baud rate
     167
     168    ; Set frame
     169    mov      al,00000011b   ; Set 8 bit, none, none
     170    add      dx,3           ; Line Control (+3)
     171    out      dx,al
     172
     173    inc      dx
     174    mov      al,3
     175    out      dx,al          ; DTR & RTS to High
     176    sti
    153177  }
    154178
     
    753777  ULONG start;
    754778  ULONG end;
     779  ULONG event_id;
    755780
    756781  if (gis == NULL) {
     
    762787  start = gis->msecs;
    763788  end = start + millies;
     789  event_id = (ULONG)&msleep;
    764790
    765791  if (end < start) {
    766792    /* wrap-around; wait until 'msecs' has wrapped, too */
    767793    while (gis->msecs >= start) {
    768       DevHelp_Yield();
     794      DevHelp_ProcBlock(event_id, 1, WAIT_IS_INTERRUPTABLE);
    769795    }
    770796  }
    771797
    772798  while (gis->msecs <= end) {
    773     DevHelp_Yield();
     799    DevHelp_ProcBlock(event_id, 1, WAIT_IS_INTERRUPTABLE);
    774800  }
    775801}
  • trunk/src/os2ahci/os2ahci.c

    r155 r156  
    4545  }
    4646
     47#define drv_parm_int_optional(s, value, type, radix) \
     48  { \
     49    char _far *_ep; \
     50    if ((s)[1] == ':') { \
     51      value = (type) strtol((s) + 2, (const char _far* _far*) &_ep, radix); \
     52      s = _ep; \
     53    } else { \
     54      value++; \
     55    } \
     56  }
     57
    4758/* set two-dimensional array of port options */
    4859#define set_port_option(opt, val)                         \
     
    8899int             init_reset = 1;    /* if != 0, reset ports during init */
    89100int             force_write_cache; /* if != 0, force write cache */
    90 int             verbosity = 1;     /* == 1 -> show sign on banner
    91                                     *  > 1 -> show adapter info during boot */
     101int             verbosity = 0;     /* default is quiet. 1=show sign on banner, >1=show adapter info during boot */
    92102int             use_lvm_info = 1;
     103int             wrap_trace_buffer = 0;
     104long            com_baud = 0;
    93105
    94106PFN             Device_Help = 0;   /* pointer to device helper entry point */
     
    243255        goto init_fail;
    244256
     257      case 'b':
     258        drv_parm_int(s, com_baud, u32, 10);
     259        break;
     260
    245261      case 'c':
    246262        /* set COM port base address for debug messages */
     
    252268      case 'd':
    253269        /* increase debug level */
    254         debug++;
     270        drv_parm_int_optional(s, debug, int, 10);
    255271        break;
    256272
     
    347363
    348364      case 'z':
     365        /* Specify to not use the LVM information. There is no reason why anyone would
     366         * want to do this, but previous versions of this driver did not have LVM capability,
     367         * so this switch is here temporarily just in case.
     368         */
    349369        use_lvm_info = !invert_option;
    350370        break;
     
    352372      case 'v':
    353373        /* be verbose during boot */
    354         verbosity++;
     374        drv_parm_int_optional(s, verbosity, int, 10);
     375        break;
     376
     377      case 'w':
     378        /* Specify to allow the trace buffer to wrap when full. */
     379        wrap_trace_buffer = !invert_option;
    355380        break;
    356381
    357382      case 'q':
    358         /* be quiet */
    359         verbosity = -1000;
     383        /* Temporarily output a non-fatal message to get anyone using this
     384         * undocumented switch to stop using it. This will be removed soon
     385         * and the error will become fatal.
     386         */
     387        cprintf("%s: unknown option: /%c\n", drv_name, *s);
    360388        break;
    361389
     
    370398  ciprintf(init_msg, drv_name, VERSION / 100, VERSION % 100);
    371399
    372 //#ifdef ECS_BUILD
    373 //  ciprintf("This driver is licensed for use only in conjunction with eComStation.\n");
    374 //#else
    375 //  ciprintf("This is the Open Watcom build.\n");
    376 //#endif
    377 
    378   if (debug) {
    379     /* initialize com port for debug output */
    380     //DAZ init_com();
    381   }
     400  if (com_baud) init_com(com_baud); /* initialize com port for debug output */
    382401
    383402  /* initialize trace buffer if applicable */
  • trunk/src/os2ahci/os2ahci.h

    r154 r156  
    500500/* libc.c */
    501501extern void        init_libc     (void);
    502 extern void        init_com      (void);
     502extern void        init_com      (long BaudRate);
    503503extern int         vsprintf      (char _far *buf, const char *fmt, va_list va);
    504504extern int         sprintf       (char _far *buf, const char *fmt, ...);
     
    574574extern int           verbosity;     /* if != 0, show some info during boot */
    575575extern int           use_lvm_info;
     576extern int           wrap_trace_buffer;
    576577
    577578extern HDRIVER       rm_drvh;       /* resource manager driver handle */
  • trunk/src/os2ahci/trace.c

    r154 r156  
    136136
    137137  while (len) {
    138     /* The following line causes filling the trace buffer to stop when full.
    139      * Comment the following line to keep filling and see the last buffer of data.
    140      * Uncomment the following line to stop filling / see the first buffer of data.
    141      */
    142     if ( ((ahci_trace_buf.writep+1) & ahci_trace_buf.mask) == ahci_trace_buf.readp ) break; /* buffer is full */
     138    if ( !wrap_trace_buffer && (((ahci_trace_buf.writep+1) & ahci_trace_buf.mask) == ahci_trace_buf.readp) ) break; /* buffer is full */
    143139
    144140    ahci_trace_buf.tbuf[ahci_trace_buf.writep] = *s++;
Note: See TracChangeset for help on using the changeset viewer.