/kernel/branches/kolibri_pe/const.inc |
---|
332,7 → 332,7 |
LAST_PAGE equ 0x0340000 |
sys_pgmap equ (OS_BASE+LAST_PAGE) |
;sys_pgmap equ (OS_BASE+LAST_PAGE) |
twdw equ 0x3000 ;(CURRENT_TASK-window_data) |
/kernel/branches/kolibri_pe/core/heap.inc |
---|
577,7 → 577,7 |
push ebx |
stdcall alloc_pages, ebx |
pop ecx ; yes ecx!!! |
and eax, eax |
test eax, eax |
jz .err |
mov edi, eax |
/kernel/branches/kolibri_pe/core/memory.inc |
---|
9,97 → 9,6 |
align 4 |
proc alloc_page |
pushfd |
cli |
push ebx |
mov ebx, [page_start] |
mov ecx, [page_end] |
.l1: |
bsf eax,[ebx]; |
jnz .found |
add ebx,4 |
cmp ebx, ecx |
jb .l1 |
pop ebx |
popfd |
xor eax,eax |
ret |
.found: |
btr [ebx], eax |
mov [page_start],ebx |
sub ebx, sys_pgmap |
lea eax, [eax+ebx*8] |
shl eax, 12 |
dec [pg_data.pages_free] |
pop ebx |
popfd |
ret |
endp |
align 4 |
proc alloc_pages stdcall, count:dword |
pushfd |
push ebx |
push edi |
cli |
mov eax, [count] |
add eax, 7 |
shr eax, 3 |
mov [count], eax |
cmp eax, [pg_data.pages_free] |
ja .fail |
mov ecx, [page_start] |
mov ebx, [page_end] |
.find: |
mov edx, [count] |
mov edi, ecx |
.match: |
cmp byte [ecx], 0xFF |
jne .next |
dec edx |
jz .ok |
inc ecx |
cmp ecx,ebx |
jb .match |
.fail: |
xor eax, eax |
pop edi |
pop ebx |
popfd |
ret |
.next: |
inc ecx |
cmp ecx, ebx |
jb .find |
pop edi |
pop ebx |
popfd |
xor eax, eax |
ret |
.ok: |
sub ecx, edi |
inc ecx |
push esi |
mov esi, edi |
xor eax, eax |
rep stosb |
sub esi, sys_pgmap |
shl esi, 3+12 |
mov eax, esi |
mov ebx, [count] |
shl ebx, 3 |
sub [pg_data.pages_free], ebx |
pop esi |
pop edi |
pop ebx |
popfd |
ret |
endp |
align 4 |
proc map_page stdcall,lin_addr:dword,phis_addr:dword,flags:dword |
push ebx |
mov eax, [phis_addr] |
123,24 → 32,25 |
align 4 |
proc free_page |
;arg: eax page address |
pushfd |
cli |
shr eax, 12 ;page index |
bts dword [sys_pgmap], eax ;that's all! |
cmc |
adc [pg_data.pages_free], 0 |
shr eax, 3 |
and eax, not 3 ;dword offset from page_map |
add eax, sys_pgmap |
cmp [page_start], eax |
ja @f |
popfd |
; pushfd |
; cli |
; shr eax, 12 ;page index |
; bts dword [sys_pgmap], eax ;that's all! |
; cmc |
; adc [pg_data.pages_free], 0 |
; shr eax, 3 |
; and eax, not 3 ;dword offset from page_map |
; add eax, sys_pgmap |
; cmp [page_start], eax |
; ja @f |
; popfd |
; ret |
;@@: |
; mov [page_start], eax |
; popfd |
ret |
@@: |
mov [page_start], eax |
popfd |
ret |
endp |
proc map_io_mem stdcall, base:dword, size:dword, flags:dword |
235,9 → 145,9 |
shr esi, 10 |
add esi, page_tabs |
mov ebp, [pg_data.pages_free] |
mov ebx, [page_start] |
mov edx, sys_pgmap |
; mov ebp, [pg_data.pages_free] |
; mov ebx, [page_start] |
; mov edx, sys_pgmap |
@@: |
xor eax, eax |
xchg eax, [esi] |
245,20 → 155,20 |
invlpg [edi] |
pop eax |
test eax, 1 |
jz .next |
; test eax, 1 |
; jz .next |
shr eax, 12 |
bts [edx], eax |
cmc |
adc ebp, 0 |
shr eax, 3 |
and eax, -4 |
add eax, edx |
cmp eax, ebx |
jae .next |
; shr eax, 12 |
; bts [edx], eax |
; cmc |
; adc ebp, 0 |
; shr eax, 3 |
; and eax, -4 |
; add eax, edx |
; cmp eax, ebx |
; jae .next |
mov ebx, eax |
; mov ebx, eax |
.next: |
add edi, 0x1000 |
add esi, 4 |
1308,12 → 1218,14 |
align 4 |
_balloc: ; gcc fastcall |
@balloc@4: |
mov eax, [_last_page] |
mov eax, [_pg_balloc] |
add ecx, 4095 |
and ecx, -4096 |
add ecx, eax |
mov [_last_page], ecx |
mov [_pg_balloc], ecx |
add eax, OS_BASE |
ret |
/kernel/branches/kolibri_pe/core/taskman.inc |
---|
380,8 → 380,8 |
else |
lea eax, [eax+ebx+2] ;all requested memory |
end if |
cmp eax, [pg_data.pages_free] |
ja .fail |
; cmp eax, [pg_data.pages_free] |
; ja .fail |
call alloc_page |
test eax, eax |
/kernel/branches/kolibri_pe/data32.inc |
---|
110,7 → 110,7 |
align 4 |
_last_page dd LAST_PAGE |
_pg_balloc dd LAST_PAGE |
;supported videomodes |
mode_1280_1024_32: |
290,6 → 290,8 |
mem_block_mask rd 2 |
large_block_mask rd 1 |
_z_core rd 50 |
mem_used.fd rd 1 |
mem_used.bk rd 1 |
/kernel/branches/kolibri_pe/kernel.asm |
---|
293,79 → 293,11 |
MEM_WC equ 1 ;write combined memory |
MEM_UC equ 0 ;uncached memory |
align 4 |
init_mem: |
mov ecx, [BOOT_VAR + 0x9100] |
mov esi, BOOT_VAR + 0x9104 |
xor eax, eax |
@@: |
cmp dword [esi+16], 1 |
jne .next |
mov edx, [esi+8] |
cmp eax, [esi+8] |
ja .next |
include 'core/mm.asm' |
mov eax, [esi+8] |
.next: |
add esi, 20 |
loop @B |
and eax, -4096 |
mov [MEM_AMOUNT], eax |
mov [pg_data.mem_amount], eax |
shr eax, 12 |
mov edx, eax |
mov [pg_data.pages_count], eax |
shr eax, 3 |
and eax, -4 |
mov [pg_data.pagemap_size], eax |
mov ecx, eax |
fastcall _balloc |
ret |
align 4 |
init_page_map: |
mov edi, sys_pgmap |
mov ecx, [pg_data.pagemap_size] |
shr ecx, 2 |
or eax, -1 |
cld |
rep stosd |
xchg bx, bx |
mov ecx, [_last_page] |
mov edx, [pg_data.pages_count] |
shr ecx, 12 |
sub edx, ecx |
mov [pg_data.pages_free], edx |
mov edi, sys_pgmap |
mov ebx, ecx |
shr ecx, 5 |
xor eax, eax |
rep stosd |
not eax |
mov ecx, ebx |
and ecx, 31 |
shl eax, cl |
mov [edi], eax |
mov [page_start], edi; |
mov ebx, sys_pgmap |
add ebx, [pg_data.pagemap_size] |
mov [page_end], ebx |
mov [pg_data.pg_mutex], 0 |
ret |
align 4 |
high_code: |
mov ax,os_stack |
mov bx,app_data |
398,8 → 330,6 |
; MEMORY MODEL |
call init_mem |
mov ecx, 1280*1024 |
fastcall _balloc |
mov [_display_data], eax |
437,9 → 367,9 |
call init_kernel_heap ; FIXME initialize heap after pager |
call init_page_map |
call _init_mm |
mov [pg_data.pg_mutex], 0 |
; SAVE REAL MODE VARIABLES |
mov ax, [BOOT_VAR + 0x9031] |
mov [IDEContrRegsBaseAddr], ax |