-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsIdfy.c
More file actions
executable file
·391 lines (357 loc) · 17 KB
/
tsIdfy.c
File metadata and controls
executable file
·391 lines (357 loc) · 17 KB
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
#include "ts.h"
/**
* <pre>
* Description:
* Identify drive with "ECHO" protocol in UART. It contains drive S/N.
*
* Arguments:
* *tscb - Test script control block
*
* Querying Data in Echo Command
* Function is getSN_Echo() in comUart.c
* wDriveEchoVersion ----> Echo data format version
* Drive CPU A00
* 0:PTB,PTC Couldn't use Echo Command
* -:GMN srstMfgID, srstSN
* -:STN srstMfgID, srstSN, srstMicroLevel ,srstNumberOfServoSector, srstHeadTable, tpiinfo, srstSpindleSpeed
*
* Drive CPU ARM
* 2:JPK,JPT srstMfgID, srstSN, srstMicroLevel ,srstNumberOfServoSector, srstHeadTable, tpiinfo, srstSpindleSpeed
* 4:EB7,JET,JGB srstMfgID, srstSN, srstMicroLevel ,srstNumberOfServoSector, srstHeadTable, tpiinfo, srstSpindleSpeed,srst,addressSRSTTop
* 4:MRK,MNR,MRS srstMfgID, srstSN, srstMicroLevel ,srstNumberOfServoSector, srstHeadTable, tpiinfo, srstSpindleSpeed,srst,addressSRSTTop
*
* Multi Grading at Function
* MFG-ID in echo command and MFG-ID on label would be different.
* MFG-ID on label is in SRST sequence.
* Report both S/N to PC
*
* Drive Voltage Report Format
* Dwrod Contents
* ------------------------
* 0 5V reading value (e.g 5.05V ==> 500) : Big endian
* 1 Reserved
* 2 12V reading value (e.g 11.96V ==> 1196) : Big endian
* 3 Reserved
* 4 Reserved
* 5 Reserved
*
* </pre>
***************************************************************************************
2010/05/13 Support JPT or later Echo command procedure Y.Enomoto
*****************************************************************************/
Byte identifyDrive(TEST_SCRIPT_CONTROL_BLOCK *tscb)
{
TEST_SCRIPT_ERROR_BLOCK *tseb = &tscb->testScriptErrorBlock;
Byte rc = 1;
Dword dwTimeoutSec = 0;
Byte bStatePrev = IDENTIFY_DRIVE_FSM_before_initialize;
// Byte bStateNow = IDENTIFY_DRIVE_FSM_srst_sequence;
Byte bStateNow = IDENTIFY_DRIVE_FSM_data_from_Echo_before_sequence;
Dword dwHugCpuCounter = 0;
ts_printf(__FILE__, __LINE__, "identifyDrive");
dwTimeoutSec = tscb->dwDriveTestIdentifyTimeoutSec;
ts_printf(__FILE__, __LINE__, "timeout = %d sec", dwTimeoutSec);
if (tscb->bPartFlag == FINAL_PART) {
ts_printf(__FILE__, __LINE__, "dwTimeoutSec = %d", dwTimeoutSec);
dwTimeoutSec = dwTimeoutSec + tscb->dwTimeStampAtFinalTestStart;
ts_printf(__FILE__, __LINE__, "dwTimeoutSec for Final = %d", dwTimeoutSec);
}
for (;;) {
/* error check */
if (tseb->isFatalError) {
ts_printf(__FILE__, __LINE__, "fatal error in Identify");
return 10;
}
/* timeout check */
if (dwTimeoutSec < getTestScriptTimeInSec()) {
ts_printf(__FILE__, __LINE__, "Error - identify timeout");
tseb->isDriveIdentifyTimeout = 1;
return 11;
}
/* state change check */
if (bStateNow != bStatePrev) {
ts_printf(__FILE__, __LINE__, "change state %d -> %d", bStatePrev, bStateNow);
} else {
ts_sleep_partial(WAIT_TIME_SEC_FOR_DRIVE_IDENTIFY_POLL);
}
bStatePrev = bStateNow;
/* release cpu resource */
if (dwHugCpuCounter++ >= RELEASE_CPU_TRIGGER) {
dwHugCpuCounter = 0;
ts_sleep_partial(WAIT_TIME_SEC_FOR_RELEASE_CPU);
}
/* run state machine */
switch (bStateNow) {
case IDENTIFY_DRIVE_FSM_data_from_Echo_before_sequence: /* srst sequence (check if srst sequence valid) */
ts_printf(__FILE__, __LINE__, "****IDENTIFY_DRIVE_FSM_data_from_Echo_before_sequence****");
rc = 0;
if (tscb->wDriveEchoVersion >= 2) { /* JPT or later */
rc = getEchoData(tscb);
}
if (!rc) {
bStateNow = IDENTIFY_DRIVE_FSM_serial_number;
}
break;
case IDENTIFY_DRIVE_FSM_serial_number: /* drive serial number */
ts_printf(__FILE__, __LINE__, "****IDENTIFY_DRIVE_FSM_serial_number****");
rc = 0;
if (tscb->wDriveEchoVersion < 2) { /* Legacy product (PTB,PTC) */
rc = driveIoCtrlByKeywordWithRetry(tscb, KEY_MFG_ID, 0, READ_FROM_DRIVE);
if (!rc) {
memmove(&tscb->bDriveMfgId[0], (Word *)&tscb->bSectorBuffer[0], sizeof(tscb->bDriveMfgId));
memmove(&tscb->bDrivePass2Id[0], (Word *)&tscb->bSectorBuffer[0], sizeof(tscb->bDriveMfgId)); /* temporaly */
memmove(&tscb->bDriveSerialNumber[0], &tscb->bSectorBuffer[sizeof(tscb->bDriveMfgId)], sizeof(tscb->bDriveSerialNumber));
}
}
if (!rc) {
if (!ts_isalnum_mem(&tscb->bDriveMfgId[0], sizeof(tscb->bDriveMfgId))) {
ts_printf(__FILE__, __LINE__, "Error - data contents invalid (MfgID %s)", tscb->bDriveMfgId);
tseb->isFatalError = 1;
return 12;
}
if (!ts_isalnum_mem(&tscb->bDriveSerialNumber[0], sizeof(tscb->bDriveSerialNumber))) {
ts_printf(__FILE__, __LINE__, "Error - data contents invalid (Serial %s)", tscb->bDriveSerialNumber);
tseb->isFatalError = 1;
return 13;
}
if (MATCH != ts_memcmp_exp(&tscb->bDriveSerialNumber[0], &tscb->bTestSerialNumber[0], sizeof(tscb->bDriveSerialNumber))) {
ts_printf(__FILE__, __LINE__, "Error - s/n invalid");
tseb->isFatalError = 1;
return 14;
}
bStateNow = IDENTIFY_DRIVE_FSM_mfg_id;
}
ts_printf(__FILE__, __LINE__, "IDENTIFY(%s)", tscb->bDriveSerialNumber);
break;
case IDENTIFY_DRIVE_FSM_mfg_id: /* drive mfg id in identify */
ts_printf(__FILE__, __LINE__, "****IDENTIFY_DRIVE_FSM_mfg_id****");
if (tscb->wDriveEchoVersion >= 2) { /* JPT or later */
bStateNow = IDENTIFY_DRIVE_FSM_srst_sequence;
} else {
bStateNow = IDENTIFY_DRIVE_FSM_mfg_id_on_label;
}
break;
case IDENTIFY_DRIVE_FSM_srst_sequence: /* srst sequence (check if srst sequence valid) */
ts_printf(__FILE__, __LINE__, "****IDENTIFY_DRIVE_FSM_srst_sequence****");
rc = driveIoCtrlByKeywordWithRetry(tscb, KEY_SRST_SEQUENCE, 0, READ_FROM_DRIVE);
if (!rc) {
if ((MATCH != memcmp(&tscb->bSectorBuffer[0], SIGNATURE_SRST_RUNNING, strlen(SIGNATURE_SRST_RUNNING))) && /* SELF */
(MATCH != memcmp(&tscb->bSectorBuffer[0], SIGNATURE_SRST_ABORT, strlen(SIGNATURE_SRST_ABORT))) && /* ABOR */
(MATCH != memcmp(&tscb->bSectorBuffer[0], SIGNATURE_SRST_COMPLETE, strlen(SIGNATURE_SRST_COMPLETE))) && /* COMP */
(MATCH != memcmp(&tscb->bSectorBuffer[0], SIGNATURE_SRST_PENDING, strlen(SIGNATURE_SRST_PENDING))) /* PEND */ ) {
ts_printf(__FILE__, __LINE__, "Error - srst seq invalid - retry");
break;
}
if (tscb->bPartFlag == SRST_PART) { /* SRST part */
if ((MATCH == memcmp(&tscb->bSectorBuffer[0], SIGNATURE_SELFFIN1, strlen(SIGNATURE_SELFFIN1)) ||
(MATCH == memcmp(&tscb->bSectorBuffer[0], SIGNATURE_SELFFIN0, strlen(SIGNATURE_SELFFIN0))))) { /* finished SRST , need to jump at final part */
ts_printf(__FILE__, __LINE__, "****SRST has finished already(%s),need to final part ****", tscb->bSectorBuffer);
return FINAL_MODE;
}
if (MATCH == memcmp(&tscb->bSectorBuffer[0], SIGNATURE_ABORSRST, strlen(SIGNATURE_ABORSRST))) { /* aborted SRST , need to ReSRST as of now ,this pattern is nothing. */
ts_printf(__FILE__, __LINE__, "****SRST Part has aborted. ****");
tseb->isFatalError = 1;
return 15;
}
if (MATCH == memcmp(&tscb->bSectorBuffer[0], SIGNATURE_PENDSRST, strlen(SIGNATURE_PENDSRST))) { /* aborted SRST , need to ReSRST as of now ,this pattern is nothing. */
ts_printf(__FILE__, __LINE__, "****SRST Part has PENDed. ****");
tseb->isFatalError = 1;
return 16;
}
}
if (tscb->bPartFlag == FINAL_PART) { /* FINAL part */
if (MATCH == memcmp(&tscb->bSectorBuffer[0], SIGNATURE_ABORFIN1, strlen(SIGNATURE_ABORFIN1))) { /* aborted FINAL , need finishing test */
ts_printf(__FILE__, __LINE__, "****Final Part has aborted. ****"); /*[019KPD] */
tseb->isFatalError = 1;
return 17;
}
if (MATCH == memcmp(&tscb->bSectorBuffer[0], SIGNATURE_ABORFIN0, strlen(SIGNATURE_ABORFIN0))) { /* aborted FINAL , need to Refianl test */
ts_printf(__FILE__, __LINE__, "****Final Part has aborted. ****"); /*[019KPD] */
tseb->isFatalError = 1;
return 18;
}
if (MATCH == memcmp(&tscb->bSectorBuffer[0], SIGNATURE_PENDFIN0, strlen(SIGNATURE_PENDFIN0))) { /* aborted FINAL , need to Refianl test */
ts_printf(__FILE__, __LINE__, "****Final Part has pended. ****"); /*[019KPD] */
tseb->isFatalError = 1;
return 19;
}
if (MATCH == memcmp(&tscb->bSectorBuffer[0], SIGNATURE_PENDFIN1, strlen(SIGNATURE_PENDFIN1))) { /* aborted FINAL , need to Refianl test */
ts_printf(__FILE__, __LINE__, "****Final Part has pended. ****"); /*[019KPD] */
tseb->isFatalError = 1;
return 20;
}
if (MATCH == memcmp(&tscb->bSectorBuffer[4], "SRST", 4)) {
ts_printf(__FILE__, __LINE__, "**** still SRST Part ****");
tseb->isFatalError = 1;
return 21;
}
}
// bStateNow = IDENTIFY_DRIVE_FSM_serial_number;
bStateNow = IDENTIFY_DRIVE_FSM_data_from_Echo_after_sequence;
}
break;
case IDENTIFY_DRIVE_FSM_data_from_Echo_after_sequence: /* srst sequence (check if srst sequence valid) */
ts_printf(__FILE__, __LINE__, "****IDENTIFY_DRIVE_FSM_data_from_Echo_after_sequence****");
rc = getEchoData(tscb);
if (!rc) {
bStateNow = IDENTIFY_DRIVE_FSM_mfg_id_on_label;
}
break;
case IDENTIFY_DRIVE_FSM_mfg_id_on_label: /* mfg id on label */
ts_printf(__FILE__, __LINE__, "****IDENTIFY_DRIVE_FSM_mfg_id_on_label****");
if (tscb->isMultiGrading) { /* isMultiGrading is from config file. always 1 */
rc = driveIoCtrlByKeywordWithRetry(tscb, KEY_MFGID_ON_LABEL, 0, READ_FROM_DRIVE);
if (!rc) {
if (tscb->wDriveEchoVersion >= 2) { /* JPT or later */
memmove(&tscb->bDriveMfgIdOnLabel[0], &tscb->bDriveMfgId[0], sizeof(tscb->bDriveMfgIdOnLabel));
Dword dwOffset = tscb->bTestLabelMfgIdOffset;
memmove(&tscb->bDriveMfgIdOnLabel[dwOffset], &tscb->bSectorBuffer[0], sizeof(tscb->bDriveMfgIdOnLabel) - dwOffset);
} else {
memmove(&tscb->bDriveMfgIdOnLabel[0], &tscb->bSectorBuffer[0], sizeof(tscb->bDriveMfgIdOnLabel));
}
if (!ts_isalnum_mem(&tscb->bDriveMfgIdOnLabel[0], sizeof(tscb->bDriveMfgIdOnLabel))) {
ts_printf(__FILE__, __LINE__, "Error - data contents invalid (LabelID %s)", tscb->bDriveMfgIdOnLabel);
tseb->isFatalError = 1;
return 22;
}
if (MATCH != ts_memcmp_exp(&tscb->bDriveMfgIdOnLabel[0], &tscb->bTestMfgId[0], sizeof(tscb->bDriveMfgIdOnLabel))) {
ts_printf(__FILE__, __LINE__, "Error - mfg-id invalid");
tseb->isFatalError = 1;
return 23;
}
memcpy(&tscb->bDrivePass2Id[0], &tscb->bDriveMfgId[0], sizeof(tscb->bDriveMfgId)); /* for function grading reportHost function */
reportHostId(tscb);
reportHostGradingId(tscb);
bStateNow = IDENTIFY_DRIVE_FSM_status;
}
} else {
ts_printf(__FILE__, __LINE__, "no Fuction grading");
memmove(&tscb->bDriveMfgIdOnLabel[0], &tscb->bDriveMfgId[0], sizeof(tscb->bDriveMfgIdOnLabel));
reportHostId(tscb);
bStateNow = IDENTIFY_DRIVE_FSM_status;
}
break;
case IDENTIFY_DRIVE_FSM_status: /* status */
ts_printf(__FILE__, __LINE__, "****IDENTIFY_DRIVE_FSM_status****");
rc = getDriveTemperature(tscb);
if (!rc) {
rc = getSRSTstep(tscb);
if (!rc) {
bStateNow = IDENTIFY_DRIVE_FSM_environment;
}
}
break;
case IDENTIFY_DRIVE_FSM_signature: /* srst signature */
ts_printf(__FILE__, __LINE__, "****IDENTIFY_DRIVE_FSM_signature****");
rc = driveIoCtrlByKeywordWithRetry(tscb, KEY_SRST_SIGNATURE, 0, READ_FROM_DRIVE);
if (!rc) {
Dword i = 0;
for (i = 0 ; i < (sizeof(tscb->bDriveSignature) / sizeof(tscb->bDriveSignature[0])) ; i++) {
tscb->bDriveSignature[i] = tscb->bSectorBuffer[8 * i];
}
bStateNow = IDENTIFY_DRIVE_FSM_environment;
}
break;
case IDENTIFY_DRIVE_FSM_environment: /* environment data */
ts_printf(__FILE__, __LINE__, "****IDENTIFY_DRIVE_FSM_environment****");
rc = getEnvironmentStatus(tscb);
if (!rc) {
bStateNow = IDENTIFY_DRIVE_FSM_report_to_host;
}
break;
case IDENTIFY_DRIVE_FSM_report_to_host: /* report to host */
ts_printf(__FILE__, __LINE__, "****IDENTIFY_DRIVE_FSM_report_to_host****");
tscb->isDriveIdentifyComplete = 1;
reportHostTestStatus(tscb);
reportHostTestTimeOut(tscb);
if (tscb->isDriveVoltageDataReport) {
memset(&tscb->bSectorBuffer[0], 0x00, 24);
tscb->bSectorBuffer[2] = 0xff & ((tscb->wCurrentV5InMilliVolts / 10) >> 8);
tscb->bSectorBuffer[3] = 0xff & ((tscb->wCurrentV5InMilliVolts / 10) >> 0);
tscb->bSectorBuffer[10] = 0xff & ((tscb->wCurrentV12InMilliVolts / 10) >> 8);
tscb->bSectorBuffer[11] = 0xff & ((tscb->wCurrentV12InMilliVolts / 10) >> 0);
reportHostTestData(tscb, KEY_TESTER_VOLTAGE_DATA, &tscb->bSectorBuffer[0], 24);
} else {
ts_printf(__FILE__, __LINE__, "no drive volt report");
}
/* 3Step is no grading *//* MNR,MRK,MRNT or EB7,JET,JGR or later */
if (tscb->bSwtablePickupf == 0) {
ts_sleep_partial(30);
if (tscb->wDriveEchoVersion >= 3) { /* MNR,MRK,MRNT or EB7,JET,JGR or later */
reportHostTestMessage(tscb, "getting switching table");
getSWtable(tscb);
reportHostTestMessage(tscb, "finished switching table");
tscb->bSwtablePickupf = 1;
}
}
/********************************************************************/
return 0;
break;
default:
ts_printf(__FILE__, __LINE__, "invalid state!!");
tseb->isFatalError = 1;
return 24;
break;
}
}
ts_printf(__FILE__, __LINE__, "shall not be here!!");
tseb->isFatalError = 1;
return 25;
}
/**
* <pre>
* Description:
* Identify drive from "ECHO" protocol in UART. It contains all of Identification Data.
* These Data access procedure came from Config file.
*
* Arguments:
* *tscb - Test script control block
*
* Querying Data in Echo Command
* Function is getSN_Echo() in comUart.c
* 2:JPK,JPT srstMfgID, srstSN, srstMicroLevel ,srstNumberOfServoSector, srstHeadTable, tpiinfo, srstSpindleSpeed
* 4:EB7,JET,JGB srstMfgID, srstSN, srstMicroLevel ,srstNumberOfServoSector, srstHeadTable, tpiinfo, srstSpindleSpeed,srst,addressSRSTTop
* 4:MRK,MNR,MRS srstMfgID, srstSN, srstMicroLevel ,srstNumberOfServoSector, srstHeadTable, tpiinfo, srstSpindleSpeed,srst,addressSRSTTop
*
* </pre>
***************************************************************************************
2010/05/13 Support JPT or later Echo command procedure Y.Enomoto
*****************************************************************************/
Byte getEchoData(TEST_SCRIPT_CONTROL_BLOCK *tscb)
{
TEST_SCRIPT_ERROR_BLOCK *tseb = &tscb->testScriptErrorBlock;
DRIVE_MEMORY_CONTROL_BLOCK *dmcb;
Byte rc = 1;
Byte *bData_address;
rc = driveIoCtrlByKeywordWithRetry(tscb, KEY_SERIAL_NUMBER, 0, READ_FROM_DRIVE); /* Read 512 bytes Echo Data */
if (!rc) {
for (dmcb = &tscb->driveMemoryControlBlock[0] ; dmcb < &tscb->driveMemoryControlBlock[MAX_SIZE_OF_DMCB] ; dmcb++) {
if (dmcb->bAccessFlag == IS_IDENTIFY_ACCESS) {
bData_address = queryDriveDataAddress(tscb, dmcb);
if (bData_address == NULL) {
continue;
}
} else {
continue;
}
if (dmcb->bEndianFlag == IS_ENDIAN_8BIT) {
memcpy(bData_address, &tscb->bSectorBuffer[dmcb->dwAddress], dmcb->wSize);
} else if (dmcb->bEndianFlag == IS_ENDIAN_16BIT_LITTLE_TO_8BIT) {
memcpyWith16bitLittleEndianTo8bitConversion(bData_address, &tscb->bSectorBuffer[dmcb->dwAddress], dmcb->wSize);
} else if (dmcb->bEndianFlag == IS_ENDIAN_32BIT_LITTLE_TO_8BIT) {
memcpyWith32bitLittleEndianTo8bitConversion(bData_address, &tscb->bSectorBuffer[dmcb->dwAddress], dmcb->wSize);
} else if (dmcb->bEndianFlag == IS_ENDIAN_16BIT_LITTLE_TO_16BIT) {
memcpyWith16bitLittleEndianTo16bitConversion((Word *)bData_address, &tscb->bSectorBuffer[dmcb->dwAddress], dmcb->wSize);
} else if (dmcb->bEndianFlag == IS_ENDIAN_32BIT_LITTLE_TO_32BIT) {
memcpyWith32bitLittleEndianTo32bitConversion((Dword *)bData_address, &tscb->bSectorBuffer[dmcb->dwAddress], dmcb->wSize);
} else if (dmcb->bEndianFlag == IS_ENDIAN_16BIT_BIG_TO_16BIT) {
memcpyWith16bitBigEndianTo16bitConversion((Word *)bData_address, &tscb->bSectorBuffer[dmcb->dwAddress], dmcb->wSize);
} else {
ts_printf(__FILE__, __LINE__, "error - unknown endian flag value %d", dmcb->bEndianFlag);
tseb->isFatalError = 1;
return 1;
}
}
}
return rc;
}