Subversion Repositories Kolibri OS

Rev

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

Rev 40 Rev 61
Line 46... Line 46...
46
; eax = 16 ; start application
46
; eax = 16 ; start application
47
;
47
;
48
; OUT:
48
; OUT:
49
;
49
;
50
; eax = 0  : read ok
50
; eax = 0  : read ok
51
; eax = 1  : no fd base and/or partition defined
51
; eax = 1  : no hd base and/or partition defined
52
; eax = 2  : yet unsupported FS
52
; eax = 2  : yet unsupported FS
53
; eax = 3  : unknown FS
53
; eax = 3  : unknown FS
54
; eax = 4  : partition not defined at hd
54
; eax = 4  : partition not defined at hd
55
; eax = 5  : file not found
55
; eax = 5  : file not found
56
; eax = 6  : end of file
56
; eax = 6  : end of file
Line 59... Line 59...
59
; eax = 9  : fat table corrupted
59
; eax = 9  : fat table corrupted
60
; eax = 10 : access denied
60
; eax = 10 : access denied
61
;
61
;
62
; ebx = size
62
; ebx = size
Line -... Line 63...
-
 
63
 
-
 
64
; \begin{diamond}[18.03.2006]
-
 
65
; for subfunction 16 (start application) error codes must be negative
-
 
66
;	because positive values are valid PIDs
-
 
67
; so possible return values are:
-
 
68
; eax > 0 : process created, eax=PID
-
 
69
 
-
 
70
; -0x10 <= eax < 0 : -eax is filesystem error code:
-
 
71
; eax = -1  = 0xFFFFFFFF : no hd base and/or partition defined
-
 
72
; eax = -3  = 0xFFFFFFFD : unknown FS
-
 
73
; eax = -5  = 0xFFFFFFFB : file not found
-
 
74
; eax = -6  = 0xFFFFFFFA : unexpected end of file (probably not executable file)
-
 
75
; eax = -9  = 0xFFFFFFF7 : fat table corrupted
-
 
76
; eax = -10 = 0xFFFFFFF6 : access denied
-
 
77
 
-
 
78
; -0x20 <= eax < -0x10: eax is process creation error code:
-
 
79
; eax = -0x20 = 0xFFFFFFE0 : too many processes
-
 
80
; eax = -0x1F = 0xFFFFFFE1 : not Menuet/Kolibri executable
-
 
81
; eax = -0x1E = 0xFFFFFFE2 : no memory
63
 
82
 
Line -... Line 83...
-
 
83
; ebx is not changed
-
 
84
 
64
    ; Extract parameters
85
; \end{diamond}[18.03.2006]
65
 
86
 
Line 66... Line 87...
66
    mov   edi,[0x3010]
87
    ; Extract parameters
67
    add   eax,[edi+0x10]        ; abs start of info block
88
	add	eax, std_application_base_address	; abs start of info block
68
 
89
 
69
    cmp   dword [eax+0],12      ; Get file size
90
    cmp   dword [eax+0],12      ; Get file size
Line 83... Line 104...
83
    cmp   dword [eax+0],2       ; DELETE - dont care about read&write blocks
104
    cmp   dword [eax+0],2       ; DELETE - dont care about read&write blocks
84
    je    fs_read
105
    je    fs_read
Line 85... Line 106...
85
 
106
 
86
    cmp   dword [0x3000],1      ; no memory checks for kernel requests
107
    cmp   dword [0x3000],1      ; no memory checks for kernel requests
87
    jz    no_checks_for_kernel
-
 
88
;iglobal
-
 
89
;  buffer_failed db 'Buffer check failed',13,10,0
-
 
90
;endg
108
    jz    no_checks_for_kernel
91
    mov   edx,eax
109
    mov   edx,eax
92
    cmp   dword [eax+0],1
110
    cmp   dword [eax+0],1
93
    jz    .check_for_write_op
111
    jz    .check_for_write_op
94
    cmp   dword [eax+0],3
112
    cmp   dword [eax+0],3
Line 102... Line 120...
102
    jnz   area_in_app_mem
120
    jnz   area_in_app_mem
Line 103... Line 121...
103
    
121
    
104
.error_output:
122
.error_output:
105
    mov   esi,buffer_failed
