summaryrefslogtreecommitdiff
path: root/tools/sdv/samples/SDV-FailDriver-STORPORT/driver/lsinvm.h
blob: 0064b03b95312f7ee124a4c0859894d5fadef876 (plain)
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
/*++

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) Microsoft Corporation. All rights reserved

Module Name:

    lsinvm.h

Abstract:

    Private header file for lsi_u3.sys modules.  This contains private
    structure and function declarations as well as constant values which do
    not need to be exported.

Environment:

    kernel mode only

Notes:


Revision History:

--*/


/*
*************************************************************************
*                                                                       *
*   Copyright 1994-2008 LSI Corporation. All rights reserved.           *
*                                                                       *
************************************************************************/


/*
 *  This include file contains the definitions for the NT driver to read user
 *   set values in the nvram chip.  The driver looks at the HBA ID and scam ID values.
 *   The structure version number for this code is major -0x00 minor -0x21.
 *   To get the definitions of the fields look at the SDMS4.0 bootrom include files
 *      ROMTYPES.H
 *      ROMPUBLC.H
 *      ROMSTRUC.H
 *      ROMSCAM.H
 *      ROMHW.H
 *      ROMBIOS.H
 */

/* If this header file has not been included yet */
#if !defined LSINVM_H
#define LSINVM_H

/*  Since all data structures must be byte aligned throughout this file, we
 *  issue the commands to perform that alignment once, and then restore the
 *  compilers default alignment at the end of this file.
 */

#pragma pack(1)                 /* Force byte alignment, MS-C, WATCOM */

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * Non Volatile Memory types
 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 */

/*  NVS_VERSION_MAJOR and NVS_VERSION_MINOR are #defined to the revision of the
 *  main data structure (NON_VOLATILE_SETTINGS) in this document.
 */

#define NVS_VERSION_MAJOR       (0x00)
#define NVS_VERSION_MINOR       (0x30)

#define BI_MAX_HBA      4
#define HW_MAX_DEVICES 16
#define HW_MAX_SCAM_DEVICES 4
#define NVMDATAOFFSET   0x100

#define FAILURE (0)
#define SUCCESS (1)

typedef enum _HEADER_TYPE
{
    HT_BOOT_ROM         = 0,
    HT_DOS_ASPI         = 1,
    HT_WINDOWS_ASPI     = 2,
    HT_NETWARE          = 3,
    HT_UNIXWARE         = 4,
    HT_SCO_UNIX         = 5,
    HT_WINDOWS_NT       = 6,
    HT_WINDOWS95        = 7,
    HT_OS_2             = 8,
    HT_SOLARIS          = 9,
    HT_INTERACTIVE      = 10,
    HT_NEXTSTEP         = 11,
    HT_END_MEMORY_BLOCK = 0xFEFE
} HEADER_TYPE;

typedef unsigned int    UINT;
typedef unsigned char   UINT8;
typedef unsigned short  UINT16;
// need to define UINT32 for NT 4.0
#if _WIN32_WINNT == 0x0400
typedef unsigned long   UINT32;
#endif

#define WIDE_NONE       (8)
#define WIDE_16         (16)
#define WIDE_32         (32)
#define WIDE_NO_CHANGE  (0xFF)

/*  Synchronous speed macros are used to declare a synchronous period for
 *  an adapter or a device.  The values of the macros used are in units of
 *  nano-seconds, the names of the macros are in mega-transfers per second.
 *
 *  SYNC_NO_CHANGE ==> Defines a SCSI synchronous period entry for no changes in
 *                     the current device synchronous selection.
 *
 *  SYNC_NONE ==> Defines a SCSI synchronous period entry for asynchronous
 *                operation.
 *
 *  SYNC_5  ==>  Defines a SCSI synchronous period entry for 5
 *               mega-transfers per second.
 *
 *  SYNC_10 ==>  Defines a SCSI synchronous period entry for 10
 *               mega-transfers per second.
 *
 *  SYNC_20 ==>  Defines a SCSI synchronous period entry for 20
 *               mega-transfers per second.
 *
 *  SYNC_40 ==>  Defines a SCSI synchronous period entry for 40
 *               mega-transfers per second.
 *
 *  SYNC_80 ==>  Defines a SCSI synchronous period entry for 80
 *               mega-transfers per second.
 */

#define SYNC_NO_CHANGE  (0xFFFF)
#define SYNC_NONE       (     0)
#define SYNC_5          (   200)
#define SYNC_10         (   100)
#define SYNC_20         (    48)
#define SYNC_40         (    40)
#define SYNC_80         (    36)

typedef UINT8  WIDE_PARAMETERS;
typedef USHORT IO_ADDRESS;
typedef UINT32 PHYS_ADDRESS;

typedef USHORT  HBA_FLAGS;
#define HF_SCAM_ENABLED             (0x0001)
#define HF_PARITY_ENABLED           (0x0002)
#define HF_DISPLAY_VERBOSE_ENABLED  (0x0004)
#define HF_NO_NON_VOLATILE_MEMORY   (0x0008)

typedef UINT8   DEVICE_FLAGS;
#define DF_DISCONNECT_ENABLED   (0x01)
#define DF_SCAN_ENABLED         (0x02)
#define DF_LUNS_ENABLED         (0x04)
#define DF_QT_ENABLED           (0x08)
#define DF_ALL_FEATURES_ENABLED (DF_DISCONNECT_ENABLED | DF_SCAN_ENABLED |  \
                                 DF_LUNS_ENABLED | DF_QT_ENABLED)

typedef enum MEMORY_STATUS
{
    MS_GOOD = 0,
    MS_ILLEGAL_ADDRESS,
    MS_GENERAL_ERROR
} MEMORY_STATUS;

typedef enum _TERMINATION_STATE
{
    TS_CANT_PROGRAM = 0,
    TS_ENABLED      = 1,
    TS_DISABLED     = 2
} TERMINATION_STATE;

typedef enum _ADAPTER_TYPE
{
    AT_UNKNOWN      = 0,
    AT_400A         = 1,
    AT_406A         = 2,
    AT_416          = 3,
    AT_8XX          = 4
} ADAPTER_TYPE;

typedef struct _ADAPTER_IO_INFO
{
    USHORT      RangeSize;
    IO_ADDRESS  IoBasePort;
} ADAPTER_IO_INFO, * PTR_ADAPTER_IO_INFO;

typedef struct _ADAPTER_MEMORY_INFO
{
    PHYS_ADDRESS        PhyMemoryBase;
    UINT8               *VirtMemoryBase;
} ADAPTER_MEMORY_INFO, * PTR_ADAPTER_MEMORY_INFO;

typedef struct _ADAPTER_416_INFO
{
    UINT32  DeviceId;
    UINT32  SerialNumber;
} ADAPTER_416_INFO, * PTR_ADAPTER_416_INFO;

typedef struct _ADAPTER_8XX_INFO
{
    USHORT  DeviceId;
    USHORT  VendorId;
    UINT8   BusNumber;
    UINT8   BusIndex;
} ADAPTER_8XX_INFO, * PTR_ADAPTER_8XX_INFO;

typedef union _ADAPTER_INFO
{
    ADAPTER_416_INFO        Hba416;
    ADAPTER_8XX_INFO        Hba8xx;
    ADAPTER_IO_INFO         HbaIo;
/*  Can't have the following structure as part of this union:
    ADAPTER_MEMORY_INFO     HbaMemory;
    This is due to it having a pointer address, which becomes 8 bytes
    long with a 64-bit OS, causing the compiler offsets to be wrong
    compared with the data stored in NVM.  It's not used in this driver.
*/
} ADAPTER_INFO, * PTR_ADAPTER_INFO;

typedef enum _SCAN_ORDER
{
    SO_LOW_TO_HIGH  = 0,
    SO_HIGH_TO_LOW  = 1
} SCAN_ORDER;

typedef enum _REMOVABLE_MEDIA
{
    RM_NO_SUPPORT           = 0,
    RM_BOOT_DEVICE_ONLY     = 1,
    RM_MEDIA_INSTALLED_ONLY = 2
} REMOVABLE_MEDIA;

typedef struct _HBA_INIT
{
    USHORT        Type;
    ADAPTER_INFO        HbaInfo;
    USHORT              InitStatus;
    IO_ADDRESS          IoPort;
} HBA_INIT, * PTR_HBA_INIT;

typedef struct _DEVICE_TABLE
{
    UINT8               Flags;          // 8 bits
    UINT8               Reserved;
    WIDE_PARAMETERS     WideDataBits;   // 8 bits
    UINT8               SyncOffset;
    USHORT              SyncPeriodNs;
    USHORT              Timeout;
} DEVICE_TABLE, * PTR_DEVICE_TABLE;

typedef struct _SCAM_IDENTIFIER
{
    UINT8   DeviceType[ 2 ];
    char    VendorId[ 8 ];
    char    VendorSpecific[ 21 ];
    UINT8   Reserved;
} SCAM_IDENTIFIER, * PTR_SCAM_IDENTIFIER;

typedef enum _SCAM_ID_METHOD
{
    SIM_DEFAULT_METHOD  = 0,
    SIM_DONT_ASSIGN     = 1,
    SIM_SET_SPECIFIC_ID = 2,
    SIM_USE_ORDER_GIVEN = 3
} SCAM_ID_METHOD;

typedef enum _SCAM_STATUS
{
    SS_UNKNOWN          = 0,
    SS_DEVICE_NOT_FOUND = 1,
    SS_ID_NOT_SET       = 2,
    SS_ID_VALID         = 3
} SCAM_STATUS;

typedef struct _SCAM_TABLE
{
    USHORT     ScamId;
    USHORT     HowToSetId;
    USHORT     ScamStatus;
    UINT8      ScamTargetId;
    UINT8      Reserved;
} SCAM_TABLE, * PTR_SCAM_TABLE;

typedef struct _NVM_HEADER
{
    USHORT     Type;
    USHORT     Length;
    USHORT     CheckSum;
} NVM_HEADER, * PTR_NVM_HEADER;

typedef SCAM_TABLE      NVM_SCAM_DATA;
typedef PTR_SCAM_TABLE  PTR_NVM_SCAM_DATA;

typedef struct _NON_VOLATILE_SETTINGS
{
    UINT8          VersionMajor;
    UINT8          VersionMinor;
    UINT32         BootCrc;
    USHORT         HbaFlags;
    USHORT         ScanOrder;
    USHORT         TerminatorState;
    USHORT         RemovableMediaSetting;
    UINT8          HostScsiId;
    UINT8          NumHba;
    UINT8          NumDevices;
    UINT8          MaxScamDevices;
    UINT8          NumValidScamDevices;
    UINT8          Reserved;
    HBA_INIT       HbaInit[ BI_MAX_HBA ];
    DEVICE_TABLE   DeviceTable[ HW_MAX_DEVICES ];
    NVM_SCAM_DATA  ScamTable[ HW_MAX_SCAM_DEVICES ];
    UINT8          freespace[1024];  // this added by NT so we can read past end
                                     // of the NVRAM structure to get all data
                                     // used for checksum
} NON_VOLATILE_SETTINGS, * PTR_NON_VOLATILE_SETTINGS;

typedef struct _SINGLE_HBA_NVS
{
    UINT16                 NextHBANVS; // offset of next struct in code segment
    IO_ADDRESS             IoPort;
    UINT16                 DeviceId;
    UINT16                 VendorId;
    UINT16                 BusNumber;
    UINT16                 BusIndex;
    NVM_HEADER             header1;
    NON_VOLATILE_SETTINGS  settings;
    NVM_HEADER             header2;

} SINGLE_HBA_NVS, * PTR_SINGLE_HBA_NVS;


/* NVM Manufacturing data table definition.  This is used for
 * GPIO pin usage information.
 */
#define NVM_OFFSET_MFG_DATA   (0x40)
#define NVM_LENGTH_MFG_DATA   (0x80)

typedef struct _NVM_MFG_DATA_TABLE
{
    UINT8      TableLen;   /* for this structure, TableLen == 5 */
    UINT8      Gpio1;
    UINT8      Gpio2;
    UINT8      Gpio3;
    UINT8      Gpio4;
} NVM_MFG_DATA_TABLE, *PTR_NVM_MFG_DATA_TABLE;

typedef struct _NVM_MFG_DATA
{
    UINT8               Checksum;
    NVM_MFG_DATA_TABLE  Table;
    /* Manufacturing data table begins at 0x40 and ends at 0xbf
    * we calculate the number of bytes that are unused and allocate
    * storage for them since they are read and are part of the
    * checksum calculation.  This structure is normally only used
    * during driver initialization.
    */
    UINT8 Unused[NVM_LENGTH_MFG_DATA -
                 sizeof( struct _NVM_MFG_DATA_TABLE ) -
                 sizeof( UINT8 /* Checksum */ )];
} NVM_MFG_DATA, *PTR_NVM_MFG_DATA;

/* Masks for GPIO pin definition byte */
#define     GPIO_USAGE_MASK     0x3f /* Bits 0-5 holds usage code */
                                     /* Bit 6 is reserved         */
#define     GPIO_LEVEL_MASK     0x80 /* Bit 7 active signal level */
/* Note:  The bit that denotes the active signal level is set to 1
 * when the manufacture uses a high signal on the GPIO pin to indicate
 * a TRUE or ON condition, whereas the bit is set to 0 if the GPIO pin
 * uses a low signal on the GPIO pin to indicate a TRUE or ON condition */

/* Defines for the known usage codes for GPIO pins */
#define     GPIO_UNUSED             0
#define     GPIO_FLASH_PROGRAM      1
#define     GPIO_HVD_SENSE          2
#define     GPIO_TERMINATION        3
#define     GPIO_CABLE_SENSE_A      4
#define     GPIO_CABLE_SENSE_B      5
#define     GPIO_TERMINATION_SENSE  6

/* Defines for GPIO pins on and off */
#define     GPIO_ON     1
#define     GPIO_OFF    0

/*  Define some macros to access the offsets of particular portions of this
 *  data structure.  These macros are then used to allow the code to more
 *  easily program only those parts of non-volatile memory which might have
 *  changed when the user issues a set NVM call.
 */

#define NVS_ADAPTER_BEGIN   (offsetof(struct _NON_VOLATILE_SETTINGS, HbaFlags))
#define NVS_ADAPTER_END     (offsetof(struct _NON_VOLATILE_SETTINGS, \
                             DeviceTable[ 0 ]))
#define NVS_ADAPTER_LENGTH  (NVS_ADAPTER_END - NVS_ADAPTER_BEGIN)

#define NVS_DEVICE_BEGIN(x) (offsetof(struct _NON_VOLATILE_SETTINGS, \
                             DeviceTable[(x)]))
#define NVS_DEVICE_END(x)   (offsetof(struct _NON_VOLATILE_SETTINGS, \
                             DeviceTable[(x)+1]))
#define NVS_DEVICE_LENGTH   (sizeof( DEVICE_TABLE ))

#if HW_MAX_SCAM_DEVICES != 0
    #define NVS_SCAM_BEGIN  (offsetof(struct _NON_VOLATILE_SETTINGS, \
                             ScamTable[0]))
    #define NVS_SCAM_END    (sizeof(NON_VOLATILE_SETTINGS))
    #define NVS_SCAM_LENGTH (NVS_SCAM_END - NVS_SCAM_BEGIN)
#endif

/*  NVM_DATA_SIZE defines the number of bytes of data we need to access the
 *  NVM header structure and the NVM data structure for our ROM.
 */

#define NVM_DATA_SIZE   (sizeof(NVM_HEADER) + sizeof(NON_VOLATILE_SETTINGS))

/*  We are now done with the requirement of forcing byte alignment on all
 *  elements so restore the compilers default structure alignment.
 */

#pragma pack()                  /* Restore default alignment, MS-C, WATCOM */

#endif /* End of if LSINVM_H */