replace old alloc_kernel_space and kernel_alloc with mem_alloc

git-svn-id: svn://kolibrios.org@864 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-09-15 15:25:03 +00:00
parent 0e79d8c724
commit 6cb566cf5e
23 changed files with 243 additions and 301 deletions

View File

@ -4,7 +4,7 @@ format MS COFF
include '../macros.inc' include '../macros.inc'
$Revision: 849 $ $Revision$
__REV__ = __REV __REV__ = __REV

View File

@ -585,12 +585,15 @@ proc load_file stdcall, file_name:dword
test eax, eax test eax, eax
jnz .fail jnz .fail
mov eax, [file_size] mov ecx, [file_size]
cmp eax, 1024*1024*16 cmp ecx, 1024*1024*16
ja .fail ja .fail
stdcall kernel_alloc, [file_size] mov edx, PG_SW
call @mem_alloc@8
mov [file], eax mov [file], eax
test eax, eax
jz .fail
stdcall read_file, [file_name], eax, dword 0, [file_size] stdcall read_file, [file_name], eax, dword 0, [file_size]
cmp ebx, [file_size] cmp ebx, [file_size]
@ -599,10 +602,11 @@ proc load_file stdcall, file_name:dword
mov eax, [file] mov eax, [file]
cmp dword [eax], 0x4B43504B cmp dword [eax], 0x4B43504B
jne .exit jne .exit
mov ebx, [eax+4]
mov [file_size], ebx
stdcall kernel_alloc, ebx
mov ecx, [eax+4]
mov [file_size], ecx
mov edx, PG_SW
call @mem_alloc@8
test eax, eax test eax, eax
jz .cleanup jz .cleanup
@ -824,20 +828,20 @@ proc load_driver stdcall, driver_name:dword
mov [coff], eax mov [coff], eax
movzx ecx, [eax+CFH.nSections] movzx ebx, [eax+CFH.nSections]
xor ebx, ebx
lea edx, [eax+20] lea edx, [eax+20]
xor ecx, ecx
@@: @@:
add ebx, [edx+CFS.SizeOfRawData] add ecx, [edx+CFS.SizeOfRawData]
add ebx, 15 add ecx, 15
and ebx, not 15 and ecx, not 15
add edx, COFF_SECTION_SIZE add edx, COFF_SECTION_SIZE
dec ecx dec ebx
jnz @B jnz @B
mov [img_size], ebx
stdcall kernel_alloc, ebx mov [img_size], ecx
mov edx, PG_SW
call @mem_alloc@8
test eax, eax test eax, eax
jz .fail jz .fail
mov [img_base], eax mov [img_base], eax

View File

@ -31,7 +31,6 @@ iglobal
szPciWrite32 db 'PciWrite32',0 szPciWrite32 db 'PciWrite32',0
szAllocPage db 'AllocPage',0 szAllocPage db 'AllocPage',0
szAllocPages db 'AllocPages',0
szFreePage db 'FreePage',0 szFreePage db 'FreePage',0
szGetPgAddr db 'GetPgAddr',0 szGetPgAddr db 'GetPgAddr',0
szMapPage db 'MapPage',0 szMapPage db 'MapPage',0
@ -42,7 +41,7 @@ iglobal
szAllocKernelSpace db 'AllocKernelSpace',0 szAllocKernelSpace db 'AllocKernelSpace',0
szFreeKernelSpace db 'FreeKernelSpace',0 szFreeKernelSpace db 'FreeKernelSpace',0
szKernelAlloc db 'KernelAlloc',0 szHeapAlloc db 'HeapAlloc',0
szKernelFree db 'KernelFree',0 szKernelFree db 'KernelFree',0
szUserAlloc db 'UserAlloc',0 szUserAlloc db 'UserAlloc',0
szUserFree db 'UserFree',0 szUserFree db 'UserFree',0
@ -104,7 +103,6 @@ kernel_export:
dd szPciWrite32 , pci_write32 dd szPciWrite32 , pci_write32
dd szAllocPage , _alloc_page ;stdcall dd szAllocPage , _alloc_page ;stdcall
dd szAllocPages , _alloc_pages ;stdcall
dd szFreePage , free_page dd szFreePage , free_page
dd szMapPage , map_page ;stdcall dd szMapPage , map_page ;stdcall
dd szMapSpace , map_space dd szMapSpace , map_space
@ -113,9 +111,8 @@ kernel_export:
dd szCommitPages , commit_pages ;not implemented dd szCommitPages , commit_pages ;not implemented
dd szReleasePages , release_pages dd szReleasePages , release_pages
dd szAllocKernelSpace, alloc_kernel_space ;stdcall
dd szFreeKernelSpace , free_kernel_space ;stdcall dd szFreeKernelSpace , free_kernel_space ;stdcall
dd szKernelAlloc , kernel_alloc ;stdcall dd szHeapAlloc , @heap_alloc@8 ;fastcall
dd szKernelFree , kernel_free ;stdcall dd szKernelFree , kernel_free ;stdcall
dd szUserAlloc , user_alloc ;stdcall dd szUserAlloc , user_alloc ;stdcall
dd szUserFree , user_free ;stdcall dd szUserFree , user_free ;stdcall

View File

@ -335,10 +335,7 @@ void* __fastcall mem_alloc(size_t size, u32_t flags)
return NULL; return NULL;
}; };
void* __stdcall alloc_kernel_space(size_t size); //__asm__("alloc_kernel_space"); void * __fastcall heap_alloc(size_t size, u32_t flags)
void* __stdcall alloc_kernel_space(size_t size)
{ {
md_t *md; md_t *md;
@ -346,16 +343,36 @@ void* __stdcall alloc_kernel_space(size_t size)
md = find_small_md(size); md = find_small_md(size);
DBG("alloc_kernel_space: %x size %x\n\n",md->base, size);
if( md ) if( md )
return (void*)md->base; {
return NULL; if( flags & PG_MAP )
} {
count_t tmp = size >> 12;
addr_t *pte = &((addr_t*)page_tabs)[md->base>>12];
while(tmp)
{
u32_t order;
addr_t frame;
size_t size;
asm volatile ("bsr %0, %1":"=&r"(order):"r"(tmp):"cc");
asm volatile ("btr %0, %1" :"=r"(tmp):"r"(order):"cc");
frame = core_alloc(order) | flags;
size = (1 << order);
while(size--)
{
*pte++ = frame;
frame+= 4096;
};
};
};
DBG("alloc_heap: %x size %x\n\n",md->base, size);
return (void*)md->base;
};
return NULL;
};
//void* __stdcall kernel_alloc(size_t size)
//{
//
// return NULL;
//}
//*/

View File

@ -45,80 +45,6 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword
ret ret
endp endp
align 4
proc kernel_alloc stdcall, size:dword
locals
lin_addr dd ?
pages_count dd ?
endl
push ebx
push edi
mov eax, [size]
add eax, 4095
and eax, not 4095;
mov [size], eax
test eax, eax
jz .err
mov ebx, eax
shr ebx, 12
mov [pages_count], ebx
stdcall alloc_kernel_space, eax
test eax, eax
jz .err
mov [lin_addr], eax
mov ecx, [pages_count]
mov edx, eax
mov ebx, ecx
shr ecx, 3
jz .next
and ebx, not 7
push ebx
stdcall _alloc_pages, ebx
pop ecx ; yes ecx!!!
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
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
jnz @B
.end:
mov eax, [lin_addr]
pop edi
pop ebx
ret
.err:
xor eax, eax
pop edi
pop ebx
ret
endp
align 4 align 4
proc kernel_free stdcall, base:dword proc kernel_free stdcall, base:dword

View File

@ -983,7 +983,9 @@ malloc_large:
align 4 align 4
init_malloc: init_malloc:
stdcall kernel_alloc, 0x40000 mov ecx, 6
call @core_alloc@4
add eax, OS_BASE
mov [mst.top], eax mov [mst.top], eax
mov [mst.topsize], 256*1024 mov [mst.topsize], 256*1024

View File

