replace old kernel_free with mem_free

git-svn-id: svn://kolibrios.org@887 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-10-27 23:38:33 +00:00
parent bc6cebbf4b
commit 3f22b06b9f
14 changed files with 296 additions and 309 deletions

View File

@ -558,7 +558,7 @@ endp
; ebx= size of file ; ebx= size of file
; ;
; warging ; warging
; You mast call kernel_free() to delete each file ; You mast call mem_free() to delete each file
; loaded by the load_file() function ; loaded by the load_file() function
align 4 align 4
@ -636,7 +636,8 @@ proc load_file stdcall, file_name:dword
pop esi pop esi
ret ret
.cleanup: .cleanup:
stdcall kernel_free, [file] mov ecx, [file]
call @mem_free@4
.fail: .fail:
xor eax, eax xor eax, eax
xor ebx, ebx xor ebx, ebx
@ -826,12 +827,10 @@ proc load_driver stdcall, driver_name:dword
mov dword [edi], '.obj' mov dword [edi], '.obj'
mov byte [edi+4], 0 mov byte [edi+4], 0
stdcall load_file, edx stdcall load_file, edx
mov [coff], eax
test eax, eax test eax, eax
jz .exit jz .exit
mov [coff], eax
movzx ebx, [eax+CFH.nSections] movzx ebx, [eax+CFH.nSections]
lea edx, [eax+20] lea edx, [eax+20]
xor ecx, ecx xor ecx, ecx
@ -847,6 +846,7 @@ proc load_driver stdcall, driver_name:dword
mov edx, PG_SW mov edx, PG_SW
call @mem_alloc@8 call @mem_alloc@8
test eax, eax test eax, eax
mov [img_base], eax
jz .fail jz .fail
mov [img_base], eax mov [img_base], eax
@ -923,14 +923,16 @@ proc load_driver stdcall, driver_name:dword
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szSTART stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szSTART
mov [start], eax mov [start], eax
stdcall kernel_free, [coff] mov ecx, [coff]
call @mem_free@4
mov ebx, [start] mov ebx, [start]
stdcall ebx, DRV_ENTRY stdcall ebx, DRV_ENTRY
test eax, eax test eax, eax
jnz .ok jnz .ok
stdcall kernel_free, [img_base] mov ecx, [img_base]
call @mem_free@4
xor eax, eax xor eax, eax
ret ret
.ok: .ok:
@ -961,9 +963,11 @@ proc load_driver stdcall, driver_name:dword
mov esi, msg_CR mov esi, msg_CR
call sys_msg_board_str call sys_msg_board_str
.cleanup: .cleanup:
stdcall kernel_free,[img_base] mov ecx, [img_base]
call @mem_free@4
.fail: .fail:
stdcall kernel_free, [coff] mov ecx, [coff]
call @mem_free@4
.exit: .exit:
xor eax, eax xor eax, eax
ret ret
@ -1065,7 +1069,9 @@ proc load_library stdcall, file_name:dword
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szEXPORTS stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szEXPORTS
mov [exports], eax mov [exports], eax
stdcall kernel_free, [coff] mov ecx, [coff]
call @mem_free@4
mov eax, [exports] mov eax, [exports]
ret ret
.fail: .fail:

View File

@ -41,8 +41,8 @@ iglobal
szAllocKernelSpace db 'AllocKernelSpace',0 szAllocKernelSpace db 'AllocKernelSpace',0
szFreeKernelSpace db 'FreeKernelSpace',0 szFreeKernelSpace db 'FreeKernelSpace',0
szHeapAlloc db 'HeapAlloc',0 szMemAlloc db 'MemAlloc',0
szKernelFree db 'KernelFree',0 szMemFree db 'MemFree',0
szUserAlloc db 'UserAlloc',0 szUserAlloc db 'UserAlloc',0
szUserFree db 'UserFree',0 szUserFree db 'UserFree',0
szKmalloc db 'Kmalloc',0 szKmalloc db 'Kmalloc',0
@ -112,8 +112,8 @@ kernel_export:
dd szReleasePages , release_pages dd szReleasePages , release_pages
dd szFreeKernelSpace , free_kernel_space ;stdcall dd szFreeKernelSpace , free_kernel_space ;stdcall
dd szHeapAlloc , @mem_alloc@8 ;fastcall dd szMemAlloc , @mem_alloc@8 ;fastcall
dd szKernelFree , kernel_free ;stdcall dd szMemFree , @mem_free@4 ;fastcall
dd szUserAlloc , user_alloc ;stdcall dd szUserAlloc , user_alloc ;stdcall
dd szUserFree , user_free ;stdcall dd szUserFree , user_free ;stdcall
dd szKmalloc , malloc dd szKmalloc , malloc

