summaryrefslogtreecommitdiffstats
path: root/private/ntos/miniport/compaq/cpqsmngr.h
blob: 7fa592cc6859e0aca3343d9a59a94f51fdbfe748 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
/*++


Copyright (c) 1993  Microsoft Corporation
Copyright (c) 1993  Compaq Computer Corporation

Module Name:

    cpqsmngr.h

Abstract:

    This file contains the data structures required to support Compaq's
    Management and Performance.

Author:

    Tombo  - Compaq Computer Corporation

Notes:

Revision History:

--*/

#ifndef CPQSMNGR
#define CPQSMNGR

#define IDA_DRIVER_NAME     "Compaq Windows NT DriveArray"
#define IDA_MAJOR_VERSION   2
#define IDA_MINOR_VERSION   00

//
//  The following defines identify the appropriate IDA controller types.
//

#define IDA_EISA_ID_TYPEMASK    0x00ffffff  // Masks off the controller type
#define IDA_EISA_ID_ARRAY       0x0040110e  // 0x0e114000 Common for all IDAs

#define IDA_EISA_ID_DISCO       0x0140110e  // 0x0e114001
#define IDA_EISA_ID_CANCUN      0x0240110e  // 0x0e114002
#define IDA_EISA_ID_STANZA      0x1040110e  // 0x0e114010
#define IDA_EISA_ID_WARRIOR     0x2040110e  // 0x0e114020
#define IDA_EISA_ID_DAZZLER     0x3040110e  // 0x0e114030

//
//  This macro checks the Irp for a device control function.
//
//  The parameters for this macro are...
//
//      IN PIRP Irp       // Pointer to the IO request packet.
//
#define MAPISPASSTHROUGH( Irp )                             \
    ((IoGetCurrentIrpStackLocation(Irp)->MajorFunction  \
		==                                          \
	IRP_MJ_DEVICE_CONTROL   ) &&                    \
    (IoGetCurrentIrpStackLocation(Irp)->\
		Parameters.DeviceIoControl.IoControlCode  \
		==                                          \
	MAP_IOCTL_PASSTHROUGH   ))
#ifndef NSCSIPASS
#define MAPISSCSIPASSTHROUGH( Irp )                             \
    ((IoGetCurrentIrpStackLocation(Irp)->MajorFunction  \
		==                                          \
	IRP_MJ_DEVICE_CONTROL   ) &&                    \
    (IoGetCurrentIrpStackLocation(Irp)->\
		Parameters.DeviceIoControl.IoControlCode  \
		==                                          \
	MAP_IOCTL_SCSIPASSTHROUGH   ))
#endif

//
//  The following macro frees up any allocated resources beginning at
//  the specified controller device.
//
#define MAP_FREE_RESOURCES( ControllerDevice ){                              \
    PMAP_CONTROLLER_DEVICE Controller;                                       \
    PMAP_CONTROLLER_DEVICE tmpController;                                    \
    PMAP_DISK_DEVICE Disk;                                                   \
    PMAP_DISK_DEVICE tmpDisk;                                                \
									     \
    for( Controller=ControllerDevice; Controller; Controller=tmpController ){\
	for( Disk=Controller->DiskDeviceList; Disk; Disk=tmpDisk ){          \
	    tmpDisk = Disk->Next;                                            \
	    ExFreePool( Disk );                                              \
	}                                                                    \
	tmpController = Controller->Next;                                    \
	ExFreePool( Controller );                                            \
    }                                                                        \
}

//
//  The following macro obtains a pointer to the last CONTROLLER_DEVICE
//  in the chain of MAP controller devices.
//
#define MAP_GET_LAST_CONTROLLER( cd ){                      \
    PMAP_CONTROLLER_DEVICE c;                               \
    if( FirstController ){                                  \
	for( c = FirstController;                           \
	     c->Next;                                       \
	     c = c->Next );                                 \
	*((PMAP_CONTROLLER_DEVICE*)(cd)) = c;               \
    }else{                                                  \
	*((PMAP_CONTROLLER_DEVICE*)(cd)) = FirstController; \
    }                                                       \
}

//
//  The following macro obtains a pointer to the last DISK_DEVICE
//  in the chain of MAP disk devices on the last controller.
//
#define MAP_GET_LAST_DISK( dd, cd ){                                        \
    PMAP_DISK_DEVICE d;                                                     \
    *((PMAP_DISK_DEVICE*)(dd)) = (PMAP_DISK_DEVICE)0;                       \
    MAP_GET_LAST_CONTROLLER( (cd) );                                        \
    if( *((PMAP_CONTROLLER_DEVICE*)(cd)) ){                                 \
	if((*((PMAP_CONTROLLER_DEVICE*)(cd)))->DiskDeviceList){             \
	    for( d = (*((PMAP_CONTROLLER_DEVICE*)(cd)))->DiskDeviceList;    \
		 d->Next;                                                   \
		 d = d->Next );                                             \
	    *((PMAP_DISK_DEVICE*)(dd)) = d;                                 \
	}                                                                   \
    }                                                                       \
}

#pragma pack( 1 )   // All structures need to be byte packed.

//
//  The following data structure represents the MAP header buffer filled
//  in by the MAP_COMMAND_IDDRIVER command.
//
//  The Entries include...
//
//      DriverName - Pointer to an Array of NUL terminated ASCII
//          characters representing the IDA driver name.
//
//      ControllerCount - The number of IDA controllers in the system.
//
//      LogicalDiskCount - The aggregate number of IDA logical disks found
//          in the system.
//
//      RequiredMemory - The memory size required for the data buffer
//          used in the IDA_MAP_COMMAND_IDCONTROLLERS command.
//
//      DriverMajorVersion - The version number to the right hand side
//          of the decimal point.
//
//      DriverMinorVersion - The version number to the left hand side
//          of the decimal point.
//

typedef struct _MAP_HEADER{

    UCHAR DriverName[32];
    ULONG ControllerCount;
    ULONG LogicalDiskCount;
    ULONG RequiredMemory;
    UCHAR DriverMajorVersion;
    UCHAR DriverMinorVersion;

}MAP_HEADER, *PMAP_HEADER;

//
//  The following data structure represents the MAP header buffer filled
//  in by the MAP_COMMAND_IDCONTROLLERS command.
//
//  The Entries include...
//
//      NextController - Pointer to the next controller in the chain.
//          A value of NULL indicates no more controllers follow.
//
//      LogicalDriveList - Pointer to the list of IDA logical drive
//          information for ALL of the IDA logical drives that exist
//          on this controller.
//
//      EisaId - The Eisa ID number read as a 32 bit value from EISA IO
//          space zC80h - zC83h.  The valid values include...
//
//              IDA_EISA_ID_DISCO       0x0140110e  // 0e 11 40 01
//              IDA_EISA_ID_CANCUN      0x0240110e  // 0e 11 40 02
//              IDA_EISA_ID_STANZA      0x1040110e  // 0e 11 40 10
//              IDA_EISA_ID_WARRIOR     0x2040110e  // 0e 11 40 20
//
//      BmicIoAddress - The IO address where this controller resides in
//          EISA IO space.  The value will be some derivative of zC80h
//          where 'z' is the physical EISA slot the controller resides
//          in.
//
//      IrqLevel - The controller's EISA bus interrupt level.
//
//      ControllerInfo - The controller's information as received by the
//          "IdentifyController" IDA logical command.
//          The size of this data structure will be the largest size
//          required to accomodate ALL flavors of Compaq supported IDA
//          controllers.
//

typedef struct _MAP_CONTROLLER_DATA{

    struct _MAP_CONTROLLER_DATA *NextController;
    struct _MAP_LOGICALDRIVE_DATA *LogicalDriveList;
    ULONG EisaId;
    ULONG BmicIoAddress;
    UCHAR IrqLevel;
    IDENTIFY_CONTROLLER ControllerInfo; //"IdentifyController"

}MAP_CONTROLLER_DATA, *PMAP_CONTROLLER_DATA;

//
//  The following data structure represents the MAP header buffer filled
//  in by the MAP_COMMAND_IDCONTROLLERS command.  This is a fragment
//  data structure that defines the IDA logical drive information for each
//  IDA controller.
//
//  The Entries include...
//
//      NextLogicalDrive - Pointer to the next IDA logical drive on this
//          controller.  A value of NULL indicates that there are no more
//          IDA logical drives on this controller.
//
//      Controller - Pointer to the Controller data structure that this
//          IDA logical drive resides on.
//
//      LogicalDriveNumber - The IDA logical drive number assigned by this
//          controller.
//
//      SystemDriveNumber - The NT drive number assigned to this IDA logical
//          drive by the IDA device driver.  It is the number that represents
//          "\Device\HarddiskN" where "N" is the SystemDriveNumber.
//
//      DeviceLengthLo - The Low 32 bits of the IDA logical device's RAW
//          partition length.
//
//      DeviceLengthHi - The High 32 bits of the IDA logical drive's RAW
//          partition length.
//
//      SectorSize - The sector size in bytes for this IDA logical device.
//
//      Configuration - The logical drive's configuration information as
//          received by the "SenseConfiguration" IDA logical command.
//          The size of this data structure will be the largest size
//          required to accomodate ALL flavors of Compaq supported IDA
//          controllers.
//
//      LogicalDriveInfo - The IDA logical drive information buffer as
//          received by the "IdentifyLogicalDrive" IDA logical command.
//          The size of this data structure will be the largest size
//          required to accomodate ALL flavors of Compaq supported IDA
//          controllers.
//

typedef struct _MAP_LOGICALDRIVE_DATA{

    struct _MAP_LOGICALDRIVE_DATA *NextLogicalDrive;
    struct _MAP_CONTROLLER_DATA *Controller;
    ULONG LogicalDriveNumber;
    ULONG SystemDriveNumber;
    ULONG DeviceLengthLo;
    ULONG DeviceLengthHi;
    ULONG SectorSize;
    SENSE_CONFIGURATION Configuration;          //"SenseConfiguration"
    IDENTIFY_LOGICAL_DRIVE LogicalDriveInfo;    //"IdentifyLogicalDrive"

}MAP_LOGICALDRIVE_DATA, *PMAP_LOGICALDRIVE_DATA;

//
//  The following data structure represents the parameter packet buffer
//  specified in all of the M&P device controls to the IDA device driver.
//
//  The Entries include...
//
//      Reserved
//
//      IdaLogicalCommand - The IDA logical command to passthrough to the
//          IDA controller.  This field is read by the IDA device driver.
//
//      BlockNumber - The starting block number on the IDA logical drive.
//
//      BlockSize - The size in bytes of the passthrough data transfer.
//
//      BlockCount - The number of blocks to transfer.  A block is equal
//          to a sector worth of data.
//

typedef struct _MAP_PARAMETER_PACKET{

    UCHAR TargetId;
    IN UCHAR IdaLogicalCommand;
    IN ULONG BlockNumber;
    IN ULONG BlockSize;
    IN USHORT BlockCount;

}MAP_PARAMETER_PACKET, *PMAP_PARAMETER_PACKET;


//
//  The following data structure represents the data packet buffer
//  specified in all of the M&P device controls to the IDA device driver.
//
//  The Entries include...
//
//      ControllerError - The error bits returned by the IDA controller.
//
//      ControllerData - The requested data returned by the controller.
//

typedef struct _MAP_DATA_PACKET{

    OUT ULONG ControllerError;
    OUT UCHAR ControllerData[];

}MAP_DATA_PACKET, *PMAP_DATA_PACKET;

