Rev 1519 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1519 | Rev 1521 | ||
---|---|---|---|
Line 52... | Line 52... | ||
52 | 52 | ||
Line 53... | Line 53... | ||
53 | 53 | ||
- | 54 | macro allocate_and_clear dest, size, err { |
|
54 | macro allocate_and_clear dest, size, err { |
55 | |
55 | 56 | ; We need to allocate at least 8 pages, if we want a continuous memory in ram |
|
56 | ; We need to allocate at least 8 pages, if we want a continuous memory in ram |
57 | push edx |
57 | if (size < 8*4096) & (size > 4096) |
58 | if (size < 8*4096) & (size > 4096) |
58 | stdcall KernelAlloc, 8*4096 |
59 | stdcall KernelAlloc, 8*4096 |
- | 60 | else |
|
- | 61 | stdcall KernelAlloc, size |
|
59 | else |
62 | end if |
60 | stdcall KernelAlloc, size |
63 | pop edx |
61 | end if |
64 | |
62 | test eax, eax |
65 | test eax, eax |
Line 63... | Line 66... | ||
63 | jz err |
66 | jz err |
64 | mov dest, eax ; Save the address to it into the device struct |
67 | mov dest, eax ; Save the address to it into the device struct |
65 | mov edi, eax ; look at last part of code! |
68 | mov edi, eax ; look at last part of code! |
66 | 69 | ||
- | 70 | ; Release the unused pages (if any) |
|
67 | ; Release the unused pages (if any) |
71 | if (size < 8*4096) & (size > 4096) |
- | 72 | add eax, (size/4096+1)*4096 |
|
68 | if (size < 8*4096) & (size > 4096) |
73 | mov ecx, 8-(size/4096+1) |
Line 69... | Line 74... | ||
69 | add eax, (size/4096+1)*4096 |
74 | push edx |
70 | mov ecx, 8-(size/4096+1) |
75 | call ReleasePages |
71 | call ReleasePages |
76 | pop edx |