Commit | Line | Data |
---|---|---|
126bb03b AC |
1 | #include <linux/slab.h> |
2 | #include "usb.h" | |
3 | #include "scsiglue.h" | |
4 | #include "smcommon.h" | |
5 | #include "smil.h" | |
6 | ||
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); | |
25 | ||
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 *); | |
30 | ||
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 *); | |
35 | ||
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 *); | |
40 | ||
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); | |
45 | ||
46 | int MarkFail_D_PhyOneBlock (struct us_data *); | |
47 | ||
48 | DWORD ErrXDCode; | |
49 | DWORD ErrCode; | |
50 | //BYTE SectBuf[SECTSIZE]; | |
d8aba9d5 RD |
51 | static BYTE WorkBuf[SECTSIZE]; |
52 | static BYTE Redundant[REDTSIZE]; | |
53 | static BYTE WorkRedund[REDTSIZE]; | |
126bb03b | 54 | //WORD Log2Phy[MAX_ZONENUM][MAX_LOGBLOCK]; |
d8aba9d5 RD |
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]; | |
126bb03b AC |
58 | WORD ReadBlock; |
59 | WORD WriteBlock; | |
60 | DWORD MediaChange; | |
d8aba9d5 | 61 | static DWORD SectCopyMode; |
126bb03b | 62 | |
25985edc | 63 | //BIT Control Macro |
d8aba9d5 | 64 | static BYTE BitData[] = { 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80 } ; |
126bb03b AC |
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]) | |
68 | ||
69 | //extern PBYTE SMHostAddr; | |
d8aba9d5 RD |
70 | BYTE IsSSFDCCompliance; |
71 | BYTE IsXDCompliance; | |
126bb03b AC |
72 | |
73 | ||
74 | // | |
25985edc | 75 | ////Power Control & Media Exist Check Function |
126bb03b AC |
76 | ////----- Init_D_SmartMedia() -------------------------------------------- |
77 | //int Init_D_SmartMedia(void) | |
78 | //{ | |
79 | // int i; | |
80 | // | |
81 | // EMCR_Print("Init_D_SmartMedia start\n"); | |
82 | // for (i=0; i<MAX_ZONENUM; i++) | |
83 | // { | |
84 | // if (Log2Phy[i]!=NULL) | |
85 | // { | |
86 | // EMCR_Print("ExFreePool Zone = %x, Addr = %x\n", i, Log2Phy[i]); | |
87 | // ExFreePool(Log2Phy[i]); | |
88 | // Log2Phy[i] = NULL; | |
89 | // } | |
90 | // } | |
91 | // | |
92 | // Initialize_D_Media(); | |
93 | // return(NO_ERROR); | |
94 | //} | |
95 | ||
96 | //----- SM_FreeMem() ------------------------------------------------- | |
97 | int SM_FreeMem(void) | |
98 | { | |
99 | int i; | |
100 | ||
548039fd | 101 | pr_info("SM_FreeMem start\n"); |
126bb03b AC |
102 | for (i=0; i<MAX_ZONENUM; i++) |
103 | { | |
104 | if (Log2Phy[i]!=NULL) | |
105 | { | |
548039fd | 106 | pr_info("Free Zone = %x, Addr = %p\n", i, Log2Phy[i]); |
126bb03b AC |
107 | kfree(Log2Phy[i]); |
108 | Log2Phy[i] = NULL; | |
109 | } | |
110 | } | |
111 | return(NO_ERROR); | |
112 | } | |
113 | ||
114 | ////----- Pwoff_D_SmartMedia() ------------------------------------------- | |
115 | //int Pwoff_D_SmartMedia(void) | |
116 | //{ | |
117 | // PowerOff_D_Media(); | |
118 | // return(NO_ERROR); | |
119 | //} | |
120 | // | |
121 | ////----- Check_D_SmartMedia() ------------------------------------------- | |
122 | //int Check_D_SmartMedia(void) | |
123 | //{ | |
124 | // if (Check_D_MediaExist()) | |
125 | // return(ErrCode); | |
126 | // | |
127 | // return(NO_ERROR); | |
128 | //} | |
129 | // | |
130 | ////----- Check_D_Parameter() -------------------------------------------- | |
131 | //int Check_D_Parameter(PFDO_DEVICE_EXTENSION fdoExt,WORD *pcyl,BYTE *phead,BYTE *psect) | |
132 | //{ | |
133 | // if (Check_D_MediaPower()) | |
134 | // return(ErrCode); | |
135 | // | |
136 | // if (Check_D_MediaFmt(fdoExt)) | |
137 | // return(ErrCode); | |
138 | // | |
139 | // if (Check_D_LogCHS(pcyl,phead,psect)) | |
140 | // return(ErrCode); | |
141 | // | |
142 | // return(NO_ERROR); | |
143 | //} | |
144 | ||
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) | |
148 | { | |
149 | WORD len, bn; | |
150 |