forked from KolibriOS/kolibrios
Use e820entry macro instead of hardcoded values.
git-svn-id: svn://kolibrios.org@8217 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
efa84a263d
commit
fe0d0438ff
@ -335,11 +335,6 @@ PAT_VALUE = 0x00070106; (UC<<24)|(UCM<<16)|(WC<<8)|WB
|
|||||||
|
|
||||||
MAX_MEMMAP_BLOCKS = 32
|
MAX_MEMMAP_BLOCKS = 32
|
||||||
|
|
||||||
TMP_FILE_NAME = 0
|
|
||||||
TMP_CMD_LINE = 1024
|
|
||||||
TMP_ICON_OFFS = 1280
|
|
||||||
|
|
||||||
|
|
||||||
EVENT_REDRAW = 0x00000001
|
EVENT_REDRAW = 0x00000001
|
||||||
EVENT_KEY = 0x00000002
|
EVENT_KEY = 0x00000002
|
||||||
EVENT_BUTTON = 0x00000004
|
EVENT_BUTTON = 0x00000004
|
||||||
@ -702,7 +697,8 @@ struct boot_data
|
|||||||
bank_switch dd ? ; Vesa 1.2 pm bank switch
|
bank_switch dd ? ; Vesa 1.2 pm bank switch
|
||||||
lfb dd ? ; Vesa 2.0 LFB address
|
lfb dd ? ; Vesa 2.0 LFB address
|
||||||
mtrr db ? ; 0 or 1: enable MTRR graphics acceleration
|
mtrr db ? ; 0 or 1: enable MTRR graphics acceleration
|
||||||
launcher_start db ? ; 0 or 1: start the first app (right now it's LAUNCHER) after kernel is loaded
|
launcher_start db ? ; 0 or 1: start the first app (right now it's
|
||||||
|
; LAUNCHER) after kernel is loaded
|
||||||
debug_print db ? ; if nonzero, duplicates debug output to the screen
|
debug_print db ? ; if nonzero, duplicates debug output to the screen
|
||||||
dma db ? ; DMA write: 1=yes, 2=no
|
dma db ? ; DMA write: 1=yes, 2=no
|
||||||
pci_data rb 8
|
pci_data rb 8
|
||||||
|
@ -10,7 +10,7 @@ $Revision$
|
|||||||
align 4
|
align 4
|
||||||
proc mem_test
|
proc mem_test
|
||||||
; if we have BIOS with fn E820, skip the test
|
; if we have BIOS with fn E820, skip the test
|
||||||
cmp dword [BOOT_LO.memmap_block_cnt], 0
|
cmp [BOOT_LO.memmap_block_cnt], 0
|
||||||
jnz .ret
|
jnz .ret
|
||||||
|
|
||||||
mov eax, cr0
|
mov eax, cr0
|
||||||
@ -32,12 +32,12 @@ proc mem_test
|
|||||||
mov cr0, eax
|
mov cr0, eax
|
||||||
inc dword [BOOT_LO.memmap_block_cnt]
|
inc dword [BOOT_LO.memmap_block_cnt]
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov [BOOT_LO.memmap_blocks + e820entry.addr.lo], eax
|
mov [BOOT_LO.memmap_blocks+e820entry.addr.lo], eax
|
||||||
mov [BOOT_LO.memmap_blocks + e820entry.addr.hi], eax
|
mov [BOOT_LO.memmap_blocks+e820entry.addr.hi], eax
|
||||||
mov [BOOT_LO.memmap_blocks + e820entry.size.lo], edi
|
mov [BOOT_LO.memmap_blocks+e820entry.size.lo], edi
|
||||||
mov [BOOT_LO.memmap_blocks + e820entry.size.hi], eax
|
mov [BOOT_LO.memmap_blocks+e820entry.size.hi], eax
|
||||||
inc eax
|
inc eax
|
||||||
mov [BOOT_LO.memmap_blocks + e820entry.type], eax
|
mov [BOOT_LO.memmap_blocks+e820entry.type], eax
|
||||||
.ret:
|
.ret:
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
@ -46,34 +46,34 @@ align 4
|
|||||||
proc init_mem
|
proc init_mem
|
||||||
; calculate maximum allocatable address and number of allocatable pages
|
; calculate maximum allocatable address and number of allocatable pages
|
||||||
mov edi, BOOT_LO.memmap_blocks
|
mov edi, BOOT_LO.memmap_blocks
|
||||||
mov ecx, [edi-4]
|
mov ecx, [edi-4] ; memmap_block_cnt
|
||||||
xor esi, esi; esi will hold total amount of memory
|
xor esi, esi; esi will hold total amount of memory
|
||||||
xor edx, edx; edx will hold maximum allocatable address
|
xor edx, edx; edx will hold maximum allocatable address
|
||||||
.calcmax:
|
.calcmax:
|
||||||
; round all to pages
|
; round all to pages
|
||||||
mov eax, [edi]
|
mov eax, [edi+e820entry.addr.lo]
|
||||||
cmp [edi+16], byte 1
|
cmp byte [edi+e820entry.type], 1
|
||||||
jne .unusable
|
jne .unusable
|
||||||
|
|
||||||
test eax, 0xFFF
|
test eax, 0xFFF
|
||||||
jz @f
|
jz @f
|
||||||
neg eax
|
neg eax
|
||||||
and eax, 0xFFF
|
and eax, 0xFFF
|
||||||
add [edi], eax
|
add [edi+e820entry.addr.lo], eax
|
||||||
adc dword [edi+4], 0
|
adc [edi+e820entry.addr.hi], 0
|
||||||
sub [edi+8], eax
|
sub [edi+e820entry.size.lo], eax
|
||||||
sbb dword [edi+12], 0
|
sbb [edi+e820entry.size.hi], 0
|
||||||
jc .unusable
|
jc .unusable
|
||||||
@@:
|
@@:
|
||||||
and dword [edi+8], not 0xFFF
|
and [edi+e820entry.size.lo], not 0xFFF
|
||||||
jz .unusable
|
jz .unusable
|
||||||
; ignore memory after 4 Gb
|
; ignore memory after 4 GiB
|
||||||
cmp dword [edi+4], 0
|
cmp [edi+e820entry.addr.hi], 0
|
||||||
jnz .unusable
|
jnz .unusable
|
||||||
mov eax, [edi]
|
mov eax, [edi]
|
||||||
cmp dword [edi+12], 0
|
cmp [edi+e820entry.size.hi], 0
|
||||||
jnz .overflow
|
jnz .overflow
|
||||||
add eax, [edi+8]
|
add eax, [edi+e820entry.size.lo]
|
||||||
jnc @f
|
jnc @f
|
||||||
.overflow:
|
.overflow:
|
||||||
mov eax, 0xFFFFF000
|
mov eax, 0xFFFFF000
|
||||||
@ -82,14 +82,14 @@ proc init_mem
|
|||||||
jae @f
|
jae @f
|
||||||
mov edx, eax
|
mov edx, eax
|
||||||
@@:
|
@@:
|
||||||
sub eax, [edi]
|
sub eax, [edi+e820entry.addr.lo]
|
||||||
mov [edi+8], eax
|
mov [edi+e820entry.size.lo], eax
|
||||||
add esi, eax
|
add esi, eax
|
||||||
jmp .usable
|
jmp .usable
|
||||||
.unusable:
|
.unusable:
|
||||||
; and dword [edi+8], 0
|
; and dword [edi+e820entry.size.lo], 0
|
||||||
.usable:
|
.usable:
|
||||||
add edi, 20
|
add edi, sizeof.e820entry
|
||||||
loop .calcmax
|
loop .calcmax
|
||||||
.calculated:
|
.calculated:
|
||||||
mov [MEM_AMOUNT-OS_BASE], esi
|
mov [MEM_AMOUNT-OS_BASE], esi
|
||||||
@ -195,13 +195,13 @@ proc init_page_map
|
|||||||
mov ebx, BOOT_LO.memmap_blocks
|
mov ebx, BOOT_LO.memmap_blocks
|
||||||
mov edx, [ebx-4]
|
mov edx, [ebx-4]
|
||||||
.scanmap:
|
.scanmap:
|
||||||
cmp [ebx+16], byte 1
|
cmp byte [ebx+e820entry.type], 1
|
||||||
jne .next
|
jne .next
|
||||||
|
|
||||||
mov ecx, [ebx+8]
|
mov ecx, [ebx+e820entry.size.lo]
|
||||||
shr ecx, 12; ecx = number of pages
|
shr ecx, 12; ecx = number of pages
|
||||||
jz .next
|
jz .next
|
||||||
mov edi, [ebx]
|
mov edi, [ebx+e820entry.addr.lo]
|
||||||
shr edi, 12; edi = first page
|
shr edi, 12; edi = first page
|
||||||
mov eax, edi
|
mov eax, edi
|
||||||
shr edi, 5
|
shr edi, 5
|
||||||
@ -239,7 +239,7 @@ proc init_page_map
|
|||||||
inc eax
|
inc eax
|
||||||
loop @b
|
loop @b
|
||||||
.next:
|
.next:
|
||||||
add ebx, 20
|
add ebx, sizeof.e820entry
|
||||||
dec edx
|
dec edx
|
||||||
jnz .scanmap
|
jnz .scanmap
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user