@ -37,42 +37,37 @@ free_page:
proc map_io_mem stdcall, base:dword, size:dword, flags:dword proc map_io_mem stdcall, base:dword, size:dword, flags:dword
push ebx
push edi push edi
mov eax, [size]
add eax, 4095 mov ecx, [size]
and eax, -4096 add ecx, 4095
mov [size], eax and ecx, -4096
stdcall alloc_kernel_space, eax mov [size], ecx
xor edx, edx
call @mem_alloc@8
test eax, eax test eax, eax
jz .fail jz .fail
push eax
mov edi, 0x1000 mov edx, eax
mov ebx, eax mov edi, eax
mov ecx,[size] shr edi, 10
mov edx, [base] add edi, page_tabs
shr eax, 12
mov ecx, [size]
shr ecx, 12 shr ecx, 12
and edx, -4096 mov eax, [base]
or edx, [flags] and eax, -4096
or eax, [flags]
@@: @@:
mov [page_tabs+eax*4], edx stosd
; push eax add eax, 0x1000
; invlpg [ebx]
; pop eax
inc eax
add ebx, edi
add edx, edi
loop @B loop @B
pop eax mov eax, [base]
mov edx, [base] and eax, 4095
and edx, 4095
add eax, edx add eax, edx
.fail: .fail:
pop edi pop edi
pop ebx
ret ret
endp endp
@ -194,8 +189,9 @@ proc init_LFB
cmp dword [LFBAddress], -1 cmp dword [LFBAddress], -1
jne @f jne @f
mov [BOOT_VAR+0x901c],byte 2 mov [BOOT_VAR+0x901c],byte 2
stdcall _alloc_pages, 0x280000 shr 12 mov ecx, 0x280000
add eax, OS_BASE mov edx, PG_SW
call @mem_alloc@8
mov [LFBAddress], eax mov [LFBAddress], eax
ret ret
@@: @@:
@ -477,7 +473,8 @@ align 4
test edx, PG_MAP test edx, PG_MAP
jnz @F jnz @F
call _alloc_page xor ecx, ecx
call @core_alloc@4
test eax, eax test eax, eax
jz .fail jz .fail
@ -789,11 +786,12 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
mov ecx, [ipc_tmp] mov ecx, [ipc_tmp]
cmp esi, 0x40000-0x1000 ; size of [ipc_tmp] minus one page cmp esi, 0x40000-0x1000 ; size of [ipc_tmp] minus one page
jbe @f jbe @f
push eax esi edi push eax
add esi,0x1000 lea ecx, [esi+0x1000]
stdcall alloc_kernel_space,esi xor edx, edx
call @mem_alloc@8
mov ecx, eax mov ecx, eax
pop edi esi eax pop eax
@@: @@:
mov [used_buf], ecx mov [used_buf], ecx
stdcall map_mem, ecx, [SLOT_BASE+eax+0xB8],\ stdcall map_mem, ecx, [SLOT_BASE+eax+0xB8],\
@ -820,7 +818,6 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
mov [edi+4], ecx mov [edi+4], ecx
add edi, 8 add edi, 8
mov esi, [msg_addr] mov esi, [msg_addr]
; add esi, new_app_base
cld cld
rep movsb rep movsb
@ -1154,54 +1151,50 @@ proc create_ring_buffer stdcall, size:dword, flags:dword
buf_ptr dd ? buf_ptr dd ?
endl endl
mov eax, [size] mov ecx, [size]
test ecx, 4095
jnz .fail
add ecx, ecx
xor edx, edx
call @mem_alloc@8
test eax, eax test eax, eax
jz .fail
add eax, eax
stdcall alloc_kernel_space, eax
test eax, eax
jz .fail
push ebx
mov [buf_ptr], eax mov [buf_ptr], eax
jz .fail
mov ebx, [size]
shr ebx, 12
push ebx push ebx
stdcall _alloc_pages, ebx xor ecx, ecx
pop ecx mov edx, [size]
shr edx, 12
mov ebx, edx
dec edx
bsr ecx, edx
inc ecx
call @core_alloc@4
test eax, eax test eax, eax
jz .mm_fail jz .mm_fail
push edi
or eax, [flags] or eax, [flags]
mov edi, [buf_ptr] mov edx, [buf_ptr]
mov ebx, [buf_ptr] lea ecx, [ebx*4]
mov edx, ecx shr edx, 10
shl edx, 2
shr edi, 10
@@: @@:
mov [page_tabs+edi], eax mov [page_tabs+edx], eax
mov [page_tabs+edi+edx], eax mov [page_tabs+edx+ecx], eax
add eax, 0x1000 add eax, 0x1000
add ebx, 0x1000 add edx, 4
add edi, 4 dec ebx
dec ecx
jnz @B jnz @B
mov eax, [buf_ptr] mov eax, [buf_ptr]
pop edi
pop ebx pop ebx
ret ret
.mm_fail: .mm_fail:
stdcall free_kernel_space, [buf_ptr] ;stdcall free_kernel_space, [buf_ptr]
xor eax, eax
pop ebx pop ebx
xor eax, eax
.fail: .fail:
ret ret
endp endp

