Subversion Repositories Kolibri OS

Rev

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

Rev 5 Rev 9
Line 149... Line 149...
149
    add    ecx,4095
149
    add    ecx,4095
150
    shr    ecx,12
150
    shr    ecx,12
151
    mov    edx,eax
151
    mov    edx,eax
152
    call   mem_alloc_specified_region ;allocate memory for application
152
    call   mem_alloc_specified_region ;allocate memory for application
153
    test   eax,eax
153
    test   eax,eax
154
    jz     .cleanfailed_mem
154
    jz     .cleanfailed_mem1
Line 155... Line 155...
155
    
155
    
156
    mov    eax,[edx+(std_application_base_address shr 20)]
156
    mov    eax,[edx+(std_application_base_address shr 20)]
157
    and    eax,not (4096-1)      ;eax - physical address of first (for application memory) page table
157
    and    eax,not (4096-1)      ;eax - physical address of first (for application memory) page table
158
    call   MEM_Get_Linear_Address
158
    call   MEM_Get_Linear_Address
Line 193... Line 193...
193
    add    esp,8+4                 ;pop linear address of page table entry and pointer to file name
193
    add    esp,8+4                 ;pop linear address of page table entry and pointer to file name
194
    call   new_start_application_fl.add_app_parameters
194
    call   new_start_application_fl.add_app_parameters
195
    mov    [esp+28],eax
195
    mov    [esp+28],eax
196
    popad
196
    popad
197
    ret
197
    ret
-
 
198
    
-
 
199
.cleanfailed_mem1:
-
 
200
;there is mem for directory entry, but there is no mem for pages
-
 
201
;so free directory entry
-
 
202
    mov    eax,[new_process_place]    
-
 
203
    shl    eax,8
-
 
204
    mov    eax,[0x80000+eax+0xB8]
-
 
205
    call   MEM_Free_Page    
198
.cleanfailed_mem:
206
.cleanfailed_mem:
-
 
207
;there is no mem for directory entry, display message.
199
    mov    esi,start_not_enough_memory
208
    mov    esi,start_not_enough_memory
200
    call   sys_msg_board_str
209
    call   sys_msg_board_str
201
.cleanfailed:                    ;clean process name
210
.cleanfailed:                    ;clean process name
-
 
211
;can't read file, clean process name. 
-
 
212
;this avoid problems with panel application.
202
    mov    edi,[new_process_place]
213
    mov    edi,[new_process_place]
203
    shl    edi,8
214
    shl    edi,8
204
    add    edi,0x80000
215
    add    edi,0x80000
205
    mov    ecx,11
216
    mov    ecx,11
206
    mov    eax,' '
217
    mov    eax,' '
207
    cld
218
    cld
208
    rep    stosb
219
    rep    stosb
209
.failed:
220
.failed:
-
 
221
;no more slots
210
    add    esp,8+4
222
    add    esp,8+4
211
    mov    [application_table_status],0
223
    mov    [application_table_status],0
212
    popad
224
    popad
213
    sti
225
    sti
214
    mov    eax,-1
226
    mov    eax,-1
Line 294... Line 306...
294
    add    ecx,4095
306
    add    ecx,4095
295
    shr    ecx,12
307
    shr    ecx,12
296
    mov    edx,eax
308
    mov    edx,eax
297
    call   mem_alloc_specified_region ;allocate memory for application
309
    call   mem_alloc_specified_region ;allocate memory for application
298
    test   eax,eax
310
    test   eax,eax
299
    jz     .cleanfailed_mem
311
    jz     .cleanfailed_mem1
Line 300... Line 312...
300
    
312
    
301
    mov    eax,[edx+(std_application_base_address shr 20)]
313
    mov    eax,[edx+(std_application_base_address shr 20)]
302
    and    eax,not (4096-1)      ;eax - physical address of first (for application memory) page table
314
    and    eax,not (4096-1)      ;eax - physical address of first (for application memory) page table
303
    call   MEM_Get_Linear_Address
315
    call   MEM_Get_Linear_Address
Line 338... Line 350...
338
    call   .add_app_parameters
350
    call   .add_app_parameters
339
    mov    [esp+28],eax
351
    mov    [esp+28],eax
340
    popad
352
    popad
341
    ret
353
    ret
Line -... Line 354...
-
 
354
    
-
 
355
.cleanfailed_mem1:
-
 
356
;there is mem for directory entry, but there is no mem for pages
-
 
357
;so free directory entry
-
 
358
    mov    eax,[new_process_place]    
-
 
359
    shl    eax,8
-
 
360
    mov    eax,[0x80000+eax+0xB8]
342
    
361
    call   MEM_Free_Page
-
 
362
.cleanfailed_mem:
343
.cleanfailed_mem:
363
;there is no mem for directory entry, display message.
344
    mov    esi,start_not_enough_memory
364
    mov    esi,start_not_enough_memory
345
    call   sys_msg_board_str
365
    call   sys_msg_board_str
-
 
366
.cleanfailed:                    ;clean process name
-
 
367
;can't read file, clean process name. 
346
.cleanfailed:                    ;clean process name
368
;this avoid problems with panel application.
347
    mov    edi,[new_process_place]
369
    mov    edi,[new_process_place]
348
    shl    edi,8
370
    shl    edi,8
349
    add    edi,0x80000
371
    add    edi,0x80000
350
    mov    ecx,11
372
    mov    ecx,11
351
    mov    eax,' '
373
    mov    eax,' '
352
    cld
374
    cld
353
    rep    stosb
375
    rep    stosb
-
 
376
.failed:
354
.failed:
377
;no more slots
355
    add    esp,8
378
    add    esp,8
356
    mov    [application_table_status],0
379
    mov    [application_table_status],0
357
    popad
380
    popad
358
    call   safe_sti
381
    call   safe_sti
Line 448... Line 471...
448
    mov    ecx,[new_process_place]     
471
    mov    ecx,[new_process_place]     
449
    shl    ecx,8
472
    shl    ecx,8
450
    mov    eax,[0x800B8+ecx]
473
    mov    eax,[0x800B8+ecx]
451
    add    eax,8+16              ;add flags
474
    add    eax,8+16              ;add flags
452
    mov    [l.cr3],eax
475
    mov    [l.cr3],eax
453
;write cr3 in TSS of System Call Handler    
-
 
454
    mov    ecx,[new_process_place]
-
 
455
    shl    ecx,7
-
 
456
    mov    [0x298000+ecx+l.cr3-tss_sceleton],eax   ;write directy to TSS
-
 
Line 457... Line 476...
457
    
476
    
458
    mov    eax,[app_start]
477
    mov    eax,[app_start]
459
    mov    [l.eip],eax           ;set eip in TSS
478
    mov    [l.eip],eax           ;set eip in TSS
460
    mov    eax,[app_esp]
479
    mov    eax,[app_esp]
Line 1229... Line 1248...
1229
    add    ecx,4096-1
1248
    add    ecx,4096-1
1230
    shr    ecx,12
1249
    shr    ecx,12
1231
    mov    edx,eax               ;edx - linear address of page directory
1250
    mov    edx,eax               ;edx - linear address of page directory
1232
    call   mem_alloc_specified_region ;allocate memory for application
1251
    call   mem_alloc_specified_region ;allocate memory for application
1233
    test   eax,eax
1252
    test   eax,eax
1234
    jz     .cleanfailed_mem
1253
    jz     .cleanfailed_mem1
Line 1235... Line 1254...
1235
    
1254
    
1236
    add    edx,(std_application_base_address shr 20)
1255
    add    edx,(std_application_base_address shr 20)
1237
    mov    eax,[edx]
1256
    mov    eax,[edx]
1238
    and    eax,not (4096-1)
1257
    and    eax,not (4096-1)
Line 1304... Line 1323...
1304
    call   new_start_application_fl.add_app_parameters ;start process
1323
    call   new_start_application_fl.add_app_parameters ;start process
1305
    mov    [esp+28],eax
1324
    mov    [esp+28],eax
1306
    popad
1325
    popad
1307
    ret
1326
    ret
Line -... Line 1327...
-
 
1327
    
-
 
1328
.cleanfailed_mem1:
-
 
1329
;there is mem for directory entry, but there is no mem for pages
-
 
1330
;so free directory entry
-
 
1331
    mov    eax,[new_process_place]
-
 
1332
    shl    eax,8
-
 
1333
    mov    eax,[0x80000+eax+0xB8]
1308
    
1334
    call   MEM_Free_Page
-
 
1335
.cleanfailed_mem:
1309
.cleanfailed_mem:
1336
;there is no mem for directory entry, display message.
1310
    mov    esi,start_not_enough_memory
1337
    mov    esi,start_not_enough_memory
1311
    call   sys_msg_board_str    
1338
    call   sys_msg_board_str    
-
 
1339
.cleanfailed:                    ;clean process name
-
 
1340
;can't read file, clean process name. 
1312
.cleanfailed:                    ;clean process name
1341
;this avoid problems with panel application.
1313
    mov    edi,[new_process_place]
1342
    mov    edi,[new_process_place]
1314
    shl    edi,8
1343
    shl    edi,8
1315
    add    edi,0x80000
1344
    add    edi,0x80000
1316
    mov    ecx,11
1345
    mov    ecx,11
1317
    mov    eax,' '
1346
    mov    eax,' '
1318
    cld
1347
    cld
1319
    rep    stosb    
1348
    rep    stosb    
-
 
1349
.failed:
1320
.failed:
1350
;no more slots
1321
    add    esp,16
1351
    add    esp,16
1322
    popad   
1352
    popad   
1323
    mov    eax,-1
1353
    mov    eax,-1
1324
    mov    [application_table_status],0
1354
    mov    [application_table_status],0