Rev 4086 | Rev 5146 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4086 | Rev 4607 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ; Search Additional Partition for KolibriOS applications |
1 | ; Search Additional Partition for KolibriOS applications |
2 | ; |
2 | ; |
3 | ; Copyright (c) 2013, Marat Zakiyanov aka Mario79, aka Mario |
3 | ; Copyright (c) 2013-2014, Marat Zakiyanov aka Mario79, aka Mario |
4 | ; All rights reserved. |
4 | ; All rights reserved. |
5 | ; |
5 | ; |
6 | ; Redistribution and use in source and binary forms, with or without |
6 | ; Redistribution and use in source and binary forms, with or without |
7 | ; modification, are permitted provided that the following conditions are met: |
7 | ; modification, are permitted provided that the following conditions are met: |
8 | ; * Redistributions of source code must retain the above copyright |
8 | ; * Redistributions of source code must retain the above copyright |
Line 74... | Line 74... | ||
74 | additional_dir_name: |
74 | additional_dir_name: |
75 | db 'kolibrios',0 |
75 | db 'kolibrios',0 |
76 | real_additional_dir: |
76 | real_additional_dir: |
77 | db '/kolibrios',0 |
77 | db '/kolibrios',0 |
78 | ;------------------------------------------------------------------------------- |
78 | ;------------------------------------------------------------------------------- |
79 | debug equ no ;yes |
- | |
80 | - | ||
81 | include '../../macros.inc' |
79 | include '../../macros.inc' |
Line 82... | Line 80... | ||
82 | 80 | ||
- | 81 | define __DEBUG__ 1 |
|
83 | if debug eq yes |
82 | define __DEBUG_LEVEL__ 2 ; 1 = verbose, 2 = main only |
84 | include '../../debug.inc' |
- | |
85 | end if |
83 | include "../../debug-fdo.inc" |
86 | ;------------------------------------------------------------------------------- |
84 | ;------------------------------------------------------------------------------- |
87 | START: |
85 | START: |
88 | mcall 5,500 |
86 | mcall 5,500 |
89 | mov ebx,start_dir |
87 | mov ebx,start_dir |
Line 92... | Line 90... | ||
92 | mov [ebx],ax |
90 | mov [ebx],ax |
93 | mov ebx,read_folder_1_name |
91 | mov ebx,read_folder_1_name |
94 | mov [ebx],ax |
92 | mov [ebx],ax |
95 | call device_detect_f70 |
93 | call device_detect_f70 |
96 | ;-------------------------------------- |
94 | ;-------------------------------------- |
97 | if debug eq yes |
- | |
98 | call print_retrieved_devices_table |
95 | call print_retrieved_devices_table |
99 | dps 'get basic file' |
96 | DEBUGF 1, "Searchap: get basic file\n" |
100 | newline |
- | |
101 | end if |
- | |
102 | ;-------------------------------------- |
97 | ;-------------------------------------- |
103 | call load_file ; download the master file |
98 | call load_file ; download the master file |
104 | xor eax,eax |
99 | xor eax,eax |
105 | cmp [fs_error],eax |
100 | cmp [fs_error],eax |
106 | jne exit |
101 | jne exit |
Line 109... | Line 104... | ||
109 | 104 | ||
110 | call search_and_load_pointer_file_label |
105 | call search_and_load_pointer_file_label |
111 | ;--------------------------------------------------------------------- |
106 | ;--------------------------------------------------------------------- |
112 | exit: |
107 | exit: |
113 | ;-------------------------------------- |
- | |
114 | if debug eq yes |
108 | ;-------------------------------------- |
115 | dps 'just exit' |
- | |
116 | ;newline |
- | |
117 | ; mov edx,read_folder_name |
- | |
118 | ; call debug_outstr |
- | |
119 | ;newline |
- | |
120 | ; mov edx,read_folder_1_name |
- | |
121 | ; call debug_outstr |
- | |
122 | ;newline |
- | |
123 | end if |
109 | DEBUGF 1, "Searchap: just exit\n" |
124 | ;-------------------------------------- |
110 | ;-------------------------------------- |
125 | mcall -1 |
111 | mcall -1 |
126 | ;--------------------------------------------------------------------- |
112 | ;--------------------------------------------------------------------- |
127 | device_detect_f70: |
113 | device_detect_f70: |
128 | ;-------------------------------------- |
- | |
129 | if debug eq yes |
- | |
130 | dps 'read_folder_name: ' |
114 | ;-------------------------------------- |
131 | mov edx,read_folder_name |
- | |
132 | call debug_outstr |
- | |
133 | newline |
- | |
134 | end if |
115 | DEBUGF 1, "Searchap: read_folder_name: %s\n",read_folder_name |
135 | ;-------------------------------------- |
116 | ;-------------------------------------- |
136 | mcall 70,read_folder |
117 | mcall 70,read_folder |
137 | test eax,eax |
118 | test eax,eax |
138 | jz @f |
119 | jz @f |
139 | cmp eax,6 |
120 | cmp eax,6 |
140 | je @f |
121 | je @f |
141 | ;-------------------------------------- |
- | |
142 | if debug eq yes |
122 | ;-------------------------------------- |
143 | dps 'read_folder_error' |
- | |
144 | newline |
- | |
145 | ; mov edx,read_folder_name |
- | |
146 | ; call debug_outstr |
- | |
147 | ;newline |
- | |
148 | end if |
123 | DEBUGF 1, "Searchap: read_folder_error\n" |
149 | ;-------------------------------------- |
124 | ;-------------------------------------- |
150 | jmp exit |
125 | jmp exit |
151 | @@: |
126 | @@: |
152 | ;-------------------------------------- |
- | |
153 | if debug eq yes |
127 | ;-------------------------------------- |
154 | call print_root_dir |
- | |
155 | end if |
128 | call print_root_dir |
156 | ;-------------------------------------- |
129 | ;-------------------------------------- |
157 | mov [left_folder_block],ebx |
130 | mov [left_folder_block],ebx |
158 | xor eax,eax |
131 | xor eax,eax |
159 | mov [temp_counter_1],eax |
132 | mov [temp_counter_1],eax |
Line 162... | Line 135... | ||
162 | imul esi,[temp_counter_1],304 |
135 | imul esi,[temp_counter_1],304 |
163 | add esi,[read_folder.return] |
136 | add esi,[read_folder.return] |
164 | add esi,32+40 |
137 | add esi,32+40 |
165 | call copy_folder_name_1 |
138 | call copy_folder_name_1 |
166 | ;-------------------------------------- |
139 | ;-------------------------------------- |
167 | if debug eq yes |
- | |
168 | ;dps 'read_folder_1_name: ' |
- | |
169 | ; mov edx,read_folder_1_name |
140 | DEBUGF 1, "Searchap: read_folder_1_name: %s\n",read_folder_1_name |
170 | ; call debug_outstr |
- | |
171 | ;newline |
- | |
172 | end if |
- | |
173 | ;-------------------------------------- |
141 | ;-------------------------------------- |
174 | mcall 70,read_folder_1 |
142 | mcall 70,read_folder_1 |
175 | test eax,eax |
143 | test eax,eax |
176 | jz @f |
144 | jz @f |
177 | cmp eax,6 |
145 | cmp eax,6 |
178 | je @f |
146 | je @f |
179 | ;-------------------------------------- |
147 | ;-------------------------------------- |
180 | if debug eq yes |
- | |
181 | dps 'read_folder_error_1' |
148 | DEBUGF 1, "Searchap: read_folder_error_1\n" |
182 | newline |
- | |
183 | ; mov edx,read_folder_1_name |
- | |
184 | ; call debug_outstr |
- | |
185 | ;newline |
- | |
186 | end if |
- | |
187 | ;-------------------------------------- |
149 | ;-------------------------------------- |
188 | jmp exit |
150 | jmp exit |
189 | @@: |
151 | @@: |
190 | mov eax,[read_folder_1.return] |
152 | mov eax,[read_folder_1.return] |
191 | cmp [eax+4],dword 0 |
153 | cmp [eax+4],dword 0 |
Line 240... | Line 202... | ||
240 | mov [fileinfo.subfunction],dword 5 |
202 | mov [fileinfo.subfunction],dword 5 |
241 | xor eax,eax |
203 | xor eax,eax |
242 | mov [fileinfo.size],eax |
204 | mov [fileinfo.size],eax |
243 | mov [fs_error],eax |
205 | mov [fs_error],eax |
244 | ;-------------------------------------- |
206 | ;-------------------------------------- |
245 | if debug eq yes |
- | |
246 | dps 'get file info' |
207 | DEBUGF 1, "Searchap: get file info\n" |
247 | newline |
- | |
248 | end if |
- | |
249 | ;-------------------------------------- |
208 | ;-------------------------------------- |
250 | mcall 68,1 |
209 | mcall 68,1 |
251 | mcall 70,fileinfo |
210 | mcall 70,fileinfo |
252 | mov [fs_error],eax |
211 | mov [fs_error],eax |
253 | test eax,eax |
212 | test eax,eax |
254 | jnz .file_error |
213 | jnz .file_error |
255 | ;-------------------------------------- |
214 | ;-------------------------------------- |
256 | if debug eq yes |
- | |
257 | dps 'file info ok' |
215 | DEBUGF 1, "Searchap: file info ok\n" |
258 | newline |
- | |
259 | end if |
- | |
260 | ;-------------------------------------- |
216 | ;-------------------------------------- |
261 | xor eax,eax |
217 | xor eax,eax |
262 | mov [fileinfo.subfunction],eax ;dword 0 |
218 | mov [fileinfo.subfunction],eax ;dword 0 |
263 | mov eax,[fileinfo.return] |
219 | mov eax,[fileinfo.return] |
264 | mov ecx,[eax+32] |
220 | mov ecx,[eax+32] |
265 | ;-------------------------------------- |
221 | ;-------------------------------------- |
266 | if debug eq yes |
- | |
267 | dps 'real file size: ' |
222 | DEBUGF 1, "Searchap: real file size: %d\n",ecx |
268 | dpd ecx |
- | |
269 | newline |
- | |
270 | end if |
- | |
271 | ;-------------------------------------- |
223 | ;-------------------------------------- |
272 | test ecx,ecx |
224 | test ecx,ecx |
273 | jz .file_error |
225 | jz .file_error |
274 | mov eax,304*32+32 ; 9 Kb |
226 | mov eax,304*32+32 ; 9 Kb |
275 | cmp ecx,eax |
227 | cmp ecx,eax |
Line 277... | Line 229... | ||
277 | mov ecx,eax |
229 | mov ecx,eax |
278 | ;----------------------------------- |
230 | ;----------------------------------- |
279 | @@: |
231 | @@: |
280 | mov [fileinfo.size],ecx |
232 | mov [fileinfo.size],ecx |
281 | ;-------------------------------------- |
233 | ;-------------------------------------- |
282 | if debug eq yes |
- | |
283 | dps 'get file' |
234 | DEBUGF 1, "Searchap: get file\n" |
284 | newline |
- | |
285 | end if |
- | |
286 | ;-------------------------------------- |
235 | ;-------------------------------------- |
287 | mcall 68,1 |
236 | mcall 68,1 |
288 | mcall 70,fileinfo |
237 | mcall 70,fileinfo |
289 | mov [fs_error],eax |
238 | mov [fs_error],eax |
290 | test eax,eax |
239 | test eax,eax |
Line 295... | Line 244... | ||
295 | ; mov [fs_error],eax |
244 | ; mov [fs_error],eax |
296 | ; jmp @f |
245 | ; jmp @f |
297 | ;----------------------------------- |
246 | ;----------------------------------- |
298 | .file_error: |
247 | .file_error: |
299 | ;-------------------------------------- |
248 | ;-------------------------------------- |
300 | if debug eq yes |
- | |
301 | dps 'read file - error!' |
249 | DEBUGF 1, "Searchap: read file - error!\n" |
302 | newline |
- | |
303 | end if |
- | |
304 | ;-------------------------------------- |
250 | ;-------------------------------------- |
305 | ret |
251 | ret |
306 | ;----------------------------------- |
252 | ;----------------------------------- |
307 | @@: |
253 | @@: |
308 | ;-------------------------------------- |
254 | ;-------------------------------------- |
309 | if debug eq yes |
- | |
310 | dps 'read file corrected size: ' |
255 | DEBUGF 1, "Searchap: read file corrected size: %d\n",[fileinfo.size] |
311 | dpd dword[fileinfo.size] |
- | |
312 | newline |
- | |
313 | end if |
- | |
314 | ;-------------------------------------- |
256 | ;-------------------------------------- |
315 | ret |
257 | ret |
316 | ;--------------------------------------------------------------------- |
258 | ;--------------------------------------------------------------------- |
317 | search_and_load_pointer_file_label: |
259 | search_and_load_pointer_file_label: |
318 | mov [fileinfo.return],dword folder_data_1 |
260 | mov [fileinfo.return],dword folder_data_1 |
Line 321... | Line 263... | ||
321 | mov [fileinfo.name],dword read_folder_name |
263 | mov [fileinfo.name],dword read_folder_name |
322 | mov esi,retrieved_devices_table |
264 | mov esi,retrieved_devices_table |
323 | ; sub esi,10 ; deleted because /rd/1/ no need to check |
265 | ; sub esi,10 ; deleted because /rd/1/ no need to check |
324 | .next_entry: |
266 | .next_entry: |
325 | ;-------------------------------------- |
267 | ;-------------------------------------- |
326 | if debug eq yes |
- | |
327 | newline |
- | |
328 | dps 'copy next entry' |
268 | DEBUGF 1, "\nSearchap: copy next entry\n" |
329 | newline |
- | |
330 | end if |
- | |
331 | ;-------------------------------------- |
269 | ;-------------------------------------- |
332 | add esi,10 |
270 | add esi,10 |
333 | push esi |
271 | push esi |
334 | add esi,1 |
272 | add esi,1 |
335 | call copy_folder_name |
273 | call copy_folder_name |
336 | mov esi,basic_file_name-1 |
274 | mov esi,basic_file_name-1 |
337 | dec edi |
275 | dec edi |
338 | call copy_folder_name.1 |
276 | call copy_folder_name.1 |
339 | pop esi |
277 | pop esi |
340 | ;-------------------------------------- |
278 | ;-------------------------------------- |
341 | if debug eq yes |
- | |
342 | mov edx,[fileinfo.name] |
279 | DEBUGF 1, "Searchap: %s\n",dword[fileinfo.name] |
343 | push ecx |
- | |
344 | call debug_outstr |
- | |
345 | pop ecx |
- | |
346 | newline |
- | |
347 | end if |
- | |
348 | ;-------------------------------------- |
280 | ;-------------------------------------- |
349 | ; mcall 5,10 |
281 | ; mcall 5,10 |
350 | push ecx |
282 | push ecx |
351 | call load_file |
283 | call load_file |
352 | pop ecx |
284 | pop ecx |
Line 359... | Line 291... | ||
359 | jae .sucess |
291 | jae .sucess |
360 | @@: |
292 | @@: |
361 | dec ecx |
293 | dec ecx |
362 | jnz .next_entry |
294 | jnz .next_entry |
363 | ;-------------------------------------- |
295 | ;-------------------------------------- |
364 | if debug eq yes |
- | |
365 | dps 'additional parttition is not found!' |
296 | DEBUGF 2, "Searchap: additional parttition is not found!\n" |
366 | newline |
- | |
367 | end if |
- | |
368 | ;-------------------------------------- |
297 | ;-------------------------------------- |
369 | ret |
298 | ret |
370 | .sucess: |
299 | .sucess: |
371 | call compare_files_and_mount |
300 | call compare_files_and_mount |
372 | cmp [compare_flag],byte 0 |
301 | cmp [compare_flag],byte 0 |
373 | jne @b |
302 | jne @b |
- | 303 | cmp [mount_dir],1 |
|
- | 304 | je @f |
|
- | 305 | DEBUGF 2, "Searchap: sorry, but the additional partition is not found!\n" |
|
- | 306 | @@: |
|
374 | ret |
307 | ret |
375 | ;--------------------------------------------------------------------- |
308 | ;--------------------------------------------------------------------- |
376 | compare_files_and_mount: |
309 | compare_files_and_mount: |
377 | push ecx esi |
310 | push ecx esi |
378 | mov ecx,[basic_file_size] |
311 | mov ecx,[basic_file_size] |
Line 388... | Line 321... | ||
388 | dec ecx |
321 | dec ecx |
389 | jnz .next_char |
322 | jnz .next_char |
390 | mov [compare_flag],byte 0 |
323 | mov [compare_flag],byte 0 |
391 | pop esi ecx |
324 | pop esi ecx |
392 | ;-------------------------------------- |
325 | ;-------------------------------------- |
393 | if debug eq yes |
- | |
394 | dps 'compare files sucess!' |
326 | DEBUGF 2, "Searchap: compare files sucess!\n" |
395 | newline |
- | |
396 | dps 'mount directory:' |
327 | DEBUGF 2, "Searchap: mount directory: %s\n",esi |
397 | newline |
- | |
398 | mov edx,esi |
328 | mov [mount_dir],1 |
399 | push esi |
- | |
400 | call debug_outstr |
- | |
401 | pop esi |
- | |
402 | newline |
- | |
403 | end if |
- | |
404 | ;-------------------------------------- |
329 | ;-------------------------------------- |
405 | ; prepare real directory path for mounting |
330 | ; prepare real directory path for mounting |
406 | inc esi |
331 | inc esi |
407 | mov edi,f30_3_work_area+64 |
332 | mov edi,f30_3_work_area+64 |
408 | call proc_copy_patch |
333 | call proc_copy_patch |
Line 420... | Line 345... | ||
420 | ;-------------------------------------- |
345 | ;-------------------------------------- |
421 | .not_match: |
346 | .not_match: |
422 | mov [compare_flag],byte 1 |
347 | mov [compare_flag],byte 1 |
423 | pop esi ecx |
348 | pop esi ecx |
424 | ;-------------------------------------- |
349 | ;-------------------------------------- |
425 | if debug eq yes |
- | |
426 | dps 'compare files is not match!' |
350 | DEBUGF 1, "Searchap: compare files is not match!\n" |
427 | newline |
- | |
428 | end if |
- | |
429 | ;-------------------------------------- |
351 | ;-------------------------------------- |
430 | ret |
352 | ret |
431 | ;--------------------------------------------------------------------- |
353 | ;--------------------------------------------------------------------- |
432 | copy_folder_name: |
354 | copy_folder_name: |
433 | mov edi,read_folder_name+1 |
355 | mov edi,read_folder_name+1 |
Line 443... | Line 365... | ||
443 | ;--------------------------------------------------------------------- |
365 | ;--------------------------------------------------------------------- |
444 | copy_folder_name_1: |
366 | copy_folder_name_1: |
445 | mov edi,read_folder_1_name+1 |
367 | mov edi,read_folder_1_name+1 |
446 | jmp proc_copy_patch |
368 | jmp proc_copy_patch |
447 | ;--------------------------------------------------------------------- |
369 | ;--------------------------------------------------------------------- |
448 | if debug eq yes |
- | |
449 | print_retrieved_devices_table: |
370 | print_retrieved_devices_table: |
450 | mov ecx,[retrieved_devices_table_counter] |
371 | mov ecx,[retrieved_devices_table_counter] |
451 | mov edx,retrieved_devices_table |
372 | mov edx,retrieved_devices_table |
452 | dps 'retrieved_devices_table:' |
373 | DEBUGF 1, "Searchap: retrieved_devices_table:\n" |
453 | newline |
- | |
454 | dps '----------' |
374 | DEBUGF 1, "Searchap: ----------\n" |
455 | newline |
- | |
456 | @@: |
375 | @@: |
457 | push ecx edx |
376 | DEBUGF 1, "Searchap: %s\n",edx |
458 | call debug_outstr |
- | |
459 | newline |
- | |
460 | pop edx ecx |
- | |
461 | add edx,10 |
377 | add edx,10 |
462 | dec ecx |
378 | dec ecx |
463 | jnz @b |
379 | jnz @b |
464 | newline |
- | |
465 | dps '----------' |
380 | DEBUGF 1, "\nSearchap: ----------\n" |
466 | newline |
- | |
467 | ret |
381 | ret |
468 | ;--------------------------------------------------------------------- |
382 | ;--------------------------------------------------------------------- |
469 | print_root_dir: |
383 | print_root_dir: |
470 | dps '----------' |
384 | DEBUGF 1, "Searchap: ----------\n" |
471 | dps 'root dir:' |
385 | DEBUGF 1, "Searchap: root dir:\n" |
472 | dps '----------' |
386 | DEBUGF 1, "Searchap: ----------\n" |
473 | newline |
- | |
474 | pusha |
387 | pusha |
475 | mov ecx,ebx |
388 | mov ecx,ebx |
476 | mov edx,folder_data+32+40 |
389 | mov edx,folder_data+32+40 |
477 | @@: |
390 | @@: |
478 | push ecx edx |
391 | DEBUGF 1, "Searchap: %s\n",edx |
479 | call debug_outstr |
- | |
480 | newline |
- | |
481 | pop edx ecx |
- | |
482 | add edx,304 |
392 | add edx,304 |
483 | dec ecx |
393 | dec ecx |
484 | jnz @b |
394 | jnz @b |
485 | popa |
395 | popa |
486 | newline |
- | |
487 | dps '----------' |
396 | DEBUGF 1, "\nSearchap: ----------\n" |
488 | newline |
- | |
489 | ret |
397 | ret |
- | 398 | ;------------------------------------------------------------------------------- |
|
490 | end if |
399 | include_debug_strings |
491 | ;------------------------------------------------------------------------------- |
400 | ;------------------------------------------------------------------------------- |
492 | IM_END: |
401 | IM_END: |
493 | ;------------------------------------------------------------------------------- |
402 | ;------------------------------------------------------------------------------- |
494 | align 4 |
403 | align 4 |
495 | left_folder_block rd 1 |
404 | left_folder_block rd 1 |
Line 497... | Line 406... | ||
497 | temp_counter_1 rd 1 |
406 | temp_counter_1 rd 1 |
498 | retrieved_devices_table_counter rd 1 |
407 | retrieved_devices_table_counter rd 1 |
499 | basic_file_size rd 1 |
408 | basic_file_size rd 1 |
500 | fs_error rd 1 |
409 | fs_error rd 1 |
501 | compare_flag rb 1 |
410 | compare_flag rb 1 |
- | 411 | mount_dir rb 1 |
|
502 | ;------------------------------------------------------------------------------- |
412 | ;------------------------------------------------------------------------------- |
503 | align 4 |
413 | align 4 |
504 | f30_3_work_area: |
414 | f30_3_work_area: |
505 | rb 128 |
415 | rb 128 |
506 | ;------------------------------------------------------------------------------- |
416 | ;------------------------------------------------------------------------------- |