/*****************************************************************************
 * Copyright (C) Cinterion Wireless Modules GmbH
 *****************************************************************************
 * Project: Quinn-CE-USB-Driver
 *****************************************************************************
 * Author : Siemens AG Berlin COM WM RD SW
 *****************************************************************************
 * $Workfile: D:/develop/ccviews/ctna0152_ms-d_view/z_ms-d/src/working/Quinn/HcUsbDrv/HcUsbDbg.h $
 * $Revision: /main/ms-d/26 $
 * $Date: 2011-06-15 18:00:31 $
 * $Author: ctna0152 $
 *****************************************************************************
 * Target:
 *  Microsoft Windows CE 5.0
 *****************************************************************************
 * Description:
 *  Quinn-USB-Driver: Header file for general debug settings
 *****************************************************************************
 *
 * $Log: D:/develop/ccviews/ctna0152_ms-d_view/z_ms-d/src/working/Quinn/HcUsbDrv/HcUsbDbg.h$ 
 * 
 * /main/ms-d/26   2011-06-15 18:00:31   ctna0152 
 * changed default debug message settings (added ZONE_USB_HOSTFN_ERROR) 
 * 
 * /main/ms-d/25   2011-01-13 15:23:42   ctna0152 
 * added debug zone for zero length packets 
 * 
 * /main/ms-d/24   2010-12-14 15:18:21   ctna0152 
 * added ZONE_USB_SUSPEND_INFO 
 * 
 * /main/ms-d/23   2010-12-13 14:21:24   ctna0152 
 * added USB reset handling 
 * 
 * /main/ms-d/22   2009-02-18 11:49:09   ctna0256 
 * Set copyright text 
 * 
 * /main/ms-d/21   2008-08-20 11:39:07   ctna0450 
 * Prepared for new disclaimer handling 
 * 
 * /main/ms-d/20   2008-07-31 15:52:59   ht37010 
 * replaced RIL trace defines with USB trace defines 
 * 
 * /main/ms-d/19   2008-04-11 18:35:15   ht37010 
 * added debug zone ZONE_USB_HOSTFN_ERROR 
 * 
 * /main/ms-d/18   2007-12-18 13:13:40   ht37010 
 * added new debug zones 
 * 
 * /main/ms-d/17   2007-09-12 12:52:16   ht37010 
 *  
 * /main/ms-d/16   2007-08-28 12:52:19   ht37010
 *
 * /main/ms-d/15   2007-08-14 12:44:54   ht37010 
 * added new debug zones 
 * 
 * /main/ms-d/14   2007-08-02 15:44:53   ht37010 
 * added zone for host function calls 
 * 
 * /main/ms-d/13   2007-08-01 10:29:57   ht37010 
 * added new debug zone for system locks 
 * 
 * /main/ms-d/12   2007-04-16 12:25:18   ht37010 
 * new default values 
 * 
 * /main/ms-d/11   2006-11-09 09:46:09   wm36264 
 * Added useful debug zones 
 * 
 * /main/ms-d/10   2006-11-03 17:07:09   wm36264 
 * Continued to prepare selective suspend handling
 *
 * /main/ms-d/9   2006-10-30 12:21:47   wm36264
 * Fixed problems with disabled retail trace
 *
 * /main/ms-d/8   2006-10-27 16:52:52   wm36264
 * Fixed probelm with debug defines
 *
 * /main/ms-d/7   2006-10-18 12:33:58   wm36264
 * Several modifications regarding default pipe handling for qmi
 *
 * /main/ms-d/6   2006-10-12 16:52:51   wm36264
 * For a possible future selective suspend implementation it is much easier when there is only one pipe class
 *
 * /main/ms-d/5   2006-09-29 15:33:18   wm36264
 * Consider latest findings about QMI and NDIS handling
 *
 * /main/ms-d/4   2006-09-27 17:07:11   wm36264
 * Switched to central version and trace handling
 *
 * /main/ms-d/3   2006-09-22 14:33:25   wm36264
 * Cosmetics mostly
 *
 * /main/ms-d/2   2006-09-21 17:05:41   wm36264
 * Prepared access to QMI interface
 *
 * /main/ms-d/1   2006-09-18 15:31:20   wm36264
 * Initial Quinn Windows CE USB Driver based on UsbSer
 *
*/

//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2008 Cinterion Wireless Modules GmbH
// Copyright (C) 2006-2008 Siemens AG
//
// Version: 1.0
// Date:    dummy
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

//////////////////////////////////////////////////////////////////////////////
//
// Debug Zones.
//
//////////////////////////////////////////////////////////////////////////////

#ifndef DEBUG

#define ZONE_ERROR                       1
#define ZONE_INIT                        1
#define ZONE_LOCK                        0