View File

@ -8,36 +8,12 @@
$Revision$ $Revision$
struc MEM_BLOCK
{ .next_block dd ?
.prev_block dd ? ;+4
.list_fd dd ? ;+8
.list_bk dd ? ;+12
.base dd ? ;+16
.size dd ? ;+20
.flags dd ? ;+24
.handle dd ? ;+28
}
MEM_LIST_OFFSET equ 8 MEM_LIST_OFFSET equ 8
FREE_BLOCK equ 4 FREE_BLOCK equ 4
USED_BLOCK equ 8 USED_BLOCK equ 8
DONT_FREE_BLOCK equ 10h DONT_FREE_BLOCK equ 10h
virtual at 0
MEM_BLOCK MEM_BLOCK
end virtual
MEM_BLOCK_SIZE equ 8*4
block_next equ MEM_BLOCK.next_block
block_prev equ MEM_BLOCK.prev_block
list_fd equ MEM_BLOCK.list_fd
list_bk equ MEM_BLOCK.list_bk
block_base equ MEM_BLOCK.base
block_size equ MEM_BLOCK.size
block_flags equ MEM_BLOCK.flags
align 4 align 4
proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword
@ -46,21 +22,6 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword
endp endp
align 4
proc kernel_free stdcall, base:dword
ret
endp
restore block_next
restore block_prev
restore block_list
restore block_base
restore block_size
restore block_flags
;;;;;;;;;;;;;; USER ;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;; USER ;;;;;;;;;;;;;;;;;
HEAP_TOP equ 0x5FC00000 HEAP_TOP equ 0x5FC00000

View File

@ -38,9 +38,13 @@ proc load_PE stdcall, file_name:dword
test eax, eax test eax, eax
jnz .cleanup jnz .cleanup
stdcall kernel_free, [base] mov ecx, [base]
call @mem_free@4
.cleanup: .cleanup:
stdcall kernel_free, [image] mov ecx, [image]
call @mem_free@4
mov eax, [entry] mov eax, [entry]
ret ret
.fail: .fail:
@ -284,7 +288,6 @@ __exports:
create_ring_buffer, 'CreateRingBuffer', \ ; stdcall create_ring_buffer, 'CreateRingBuffer', \ ; stdcall
destroy_kernel_object, 'DestroyObject', \ destroy_kernel_object, 'DestroyObject', \
free_kernel_space, 'FreeKernelSpace', \ ; stdcall free_kernel_space, 'FreeKernelSpace', \ ; stdcall
kernel_free, 'KernelFree', \ ; stdcall
malloc, 'Kmalloc', \ malloc, 'Kmalloc', \
free, 'Kfree', \ free, 'Kfree', \
map_io_mem, 'MapIoMem', \ ; stdcall map_io_mem, 'MapIoMem', \ ; stdcall

View File

@ -235,7 +235,8 @@ end if
call set_cr3 call set_cr3
.err: .err:
.err_hdr: .err_hdr:
stdcall kernel_free,[file_base] mov ecx, [file_base]
call @mem_free@4
.err_file: .err_file:
xor eax, eax xor eax, eax
mov [application_table_status],eax mov [application_table_status],eax

View File

@ -72,7 +72,7 @@ v86_create:
mov edi, eax mov edi, eax
add eax, 1000h add eax, 1000h
push eax push eax
call get_pg_addr sub eax, OS_BASE
or al, PG_UW or al, PG_UW
stosd stosd
; ...and also copy system page tables ; ...and also copy system page tables
@ -143,7 +143,11 @@ v86_create:
; destroys: eax, ebx, ecx, edx (due to free) ; destroys: eax, ebx, ecx, edx (due to free)
v86_destroy: v86_destroy:
push eax push eax
stdcall kernel_free, [eax+V86_machine.pagedir]
mov ecx, [eax+V86_machine.pagedir]
sub ecx, OS_BASE
call @core_free@4
pop eax pop eax
jmp free jmp free

