📄 tpbulk.lst
字号:
C51 COMPILER V6.20c TPBULK 08/21/2003 22:51:01 PAGE 1
C51 COMPILER V6.20c, COMPILATION OF MODULE TPBULK
OBJECT MODULE PLACED IN TPBULK.OBJ
COMPILER INVOKED BY: E:\WIN98\HARDWARE\KEILC\C51\BIN\C51.EXE TPBULK.C BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include "common.h"
2 #include "SL811.H"
3 #include "TPBULK.H"
4 #include "HAL.H"
5 #include "HPI.H"
6 //#include "common.h"
7
8 //////////////////////////////////
9 extern unsigned char xdata DBUF[BUFFER_LENGTH];
10 extern XXGPKG usbstack;
11 extern SYS_INFO_BLOCK xdata DeviceInfo;
12 extern FILE_INFO xdata ThisFile;
13 extern FREE_FAT_INFO xdata FreeFat;
14 extern unsigned char xdata CurFatSector[512];
15
16 TPBLK_STRUC idata TPBulk_Block;
17 #define TPBulk_CBW TPBulk_Block.TPBulk_CommandBlock
18 #define CBW_wXferLen TPBulk_CBW.dCBW_DataXferLen
19 #define RBC_CDB TPBulk_CBW.cdbRBC
20 #define RBC_LUN TPBulk_CBW.bCBW_LUN
21 #define TPBulk_CSW TPBulk_Block.TPBulk_CommandStatus
22
23 ///////////////////////////////////////////////////////////////////////////
24 unsigned char EnumMassDev(void)
25 {
26 1
27 1 PMBR_BLOCK pMBR;
28 1 PBPB_BLOCK pBPB;
29 1 ////////////////////////////////////////////////////
30 1 if(!SPC_Inquiry())
31 1 return FALSE;
32 1 //if(!SPC_READLONG())
33 1 // return FALSE;
34 1 if(!SPC_TestUnit())
35 1 return FALSE;
36 1 if(!SPC_LockMedia())
37 1 return FALSE;
38 1 if(!SPC_RequestSense())
39 1 return FALSE;
40 1 if(!SPC_TestUnit())
41 1 return FALSE;
42 1 if(!RBC_ReadCapacity())
43 1 return FALSE;
44 1 ////////////////////////////////////////////////////
45 1 pMBR=(PMBR_BLOCK)DBUF;
46 1 DeviceInfo.BPB_BytesPerSec=512; //暂假设为512
47 1 //if(!RBC_Read(0x0,1,DBUF))
48 1 // return FALSE;
49 1
50 1 if(!SPC_RequestSense())
51 1 return FALSE;
52 1 if(!SPC_TestUnit())
53 1 return FALSE;
54 1 if(!RBC_ReadCapacity())
55 1 return FALSE;
C51 COMPILER V6.20c TPBULK 08/21/2003 22:51:01 PAGE 2
56 1 if(!RBC_Read(0x0,1,DBUF))
57 1 return FALSE;
58 1 //////////////////////////////////
59 1 if(DBUF[0]==0xeb||DBUF[0]==0xe9)
60 1 {
61 2 DeviceInfo.StartSector=0;
62 2 //DeviceInfo.TotalSector=SwapINT32(pMBR->TotalSector);
63 2 }
64 1 else
65 1 {
66 2 //////////////////////////////////
67 2 DeviceInfo.StartSector=SwapINT32(pMBR->StartSector);
68 2 //DeviceInfo.TotalSector=SwapINT32(pMBR->TotalSector);
69 2 }
70 1 ///////////////////////////////////////////////////////
71 1 pBPB=(PBPB_BLOCK)DBUF;
72 1 if(!RBC_Read(DeviceInfo.StartSector,1,DBUF))
73 1 return FALSE;
74 1 DeviceInfo.BPB_BytesPerSec=SwapINT16(pBPB->BPB_BytesPerSec);
75 1 DeviceInfo.BPB_SecPerClus=pBPB->BPB_SecPerClus;
76 1 DeviceInfo.BPB_NumFATs=pBPB->BPB_NumFATs;
77 1 DeviceInfo.BPB_RootEntCnt=SwapINT16(pBPB->BPB_RootEntCnt);
78 1 DeviceInfo.BPB_TotSec16=SwapINT16(pBPB->BPB_TotSec16);
79 1 DeviceInfo.BPB_FATSz16=SwapINT16(pBPB->BPB_FATSz16);
80 1 DeviceInfo.BPB_TotSec32=SwapINT32(pBPB->BPB_TotSec32);
81 1 DeviceInfo.FatStartSector=DeviceInfo.StartSector+1;
82 1 DeviceInfo.RootStartSector=DeviceInfo.StartSector+2*DeviceInfo.BPB_FATSz16+1;
83 1 //DeviceInfo.DataStartSector=DeviceInfo.RootStartSector+DeviceInfo.BPB_RootEntCnt;
84 1 DeviceInfo.FirstDataSector=DeviceInfo.FatStartSector+2*DeviceInfo.BPB_FATSz16+32;
85 1 //DeviceInfo.FirstSectorofCluster=;
86 1 ///////////////////////////////////////////////////////
87 1 ThisFile.bFileOpen=0;
88 1 ///////////////////////////////////////////////////////
89 1
90 1 //FreeFat.SectorNum=DeviceInfo.FatStartSector;
91 1 //FreeFat.OldSectorNum=DeviceInfo.FatStartSector;
92 1 //FreeFat.OffsetofSector=2;
93 1 //(!RBC_Read(FreeFat.SectorNum,1,CurFatSector))
94 1 // return 0x0;
95 1 ///////////////////////////////////////////////////////
96 1 return TRUE;
97 1 }
98
99 unsigned char TPBulk_GetMaxLUN(void)
100 {
101 1
102 1 usbstack.setup.bmRequest=0xa1;
103 1 usbstack.setup.bRequest=0xfe;
104 1 usbstack.setup.wValue=0;
105 1 usbstack.setup.wIndex=0;
106 1 usbstack.setup.wLength=1;
107 1 usbstack.buffer=DBUF;
108 1 return ep0Xfer();
109 1
110 1 }
111
112 unsigned char SPC_Inquiry(void)
113 {
114 1 #define cdbInquirySPC RBC_CDB.SpcCdb_Inquiry
115 1 //unsigned char len;
116 1 //unsigned char retStatus=FALSE;
117 1 TPBulk_CBW.dCBW_Signature=CBW_SIGNATURE;
C51 COMPILER V6.20c TPBULK 08/21/2003 22:51:01 PAGE 3
118 1 TPBulk_CBW.dCBW_Tag=0x60a624de;
119 1 TPBulk_CBW.dCBW_DataXferLen=0x24000000;
120 1 TPBulk_CBW.bCBW_Flag=0x80;
121 1 TPBulk_CBW.bCBW_LUN=0;
122 1 TPBulk_CBW.bCBW_CDBLen=sizeof(INQUIRY_SPC);
123 1
124 1 /////////////////////////////////
125 1 cdbInquirySPC.OperationCode=SPC_CMD_INQUIRY;
126 1 cdbInquirySPC.EnableVPD=0;
127 1 cdbInquirySPC.CmdSupportData=0;
128 1 cdbInquirySPC.PageCode=0;
129 1 cdbInquirySPC.AllocationLen=0x24;
130 1 cdbInquirySPC.Control=0;
131 1 ////////////////////////////////
132 1 //if(!epBulkRcv(DBUF,5))
133 1 // return FALSE;
134 1 if(!epBulkSend((unsigned char *)&TPBulk_CBW,sizeof(TPBulk_CBW)))
135 1 return FALSE;
136 1
137 1 if(!epBulkRcv(DBUF,38))
138 1 return FALSE;
139 1 if(!epBulkRcv((unsigned char *)&TPBulk_CSW,13))
140 1 return FALSE;
141 1 ////////////////////////////////
142 1 return TRUE;
143 1 #undef cdbInquirySPC
144 1 }
145
146 unsigned char SPC_READLONG(void)
147 {
148 1 #define cdbReadLong RBC_CDB.SpcCdb_ReadLong
149 1 //nsigned char retStatus=FALSE;
150 1 TPBulk_CBW.dCBW_Signature=CBW_SIGNATURE;
151 1 TPBulk_CBW.dCBW_Tag=0x60a624de;
152 1 TPBulk_CBW.dCBW_DataXferLen=0xfc000000;
153 1 TPBulk_CBW.bCBW_Flag=0x80;
154 1 TPBulk_CBW.bCBW_LUN=0;
155 1 TPBulk_CBW.bCBW_CDBLen=sizeof(READ_LONG_CMD);
156 1
157 1 /////////////////////////////////////
158 1 cdbReadLong.OperationCode=SPC_CMD_READLONG;
159 1 cdbReadLong.LogicalUnitNum=0;
160 1 cdbReadLong.AllocationLen=0xfc;
161 1 //////////////////////////////////////
162 1 if(!epBulkSend((unsigned char *)&TPBulk_CBW,sizeof(TPBulk_CBW)))
163 1 return FALSE;
164 1
165 1 if(!epBulkRcv(DBUF,0xfc))
166 1 return FALSE;
167 1
168 1 if(!epBulkRcv((unsigned char *)&TPBulk_CSW,13))
169 1 return FALSE;
170 1 ////////////////////////////
171 1 return TRUE;
172 1 #undef cdbReadLong
173 1 }
174 unsigned char SPC_RequestSense(void)
175 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -