-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathddk.h
424 lines (354 loc) · 19.4 KB
/
ddk.h
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
#pragma once
// some defines from Windows 2000 DDK
#define IOCTL_KEYBOARD_SET_INDICATORS CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0002, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_KEYBOARD_QUERY_TYPEMATIC CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_KEYBOARD_QUERY_INDICATORS CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
typedef struct _KEYBOARD_INDICATOR_PARAMETERS {
USHORT UnitId; // Unit identifier.
USHORT LedFlags; // LED indicator state.
} KEYBOARD_INDICATOR_PARAMETERS, *PKEYBOARD_INDICATOR_PARAMETERS;
#define KEYBOARD_CAPS_LOCK_ON 4
#define KEYBOARD_NUM_LOCK_ON 2
#define KEYBOARD_SCROLL_LOCK_ON 1
#define FILE_DEVICE_CONTROLLER 0x00000004
#define IOCTL_SCSI_BASE FILE_DEVICE_CONTROLLER
#define IOCTL_SCSI_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define SCSI_IOCTL_DATA_OUT 0
#define SCSI_IOCTL_DATA_IN 1
#define SCSI_IOCTL_DATA_UNSPECIFIED 2
typedef struct _SCSI_PASS_THROUGH_DIRECT {
USHORT Length;
UCHAR ScsiStatus;
UCHAR PathId;
UCHAR TargetId;
UCHAR Lun;
UCHAR CdbLength;
UCHAR SenseInfoLength;
UCHAR DataIn;
ULONG DataTransferLength;
ULONG TimeOutValue;
PVOID DataBuffer;
ULONG SenseInfoOffset;
UCHAR Cdb[16];
} SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
#pragma pack(push, cdb, 1)
typedef union _CDB
{
//
// Standard 6-byte CDB
//
struct _CDB6READWRITE {
UCHAR OperationCode;
UCHAR LogicalBlockMsb1 : 5;
UCHAR LogicalUnitNumber : 3;
UCHAR LogicalBlockMsb0;
UCHAR LogicalBlockLsb;
UCHAR TransferBlocks;
UCHAR Control;
} CDB6READWRITE, *PCDB6READWRITE;
//
// SCSI Inquiry CDB
//
struct _CDB6INQUIRY {
UCHAR OperationCode;
UCHAR Reserved1 : 5;
UCHAR LogicalUnitNumber : 3;
UCHAR PageCode;
UCHAR IReserved;
UCHAR AllocationLength;
UCHAR Control;
} CDB6INQUIRY, *PCDB6INQUIRY;
//
// Mode sense
//
struct _MODE_SENSE10 {
UCHAR OperationCode;
UCHAR Reserved1 : 3;
UCHAR Dbd : 1;
UCHAR Reserved2 : 1;
UCHAR LogicalUnitNumber : 3;
UCHAR PageCode : 6;
UCHAR Pc : 2;
UCHAR Reserved3[4];
UCHAR AllocationLength[2];
UCHAR Control;
} MODE_SENSE10, *PMODE_SENSE10;
//
// Mode select
//
struct _MODE_SELECT10 {
UCHAR OperationCode;
UCHAR SPBit : 1;
UCHAR Reserved1 : 3;
UCHAR PFBit : 1;
UCHAR LogicalUnitNumber : 3;
UCHAR Reserved2[5];
UCHAR ParameterListLength[2];
UCHAR Control;
} MODE_SELECT10, *PMODE_SELECT10;
//
// Standard 10-byte CDB
struct _CDB10 {
UCHAR OperationCode;
UCHAR RelativeAddress : 1;
UCHAR Reserved1 : 2;
UCHAR ForceUnitAccess : 1;
UCHAR DisablePageOut : 1;
UCHAR LogicalUnitNumber : 3;
UCHAR LogicalBlockByte0;
UCHAR LogicalBlockByte1;
UCHAR LogicalBlockByte2;
UCHAR LogicalBlockByte3;
UCHAR Reserved2;
UCHAR TransferBlocksMsb;
UCHAR TransferBlocksLsb;
UCHAR Control;
} CDB10;
//
// Standard 12-byte CDB
//
struct _CDB12 {
UCHAR OperationCode;
UCHAR RelativeAddress : 1;
UCHAR Reserved1 : 2;
UCHAR ForceUnitAccess : 1;
UCHAR DisablePageOut : 1;
UCHAR LogicalUnitNumber : 3;
UCHAR LogicalBlock[4];
UCHAR TransferLength[4];
UCHAR Reserved2;
UCHAR Control;
} CDB12;
struct _START_STOP {
UCHAR OperationCode; // 0x1B - SCSIOP_START_STOP_UNIT
UCHAR Immediate: 1;
UCHAR Reserved1 : 4;
UCHAR LogicalUnitNumber : 3;
UCHAR Reserved2[2];
UCHAR Start : 1;
UCHAR LoadEject : 1;
UCHAR Reserved3 : 6;
UCHAR Control;
} START_STOP;
ULONG AsUlong[4];
UCHAR AsByte[16];
} CDB, *PCDB;
#pragma pack(pop, cdb)
typedef struct _INQUIRYDATA
{
UCHAR DeviceType : 5;
UCHAR DeviceTypeQualifier : 3;
UCHAR DeviceTypeModifier : 7;
UCHAR RemovableMedia : 1;
UCHAR Versions;
UCHAR ResponseDataFormat : 4;
UCHAR HiSupport : 1;
UCHAR NormACA : 1;
UCHAR ReservedBit : 1;
UCHAR AERC : 1;
UCHAR AdditionalLength;
UCHAR Reserved[2];
UCHAR SoftReset : 1;
UCHAR CommandQueue : 1;
UCHAR Reserved2 : 1;
UCHAR LinkedCommands : 1;
UCHAR Synchronous : 1;
UCHAR Wide16Bit : 1;
UCHAR Wide32Bit : 1;
UCHAR RelativeAddressing : 1;
UCHAR VendorId[8];
UCHAR ProductId[16];
UCHAR ProductRevisionLevel[4];
UCHAR VendorSpecific[20];
UCHAR Reserved3[40];
} INQUIRYDATA, *PINQUIRYDATA;
/****************************************************************************
* *
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY *
* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE *
* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR *
* PURPOSE. *
* *
* Copyright (C) 1993-95 Microsoft Corporation. All Rights Reserved. *
* *
****************************************************************************/
//***************************************************************************
//
// Name: WNASPI32.H
//
// Description: ASPI for Win32 definitions ('C' Language)
//
//***************************************************************************
#ifdef __cplusplus
extern "C" {
#endif
typedef void *LPSRB;
typedef void (*PFNPOST)();
DWORD SendASPI32Command (LPSRB);
DWORD GetASPI32SupportInfo (VOID);
#define SENSE_LEN 14 // Default sense buffer length
#define SRB_DIR_SCSI 0x00 // Direction determined by SCSI // command
#define SRB_DIR_IN 0x08 // Transfer from SCSI target to // host
#define SRB_DIR_OUT 0x10 // Transfer from host to SCSI // target
#define SRB_POSTING 0x01 // Enable ASPI posting
#define SRB_EVENT_NOTIFY 0x40 // Enable ASPI event notification
#define SRB_ENABLE_RESIDUAL_COUNT 0x04 // Enable residual byte count // reporting
#define SRB_DATA_SG_LIST 0x02 // Data buffer points to // scatter-gather list
#define WM_ASPIPOST 0x4D42 // ASPI Post message
//***************************************************************************
// %%% ASPI Command Definitions %%%
//***************************************************************************
#define SC_HA_INQUIRY 0x00 // Host adapter inquiry
#define SC_GET_DEV_TYPE 0x01 // Get device type
#define SC_EXEC_SCSI_CMD 0x02 // Execute SCSI command
#define SC_ABORT_SRB 0x03 // Abort an SRB
#define SC_RESET_DEV 0x04 // SCSI bus device reset
#define SC_GET_DISK_INFO 0x06 // Get Disk information
//***************************************************************************
// %%% SRB Status %%%
//***************************************************************************
#define SS_PENDING 0x00 // SRB being processed
#define SS_COMP 0x01 // SRB completed without error
#define SS_ABORTED 0x02 // SRB aborted
#define SS_ABORT_FAIL 0x03 // Unable to abort SRB
#define SS_ERR 0x04 // SRB completed with error
#define SS_INVALID_CMD 0x80 // Invalid ASPI command
#define SS_INVALID_HA 0x81 // Invalid host adapter number
#define SS_NO_DEVICE 0x82 // SCSI device not installed
#define SS_INVALID_SRB 0xE0 // Invalid parameter set in SRB
#define SS_FAILED_INIT 0xE4 // ASPI for windows failed init
#define SS_ASPI_IS_BUSY 0xE5 // No resources available to execute cmd
#define SS_BUFFER_TO_BIG 0xE6 // Buffer size to big to handle!
//***************************************************************************
// %%% Host Adapter Status %%%
//***************************************************************************
#define HASTAT_OK 0x00 // Host adapter did not detect an // error
#define HASTAT_SEL_TO 0x11 // Selection Timeout
#define HASTAT_DO_DU 0x12 // Data overrun data underrun
#define HASTAT_BUS_FREE 0x13 // Unexpected bus free
#define HASTAT_PHASE_ERR 0x14 // Target bus phase sequence // failure
#define HASTAT_TIMEOUT 0x09 // Timed out while SRB was waiting to beprocessed.
#define HASTAT_COMMAND_TIMEOUT 0x0B // While processing the SRB, the
// adapter timed out.
#define HASTAT_MESSAGE_REJECT 0x0D // While processing SRB, the // adapter received a MESSAGE // REJECT.
#define HASTAT_BUS_RESET 0x0E // A bus reset was detected.
#define HASTAT_PARITY_ERROR 0x0F // A parity error was detected.
#define HASTAT_REQUEST_SENSE_FAILED 0x10 // The adapter failed in issuing
// REQUEST SENSE.
//***************************************************************************
// %%% SRB - HOST ADAPTER INQUIRY - SC_HA_INQUIRY %%%
//***************************************************************************
typedef struct {
BYTE SRB_Cmd; // ASPI command code = SC_HA_INQUIRY
BYTE SRB_Status; // ASPI command status byte
BYTE SRB_HaId; // ASPI host adapter number
BYTE SRB_Flags; // ASPI request flags
DWORD SRB_Hdr_Rsvd; // Reserved, MUST = 0
BYTE HA_Count; // Number of host adapters present
BYTE HA_SCSI_ID; // SCSI ID of host adapter
BYTE HA_ManagerId[16]; // String describing the manager
BYTE HA_Identifier[16]; // String describing the host adapter
BYTE HA_Unique[16]; // Host Adapter Unique parameters
WORD HA_Rsvd1;
} SRB_HAInquiry, *PSRB_HAInquiry;
//***************************************************************************
// %%% SRB - GET DEVICE TYPE - SC_GET_DEV_TYPE %%%
//***************************************************************************
typedef struct {
BYTE SRB_Cmd; // ASPI command code = SC_GET_DEV_TYPE
BYTE SRB_Status; // ASPI command status byte
BYTE SRB_HaId; // ASPI host adapter number
BYTE SRB_Flags; // Reserved
DWORD SRB_Hdr_Rsvd; // Reserved
BYTE SRB_Target; // Target's SCSI ID
BYTE SRB_Lun; // Target's LUN number
BYTE SRB_DeviceType; // Target's peripheral device type
BYTE SRB_Rsvd1;
} SRB_GDEVBlock, *PSRB_GDEVBlock;
//***************************************************************************
// %%% SRB - EXECUTE SCSI COMMAND - SC_EXEC_SCSI_CMD %%%
//***************************************************************************
typedef struct {
BYTE SRB_Cmd; // ASPI command code = SC_EXEC_SCSI_CMD
BYTE SRB_Status; // ASPI command status byte
BYTE SRB_HaId; // ASPI host adapter number
BYTE SRB_Flags; // ASPI request flags
DWORD SRB_Hdr_Rsvd; // Reserved
BYTE SRB_Target; // Target's SCSI ID
BYTE SRB_Lun; // Target's LUN number
WORD SRB_Rsvd1; // Reserved for Alignment
DWORD SRB_BufLen; // Data Allocation Length
BYTE *SRB_BufPointer; // Data Buffer Pointer
BYTE SRB_SenseLen; // Sense Allocation Length
BYTE SRB_CDBLen; // CDB Length
BYTE SRB_HaStat; // Host Adapter Status
BYTE SRB_TargStat; // Target Status
void *SRB_PostProc; // Post routine
void *SRB_Rsvd2; // Reserved
BYTE SRB_Rsvd3[16]; // Reserved for alignment
BYTE CDBByte[16]; // SCSI CDB
BYTE SenseArea[SENSE_LEN+2]; // Request Sense buffer
} SRB_ExecSCSICmd, *PSRB_ExecSCSICmd;
//***************************************************************************
// %%% SRB - ABORT AN SRB - SC_ABORT_SRB %%%
//***************************************************************************
typedef struct {
BYTE SRB_Cmd; // ASPI command code = SC_EXEC_SCSI_CMD
BYTE SRB_Status; // ASPI command status byte
BYTE SRB_HaId; // ASPI host adapter number
BYTE SRB_Flags; // Reserved
DWORD SRB_Hdr_Rsvd; // Reserved
void *SRB_ToAbort; // Pointer to SRB to abort
} SRB_Abort, *PSRB_Abort;
//***************************************************************************
// %%% SRB - BUS DEVICE RESET - SC_RESET_DEV %%%
//***************************************************************************
typedef struct {
BYTE SRB_Cmd; // ASPI command code = SC_EXEC_SCSI_CMD
BYTE SRB_Status; // ASPI command status byte
BYTE SRB_HaId; // ASPI host adapter number
BYTE SRB_Flags; // Reserved
DWORD SRB_Hdr_Rsvd; // Reserved
BYTE SRB_Target; // Target's SCSI ID
BYTE SRB_Lun; // Target's LUN number
BYTE SRB_Rsvd1[12]; // Reserved for Alignment
BYTE SRB_HaStat; // Host Adapter Status
BYTE SRB_TargStat; // Target Status
void *SRB_PostProc; // Post routine
void *SRB_Rsvd2; // Reserved
BYTE SRB_Rsvd3[16]; // Reserved
BYTE CDBByte[16]; // SCSI CDB
} SRB_BusDeviceReset, *PSRB_BusDeviceReset;
//***************************************************************************
// %%% SRB - GET DISK INFORMATION - SC_GET_DISK_INFO %%%
//***************************************************************************
typedef struct {
BYTE SRB_Cmd; // ASPI command code = SC_EXEC_SCSI_CMD
BYTE SRB_Status; // ASPI command status byte
BYTE SRB_HaId; // ASPI host adapter number
BYTE SRB_Flags; // Reserved
DWORD SRB_Hdr_Rsvd; // Reserved
BYTE SRB_Target; // Target's SCSI ID
BYTE SRB_Lun; // Target's LUN number
BYTE SRB_DriveFlags; // Driver flags
BYTE SRB_Int13HDriveInfo; // Host Adapter Status
BYTE SRB_Heads; // Preferred number of heads translation
BYTE SRB_Sectors; // Preferred number of sectors translation
BYTE SRB_Rsvd1[10]; // Reserved
} SRB_GetDiskInfo, *PSRB_GetDiskInfo;
//
// SCSI CDB operation codes
//
// 6-byte commands:
#define SCSIOP_TEST_UNIT_READY 0x00
// 10-byte commands
#define SCSIOP_START_STOP_UNIT 0x1B
#define SCSIOP_READ 0x28
#define SCSIOP_READ_TOC 0x43
// 12-byte commands
#define SCSIOP_SET_CD_SPEED 0xBB
#ifdef __cplusplus
}
#endif