123
    mov   esi,buffer_failed
106
    call  sys_msg_board_str
124
    call  sys_msg_board_str
107
    mov   eax,7
125
;    mov   eax,7
108
    mov   dword [esp+36],7
126
    mov   dword [esp+36],7
109
    ret
127
    ret
110
iglobal
128
iglobal
111
  buffer_failed db 'Buffer check failed',13,10,0
129
  buffer_failed db 'K : Buffer check failed',13,10,0
112
endg 
130
endg 
113
.usual_check:
131
.usual_check:
114
    cmp   dword [eax+0],0
132
    cmp   dword [eax+0],0
115
    mov   ecx,512
133
    mov   ecx,512
Line 120... Line 138...
120
    mov   ebx,[eax+12]
138
    mov   ebx,[eax+12]
121
    add   ebx,std_application_base_address
139
    add   ebx,std_application_base_address
122
    call  check_region
140
    call  check_region
123
    test  eax,eax
141
    test  eax,eax
124
    jz    .error_output
142
    jz    .error_output
125
    jmp   area_in_app_mem           
-
 
126
;    mov   ebx,[0x3000]          ; pointer in application memory ?
-
 
127
;    shl   ebx,8
-
 
128
;    mov   ebx,[ebx+0x80000+0x8c]
-
 
129
 
-
 
130
;    mov   ebp,ebx               ; save for checking at stack save
-
 
131
;    sub   ebp,[eax+12]
-
 
132
;    shr   ebp,9
-
 
133
 
-
 
134
;    sub   ebx,512               ; need atleast one block
-
 
135
 
-
 
136
;    cmp   ebx,[eax+12]
-
 
137
;    ja    area_in_app_mem
-
 
138
;    mov   eax,7
-
 
139
;    mov   dword [esp+36],7
-
 
140
;    ret
-
 
141
  area_in_app_mem:
143
  area_in_app_mem:
142
    mov   eax,edx
144
    mov   eax,edx
143
  no_checks_for_kernel:
145
  no_checks_for_kernel:
Line 144... Line 146...
144
 
146
 
145
 
147
 
146
    cmp   dword [eax+0],3       ; APPEND - allow write 0 bytes (truncate)
148
    cmp   dword [eax+0],3       ; APPEND - allow write 0 bytes (truncate)
147
    je    fs_read
149
    je    fs_read
148
    cmp   dword [eax+8],0       ; read or write 0 blocks/bytes ?
150
    cmp   dword [eax+8],0       ; read or write 0 blocks/bytes ?
149
    jne   fs_read
151
    jne   fs_read
150
    mov   dword [esp+36],0
152
    and   dword [esp+36],0
Line 151... Line 153...
151
    ret
153
    ret
152
  fs_read:
154
  fs_read:
153
 
155
 
154
    mov   ebx,[eax+20]          ; program wants root directory ?
156
    mov   ebx,[eax+20]          ; program wants root directory ?
155
    test  bl,bl
157
    test  bl,bl
156
    je    fs_getroot
158
    je    fs_getroot
-
 
159
    test  bh,bh
-
 
160
    jne   fs_noroot
-
 
161
  fs_getroot:
-
 
162
; \begin{diamond}[18.03.2006]
-
 
163
; root - only read is allowed
-
 
164
; other operations return "access denied", eax=10
-
 
165
; (execute operation returns eax=-10)
157
    test  bh,bh
166
	cmp	dword [eax], 0
-
 
167
	jz	.read_root
-
 
168
	mov	ecx, 10
-
 
169
	cmp	dword [eax], 16
-
 
170
	jnz	@f
-
 
171
	neg	ecx
-
 
172
@@:	mov	[esp+36], ecx
158
    jne   fs_noroot
173
	ret
159
  fs_getroot:
174
.read_root:
160
    mov   edx,[edi+0x10]
175
; \end{diamond}[18.03.2006]
161
    mov   esi,dir0
176
    mov   esi,dir0
162
    mov   edi,[eax+12]
177
    mov   edi,[eax+12]
-
 
178
    add   edi,std_application_base_address
163
    add   edi,edx
179
    mov   ecx,11
164
    mov   ecx,11
180
    push  ecx
165
    cld
181
;    cld	; already is
166
    rep   movsb
182
    rep   movsb
167
    mov   eax,0x10
183
    mov   al,0x10
168
    stosb
184
    stosb
169
    add   edi,32-11-1
185
    add   edi,32-11-1
170
    mov   ecx,11
186
    pop   ecx
171
    rep   movsb
187
    rep   movsb
172
    stosb
188
    stosb
Line 173... Line 189...
173
    mov   dword [esp+36],0      ; ok read
189
    and   dword [esp+36],0      ; ok read
174
    mov   dword [esp+24],32*2   ; size of root
-
 
175
    ret
190
    mov   dword [esp+24],32*2   ; size of root
176
 
191
    ret
177
  fs_info:                      ;start of code - Mihasik
192
 
178
    mov   edi,eax
193
  fs_info:                      ;start of code - Mihasik
179
    push  edi
194
    push  eax
180
    cmp   [eax+21],byte 'h'
195
    cmp   [eax+21],byte 'h'
Line 208... Line 223...
208
    mov   [edi],edx              ; cluster size in bytes
223
    mov   [edi],edx              ; cluster size in bytes
209
    ret                          ;end of code - Mihasik
224
    ret                          ;end of code - Mihasik
Line 210... Line 225...
210
 
225
 
Line 211... Line -...
211
  fs_noroot:
-
 
212
 
226
  fs_noroot:
213
    mov   ebx,[eax+0]
-
 
214
    push  ebx                   ; read/write/delete/.../makedir/rename/lba/run
227
 
215
    mov   ebx,[eax+4]
-
 
216
    push  ebx                   ; 512 block number to read
-
 
217
    mov   ebx,[eax+8]
-
 
218
 
-
 
219
;    cmp   dword [eax+0],0       ; if read, check that the data stays at
-
 
220
;    jne   ret_size_fine         ; application memory
-
 
221
;    cmp   ebx,ebp
-
 
222
;    jbe   ret_size_fine
-
 
223
;    mov   ebx,ebp
-
 
224
;  ret_size_fine:
228
    push  dword [eax+0]         ; read/write/delete/.../makedir/rename/lba/run
225
 
229
    push  dword [eax+4]         ; 512 block number to read
226
    push  ebx                   ; bytes to write/append or 512 blocks to read
230
    push  dword [eax+8]         ; bytes to write/append or 512 blocks to read
227
    mov   ebx,[eax+12]
231
    mov   ebx,[eax+12]
Line 228... Line 232...
228
    add   ebx,[edi+0x10]
232
    add   ebx,std_application_base_address
229
    push  ebx                   ; abs start of return/save area
-
 
230
 
233
    push  ebx                   ; abs start of return/save area
-
 
234
 
Line 231... Line 235...
231
    lea   esi,[eax+20]          ; abs start of dir + filename
235
    lea   esi,[eax+20]          ; abs start of dir + filename
Line 232... Line 236...
232
    mov   edi,[edi+0x10]        ; abs start of work area
236
    mov   edi,[eax+16]
233
    add   edi,[eax+16]
237
    add   edi,std_application_base_address	; abs start of work area
Line 234... Line -...
234
 
-
 
235
    call  expand_pathz
238
 
236
 
239
    call  expand_pathz
237
    push  edi                   ; dir start
240
 
238
    push  ebx                   ; name of file start
241
    push  edi                   ; dir start
239
 
242
    push  ebx                   ; name of file start
Line 240... Line 243...
240
    mov   ebx,[dir0+11]         ; /RAMDISK
243
 
Line 241... Line 244...
241
    mov   eax,[edi+1]
244
    mov   eax,[edi+1]
242
    cmp   eax,'RD  '
245
    cmp   eax,'RD  '
Line 243... Line -...
243
    je    fs_yesramdisk
-
 
244
    cmp   eax,ebx
246
    je    fs_yesramdisk
245
    jne   fs_noramdisk
247
    cmp   eax,'RAMD'
246
 
248
    jne   fs_noramdisk
247
  fs_yesramdisk:
249
 
248
 
250
  fs_yesramdisk:
Line 249... Line 251...
249
    cmp   byte [edi+1+11],0
251
 
Line 250... Line 252...
250
    je    fs_give_dir1
