blob: 15ee25591bb7b5ba63c0e59197b4dfdb3a809508 (
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
|
/*++
Copyright (c) 1991-1993 Microsoft Corporation
Module Name:
simbad.h
Abstract:
The SIMulated BAD sector utility allows a user to specify
bad physical sectors through the device control interface.
The device driver keeps an array of SIMBAD sectors and when
a request for a transfer includes one of these sectors the
driver returns the corresponding status and fails the transfer.
Author:
Mike Glass (mglass) 2-Feb-1992
Bob Rinne (bobri)
Revision History:
09-Apr-92 - BobRi - Added specific control over errors (read,map,etc).
12-May-94 - Venkat- Added code to drop of writes to DISK (CHKDSK testing)
19-Nov-94 - KPeery- Added code to reset the system (restart testing)
--*/
#define MAXIMUM_SIMBAD_SECTORS 256
//
// This structure is used by the driver and application to
// specify which sector is BAD and what status the driver
// should return.
//
typedef struct _BAD_SECTOR {
ULONG BlockAddress;
ULONG AccessType;
NTSTATUS Status;
} BAD_SECTOR, *PBAD_SECTOR;
//
// This structure is maintained by the device driver. It keeps a
// count of how many sectors have been marked BAD and an array of
// the BAD sectors.
//
typedef struct _SIMBAD_SECTORS {
BOOLEAN Enabled;
BOOLEAN Orphaned;
BOOLEAN RandomWriteDrop;
ULONG Seed;
BOOLEAN BugCheck;
BOOLEAN FirmwareReset;
ULONG Count;
BAD_SECTOR Sector[MAXIMUM_SIMBAD_SECTORS];
} SIMBAD_SECTORS, *PSIMBAD_SECTORS;
//
// This structure is passed from the application to the device
// driver through the device control interface to add and remove
// bad sectors.
//
// If the function is add or remove sectors then the Count field
// specifies how many sectors to add or remove.
//
// If the function is list sectors then the Count field returns
// the number of sectors marked bad.
// The bad sector array contains the sectors to add or remove
// from the driver's array of bad sectors.
//
// If the function is list then the array returns all sectors
// marked bad.
//
// This facility does not allow mixed adds and removes in a
// single device control call.
//
// NOTE: if a request specifies a number of adds that will exceed
// the array limit (MAXIMUM_SIMBAD_SECTORS), then sectors will be
// added to fill the array and the count field will be adjusted to
// the number of sectors successfully added.
//
typedef struct _SIMBAD_DATA {
ULONG Function;
ULONG Count;
BAD_SECTOR Sector[MAXIMUM_SIMBAD_SECTORS];
} SIMBAD_DATA, *PSIMBAD_DATA;
//
// Simulated Bad Sector Functions
//
#define SIMBAD_ADD_SECTORS 0x00000000
#define SIMBAD_REMOVE_SECTORS 0x00000001
#define SIMBAD_LIST_BAD_SECTORS 0x00000002
//
// When the disable or enable function is specified,
// the rest of the structure is ignored.
// The SimBad function is disabled on driver startup.
// The disable/enable status affects whether completing
// transfers are checks against the bad sector array.
// While the function is disabled, requests to manipulate
// the driver's bad sector array are still allowed
// (ie add sector, remove sector, list bad sectors).
//
#define SIMBAD_ENABLE 0x00000003
#define SIMBAD_DISABLE 0x00000004
//
// This function cause all accesses to a driver
// to return failure.
//
#define SIMBAD_ORPHAN 0x00000005
//
// This function clears the internal bad sector list in the driver.
//
#define SIMBAD_CLEAR 0x00000006
//
// Randomly drops of writes to the disk. Used for corrupting the DISK.
// These corrupt disk are used to test CHKDSK.
//
#define SIMBAD_RANDOM_WRITE_FAIL 0x00000007
//
// Bug checks the system. Used for crash dump
//
#define SIMBAD_BUG_CHECK 0x00000008
//
// Call HalReturnToFirmware() to reset the system. Used for restart testing.
//
#define SIMBAD_FIRMWARE_RESET 0x00000009
//
// These are the access codes that will drive when simbad
// returns failures on disks.
//
#define SIMBAD_ACCESS_READ 0x00000001
#define SIMBAD_ACCESS_WRITE 0x00000002
#define SIMBAD_ACCESS_VERIFY 0x00000004
//
// Error sector can be mapped via device control.
//
#define SIMBAD_ACCESS_CAN_REASSIGN_SECTOR 0x00000008
//
// When returning an error indicate Irp offset of zero
// (simulates drivers that cannot tell where the error occured within
// an I/O)
//
#define SIMBAD_ACCESS_ERROR_ZERO_OFFSET 0x00000010
//
// Fail calls to reassign bad sector IOCTL.
//
#define SIMBAD_ACCESS_FAIL_REASSIGN_SECTOR 0x00000020
|