Rev 2047 | Rev 2425 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2047 | Rev 2350 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2008. 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: 2047 $ |
8 | $Revision: 2350 $ |
9 | 9 | ||
10 | 10 | ||
Line 76... | Line 76... | ||
76 | mov eax, esi |
76 | mov eax, esi |
77 | mov [MEM_AMOUNT-OS_BASE], eax |
77 | mov [MEM_AMOUNT-OS_BASE], eax |
78 | mov [pg_data.mem_amount-OS_BASE], eax ; the true MEMTOP |
78 | mov [pg_data.mem_amount-OS_BASE], eax ; the true MEMTOP |
79 | mov [UserDMAaddr-OS_BASE], eax |
79 | mov [UserDMAaddr-OS_BASE], eax |
Line 80... | Line -... | ||
80 | - | ||
81 | mov edx, esi ; edx will hold maximum allocatable address |
80 | |
82 | shr esi, 12 |
81 | shr esi, 12 |
Line 83... | Line -... | ||
83 | mov [pg_data.pages_count-OS_BASE], esi ; max number of PTEs ? |
- | |
84 | - | ||
85 | shr edx, 12 |
82 | mov [pg_data.pages_count-OS_BASE], esi ; max number of PTEs ? |
86 | add edx, 31 |
83 | |
87 | and edx, not 31 |
84 | mov edx, esi ; edx will hold maximum allocatable address |
Line 88... | Line 85... | ||
88 | shr edx, 3 |
85 | shr edx, 3 |
89 | mov [pg_data.pagemap_size-OS_BASE], edx ; size of sys_pgmap structure |
86 | mov [pg_data.pagemap_size-OS_BASE], edx ; size of sys_pgmap structure |
90 | 87 | ||
Line 91... | Line 88... | ||
91 | add edx, (sys_pgmap-OS_BASE)+4095 |
88 | add edx, (sys_pgmap-OS_BASE)+4095 |
92 | and edx, not 4095 |
89 | and edx, not 4095 |
93 | mov [tmp_page_tabs], edx ; free zone to build PTEs |
90 | mov [tmp_page_tabs], edx ; free zone to build PTEs for all available memory |
94 | 91 | ||
Line 95... | Line 92... | ||
95 | mov edx, (HEAP_BASE-OS_BASE+HEAP_MIN_SIZE)/4096 |
92 | mov edx, (HEAP_BASE-OS_BASE+HEAP_MIN_SIZE)/4096 |
Line 96... | Line 93... | ||
96 | mov [pg_data.kernel_pages -OS_BASE], edx |
93 | mov [pg_data.kernel_pages -OS_BASE], edx |
97 | shr edx, 10 |
94 | shr edx, 10 |
Line 134... | Line 131... | ||
134 | ret |
131 | ret |
135 | endp |
132 | endp |
Line 136... | Line 133... | ||
136 | 133 | ||
137 | align 4 |
134 | align 4 |
138 | proc init_page_map |
135 | proc init_page_map |
139 | ; mark all memory as unavailable |
136 | ; mark all memory as available |
140 | mov edi, sys_pgmap-OS_BASE |
137 | mov edi, sys_pgmap-OS_BASE |
141 | mov ecx, [pg_data.pagemap_size-OS_BASE] |
138 | mov ecx, [pg_data.pagemap_size-OS_BASE] |
142 | shr ecx, 2 |
139 | shr ecx, 2 |
143 | xor eax, eax |
140 | mov eax, -1 |
144 | cld |
141 | cld |
Line 145... | Line -... | ||
145 | rep stosd |
- | |
146 | - | ||
147 | ; scan through memory map and mark free areas as available |
- | |
148 | mov ebx, BOOT_VAR-OS_BASE + 0x9104 |
- | |
149 | mov edx, [ebx-4] |
- | |
150 | .scanmap: |
- | |
151 | mov ecx, [ebx+8] |
- | |
152 | shr ecx, 12 ; ecx = number of pages |
- | |
153 | jz .next |
- | |
154 | mov edi, [ebx] |
- | |
155 | shr edi, 12 ; edi = first page |
- | |
156 | mov eax, edi |
- | |
157 | shr edi, 5 |
- | |
158 | shl edi, 2 |
- | |
159 | add edi, sys_pgmap-OS_BASE |
- | |
160 | and eax, 31 |
- | |
161 | jz .startok |
- | |
162 | add ecx, eax |
- | |
163 | sub ecx, 32 |
- | |
164 | jbe .onedword |
- | |
165 | push ecx |
- | |
166 | mov ecx, eax |
- | |
167 | or eax, -1 |
- | |
168 | shl eax, cl |
- | |
169 | or [edi], eax |
- | |
170 | add edi, 4 |
- | |
171 | pop ecx |
- | |
172 | .startok: |
- | |
173 | push ecx |
- | |
174 | shr ecx, 5 |
- | |
175 | or eax, -1 |
- | |
176 | rep stosd |
- | |
177 | pop ecx |
- | |
178 | and ecx, 31 |
- | |
179 | neg eax |
- | |
180 | shl eax, cl |
- | |
181 | dec eax |
- | |
182 | or [edi], eax |
- | |
183 | jmp .next |
- | |
184 | .onedword: |
- | |
185 | add ecx, 32 |
- | |
186 | sub ecx, eax |
- | |
187 | @@: |
- | |
188 | bts [edi], eax |
- | |
189 | inc eax |
- | |
190 | loop @b |
- | |
191 | .next: |
- | |
192 | add ebx, 20 |
- | |
Line 193... | Line 142... | ||
193 | dec edx |
142 | rep stosd |
194 | jnz .scanmap |
143 | |
195 | 144 | ||
196 | ; mark kernel memory as allocated (unavailable) |
145 | ; mark kernel memory as allocated (unavailable) |