//
//  The following data structures are used to abstract Microsoft's use
//  of controller and device data structures to fit COMPAQ's M&P data
//  structure format.  This permits Microsoft's data structures to remain
//  unaltered so that my buddy, Mr. Disk himself, Mike Glass (AKA Gumby)
//  can still support general Array functionalilty without having to
//  figure out what the hell I did!
//

typedef struct _MAP_CONTROLLER_DEVICE{

    //  Pointer to the next controller device structure.
    struct _MAP_CONTROLLER_DEVICE* Next;

    //  Pointer to the Microsoft defined device extension for this controller.
    PDEVICE_EXTENSION ControllerExtension;

    //  EISA ID for this controller device.
    ULONG EisaID;

    //  Pointer to a list of MAP logical device data structures.
    struct _MAP_DISK_DEVICE* DiskDeviceList;

    //  Array controller configuration information data area.
    IDENTIFY_CONTROLLER ControllerInformation;

}MAP_CONTROLLER_DEVICE, *PMAP_CONTROLLER_DEVICE;


typedef struct _MAP_DISK_DEVICE{

    //  Pointer to the next disk device data structure.
    struct _MAP_DISK_DEVICE* Next;

    //  Pointer to Microsoft's defined disk device extension.
    PDEVICE_EXTENSION DeviceExtension;

    //  Disk device configuration information data area.
    SENSE_CONFIGURATION DeviceConfiguration;

    //  Disk device information data area.
    IDENTIFY_LOGICAL_DRIVE DeviceInformation;

    //  The logical drive number for this disk device on this controller.
    ULONG LogicalDriveNumber;

    //  The NT system drive number assigned by NT.
    ULONG SystemDriveNumber;

    //  Pointer to the controller device data area for the controller this
    //  logical disk device resides on.
    PMAP_CONTROLLER_DEVICE ControllerDevice;

}MAP_DISK_DEVICE, *PMAP_DISK_DEVICE;
#ifndef NSCSIPASS
typedef struct {
	CHAR CmdError;
	CHAR device_status;
	CHAR machine_error;
	CHAR reserved;
	UCHAR data[512];
} SCSI_BUFFER,*PSCSI_BUFFER;

typedef struct _SCSI_PASSTHRU_HEADER {
    UCHAR scsi_target_id;
    UCHAR path_id;
    UCHAR logical_unit;
    ULONG time_out_value;
    ULONG flags;
    UCHAR device_status;
    UCHAR machine_error;
    UCHAR cdb_length;
    UCHAR reserved[16];

} SCSI_PASSTHRU_HEADER, *PSCSI_PASSTHRU_HEADER;

#define MAX_CDB_LENGTH 24
typedef struct _SCSI_PASSTHRU_CDB {
    UCHAR cdb[MAX_CDB_LENGTH];
} SCSI_PASSTHRU_CDB, *PSCSI_PASSTHRU_CDB;

typedef struct _SCSI_PASSTHRU {
    SCSI_PASSTHRU_HEADER scsi_header;
    SCSI_PASSTHRU_CDB scsi_cdb;
} SCSI_PASSTHRU, *PSCSI_PASSTHRU;
#endif
#define CPQ_SCSI_ERR_OK             0
#define CPQ_SCSI_ERR_FAILED         1
#define CPQ_SCSI_ERR_BAD_CNTL_CODE  2
#define CPQ_SCSI_ERR_REVISION       3
#define CPQ_SCSI_ERR_NONCONTIGUOUS  4


//Arbitrary return values not associated to the same routines.

#define CPQ_CIM_ISSUED 1
#define CPQ_CIM_COMPLETED 2
#define CPQ_CIM_CMDBUILT 3
#define CPQ_CIM_NONCONTIGUOUS 4
#define CPQ_CIM_ERROR 5

//
// Define header for I/O control SRB.
//

