Subversion Repositories Kolibri OS

Rev

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

Rev 357 Rev 363
Line 69... Line 69...
69
   xor eax, eax
69
   xor eax, eax
70
   cld
70
   cld
71
   rep stosd
71
   rep stosd
72
}
72
}
Line -... Line 73...
-
 
73
 
73
 
74
 
-
 
75
align 4
-
 
76
proc fs_execute
74
align 4
77
 
-
 
78
;fn_read:dword, file_size:dword, cluster:dword
-
 
79
 
-
 
80
; ebx - cmdline
-
 
81
; edx - flags
-
 
82
; ebp - full filename
-
 
83
; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it
75
proc fs_exec stdcall file_name:dword, cmd_line:dword, flags:dword
84
 
-
 
85
           locals
-
 
86
             cmdline       rd 64        ;256/4
-
 
87
             filename      rd 256       ;1024/4
-
 
88
             flags         dd ?
76
           locals
89
 
77
             save_cr3      dd ?
90
             save_cr3      dd ?
78
             slot          dd ?
91
             slot          dd ?
79
             slot_base     dd ?
92
             slot_base     dd ?
80
             file_base     dd ?
93
             file_base     dd ?
81
             file_size     dd ?
-
 
-
 
94
             file_size     dd ?
82
 
95
                                          ;app header data
83
             app_cmdline   dd ? ;0x00
96
             hdr_cmdline   dd ? ;0x00
84
             app_path      dd ? ;0x04
97
             hdr_path      dd ? ;0x04
85
             app_eip       dd ? ;0x08
98
             hdr_eip       dd ? ;0x08
86
             app_esp       dd ? ;0x0C
99
             hdr_esp       dd ? ;0x0C
87
             app_mem       dd ? ;0x10
100
             hdr_mem       dd ? ;0x10
88
             app_i_end     dd ? ;0x14
101
             hdr_i_end     dd ? ;0x14
Line -... Line 102...
-
 
102
           endl
-
 
103
 
-
 
104
           pushad
-
 
105
 
-
 
106
           mov [cmdline], ebx
-
 
107
           mov [flags], edx
-
 
108
 
-
 
109
; [ebp]  pointer to filename
-
 
110
 
-
 
111
           lea eax, [filename]
-
 
112
           mov dword [eax+1020],0              ;force terminate
-
 
113
                                               ;string
-
 
114
           stdcall k_strncpy, eax, [ebp], 1023
-
 
115
 
-
 
116
           lea eax, [cmdline]
-
 
117
           mov dword [eax+252], 0
-
 
118
           stdcall k_strncpy, eax, [cmdline], 255
89
           endl
119
 
90
 
120
           lea eax, [filename]
91
           stdcall load_file,[file_name]
121
           stdcall load_file, eax
92
           mov  ecx, -ERROR_FILE_NOT_FOUND
122
           mov  ecx, -ERROR_FILE_NOT_FOUND
Line 93... Line 123...
93
           test eax, eax
123
           test eax, eax
94
           jz .err_file
124
           jz .err_file
Line 95... Line 125...
95
 
125
 
96
           mov [file_base], eax
126
           mov [file_base], eax
97
           mov [file_size], ebx
127
           mov [file_size], ebx
98
 
128
 
99
           lea ebx, [app_cmdline]
129
           lea ebx, [hdr_cmdline]
Line 115... Line 145...
115
           mov eax, 1
145
           mov eax, 1
116
           xchg eax, [application_table_status]
146
           xchg eax, [application_table_status]
117
           cmp eax, 0
147
           cmp eax, 0
118
           jne .wait_lock
148
           jne .wait_lock
Line 119... Line 149...
119
 
149
 
120
           pushfd
150
;           pushfd
Line 121... Line 151...
121
           cli
151
;           cli
Line 122... Line 152...
122
 
152
 
123
           call set_application_table_status
153
           call set_application_table_status
Line 133... Line 163...
133
           mov [slot_base], eax
163
           mov [slot_base], eax
134
           mov edi, eax
164
           mov edi, eax
135
           _clear_ 256     ;clean extended information about process
165
           _clear_ 256     ;clean extended information about process
Line 136... Line 166...
136
 
166
 
137
; write application name
167
; write application name
138
           mov edi, [file_name]
168
           lea edi, [filename]
139
           mov al, '/'
169
           mov al, '/'
Line 140... Line 170...
140
           call k_strrchr  ; now eax points to name without path
170
           call k_strrchr  ; now eax points to name without path
141
 
171
 
142
           lea esi, [eax+1]
172
           lea esi, [eax+1]
143
           test eax, eax
173
           test eax, eax
144
           jnz @F
174
           jnz @F
145
           mov esi, [file_name]
175
           lea esi, [filename]
146
@@:
176
@@:
147
           mov ecx, 8  ; 8 chars for name
177
           mov ecx, 8  ; 8 chars for name
148
           mov edi, [slot_base]
178
           mov edi, [slot_base]
Line 157... Line 187...
157
.copy_process_name_done:
187
.copy_process_name_done:
Line 158... Line 188...
158
 
188
 
159
           mov ebx, cr3
189
           mov ebx, cr3
Line 160... Line 190...
160
           mov [save_cr3], ebx
190
           mov [save_cr3], ebx
161
 
191
 
162
           stdcall create_app_space,[app_mem],[file_base],[file_size]
192
           stdcall create_app_space,[hdr_mem],[file_base],[file_size]
Line 163... Line 193...
163
           test eax, eax
193
           test eax, eax
164
           jz .failed
194
           jz .failed
165
 
195
 
166
           mov   ebx,[slot_base]
196
           mov   ebx,[slot_base]
Line 167... Line 197...
167
           mov   [ebx+APPDATA.dir_table],eax
197
           mov   [ebx+APPDATA.dir_table],eax
168
           mov   eax,[app_mem]
198
           mov   eax,[hdr_mem]
169
           mov   [ebx+APPDATA.mem_size],eax
199
           mov   [ebx+APPDATA.mem_size],eax
170
 
200
 
171
if GREEDY_KERNEL
201
if GREEDY_KERNEL
172
else
202
else
173
           mov ecx, [app_mem]
203
           mov ecx, [hdr_mem]
174
           mov edi, [file_size]
204
           mov edi, [file_size]
Line 185... Line 215...
185
end if
215
end if
Line 186... Line 216...
186
 
216
 
Line 187... Line 217...
187
; release only virtual space, not phisical memory
217
; release only virtual space, not phisical memory
188
 
218
 
189
           stdcall free_kernel_space, [file_base]
219
           stdcall free_kernel_space, [file_base]
-
 
220
           lea eax, [hdr_cmdline]
190
           lea eax, [app_cmdline]
221
           lea ebx, [cmdline]
Line 191... Line 222...
191
           stdcall set_app_params ,[slot],eax,[cmd_line],\
222
           lea ecx, [filename]
192
                                         [file_name], [flags]
223
           stdcall set_app_params ,[slot],eax,ebx,ecx,[flags]
Line 193... Line 224...
193
 
224
 
194
           mov eax, [save_cr3]
225
           mov eax, [save_cr3]
195
           call set_cr3
226
           call set_cr3
196
 
227
 
197
           popfd
228
 ;          popfd
198
           xor ebx, ebx
229
           xor ebx, ebx
199
           mov [application_table_status],ebx ;unlock application_table_status mutex
230
           mov [application_table_status],ebx ;unlock application_table_status mutex
200
           mov eax,[process_number]  ;set result
231
           mov eax,[process_number]  ;set result
201
           ret
232
           ret
202
.failed:
233
.failed:
203
           mov eax, [save_cr3]
234
           mov eax, [save_cr3]
204
           call set_cr3
235
           call set_cr3
205
.err:
236
.err:
206
           popfd
237
 ;          popfd
207
.err_hdr:
238
.err_hdr:
Line 546... Line 577...
546
           stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP
577
           stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP
547
           dec [pg_data.pg_mutex]
578
           dec [pg_data.pg_mutex]
548
           ret
579
           ret
549
endp
580
endp
Line 550... Line -...
550
 
-
 
551
align 4
-
 
552
proc fs_execute
-
 
553
 
-
 
554
;fn_read:dword, file_size:dword, cluster:dword
-
 
555
 
-
 
556
; ebx - cmdline
-
 
557
; edx - flags
-
 
558
; ebp - full filename
-
 
559
; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it
-
 
560
 
-
 
561
           locals
-
 
562
             cmdline    dd ?
-
 
563
             flags      dd ?
-
 
564
             filename   dd ?
-
 
565
             retval     dd ?
-
 
566
           endl
-
 
567
 
-
 
568
           pushad
-
 
569
 
-
 
570
           mov [cmdline], ebx
-
 
571
           mov [flags], edx
-
 
572
           mov eax, [ebp]
-
 
573
           mov [filename], eax
-
 
574
 
-
 
575
           mov ebx, pg_data.tmp_task_mutex
-
 
576
           call wait_mutex   ;ebx
-
 
577
 
-
 
578
           mov edi, [tmp_task_data]
-
 
579
           mov ecx, (1024+256)/4
-
 
580
           xor eax, eax
-
 
581
           rep stosd
-
 
582
 
-
 
583
           mov esi, [filename]
-
 
584
           mov edi, [tmp_task_data]
-
 
585
           mov ecx, 1024
-
 
586
           rep movsb
-
 
587
 
-
 
588
           mov esi, [cmdline]
-
 
589
           test esi, esi
-
 
590
           jz @f
-
 
591
           mov ecx, 256
-
 
592
           rep movsb
-
 
593
@@:
-
 
594
           mov eax, [tmp_task_data]
-
 
595
           lea ebx, [eax+1024]        ;cmd line
-
 
596
 
-
 
597
           stdcall fs_exec, eax, ebx, [flags]
-
 
598
 
-
 
599
           mov [retval], eax
-
 
600
           popad
-
 
601
           mov [pg_data.tmp_task_mutex], 0
-
 
602
           mov eax, [retval]
-
 
603
           ret
-
 
604
 
-
 
605
endp
-
 
606
 
-
 
607
 
581
 
608
pid_to_slot:
582
pid_to_slot:
609
;Input:
583
;Input:
610
;  eax - pid of process
584
;  eax - pid of process
611
;Output:
585
;Output: