Rev 7130 | Rev 7136 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7130 | Rev 7132 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2015. 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: 7130 $ |
8 | $Revision: 7132 $ |
9 | 9 | ||
10 | 10 | ||
Line 11... | Line 11... | ||
11 | MEM_WB equ 6 ;write-back memory |
11 | MEM_WB equ 6 ;write-back memory |
12 | MEM_WC equ 1 ;write combined memory |
12 | MEM_WC equ 1 ;write combined memory |
13 | MEM_UC equ 0 ;uncached memory |
13 | MEM_UC equ 0 ;uncached memory |
14 | 14 | ||
15 | align 4 |
15 | align 4 |
Line 16... | Line 16... | ||
16 | proc mem_test |
16 | proc mem_test |
17 | ; if we have BIOS with fn E820, skip the test |
17 | ; if we have BIOS with fn E820, skip the test |
18 | cmp dword [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCK_CNT], 0 |
18 | cmp dword [BOOT_LO.memmap_block_cnt], 0 |
Line 33... | Line 33... | ||
33 | xchg ebx, dword [edi] |
33 | xchg ebx, dword [edi] |
34 | je @b |
34 | je @b |
Line 35... | Line 35... | ||
35 | 35 | ||
36 | and eax, not (CR0_CD+CR0_NW) ;enable caching |
36 | and eax, not (CR0_CD+CR0_NW) ;enable caching |
37 | mov cr0, eax |
37 | mov cr0, eax |
38 | inc dword [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCK_CNT] |
38 | inc dword [BOOT_LO.memmap_block_cnt] |
39 | xor eax, eax |
39 | xor eax, eax |
40 | mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.addr.lo], eax |
40 | mov [BOOT_LO.memmap_blocks + e820entry.addr.lo], eax |
41 | mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.addr.hi], eax |
41 | mov [BOOT_LO.memmap_blocks + e820entry.addr.hi], eax |
42 | mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.size.lo], edi |
42 | mov [BOOT_LO.memmap_blocks + e820entry.size.lo], edi |
43 | mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.size.hi], eax |
43 | mov [BOOT_LO.memmap_blocks + e820entry.size.hi], eax |
44 | inc eax |
44 | inc eax |
45 | mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.type], eax |
45 | mov [BOOT_LO.memmap_blocks + e820entry.type], eax |
46 | .ret: |
46 | .ret: |
47 | ret |
47 | ret |
Line 48... | Line 48... | ||
48 | endp |
48 | endp |
49 | 49 | ||
50 | align 4 |
50 | align 4 |
51 | proc init_mem |
51 | proc init_mem |
52 | ; calculate maximum allocatable address and number of allocatable pages |
52 | ; calculate maximum allocatable address and number of allocatable pages |
53 | mov edi, BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS |
53 | mov edi, BOOT_LO.memmap_blocks |
54 | mov ecx, [edi-4] |
54 | mov ecx, [edi-4] |
55 | xor esi, esi; esi will hold total amount of memory |
55 | xor esi, esi; esi will hold total amount of memory |
56 | xor edx, edx; edx will hold maximum allocatable address |
56 | xor edx, edx; edx will hold maximum allocatable address |
Line 195... | Line 195... | ||
195 | xor eax, eax |
195 | xor eax, eax |
196 | cld |
196 | cld |
197 | rep stosd |
197 | rep stosd |
Line 198... | Line 198... | ||
198 | 198 | ||
199 | ; scan through memory map and mark free areas as available |
199 | ; scan through memory map and mark free areas as available |
200 | mov ebx, BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS |
200 | mov ebx, BOOT_LO.memmap_blocks |
201 | mov edx, [ebx-4] |
201 | mov edx, [ebx-4] |
202 | .scanmap: |
202 | .scanmap: |
203 | cmp [ebx+16], byte 1 |
203 | cmp [ebx+16], byte 1 |
Line 457... | Line 457... | ||
457 | push ebx |
457 | push ebx |
458 | push edi |
458 | push edi |
Line 459... | Line 459... | ||
459 | 459 | ||
460 | if defined UEFI |
460 | if defined UEFI |
461 | ; UEFI loader knows where RSDP is |
461 | ; UEFI loader knows where RSDP is |
462 | mov ebx, [BOOT_ACPI_RSDP] |
462 | mov ebx, [BOOT_LO.acpi_rsdp] |
463 | test ebx, ebx |
463 | test ebx, ebx |
464 | jz .done |
464 | jz .done |
465 | call .check |
465 | call .check |
466 | else |
466 | else |