Subversion Repositories Kolibri OS

Rev

Rev 839 | Rev 843 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 839 Rev 840
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
 
7
 
8
$Revision: 839 $
8
$Revision: 840 $
9
 
9
 
10
 
10
 
11
GREEDY_KERNEL  equ 0
11
GREEDY_KERNEL  equ 0
12
 
12
 
13
struc APP_HEADER_00
13
struc APP_HEADER_00
14
{ .banner      dq ?
14
{ .banner      dq ?
15
  .version     dd ?    ;+8
15
  .version     dd ?    ;+8
16
  .start       dd ?    ;+12
16
  .start       dd ?    ;+12
17
  .i_end       dd ?    ;+16
17
  .i_end       dd ?    ;+16
18
  .mem_size    dd ?    ;+20
18
  .mem_size    dd ?    ;+20
19
  .i_param     dd ?    ;+24
19
  .i_param     dd ?    ;+24
20
}
20
}
21
 
21
 
22
struc APP_HEADER_01
22
struc APP_HEADER_01
23
{ .banner      dq ?
23
{ .banner      dq ?
24
  .version     dd ?    ;+8
24
  .version     dd ?    ;+8
25
  .start       dd ?    ;+12
25
  .start       dd ?    ;+12
26
  .i_end       dd ?    ;+16
26
  .i_end       dd ?    ;+16
27
  .mem_size    dd ?    ;+20
27
  .mem_size    dd ?    ;+20
28
  .stack_top   dd ?    ;+24
28
  .stack_top   dd ?    ;+24
29
  .i_param     dd ?    ;+28
29
  .i_param     dd ?    ;+28
30
  .i_icon      dd ?    ;+32
30
  .i_icon      dd ?    ;+32
31
}
31
}
32
 
32
 
33
 
33
 
34
struc APP_PARAMS
34
struc APP_PARAMS
35
{ .app_cmdline	 ;0x00
35
{ .app_cmdline	 ;0x00
36
  .app_path	 ;0x04
36
  .app_path	 ;0x04
37
  .app_eip	 ;0x08
37
  .app_eip	 ;0x08
38
  .app_esp	 ;0x0C
38
  .app_esp	 ;0x0C
39
  .app_mem	 ;0x10
39
  .app_mem	 ;0x10
40
}
40
}
41
 
41
 
42
macro _clear_ op
42
macro _clear_ op
43
{  mov ecx, op/4
43
{  mov ecx, op/4
44
   xor eax, eax
44
   xor eax, eax
45
   cld
45
   cld
46
   rep stosd
46
   rep stosd
47
}
47
}
48
 
48
 
49
fs_execute_from_sysdir:
49
fs_execute_from_sysdir:
50
	xor	ebx, ebx
50
	xor	ebx, ebx
51
	xor	edx, edx
51
	xor	edx, edx
52
	mov	esi, sysdir_path
52
	mov	esi, sysdir_path
53
 
53
 
54
align 4
54
align 4
55
proc fs_execute
55
proc fs_execute
56
 
56
 
57
;fn_read:dword, file_size:dword, cluster:dword
57
;fn_read:dword, file_size:dword, cluster:dword
58
 
58
 
59
; ebx - cmdline
59
; ebx - cmdline
60
; edx - flags
60
; edx - flags
61
; ebp - full filename
61
; ebp - full filename
62
; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it
62
; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it
63
 
63
 
64
	   locals
64
	   locals
65
	     cmdline	   rd 64	;256/4
65
	     cmdline	   rd 64	;256/4
66
	     filename	   rd 256	;1024/4
66
	     filename	   rd 256	;1024/4
67
	     flags	   dd ?
67
	     flags	   dd ?
68
 
68
 
69
	     save_cr3	   dd ?
69
	     save_cr3	   dd ?
70
	     slot	   dd ?
70
	     slot	   dd ?
71
	     slot_base	   dd ?
71
	     slot_base	   dd ?
72
	     file_base	   dd ?
72
	     file_base	   dd ?
73
	     file_size	   dd ?
73
	     file_size	   dd ?
74
					  ;app header data
74
					  ;app header data
75
	     hdr_cmdline   dd ? ;0x00
75
	     hdr_cmdline   dd ? ;0x00
76
	     hdr_path	   dd ? ;0x04
76
	     hdr_path	   dd ? ;0x04
77
	     hdr_eip	   dd ? ;0x08
77
	     hdr_eip	   dd ? ;0x08
78
	     hdr_esp	   dd ? ;0x0C
78
	     hdr_esp	   dd ? ;0x0C
79
	     hdr_mem	   dd ? ;0x10
79
	     hdr_mem	   dd ? ;0x10
80
	     hdr_i_end	   dd ? ;0x14
80
	     hdr_i_end	   dd ? ;0x14
81
	   endl
81
	   endl
82
 
82
 
83
	   pushad
83
	   pushad
84
 
84
 
85
	   mov [flags], edx
85
	   mov [flags], edx
86
 
86
 
87
; [ebp]  pointer to filename
87
; [ebp]  pointer to filename
88
 
88
 
89
	   lea edi, [filename]
89
	   lea edi, [filename]
90
	   lea ecx, [edi+1024]
90
	   lea ecx, [edi+1024]
91
	   mov al, '/'
91
	   mov al, '/'
92
	   stosb
92
	   stosb
93
@@:
93
@@:
94
	   cmp edi, ecx
94
	   cmp edi, ecx
95
	   jae .bigfilename
95
	   jae .bigfilename
96
	   lodsb
96
	   lodsb
97
	   stosb
97
	   stosb
98
	   test al, al
98
	   test al, al
99
	   jnz @b
99
	   jnz @b
100
	   mov esi, [ebp]
100
	   mov esi, [ebp]
101
	   test esi, esi
101
	   test esi, esi
102
	   jz .namecopied
102
	   jz .namecopied
103
	   mov byte [edi-1], '/'
103
	   mov byte [edi-1], '/'
104
@@:
104
@@:
105
	   cmp edi, ecx
105
	   cmp edi, ecx
106
	   jae .bigfilename
106
	   jae .bigfilename
107
	   lodsb
107
	   lodsb
108
	   stosb
108
	   stosb
109
	   test al, al
109
	   test al, al
110
	   jnz @b
110
	   jnz @b
111
	   jmp .namecopied
111
	   jmp .namecopied
112
.bigfilename:
112
.bigfilename:
113
	   popad
113
	   popad
114
	   mov eax, -ERROR_FILE_NOT_FOUND
114
	   mov eax, -ERROR_FILE_NOT_FOUND
115
	   ret
115
	   ret
116
.namecopied:
116
.namecopied:
117
 
117
 
118
	   mov [cmdline], ebx
118
	   mov [cmdline], ebx
119
	   test ebx, ebx
119
	   test ebx, ebx
120
	   jz @F
120
	   jz @F
121
 
121
 
122
	   lea eax, [cmdline]
122
	   lea eax, [cmdline]
123
	   mov dword [eax+252], 0
123
	   mov dword [eax+252], 0
124
	   stdcall strncpy, eax, ebx, 255
124
	   stdcall strncpy, eax, ebx, 255
125
@@:
125
@@:
126
	   lea eax, [filename]
126
	   lea eax, [filename]
127
	   stdcall load_file, eax
127
	   stdcall load_file, eax
128
	   mov	ecx, -ERROR_FILE_NOT_FOUND
128
	   mov	ecx, -ERROR_FILE_NOT_FOUND
129
	   test eax, eax
129
	   test eax, eax
130
	   jz .err_file
130
	   jz .err_file
131
 
131
 
132
	   mov [file_base], eax
132
	   mov [file_base], eax
133
	   mov [file_size], ebx
133
	   mov [file_size], ebx
134
 
134
 
135
	   lea ebx, [hdr_cmdline]
135
	   lea ebx, [hdr_cmdline]
136
	   call test_app_header
136
	   call test_app_header
137
	   mov ecx, -0x1F
137
	   mov ecx, -0x1F
138
	   test eax, eax
138
	   test eax, eax
139
	   jz .err_hdr
139
	   jz .err_hdr
140
 
140
 
141
	   DEBUGF 1,"%s",new_process_loading
141
	   DEBUGF 1,"%s",new_process_loading
142
 
142
 
143
.wait_lock:
143
.wait_lock:
144
	   cmp [application_table_status],0
144
	   cmp [application_table_status],0
145
	   je .get_lock
145
	   je .get_lock
146
	   call   change_task
146
	   call   change_task
147
	   jmp .wait_lock
147
	   jmp .wait_lock
148
 
148
 
149
.get_lock:
149
.get_lock:
150
	   mov eax, 1
150
	   mov eax, 1
151
	   xchg eax, [application_table_status]
151
	   xchg eax, [application_table_status]
152
	   cmp eax, 0
152
	   cmp eax, 0
153
	   jne .wait_lock
153
	   jne .wait_lock
154
 
154
 
155
	   call set_application_table_status
155
	   call set_application_table_status
156
 
156
 
157
	   call get_new_process_place
157
	   call get_new_process_place
158
	   test eax, eax
158
	   test eax, eax
159
	   mov ecx, -0x20      ; too many processes
159
	   mov ecx, -0x20      ; too many processes
160
	   jz .err
160
	   jz .err
161
 
161
 
162
	   mov [slot], eax