#define ZONE_INFO                        0
#define ZONE_WARN                        0

#define ZONE_USB                         1
#define ZONE_USB_NOTIFY                  0
#define ZONE_USB_PARSE                   0
#define ZONE_USB_PIPE                    0
#define ZONE_USB_TRANSFER                0
#define ZONE_USB_SUSPEND                 1
#define ZONE_USB_RESUME                  1
#define ZONE_USB_HOSTFN                  0
#define ZONE_USB_HOSTFN_ERROR            1

#define ZONE_PORT                        0
#define ZONE_PORT_READ                   0
#define ZONE_PORT_WRITE                  0
#define ZONE_PORT_DATA                   0
#define ZONE_PORT_SIGNALS                0
#define ZONE_PORT_EVENTS                 0
#define ZONE_PORT_IOCTL                  0

#define ZONE_USB_DISABLE                 0
#define ZONE_USB_DISABLE_INFO            1
#define ZONE_USB_WATCHDOG                0

#define ZONE_USB_SUSPEND_INFO            1

#define ZONE_USB_ZLP                     1

#else   // DEBUG

#define ZONE_ERROR                       DEBUGZONE(0)
#define ZONE_INIT                        DEBUGZONE(1)
#define ZONE_USB                         DEBUGZONE(2)
#define ZONE_USB_PARSE                   DEBUGZONE(3)
#define ZONE_USB_PIPE                    DEBUGZONE(4)
#define ZONE_USB_TRANSFER                DEBUGZONE(5)
#define ZONE_USB_SUSPEND                 DEBUGZONE(6)
#define ZONE_PORT_READ                   DEBUGZONE(7)
#define ZONE_PORT_WRITE                  DEBUGZONE(8)
#define ZONE_PORT_DATA                   DEBUGZONE(9)
#define ZONE_PORT_SIGNALS                DEBUGZONE(10)
#define ZONE_PORT_EVENTS                 DEBUGZONE(11)
#define ZONE_LOCK                        DEBUGZONE(12)
#define ZONE_USB_HOSTFN                  DEBUGZONE(13)
#define ZONE_PORT                        DEBUGZONE(14)
#define ZONE_PORT_IOCTL                  DEBUGZONE(15)
#define ZONE_INFO                        DEBUGZONE(16)
#define ZONE_WARN                        DEBUGZONE(17)
#define ZONE_USB_RESUME                  DEBUGZONE(18)
#define ZONE_USB_NOTIFY                  DEBUGZONE(19)
#define ZONE_USB_HOSTFN_ERROR            DEBUGZONE(20)
#define ZONE_USB_DISABLE                 DEBUGZONE(21)
#define ZONE_USB_DISABLE_INFO            DEBUGZONE(22)
#define ZONE_USB_WATCHDOG                DEBUGZONE(23)
#define ZONE_USB_SUSPEND_INFO            DEBUGZONE(24)
#define ZONE_USB_ZLP                     DEBUGZONE(25)

#endif // DEBUG

//////////////////////////////////////////////////////////////////////////////

#if defined(USB_TRACE_REQUIRED) || defined (DEBUG)

#define DUMP_USB_DEVICE_DESCRIPTOR(d) {                                                             \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: -----------------------------\r\n")));                     \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: USB_DEVICE_DESCRIPTOR:\r\n")));                            \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bLength: 0x%x\r\n"), d.bLength));                          \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bDescriptorType: 0x%x\r\n"), d.bDescriptorType));          \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bcdUSB: 0x%x\r\n"), d.bcdUSB));                            \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bDeviceClass: 0x%x\r\n"), d.bDeviceClass));                \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bDeviceSubClass: 0x%x\r\n"), d.bDeviceSubClass));          \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bDeviceProtocol: 0x%x\r\n"), d.bDeviceProtocol));          \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bMaxPacketSize0: 0x%x\r\n"), d.bMaxPacketSize0));          \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: idVendor: 0x%x\r\n"), d.idVendor));                        \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: idProduct: 0x%x\r\n"), d.idProduct));                      \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bcdDevice: 0x%x\r\n"), d.bcdDevice));                      \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: iManufacturer: 0x%x\r\n"), d.iManufacturer));              \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: iProduct: 0x%x\r\n"), d.iProduct));                        \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: iSerialNumber: 0x%x\r\n"), d.iSerialNumber));              \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bNumConfigurations: 0x%x\r\n"), d.bNumConfigurations));    \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: -----------------------------\r\n")));                     \
}

#define DUMP_USB_CONFIGURATION_DESCRIPTOR(c) {                                                      \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: -----------------------------\r\n")));                     \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: USB_CONFIGURATION_DESCRIPTOR:\r\n")));                     \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bLength: 0x%x\r\n"), c.bLength));                          \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bDescriptorType: 0x%x\r\n"), c.bDescriptorType));          \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: wTotalLength: 0x%x\r\n"), c.wTotalLength));                \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bNumInterfaces: 0x%x\r\n"), c.bNumInterfaces));            \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bConfigurationValue: 0x%x\r\n"), c.bConfigurationValue));  \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: iConfiguration: 0x%x\r\n"), c.iConfiguration));            \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bmAttributes: 0x%x\r\n"), c.bmAttributes));                \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: MaxPower: 0x%x\r\n"), c.MaxPower));                        \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: -----------------------------\r\n")));                     \
}

#define DUMP_USB_INTERFACE_DESCRIPTOR(i, index) {                                                   \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: -----------------------------\r\n")));                     \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: USB_INTERFACE_DESCRIPTOR[%02d]:\r\n"), index));            \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bLength: 0x%x\r\n"), i.bLength));                          \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bDescriptorType: 0x%x\r\n"), i.bDescriptorType));          \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bInterfaceNumber: 0x%x\r\n"), i.bInterfaceNumber));        \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bAlternateSetting: 0x%x\r\n"), i.bAlternateSetting));      \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bNumEndpoints: 0x%x\r\n"), i.bNumEndpoints));              \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bInterfaceClass: 0x%x\r\n"), i.bInterfaceClass));          \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bInterfaceSubClass: 0x%x\r\n"), i.bInterfaceSubClass));    \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bInterfaceProtocol: 0x%x\r\n"), i.bInterfaceProtocol));    \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: iInterface: 0x%x\r\n"), i.iInterface));                    \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: -----------------------------\r\n")));                     \
}

#define DUMP_USB_ENDPOINT_DESCRIPTOR(e) {                                                           \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: -----------------------------\r\n")));                     \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: USB_ENDPOINT_DESCRIPTOR:\r\n")));                          \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bLength: 0x%x\r\n"), e.bLength));                          \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bDescriptorType: 0x%x\r\n"), e.bDescriptorType));          \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bEndpointAddress: 0x%x\r\n"), e.bEndpointAddress));        \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bmAttributes: 0x%x\r\n"), e.bmAttributes));                \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: wMaxPacketSize: 0x%x\r\n"), e.wMaxPacketSize));            \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: bInterval: 0x%x\r\n"), e.bInterval));                      \
  DEBUGMSG(ZONE_USB_PARSE, (TEXT("HcUsb: -----------------------------\r\n")));                     \
}

#define GET_DIRECTION_STRING(f)  ((f) ? TEXT("Out") : TEXT("In"))

#define GET_PIPE_STRING(t, i)    ((t == USB_ENDPOINT_TYPE_CONTROL)      ? TEXT("Default Control Pipe")   : \
                                 ((t == USB_ENDPOINT_TYPE_ISOCHRONOUS) && USB_ENDPOINT_DIRECTION_IN(i))  ? \
                                                                          TEXT("Isochrounous In Pipe")   : \
                                 ((t == USB_ENDPOINT_TYPE_ISOCHRONOUS) && USB_ENDPOINT_DIRECTION_OUT(i)) ? \
                                                                          TEXT("Isochrounous Out Pipe")  : \
                                 ((t == USB_ENDPOINT_TYPE_BULK)        && USB_ENDPOINT_DIRECTION_IN(i))  ? \
                                                                          TEXT("Bulk In Pipe")           : \
                                 ((t == USB_ENDPOINT_TYPE_BULK)        && USB_ENDPOINT_DIRECTION_OUT(i)) ? \
                                                                          TEXT("Bulk Out Pipe")          : \
                                 ((t == USB_ENDPOINT_TYPE_INTERRUPT)   && USB_ENDPOINT_DIRECTION_IN(i))  ? \
                                                                          TEXT("Interrupt In Pipe")      : \
                                 ((t == USB_ENDPOINT_TYPE_INTERRUPT)   && USB_ENDPOINT_DIRECTION_OUT(i)) ? \
                                                                          TEXT("Interrupt Out Pipe")     : \
                                                                          TEXT("Unknown Pipe"))

#else // WANT_RETAIL_HCUSBDRV_OUTPUT || DEBUG

#define DUMP_USB_DEVICE_DESCRIPTOR(p)
#define DUMP_USB_CONFIGURATION_DESCRIPTOR(c)
#define DUMP_USB_INTERFACE_DESCRIPTOR(i, index)
#define DUMP_USB_ENDPOINT_DESCRIPTOR(e)
#define GET_DIRECTION_STRING(d)
#define GET_PIPE_STRING(t, i)

#endif // WANT_RETAIL_HCUSBDRV_OUTPUT || DEBUG
