From 42356824820f1ba32e4bb89d246e9e00bf331d71 Mon Sep 17 00:00:00 2001 From: ftillier Date: Fri, 29 Jul 2005 05:41:02 +0000 Subject: [PATCH] Make kernel complib static git-svn-id: svn://openib.tc.cornell.edu/gen1@49 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/core/al/kernel/al_driver.c | 14 ++++- trunk/core/bus/kernel/SOURCES | 2 +- trunk/core/bus/kernel/bus_driver.c | 18 ++++-- trunk/core/bus/kernel/ib_bus.inf | 6 +- trunk/core/complib/cl_memory.c | 16 ++++- trunk/core/complib/cl_obj.c | 10 ++++ trunk/core/complib/kernel/SOURCES | 2 +- trunk/core/complib/kernel/cl_driver.c | 37 ------------ trunk/core/iou/kernel/SOURCES | 2 +- trunk/core/iou/kernel/iou_driver.c | 15 ++++- trunk/hw/mt23108/kernel/hca_driver.c | 13 ++++ trunk/hw/mt23108/kernel/infinihost.inf | 6 +- .../vapi/mlxsys/os_dep/win/tdriver/Md.c | 12 ++++ trunk/inc/kernel/complib/cl_init.h | 59 +++++++++++++++++++ trunk/inc/kernel/complib/cl_types_osd.h | 14 ++--- trunk/tests/alts/kernel/alts.inf | 2 +- trunk/tests/alts/kernel/alts_driver.c | 13 +++- trunk/ulp/ipoib/kernel/SOURCES | 2 +- trunk/ulp/ipoib/kernel/ipoib_adapter.c | 11 ++++ trunk/ulp/srp/kernel/SOURCES | 5 +- trunk/ulp/srp/kernel/srp_driver.c | 21 ++++++- 21 files changed, 203 insertions(+), 77 deletions(-) create mode 100644 trunk/inc/kernel/complib/cl_init.h diff --git a/trunk/core/al/kernel/al_driver.c b/trunk/core/al/kernel/al_driver.c index 4ca19705..96320c65 100644 --- a/trunk/core/al/kernel/al_driver.c +++ b/trunk/core/al/kernel/al_driver.c @@ -34,8 +34,7 @@ // Provides the driver entry points for the Access Layer. // -#include "complib/cl_types.h" -#include "complib/cl_memory.h" +#include #include "al_init.h" #include "al_mgr.h" #include "al_debug.h" @@ -239,10 +238,19 @@ DllInitialize( AL_ENTER( AL_DBG_DEV ); + status = CL_INIT; + if( !NT_SUCCESS(status) ) + { + AL_TRACE_EXIT( AL_DBG_ERROR, + ("cl_init returned %08X.\n", status) ); + return status; + } + /* Get the registry values. */ status = __read_registry( p_registry_path ); if( !NT_SUCCESS(status) ) { + CL_DEINIT; AL_TRACE_EXIT( AL_DBG_ERROR, ("__read_registry returned %08x.\n", status) ); return status; @@ -258,6 +266,8 @@ DllUnload( void ) { AL_ENTER( AL_DBG_DEV ); + CL_DEINIT; + AL_EXIT( AL_DBG_DEV ); return STATUS_SUCCESS; } diff --git a/trunk/core/bus/kernel/SOURCES b/trunk/core/bus/kernel/SOURCES index 13f2bd1f..4bdc58da 100644 --- a/trunk/core/bus/kernel/SOURCES +++ b/trunk/core/bus/kernel/SOURCES @@ -10,7 +10,7 @@ SOURCES= ibbus.rc \ INCLUDES=..\..\..\inc;..\..\..\inc\kernel;..\..\al;..\..\al\kernel; -C_DEFINES=$(C_DEFINES) -DDRIVER -DDEPRECATE_DDK_FUNCTIONS +C_DEFINES=$(C_DEFINES) -DDRIVER -DDEPRECATE_DDK_FUNCTIONS -DNEED_CL_OBJ TARGETLIBS= \ $(TARGETPATH)\*\complib.lib \ diff --git a/trunk/core/bus/kernel/bus_driver.c b/trunk/core/bus/kernel/bus_driver.c index 5022bb99..09c17139 100644 --- a/trunk/core/bus/kernel/bus_driver.c +++ b/trunk/core/bus/kernel/bus_driver.c @@ -30,18 +30,17 @@ */ - - /* * Provides the driver entry points for the InfiniBand Bus Driver. */ -#include "complib/cl_types.h" +#include #include "bus_driver.h" #include "bus_pnp.h" #include "al_mgr.h" #include "al_dev.h" -#include "complib/cl_memory.h" +#include + bus_globals_t bus_globals = { BUS_DBG_ERROR, @@ -327,6 +326,8 @@ bus_drv_unload( UNUSED_PARAM( p_driver_obj ); + CL_DEINIT; + BUS_EXIT( BUS_DBG_DRV ); } @@ -340,6 +341,14 @@ DriverEntry( BUS_ENTER( BUS_DBG_DRV ); + status = CL_INIT; + if( !NT_SUCCESS(status) ) + { + BUS_TRACE_EXIT( BUS_DBG_ERROR, + ("cl_init returned %08X.\n", status) ); + return status; + } + /* Store the driver object pointer in the global parameters. */ bus_globals.p_driver_obj = p_driver_obj; @@ -347,6 +356,7 @@ DriverEntry( status = __read_registry( p_registry_path ); if( !NT_SUCCESS(status) ) { + CL_DEINIT; BUS_TRACE_EXIT( BUS_DBG_ERROR, ("__read_registry returned %08x.\n", status) ); return status; diff --git a/trunk/core/bus/kernel/ib_bus.inf b/trunk/core/bus/kernel/ib_bus.inf index 5db472df..46d82132 100644 --- a/trunk/core/bus/kernel/ib_bus.inf +++ b/trunk/core/bus/kernel/ib_bus.inf @@ -7,7 +7,7 @@ Class=System ClassGuid={4D36E97D-E325-11CE-BFC1-08002BE10318} Provider=%SST% CatalogFile=ibbus.cat -DriverVer=05/10/2005,3.0.0031.0 +DriverVer=07/28/2005,3.0.0034.0 ; ================= Device Install section ===================== @@ -28,7 +28,6 @@ Ibbus.WOW64CopyFiles=%DIRID_SYSTEM_X86% 1=%DiskId%,,,\ia64 [SourceDisksFiles.x86] -complib.sys=1 ibal.sys=1 ibbus.sys=1 ibiou.sys=1 @@ -42,7 +41,6 @@ dapld.dll=1 dapl.dll=1 [SourceDisksFiles.amd64] -complib.sys=1 ibal.sys=1 ibbus.sys=1 ibiou.sys=1 @@ -64,7 +62,6 @@ dapl32d.dll=1 dapl32.dll=1 [SourceDisksFiles.ia64] -complib.sys=1 ibal.sys=1 ibbus.sys=1 ibiou.sys=1 @@ -154,7 +151,6 @@ CopyFiles = Iou.CopyFiles AddService = ibiou,%SPSVCINST_ASSOCSERVICE%,Iou.ServiceInstall [Ibbus.CopyFiles] -complib.sys ibal.sys ibbus.sys diff --git a/trunk/core/complib/cl_memory.c b/trunk/core/complib/cl_memory.c index 5f8d7366..3ed52f01 100644 --- a/trunk/core/complib/cl_memory.c +++ b/trunk/core/complib/cl_memory.c @@ -42,9 +42,11 @@ #include "cl_memtrack.h" +#include cl_mem_tracker_t *gp_mem_tracker = NULL; +atomic32_t g_mem_trk_ref = 0; /* @@ -73,7 +75,10 @@ __cl_mem_track_start( void ) cl_status_t status; if( gp_mem_tracker ) + { + cl_atomic_inc( &g_mem_trk_ref ); return; + } /* Allocate the memory tracker object. */ gp_mem_tracker = (cl_mem_tracker_t*) @@ -95,6 +100,8 @@ __cl_mem_track_start( void ) return; } + cl_atomic_inc( &g_mem_trk_ref ); + cl_msg_out( "\n\n\n*** Memory tracker object address = %p ***\n\n\n", gp_mem_tracker ); } @@ -112,6 +119,9 @@ __cl_mem_track_stop( void ) if( !gp_mem_tracker ) return; + if( cl_atomic_dec( &g_mem_trk_ref ) ) + return; + if( cl_qmap_count( &gp_mem_tracker->alloc_map ) ) { /* There are still items in the list. Print them out. */ @@ -207,7 +217,7 @@ __cl_malloc_trk( cl_malloc_hdr_t *p_hdr; cl_list_item_t *p_list_item; void *p_mem; - char temp_buf[FILE_NAME_LENGTH]; + uint64_t temp_buf[FILE_NAME_LENGTH/sizeof(uint64_t)]; int32_t temp_line; /* @@ -227,9 +237,9 @@ __cl_malloc_trk( * parameters are in paged pool. */ temp_line = line_num; - strncpy( temp_buf, p_file_name, FILE_NAME_LENGTH ); + strncpy( (char*)temp_buf, p_file_name, FILE_NAME_LENGTH ); /* Make sure the string is null terminated. */ - temp_buf[FILE_NAME_LENGTH - 1] = '\0'; + ((char*)temp_buf)[FILE_NAME_LENGTH - 1] = '\0'; cl_spinlock_acquire( &gp_mem_tracker->lock ); diff --git a/trunk/core/complib/cl_obj.c b/trunk/core/complib/cl_obj.c index d07c8f91..74483421 100644 --- a/trunk/core/complib/cl_obj.c +++ b/trunk/core/complib/cl_obj.c @@ -43,6 +43,7 @@ /* The global object manager. */ cl_obj_mgr_t *gp_obj_mgr = NULL; +atomic32_t g_cl_obj_ref = 0; @@ -57,7 +58,10 @@ cl_obj_mgr_create() /* See if the object manager has already been created. */ if( gp_obj_mgr ) + { + cl_atomic_inc( &g_cl_obj_ref ); return CL_SUCCESS; + } /* Allocate the object manager. */ gp_obj_mgr = cl_zalloc( sizeof( cl_obj_mgr_t ) ); @@ -70,6 +74,8 @@ cl_obj_mgr_create() cl_async_proc_construct( &gp_obj_mgr->async_proc_mgr ); cl_qpool_construct( &gp_obj_mgr->rel_pool ); + cl_atomic_inc( &g_cl_obj_ref ); + /* Initialize the spinlock. */ status = cl_spinlock_init( &gp_obj_mgr->lock ); if( status != CL_SUCCESS ) @@ -110,6 +116,10 @@ cl_obj_mgr_destroy() if( !gp_obj_mgr ) return; + /* See if this is the last call. */ + if( cl_atomic_dec( &g_cl_obj_ref ) ) + return; + /* Verify that all object's have been destroyed. */ for( p_list_item = cl_qlist_head( &gp_obj_mgr->obj_list ); p_list_item != cl_qlist_end( &gp_obj_mgr->obj_list ); diff --git a/trunk/core/complib/kernel/SOURCES b/trunk/core/complib/kernel/SOURCES index b43f5685..e1f602c7 100644 --- a/trunk/core/complib/kernel/SOURCES +++ b/trunk/core/complib/kernel/SOURCES @@ -1,6 +1,6 @@ TARGETNAME=complib TARGETPATH=..\..\..\bin\kernel\obj$(BUILD_ALT_DIR) -TARGETTYPE=EXPORT_DRIVER +TARGETTYPE=DRIVER_LIBRARY DLLDEF=cl_exports.def diff --git a/trunk/core/complib/kernel/cl_driver.c b/trunk/core/complib/kernel/cl_driver.c index e29ab29e..2efa9876 100644 --- a/trunk/core/complib/kernel/cl_driver.c +++ b/trunk/core/complib/kernel/cl_driver.c @@ -33,43 +33,6 @@ #include "complib/comp_lib.h" -NTSTATUS -DriverEntry( - IN DRIVER_OBJECT *pDevObj, - IN UNICODE_STRING *RegistryPath ) -{ - UNUSED_PARAM( pDevObj ); - UNUSED_PARAM( RegistryPath ); - return STATUS_SUCCESS; -} - - -NTSTATUS -DllInitialize( - IN UNICODE_STRING *RegistryPath ) -{ - cl_status_t status; - UNUSED_PARAM( RegistryPath ); - - __cl_mem_track( TRUE ); - - status = cl_obj_mgr_create(); - - return cl_to_ntstatus( status ); -} - - -NTSTATUS -DllUnload(void) -{ - cl_obj_mgr_destroy(); - - __cl_mem_track( FALSE ); - - return STATUS_SUCCESS; -} - - CL_EXPORT NTSTATUS cl_to_ntstatus( IN cl_status_t status ) diff --git a/trunk/core/iou/kernel/SOURCES b/trunk/core/iou/kernel/SOURCES index d60580df..3796900b 100644 --- a/trunk/core/iou/kernel/SOURCES +++ b/trunk/core/iou/kernel/SOURCES @@ -9,7 +9,7 @@ SOURCES= ibiou.rc \ INCLUDES=..\..\..\inc;..\..\..\inc\kernel; -C_DEFINES=$(C_DEFINES) -DDRIVER -DDEPRECATE_DDK_FUNCTIONS +C_DEFINES=$(C_DEFINES) -DDRIVER -DDEPRECATE_DDK_FUNCTIONS -DNEED_CL_OBJ TARGETLIBS= \ $(TARGETPATH)\*\complib.lib diff --git a/trunk/core/iou/kernel/iou_driver.c b/trunk/core/iou/kernel/iou_driver.c index 5f880d84..a0627677 100644 --- a/trunk/core/iou/kernel/iou_driver.c +++ b/trunk/core/iou/kernel/iou_driver.c @@ -34,10 +34,10 @@ * Provides the driver entry points for the InfiniBand I/O Unit Bus Driver. */ -#include "complib/cl_types.h" +#include #include "iou_driver.h" #include "iou_pnp.h" -#include "complib/cl_memory.h" +#include iou_globals_t iou_globals = { @@ -188,6 +188,8 @@ iou_unload( UNUSED_PARAM( p_driver_obj ); + CL_DEINIT; + IOU_EXIT( IOU_DBG_DRV ); } @@ -201,6 +203,14 @@ DriverEntry( IOU_ENTER( IOU_DBG_DRV ); + status = CL_INIT; + if( !NT_SUCCESS(status) ) + { + IOU_TRACE_EXIT( IOU_DBG_ERROR, + ("cl_init returned %08X.\n", status) ); + return status; + } + /* Store the driver object pointer in the global parameters. */ iou_globals.p_driver_obj = p_driver_obj; @@ -208,6 +218,7 @@ DriverEntry( status = __read_registry( p_registry_path ); if( !NT_SUCCESS(status) ) { + CL_DEINIT; IOU_TRACE_EXIT( IOU_DBG_ERROR, ("__read_registry returned %08x.\n", status) ); return status; diff --git a/trunk/hw/mt23108/kernel/hca_driver.c b/trunk/hw/mt23108/kernel/hca_driver.c index 2b623e77..39fca4b8 100644 --- a/trunk/hw/mt23108/kernel/hca_driver.c +++ b/trunk/hw/mt23108/kernel/hca_driver.c @@ -42,6 +42,7 @@ #include "MdCard.h" #pragma warning( pop ) #include +#include /* @@ -267,9 +268,18 @@ DriverEntry( HCA_ENTER( HCA_DBG_DEV ); + status = CL_INIT; + if( !NT_SUCCESS(status) ) + { + HCA_TRACE_EXIT( HCA_DBG_ERROR, + ("cl_init returned %08X.\n", status) ); + return status; + } + status = __read_registry( p_registry_path ); if( !NT_SUCCESS( status ) ) { + CL_DEINIT; HCA_TRACE_EXIT( HCA_DBG_ERROR, ("__read_registry_path returned 0x%X.\n", status) ); return status; @@ -279,6 +289,7 @@ DriverEntry( cl_status = mlnx_hobs_init(); if( cl_status != CL_SUCCESS ) { + CL_DEINIT; HCA_TRACE_EXIT( HCA_DBG_ERROR, ("mlnx_hobs_init returned %s.\n", cl_status_text[cl_status]) ); return cl_to_ntstatus( cl_status ); @@ -353,6 +364,8 @@ hca_drv_unload( UNUSED_PARAM( p_driver_obj ); + CL_DEINIT; + HCA_EXIT( HCA_DBG_DEV ); } diff --git a/trunk/hw/mt23108/kernel/infinihost.inf b/trunk/hw/mt23108/kernel/infinihost.inf index 9435c9bd..377e1d96 100644 --- a/trunk/hw/mt23108/kernel/infinihost.inf +++ b/trunk/hw/mt23108/kernel/infinihost.inf @@ -7,7 +7,7 @@ Class=InfiniBandHca ClassGUID=%HcaClassGuid% Provider=%SST% CatalogFile=infiniserv.cat -DriverVer=05/10/2005,3.0.0031.0 +DriverVer=07/28/2005,3.0.0034.0 ; ================= Destination directory section ===================== @@ -45,7 +45,6 @@ HKLM,"System\CurrentControlSet\Control\CoDeviceInstallers", \ [SourceDisksFiles] IbInstaller.dll=1 -complib.sys=1 ibal.sys=1 mt23108.sys=1 thca.sys=1 @@ -54,7 +53,6 @@ mt23108ud.dll=1 [SourceDisksFiles.amd64] IbInstaller.dll=1 -complib.sys=1 ibal.sys=1 mt23108.sys=1 thca.sys=1 @@ -65,7 +63,6 @@ mt23108ud.dll=1 [SourceDisksFiles.ia64] IbInstaller.dll=1 -complib.sys=1 ibal.sys=1 mt23108.sys=1 thca.sys=1 @@ -131,7 +128,6 @@ AddService = mt23108,%SPSVCINST_ASSOCSERVICE%,MT23108.ServiceInstall AddService = ibal,%SPSVCINST_NULL%,Ibal.ServiceInstall [MT23108.CopyFiles] -complib.sys ibal.sys mt23108.sys thca.sys diff --git a/trunk/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/Md.c b/trunk/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/Md.c index ded1da1d..f28fb874 100644 --- a/trunk/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/Md.c +++ b/trunk/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/Md.c @@ -30,10 +30,13 @@ * $Id$ */ + #define _MD_C_ #include "MdGen.h" #include "thh_hob.h" +#include + #define CHECK_INIT(lbl) \ if (l_MddkStatus != MT_OK) \ @@ -255,6 +258,10 @@ Return Value: /* no context yet */ g_pDrvContext = NULL; + l_Status = CL_INIT; + if( !NT_SUCCESS(l_Status) ) + return l_Status; + /* create Control Device names */ if (!MdCreateDeviceNames(MD_CTL_DEVICE_NAME, &l_usNtDeviceName, &l_usDosDeviceName)) { /* failed - no resources */ @@ -410,6 +417,8 @@ err: MdKdPrint( DBGLVL_ALWAYS ,("(MdDeviceInit) Device failed to initialize \n")); #pragma warning( pop ) + CL_DEINIT; + /* Write to event log */ WriteEventLogEntry( pi_pDriverObject, MD_EVENT_LOG_LOAD_ERROR, 0, l_Status, 1, l_Status ); @@ -565,6 +574,9 @@ if (l_pDrvContext->m_fSupportTavor) /* free the driver context */ MdExFreePool( l_pDrvContext ); + + CL_DEINIT; + g_pDrvContext = NULL; MDASSERT( g_pDbgData->m_nExAllocCount == 0 ); diff --git a/trunk/inc/kernel/complib/cl_init.h b/trunk/inc/kernel/complib/cl_init.h new file mode 100644 index 00000000..206e6308 --- /dev/null +++ b/trunk/inc/kernel/complib/cl_init.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2005 SilverStorm Technologies. All rights reserved. + * + * This software is available to you under the OpenIB.org BSD license + * below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * $Id$ + */ + + +#ifndef _CL_INIT_H_ +#define _CL_INIT_H_ + + +#include +#include + + +#ifdef CL_TRACK_MEM +#ifdef NEED_CL_OBJ +#define CL_INIT (__cl_mem_track( TRUE ), cl_obj_mgr_create()) +#define CL_DEINIT (cl_obj_mgr_destroy(), __cl_mem_track( FALSE )) +#else /* NEED_CL_OBJ */ +#define CL_INIT (__cl_mem_track( TRUE ), STATUS_SUCCESS) +#define CL_DEINIT (__cl_mem_track( FALSE )) +#endif /* NEED_CL_OBJ */ +#else /* CL_TRACK_MEM */ +#ifdef NEED_CL_OBJ +#define CL_INIT cl_obj_mgr_create() +#define CL_DEINIT cl_obj_mgr_destroy() +#else /* NEED_CL_OBJ */ +#define CL_INIT STATUS_SUCCESS +#define CL_DEINIT +#endif /* NEED_CL_OBJ */ +#endif /* CL_TRACK_MEM */ + +#endif // _CL_INIT_H_ diff --git a/trunk/inc/kernel/complib/cl_types_osd.h b/trunk/inc/kernel/complib/cl_types_osd.h index b328272f..98499318 100644 --- a/trunk/inc/kernel/complib/cl_types_osd.h +++ b/trunk/inc/kernel/complib/cl_types_osd.h @@ -46,6 +46,9 @@ extern "C" #include #if defined( NDIS_MINIPORT_DRIVER ) #include +#if NDIS_WDM +#define CL_NTDDK +#endif /* NDIS_WDM */ #elif !defined( _MINIPORT_ ) #include #define CL_NTDDK @@ -93,11 +96,7 @@ typedef volatile __int32 atomic32_t; #define UNUSED_PARAM UNREFERENCED_PARAMETER -#if !defined(EXPORT_CL_SYMBOLS) -#define CL_EXPORT DECLSPEC_IMPORT -#else -#define CL_EXPORT __declspec(dllexport) -#endif +#define CL_EXPORT #if !defined( __cplusplus ) #define inline __inline @@ -119,15 +118,14 @@ typedef enum _cl_status cl_status_t; #define CL_CONST64( x ) x##ui64 -CL_INLINE NTSTATUS +NTSTATUS cl_to_ntstatus( IN enum _cl_status status ); -CL_INLINE enum _cl_status +enum _cl_status cl_from_ntstatus( IN NTSTATUS status ); - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/trunk/tests/alts/kernel/alts.inf b/trunk/tests/alts/kernel/alts.inf index 4898bb07..8c6b7818 100644 --- a/trunk/tests/alts/kernel/alts.inf +++ b/trunk/tests/alts/kernel/alts.inf @@ -26,7 +26,7 @@ Class=InfiniBandHca ClassGUID=%HcaClassGuid% Provider=%Vendor% CatalogFile=infiniserv.cat -DriverVer=05/10/2005,3.0.0031.0 +DriverVer=07/28/2005,3.0.0034.0 ; ================= Destination directory section ===================== diff --git a/trunk/tests/alts/kernel/alts_driver.c b/trunk/tests/alts/kernel/alts_driver.c index a537b772..43ff0882 100644 --- a/trunk/tests/alts/kernel/alts_driver.c +++ b/trunk/tests/alts/kernel/alts_driver.c @@ -30,7 +30,6 @@ */ - /* * Provides the driver entry points for the ALTS kernel driver. */ @@ -41,6 +40,7 @@ #include #include "alts_common.h" #include "alts_debug.h" +#include #if !defined(FILE_DEVICE_INFINIBAND) // Not defined in WXP DDK @@ -133,6 +133,7 @@ DriverEntry( IN PDRIVER_OBJECT p_driver_obj, IN PUNICODE_STRING p_registry_path ) { + NTSTATUS status; #ifdef _DEBUG_ static boolean_t exit = FALSE; #endif @@ -150,6 +151,14 @@ DriverEntry( } #endif + status = CL_INIT; + if( !NT_SUCCESS(status) ) + { + ALTS_TRACE_EXIT( ALTS_DBG_ERROR, + ("cl_init returned %08X.\n", status) ); + return status; + } + p_driver_obj->MajorFunction[IRP_MJ_PNP] = cl_pnp; p_driver_obj->MajorFunction[IRP_MJ_POWER] = cl_power; // p_driver_obj->MajorFunction[IRP_MJ_DEVICE_CONTROL] = alts_ioctl; @@ -170,6 +179,8 @@ alts_drv_unload( UNUSED_PARAM( p_driver_obj ); + CL_DEINIT; + ALTS_EXIT( ALTS_DBG_DEV ); } diff --git a/trunk/ulp/ipoib/kernel/SOURCES b/trunk/ulp/ipoib/kernel/SOURCES index 7ab9d34c..a7f370da 100644 --- a/trunk/ulp/ipoib/kernel/SOURCES +++ b/trunk/ulp/ipoib/kernel/SOURCES @@ -11,7 +11,7 @@ SOURCES= ipoib.rc \ INCLUDES=..;..\..\..\inc;..\..\..\inc\kernel; C_DEFINES=$(C_DEFINES) -DNDIS_MINIPORT_DRIVER -DNDIS_WDM=1 \ - -DDEPRECATE_DDK_FUNCTIONS -DNDIS51_MINIPORT + -DDEPRECATE_DDK_FUNCTIONS -DNDIS51_MINIPORT -DNEED_CL_OBJ -DBINARY_COMPATIBLE=0 TARGETLIBS= \ $(TARGETPATH)\*\complib.lib \ diff --git a/trunk/ulp/ipoib/kernel/ipoib_adapter.c b/trunk/ulp/ipoib/kernel/ipoib_adapter.c index 276c8e02..d3180654 100644 --- a/trunk/ulp/ipoib/kernel/ipoib_adapter.c +++ b/trunk/ulp/ipoib/kernel/ipoib_adapter.c @@ -35,6 +35,7 @@ #include "ipoib_port.h" #include "ipoib_driver.h" #include "ipoib_debug.h" +#include #define ITEM_POOL_START 16 @@ -129,9 +130,17 @@ ipoib_create_adapter( IPOIB_ENTER( IPOIB_DBG_INIT ); + if( !NT_SUCCESS( CL_INIT ) ) + { + IPOIB_TRACE_EXIT( IPOIB_DBG_ERROR, + ("cl_init failed.\n") ); + return IB_ERROR; + } + p_adapter = cl_zalloc( sizeof(ipoib_adapter_t) ); if( !p_adapter ) { + CL_DEINIT; IPOIB_TRACE_EXIT( IPOIB_DBG_ERROR, ("Failed to allocate ipoib_adapter_t (%d bytes)", sizeof(ipoib_adapter_t)) ); @@ -455,6 +464,8 @@ __adapter_free( cl_free( p_adapter ); + CL_DEINIT; + IPOIB_EXIT( IPOIB_DBG_INIT ); } diff --git a/trunk/ulp/srp/kernel/SOURCES b/trunk/ulp/srp/kernel/SOURCES index 6fc39897..42e7e5fc 100644 --- a/trunk/ulp/srp/kernel/SOURCES +++ b/trunk/ulp/srp/kernel/SOURCES @@ -16,9 +16,10 @@ INCLUDES=..\..\..\inc;..\..\..\inc\kernel; !if defined(DDK_TARGET_OS) && "$(DDK_TARGET_OS)"=="WinXP" # storport.h in WinXP DDK already have "..._ALIASES" definition -C_DEFINES=$(C_DEFINES) -DDEPRECATE_DDK_FUNCTIONS -DWinXP +C_DEFINES=$(C_DEFINES) -DDEPRECATE_DDK_FUNCTIONS -DWinXP -DNEED_CL_OBJ !else -C_DEFINES=$(C_DEFINES) -DDEPRECATE_DDK_FUNCTIONS -DSTOR_USE_SCSI_ALIASES +C_DEFINES=$(C_DEFINES) -DDEPRECATE_DDK_FUNCTIONS -DSTOR_USE_SCSI_ALIASES \ + -DNEED_CL_OBJ !endif TARGETLIBS= \ diff --git a/trunk/ulp/srp/kernel/srp_driver.c b/trunk/ulp/srp/kernel/srp_driver.c index 448da385..71b7b4bd 100644 --- a/trunk/ulp/srp/kernel/srp_driver.c +++ b/trunk/ulp/srp/kernel/srp_driver.c @@ -30,8 +30,6 @@ */ - - #include "srp_data.h" #include "srp_data_path.h" #include "srp_debug.h" @@ -41,6 +39,7 @@ #include #include +#include #define SCSI_MAXIMUM_TRANSFER_SIZE (1024 * 1024) @@ -204,12 +203,20 @@ DriverEntry( IN DRIVER_OBJECT *p_drv_obj, IN UNICODE_STRING *p_registry_path ) { - ULONG status = (ULONG)STATUS_INSUFFICIENT_RESOURCES; + ULONG status; HW_INITIALIZATION_DATA hw_data; cl_status_t cl_status; SRP_ENTER( SRP_DBG_PNP ); + status = CL_INIT; + if( !NT_SUCCESS(status) ) + { + SRP_TRACE_EXIT( SRP_DBG_ERROR, + ("cl_init returned %08X.\n", status) ); + return status; + } + gp_drv_obj = p_drv_obj; cl_obj_construct( &g_drv_obj, SRP_OBJ_TYPE_DRV ); @@ -271,10 +278,16 @@ DriverEntry( } else { + CL_DEINIT; SRP_TRACE( SRP_DBG_ERROR, ("StorPortInitialize returned 0x%x.\n", status) ); } } + else + { + CL_DEINIT; + status = (ULONG)STATUS_INSUFFICIENT_RESOURCES; + } SRP_TRACE_EXIT( SRP_DBG_PNP, ("DriverEntry returning status of 0x%x.\n", status) ); return status; @@ -291,6 +304,8 @@ srp_unload( SRP_TRACE( SRP_DBG_VERBOSE, ("Driver Object ref_cnt = %d\n", g_drv_obj.ref_cnt) ); cl_obj_destroy( &g_drv_obj ); + CL_DEINIT; + /* Invoke the port driver's unload routine. */ SRP_TRACE( SRP_DBG_DEBUG, ("Invoking the port driver's unload routine.\n") ); gpfn_unload( p_drv_obj ); -- 2.41.0