162
	   mov [slot], eax
163
	   shl eax, 8
163
	   shl eax, 8
164
	   add eax, SLOT_BASE
164
	   add eax, SLOT_BASE
165
	   mov [slot_base], eax
165
	   mov [slot_base], eax
166
	   mov edi, eax
166
	   mov edi, eax
167
	   _clear_ 256	   ;clean extended information about process
167
	   _clear_ 256	   ;clean extended information about process
168
 
168
 
169
; write application name
169
; write application name
170
	   lea eax, [filename]
170
	   lea eax, [filename]
171
	   stdcall strrchr,  eax, '/'  ; now eax points to name without path
171
	   stdcall strrchr,  eax, '/'  ; now eax points to name without path
172
 
172
 
173
	   lea esi, [eax+1]
173
	   lea esi, [eax+1]
174
	   test eax, eax
174
	   test eax, eax
175
	   jnz @F
175
	   jnz @F
176
	   lea esi, [filename]
176
	   lea esi, [filename]
177
@@:
177
@@:
178
	   mov ecx, 8  ; 8 chars for name
178
	   mov ecx, 8  ; 8 chars for name
179
	   mov edi, [slot_base]
179
	   mov edi, [slot_base]
180
.copy_process_name_loop:
180
.copy_process_name_loop:
181
	   lodsb
181
	   lodsb
182
	   cmp al, '.'
182
	   cmp al, '.'
183
	   jz .copy_process_name_done
183
	   jz .copy_process_name_done
184
	   test al, al
184
	   test al, al
185
	   jz .copy_process_name_done
185
	   jz .copy_process_name_done
186
	   stosb
186
	   stosb
187
	   loop .copy_process_name_loop
187
	   loop .copy_process_name_loop
188
.copy_process_name_done:
188
.copy_process_name_done:
189
 
189
 
190
 
190
 
191
	   mov ebx, cr3
191
	   mov ebx, cr3
192
	   mov [save_cr3], ebx
192
	   mov [save_cr3], ebx
193
 
193
 
194
	   stdcall create_app_space,[hdr_mem],[file_base],[file_size]
194
	   stdcall create_app_space,[hdr_mem],[file_base],[file_size]
195
	   mov ecx, -30  ; no memory
195
	   mov ecx, -30  ; no memory
196
	   test eax, eax
196
	   test eax, eax
197
	   jz .failed
197
	   jz .failed
198
 
198
 
199
	   mov	 ebx,[slot_base]
199
	   mov	 ebx,[slot_base]
200
	   mov	 [ebx+APPDATA.dir_table],eax
200
	   mov	 [ebx+APPDATA.dir_table],eax
201
	   mov	 eax,[hdr_mem]
201
	   mov	 eax,[hdr_mem]
202
	   mov	 [ebx+APPDATA.mem_size],eax
202
	   mov	 [ebx+APPDATA.mem_size],eax
203
 
203
 
204
if GREEDY_KERNEL
204
if GREEDY_KERNEL
205
else
205
else
206
	   mov ecx, [hdr_mem]
206
	   mov ecx, [hdr_mem]
207
	   mov edi, [file_size]
207
	   mov edi, [file_size]
208
	   add edi, 4095
208
	   add edi, 4095
209
	   and edi, not 4095
209
	   and edi, not 4095
210
	   sub ecx, edi
210
	   sub ecx, edi
211
	   jna @F
211
	   jna @F
212
 
212
 
213
	   xor eax, eax
213
	   xor eax, eax
214
           cld
214
           cld
215
	   rep stosb
215
	   rep stosb
216
@@:
216
@@:
217
end if
217
end if
218
 
218
 
219
; release only virtual space, not phisical memory
219
; release only virtual space, not phisical memory
220
 
220
 
221
	   stdcall free_kernel_space, [file_base]
221
	   stdcall free_kernel_space, [file_base]
222
	   lea eax, [hdr_cmdline]
222
	   lea eax, [hdr_cmdline]
223
	   lea ebx, [cmdline]
223
	   lea ebx, [cmdline]
224
	   lea ecx, [filename]
224
	   lea ecx, [filename]
225
	   stdcall set_app_params ,[slot],eax,ebx,ecx,[flags]
225
	   stdcall set_app_params ,[slot],eax,ebx,ecx,[flags]
226
 
226
 
227
	   mov eax, [save_cr3]
227
	   mov eax, [save_cr3]
228
	   call set_cr3
228
	   call set_cr3
229
 
229
 
230
	   xor ebx, ebx
230
	   xor ebx, ebx
231
	   mov [application_table_status],ebx ;unlock application_table_status mutex
231
	   mov [application_table_status],ebx ;unlock application_table_status mutex
232
	   mov eax,[process_number]  ;set result
232
	   mov eax,[process_number]  ;set result
233
	   ret
233
	   ret
234
.failed:
234
.failed:
235
	   mov eax, [save_cr3]
235
	   mov eax, [save_cr3]
236
	   call set_cr3
236
	   call set_cr3
237
.err:
237
.err:
238
.err_hdr:
238
.err_hdr:
239
	   stdcall kernel_free,[file_base]
239
	   stdcall kernel_free,[file_base]
240
.err_file:
240
.err_file:
241
	   xor eax, eax
241
	   xor eax, eax
242
	   mov [application_table_status],eax
242
	   mov [application_table_status],eax
243
	   mov eax, ecx
243
	   mov eax, ecx
244
	   ret
244
	   ret
245
endp
245
endp
246
 
246
 
247
align 4
247
align 4
248
test_app_header:
248
test_app_header:
249
	   virtual at eax
249
	   virtual at eax
250
	     APP_HEADER_00 APP_HEADER_00
250
	     APP_HEADER_00 APP_HEADER_00
251
	   end virtual
251
	   end virtual
252
	   virtual at eax
252
	   virtual at eax
253
	     APP_HEADER_01 APP_HEADER_01
253
	     APP_HEADER_01 APP_HEADER_01
254
	   end virtual
254
	   end virtual
255
 
255
 
256
	   cmp dword [eax], 'MENU'
256
	   cmp dword [eax], 'MENU'
257
	   jne .fail
257
	   jne .fail
258
	   cmp word [eax+4],'ET'
258
	   cmp word [eax+4],'ET'
259
	   jne .fail
259
	   jne .fail
260
 
260
 
261
	   cmp [eax+6], word '00'
261
	   cmp [eax+6], word '00'
262
	   jne	.check_01_header
262
	   jne	.check_01_header
263
 
263
 
264
	   mov	ecx,[APP_HEADER_00.start]
264
	   mov	ecx,[APP_HEADER_00.start]
265
	   mov	[ebx+0x08], ecx 	       ;app_eip
265
	   mov	[ebx+0x08], ecx 	       ;app_eip
266
	   mov	edx,[APP_HEADER_00.mem_size]
266
	   mov	edx,[APP_HEADER_00.mem_size]
267
	   mov	[ebx+0x10], edx 	       ;app_mem
267
	   mov	[ebx+0x10], edx 	       ;app_mem
268
	   shr	edx,1
268
	   shr	edx,1
269
	   sub	edx,0x10
269
	   sub	edx,0x10
270
	   mov	[ebx+0x0C], edx 	       ;app_esp
270
	   mov	[ebx+0x0C], edx 	       ;app_esp
271
	   mov	ecx,[APP_HEADER_00.i_param]
271
	   mov	ecx,[APP_HEADER_00.i_param]
272
	   mov	[ebx], ecx		       ;app_cmdline
272
	   mov	[ebx], ecx		       ;app_cmdline
273
	   mov	[ebx+4], dword 0	       ;app_path
273
	   mov	[ebx+4], dword 0	       ;app_path
274
	   mov	edx, [APP_HEADER_00.i_end]
274
	   mov	edx, [APP_HEADER_00.i_end]
275
	   mov	[ebx+0x14], edx
275
	   mov	[ebx+0x14], edx
276
	   ret
276
	   ret
277
 
277
 
278
 .check_01_header:
278
 .check_01_header:
279
 
279
 
280
	   cmp	[eax+6],word '01'
280
	   cmp	[eax+6],word '01'
281
	   jne	.fail
281
	   jne	.fail
282
 
282
 
283
	   mov	ecx,[APP_HEADER_01.start]
283
	   mov	ecx,[APP_HEADER_01.start]
284
	   mov	[ebx+0x08], ecx 	       ;app_eip
284
	   mov	[ebx+0x08], ecx 	       ;app_eip
285
	   mov	edx,[APP_HEADER_01.mem_size]
285
	   mov	edx,[APP_HEADER_01.mem_size]
286
 
286
 
287
; \begin{diamond}[20.08.2006]
287
; \begin{diamond}[20.08.2006]
288
; sanity check (functions 19,58 load app_i_end bytes and that must
288
; sanity check (functions 19,58 load app_i_end bytes and that must
289
; fit in allocated memory to prevent kernel faults)
289
; fit in allocated memory to prevent kernel faults)
290
	   cmp	edx,[APP_HEADER_01.i_end]
290
	   cmp	edx,[APP_HEADER_01.i_end]
291
	   jb	.fail
291
	   jb	.fail
292
; \end{diamond}[20.08.2006]
292
; \end{diamond}[20.08.2006]
293
 
293
 
294
	   mov	[ebx+0x10], edx 	       ;app_mem
294
	   mov	[ebx+0x10], edx 	       ;app_mem
295
	   mov	ecx,[APP_HEADER_01.stack_top]
295
	   mov	ecx,[APP_HEADER_01.stack_top]
296
	   mov	[ebx+0x0C], ecx 	       ;app_esp
296
	   mov	[ebx+0x0C], ecx 	       ;app_esp
297
	   mov	edx,[APP_HEADER_01.i_param]
297
	   mov	edx,[APP_HEADER_01.i_param]
298
	   mov	[ebx], edx		       ;app_cmdline
298
	   mov	[ebx], edx		       ;app_cmdline
299
	   mov	ecx,[APP_HEADER_01.i_icon]
299
	   mov	ecx,[APP_HEADER_01.i_icon]
300
	   mov	[ebx+4], ecx		       ;app_path
300
	   mov	[ebx+4], ecx		       ;app_path
301
	   mov	edx, [APP_HEADER_01.i_end]
301
	   mov	edx, [APP_HEADER_01.i_end]
302
	   mov	[ebx+0x14], edx
302
	   mov	[ebx+0x14], edx
303
	   ret
303
	   ret
304
.fail:
304
.fail:
305
	   xor eax, eax
305
	   xor eax, eax
306
	   ret
306
	   ret
307
 
307
 
308
align 4
308
align 4
309
proc get_new_process_place
309
proc get_new_process_place
310
;input:
310
;input:
311
;  none
311
;  none
312
;result:
312
;result:
313
;  eax=[new_process_place]<>0 - ok
313
;  eax=[new_process_place]<>0 - ok
314
;      0 - failed.
314
;      0 - failed.
315
;This function find least empty slot.
315
;This function find least empty slot.
316
;It doesn't increase [TASK_COUNT]!
316
;It doesn't increase [TASK_COUNT]!
317
	   mov	  eax,CURRENT_TASK
317
	   mov	  eax,CURRENT_TASK
318
	   mov	  ebx,[TASK_COUNT]
318
	   mov	  ebx,[TASK_COUNT]
319
	   inc	  ebx
319
	   inc	  ebx
320
	   shl	  ebx,5
320
	   shl	  ebx,5
321
	   add	  ebx,eax		;ebx - address of process information for (last+1) slot
321
	   add	  ebx,eax		;ebx - address of process information for (last+1) slot
322
.newprocessplace:
322
.newprocessplace:
323
;eax = address of process information for current slot
323
;eax = address of process information for current slot
324
	   cmp	  eax,ebx
324
	   cmp	  eax,ebx
325
	   jz	  .endnewprocessplace	;empty slot after high boundary
325
	   jz	  .endnewprocessplace	;empty slot after high boundary
326
	   add	  eax,0x20
326
	   add	  eax,0x20
327
	   cmp	  word [eax+0xa],9	;check process state, 9 means that process slot is empty
327
	   cmp	  word [eax+0xa],9	;check process state, 9 means that process slot is empty
328
	   jnz	  .newprocessplace
328
	   jnz	  .newprocessplace
329
.endnewprocessplace:
329
.endnewprocessplace:
330
	   mov	  ebx,eax
330
	   mov	  ebx,eax
331
	   sub	  eax,CURRENT_TASK
331
	   sub	  eax,CURRENT_TASK
332
	   shr	  eax,5 		;calculate slot index
332
	   shr	  eax,5 		;calculate slot index
333
	   cmp	  eax,256
333
	   cmp	  eax,256
334
	   jge	  .failed		;it should be <256
334
	   jge	  .failed		;it should be <256
335
	   mov	  word [ebx+0xa],9	;set process state to 9 (for slot after hight boundary)
335
	   mov	  word [ebx+0xa],9	;set process state to 9 (for slot after hight boundary)
336
	   ret
336
	   ret
337
.failed:
337
.failed:
338
	   xor	  eax,eax
338
	   xor	  eax,eax
339
	   ret
339
	   ret
340
endp
340
endp
341
 
341
 
342
align 4
342
align 4
343
proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword
343
proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword
344
	   locals
344
	   locals
345
	     app_pages	 dd ?
345
	     app_pages	 dd ?
346
	     img_pages	 dd ?
346
	     img_pages	 dd ?
347
	     dir_addr	 dd ?
347
	     dir_addr	 dd ?
348
	     app_tabs	 dd ?
348
	     app_tabs	 dd ?
349
	   endl
349
	   endl
350
 
350
 
351
	   mov ebx, pg_data.pg_mutex
351
	   mov ebx, pg_data.pg_mutex
352
	   call wait_mutex   ;ebx
352
	   call wait_mutex   ;ebx
353
 
353
 
354
	   xor eax, eax
354
	   xor eax, eax
355
	   mov [dir_addr], eax
355
	   mov [dir_addr], eax
356
 
356
 
357
	   mov eax, [app_size]
357
	   mov eax, [app_size]
358
	   add eax, 4095
358
	   add eax, 4095
359
	   and eax, NOT(4095)
359
	   and eax, NOT(4095)
360
	   mov [app_size], eax
360
	   mov [app_size], eax
361
	   mov ebx, eax
361
	   mov ebx, eax
362
	   shr eax, 12
362
	   shr eax, 12
363
	   mov [app_pages], eax
363
	   mov [app_pages], eax
364
 
364
 
365
	   add ebx, 0x3FFFFF
365
	   add ebx, 0x3FFFFF
366
	   and ebx, NOT(0x3FFFFF)
366
	   and ebx, NOT(0x3FFFFF)
367
	   shr ebx, 22
367
	   shr ebx, 22
368
	   mov [app_tabs], ebx
368
	   mov [app_tabs], ebx
369
 
369
 
370
	   mov ecx, [img_size]
370
	   mov ecx, [img_size]
371
	   add ecx, 4095
371
	   add ecx, 4095
372
	   and ecx, NOT(4095)
372
	   and ecx, NOT(4095)
373
 
373
 
374
	   mov [img_size], ecx
374
	   mov [img_size], ecx
375
	   shr ecx, 12
375
	   shr ecx, 12
376
	   mov [img_pages], ecx
376
	   mov [img_pages], ecx
377
 
377
 
378
     if GREEDY_KERNEL
378
     if GREEDY_KERNEL
379
	   lea eax, [ecx+ebx+2]    ;only image size
379
	   lea eax, [ecx+ebx+2]    ;only image size
380
     else
380
     else
381
	   lea eax, [eax+ebx+2]    ;all requested memory
381
	   lea eax, [eax+ebx+2]    ;all requested memory
382
     end if
382
     end if
383
	   cmp eax, [pg_data.pages_free]
383
	   cmp eax, [pg_data.pages_free]
384
	   ja .fail
384
	   ja .fail
385
 
385
 
386
	   call alloc_page
386
	   call alloc_page
387
	   test eax, eax
387
	   test eax, eax
388
	   jz .fail
388
	   jz .fail
389
	   mov [dir_addr], eax
389
	   mov [dir_addr], eax
390
 
390
 
391
           lea edi, [eax + OS_BASE]
391
           lea edi, [eax + OS_BASE]
392
           mov ecx, (OS_BASE shr 20)/4
392
           mov ecx, (OS_BASE shr 20)/4
393
	   xor eax, eax
393
	   xor eax, eax
394
	   cld
394
	   cld
395
	   rep stosd
395
	   rep stosd
396
 
396
 
397
           mov ecx, 1024-(OS_BASE shr 20)/4
397
           mov ecx, 1024-(OS_BASE shr 20)/4
398
	   mov esi, sys_pgdir+(OS_BASE shr 20)
398
	   mov esi, sys_pgdir+(OS_BASE shr 20)
399
	   rep movsd
399
	   rep movsd
400
 
400
 
401
           mov edi, [dir_addr]
401
           mov edi, [dir_addr]
402
           lea eax, [edi+PG_SW]
402
           lea eax, [edi+PG_SW]
403
           mov [edi+OS_BASE+(page_tabs shr 20)], eax
403
           mov [edi+OS_BASE+(page_tabs shr 20)], eax
404
 
404
 
405
           and eax, -4096
405
           and eax, -4096
406
	   call set_cr3
406
	   call set_cr3
407
 
407
 
408
	   mov edx, [app_tabs]
408
	   mov edx, [app_tabs]
409
           xor edi, edi
409
           xor edi, edi
410
@@:
410
@@:
411
	   call alloc_page
411
	   call alloc_page
412
	   test eax, eax
412
	   test eax, eax
413
	   jz .fail
413
	   jz .fail
414
 
414
 
415
	   stdcall map_page_table, edi, eax
415
	   stdcall map_page_table, edi, eax
416
	   add edi, 0x00400000
416
	   add edi, 0x00400000
417
	   dec edx
417
	   dec edx
418
	   jnz @B
418
	   jnz @B
419
 
419
 
420
           mov edi, page_tabs
420
           mov edi, page_tabs
421
 
421
 
422
	   mov ecx, [app_tabs]
422
	   mov ecx, [app_tabs]
423
	   shl ecx, 10
423
	   shl ecx, 10
424
	   xor eax, eax
424
	   xor eax, eax
425
	   rep stosd
425
	   rep stosd
426
 
426
 
427
	   mov ecx, [img_pages]
427
	   mov ecx, [img_pages]
428
	   mov ebx, PG_UW
428
	   mov ebx, PG_UW
429
           mov esi, [img_base]
429
           mov esi, [img_base]
430
	   shr esi, 10
430
	   shr esi, 10
431
	   add esi, page_tabs
431
	   add esi, page_tabs
432
           xor edx, edx
432
           xor edx, edx
433
           mov edi, page_tabs
433
           mov edi, page_tabs
434
.remap:
434
.remap:
435
	   lodsd
435
	   lodsd
436
	   or eax, ebx	    ; force user level r/w access
436
	   or eax, ebx	    ; force user level r/w access
437
	   stosd
437
	   stosd
438
	   add edx, 0x1000
438
	   add edx, 0x1000
439
	   dec [app_pages]
439
	   dec [app_pages]
440
	   dec ecx
440
	   dec ecx
441
	   jnz .remap
441
	   jnz .remap
442
 
442
 
443
	   mov ecx, [app_pages]
443
	   mov ecx, [app_pages]
444
	   test ecx, ecx
444
	   test ecx, ecx
445
	   jz .done
445
	   jz .done
446
 
446
 
447
if GREEDY_KERNEL
447
if GREEDY_KERNEL
448
	   mov eax, 0x02
448
	   mov eax, 0x02
449
           rep stosd
449
           rep stosd
450
else
450
else
451
 
451
 
452
.alloc:
452
.alloc:
453
	   call alloc_page
453
	   call alloc_page
454
	   test eax, eax
454
	   test eax, eax
455
	   jz .fail
455
	   jz .fail
456
 
456
 
457
	   stdcall map_page,edx,eax,dword PG_UW
457
	   stdcall map_page,edx,eax,dword PG_UW
458
	   add edx, 0x1000
458
	   add edx, 0x1000
459
	   dec [app_pages]
459
	   dec [app_pages]
460
	   jnz .alloc
460
	   jnz .alloc
461
end if
461
end if
462
 
462
 
463
.done:
463
.done:
464
           dec [pg_data.pg_mutex]
464
           dec [pg_data.pg_mutex]
465
	   mov eax, [dir_addr]
465
	   mov eax, [dir_addr]
466
	   ret
466
	   ret
467
.fail:
467
.fail:
468
	   dec [pg_data.pg_mutex]
468
	   dec [pg_data.pg_mutex]
469
	   cmp [dir_addr], 0
469
	   cmp [dir_addr], 0
470
	   je @f
470
	   je @f
471
	   stdcall destroy_app_space, [dir_addr]
471
	   stdcall destroy_app_space, [dir_addr]
472
@@:
472
@@:
473
	   xor eax, eax
473
	   xor eax, eax
474
	   ret
474
	   ret
475
endp
475
endp
476
 
476
 
477
align 4
477
align 4
478
set_cr3:
478
set_cr3:
479
 
479
 
480
	   mov ebx, [current_slot]
480
	   mov ebx, [current_slot]
481
	   mov [ebx+APPDATA.dir_table], eax
481
	   mov [ebx+APPDATA.dir_table], eax
482
	   mov cr3, eax
482
	   mov cr3, eax
483
	   ret
483
	   ret
484
 
484
 
485
align 4
485
align 4
486
proc destroy_page_table stdcall, pg_tab:dword
486
proc destroy_page_table stdcall, pg_tab:dword
487
 
487
 
488
	   push esi
488
	   push esi
489
 
489
 
490
	   mov esi, [pg_tab]
490
	   mov esi, [pg_tab]
491
	   mov ecx, 1024
491
	   mov ecx, 1024
492
.free:
492
.free:
493
	   mov eax, [esi]
493
	   mov eax, [esi]
494
	   test eax, 1
494
	   test eax, 1
495
	   jz .next
495
	   jz .next
496
           test eax, 1 shl 9
496
           test eax, 1 shl 9
497
           jnz .next                      ;skip shared pages
497
           jnz .next                      ;skip shared pages
498
	   call free_page
498
	   call free_page
499
.next:
499
.next:
500
	   add esi, 4
500
	   add esi, 4
501
	   dec ecx
501
	   dec ecx
502
	   jnz .free
502
	   jnz .free
503
	   pop esi
503
	   pop esi
504
	   ret
504
	   ret
505
endp
505
endp
506
 
506
 
507
align 4
507
align 4
508
proc destroy_app_space stdcall, pg_dir:dword
508
proc destroy_app_space stdcall, pg_dir:dword
509
 
509
 
510
	   mov ebx, pg_data.pg_mutex
510
	   mov ebx, pg_data.pg_mutex
511
	   call wait_mutex   ;ebx
511
	   call wait_mutex   ;ebx
512
 
512
 
513
	   xor	 edx,edx
513
	   xor	 edx,edx
514
	   mov	 eax,0x2
514
	   mov	 eax,0x2
515
	   mov ebx, [pg_dir]
515
	   mov ebx, [pg_dir]
516
.loop:
516
.loop:
517
;eax = current slot of process
517
;eax = current slot of process
518
	   mov	 ecx,eax
518
	   mov	 ecx,eax
519
	   shl	 ecx,5
519
	   shl	 ecx,5
520
	   cmp	 byte [CURRENT_TASK+ecx+0xa],9	;if process running?
520
	   cmp	 byte [CURRENT_TASK+ecx+0xa],9	;if process running?
521
	   jz	 @f				 ;skip empty slots
521
	   jz	 @f				 ;skip empty slots
522
	   shl	 ecx,3
522
	   shl	 ecx,3
523
	   cmp	 [SLOT_BASE+ecx+0xB8],ebx	;compare page directory addresses
523
	   cmp	 [SLOT_BASE+ecx+0xB8],ebx	;compare page directory addresses
524
	   jnz	 @f
524
	   jnz	 @f
525
	   inc	 edx				;thread found
525
	   inc	 edx				;thread found
526
@@:
526
@@:
527
	   inc	 eax
527
	   inc	 eax
528
	   cmp	 eax,[TASK_COUNT]		;exit loop if we look through all processes
528
	   cmp	 eax,[TASK_COUNT]		;exit loop if we look through all processes
529
	   jle	 .loop
529
	   jle	 .loop
530
 
530
 
531
;edx = number of threads
531
;edx = number of threads
532
;our process is zombi so it isn't counted
532
;our process is zombi so it isn't counted
533
	   cmp	 edx,1
533
	   cmp	 edx,1
534
	   jg	 .exit
534
	   jg	 .exit
535
;if there isn't threads then clear memory.
535
;if there isn't threads then clear memory.
536
 
536
 
537
	   mov eax, [pg_dir]
537
	   mov eax, [pg_dir]
538
           and eax, -4096
538
           and eax, -4096
539
           add eax, OS_BASE
539
           add eax, OS_BASE
540
           mov [tmp_task_pdir], eax
540
           mov [tmp_task_pdir], eax
541
           mov esi, eax
541
           mov esi, eax
542
           mov edi, (HEAP_BASE shr 20)/4
542
           mov edi, (HEAP_BASE shr 20)/4
543
.destroy:
543
.destroy:
544
	   mov eax, [esi]
544
	   mov eax, [esi]
545
	   test eax, 1
545
	   test eax, 1
546
	   jz .next
546
	   jz .next
547
	   and eax, not 0xFFF
547
	   and eax, not 0xFFF
548
           add eax, OS_BASE
548
           add eax, OS_BASE
549
 
549
 
550
           stdcall destroy_page_table, eax
550
           stdcall destroy_page_table, eax
551
 
551
 
552
           mov eax, [esi]
552
           mov eax, [esi]
553
	   call free_page
553
	   call free_page
554
.next:
554
.next:
555
	   add esi, 4
555
	   add esi, 4
556
	   dec edi
556
	   dec edi
557
	   jnz .destroy
557
	   jnz .destroy
558
 
558
 
559
	   mov eax, [pg_dir]
559
	   mov eax, [pg_dir]
560
	   call free_page
560
	   call free_page
561
.exit:
561
.exit:
562
	   dec [pg_data.pg_mutex]
562
	   dec [pg_data.pg_mutex]
563
	   ret
563
	   ret
564
endp
564
endp
565
 
565
 
566
align 4
566
align 4
567
get_pid:
567
get_pid:
568
	   mov eax, [TASK_BASE]
568
	   mov eax, [TASK_BASE]
569
           mov eax, [eax+TASKDATA.pid]
569
           mov eax, [eax+TASKDATA.pid]
570
	   ret
570
	   ret
571
 
571
 
572
pid_to_slot:
572
pid_to_slot:
573
;Input:
573
;Input:
574
;  eax - pid of process
574
;  eax - pid of process
575
;Output:
575
;Output:
576
;  eax - slot of process or 0 if process don't exists
576
;  eax - slot of process or 0 if process don't exists
577
;Search process by PID.
577
;Search process by PID.
578
    push   ebx
578
    push   ebx
579
    push   ecx
579
    push   ecx
580
    mov    ebx,[TASK_COUNT]
580
    mov    ebx,[TASK_COUNT]
581
    shl    ebx,5
581
    shl    ebx,5
582
    mov    ecx,2*32
582
    mov    ecx,2*32
583
 
583
 
584
.loop:
584
.loop:
585
;ecx=offset of current process info entry
585
;ecx=offset of current process info entry
586
;ebx=maximum permitted offset
586
;ebx=maximum permitted offset
587
    cmp    byte [CURRENT_TASK+ecx+0xa],9
587
    cmp    byte [CURRENT_TASK+ecx+0xa],9
588
    jz	   .endloop		 ;skip empty slots
588
    jz	   .endloop		 ;skip empty slots
589
    cmp    [CURRENT_TASK+ecx+0x4],eax ;check PID
589
    cmp    [CURRENT_TASK+ecx+0x4],eax ;check PID
590
    jz	   .pid_found
590
    jz	   .pid_found
591
.endloop:
591
.endloop:
592
    add    ecx,32
592
    add    ecx,32
593
    cmp    ecx,ebx
593
    cmp    ecx,ebx
594
    jle    .loop
594
    jle    .loop
595
 
595
 
596
    pop    ecx
596
    pop    ecx
597
    pop    ebx
597
    pop    ebx
598
    xor    eax,eax
598
    xor    eax,eax
599
    ret
599
    ret
600
 
600
 
601
.pid_found:
601
.pid_found:
602
    shr    ecx,5
602
    shr    ecx,5
603
    mov    eax,ecx		 ;convert offset to index of slot
603
    mov    eax,ecx		 ;convert offset to index of slot
604
    pop    ecx
604
    pop    ecx
605
    pop    ebx
605
    pop    ebx
606
    ret
606
    ret
607
 
607
 
608
check_region:
608
check_region:
609
;input:
609
;input:
610
;  ebx - start of buffer
610
;  ebx - start of buffer
611
;  ecx - size of buffer
611
;  ecx - size of buffer
612
;result:
612
;result:
613
;  eax = 1 region lays in app memory
613
;  eax = 1 region lays in app memory
614
;  eax = 0 region don't lays in app memory
614
;  eax = 0 region don't lays in app memory
615
     mov  eax,[CURRENT_TASK]
615
     mov  eax,[CURRENT_TASK]
616
     jmp  check_process_region
616
     jmp  check_process_region
617
;-----------------------------------------------------------------------------
617
;-----------------------------------------------------------------------------
618
check_process_region:
618
check_process_region:
619
;input:
619
;input:
620
;  eax - slot
620
;  eax - slot
621
;  ebx - start of buffer
621
;  ebx - start of buffer
622
;  ecx - size of buffer
622
;  ecx - size of buffer
623
;result:
623
;result:
624
;  eax = 1 region lays in app memory
624
;  eax = 1 region lays in app memory
625
;  eax = 0 region don't lays in app memory
625
;  eax = 0 region don't lays in app memory
626
 
626
 
627
     test ecx,ecx
627
     test ecx,ecx
628
     jle  .ok
628
     jle  .ok
629
     shl  eax,5
629
     shl  eax,5
630
     cmp  word [CURRENT_TASK+eax+0xa],0
630
     cmp  word [CURRENT_TASK+eax+0xa],0
631
     jnz  .failed
631
     jnz  .failed
632
     shl  eax,3
632
     shl  eax,3
633
     mov  eax,[SLOT_BASE+eax+0xb8]
633
     mov  eax,[SLOT_BASE+eax+0xb8]
634
     test eax,eax
634
     test eax,eax
635
     jz   .failed
635
     jz   .failed
636
 
636
 
637
     mov  eax,1
637
     mov  eax,1
638
     ret
638
     ret
639
 
639
 
640
 
640
 
641
;    call MEM_Get_Linear_Address
641
;    call MEM_Get_Linear_Address
642
;    push ebx
642
;    push ebx
643
;    push ecx
643
;    push ecx
644
;    push edx
644
;    push edx
645
;    mov  edx,ebx
645
;    mov  edx,ebx
646
;    and  edx,not (4096-1)
646
;    and  edx,not (4096-1)
647
;    sub  ebx,edx
647
;    sub  ebx,edx
648
;    add  ecx,ebx
648
;    add  ecx,ebx
649
;    mov  ebx,edx
649
;    mov  ebx,edx
650
;    add  ecx,(4096-1)
650
;    add  ecx,(4096-1)
651
;    and  ecx,not (4096-1)
651
;    and  ecx,not (4096-1)
652
;.loop:
652
;.loop:
653
;;eax - linear address of page directory
653
;;eax - linear address of page directory
654
;;ebx - current page
654
;;ebx - current page
655
;;ecx - current size
655
;;ecx - current size
656
;    mov  edx,ebx
656
;    mov  edx,ebx
657
;    shr  edx,22
657
;    shr  edx,22
658
;    mov  edx,[eax+4*edx]
658
;    mov  edx,[eax+4*edx]
659
;    and  edx,not (4096-1)
659
;    and  edx,not (4096-1)
660
;    test edx,edx
660
;    test edx,edx
661
;    jz   .failed1
661
;    jz   .failed1
662
;    push eax
662
;    push eax
663
;    mov  eax,edx
663
;    mov  eax,edx
664
;    call MEM_Get_Linear_Address
664
;    call MEM_Get_Linear_Address
665
;    mov  edx,ebx
665
;    mov  edx,ebx
666
;    shr  edx,12
666
;    shr  edx,12
667
;    and  edx,(1024-1)
667
;    and  edx,(1024-1)
668
;    mov  eax,[eax+4*edx]
668
;    mov  eax,[eax+4*edx]
669
;    and  eax,not (4096-1)
669
;    and  eax,not (4096-1)
670
;    test eax,eax
670
;    test eax,eax
671
;    pop  eax
671
;    pop  eax
672
;    jz   .failed1
672
;    jz   .failed1
673
;    add  ebx,4096
673
;    add  ebx,4096
674
;    sub  ecx,4096
674
;    sub  ecx,4096
675
;    jg   .loop
675
;    jg   .loop
676
;    pop  edx
676
;    pop  edx
677
;    pop  ecx
677
;    pop  ecx
678
;    pop  ebx
678
;    pop  ebx
679
.ok:
679
.ok:
680
    mov  eax,1
680
    mov  eax,1
681
    ret
681
    ret
682
;
682
;
683
;.failed1:
683
;.failed1:
684
;    pop  edx
684
;    pop  edx
685
;    pop  ecx
685
;    pop  ecx
686
;    pop  ebx
686
;    pop  ebx
687
.failed:
687
.failed:
688
    xor  eax,eax
688
    xor  eax,eax
689
    ret
689
    ret
690
 
690
 
691
align 4
691
align 4
692
proc read_process_memory
692
proc read_process_memory
693
;Input:
693
;Input:
694
;  eax - process slot
694
;  eax - process slot
695
;  ebx - buffer address
695
;  ebx - buffer address
696
;  ecx - buffer size
696
;  ecx - buffer size
697
;  edx - start address in other process
697
;  edx - start address in other process
698
;Output:
698
;Output:
699
;  eax - number of bytes read.
699
;  eax - number of bytes read.
700
	   locals
700
	   locals
701
	     slot	dd ?
701
	     slot	dd ?
702
	     buff	dd ?
702
	     buff	dd ?
703
	     r_count	dd ?
703
	     r_count	dd ?
704
	     offset	dd ?
704
	     offset	dd ?
705
	     tmp_r_cnt	dd ?
705
	     tmp_r_cnt	dd ?
706
	   endl
706
	   endl
707
 
707
 
708
	   mov [slot], eax
708
	   mov [slot], eax
709
	   mov [buff], ebx
709
	   mov [buff], ebx
710
	   and [r_count], 0
710
	   and [r_count], 0
711
	   mov [tmp_r_cnt], ecx
711
	   mov [tmp_r_cnt], ecx
712
	   mov [offset], edx
712
	   mov [offset], edx
713
 
713
 
714
	   pushad
714
	   pushad
715
.read_mem:
715
.read_mem:
716
	   mov edx, [offset]
716
	   mov edx, [offset]
717
	   mov ebx, [tmp_r_cnt]
717
	   mov ebx, [tmp_r_cnt]
718
 
718
 
719
	   mov ecx, 0x400000
719
	   mov ecx, 0x400000
720
	   and edx, 0x3FFFFF
720
	   and edx, 0x3FFFFF
721
	   sub ecx, edx
721
	   sub ecx, edx
722
	   cmp ecx, ebx
722
	   cmp ecx, ebx
723
	   jbe @f
723
	   jbe @f
724
	   mov ecx, ebx
724
	   mov ecx, ebx
725
@@:
725
@@:
726
	   cmp ecx, 0x8000
726
	   cmp ecx, 0x8000
727
	   jna @F
727
	   jna @F
728
	   mov ecx, 0x8000
728
	   mov ecx, 0x8000
729
@@:
729
@@:
730
	   mov eax, [slot]
730
	   mov eax, [slot]
731
	   shl	eax,8
731
	   shl	eax,8
732
	   mov ebx, [offset]
732
	   mov ebx, [offset]
733
     ;      add ebx, new_app_base
733
     ;      add ebx, new_app_base
734
	   push ecx
734
	   push ecx
735
	   stdcall map_memEx, [proc_mem_map],\
735
	   stdcall map_memEx, [proc_mem_map],\
736
			      [SLOT_BASE+eax+0xB8],\
736
			      [SLOT_BASE+eax+0xB8],\
737
			      ebx, ecx
737
			      ebx, ecx
738
	   pop ecx
738
	   pop ecx
739
 
739
 
740
	   mov esi, [offset]
740
	   mov esi, [offset]
741
	   and esi, 0xfff
741
	   and esi, 0xfff
742
	   add esi, [proc_mem_map]
742
	   add esi, [proc_mem_map]
743
	   mov edi, [buff]
743
	   mov edi, [buff]
744
	   mov edx, ecx
744
	   mov edx, ecx
745
	   rep movsb
745
	   rep movsb
746
	   add [r_count], edx
746
	   add [r_count], edx
747
 
747
 
748
	   add [offset], edx
748
	   add [offset], edx
749
	   sub [tmp_r_cnt], edx
749
	   sub [tmp_r_cnt], edx
750
	   jnz .read_mem
750
	   jnz .read_mem
751
 
751
 
752
	   popad
752
	   popad
753
	   mov eax, [r_count]
753
	   mov eax, [r_count]
754
	   ret
754
	   ret
755
endp
755
endp
756
 
756
 
757
align 4
757
align 4
758
proc write_process_memory
758
proc write_process_memory
759
;Input:
759
;Input:
760
;  eax - process slot
760
;  eax - process slot
761
;  ebx - buffer address
761
;  ebx - buffer address
762
;  ecx - buffer size
762
;  ecx - buffer size
763
;  edx - start address in other process
763
;  edx - start address in other process
764
;Output:
764
;Output:
765
;  eax - number of bytes written
765
;  eax - number of bytes written
766
 
766
 
767
	   locals
767
	   locals
768
	     slot	dd ?
768
	     slot	dd ?
769
	     buff	dd ?
769
	     buff	dd ?
770
	     w_count	dd ?
770
	     w_count	dd ?
771
	     offset	dd ?
771
	     offset	dd ?
772
	     tmp_w_cnt	dd ?
772
	     tmp_w_cnt	dd ?
773
	   endl
773
	   endl
774
 
774
 
775
	   mov [slot], eax
775
	   mov [slot], eax
776
	   mov [buff], ebx
776
	   mov [buff], ebx
777
	   and [w_count], 0
777
	   and [w_count], 0
778
	   mov [tmp_w_cnt], ecx
778
	   mov [tmp_w_cnt], ecx
779
	   mov [offset], edx
779
	   mov [offset], edx
780
 
780
 
781
	   pushad
781
	   pushad
782
.read_mem:
782
.read_mem:
783
	   mov edx, [offset]
783
	   mov edx, [offset]
784
	   mov ebx, [tmp_w_cnt]
784
	   mov ebx, [tmp_w_cnt]
785
 
785
 
786
	   mov ecx, 0x400000
786
	   mov ecx, 0x400000
787
	   and edx, 0x3FFFFF
787
	   and edx, 0x3FFFFF
788
	   sub ecx, edx
788
	   sub ecx, edx
789
	   cmp ecx, ebx
789
	   cmp ecx, ebx
790
	   jbe @f
790
	   jbe @f
791
	   mov ecx, ebx
791
	   mov ecx, ebx
792
@@:
792
@@:
793
	   cmp ecx, 0x8000
793
	   cmp ecx, 0x8000
794
	   jna @F
794
	   jna @F
795
	   mov ecx, 0x8000
795
	   mov ecx, 0x8000
796
@@:
796
@@:
797
	   mov eax, [slot]
797
	   mov eax, [slot]
798
	   shl	eax,8
798
	   shl	eax,8
799
	   mov ebx, [offset]
799
	   mov ebx, [offset]
800
      ;     add ebx, new_app_base
800
      ;     add ebx, new_app_base
801
	   push ecx
801
	   push ecx
802
	   stdcall map_memEx, [proc_mem_map],\
802
	   stdcall map_memEx, [proc_mem_map],\
803
			      [SLOT_BASE+eax+0xB8],\
803
			      [SLOT_BASE+eax+0xB8],\
804
			      ebx, ecx
804
			      ebx, ecx
805
	   pop ecx
805
	   pop ecx
806
 
806
 
807
	   mov edi, [offset]
807
	   mov edi, [offset]
808
	   and edi, 0xfff
808
	   and edi, 0xfff
809
	   add edi, [proc_mem_map]
809
	   add edi, [proc_mem_map]
810
	   mov esi, [buff]
810
	   mov esi, [buff]
811
	   mov edx, ecx
811
	   mov edx, ecx
812
	   rep movsb
812
	   rep movsb
813
 
813
 
814
	   add [w_count], edx
814
	   add [w_count], edx
815
	   add [offset], edx
815
	   add [offset], edx
816
	   sub [tmp_w_cnt], edx
816
	   sub [tmp_w_cnt], edx
817
	   jnz .read_mem
817
	   jnz .read_mem
818
 
818
 
819
	   popad
819
	   popad
820
	   mov eax, [w_count]
820
	   mov eax, [w_count]
821
	   ret
821
	   ret
822
endp
822
endp
823
 
823
 
824
align 4
824
align 4
825
proc new_sys_threads
825
proc new_sys_threads
826
	   locals
826
	   locals
827
	     slot	   dd ?
827
	     slot	   dd ?
828
	     app_cmdline   dd ? ;0x00
828
	     app_cmdline   dd ? ;0x00
829
	     app_path	   dd ? ;0x04
829
	     app_path	   dd ? ;0x04
830
	     app_eip	   dd ? ;0x08
830
	     app_eip	   dd ? ;0x08
831
	     app_esp	   dd ? ;0x0C
831
	     app_esp	   dd ? ;0x0C
832
	     app_mem	   dd ? ;0x10
832
	     app_mem	   dd ? ;0x10
833
	   endl
833
	   endl
834
 
834
 
835
	   cmp eax,1
835
	   cmp eax,1
836
	   jne .failed			;other subfunctions
836
	   jne .failed			;other subfunctions
837
 
837
 
838
	   xor	eax,eax
838
	   xor	eax,eax
839
	   mov [app_cmdline], eax
839
	   mov [app_cmdline], eax
840
	   mov [app_path], eax
840
	   mov [app_path], eax
841
	   mov [app_eip], ebx
841
	   mov [app_eip], ebx
842
	   mov [app_esp], ecx
842
	   mov [app_esp], ecx
843
 
843
 
844
	   ;mov    esi,new_process_loading
844
	   ;mov    esi,new_process_loading
845
	   ;call   sys_msg_board_str
845
	   ;call   sys_msg_board_str
846
	   DEBUGF 1,"%s",new_process_loading
846
	   DEBUGF 1,"%s",new_process_loading
847
.wait_lock:
847
.wait_lock:
848
	   cmp [application_table_status],0
848
	   cmp [application_table_status],0
849
	   je .get_lock
849
	   je .get_lock
850
	   call   change_task
850
	   call   change_task
851
	   jmp .wait_lock
851
	   jmp .wait_lock
852
 
852
 
853
.get_lock:
853
.get_lock:
854
	   mov eax, 1
854
	   mov eax, 1
855
	   xchg eax, [application_table_status]
855
	   xchg eax, [application_table_status]
856
	   cmp eax, 0
856
	   cmp eax, 0
857
	   jne .wait_lock
857
	   jne .wait_lock
858
 
858
 
859
	   call   set_application_table_status
859
	   call   set_application_table_status
860
 
860
 
861
	   call get_new_process_place
861
	   call get_new_process_place
862
	   test eax, eax
862
	   test eax, eax
863
	   jz .failed
863
	   jz .failed
864
 
864
 
865
	   mov [slot], eax
865
	   mov [slot], eax
866
 
866
 
867
	   mov	  esi,[current_slot]
867
	   mov	  esi,[current_slot]
868
	   mov	  ebx,esi	      ;ebx=esi - pointer to extended information about current thread
868
	   mov	  ebx,esi	      ;ebx=esi - pointer to extended information about current thread
869
 
869
 
870
	   mov	  edi, eax
870
	   mov	  edi, eax
871
	   shl	  edi,8
871
	   shl	  edi,8
872
	   add	  edi,SLOT_BASE
872
	   add	  edi,SLOT_BASE
873
	   mov	  edx,edi	      ;edx=edi - pointer to extended infomation about new thread
873
	   mov	  edx,edi	      ;edx=edi - pointer to extended infomation about new thread
874
	   mov	  ecx,256/4
874
	   mov	  ecx,256/4
875
	   xor eax, eax
875
	   xor eax, eax
876
	   cld
876
	   cld
877
	   rep	  stosd 	      ;clean extended information about new thread
877
	   rep	  stosd 	      ;clean extended information about new thread
878
	   mov	  esi,ebx
878
	   mov	  esi,ebx
879
	   mov	  edi,edx
879
	   mov	  edi,edx
880
	   mov	  ecx,11
880
	   mov	  ecx,11
881
	   rep	  movsb 	      ;copy process name
881
	   rep	  movsb 	      ;copy process name
882
 
882
 
883
	   mov eax,[ebx+APPDATA.heap_base]
883
	   mov eax,[ebx+APPDATA.heap_base]
884
	   mov [edx+APPDATA.heap_base], eax
884
	   mov [edx+APPDATA.heap_base], eax
885
 
885
 
886
	   mov ecx,[ebx+APPDATA.heap_top]
886
	   mov ecx,[ebx+APPDATA.heap_top]
887
	   mov [edx+APPDATA.heap_top], ecx
887
	   mov [edx+APPDATA.heap_top], ecx
888
 
888
 
889
	   mov eax,[ebx+APPDATA.mem_size]
889
	   mov eax,[ebx+APPDATA.mem_size]
890
	   mov [edx+APPDATA.mem_size], eax
890
	   mov [edx+APPDATA.mem_size], eax
891
 
891
 
892
	   mov ecx,[ebx+APPDATA.dir_table]
892
	   mov ecx,[ebx+APPDATA.dir_table]
893
	   mov [edx+APPDATA.dir_table],ecx	;copy page directory
893
	   mov [edx+APPDATA.dir_table],ecx	;copy page directory
894
 
894
 
895
	   lea eax, [app_cmdline]
895
	   lea eax, [app_cmdline]
896
	   stdcall set_app_params ,[slot],eax,dword 0,\
896
	   stdcall set_app_params ,[slot],eax,dword 0,\
897
					 dword 0,dword 0
897
					 dword 0,dword 0
898
 
898
 
899
	   ;mov    esi,new_process_running
899
	   ;mov    esi,new_process_running
900
	   ;call   sys_msg_board_str     ;output information about succefull startup
900
	   ;call   sys_msg_board_str     ;output information about succefull startup
901
	   DEBUGF 1,"%s",new_process_running
901
	   DEBUGF 1,"%s",new_process_running
902
 
902
 
903
	   mov	  [application_table_status],0 ;unlock application_table_status mutex
903
	   mov	  [application_table_status],0 ;unlock application_table_status mutex
904
	   mov	  eax,[process_number]	;set result
904
	   mov	  eax,[process_number]	;set result
905
	   ret
905
	   ret
906
.failed:
906
.failed:
907
	   mov	  [application_table_status],0
907
	   mov	  [application_table_status],0
908
	   mov	  eax,-1
908
	   mov	  eax,-1
909
	   ret
909
	   ret
910
endp
910
endp
911
 
911
 
912
; param
912
; param
913
;  ebx=mutex
913
;  ebx=mutex
914
 
914
 
915
align 4
915
align 4
916
wait_mutex:
916
wait_mutex:
917
	   push eax
917
	   push eax
918
	   push ebx
918
	   push ebx
919
.do_wait:
919
.do_wait:
920
	   cmp dword [ebx],0
920
	   cmp dword [ebx],0
921
	   je .get_lock
921
	   je .get_lock
922
	   call change_task
922
	   call change_task
923
	   jmp .do_wait
923
	   jmp .do_wait
924
.get_lock:
924
.get_lock:
925
	   mov eax, 1
925
	   mov eax, 1
926
	   xchg eax, [ebx]
926
	   xchg eax, [ebx]
927
	   test eax, eax
927
	   test eax, eax
928
	   jnz .do_wait
928
	   jnz .do_wait
929
	   pop ebx
929
	   pop ebx
930
	   pop eax
930
	   pop eax
931
	   ret
931
	   ret
932
 
932
 
933
EFL_IF	    equ 0x0200
933
EFL_IF	    equ 0x0200
934
EFL_IOPL1   equ 0x1000
934
EFL_IOPL1   equ 0x1000
935
EFL_IOPL2   equ 0x2000
935
EFL_IOPL2   equ 0x2000
936
EFL_IOPL3   equ 0x3000
936
EFL_IOPL3   equ 0x3000
937
 
937
 
938
 
938
 
939
align 4
939
align 4
940
proc set_app_params stdcall,slot:dword, params:dword,\
940
proc set_app_params stdcall,slot:dword, params:dword,\
941
			cmd_line:dword, app_path:dword, flags:dword
941
			cmd_line:dword, app_path:dword, flags:dword
942
 
942
 
943
	   locals
943
	   locals
944
	     pl0_stack dd ?
944
	     pl0_stack dd ?
945
	   endl
945
	   endl
946
 
946
 
947
           stdcall alloc_pages, (RING0_STACK_SIZE+512) shr 12
947
           stdcall alloc_pages, (RING0_STACK_SIZE+512) shr 12
948
           add eax, OS_BASE
948
           add eax, OS_BASE
949
	   mov [pl0_stack], eax
949
	   mov [pl0_stack], eax
950
 
950
 
951
	   lea edi, [eax+RING0_STACK_SIZE]
951
	   lea edi, [eax+RING0_STACK_SIZE]
952
 
952
 
953
	   mov eax, [slot]
953
	   mov eax, [slot]
954
	   mov ebx, eax
954
	   mov ebx, eax
955
 
955
 
956
	   shl eax, 8
956
	   shl eax, 8
957
	   mov [eax+SLOT_BASE+APPDATA.fpu_state], edi
957
	   mov [eax+SLOT_BASE+APPDATA.fpu_state], edi
958
	   mov [eax+SLOT_BASE+APPDATA.fpu_handler], 0
958
	   mov [eax+SLOT_BASE+APPDATA.fpu_handler], 0
959
	   mov [eax+SLOT_BASE+APPDATA.sse_handler], 0
959
	   mov [eax+SLOT_BASE+APPDATA.sse_handler], 0
960
 
960
 
961
;set default io permission map
961
;set default io permission map
962
	   mov [eax+SLOT_BASE+APPDATA.io_map],\
962
	   mov [eax+SLOT_BASE+APPDATA.io_map],\
963
		  (tss._io_map_0-OS_BASE+PG_MAP)
963
		  (tss._io_map_0-OS_BASE+PG_MAP)
964
	   mov [eax+SLOT_BASE+APPDATA.io_map+4],\
964
	   mov [eax+SLOT_BASE+APPDATA.io_map+4],\
965
		  (tss._io_map_1-OS_BASE+PG_MAP)
965
		  (tss._io_map_1-OS_BASE+PG_MAP)
966
 
966
 
967
	   mov esi, fpu_data
967
	   mov esi, fpu_data
968
	   mov ecx, 512/4
968
	   mov ecx, 512/4
969
	   rep movsd
969
	   rep movsd
970
 
970
 
971
	   cmp	  ebx,[TASK_COUNT]
971
	   cmp	  ebx,[TASK_COUNT]
972
	   jle	  .noinc
972
	   jle	  .noinc
973
	   inc	  dword [TASK_COUNT]	   ;update number of processes
973
	   inc	  dword [TASK_COUNT]	   ;update number of processes
974
.noinc:
974
.noinc:
975
	   shl ebx,8
975
	   shl ebx,8
976
	   lea edx, [ebx+SLOT_BASE+APP_EV_OFFSET]
976
	   lea edx, [ebx+SLOT_BASE+APP_EV_OFFSET]
977
	   mov [SLOT_BASE+APPDATA.fd_ev+ebx],edx
977
	   mov [SLOT_BASE+APPDATA.fd_ev+ebx],edx
978
	   mov [SLOT_BASE+APPDATA.bk_ev+ebx],edx
978
	   mov [SLOT_BASE+APPDATA.bk_ev+ebx],edx
979
 
979
 
980
	   add edx, APP_OBJ_OFFSET-APP_EV_OFFSET
980
	   add edx, APP_OBJ_OFFSET-APP_EV_OFFSET
981
	   mov [SLOT_BASE+APPDATA.fd_obj+ebx],edx
981
	   mov [SLOT_BASE+APPDATA.fd_obj+ebx],edx
982
	   mov [SLOT_BASE+APPDATA.bk_obj+ebx],edx
982
	   mov [SLOT_BASE+APPDATA.bk_obj+ebx],edx
983
 
983
 
984
	   mov ecx, [def_cursor]
984
	   mov ecx, [def_cursor]
985
	   mov [SLOT_BASE+APPDATA.cursor+ebx],ecx
985
	   mov [SLOT_BASE+APPDATA.cursor+ebx],ecx
986
	   mov eax, [pl0_stack]
986
	   mov eax, [pl0_stack]
987
	   mov [SLOT_BASE+APPDATA.pl0_stack+ebx],eax
987
	   mov [SLOT_BASE+APPDATA.pl0_stack+ebx],eax
988
	   add eax, RING0_STACK_SIZE
988
	   add eax, RING0_STACK_SIZE
989
	   mov [SLOT_BASE+APPDATA.saved_esp0+ebx], eax
989
	   mov [SLOT_BASE+APPDATA.saved_esp0+ebx], eax
990
 
990
 
991
           call alloc_page
991
           call alloc_page
992
           add eax, OS_BASE
992
           add eax, OS_BASE
993
	   mov esi,[current_slot]
993
	   mov esi,[current_slot]
994
	   mov esi,[esi+APPDATA.cur_dir]
994
	   mov esi,[esi+APPDATA.cur_dir]
995
	   mov ecx,0x1000/4
995
	   mov ecx,0x1000/4
996
	   mov edi,eax
996
	   mov edi,eax
997
	   mov [ebx+SLOT_BASE+APPDATA.cur_dir],eax
997
	   mov [ebx+SLOT_BASE+APPDATA.cur_dir],eax
998
	   rep movsd
998
	   rep movsd
999
 
999
 
1000
	   shr ebx,3
1000
	   shr ebx,3
1001
	   mov eax, new_app_base
-
 
1002
	   mov dword [CURRENT_TASK+ebx+0x10],eax
1001
           mov dword [CURRENT_TASK+ebx+0x10], 0
1003
 
1002
 
1004
.add_command_line:
1003
.add_command_line:
1005
	   mov edx,[params]
1004
	   mov edx,[params]
1006
	   mov edx,[edx]	   ;app_cmdline
1005
	   mov edx,[edx]	   ;app_cmdline
1007
	   test edx,edx
1006
	   test edx,edx
1008
	   jz @f		   ;application doesn't need parameters
1007
	   jz @f		   ;application doesn't need parameters
1009
 
1008
 
1010
	   mov	   eax, edx
1009
	   mov	   eax, edx
1011
	   add	   eax, 256
1010
	   add	   eax, 256
1012
	   jc	   @f
1011
	   jc	   @f
1013
 
1012
 
1014
	   cmp	   eax, [SLOT_BASE+APPDATA.mem_size+ebx*8]
1013
	   cmp	   eax, [SLOT_BASE+APPDATA.mem_size+ebx*8]
1015
	   ja	   @f
1014
	   ja	   @f
1016
 
1015
 
1017
	   mov	   byte [edx], 0   ;force empty string if no cmdline given
1016
	   mov	   byte [edx], 0   ;force empty string if no cmdline given
1018
	   mov	   eax, [cmd_line]
1017
	   mov	   eax, [cmd_line]
1019
	   test    eax, eax
1018
	   test    eax, eax
1020
	   jz	   @f
1019
	   jz	   @f
1021
	   stdcall strncpy, edx, eax, 256
1020
	   stdcall strncpy, edx, eax, 256
1022
@@:
1021
@@:
1023
	   mov edx,[params]
1022
	   mov edx,[params]
1024
	   mov edx, [edx+4]	   ;app_path
1023
	   mov edx, [edx+4]	   ;app_path
1025
	   test edx,edx
1024
	   test edx,edx
1026
	   jz @F		   ;application don't need path of file
1025
	   jz @F		   ;application don't need path of file
1027
	   mov	   eax, edx
1026
	   mov	   eax, edx
1028
	   add	   eax, 1024
1027
	   add	   eax, 1024
1029
	   jc	   @f
1028
	   jc	   @f
1030
	   cmp	   eax, [SLOT_BASE+APPDATA.mem_size+ebx*8]
1029
	   cmp	   eax, [SLOT_BASE+APPDATA.mem_size+ebx*8]
1031
	   ja	   @f
1030
	   ja	   @f
1032
	   stdcall strncpy, edx, [app_path], 1024
1031
	   stdcall strncpy, edx, [app_path], 1024
1033
@@:
1032
@@:
1034
	   mov	  ebx,[slot]
1033
	   mov	  ebx,[slot]
1035
	   mov	  eax,ebx
1034
	   mov	  eax,ebx
1036
	   shl	  ebx,5
1035
	   shl	  ebx,5
1037
	   lea	  ecx,[draw_data+ebx]  ;ecx - pointer to draw data
1036
	   lea	  ecx,[draw_data+ebx]  ;ecx - pointer to draw data
1038
 
1037
 
1039
; set window state to 'normal' (non-minimized/maximized/rolled-up) state
1038
; set window state to 'normal' (non-minimized/maximized/rolled-up) state
1040
	   mov	   [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL
1039
	   mov	   [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL
1041
	   mov	   [ebx+window_data+WDATA.fl_redraw], 1
1040
	   mov	   [ebx+window_data+WDATA.fl_redraw], 1
1042
	   add	  ebx,CURRENT_TASK	      ;ebx - pointer to information about process
1041
	   add	  ebx,CURRENT_TASK	      ;ebx - pointer to information about process
1043
	   mov	  [ebx+TASKDATA.wnd_number],al;set window number on screen = process slot
1042
	   mov	  [ebx+TASKDATA.wnd_number],al;set window number on screen = process slot
1044
 
1043
 
1045
	   mov	  [ebx+TASKDATA.event_mask],dword 1+2+4 ;set default event flags (see 40 function)
1044
	   mov	  [ebx+TASKDATA.event_mask],dword 1+2+4 ;set default event flags (see 40 function)
1046
 
1045
 
1047
	   inc	  dword [process_number]
1046
	   inc	  dword [process_number]
1048
	   mov	  eax,[process_number]
1047
	   mov	  eax,[process_number]
1049
	   mov	  [ebx+4],eax		;set PID
1048
	   mov	  [ebx+4],eax		;set PID
1050
 
1049
 
1051
;set draw data to full screen
1050
;set draw data to full screen
1052
 
1051
 
1053
	   mov	  [ecx+0],dword 0
1052
	   mov	  [ecx+0],dword 0
1054
	   mov	  [ecx+4],dword 0
1053
	   mov	  [ecx+4],dword 0
1055
	   mov	  eax,[Screen_Max_X]
1054
	   mov	  eax,[Screen_Max_X]
1056
	   mov	  [ecx+8],eax
1055
	   mov	  [ecx+8],eax
1057
	   mov	  eax,[Screen_Max_Y]
1056
	   mov	  eax,[Screen_Max_Y]
1058
	   mov	  [ecx+12],eax
1057
	   mov	  [ecx+12],eax
1059
 
1058
 
1060
	   mov ebx, [pl0_stack]
1059
	   mov ebx, [pl0_stack]
1061
	   mov esi,[params]
1060
	   mov esi,[params]
1062
	   lea ecx, [ebx+REG_EIP]
1061
	   lea ecx, [ebx+REG_EIP]
1063
	   xor eax, eax
1062
	   xor eax, eax
1064
 
1063
 
1065
	   mov [ebx+REG_RET], dword irq0.return
1064
	   mov [ebx+REG_RET], dword irq0.return
1066
	   mov [ebx+REG_EDI], eax
1065
	   mov [ebx+REG_EDI], eax
1067
	   mov [ebx+REG_ESI], eax
1066
	   mov [ebx+REG_ESI], eax
1068
	   mov [ebx+REG_EBP], eax
1067
	   mov [ebx+REG_EBP], eax
1069
	   mov [ebx+REG_ESP], ecx   ;ebx+REG_EIP
1068
	   mov [ebx+REG_ESP], ecx   ;ebx+REG_EIP
1070
	   mov [ebx+REG_EBX], eax
1069
	   mov [ebx+REG_EBX], eax
1071
	   mov [ebx+REG_EDX], eax
1070
	   mov [ebx+REG_EDX], eax
1072
	   mov [ebx+REG_ECX], eax
1071
	   mov [ebx+REG_ECX], eax
1073
	   mov [ebx+REG_EAX], eax
1072
	   mov [ebx+REG_EAX], eax
1074
 
1073
 
1075
	   mov eax, [esi+0x08]	     ;app_eip
1074
	   mov eax, [esi+0x08]	     ;app_eip
1076
	   mov [ebx+REG_EIP],  eax   ;app_entry
1075
	   mov [ebx+REG_EIP],  eax   ;app_entry
1077
	   mov [ebx+REG_CS], dword app_code
1076
	   mov [ebx+REG_CS], dword app_code
1078
	   mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF
1077
	   mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF
1079
 
1078
 
1080
	   mov eax, [esi+0x0C]	     ;app_esp
1079
	   mov eax, [esi+0x0C]	     ;app_esp
1081
	   mov [ebx+REG_APP_ESP], eax	 ;app_stack
1080
	   mov [ebx+REG_APP_ESP], eax	 ;app_stack
1082
	   mov [ebx+REG_SS], dword app_data
1081
	   mov [ebx+REG_SS], dword app_data
1083
 
1082
 
1084
	   lea ecx, [ebx+REG_RET]
1083
	   lea ecx, [ebx+REG_RET]
1085
	   mov ebx, [slot]
1084
	   mov ebx, [slot]
1086
	   shl ebx, 5
1085
	   shl ebx, 5
1087
	   mov [ebx*8+SLOT_BASE+APPDATA.saved_esp], ecx
1086
	   mov [ebx*8+SLOT_BASE+APPDATA.saved_esp], ecx
1088
 
1087
 
1089
	   xor	ecx, ecx	; process state - running
1088
	   xor	ecx, ecx	; process state - running
1090
; set if debuggee
1089
; set if debuggee
1091
	   test byte [flags], 1
1090
	   test byte [flags], 1
1092
	   jz	.no_debug
1091
	   jz	.no_debug
1093
	   inc	ecx		; process state - suspended
1092
	   inc	ecx		; process state - suspended
1094
	   mov	eax,[CURRENT_TASK]
1093
	   mov	eax,[CURRENT_TASK]
1095
	   mov	[SLOT_BASE+ebx*8+APPDATA.debugger_slot],eax
1094
	   mov	[SLOT_BASE+ebx*8+APPDATA.debugger_slot],eax
1096
.no_debug:
1095
.no_debug:
1097
	   mov	[CURRENT_TASK+ebx+TASKDATA.state], cl
1096
	   mov	[CURRENT_TASK+ebx+TASKDATA.state], cl
1098
	   ;mov    esi,new_process_running
1097
	   ;mov    esi,new_process_running
1099
	   ;call   sys_msg_board_str     ;output information about succefull startup
1098
	   ;call   sys_msg_board_str     ;output information about succefull startup
1100
	   DEBUGF 1,"%s",new_process_running
1099
	   DEBUGF 1,"%s",new_process_running
1101
	   ret
1100
	   ret
1102
endp
1101
endp
1103
 
1102
 
1104
include "debug.inc"
1103
include "debug.inc"
1105
>
1104
>