View File

@ -44,14 +44,14 @@ kernel_export \
CommitPages,\ CommitPages,\
ReleasePages,\ ReleasePages,\
\ \
FreeKernelSpace,\ FreeKernelSpace, \
HeapAlloc,\ MemAlloc, \
KernelFree,\ MemFree, \
UserAlloc,\ UserAlloc, \
UserFree,\ UserFree, \
Kmalloc,\ Kmalloc, \
Kfree,\ Kfree, \
CreateRingBuffer,\ CreateRingBuffer, \
\ \
GetPid,\ GetPid,\
CreateObject,\ CreateObject,\

View File

@ -83,7 +83,7 @@ proc START stdcall, state:dword
mov ecx, 16*512 mov ecx, 16*512
mov edx, PG_SW mov edx, PG_SW
call HeapAlloc call MemAlloc
test eax, eax test eax, eax
jz .out_of_mem jz .out_of_mem
mov [mix_buff], eax mov [mix_buff], eax
@ -426,7 +426,7 @@ proc CreateBuffer stdcall, format:dword, size:dword
add ecx, 128 ;resampler required add ecx, 128 ;resampler required
mov [eax+STREAM.in_size], ecx mov [eax+STREAM.in_size], ecx
mov edx, PG_SW mov edx, PG_SW
call HeapAlloc call MemAlloc
mov edi, [str] mov edi, [str]
mov [edi+STREAM.in_base], eax mov [edi+STREAM.in_base], eax
@ -513,9 +513,11 @@ DestroyBuffer:
mov [ecx+STREAM.str_fd], ebx mov [ecx+STREAM.str_fd], ebx
popf popf
stdcall KernelFree, [eax+STREAM.in_base] mov ecx, [eax+STREAM.in_base]
call MemFree
mov eax, [.handle] mov eax, [.handle]
stdcall KernelFree, [eax+STREAM.out_base] mov ecx, [eax+STREAM.out_base]
call MemFree
pop eax ;restore stack pop eax ;restore stack
call DestroyObject ;eax= stream call DestroyObject ;eax= stream

View File

@ -511,7 +511,7 @@ proc create_primary_buff
mov ecx, 0x10000 mov ecx, 0x10000
mov edx, PG_SW mov edx, PG_SW
call HeapAlloc call MemAlloc
mov [ctrl.buffer], eax mov [ctrl.buffer], eax
mov edi, eax mov edi, eax

View File

@ -533,7 +533,7 @@ proc create_primary_buff
mov ecx, 0x10000 mov ecx, 0x10000
mov edx, PG_SW mov edx, PG_SW
call HeapAlloc call MemAlloc
mov [ctrl.buffer], eax mov [ctrl.buffer], eax
mov edi, eax mov edi, eax

View File

