new 68.26 user_unmap(void* block_base, unsigned int offset, size_t unmap_size);

git-svn-id: svn://kolibrios.org@2400 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2012-02-24 21:47:01 +00:00
parent ce623ccaec
commit 8c4037718d
2 changed files with 73 additions and 2 deletions

View File

@ -848,6 +848,71 @@ proc user_free stdcall, base:dword
ret ret
endp endp
align 4
proc user_unmap stdcall, base:dword, offset:dword, size:dword
push ebx
mov ebx, [base] ; must be valid pointer
test ebx, ebx
jz .error
mov edx, [offset] ; check offset
add edx, ebx ; must be below 2Gb app limit
js .error
shr ebx, 12 ; chek block attributes
lea ebx, [page_tabs+ebx*4]
mov eax, [ebx-4] ; block attributes
test al, USED_BLOCK
jz .error
test al, DONT_FREE_BLOCK
jnz .error
shr edx, 12
lea edx, [page_tabs+edx*4] ; unmap offset
mov ecx, [size]
add ecx, 4095
shr ecx, 12 ; unmap size in pages
shr eax, 12 ; block size + 1 page
lea ebx, [ebx+eax*4-4] ; block end ptr
lea eax, [edx+ecx*4] ; unmap end ptr
cmp eax, ebx ; check for overflow
ja .error
mov ebx, [offset]
and ebx, not 4095 ; is it required ?
.unmap:
mov eax, [edx] ; get page addres
test al, 1 ; page mapped ?
jz @F
test eax, PG_SHARED ; page shared ?
jnz @F
mov [page_tabs+edx*4], dword 2
; mark page as reserved
invlpg [ebx] ; when we start using
call free_page ; empty c-o-w page instead this ?
@@:
add ebx, 4096
add edx, 4
dec ecx
jnz .unmap
pop ebx
or al, 1 ; return non zero on success
ret
.error:
pop ebx
xor eax, eax ; something wrong
ret
endp
align 4
user_normalize: user_normalize:
; in: esi=heap_base, edi=heap_top ; in: esi=heap_base, edi=heap_top
; out: eax=0 <=> OK ; out: eax=0 <=> OK

View File

@ -1307,6 +1307,11 @@ f68:
@@: @@:
ret ret
.26:
stdcall user_unmap, ecx, edx, esi
mov [esp+32], eax
ret
.fail: .fail:
xor eax, eax xor eax, eax
mov [esp+32], eax mov [esp+32], eax
@ -1329,8 +1334,9 @@ f68call: ; keep this table closer to main code
dd f68.21 ; load_driver dd f68.21 ; load_driver
dd f68.22 ; shmem_open dd f68.22 ; shmem_open
dd f68.23 ; shmem_close dd f68.23 ; shmem_close
dd f68.24 dd f68.24 ; set exception handler
dd f68.25 dd f68.25 ; unmask exception
dd f68.26 ; user_unmap
align 4 align 4