Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1313 → Rev 2971

/kernel/branches/kolibri_pe/core/dll.c
235,6 → 235,7
 
int sys_exec(char *path, char *cmdline, u32_t flags)
{
 
PIMAGE_DOS_HEADER dos;
PIMAGE_NT_HEADERS32 nt;
 
241,6 → 242,7
size_t img_size;
count_t img_pages;
count_t img_tabs;
 
addr_t ex_pg_dir;
addr_t ex_stack_page;
addr_t ex_pl0_stack;
588,6 → 590,7
exp_dll = find_dll(&core_dll.link, libname);
if(exp_dll == NULL)
{
 
exp_dll = find_dll(&current_slot->dll_list, libname);
if(exp_dll == NULL)
{
/kernel/branches/kolibri_pe/core/dll.inc
17,6 → 17,8
align 4
proc attach_int_handler stdcall, irq:dword, handler:dword, access_rights:dword
 
push ebx
 
mov ebx, [irq] ;irq num
test ebx, ebx
jz .err
41,9 → 43,11
mov [irq_owner + 4 * ebx], PID_KERNEL ; all handlers belong to a kernel
 
stdcall enable_irq, [irq]
pop ebx
mov eax, 1
ret
.err:
pop ebx
xor eax, eax
ret
endp
824,6 → 828,8
mov dword [edx+8], 'vers'
mov byte [edx+12], '/'
mov esi, [driver_name]
.redo:
lea edx, [file_name]
lea edi, [edx+13]
mov ecx, 16
@@:
/kernel/branches/kolibri_pe/core/export.asm
17,6 → 17,7
.ascii " -export:CreateRingBuffer" # stdcall
.ascii " -export:CommitPages" # eax, ebx, ecx FIXME
.ascii " -export:UnmapPages" # eax, ecx FIXME
 
.ascii " -export:CreateObject" # eax, ebx FIXME
.ascii " -export:DestroyObject" # eax
 
24,7 → 25,6
.ascii " -export:SysMsgBoardStr" #
.ascii " -export:SetScreen" #
 
 
.ascii " -export:PciApi" #
.ascii " -export:PciRead8" # stdcall
.ascii " -export:PciRead16" # stdcall
38,6 → 38,10
.ascii " -export:HwCursorRestore" #
.ascii " -export:HwCursorCreate" #
 
.ascii " -export:create_window" # cdecl
.ascii " -export:show_window" # cdecl
.ascii " -export:get_event" # cdecl
.ascii " -export:def_window_proc" # cdecl
 
 
 
/kernel/branches/kolibri_pe/core/frame.c
300,7 → 300,7
list_remove(&slab->link);
list_prepend(&slab->link, &page_cache.full_slabs);
page_cache.partial_count--;
DBG("%s insert empty page slab\n");
DBG("%s insert empty page slab\n", __FUNCTION__);
};
spinlock_unlock(&page_cache.lock);
 
396,9 → 396,9
(slab->avail >= 4))
{
slab->state = 1;
// list_remove(&slab->link);
// list_prepend(&slab->link, &page_cache.partial_slabs);
// page_cache.partial_count++;
list_remove(&slab->link);
list_prepend(&slab->link, &page_cache.partial_slabs);
page_cache.partial_count++;
 
DBG("%s: insert partial page slab\n", __FUNCTION__);
}
440,3 → 440,6
return z_core.free_count;
}
 
 
 
 
/kernel/branches/kolibri_pe/core/heap.c
1,4 → 1,6
 
#define ALLOC_FAST
 
#include <types.h>
#include <core.h>
#include <spinlock.h>
294,10 → 296,10
map = (mmap_t*)PA2KA(frame_alloc( (sizeof(mmap_t) +
sizeof(addr_t) * pages) >> PAGE_WIDTH));
 
