kernel: minor optimizations

git-svn-id: svn://kolibrios.org@4424 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2014-01-02 19:43:51 +00:00
parent 3ed9acd41a
commit 3e99300152
5 changed files with 30 additions and 51 deletions

View File

@ -129,15 +129,11 @@ proc init_kernel_heap
loop @B
stdcall alloc_pages, dword 32
or eax, PG_SW
mov ebx, HEAP_BASE
mov ecx, 32
mov edx, eax
mov edi, HEAP_BASE
.l1:
stdcall map_page, edi, edx, PG_SW
add edi, 0x1000
add edx, 0x1000
dec ecx
jnz .l1
call commit_pages
mov edi, HEAP_BASE ;descriptors
mov ebx, HEAP_BASE+sizeof.MEM_BLOCK ;free space
@ -480,46 +476,39 @@ proc kernel_alloc stdcall, size:dword
mov [pages_count], ebx
stdcall alloc_kernel_space, eax
mov [lin_addr], eax
mov ebx, [pages_count]
test eax, eax
jz .err
mov [lin_addr], eax
mov ecx, [pages_count]
mov edx, eax
mov ebx, ecx
shr ecx, 3
jz .next
shr ebx, 3
jz .tail
and ebx, not 7
push ebx
shl ebx, 3
stdcall alloc_pages, ebx
pop ecx ; yes ecx!!!
and eax, eax
test eax, eax
jz .err
mov edi, eax
mov edx, [lin_addr]
@@:
stdcall map_page, edx, edi, dword PG_SW
add edx, 0x1000
add edi, 0x1000
dec ecx
jnz @B
.next:
mov ecx, [pages_count]
and ecx, 7
mov ecx, ebx
or eax, PG_SW
mov ebx, [lin_addr]
call commit_pages
mov edx, ebx ; this dirty hack
.tail:
mov ebx, [pages_count]
and ebx, 7
jz .end
@@:
push ecx
call alloc_page
pop ecx
test eax, eax
jz .err
stdcall map_page, edx, eax, dword PG_SW
add edx, 0x1000
dec ecx
dec ebx
jnz @B
.end:
mov eax, [lin_addr]

View File

@ -123,19 +123,19 @@ proc alloc_pages stdcall, count:dword
endp
align 4
proc map_page stdcall,lin_addr:dword,phis_addr:dword,flags:dword
;proc map_page stdcall,lin_addr:dword,phis_addr:dword,flags:dword
map_page:
push ebx
mov eax, [phis_addr]
mov eax, [esp+12] ; phis_addr
and eax, not 0xFFF
or eax, [flags]
mov ebx, [lin_addr]
or eax, [esp+16] ; flags
mov ebx, [esp+8] ; lin_addr
shr ebx, 12
mov [page_tabs+ebx*4], eax
mov eax, [lin_addr]
invlpg [eax]
mov eax, [esp+8] ; lin_addr
pop ebx
ret
endp
invlpg [eax]
ret 12
align 4
map_space: ;not implemented

View File

@ -517,6 +517,7 @@ end if
add edi, page_tabs
.remap:
lodsd
and eax, 0xFFFFF000
or eax, ebx; force user level r/w access
stosd
add edx, 0x1000

View File

@ -523,9 +523,6 @@ mouse._.find_sys_window_under_cursor: ;////////////////////////////////////////
;< esi = process slot
;< edi = pointer to WDATA struct
;------------------------------------------------------------------------------
; mov esi, [Screen_Max_X]
; inc esi
; imul esi, [mouse.state.pos.y]
mov esi, [mouse.state.pos.y]
mov esi, [d_width_calc_area + esi*4]

View File

@ -1881,12 +1881,7 @@ align 4
; get WinMap start
push esi
; mov edi, [Screen_Max_X]
; inc edi
; mov esi, edi
mov esi, [Screen_Max_X]
inc esi
; imul edi, ebx
mov esi, [_display.width]
mov edi, [d_width_calc_area + ebx*4]
add edi, eax
@ -1929,9 +1924,6 @@ align 4
; get WinMap start -> ebp
push eax
; mov eax, [Screen_Max_X] ; screen_sx
; inc eax
; imul eax, ebx
mov eax, [d_width_calc_area + ebx*4]
add eax, [esp]