1 #include <linux/slab.h>
7 int Check_D_LogCHS (WORD
*,BYTE
*,BYTE
*);
8 void Initialize_D_Media (void);
9 void PowerOff_D_Media (void);
10 int Check_D_MediaPower (void);
11 int Check_D_MediaExist (void);
12 int Check_D_MediaWP (void);
13 int Check_D_MediaFmt (struct us_data
*);
14 int Check_D_MediaFmtForEraseAll (struct us_data
*);
15 int Conv_D_MediaAddr (struct us_data
*, DWORD
);
16 int Inc_D_MediaAddr (struct us_data
*);
17 int Check_D_FirstSect (void);
18 int Check_D_LastSect (void);
19 int Media_D_ReadOneSect (struct us_data
*, WORD
, BYTE
*);
20 int Media_D_WriteOneSect (struct us_data
*, WORD
, BYTE
*);
21 int Media_D_CopyBlockHead (struct us_data
*);
22 int Media_D_CopyBlockTail (struct us_data
*);
23 int Media_D_EraseOneBlock (void);
24 int Media_D_EraseAllBlock (void);
26 int Copy_D_BlockAll (struct us_data
*, DWORD
);
27 int Copy_D_BlockHead (struct us_data
*);
28 int Copy_D_BlockTail (struct us_data
*);
29 int Reassign_D_BlockHead (struct us_data
*);
31 int Assign_D_WriteBlock (void);
32 int Release_D_ReadBlock (struct us_data
*);
33 int Release_D_WriteBlock (struct us_data
*);
34 int Release_D_CopySector (struct us_data
*);
36 int Copy_D_PhyOneSect (struct us_data
*);
37 int Read_D_PhyOneSect (struct us_data
*, WORD
, BYTE
*);
38 int Write_D_PhyOneSect (struct us_data
*, WORD
, BYTE
*);
39 int Erase_D_PhyOneBlock (struct us_data
*);
41 int Set_D_PhyFmtValue (struct us_data
*);
42 int Search_D_CIS (struct us_data
*);
43 int Make_D_LogTable (struct us_data
*);
44 void Check_D_BlockIsFull (void);
46 int MarkFail_D_PhyOneBlock (struct us_data
*);
50 //BYTE SectBuf[SECTSIZE];
51 static BYTE WorkBuf
[SECTSIZE
];
52 static BYTE Redundant
[REDTSIZE
];
53 static BYTE WorkRedund
[REDTSIZE
];
54 //WORD Log2Phy[MAX_ZONENUM][MAX_LOGBLOCK];
55 static WORD
*Log2Phy
[MAX_ZONENUM
]; // 128 x 1000, Log2Phy[MAX_ZONENUM][MAX_LOGBLOCK];
56 static BYTE Assign
[MAX_ZONENUM
][MAX_BLOCKNUM
/8];
57 static WORD AssignStart
[MAX_ZONENUM
];
61 static DWORD SectCopyMode
;
64 static BYTE BitData
[] = { 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80 } ;
65 #define Set_D_Bit(a,b) (a[(BYTE)((b)/8)]|= BitData[(b)%8])
66 #define Clr_D_Bit(a,b) (a[(BYTE)((b)/8)]&=~BitData[(b)%8])
67 #define Chk_D_Bit(a,b) (a[(BYTE)((b)/8)] & BitData[(b)%8])
69 //extern PBYTE SMHostAddr;
70 BYTE IsSSFDCCompliance
;
75 ////Power Control & Media Exist Check Function
76 ////----- Init_D_SmartMedia() --------------------------------------------
77 //int Init_D_SmartMedia(void)
81 // EMCR_Print("Init_D_SmartMedia start\n");
82 // for (i=0; i<MAX_ZONENUM; i++)
84 // if (Log2Phy[i]!=NULL)
86 // EMCR_Print("ExFreePool Zone = %x, Addr = %x\n", i, Log2Phy[i]);
87 // ExFreePool(Log2Phy[i]);
92 // Initialize_D_Media();
96 //----- SM_FreeMem() -------------------------------------------------
101 pr_info("SM_FreeMem start\n");
102 for (i
=0; i
<MAX_ZONENUM
; i
++)
104 if (Log2Phy
[i
]!=NULL
)
106 pr_info("Free Zone = %x, Addr = %p\n", i
, Log2Phy
[i
]);
114 ////----- Pwoff_D_SmartMedia() -------------------------------------------
115 //int Pwoff_D_SmartMedia(void)
117 // PowerOff_D_Media();
121 ////----- Check_D_SmartMedia() -------------------------------------------
122 //int Check_D_SmartMedia(void)
124 // if (Check_D_MediaExist())
130 ////----- Check_D_Parameter() --------------------------------------------
131 //int Check_D_Parameter(PFDO_DEVICE_EXTENSION fdoExt,WORD *pcyl,BYTE *phead,BYTE *psect)
133 // if (Check_D_MediaPower())
136 // if (Check_D_MediaFmt(fdoExt))
139 // if (Check_D_LogCHS(pcyl,phead,psect))
145 //SmartMedia Read/Write/Erase Function
146 //----- Media_D_ReadSector() -------------------------------------------
147 int Media_D_ReadSector(struct us_data
*us
, DWORD start
,WORD count
,BYTE
*buf
)
151 //if (Check_D_MediaPower()) ; ¦b 6250 don't care
153 //if (Check_D_MediaFmt(fdoExt)) ;
155 if (Conv_D_MediaAddr(us
, start
))
160 len
= Ssfdc
.MaxSectors
- Media
.Sector
;
165 //if (Media_D_ReadOneSect(fdoExt, SectBuf))
166 //if (Media_D_ReadOneSect(fdoExt, count, buf))
167 if (Media_D_ReadOneSect(us
, bn
, buf
))
169 ErrCode
= ERR_EccReadErr
;
179 buf
+= bn
* SECTSIZE
;
181 if (Inc_D_MediaAddr(us
))
188 //----- Media_D_CopySector() ------------------------------------------
189 int Media_D_CopySector(struct us_data
*us
, DWORD start
,WORD count
,BYTE
*buf
)
194 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
195 //ADDRESS_T bb = (ADDRESS_T) &Media;
197 /* pr_info("Media_D_CopySector !!!\n"); */
198 if (Conv_D_MediaAddr(us
, start
))
203 if (Assign_D_WriteBlock())
206 len
= Ssfdc
.MaxSectors
- Media
.Sector
;
212 //if (Ssfdc_D_CopyBlock(fdoExt,count,buf,Redundant))
213 if (Ssfdc_D_CopyBlock(us
,bn
,buf
,Redundant
))
215 ErrCode
= ERR_WriteFault
;
220 //if (Release_D_ReadBlock(fdoExt))
221 if (Release_D_CopySector(us
))
223 if (ErrCode
==ERR_HwError
)
225 ErrCode
= ERR_WriteFault
;
234 buf
+= bn
* SECTSIZE
;
236 if (Inc_D_MediaAddr(us
))
243 //----- Release_D_CopySector() ------------------------------------------
244 int Release_D_CopySector(struct us_data
*us
)
246 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
247 //ADDRESS_T bb = (ADDRESS_T) &Media;
249 Log2Phy
[Media
.Zone
][Media
.LogBlock
]=WriteBlock
;
250 Media
.PhyBlock
=ReadBlock
;
252 if (Media
.PhyBlock
==NO_ASSIGN
)
254 Media
.PhyBlock
=WriteBlock
;
258 Clr_D_Bit(Assign
[Media
.Zone
],Media
.PhyBlock
);
259 Media
.PhyBlock
=WriteBlock
;
264 //----- Media_D_WriteSector() ------------------------------------------
265 int Media_D_WriteSector(PFDO_DEVICE_EXTENSION fdoExt, DWORD start,WORD count,BYTE *buf)
269 SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
270 ADDRESS_T bb = (ADDRESS_T) &Media;
272 //if (Check_D_MediaPower())
275 //if (Check_D_MediaFmt(fdoExt))
278 //if (Check_D_MediaWP())
281 if (Conv_D_MediaAddr(fdoExt, start))
284 //ENE_Print("Media_D_WriteSector --- Sector = %x\n", Media.Sector);
285 if (Check_D_FirstSect())
287 if (Media_D_CopyBlockHead(fdoExt))
289 ErrCode = ERR_WriteFault;
296 if (!Check_D_FirstSect())
298 if (Assign_D_WriteBlock())
302 len = Ssfdc.MaxSectors - Media.Sector;
307 //for(i=0;i<SECTSIZE;i++)
308 // SectBuf[i]=*buf++;
310 //if (Media_D_WriteOneSect(fdoExt, SectBuf))
311 if (Media_D_WriteOneSect(fdoExt, bn, buf))
313 ErrCode = ERR_WriteFault;
317 Media.Sector += bn - 1;
319 if (!Check_D_LastSect())
321 if (Release_D_ReadBlock(fdoExt))
323 { if (ErrCode==ERR_HwError)
325 ErrCode = ERR_WriteFault;
336 buf += bn * SECTSIZE;
341 if (Inc_D_MediaAddr(fdoExt))
345 if (!Check_D_LastSect())
348 if (Inc_D_MediaAddr(fdoExt))
351 if (Media_D_CopyBlockTail(fdoExt))
353 ErrCode = ERR_WriteFault;
360 ////----- Media_D_EraseBlock() -------------------------------------------
361 //int Media_D_EraseBlock(PFDO_DEVICE_EXTENSION fdoExt, DWORD start,WORD count)
363 // if (Check_D_MediaPower())
366 // if (Check_D_MediaFmt(fdoExt))
369 // if (Check_D_MediaWP())
372 // if (Conv_D_MediaAddr(start))
375 // while(Check_D_FirstSect()) {
376 // if (Inc_D_MediaAddr(fdoExt))
384 // if (!Check_D_LastSect())
385 // if (Media_D_EraseOneBlock())
386 // if (ErrCode==ERR_HwError)
388 // ErrCode = ERR_WriteFault;
392 // if (Inc_D_MediaAddr(fdoExt))
400 ////----- Media_D_EraseAll() ---------------------------------------------
401 //int Media_D_EraseAll(PFDO_DEVICE_EXTENSION fdoExt)
403 // if (Check_D_MediaPower())
406 // if (Check_D_MediaFmtForEraseAll(fdoExt))
409 // if (Check_D_MediaWP())
412 // if (Media_D_EraseAllBlock())
418 //SmartMedia Write Function for One Sector Write Mode
419 //----- Media_D_OneSectWriteStart() ------------------------------------
420 int Media_D_OneSectWriteStart(PFDO_DEVICE_EXTENSION fdoExt,DWORD start,BYTE *buf)
423 // SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
424 // ADDRESS_T bb = (ADDRESS_T) &Media;
426 // //if (Check_D_MediaPower())
427 // // return(ErrCode);
428 // //if (Check_D_MediaFmt(fdoExt))
429 // // return(ErrCode);
430 // //if (Check_D_MediaWP())
431 // // return(ErrCode);
432 // if (Conv_D_MediaAddr(fdoExt, start))
435 // if (Check_D_FirstSect())
436 // if (Media_D_CopyBlockHead(fdoExt))
438 // ErrCode = ERR_WriteFault;
442 // if (!Check_D_FirstSect())
443 // if (Assign_D_WriteBlock())
446 // //for(i=0;i<SECTSIZE;i++)
447 // // SectBuf[i]=*buf++;
449 // //if (Media_D_WriteOneSect(fdoExt, SectBuf))
450 // if (Media_D_WriteOneSect(fdoExt, buf))
452 // ErrCode = ERR_WriteFault;
456 // if (!Check_D_LastSect())
458 // if (Release_D_ReadBlock(fdoExt))
459 // if (ErrCode==ERR_HwError)
461 // ErrCode = ERR_WriteFault;
469 //----- Media_D_OneSectWriteNext() -------------------------------------
470 int Media_D_OneSectWriteNext(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf)
473 // SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
474 // ADDRESS_T bb = (ADDRESS_T) &Media;
476 // if (Inc_D_MediaAddr(fdoExt))
479 // if (!Check_D_FirstSect())
480 // if (Assign_D_WriteBlock())
483 // //for(i=0;i<SECTSIZE;i++)
484 // // SectBuf[i]=*buf++;
486 // //if (Media_D_WriteOneSect(fdoExt, SectBuf))
487 // if (Media_D_WriteOneSect(fdoExt, buf))
489 // ErrCode = ERR_WriteFault;
493 // if (!Check_D_LastSect())
495 // if (Release_D_ReadBlock(fdoExt))
496 // if (ErrCode==ERR_HwError)
498 // ErrCode = ERR_WriteFault;
506 //----- Media_D_OneSectWriteFlush() ------------------------------------
507 int Media_D_OneSectWriteFlush(PFDO_DEVICE_EXTENSION fdoExt)
509 if (!Check_D_LastSect())
512 if (Inc_D_MediaAddr(fdoExt))
515 if (Media_D_CopyBlockTail(fdoExt))
517 ErrCode = ERR_WriteFault;
524 ////LED Tern On/Off Subroutine
525 ////----- SM_EnableLED() -----------------------------------------------
526 //void SM_EnableLED(PFDO_DEVICE_EXTENSION fdoExt, BOOLEAN enable)
528 // if (fdoExt->Drive_IsSWLED)
537 ////----- Led_D_TernOn() -------------------------------------------------
538 //void Led_D_TernOn(void)
540 // if (Check_D_CardStsChg())
541 // MediaChange=ERROR;
546 ////----- Led_D_TernOff() ------------------------------------------------
547 //void Led_D_TernOff(void)
549 // if (Check_D_CardStsChg())
550 // MediaChange=ERROR;
555 ////SmartMedia Logical Format Subroutine
556 ////----- Check_D_LogCHS() -----------------------------------------------
557 //int Check_D_LogCHS(WORD *c,BYTE *h,BYTE *s)
559 // switch(Ssfdc.Model) {
560 // case SSFDC1MB: *c=125; *h= 4; *s= 4; break;
561 // case SSFDC2MB: *c=125; *h= 4; *s= 8; break;
562 // case SSFDC4MB: *c=250; *h= 4; *s= 8; break;
563 // case SSFDC8MB: *c=250; *h= 4; *s=16; break;
564 // case SSFDC16MB: *c=500; *h= 4; *s=16; break;
565 // case SSFDC32MB: *c=500; *h= 8; *s=16; break;
566 // case SSFDC64MB: *c=500; *h= 8; *s=32; break;
567 // case SSFDC128MB: *c=500; *h=16; *s=32; break;
568 // default: *c= 0; *h= 0; *s= 0; ErrCode = ERR_NoSmartMedia; return(ERROR);
571 // return(SMSUCCESS);
574 ////Power Control & Media Exist Check Subroutine
575 ////----- Initialize_D_Media() -------------------------------------------
576 //void Initialize_D_Media(void)
578 // ErrCode = NO_ERROR;
579 // MediaChange = ERROR;
580 // SectCopyMode = COMPLETED;
584 ////----- PowerOff_D_Media() ---------------------------------------------
585 //void PowerOff_D_Media(void)
590 ////----- Check_D_MediaPower() -------------------------------------------
591 //int Check_D_MediaPower(void)
593 // //usleep(56*1024);
594 // if (Check_D_CardStsChg())
595 // MediaChange = ERROR;
596 // //usleep(56*1024);
597 // if ((!Check_D_CntPower())&&(!MediaChange)) // ¦³ power & Media ¨S³Q change, «h return success
598 // return(SMSUCCESS);
599 // //usleep(56*1024);
601 // if (Check_D_CardExist()) // Check if card is not exist, return err
603 // ErrCode = ERR_NoSmartMedia;
604 // MediaChange = ERROR;
607 // //usleep(56*1024);
608 // if (Cnt_D_PowerOn())
610 // ErrCode = ERR_NoSmartMedia;
611 // MediaChange = ERROR;
614 // //usleep(56*1024);
615 // Ssfdc_D_Reset(fdoExt);
616 // //usleep(56*1024);
617 // return(SMSUCCESS);
620 ////-----Check_D_MediaExist() --------------------------------------------
621 //int Check_D_MediaExist(void)
623 // if (Check_D_CardStsChg())
624 // MediaChange = ERROR;
626 // if (!Check_D_CardExist())
629 // return(SMSUCCESS);
631 // ErrCode = ERR_ChangedMedia;
635 // ErrCode = ERR_NoSmartMedia;
640 ////----- Check_D_MediaWP() ----------------------------------------------
641 //int Check_D_MediaWP(void)
643 // if (Ssfdc.Attribute &MWP)
645 // ErrCode = ERR_WrtProtect;
649 // return(SMSUCCESS);
652 //SmartMedia Physical Format Test Subroutine
653 //----- Check_D_MediaFmt() ---------------------------------------------
654 int Check_D_MediaFmt(struct us_data
*us
)
656 pr_info("Check_D_MediaFmt\n");
657 //ULONG i,j, result=FALSE, zone,block;
664 SectCopyMode
= COMPLETED
;
667 if (Set_D_PhyFmtValue(us
))
669 ErrCode
= ERR_UnknownMedia
;
674 if (Search_D_CIS(us
))
676 ErrCode
= ERR_IllegalFmt
;
681 MediaChange
= SMSUCCESS
;
685 ////----- Check_D_BlockIsFull() ----------------------------------
686 //void Check_D_BlockIsFull()
690 // if (IsXDCompliance || IsSSFDCCompliance)
692 // // If the blocks are full then return write-protect.
693 // block = Ssfdc.MaxBlocks/8;
694 // for (Media.Zone=0; Media.Zone<Ssfdc.MaxZones; Media.Zone++)
696 // if (Log2Phy[Media.Zone]==NULL)
698 // if (Make_D_LogTable())
700 // ErrCode = ERR_IllegalFmt;
705 // for (i=0; i<block; i++)
707 // if (Assign[Media.Zone][i] != 0xFF)
711 // Ssfdc.Attribute |= WP;
716 ////----- Check_D_MediaFmtForEraseAll() ----------------------------------
717 //int Check_D_MediaFmtForEraseAll(PFDO_DEVICE_EXTENSION fdoExt)
719 // MediaChange = ERROR;
720 // SectCopyMode = COMPLETED;
722 // if (Set_D_PhyFmtValue(fdoExt))
724 // ErrCode = ERR_UnknownMedia;
728 // if (Search_D_CIS(fdoExt))
730 // ErrCode = ERR_IllegalFmt;
734 // return(SMSUCCESS);
737 //SmartMedia Physical Address Control Subroutine
738 //----- Conv_D_MediaAddr() ---------------------------------------------
739 int Conv_D_MediaAddr(struct us_data
*us
, DWORD addr
)
743 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
744 //ADDRESS_T bb = (ADDRESS_T) &Media;
746 temp
= addr
/Ssfdc
.MaxSectors
;
747 Media
.Zone
= (BYTE
) (temp
/Ssfdc
.MaxLogBlocks
);
749 if (Log2Phy
[Media
.Zone
]==NULL
)
751 if (Make_D_LogTable(us
))
753 ErrCode
= ERR_IllegalFmt
;
758 Media
.Sector
= (BYTE
) (addr
%Ssfdc
.MaxSectors
);
759 Media
.LogBlock
= (WORD
) (temp
%Ssfdc
.MaxLogBlocks
);
761 if (Media
.Zone
<Ssfdc
.MaxZones
)
763 Clr_D_RedundantData(Redundant
);
764 Set_D_LogBlockAddr(Redundant
);
765 Media
.PhyBlock
= Log2Phy
[Media
.Zone
][Media
.LogBlock
];
769 ErrCode
= ERR_OutOfLBA
;
773 //----- Inc_D_MediaAddr() ----------------------------------------------
774 int Inc_D_MediaAddr(struct us_data
*us
)
776 WORD LogBlock
= Media
.LogBlock
;
777 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
778 //ADDRESS_T bb = (ADDRESS_T) &Media;
780 if (++Media
.Sector
<Ssfdc
.MaxSectors
)
783 if (Log2Phy
[Media
.Zone
]==NULL
)
785 if (Make_D_LogTable(us
))
787 ErrCode
= ERR_IllegalFmt
;
793 Media
.LogBlock
= LogBlock
;
795 if (++Media
.LogBlock
<Ssfdc
.MaxLogBlocks
)
797 Clr_D_RedundantData(Redundant
);
798 Set_D_LogBlockAddr(Redundant
);
799 Media
.PhyBlock
=Log2Phy
[Media
.Zone
][Media
.LogBlock
];
805 if (++Media
.Zone
<Ssfdc
.MaxZones
)
807 if (Log2Phy
[Media
.Zone
]==NULL
)
809 if (Make_D_LogTable(us
))
811 ErrCode
= ERR_IllegalFmt
;
818 Clr_D_RedundantData(Redundant
);
819 Set_D_LogBlockAddr(Redundant
);
820 Media
.PhyBlock
=Log2Phy
[Media
.Zone
][Media
.LogBlock
];
825 ErrCode
= ERR_OutOfLBA
;
830 //----- Check_D_FirstSect() --------------------------------------------
831 int Check_D_FirstSect(void)
833 SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
834 ADDRESS_T bb = (ADDRESS_T) &Media;
842 //----- Check_D_LastSect() ---------------------------------------------
843 int Check_D_LastSect(void)
845 SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
846 ADDRESS_T bb = (ADDRESS_T) &Media;
848 if (Media.Sector<(Ssfdc.MaxSectors-1))
854 //SmartMedia Read/Write Subroutine with Retry
855 //----- Media_D_ReadOneSect() ------------------------------------------
856 int Media_D_ReadOneSect(struct us_data
*us
, WORD count
, BYTE
*buf
)
860 if (!Read_D_PhyOneSect(us
, count
, buf
))
862 if (ErrCode
==ERR_HwError
)
864 if (ErrCode
==ERR_DataStatus
)
867 #ifdef RDERR_REASSIGN
868 if (Ssfdc
.Attribute
&MWP
)
870 if (ErrCode
==ERR_CorReadErr
)
876 for(retry
=0; retry
<2; retry
++)
878 if (Copy_D_BlockAll(us
, (err
==ERR_EccReadErr
)?REQ_FAIL
:REQ_ERASE
))
880 if (ErrCode
==ERR_HwError
)
886 if (ErrCode
==ERR_CorReadErr
)
893 if (ErrCode
==ERR_CorReadErr
) return(SMSUCCESS
);
899 //----- Media_D_WriteOneSect() -----------------------------------------
900 int Media_D_WriteOneSect(PFDO_DEVICE_EXTENSION fdoExt, WORD count, BYTE *buf)
903 SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
904 ADDRESS_T bb = (ADDRESS_T) &Media;
906 if (!Write_D_PhyOneSect(fdoExt, count, buf))
908 if (ErrCode==ERR_HwError)
911 for(retry=1; retry<2; retry++)
913 if (Reassign_D_BlockHead(fdoExt))
915 if (ErrCode==ERR_HwError)
920 if (!Write_D_PhyOneSect(fdoExt, count, buf))
922 if (ErrCode==ERR_HwError)
926 if (Release_D_WriteBlock(fdoExt))
929 ErrCode = ERR_WriteFault;
934 //SmartMedia Data Copy Subroutine with Retry
935 //----- Media_D_CopyBlockHead() ----------------------------------------
936 int Media_D_CopyBlockHead(PFDO_DEVICE_EXTENSION fdoExt)
940 for(retry=0; retry<2; retry++)
942 if (!Copy_D_BlockHead(fdoExt))
944 if (ErrCode==ERR_HwError)
952 //----- Media_D_CopyBlockTail() ----------------------------------------
953 int Media_D_CopyBlockTail(PFDO_DEVICE_EXTENSION fdoExt)
957 if (!Copy_D_BlockTail(fdoExt))
959 if (ErrCode==ERR_HwError)
962 for(retry=1; retry<2; retry++)
964 if (Reassign_D_BlockHead(fdoExt))
966 if (ErrCode==ERR_HwError)
971 if (!Copy_D_BlockTail(fdoExt))
973 if (ErrCode==ERR_HwError)
977 if (Release_D_WriteBlock(fdoExt))
980 ErrCode = ERR_WriteFault;
985 ////----- Media_D_EraseOneBlock() ----------------------------------------
986 //int Media_D_EraseOneBlock(void)
988 // WORD LogBlock = Media.LogBlock;
989 // WORD PhyBlock = Media.PhyBlock;
990 // SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
991 // ADDRESS_T bb = (ADDRESS_T) &Media;
993 // if (Media.PhyBlock==NO_ASSIGN)
994 // return(SMSUCCESS);
996 // if (Log2Phy[Media.Zone]==NULL)
998 // if (Make_D_LogTable())
1000 // ErrCode = ERR_IllegalFmt;
1004 // Media.LogBlock = LogBlock;
1005 // Media.PhyBlock = PhyBlock;
1007 // Log2Phy[Media.Zone][Media.LogBlock]=NO_ASSIGN;
1009 // if (Erase_D_PhyOneBlock(fdoExt))
1011 // if (ErrCode==ERR_HwError)
1013 // if (MarkFail_D_PhyOneBlock())
1016 // ErrCode = ERR_WriteFault;
1020 // Clr_D_Bit(Assign[Media.Zone],Media.PhyBlock);
1021 // Media.PhyBlock=NO_ASSIGN;
1022 // return(SMSUCCESS);
1025 ////SmartMedia Erase Subroutine
1026 ////----- Media_D_EraseAllBlock() ----------------------------------------
1027 //int Media_D_EraseAllBlock(void)
1031 // SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1032 // ADDRESS_T bb = (ADDRESS_T) &Media;
1034 // MediaChange = ERROR;
1035 // Media.Sector = 0;
1037 // for(Media.Zone=0; Media.Zone<Ssfdc.MaxZones; Media.Zone++)
1038 // for(Media.PhyBlock=0; Media.PhyBlock<Ssfdc.MaxBlocks; Media.PhyBlock++) {
1039 // if (Ssfdc_D_ReadRedtData(Redundant))
1041 // Ssfdc_D_Reset(fdoExt);
1045 // Ssfdc_D_Reset(fdoExt);
1046 // if (!Check_D_FailBlock(Redundant))
1050 // if (Ssfdc_D_EraseBlock(fdoExt))
1052 // ErrCode = ERR_HwError;
1056 // if (Ssfdc_D_CheckStatus())
1058 // if (MarkFail_D_PhyOneBlock())
1065 // if (Media.PhyBlock!=CisArea.PhyBlock)
1067 // ErrCode = ERR_IllegalFmt;
1075 // return(SMSUCCESS);
1078 //SmartMedia Physical Sector Data Copy Subroutine
1079 //----- Copy_D_BlockAll() ----------------------------------------------
1080 int Copy_D_BlockAll(struct us_data
*us
, DWORD mode
)
1083 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1084 //ADDRESS_T bb = (ADDRESS_T) &Media;
1088 if (Assign_D_WriteBlock())
1091 SectCopyMode
=REQ_FAIL
;
1093 for(Media
.Sector
=0; Media
.Sector
<Ssfdc
.MaxSectors
; Media
.Sector
++)
1095 if (Copy_D_PhyOneSect(us
))
1097 if (ErrCode
==ERR_HwError
)
1099 if (Release_D_WriteBlock(us
))
1102 ErrCode
= ERR_WriteFault
;
1103 Media
.PhyBlock
=ReadBlock
;
1110 if (Release_D_ReadBlock(us
))
1113 Media
.PhyBlock
=WriteBlock
;
1118 //----- Copy_D_BlockHead() ---------------------------------------------
1119 int Copy_D_BlockHead(PFDO_DEVICE_EXTENSION fdoExt)
1122 SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1123 ADDRESS_T bb = (ADDRESS_T) &Media;
1126 if (Assign_D_WriteBlock())
1129 for(Media.Sector=0; Media.Sector<sect; Media.Sector++)
1131 if (Copy_D_PhyOneSect(fdoExt))
1133 if (ErrCode==ERR_HwError)
1135 if (Release_D_WriteBlock(fdoExt))
1138 ErrCode = ERR_WriteFault;
1139 Media.PhyBlock=ReadBlock;
1146 Media.PhyBlock=WriteBlock;
1151 //----- Copy_D_BlockTail() ---------------------------------------------
1152 int Copy_D_BlockTail(PFDO_DEVICE_EXTENSION fdoExt)
1155 SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1156 ADDRESS_T bb = (ADDRESS_T) &Media;
1158 for(sect=Media.Sector; Media.Sector<Ssfdc.MaxSectors; Media.Sector++)
1160 if (Copy_D_PhyOneSect(fdoExt))
1162 if (ErrCode==ERR_HwError)
1165 Media.PhyBlock=WriteBlock;
1172 if (Release_D_ReadBlock(fdoExt))
1175 Media.PhyBlock=WriteBlock;
1180 //----- Reassign_D_BlockHead() -----------------------------------------
1181 int Reassign_D_BlockHead(PFDO_DEVICE_EXTENSION fdoExt)
1186 SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1187 ADDRESS_T bb = (ADDRESS_T) &Media;
1193 if (Assign_D_WriteBlock())
1196 SectCopyMode=REQ_FAIL;
1198 for(Media.Sector=0; Media.Sector<sect; Media.Sector++)
1200 if (Copy_D_PhyOneSect(fdoExt))
1202 if (ErrCode==ERR_HwError)
1204 if (Release_D_WriteBlock(fdoExt))
1207 ErrCode = ERR_WriteFault;
1209 WriteBlock=ReadBlock;
1212 Media.PhyBlock=WriteBlock;
1218 if (Release_D_ReadBlock(fdoExt))
1224 Media.PhyBlock=WriteBlock;
1228 //SmartMedia Physical Block Assign/Release Subroutine
1229 //----- Assign_D_WriteBlock() ------------------------------------------
1230 int Assign_D_WriteBlock(void)
1232 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1233 //ADDRESS_T bb = (ADDRESS_T) &Media;
1234 ReadBlock
=Media
.PhyBlock
;
1236 for(WriteBlock
=AssignStart
[Media
.Zone
]; WriteBlock
<Ssfdc
.MaxBlocks
; WriteBlock
++)
1238 if (!Chk_D_Bit(Assign
[Media
.Zone
],WriteBlock
))
1240 Set_D_Bit(Assign
[Media
.Zone
],WriteBlock
);
1241 AssignStart
[Media
.Zone
]=WriteBlock
+1;
1242 Media
.PhyBlock
=WriteBlock
;
1243 SectCopyMode
=REQ_ERASE
;
1244 //ErrXDCode = NO_ERROR;
1249 for(WriteBlock
=0; WriteBlock
<AssignStart
[Media
.Zone
]; WriteBlock
++)
1251 if (!Chk_D_Bit(Assign
[Media
.Zone
],WriteBlock
))
1253 Set_D_Bit(Assign
[Media
.Zone
],WriteBlock
);
1254 AssignStart
[Media
.Zone
]=WriteBlock
+1;
1255 Media
.PhyBlock
=WriteBlock
;
1256 SectCopyMode
=REQ_ERASE
;
1257 //ErrXDCode = NO_ERROR;
1262 WriteBlock
=NO_ASSIGN
;
1263 ErrCode
= ERR_WriteFault
;
1265 //Ssfdc.Attribute |= WP;
1266 //ErrXDCode = ERR_WrtProtect;
1270 //----- Release_D_ReadBlock() ------------------------------------------
1271 int Release_D_ReadBlock(struct us_data
*us
)
1274 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1275 //ADDRESS_T bb = (ADDRESS_T) &Media;
1278 SectCopyMode
=COMPLETED
;
1280 if (mode
==COMPLETED
)
1283 Log2Phy
[Media
.Zone
][Media
.LogBlock
]=WriteBlock
;
1284 Media
.PhyBlock
=ReadBlock
;
1286 if (Media
.PhyBlock
==NO_ASSIGN
)
1288 Media
.PhyBlock
=WriteBlock
;
1292 if (mode
==REQ_ERASE
)
1294 if (Erase_D_PhyOneBlock(us
))
1296 if (ErrCode
==ERR_HwError
) return(ERROR
);
1297 if (MarkFail_D_PhyOneBlock(us
)) return(ERROR
);
1300 Clr_D_Bit(Assign
[Media
.Zone
],Media
.PhyBlock
);
1302 else if (MarkFail_D_PhyOneBlock(us
))
1305 Media
.PhyBlock
=WriteBlock
;
1309 //----- Release_D_WriteBlock() -----------------------------------------
1310 int Release_D_WriteBlock(struct us_data
*us
)
1312 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1313 //ADDRESS_T bb = (ADDRESS_T) &Media;
1314 SectCopyMode
=COMPLETED
;
1315 Media
.PhyBlock
=WriteBlock
;
1317 if (MarkFail_D_PhyOneBlock(us
))
1320 Media
.PhyBlock
=ReadBlock
;
1324 //SmartMedia Physical Sector Data Copy Subroutine
1325 //----- Copy_D_PhyOneSect() --------------------------------------------
1326 int Copy_D_PhyOneSect(struct us_data
*us
)
1330 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1331 //ADDRESS_T bb = (ADDRESS_T) &Media;
1333 /* pr_info("Copy_D_PhyOneSect --- Secotr = %x\n", Media.Sector); */
1334 if (ReadBlock
!=NO_ASSIGN
)
1336 Media
.PhyBlock
=ReadBlock
;
1337 for(retry
=0; retry
<2; retry
++)
1342 if (Ssfdc_D_ReadCisSect(us
,WorkBuf
,WorkRedund
))
1343 { ErrCode
= ERR_HwError
; MediaChange
=ERROR
; return(ERROR
); }
1345 if (Check_D_CISdata(WorkBuf
,WorkRedund
))
1346 { ErrCode
= ERR_HwError
; MediaChange
=ERROR
; return(ERROR
); }
1349 if (Ssfdc_D_ReadSect(us
,WorkBuf
,WorkRedund
))
1350 { ErrCode
= ERR_HwError
; MediaChange
=ERROR
; return(ERROR
); }
1351 if (Check_D_DataStatus(WorkRedund
))
1352 { err
=ERROR
; break; }
1353 if (!Check_D_ReadError(WorkRedund
))
1354 { err
=SMSUCCESS
; break; }
1355 if (!Check_D_Correct(WorkBuf
,WorkRedund
))
1356 { err
=SMSUCCESS
; break; }
1359 SectCopyMode
=REQ_FAIL
;
1365 for(i
=0; i
<SECTSIZE
; i
++)
1366 WorkBuf
[i
]=DUMMY_DATA
;
1367 Clr_D_RedundantData(WorkRedund
);
1370 Set_D_LogBlockAddr(WorkRedund
);
1373 Set_D_RightECC(WorkRedund
);
1374 Set_D_DataStaus(WorkRedund
);
1377 Media
.PhyBlock
=WriteBlock
;
1379 if (Ssfdc_D_WriteSectForCopy(us
, WorkBuf
, WorkRedund
))
1380 { ErrCode
= ERR_HwError
; MediaChange
=ERROR
; return(ERROR
); }
1381 if (Ssfdc_D_CheckStatus())
1382 { ErrCode
= ERR_WriteFault
; return(ERROR
); }
1384 Media
.PhyBlock
=ReadBlock
;
1388 //SmartMedia Physical Sector Read/Write/Erase Subroutine
1389 //----- Read_D_PhyOneSect() --------------------------------------------
1390 int Read_D_PhyOneSect(struct us_data
*us
, WORD count
, BYTE
*buf
)
1394 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1395 //ADDRESS_T bb = (ADDRESS_T) &Media;
1397 if (Media
.PhyBlock
==NO_ASSIGN
)
1399 for(i
=0; i
<SECTSIZE
; i
++)
1404 for(retry
=0; retry
<2; retry
++)
1410 if (Ssfdc_D_ReadCisSect(us
,WorkBuf
,WorkRedund
))
1411 { ErrCode
= ERR_HwError
; MediaChange
=ERROR
; return(ERROR
); }
1412 if (Check_D_CISdata(WorkBuf
,WorkRedund
))
1413 { ErrCode
= ERR_HwError
; MediaChange
=ERROR
; return(ERROR
); }
1416 //if (Ssfdc_D_ReadSect(fdoExt,buf,Redundant))
1417 if (Ssfdc_D_ReadBlock(us
,count
,buf
,Redundant
))
1418 { ErrCode
= ERR_HwError
; MediaChange
=ERROR
; return(ERROR
); }
1419 if (Check_D_DataStatus(Redundant
))
1420 { ErrCode
= ERR_DataStatus
; return(ERROR
); }
1422 if (!Check_D_ReadError(Redundant
))
1425 if (!Check_D_Correct(buf
,Redundant
))
1426 { ErrCode
= ERR_CorReadErr
; return(ERROR
); }
1429 ErrCode
= ERR_EccReadErr
;
1433 //----- Write_D_PhyOneSect() -------------------------------------------
1434 int Write_D_PhyOneSect(PFDO_DEVICE_EXTENSION fdoExt, WORD count, BYTE *buf)
1436 SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1437 ADDRESS_T bb = (ADDRESS_T) &Media;
1439 //if (Ssfdc_D_WriteSect(fdoExt,buf,Redundant))
1440 if (Ssfdc_D_WriteBlock(fdoExt,count,buf,Redundant))
1441 { ErrCode = ERR_HwError; MediaChange=ERROR; return(ERROR); }
1442 if (Ssfdc_D_CheckStatus())
1443 { ErrCode = ERR_WriteFault; return(ERROR); }
1448 //----- Erase_D_PhyOneBlock() ------------------------------------------
1449 int Erase_D_PhyOneBlock(struct us_data
*us
)
1451 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1452 //ADDRESS_T bb = (ADDRESS_T) &Media;
1454 if (Ssfdc_D_EraseBlock(us
))
1455 { ErrCode
= ERR_HwError
; MediaChange
=ERROR
; return(ERROR
); }
1456 if (Ssfdc_D_CheckStatus())
1457 { ErrCode
= ERR_WriteFault
; return(ERROR
); }
1462 //SmartMedia Physical Format Check Local Subroutine
1463 //----- Set_D_PhyFmtValue() --------------------------------------------
1464 int Set_D_PhyFmtValue(struct us_data
*us
)
1466 // PPDO_DEVICE_EXTENSION pdoExt;
1468 // DWORD UserDefData_1, UserDefData_2, Data, mask;
1470 // //if (!fdoExt->ChildDeviceObject) return(ERROR);
1471 // //pdoExt = fdoExt->ChildDeviceObject->DeviceExtension;
1473 // Ssfdc_D_ReadID(idcode, READ_ID_1);
1475 //if (Set_D_SsfdcModel(idcode[1]))
1476 if (Set_D_SsfdcModel(us
->SM_DeviceID
))
1479 // //Use Multi-function pin to differentiate SM and xD.
1480 // UserDefData_1 = ReadPCIReg(fdoExt->BusID, fdoExt->DevID, fdoExt->FuncID, PCI_REG_USER_DEF) & 0x80;
1481 // if (UserDefData_1)
1483 // if ( READ_PORT_BYTE(SM_REG_INT_STATUS) & 0x80 ) fdoExt->DiskType = DISKTYPE_XD;
1484 // if ( READ_PORT_BYTE(SM_REG_INT_STATUS) & 0x40 ) fdoExt->DiskType = DISKTYPE_SM;
1486 // if ( IsXDCompliance && (fdoExt->DiskType == DISKTYPE_XD) )
1488 // Ssfdc_D_ReadID(idcode, READ_ID_3);
1489 // if (idcode[2] != 0xB5)
1494 // //Use GPIO to differentiate SM and xD.
1495 // UserDefData_2 = ReadPCIReg(fdoExt->BusID, fdoExt->DevID, fdoExt->FuncID, PCI_REG_USER_DEF) >> 8;
1496 // if ( UserDefData_2 )
1498 // Data = ReadPCIReg(fdoExt->BusID, fdoExt->DevID, 0, 0xAC);
1500 // mask = 1 << (UserDefData_2-1);
1501 // // 1 : xD , 0 : SM
1502 // if ( Data & mask)
1503 // fdoExt->DiskType = DISKTYPE_XD;
1505 // fdoExt->DiskType = DISKTYPE_SM;
1507 // if ( IsXDCompliance && (fdoExt->DiskType == DISKTYPE_XD) )
1509 // Ssfdc_D_ReadID(idcode, READ_ID_3);
1510 // if (idcode[2] != 0xB5)
1515 // if ( !(UserDefData_1 | UserDefData_2) )
1517 // // Use UserDefine Register to differentiate SM and xD.
1518 // Ssfdc_D_ReadID(idcode, READ_ID_3);
1520 // if (idcode[2] == 0xB5)
1521 // fdoExt->DiskType = DISKTYPE_XD;
1524 // if (!IsXDCompliance)
1525 // fdoExt->DiskType = DISKTYPE_SM;
1530 // if (fdoExt->UserDef_DiskType == 0x04) fdoExt->DiskType = DISKTYPE_XD;
1531 // if (fdoExt->UserDef_DiskType == 0x08) fdoExt->DiskType = DISKTYPE_SM;
1534 // if (!fdoExt->UserDef_DisableWP)
1536 // if (fdoExt->DiskType == DISKTYPE_SM)
1538 // if (Check_D_SsfdcWP())
1539 // Ssfdc.Attribute|=WP;
1546 //----- Search_D_CIS() -------------------------------------------------
1547 int Search_D_CIS(struct us_data
*us
)
1549 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1550 //ADDRESS_T bb = (ADDRESS_T) &Media;
1552 Media
.Zone
=0; Media
.Sector
=0;
1554 for (Media
.PhyBlock
=0; Media
.PhyBlock
<(Ssfdc
.MaxBlocks
-Ssfdc
.MaxLogBlocks
-1); Media
.PhyBlock
++)
1556 if (Ssfdc_D_ReadRedtData(us
, Redundant
))
1562 if (!Check_D_FailBlock(Redundant
))
1566 if (Media
.PhyBlock
==(Ssfdc
.MaxBlocks
-Ssfdc
.MaxLogBlocks
-1))
1572 while (Media
.Sector
<CIS_SEARCH_SECT
)
1576 if (Ssfdc_D_ReadRedtData(us
, Redundant
))
1582 if (!Check_D_DataStatus(Redundant
))
1584 if (Ssfdc_D_ReadSect(us
,WorkBuf
,Redundant
))
1590 if (Check_D_CISdata(WorkBuf
,Redundant
))
1596 CisArea
.PhyBlock
=Media
.PhyBlock
;
1597 CisArea
.Sector
=Media
.Sector
;
1609 //----- Make_D_LogTable() ----------------------------------------------
1610 int Make_D_LogTable(struct us_data
*us
)
1612 WORD phyblock
,logblock
;
1613 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1614 //ADDRESS_T bb = (ADDRESS_T) &Media;
1616 if (Log2Phy
[Media
.Zone
]==NULL
)
1618 Log2Phy
[Media
.Zone
] = kmalloc(MAX_LOGBLOCK
*sizeof(WORD
), GFP_KERNEL
);
1619 /* pr_info("ExAllocatePool Zone = %x, Addr = %x\n",
1620 Media.Zone, Log2Phy[Media.Zone]); */
1621 if (Log2Phy
[Media
.Zone
]==NULL
)
1627 //for(Media.Zone=0; Media.Zone<MAX_ZONENUM; Media.Zone++)
1628 //for(Media.Zone=0; Media.Zone<Ssfdc.MaxZones; Media.Zone++)
1630 /* pr_info("Make_D_LogTable --- MediaZone = 0x%x\n",
1632 for(Media
.LogBlock
=0; Media
.LogBlock
<Ssfdc
.MaxLogBlocks
; Media
.LogBlock
++)
1633 Log2Phy
[Media
.Zone
][Media
.LogBlock
]=NO_ASSIGN
;
1635 for(Media
.PhyBlock
=0; Media
.PhyBlock
<(MAX_BLOCKNUM
/8); Media
.PhyBlock
++)
1636 Assign
[Media
.Zone
][Media
.PhyBlock
]=0x00;
1638 for(Media
.PhyBlock
=0; Media
.PhyBlock
<Ssfdc
.MaxBlocks
; Media
.PhyBlock
++)
1640 if ((!Media
.Zone
) && (Media
.PhyBlock
<=CisArea
.PhyBlock
))
1642 Set_D_Bit(Assign
[Media
.Zone
],Media
.PhyBlock
);
1646 if (Ssfdc_D_ReadRedtData(us
, Redundant
))
1647 { Ssfdc_D_Reset(us
); return(ERROR
); }
1649 if (!Check_D_DataBlank(Redundant
))
1652 Set_D_Bit(Assign
[Media
.Zone
],Media
.PhyBlock
);
1654 if (Check_D_FailBlock(Redundant
))
1657 //if (Check_D_DataStatus(Redundant))
1660 if (Load_D_LogBlockAddr(Redundant
))
1663 if (Media
.LogBlock
>=Ssfdc
.MaxLogBlocks
)
1666 if (Log2Phy
[Media
.Zone
][Media
.LogBlock
]==NO_ASSIGN
)
1668 Log2Phy
[Media
.Zone
][Media
.LogBlock
]=Media
.PhyBlock
;
1672 phyblock
= Media
.PhyBlock
;
1673 logblock
= Media
.LogBlock
;
1674 Media
.Sector
= (BYTE
)(Ssfdc
.MaxSectors
-1);
1676 if (Ssfdc_D_ReadRedtData(us
, Redundant
))
1677 { Ssfdc_D_Reset(us
); return(ERROR
); }
1679 if (!Load_D_LogBlockAddr(Redundant
))
1681 if (Media
.LogBlock
==logblock
)
1683 Media
.PhyBlock
=Log2Phy
[Media
.Zone
][logblock
];
1685 if (Ssfdc_D_ReadRedtData(us
, Redundant
))
1686 { Ssfdc_D_Reset(us
); return(ERROR
); }
1688 Media
.PhyBlock
=phyblock
;
1690 if (!Load_D_LogBlockAddr(Redundant
))
1692 if (Media
.LogBlock
!=logblock
)
1694 Media
.PhyBlock
=Log2Phy
[Media
.Zone
][logblock
];
1695 Log2Phy
[Media
.Zone
][logblock
]=phyblock
;
1700 Media
.PhyBlock
=Log2Phy
[Media
.Zone
][logblock
];
1701 Log2Phy
[Media
.Zone
][logblock
]=phyblock
;
1709 //#ifdef L2P_ERR_ERASE
1710 // if (!(Ssfdc.Attribute &MWP))
1712 // Ssfdc_D_Reset(fdoExt);
1713 // if (Ssfdc_D_EraseBlock(fdoExt))
1716 // if (Ssfdc_D_CheckStatus())
1718 // if (MarkFail_D_PhyOneBlock())
1722 // Clr_D_Bit(Assign[Media.Zone],Media.PhyBlock);
1725 // Ssfdc.Attribute|=MWP;
1727 Media
.PhyBlock
=phyblock
;
1729 } // End for (Media.PhyBlock<Ssfdc.MaxBlocks)
1731 AssignStart
[Media
.Zone
]=0;
1733 } // End for (Media.Zone<MAX_ZONENUM)
1739 //----- MarkFail_D_PhyOneBlock() ---------------------------------------
1740 int MarkFail_D_PhyOneBlock(struct us_data
*us
)
1743 //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1744 //ADDRESS_T bb = (ADDRESS_T) &Media;
1747 Set_D_FailBlock(WorkRedund
);
1748 //Ssfdc_D_WriteRedtMode();
1750 for(Media
.Sector
=0; Media
.Sector
<Ssfdc
.MaxSectors
; Media
.Sector
++)
1752 if (Ssfdc_D_WriteRedtData(us
, WorkRedund
))
1755 Media
.Sector
= sect
;
1756 ErrCode
= ERR_HwError
;
1757 MediaChange
= ERROR
;
1759 } // NO Status Check
1768 ////----- SM_Init() ----------------------------------------------------
1769 //void SM_Init(void)
1771 // _Hw_D_ClrIntCardChg();
1772 // _Hw_D_SetIntMask();
1773 // // For DMA Interrupt
1774 // _Hw_D_ClrDMAIntCardChg();
1775 // _Hw_D_SetDMAIntMask();
1778 ////----- Media_D_EraseAllRedtData() -----------------------------------
1779 //int Media_D_EraseAllRedtData(DWORD Index, BOOLEAN CheckBlock)
1783 // if (Check_D_MediaPower())
1786 // if (Check_D_MediaWP())
1789 // for (i=0; i<REDTSIZE; i++)
1790 // WorkRedund[i] = 0xFF;
1792 // Media.Zone = (BYTE)Index;
1793 // for (Media.PhyBlock=0; Media.PhyBlock<Ssfdc.MaxBlocks; Media.PhyBlock++)
1795 // if ((!Media.Zone) && (Media.PhyBlock<=CisArea.PhyBlock))
1798 // if (Ssfdc_D_EraseBlock(fdoExt))
1800 // ErrCode = ERR_HwError;
1804 // for(Media.Sector=0; Media.Sector<Ssfdc.MaxSectors; Media.Sector++)
1806 // Ssfdc_D_WriteRedtMode();
1808 // if (Ssfdc_D_WriteRedtData(WorkRedund))
1810 // Ssfdc_D_Reset(fdoExt);
1811 // ErrCode = ERR_HwError;
1812 // MediaChange = ERROR;
1814 // } // NO Status Check
1817 // Ssfdc_D_Reset(fdoExt);
1820 // Ssfdc_D_Reset(fdoExt);
1822 // return(SMSUCCESS);
1825 ////----- Media_D_GetMediaInfo() ---------------------------------------
1826 //DWORD Media_D_GetMediaInfo(PFDO_DEVICE_EXTENSION fdoExt, PIOCTL_MEDIA_INFO_IN pParamIn, PIOCTL_MEDIA_INFO_OUT pParamOut)
1828 // pParamOut->ErrCode = STATUS_CMD_FAIL;
1830 // Init_D_SmartMedia();
1832 // if (Check_D_MediaPower())
1833 // return (ErrCode==ERR_NoSmartMedia) ? STATUS_CMD_NO_MEDIA : STATUS_CMD_FAIL;
1835 // if (Set_D_PhyFmtValue(fdoExt))
1836 // return STATUS_CMD_FAIL;
1838 // //usleep(56*1024);
1839 // if (Search_D_CIS(fdoExt))
1840 // return STATUS_CMD_FAIL;
1842 // if (Check_D_MediaWP())
1843 // return STATUS_CMD_MEDIA_WP;
1845 // pParamOut->PageSize = Ssfdc.MaxSectors;
1846 // pParamOut->BlockSize = Ssfdc.MaxBlocks;
1847 // pParamOut->ZoneSize = Ssfdc.MaxZones;
1849 // return STATUS_CMD_SUCCESS;