@ -168,12 +168,12 @@ ntfs_setup: ; CODE XREF: part_set.inc
@@: @@:
; $MFT and $MFTMirr invalid! ; $MFT and $MFTMirr invalid!
.fail_free_frs: .fail_free_frs:
push [ntfs_data.frs_buffer] mov ecx, [ntfs_data.frs_buffer]
call kernel_free call @mem_free@4
jmp problem_fat_dec_count jmp problem_fat_dec_count
.fail_free_mft: .fail_free_mft:
push [ntfs_data.mft_retrieval] mov ecx, [ntfs_data.mft_retrieval]
call kernel_free call @mem_free@4
jmp .fail_free_frs jmp .fail_free_frs
.mftok: .mftok:
; read $MFT table retrieval information ; read $MFT table retrieval information
@ -259,9 +259,9 @@ ntfs_setup: ; CODE XREF: part_set.inc
mov ecx, [ntfs_data.mft_retrieval_size] mov ecx, [ntfs_data.mft_retrieval_size]
add ecx, ecx add ecx, ecx
rep movsd rep movsd
push [ntfs_data.mft_retrieval] mov ecx, [ntfs_data.mft_retrieval]
mov [ntfs_data.mft_retrieval], eax mov [ntfs_data.mft_retrieval], eax
call kernel_free call @mem_free@4
mov eax, [ntfs_data.mft_retrieval_size] mov eax, [ntfs_data.mft_retrieval_size]
.ok: .ok:
shl eax, 3 shl eax, 3
@ -980,8 +980,8 @@ ntfs_find_lfn:
@@: @@:
; reallocate ; reallocate
push eax push eax
push [ntfs_data.cur_index_buf] mov ecx, [ntfs_data.cur_index_buf]
call kernel_free call @mem_free@4
pop ecx pop ecx
mov [ntfs_data.cur_index_size], ecx mov [ntfs_data.cur_index_size], ecx
mov edx, PG_SW mov edx, PG_SW
@ -1013,10 +1013,10 @@ ntfs_find_lfn:
rep movsd rep movsd
mov esi, eax mov esi, eax
mov [ntfs_data.cur_index_size], ebp mov [ntfs_data.cur_index_size], ebp
push esi ebp
push [ntfs_data.cur_index_buf] mov ecx, [ntfs_data.cur_index_buf]
call kernel_free call @mem_free@4
pop ebp esi
mov [ntfs_data.cur_index_buf], esi mov [ntfs_data.cur_index_buf], esi
.ok2: .ok2:
add esi, 10h add esi, 10h
@ -1327,8 +1327,8 @@ ntfs_HdReadFolder:
@@: @@:
; reallocate ; reallocate
push eax push eax
push [ntfs_data.cur_index_buf] mov ecx, [ntfs_data.cur_index_buf]
call kernel_free call @mem_free@4
pop ecx pop ecx
mov [ntfs_data.cur_index_size], ecx mov [ntfs_data.cur_index_size], ecx
mov edx, PG_SW mov edx, PG_SW
@ -1365,10 +1365,10 @@ ntfs_HdReadFolder:
rep movsd rep movsd
mov esi, eax mov esi, eax
mov [ntfs_data.cur_index_size], ebp mov [ntfs_data.cur_index_size], ebp
push esi ebp
push [ntfs_data.cur_index_buf] mov ecx, [ntfs_data.cur_index_buf]
call kernel_free call @mem_free@4
pop ebp esi
mov [ntfs_data.cur_index_buf], esi mov [ntfs_data.cur_index_buf], esi
.ok2: .ok2:
add esi, 10h add esi, 10h

View File

@ -27,7 +27,9 @@ read_skin_file:
mov esi, eax mov esi, eax
mov edi, skin_data mov edi, skin_data
rep movsd rep movsd
stdcall kernel_free, eax
mov ecx, eax
call @mem_free@4
call parse_skin_data call parse_skin_data
xor eax, eax xor eax, eax
@ -37,9 +39,10 @@ read_skin_file:
inc eax inc eax
ret ret
.noskin: .noskin:
stdcall kernel_free, eax mov ecx, eax
push 2 call @mem_free@4
pop eax
mov eax, 2
ret ret
struct SKIN_HEADER struct SKIN_HEADER

View File

@ -142,6 +142,7 @@ extrn _init
extrn _init_mm extrn _init_mm
extrn @core_alloc@4 extrn @core_alloc@4
extrn @core_free@4
extrn @init_heap@8 extrn @init_heap@8
extrn @find_large_md@4 extrn @find_large_md@4
@ -2280,7 +2281,10 @@ sys_background:
pushad pushad
; return memory for old background ; return memory for old background
stdcall kernel_free, [img_background]
mov ecx, [img_background]
call @mem_free@4
; calculate RAW size ; calculate RAW size
xor eax,eax xor eax,eax
inc eax inc eax

View File

@ -366,8 +366,8 @@ proc load_cursor stdcall, src:dword, flags:dword
stdcall load_file, [src] stdcall load_file, [src]
test eax, eax test eax, eax
jz .fail
mov [src], eax mov [src], eax
jz .fail
@@: @@:
push ebx push ebx
push esi push esi
@ -383,7 +383,9 @@ proc load_cursor stdcall, src:dword, flags:dword
cmp word [flags], LOAD_FROM_FILE cmp word [flags], LOAD_FROM_FILE
jne .exit jne .exit
stdcall kernel_free, [src]
mov ecx, [src]
call @mem_free@4
.exit: .exit:
pop edi pop edi
pop esi pop esi
@ -436,7 +438,8 @@ align 4
destroy_cursor: destroy_cursor:
push eax push eax
stdcall kernel_free, [eax+CURSOR.base] mov ecx, [eax+CURSOR.base]
call @mem_free@4
pop eax pop eax
call destroy_kernel_object call destroy_kernel_object