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'
$Revision: 849 $
$Revision$
__REV__ = __REV

View File

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

View File

@ -31,7 +31,6 @@ iglobal
szPciWrite32 db 'PciWrite32',0
szAllocPage db 'AllocPage',0
szAllocPages db 'AllocPages',0
szFreePage db 'FreePage',0
szGetPgAddr db 'GetPgAddr',0
szMapPage db 'MapPage',0
@ -42,7 +41,7 @@ iglobal
szAllocKernelSpace db 'AllocKernelSpace',0
szFreeKernelSpace db 'FreeKernelSpace',0
szKernelAlloc db 'KernelAlloc',0
szHeapAlloc db 'HeapAlloc',0
szKernelFree db 'KernelFree',0
szUserAlloc db 'UserAlloc',0
szUserFree db 'UserFree',0
@ -103,8 +102,7 @@ kernel_export:
dd szPciWrite16 , pci_write16
dd szPciWrite32 , pci_write32
dd szAllocPage , _alloc_page ;stdcall
dd szAllocPages , _alloc_pages ;stdcall
dd szAllocPage , _alloc_page ;stdcall
dd szFreePage , free_page
dd szMapPage , map_page ;stdcall
dd szMapSpace , map_space
@ -113,9 +111,8 @@ kernel_export:
dd szCommitPages , commit_pages ;not implemented
dd szReleasePages , release_pages
dd szAllocKernelSpace, alloc_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 szUserAlloc , user_alloc ;stdcall
dd szUserFree , user_free ;stdcall

View File

@ -335,10 +335,7 @@ void* __fastcall mem_alloc(size_t size, u32_t flags)
return NULL;
};
void* __stdcall alloc_kernel_space(size_t size); //__asm__("alloc_kernel_space");
void* __stdcall alloc_kernel_space(size_t size)
void * __fastcall heap_alloc(size_t size, u32_t flags)
{
md_t *md;
@ -346,16 +343,36 @@ void* __stdcall alloc_kernel_space(size_t size)
md = find_small_md(size);
DBG("alloc_kernel_space: %x size %x\n\n",md->base, size);
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
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
proc kernel_free stdcall, base:dword

View File

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

View File

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

View File

@ -559,7 +559,7 @@ addr_t __fastcall core_alloc(u32_t order) //export
v = zone_frame_alloc(&z_core, order);
spinlock_unlock(&z_core.lock);
safe_sti(efl);
DBG("core alloc: %x, size %x\n", v << FRAME_WIDTH, (1<<order)<<12);
return (v << FRAME_WIDTH);
};
@ -593,29 +593,6 @@ addr_t alloc_page() //obsolete
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)
{
frame_t *frame;

View File

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

View File

@ -955,7 +955,8 @@ proc set_app_params stdcall,slot:dword, params:dword,\
pl0_stack dd ?
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
mov [pl0_stack], eax

View File

@ -49,10 +49,11 @@ v86_create:
; first half (0x800 bytes) is page table for addresses 0 - 0x100000,
; second half is for V86-to-linear translation.
; Third and fourth are for I/O permission map.
push 8000h ; blocks less than 8 pages are discontinuous
call kernel_alloc
mov ecx, 2
call @core_alloc@4
test eax, eax
jz .fail2
add eax, OS_BASE
mov [ebx+V86_machine.pagedir], eax
push 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_appl_search_start-cache_ide0],0
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
pop ecx
mov edx,eax
@ -199,4 +201,4 @@ end_get_cache:
; mov [cache_ide0_pointer],HD_CACHE
; mov [cache_ide0_system_data],HD_CACHE+65536
; mov [cache_ide0_system_sad_size],1919
popa
popa

View File

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

View File

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

View File

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

View File

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

View File