#ifdef NDAZ
typedef struct _SRB_IO_CONTROL {
	ULONG HeaderLength;
	UCHAR Signature[8];
	ULONG Timeout;
	ULONG ControlCode;
	ULONG ReturnCode;
	ULONG Length;
} SRB_IO_CONTROL, *PSRB_IO_CONTROL;
#endif


typedef struct _IDA_ERROR_BITS {
	ULONG ControllerError;
} IDA_ERROR_BITS, *PIDA_ERROR_BITS;

typedef struct _SCSI_BUFFER_HEADER {
	UCHAR CmdError;
	UCHAR device_status;
	UCHAR machine_error;
	UCHAR reserved;
} SCSI_BUFFER_HEADER, *PSCSI_BUFFER_HEADER;

typedef struct _IDA_SCSI_PASSTHRU {
	SCSI_PASSTHRU scsipass;
	SCSI_BUFFER scsibuffer;
}IDA_SCSI_PASSTHRU, *PIDA_SCSI_PASSTHRU;

typedef struct _CPQ_IDA_PASSTHRU {
	SRB_IO_CONTROL Header;
	MAP_PARAMETER_PACKET PassThru;
	UCHAR ReturnData[1];
}CPQ_IDA_PASSTHRU, *PCPQ_IDA_PASSTHRU;

typedef struct _CPQ_IDA_SCSI_PASSTHRU {
	SRB_IO_CONTROL Header;
	IDA_SCSI_PASSTHRU ScsiPassThru;
}CPQ_IDA_SCSI_PASSTHRU, *PCPQ_IDA_SCSI_PASSTHRU;

typedef struct _CPQ_IDA_IDENTIFY {
	SRB_IO_CONTROL Header;
	UCHAR ReturnData[1];
}CPQ_IDA_IDENTIFY, *PCPQ_IDA_IDENTIFY;

typedef struct _IDA_CONFIGURATION {
   ULONG       ulBaseIOAddress;
   ULONG       ulBaseMemoryAddress;
   ULONG       ulControllerID;
   BYTE        bIoBusType;
   IO_BUS_DATA IoBusData;
} IDA_CONFIGURATION, *PIDA_CONFIGURATION;

typedef struct _IDA_CONFIGURATION_BUFFER {
   SRB_IO_CONTROL IoctlHeader;
   IDA_CONFIGURATION IDAConfiguration;
} IDA_CONFIGURATION_BUFFER, *PIDA_CONFIGURATION_BUFFER;

#define CPQ_IOCTL_IDENTIFY_DRIVER       1
#define CPQ_IOCTL_IDENTIFY_CONTROLLERS 2
#define CPQ_IOCTL_PASSTHROUGH           3
#define CPQ_IOCTL_SCSIPASSTHROUGH       4
#define CPQ_IOCTL_CONFIGURATION_INFO    5

#define IDA_SIGNATURE "IDAM&P"


#pragma pack(   )

//
//  The following defines specify the possible Ioctl commands that
//  can be passed to the IDA device driver from the M&P agent.
//

#define MAP_IOCTL_IDENTIFY_DRIVER   \
    CTL_CODE(FILE_DEVICE_DISK,2048,METHOD_BUFFERED,FILE_ANY_ACCESS)

#define MAP_IOCTL_IDENTIFY_CONTROLLERS  \
    CTL_CODE(FILE_DEVICE_DISK,2049,METHOD_BUFFERED,FILE_ANY_ACCESS)

#define MAP_IOCTL_PASSTHROUGH   \
    CTL_CODE(FILE_DEVICE_DISK,2050,METHOD_OUT_DIRECT,FILE_ANY_ACCESS)

#define MAP_IOCTL_SCSIPASSTHROUGH   \
    CTL_CODE(FILE_DEVICE_DISK,2051,METHOD_OUT_DIRECT,FILE_ANY_ACCESS)

#define MAP_IOCTL_CONFIGURATION_INFO   \
    CTL_CODE(FILE_DEVICE_DISK,2052,METHOD_OUT_DIRECT,FILE_ANY_ACCESS)

#endif  //CPQSMNGR