Subversion Repositories Kolibri OS

Rev

Rev 3650 | Rev 3668 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3650 Rev 3664
Line 35... Line 35...
35
	dd I_END
35
	dd I_END
36
	dd stacktop
36
	dd stacktop
37
	dd 0x0
37
	dd 0x0
38
	dd 0x0
38
	dd 0x0
39
;-------------------------------------------------------------------------------
39
;-------------------------------------------------------------------------------
-
 
40
debug equ no	;yes
-
 
41
 
40
include	'../../macros.inc'
42
include	'../../macros.inc'
-
 
43
 
-
 
44
if debug eq yes	
41
include	'../../debug.inc'
45
include	'../../debug.inc'
-
 
46
end if
42
;-------------------------------------------------------------------------------
47
;-------------------------------------------------------------------------------
43
START:
48
START:
44
	mov	ebx,start_dir
49
	mov	ebx,start_dir
45
	mov	ax,[ebx]
50
	mov	ax,[ebx]
46
	mov	ebx,read_folder_name
51
	mov	ebx,read_folder_name
47
	mov	[ebx],ax
52
	mov	[ebx],ax
48
	mov	ebx,read_folder_1_name
53
	mov	ebx,read_folder_1_name
49
	mov	[ebx],ax
54
	mov	[ebx],ax
50
	call	device_detect_f70
55
	call	device_detect_f70
51
	call	print_retrieved_devices_table
-
 
52
	
-
 
53
	mov	[fileinfo.return],dword folder_data
-
 
54
;--------------------------------------
56
;--------------------------------------
-
 
57
if debug eq yes	
-
 
58
	call	print_retrieved_devices_table
55
dps 'get basic file'
59
dps 'get basic file'
56
newline
60
newline
-
 
61
end if
57
;--------------------------------------
62
;--------------------------------------
58
	call	load_file	; download the master file
63
	call	load_file	; download the master file
59
	xor	eax,eax
64
	xor	eax,eax
60
	cmp	[fs_error],eax
65
	cmp	[fs_error],eax
61
	jne	exit
66
	jne	exit
Line 63... Line 68...
63
	mov	[basic_file_size],eax	
68
	mov	[basic_file_size],eax	
Line 64... Line 69...
64
	
69
	
65
	call	search_and_load_pointer_file_label
70
	call	search_and_load_pointer_file_label
66
;---------------------------------------------------------------------
71
;---------------------------------------------------------------------
-
 
72
exit:
-
 
73
;--------------------------------------
67
exit:
74
if debug eq yes
68
dps 'just exit'
75
dps 'just exit'
69
;newline
76
;newline
70
;	mov	edx,read_folder_name
77
;	mov	edx,read_folder_name
71
;	call	debug_outstr
78
;	call	debug_outstr
72
;newline
79
;newline
73
;	mov	edx,read_folder_1_name
80
;	mov	edx,read_folder_1_name
74
;	call	debug_outstr
81
;	call	debug_outstr
-
 
82
;newline
-
 
83
end if
75
;newline
84
;--------------------------------------
76
	mcall	-1
85
	mcall	-1
77
;---------------------------------------------------------------------
86
;---------------------------------------------------------------------
78
device_detect_f70:
87
device_detect_f70:
-
 
88
;--------------------------------------
79
;--------------------------------------
89
if debug eq yes
80
dps	'read_folder_name: '
90
dps	'read_folder_name: '
81
	mov	edx,read_folder_name
91
	mov	edx,read_folder_name
82
	call	debug_outstr
92
	call	debug_outstr
-
 
93
newline
83
newline
94
end if
84
;--------------------------------------
95
;--------------------------------------
85
	mcall	70,read_folder
96
	mcall	70,read_folder
86
	test	eax,eax
97
	test	eax,eax
87
	jz	@f
98
	jz	@f
88
	cmp	eax,6
99
	cmp	eax,6
-
 
100
	je	@f
-
 
101
;--------------------------------------
89
	je	@f
102
if debug eq yes
90
dps 'read_folder_error'
103
dps 'read_folder_error'
91
newline
104
newline
92
;	mov	edx,read_folder_name
105
;	mov	edx,read_folder_name
93
;	call	debug_outstr
106
;	call	debug_outstr
-
 
107
;newline
-
 
108
end if
94
;newline
109
;--------------------------------------
95
	jmp	exit
110
	jmp	exit
96
@@:
111
@@:
-
 
112
;--------------------------------------
97
;--------------------------------------
113
if debug eq yes
-
 
114
	call	print_root_dir
-
 
115
end if
98
	call	print_root_dir
116
;--------------------------------------
-
 
117
	mov	[left_folder_block],ebx
99
	mov	[left_folder_block],ebx
118
	xor	eax,eax
100
	mov	[temp_counter_1],0
119
	mov	[temp_counter_1],eax
101
	mov	[retrieved_devices_table_counter],0
120
	mov	[retrieved_devices_table_counter],eax
102
.start_temp_counter_1:
121
.start_temp_counter_1:
103
	imul	esi,[temp_counter_1],304
122
	imul	esi,[temp_counter_1],304
104
	add	esi,[read_folder.return]
123
	add	esi,[read_folder.return]
105
	add	esi,32+40
124
	add	esi,32+40
-
 
125
	call	copy_folder_name_1
-
 
126
;--------------------------------------
106
	call	copy_folder_name_1
127
if debug eq yes
107
;dps	'read_folder_1_name: '
128
;dps	'read_folder_1_name: '
108
;	mov	edx,read_folder_1_name
129
;	mov	edx,read_folder_1_name
109
;	call	debug_outstr
130
;	call	debug_outstr
-
 
131
;newline
-
 
132
end if
110
;newline
133
;--------------------------------------
111
	mcall	70,read_folder_1
134
	mcall	70,read_folder_1
112
	test	eax,eax
135
	test	eax,eax
113
	jz	@f
136
	jz	@f
114
	cmp	eax,6
137
	cmp	eax,6
-
 
138
	je	@f
-
 
139
;--------------------------------------
115
	je	@f
140
if debug eq yes
116
dps 'read_folder_error_1'
141
dps 'read_folder_error_1'
117
newline
142
newline
118
;	mov	edx,read_folder_1_name
143
;	mov	edx,read_folder_1_name
119
;	call	debug_outstr
144
;	call	debug_outstr
-
 
145
;newline
-
 
146
end if
120
;newline
147
;--------------------------------------
121
	jmp	exit
148
	jmp	exit
122
@@:
149
@@:
123
	mov	eax,[read_folder_1.return]
150
	mov	eax,[read_folder_1.return]
124
	cmp	[eax+4],dword 0
151
	cmp	[eax+4],dword 0
125
	je	.continue
152
	je	.continue
126
	mov	[right_folder_block],ebx
153
	mov	[right_folder_block],ebx
127
	mov	ebp,0
154
	xor	ebp,ebp
128
.start_copy_device_patch:
155
.start_copy_device_patch:
129
	imul	edi,[retrieved_devices_table_counter],10
156
	imul	edi,[retrieved_devices_table_counter],10
130
	add	edi,retrieved_devices_table
157
	add	edi,retrieved_devices_table
131
	mov	[edi],byte '/'
158
	mov	[edi],byte '/'
Line 149... Line 176...
149
	cmp	eax,[left_folder_block]
176
	cmp	eax,[left_folder_block]
150
	jb	.start_temp_counter_1
177
	jb	.start_temp_counter_1
151
	mov	esi,retrieved_devices_table+1
178
	mov	esi,retrieved_devices_table+1
152
	call	copy_folder_name
179
	call	copy_folder_name
153
	mov	esi,retrieved_devices_table+3
180
	mov	esi,retrieved_devices_table+3
154
	mov	ecx,0
181
	xor	ecx,ecx
155
@@:
182
@@:
156
	add	esi,8
183
	add	esi,8
157
	cld
184
	cld
158
	lodsw
185
	lodsw
159
	inc	ecx
186
	inc	ecx
Line 172... Line 199...
172
load_file:
199
load_file:
173
	mov	[fileinfo.subfunction],dword 5
200
	mov	[fileinfo.subfunction],dword 5
174
	xor	eax,eax
201
	xor	eax,eax
175
	mov	[fileinfo.size],eax
202
	mov	[fileinfo.size],eax
176
	mov	[fs_error],eax
203
	mov	[fs_error],eax
-
 
204
;--------------------------------------
-
 
205
if debug eq yes
177
dps 'get file info'
206
dps 'get file info'
178
newline
207
newline
-
 
208
end if
-
 
209
;--------------------------------------
179
	mcall	70,fileinfo
210
	mcall	70,fileinfo
180
	mov	[fs_error],eax
211
	mov	[fs_error],eax
181
	test	eax,eax
212
	test	eax,eax
182
	jnz	.file_error
213
	jnz	.file_error
-
 
214
;--------------------------------------
-
 
215
if debug eq yes
183
dps 'file info ok'
216
dps 'file info ok'
184
newline
217
newline
-
 
218
end if
-
 
219
;--------------------------------------
-
 
220
	xor	eax,eax
185
	mov	[fileinfo.subfunction],dword 0
221
	mov	[fileinfo.subfunction],eax	;dword 0
186
	mov	eax,[fileinfo.return]
222
	mov	eax,[fileinfo.return]
187
	mov	ecx,[eax+32]
223
	mov	ecx,[eax+32]
-
 
224
;--------------------------------------
-
 
225
if debug eq yes
188
dps 'real file size: '
226
dps 'real file size: '
189
dpd ecx
227
dpd ecx
190
newline
228
newline
-
 
229
end if
-
 
230
;--------------------------------------
191
	test	ecx,ecx
231
	test	ecx,ecx
192
	jz	.file_error
232
	jz	.file_error
193
	cmp	ecx,304*32+32 ; 9 Kb
233
	mov	eax,304*32+32 ; 9 Kb
-
 
234
	cmp	ecx,eax
194
	jbe	@f
235
	jbe	@f
195
	mov	ecx,304*32+32 ; 9 Kb
236
	mov	ecx,eax
196
;-----------------------------------
237
;-----------------------------------
197
@@:	
238
@@:	
198
	mov	[fileinfo.size],ecx
239
	mov	[fileinfo.size],ecx
-
 
240
;--------------------------------------
-
 
241
if debug eq yes
199
dps 'get file'
242
dps 'get file'
200
newline	
243
newline	
-
 
244
end if
-
 
245
;--------------------------------------
201
	mcall	70,fileinfo
246
	mcall	70,fileinfo
202
	mov	[fs_error],eax
247
	mov	[fs_error],eax
203
	test	eax,eax
248
	test	eax,eax
204
	jz	@f
249
	jz	@f
205
;	cmp	eax,6
250
;	cmp	eax,6
Line 207... Line 252...
207
;	xor	eax,eax
252
;	xor	eax,eax
208
;	mov	[fs_error],eax
253
;	mov	[fs_error],eax
209
;	jmp	@f
254
;	jmp	@f
210
;-----------------------------------
255
;-----------------------------------
211
.file_error:
256
.file_error:
-
 
257
;--------------------------------------
-
 
258
if debug eq yes
212
dps 'read file - error!'
259
dps 'read file - error!'
213
newline
260
newline
-
 
261
end if
-
 
262
;--------------------------------------
214
	ret
263
	ret
215
;-----------------------------------	
264
;-----------------------------------	
216
@@:	
265
@@:
-
 
266
;--------------------------------------
-
 
267
if debug eq yes
217
dps 'read file corrected size: '
268
dps 'read file corrected size: '
218
dpd dword[fileinfo.size]
269
dpd dword[fileinfo.size]
219
newline
270
newline
-
 
271
end if
-
 
272
;--------------------------------------
220
	ret
273
	ret
221
;---------------------------------------------------------------------
274
;---------------------------------------------------------------------
222
search_and_load_pointer_file_label:
275
search_and_load_pointer_file_label:
223
	mov	[fileinfo.return],dword folder_data_1
276
	mov	[fileinfo.return],dword folder_data_1
224
	mov	ecx,[retrieved_devices_table_counter]
277
	mov	ecx,[retrieved_devices_table_counter]
225
	dec	ecx	; /rd/1/ no need to check
278
	dec	ecx	; /rd/1/ no need to check
226
	mov	[fileinfo.name],dword read_folder_name
279
	mov	[fileinfo.name],dword read_folder_name
227
	mov	esi,retrieved_devices_table
280
	mov	esi,retrieved_devices_table
228
;	sub	esi,10	; deleted because /rd/1/ no need to check
281
;	sub	esi,10	; deleted because /rd/1/ no need to check
229
.next_entry:
282
.next_entry:
-
 
283
;--------------------------------------
-
 