@ -8,7 +8,7 @@
$Revision$
ntfs_test_bootsec:
ntfs_test_bootsec:
; in: ebx->buffer, edx=size of partition
; out: CF set <=> invalid
; 1. Name=='NTFS '
@ -133,14 +133,15 @@ ntfs_setup: ; CODE XREF: part_set.inc
mov eax, 1
shl eax, cl
.4:
mov ecx, [ntfs_data.frs_size]
mov [ntfs_data.iab_size], eax
; allocate space for buffers
add eax, [ntfs_data.frs_size]
push eax
call kernel_alloc
add ecx, eax
mov edx, PG_SW
call @mem_alloc@8
test eax, eax
jz problem_fat_dec_count
mov [ntfs_data.frs_buffer], eax
jz problem_fat_dec_count
add eax, [ntfs_data.frs_size]
mov [ntfs_data.iab_buffer], eax
; read $MFT disposition
@ -177,10 +178,9 @@ ntfs_setup: ; CODE XREF: part_set.inc
.mftok:
; read $MFT table retrieval information
; start with one page, increase if not enough (when MFT too fragmented)
push ebx
push 0x1000
call kernel_alloc
pop ebx
mov ecx, 0x1000
mov edx, PG_SW
call @mem_alloc@8
test eax, eax
jz .fail_free_frs
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
mov [ntfs_data.cur_index_size], 0x1000/0x200
push 0x1000
call kernel_alloc
mov ecx, 0x1000
mov edx, PG_SW
call @mem_alloc@8
test eax, eax
jz .fail_free_mft
mov [ntfs_data.cur_index_buf], eax
jz .fail_free_mft
popad
call free_hd_channel
@ -241,11 +242,12 @@ ntfs_setup: ; CODE XREF: part_set.inc
mov eax, [ntfs_data.mft_retrieval_size]
cmp eax, [ntfs_data.mft_retrieval_alloc]
jnz .ok
add eax, 0x1000/8
mov [ntfs_data.mft_retrieval_alloc], eax
shl eax, 3
push eax
call kernel_alloc
lea ecx, [eax+0x1000/8]
mov [ntfs_data.mft_retrieval_alloc], ecx
shl ecx, 3
mov edx, PG_SW
call @mem_alloc@8
test eax, eax
jnz @f
popad
@ -980,10 +982,10 @@ ntfs_find_lfn:
push eax
push [ntfs_data.cur_index_buf]
call kernel_free
pop eax
mov [ntfs_data.cur_index_size], eax
push eax
call kernel_alloc
pop ecx
mov [ntfs_data.cur_index_size], ecx
mov edx, PG_SW
call @mem_alloc@8
test eax, eax
jnz @f
and [ntfs_data.cur_index_size], 0
@ -998,12 +1000,13 @@ ntfs_find_lfn:
shr ebp, 9
cmp ebp, [ntfs_data.cur_index_size]
jbe .ok2
push esi ebp
push ebp
call kernel_alloc
pop ebp esi
mov ecx, ebp
mov edx, PG_SW
call @mem_alloc@8
test eax, eax
jz .stc_ret
mov edi, eax
mov ecx, [ntfs_data.cur_index_size]
shl ecx, 9-2
@ -1326,10 +1329,10 @@ ntfs_HdReadFolder:
push eax
push [ntfs_data.cur_index_buf]
call kernel_free
pop eax
mov [ntfs_data.cur_index_size], eax
push eax
call kernel_alloc
pop ecx
mov [ntfs_data.cur_index_size], ecx
mov edx, PG_SW
call @mem_alloc@8
test eax, eax
jnz @f
and [ntfs_data.cur_index_size], 0
@ -1349,12 +1352,13 @@ ntfs_HdReadFolder:
shr ebp, 9
cmp ebp, [ntfs_data.cur_index_size]
jbe .ok2
push esi ebp
push ebp
call kernel_alloc
pop ebp esi
mov ecx, ebp
mov edx, PG_SW
call @mem_alloc@8
test eax, eax
jz .nomem
mov edi, eax
mov ecx, [ntfs_data.cur_index_size]
shl ecx, 9-2

View File

