1) unmap_pages

2) code cleanup

git-svn-id: svn://kolibrios.org@819 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-07-04 20:44:53 +00:00
parent e5ba650fda
commit ed2e35a24c
8 changed files with 78 additions and 46 deletions

View File

@ -388,7 +388,9 @@ endp
align 4
proc reg_service stdcall, name:dword, handler:dword
xor eax, eax
push ebx
xor eax, eax
cmp [name], eax
je .fail
@ -396,14 +398,11 @@ proc reg_service stdcall, name:dword, handler:dword
cmp [handler], eax
je .fail
push ebx
mov eax, SRV_SIZE
call malloc ;call alloc_service
pop ebx
test eax, eax
jz .fail
push ebx
push esi
push edi
mov edi, eax
@ -429,6 +428,7 @@ proc reg_service stdcall, name:dword, handler:dword
ret
.fail:
xor eax, eax
pop ebx
ret
endp

View File

@ -121,7 +121,7 @@ kernel_export:
dd szUserFree , user_free ;stdcall
dd szKmalloc , malloc
dd szKfree , free
dd szCreateRingBuffer, create_ring_buffer
dd szCreateRingBuffer, create_ring_buffer ;stdcall
dd szGetPid , get_pid
dd szCreateObject , create_kernel_object

View File

@ -164,7 +164,7 @@ endp
; ebx= descriptor index
align 4
get_block:
get_small_block:
mov ecx, eax
shr ecx, 12
dec ecx
@ -211,7 +211,7 @@ get_block:
ret
align 4
proc alloc_mem_block
alloc_mem_block:
mov ebx, [mem_block_start]
mov ecx, [mem_block_end]
@ -233,9 +233,8 @@ found:
add eax, [mem_block_arr]
dec [free_blocks]
ret
endp
proc free_mem_block
align 4
free_mem_block:
mov dword [eax], 0
mov dword [eax+4], 0
mov dword [eax+8], 0
@ -263,7 +262,6 @@ proc free_mem_block
.err:
xor eax, eax
ret
endp
align 4
proc alloc_kernel_space stdcall, size:dword
@ -284,7 +282,7 @@ proc alloc_kernel_space stdcall, size:dword
cmp eax, [heap_free]
ja .error
call get_block ; eax
call get_small_block ; eax
test edi, edi
jz .error

View File

@ -126,12 +126,12 @@ proc free_page
;arg: eax page address
pushfd
cli
shr eax, 12 ;page index
bts dword [sys_pgmap], eax ;that's all!
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
and eax, not 3 ;dword offset from page_map
add eax, sys_pgmap
cmp [page_start], eax
ja @f
@ -166,7 +166,9 @@ proc map_io_mem stdcall, base:dword, size:dword, flags:dword
or edx, [flags]
@@:
mov [page_tabs+eax*4], edx
invlpg [ebx]
; push eax
; invlpg [ebx]
; pop eax
inc eax
add ebx, edi
add edx, edi
@ -184,7 +186,7 @@ endp
; param
; eax= page base + page flags
; ebx= liear address
; ebx= linear address
; ecx= count
align 4
@ -202,7 +204,9 @@ commit_pages:
shr ebx, 12
@@:
mov [page_tabs+ebx*4], eax
invlpg [edi]
; push eax
; invlpg [edi]
; pop eax
add edi, edx
add eax, edx
inc ebx
@ -263,6 +267,32 @@ release_pages:
popad
ret
; param
; eax= base
; ecx= count
align 4
unmap_pages:
push edi
mov edi, eax
mov edx, eax
shr edi, 10
add edi, page_tabs
xor eax, eax
@@:
stosd
invlpg [edx]
add edx, 0x1000
loop @b
pop edi
ret
align 4
proc map_page_table stdcall, lin_addr:dword, phis_addr:dword
push ebx
@ -1085,6 +1115,27 @@ new_services:
mov [esp+36], eax
ret
align 4
proc load_pe_driver stdcall, file:dword
stdcall load_PE, [file]
test eax, eax
jz .fail
mov esi, eax
stdcall eax, DRV_ENTRY
test eax, eax
jz .fail
mov [eax+SRV.entry], esi
ret
.fail:
xor eax, eax
ret
endp
align 4
proc init_mtrr
@ -1159,8 +1210,6 @@ proc set_mtrr stdcall, reg:dword,base:dword,size:dword,mem_type:dword
ret
endp
align 4
proc stall stdcall, delay:dword
push ecx
@ -1228,8 +1277,6 @@ proc create_ring_buffer stdcall, size:dword, flags:dword
@@:
mov [page_tabs+edi], eax
mov [page_tabs+edi+edx], eax
invlpg [ebx]
invlpg [ebx+esi]
add eax, 0x1000
add ebx, 0x1000
add edi, 4
@ -1248,14 +1295,4 @@ proc create_ring_buffer stdcall, size:dword, flags:dword
ret
endp
if 0
push eax
push edx
mov edx, 0x400 ;bochs
mov al,0xff ;bochs
out dx, al ;bochs
pop edx
pop eax
end if

