1 #include <linux/slab.h>
2 #include "usb.h"
3 #include "scsiglue.h"
4 #include "transport.h"
5 //#include "init.h"
6
7 //#include "stdlib.h"
8 //#include "EUCR6SK.h"
9 #include "smcommon.h"
10 #include "smil.h"
11
12 void _Set_D_SsfdcRdCmd (BYTE);
13 void _Set_D_SsfdcRdAddr (BYTE);
14 void _Set_D_SsfdcRdChip (void);
15 void _Set_D_SsfdcRdStandby (void);
16 void _Start_D_SsfdcRdHwECC (void);
17 void _Stop_D_SsfdcRdHwECC (void);
18 void _Load_D_SsfdcRdHwECC (BYTE);
19 void _Set_D_SsfdcWrCmd (BYTE);
20 void _Set_D_SsfdcWrAddr (BYTE);
21 void _Set_D_SsfdcWrBlock (void);
22 void _Set_D_SsfdcWrStandby (void);
23 void _Start_D_SsfdcWrHwECC (void);
24 void _Load_D_SsfdcWrHwECC (BYTE);
25 int _Check_D_SsfdcBusy (WORD);
26 int _Check_D_SsfdcStatus (void);
27 void _Reset_D_SsfdcErr (void);
28 void _Read_D_SsfdcBuf (BYTE *);
29 void _Write_D_SsfdcBuf (BYTE *);
30 void _Read_D_SsfdcByte (BYTE *);
31 void _ReadRedt_D_SsfdcBuf (BYTE *);
32 void _WriteRedt_D_SsfdcBuf (BYTE *);
33 BYTE _Check_D_DevCode (BYTE);
34
35 void _Set_D_ECCdata (BYTE,BYTE *);
36 void _Calc_D_ECCdata (BYTE *);
37
38 //void SM_ReadDataWithDMA (PFDO_DEVICE_EXTENSION, BYTE *, WORD);
39 //void SM_WriteDataWithDMA (PFDO_DEVICE_EXTENSION, BYTE *, WORD);
40 //
41 struct SSFDCTYPE Ssfdc;
42 struct ADDRESS Media;
43 struct CIS_AREA CisArea;
44
45 BYTE EccBuf[6];
46 extern PBYTE SMHostAddr;
47 extern BYTE IsSSFDCCompliance;
48 extern BYTE IsXDCompliance;
49 extern DWORD ErrXDCode;
50
51 extern WORD ReadBlock;
52 extern WORD WriteBlock;
53
54 //KEVENT SM_DMADoneEvent;
55
56 #define EVEN 0 // Even Page for 256byte/page
57 #define ODD 1 // Odd Page for 256byte/page
58
59
60 //SmartMedia Redundant buffer data Control Subroutine
61 //----- Check_D_DataBlank() --------------------------------------------
Check_D_DataBlank(BYTE * redundant)62 int Check_D_DataBlank(BYTE *redundant)
63 {
64 char i;
65
66 for(i=0; i<REDTSIZE; i++)
67 if (*redundant++!=0xFF)
68 return(ERROR);
69
70 return(SUCCESS);
71 }
72
73 //----- Check_D_FailBlock() --------------------------------------------
Check_D_FailBlock(BYTE * redundant)74 int Check_D_FailBlock(BYTE *redundant)
75 {
76 redundant+=REDT_BLOCK;
77
78 if (*redundant==0xFF)
79 return(SUCCESS);
80 if (!*redundant)
81 return(ERROR);
82 if (hweight8(*redundant)<7)
83 return(ERROR);
84
85 return(SUCCESS);
86 }
87
88 //----- Check_D_DataStatus() -------------------------------------------
Check_D_DataStatus(BYTE * redundant)89 int Check_D_DataStatus(BYTE *redundant)
90 {
91 redundant+=REDT_DATA;
92
93 if (*redundant==0xFF)
94 return(SUCCESS);
95 if (!*redundant)
96 {
97 ErrXDCode = ERR_DataStatus;
98 return(ERROR);
99 }
100 else
101 ErrXDCode = NO_ERROR;
102
103 if (hweight8(*redundant)<5)
104 return(ERROR);
105
106 return(SUCCESS);
107 }
108
109 //----- Load_D_LogBlockAddr() ------------------------------------------
Load_D_LogBlockAddr(BYTE * redundant)110 int Load_D_LogBlockAddr(BYTE *redundant)
111 {
112 WORD addr1,addr2;
113 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
114 //ADDRESS_T bb = (ADDRESS_T) &Media;
115
116 addr1=(WORD)*(redundant+REDT_ADDR1H)*0x0100+(WORD)*(redundant+REDT_ADDR1L);
117 addr2=(WORD)*(redundant+REDT_ADDR2H)*0x0100+(WORD)*(redundant+REDT_ADDR2L);
118
119 if (addr1==addr2)
120 if ((addr1 &0xF000)==0x1000)
121 { Media.LogBlock=(addr1 &0x0FFF)/2; return(SUCCESS); }
122
123 if (hweight16((WORD)(addr1^addr2))!=0x01) return(ERROR);
124
125 if ((addr1 &0xF000)==0x1000)
126 if (!(hweight16(addr1) &0x01))
127 { Media.LogBlock=(addr1 &0x0FFF)/2; return(SUCCESS); }
128
129 if ((addr2 &0xF000)==0x1000)
130 if (!(hweight16(addr2) &0x01))
131 { Media.LogBlock=(addr2 &0x0FFF)/2; return(SUCCESS); }
132
133 return(ERROR);
134 }
135
136 //----- Clr_D_RedundantData() ------------------------------------------
Clr_D_RedundantData(BYTE * redundant)137 void Clr_D_RedundantData(BYTE *redundant)
138 {
139 char i;
140
141 for(i=0; i<REDTSIZE; i++)
142 *(redundant+i)=0xFF;
143 }
144
145 //----- Set_D_LogBlockAddr() -------------------------------------------
Set_D_LogBlockAddr(BYTE * redundant)146 void Set_D_LogBlockAddr(BYTE *redundant)
147 {
148 WORD addr;
149
150 *(redundant+REDT_BLOCK)=0xFF;
151 *(redundant+REDT_DATA) =0xFF;
152 addr=Media.LogBlock*2+0x1000;
153
154 if ((hweight16(addr)%2))
155 addr++;
156
157 *(redundant+REDT_ADDR1H)=*(redundant+REDT_ADDR2H)=(BYTE)(addr/0x0100);
158 *(redundant+REDT_ADDR1L)=*(redundant+REDT_ADDR2L)=(BYTE)addr;
159 }
160
161 //----- Set_D_FailBlock() ----------------------------------------------
Set_D_FailBlock(BYTE * redundant)162 void Set_D_FailBlock(BYTE *redundant)
163 {
164 char i;
165
166 for(i=0; i<REDTSIZE; i++)
167 *redundant++=(BYTE)((i==REDT_BLOCK)?0xF0:0xFF);
168 }
169
170 //----- Set_D_DataStaus() ----------------------------------------------
Set_D_DataStaus(BYTE * redundant)171 void Set_D_DataStaus(BYTE *redundant)
172 {
173 redundant+=REDT_DATA;
174 *redundant=0x00;
175 }
176
177 //SmartMedia Function Command Subroutine
178 // 6250 CMD 6
179 //----- Ssfdc_D_Reset() ------------------------------------------------
Ssfdc_D_Reset(struct us_data * us)180 void Ssfdc_D_Reset(struct us_data *us)
181 {
182 //NTSTATUS ntStatus = STATUS_SUCCESS;
183 //PBULK_CBW pBulkCbw = fdoExt->pBulkCbw;
184 //BYTE buf[0x200];
185
186 //printk("Ssfdc_D_Reset --- But do nothing !!\n");
187 return;
188 /* RtlZeroMemory(pBulkCbw, sizeof(struct _BULK_CBW));
189 pBulkCbw->dCBWSignature = CBW_SIGNTURE;
190 pBulkCbw->bCBWLun = CBW_LUN;
191 //pBulkCbw->dCBWDataTransferLength = 0x200;
192 pBulkCbw->bmCBWFlags = 0x80;
193 pBulkCbw->CBWCb[0] = 0xF2;
194 pBulkCbw->CBWCb[1] = 0x07;
195
196 ntStatus = ENE_SendScsiCmd(fdoExt, FDIR_READ, NULL);
197
198 if (!NT_SUCCESS(ntStatus))
199 {
200 ENE_Print("Ssfdc_D_Reset Fail !!\n");
201 //return ntStatus;
202 }*/
203 }
204
205 //----- Ssfdc_D_ReadCisSect() ------------------------------------------
Ssfdc_D_ReadCisSect(struct us_data * us,BYTE * buf,BYTE * redundant)206 int Ssfdc_D_ReadCisSect(struct us_data *us, BYTE *buf,BYTE *redundant)
207 {
208 BYTE zone,sector;
209 WORD block;
210 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
211 //ADDRESS_T bb = (ADDRESS_T) &Media;
212
213 zone=Media.Zone; block=Media.PhyBlock; sector=Media.Sector;
214 Media.Zone=0;
215 Media.PhyBlock=CisArea.PhyBlock;
216 Media.Sector=CisArea.Sector;
217
218 if (Ssfdc_D_ReadSect(us,buf,redundant))
219 {
220 Media.Zone=zone; Media.PhyBlock=block; Media.Sector=sector;
221 return(ERROR);
222 }
223
224 Media.Zone=zone; Media.PhyBlock=block; Media.Sector=sector;
225 return(SUCCESS);
226 }
227 /*
228 ////----- Ssfdc_D_WriteRedtMode() ----------------------------------------
229 //void Ssfdc_D_WriteRedtMode(void)
230 //{
231 // _Set_D_SsfdcRdCmd (RST_CHIP);
232 // _Check_D_SsfdcBusy (BUSY_RESET);
233 // _Set_D_SsfdcRdCmd (READ_REDT);
234 // _Check_D_SsfdcBusy (BUSY_READ);
235 // _Set_D_SsfdcRdStandby ();
236 //}
237 //
238 ////----- Ssfdc_D_ReadID() -----------------------------------------------
239 //void Ssfdc_D_ReadID(BYTE *buf, BYTE ReadID)
240 //{
241 // _Set_D_SsfdcRdCmd (ReadID);
242 // _Set_D_SsfdcRdChip ();
243 // _Read_D_SsfdcByte (buf++);
244 // _Read_D_SsfdcByte (buf++);
245 // _Read_D_SsfdcByte (buf++);
246 // _Read_D_SsfdcByte (buf);
247 // _Set_D_SsfdcRdStandby ();
248 //}
249 */
250 // 6250 CMD 1
251 //----- Ssfdc_D_ReadSect() ---------------------------------------------
Ssfdc_D_ReadSect(struct us_data * us,BYTE * buf,BYTE * redundant)252 int Ssfdc_D_ReadSect(struct us_data *us, BYTE *buf,BYTE *redundant)
253 {
254 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
255 int result;
256 WORD addr;
257
258 result = ENE_LoadBinCode(us, SM_RW_PATTERN);
259 if (result != USB_STOR_XFER_GOOD)
260 {
261 printk("Load SM RW Code Fail !!\n");
262 return USB_STOR_TRANSPORT_ERROR;
263 }
264
265 addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
266 addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
267
268 // Read sect data
269 memset(bcb, 0, sizeof(struct bulk_cb_wrap));
270 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
271 bcb->DataTransferLength = 0x200;
272 bcb->Flags = 0x80;
273 bcb->CDB[0] = 0xF1;
274 bcb->CDB[1] = 0x02;
275 bcb->CDB[4] = (BYTE)addr;
276 bcb->CDB[3] = (BYTE)(addr/0x0100);
277 bcb->CDB[2] = Media.Zone/2;
278
279 result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0);
280 if (result != USB_STOR_XFER_GOOD)
281 return USB_STOR_TRANSPORT_ERROR;
282
283 // Read redundant
284 memset(bcb, 0, sizeof(struct bulk_cb_wrap));
285 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
286 bcb->DataTransferLength = 0x10;
287 bcb->Flags = 0x80;
288 bcb->CDB[0] = 0xF1;
289 bcb->CDB[1] = 0x03;
290 bcb->CDB[4] = (BYTE)addr;
291 bcb->CDB[3] = (BYTE)(addr/0x0100);
292 bcb->CDB[2] = Media.Zone/2;
293 bcb->CDB[8] = 0;
294 bcb->CDB[9] = 1;
295
296 result = ENE_SendScsiCmd(us, FDIR_READ, redundant, 0);
297 if (result != USB_STOR_XFER_GOOD)
298 return USB_STOR_TRANSPORT_ERROR;
299
300 return USB_STOR_TRANSPORT_GOOD;
301 }
302
303 //----- Ssfdc_D_ReadBlock() ---------------------------------------------
Ssfdc_D_ReadBlock(struct us_data * us,WORD count,BYTE * buf,BYTE * redundant)304 int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant)
305 {
306 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
307 int result;
308 WORD addr;
309
310 //printk("Ssfdc_D_ReadBlock\n");
311 result = ENE_LoadBinCode(us, SM_RW_PATTERN);
312 if (result != USB_STOR_XFER_GOOD)
313 {
314 printk("Load SM RW Code Fail !!\n");
315 return USB_STOR_TRANSPORT_ERROR;
316 }
317
318 addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
319 addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
320
321 // Read sect data
322 memset(bcb, 0, sizeof(struct bulk_cb_wrap));
323 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
324 bcb->DataTransferLength = 0x200*count;
325 bcb->Flags = 0x80;
326 bcb->CDB[0] = 0xF1;
327 bcb->CDB[1] = 0x02;
328 bcb->CDB[4] = (BYTE)addr;
329 bcb->CDB[3] = (BYTE)(addr/0x0100);
330 bcb->CDB[2] = Media.Zone/2;
331
332 result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0);
333 if (result != USB_STOR_XFER_GOOD)
334 return USB_STOR_TRANSPORT_ERROR;
335
336 // Read redundant
337 memset(bcb, 0, sizeof(struct bulk_cb_wrap));
338 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
339 bcb->DataTransferLength = 0x10;
340 bcb->Flags = 0x80;
341 bcb->CDB[0] = 0xF1;
342 bcb->CDB[1] = 0x03;
343 bcb->CDB[4] = (BYTE)addr;
344 bcb->CDB[3] = (BYTE)(addr/0x0100);
345 bcb->CDB[2] = Media.Zone/2;
346 bcb->CDB[8] = 0;
347 bcb->CDB[9] = 1;
348
349 result = ENE_SendScsiCmd(us, FDIR_READ, redundant, 0);
350 if (result != USB_STOR_XFER_GOOD)
351 return USB_STOR_TRANSPORT_ERROR;
352
353 return USB_STOR_TRANSPORT_GOOD;
354 }
355 /*
356 ////----- Ssfdc_D_ReadSect_DMA() ---------------------------------------------
357 //int Ssfdc_D_ReadSect_DMA(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf,BYTE *redundant)
358 //{
359 // WORD SectByteCount, addr;
360 // DWORD Buffer[4];
361 // WORD len;
362 //
363 // if (!_Hw_D_ChkCardIn())
364 // return(ERROR);
365 // addr=(WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
366 // addr=addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
367 // // cycle starting address
368 // SM_STARTADDR_LSB = 0x00;
369 // SM_STARTADDR_IISB = (BYTE)addr;
370 // SM_STARTADDR_IIISB = (BYTE)(addr/0x0100);
371 // SM_STARTADDR_MSB = Media.Zone/2;
372 //
373 // //Sector byte count = 0x200(DMA)
374 // SectByteCount = 0x20f;
375 // SM_BYTECNT_LO = (BYTE)SectByteCount;
376 // SM_CMD_CTRL3 = (SM_CMD_CTRL3 & 0xFC) | (BYTE)(SectByteCount/0x0100);
377 // if ( ((fdoExt->ChipID==READER_CB712)&&(fdoExt->RevID==CHIP_A)) || fdoExt->IsHibernate )
378 // SM_FIFO_CTRL = (SM_APB08_MASK | SM_DMAEN_MASK | SM_DMA_UPSTREAM_MASK | SM_FIFOSHLDVLU_8_MASK);
379 // else
380 // SM_FIFO_CTRL = (SM_APB32_MASK | SM_DMAEN_MASK | SM_DMA_UPSTREAM_MASK | SM_FIFOSHLDVLU_8_MASK);
381 //
382 // _Hw_D_EccRdReset();
383 // _Hw_D_EccRdStart();
384 //
385 // SM_CMD_CTRL1 = (SM_CMD_READ_1);
386 // SM_CMD_CTRL1 = (SM_CMD_READ_1 | SM_CMD_START_BIT);
387 //
388 // SectByteCount = 0x1ff;
389 // //SM_ReadDataWithDMA(fdoExt, buf, SectByteCount);
390 // //_ReadRedt_D_SsfdcBuf(redundant);
391 // len = 0x1000 - ((WORD)(buf) & 0x0FFF);
392 // if (len < 0x200)
393 // {
394 // SM_ReadDataWithDMA(fdoExt, buf, len-1);
395 // SM_ReadDataWithDMA(fdoExt, buf+len, SectByteCount-len);
396 // //ENE_Print("Read DMA !!! buf1 = %p, len = %x, buf2 = %p\n", buf, len, buf+len);
397 // }
398 // else
399 // SM_ReadDataWithDMA(fdoExt, buf, SectByteCount);
400 //
401 // if ( ((fdoExt->ChipID==READER_CB712)&&(fdoExt->RevID==CHIP_A)) || fdoExt->IsHibernate )
402 // {
403 // _ReadRedt_D_SsfdcBuf(redundant);
404 // }
405 // else
406 // {
407 // Buffer[0] = READ_PORT_DWORD(SM_REG_DATA);
408 // Buffer[1] = READ_PORT_DWORD(SM_REG_DATA);
409 // Buffer[2] = READ_PORT_DWORD(SM_REG_DATA);
410 // Buffer[3] = READ_PORT_DWORD(SM_REG_DATA);
411 // memcpy(redundant, Buffer, 0x10);
412 // }
413 //
414 // while ( _Hw_D_ChkCardIn() )
415 // {
416 // if((READ_PORT_BYTE(SM_REG_INT_STATUS) & 0x10))
417 // {
418 // WRITE_PORT_BYTE(SM_REG_INT_STATUS, 0x10);
419 // break;
420 // }
421 // }
422 // _Hw_D_EccRdStop();
423 // _Hw_D_SetRdStandby();
424 // _Load_D_SsfdcRdHwECC(EVEN);
425 //
426 // _Calc_D_ECCdata(buf);
427 // _Set_D_SsfdcRdStandby();
428 //
429 // if (!_Hw_D_ChkCardIn())
430 // return(ERROR);
431 // return(SUCCESS);
432 //}
433 //
434 ////----- Ssfdc_D_ReadSect_PIO() ---------------------------------------------
435 //int Ssfdc_D_ReadSect_PIO(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf,BYTE *redundant)
436 //{
437 // _Set_D_SsfdcRdCmd(READ);
438 // _Set_D_SsfdcRdAddr(EVEN);
439 //
440 // if (_Check_D_SsfdcBusy(BUSY_READ))
441 // { _Reset_D_SsfdcErr(); return(ERROR); }
442 //
443 // _Start_D_SsfdcRdHwECC();
444 // _Read_D_SsfdcBuf(buf);
445 // _Stop_D_SsfdcRdHwECC();
446 // _ReadRedt_D_SsfdcBuf(redundant);
447 // _Load_D_SsfdcRdHwECC(EVEN);
448 //
449 // if (_Check_D_SsfdcBusy(BUSY_READ))
450 // { _Reset_D_SsfdcErr(); return(ERROR); }
451 //
452 // _Calc_D_ECCdata(buf);
453 // _Set_D_SsfdcRdStandby();
454 // return(SUCCESS);
455 //}
456
457 // 6250 CMD 3
458 //----- Ssfdc_D_WriteSect() --------------------------------------------
459 int Ssfdc_D_WriteSect(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf,BYTE *redundant)
460 {
461 PBULK_CBW pBulkCbw = fdoExt->pBulkCbw;
462 NTSTATUS ntStatus;
463 WORD addr;
464
465 //ENE_Print("SMILSUB --- Ssfdc_D_WriteSect\n");
466 ENE_LoadBinCode(fdoExt, SM_RW_PATTERN);
467
468 addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
469 addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
470
471 // Write sect data
472 RtlZeroMemory(pBulkCbw, sizeof(struct _BULK_CBW));
473 pBulkCbw->dCBWSignature = CBW_SIGNTURE;
474 pBulkCbw->bCBWLun = CBW_LUN;
475 pBulkCbw->dCBWDataTransferLength = 0x200;
476 pBulkCbw->bmCBWFlags = 0x00;
477 pBulkCbw->CBWCb[0] = 0xF0;
478 pBulkCbw->CBWCb[1] = 0x04;
479 //pBulkCbw->CBWCb[4] = (BYTE)addr;
480 //pBulkCbw->CBWCb[3] = (BYTE)(addr/0x0100);
481 //pBulkCbw->CBWCb[2] = Media.Zone/2;
482 //pBulkCbw->CBWCb[5] = *(redundant+REDT_ADDR1H);
483 //pBulkCbw->CBWCb[6] = *(redundant+REDT_ADDR1L);
484 pBulkCbw->CBWCb[7] = (BYTE)addr;
485 pBulkCbw->CBWCb[6] = (BYTE)(addr/0x0100);
486 pBulkCbw->CBWCb[5] = Media.Zone/2;
487 pBulkCbw->CBWCb[8] = *(redundant+REDT_ADDR1H);
488 pBulkCbw->CBWCb[9] = *(redundant+REDT_ADDR1L);
489
490 ntStatus = ENE_SendScsiCmd(fdoExt, FDIR_WRITE, buf);
491
492 if (!NT_SUCCESS(ntStatus))
493 return(ERROR);
494
495 // // For Test
496 // {
497 // BYTE bf[0x200], rdd[0x10];
498 // ULONG i;
499 //
500 // RtlZeroMemory(bf, 0x200);
501 // RtlZeroMemory(rdd, 0x10);
502 // ntStatus = SM_ReadBlock(fdoExt, bf, rdd);
503 // for (i=0; i<0x200; i++)
504 // {
505 // if (buf[i] != bf[i])
506 // ENE_Print("buf[%x] = %x, bf[%x] = %x\n", buf, bf);
507 // }
508 // if (!NT_SUCCESS(ntStatus))
509 // ENE_Print("Error\n");
510 // }
511
512 return(SUCCESS);
513 }
514 */
515 //----- Ssfdc_D_CopyBlock() --------------------------------------------
Ssfdc_D_CopyBlock(struct us_data * us,WORD count,BYTE * buf,BYTE * redundant)516 int Ssfdc_D_CopyBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant)
517 {
518 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
519 int result;
520 //PBULK_CBW pBulkCbw = fdoExt->pBulkCbw;
521 //NTSTATUS ntStatus;
522 WORD ReadAddr, WriteAddr;
523
524 //printk("Ssfdc_D_WriteSect --- ZONE = %x, ReadBlock = %x, WriteBlock = %x\n", Media.Zone, ReadBlock, WriteBlock);
525
526 result = ENE_LoadBinCode(us, SM_RW_PATTERN);
527 if (result != USB_STOR_XFER_GOOD)
528 {
529 printk("Load SM RW Code Fail !!\n");
530 return USB_STOR_TRANSPORT_ERROR;
531 }
532
533 ReadAddr = (WORD)Media.Zone*Ssfdc.MaxBlocks+ReadBlock;
534 ReadAddr = ReadAddr*(WORD)Ssfdc.MaxSectors;
535 WriteAddr = (WORD)Media.Zone*Ssfdc.MaxBlocks+WriteBlock;
536 WriteAddr = WriteAddr*(WORD)Ssfdc.MaxSectors;
537
538 // Write sect data
539 memset(bcb, 0, sizeof(struct bulk_cb_wrap));
540 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
541 bcb->DataTransferLength = 0x200*count;
542 bcb->Flags = 0x00;
543 bcb->CDB[0] = 0xF0;
544 bcb->CDB[1] = 0x08;
545 bcb->CDB[7] = (BYTE)WriteAddr;
546 bcb->CDB[6] = (BYTE)(WriteAddr/0x0100);
547 bcb->CDB[5] = Media.Zone/2;
548 bcb->CDB[8] = *(redundant+REDT_ADDR1H);
549 bcb->CDB[9] = *(redundant+REDT_ADDR1L);
550 bcb->CDB[10] = Media.Sector;
551
552 if (ReadBlock != NO_ASSIGN)
553 {
554 bcb->CDB[4] = (BYTE)ReadAddr;
555 bcb->CDB[3] = (BYTE)(ReadAddr/0x0100);
556 bcb->CDB[2] = Media.Zone/2;
557 }
558 else
559 bcb->CDB[11] = 1;
560
561 result = ENE_SendScsiCmd(us, FDIR_WRITE, buf, 0);
562 if (result != USB_STOR_XFER_GOOD)
563 return USB_STOR_TRANSPORT_ERROR;
564
565 return USB_STOR_TRANSPORT_GOOD;
566 }
567 /*
568 //----- Ssfdc_D_WriteBlock() --------------------------------------------
569 int Ssfdc_D_WriteBlock(PFDO_DEVICE_EXTENSION fdoExt, WORD count, BYTE *buf,BYTE *redundant)
570 {
571 PBULK_CBW pBulkCbw = fdoExt->pBulkCbw;
572 NTSTATUS ntStatus;
573 WORD addr;
574
575 //ENE_Print("SMILSUB --- Ssfdc_D_WriteSect\n");
576 ENE_LoadBinCode(fdoExt, SM_RW_PATTERN);
577
578 addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
579 addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
580
581 // Write sect data
582 RtlZeroMemory(pBulkCbw, sizeof(struct _BULK_CBW));
583 pBulkCbw->dCBWSignature = CBW_SIGNTURE;
584 pBulkCbw->bCBWLun = CBW_LUN;
585 pBulkCbw->dCBWDataTransferLength = 0x200*count;
586 pBulkCbw->bmCBWFlags = 0x00;
587 pBulkCbw->CBWCb[0] = 0xF0;
588 pBulkCbw->CBWCb[1] = 0x04;
589 pBulkCbw->CBWCb[7] = (BYTE)addr;
590 pBulkCbw->CBWCb[6] = (BYTE)(addr/0x0100);
591 pBulkCbw->CBWCb[5] = Media.Zone/2;
592 pBulkCbw->CBWCb[8] = *(redundant+REDT_ADDR1H);
593 pBulkCbw->CBWCb[9] = *(redundant+REDT_ADDR1L);
594
595 ntStatus = ENE_SendScsiCmd(fdoExt, FDIR_WRITE, buf);
596
597 if (!NT_SUCCESS(ntStatus))
598 return(ERROR);
599
600 // // For Test
601 // {
602 // BYTE bf[0x200], rdd[0x10];
603 // ULONG i;
604 //
605 // RtlZeroMemory(bf, 0x200);
606 // RtlZeroMemory(rdd, 0x10);
607 // ntStatus = SM_ReadBlock(fdoExt, bf, rdd);
608 // for (i=0; i<0x200; i++)
609 // {
610 // if (buf[i] != bf[i])
611 // ENE_Print("buf[%x] = %x, bf[%x] = %x\n", buf, bf);
612 // }
613 // if (!NT_SUCCESS(ntStatus))
614 // ENE_Print("Error\n");
615 // }
616
617 return(SUCCESS);
618 }
619 //
620 ////----- Ssfdc_D_WriteSect_DMA() --------------------------------------------
621 //int Ssfdc_D_WriteSect_DMA(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf,BYTE *redundant)
622 //{
623 // WORD SectByteCount, addr;
624 // DWORD Buffer[4];
625 // WORD len;
626 //
627 // if (!_Hw_D_ChkCardIn())
628 // return(ERROR);
629 // addr=(WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
630 // addr=addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
631 // // cycle starting address
632 // SM_STARTADDR_LSB = 0x00;
633 // SM_STARTADDR_IISB = (BYTE)addr;
634 // SM_STARTADDR_IIISB = (BYTE)(addr/0x0100);
635 // SM_STARTADDR_MSB = Media.Zone/2;
636 //
637 // //Sector byte count (DMA)
638 // SectByteCount = 0x20f;
639 // SM_BYTECNT_LO = (BYTE)SectByteCount;
640 // SM_CMD_CTRL3 = (SM_CMD_CTRL3 & 0xFC) | 0x20 | (BYTE)(SectByteCount/0x0100);
641 // if ( ((fdoExt->ChipID==READER_CB712)&&(fdoExt->RevID==CHIP_A)) || fdoExt->IsHibernate )
642 // SM_FIFO_CTRL = (SM_APB08_MASK | SM_DMAEN_MASK | SM_DMA_DOWNSTREAM_MASK | SM_FIFOSHLDVLU_8_MASK);
643 // else
644 // SM_FIFO_CTRL = (SM_APB32_MASK | SM_DMAEN_MASK | SM_DMA_DOWNSTREAM_MASK | SM_FIFOSHLDVLU_8_MASK);
645 //
646 // _Hw_D_EccRdReset();
647 // _Hw_D_EccRdStart();
648 //
649 // SM_CMD_CTRL1 = SM_CMD_PAGPRGM_TRUE;
650 // SM_CMD_CTRL1 = (SM_CMD_PAGPRGM_TRUE | SM_CMD_START_BIT);
651 //
652 // SectByteCount = 0x1ff;
653 // //SM_WriteDataWithDMA(fdoExt, buf, SectByteCount);
654 // //_WriteRedt_D_SsfdcBuf(redundant);
655 // len = 0x1000 - ((WORD)(buf) & 0x0FFF);
656 // if (len < 0x200)
657 // {
658 // SM_WriteDataWithDMA(fdoExt, buf, len-1);
659 // SM_WriteDataWithDMA(fdoExt, buf+len, SectByteCount-len);
660 // //ENE_Print("Read DMA !!! buf1 = %p, len = %x, buf2 = %p\n", buf, len, buf+len);
661 // }
662 // else
663 // SM_WriteDataWithDMA(fdoExt, buf, SectByteCount);
664 //
665 // //T1 = (ULONGLONG)buf & 0xFFFFFFFFFFFFF000;
666 // //T2 = ((ULONGLONG)buf + 0x1FF) & 0xFFFFFFFFFFFFF000;
667 // //if (T1 != T2)
668 // // ENE_Print("Ssfdc_D_WriteSect_DMA !!! buf = %p, T1 = %p, T2 = %p\n", buf, T1, T2);
669 // //if (T2-T1)
670 // //{
671 // // l1 = (WORD)(T2 - (ULONGLONG)buf);
672 // // SM_WriteDataWithDMA(fdoExt, buf, l1-1);
673 // // SM_WriteDataWithDMA(fdoExt, (PBYTE)T2, SectByteCount-l1);
674 // //}
675 // //else
676 // // SM_WriteDataWithDMA(fdoExt, buf, SectByteCount);
677 //
678 // if ( ((fdoExt->ChipID==READER_CB712)&&(fdoExt->RevID==CHIP_A)) || fdoExt->IsHibernate )
679 // {
680 // _WriteRedt_D_SsfdcBuf(redundant);
681 // }
682 // else
683 // {
684 // memcpy(Buffer, redundant, 0x10);
685 // WRITE_PORT_DWORD(SM_REG_DATA, Buffer[0]);
686 // WRITE_PORT_DWORD(SM_REG_DATA, Buffer[1]);
687 // WRITE_PORT_DWORD(SM_REG_DATA, Buffer[2]);
688 // WRITE_PORT_DWORD(SM_REG_DATA, Buffer[3]);
689 // }
690 //
691 // while ( _Hw_D_ChkCardIn() )
692 // {
693 // if ((READ_PORT_BYTE(SM_REG_INT_STATUS) & 0x10))
694 // {
695 // WRITE_PORT_BYTE(SM_REG_INT_STATUS, 0x10);
696 // break;
697 // }
698 // }
699 // _Hw_D_EccRdStop();
700 // _Hw_D_SetRdStandby();
701 //
702 // _Set_D_SsfdcWrStandby();
703 // _Set_D_SsfdcRdStandby();
704 // if (!_Hw_D_ChkCardIn())
705 // return(ERROR);
706 //
707 // return(SUCCESS);
708 //}
709 //
710 ////----- Ssfdc_D_WriteSect_PIO() --------------------------------------------
711 //int Ssfdc_D_WriteSect_PIO(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf,BYTE *redundant)
712 //{
713 // _Calc_D_ECCdata(buf);
714 // _Set_D_SsfdcWrCmd(WRDATA);
715 // _Set_D_SsfdcWrAddr(EVEN);
716 // _Start_D_SsfdcWrHwECC();
717 //
718 // _Write_D_SsfdcBuf(buf);
719 //
720 // _Load_D_SsfdcWrHwECC(EVEN);
721 // _Set_D_ECCdata(EVEN,redundant);
722 //
723 // _WriteRedt_D_SsfdcBuf(redundant);
724 //
725 // _Set_D_SsfdcWrCmd(WRITE);
726 //
727 // if (_Check_D_SsfdcBusy(BUSY_PROG))
728 // { _Reset_D_SsfdcErr(); return(ERROR); }
729 //
730 // _Set_D_SsfdcWrStandby();
731 // _Set_D_SsfdcRdStandby();
732 // return(SUCCESS);
733 //}
734 */
735 //----- Ssfdc_D_WriteSectForCopy() -------------------------------------
Ssfdc_D_WriteSectForCopy(struct us_data * us,BYTE * buf,BYTE * redundant)736 int Ssfdc_D_WriteSectForCopy(struct us_data *us, BYTE *buf, BYTE *redundant)
737 {
738 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
739 int result;
740 //PBULK_CBW pBulkCbw = fdoExt->pBulkCbw;
741 //NTSTATUS ntStatus;
742 WORD addr;
743
744 //printk("SMILSUB --- Ssfdc_D_WriteSectForCopy\n");
745 result = ENE_LoadBinCode(us, SM_RW_PATTERN);
746 if (result != USB_STOR_XFER_GOOD)
747 {
748 printk("Load SM RW Code Fail !!\n");
749 return USB_STOR_TRANSPORT_ERROR;
750 }
751
752
753 addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
754 addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
755
756 // Write sect data
757 memset(bcb, 0, sizeof(struct bulk_cb_wrap));
758 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
759 bcb->DataTransferLength = 0x200;
760 bcb->Flags = 0x00;
761 bcb->CDB[0] = 0xF0;
762 bcb->CDB[1] = 0x04;
763 bcb->CDB[7] = (BYTE)addr;
764 bcb->CDB[6] = (BYTE)(addr/0x0100);
765 bcb->CDB[5] = Media.Zone/2;
766 bcb->CDB[8] = *(redundant+REDT_ADDR1H);
767 bcb->CDB[9] = *(redundant+REDT_ADDR1L);
768
769 result = ENE_SendScsiCmd(us, FDIR_WRITE, buf, 0);
770 if (result != USB_STOR_XFER_GOOD)
771 return USB_STOR_TRANSPORT_ERROR;
772
773 return USB_STOR_TRANSPORT_GOOD;
774 }
775
776 // 6250 CMD 5
777 //----- Ssfdc_D_EraseBlock() -------------------------------------------
Ssfdc_D_EraseBlock(struct us_data * us)778 int Ssfdc_D_EraseBlock(struct us_data *us)
779 {
780 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
781 int result;
782 WORD addr;
783
784 result = ENE_LoadBinCode(us, SM_RW_PATTERN);
785 if (result != USB_STOR_XFER_GOOD)
786 {
787 printk("Load SM RW Code Fail !!\n");
788 return USB_STOR_TRANSPORT_ERROR;
789 }
790
791 addr=(WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
792 addr=addr*(WORD)Ssfdc.MaxSectors;
793
794 memset(bcb, 0, sizeof(struct bulk_cb_wrap));
795 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
796 bcb->DataTransferLength = 0x200;
797 bcb->Flags = 0x80;
798 bcb->CDB[0] = 0xF2;
799 bcb->CDB[1] = 0x06;
800 bcb->CDB[7] = (BYTE)addr;
801 bcb->CDB[6] = (BYTE)(addr/0x0100);
802 bcb->CDB[5] = Media.Zone/2;
803
804 result = ENE_SendScsiCmd(us, FDIR_READ, NULL, 0);
805 if (result != USB_STOR_XFER_GOOD)
806 return USB_STOR_TRANSPORT_ERROR;
807
808 return USB_STOR_TRANSPORT_GOOD;
809 }
810
811 // 6250 CMD 2
812 //----- Ssfdc_D_ReadRedtData() -----------------------------------------
Ssfdc_D_ReadRedtData(struct us_data * us,BYTE * redundant)813 int Ssfdc_D_ReadRedtData(struct us_data *us, BYTE *redundant)
814 {
815 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
816 int result;
817 WORD addr;
818 BYTE *buf;
819
820 result = ENE_LoadBinCode(us, SM_RW_PATTERN);
821 if (result != USB_STOR_XFER_GOOD)
822 {
823 printk("Load SM RW Code Fail !!\n");
824 return USB_STOR_TRANSPORT_ERROR;
825 }
826
827 addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
828 addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
829
830 memset(bcb, 0, sizeof(struct bulk_cb_wrap));
831 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
832 bcb->DataTransferLength = 0x10;
833 bcb->Flags = 0x80;
834 bcb->CDB[0] = 0xF1;
835 bcb->CDB[1] = 0x03;
836 bcb->CDB[4] = (BYTE)addr;
837 bcb->CDB[3] = (BYTE)(addr/0x0100);
838 bcb->CDB[2] = Media.Zone/2;
839 bcb->CDB[8] = 0;
840 bcb->CDB[9] = 1;
841
842 buf = kmalloc(0x10, GFP_KERNEL);
843 //result = ENE_SendScsiCmd(us, FDIR_READ, redundant, 0);
844 result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0);
845 memcpy(redundant, buf, 0x10);
846 kfree(buf);
847 if (result != USB_STOR_XFER_GOOD)
848 return USB_STOR_TRANSPORT_ERROR;
849
850 return USB_STOR_TRANSPORT_GOOD;
851 }
852
853 // 6250 CMD 4
854 //----- Ssfdc_D_WriteRedtData() ----------------------------------------
Ssfdc_D_WriteRedtData(struct us_data * us,BYTE * redundant)855 int Ssfdc_D_WriteRedtData(struct us_data *us, BYTE *redundant)
856 {
857 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
858 int result;
859 //PBULK_CBW pBulkCbw = fdoExt->pBulkCbw;
860 //NTSTATUS ntStatus;
861 WORD addr;
862
863 result = ENE_LoadBinCode(us, SM_RW_PATTERN);
864 if (result != USB_STOR_XFER_GOOD)
865 {
866 printk("Load SM RW Code Fail !!\n");
867 return USB_STOR_TRANSPORT_ERROR;
868 }
869
870 addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
871 addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
872
873 memset(bcb, 0, sizeof(struct bulk_cb_wrap));
874 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
875 bcb->DataTransferLength = 0x10;
876 bcb->Flags = 0x80;
877 bcb->CDB[0] = 0xF2;
878 bcb->CDB[1] = 0x05;
879 bcb->CDB[7] = (BYTE)addr;
880 bcb->CDB[6] = (BYTE)(addr/0x0100);
881 bcb->CDB[5] = Media.Zone/2;
882 bcb->CDB[8] = *(redundant+REDT_ADDR1H);
883 bcb->CDB[9] = *(redundant+REDT_ADDR1L);
884
885 result = ENE_SendScsiCmd(us, FDIR_READ, NULL, 0);
886 if (result != USB_STOR_XFER_GOOD)
887 return USB_STOR_TRANSPORT_ERROR;
888
889 return USB_STOR_TRANSPORT_GOOD;
890 }
891
892 //----- Ssfdc_D_CheckStatus() ------------------------------------------
Ssfdc_D_CheckStatus(void)893 int Ssfdc_D_CheckStatus(void)
894 {
895 // Driver ����
896 return(SUCCESS);
897 //_Set_D_SsfdcRdCmd(RDSTATUS);
898 //
899 //if (_Check_D_SsfdcStatus())
900 //{ _Set_D_SsfdcRdStandby(); return(ERROR); }
901 //
902 //_Set_D_SsfdcRdStandby();
903 //return(SUCCESS);
904 }
905 /*
906 ////NAND Memory (SmartMedia) Control Subroutine for Read Data
907 ////----- _Set_D_SsfdcRdCmd() --------------------------------------------
908 //void _Set_D_SsfdcRdCmd(BYTE cmd)
909 //{
910 // _Hw_D_SetRdCmd();
911 // _Hw_D_OutData(cmd);
912 // _Hw_D_SetRdData();
913 //}
914 //
915 ////----- _Set_D_SsfdcRdAddr() -------------------------------------------
916 //void _Set_D_SsfdcRdAddr(BYTE add)
917 //{
918 // WORD addr;
919 // SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
920 // ADDRESS_T bb = (ADDRESS_T) &Media;
921 //
922 // addr=(WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
923 // addr=addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
924 //
925 // //if ((Ssfdc.Attribute &MPS)==PS256) // for 256byte/page
926 // // addr=addr*2+(WORD)add;
927 //
928 // _Hw_D_SetRdAddr();
929 // _Hw_D_OutData(0x00);
930 // _Hw_D_OutData((BYTE)addr);
931 // _Hw_D_OutData((BYTE)(addr/0x0100));
932 //
933 // if ((Ssfdc.Attribute &MADC)==AD4CYC)
934 // _Hw_D_OutData((BYTE)(Media.Zone/2)); // Patch
935 //
936 // _Hw_D_SetRdData();
937 //}
938 //
939 ////----- _Set_D_SsfdcRdChip() -------------------------------------------
940 //void _Set_D_SsfdcRdChip(void)
941 //{
942 // _Hw_D_SetRdAddr();
943 // _Hw_D_OutData(0x00);
944 // _Hw_D_SetRdData();
945 //}
946 //
947 ////----- _Set_D_SsfdcRdStandby() ----------------------------------------
948 //void _Set_D_SsfdcRdStandby(void)
949 //{
950 // _Hw_D_SetRdStandby();
951 //}
952 //
953 ////----- _Start_D_SsfdcRdHwECC() ----------------------------------------
954 //void _Start_D_SsfdcRdHwECC(void)
955 //{
956 //#ifdef HW_ECC_SUPPORTED
957 // _Hw_D_EccRdReset();
958 // _Hw_D_InData();
959 // _Hw_D_EccRdStart();
960 //#endif
961 //}
962 //
963 ////----- _Stop_D_SsfdcRdHwECC() -----------------------------------------
964 //void _Stop_D_SsfdcRdHwECC(void)
965 //{
966 //#ifdef HW_ECC_SUPPORTED
967 // _Hw_D_EccRdStop();
968 //#endif
969 //}
970 //
971 ////----- _Load_D_SsfdcRdHwECC() -----------------------------------------
972 //void _Load_D_SsfdcRdHwECC(BYTE add)
973 //{
974 //#ifdef HW_ECC_SUPPORTED
975 // _Hw_D_EccRdRead();
976 // //if (!(add==ODD && (Ssfdc.Attribute &MPS)==PS256))
977 // {
978 // EccBuf[0]=_Hw_D_InData();
979 // EccBuf[1]=_Hw_D_InData();
980 // EccBuf[2]=_Hw_D_InData();
981 // }
982 //
983 // //if (!(add==EVEN && (Ssfdc.Attribute &MPS)==PS256))
984 // {
985 // EccBuf[3]=_Hw_D_InData();
986 // EccBuf[4]=_Hw_D_InData();
987 // EccBuf[5]=_Hw_D_InData();
988 // }
989 //
990 // _Hw_D_EccRdStop();
991 //#endif
992 //}
993 //
994 ////NAND Memory (SmartMedia) Control Subroutine for Write Data
995 //
996 ////----- _Set_D_SsfdcWrCmd() -----------------------------------------
997 //void _Set_D_SsfdcWrCmd(BYTE cmd)
998 //{
999 // _Hw_D_SetWrCmd();
1000 // _Hw_D_OutData(cmd);
1001 // _Hw_D_SetWrData();
1002 //}
1003 //
1004 ////----- _Set_D_SsfdcWrAddr() -----------------------------------------
1005 //void _Set_D_SsfdcWrAddr(BYTE add)
1006 //{
1007 // WORD addr;
1008 // SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1009 // ADDRESS_T bb = (ADDRESS_T) &Media;
1010 //
1011 // addr=(WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
1012 // addr=addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
1013 //
1014 // //if ((Ssfdc.Attribute &MPS)==PS256) // for 256byte/page
1015 // // addr=addr*2+(WORD)add;
1016 //
1017 // _Hw_D_SetWrAddr();
1018 // _Hw_D_OutData(0x00);
1019 // _Hw_D_OutData((BYTE)addr);
1020 // _Hw_D_OutData((BYTE)(addr/0x0100));
1021 //
1022 // if ((Ssfdc.Attribute &MADC)==AD4CYC)
1023 // _Hw_D_OutData((BYTE)(Media.Zone/2)); // Patch
1024 //
1025 // _Hw_D_SetWrData();
1026 //}
1027 //
1028 ////----- _Set_D_SsfdcWrBlock() -----------------------------------------
1029 //void _Set_D_SsfdcWrBlock(void)
1030 //{
1031 // WORD addr;
1032 // SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1033 // ADDRESS_T bb = (ADDRESS_T) &Media;
1034 //
1035 // addr=(WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
1036 // addr=addr*(WORD)Ssfdc.MaxSectors;
1037 //
1038 // //if ((Ssfdc.Attribute &MPS)==PS256) // for 256byte/page
1039 // // addr=addr*2;
1040 //
1041 // _Hw_D_SetWrAddr();
1042 // _Hw_D_OutData((BYTE)addr);
1043 // _Hw_D_OutData((BYTE)(addr/0x0100));
1044 //
1045 // if ((Ssfdc.Attribute &MADC)==AD4CYC)
1046 // _Hw_D_OutData((BYTE)(Media.Zone/2)); // Patch
1047 //
1048 // _Hw_D_SetWrData();
1049 //}
1050 //
1051 ////----- _Set_D_SsfdcWrStandby() -----------------------------------------
1052 //void _Set_D_SsfdcWrStandby(void)
1053 //{
1054 // _Hw_D_SetWrStandby();
1055 //}
1056 //
1057 ////----- _Start_D_SsfdcWrHwECC() -----------------------------------------
1058 //void _Start_D_SsfdcWrHwECC(void)
1059 //{
1060 //#ifdef HW_ECC_SUPPORTED
1061 // _Hw_D_EccWrReset();
1062 // _Hw_D_InData();
1063 // _Hw_D_EccWrStart();
1064 //#endif
1065 //}
1066 //
1067 ////----- _Load_D_SsfdcWrHwECC() -----------------------------------------
1068 //void _Load_D_SsfdcWrHwECC(BYTE add)
1069 //{
1070 //#ifdef HW_ECC_SUPPORTED
1071 // _Hw_D_EccWrRead();
1072 // //if (!(add==ODD && (Ssfdc.Attribute &MPS)==PS256))
1073 // {
1074 // EccBuf[0]=_Hw_D_InData();
1075 // EccBuf[1]=_Hw_D_InData();
1076 // EccBuf[2]=_Hw_D_InData();
1077 // }
1078 //
1079 // //if (!(add==EVEN && (Ssfdc.Attribute &MPS)==PS256))
1080 // {
1081 // EccBuf[3]=_Hw_D_InData();
1082 // EccBuf[4]=_Hw_D_InData();
1083 // EccBuf[5]=_Hw_D_InData();
1084 // }
1085 //
1086 // _Hw_D_EccWrStop();
1087 //#endif
1088 //}
1089 //
1090 ////NAND Memory (SmartMedia) Control Subroutine
1091 ////----- _Check_D_SsfdcBusy() -------------------------------------------
1092 //int _Check_D_SsfdcBusy(WORD time)
1093 //{
1094 // WORD count = 0;
1095 //
1096 // do {
1097 // if (!_Hw_D_ChkBusy())
1098 // return(SUCCESS);
1099 // EDelay(100);
1100 // count++;
1101 // } while (count<=time);
1102 //
1103 // return(ERROR);
1104 //}
1105 //
1106 ////----- _Check_D_SsfdcStatus() -----------------------------------------
1107 //int _Check_D_SsfdcStatus(void)
1108 //{
1109 // if (_Hw_D_InData() & WR_FAIL)
1110 // return(ERROR);
1111 //
1112 // return(SUCCESS);
1113 //}
1114 //
1115 //// For 712
1116 ////----- _Reset_D_SsfdcErr() -----------------------------------------
1117 //void _Reset_D_SsfdcErr(void)
1118 //{
1119 // WORD count = 0;
1120 //
1121 // _Hw_D_SetRdCmd();
1122 // _Hw_D_OutData(RST_CHIP);
1123 // _Hw_D_SetRdData();
1124 //
1125 // do {
1126 // if (!_Hw_D_ChkBusy())
1127 // break;
1128 // EDelay(100);
1129 // count++;
1130 // } while (count<=BUSY_RESET);
1131 //
1132 // _Hw_D_SetRdStandby();
1133 //}
1134 //
1135 ////NAND Memory (SmartMedia) Buffer Data Xfer Subroutine
1136 ////----- SM_ReadDataWithDMA() -----------------------------------------
1137 //void SM_ReadDataWithDMA(PFDO_DEVICE_EXTENSION fdoExt, BYTE *databuf, WORD SectByteCount)
1138 //{
1139 // PHYSICAL_ADDRESS Addr;
1140 // LARGE_INTEGER ptimeout ;
1141 //
1142 // KeClearEvent(&fdoExt->SM_DMADoneEvent);
1143 //
1144 // Addr = MmGetPhysicalAddress(databuf);
1145 //
1146 // WRITE_PORT_DWORD(SM_DMA_ADDR_REG, (DWORD)Addr.LowPart);
1147 // WRITE_PORT_BYTE(SM_DMA_DATA_CTRL, 0);
1148 // WRITE_PORT_WORD(SM_DMA_BYTE_COUNT_REG, SectByteCount);
1149 //
1150 // while ( _Hw_D_ChkCardIn() )
1151 // {
1152 // if ((READ_PORT_BYTE(SM_REG_FIFO_STATUS) & 0x80))
1153 // break;
1154 // }
1155 // if (!_Hw_D_ChkCardIn()) return;
1156 // WRITE_PORT_BYTE(SM_DMA_DATA_CTRL, 0x01);
1157 //
1158 // ptimeout.QuadPart = 2000 * (-10000); // 2 sec
1159 // KeWaitForSingleObject(&fdoExt->SM_DMADoneEvent, Executive, KernelMode, FALSE, &ptimeout);
1160 // _Hw_D_SetDMAIntMask();
1161 //}
1162 //
1163 ////----- SM_WriteDataWithDMA() -----------------------------------------
1164 //void SM_WriteDataWithDMA(PFDO_DEVICE_EXTENSION fdoExt, BYTE *databuf, WORD SectByteCount)
1165 //{
1166 // PHYSICAL_ADDRESS Addr;
1167 // LARGE_INTEGER ptimeout ;
1168 //
1169 // KeClearEvent(&fdoExt->SM_DMADoneEvent);
1170 //
1171 // Addr = MmGetPhysicalAddress(databuf);
1172 //
1173 // WRITE_PORT_DWORD(SM_DMA_ADDR_REG, (DWORD)Addr.LowPart);
1174 // WRITE_PORT_BYTE(SM_DMA_DATA_CTRL, 2);
1175 // WRITE_PORT_WORD(SM_DMA_BYTE_COUNT_REG, SectByteCount);
1176 //
1177 // while ( _Hw_D_ChkCardIn() )
1178 // {
1179 // if ((READ_PORT_BYTE(SM_REG_FIFO_STATUS) & 0x40))
1180 // break;
1181 // }
1182 // if (!_Hw_D_ChkCardIn()) return;
1183 // WRITE_PORT_BYTE(SM_DMA_DATA_CTRL, 0x03);
1184 //
1185 // ptimeout.QuadPart = 2000 * (-10000); // 2 sec
1186 // KeWaitForSingleObject(&fdoExt->SM_DMADoneEvent, Executive, KernelMode, FALSE, &ptimeout);
1187 // _Hw_D_SetDMAIntMask();
1188 //}
1189 //
1190 ////----- _Read_D_SsfdcBuf() -----------------------------------------
1191 //void _Read_D_SsfdcBuf(BYTE *databuf)
1192 //{
1193 // int i;
1194 //
1195 // //for(i=0x0000;i<(((Ssfdc.Attribute &MPS)==PS256)?0x0100:0x0200);i++)
1196 // for(i=0; i<0x200; i++)
1197 // *databuf++ =_Hw_D_InData();
1198 //}
1199 //
1200 ////----- _Write_D_SsfdcBuf() -----------------------------------------
1201 //void _Write_D_SsfdcBuf(BYTE *databuf)
1202 //{
1203 // int i;
1204 //
1205 // //for(i=0x0000;i<(((Ssfdc.Attribute &MPS)==PS256)?0x0100:0x0200);i++)
1206 // for(i=0; i<0x200; i++)
1207 // _Hw_D_OutData(*databuf++);
1208 //}
1209 //
1210 ////----- _Read_D_SsfdcByte() -----------------------------------------
1211 //void _Read_D_SsfdcByte(BYTE *databuf)
1212 //{
1213 // *databuf=(BYTE)_Hw_D_InData();
1214 //}
1215 //
1216 ////----- _ReadRedt_D_SsfdcBuf() -----------------------------------------
1217 //void _ReadRedt_D_SsfdcBuf(BYTE *redundant)
1218 //{
1219 // char i;
1220 //
1221 // //for(i=0x00;i<(((Ssfdc.Attribute &MPS)==PS256)?0x08:0x10);i++)
1222 // for(i=0; i<0x10; i++)
1223 // redundant[i] =_Hw_D_InData();
1224 //}
1225 //
1226 ////----- _WriteRedt_D_SsfdcBuf() -----------------------------------------
1227 //void _WriteRedt_D_SsfdcBuf(BYTE *redundant)
1228 //{
1229 // char i;
1230 //
1231 // //for(i=0x00;i<(((Ssfdc.Attribute &MPS)==PS256)?0x08:0x10);i++)
1232 // for(i=0; i<0x10; i++)
1233 // _Hw_D_OutData(*redundant++);
1234 //}
1235 */
1236 //SmartMedia ID Code Check & Mode Set Subroutine
1237 //----- Set_D_SsfdcModel() ---------------------------------------------
Set_D_SsfdcModel(BYTE dcode)1238 int Set_D_SsfdcModel(BYTE dcode)
1239 {
1240 switch (_Check_D_DevCode(dcode)) {
1241 case SSFDC1MB:
1242 Ssfdc.Model = SSFDC1MB;
1243 Ssfdc.Attribute = FLASH | AD3CYC | BS16 | PS256;
1244 Ssfdc.MaxZones = 1;
1245 Ssfdc.MaxBlocks = 256;
1246 Ssfdc.MaxLogBlocks = 250;
1247 Ssfdc.MaxSectors = 8;
1248 break;
1249 case SSFDC2MB:
1250 Ssfdc.Model = SSFDC2MB;
1251 Ssfdc.Attribute = FLASH | AD3CYC | BS16 | PS256;
1252 Ssfdc.MaxZones = 1;
1253 Ssfdc.MaxBlocks = 512;
1254 Ssfdc.MaxLogBlocks = 500;
1255 Ssfdc.MaxSectors = 8;
1256 break;
1257 case SSFDC4MB:
1258 Ssfdc.Model = SSFDC4MB;
1259 Ssfdc.Attribute = FLASH | AD3CYC | BS16 | PS512;
1260 Ssfdc.MaxZones = 1;
1261 Ssfdc.MaxBlocks = 512;
1262 Ssfdc.MaxLogBlocks = 500;
1263 Ssfdc.MaxSectors = 16;
1264 break;
1265 case SSFDC8MB:
1266 Ssfdc.Model = SSFDC8MB;
1267 Ssfdc.Attribute = FLASH | AD3CYC | BS16 | PS512;
1268 Ssfdc.MaxZones = 1;
1269 Ssfdc.MaxBlocks = 1024;
1270 Ssfdc.MaxLogBlocks = 1000;
1271 Ssfdc.MaxSectors = 16;
1272 break;
1273 case SSFDC16MB:
1274 Ssfdc.Model = SSFDC16MB;
1275 Ssfdc.Attribute = FLASH | AD3CYC | BS32 | PS512;
1276 Ssfdc.MaxZones = 1;
1277 Ssfdc.MaxBlocks = 1024;
1278 Ssfdc.MaxLogBlocks = 1000;
1279 Ssfdc.MaxSectors = 32;
1280 break;
1281 case SSFDC32MB:
1282 Ssfdc.Model = SSFDC32MB;
1283 Ssfdc.Attribute = FLASH | AD3CYC | BS32 | PS512;
1284 Ssfdc.MaxZones = 2;
1285 Ssfdc.MaxBlocks = 1024;
1286 Ssfdc.MaxLogBlocks = 1000;
1287 Ssfdc.MaxSectors = 32;
1288 break;
1289 case SSFDC64MB:
1290 Ssfdc.Model = SSFDC64MB;
1291 Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512;
1292 Ssfdc.MaxZones = 4;
1293 Ssfdc.MaxBlocks = 1024;
1294 Ssfdc.MaxLogBlocks = 1000;
1295 Ssfdc.MaxSectors = 32;
1296 break;
1297 case SSFDC128MB:
1298 Ssfdc.Model = SSFDC128MB;
1299 Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512;
1300 Ssfdc.MaxZones = 8;
1301 Ssfdc.MaxBlocks = 1024;
1302 Ssfdc.MaxLogBlocks = 1000;
1303 Ssfdc.MaxSectors = 32;
1304 break;
1305 case SSFDC256MB:
1306 Ssfdc.Model = SSFDC256MB;
1307 Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512;
1308 Ssfdc.MaxZones = 16;
1309 Ssfdc.MaxBlocks = 1024;
1310 Ssfdc.MaxLogBlocks = 1000;
1311 Ssfdc.MaxSectors = 32;
1312 break;
1313 case SSFDC512MB:
1314 Ssfdc.Model = SSFDC512MB;
1315 Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512;
1316 Ssfdc.MaxZones = 32;
1317 Ssfdc.MaxBlocks = 1024;
1318 Ssfdc.MaxLogBlocks = 1000;
1319 Ssfdc.MaxSectors = 32;
1320 break;
1321 case SSFDC1GB:
1322 Ssfdc.Model = SSFDC1GB;
1323 Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512;
1324 Ssfdc.MaxZones = 64;
1325 Ssfdc.MaxBlocks = 1024;
1326 Ssfdc.MaxLogBlocks = 1000;
1327 Ssfdc.MaxSectors = 32;
1328 break;
1329 case SSFDC2GB:
1330 Ssfdc.Model = SSFDC2GB;
1331 Ssfdc.Attribute = FLASH | AD4CYC | BS32 | PS512;
1332 Ssfdc.MaxZones = 128;
1333 Ssfdc.MaxBlocks = 1024;
1334 Ssfdc.MaxLogBlocks = 1000;
1335 Ssfdc.MaxSectors = 32;
1336 break;
1337 default:
1338 Ssfdc.Model = NOSSFDC;
1339 return(ERROR);
1340 }
1341
1342 return(SUCCESS);
1343 }
1344
1345 //----- _Check_D_DevCode() ---------------------------------------------
_Check_D_DevCode(BYTE dcode)1346 BYTE _Check_D_DevCode(BYTE dcode)
1347 {
1348 switch(dcode){
1349 case 0x6E:
1350 case 0xE8:
1351 case 0xEC: return(SSFDC1MB); // 8Mbit (1M) NAND
1352 case 0x64:
1353 case 0xEA: return(SSFDC2MB); // 16Mbit (2M) NAND
1354 case 0x6B:
1355 case 0xE3:
1356 case 0xE5: return(SSFDC4MB); // 32Mbit (4M) NAND
1357 case 0xE6: return(SSFDC8MB); // 64Mbit (8M) NAND
1358 case 0x73: return(SSFDC16MB); // 128Mbit (16M)NAND
1359 case 0x75: return(SSFDC32MB); // 256Mbit (32M)NAND
1360 case 0x76: return(SSFDC64MB); // 512Mbit (64M)NAND
1361 case 0x79: return(SSFDC128MB); // 1Gbit(128M)NAND
1362 case 0x71: return(SSFDC256MB);
1363 case 0xDC: return(SSFDC512MB);
1364 case 0xD3: return(SSFDC1GB);
1365 case 0xD5: return(SSFDC2GB);
1366 default: return(NOSSFDC);
1367 }
1368 }
1369 /*
1370 ////SmartMedia Power Control Subroutine
1371 ////----- Cnt_D_Reset() ----------------------------------------------
1372 //void Cnt_D_Reset(void)
1373 //{
1374 // _Hw_D_LedOff();
1375 // _Hw_D_SetRdStandby();
1376 // _Hw_D_VccOff();
1377 //}
1378 //
1379 ////----- Cnt_D_PowerOn() ----------------------------------------------
1380 //int Cnt_D_PowerOn(void)
1381 //{
1382 // // No support 5V.
1383 // _Hw_D_EnableVcc3VOn(); // Set SM_REG_CTRL_5 Reg. to 3V
1384 // _Hw_D_VccOn();
1385 // _Hw_D_SetRdStandby();
1386 // _Wait_D_Timer(TIME_PON);
1387 //
1388 // if (_Hw_D_ChkPower())
1389 // {
1390 // _Hw_D_EnableOB(); // Set SM_REG_CTRL_5 Reg. to 0x83
1391 // return(SUCCESS);
1392 // }
1393 //
1394 // _Hw_D_SetVccOff();
1395 // return(ERROR);
1396 //}
1397 //
1398 ////----- Cnt_D_PowerOff() ----------------------------------------------
1399 //void Cnt_D_PowerOff(void)
1400 //{
1401 // _Hw_D_SetRdStandby();
1402 // _Hw_D_SetVccOff();
1403 // _Hw_D_VccOff();
1404 //}
1405 //
1406 ////----- Cnt_D_LedOn() ----------------------------------------------
1407 //void Cnt_D_LedOn(void)
1408 //{
1409 // _Hw_D_LedOn();
1410 //}
1411 //
1412 ////----- Cnt_D_LedOff() ----------------------------------------------
1413 //void Cnt_D_LedOff(void)
1414 //{
1415 // _Hw_D_LedOff();
1416 //}
1417 //
1418 ////----- Check_D_CntPower() ----------------------------------------------
1419 //int Check_D_CntPower(void)
1420 //{
1421 // if (_Hw_D_ChkPower())
1422 // return(SUCCESS); // Power On
1423 //
1424 // return(ERROR); // Power Off
1425 //}
1426 //
1427 ////----- Check_D_CardExist() ----------------------------------------------
1428 //int Check_D_CardExist(void)
1429 //{
1430 // char i,j,k;
1431 //
1432 // if (!_Hw_D_ChkStatus()) // Not Status Change
1433 // if (_Hw_D_ChkCardIn())
1434 // return(SUCCESS); // Card exist in Slot
1435 //
1436 // for(i=0,j=0,k=0; i<16; i++) {
1437 // if (_Hw_D_ChkCardIn()) // Status Change
1438 // {
1439 // j++; k=0;
1440 // }
1441 // else
1442 // {
1443 // j=0; k++;
1444 // }
1445 //
1446 // if (j>3)
1447 // return(SUCCESS); // Card exist in Slot
1448 // if (k>3)
1449 // return(ERROR); // NO Card exist in Slot
1450 //
1451 // _Wait_D_Timer(TIME_CDCHK);
1452 // }
1453 //
1454 // return(ERROR);
1455 //}
1456 //
1457 ////----- Check_D_CardStsChg() ----------------------------------------------
1458 //int Check_D_CardStsChg(void)
1459 //{
1460 // if (_Hw_D_ChkStatus())
1461 // return(ERROR); // Status Change
1462 //
1463 // return(SUCCESS); // Not Status Change
1464 //}
1465 //
1466 ////----- Check_D_SsfdcWP() ----------------------------------------------
1467 //int Check_D_SsfdcWP(void)
1468 //{ // ERROR: WP, SUCCESS: Not WP
1469 // char i;
1470 //
1471 // for(i=0; i<8; i++) {
1472 // if (_Hw_D_ChkWP())
1473 // return(ERROR);
1474 // _Wait_D_Timer(TIME_WPCHK);
1475 // }
1476 //
1477 // return(SUCCESS);
1478 //}
1479 //
1480 */
1481 //SmartMedia ECC Control Subroutine
1482 //----- Check_D_ReadError() ----------------------------------------------
Check_D_ReadError(BYTE * redundant)1483 int Check_D_ReadError(BYTE *redundant)
1484 {
1485 return SUCCESS;
1486 }
1487
1488 //----- Check_D_Correct() ----------------------------------------------
Check_D_Correct(BYTE * buf,BYTE * redundant)1489 int Check_D_Correct(BYTE *buf,BYTE *redundant)
1490 {
1491 return SUCCESS;
1492 }
1493
1494 //----- Check_D_CISdata() ----------------------------------------------
Check_D_CISdata(BYTE * buf,BYTE * redundant)1495 int Check_D_CISdata(BYTE *buf, BYTE *redundant)
1496 {
1497 BYTE cis[] = {0x01, 0x03, 0xD9, 0x01, 0xFF, 0x18, 0x02,
1498 0xDF, 0x01, 0x20};
1499
1500 int cis_len = sizeof(cis);
1501
1502 if (!IsSSFDCCompliance && !IsXDCompliance)
1503 return SUCCESS;
1504
1505 if (!memcmp(redundant + 0x0D, EccBuf, 3))
1506 return memcmp(buf, cis, cis_len);
1507
1508 if (!_Correct_D_SwECC(buf, redundant + 0x0D, EccBuf))
1509 return memcmp(buf, cis, cis_len);
1510
1511 buf += 0x100;
1512 if (!memcmp(redundant + 0x08, EccBuf + 0x03, 3))
1513 return memcmp(buf, cis, cis_len);
1514
1515 if (!_Correct_D_SwECC(buf, redundant + 0x08, EccBuf + 0x03))
1516 return memcmp(buf, cis, cis_len);
1517
1518 return ERROR;
1519 }
1520
1521 //----- Set_D_RightECC() ----------------------------------------------
Set_D_RightECC(BYTE * redundant)1522 void Set_D_RightECC(BYTE *redundant)
1523 {
1524 // Driver ���� ECC Check
1525 return;
1526 //StringCopy((char *)(redundant+0x0D),(char *)EccBuf,3);
1527 //StringCopy((char *)(redundant+0x08),(char *)(EccBuf+0x03),3);
1528 }
1529 /*
1530 ////----- _Calc_D_ECCdata() ----------------------------------------------
1531 //void _Calc_D_ECCdata(BYTE *buf)
1532 //{
1533 //#ifdef HW_ECC_SUPPORTED
1534 //#else
1535 // _Calculate_D_SwECC(buf,EccBuf);
1536 // buf+=0x0100;
1537 // _Calculate_D_SwECC(buf,EccBuf+0x03);
1538 //#endif
1539 //}
1540 //
1541 ////----- _Set_D_ECCdata() ----------------------------------------------
1542 //void _Set_D_ECCdata(BYTE add,BYTE *redundant)
1543 //{
1544 // //if (add==EVEN && (Ssfdc.Attribute &MPS)==PS256)
1545 // // return;
1546 //
1547 // // for 256byte/page
1548 // StringCopy((char *)(redundant+0x0D),(char *)EccBuf,3);
1549 // StringCopy((char *)(redundant+0x08),(char *)(EccBuf+0x03),3);
1550 //}
1551 */
1552
1553 /*
1554 //----- SM_ReadBlock() ---------------------------------------------
1555 int SM_ReadBlock(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf,BYTE *redundant)
1556 {
1557 PBULK_CBW pBulkCbw = fdoExt->pBulkCbw;
1558 NTSTATUS ntStatus;
1559 WORD addr;
1560
1561 ENE_LoadBinCode(fdoExt, SM_RW_PATTERN);
1562
1563 addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
1564 addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
1565
1566 // Read sect data
1567 RtlZeroMemory(pBulkCbw, sizeof(struct _BULK_CBW));
1568 pBulkCbw->dCBWSignature = CBW_SIGNTURE;
1569 pBulkCbw->bCBWLun = CBW_LUN;
1570 pBulkCbw->dCBWDataTransferLength = 0x200;
1571 pBulkCbw->bmCBWFlags = 0x80;
1572 pBulkCbw->CBWCb[0] = 0xF1;
1573 pBulkCbw->CBWCb[1] = 0x02;
1574 pBulkCbw->CBWCb[4] = (BYTE)addr;
1575 pBulkCbw->CBWCb[3] = (BYTE)(addr/0x0100);
1576 pBulkCbw->CBWCb[2] = Media.Zone/2;
1577
1578 ntStatus = ENE_SendScsiCmd(fdoExt, FDIR_READ, buf);
1579
1580 if (!NT_SUCCESS(ntStatus))
1581 return(ERROR);
1582
1583 // Read redundant
1584 RtlZeroMemory(pBulkCbw, sizeof(struct _BULK_CBW));
1585 pBulkCbw->dCBWSignature = CBW_SIGNTURE;
1586 pBulkCbw->bCBWLun = CBW_LUN;
1587 pBulkCbw->dCBWDataTransferLength = 0x10;
1588 pBulkCbw->bmCBWFlags = 0x80;
1589 pBulkCbw->CBWCb[0] = 0xF1;
1590 pBulkCbw->CBWCb[1] = 0x03;
1591 pBulkCbw->CBWCb[4] = (BYTE)addr;
1592 pBulkCbw->CBWCb[3] = (BYTE)(addr/0x0100);
1593 pBulkCbw->CBWCb[2] = Media.Zone/2;
1594 pBulkCbw->CBWCb[5] = 0;
1595 pBulkCbw->CBWCb[6] = 1;
1596
1597 ntStatus = ENE_SendScsiCmd(fdoExt, FDIR_READ, redundant);
1598
1599 if (!NT_SUCCESS(ntStatus))
1600 return(ERROR);
1601
1602 return(SUCCESS);
1603 }*/
1604