View File

@ -559,7 +559,7 @@ addr_t __fastcall core_alloc(u32_t order) //export
v = zone_frame_alloc(&z_core, order); v = zone_frame_alloc(&z_core, order);
spinlock_unlock(&z_core.lock); spinlock_unlock(&z_core.lock);
safe_sti(efl); safe_sti(efl);
DBG("core alloc: %x, size %x\n", v << FRAME_WIDTH, (1<<order)<<12);
return (v << FRAME_WIDTH); return (v << FRAME_WIDTH);
}; };
@ -593,29 +593,6 @@ addr_t alloc_page() //obsolete
return (v << FRAME_WIDTH); return (v << FRAME_WIDTH);
}; };
addr_t __stdcall alloc_pages(count_t count) //obsolete
{
eflags_t efl;
u32_t edx;
pfn_t v;
count = (count+7)&~7;
edx = save_edx();
efl = safe_cli();
spinlock_lock(&z_core.lock);
v = zone_frame_alloc(&z_core, to_order(count));
spinlock_unlock(&z_core.lock);
safe_sti(efl);
DBG("alloc_pages: %x count %x\n", v << FRAME_WIDTH, count);
restore_edx(edx);
return (v << FRAME_WIDTH);
};
void __fastcall zone_free(zone_t *zone, pfn_t frame_idx) void __fastcall zone_free(zone_t *zone, pfn_t frame_idx)
{ {
frame_t *frame; frame_t *frame;

View File

@ -24,13 +24,13 @@ proc load_PE stdcall, file_name:dword
mov [image], eax mov [image], eax
mov edx, [eax+60] mov ebx, [eax+60]
mov ecx, [eax+80+edx]
stdcall kernel_alloc, [eax+80+edx] mov edx, PG_SW
call @mem_alloc@8
test eax, eax test eax, eax
jz .cleanup
mov [base], eax mov [base], eax
jz .cleanup
stdcall map_PE, eax, [image] stdcall map_PE, eax, [image]
@ -279,13 +279,11 @@ L40:
align 16 align 16
__exports: __exports:
export 'KERNEL', \ export 'KERNEL', \
alloc_kernel_space, 'AllocKernelSpace', \ ; stdcall
commit_pages, 'CommitPages', \ ; eax, ebx, ecx commit_pages, 'CommitPages', \ ; eax, ebx, ecx
create_kernel_object, 'CreateObject', \ create_kernel_object, 'CreateObject', \
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_alloc, 'KernelAlloc', \ ; stdcall
kernel_free, 'KernelFree', \ ; stdcall kernel_free, 'KernelFree', \ ; stdcall
malloc, 'Kmalloc', \ malloc, 'Kmalloc', \
free, 'Kfree', \ free, 'Kfree', \

View File

@ -955,7 +955,8 @@ proc set_app_params stdcall,slot:dword, params:dword,\
pl0_stack dd ? pl0_stack dd ?
endl endl
stdcall _alloc_pages, (RING0_STACK_SIZE+512) shr 12 mov ecx, 1 ;(RING0_STACK_SIZE+512) shr 12
call @core_alloc@4
add eax, OS_BASE add eax, OS_BASE
mov [pl0_stack], eax mov [pl0_stack], eax

View File

@ -49,10 +49,11 @@ v86_create:
; first half (0x800 bytes) is page table for addresses 0 - 0x100000, ; first half (0x800 bytes) is page table for addresses 0 - 0x100000,
; second half is for V86-to-linear translation. ; second half is for V86-to-linear translation.
; Third and fourth are for I/O permission map. ; Third and fourth are for I/O permission map.
push 8000h ; blocks less than 8 pages are discontinuous mov ecx, 2
call kernel_alloc call @core_alloc@4
test eax, eax test eax, eax
jz .fail2 jz .fail2
add eax, OS_BASE
mov [ebx+V86_machine.pagedir], eax mov [ebx+V86_machine.pagedir], eax
push edi eax push edi eax
mov edi, eax mov edi, eax

View File

@ -91,7 +91,9 @@ get_cache_ide:
and [esi+cache_ide0_search_start-cache_ide0],0 and [esi+cache_ide0_search_start-cache_ide0],0
and [esi+cache_ide0_appl_search_start-cache_ide0],0 and [esi+cache_ide0_appl_search_start-cache_ide0],0
push ecx push ecx
stdcall kernel_alloc,[esi+cache_ide0_size-cache_ide0] mov ecx, [esi+cache_ide0_size-cache_ide0]
mov edx, PG_SW
call @mem_alloc@8
mov [esi+cache_ide0_pointer-cache_ide0],eax mov [esi+cache_ide0_pointer-cache_ide0],eax
pop ecx pop ecx
mov edx,eax mov edx,eax

View File

@ -36,7 +36,6 @@ kernel_export \
PciWrite32,\ PciWrite32,\
\ \
AllocPage,\ AllocPage,\
AllocPages,\
FreePage,\ FreePage,\
MapPage,\ MapPage,\
MapSpace,\ MapSpace,\
@ -45,9 +44,8 @@ kernel_export \
CommitPages,\ CommitPages,\
ReleasePages,\ ReleasePages,\
\ \
AllocKernelSpace,\
FreeKernelSpace,\ FreeKernelSpace,\
KernelAlloc,\ HeapAlloc,\
KernelFree,\ KernelFree,\
UserAlloc,\ UserAlloc,\
UserFree,\ UserFree,\

View File

@ -81,7 +81,9 @@ proc START stdcall, state:dword
jz .fail jz .fail
mov [hSound], eax mov [hSound], eax
stdcall KernelAlloc, 16*512 mov ecx, 16*512
mov edx, PG_SW
call HeapAlloc
test eax, eax test eax, eax
jz .out_of_mem jz .out_of_mem
mov [mix_buff], eax mov [mix_buff], eax
@ -325,7 +327,6 @@ proc CreateBuffer stdcall, format:dword, size:dword
locals locals
str dd ? str dd ?
ring_size dd ? ring_size dd ?
ring_pages dd ?
endl endl
mov eax, [format] mov eax, [format]
@ -402,8 +403,6 @@ proc CreateBuffer stdcall, format:dword, size:dword
.waveout: .waveout:
mov [ring_size], ebx mov [ring_size], ebx
mov eax, ebx mov eax, ebx
shr ebx, 12
mov [ring_pages], ebx
stdcall CreateRingBuffer, eax, PG_SW stdcall CreateRingBuffer, eax, PG_SW
@ -426,7 +425,8 @@ proc CreateBuffer stdcall, format:dword, size:dword
mov ecx, [size] mov ecx, [size]
add ecx, 128 ;resampler required add ecx, 128 ;resampler required
mov [eax+STREAM.in_size], ecx mov [eax+STREAM.in_size], ecx
stdcall KernelAlloc, ecx mov edx, PG_SW
call HeapAlloc
mov edi, [str] mov edi, [str]
mov [edi+STREAM.in_base], eax mov [edi+STREAM.in_base], eax
@ -440,7 +440,7 @@ proc CreateBuffer stdcall, format:dword, size:dword
mov [edi+STREAM.in_top], eax mov [edi+STREAM.in_top], eax
.out_buff: .out_buff:
stdcall AllocKernelSpace, dword 128*1024 stdcall CreateRingBuffer, 64*1024, PG_SW
mov edi, [str] mov edi, [str]
mov [edi+STREAM.out_base], eax mov [edi+STREAM.out_base], eax
@ -450,21 +450,6 @@ proc CreateBuffer stdcall, format:dword, size:dword
add eax, 64*1024 add eax, 64*1024
mov [edi+STREAM.out_top], eax mov [edi+STREAM.out_top], eax
stdcall AllocPages, dword 64/4
mov edi, [str]
mov ebx, [edi+STREAM.out_base]
mov ecx, 16
or eax, PG_SW
push eax
push ebx
call CommitPages ;eax, ebx, ecx
mov ecx, 16
pop ebx
pop eax
add ebx, 64*1024
call CommitPages ;double mapped
mov edi, [str]
mov ecx, [edi+STREAM.in_top] mov ecx, [edi+STREAM.in_top]
mov edi, [edi+STREAM.in_base] mov edi, [edi+STREAM.in_base]
sub ecx, edi sub ecx, edi

View File

@ -32,6 +32,8 @@ end if
CPU_FREQ equ 2600d CPU_FREQ equ 2600d
PG_SW equ 0x003
BIT0 EQU 0x00000001 BIT0 EQU 0x00000001
BIT1 EQU 0x00000002 BIT1 EQU 0x00000002
BIT2 EQU 0x00000004 BIT2 EQU 0x00000004
@ -507,7 +509,9 @@ endp
align 4 align 4
proc create_primary_buff proc create_primary_buff
stdcall KernelAlloc, 0x10000 mov ecx, 0x10000
mov edx, PG_SW
call HeapAlloc
mov [ctrl.buffer], eax mov [ctrl.buffer], eax
mov edi, eax mov edi, eax

View File

@ -32,6 +32,8 @@ end if
CPU_FREQ equ 2600d CPU_FREQ equ 2600d
PG_SW equ 0x003
BIT0 EQU 0x00000001 BIT0 EQU 0x00000001
BIT1 EQU 0x00000002 BIT1 EQU 0x00000002
BIT2 EQU 0x00000004 BIT2 EQU 0x00000004
@ -529,7 +531,9 @@ endp
align 4 align 4
proc create_primary_buff proc create_primary_buff
stdcall KernelAlloc, 0x10000 mov ecx, 0x10000
mov edx, PG_SW
call HeapAlloc
mov [ctrl.buffer], eax mov [ctrl.buffer], eax
mov edi, eax mov edi, eax

View File

@ -133,14 +133,15 @@ ntfs_setup: ; CODE XREF: part_set.inc
mov eax, 1 mov eax, 1
shl eax, cl shl eax, cl
.4: .4:
mov ecx, [ntfs_data.frs_size]
mov [ntfs_data.iab_size], eax mov [ntfs_data.iab_size], eax
; allocate space for buffers ; allocate space for buffers
add eax, [ntfs_data.frs_size] add ecx, eax
push eax mov edx, PG_SW
call kernel_alloc call @mem_alloc@8
test eax, eax test eax, eax
jz problem_fat_dec_count
mov [ntfs_data.frs_buffer], eax mov [ntfs_data.frs_buffer], eax
jz problem_fat_dec_count
add eax, [ntfs_data.frs_size] add eax, [ntfs_data.frs_size]
mov [ntfs_data.iab_buffer], eax mov [ntfs_data.iab_buffer], eax
; read $MFT disposition ; read $MFT disposition
@ -177,10 +178,9 @@ ntfs_setup: ; CODE XREF: part_set.inc
.mftok: .mftok:
; read $MFT table retrieval information ; read $MFT table retrieval information
; start with one page, increase if not enough (when MFT too fragmented) ; start with one page, increase if not enough (when MFT too fragmented)
push ebx mov ecx, 0x1000
push 0x1000 mov edx, PG_SW
call kernel_alloc call @mem_alloc@8
pop ebx
test eax, eax test eax, eax
jz .fail_free_frs jz .fail_free_frs
mov [ntfs_data.mft_retrieval], eax mov [ntfs_data.mft_retrieval], eax
@ -225,11 +225,12 @@ ntfs_setup: ; CODE XREF: part_set.inc
; if they will be needed, they will be loaded later ; if they will be needed, they will be loaded later
mov [ntfs_data.cur_index_size], 0x1000/0x200 mov [ntfs_data.cur_index_size], 0x1000/0x200
push 0x1000 mov ecx, 0x1000
call kernel_alloc mov edx, PG_SW
call @mem_alloc@8
test eax, eax test eax, eax
jz .fail_free_mft
mov [ntfs_data.cur_index_buf], eax mov [ntfs_data.cur_index_buf], eax
jz .fail_free_mft
popad popad
call free_hd_channel call free_hd_channel
@ -241,11 +242,12 @@ ntfs_setup: ; CODE XREF: part_set.inc
mov eax, [ntfs_data.mft_retrieval_size] mov eax, [ntfs_data.mft_retrieval_size]
cmp eax, [ntfs_data.mft_retrieval_alloc] cmp eax, [ntfs_data.mft_retrieval_alloc]
jnz .ok jnz .ok
add eax, 0x1000/8
mov [ntfs_data.mft_retrieval_alloc], eax lea ecx, [eax+0x1000/8]
shl eax, 3 mov [ntfs_data.mft_retrieval_alloc], ecx
push eax shl ecx, 3
call kernel_alloc mov edx, PG_SW
call @mem_alloc@8
test eax, eax test eax, eax
jnz @f jnz @f
popad popad
@ -980,10 +982,10 @@ ntfs_find_lfn:
push eax push eax
push [ntfs_data.cur_index_buf] push [ntfs_data.cur_index_buf]
call kernel_free call kernel_free
pop eax pop ecx
mov [ntfs_data.cur_index_size], eax mov [ntfs_data.cur_index_size], ecx
push eax mov edx, PG_SW
call kernel_alloc call @mem_alloc@8
test eax, eax test eax, eax
jnz @f jnz @f
and [ntfs_data.cur_index_size], 0 and [ntfs_data.cur_index_size], 0
@ -998,12 +1000,13 @@ ntfs_find_lfn:
shr ebp, 9 shr ebp, 9
cmp ebp, [ntfs_data.cur_index_size] cmp ebp, [ntfs_data.cur_index_size]
jbe .ok2 jbe .ok2
push esi ebp
push ebp mov ecx, ebp
call kernel_alloc mov edx, PG_SW
pop ebp esi call @mem_alloc@8
test eax, eax test eax, eax
jz .stc_ret jz .stc_ret
mov edi, eax mov edi, eax
mov ecx, [ntfs_data.cur_index_size] mov ecx, [ntfs_data.cur_index_size]
shl ecx, 9-2 shl ecx, 9-2
@ -1326,10 +1329,10 @@ ntfs_HdReadFolder:
push eax push eax
push [ntfs_data.cur_index_buf] push [ntfs_data.cur_index_buf]
call kernel_free call kernel_free
pop eax pop ecx
mov [ntfs_data.cur_index_size], eax mov [ntfs_data.cur_index_size], ecx
push eax mov edx, PG_SW
call kernel_alloc call @mem_alloc@8
test eax, eax test eax, eax
jnz @f jnz @f
and [ntfs_data.cur_index_size], 0 and [ntfs_data.cur_index_size], 0
@ -1349,12 +1352,13 @@ ntfs_HdReadFolder:
shr ebp, 9 shr ebp, 9
cmp ebp, [ntfs_data.cur_index_size] cmp ebp, [ntfs_data.cur_index_size]
jbe .ok2 jbe .ok2
push esi ebp
push ebp mov ecx, ebp
call kernel_alloc mov edx, PG_SW
pop ebp esi call @mem_alloc@8
test eax, eax test eax, eax
jz .nomem jz .nomem
mov edi, eax mov edi, eax
mov ecx, [ntfs_data.cur_index_size] mov ecx, [ntfs_data.cur_index_size]
shl ecx, 9-2 shl ecx, 9-2

View File

@ -84,7 +84,10 @@ endl
endp endp
proc load_file_parse_table proc load_file_parse_table
stdcall kernel_alloc,0x1000
xor eac, ecx
call @core_alloc@4
add eax, OS_BASE
mov [tmp_file_name_table],eax mov [tmp_file_name_table],eax
mov edi,eax mov edi,eax
mov esi,sysdir_name mov esi,sysdir_name

View File

@ -10,7 +10,11 @@ $Revision$
align 4 align 4
init_events: init_events:
stdcall kernel_alloc, 512*EVENT_SIZE
mov ecx, 512*EVENT_SIZE
mov edx, PG_SW
call @mem_alloc@8
mov [events], eax mov [events], eax
xor eax, eax xor eax, eax
mov [event_uid], eax mov [event_uid], eax

View File

@ -29,14 +29,18 @@ typedef struct
}phismem_t; }phismem_t;
# define PA2KA(x) (((addr_t) (x)) + OS_BASE) #define PG_MAP 1
# define KA2PA(x) (((addr_t) (x)) - OS_BASE)
#define PAGE_SIZE 4096 #define PAGE_SIZE 4096
#define FRAME_WIDTH 12 #define FRAME_WIDTH 12
#define BUDDY_SYSTEM_INNER_BLOCK 0xff #define BUDDY_SYSTEM_INNER_BLOCK 0xff
# define PA2KA(x) (((addr_t) (x)) + OS_BASE)
# define KA2PA(x) (((addr_t) (x)) - OS_BASE)
static inline count_t SIZE2FRAMES(size_t size) static inline count_t SIZE2FRAMES(size_t size)
{ {
if (!size) if (!size)
@ -66,3 +70,5 @@ void frame_free(pfn_t frame);
void __fastcall frame_set_parent(pfn_t pfn, void *data); void __fastcall frame_set_parent(pfn_t pfn, void *data);
void* __fastcall frame_get_parent(pfn_t pfn); void* __fastcall frame_get_parent(pfn_t pfn);
void* __fastcall heap_alloc(size_t size, u32_t flags) ;

View File

@ -141,24 +141,27 @@ extrn _poweroff
extrn _init extrn _init
extrn _init_mm extrn _init_mm
extrn @core_alloc@4
extrn @init_heap@8 extrn @init_heap@8
extrn @find_large_md@4 extrn @find_large_md@4
extrn @find_small_md@4 extrn @find_small_md@4
extrn @phis_alloc@4 extrn @phis_alloc@4
extrn @mem_alloc@8 extrn @mem_alloc@8
extrn _alloc_kernel_space@4 extrn @heap_alloc@8
extrn _slab_cache_init extrn _slab_cache_init
extrn _alloc_pages
extrn _alloc_page extrn _alloc_page
extrn _get_free_mem extrn _get_free_mem
alloc_kernel_space equ _alloc_kernel_space@4
extrn _bx_from_load extrn _bx_from_load
@mem_alloc@8 equ @heap_alloc@8
section '.flat' code readable align 4096 section '.flat' code readable align 4096
use32 use32
@ -555,7 +558,9 @@ __setvars:
call init_fpu call init_fpu
call init_malloc call init_malloc
stdcall alloc_kernel_space, 0x51000 mov ecx, 0x51000
xor edx, edx
call @mem_alloc@8
mov [default_io_map], eax mov [default_io_map], eax
add eax, 0x2000 add eax, 0x2000
@ -611,8 +616,10 @@ __setvars:
mov [BgrDrawMode],eax mov [BgrDrawMode],eax
mov [BgrDataWidth],eax mov [BgrDataWidth],eax
mov [BgrDataHeight],eax mov [BgrDataHeight],eax
mov ecx, 4095
mov edx, PG_SW
mov [mem_BACKGROUND],4095 mov [mem_BACKGROUND],4095
stdcall kernel_alloc, [mem_BACKGROUND] call @mem_alloc@8
mov [img_background], eax mov [img_background], eax
mov [SLOT_BASE + 256 + APPDATA.dir_table], _sys_pdbr + (0x100000000-OS_BASE) mov [SLOT_BASE + 256 + APPDATA.dir_table], _sys_pdbr + (0x100000000-OS_BASE)
@ -2290,10 +2297,11 @@ sys_background:
@@: @@:
mov eax,[BgrDataWidth] mov eax,[BgrDataWidth]
imul eax,[BgrDataHeight] imul eax,[BgrDataHeight]
lea eax,[eax*3] lea ecx,[eax*3]
mov [mem_BACKGROUND],eax mov [mem_BACKGROUND],ecx
; get memory for new background ; get memory for new background
stdcall kernel_alloc, eax mov edx, PG_SW
stdcall @mem_alloc@8
test eax, eax test eax, eax
jz .exit_mem jz .exit_mem
mov [img_background], eax mov [img_background], eax

View File

@ -11,12 +11,19 @@ LDFLAGS = -shared -s -Map kernel.map --image-base 0x100000 --file-alignment 32
KERNEL_SRC:= \ KERNEL_SRC:= \
kernel.asm \ kernel.asm \
data32.inc \
core/memory.inc \ core/memory.inc \
core/heap.inc \ core/heap.inc \
core/malloc.inc \
core/taskman.inc \ core/taskman.inc \
core/v86.inc \
core/sys32.inc \ core/sys32.inc \
core/dll.inc \ core/dll.inc \
data32.inc core/exports.inc \
fs/ntfs.inc \
gui/event.inc \
video/cursors.inc
PE_SRC:= \ PE_SRC:= \
init.c \ init.c \

View File

@ -313,12 +313,13 @@ vesa_cursor:
mov [eax+CURSOR.hot_x], ebx mov [eax+CURSOR.hot_x], ebx
mov [eax+CURSOR.hot_y], ebx mov [eax+CURSOR.hot_y], ebx
stdcall kernel_alloc, 0x1000 mov edi, eax
mov ecx, 0x1000
mov edx, PG_SW
call @mem_alloc@8
test eax, eax test eax, eax
jz .fail
mov edi, [.hcursor]
mov [edi+CURSOR.base], eax mov [edi+CURSOR.base], eax
jz .fail
mov esi, [.src] mov esi, [.src]
mov ebx, [.flags] mov ebx, [.flags]