if ( map )
{
map->size = size;
 
if ( map )
{
order = size >> HF_WIDTH;
 
if( order )
313,7 → 315,6
 
if( frame )
{
addr_t page = 0;
addr_t mem;
 
z_heap.free_count -= (1 << order);
342,36 → 343,37
 
if( flags & PG_MAP )
{
addr_t page_frame;
 
#ifdef ALLOC_IMM
#ifdef ALLOC_FAST
 
while( pages )
{
u32_t order;
addr_t page_frame;
 
asm volatile ("bsr %0, %1":"=&r"(order):"r"(tmp):"cc");
asm volatile ("btr %0, %1" :"=r"(tmp):"r"(order):"cc");
asm volatile ("bsrl %1, %0":"=&r"(order):"r"(pages):"cc");
asm volatile ("btrl %1, %0" :"=&r"(pages):"r"(order):"cc");
 
page_frame = frame_alloc(1 << order) | (flags & 0xFFF);
page_frame = frame_alloc(1 << order) | (flags & 0xFFF); /* FIXME check */
 
for(i = 0; i < 1 << order; i++)
{
*pte++ = 0; //page;
*mpte++ = page;
*pte++ = 0;
*mpte++ = page_frame;
 
asm volatile ( "invlpg (%0)" ::"r" (mem) );
mem+= 4096;
page_frame+= 4096;
};
}
#else
 
page = PG_DEMAND | (flags & 0xFFF);
page_frame = PG_DEMAND | (flags & 0xFFF);
 
while(pages--)
{
*pte++ = 0;
*mpte++ = page;
*mpte++ = page_frame;
asm volatile ( "invlpg (%0)" ::"r" (mem) );
mem+= 4096;
};
381,7 → 383,7
{
while(pages--)
{
*pte++ = 0; //page;
*pte++ = 0;
*mpte++ = 0;
 
asm volatile ( "invlpg (%0)" ::"r" (mem) );
389,7 → 391,6
};
}
 
#endif
DBG("%s %x size %d order %d\n", __FUNCTION__, heap, size, order);
 
return heap;
/kernel/branches/kolibri_pe/core/heap.inc
23,7 → 23,6
align 4
_init_user_heap:
init_heap:
 
mov ebx,[current_slot]
mov eax, [ebx+APPDATA.heap_top]
test eax, eax
46,6 → 45,7
sub eax, 4096
or ecx, FREE_BLOCK
mov [page_tabs+edx], ecx
 
ret
 
align 4
/kernel/branches/kolibri_pe/core/init.asm
230,7 → 230,6
mov eax, cr3
mov cr3, eax
 
 
jmp system_init
 
if 0
/kernel/branches/kolibri_pe/core/memory.inc
265,6 → 265,7
pop edi
pop esi
@@:
 
call _alloc_page
test eax, eax
jz .exit
/kernel/branches/kolibri_pe/core/pe.c
207,7 → 207,6
u32_t sec_align;
int i;
 
 
/* assumed that image is valid */
 
dos = (PIMAGE_DOS_HEADER)raw;
314,8 → 313,6
imp = MakePtr(PIMAGE_IMPORT_DESCRIPTOR, img_base,
nt->OptionalHeader.DataDirectory[1].VirtualAddress);
 
 
 
while ( 1 )
{
PIMAGE_THUNK_DATA32 thunk;
/kernel/branches/kolibri_pe/core/slab.c
240,7 → 240,9
DBG("%s\n", __FUNCTION__);
 
cache = (slab_cache_t*)slab_cache_alloc();
 
_slab_cache_create(cache, size, align, constructor, destructor, flags);
 
return cache;
}
 
/kernel/branches/kolibri_pe/core/sys32.inc
291,23 → 291,14
ret
 
irqD:
save_ring3_context
mov ax, sel_app_data
mov ds, ax
mov es, ax
 
mov dx,0xf0
push eax
mov al,0
out dx,al
 
mov dx,0xa0
out 0xf0,al
mov al,0x20
out dx,al
mov dx,0x20
out dx,al
out 0xa0,al
out 0x20,al
pop eax
 
restore_ring3_context
 
iret
 
 
459,7 → 450,6
@@:
;mov esi,process_terminating
;call sys_msg_board_str
DEBUGF 1,"%s",process_terminating
@@:
cli
cmp [application_table_status],0
603,11 → 593,13
 
xor eax, eax
mov [window_data+esi+WDATA.box.left],eax
 
mov [window_data+esi+WDATA.box.width],eax
mov [window_data+esi+WDATA.box.top],eax
mov [window_data+esi+WDATA.box.height],eax
mov [window_data+esi+WDATA.cl_workarea],eax
mov [window_data+esi+WDATA.cl_titlebar],eax
 
mov [window_data+esi+WDATA.cl_frames],eax
mov dword [window_data+esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn
lea edi, [esi+draw_data]
814,7 → 806,6
mov [application_table_status],0
;mov esi,process_terminated
;call sys_msg_board_str
DEBUGF 1,"%s",process_terminated
add esp, 4
ret
restore .slot
/kernel/branches/kolibri_pe/core/syscall.asm
4,6 → 4,21
public _i40
 
 
public _create_window
public _show_window
public _get_event
public _def_window_proc
 
public stb_create_window
public stb_show_window
public stb_get_event
public stb_def_window_proc
 
extrn _sys_create_window
extrn _sys_show_window
extrn _sys_get_event
extrn _sys_def_window_proc
 
section '.text' code readable align 16
 
align 16
14,3 → 29,74
int 0x41
iretd
 
align 4
stb_create_window:
 
pushd [ecx+20]
pushd [ecx+16]
pushd [ecx+12]
pushd [ecx+8]
pushd [ecx+4]
pushd [ecx]
 
call _sys_create_window
 
add esp, 24
mov [esp + 32], eax
ret
 
align 4
stb_show_window:
pushd [ecx]
call _sys_show_window
add esp, 4
mov [esp + 32], eax
ret
 
align 4
stb_get_event:
pushd [ecx]
call _sys_get_event
add esp, 4
mov [esp + 32], eax
ret
 
align 4
stb_def_window_proc:
pushd [ecx]
call _sys_def_window_proc
add esp, 4
mov [esp + 32], eax
ret
 
align 4
_create_window:
 
lea ecx, [esp+4]
mov eax, 73
int 0x41
ret
 
align 4
_show_window:
 
lea ecx, [esp+4]
mov eax, 74
int 0x41
ret
 
align 4
_get_event:
lea ecx, [esp+4]
mov eax, 75
int 0x41
ret
 
align 4
_def_window_proc:
 
lea ecx, [esp+4]
mov eax, 76
int 0x41
ret
 
/kernel/branches/kolibri_pe/core/syscall.inc
16,8 → 16,7
mov ecx, edx
mov edx, esi
mov esi, edi
mov edi, [esp+28 + 4]
and edi,0xff
movzx edi, byte[esp+28 + 4]
call dword [servetable+edi*4]
ret
 
24,21 → 23,6
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; SYSTEM CALL ENTRY ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
align 16
i41:
pushad
cld
movzx eax, al
call dword [servetable2 + eax * 4]
popad
iretd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; SYSENTER ENTRY ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
70,6 → 54,21
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; SYSTEM CALL ENTRY ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
align 16
i40:
pushad
cld
movzx eax, al
call dword [servetable2 + eax * 4]
popad
iretd
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; SYSCALL ENTRY ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
256,6 → 255,10
dd cross_order ; 70-Common file system interface, version 2
dd cross_order ; 71-Window settings
dd cross_order ; 72-Send window message
dd stb_create_window ; 73-create window
dd stb_show_window ; 74-show window
dd stb_get_event ; 75-get event
dd stb_def_window_proc
times 255 - ( ($-servetable2) /4 ) dd undefined_syscall
dd sys_end ; -1-end application
 
/kernel/branches/kolibri_pe/core/taskman.inc
141,6 → 141,7
@@:
cmp edi, ecx
jae .bigfilename
 
lodsb
stosb
test al, al
172,7 → 173,7
test eax, eax
jz .err_hdr
 
DEBUGF 1,"%s",new_process_loading
; DEBUGF 1,"%s",new_process_loading
 
lea ebx, [application_table_status]
call wait_mutex
226,8 → 227,8
mov [ebx+APPDATA.mem_size],ecx
 
mov edi, [file_size]
; add edi, 4095
; and edi, not 4095
add edi, 4095
and edi, not 4095
sub ecx, edi
jna @F
 
261,6 → 262,7
pop ebx
mov eax, -ERROR_FILE_NOT_FOUND
ret
 
.failed:
mov eax, [save_cr3]
call set_cr3
279,6 → 281,7
ret
endp
 
 
align 4
proc pe_app_param stdcall path:dword, raw:dword, ex_pg_dir:dword, ex_stack:dword
 
448,7 → 451,6
popad
iretd
 
 
align 4
proc get_new_process_place
;input:
674,9 → 676,10
add esp, 16
ret
 
 
 
align 4
set_cr3:
 
mov ebx, [current_slot]
mov [ebx+APPDATA.dir_table], eax
mov cr3, eax
1045,9 → 1048,8
mov [app_eip], ebx
mov [app_esp], ecx
 
;mov esi,new_process_loading
;call sys_msg_board_str
DEBUGF 1,"%s",new_process_loading
;DEBUGF 1,"%s",new_process_loading
 
.wait_lock:
cmp [application_table_status],0
je .get_lock
1101,9 → 1103,7
stdcall set_app_params ,[slot],eax,dword 0,\
dword 0,dword 0
 
;mov esi,new_process_running
;call sys_msg_board_str ;output information about succefull startup
DEBUGF 1,"%s",new_process_running
; DEBUGF 1,"%s",new_process_running
 
mov [application_table_status],0 ;unlock application_table_status mutex
mov eax,[process_number] ;set result