Rev 1366 | Rev 1496 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1366 | Rev 1461 | ||
---|---|---|---|
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: 1366 $ |
8 | $Revision: 1461 $ |
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] |
- | 45 | pop ebx |
|
- | 46 | popfd |
|
- | 47 | ret |
|
- | 48 | ;//- |
|
- | 49 | .out_of_memory: |
|
- | 50 | mov [pg_data.pages_free], 1 |
|
- | 51 | xor eax, eax |
|
36 | pop ebx |
52 | pop ebx |
37 | popfd |
53 | popfd |
38 | ret |
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 |