252
    cmp   byte [edi+1+11],0
Line 310... Line 312...
310
 
312
 
311
    mov   eax,[esp+4]           ; fname
313
    mov   eax,[esp+4]           ; fname
Line 312... Line 314...
312
    add   eax,2*12+1
314
    add   eax,2*12+1
313
 
315
 
314
    xor   ebx,ebx               ; parameters to pass
316
    xor   ebx,ebx               ; parameters to pass
315
    cmp   dword [esp+12],0
-
 
316
    je    no_fl_start_param
317
    cmp   dword [esp+12],ebx;0
317
    mov   ebx,[0x3010]
318
    je    no_fl_start_param
318
    mov   ebx,[ebx+0x10]
319
    mov   ebx, [esp+12]
319
    add   ebx,[esp+12]
320
    add   ebx, std_application_base_address
Line 320... Line 321...
320
  no_fl_start_param:
321
  no_fl_start_param:
Line 321... Line 322...
321
    mov   edx,[esp+16]		; flags
322
    mov   edx,[esp+16]		; flags
Line 322... Line 323...
322
 
323
 
323
    call  start_application_fl
324
    call  start_application_fl
324
 
325
 
325
    jmp   file_system_return
326
    jmp   file_system_startapp_return
Line 348... Line 349...
348
  fs_noramdisk_getinfo:             ;End of code - Mihasik
349
  fs_noramdisk_getinfo:             ;End of code - Mihasik
Line 349... Line 350...
349
 
350
 
Line 350... Line 351...
350
  fs_noramdisk:
351
  fs_noramdisk:
351
  
-
 
352
  ;********************************************************************
352
  
353
    mov   ebx,[dir0+22]         ; /FLOPPYDISK
353
  ;********************************************************************
354
    mov   eax,[edi+1]
354
    mov   eax,[edi+1]
355
    cmp   eax,'FD  '
355
    cmp   eax,'FD  '
356
    je    fs_yesflpdisk
356
    je    fs_yesflpdisk
Line 357... Line 357...
357
    cmp   eax,ebx
357
    cmp   eax,'FLOP'
358
    jne   fs_noflpdisk
358
    jne   fs_noflpdisk
Line 359... Line 359...
359
 
359
 
360
  fs_yesflpdisk:
360
  fs_yesflpdisk:
Line 361... Line -...
361
    call   reserve_flp
-
 
362
 
361
    call   reserve_flp
363
    cmp   byte [edi+1+11],0
362
 
364
    je    fs_give_dir1
363
    cmp   byte [edi+1+11],0
365
 
364
    je    fs_give_dir1
366
    mov   ebx,[dir1]            ; /FIRST
365
 
367
    mov   eax,[edi+1+12]
-
 
368
    cmp   eax,'1   '            
366
    mov   eax,[edi+1+12]
369
    je    fs_yesflpdisk_first
367
    cmp   eax,'1   '            
370
    cmp   eax,ebx
368
    je    fs_yesflpdisk_first
371
    je    fs_yesflpdisk_first
369
    cmp   eax,'FIRS'
372
    mov   ebx,[dir1+11]         ; /SECOND
370
    je    fs_yesflpdisk_first
Line 373... Line 371...
373
    cmp   eax,'2   '
371
    cmp   eax,'2   '
374
    je    fs_yesflpdisk_second
372
    je    fs_yesflpdisk_second
Line 432... Line 430...
432
 
430
 
433
    mov   eax,[esp+4]           ; fname
431
    mov   eax,[esp+4]           ; fname
Line 434... Line 432...
434
    add   eax,2*12+1
432
    add   eax,2*12+1
435
 
433
 
436
    xor   ebx,ebx               ; parameters to pass
434
    xor   ebx,ebx               ; parameters to pass
437
    cmp   dword [esp+12],0
435
    cmp   dword [esp+12],ebx;0
438
    je    no_flp_start_param
436
    je    no_flp_start_param
439
    mov   ebx,[0x3010]
437
    mov   ebx,[0x3010]
Line 440... Line 438...
440
    mov   ebx,[ebx+0x10]
438
    mov   ebx,[ebx+0x10]
441
    add   ebx,[esp+12]
439
    add   ebx,[esp+12]
Line 442... Line 440...
442
 
440
 
Line -... Line 441...
-
 
441
  no_flp_start_param:
-
 
442
    mov   edx,[esp+16]		; flags
443
  no_flp_start_param:
443
 
Line 444... Line 444...
444
    mov   edx,[esp+16]		; flags
444
    call  start_application_floppy
Line 445... Line 445...
445
 
445
 
Line 493... Line 493...
493
choice_necessity_partition:
493
choice_necessity_partition:
494
    mov   eax,[edi+1+12]
494
    mov   eax,[edi+1+12]
495
    call  StringToNumber
495
    call  StringToNumber
496
        mov   [fat32part],eax
496
        mov   [fat32part],eax
497
choice_necessity_partition_1:
497
choice_necessity_partition_1:
498
    mov   [0xfe10],dword 0    ; entries in hd cache
-
 
499
    mov   ecx,[hdpos]
498
    mov   ecx,[hdpos]
500
    xor   eax,eax
499
    xor   eax,eax
-
 
500
    mov   [0xfe10], eax    ; entries in hd cache
501
    mov   edx,0x40002
501
    mov   edx,0x40002
502
 search_partition_array:
502
 search_partition_array:
503
    mov   bl,[edx]
503
    mov   bl,[edx]
504
    movzx ebx,bl
504
    movzx ebx,bl
505
    add   eax,ebx
505
    add   eax,ebx
Line 514... Line 514...
514
    mov   [transfer_adress],eax
514
    mov   [transfer_adress],eax
515
    call  partition_data_transfer_1
515
    call  partition_data_transfer_1
516
    ret
516
    ret
Line 517... Line 517...
517
 
517
 
518
 old_path_harddisk:
-
 
519
    mov   ebx,[dir0]            ; /HARDDISK
518
 old_path_harddisk:
520
    mov   eax,[edi+1]
519
    mov   eax,[edi+1]
521
    cmp   eax,'HD  '
520
    cmp   eax,'HD  '
522
    je    fs_yesharddisk
521
    je    fs_yesharddisk
523
    cmp   eax,ebx
522
    cmp   eax,'HARD'
Line 524... Line 523...
524
    jne   fs_noharddisk
523
    jne   fs_noharddisk
525
 
524
 
Line 541... Line 540...
541
 fs_for_new_semantic:
540
 fs_for_new_semantic:
542
    call  choice_necessity_partition 
541
    call  choice_necessity_partition 
Line 543... Line 542...
543
 
542
 
544
  fs_yesharddisk_all:
543
  fs_yesharddisk_all:
-
 
544
    mov   eax,1
-
 
545
	cmp	dword [esp+20], 16
-
 
546
	jnz	@f
-
 
547
	neg	eax
545
    mov   eax,1
548
@@:	mov	ebx, [esp+24+24]
546
    cmp   [hdpos],0             ; is hd base set?
549
    cmp   [hdpos],0             ; is hd base set?
547
    jz    file_system_return    ; no
550
    jz    file_system_return    ; no
548
    cmp   [fat32part],0         ; is partition set?
551
    cmp   [fat32part],0         ; is partition set?
Line 659... Line 662...
659
 
662
 
660
    mov   edi,[esp+0]           ; start of source file name
663
    mov   edi,[esp+0]           ; start of source file name
661
    add   edi,12+1              ; continue after name
664
    add   edi,12+1              ; continue after name
Line 662... Line -...
662
    call  expand_pathz          ; convert destination name
-
 
663
 
665
    call  expand_pathz          ; convert destination name
664
    mov   edx,[dir0]            ; /HARDDISK
666
 
665
    mov   eax,[edi+1]
667
    mov   eax,[edi+1]
666
    cmp   eax,'HD  '
668
    cmp   eax,'HD  '
667
    je    fs_rename_test1
669
    je    fs_rename_test1
Line 668... Line 670...
668
    cmp   eax,edx
670
    cmp   eax,'HARD'
669
    jne   fs_rename_error
-
 
670
 
671
    jne   fs_rename_error
671
  fs_rename_test1:
672
 
672
    mov   edx,[dir1]            ; /FIRST
673
  fs_rename_test1:
673
    mov   eax,[edi+1+12]
674
    mov   eax,[edi+1+12]
674
    cmp   eax,'1   '
675
    cmp   eax,'1   '
Line 675... Line 676...
675
    je    fs_rename_start
676
    je    fs_rename_start
676
    cmp   eax,edx
677
    cmp   eax,'FIRS'
677
    jne   fs_rename_error
678
    jne   fs_rename_error
Line 772... Line 773...
772
 
773
 
773
    mov   ecx,[esp+4]           ; work area
774
    mov   ecx,[esp+4]           ; work area
Line 774... Line 775...
774
    add   ecx,512
775
    add   ecx,512
775
 
776
 
776
    xor   ebp,ebp               ; parameters to pass
777
    xor   ebp,ebp               ; parameters to pass
777
    cmp   dword [esp+12],0
-
 
778
    je    no_hd_start_param
778
    cmp   dword [esp+12],ebp;0
779
    mov   ebp,[0x3010]
779
    je    no_hd_start_param
780
    mov   ebp,[ebp+0x10]
780
    mov   ebp, [esp+12]
781
    add   ebp,[esp+12]
781
    add   ebp, std_application_base_address
Line 782... Line 782...
782
  no_hd_start_param:
782
  no_hd_start_param:
Line 783... Line 783...
783
    mov   edx,[esp+16]		; flags
783
    mov   edx,[esp+16]		; flags
Line 784... Line 784...
784
 
784
 
Line 785... Line 785...
785
    call  start_application_hd
785
    call  start_application_hd
-
 
786
 
-
 
787
    jmp   file_system_startapp_return
-
 
788
 
-
 
789
  fs_noharddisk_start_application:
-
 
790
 
-
 
791
  fs_noharddisk:
-
 
792
; \begin{diamond}[18.03.2006]
-
 
793
	mov	eax, 5		; file not found
Line 786... Line 794...
786
 
794
; à ìîæåò áûòü, âîçâðàùàòü äðóãîé êîä îøèáêè?
Line 787... Line 795...
787
    jmp   file_system_return
795
	cmp	dword [esp+20], 16
Line 799... Line 807...
799
    ret
807
    ret
Line 800... Line 808...
800
 
808
 
Line -... Line 809...
-
 
809
 
-
 
810
  fs_give_dir1:
-
 
811
 
-
 
812
; \begin{diamond}[18.03.2006]
-
 
813
; /RD,/FD,/HD - only read is allowed
-
 
814
; other operations return "access denied", eax=10
-
 
815
; (execute operation returns eax=-10)
-
 
816
	cmp	dword [esp+20], 0
-
 
817
	jz	.read
-
 
818
	add	esp, 20
-
 
819
	pop	ecx
-
 
820
	mov	eax, 10
-
 
821
	cmp	ecx, 16
-
 
822
	jnz	@f
-
 
823
	neg	eax
-
 
824
@@:	mov	[esp+36], eax
801
 
825
	ret
802
  fs_give_dir1:
826
.read:
803
 
827
; \end{diamond}[18.03.2006]
804
    mov   eax,0x10
828
    mov   al,0x10
805
    mov   ebx,1
829
    mov   ebx,1
806
    mov   edi,[esp+8]
830
    mov   edi,[esp+8]
807
    mov   esi,dir1
831
    mov   esi,dir1
808
  fs_d1_new:
832
  fs_d1_new:
809
    mov   ecx,11
833
    mov   ecx,11
810
    cld
834
;    cld
811
    rep   movsb
835
    rep   movsb
812
    stosb
836
    stosb
Line 813... Line 837...
813
    add   edi,32-11-1
837
    add   edi,32-11-1
Line 814... Line 838...
814
    dec   ebx
838
    dec   ebx
815
    jne   fs_d1_new
839
    jne   fs_d1_new
816
 
840
 
Line 849... Line 873...
849
    mov   esi,eax
873
    mov   esi,eax
Line 850... Line 874...
850
 
874
 
851
    shl   esi,9
875
    shl   esi,9
852
    add   esi,0x100000
876
    add   esi,0x100000
853
    mov   ecx,512/4
877
    mov   ecx,512/4
854
    cld
878
;    cld
Line 855... Line 879...
855
    rep   movsd
879
    rep   movsd
Line 856... Line 880...
856
 
880