[IOU] Add WPP tracing to IOU bus driver.
[mirror/winof/.git] / core / iou / kernel / iou_ioc_mgr.c
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