2 * Copyright (c) 2005 SilverStorm Technologies. All rights reserved.
\r
4 * This software is available to you under the OpenIB.org BSD license
\r
7 * Redistribution and use in source and binary forms, with or
\r
8 * without modification, are permitted provided that the following
\r
9 * conditions are met:
\r
11 * - Redistributions of source code must retain the above
\r
12 * copyright notice, this list of conditions and the following
\r
15 * - Redistributions in binary form must reproduce the above
\r
16 * copyright notice, this list of conditions and the following
\r
17 * disclaimer in the documentation and/or other materials
\r
18 * provided with the distribution.
\r
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
24 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
25 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
34 * Provides the driver entry points for the InfiniBand I/O Unit Bus Driver.
\r
37 #include <complib/cl_types.h>
\r
38 #include "iou_driver.h"
\r
39 #include "iou_pnp.h"
\r
40 #include <complib/cl_init.h>
\r
43 iou_globals_t iou_globals = {
\r
51 IN UNICODE_STRING* const p_Param_Path );
\r
55 IN DEVICE_OBJECT *p_dev_obj,
\r
60 IN DEVICE_OBJECT *p_dev_obj,
\r
65 IN DEVICE_OBJECT *p_dev_obj,
\r
68 /***f* InfiniBand Bus Driver/iou_sysctl
\r
73 * Entry point for handling WMI IRPs.
\r
79 IN DEVICE_OBJECT *p_dev_obj,
\r
85 IN DRIVER_OBJECT *p_driver_obj );
\r
89 IN DRIVER_OBJECT *p_driver_obj,
\r
90 IN UNICODE_STRING *p_registry_path );
\r
93 #pragma alloc_text (INIT, DriverEntry)
\r
94 #pragma alloc_text (INIT, __read_registry)
\r
95 #pragma alloc_text (PAGE, iou_unload)
\r
96 #pragma alloc_text (PAGE, iou_drv_open)
\r
97 #pragma alloc_text (PAGE, iou_drv_close)
\r
98 #pragma alloc_text (PAGE, iou_drv_ioctl)
\r
99 #pragma alloc_text (PAGE_PNP, iou_sysctl)
\r
105 IN UNICODE_STRING* const p_registry_path )
\r
108 /* Remember the terminating entry in the table below. */
\r
109 RTL_QUERY_REGISTRY_TABLE table[2];
\r
110 UNICODE_STRING param_path;
\r
112 IOU_ENTER( IOU_DBG_DRV );
\r
114 RtlInitUnicodeString( ¶m_path, NULL );
\r
115 param_path.MaximumLength = p_registry_path->Length +
\r
116 sizeof(L"\\Parameters");
\r
117 param_path.Buffer = cl_zalloc( param_path.MaximumLength );
\r
118 if( !param_path.Buffer )
\r
120 IOU_TRACE_EXIT( IOU_DBG_ERROR,
\r
121 ("Failed to allocate parameters path buffer.\n") );
\r
122 return STATUS_INSUFFICIENT_RESOURCES;
\r
125 RtlAppendUnicodeStringToString( ¶m_path, p_registry_path );
\r
126 RtlAppendUnicodeToString( ¶m_path, L"\\Parameters" );
\r
129 * Clear the table. This clears all the query callback pointers,
\r
130 * and sets up the terminating table entry.
\r
132 cl_memclr( table, sizeof(table) );
\r
134 /* Setup the table entries. */
\r
135 table[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
\r
136 table[0].Name = L"DebugFlags";
\r
137 table[0].EntryContext = &iou_globals.dbg_lvl;
\r
138 table[0].DefaultType = REG_DWORD;
\r
139 table[0].DefaultData = &iou_globals.dbg_lvl;
\r
140 table[0].DefaultLength = sizeof(ULONG);
\r
143 status = RtlQueryRegistryValues( RTL_REGISTRY_ABSOLUTE,
\r
144 param_path.Buffer, table, NULL, NULL );
\r
146 cl_free( param_path.Buffer );
\r
147 IOU_EXIT( IOU_DBG_DRV );
\r
154 IN DEVICE_OBJECT *p_dev_obj,
\r
158 cl_pnp_po_ext_t *p_ext;
\r
160 IOU_ENTER( IOU_DBG_DRV );
\r
162 CL_ASSERT( p_dev_obj );
\r
163 CL_ASSERT( p_irp );
\r
165 p_ext = p_dev_obj->DeviceExtension;
\r
167 if( p_ext->p_next_do )
\r
169 IoSkipCurrentIrpStackLocation( p_irp );
\r
170 status = IoCallDriver( p_ext->p_next_do, p_irp );
\r
174 status = p_irp->IoStatus.Status;
\r
175 IoCompleteRequest( p_irp, IO_NO_INCREMENT );
\r
178 IOU_EXIT( IOU_DBG_DRV );
\r
185 IN DRIVER_OBJECT *p_driver_obj )
\r
187 IOU_ENTER( IOU_DBG_DRV );
\r
189 UNUSED_PARAM( p_driver_obj );
\r
193 IOU_EXIT( IOU_DBG_DRV );
\r
199 IN DRIVER_OBJECT *p_driver_obj,
\r
200 IN UNICODE_STRING *p_registry_path )
\r
204 IOU_ENTER( IOU_DBG_DRV );
\r
207 if( !NT_SUCCESS(status) )
\r
209 IOU_TRACE_EXIT( IOU_DBG_ERROR,
\r
210 ("cl_init returned %08X.\n", status) );
\r
214 /* Store the driver object pointer in the global parameters. */
\r
215 iou_globals.p_driver_obj = p_driver_obj;
\r
217 /* Get the registry values. */
\r
218 status = __read_registry( p_registry_path );
\r
219 if( !NT_SUCCESS(status) )
\r
222 IOU_TRACE_EXIT( IOU_DBG_ERROR,
\r
223 ("__read_registry returned %08x.\n", status) );
\r
227 /* Setup the entry points. */
\r
228 p_driver_obj->MajorFunction[IRP_MJ_PNP] = cl_pnp;
\r
229 p_driver_obj->MajorFunction[IRP_MJ_POWER] = cl_power;
\r
230 p_driver_obj->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = iou_sysctl;
\r
231 p_driver_obj->DriverUnload = iou_unload;
\r
232 p_driver_obj->DriverExtension->AddDevice = iou_add_device;
\r
234 IOU_EXIT( IOU_DBG_DRV );
\r
235 return STATUS_SUCCESS;
\r