@ -84,20 +84,23 @@ endl
endp
proc load_file_parse_table
stdcall kernel_alloc,0x1000
mov [tmp_file_name_table],eax
mov edi,eax
mov esi,sysdir_name
mov ecx,128/4
rep movsd
invoke ini.enum_keys,conf_fname,conf_path_sect,get_every_key
xor eac, ecx
call @core_alloc@4
add eax, OS_BASE
mov [tmp_file_name_table],eax
mov edi,eax
mov esi,sysdir_name
mov ecx,128/4
rep movsd
mov eax,[tmp_file_name_table]
mov [full_file_name_table],eax
mov eax,[tmp_file_name_size]
mov [full_file_name_table.size],eax
ret
invoke ini.enum_keys,conf_fname,conf_path_sect,get_every_key
mov eax,[tmp_file_name_table]
mov [full_file_name_table],eax
mov eax,[tmp_file_name_size]
mov [full_file_name_table.size],eax
ret
endp
uglobal

View File

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

View File

@ -29,14 +29,18 @@ typedef struct
}phismem_t;
# define PA2KA(x) (((addr_t) (x)) + OS_BASE)
# define KA2PA(x) (((addr_t) (x)) - OS_BASE)
#define PG_MAP 1
#define PAGE_SIZE 4096
#define FRAME_WIDTH 12
#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)
{
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_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_mm
extrn @core_alloc@4
extrn @init_heap@8
extrn @find_large_md@4
extrn @find_small_md@4
extrn @phis_alloc@4
extrn @mem_alloc@8
extrn _alloc_kernel_space@4
extrn @heap_alloc@8
extrn _slab_cache_init
extrn _alloc_pages
extrn _alloc_page
extrn _get_free_mem
alloc_kernel_space equ _alloc_kernel_space@4
extrn _bx_from_load
@mem_alloc@8 equ @heap_alloc@8
section '.flat' code readable align 4096
use32
@ -555,7 +558,9 @@ __setvars:
call init_fpu
call init_malloc
stdcall alloc_kernel_space, 0x51000
mov ecx, 0x51000
xor edx, edx
call @mem_alloc@8
mov [default_io_map], eax
add eax, 0x2000
@ -611,8 +616,10 @@ __setvars:
mov [BgrDrawMode],eax
mov [BgrDataWidth],eax
mov [BgrDataHeight],eax
mov ecx, 4095
mov edx, PG_SW
mov [mem_BACKGROUND],4095
stdcall kernel_alloc, [mem_BACKGROUND]
call @mem_alloc@8
mov [img_background], eax
mov [SLOT_BASE + 256 + APPDATA.dir_table], _sys_pdbr + (0x100000000-OS_BASE)
@ -2290,10 +2297,11 @@ sys_background:
@@:
mov eax,[BgrDataWidth]
imul eax,[BgrDataHeight]
lea eax,[eax*3]
mov [mem_BACKGROUND],eax
lea ecx,[eax*3]
mov [mem_BACKGROUND],ecx
; get memory for new background
stdcall kernel_alloc, eax
mov edx, PG_SW
stdcall @mem_alloc@8
test eax, eax
jz .exit_mem
mov [img_background], eax

View File

@ -6,17 +6,24 @@ INCLUDE = include/
DEFS = -DUSE_SMP -DCONFIG_DEBUG
CFLAGS = -c -O2 -I $(INCLUDE) -fomit-frame-pointer -fno-builtin-printf -masm=intel
CFLAGS = -c -O2 -I $(INCLUDE) -fomit-frame-pointer -fno-builtin-printf -masm=intel
LDFLAGS = -shared -s -Map kernel.map --image-base 0x100000 --file-alignment 32
KERNEL_SRC:= \
kernel.asm \
data32.inc \
core/memory.inc \
core/heap.inc \
core/malloc.inc \
core/taskman.inc \
core/v86.inc \
core/sys32.inc \
core/dll.inc \
data32.inc
core/exports.inc \
fs/ntfs.inc \
gui/event.inc \
video/cursors.inc
PE_SRC:= \
init.c \

View File

@ -313,12 +313,13 @@ vesa_cursor:
mov [eax+CURSOR.hot_x], 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
jz .fail
mov edi, [.hcursor]
mov [edi+CURSOR.base], eax
jz .fail
mov esi, [.src]
mov ebx, [.flags]