Rev 841 | Rev 846 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 841 | Rev 843 | ||
---|---|---|---|
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: 841 $ |
8 | $Revision: 843 $ |
9 | - | ||
10 | - | ||
11 | align 4 |
- | |
12 | proc alloc_page |
- | |
13 | - | ||
14 | pushfd |
- | |
15 | cli |
- | |
16 | push ebx |
- | |
17 | mov ebx, [page_start] |
- | |
18 | mov ecx, [page_end] |
- | |
19 | .l1: |
- | |
20 | bsf eax,[ebx]; |
- | |
21 | jnz .found |
- | |
22 | add ebx,4 |
- | |
23 | cmp ebx, ecx |
- | |
24 | jb .l1 |
- | |
25 | pop ebx |
- | |
26 | popfd |
- | |
27 | xor eax,eax |
- | |
28 | ret |
- | |
29 | .found: |
- | |
30 | btr [ebx], eax |
- | |
31 | mov [page_start],ebx |
- | |
32 | sub ebx, sys_pgmap |
- | |
33 | lea eax, [eax+ebx*8] |
- | |
34 | shl eax, 12 |
- | |
35 | dec [pg_data.pages_free] |
- | |
36 | pop ebx |
- | |
37 | popfd |
- | |
38 | ret |
- | |
39 | endp |
- | |
40 | - | ||
41 | align 4 |
- | |
42 | proc alloc_pages stdcall, count:dword |
- | |
43 | pushfd |
- | |
44 | push ebx |
- | |
45 | push edi |
- | |
46 | cli |
- | |
47 | mov eax, [count] |
- | |
48 | add eax, 7 |
- | |
49 | shr eax, 3 |
- | |
50 | mov [count], eax |
- | |
51 | cmp eax, [pg_data.pages_free] |
- | |
52 | ja .fail |
- | |
53 | - | ||
54 | mov ecx, [page_start] |
- | |
55 | mov ebx, [page_end] |
- | |
56 | .find: |
- | |
57 | mov edx, [count] |
- | |
58 | mov edi, ecx |
- | |
59 | .match: |
- | |
60 | cmp byte [ecx], 0xFF |
- | |
61 | jne .next |
- | |
62 | dec edx |
- | |
63 | jz .ok |
- | |
64 | inc ecx |
- | |
65 | cmp ecx,ebx |
- | |
66 | jb .match |
- | |
67 | .fail: |
- | |
68 | xor eax, eax |
- | |
69 | pop edi |
- | |
70 | pop ebx |
- | |
71 | popfd |
- | |
72 | ret |
- | |
73 | .next: |
- | |
74 | inc ecx |
- | |
75 | cmp ecx, ebx |
- | |
76 | jb .find |
- | |
77 | pop edi |
- | |
78 | pop ebx |
- | |
79 | popfd |
- | |
80 | xor eax, eax |
- | |
81 | ret |
- | |
82 | .ok: |
- | |
83 | sub ecx, edi |
- | |
84 | inc ecx |
- | |
85 | push esi |
- | |
86 | mov esi, edi |
- | |
87 | xor eax, eax |
- | |
88 | rep stosb |
- | |
89 | sub esi, sys_pgmap |
- | |
90 | shl esi, 3+12 |
- | |
91 | mov eax, esi |
- | |
92 | mov ebx, [count] |
- | |
93 | shl ebx, 3 |
- | |
94 | sub [pg_data.pages_free], ebx |
- | |
95 | pop esi |
- | |
96 | pop edi |
- | |
97 | pop ebx |
- | |
98 | popfd |
- | |
99 | ret |
- | |
100 | endp |
9 | |
101 | 10 | ||
102 | align 4 |
11 | align 4 |
103 | proc map_page stdcall,lin_addr:dword,phis_addr:dword,flags:dword |
12 | proc map_page stdcall,lin_addr:dword,phis_addr:dword,flags:dword |
104 | push ebx |
13 | push ebx |
Line 121... | Line 30... | ||
121 | ret |
30 | ret |
Line 122... | Line 31... | ||
122 | 31 | ||
123 | 32 | ||
- | 33 | align 4 |
|
124 | align 4 |
34 | proc free_page |
125 | proc free_page |
35 | |
126 | ;arg: eax page address |
36 | ;arg: eax page address |
127 | pushfd |
37 | ; pushfd |
128 | cli |
38 | ; cli |
129 | shr eax, 12 ;page index |
39 | ; shr eax, 12 ;page index |
130 | bts dword [sys_pgmap], eax ;that's all! |
40 | ; bts dword [sys_pgmap], eax ;that's all! |
131 | cmc |
41 | ; cmc |
132 | adc [pg_data.pages_free], 0 |
42 | ; adc [pg_data.pages_free], 0 |
133 | shr eax, 3 |
43 | ; shr eax, 3 |
134 | and eax, not 3 ;dword offset from page_map |
44 | ; and eax, not 3 ;dword offset from page_map |
135 | add eax, sys_pgmap |
45 | ; add eax, sys_pgmap |
136 | cmp [page_start], eax |
46 | ; cmp [page_start], eax |
137 | ja @f |
47 | ; ja @f |
138 | popfd |
48 | ; popfd |
139 | ret |
49 | ; ret |
140 | @@: |
50 | ;@@: |
141 | mov [page_start], eax |
51 | ; mov [page_start], eax |
142 | popfd |
52 | ; popfd |
Line 143... | Line 53... | ||
143 | ret |
53 | ret |
Line 233... | Line 143... | ||
233 | mov edi, eax |
143 | mov edi, eax |
Line 234... | Line 144... | ||
234 | 144 | ||
235 | shr esi, 10 |
145 | shr esi, 10 |
Line 236... | Line 146... | ||
236 | add esi, page_tabs |
146 | add esi, page_tabs |
237 | 147 | ||
238 | mov ebp, [pg_data.pages_free] |
148 | ; mov ebp, [pg_data.pages_free] |
239 | mov ebx, [page_start] |
149 | ; mov ebx, [page_start] |
240 | mov edx, sys_pgmap |
150 | ; mov edx, sys_pgmap |
241 | @@: |
151 | @@: |
242 | xor eax, eax |
152 | xor eax, eax |
243 | xchg eax, [esi] |
153 | xchg eax, [esi] |
244 | push eax |
154 | push eax |
Line 245... | Line 155... | ||
245 | invlpg [edi] |
155 | invlpg [edi] |
246 | pop eax |
156 | pop eax |
Line 247... | Line 157... | ||
247 | 157 | ||
248 | test eax, 1 |
158 | ; test eax, 1 |
249 | jz .next |
159 | ; jz .next |
250 | 160 | ||
251 | shr eax, 12 |
161 | ; shr eax, 12 |
252 | bts [edx], eax |
162 | ; bts [edx], eax |
253 | cmc |
163 | ; cmc |
254 | adc ebp, 0 |
164 | ; adc ebp, 0 |
255 | shr eax, 3 |
165 | ; shr eax, 3 |
Line 256... | Line 166... | ||
256 | and eax, -4 |
166 | ; and eax, -4 |
257 | add eax, edx |
167 | ; add eax, edx |
258 | cmp eax, ebx |
168 | ; cmp eax, ebx |
259 | jae .next |
169 | ; jae .next |
260 | 170 | ||
261 | mov ebx, eax |
171 | ; mov ebx, eax |
Line 1306... | Line 1216... | ||
1306 | endp |
1216 | endp |
Line 1307... | Line 1217... | ||
1307 | 1217 | ||
1308 | 1218 | ||
- | 1219 | align 4 |
|
- | 1220 | _balloc: ; gcc fastcall |
|
Line 1309... | Line 1221... | ||
1309 | align 4 |
1221 | @balloc@4: |
1310 | _balloc: ; gcc fastcall |
1222 | |
1311 | 1223 | ||
1312 | mov eax, [_last_page] |
1224 | mov eax, [_pg_balloc] |
1313 | add ecx, 4095 |
1225 | add ecx, 4095 |
1314 | and ecx, -4096 |
1226 | and ecx, -4096 |
1315 | add ecx, eax |
1227 | add ecx, eax |