Rev 1376 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1376 | Rev 2212 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2009. 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: 1376 $ |
8 | $Revision: 2212 $ |
9 | 9 | ||
Line 10... | Line 10... | ||
10 | 10 | ||
11 | align 4 |
11 | align 4 |
12 | proc alloc_page |
12 | proc alloc_page |
- | 13 | ||
- | 14 | pushfd |
|
- | 15 | cli |
|
- | 16 | push ebx |
|
- | 17 | ;//- |
|
13 | 18 | cmp [pg_data.pages_free], 1 |
|
14 | pushfd |
19 | jle .out_of_memory |
15 | cli |
20 | ;//- |
16 | push ebx |
21 | |
17 | mov ebx, [page_start] |
22 | mov ebx, [page_start] |
Line 25... | Line 30... | ||
25 | pop ebx |
30 | pop ebx |
26 | popfd |
31 | popfd |
27 | xor eax,eax |
32 | xor eax,eax |
28 | ret |
33 | ret |
29 | .found: |
34 | .found: |
- | 35 | ;//- |
|
- | 36 | dec [pg_data.pages_free] |
|
- | 37 | jz .out_of_memory |
|
- | 38 | ;//- |
|
30 | btr [ebx], eax |
39 | btr [ebx], eax |
31 | mov [page_start],ebx |
40 | mov [page_start],ebx |
32 | sub ebx, sys_pgmap |
41 | sub ebx, sys_pgmap |
33 | lea eax, [eax+ebx*8] |
42 | lea eax, [eax+ebx*8] |
34 | shl eax, 12 |
43 | shl eax, 12 |
35 | dec [pg_data.pages_free] |
44 | ;//- dec [pg_data.pages_free] |
36 | pop ebx |
45 | pop ebx |
37 | popfd |
46 | popfd |
38 | ret |
47 | ret |
- | 48 | ;//- |
|
- | 49 | .out_of_memory: |
|
- | 50 | mov [pg_data.pages_free], 1 |
|
- | 51 | xor eax, eax |
|
- | 52 | pop ebx |
|
- | 53 | popfd |
|
- | 54 | ret |
|
- | 55 | ;//- |
|
39 | endp |
56 | endp |
Line 40... | Line 57... | ||
40 | 57 | ||
41 | align 4 |
58 | align 4 |
42 | proc alloc_pages stdcall, count:dword |
59 | proc alloc_pages stdcall, count:dword |
Line 46... | Line 63... | ||
46 | cli |
63 | cli |
47 | mov eax, [count] |
64 | mov eax, [count] |
48 | add eax, 7 |
65 | add eax, 7 |
49 | shr eax, 3 |
66 | shr eax, 3 |
50 | mov [count], eax |
67 | mov [count], eax |
- | 68 | ;//- |
|
51 | cmp eax, [pg_data.pages_free] |
69 | mov ebx, [pg_data.pages_free] |
52 | ja .fail |
70 | sub ebx, 9 |
- | 71 | js .out_of_memory |
|
- | 72 | shr ebx, 3 |
|
- | 73 | cmp eax, ebx |
|
- | 74 | jg .out_of_memory |
|
53 | 75 | ;//- |
|
54 | mov ecx, [page_start] |
76 | mov ecx, [page_start] |
55 | mov ebx, [page_end] |
77 | mov ebx, [page_end] |
56 | .find: |
78 | .find: |
57 | mov edx, [count] |
79 | mov edx, [count] |
58 | mov edi, ecx |
80 | mov edi, ecx |
Line 62... | Line 84... | ||
62 | dec edx |
84 | dec edx |
63 | jz .ok |
85 | jz .ok |
64 | inc ecx |
86 | inc ecx |
65 | cmp ecx,ebx |
87 | cmp ecx,ebx |
66 | jb .match |
88 | jb .match |
- | 89 | .out_of_memory: |
|
67 | .fail: |
90 | .fail: |
68 | xor eax, eax |
91 | xor eax, eax |
69 | pop edi |
92 | pop edi |
70 | pop ebx |
93 | pop ebx |
71 | popfd |
94 | popfd |
Line 477... | Line 500... | ||
477 | 500 | ||
478 | add edi, 0x00400000 |
501 | add edi, 0x00400000 |
479 | cmp edi, esi |
502 | cmp edi, esi |
480 | jb @B |
503 | jb @B |
- | 504 | .grow: |
|
- | 505 | ;//- |
|
- | 506 | pop edi |
|
- | 507 | push edi |
|
- | 508 | mov esi, [pg_data.pages_free] |
|
- | 509 | sub esi, 1 |
|
- | 510 | shr edi, 12 |
|
- | 511 | cmp esi, edi |
|
- | 512 | jle .out_of_memory |
|
481 | .grow: |
513 | ;//- |
482 | pop edi |
514 | pop edi |
483 | pop esi |
515 | pop esi |
484 | @@: |
516 | @@: |
485 | call alloc_page |
517 | call alloc_page |
Line 498... | Line 530... | ||
498 | add esi, 0x1000 |
530 | add esi, 0x1000 |
499 | cmp esi, edi |
531 | cmp esi, edi |
500 | jb @B |
532 | jb @B |
Line 501... | Line 533... | ||
501 | 533 | ||
- | 534 | jmp .update_size |
|
502 | jmp .update_size |
535 | ;//- |
- | 536 | .exit_pop: |
|
- | 537 | .out_of_memory: |
|
503 | .exit_pop: |
538 | ;//- |
504 | pop edi |
539 | pop edi |
505 | pop esi |
540 | pop esi |
506 | .exit: |
541 | .exit: |
507 | xor eax, eax |
542 | xor eax, eax |
Line 912... | Line 947... | ||
912 | ret |
947 | ret |
913 | endp |
948 | endp |
Line 914... | Line 949... | ||
914 | 949 | ||
915 | sys_IPC: |
950 | sys_IPC: |
916 | ;input: |
951 | ;input: |
917 | ; eax=1 - set ipc buffer area |
952 | ; ebx=1 - set ipc buffer area |
918 | ; ebx=address of buffer |
953 | ; ecx=address of buffer |
919 | ; ecx=size of buffer |
954 | ; edx=size of buffer |
920 | ; eax=2 - send message |
955 | ; eax=2 - send message |
921 | ; ebx=PID |
956 | ; ebx=PID |
922 | ; ecx=address of message |
957 | ; ecx=address of message |
Line 923... | Line -... | ||
923 | ; edx=size of message |
- | |
924 | - | ||
925 | cmp eax,1 |
- | |
926 | jne @f |
- | |
927 | call set_ipc_buff |
- | |
928 | mov [esp+36], eax |
958 | ; edx=size of message |
929 | ret |
- | |
930 | @@: |
- | |
931 | cmp eax, 2 |
- | |
932 | jne @f |
- | |
933 | stdcall sys_ipc_send, ebx, ecx, edx |
- | |
934 | mov [esp+36], eax |
- | |
935 | ret |
- | |
936 | @@: |
- | |
937 | xor eax, eax |
- | |
938 | not eax |
- | |
939 | mov [esp+36], eax |
- | |
940 | ret |
959 | |
941 | - | ||
Line 942... | Line 960... | ||
942 | align 4 |
960 | dec ebx |
943 | proc set_ipc_buff |
961 | jnz @f |
944 | 962 | ||
945 | mov eax,[current_slot] |
963 | mov eax,[current_slot] |
946 | pushf |
964 | pushf |
Line 947... | Line 965... | ||
947 | cli |
965 | cli |
948 | mov [eax+APPDATA.ipc_start],ebx ;set fields in extended information area |
966 | mov [eax+APPDATA.ipc_start],ecx ;set fields in extended information area |
949 | mov [eax+APPDATA.ipc_size],ecx |
967 | mov [eax+APPDATA.ipc_size],edx |
950 | 968 | ||
951 | add ecx, ebx |
969 | add edx, ecx |
952 | add ecx, 4095 |
970 | add edx, 4095 |
953 | and ecx, not 4095 |
971 | and edx, not 4095 |
954 | 972 | ||
Line 955... | Line 973... | ||
955 | .touch: mov eax, [ebx] |
973 | .touch: mov eax, [ecx] |
956 | add ebx, 0x1000 |
974 | add ecx, 0x1000 |
957 | cmp ebx, ecx |
975 | cmp ecx, edx |
- | 976 | jb .touch |
|
- | 977 | ||
- | 978 | popf |
|
- | 979 | mov [esp+32], ebx ;ebx=0 |
|
- | 980 | ret |
|
- | 981 | ||
- | 982 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
- | 983 | ;2 |
|
- | 984 | @@: |
|
- | 985 | dec ebx |
|
- | 986 | jnz @f |
|
- | 987 | ||
- | 988 | stdcall sys_ipc_send, ecx, edx, esi |
|
- | 989 | mov [esp+32], eax |
|
- | 990 | ret |
|
- | 991 | @@: |
|
- | 992 | or eax,-1 |
|
- | 993 | mov [esp+32], eax |
|
- | 994 | ret |
|
- | 995 | ||
- | 996 | ;align 4 |
|
- | 997 | ;proc set_ipc_buff |
|
- | 998 | ||
- | 999 | ; mov eax,[current_slot] |
|
- | 1000 | ; pushf |
|
- | 1001 | ; cli |
|
- | 1002 | ; mov [eax+APPDATA.ipc_start],ebx ;set fields in extended information area |
|
- | 1003 | ; mov [eax+APPDATA.ipc_size],ecx |
|
- | 1004 | ; |
|
- | 1005 | ; add ecx, ebx |
|
- | 1006 | ; add ecx, 4095 |
|
- | 1007 | ; and ecx, not 4095 |
|
- | 1008 | ; |
|
- | 1009 | ;.touch: mov eax, [ebx] |
|
- | 1010 | ; add ebx, 0x1000 |
|
- | 1011 | ; cmp ebx, ecx |
|
958 | jb .touch |
1012 | ; jb .touch |
Line 959... | Line 1013... | ||
959 | 1013 | ; |
|
960 | popf |
1014 | ; popf |
961 | xor eax, eax |
1015 | ; xor eax, eax |
962 | ret |
1016 | ; ret |
Line 1110... | Line 1164... | ||
1110 | mov [ecx+24], eax |
1164 | mov [ecx+24], eax |
1111 | ret |
1165 | ret |
1112 | .fail: |
1166 | .fail: |
1113 | or dword [esp+32], -1 |
1167 | or dword [esp+32], -1 |
1114 | ret |
1168 | ret |
1115 | iglobal |
- | |
1116 | align 4 |
- | |
1117 | f68call: |
- | |
1118 | dd f68.11 ; init_heap |
- | |
1119 | dd f68.12 ; user_alloc |
- | |
1120 | dd f68.13 ; user_free |
- | |
1121 | dd f68.14 ; get_event_ex |
- | |
1122 | dd f68.fail ;moved to f68.24 |
- | |
1123 | dd f68.16 ; get_service |
- | |
1124 | dd f68.17 ; call_service |
- | |
1125 | dd f68.fail ;moved to f68.25 |
- | |
1126 | dd f68.19 ; load_dll |
- | |
1127 | dd f68.20 ; user_realloc |
- | |
1128 | dd f68.21 ; load_driver |
- | |
1129 | dd f68.22 ; shmem_open |
- | |
1130 | dd f68.23 ; shmem_close |
- | |
1131 | dd f68.24 |
- | |
1132 | dd f68.25 |
- | |
1133 | endg |
1169 | |
1134 | align 4 |
1170 | align 4 |
1135 | f68: |
1171 | f68: |
1136 | cmp ebx,4 |
1172 | cmp ebx,4 |
1137 | jbe sys_sheduler |
1173 | jbe sys_sheduler |
Line 1248... | Line 1284... | ||
1248 | .fail: |
1284 | .fail: |
1249 | xor eax, eax |
1285 | xor eax, eax |
1250 | mov [esp+32], eax |
1286 | mov [esp+32], eax |
1251 | ret |
1287 | ret |
Line -... | Line 1288... | ||
- | 1288 | ||
- | 1289 | ||
- | 1290 | align 4 |
|
- | 1291 | f68call: ; keep this table closer to main code |
|
- | 1292 | ||
- | 1293 | dd f68.11 ; init_heap |
|
- | 1294 | dd f68.12 ; user_alloc |
|
- | 1295 | dd f68.13 ; user_free |
|
- | 1296 | dd f68.14 ; get_event_ex |
|
- | 1297 | dd f68.fail ; moved to f68.24 |
|
- | 1298 | dd f68.16 ; get_service |
|
- | 1299 | dd f68.17 ; call_service |
|
- | 1300 | dd f68.fail ; moved to f68.25 |
|
- | 1301 | dd f68.19 ; load_dll |
|
- | 1302 | dd f68.20 ; user_realloc |
|
- | 1303 | dd f68.21 ; load_driver |
|
- | 1304 | dd f68.22 ; shmem_open |
|
- | 1305 | dd f68.23 ; shmem_close |
|
- | 1306 | dd f68.24 |
|
- | 1307 | dd f68.25 |
|
- | 1308 | ||
1252 | 1309 | ||
1253 | align 4 |
1310 | align 4 |
Line 1254... | Line 1311... | ||
1254 | proc load_pe_driver stdcall, file:dword |
1311 | proc load_pe_driver stdcall, file:dword |
1255 | 1312 | ||
Line 1367... | Line 1424... | ||
1367 | wrmsr |
1424 | wrmsr |
Line 1368... | Line 1425... | ||
1368 | 1425 | ||
1369 | mov ebx, [size] |
1426 | mov ebx, [size] |
1370 | dec ebx |
1427 | dec ebx |
1371 | mov eax, 0xFFFFFFFF |
1428 | mov eax, 0xFFFFFFFF |
1372 | mov edx, 0x0000000F |
1429 | mov edx, 0x00000000 |
1373 | sub eax, ebx |
1430 | sub eax, ebx |
1374 | sbb edx, 0 |
1431 | sbb edx, 0 |
1375 | or eax, 0x800 |
1432 | or eax, 0x800 |
1376 | inc ecx |
1433 | inc ecx |