View File

@ -280,7 +280,9 @@ L40:
__exports:
export 'KERNEL', \
alloc_kernel_space, 'AllocKernelSpace', \ ; stdcall
commit_pages, 'CommitPages', \ ; eax, ebx, ecx
create_kernel_object, 'CreateObject', \
create_ring_buffer, 'CreateRingBuffer', \ ; stdcall
destroy_kernel_object, 'DestroyObject', \
free_kernel_space, 'FreeKernelSpace', \ ; stdcall
kernel_alloc, 'KernelAlloc', \ ; stdcall
@ -288,6 +290,7 @@ __exports:
malloc, 'Kmalloc', \
free, 'Kfree', \
map_io_mem, 'MapIoMem', \ ; stdcall
get_pg_addr, 'GetPgAddr', \ ; eax
\
select_hw_cursor, 'SelectHwCursor', \ ; stdcall
set_hw_cursor, 'SetHwCursor', \ ; stdcall
@ -303,9 +306,10 @@ __exports:
pci_write16, 'PciWrite16', \ ; stdcall
pci_write32, 'PciWrite32', \ ; stdcall
\
reg_service, 'RegService', \
reg_service, 'RegService', \ ; stdcall
user_alloc, 'UserAlloc', \ ; stdcall
user_free, 'UserFree', \ ; stdcall
unmap_pages, 'UnmapPages', \ ; eax, ecx
sys_msg_board_str, 'SysMsgBoardStr'

View File

@ -212,8 +212,7 @@ else
jna @F
xor eax, eax
; add edi, new_app_base
cld
cld
rep stosb
@@:
end if
@ -453,12 +452,7 @@ proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword
if GREEDY_KERNEL
mov eax, 0x02
.reserve:
stosd
invlpg [edx]
add edx, 4096
dec ecx
jnz .reserve
rep stosd
else
.alloc:
@ -507,6 +501,8 @@ proc destroy_page_table stdcall, pg_tab:dword
mov eax, [esi]
test eax, 1
jz .next
test eax, 1 shl 9
jnz .next ;skip shared pages
call free_page
.next:
add esi, 4
@ -576,9 +572,8 @@ endp
align 4
get_pid:
;mov eax, [TASK_DATA] ; I think it's the bug. (Rus)
mov eax, [TASK_BASE]
mov eax, [eax+4]
mov eax, [eax+TASKDATA.pid]
ret
pid_to_slot:

View File

@ -178,7 +178,7 @@ macro OUT_PACKET0 reg, count
inc edx
}
macro OUT_PACKET3 pkt, count \
macro OUT_PACKET3 pkt, count
{
mov eax, (RADEON_CP_PACKET3 or pkt or (count shl 16))
mov [edi+edx*4], eax

View File

@ -468,8 +468,6 @@ proc init_cursors
.init:
mov [cur_def_interl], ebx
; stdcall load_pe_driver, szAtiHW
stdcall load_driver, szHwMouse
mov [hw_cursor], eax
test eax, eax