📄 sbc.lst
字号:
C51 COMPILER V7.50 SBC 06/03/2006 10:32:52 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE SBC
OBJECT MODULE PLACED IN sbc.obj
COMPILER INVOKED BY: C:\Program Files\keil\C51\BIN\C51.EXE lib_storage\sbc.c LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\sbc
-.lst) OBJECT(sbc.obj)
line level source
1 //sbc_operation
2
3
4 #include "config.h" /* system configuration */
5 #include "lib_mcu\usb\usb_drv.h" /* usb driver definition */
6 #include "modules\mem\hard.h" /* low level function definition */
7 #include "lib_storage\sbc.h" /* SBC commands definition */
8 #include "lib_mcu\ide\ideio.h"
9
10 //#define Usb_clear_RXOUTB0() {if(UEPSTAX & 0x42) UEPSTAX &= 0xbd;}
11
12 uchar code HDD_MANUFACTURER_ID[] = "QUANTUM ";
13 uchar code HDD_PRODUCT_ID[] = "HDD_650M_MP3_ST ";
14 uchar code HDD_REVITION[] = "1.0 ";
15
16 bdata bit no_data_phase;
17 Uint32 data hdd_sector;
18 Uint16 data hdd_data_length;
19 extern data Uint32 dCBWDataTransferLength;
20 extern xdata Uint32 fat_bpb_add; /* address of the first byte of FAT */
21
22
23
24 extern void usb_mass_storage_csw (void);
25
26
27
28 void scsi_command_iquiry(void)
29 {uchar inquiry_allocation_length;
30 1 uchar i;
31 1 ACC = Usb_read_byte(); //read LUN
32 1 ACC = Usb_read_byte(); //read pagecode
33 1 ACC = Usb_read_byte(); //read Reserved
34 1 inquiry_allocation_length = Usb_read_byte(); //read inquiry_allocation_length
35 1 ACC = Usb_read_byte(); //read control code
36 1
37 1 Usb_clear_RXOUT_PP();
38 1
39 1 Usb_clear_no_data_phase();
40 1 Usb_clear_status_ready();
41 1 Usb_select_ep(EP_IN);
42 1
43 1 Usb_write_byte(0x00); //外设属性
44 1 Usb_write_byte(0x80); //设备可移动
45 1 Usb_write_byte(0x00);
46 1 Usb_write_byte(0x01);
47 1 Usb_write_byte(inquiry_allocation_length-5); //以下还有相应的字节数传输
48 1 Usb_write_byte(0x00);
49 1 Usb_write_byte(0x00);
50 1 Usb_write_byte(0x00);
51 1
52 1 for (i=0; i<8; i++)
53 1 Usb_write_byte(HDD_MANUFACTURER_ID[i]);
54 1
C51 COMPILER V7.50 SBC 06/03/2006 10:32:52 PAGE 2
55 1 for (i=0; i<16; i++)
56 1 Usb_write_byte(HDD_PRODUCT_ID[i]);
57 1
58 1 for (i=0; i<4; i++)
59 1 Usb_write_byte(HDD_REVITION[i]);
60 1
61 1 Usb_set_TXRDY();
62 1 Usb_select_ep(EP_IN);
63 1 while (!Usb_tx_complete());
64 1 Usb_clear_TXCMPL();
65 1 dCBWDataTransferLength = 0;
66 1 status = 0;
67 1 }
68
69
70 void scsi_command_read_long(void)
71 {
72 1 Usb_clear_RXOUT_PP();
73 1
74 1 Usb_clear_no_data_phase();
75 1 Usb_clear_status_ready();
76 1 Usb_select_ep(EP_IN);
77 1
78 1 Usb_write_byte(0x00);
79 1 Usb_write_byte(0x00);
80 1 Usb_write_byte(0x00);
81 1 Usb_write_byte(0x08);
82 1 Usb_write_byte(0x00);
83 1 Usb_write_byte(0x00);
84 1 Usb_write_byte(0x00);
85 1 Usb_write_byte(0x00);
86 1 Usb_write_byte(0x0c);
87 1 Usb_write_byte(0x00);
88 1 Usb_write_byte(0x02);
89 1 Usb_write_byte(0x00);
90 1
91 1 Usb_set_TXRDY();
92 1 Usb_select_ep(EP_IN);
93 1 while (!Usb_tx_complete());
94 1 Usb_clear_TXCMPL();
95 1 dCBWDataTransferLength = 0;
96 1 status = 0;
97 1 }
98
99 void scsi_command_read_capacity(void)
100 {
101 1 Usb_clear_RXOUT_PP();
102 1
103 1 Usb_clear_no_data_phase();
104 1 Usb_clear_status_ready();
105 1 Usb_select_ep(EP_IN);
106 1
107 1 Usb_write_byte(0x00);
108 1 Usb_write_byte(0x14);
109 1 Usb_write_byte(0x50);
110 1 Usb_write_byte(0x00);
111 1 Usb_write_byte(0x00);
112 1 Usb_write_byte(0x00);
113 1 Usb_write_byte(0x02);
114 1 Usb_write_byte(0x00);
115 1
116 1 Usb_set_TXRDY();
C51 COMPILER V7.50 SBC 06/03/2006 10:32:52 PAGE 3
117 1 Usb_select_ep(EP_IN);
118 1 while (!Usb_tx_complete());
119 1 Usb_clear_TXCMPL();
120 1 dCBWDataTransferLength = 0;
121 1 status = 0;
122 1 }
123
124
125 void scsi_command_mode_sence(void)
126 { Usb_clear_RXOUT_PP();
127 1
128 1 Usb_clear_no_data_phase();
129 1 Usb_clear_status_ready();
130 1 Usb_select_ep(EP_IN);
131 1
132 1 Usb_write_byte(0x03);
133 1 Usb_write_byte(0x00);
134 1 Usb_write_byte(0x00);
135 1 Usb_write_byte(0x00);
136 1
137 1 Usb_set_TXRDY();
138 1 Usb_select_ep(EP_IN);
139 1 while (!Usb_tx_complete());
140 1 Usb_clear_TXCMPL();
141 1 dCBWDataTransferLength = 0;
142 1 status = 0;
143 1 }
144
145 void scsi_command_test_uint_ready(void)
146 {
147 1 Usb_clear_RXOUT_PP();
148 1 dCBWDataTransferLength = 0;
149 1 status = 0;
150 1 }
151
152 void Sbc_chip_init (void)
153 {
154 1 Hard_install();
155 1 }
156
157
158 void Sbc_command_chip(void)
159 {
160 1 uchar rwtime;
161 1 uchar i;
162 1
163 1 switch(Usb_read_byte()) //read operate code
164 1 {
165 2 case SCSI_IQUIRY:
166 2 {scsi_command_iquiry();
167 3 break;
168 3 }
169 2 case SCSI_READ_LONG:
170 2 {scsi_command_read_long();
171 3 break;
172 3 }
173 2 case SCSI_READ_CAPACITY:
174 2 {scsi_command_read_capacity();
175 3 break;
176 3 }
177 2 case SCSI_MODE_SENCE:
178 2 {
C51 COMPILER V7.50 SBC 06/03/2006 10:32:52 PAGE 4
179 3 scsi_command_mode_sence();
180 3 break;
181 3 }
182 2
183 2 case SCSI_TEST_UNIT_READY:
184 2 {
185 3 scsi_command_test_uint_ready();
186 3 break;
187 3 }
188 2
189 2 case SCSI_READ:
190 2 {
191 3 ACC = Usb_read_byte();
192 3 ((Byte*)&hdd_sector)[0] = Usb_read_byte();
193 3 ((Byte*)&hdd_sector)[1] = Usb_read_byte();
194 3 ((Byte*)&hdd_sector)[2] = Usb_read_byte();
195 3 ((Byte*)&hdd_sector)[3] = Usb_read_byte();
196 3 ACC = Usb_read_byte();
197 3 ((Byte*)&hdd_data_length)[0] = Usb_read_byte();
198 3 ((Byte*)&hdd_data_length)[1] = Usb_read_byte();
199 3
200 3 rwtime = hdd_data_length;
201 3 Usb_clear_RXOUT_PP();
202 3
203 3 for(i = 0; i < rwtime; i++)
204 3 {
205 4 if (hdd_read_one_sector(hdd_sector+i))
206 4 {dCBWDataTransferLength = 0;
207 5 status = 0;
208 5 }
209 4 else
210 4 {status = 1;
211 5 break;
212 5 }
213 4 }
214 3 break;
215 3 }
216 2
217 2 case SCSI_WRITE:
218 2 {
219 3 ACC = Usb_read_byte();
220 3 ((Byte*)&hdd_sector)[0] = Usb_read_byte();
221 3 ((Byte*)&hdd_sector)[1] = Usb_read_byte();
222 3 ((Byte*)&hdd_sector)[2] = Usb_read_byte();
223 3 ((Byte*)&hdd_sector)[3] = Usb_read_byte();
224 3 ACC = Usb_read_byte();
225 3 ((Byte*)&hdd_data_length)[0] = Usb_read_byte();
226 3 ((Byte*)&hdd_data_length)[1] = Usb_read_byte();
227 3
228 3 rwtime = hdd_data_length;
229 3 Usb_clear_RXOUT_PP();
230 3
231 3 for(i = 0; i < rwtime; i++)
232 3 {
233 4 if (hdd_write_usb_sector(hdd_sector+i))
234 4 {
235 5 dCBWDataTransferLength = 0;
236 5 status = 0;
237 5 }
238 4 }
239 3
240 3 break;
C51 COMPILER V7.50 SBC 06/03/2006 10:32:52 PAGE 5
241 3 }
242 2
243 2
244 2 default :
245 2 {
246 3 Usb_clear_RXOUT_PP();
247 3 dCBWDataTransferLength = 0;
248 3 status = 0;
249 3 break;
250 3 }
251 2
252 2 }
253 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 624 ----
CONSTANT SIZE = 31 ----
XDATA SIZE = ---- 2
PDATA SIZE = ---- ----
DATA SIZE = 6 ----
IDATA SIZE = ---- ----
BIT SIZE = 1 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -