[IOU] Add WPP tracing to IOU bus driver.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 30 Aug 2006 18:35:01 +0000 (18:35 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 30 Aug 2006 18:35:01 +0000 (18:35 +0000)
Submitted by Yossi Leybovich (sleybo@mellanox.co.il)

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@469 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/iou/kernel/SOURCES
core/iou/kernel/iou_driver.c
core/iou/kernel/iou_driver.h
core/iou/kernel/iou_ioc_mgr.c
core/iou/kernel/iou_pnp.c

index 3796900..141da4c 100644 (file)
@@ -2,6 +2,13 @@ TARGETNAME=ibiou
 TARGETPATH=..\..\..\bin\kernel\obj$(BUILD_ALT_DIR)\r
 TARGETTYPE=DRIVER\r
 \r
+!if $(FREEBUILD)\r
+ENABLE_EVENT_TRACING=1\r
+!else\r
+#ENABLE_EVENT_TRACING=1\r
+!endif\r
+\r
+\r
 SOURCES= ibiou.rc              \\r
        iou_driver.c            \\r
        iou_pnp.c                       \\r
@@ -9,7 +16,8 @@ SOURCES= ibiou.rc              \
 \r
 INCLUDES=..\..\..\inc;..\..\..\inc\kernel;\r
 \r
-C_DEFINES=$(C_DEFINES) -DDRIVER -DDEPRECATE_DDK_FUNCTIONS -DNEED_CL_OBJ\r
+C_DEFINES=$(C_DEFINES) -DDRIVER -DDEPRECATE_DDK_FUNCTIONS -DNEED_CL_OBJ -DWPP_OLDCC\r
+\r
 \r
 TARGETLIBS= \\r
        $(TARGETPATH)\*\complib.lib\r
@@ -22,4 +30,15 @@ TARGETLIBS= \
 TARGETLIBS= $(TARGETLIBS) $(DDK_LIB_PATH)\ntstrsafe.lib\r
 !endif\r
 \r
+!IFDEF ENABLE_EVENT_TRACING\r
+\r
+C_DEFINES = $(C_DEFINES) -DEVENT_TRACING\r
+\r
+RUN_WPP = $(SOURCES) -km -ext: .c .h .C .H \\r
+  -scan:iou_driver.h \\r
+       -func:IOU_PRINT(LEVEL,FLAGS,(MSG,...)) \\r
+       -func:IOU_PRINT_EXIT(LEVEL,FLAGS,(MSG,...)) \r
+\r
+!ENDIF\r
+\r
 MSC_WARNING_LEVEL= /W4\r
index a062767..3586e27 100644 (file)
 \r
 #include <complib/cl_types.h>\r
 #include "iou_driver.h"\r
+#if defined(EVENT_TRACING)\r
+#ifdef offsetof\r
+#undef offsetof\r
+#endif\r
+#include "iou_driver.tmh"\r
+#endif\r
 #include "iou_pnp.h"\r
 #include <complib/cl_init.h>\r
 \r
 \r
 iou_globals_t  iou_globals = {\r
-       IOU_DBG_ERROR,\r
        NULL\r
 };\r
 \r
+uint32_t               g_iou_dbg_level = TRACE_LEVEL_ERROR;\r
+uint32_t               g_iou_dbg_flags = 0x00000fff;\r
 \r
 static NTSTATUS\r
 __read_registry(\r
@@ -106,7 +113,7 @@ __read_registry(
 {\r
        NTSTATUS                                        status;\r
        /* Remember the terminating entry in the table below. */\r
-       RTL_QUERY_REGISTRY_TABLE        table[2];\r
+       RTL_QUERY_REGISTRY_TABLE        table[3];\r
        UNICODE_STRING                          param_path;\r
 \r
        IOU_ENTER( IOU_DBG_DRV );\r
@@ -117,7 +124,7 @@ __read_registry(
        param_path.Buffer = cl_zalloc( param_path.MaximumLength );\r
        if( !param_path.Buffer )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, \r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR,IOU_DBG_ERROR,\r
                        ("Failed to allocate parameters path buffer.\n") );\r
                return STATUS_INSUFFICIENT_RESOURCES;\r
        }\r
@@ -134,15 +141,24 @@ __read_registry(
        /* Setup the table entries. */\r
        table[0].Flags = RTL_QUERY_REGISTRY_DIRECT;\r
        table[0].Name = L"DebugFlags";\r
-       table[0].EntryContext = &iou_globals.dbg_lvl;\r
+       table[0].EntryContext = &g_iou_dbg_level;\r
        table[0].DefaultType = REG_DWORD;\r
-       table[0].DefaultData = &iou_globals.dbg_lvl;\r
+       table[0].DefaultData = &g_iou_dbg_level;\r
        table[0].DefaultLength = sizeof(ULONG);\r
 \r
+       table[1].Flags = RTL_QUERY_REGISTRY_DIRECT;\r
+       table[1].Name = L"DebugFlags";\r
+       table[1].EntryContext = &g_iou_dbg_flags;\r
+       table[1].DefaultType = REG_DWORD;\r
+       table[1].DefaultData = &g_iou_dbg_flags;\r
+       table[1].DefaultLength = sizeof(ULONG);\r
        /* Have at it! */\r
-       status = RtlQueryRegistryValues( RTL_REGISTRY_ABSOLUTE, \r
+       status = RtlQueryRegistryValues( RTL_REGISTRY_ABSOLUTE,\r
                param_path.Buffer, table, NULL, NULL );\r
 \r
+       if( g_iou_dbg_flags & IOU_DBG_ERR )\r
+               g_iou_dbg_flags |= CL_DBG_ERROR;\r
+\r
        cl_free( param_path.Buffer );\r
        IOU_EXIT( IOU_DBG_DRV );\r
        return status;\r
@@ -185,6 +201,9 @@ iou_unload(
        IN                              DRIVER_OBJECT                           *p_driver_obj )\r
 {\r
        IOU_ENTER( IOU_DBG_DRV );\r
+#if defined(EVENT_TRACING)\r
+       WPP_CLEANUP( p_drv_obj );\r
+#endif\r
 \r
        UNUSED_PARAM( p_driver_obj );\r
 \r
@@ -203,10 +222,14 @@ DriverEntry(
 \r
        IOU_ENTER( IOU_DBG_DRV );\r
 \r
+#if defined(EVENT_TRACING)\r
+       WPP_INIT_TRACING( p_drv_obj, p_registry_path );\r
+#endif\r
+\r
        status = CL_INIT;\r
        if( !NT_SUCCESS(status) )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("cl_init returned %08X.\n", status) );\r
                return status;\r
        }\r
@@ -219,7 +242,7 @@ DriverEntry(
        if( !NT_SUCCESS(status) )\r
        {\r
                CL_DEINIT;\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, \r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("__read_registry returned %08x.\n", status) );\r
                return status;\r
        }\r
index b4cefae..d8c028f 100644 (file)
 #endif\r
 #include <ntstrsafe.h>\r
 \r
+extern uint32_t                g_iou_dbg_level;\r
+extern uint32_t                g_iou_dbg_flags;\r
+\r
+#if defined(EVENT_TRACING)\r
+//\r
+// Software Tracing Definitions \r
+//\r
+\r
+#define WPP_CONTROL_GUIDS \\r
+       WPP_DEFINE_CONTROL_GUID(IOUCtlGuid,(A0090FEF,01BB,4617,AF1E,FD02FD5B24ED),  \\r
+       WPP_DEFINE_BIT( IOU_DBG_ERROR) \\r
+       WPP_DEFINE_BIT( IOU_DBG_DRV) \\r
+       WPP_DEFINE_BIT( IOU_DBG_PNP) \\r
+       WPP_DEFINE_BIT( IOU_DBG_POWER) \\r
+       WPP_DEFINE_BIT( IOU_DBG_PORT) \\r
+       WPP_DEFINE_BIT( IOU_DBG_IOU))\r
+\r
+\r
+\r
+#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level  >= lvl)\r
+#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags)\r
+#define WPP_FLAG_ENABLED(flags)(WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level  >= TRACE_LEVEL_VERBOSE)\r
+#define WPP_FLAG_LOGGER(flags) WPP_LEVEL_LOGGER(flags)\r
+\r
+\r
+// begin_wpp config\r
+// IOU_ENTER(FLAG);\r
+// IOU_EXIT(FLAG);\r
+// USEPREFIX(IOU_PRINT, "%!STDPREFIX! [IOU] :%!FUNC!() :");\r
+// USESUFFIX(IOU_ENTER, " [IOU] :%!FUNC!():[");\r
+// USESUFFIX(IOU_EXIT, " [IOU] :%!FUNC!():]");\r
+// end_wpp\r
+\r
+\r
+#else\r
+\r
+\r
+#include <evntrace.h>\r
 \r
 /*\r
- * Main header for IB Bus driver.\r
+ * Debug macros\r
  */\r
 \r
-#define IOU_ENTER( lvl )                       \\r
-       CL_ENTER( lvl, iou_globals.dbg_lvl )\r
 \r
-#define IOU_EXIT( lvl )                                \\r
-       CL_EXIT( lvl, iou_globals.dbg_lvl )\r
+#define IOU_DBG_ERR            (1 << 0)\r
+#define IOU_DBG_DRV            (1 << 1)\r
+#define IOU_DBG_PNP            (1 << 2)\r
+#define IOU_DBG_POWER  (1 << 3)\r
+#define IOU_DBG_PORT   (1 << 4)\r
+#define IOU_DBG_IOU            (1 << 5)\r
+\r
+#define IOU_DBG_ERROR  (CL_DBG_ERROR | IOU_DBG_ERR)\r
+#define IOU_DBG_ALL            CL_DBG_ALL\r
+\r
+#if DBG\r
+\r
+// assignment of _level_ is need to to overcome warning C4127\r
+#define IOU_PRINT(_level_,_flag_,_msg_) \\r
+       { \\r
+               if( g_iou_dbg_level >= (_level_) ) \\r
+                       CL_TRACE( _flag_, g_iou_dbg_flags, _msg_ ); \\r
+       }\r
+\r
+#define IOU_PRINT_EXIT(_level_,_flag_,_msg_) \\r
+       { \\r
+               if( g_iou_dbg_level >= (_level_) ) \\r
+                       CL_TRACE( _flag_, g_iou_dbg_flags, _msg_ );\\r
+               IOU_EXIT(_flag_);\\r
+       }\r
 \r
-#define IOU_TRACE( lvl, msg )          \\r
-       CL_TRACE( lvl, iou_globals.dbg_lvl, msg )\r
+#define IOU_ENTER(_flag_) \\r
+       { \\r
+               if( g_iou_dbg_level >= TRACE_LEVEL_VERBOSE ) \\r
+                       CL_ENTER( _flag_, g_iou_dbg_flags ); \\r
+       }\r
 \r
-#define IOU_TRACE_EXIT( lvl, msg )     \\r
-       CL_TRACE_EXIT( lvl, iou_globals.dbg_lvl, msg )\r
+#define IOU_EXIT(_flag_)\\r
+       { \\r
+               if( g_iou_dbg_level >= TRACE_LEVEL_VERBOSE ) \\r
+                       CL_EXIT( _flag_, g_iou_dbg_flags ); \\r
+       }\r
+\r
+\r
+#else\r
+\r
+#define IOU_PRINT(lvl, flags, msg)\r
+\r
+#define IOU_PRINT_EXIT(_level_,_flag_,_msg_)\r
+\r
+#define IOU_ENTER(_flag_)\r
+\r
+#define IOU_EXIT(_flag_)\r
+\r
+\r
+#endif\r
+\r
+\r
+#endif //EVENT_TRACING\r
+\r
+/*\r
+ * Main header for IB Bus driver.\r
+ */\r
 \r
-#define IOU_PRINT( lvl, msg )          \\r
-       CL_PRINT( lvl, iou_globals.dbl_lvl, msg )\r
 \r
-#define IOU_DBG_ERROR  CL_DBG_ERROR\r
-#define IOU_DBG_DRV            (1 << 0)\r
-#define IOU_DBG_PNP            (1 << 1)\r
-#define IOU_DBG_POWER  (1 << 2)\r
-#define IOU_DBG_PORT   (1 << 3)\r
-#define IOU_DBG_IOU            (1 << 4)\r
 \r
 /*\r
  * ALLOC_PRAGMA sections:\r
@@ -160,9 +238,6 @@ typedef struct _iou_pdo_ext
  */\r
 typedef struct _iou_globals\r
 {\r
-       /* Debug level. */\r
-       uint32_t                                dbg_lvl;\r
-\r
        /* Driver object.  Used for creating child devices. */\r
        DRIVER_OBJECT                   *p_driver_obj;\r
 \r
index ee5061f..c59c19e 100644 (file)
 #include <iba/ib_types.h>\r
 #include <complib/cl_async_proc.h>\r
 #include <complib/cl_bus_ifc.h>\r
+#include "iou_driver.h"\r
+#if defined(EVENT_TRACING)\r
+#ifdef offsetof\r
+#undef offsetof\r
+#endif\r
+#include "iou_ioc_mgr.tmh"\r
+#endif\r
 #include "iou_pnp.h"\r
 #include "iou_ioc_mgr.h"\r
 #include <initguid.h>\r
@@ -282,7 +289,7 @@ ioc_mgr_init(
        if( cl_status != CL_SUCCESS )\r
        {\r
                free_ioc_mgr( &p_ioc_mgr->obj );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("cl_mutex_init returned %s.\n", cl_status_text[cl_status]) );\r
                return IB_ERROR;\r
        }\r
@@ -293,7 +300,7 @@ ioc_mgr_init(
        if( cl_status != CL_SUCCESS )\r
        {\r
                free_ioc_mgr( &p_ioc_mgr->obj );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("cl_obj_init returned %s.\n", cl_status_text[cl_status]) );\r
                return IB_ERROR;\r
        }\r
@@ -302,7 +309,8 @@ ioc_mgr_init(
        if( status != IB_SUCCESS )\r
        {\r
                cl_obj_destroy( &p_ioc_mgr->obj );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, ("ib_reg_pnp returned %s.\n",\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
+                       ("ib_reg_pnp returned %s.\n",\r
                        p_ioc_mgr->ifc.get_err_str(status)) );\r
                return status;\r
        }\r
@@ -318,7 +326,8 @@ ioc_mgr_init(
        if( status != IB_SUCCESS )\r
        {\r
                cl_obj_destroy( &p_ioc_mgr->obj );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, ("ib_reg_pnp returned %s.\n",\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
+                       ("ib_reg_pnp returned %s.\n",\r
                        p_ioc_mgr->ifc.get_err_str(status)) );\r
                return status;\r
        }\r
@@ -453,7 +462,8 @@ ioc_mgr_get_iou_relations(
        if( !n_devs )\r
        {\r
                cl_mutex_release( &p_ioc_mgr->pdo_mutex );\r
-               IOU_TRACE_EXIT( IOU_DBG_PNP, ("No child PDOs.\n") );\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IOU_DBG_PNP,\r
+                       ("No child PDOs.\n") );\r
                return STATUS_NO_SUCH_DEVICE;\r
        }\r
 \r
@@ -462,7 +472,7 @@ ioc_mgr_get_iou_relations(
        if( !NT_SUCCESS( status ) )\r
        {\r
                cl_mutex_release( &p_ioc_mgr->pdo_mutex );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("cl_alloc_relations returned %08x.\n", status) );\r
                return status;\r
        }\r
@@ -496,7 +506,8 @@ ioc_mgr_ioc_add(
                p_pnp_rec->info.chassis_slot != p_ioc_mgr->info.slot||\r
                p_pnp_rec->info.iou_guid != p_ioc_mgr->info.guid )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_PNP, ("IOC not in this IOU.\n") );\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IOU_DBG_PNP,\r
+                       ("IOC not in this IOU.\n") );\r
                return IB_NOT_DONE;\r
        }\r
 \r
@@ -510,13 +521,13 @@ ioc_mgr_ioc_add(
                FALSE, &p_pdo );\r
        if( !NT_SUCCESS( status ) )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("IoCreateDevice returned %08x.\n", status) );\r
                return IB_ERROR;\r
        }\r
 \r
        /* Initialize the device extension. */\r
-       cl_init_pnp_po_ext( p_pdo, NULL, p_pdo, iou_globals.dbg_lvl,\r
+       cl_init_pnp_po_ext( p_pdo, NULL, p_pdo, g_iou_dbg_flags,\r
                &vfptr_ioc_pnp, &vfptr_iou_query_txt );\r
 \r
        /* Set the DO_BUS_ENUMERATED_DEVICE flag to mark it as a PDO. */\r
@@ -624,7 +635,8 @@ ioc_release_resources(
 \r
        /* Remove this PDO from its list. */\r
        cl_mutex_acquire( &p_ioc_mgr->pdo_mutex );\r
-       IOU_TRACE( IOU_DBG_PNP, ("Removing IOC from list.\n") );\r
+       IOU_PRINT( TRACE_LEVEL_INFORMATION, IOU_DBG_PNP,\r
+               ("Removing IOC from list.\n") );\r
        cl_qlist_remove_item( &p_ioc_mgr->ioc_list, &p_ext->pdo.list_item );\r
        cl_mutex_release( &p_ioc_mgr->pdo_mutex );\r
        po_state.DeviceState = PowerDeviceD3;\r
@@ -654,7 +666,8 @@ ioc_remove(
                cl_set_pnp_state( &p_ext->pdo.cl_ext, NotStarted );\r
                /* Don't delete the device.  It may simply be disabled. */\r
                *p_action = IrpComplete;\r
-               IOU_TRACE_EXIT( IOU_DBG_PNP, ("Device still present.\n") );\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IOU_DBG_PNP,\r
+                       ("Device still present.\n") );\r
                return STATUS_SUCCESS;\r
        }\r
 \r
@@ -663,7 +676,8 @@ ioc_remove(
                /* Reset the state to RemovePending.  Complib set it to Deleted. */\r
                cl_rollback_pnp_state( &p_ext->pdo.cl_ext );\r
                *p_action = IrpComplete;\r
-               IOU_TRACE_EXIT( IOU_DBG_PNP, ("Device not reported missing yet.\n") );\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IOU_DBG_PNP,\r
+                       ("Device not reported missing yet.\n") );\r
                return STATUS_SUCCESS;\r
        }\r
 \r
@@ -773,7 +787,7 @@ ioc_query_target_relations(
        status = cl_alloc_relations( p_irp, 1 );\r
        if( !NT_SUCCESS( status ) )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("cl_alloc_relations returned 0x%08x.\n", status) );\r
                return status;\r
        }\r
@@ -803,14 +817,15 @@ ioc_query_device_id(
        p_ext = (ioc_ext_t*)p_dev_obj->DeviceExtension;\r
        if( !p_ext->pdo.b_present )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, ("Device not present.\n") );\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
+                       ("Device not present.\n") );\r
                return STATUS_NO_SUCH_DEVICE;\r
        }\r
 \r
        p_string = ExAllocatePool( PagedPool, IOC_DEV_ID_SIZE );\r
        if( !p_string )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to allocate device ID buffer (%d bytes).\n",\r
                        IOC_DEV_ID_SIZE) );\r
                return STATUS_INSUFFICIENT_RESOURCES;\r
@@ -826,7 +841,7 @@ ioc_query_device_id(
        if( !NT_SUCCESS( status ) )\r
        {\r
                ExFreePool( p_string );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to format device ID string.\n") );\r
                return status;\r
        }\r
@@ -854,14 +869,15 @@ ioc_query_hardware_ids(
        p_ext = (ioc_ext_t*)p_dev_obj->DeviceExtension;\r
        if( !p_ext->pdo.b_present )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, ("Device not present.\n") );\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
+                       ("Device not present.\n") );\r
                return STATUS_NO_SUCH_DEVICE;\r
        }\r
 \r
        p_string = ExAllocatePool( PagedPool, IOC_HW_ID_SIZE );\r
        if( !p_string )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to allocate hardware ID buffer (%d bytes).\n",\r
                        IOC_HW_ID_SIZE) );\r
                return STATUS_INSUFFICIENT_RESOURCES;\r
@@ -882,7 +898,7 @@ ioc_query_hardware_ids(
        if( !NT_SUCCESS( status ) )\r
        {\r
                ExFreePool( p_string );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to format hardware ID string.\n") );\r
                return status;\r
        }\r
@@ -894,7 +910,7 @@ ioc_query_hardware_ids(
        if( !NT_SUCCESS( status ) )\r
        {\r
                ExFreePool( p_string );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to format hardware ID string.\n") );\r
                return status;\r
        }\r
@@ -906,7 +922,7 @@ ioc_query_hardware_ids(
        if( !NT_SUCCESS( status ) )\r
        {\r
                ExFreePool( p_string );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to format hardware ID string.\n") );\r
                return status;\r
        }\r
@@ -918,7 +934,7 @@ ioc_query_hardware_ids(
        if( !NT_SUCCESS( status ) )\r
        {\r
                ExFreePool( p_string );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to format hardware ID string.\n") );\r
                return status;\r
        }\r
@@ -945,14 +961,15 @@ ioc_query_compatible_ids(
        p_ext = (ioc_ext_t*)p_dev_obj->DeviceExtension;\r
        if( !p_ext->pdo.b_present )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, ("Device not present.\n") );\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
+                       ("Device not present.\n") );\r
                return STATUS_NO_SUCH_DEVICE;\r
        }\r
 \r
        p_string = ExAllocatePool( PagedPool, IOC_COMPAT_ID_SIZE );\r
        if( !p_string )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to allocate compatible ID buffer (%d bytes).\n",\r
                        IOC_HW_ID_SIZE) );\r
                return STATUS_INSUFFICIENT_RESOURCES;\r
@@ -971,7 +988,7 @@ ioc_query_compatible_ids(
        if( !NT_SUCCESS( status ) )\r
        {\r
                ExFreePool( p_string );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to format device ID string.\n") );\r
                return status;\r
        }\r
@@ -983,7 +1000,7 @@ ioc_query_compatible_ids(
        if( !NT_SUCCESS( status ) )\r
        {\r
                ExFreePool( p_string );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to format device ID string.\n") );\r
                return status;\r
        }\r
@@ -1008,7 +1025,8 @@ ioc_query_unique_id(
        p_ext = p_dev_obj->DeviceExtension;\r
        if( !p_ext->pdo.b_present )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, ("Device not present.\n") );\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
+                       ("Device not present.\n") );\r
                return STATUS_NO_SUCH_DEVICE;\r
        }\r
 \r
@@ -1016,7 +1034,7 @@ ioc_query_unique_id(
        p_string = ExAllocatePool( PagedPool, sizeof(WCHAR) * 17 );\r
        if( !p_string )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to allocate instance ID buffer (%d bytes).\n",\r
                        sizeof(WCHAR) * 17) );\r
                return STATUS_NO_MEMORY;\r
@@ -1028,7 +1046,7 @@ ioc_query_unique_id(
        {\r
                CL_ASSERT( NT_SUCCESS( status ) );\r
                ExFreePool( p_string );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("RtlStringCchPrintfW returned %08x.\n", status) );\r
                return status;\r
        }\r
@@ -1054,7 +1072,8 @@ ioc_query_description(
        p_ext = p_dev_obj->DeviceExtension;\r
        if( !p_ext->pdo.b_present )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, ("Device not present.\n") );\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
+                       ("Device not present.\n") );\r
                return STATUS_NO_SUCH_DEVICE;\r
        }\r
 \r
@@ -1062,7 +1081,7 @@ ioc_query_description(
                PagedPool, sizeof(WCHAR) * sizeof(p_ext->info.profile.id_string) );\r
        if( !p_string )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to allocate device description buffer (%d bytes).\n",\r
                        sizeof(WCHAR) * sizeof(p_ext->info.profile.id_string)) );\r
                return STATUS_INSUFFICIENT_RESOURCES;\r
@@ -1092,7 +1111,7 @@ ioc_query_description(
        {\r
                CL_ASSERT( NT_SUCCESS( status ) );\r
                ExFreePool( p_string );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("RtlStringCchPrintfW returned %08x.\n", status) );\r
                return status;\r
        }\r
@@ -1117,14 +1136,15 @@ ioc_query_location(
        p_ext = (ioc_ext_t*)p_dev_obj->DeviceExtension;\r
        if( !p_ext->pdo.b_present )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, ("Device not present.\n") );\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
+                       ("Device not present.\n") );\r
                return STATUS_NO_SUCH_DEVICE;\r
        }\r
 \r
        p_string = ExAllocatePool( PagedPool, IOC_LOCATION_SIZE );\r
        if( !p_string )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to allocate location buffer (%d bytes).\n",\r
                        IOC_LOCATION_SIZE) );\r
                return STATUS_INSUFFICIENT_RESOURCES;\r
@@ -1146,7 +1166,7 @@ ioc_query_location(
        if( !NT_SUCCESS( status ) )\r
        {\r
                ExFreePool( p_string );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to format device ID string.\n") );\r
                return status;\r
        }\r
@@ -1171,7 +1191,8 @@ ioc_query_bus_info(
        p_ext = (ioc_ext_t*)p_dev_obj->DeviceExtension;\r
        if( !p_ext->pdo.b_present )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, ("Device not present.\n") );\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
+                       ("Device not present.\n") );\r
                return STATUS_NO_SUCH_DEVICE;\r
        }\r
 \r
@@ -1180,7 +1201,7 @@ ioc_query_bus_info(
        p_iou_info = ExAllocatePool( PagedPool, sizeof(PNP_BUS_INFORMATION) );\r
        if( !p_iou_info )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to allocate PNP_BUS_INFORMATION (%d bytes).\n",\r
                        sizeof(PNP_BUS_INFORMATION)) );\r
                return STATUS_INSUFFICIENT_RESOURCES;\r
@@ -1254,14 +1275,16 @@ ioc_query_interface(
        /* Compare requested GUID with our supported interface GUIDs. */\r
        if( IsEqualGUID( p_guid, &GUID_BUS_INTERFACE_STANDARD ) )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_PNP, ("BUS_INTERFACE_STANDARD\n") );\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IOU_DBG_PNP,\r
+                       ("BUS_INTERFACE_STANDARD\n") );\r
                return cl_fwd_query_ifc(\r
                        p_ext->pdo.p_parent_ext->cl_ext.p_self_do, p_io_stack );\r
        }\r
 \r
        if( !IsEqualGUID( p_guid, &GUID_IB_AL_INTERFACE ) )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_PNP, ("Unsupported interface: \n\t"\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IOU_DBG_PNP,\r
+                       ("Unsupported interface: \n\t"\r
                        "0x%08x, 0x%04x, 0x%04x, 0x%02x, 0x%02x, 0x%02x,"\r
                        "0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x.\n",\r
                        p_guid->Data1, p_guid->Data2, p_guid->Data3,\r
@@ -1276,14 +1299,15 @@ ioc_query_interface(
                p_ext->pdo.p_parent_ext->cl_ext.p_self_do, p_io_stack );\r
        if( !NT_SUCCESS( status ) )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to forward interface query: %08X\n", status) );\r
                return status;\r
        }\r
 \r
        if( !p_io_stack->Parameters.QueryInterface.InterfaceSpecificData )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, ("No interface specific data!\n") );\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
+                       ("No interface specific data!\n") );\r
                return status;\r
        }\r
 \r
@@ -1296,7 +1320,8 @@ ioc_query_interface(
                p_ifc_data->version != IOC_INTERFACE_DATA_VERSION )\r
        {\r
                p_ifc->wdm.InterfaceDereference( p_ifc->wdm.Context );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, ("Unsupported interface data: \n\t"\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
+                       ("Unsupported interface data: \n\t"\r
                        "0x%08x, 0x%04x, 0x%04x, 0x%02x, 0x%02x, 0x%02x,"\r
                        "0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x.\n",\r
                        p_guid->Data1, p_guid->Data2, p_guid->Data3,\r
@@ -1311,7 +1336,7 @@ ioc_query_interface(
        if( p_ifc_data->size != sizeof(ioc_ifc_data_t) )\r
        {\r
                p_ifc->wdm.InterfaceDereference( p_ifc->wdm.Context );\r
-               IOU_TRACE_EXIT( IOU_DBG_PNP,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IOU_DBG_PNP,\r
                        ("Buffer too small (%d given, %d required).\n",\r
                        p_ifc_data->size,\r
                        sizeof(ioc_ifc_data_t)) );\r
index 51d48b1..3652c2c 100644 (file)
  */\r
 \r
 \r
+#include "iou_driver.h"\r
+#if defined(EVENT_TRACING)\r
+#ifdef offsetof\r
+#undef offsetof\r
+#endif\r
+#include "iou_pnp.tmh"\r
+#endif\r
 #include "iou_pnp.h"\r
 #include "iou_ioc_mgr.h"\r
 #include <complib/cl_memory.h>\r
@@ -161,7 +168,7 @@ iou_add_device(
                FILE_DEVICE_SECURE_OPEN, FALSE, &p_dev_obj );\r
        if( !NT_SUCCESS(status) )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, \r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to create bus root FDO device.\n") );\r
                return status;\r
        }\r
@@ -174,11 +181,12 @@ iou_add_device(
        if( !p_next_do )\r
        {\r
                IoDeleteDevice( p_dev_obj );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, ("IoAttachToDeviceStack failed.\n") );\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
+                       ("IoAttachToDeviceStack failed.\n") );\r
                return STATUS_NO_SUCH_DEVICE;\r
        }\r
 \r
-       cl_init_pnp_po_ext( p_dev_obj, p_next_do, p_pdo, iou_globals.dbg_lvl,\r
+       cl_init_pnp_po_ext( p_dev_obj, p_next_do, p_pdo, g_iou_dbg_flags,\r
                &vfptr_fdo_pnp, NULL );\r
 \r
        IOU_EXIT( IOU_DBG_PNP );\r
@@ -246,7 +254,7 @@ fdo_start(
        status = cl_do_sync_pnp( p_dev_obj, p_irp, p_action );\r
        if( !NT_SUCCESS( status ) )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, \r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Lower drivers failed IRP_MN_START_DEVICE.\n") );\r
                return status;\r
        }\r
@@ -254,7 +262,7 @@ fdo_start(
        status = __get_iou_ifc( p_ext );\r
        if( !NT_SUCCESS( status ) )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR,\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("Failed to get IOU interface.\n") );\r
                return status;\r
        }\r
@@ -263,7 +271,8 @@ fdo_start(
        ib_status = ioc_mgr_init( &p_ext->ioc_mgr );\r
        if( ib_status != IB_SUCCESS )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, ("ioc_mgr_init returned %s.\n",\r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
+                       ("ioc_mgr_init returned %s.\n",\r
                        p_ext->ioc_mgr.ifc.get_err_str(ib_status)) );\r
                return STATUS_UNSUCCESSFUL;\r
        }\r
@@ -334,7 +343,7 @@ fdo_query_capabilities(
 \r
        if( !NT_SUCCESS( status ) )\r
        {\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, \r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("cl_do_sync_pnp returned %08x.\n", status) );\r
                return status;\r
        }\r
@@ -499,7 +508,7 @@ __set_power_completion(
        {\r
                PoStartNextPowerIrp( p_irp );\r
                IoReleaseRemoveLock( &p_ext->cl_ext.remove_lock, p_irp );\r
-               IOU_TRACE_EXIT( IOU_DBG_ERROR, \r
+               IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("IRP_MN_SET_POWER for system failed by lower driver with %08x.\n",\r
                        p_irp->IoStatus.Status) );\r
                return STATUS_SUCCESS;\r
@@ -522,7 +531,7 @@ __set_power_completion(
                p_irp->IoStatus.Status = status;\r
                IoCompleteRequest( p_irp, IO_NO_INCREMENT );\r
                IoReleaseRemoveLock( &p_ext->cl_ext.remove_lock, p_irp );\r
-               IOU_TRACE( IOU_DBG_ERROR,\r
+               IOU_PRINT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
                        ("PoRequestPowerIrp returned %08x.\n", status) );\r
        }\r
 \r