Rev 837 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 837 | Rev 846 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;; ;; |
6 | ;; ;; |
7 | ;; System service for filesystem call ;; |
7 | ;; System service for filesystem call ;; |
8 | ;; (C) 2004 Ville Turjanmaa, License: GPL ;; |
8 | ;; (C) 2004 Ville Turjanmaa, License: GPL ;; |
9 | ;; 29.04.2006 Elimination of hangup after the ;; |
9 | ;; 29.04.2006 Elimination of hangup after the ;; |
10 | ;; expiration hd_wait_timeout (for LBA) - Mario79 ;; |
10 | ;; expiration hd_wait_timeout (for LBA) - Mario79 ;; |
11 | ;; 15.01.2005 get file size/attr/date, ;; |
11 | ;; 15.01.2005 get file size/attr/date, ;; |
12 | ;; file_append (only for hd) - ATV ;; |
12 | ;; file_append (only for hd) - ATV ;; |
13 | ;; 23.11.2004 test if hd/partition is set - ATV ;; |
13 | ;; 23.11.2004 test if hd/partition is set - ATV ;; |
14 | ;; 18.11.2004 get_disk_info and more error codes - ATV ;; |
14 | ;; 18.11.2004 get_disk_info and more error codes - ATV ;; |
15 | ;; 08.11.2004 expand_pathz and rename (only for hd) - ATV ;; |
15 | ;; 08.11.2004 expand_pathz and rename (only for hd) - ATV ;; |
16 | ;; 20.10.2004 Makedir/Removedir (only for hd) - ATV ;; |
16 | ;; 20.10.2004 Makedir/Removedir (only for hd) - ATV ;; |
17 | ;; ;; |
17 | ;; ;; |
18 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
18 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
19 | 19 | ||
20 | $Revision: 709 $ |
20 | $Revision: 846 $ |
21 | 21 | ||
22 | 22 | ||
23 | iglobal |
23 | iglobal |
24 | dir0: db 'HARDDISK ' |
24 | dir0: db 'HARDDISK ' |
25 | db 'RAMDISK ' |
25 | db 'RAMDISK ' |
26 | db 'FLOPPYDISK ' |
26 | db 'FLOPPYDISK ' |
27 | db 0 |
27 | db 0 |
28 | 28 | ||
29 | dir1: db 'FIRST ' |
29 | dir1: db 'FIRST ' |
30 | db 'SECOND ' |
30 | db 'SECOND ' |
31 | db 'THIRD ' |
31 | db 'THIRD ' |
32 | db 'FOURTH ' |
32 | db 'FOURTH ' |
33 | db 0 |
33 | db 0 |
34 | 34 | ||
35 | not_select_IDE db 0 |
35 | not_select_IDE db 0 |
36 | 36 | ||
37 | hd_address_table: dd 0x1f0,0x00,0x1f0,0x10 |
37 | hd_address_table: dd 0x1f0,0x00,0x1f0,0x10 |
38 | dd 0x170,0x00,0x170,0x10 |
38 | dd 0x170,0x00,0x170,0x10 |
39 | endg |
39 | endg |
40 | 40 | ||
41 | file_system: |
41 | file_system: |
42 | 42 | ||
43 | ; IN: |
43 | ; IN: |
44 | ; |
44 | ; |
45 | ; eax = 0 ; read file /RamDisk/First 6 |
45 | ; eax = 0 ; read file /RamDisk/First 6 |
46 | ; eax = 8 ; lba read |
46 | ; eax = 8 ; lba read |
47 | ; eax = 15 ; get_disk_info |
47 | ; eax = 15 ; get_disk_info |
48 | ; |
48 | ; |
49 | ; OUT: |
49 | ; OUT: |
50 | ; |
50 | ; |
51 | ; eax = 0 : read ok |
51 | ; eax = 0 : read ok |
52 | ; eax = 1 : no hd base and/or partition defined |
52 | ; eax = 1 : no hd base and/or partition defined |
53 | ; eax = 2 : function is unsupported for this FS |
53 | ; eax = 2 : function is unsupported for this FS |
54 | ; eax = 3 : unknown FS |
54 | ; eax = 3 : unknown FS |
55 | ; eax = 4 : partition not defined at hd |
55 | ; eax = 4 : partition not defined at hd |
56 | ; eax = 5 : file not found |
56 | ; eax = 5 : file not found |
57 | ; eax = 6 : end of file |
57 | ; eax = 6 : end of file |
58 | ; eax = 7 : memory pointer not in application area |
58 | ; eax = 7 : memory pointer not in application area |
59 | ; eax = 8 : disk full |
59 | ; eax = 8 : disk full |
60 | ; eax = 9 : fat table corrupted |
60 | ; eax = 9 : fat table corrupted |
61 | ; eax = 10 : access denied |
61 | ; eax = 10 : access denied |
62 | ; eax = 11 : disk error |
62 | ; eax = 11 : disk error |
63 | ; |
63 | ; |
64 | ; ebx = size |
64 | ; ebx = size |
65 | 65 | ||
66 | ; \begin{diamond}[18.03.2006] |
66 | ; \begin{diamond}[18.03.2006] |
67 | ; for subfunction 16 (start application) error codes must be negative |
67 | ; for subfunction 16 (start application) error codes must be negative |
68 | ; because positive values are valid PIDs |
68 | ; because positive values are valid PIDs |
69 | ; so possible return values are: |
69 | ; so possible return values are: |
70 | ; eax > 0 : process created, eax=PID |
70 | ; eax > 0 : process created, eax=PID |
71 | 71 | ||
72 | ; -0x10 <= eax < 0 : -eax is filesystem error code: |
72 | ; -0x10 <= eax < 0 : -eax is filesystem error code: |
73 | ; eax = -1 = 0xFFFFFFFF : no hd base and/or partition defined |
73 | ; eax = -1 = 0xFFFFFFFF : no hd base and/or partition defined |
74 | ; eax = -3 = 0xFFFFFFFD : unknown FS |
74 | ; eax = -3 = 0xFFFFFFFD : unknown FS |
75 | ; eax = -5 = 0xFFFFFFFB : file not found |
75 | ; eax = -5 = 0xFFFFFFFB : file not found |
76 | ; eax = -6 = 0xFFFFFFFA : unexpected end of file (probably not executable file) |
76 | ; eax = -6 = 0xFFFFFFFA : unexpected end of file (probably not executable file) |
77 | ; eax = -9 = 0xFFFFFFF7 : fat table corrupted |
77 | ; eax = -9 = 0xFFFFFFF7 : fat table corrupted |
78 | ; eax = -10 = 0xFFFFFFF6 : access denied |
78 | ; eax = -10 = 0xFFFFFFF6 : access denied |
79 | 79 | ||
80 | ; -0x20 <= eax < -0x10: eax is process creation error code: |
80 | ; -0x20 <= eax < -0x10: eax is process creation error code: |
81 | ; eax = -0x20 = 0xFFFFFFE0 : too many processes |
81 | ; eax = -0x20 = 0xFFFFFFE0 : too many processes |
82 | ; eax = -0x1F = 0xFFFFFFE1 : not Menuet/Kolibri executable |
82 | ; eax = -0x1F = 0xFFFFFFE1 : not Menuet/Kolibri executable |
83 | ; eax = -0x1E = 0xFFFFFFE2 : no memory |
83 | ; eax = -0x1E = 0xFFFFFFE2 : no memory |
84 | 84 | ||
85 | ; ebx is not changed |
85 | ; ebx is not changed |
86 | 86 | ||
87 | ; \end{diamond}[18.03.2006] |
87 | ; \end{diamond}[18.03.2006] |
88 | 88 | ||
89 | ; Extract parameters |
89 | ; Extract parameters |
90 | ; add eax, std_application_base_address ; abs start of info block |
90 | ; add eax, std_application_base_address ; abs start of info block |
91 | 91 | ||
92 | cmp dword [eax+0],15 ; GET_DISK_INFO |
92 | cmp dword [eax+0],15 ; GET_DISK_INFO |
93 | je fs_info |
93 | je fs_info |
94 | 94 | ||
95 | cmp dword [CURRENT_TASK],1 ; no memory checks for kernel requests |
95 | cmp dword [CURRENT_TASK],1 ; no memory checks for kernel requests |
96 | jz no_checks_for_kernel |
96 | jz no_checks_for_kernel |
97 | mov edx,eax |
97 | mov edx,eax |
98 | cmp dword [eax+0],1 |
98 | cmp dword [eax+0],1 |
99 | jnz .usual_check |
99 | jnz .usual_check |
100 | mov ebx,[eax+12] |
100 | mov ebx,[eax+12] |
101 | ; add ebx,std_application_base_address |
101 | ; add ebx,std_application_base_address |
102 | mov ecx,[eax+8] |
102 | mov ecx,[eax+8] |
103 | call check_region |
103 | call check_region |
104 | test eax,eax |
104 | test eax,eax |
105 | jnz area_in_app_mem |
105 | jnz area_in_app_mem |
106 | 106 | ||
107 | .error_output: |
107 | .error_output: |
108 | mov esi,buffer_failed |
108 | mov esi,buffer_failed |
109 | call sys_msg_board_str |
109 | call sys_msg_board_str |
110 | ; mov eax,7 |
110 | ; mov eax,7 |
111 | mov dword [esp+36],7 |
111 | mov dword [esp+36],7 |
112 | ret |
112 | ret |
113 | iglobal |
113 | iglobal |
114 | buffer_failed db 'K : Buffer check failed',13,10,0 |
114 | buffer_failed db 'K : Buffer check failed',13,10,0 |
115 | endg |
115 | endg |
116 | .usual_check: |
116 | .usual_check: |
117 | cmp dword [eax+0],0 |
117 | cmp dword [eax+0],0 |
118 | mov ecx,512 |
118 | mov ecx,512 |
119 | jnz .small_size |
119 | jnz .small_size |
120 | mov ecx,[eax+8] |
120 | mov ecx,[eax+8] |
121 | shl ecx,9 |
121 | shl ecx,9 |
122 | .small_size: |
122 | .small_size: |
123 | mov ebx,[eax+12] |
123 | mov ebx,[eax+12] |
124 | ; add ebx,std_application_base_address |
124 | ; add ebx,std_application_base_address |
125 | call check_region |
125 | call check_region |
126 | test eax,eax |
126 | test eax,eax |
127 | jz .error_output |
127 | jz .error_output |
128 | area_in_app_mem: |
128 | area_in_app_mem: |
129 | mov eax,edx |
129 | mov eax,edx |
130 | no_checks_for_kernel: |
130 | no_checks_for_kernel: |
131 | 131 | ||
132 | fs_read: |
132 | fs_read: |
133 | 133 | ||
134 | mov ebx,[eax+20] ; program wants root directory ? |
134 | mov ebx,[eax+20] ; program wants root directory ? |
135 | test bl,bl |
135 | test bl,bl |
136 | je fs_getroot |
136 | je fs_getroot |
137 | test bh,bh |
137 | test bh,bh |
138 | jne fs_noroot |
138 | jne fs_noroot |
139 | fs_getroot: |
139 | fs_getroot: |
140 | ; \begin{diamond}[18.03.2006] |
140 | ; \begin{diamond}[18.03.2006] |
141 | ; root - only read is allowed |
141 | ; root - only read is allowed |
142 | ; other operations return "access denied", eax=10 |
142 | ; other operations return "access denied", eax=10 |
143 | ; (execute operation returns eax=-10) |
143 | ; (execute operation returns eax=-10) |
144 | cmp dword [eax], 0 |
144 | cmp dword [eax], 0 |
145 | jz .read_root |
145 | jz .read_root |
146 | mov dword [esp+36], 10 |
146 | mov dword [esp+36], 10 |
147 | ret |
147 | ret |
148 | .read_root: |
148 | .read_root: |
149 | ; \end{diamond}[18.03.2006] |
149 | ; \end{diamond}[18.03.2006] |
150 | mov esi,dir0 |
150 | mov esi,dir0 |
151 | mov edi,[eax+12] |
151 | mov edi,[eax+12] |
152 | ; add edi,std_application_base_address |
152 | ; add edi,std_application_base_address |
153 | mov ecx,11 |
153 | mov ecx,11 |
154 | push ecx |
154 | push ecx |
155 | ; cld ; already is |
155 | ; cld ; already is |
156 | rep movsb |
156 | rep movsb |
157 | mov al,0x10 |
157 | mov al,0x10 |
158 | stosb |
158 | stosb |
159 | add edi,32-11-1 |
159 | add edi,32-11-1 |
160 | pop ecx |
160 | pop ecx |
161 | rep movsb |
161 | rep movsb |
162 | stosb |
162 | stosb |
163 | and dword [esp+36],0 ; ok read |
163 | and dword [esp+36],0 ; ok read |
164 | mov dword [esp+24],32*2 ; size of root |
164 | mov dword [esp+24],32*2 ; size of root |
165 | ret |
165 | ret |
166 | 166 | ||
167 | fs_info: ;start of code - Mihasik |
167 | fs_info: ;start of code - Mihasik |
168 | push eax |
168 | push eax |
169 | cmp [eax+21],byte 'h' |
169 | cmp [eax+21],byte 'h' |
170 | je fs_info_h |
170 | je fs_info_h |
171 | cmp [eax+21],byte 'H' |
171 | cmp [eax+21],byte 'H' |
172 | je fs_info_h |
172 | je fs_info_h |
173 | cmp [eax+21],byte 'r' |
173 | cmp [eax+21],byte 'r' |
174 | je fs_info_r |
174 | je fs_info_r |
175 | cmp [eax+21],byte 'R' |
175 | cmp [eax+21],byte 'R' |
176 | je fs_info_r |
176 | je fs_info_r |
177 | mov eax,3 ;if unknown disk |
177 | mov eax,3 ;if unknown disk |
178 | xor ebx,ebx |
178 | xor ebx,ebx |
179 | xor ecx,ecx |
179 | xor ecx,ecx |
180 | xor edx,edx |
180 | xor edx,edx |
181 | jmp fs_info1 |
181 | jmp fs_info1 |
182 | fs_info_r: |
182 | fs_info_r: |
183 | call ramdisk_free_space ;if ramdisk |
183 | call ramdisk_free_space ;if ramdisk |
184 | mov ecx,edi ;free space in ecx |
184 | mov ecx,edi ;free space in ecx |
185 | shr ecx,9 ;free clusters |
185 | shr ecx,9 ;free clusters |
186 | mov ebx,2847 ;total clusters |
186 | mov ebx,2847 ;total clusters |
187 | mov edx,512 ;cluster size |
187 | mov edx,512 ;cluster size |
188 | xor eax,eax ;always 0 |
188 | xor eax,eax ;always 0 |
189 | jmp fs_info1 |
189 | jmp fs_info1 |
190 | fs_info_h: ;if harddisk |
190 | fs_info_h: ;if harddisk |
191 | call get_hd_info |
191 | call get_hd_info |
192 | fs_info1: |
192 | fs_info1: |
193 | pop edi |
193 | pop edi |
194 | mov [esp+36],eax |
194 | mov [esp+36],eax |
195 | mov [esp+24],ebx ; total clusters on disk |
195 | mov [esp+24],ebx ; total clusters on disk |
196 | mov [esp+32],ecx ; free clusters on disk |
196 | mov [esp+32],ecx ; free clusters on disk |
197 | mov [edi],edx ; cluster size in bytes |
197 | mov [edi],edx ; cluster size in bytes |
198 | ret ;end of code - Mihasik |
198 | ret ;end of code - Mihasik |
199 | 199 | ||
200 | fs_noroot: |
200 | fs_noroot: |
201 | 201 | ||
202 | push dword [eax+0] ; read/write/delete/.../makedir/rename/lba/run |
202 | push dword [eax+0] ; read/write/delete/.../makedir/rename/lba/run |
203 | push dword [eax+4] ; 512 block number to read |
203 | push dword [eax+4] ; 512 block number to read |
204 | push dword [eax+8] ; bytes to write/append or 512 blocks to read |
204 | push dword [eax+8] ; bytes to write/append or 512 blocks to read |
205 | mov ebx,[eax+12] |
205 | mov ebx,[eax+12] |
206 | ; add ebx,std_application_base_address |
206 | ; add ebx,std_application_base_address |
207 | push ebx ; abs start of return/save area |
207 | push ebx ; abs start of return/save area |
208 | 208 | ||
209 | lea esi,[eax+20] ; abs start of dir + filename |
209 | lea esi,[eax+20] ; abs start of dir + filename |
210 | mov edi,[eax+16] |
210 | mov edi,[eax+16] |
211 | ; add edi,std_application_base_address ; abs start of work area |
211 | ; add edi,std_application_base_address ; abs start of work area |
212 | 212 | ||
213 | call expand_pathz |
213 | call expand_pathz |
214 | 214 | ||
215 | push edi ; dir start |
215 | push edi ; dir start |
216 | push ebx ; name of file start |
216 | push ebx ; name of file start |
217 | 217 | ||
218 | mov eax,[edi+1] |
218 | mov eax,[edi+1] |
219 | cmp eax,'RD ' |
219 | cmp eax,'RD ' |
220 | je fs_yesramdisk |
220 | je fs_yesramdisk |
221 | cmp eax,'RAMD' |
221 | cmp eax,'RAMD' |
222 | jne fs_noramdisk |
222 | jne fs_noramdisk |
223 | 223 | ||
224 | fs_yesramdisk: |
224 | fs_yesramdisk: |
225 | 225 | ||
226 | cmp byte [edi+1+11],0 |
226 | cmp byte [edi+1+11],0 |
227 | je fs_give_dir1 |
227 | je fs_give_dir1 |
228 | 228 | ||
229 | mov eax,[edi+1+12] |
229 | mov eax,[edi+1+12] |
230 | cmp eax,'1 ' |
230 | cmp eax,'1 ' |
231 | je fs_yesramdisk_first |
231 | je fs_yesramdisk_first |
232 | cmp eax,'FIRS' |
232 | cmp eax,'FIRS' |
233 | jne fs_noramdisk |
233 | jne fs_noramdisk |
234 | 234 | ||
235 | fs_yesramdisk_first: |
235 | fs_yesramdisk_first: |
236 | 236 | ||
237 | cmp dword [esp+20],8 ; LBA read ramdisk |
237 | cmp dword [esp+20],8 ; LBA read ramdisk |
238 | jne fs_no_LBA_read_ramdisk |
238 | jne fs_no_LBA_read_ramdisk |
239 | 239 | ||
240 | mov eax,[esp+16] ; LBA block to read |
240 | mov eax,[esp+16] ; LBA block to read |
241 | mov ecx,[esp+8] ; abs pointer to return area |
241 | mov ecx,[esp+8] ; abs pointer to return area |
242 | 242 | ||
243 | call LBA_read_ramdisk |
243 | call LBA_read_ramdisk |
244 | jmp file_system_return |
244 | jmp file_system_return |
245 | 245 | ||
246 | 246 | ||
247 | fs_no_LBA_read_ramdisk: |
247 | fs_no_LBA_read_ramdisk: |
248 | 248 | ||
249 | cmp dword [esp+20],0 ; READ |
249 | cmp dword [esp+20],0 ; READ |
250 | jne fs_noramdisk_read |
250 | jne fs_noramdisk_read |
251 | 251 | ||
252 | mov eax,[esp+4] ; fname |
252 | mov eax,[esp+4] ; fname |
253 | add eax,2*12+1 |
253 | add eax,2*12+1 |
254 | mov ebx,[esp+16] ; block start |
254 | mov ebx,[esp+16] ; block start |
255 | inc ebx |
255 | inc ebx |
256 | mov ecx,[esp+12] ; block count |
256 | mov ecx,[esp+12] ; block count |
257 | mov edx,[esp+8] ; return |
257 | mov edx,[esp+8] ; return |
258 | mov esi,[esp+0] |
258 | mov esi,[esp+0] |
259 | sub esi,eax |
259 | sub esi,eax |
260 | add esi,12+1 ; file name length |
260 | add esi,12+1 ; file name length |
261 | call fileread |
261 | call fileread |
262 | 262 | ||
263 | jmp file_system_return |
263 | jmp file_system_return |
264 | 264 | ||
265 | 265 | ||
266 | fs_noramdisk_read: |
266 | fs_noramdisk_read: |
267 | fs_noramdisk: |
267 | fs_noramdisk: |
268 | 268 | ||
269 | ;******************************************************************** |
269 | ;******************************************************************** |
270 | mov eax,[edi+1] |
270 | mov eax,[edi+1] |
271 | cmp eax,'FD ' |
271 | cmp eax,'FD ' |
272 | je fs_yesflpdisk |
272 | je fs_yesflpdisk |
273 | cmp eax,'FLOP' |
273 | cmp eax,'FLOP' |
274 | jne fs_noflpdisk |
274 | jne fs_noflpdisk |
275 | 275 | ||
276 | fs_yesflpdisk: |
276 | fs_yesflpdisk: |
277 | call reserve_flp |
277 | call reserve_flp |
278 | 278 | ||
279 | cmp byte [edi+1+11],0 |
279 | cmp byte [edi+1+11],0 |
280 | je fs_give_dir1 |
280 | je fs_give_dir1 |
281 | 281 | ||
282 | mov eax,[edi+1+12] |
282 | mov eax,[edi+1+12] |
283 | cmp eax,'1 ' |
283 | cmp eax,'1 ' |
284 | je fs_yesflpdisk_first |
284 | je fs_yesflpdisk_first |
285 | cmp eax,'FIRS' |
285 | cmp eax,'FIRS' |
286 | je fs_yesflpdisk_first |
286 | je fs_yesflpdisk_first |
287 | cmp eax,'2 ' |
287 | cmp eax,'2 ' |
288 | je fs_yesflpdisk_second |
288 | je fs_yesflpdisk_second |
289 | cmp eax,'SECO' |
289 | cmp eax,'SECO' |
290 | jne fs_noflpdisk |
290 | jne fs_noflpdisk |
291 | jmp fs_yesflpdisk_second |
291 | jmp fs_yesflpdisk_second |
292 | 292 | ||
293 | fs_yesflpdisk_first: |
293 | fs_yesflpdisk_first: |
294 | mov [flp_number],1 |
294 | mov [flp_number],1 |
295 | jmp fs_yesflpdisk_start |
295 | jmp fs_yesflpdisk_start |
296 | fs_yesflpdisk_second: |
296 | fs_yesflpdisk_second: |
297 | mov [flp_number],2 |
297 | mov [flp_number],2 |
298 | fs_yesflpdisk_start: |
298 | fs_yesflpdisk_start: |
299 | cmp dword [esp+20],0 ; READ |
299 | cmp dword [esp+20],0 ; READ |
300 | jne fs_noflpdisk_read |
300 | jne fs_noflpdisk_read |
301 | 301 | ||
302 | mov eax,[esp+4] ; fname |
302 | mov eax,[esp+4] ; fname |
303 | add eax,2*12+1 |
303 | add eax,2*12+1 |
304 | mov ebx,[esp+16] ; block start |
304 | mov ebx,[esp+16] ; block start |
305 | inc ebx |
305 | inc ebx |
306 | mov ecx,[esp+12] ; block count |
306 | mov ecx,[esp+12] ; block count |
307 | mov edx,[esp+8] ; return |
307 | mov edx,[esp+8] ; return |
308 | mov esi,[esp+0] |
308 | mov esi,[esp+0] |
309 | sub esi,eax |
309 | sub esi,eax |
310 | add esi,12+1 ; file name length |
310 | add esi,12+1 ; file name length |
311 | call floppy_fileread |
311 | call floppy_fileread |
312 | 312 | ||
313 | jmp file_system_return |
313 | jmp file_system_return |
314 | 314 | ||
315 | 315 | ||
316 | fs_noflpdisk_read: |
316 | fs_noflpdisk_read: |
317 | fs_noflpdisk: |
317 | fs_noflpdisk: |
318 | ;***************************************************************** |
318 | ;***************************************************************** |
319 | 319 | ||
320 | mov eax,[edi+1] |
320 | mov eax,[edi+1] |
321 | cmp eax,'HD0 ' |
321 | cmp eax,'HD0 ' |
322 | je fs_yesharddisk_IDE0 |
322 | je fs_yesharddisk_IDE0 |
323 | cmp eax,'HD1 ' |
323 | cmp eax,'HD1 ' |
324 | je fs_yesharddisk_IDE1 |
324 | je fs_yesharddisk_IDE1 |
325 | cmp eax,'HD2 ' |
325 | cmp eax,'HD2 ' |
326 | je fs_yesharddisk_IDE2 |
326 | je fs_yesharddisk_IDE2 |
327 | cmp eax,'HD3 ' |
327 | cmp eax,'HD3 ' |
328 | je fs_yesharddisk_IDE3 |
328 | je fs_yesharddisk_IDE3 |
329 | jmp old_path_harddisk |
329 | jmp old_path_harddisk |
330 | fs_yesharddisk_IDE0: |
330 | fs_yesharddisk_IDE0: |
331 | call reserve_hd1 |
331 | call reserve_hd1 |
332 | mov [hdbase],0x1f0 |
332 | mov [hdbase],0x1f0 |
333 | mov [hdid],0x0 |
333 | mov [hdid],0x0 |
334 | mov [hdpos],1 |
334 | mov [hdpos],1 |
335 | jmp fs_yesharddisk_partition |
335 | jmp fs_yesharddisk_partition |
336 | fs_yesharddisk_IDE1: |
336 | fs_yesharddisk_IDE1: |
337 | call reserve_hd1 |
337 | call reserve_hd1 |
338 | mov [hdbase],0x1f0 |
338 | mov [hdbase],0x1f0 |
339 | mov [hdid],0x10 |
339 | mov [hdid],0x10 |
340 | mov [hdpos],2 |
340 | mov [hdpos],2 |
341 | jmp fs_yesharddisk_partition |
341 | jmp fs_yesharddisk_partition |
342 | fs_yesharddisk_IDE2: |
342 | fs_yesharddisk_IDE2: |
343 | call reserve_hd1 |
343 | call reserve_hd1 |
344 | mov [hdbase],0x170 |
344 | mov [hdbase],0x170 |
345 | mov [hdid],0x0 |
345 | mov [hdid],0x0 |
346 | mov [hdpos],3 |
346 | mov [hdpos],3 |
347 | jmp fs_yesharddisk_partition |
347 | jmp fs_yesharddisk_partition |
348 | fs_yesharddisk_IDE3: |
348 | fs_yesharddisk_IDE3: |
349 | call reserve_hd1 |
349 | call reserve_hd1 |
350 | mov [hdbase],0x170 |
350 | mov [hdbase],0x170 |
351 | mov [hdid],0x10 |
351 | mov [hdid],0x10 |
352 | mov [hdpos],4 |
352 | mov [hdpos],4 |
353 | fs_yesharddisk_partition: |
353 | fs_yesharddisk_partition: |
354 | call reserve_hd_channel |
354 | call reserve_hd_channel |
355 | ; call choice_necessity_partition |
355 | ; call choice_necessity_partition |
356 | ; jmp fs_yesharddisk_all |
356 | ; jmp fs_yesharddisk_all |
357 | jmp fs_for_new_semantic |
357 | jmp fs_for_new_semantic |
358 | 358 | ||
359 | choice_necessity_partition: |
359 | choice_necessity_partition: |
360 | mov eax,[edi+1+12] |
360 | mov eax,[edi+1+12] |
361 | call StringToNumber |
361 | call StringToNumber |
362 | mov [fat32part],eax |
362 | mov [fat32part],eax |
363 | choice_necessity_partition_1: |
363 | choice_necessity_partition_1: |
364 | mov ecx,[hdpos] |
364 | mov ecx,[hdpos] |
365 | xor eax,eax |
365 | xor eax,eax |
366 | mov [hd_entries], eax ; entries in hd cache |
366 | mov [hd_entries], eax ; entries in hd cache |
367 | mov edx,DRIVE_DATA+2 |
367 | mov edx,DRIVE_DATA+2 |
368 | cmp ecx,0x80 |
368 | cmp ecx,0x80 |
369 | jb search_partition_array |
369 | jb search_partition_array |
370 | mov ecx,4 |
370 | mov ecx,4 |
371 | search_partition_array: |
371 | search_partition_array: |
372 | mov bl,[edx] |
372 | mov bl,[edx] |
373 | movzx ebx,bl |
373 | movzx ebx,bl |
374 | add eax,ebx |
374 | add eax,ebx |
375 | inc edx |
375 | inc edx |
376 | loop search_partition_array |
376 | loop search_partition_array |
377 | mov ecx,[hdpos] |
377 | mov ecx,[hdpos] |
378 | mov edx,BiosDiskPartitions |
378 | mov edx,BiosDiskPartitions |
379 | sub ecx,0x80 |
379 | sub ecx,0x80 |
380 | jb .s |
380 | jb .s |
381 | je .f |
381 | je .f |
382 | @@: |
382 | @@: |
383 | mov ebx,[edx] |
383 | mov ebx,[edx] |
384 | add edx,4 |
384 | add edx,4 |
385 | add eax,ebx |
385 | add eax,ebx |
386 | loop @b |
386 | loop @b |
387 | jmp .f |
387 | jmp .f |
388 | .s: |
388 | .s: |
389 | sub eax,ebx |
389 | sub eax,ebx |
390 | .f: |
390 | .f: |
391 | add eax,[fat32part] |
391 | add eax,[fat32part] |
392 | dec eax |
392 | dec eax |
393 | xor edx,edx |
393 | xor edx,edx |
394 | imul eax,100 |
394 | imul eax,100 |
395 | add eax,DRIVE_DATA+0xa |
395 | add eax,DRIVE_DATA+0xa |
396 | mov [transfer_adress],eax |
396 | mov [transfer_adress],eax |
397 | call partition_data_transfer_1 |
397 | call partition_data_transfer_1 |
398 | ret |
398 | ret |
399 | 399 | ||
400 | old_path_harddisk: |
400 | old_path_harddisk: |
401 | mov eax,[edi+1] |
401 | mov eax,[edi+1] |
402 | cmp eax,'HD ' |
402 | cmp eax,'HD ' |
403 | je fs_yesharddisk |
403 | je fs_yesharddisk |
404 | cmp eax,'HARD' |
404 | cmp eax,'HARD' |
405 | jne fs_noharddisk |
405 | jne fs_noharddisk |
406 | 406 | ||
407 | fs_yesharddisk: |
407 | fs_yesharddisk: |
408 | cmp dword [esp+20],8 ; LBA read |
408 | cmp dword [esp+20],8 ; LBA read |
409 | jne fs_no_LBA_read |
409 | jne fs_no_LBA_read |
410 | mov eax,[esp+16] ; LBA block to read |
410 | mov eax,[esp+16] ; LBA block to read |
411 | lea ebx,[edi+1+12] ; pointer to FIRST/SECOND/THIRD/FOURTH |
411 | lea ebx,[edi+1+12] ; pointer to FIRST/SECOND/THIRD/FOURTH |
412 | mov ecx,[esp+8] ; abs pointer to return area |
412 | mov ecx,[esp+8] ; abs pointer to return area |
413 | call LBA_read |
413 | call LBA_read |
414 | jmp file_system_return |
414 | jmp file_system_return |
415 | 415 | ||
416 | fs_no_LBA_read: |
416 | fs_no_LBA_read: |
417 | 417 | ||
418 | cmp byte [edi+1+11],0 ; directory read |
418 | cmp byte [edi+1+11],0 ; directory read |
419 | je fs_give_dir1 |
419 | je fs_give_dir1 |
420 | call reserve_hd1 |
420 | call reserve_hd1 |
421 | fs_for_new_semantic: |
421 | fs_for_new_semantic: |
422 | call choice_necessity_partition |
422 | call choice_necessity_partition |
423 | 423 | ||
424 | fs_yesharddisk_all: |
424 | fs_yesharddisk_all: |
425 | mov eax,1 |
425 | mov eax,1 |
426 | mov ebx, [esp+24+24] |
426 | mov ebx, [esp+24+24] |
427 | cmp [hdpos],0 ; is hd base set? |
427 | cmp [hdpos],0 ; is hd base set? |
428 | jz hd_err_return |
428 | jz hd_err_return |
429 | cmp [fat32part],0 ; is partition set? |
429 | cmp [fat32part],0 ; is partition set? |
430 | jnz @f |
430 | jnz @f |
431 | hd_err_return: |
431 | hd_err_return: |
432 | call free_hd_channel |
432 | call free_hd_channel |
433 | and [hd1_status], 0 |
433 | and [hd1_status], 0 |
434 | jmp file_system_return |
434 | jmp file_system_return |
435 | @@: |
435 | @@: |
436 | 436 | ||
437 | cmp dword [esp+20],0 ; READ |
437 | cmp dword [esp+20],0 ; READ |
438 | jne fs_noharddisk_read |
438 | jne fs_noharddisk_read |
439 | 439 | ||
440 | mov eax,[esp+0] ; /fname |
440 | mov eax,[esp+0] ; /fname |
441 | lea edi,[eax+12] |
441 | lea edi,[eax+12] |
442 | mov byte [eax],0 ; path to asciiz |
442 | mov byte [eax],0 ; path to asciiz |
443 | inc eax ; filename start |
443 | inc eax ; filename start |
444 | 444 | ||
445 | mov ebx,[esp+12] ; count to read |
445 | mov ebx,[esp+12] ; count to read |
446 | mov ecx,[esp+8] ; buffer |
446 | mov ecx,[esp+8] ; buffer |
447 | mov edx,[esp+4] |
447 | mov edx,[esp+4] |
448 | add edx,12*2 ; dir start |
448 | add edx,12*2 ; dir start |
449 | sub edi,edx ; path length |
449 | sub edi,edx ; path length |
450 | mov esi,[esp+16] ; blocks to read |
450 | mov esi,[esp+16] ; blocks to read |
451 | 451 | ||
452 | call file_read |
452 | call file_read |
453 | 453 | ||
454 | mov edi,[esp+0] |
454 | mov edi,[esp+0] |
455 | mov byte [edi],'/' |
455 | mov byte [edi],'/' |
456 | 456 | ||
457 | call free_hd_channel |
457 | call free_hd_channel |
458 | and [hd1_status], 0 |
458 | and [hd1_status], 0 |
459 | jmp file_system_return |
459 | jmp file_system_return |
460 | 460 | ||
461 | fs_noharddisk_read: |
461 | fs_noharddisk_read: |
462 | 462 | ||
463 | call free_hd_channel |
463 | call free_hd_channel |
464 | and [hd1_status], 0 |
464 | and [hd1_status], 0 |
465 | 465 | ||
466 | fs_noharddisk: |
466 | fs_noharddisk: |
467 | ; \begin{diamond}[18.03.2006] |
467 | ; \begin{diamond}[18.03.2006] |
468 | mov eax, 5 ; file not found |
468 | mov eax, 5 ; file not found |
469 | ; à ìîæåò áûòü, âîçâðàùàòü äðóãîé êîä îøèáêè? |
469 | ; à ìîæåò áûòü, âîçâðàùàòü äðóãîé êîä îøèáêè? |
470 | mov ebx, [esp+24+24] ; do not change ebx in application |
470 | mov ebx, [esp+24+24] ; do not change ebx in application |
471 | ; \end{diamond}[18.03.2006] |
471 | ; \end{diamond}[18.03.2006] |
472 | 472 | ||
473 | file_system_return: |
473 | file_system_return: |
474 | 474 | ||
475 | add esp,24 |
475 | add esp,24 |
476 | 476 | ||
477 | mov [esp+36],eax |
477 | mov [esp+36],eax |
478 | mov [esp+24],ebx |
478 | mov [esp+24],ebx |
479 | ret |
479 | ret |
480 | 480 | ||
481 | 481 | ||
482 | fs_give_dir1: |
482 | fs_give_dir1: |
483 | 483 | ||
484 | ; \begin{diamond}[18.03.2006] |
484 | ; \begin{diamond}[18.03.2006] |
485 | ; /RD,/FD,/HD - only read is allowed |
485 | ; /RD,/FD,/HD - only read is allowed |
486 | ; other operations return "access denied", eax=10 |
486 | ; other operations return "access denied", eax=10 |
487 | ; (execute operation returns eax=-10) |
487 | ; (execute operation returns eax=-10) |
488 | cmp dword [esp+20], 0 |
488 | cmp dword [esp+20], 0 |
489 | jz .read |
489 | jz .read |
490 | add esp, 20 |
490 | add esp, 20 |
491 | pop ecx |
491 | pop ecx |
492 | mov dword [esp+36], 10 |
492 | mov dword [esp+36], 10 |
493 | ret |
493 | ret |
494 | .read: |
494 | .read: |
495 | ; \end{diamond}[18.03.2006] |
495 | ; \end{diamond}[18.03.2006] |
496 | mov al,0x10 |
496 | mov al,0x10 |
497 | mov ebx,1 |
497 | mov ebx,1 |
498 | mov edi,[esp+8] |
498 | mov edi,[esp+8] |
499 | mov esi,dir1 |
499 | mov esi,dir1 |
500 | fs_d1_new: |
500 | fs_d1_new: |
501 | mov ecx,11 |
501 | mov ecx,11 |
502 | ; cld |
502 | ; cld |
503 | rep movsb |
503 | rep movsb |
504 | stosb |
504 | stosb |
505 | add edi,32-11-1 |
505 | add edi,32-11-1 |
506 | dec ebx |
506 | dec ebx |
507 | jne fs_d1_new |
507 | jne fs_d1_new |
508 | 508 | ||
509 | add esp,24 |
509 | add esp,24 |
510 | 510 | ||
511 | and dword [esp+36],0 ; ok read |
511 | and dword [esp+36],0 ; ok read |
512 | mov dword [esp+24],32*1 ; dir/data size |
512 | mov dword [esp+24],32*1 ; dir/data size |
513 | ret |
513 | ret |
514 | 514 | ||
515 | 515 | ||
516 | 516 | ||
517 | LBA_read_ramdisk: |
517 | LBA_read_ramdisk: |
518 | 518 | ||
519 | cmp [lba_read_enabled],1 |
519 | cmp [lba_read_enabled],1 |
520 | je lbarrl1 |
520 | je lbarrl1 |
521 | 521 | ||
522 | xor ebx,ebx |
522 | xor ebx,ebx |
523 | mov eax,2 |
523 | mov eax,2 |
524 | ret |
524 | ret |
525 | 525 | ||
526 | lbarrl1: |
526 | lbarrl1: |
527 | 527 | ||
528 | cmp eax,18*2*80 |
528 | cmp eax,18*2*80 |
529 | jb lbarrl2 |
529 | jb lbarrl2 |
530 | xor ebx,ebx |
530 | xor ebx,ebx |
531 | mov eax,3 |
531 | mov eax,3 |
532 | ret |
532 | ret |
533 | 533 | ||
534 | lbarrl2: |
534 | lbarrl2: |
535 | 535 | ||
536 | pushad |
536 | pushad |
537 | 537 | ||
538 | call restorefatchain |
538 | call restorefatchain |
539 | 539 | ||
540 | mov edi,ecx |
540 | mov edi,ecx |
541 | mov esi,eax |
541 | mov esi,eax |
542 | 542 | ||
543 | shl esi,9 |
543 | shl esi,9 |
544 | add esi,RAMDISK |
544 | add esi, [_rd_base] |
545 | mov ecx,512/4 |
545 | mov ecx,512/4 |
546 | ; cld |
546 | ; cld |
547 | rep movsd |
547 | rep movsd |
548 | 548 | ||
549 | popad |
549 | popad |
550 | 550 | ||
551 | xor ebx,ebx |
551 | xor ebx,ebx |
552 | xor eax,eax |
552 | xor eax,eax |
553 | ret |
553 | ret |
554 | 554 | ||
555 | LBA_read: |
555 | LBA_read: |
556 | 556 | ||
557 | ; IN: |
557 | ; IN: |
558 | ; |
558 | ; |
559 | ; eax = LBA block to read |
559 | ; eax = LBA block to read |
560 | ; ebx = pointer to FIRST/SECOND/THIRD/FOURTH |
560 | ; ebx = pointer to FIRST/SECOND/THIRD/FOURTH |
561 | ; ecx = abs pointer to return area |
561 | ; ecx = abs pointer to return area |
562 | 562 | ||
563 | cmp [lba_read_enabled],1 |
563 | cmp [lba_read_enabled],1 |
564 | je lbarl1 |
564 | je lbarl1 |
565 | mov eax,2 |
565 | mov eax,2 |
566 | ret |
566 | ret |
567 | 567 | ||
568 | lbarl1: |
568 | lbarl1: |
569 | 569 | ||
570 | call reserve_hd1 |
570 | call reserve_hd1 |
571 | 571 | ||
572 | push eax |
572 | push eax |
573 | push ecx |
573 | push ecx |
574 | 574 | ||
575 | mov edi,hd_address_table |
575 | mov edi,hd_address_table |
576 | mov esi,dir1 |
576 | mov esi,dir1 |
577 | mov eax,[ebx] |
577 | mov eax,[ebx] |
578 | mov edx,'1 ' |
578 | mov edx,'1 ' |
579 | mov ecx,4 |
579 | mov ecx,4 |
580 | blar0: |
580 | blar0: |
581 | cmp eax,[esi] |
581 | cmp eax,[esi] |
582 | je blar2 |
582 | je blar2 |
583 | cmp eax,edx |
583 | cmp eax,edx |
584 | je blar2 |
584 | je blar2 |
585 | inc edx |
585 | inc edx |
586 | add edi,8 |
586 | add edi,8 |
587 | add esi,11 |
587 | add esi,11 |
588 | dec ecx |
588 | dec ecx |
589 | jnz blar0 |
589 | jnz blar0 |
590 | 590 | ||
591 | mov eax,1 |
591 | mov eax,1 |
592 | mov ebx,1 |
592 | mov ebx,1 |
593 | jmp LBA_read_ret |
593 | jmp LBA_read_ret |
594 | 594 | ||
595 | blar2: |
595 | blar2: |
596 | mov eax,[edi+0] |
596 | mov eax,[edi+0] |
597 | mov ebx,[edi+4] |
597 | mov ebx,[edi+4] |
598 | 598 | ||
599 | mov [hdbase],eax |
599 | mov [hdbase],eax |
600 | mov [hdid],ebx |
600 | mov [hdid],ebx |
601 | 601 | ||
602 | call wait_for_hd_idle |
602 | call wait_for_hd_idle |
603 | cmp [hd_error],0 |
603 | cmp [hd_error],0 |
604 | jne hd_lba_error |
604 | jne hd_lba_error |
605 | 605 | ||
606 | ; eax = hd port |
606 | ; eax = hd port |
607 | ; ebx = set for primary (0x00) or slave (0x10) |
607 | ; ebx = set for primary (0x00) or slave (0x10) |
608 | 608 | ||
609 | cli |
609 | cli |
610 | 610 | ||
611 | mov edx,eax |
611 | mov edx,eax |
612 | inc edx |
612 | inc edx |
613 | xor eax,eax |
613 | xor eax,eax |
614 | out dx,al |
614 | out dx,al |
615 | inc edx |
615 | inc edx |
616 | inc eax |
616 | inc eax |
617 | out dx,al |
617 | out dx,al |
618 | inc edx |
618 | inc edx |
619 | mov eax,[esp+4] |
619 | mov eax,[esp+4] |
620 | out dx,al |
620 | out dx,al |
621 | shr eax,8 |
621 | shr eax,8 |
622 | inc edx |
622 | inc edx |
623 | out dx,al |
623 | out dx,al |
624 | shr eax,8 |
624 | shr eax,8 |
625 | inc edx |
625 | inc edx |
626 | out dx,al |
626 | out dx,al |
627 | shr eax,8 |
627 | shr eax,8 |
628 | inc edx |
628 | inc edx |
629 | and al,1+2+4+8 |
629 | and al,1+2+4+8 |
630 | add al,bl |
630 | add al,bl |
631 | add al,128+64+32 |
631 | add al,128+64+32 |
632 | out dx,al |
632 | out dx,al |
633 | 633 | ||
634 | inc edx |
634 | inc edx |
635 | mov al,20h |
635 | mov al,20h |
636 | out dx,al |
636 | out dx,al |
637 | 637 | ||
638 | sti |
638 | sti |
639 | 639 | ||
640 | call wait_for_sector_buffer |
640 | call wait_for_sector_buffer |
641 | cmp [hd_error],0 |
641 | cmp [hd_error],0 |
642 | jne hd_lba_error |
642 | jne hd_lba_error |
643 | 643 | ||
644 | cli |
644 | cli |
645 | 645 | ||
646 | mov edi,[esp+0] |
646 | mov edi,[esp+0] |
647 | mov ecx,256 |
647 | mov ecx,256 |
648 | sub edx,7 |
648 | sub edx,7 |
649 | cld |
649 | cld |
650 | rep insw |
650 | rep insw |
651 | 651 | ||
652 | sti |
652 | sti |
653 | 653 | ||
654 | xor eax,eax |
654 | xor eax,eax |
655 | xor ebx,ebx |
655 | xor ebx,ebx |
656 | 656 | ||
657 | LBA_read_ret: |
657 | LBA_read_ret: |
658 | mov [hd_error],0 |
658 | mov [hd_error],0 |
659 | mov [hd1_status],0 |
659 | mov [hd1_status],0 |
660 | add esp,2*4 |
660 | add esp,2*4 |
661 | 661 | ||
662 | ret |
662 | ret |
663 | 663 | ||
664 | 664 | ||
665 | expand_pathz: |
665 | expand_pathz: |
666 | ; IN: |
666 | ; IN: |
667 | ; esi = asciiz path & file |
667 | ; esi = asciiz path & file |
668 | ; edi = buffer for path & file name |
668 | ; edi = buffer for path & file name |
669 | ; OUT: |
669 | ; OUT: |
670 | ; edi = directory & file : / 11 + / 11 + / 11 - zero terminated |
670 | ; edi = directory & file : / 11 + / 11 + / 11 - zero terminated |
671 | ; ebx = /file name - zero terminated |
671 | ; ebx = /file name - zero terminated |
672 | ; esi = pointer after source |
672 | ; esi = pointer after source |
673 | 673 | ||
674 | push eax |
674 | push eax |
675 | push ecx |
675 | push ecx |
676 | push edi ;[esp+0] |
676 | push edi ;[esp+0] |
677 | 677 | ||
678 | pathz_start: |
678 | pathz_start: |
679 | mov byte [edi],'/' |
679 | mov byte [edi],'/' |
680 | inc edi |
680 | inc edi |
681 | mov al,32 |
681 | mov al,32 |
682 | mov ecx,11 |
682 | mov ecx,11 |
683 | cld |
683 | cld |
684 | rep stosb ; clear filename area |
684 | rep stosb ; clear filename area |
685 | sub edi,11 |
685 | sub edi,11 |
686 | mov ebx,edi ; start of dir/file name |
686 | mov ebx,edi ; start of dir/file name |
687 | 687 | ||
688 | pathz_new_char: |
688 | pathz_new_char: |
689 | mov al,[esi] |
689 | mov al,[esi] |
690 | inc esi |
690 | inc esi |
691 | cmp al,0 |
691 | cmp al,0 |
692 | je pathz_end |
692 | je pathz_end |
693 | 693 | ||
694 | cmp al,'/' |
694 | cmp al,'/' |
695 | jne pathz_not_path |
695 | jne pathz_not_path |
696 | cmp edi,ebx ; skip first '/' |
696 | cmp edi,ebx ; skip first '/' |
697 | jz pathz_new_char |
697 | jz pathz_new_char |
698 | lea edi,[ebx+11] ; start of next directory |
698 | lea edi,[ebx+11] ; start of next directory |
699 | jmp pathz_start |
699 | jmp pathz_start |
700 | 700 | ||
701 | pathz_not_path: |
701 | pathz_not_path: |
702 | cmp al,'.' |
702 | cmp al,'.' |
703 | jne pathz_not_ext |
703 | jne pathz_not_ext |
704 | lea edi,[ebx+8] ; start of extension |
704 | lea edi,[ebx+8] ; start of extension |
705 | jmp pathz_new_char |
705 | jmp pathz_new_char |
706 | 706 | ||
707 | pathz_not_ext: |
707 | pathz_not_ext: |
708 | cmp al,'a' |
708 | cmp al,'a' |
709 | jb pathz_not_low |
709 | jb pathz_not_low |
710 | cmp al,'z' |
710 | cmp al,'z' |
711 | ja pathz_not_low |
711 | ja pathz_not_low |
712 | sub al,0x20 ; char to uppercase |
712 | sub al,0x20 ; char to uppercase |
713 | 713 | ||
714 | pathz_not_low: |
714 | pathz_not_low: |
715 | mov [edi],al |
715 | mov [edi],al |
716 | inc edi |
716 | inc edi |
717 | mov eax,[esp+0] ; start_of_dest_path |
717 | mov eax,[esp+0] ; start_of_dest_path |
718 | add eax,512 ; keep maximum path under 512 bytes |
718 | add eax,512 ; keep maximum path under 512 bytes |
719 | cmp edi,eax |
719 | cmp edi,eax |
720 | jb pathz_new_char |
720 | jb pathz_new_char |
721 | 721 | ||
722 | pathz_end: |
722 | pathz_end: |
723 | cmp ebx,edi ; if path end with '/' |
723 | cmp ebx,edi ; if path end with '/' |
724 | jnz pathz_put_zero ; go back 1 level |
724 | jnz pathz_put_zero ; go back 1 level |
725 | sub ebx,12 |
725 | sub ebx,12 |
726 | 726 | ||
727 | pathz_put_zero: |
727 | pathz_put_zero: |
728 | mov byte [ebx+11],0 |
728 | mov byte [ebx+11],0 |
729 | dec ebx ; include '/' char into file name |
729 | dec ebx ; include '/' char into file name |
730 | pop edi |
730 | pop edi |
731 | pop ecx |
731 | pop ecx |
732 | pop eax |
732 | pop eax |
733 | ret |
733 | ret |
734 | 734 | ||
735 | ;******************************************* |
735 | ;******************************************* |
736 | ;* string to number |
736 | ;* string to number |
737 | ;* input eax - 4 byte string |
737 | ;* input eax - 4 byte string |
738 | ;* output eax - number |
738 | ;* output eax - number |
739 | ;******************************************* |
739 | ;******************************************* |
740 | StringToNumber: |
740 | StringToNumber: |
741 | ; ÏÅÐÅÂÎÄ ÑÒÐÎÊÎÂÎÃÎ ×ÈÑËÀ  ×ÈÑËÎÂÎÉ ÂÈÄ |
741 | ; ÏÅÐÅÂÎÄ ÑÒÐÎÊÎÂÎÃÎ ×ÈÑËÀ  ×ÈÑËÎÂÎÉ ÂÈÄ |
742 | ; Âõîä: |
742 | ; Âõîä: |
743 | ; EDI - àäðåñ ñòðîêè ñ ÷èñëîì. Êîíåö ÷èñëà îòìå÷åí êîäîì 0Dh |
743 | ; EDI - àäðåñ ñòðîêè ñ ÷èñëîì. Êîíåö ÷èñëà îòìå÷åí êîäîì 0Dh |
744 | ; Âûõîä: |
744 | ; Âûõîä: |
745 | ; CF - èíäèêàòîð îøèáîê: |
745 | ; CF - èíäèêàòîð îøèáîê: |
746 | ; 0 - îøèáîê íåò; |
746 | ; 0 - îøèáîê íåò; |
747 | ; 1 - îøèáêà |
747 | ; 1 - îøèáêà |
748 | ; Åñëè CF=0, òî AX - ÷èñëî. |
748 | ; Åñëè CF=0, òî AX - ÷èñëî. |
749 | 749 | ||
750 | push bx |
750 | push bx |
751 | push cx |
751 | push cx |
752 | push dx |
752 | push dx |
753 | push edi |
753 | push edi |
754 | mov [partition_string],eax |
754 | mov [partition_string],eax |
755 | mov edi,partition_string |
755 | mov edi,partition_string |
756 | xor cx,cx |
756 | xor cx,cx |
757 | i1: |
757 | i1: |
758 | mov al,[edi] |
758 | mov al,[edi] |
759 | cmp al,32 ;13 |
759 | cmp al,32 ;13 |
760 | je i_exit |
760 | je i_exit |
761 | ; cmp al,'0' |
761 | ; cmp al,'0' |
762 | ; jb err |
762 | ; jb err |
763 | ; cmp al,'9' |
763 | ; cmp al,'9' |
764 | ; ja err |
764 | ; ja err |
765 | sub al,48 |
765 | sub al,48 |
766 | shl cx,1 |
766 | shl cx,1 |
767 | jc err |
767 | jc err |
768 | mov bx,cx |
768 | mov bx,cx |
769 | shl cx,1 |
769 | shl cx,1 |
770 | jc err |
770 | jc err |
771 | shl cx,1 |
771 | shl cx,1 |
772 | jc err |
772 | jc err |
773 | add cx,bx |
773 | add cx,bx |
774 | jc err |
774 | jc err |
775 | cbw |
775 | cbw |
776 | add cx,ax |
776 | add cx,ax |
777 | jc err |
777 | jc err |
778 | i3: |
778 | i3: |
779 | inc edi |
779 | inc edi |
780 | jmp i1 |
780 | jmp i1 |
781 | i_exit: |
781 | i_exit: |
782 | mov ax,cx |
782 | mov ax,cx |
783 | clc |
783 | clc |
784 | i4: |
784 | i4: |
785 | movzx eax,ax |
785 | movzx eax,ax |
786 | pop edi |
786 | pop edi |
787 | pop dx |
787 | pop dx |
788 | pop cx |
788 | pop cx |
789 | pop bx |
789 | pop bx |
790 | ret |
790 | ret |
791 | 791 | ||
792 | err: |
792 | err: |
793 | stc |
793 | stc |
794 | jmp i4 |
794 | jmp i4 |
795 | 795 | ||
796 | partition_string: dd 0 |
796 | partition_string: dd 0 |
797 | db 32>=>>=> |
797 | db 32>=>>=> |