284
if debug eq yes
230
newline
285
newline
231
dps 'copy next entry'
286
dps 'copy next entry'
232
newline
287
newline
-
 
288
end if
-
 
289
;--------------------------------------
233
	add	esi,10
290
	add	esi,10
234
	push	esi
291
	push	esi
235
	add	esi,1
292
	add	esi,1
236
	call	copy_folder_name
293
	call	copy_folder_name
237
	mov	esi,basic_file_name-1
294
	mov	esi,basic_file_name-1
238
	dec	edi
295
	dec	edi
239
	call	copy_folder_name.1
296
	call	copy_folder_name.1
240
	pop	esi
297
	pop	esi
-
 
298
;--------------------------------------
-
 
299
if debug eq yes
241
	mov	edx,[fileinfo.name]
300
	mov	edx,[fileinfo.name]
242
	push	ecx
301
	push	ecx
243
	call	debug_outstr
302
	call	debug_outstr
244
	pop	ecx
303
	pop	ecx
245
newline	
304
newline	
-
 
305
end if
-
 
306
;--------------------------------------
246
;	mcall	5,10
307
;	mcall	5,10
247
	push	ecx
308
	push	ecx
248
	call	load_file
309
	call	load_file
249
	pop	ecx
310
	pop	ecx
Line 255... Line 316...
255
	cmp	eax,[basic_file_size]
316
	cmp	eax,[basic_file_size]
256
	jae	.sucess
317
	jae	.sucess
257
@@:
318
@@:
258
	dec	ecx
319
	dec	ecx
259
	jnz	.next_entry
320
	jnz	.next_entry
-
 
321
;--------------------------------------
-
 
322
if debug eq yes
260
dps 'additional parttition is not found!'
323
dps 'additional parttition is not found!'
261
newline	
324
newline	
-
 
325
end if
-
 
326
;--------------------------------------
262
	ret
327
	ret
263
.sucess:
328
.sucess:
264
	call	compare_files_and_mount
329
	call	compare_files_and_mount
265
	cmp	[compare_flag],0
330
	cmp	[compare_flag],0
266
	jne	@b
331
	jne	@b
Line 280... Line 345...
280
	jne	.not_match
345
	jne	.not_match
281
	dec	ecx
346
	dec	ecx
282
	jnz	.next_char
347
	jnz	.next_char
283
	mov	[compare_flag],byte 0
348
	mov	[compare_flag],byte 0
284
	pop	esi ecx
349
	pop	esi ecx
-
 
350
;--------------------------------------
-
 
351
if debug eq yes
285
dps 'compare files sucess!'
352
dps 'compare files sucess!'
286
newline	
353
newline	
287
dps 'mount directory:'
354
dps 'mount directory:'
288
newline
355
newline
289
	mov	edx,esi
356
	mov	edx,esi
-
 
357
	push	esi
290
	call	debug_outstr
358
	call	debug_outstr
-
 
359
	pop	esi
291
newline
360
newline
-
 
361
end if
-
 
362
;--------------------------------------
-
 
363
; prepare real directory path for mounting
-
 
364
	inc	esi
-
 
365
	mov	edi,f30_3_work_area+64
-
 
366
	call	proc_copy_patch
-
 
367
; prepare fake directory name
-
 
368
	mov	esi,additional_dir_name
-
 
369
	mov	edi,f30_3_work_area
-
 
370
	call	proc_copy_patch
292
; here is call kernel function to mount the found partition
371
; here is call kernel function to mount the found partition
293
; as "/addappl" directory to root directory "/"
372
; as "/addappl" directory to root directory "/"
-
 
373
	mcall	30,3,f30_3_work_area
294
	ret
374
	ret
295
;--------------------------------------
375
;--------------------------------------
296
.not_match:
376
.not_match:
297
	mov	[compare_flag],byte 1
377
	mov	[compare_flag],byte 1
298
	pop	esi ecx
378
	pop	esi ecx
-
 
379
;--------------------------------------
-
 
380
if debug eq yes
299
dps 'compare files is not match!'
381
dps 'compare files is not match!'
300
newline	
382
newline	
301
	ret
383
end if
302
;---------------------------------------------------------------------
384
;--------------------------------------
303
proc_copy_patch:
-
 
304
@@:
-
 
305
	cld
-
 
306
	lodsb
-
 
307
	stosb
-
 
308
	cmp	al,0
-
 
309
	jne	@r
-
 
310
	ret
385
	ret
311
;---------------------------------------------------------------------	
386
;---------------------------------------------------------------------
312
copy_folder_name:
387
copy_folder_name:
313
	mov	edi,read_folder_name+1
388
	mov	edi,read_folder_name+1
314
.1:
389
.1:
315
@@:
390
proc_copy_patch:
316
	cld
391
	cld
-
 
392
@@:
317
	lodsb
393
	lodsb
318
	stosb
394
	stosb
319
	cmp	al,0
395
	test	al,al
320
	jne	@r
396
	jnz	@r
321
	ret
397
	ret
322
;---------------------------------------------------------------------
398
;---------------------------------------------------------------------
323
copy_folder_name_1:
399
copy_folder_name_1:
324
	mov	edi,read_folder_1_name+1
400
	mov	edi,read_folder_1_name+1
325
@@:
-
 
326
	cld
-
 
327
	lodsb
-
 
328
	stosb
-
 
329
	cmp	al,0
401
	jmp	proc_copy_patch
330
	jne	@r
-
 
331
	ret
-
 
332
;---------------------------------------------------------------------
402
;---------------------------------------------------------------------
-
 
403
if debug eq yes
333
print_retrieved_devices_table:
404
print_retrieved_devices_table:
334
	mov	ecx,[retrieved_devices_table_counter]
405
	mov	ecx,[retrieved_devices_table_counter]
335
	mov	edx,retrieved_devices_table
406
	mov	edx,retrieved_devices_table
336
dps 'retrieved_devices_table:'
407
dps 'retrieved_devices_table:'
337
newline
408
newline
Line 369... Line 440...
369
	popa
440
	popa
370
newline
441
newline
371
dps '----------'
442
dps '----------'
372
newline
443
newline
373
	ret
444
	ret
-
 
445
end if
374
;---------------------------------------------------------------------
446
;---------------------------------------------------------------------
375
read_folder:
447
read_folder:
376
.subfunction	dd 1
448
.subfunction	dd 1
377
.start		dd 0
449
.start		dd 0
378
.flags		dd 0
450
.flags		dd 0
Line 388... Line 460...
388
.size		dd 32
460
.size		dd 32
389
.return		dd folder_data_1
461
.return		dd folder_data_1
390
		db 0
462
		db 0
391
.name:		dd read_folder_1_name
463
.name:		dd read_folder_1_name
392
;---------------------------------------------------------------------
464
;---------------------------------------------------------------------
393
align 4
-
 
394
fileinfo:
465
fileinfo:
395
.subfunction	dd 5
466
.subfunction	dd 5
396
.Offset		dd 0
467
.Offset		dd 0
397
.Offset_1	dd 0
468
.Offset_1	dd 0
398
.size		dd 0
469
.size		dd 0
Line 405... Line 476...
405
;-------------------------------------------------------------------------------
476
;-------------------------------------------------------------------------------
406
basic_file_path:
477
basic_file_path:
407
	db '/rd/1/'
478
	db '/rd/1/'
408
basic_file_name:
479
basic_file_name:
409
	db 'kolibri.lbl',0
480
	db 'kolibri.lbl',0
-
 
481
additional_dir_name:
-
 
482
	db 'addappl',0
410
;-------------------------------------------------------------------------------
483
;-------------------------------------------------------------------------------
411
IM_END:
484
IM_END:
412
;-------------------------------------------------------------------------------
485
;-------------------------------------------------------------------------------
413
align 4
486
align 4
414
left_folder_block	rd 1
487
left_folder_block	rd 1
Line 418... Line 491...
418
basic_file_size		rd 1
491
basic_file_size		rd 1
419
fs_error		rd 1
492
fs_error		rd 1
420
compare_flag		rb 1
493
compare_flag		rb 1
421
;-------------------------------------------------------------------------------
494
;-------------------------------------------------------------------------------
422
align 4
495
align 4
-
 
496
f30_3_work_area:
-
 
497
	rb 128
-
 
498
;-------------------------------------------------------------------------------
-
 
499
align 4
423
retrieved_devices_table:
500
retrieved_devices_table:
424
	rb 10*100
501
	rb 10*100
425
;-------------------------------------------------------------------------------
502
;-------------------------------------------------------------------------------
426
align 4
503
align 4
427
read_folder_name:
504
read_folder_name: