Subversion Repositories Kolibri OS

Rev

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

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