Subversion Repositories Kolibri OS

Rev

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

Rev 924 Rev 940
Line 3... Line 3...
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 924 $
8
$Revision: 940 $
9
 
9
 
Line 1007... Line 1007...
1007
.fail:
1007
.fail:
1008
           mov dword [esp+36], -1
1008
           mov dword [esp+36], -1
1009
           ret
1009
           ret
Line 1010... Line 1010...
1010
 
1010
 
1011
align 4
1011
align 4
-
 
1012
f68call:
-
 
1013
           dd f68.11
-
 
1014
           dd f68.12
-
 
1015
           dd f68.13
-
 
1016
           dd f68.14
-
 
1017
           dd f68.15
-
 
1018
           dd f68.16
-
 
1019
           dd f68.17
-
 
1020
           dd f68.18
-
 
1021
           dd f68.19
-
 
1022
           dd f68.20
-
 
1023
           dd f68.21
-
 
1024
           dd f68.22
-
 
1025
 
-
 
1026
 
-
 
1027
align 4
Line 1012... Line 1028...
1012
new_services:
1028
f68:
1013
 
1029
 
Line 1014... Line 1030...
1014
           cmp  eax,4
1030
           cmp  eax,4
1015
           jle  sys_sheduler
1031
           jle  sys_sheduler
1016
 
-
 
Line -... Line 1032...
-
 
1032
 
-
 
1033
           cmp eax, 11
-
 
1034
           jb .fail
-
 
1035
 
-
 
1036
           cmp eax, 22
-
 
1037
           ja .fail
1017
           cmp eax, 11
1038
 
1018
           jb .fail
1039
           jmp dword [f68call+eax*4-11*4]
1019
           ja @f
1040
 
1020
 
1041
.11:
1021
           call init_heap
-
 
1022
           mov [esp+36], eax
-
 
Line 1023... Line 1042...
1023
           ret
1042
           call init_heap
1024
@@:
1043
           mov [esp+36], eax
1025
           cmp eax, 12
1044
           ret
1026
           ja @f
1045
.12:
1027
 
-
 
1028
           stdcall user_alloc, ebx
-
 
1029
           mov [esp+36], eax
1046
 
1030
           ret
1047
           stdcall user_alloc, ebx
1031
@@:
1048
           mov [esp+36], eax
1032
           cmp eax, 13
1049
           ret
1033
           ja @f
-
 
1034
           stdcall user_free, ebx
-
 
1035
           mov [esp+36], eax
1050
.13:
1036
           ret
1051
           stdcall user_free, ebx
1037
@@:
1052
           mov [esp+36], eax
1038
           cmp eax, 14
1053
           ret
1039
           ja @f
1054
.14:
1040
           cmp ebx, OS_BASE
1055
           cmp ebx, OS_BASE
1041
           jae .fail
-
 
1042
           stdcall get_event_ex, ebx, ecx
-
 
1043
           mov [esp+36], eax
1056
           jae .fail
1044
           ret
1057
           stdcall get_event_ex, ebx, ecx
1045
@@:
1058
           mov [esp+36], eax
1046
           cmp eax, 15
1059
           ret
1047
           ja @f
1060
.15:
1048
           mov ecx, [current_slot]
1061
           mov ecx, [current_slot]
1049
           mov eax, [ecx+APPDATA.fpu_handler]
-
 
1050
           mov [ecx+APPDATA.fpu_handler], ebx
-
 
1051
           mov [esp+36], eax
-
 
1052
           ret
1062
           mov eax, [ecx+APPDATA.fpu_handler]
1053
@@:
1063
           mov [ecx+APPDATA.fpu_handler], ebx
1054
           cmp eax, 16
1064
           mov [esp+36], eax
1055
           ja @f
1065
           ret
1056
 
1066
.16:
1057
           test ebx, ebx
1067
           test ebx, ebx
1058
           jz .fail
1068
           jz .fail
1059
           cmp ebx, OS_BASE
1069
           cmp ebx, OS_BASE
1060
           jae .fail
-
 
1061
           stdcall get_service, ebx
-
 
1062
           mov [esp+36], eax
1070
           jae .fail
1063
           ret
1071
           stdcall get_service, ebx
1064
@@:
1072
           mov [esp+36], eax
1065
           cmp eax, 17
1073
           ret
1066
           ja @f
-
 
1067
           call srv_handlerEx   ;ebx
-
 
1068
           mov [esp+36], eax
1074
.17:
1069
           ret
1075
           call srv_handlerEx   ;ebx
1070
@@:
1076
           mov [esp+36], eax
1071
           cmp eax, 18
1077
           ret
1072
           ja @f
1078
.18:
1073
           mov ecx, [current_slot]
1079
           mov ecx, [current_slot]
1074
           mov eax, [ecx+APPDATA.sse_handler]
-
 
1075
           mov [ecx+APPDATA.sse_handler], ebx
-
 
1076
           mov [esp+36], eax
1080
           mov eax, [ecx+APPDATA.sse_handler]
1077
           ret
1081
           mov [ecx+APPDATA.sse_handler], ebx
1078
@@:
1082
           mov [esp+36], eax
1079
           cmp eax, 19
1083
           ret
1080
           ja @f
1084
.19:
1081
           cmp ebx, OS_BASE
1085
           cmp ebx, OS_BASE
1082
           jae .fail
-
 
1083
           stdcall load_library, ebx
-
 
1084
           mov [esp+36], eax
1086
           jae .fail
1085
           ret
1087
           stdcall load_library, ebx
1086
@@:
1088
           mov [esp+36], eax
1087
           cmp     eax, 20
1089
           ret
1088
           ja      @F
1090
.20:
1089
           mov     eax, ecx
-
 
1090
           call    user_realloc
-
 
1091
           mov     [esp+36], eax
1091
           mov     eax, ecx
1092
           ret
1092
           call    user_realloc
Line 1093... Line 1093...
1093
@@:
1093
           mov     [esp+36], eax
Line 1110... Line 1110...
1110
           mov [eax+SRV.entry], esi
1110
           mov [eax+SRV.entry], esi
Line 1111... Line 1111...
1111
 
1111
 
1112
@@:
1112
@@:
1113
           mov [esp+36], eax
1113
           mov [esp+36], eax
-
 
1114
           ret
-
 
1115
.22:
-
 
1116
           cmp ebx, OS_BASE
Line -... Line 1117...
-
 
1117
           jae .fail
-
 
1118
 
-
 
1119
           stdcall shmem_open, ebx, ecx, edx
-
 
1120
           mov [esp+28], edx
Line 1114... Line 1121...
1114
           ret
1121
           mov [esp+36], eax
1115
 
1122
           ret
1116
 
1123
 
1117
.fail:
1124
.fail:
Line 1307... Line 1314...
1307
           ret
1314
           ret
1308
endp
1315
endp
Line 1309... Line -...
1309
 
-
 
1310
 
-
 
1311
 
-
 
1312
if 0
-
 
1313
 
-
 
1314
; under constuction
-
 
1315
 
-
 
1316
 
-
 
1317
shmem_list:
-
 
1318
    .bk       dd shmem_list
-
 
1319
    .fd       dd shmem_list
-
 
1320
 
-
 
1321
 
-
 
1322
shmem
-
 
1323
    .bk         dd ?
-
 
1324
    .fd         dd ?
-
 
1325
    .base       dd ?
-
 
1326
    .size       dd ?
-
 
1327
    .access     dd ?
-
 
1328
    .refcount   dd ?
-
 
1329
    .name       rb 32
-
 
1330
 
-
 
1331
 
-
 
1332
align 4
-
 
1333
proc shmem_open stdcall name:dword, size:dword, access:dword
-
 
1334
           locals
-
 
1335
              mapped    dd ?
-
 
1336
              shm       dd ?
-
 
1337
              pages     dd ?
-
 
1338
           endl
-
 
1339
 
-
 
1340
           push esi
-
 
1341
           push edi
-
 
1342
 
-
 
1343
           mov [mapped], 0
-
 
1344
 
-
 
1345
           mov eax, [name]
-
 
1346
           test eax, eax
-
 
1347
           jz .exit
-
 
1348
 
-
 
1349
           pushfd                      ;mutex required
-
 
1350
           cli
-
 
1351
 
-
 
1352
           mov ebx, [shmem_list.fd]
-
 
1353
@@:
-
 
1354
           cmp ebx, shmem_list
-
 
1355
           je .not_found
-
 
1356
 
-
 
1357
           lea edx, [edx+24] ; link , base, size
-
 
1358
           stdcall strncmp, edx, eax, 32
-
 
1359
           test eax, eax
-
 
1360
           je .found
-
 
1361
 
-
 
1362
           mov ebx, [ebx+4]
-
 
1363
           jmp @B
-
 
1364
.found:                               ;check access rights
-
 
1365
           mov eax, [access]
-
 
1366
           test eax, SHM_CREATE
-
 
1367
           mov ecx, [ebx+8]
-
 
1368
           jnz .fail_exist
-
 
1369
 
-
 
1370
           and eax, ACC_MASK
-
 
1371
           and ecx, ACC_MASK
-
 
1372
           cmp eax, ecx
-
 
1373
           jne .fail_acc
-
 
1374
 
-
 
1375
           stdcall user_alloc, [ebx+12]
-
 
1376
           test eax, eax
-
 
1377
           mov [mapped], eax
-
 
1378
           jz .fail_mem
-
 
1379
 
-
 
1380
           mov eax, [ebx+4]
-
 
1381
           mov ecx, [ebx+12]
-
 
1382
           shr ecx, 12
-
 
1383
           mov ebx, [mapped]
-
 
1384
           call commit_pages
-
 
1385
.exit:
-
 
1386
           mov eax, [mapped]
-
 
1387
           pop edi
-
 
1388
           pop esi
-
 
1389
           ret
-
 
1390
 
-
 
1391
.not_found:
-
 
1392
           mov eax, [access]
-
 
1393
           test eax, SHM_CREATE
-
 
1394
           mov ebx, E_NOTFOUND
-
 
1395
           jz .exit
-
 
1396
 
-
 
1397
;create shmem
-
 
1398
           mov ecx, [size]
-
 
1399
           test ecx, ecx
-
 
1400
           mov ebx, E_PARAM
-
 
1401
           jz .exit
-
 
1402
 
-
 
1403
           add ecx, 4095
-
 
1404
           and ecx, -4096
-
 
1405
           mov [size], ecx
-
 
1406
           stdcall user_alloc, ecx
-
 
1407
           test eax, eax
-
 
1408
           mov [mapped], eax
-
 
1409
           mov ebx, E_NOMEM
-
 
1410
           jz .exit
-
 
1411
 
-
 
1412
           mov eax, 24+32
-
 
1413
           call malloc
-
 
1414
           test eax, eax
-
 
1415
           mov [shm], eax
-
 
1416
           mov ebx, E_NOMEM
-
 
1417
           jz .exit                ;FIXME cleanup
-
 
1418
 
-
 
1419
           mov [eax+24+28], dword 0
-
 
1420
           lea edx, [eax+24]
-
 
1421
           stdcall strncpy, edx, [name], 31
-
 
1422
 
-
 
1423
           mov eax, [size]
-
 
1424
           shr eax, 12
-
 
1425
           mov esi, eax
-
 
1426
           stdcall alloc_pages, eax
-
 
1427
           test eax, eax
-
 
1428
           mov [pages], eax
-
 
1429
           mov ebx, E_NOMEM
-
 
1430
           jz .exit                ;FIXME cleanup
-
 
1431
 
-
 
1432
           mov edi, eax
-
 
1433
           add edi, [size]
-
 
1434
           and esi,  7
-
 
1435
           add esi, -8
-
 
1436
           jz @F
-
 
1437
 
-
 
1438
;release unused pages
-
 
1439
 
-
 
1440
.release:
-
 
1441
           mov eax, edi
-
 
1442
           add edi, 4096
-
 
1443
           call free_page
-
 
1444
           dec esi
-
 
1445
           jnz .release
-
 
1446
 
-
 
1447
           mov eax, [ebx+4]
-
 
1448
           mov ecx, [ebx+12]
-
 
1449
           shr ecx, 12
-
 
1450
           mov ebx, [mapped]
-
 
1451
           call commit_pages
-
 
1452
 
-
 
1453
           mov eax, [access]
-
 
1454
           and eax, ACC_MASK
-
 
1455
           or eax,  [pages]
-
 
1456
           mov ebx, [mapped]
-
 
1457
           mov ecx, [size]
-
 
1458
           shr ecx, 12
-
 
1459
           call commit_pages
-
 
1460
 
-
 
1461
           mov edx, [shm]
-
 
1462
           mov ecx, [pages]
-
 
1463
           mov [edx+8], ecx
-
 
1464
           mov ecx, [size]
-
 
1465
           mov [edx+12], ecx
-
 
1466
 
-
 
1467
    ;       mov [edx], shmem
-
 
1468
    ;       mov [edx+4], [shmem.fd]
-
 
1469
    ;       mov [shmem.fd.bk], edx
-
 
1470
    ;       mov [shmem.fd], edx
-
 
1471
 
-
 
1472
           xor ebx, ebx
-
 
1473
           jmp .exit
-
 
1474
 
-
 
1475
.fail_exist:
-
 
1476
           mov ebx, E_EXIST
-
 
1477
           xor eax, eax
-
 
1478
           ret
-
 
1479
.fail_access:
-
 
1480
           mov ebx, E_ACCESS
-
 
1481
           xor eax, eax
-
 
1482
           ret
-
 
1483
.fail_mem:
-
 
1484
           mov ebx, E_NOMEM
-
 
1485
           xor eax, eax
-
 
1486
           ret
-