Changeset 111 for trunk


Ignore:
Timestamp:
Jun 27, 2011, 6:40:13 PM (14 years ago)
Author:
Markus Thielen
Message:

added support for os2trace (buggy; messages get swallowed); reverted last change that ignored unknown command line arguments

Location:
trunk/src/os2ahci
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/os2ahci/Makefile

    r102 r111  
    117117# emacs TAGS file creation
    118118# NOTE: OS/2 emacs etags.exe expects an empty file named c:\dev\null...
    119 tags:   $(SRCS) $(INCS)
    120         etags.exe $(SRCS) $(INCS) Makefile
     119tags:   $(SRCS) $(INCS) Makefile
     120        etags.exe $(SRCS) $(INCS) $(DDK)\base\src\dev\dasd\diskh\dhcalls.h \
     121        $(DDK)\base\src\dev\dasd\diskh\iorb.h \
     122        $(DDK)\base\h\bsedos16.h
    121123
    122124bldday.h:
  • trunk/src/os2ahci/ahci.c

    r110 r111  
    542542      if (rc == 0) {
    543543        /* we have a valid IDENTIFY or IDENTIFY_PACKET response */
    544         ddphex(id_buf, 512, "ATA_IDENTIFY%s results:\n", (is_ata) ? "" : "_PACKET");
     544        ddphex(id_buf, 512, TRACE_MINOR_ATA_IDENTIFY,
     545               "ATA_IDENTIFY%s results:\n", (is_ata) ? "" : "_PACKET");
    545546        ahci_setup_device(ai, p, 0, id_buf);
    546547      } else {
     
    15501551  dphex(((IORB_ADAPTER_PASSTHRU _far *) iorb)->pControllerCmd,
    15511552        ((IORB_ADAPTER_PASSTHRU _far *) iorb)->ControllerCmdLen,
    1552         "ahci_execute_cdb(%d.%d.%d): ", a, p, d);
     1553        TRACE_MINOR_EXEC_CDB, "ahci_execute_cdb(%d.%d.%d): ", a, p, d);
    15531554
    15541555  if (ad_infos[a].ports[p].devs[d].atapi) {
     
    15721573  dphex(((IORB_ADAPTER_PASSTHRU _far *) iorb)->pControllerCmd,
    15731574        ((IORB_ADAPTER_PASSTHRU _far *) iorb)->ControllerCmdLen,
    1574         "ahci_execute_ata(%d.%d.%d): ", a, p, d);
     1575        TRACE_MINOR_EXEC_ATA, "ahci_execute_ata(%d.%d.%d): ", a, p, d);
    15751576
    15761577  ahci_exec_iorb(iorb, 0, ata_execute_ata);
  • trunk/src/os2ahci/ata.c

    r110 r111  
    279279  if (debug >= 2) {
    280280    printf("ATA command for %d.%d.%d:\n", ad_no(ai), p, d);
    281     phex(cmd_hdr, offsetof(AHCI_CMD_HDR, reserved), "cmd_hdr:   ");
    282     phex(&ata_cmd, sizeof(ata_cmd), "ata_cmd:   ");
     281    phex(cmd_hdr, offsetof(AHCI_CMD_HDR, reserved),
     282         TRACE_MINOR_CMD_HDR, "cmd_hdr:   ");
     283    phex(&ata_cmd, sizeof(ata_cmd), TRACE_MINOR_ATA_CMD, "ata_cmd:   ");
    283284    if (atapi_cmd != NULL) {
    284       phex(atapi_cmd, atapi_cmd_len, "atapi_cmd: ");
     285      phex(atapi_cmd, atapi_cmd_len, TRACE_MINOR_ATAPI_CMD, "atapi_cmd: ");
    285286    }
    286287    if (n > 0) {
    287       phex(cmd_tbl->sg_list, sizeof(*cmd_tbl->sg_list) * n, "sg_list:   ");
     288      phex(cmd_tbl->sg_list, sizeof(*cmd_tbl->sg_list) * n,
     289           TRACE_MINOR_SG_LIST, "sg_list:   ");
    288290    }
    289291  }
  • trunk/src/os2ahci/atapi.c

    r110 r111  
    340340  ATAPI_SENSE_DATA *psd = (ATAPI_SENSE_DATA *) aws->buf;
    341341
    342   dphex(psd, sizeof(*psd), "sense buffer:\n");
     342  dphex(psd, sizeof(*psd), TRACE_MINOR_SENSE_BUF, "sense buffer:\n");
    343343
    344344  if ((iorb->RequestControl & IORB_REQ_STATUSBLOCK) &&
  • trunk/src/os2ahci/libc.c

    r110 r111  
    5858                                                ULONG parm2);
    5959static int              mdelay_cal_end         (void);
     60static int              trace_enabled          (void);
    6061
    6162/* ------------------------ global/static variables ------------------------ */
     
    9899static ULONG heap_phys_addr;
    99100
     101/* global info segment */
     102volatile PGINFOSEG gis;
     103
     104
    100105/* ----------------------------- start of code ----------------------------- */
    101106
     
    105110void init_libc(void)
    106111{
     112  PSEL p;
     113
    107114  DevHelp_CreateSpinLock(&mem_lock);
    108115  DevHelp_CreateSpinLock(&com_lock);
    109116
    110117  DevHelp_VirtToPhys(heap_buf, &heap_phys_addr);
     118
     119  /* get global info segment */
     120  if (DevHelp_GetDOSVar(DHGETDOSV_SYSINFOSEG, 0, (PPVOID) &p) == 0) {
     121    gis = (PGINFOSEG) ((u32) *p << 16);
     122  }
     123
    111124}
    112125
     
    263276  static char buf[1024];
    264277  char *s;
     278  int len;
    265279
    266280  spin_lock(com_lock);
    267281
    268   vsprintf(buf, fmt, va);
     282  len = vsprintf(buf, fmt, va);
     283
     284   if (com_base == 0) {
     285    /* write debug message to trace buffer, not COM port */
     286    trace(debug, len, buf);
     287    spin_unlock(com_lock);
     288    return;
     289  }
    269290
    270291  /* write debug message to serial port */
     
    329350  vsprintf(buf, fmt, va);
    330351
    331   if (debug) {
     352  if (debug && com_base != 0) {
    332353    /* print the same message to COM1 as well */
    333354    printf("%s", buf);
     
    346367 * Print hex buffer to COM port.
    347368 */
    348 void phex(const void _far *p, int len, const char *fmt, ...)
     369void phex(const void _far *p, int len, u16 trace_minor_code, const char *fmt, ...)
    349370{
    350371  va_list va;
     
    353374
    354375  if (!debug) {
     376    return;
     377  }
     378
     379  if (!com_base) {
     380    /* dump to kernel trace buffer, not serial port;
     381     * just dump the buffer, it is formatted by TRACEFMT
     382     *
     383     * NOTE: writing the header to the trace buffer causes
     384     *       the trace facility to hick up and swallow the
     385     *       binary data that follows...
     386     */
     387    trace(trace_minor_code, len, buf);
    355388    return;
    356389  }
     
    705738void msleep(u32 millies)
    706739{
    707   volatile PGINFOSEG gis;
    708740  ULONG start;
    709741  ULONG end;
    710   PSEL p;
    711 
    712   if (DevHelp_GetDOSVar(DHGETDOSV_SYSINFOSEG, 0, (PPVOID) &p)) {
     742
     743  if (gis == NULL) {
    713744    /* no global info segment; use mdelay() */
    714745    mdelay(millies);
    715746    return;
    716747  }
    717   gis = (PGINFOSEG) ((u32) *p << 16);
     748
    718749  start = gis->msecs;
    719750  end = start + millies;
     
    834865  return(mdelay_cal_status == MD_CALIBRATION_END);
    835866}
     867
     868/******************************************************************************
     869 * is_trace_enabled - checks if kernel tracing is enabled
     870 */
     871int is_trace_enabled(void)
     872{
     873  int ret = 1; /* if global info seg is not present/known,
     874                * we enable tracing for now */
     875
     876  /* check global info segment's trace enabled bitmap if our
     877   * major trace code is enabled
     878   */
     879  if (gis) {
     880    u8 trace_bitmap = gis->amecRAS[AHCI_TRACE_MAJOR / 8];
     881    if (trace_bitmap & (0x80 >> (AHCI_TRACE_MAJOR % 8))) {
     882      ret = 1;
     883    } else {
     884      ret = 0;
     885    }
     886  }
     887
     888  return ret;
     889}
     890
     891/******************************************************************************
     892 * trace - write a buffer to the kernel trace buffer
     893 */
     894void trace(u16 minor_code, u16 cb_buf, const char _far *buf)
     895{
     896  if (!is_trace_enabled()) {
     897    return;
     898  }
     899
     900  DevHelp_RAS(AHCI_TRACE_MAJOR, minor_code, cb_buf, (PBYTE) buf);
     901}
     902
  • trunk/src/os2ahci/os2ahci.c

    r110 r111  
    307307
    308308      default:
    309         cprintf("unknown option: /%c - ignored\n", *s);
    310         break;
     309        cprintf("unknown option: /%c\n", *s);
     310        goto init_fail;
    311311      }
    312312    }
  • trunk/src/os2ahci/os2ahci.h

    r110 r111  
    250250#define ANSI_CLR_WHITE  "\x1b[37m"
    251251#define ANSI_RESET      "\x1b[0m"
     252
     253/******************************************************************************
     254 * trace constants
     255 */
     256#define AHCI_TRACE_MAJOR 0x00faU
     257#define TRACE_MINOR_ATA_IDENTIFY  0x0020
     258#define TRACE_MINOR_EXEC_CDB      0x0021
     259#define TRACE_MINOR_EXEC_ATA      0x0022
     260#define TRACE_MINOR_ATA_CMD       0x0023
     261#define TRACE_MINOR_ATAPI_CMD     0x0024
     262#define TRACE_MINOR_SG_LIST       0x0025
     263#define TRACE_MINOR_SENSE_BUF     0x0026
     264#define TRACE_MINOR_OEMHLP_PARM   0x0027
     265#define TRACE_MINOR_OEMHLP_DATA   0x0028
     266#define TRACE_MINOR_CMD_HDR       0x0029
     267
     268
    252269
    253270/* ------------------------ typedefs and structures ------------------------ */
     
    447464extern void        cprintf       (const char *fmt, ...);
    448465extern void        phex          (const void _far *p, int len,
    449                                   const char *fmt, ...);
     466                                  u16 trace_minor_code, const char *fmt, ...);
    450467extern size_t      strlen        (const char _far *s);
    451468extern char _far  *strcpy        (char _far *dst, const char _far *src);
     
    465482extern int         disable       (void);
    466483extern void        enable        (void);
     484extern void        trace         (u16 minor_code, u16 cb_buf,
     485                                  const char _far *buf);
    467486
    468487/* pci.c */
     
    488507extern USHORT      ioctl_passthrough  (RP_GENIOCTL _far *ioctl);
    489508
     509
    490510/* ---------------------------- global variables --------------------------- */
    491511
  • trunk/src/os2ahci/pci.c

    r108 r111  
    937937  }
    938938
    939   dddphex(parm, sizeof(*parm), "oemhlp_parm: ");
    940   dddphex(data, sizeof(*data), "oemhlp_data: ");
     939  dddphex(parm, sizeof(*parm), TRACE_MINOR_OEMHLP_PARM, "oemhlp_parm: ");
     940  dddphex(data, sizeof(*data), TRACE_MINOR_OEMHLP_DATA, "oemhlp_data: ");
    941941
    942942  if (ioctl.rph.Status & STERR) {
  • trunk/src/os2ahci/version.h

    r110 r111  
    1414
    1515
    16 #define VERSION            115       /* driver version (2 implied decimals) */
     16#define VERSION            116       /* driver version (2 implied decimals) */
    1717
Note: See TracChangeset for help on using the changeset viewer.