/kernel/branches/net/core/conf_lib.inc |
---|
12,11 → 12,11 |
$Revision$ |
iglobal |
conf_path_sect: db 'path',0 |
conf_fname db '/sys/sys.conf',0 |
endg |
; set soke kernel configuration |
proc set_kernel_conf |
locals |
64,7 → 64,7 |
popad |
ret |
endp |
iglobal |
ugui db 'gui',0 |
ugui_mouse_speed db 'mouse_speed',0 |
ugui_mouse_speed_def db '2',0 |
74,8 → 74,63 |
udev db 'dev',0 |
udev_midibase db 'midibase',0 |
udev_midibase_def db '0x320',0 |
endg |
;set up netvork configuration |
proc set_network_conf |
locals |
par db 30 dup(?) |
endl |
pushad |
;[net] |
;active |
lea eax,[par] |
invoke ini.get_int,conf_fname, unet, unet_active, 0 |
or eax,eax |
jz .do_not_set_net |
mov eax, [stack_config] |
and eax, 0xFFFFFF80 |
add eax, 3 |
mov [stack_config], eax |
call ash_eth_enable |
;addr |
lea eax,[par] |
push eax |
invoke ini.get_str,conf_fname, unet, unet_addr, eax,30, unet_def |
pop eax |
stdcall do_inet_adr,eax |
mov [stack_ip], eax |
;mask |
lea eax,[par] |
push eax |
invoke ini.get_str,conf_fname, unet, unet_mask, eax,30, unet_def |
pop eax |
stdcall do_inet_adr,eax |
mov [subnet_mask], eax |
;gate |
lea eax,[par] |
push eax |
invoke ini.get_str,conf_fname, unet, unet_gate, eax,30, unet_def |
pop eax |
stdcall do_inet_adr,eax |
mov [gateway_ip], eax |
.do_not_set_net: |
popad |
ret |
endp |
iglobal |
unet db 'net',0 |
unet_active db 'active',0 |
unet_addr db 'addr',0 |
unet_mask db 'mask',0 |
unet_gate db 'gate',0 |
unet_def db 0 |
endg |
; convert string to DWord |
proc strtoint stdcall,strs |
pushad |
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/debug.inc |
---|
10,10 → 10,12 |
; diamond, 2006 |
sys_debug_services: |
cmp eax, 9 |
cmp ebx, 9 |
ja @f |
jmp dword [sys_debug_services_table+eax*4] |
jmp dword [sys_debug_services_table+ebx*4] |
@@: ret |
iglobal |
align 4 |
sys_debug_services_table: |
dd debug_set_event_data |
dd debug_getcontext |
25,21 → 27,21 |
dd debug_write_process_memory |
dd debug_terminate |
dd debug_set_drx |
endg |
debug_set_event_data: |
; in: ebx = pointer |
; in: ecx = pointer |
; destroys eax |
mov eax, [current_slot] |
mov [eax+APPDATA.dbg_event_mem], ebx |
mov [eax+APPDATA.dbg_event_mem], ecx |
ret |
get_debuggee_slot: |
; in: ebx=PID |
; in: ecx=PID |
; out: CF=1 if error |
; CF=0 and eax=slot*0x20 if ok |
; out: interrupts disabled |
cli |
mov eax, ebx |
mov eax, ecx |
call pid_to_slot |
test eax, eax |
jz .ret_bad |
56,7 → 58,7 |
ret |
debug_detach: |
; in: ebx=pid |
; in: ecx=pid |
; destroys eax,ebx |
call get_debuggee_slot |
jc .ret |
67,54 → 69,55 |
ret |
debug_terminate: |
; in: ebx=pid |
; in: ecx=pid |
call get_debuggee_slot |
jc debug_detach.ret |
mov ecx, eax |
shr ecx, 5 |
push 2 |
pop ebx |
jmp sys_system |
; push 2 |
; pop ebx |
mov edx,esi |
jmp sysfn_terminate |
debug_suspend: |
; in: ebx=pid |
; destroys eax,ebx |
; in: ecx=pid |
; destroys eax,ecx |
cli |
mov eax, ebx |
mov eax, ecx |
call pid_to_slot |
shl eax, 5 |
jz .ret |
mov bl, [CURRENT_TASK+eax+TASKDATA.state] ; process state |
test bl, bl |
mov cl, [CURRENT_TASK+eax+TASKDATA.state] ; process state |
test cl, cl |
jz .1 |
cmp bl, 5 |
cmp cl, 5 |
jnz .ret |
mov bl, 2 |
.2: mov [CURRENT_TASK+eax+TASKDATA.state], bl |
mov cl, 2 |
.2: mov [CURRENT_TASK+eax+TASKDATA.state], cl |
.ret: |
sti |
ret |
.1: |
inc ebx |
inc ecx |
jmp .2 |
do_resume: |
mov bl, [CURRENT_TASK+eax+TASKDATA.state] |
cmp bl, 1 |
mov cl, [CURRENT_TASK+eax+TASKDATA.state] |
cmp cl, 1 |
jz .1 |
cmp bl, 2 |
cmp cl, 2 |
jnz .ret |
mov bl, 5 |
.2: mov [CURRENT_TASK+eax+TASKDATA.state], bl |
mov cl, 5 |
.2: mov [CURRENT_TASK+eax+TASKDATA.state], cl |
.ret: ret |
.1: dec ebx |
.1: dec ecx |
jmp .2 |
debug_resume: |
; in: ebx=pid |
; in: ecx=pid |
; destroys eax,ebx |
cli |
mov eax, ebx |
mov eax, ecx |
call pid_to_slot |
shl eax, 5 |
jz .ret |
124,23 → 127,24 |
debug_getcontext: |
; in: |
; ebx=pid |
; ecx=sizeof(CONTEXT) |
; edx->CONTEXT |
; ecx=pid |
; edx=sizeof(CONTEXT) |
; esi->CONTEXT |
; destroys eax,ecx,edx,esi,edi |
cmp ecx, 28h |
cmp edx, 28h |
jnz .ret |
push ebx |
mov ebx, edx |
; push ecx |
; mov ecx, esi |
call check_region |
pop ebx |
; pop ecx |
dec eax |
jnz .ret |
call get_debuggee_slot |
jc .ret |
mov edi, esi |
mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack] |
lea esi, [eax+RING0_STACK_SIZE] |
mov edi, edx |
.ring0: |
; note that following code assumes that all interrupt/exception handlers |
; saves ring-3 context by pushad in this order |
174,23 → 178,24 |
debug_setcontext: |
; in: |
; ebx=pid |
; ecx=sizeof(CONTEXT) |
; edx->CONTEXT |
; ecx=pid |
; edx=sizeof(CONTEXT) |
; esi->CONTEXT |
; destroys eax,ecx,edx,esi,edi |
cmp ecx, 28h |
cmp edx, 28h |
jnz .ret |
push ebx |
mov ebx, edx |
; push ebx |
; mov ebx, edx |
call check_region |
pop ebx |
; pop ebx |
dec eax |
jnz .ret |
call get_debuggee_slot |
jc .stiret |
; mov esi, edx |
mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack] |
lea edi, [eax+RING0_STACK_SIZE] |
mov esi, edx |
.ring0: |
sub edi, 8+12+20h |
mov eax, [esi+24h] ;edi |
227,22 → 232,26 |
lea eax, [eax*8+SLOT_BASE+APPDATA.dbg_regs] |
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3 |
; [eax+10]=dr7 |
cmp edx, OS_BASE |
cmp esi, OS_BASE |
jae .errret |
cmp cl, 3 |
cmp dl, 3 |
ja .errret |
mov ebx, dr7 |
shr ebx, cl |
shr ebx, cl |
test ebx, 2 ; bit 1+2*index = G0..G3, global break enable |
mov ecx, dr7 |
;fix me |
xchg ecx,edx |
shr edx, cl |
shr edx, cl |
xchg ecx,edx |
test ecx, 2 ; bit 1+2*index = G0..G3, global break enable |
jnz .errret2 |
test ch, ch |
test dh, dh |
jns .new |
; clear breakpoint |
movzx ecx, cl |
add ecx, ecx |
and dword [eax+ecx*2], 0 ; clear DR<i> |
btr dword [eax+10h], ecx ; clear L<i> bit |
movzx edx, dl |
add edx, edx |
and dword [eax+edx*2], 0 ; clear DR<i> |
btr dword [eax+10h], edx ; clear L<i> bit |
test byte [eax+10h], 55h |
jnz .okret |
; imul eax, ebp, tss_step/32 |
249,45 → 258,49 |
; and byte [eax + tss_data + TSS._trap], not 1 |
and [ebp*8 + SLOT_BASE+APPDATA.dbg_state], not 1 |
.okret: |
and dword [esp+36], 0 |
and dword [esp+32], 0 |
sti |
ret |
.errret: |
sti |
mov dword [esp+36], 1 |
mov dword [esp+32], 1 |
ret |
.errret2: |
sti |
mov dword [esp+36], 2 |
mov dword [esp+32], 2 |
ret |
.new: |
; add new breakpoint |
; cl=index; ch=flags; edx=address |
test ch, 0xF0 |
; dl=index; dh=flags; esi=address |
test dh, 0xF0 |
jnz .errret |
mov bl, ch |
and bl, 3 |
cmp bl, 2 |
mov cl, dh |
and cl, 3 |
cmp cl, 2 |
jz .errret |
mov bl, ch |
shr bl, 2 |
cmp bl, 2 |
mov cl, dh |
shr cl, 2 |
cmp cl, 2 |
jz .errret |
test dl, bl |
mov ebx,esi |
test bl, dl |
jnz .errret |
or byte [eax+10h+1], 3 ; set GE and LE flags |
movzx ebx, ch |
movzx ecx, cl |
movzx edx, dh |
movzx ecx, dl |
add ecx, ecx |
bts dword [eax+10h], ecx ; set L<i> flag |
add ecx, ecx |
mov [eax+ecx], edx ; set DR<i> |
mov [eax+ecx], ebx;esi ; set DR<i> |
shl edx, cl |
mov ebx, 0xF |
shl ebx, cl |
mov edx, 0xF |
shl edx, cl |
not edx |
and [eax+10h+2], dx |
or [eax+10h+2], bx ; set R/W and LEN fields |
not ebx |
and [eax+10h+2], bx |
or [eax+10h+2], dx ; set R/W and LEN fields |
; imul eax, ebp, tss_step/32 |
; or byte [eax + tss_data + TSS._trap], 1 |
or [ebp*8 + SLOT_BASE+APPDATA.dbg_state], 1 |
295,51 → 308,51 |
debug_read_process_memory: |
; in: |
; ebx=pid |
; ecx=length |
; esi->buffer in debugger |
; edx=address in debuggee |
; ecx=pid |
; edx=length |
; edi->buffer in debugger |
; esi=address in debuggee |
; out: [esp+36]=sizeof(read) |
; destroys all |
push ebx |
mov ebx, esi |
; push ebx |
; mov ebx, esi |
call check_region |
pop ebx |
; pop ebx |
dec eax |
jnz .err |
call get_debuggee_slot |
jc .err |
shr eax, 5 |
mov ebx, esi |
; mov ebx, esi |
call read_process_memory |
sti |
mov dword [esp+36], eax |
mov dword [esp+32], eax |
ret |
.err: |
or dword [esp+36], -1 |
or dword [esp+32], -1 |
ret |
debug_write_process_memory: |
; in: |
; ebx=pid |
; ecx=length |
; esi->buffer in debugger |
; edx=address in debuggee |
; ecx=pid |
; edx=length |
; edi->buffer in debugger |
; esi=address in debuggee |
; out: [esp+36]=sizeof(write) |
; destroys all |
push ebx |
mov ebx, esi |
; push ebx |
; mov ebx, esi |
call check_region |
pop ebx |
; pop ebx |
dec eax |
jnz debug_read_process_memory.err |
call get_debuggee_slot |
jc debug_read_process_memory.err |
shr eax, 5 |
mov ebx, esi |
; mov ebx, esi |
call write_process_memory |
sti |
mov [esp+36], eax |
mov [esp+32], eax |
ret |
debugger_notify: |
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/dll.inc |
---|
1,6 → 1,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; |
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
315,7 → 315,7 |
cmp [edi+SRV.magic], ' SRV' |
jne .fail |
cmp [edi+SRV.size], SRV_SIZE |
cmp [edi+SRV.size], SRV.sizeof |
jne .fail |
stdcall [edi+SRV.srv_proc], esi |
333,7 → 333,7 |
endp |
; param |
; ebx= io_control |
; ecx= io_control |
; |
; retval |
; eax= error code |
340,17 → 340,17 |
align 4 |
srv_handlerEx: |
cmp ebx, OS_BASE |
cmp ecx, OS_BASE |
jae .fail |
mov eax, [ebx+handle] |
mov eax, [ecx+handle] |
cmp [eax+SRV.magic], ' SRV' |
jne .fail |
cmp [eax+SRV.size], SRV_SIZE |
cmp [eax+SRV.size], SRV.sizeof |
jne .fail |
stdcall [eax+SRV.srv_proc], ebx |
stdcall [eax+SRV.srv_proc], ecx |
ret |
.fail: |
or eax, -1 |
402,8 → 402,8 |
cmp [handler], eax |
je .fail |
mov eax, SRV_SIZE |
call malloc ;call alloc_service |
mov eax, SRV.sizeof |
call malloc |
test eax, eax |
jz .fail |
411,13 → 411,15 |
push edi |
mov edi, eax |
mov esi, [name] |
mov ecx, 16/4 |
rep movsd |
movsd |
movsd |
movsd |
movsd |
pop edi |
pop esi |
mov [eax+SRV.magic], ' SRV' |
mov [eax+SRV.size], SRV_SIZE |
mov [eax+SRV.size], SRV.sizeof |
mov ebx, srv.fd-SRV_FD_OFFSET |
mov edx, [ebx+SRV.fd] |
472,8 → 474,8 |
xor eax, eax |
ret |
.ok: |
mov ebx, [pSym] |
mov eax, [ebx+8] |
mov eax, [pSym] |
mov eax, [eax+8] |
ret |
endp |
611,7 → 613,10 |
jz .cleanup |
mov [file2], eax |
pushfd |
cli |
stdcall unpack, [file], eax |
popfd |
stdcall kernel_free, [file] |
mov eax, [file2] |
mov ebx, [file_size] |
676,7 → 681,7 |
endp |
align 4 |
proc fix_coff_symbols stdcall, sec:dword, symbols:dword,\ |
proc fix_coff_symbols stdcall uses ebx esi, sec:dword, symbols:dword,\ |
sym_count:dword, strings:dword, imports:dword |
locals |
retval dd ? |
738,7 → 743,8 |
endp |
align 4 |
proc fix_coff_relocs stdcall, coff:dword, sec:dword, sym:dword |
proc fix_coff_relocs stdcall uses ebx esi, coff:dword, sym:dword, \ |
delta:dword |
locals |
n_sec dd ? |
endl |
746,8 → 752,8 |
mov eax, [coff] |
movzx ebx, [eax+CFH.nSections] |
mov [n_sec], ebx |
lea esi, [eax+20] |
.fix_sec: |
mov esi, [sec] |
mov edi, [esi+CFS.PtrReloc] |
add edi, [coff] |
754,7 → 760,7 |
movzx ecx, [esi+CFS.NumReloc] |
test ecx, ecx |
jz .next |
.next_reloc: |
.reloc_loop: |
mov ebx, [edi+CRELOC.SymIndex] |
add ebx,ebx |
lea ebx,[ebx+ebx*8] |
777,12 → 783,14 |
mov eax, [edi+CRELOC.VirtualAddress] |
add eax, [esi+CFS.VirtualAddress] |
.fix: |
add eax, [delta] |
add [eax], edx |
.next_reloc: |
add edi, 10 |
dec ecx |
jnz .next_reloc |
jnz .reloc_loop |
.next: |
add [sec], COFF_SECTION_SIZE |
add esi, COFF_SECTION_SIZE |
dec [n_sec] |
jnz .fix_sec |
.exit: |
789,6 → 797,43 |
ret |
endp |
proc rebase_coff stdcall uses ebx esi, coff:dword, sym:dword, \ |
delta:dword |
locals |
n_sec dd ? |
endl |
mov eax, [coff] |
movzx ebx, [eax+CFH.nSections] |
mov [n_sec], ebx |
lea esi, [eax+20] |
mov edx, [delta] |
.fix_sec: |
mov edi, [esi+CFS.PtrReloc] |
add edi, [coff] |
movzx ecx, [esi+CFS.NumReloc] |
test ecx, ecx |
jz .next |
.reloc_loop: |
cmp [edi+CRELOC.Type], 6 |
jne .next_reloc |
.dir_32: |
mov eax, [edi+CRELOC.VirtualAddress] |
add eax, [esi+CFS.VirtualAddress] |
add [eax+edx], edx |
.next_reloc: |
add edi, 10 |
dec ecx |
jnz .reloc_loop |
.next: |
add esi, COFF_SECTION_SIZE |
dec [n_sec] |
jnz .fix_sec |
.exit: |
ret |
endp |
align 4 |
proc load_driver stdcall, driver_name:dword |
locals |
900,10 → 945,8 |
jz .link_fail |
mov ebx, [coff] |
add ebx, 20 |
stdcall fix_coff_relocs, [coff], ebx, [sym] |
stdcall fix_coff_relocs, ebx, [sym], 0 |
mov ebx, [coff] |
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szVersion |
test eax, eax |
jz .link_fail |
975,117 → 1018,530 |
ret |
endp |
; in: edx -> COFF_SECTION struct |
; out: eax = alignment as mask for bits to drop |
coff_get_align: |
; Rules: |
; - if alignment is not given, use default = 4K; |
; - if alignment is given and is no more than 4K, use it; |
; - if alignment is more than 4K, revert to 4K. |
push ecx |
mov cl, byte [edx+CFS.Characteristics+2] |
mov eax, 1 |
shr cl, 4 |
dec cl |
js .default |
cmp cl, 12 |
jbe @f |
.default: |
mov cl, 12 |
@@: |
shl eax, cl |
pop ecx |
dec eax |
ret |
align 4 |
proc load_library stdcall, file_name:dword |
locals |
fullname rb 260 |
fileinfo rb 40 |
coff dd ? |
sym dd ? |
strings dd ? |
img_size dd ? |
img_base dd ? |
exports dd ? |
endl |
cli |
stdcall load_file, [file_name] |
; resolve file name |
mov ebx, [file_name] |
lea edi, [fullname+1] |
mov byte [edi-1], '/' |
stdcall get_full_file_name, edi, 259 |
test al, al |
jz .fail |
; scan for required DLL in list of already loaded for this process, |
; ignore timestamp |
mov esi, [CURRENT_TASK] |
shl esi, 8 |
lea edi, [fullname] |
mov ebx, [esi+SLOT_BASE+APPDATA.dlls_list_ptr] |
test ebx, ebx |
jz .not_in_process |
mov esi, [ebx+HDLL.fd] |
.scan_in_process: |
cmp esi, ebx |
jz .not_in_process |
mov eax, [esi+HDLL.parent] |
add eax, DLLDESCR.name |
stdcall strncmp, eax, edi, -1 |
test eax, eax |
jnz .next_in_process |
; simple variant: load DLL which is already loaded in this process |
; just increment reference counters and return address of exports table |
inc [esi+HDLL.refcount] |
mov ecx, [esi+HDLL.parent] |
inc [ecx+DLLDESCR.refcount] |
mov eax, [ecx+DLLDESCR.exports] |
sub eax, [ecx+DLLDESCR.defaultbase] |
add eax, [esi+HDLL.base] |
ret |
.next_in_process: |
mov esi, [esi+HDLL.fd] |
jmp .scan_in_process |
.not_in_process: |
; scan in full list, compare timestamp |
lea eax, [fileinfo] |
stdcall get_fileinfo, edi, eax |
test eax, eax |
jnz .fail |
mov esi, [dll_list.fd] |
.scan_for_dlls: |
cmp esi, dll_list |
jz .load_new |
lea eax, [esi+DLLDESCR.name] |
stdcall strncmp, eax, edi, -1 |
test eax, eax |
jnz .continue_scan |
.test_prev_dll: |
mov eax, dword [fileinfo+24] ; last modified time |
mov edx, dword [fileinfo+28] ; last modified date |
cmp dword [esi+DLLDESCR.timestamp], eax |
jnz .continue_scan |
cmp dword [esi+DLLDESCR.timestamp+4], edx |
jz .dll_already_loaded |
.continue_scan: |
mov esi, [esi+DLLDESCR.fd] |
jmp .scan_for_dlls |
; new DLL |
.load_new: |
; load file |
stdcall load_file, edi |
test eax, eax |
jz .fail |
mov [coff], eax |
mov dword [fileinfo+32], ebx |
mov [coff], eax |
movzx ecx, [eax+CFH.nSections] |
; allocate DLLDESCR struct; size is DLLDESCR.sizeof plus size of DLL name |
mov esi, edi |
mov ecx, -1 |
xor eax, eax |
repnz scasb |
not ecx |
lea eax, [ecx+DLLDESCR.sizeof] |
push ecx |
call malloc |
pop ecx |
test eax, eax |
jz .fail_and_free_coff |
; save timestamp |
lea edi, [eax+DLLDESCR.name] |
rep movsb |
mov esi, eax |
mov eax, dword [fileinfo+24] |
mov dword [esi+DLLDESCR.timestamp], eax |
mov eax, dword [fileinfo+28] |
mov dword [esi+DLLDESCR.timestamp+4], eax |
; initialize DLLDESCR struct |
and dword [esi+DLLDESCR.refcount], 0 ; no HDLLs yet; later it will be incremented |
mov [esi+DLLDESCR.fd], dll_list |
mov eax, [dll_list.bk] |
mov [dll_list.bk], esi |
mov [esi+DLLDESCR.bk], eax |
mov [eax+DLLDESCR.fd], esi |
; calculate size of loaded DLL |
mov edx, [coff] |
movzx ecx, [edx+CFH.nSections] |
xor ebx, ebx |
lea edx, [eax+20] |
add edx, 20 |
@@: |
call coff_get_align |
add ebx, eax |
not eax |
and ebx, eax |
add ebx, [edx+CFS.SizeOfRawData] |
add ebx, 15 |
and ebx, not 15 |
add edx, COFF_SECTION_SIZE |
dec ecx |
jnz @B |
mov [img_size], ebx |
call init_heap |
stdcall user_alloc, [img_size] |
; it must be nonzero and not too big |
mov [esi+DLLDESCR.size], ebx |
test ebx, ebx |
jz .fail_and_free_dll |
cmp ebx, MAX_DEFAULT_DLL_ADDR-MIN_DEFAULT_DLL_ADDR |
ja .fail_and_free_dll |
; allocate memory for kernel-side image |
stdcall kernel_alloc, ebx |
test eax, eax |
jz .fail |
mov [img_base], eax |
jz .fail_and_free_dll |
mov [esi+DLLDESCR.data], eax |
; calculate preferred base address |
add ebx, 0x1FFF |
and ebx, not 0xFFF |
mov ecx, [dll_cur_addr] |
lea edx, [ecx+ebx] |
cmp edx, MAX_DEFAULT_DLL_ADDR |
jb @f |
mov ecx, MIN_DEFAULT_DLL_ADDR |
lea edx, [ecx+ebx] |
@@: |
mov [esi+DLLDESCR.defaultbase], ecx |
mov [dll_cur_addr], edx |
; copy sections and set correct values for VirtualAddress'es in headers |
push esi |
mov edx, [coff] |
movzx ebx, [edx+CFH.nSections] |
mov edi, [img_base] |
lea eax, [edx+20] |
mov edi, eax |
add edx, 20 |
cld |
@@: |
mov [eax+CFS.VirtualAddress], edi |
mov esi, [eax+CFS.PtrRawData] |
call coff_get_align |
add ecx, eax |
add edi, eax |
not eax |
and ecx, eax |
and edi, eax |
mov [edx+CFS.VirtualAddress], ecx |
add ecx, [edx+CFS.SizeOfRawData] |
mov esi, [edx+CFS.PtrRawData] |
push ecx |
mov ecx, [edx+CFS.SizeOfRawData] |
test esi, esi |
jnz .copy |
add edi, [eax+CFS.SizeOfRawData] |
xor eax, eax |
rep stosb |
jmp .next |
.copy: |
add esi, edx |
mov ecx, [eax+CFS.SizeOfRawData] |
cld |
add esi, [coff] |
rep movsb |
.next: |
add edi, 15 ;-new_app_base |
and edi, -16 |
add eax, COFF_SECTION_SIZE |
pop ecx |
add edx, COFF_SECTION_SIZE |
dec ebx |
jnz @B |
pop esi |
; save some additional data from COFF file |
; later we will use COFF header, headers for sections and symbol table |
; and also relocations table for all sections |
mov edx, [coff] |
mov ebx, [edx+CFH.pSymTable] |
mov edi, dword [fileinfo+32] |
sub edi, ebx |
jc .fail_and_free_data |
mov [esi+DLLDESCR.symbols_lim], edi |
add ebx, edx |
mov [sym], ebx |
movzx ecx, [edx+CFH.nSections] |
lea ecx, [ecx*5] |
lea edi, [edi+ecx*8+20] |
add edx, 20 |
@@: |
movzx eax, [edx+CFS.NumReloc] |
lea eax, [eax*5] |
lea edi, [edi+eax*2] |
add edx, COFF_SECTION_SIZE |
sub ecx, 5 |
jnz @b |
stdcall kernel_alloc, edi |
test eax, eax |
jz .fail_and_free_data |
mov edx, [coff] |
movzx ecx, [edx+CFH.nSections] |
lea ecx, [ecx*5] |
lea ecx, [ecx*2+5] |
mov [esi+DLLDESCR.coff_hdr], eax |
push esi |
mov esi, edx |
mov edi, eax |
rep movsd |
pop esi |
mov [esi+DLLDESCR.symbols_ptr], edi |
push esi |
mov ecx, [edx+CFH.nSymbols] |
mov [esi+DLLDESCR.symbols_num], ecx |
mov ecx, [esi+DLLDESCR.symbols_lim] |
mov esi, ebx |
rep movsb |
pop esi |
mov ebx, [esi+DLLDESCR.coff_hdr] |
push esi |
movzx eax, [edx+CFH.nSections] |
lea edx, [ebx+20] |
@@: |
movzx ecx, [edx+CFS.NumReloc] |
lea ecx, [ecx*5] |
mov esi, [edx+CFS.PtrReloc] |
mov [edx+CFS.PtrReloc], edi |
sub [edx+CFS.PtrReloc], ebx |
add esi, [coff] |
shr ecx, 1 |
rep movsd |
adc ecx, ecx |
rep movsw |
add edx, COFF_SECTION_SIZE |
dec eax |
jnz @b |
pop esi |
; fixup symbols |
mov edx, ebx |
mov eax, [ebx+CFH.nSymbols] |
add edx, 20 |
mov ecx, [esi+DLLDESCR.symbols_num] |
lea ecx, [ecx*9] |
add ecx,ecx |
lea ecx,[ecx+ecx*8] ;ecx*=18 = nSymbols*CSYM_SIZE |
add ecx, [sym] |
mov [strings], ecx |
add ecx, [esi+DLLDESCR.symbols_ptr] |
lea eax, [edx+20] |
stdcall fix_coff_symbols, edx, [esi+DLLDESCR.symbols_ptr], eax,\ |
ecx, 0 |
; test eax, eax |
; jnz @F |
; |
;@@: |
stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\ |
[strings], dword 0 |
stdcall get_coff_sym,[esi+DLLDESCR.symbols_ptr],[ebx+CFH.nSymbols],szEXPORTS |
test eax, eax |
jnz @F |
stdcall get_coff_sym,[esi+DLLDESCR.symbols_ptr],[ebx+CFH.nSymbols],sz_EXPORTS |
@@: |
mov edx, [coff] |
movzx ebx, [edx+CFH.nSections] |
mov edi, new_app_base |
lea eax, [edx+20] |
@@: |
add [eax+CFS.VirtualAddress], edi ;patch user space offset |
add eax, COFF_SECTION_SIZE |
dec ebx |
jnz @B |
mov [esi+DLLDESCR.exports], eax |
add edx, 20 |
stdcall fix_coff_relocs, [coff], edx, [sym] |
; fix relocs in the hidden copy in kernel memory to default address |
; it is first fix; usually this will be enough, but second fix |
; can be necessary if real load address will not equal assumption |
mov eax, [esi+DLLDESCR.data] |
sub eax, [esi+DLLDESCR.defaultbase] |
stdcall fix_coff_relocs, ebx, [esi+DLLDESCR.symbols_ptr], eax |
mov ebx, [coff] |
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szEXPORTS |
stdcall kernel_free, [coff] |
.dll_already_loaded: |
inc [esi+DLLDESCR.refcount] |
push esi |
call init_heap |
pop esi |
mov edi, [esi+DLLDESCR.size] |
stdcall user_alloc_at, [esi+DLLDESCR.defaultbase], edi |
test eax, eax |
jnz @F |
jnz @f |
stdcall user_alloc, edi |
test eax, eax |
jz .fail_and_dereference |
@@: |
mov [img_base], eax |
mov eax, HDLL.sizeof |
call malloc |
test eax, eax |
jz .fail_and_free_user |
mov ebx, [CURRENT_TASK] |
shl ebx, 5 |
mov edx, [CURRENT_TASK+ebx+TASKDATA.pid] |
mov [eax+HDLL.pid], edx |
push eax |
call init_dlls_in_thread |
pop ebx |
test eax, eax |
jz .fail_and_free_user |
mov edx, [eax+HDLL.fd] |
mov [ebx+HDLL.fd], edx |
mov [ebx+HDLL.bk], eax |
mov [eax+HDLL.fd], ebx |
mov [edx+HDLL.bk], ebx |
mov eax, ebx |
mov ebx, [img_base] |
mov [eax+HDLL.base], ebx |
mov [eax+HDLL.size], edi |
mov [eax+HDLL.refcount], 1 |
mov [eax+HDLL.parent], esi |
mov edx, ebx |
shr edx, 12 |
or dword [page_tabs+(edx-1)*4], DONT_FREE_BLOCK |
; copy entries of page table from kernel-side image to usermode |
; use copy-on-write for user-mode image, so map as readonly |
xor edi, edi |
mov ecx, [esi+DLLDESCR.data] |
shr ecx, 12 |
.map_pages_loop: |
mov eax, [page_tabs+ecx*4] |
and eax, not 0xFFF |
or al, PG_USER |
xchg eax, [page_tabs+edx*4] |
test al, 1 |
jz @f |
call free_page |
@@: |
invlpg [ebx+edi] |
inc ecx |
inc edx |
add edi, 0x1000 |
cmp edi, [esi+DLLDESCR.size] |
jb .map_pages_loop |
mov ebx, [coff] |
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],sz_EXPORTS |
; if real user-mode base is not equal to preferred base, relocate image |
sub ebx, [esi+DLLDESCR.defaultbase] |
jz @f |
stdcall rebase_coff, [esi+DLLDESCR.coff_hdr], [esi+DLLDESCR.symbols_ptr], ebx |
@@: |
mov [exports], eax |
mov eax, [esi+DLLDESCR.exports] |
sub eax, [esi+DLLDESCR.defaultbase] |
add eax, [img_base] |
ret |
.fail_and_free_data: |
stdcall kernel_free, [esi+DLLDESCR.data] |
.fail_and_free_dll: |
mov eax, esi |
call free |
.fail_and_free_coff: |
stdcall kernel_free, [coff] |
mov eax, [exports] |
ret |
.fail: |
xor eax, eax |
ret |
.fail_and_free_user: |
stdcall user_free, [img_base] |
.fail_and_dereference: |
mov eax, 1 ; delete 1 reference |
call dereference_dll |
xor eax, eax |
ret |
endp |
; initialize [APPDATA.dlls_list_ptr] for given thread |
; DLL is per-process object, so APPDATA.dlls_list_ptr must be |
; kept in sync for all threads of one process. |
; out: eax = APPDATA.dlls_list_ptr if all is OK, |
; NULL if memory allocation failed |
init_dlls_in_thread: |
mov ebx, [current_slot] |
mov eax, [ebx+APPDATA.dlls_list_ptr] |
test eax, eax |
jnz .ret |
push [ebx+APPDATA.dir_table] |
mov eax, 8 |
call malloc |
pop edx |
test eax, eax |
jz .ret |
mov [eax], eax |
mov [eax+4], eax |
mov ecx, [TASK_COUNT] |
mov ebx, SLOT_BASE+256 |
.set: |
cmp [ebx+APPDATA.dir_table], edx |
jnz @f |
mov [ebx+APPDATA.dlls_list_ptr], eax |
@@: |
add ebx, 256 |
dec ecx |
jnz .set |
.ret: |
ret |
; in: eax = number of references to delete, esi -> DLLDESCR struc |
dereference_dll: |
sub [esi+DLLDESCR.refcount], eax |
jnz .ret |
mov eax, [esi+DLLDESCR.fd] |
mov edx, [esi+DLLDESCR.bk] |
mov [eax+DLLDESCR.bk], edx |
mov [edx+DLLDESCR.fd], eax |
stdcall kernel_free, [esi+DLLDESCR.coff_hdr] |
stdcall kernel_free, [esi+DLLDESCR.data] |
mov eax, esi |
call free |
.ret: |
ret |
destroy_hdll: |
push ebx ecx esi edi |
push eax |
mov ebx, [eax+HDLL.base] |
mov esi, [eax+HDLL.parent] |
mov edx, [esi+DLLDESCR.size] |
; The following actions require the context of application where HDLL is mapped. |
; However, destroy_hdll can be called in the context of OS thread when |
; cleaning up objects created by the application which is destroyed. |
; So remember current cr3 and set it to page table of target. |
mov eax, [ecx+APPDATA.dir_table] |
; Because we cheat with cr3, disable interrupts: task switch would restore |
; page table from APPDATA of current thread. |
; Also set [current_slot] because it is used by user_free. |
pushf |
cli |
push [current_slot] |
mov [current_slot], ecx |
mov ecx, cr3 |
push ecx |
mov cr3, eax |
push ebx ; argument for user_free |
mov eax, ebx |
shr ebx, 12 |
push ebx |
mov esi, [esi+DLLDESCR.data] |
shr esi, 12 |
.unmap_loop: |
push eax |
mov eax, 2 |
xchg eax, [page_tabs+ebx*4] |
mov ecx, [page_tabs+esi*4] |
and eax, not 0xFFF |
and ecx, not 0xFFF |
cmp eax, ecx |
jz @f |
call free_page |
@@: |
pop eax |
invlpg [eax] |
add eax, 0x1000 |
inc ebx |
inc esi |
sub edx, 0x1000 |
ja .unmap_loop |
pop ebx |
and dword [page_tabs+(ebx-1)*4], not DONT_FREE_BLOCK |
call user_free |
; Restore context. |
pop eax |
mov cr3, eax |
pop [current_slot] |
popf |
; Ok, cheating is done. |
pop eax |
push eax |
mov esi, [eax+HDLL.parent] |
mov eax, [eax+HDLL.refcount] |
call dereference_dll |
pop eax |
mov edx, [eax+HDLL.bk] |
mov ebx, [eax+HDLL.fd] |
mov [ebx+HDLL.bk], edx |
mov [edx+HDLL.fd], ebx |
call free |
pop edi esi ecx ebx |
ret |
; ecx -> APPDATA for slot, esi = dlls_list_ptr |
destroy_all_hdlls: |
test esi, esi |
jz .ret |
.loop: |
mov eax, [esi+HDLL.fd] |
cmp eax, esi |
jz free |
call destroy_hdll |
jmp .loop |
.ret: |
ret |
align 4 |
proc stop_all_services |
stop_all_services: |
push ebp |
mov edx, [srv.fd] |
.next: |
cmp edx, srv.fd-SRV_FD_OFFSET |
1092,7 → 1548,7 |
je .done |
cmp [edx+SRV.magic], ' SRV' |
jne .next |
cmp [edx+SRV.size], SRV_SIZE |
cmp [edx+SRV.size], SRV.sizeof |
jne .next |
mov ebx, [edx+SRV.entry] |
1101,12 → 1557,16 |
jz .next |
push edx |
stdcall ebx, dword -1 |
mov ebp, esp |
push 0 |
push -1 |
call ebx |
mov esp, ebp |
pop edx |
jmp .next |
.done: |
pop ebp |
ret |
endp |
; param |
; eax= size |
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/export.inc |
---|
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/exports.inc |
---|
60,10 → 60,6 |
szClearEvent db 'ClearEvent',0 |
szLoadCursor db 'LoadCursor',0 |
szSelectHwCursor db 'SelectHwCursor',0 |
szSetHwCursor db 'SetHwCursor',0 |
szHwCursorRestore db 'HwCursorRestore', 0 |
szHwCursorCreate db 'HwCursorCreate', 0 |
szSysMsgBoardStr db 'SysMsgBoardStr', 0 |
szSysMsgBoardChar db 'SysMsgBoardChar', 0 |
139,11 → 135,6 |
dd szLoadCursor , load_cursor ;stdcall |
dd szSelectHwCursor , select_hw_cursor ;import stdcall |
dd szSetHwCursor , set_hw_cursor ;import stdcall |
dd szHwCursorRestore , hw_restore ;import |
dd szHwCursorCreate , create_cursor ;import |
dd szSysMsgBoardStr , sys_msg_board_str |
dd szSysMsgBoardChar , sys_msg_board |
dd szGetCurrentTask , get_curr_task |
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/ext_lib.inc |
---|
13,7 → 13,9 |
$Revision$ |
if 0 |
; The code currently does not work. Kill "if 0/end if" only after correcting |
; to current kernel (dll.inc). |
macro library [name,fname] |
{ |
forward |
315,3 → 317,4 |
uglobal |
s_libname db 64 dup (0) |
endg |
end if |
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/fpu.inc |
---|
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/heap.inc |
---|
1,6 → 1,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; |
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
140,7 → 140,7 |
mov ecx, [pg_data.kernel_pages] |
shl ecx, 12 |
sub ecx, HEAP_BASE+4096*MEM_BLOCK_SIZE |
sub ecx, HEAP_BASE-OS_BASE+4096*MEM_BLOCK_SIZE |
mov [heap_size], ecx |
mov [heap_free], ecx |
mov [ebx+block_size], ecx |
759,6 → 759,102 |
endp |
align 4 |
proc user_alloc_at stdcall, address:dword, alloc_size:dword |
push ebx |
push esi |
push edi |
mov ebx, [current_slot] |
mov edx, [address] |
and edx, not 0xFFF |
mov [address], edx |
sub edx, 0x1000 |
jb .error |
mov esi, [ebx+APPDATA.heap_base] |
mov edi, [ebx+APPDATA.heap_top] |
cmp edx, esi |
jb .error |
.scan: |
cmp esi, edi |
jae .error |
mov ebx, esi |
shr ebx, 12 |
mov eax, [page_tabs+ebx*4] |
mov ecx, eax |
and ecx, 0xFFFFF000 |
add ecx, esi |
cmp edx, ecx |
jb .found |
mov esi, ecx |
jmp .scan |
.error: |
xor eax, eax |
pop edi |
pop esi |
pop ebx |
ret |
.found: |
test al, FREE_BLOCK |
jz .error |
mov eax, ecx |
sub eax, edx |
sub eax, 0x1000 |
cmp eax, [alloc_size] |
jb .error |
; Here we have 1 big free block which includes requested area. |
; In general, 3 other blocks must be created instead: |
; free at [esi, edx); |
; busy at [edx, edx+0x1000+ALIGN_UP(alloc_size,0x1000)); |
; free at [edx+0x1000+ALIGN_UP(alloc_size,0x1000), ecx) |
; First or third block (or both) may be absent. |
mov eax, edx |
sub eax, esi |
jz .nofirst |
or al, FREE_BLOCK |
mov [page_tabs+ebx*4], eax |
.nofirst: |
mov eax, [alloc_size] |
add eax, 0x1FFF |
and eax, not 0xFFF |
mov ebx, edx |
add edx, eax |
shr ebx, 12 |
or al, USED_BLOCK |
mov [page_tabs+ebx*4], eax |
shr eax, 12 |
dec eax |
jz .second_nofill |
inc ebx |
.fill: |
mov dword [page_tabs+ebx*4], 2 |
inc ebx |
dec eax |
jnz .fill |
.second_nofill: |
sub ecx, edx |
jz .nothird |
or cl, FREE_BLOCK |
mov [page_tabs+ebx*4], ecx |
.nothird: |
mov edx, [current_slot] |
mov ebx, [alloc_size] |
add ebx, 0xFFF |
and ebx, not 0xFFF |
add ebx, [edx+APPDATA.mem_size] |
call update_mem_size |
mov eax, [address] |
pop edi |
pop esi |
pop ebx |
ret |
endp |
align 4 |
proc user_free stdcall, base:dword |
push esi |
1221,10 → 1317,10 |
and eax, SHM_OPEN_MASK |
mov [action], eax |
mov eax, [name] |
test eax, eax |
mov ebx, [name] |
test ebx, ebx |
mov edx, E_PARAM |
jz .exit |
jz .fail |
mov esi, [shmem_list.fd] |
align 4 |
1233,7 → 1329,7 |
je .not_found |
lea edx, [esi+SMEM.name] ; link , base, size |
stdcall strncmp, edx, eax, 32 |
stdcall strncmp, edx, ebx, 32 |
test eax, eax |
je .found |
1245,7 → 1341,7 |
cmp eax, SHM_OPEN |
mov edx, E_NOTFOUND |
je .exit |
je .fail |
cmp eax, SHM_CREATE |
mov edx, E_PARAM |
1252,13 → 1348,13 |
je .create_shm |
cmp eax, SHM_OPEN_ALWAYS |
jne .exit |
jne .fail |
.create_shm: |
mov ecx, [size] |
test ecx, ecx |
jz .exit |
jz .fail |
add ecx, 4095 |
and ecx, -4096 |
1269,7 → 1365,7 |
test eax, eax |
mov esi, eax |
mov edx, E_NOMEM |
jz .exit |
jz .fail |
stdcall kernel_alloc, [size] |
test eax, eax |
1312,7 → 1408,7 |
je .create_map |
cmp eax, SHM_OPEN_ALWAYS |
jne .exit |
jne .fail |
.create_map: |
1321,7 → 1417,7 |
cmp eax, [esi+SMEM.access] |
mov [access], eax |
mov edx, E_ACCESS |
ja .exit |
ja .fail |
mov ebx, [CURRENT_TASK] |
shl ebx, 5 |
1332,12 → 1428,14 |
test eax, eax |
mov edi, eax |
mov edx, E_NOMEM |
jz .exit |
jz .fail |
inc [esi+SMEM.refcount] |
mov [edi+SMAP.magic], 'SMAP' |
mov [edi+SMAP.destroy], destroy_smap |
mov [edi+SMAP.parent], esi |
mov [edi+SMAP.base], 0 |
mov [edi+SMAP.parent], 0 |
stdcall user_alloc, [esi+SMEM.size] |
test eax, eax |
1345,9 → 1443,7 |
mov edx, E_NOMEM |
jz .cleanup2 |
lock inc [esi+SMEM.refcount] |
mov [edi+SMAP.base], eax |
mov [edi+SMAP.parent], esi |
mov ecx, [esi+SMEM.size] |
mov [size], ecx |
1374,10 → 1470,10 |
xor edx, edx |
cmp [owner_access], 0 |
jne .exit |
jne .fail |
.exit: |
mov edx, [size] |
.exit: |
.fail: |
mov eax, [mapped] |
popfd |
1385,13 → 1481,14 |
pop esi |
pop ebx |
ret |
.cleanup: |
mov [size], edx |
mov eax, esi |
call free |
jmp .exit |
.cleanup2: |
mov [size], edx |
mov eax, edi |
call destroy_smap |
jmp .exit |
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/malloc.inc |
---|
1,6 → 1,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
20,6 → 20,7 |
; esi= nb |
; ebx= idx |
; |
align 16 |
malloc: |
push esi |
134,13 → 135,17 |
mov [eax+12], ecx ; r->bk = B; |
mov eax, ebx |
pop esi |
mov [mst.mutex], 0 |
ret |
.small: |
; if (ms.treemap != 0 && (mem = malloc_small(nb)) != 0) |
cmp [mst.treemap], 0 |
je .from_top |
;;;;;;;;;;; start a change <lrz> |
mov eax,[mst.treemap] |
test eax,eax |
;;;;;;;;;;; end the change <lrz> |
; cmp [mst.treemap], 0 |
jz .from_top |
mov eax, esi |
call malloc_small |
test eax, eax |
196,7 → 201,6 |
; param |
; eax= mem |
align 4 |
free: |
push edi |
mov edi, eax |
246,7 → 250,7 |
shr ecx, 3 |
cmp eax, edx |
jne @F |
and [mst.smallmap], ecx |
btr [mst.smallmap], ecx |
@@: |
mov [eax+12], edx ;F->bk = B; |
mov [edx+8], eax ;B->fd = F |
383,7 → 387,6 |
; ecx = chunk |
; eax = size |
align 4 |
insert_chunk: |
cmp eax, 256 |
416,13 → 419,11 |
and [mst.mutex], 0 |
ret |
align 4 |
; param |
; esi= chunk |
; ebx= size |
align 4 |
insert_large_chunk: |
; I = compute_tree_index(S); |
475,7 → 476,6 |
shl eax, cl ;eax= K |
jmp .loop |
.not_eq_size: |
; C = &(T->child[(K >> 31) & 1]); |
517,7 → 517,6 |
mov [esi+8], eax |
mov [esi+12], edx |
ret |
.insert_child: |
; *C = X; |
536,7 → 535,6 |
; param |
; edx= chunk |
align 4 |
unlink_large_chunk: |
mov eax, [edx+12] |
593,6 → 591,7 |
btr [mst.treemap], ecx |
pop edi |
ret |
.l3: |
cmp [edi+16], edx |
jne @F |
599,11 → 598,14 |
mov [edi+16], eax |
jmp .l4 |
@@: |
mov [edi+20], eax |
.l4: |
test eax, eax |
je .done |
.l5: |
mov [eax+24], edi |
mov ecx, [edx+16] |
612,6 → 614,7 |
mov [eax+16], ecx |
mov [ecx+24], eax |
.l6: |
mov edx, [edx+20] |
test edx, edx |
619,6 → 622,7 |
mov [eax+20], edx |
mov [edx+24], eax |
.done: |
pop edi |
ret |
626,7 → 630,6 |
; param |
; esi= nb |
align 4 |
malloc_small: |
push ebp |
mov ebp, esi |
641,8 → 644,10 |
mov edi, [ecx+4] |
and edi, -4 |
sub edi, esi |
.loop: |
mov ebx, ecx |
.loop_1: |
; while ((t = leftmost_child(t)) != 0) |
652,8 → 657,10 |
jz @F |
mov ecx, eax |
jmp .l1 |
@@: |
mov ecx, [ecx+20] |
.l1: |
test ecx, ecx |
jz .unlink |
704,6 → 711,7 |
lea eax, [ebx+8] |
ret |
.split: |
; v->head = nb|PINUSE_BIT|CINUSE_BIT; |
736,6 → 744,7 |
pop ebp |
lea eax, [ebx+8] |
ret |
.large: |
lea eax, [ebx+8] |
push eax |
750,12 → 759,12 |
; param |
; esi= nb |
align 4 |
malloc_large: |
.idx equ esp+4 |
.rst equ esp |
push ebp |
push esi |
push edi |
sub esp, 8 |
; v = 0; |
789,11 → 798,13 |
jne @F |
xor ecx, ecx |
jmp .l1 |
@@: |
mov edx, ecx |
shr edx, 1 |
mov ecx, 37 |
sub ecx, edx |
.l1: |
mov edx, ebx |
shl edx, cl |
800,6 → 811,7 |
; rst = 0; |
mov [.rst], ebp |
.loop: |
; trem = (t->head & ~INUSE_BITS) - nb; |
819,6 → 831,7 |
mov ebp, eax |
mov edi, ecx |
je .l2 |
@@: |
; rt = t->child[1]; |
840,6 → 853,7 |
; rst = rt; |
mov [.rst], ecx |
@@: |
; if (t == 0) |
850,9 → 864,11 |
add edx, edx |
jmp .loop |
@@: |
; t = rst; |
mov eax, [.rst] |
.l2: |
; if (t == 0 && v == 0) |
861,6 → 877,7 |
test ebp, ebp |
jne .l7 |
mov ecx, [.idx] |
.l3: |
; leftbits = (-1<<idx) & ms.treemap; |
874,11 → 891,13 |
bsf eax, edx |
; t = ms.treebins[i]; |
mov eax, [mst.treebins+eax*4] |
@@: |
; while (t != 0) |
test eax, eax |
jz .l5 |
.l4: |
; trem = (t->head & ~INUSE_BITS) - nb; |
896,6 → 915,7 |
mov edi, ecx |
; v = t; |
mov ebp, eax |
@@: |
; t = leftmost_child(t); |
905,8 → 925,10 |
je @F |
mov eax, ecx |
jmp .l6 |
@@: |
mov eax, [eax+20] |
.l6: |
; while (t != 0) |
913,6 → 935,7 |
test eax, eax |
jne .l4 |
.l5: |
; if (v != 0) |
919,6 → 942,7 |
test ebp, ebp |
jz .done |
.l7: |
; r = chunk_plus_offset((mchunkptr)v, nb); |
947,8 → 971,10 |
lea eax, [ebp+8] |
add esp, 8 |
pop edi |
pop esi |
pop ebp |
ret |
.large: |
; v->head = nb|PINUSE_BIT|CINUSE_BIT; |
971,16 → 997,18 |
lea eax, [ebp+8] |
add esp, 8 |
pop edi |
pop esi |
pop ebp |
ret |
.done: |
add esp, 8 |
pop edi |
pop esi |
pop ebp |
xor eax, eax |
ret |
align 4 |
init_malloc: |
stdcall kernel_alloc, 0x40000 |
989,6 → 1017,7 |
mov [mst.topsize], 128*1024 |
mov dword [eax+4], (128*1024) or 1 |
mov eax, mst.smallbins |
@@: |
mov [eax+8], eax |
mov [eax+12], eax |
998,6 → 1027,3 |
ret |
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/memory.inc |
---|
1,6 → 1,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; |
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
167,7 → 167,7 |
@@: |
mov [page_tabs+eax*4], edx |
; push eax |
; invlpg [ebx] |
invlpg [ebx] |
; pop eax |
inc eax |
add ebx, edi |
205,7 → 205,7 |
@@: |
mov [page_tabs+ebx*4], eax |
; push eax |
; invlpg [edi] |
invlpg [edi] |
; pop eax |
add edi, edx |
add eax, edx |
321,8 → 321,17 |
cmp dword [LFBAddress], -1 |
jne @f |
mov [BOOT_VAR+0x901c],byte 2 |
stdcall kernel_alloc, 0x280000 |
mov [LFBAddress], eax |
stdcall alloc_pages, (0x280000 / 4096) |
push eax |
call alloc_page |
stdcall map_page_table, LFB_BASE, eax |
pop eax |
or eax, PG_UW |
mov ebx, LFB_BASE |
mov ecx, 0x280000 / 4096 |
call commit_pages |
mov [LFBAddress], dword LFB_BASE |
ret |
@@: |
test [SCR_MODE],word 0100000000000000b |
334,7 → 343,7 |
mov edx, LFB_BASE |
mov esi, [LFBAddress] |
mov edi, 0x00800000 |
mov edi, 0x00C00000 |
mov dword [exp_lfb+4], edx |
shr edi, 12 |
558,14 → 567,6 |
push ebx ;that is locals: .err_addr = cr2 |
inc [pg_data.pages_faults] |
; push eax |
; push edx |
; mov edx, 0x400 ;bochs |
; mov al,0xff ;bochs |
; out dx, al ;bochs |
; pop edx |
; pop eax |
mov eax, [pf_err_code] |
cmp ebx, OS_BASE ;ebx == .err_addr |
592,6 → 593,11 |
pop ebx ;restore exception number (#PF) |
ret |
; xchg bx, bx |
; add esp,12 ;clear in stack: locals(.err_addr) + #PF + ret_to_caller |
; restore_ring3_context |
; iretd |
.user_space: |
test eax, PG_MAP |
jnz .err_access ;Ñòðà Ãèöà ïðèñóòñòâóåò |
614,7 → 620,7 |
test eax, eax |
jz .fail |
stdcall map_page,[.err_addr],eax,dword PG_UW |
stdcall map_page,[.err_addr],eax,PG_UW |
mov edi, [.err_addr] |
and edi, 0xFFFFF000 |
627,9 → 633,40 |
restore_ring3_context |
iretd |
.err_access = .fail |
;Ãèêîãäà ÃÃ¥ ïðîèñõîäèò |
;jmp .fail |
.err_access: |
; access denied? this may be a result of copy-on-write protection for DLL |
; check list of HDLLs |
and ebx, not 0xFFF |
mov eax, [CURRENT_TASK] |
shl eax, 8 |
mov eax, [SLOT_BASE+eax+APPDATA.dlls_list_ptr] |
test eax, eax |
jz .fail |
mov esi, [eax+HDLL.fd] |
.scan_hdll: |
cmp esi, eax |
jz .fail |
mov edx, ebx |
sub edx, [esi+HDLL.base] |
cmp edx, [esi+HDLL.size] |
jb .fault_in_hdll |
.scan_hdll.next: |
mov esi, [esi+HDLL.fd] |
jmp .scan_hdll |
.fault_in_hdll: |
; allocate new page, map it as rw and copy data |
call alloc_page |
test eax, eax |
jz .fail |
stdcall map_page,ebx,eax,PG_UW |
mov edi, ebx |
mov ecx, 1024 |
sub ebx, [esi+HDLL.base] |
mov esi, [esi+HDLL.parent] |
mov esi, [esi+DLLDESCR.data] |
add esi, ebx |
rep movsd |
jmp .exit |
.kernel_space: |
test eax, PG_MAP |
677,14 → 714,17 |
jmp .exit |
endp |
align 4 |
proc map_mem stdcall, lin_addr:dword,pdir:dword,\ |
ofs:dword,buf_size:dword |
mov eax, [buf_size] |
test eax, eax |
; returns number of mapped bytes |
proc map_mem stdcall, lin_addr:dword,slot:dword,\ |
ofs:dword,buf_size:dword,req_access:dword |
push 0 ; initialize number of mapped bytes |
cmp [buf_size], 0 |
jz .exit |
mov eax, [pdir] |
mov eax, [slot] |
shl eax, 8 |
mov eax, [SLOT_BASE+eax+APPDATA.dir_table] |
and eax, 0xFFFFF000 |
stdcall map_page,[ipc_pdir],eax,PG_UW |
716,10 → 756,11 |
and edx, 0x3FF |
mov esi, [ipc_ptab] |
.map: mov eax, [esi+edx*4] |
and eax, 0xFFFFF000 |
jz .exit |
stdcall map_page,edi,eax,PG_UW |
.map: |
stdcall safe_map_page,[slot],[req_access],[ofs] |
jnc .exit |
add dword [ebp-4], 4096 |
add [ofs], 4096 |
dec ecx |
jz .exit |
add edi, 0x1000 |
736,20 → 777,23 |
jmp .map |
.exit: |
pop eax |
ret |
endp |
align 4 |
proc map_memEx stdcall, lin_addr:dword,pdir:dword,\ |
ofs:dword,buf_size:dword |
mov eax, [buf_size] |
test eax, eax |
proc map_memEx stdcall, lin_addr:dword,slot:dword,\ |
ofs:dword,buf_size:dword,req_access:dword |
push 0 ; initialize number of mapped bytes |
cmp [buf_size], 0 |
jz .exit |
mov eax, [pdir] |
mov eax, [slot] |
shl eax, 8 |
mov eax, [SLOT_BASE+eax+APPDATA.dir_table] |
and eax, 0xFFFFF000 |
stdcall map_page,[proc_mem_pdir],eax,dword PG_UW |
stdcall map_page,[proc_mem_pdir],eax,PG_UW |
mov ebx, [ofs] |
shr ebx, 22 |
mov esi, [proc_mem_pdir] |
758,7 → 802,7 |
and eax, 0xFFFFF000 |
test eax, eax |
jz .exit |
stdcall map_page,edi,eax,dword PG_UW |
stdcall map_page,edi,eax,PG_UW |
@@: mov edi, [lin_addr] |
and edi, 0xFFFFF000 |
772,22 → 816,102 |
and edx, 0x3FF |
mov esi, [proc_mem_tab] |
.map: mov eax, [esi+edx*4] |
; and eax, 0xFFFFF000 |
; test eax, eax |
; jz .exit |
stdcall map_page,edi,eax,dword PG_UW |
.map: |
stdcall safe_map_page,[slot],[req_access],[ofs] |
jnc .exit |
add dword [ebp-4], 0x1000 |
add edi, 0x1000 |
add [ofs], 0x1000 |
inc edx |
dec ecx |
jnz .map |
.exit: |
pop eax |
ret |
endp |
; in: esi+edx*4 = pointer to page table entry |
; in: [slot], [req_access], [ofs] on the stack |
; in: edi = linear address to map |
; out: CF cleared <=> failed |
; destroys: only eax |
proc safe_map_page stdcall, slot:dword, req_access:dword, ofs:dword |
mov eax, [esi+edx*4] |
test al, PG_MAP |
jz .not_present |
test al, PG_WRITE |
jz .resolve_readonly |
; normal case: writable page, just map with requested access |
.map: |
stdcall map_page, edi, eax, [req_access] |
stc |
.fail: |
ret |
.not_present: |
; check for alloc-on-demand page |
test al, 2 |
jz .fail |
; allocate new page, save it to source page table |
push ecx |
call alloc_page |
pop ecx |
test eax, eax |
jz .fail |
or al, PG_UW |
mov [esi+edx*4], eax |
jmp .map |
.resolve_readonly: |
; readonly page, probably copy-on-write |
; check: readonly request of readonly page is ok |
test [req_access], PG_WRITE |
jz .map |
; find control structure for this page |
pushf |
cli |
cld |
push ebx ecx |
mov eax, [slot] |
shl eax, 8 |
mov eax, [SLOT_BASE+eax+APPDATA.dlls_list_ptr] |
test eax, eax |
jz .no_hdll |
mov ecx, [eax+HDLL.fd] |
.scan_hdll: |
cmp ecx, eax |
jz .no_hdll |
mov ebx, [ofs] |
and ebx, not 0xFFF |
sub ebx, [ecx+HDLL.base] |
cmp ebx, [ecx+HDLL.size] |
jb .hdll_found |
mov ecx, [ecx+HDLL.fd] |
jmp .scan_hdll |
.no_hdll: |
pop ecx ebx |
popf |
clc |
ret |
.hdll_found: |
; allocate page, save it in page table, map it, copy contents from base |
mov eax, [ecx+HDLL.parent] |
add ebx, [eax+DLLDESCR.data] |
call alloc_page |
test eax, eax |
jz .no_hdll |
or al, PG_UW |
mov [esi+edx*4], eax |
stdcall map_page, edi, eax, [req_access] |
push esi edi |
mov esi, ebx |
mov ecx, 4096/4 |
rep movsd |
pop edi esi |
pop ecx ebx |
popf |
stc |
ret |
endp |
sys_IPC: |
;input: |
; eax=1 - set ipc buffer area |
870,15 → 994,15 |
mov ecx, [ipc_tmp] |
cmp esi, 0x40000-0x1000 ; size of [ipc_tmp] minus one page |
jbe @f |
push eax esi edi |
push esi edi |
add esi,0x1000 |
stdcall alloc_kernel_space,esi |
mov ecx, eax |
pop edi esi eax |
pop edi esi |
@@: |
mov [used_buf], ecx |
stdcall map_mem, ecx, [SLOT_BASE+eax+0xB8],\ |
edi, esi |
stdcall map_mem, ecx, [dst_slot],\ |
edi, esi, PG_SW |
mov edi, [dst_offset] |
add edi, [used_buf] |
986,109 → 1110,99 |
mov [ecx+24], eax |
ret |
.fail: |
mov dword [esp+32], -1 |
or dword [esp+32], -1 |
ret |
iglobal |
align 4 |
f68call: |
dd f68.11 |
dd f68.12 |
dd f68.13 |
dd f68.14 |
dd f68.11 ; init_heap |
dd f68.12 ; user_alloc |
dd f68.13 ; user_free |
dd f68.14 ; get_event_ex |
dd f68.fail ;moved to f68.24 |
dd f68.16 |
dd f68.17 |
dd f68.16 ; get_service |
dd f68.17 ; call_service |
dd f68.fail ;moved to f68.25 |
dd f68.19 |
dd f68.20 |
dd f68.21 |
dd f68.22 |
dd f68.23 |
dd f68.19 ; load_dll |
dd f68.20 ; user_realloc |
dd f68.21 ; load_driver |
dd f68.22 ; shmem_open |
dd f68.23 ; shmem_close |
dd f68.24 |
dd f68.25 |
endg |
align 4 |
f68: |
cmp eax,4 |
jle sys_sheduler |
cmp ebx,4 |
jbe sys_sheduler |
cmp eax, 11 |
cmp ebx, 11 |
jb .fail |
cmp eax, 25 |
cmp ebx, 25 |
ja .fail |
jmp dword [f68call+eax*4-11*4] |
jmp dword [f68call+ebx*4-11*4] |
.11: |
call init_heap |
mov [esp+36], eax |
mov [esp+32], eax |
ret |
.12: |
stdcall user_alloc, ebx |
mov [esp+36], eax |
stdcall user_alloc, ecx |
mov [esp+32], eax |
ret |
.13: |
stdcall user_free, ebx |
mov [esp+36], eax |
stdcall user_free, ecx |
mov [esp+32], eax |
ret |
.14: |
cmp ebx, OS_BASE |
cmp ecx, OS_BASE |
jae .fail |
mov edi,ebx |
mov edi,ecx |
call get_event_ex |
mov [esp+36], eax |
mov [esp+32], eax |
ret |
.24: |
mov eax, [current_slot] |
xchg ebx, [eax+APPDATA.exc_handler] |
xchg ecx, [eax+APPDATA.except_mask] |
mov [esp+36], ebx ; reg_eax+8 |
mov [esp+24], ecx ; reg_ebx+8 |
ret |
.16: |
test ebx, ebx |
test ecx, ecx |
jz .fail |
cmp ebx, OS_BASE |
cmp ecx, OS_BASE |
jae .fail |
stdcall get_service, ebx |
mov [esp+36], eax |
stdcall get_service, ecx |
mov [esp+32], eax |
ret |
.17: |
call srv_handlerEx ;ebx |
mov [esp+36], eax |
call srv_handlerEx ;ecx |
mov [esp+32], eax |
ret |
.25: |
cmp ebx,32 |
jae .fail |
mov eax, [current_slot] |
btr [eax+APPDATA.except_mask],ebx |
setc byte[esp+36] |
jecxz @f |
bts [eax+APPDATA.except_mask],ebx |
@@: ret |
.19: |
cmp ebx, OS_BASE |
cmp ecx, OS_BASE |
jae .fail |
stdcall load_library, ebx |
mov [esp+36], eax |
stdcall load_library, ecx |
mov [esp+32], eax |
ret |
.20: |
mov eax, ecx |
call user_realloc |
mov [esp+36], eax |
mov eax, edx |
mov ebx, ecx |
call user_realloc ;in: eax = pointer, ebx = new size |
mov [esp+32], eax |
ret |
.21: |
cmp ecx, OS_BASE |
jae .fail |
cmp ebx, OS_BASE |
jae .fail |
stdcall load_PE, ebx |
mov edi, edx |
stdcall load_PE, ecx |
mov esi, eax |
test eax, eax |
jz @F |
mov esi, eax |
stdcall eax, DRV_ENTRY |
push edi |
push DRV_ENTRY |
call eax |
add esp, 8 |
test eax, eax |
jz @F |
1095,28 → 1209,45 |
mov [eax+SRV.entry], esi |
@@: |
mov [esp+36], eax |
mov [esp+32], eax |
ret |
.22: |
cmp ebx, OS_BASE |
cmp ecx, OS_BASE |
jae .fail |
stdcall shmem_open, ebx, ecx, edx |
mov [esp+28], edx |
mov [esp+36], eax |
stdcall shmem_open, ecx, edx, esi |
mov [esp+24], edx |
mov [esp+32], eax |
ret |
.23: |
cmp ebx, OS_BASE |
cmp ecx, OS_BASE |
jae .fail |
stdcall shmem_close, ebx |
mov [esp+36], eax |
stdcall shmem_close, ecx |
mov [esp+32], eax |
ret |
.24: |
mov eax, [current_slot] |
xchg ecx, [eax+APPDATA.exc_handler] |
xchg edx, [eax+APPDATA.except_mask] |
mov [esp+32], ecx ; reg_eax+8 |
mov [esp+20], edx ; reg_ebx+8 |
ret |
.25: |
cmp ecx,32 |
jae .fail |
mov eax, [current_slot] |
btr [eax+APPDATA.except_mask],ecx |
setc byte[esp+32] |
jecxz @f |
bts [eax+APPDATA.except_mask],ecx |
@@: |
ret |
.fail: |
xor eax, eax |
mov [esp+36], eax |
mov [esp+32], eax |
ret |
align 4 |
1156,41 → 1287,52 |
mov ecx, 0x2FF |
rdmsr ; |
; has BIOS already initialized MTRRs? |
test ah, 8 |
jnz .skip_init |
; rarely needed, so mainly placeholder |
; main memory - cached |
push eax |
xor edx, edx |
xor eax, eax |
mov ecx, 0x2FF |
wrmsr ;disable all MTRR |
mov eax, [MEM_AMOUNT] |
; round eax up to next power of 2 |
dec eax |
bsr ecx, eax |
mov eax, 2 |
shl eax, cl |
stdcall set_mtrr, edx,edx,eax,MEM_WB |
stdcall set_mtrr, 1,[LFBAddress],[LFBSize],MEM_WC |
mov ebx, 2 |
shl ebx, cl |
dec ebx |
; base of memory range = 0, type of memory range = MEM_WB |
xor edx, edx |
mov eax, MEM_WB |
mov ecx, 0x200 |
wrmsr |
; mask of memory range = 0xFFFFFFFFF - (size - 1), ebx = size - 1 |
mov eax, 0xFFFFFFFF |
mov edx, 0x0000000F |
sub eax, ebx |
sbb edx, 0 |
or eax, 0x800 |
inc ecx |
wrmsr |
; clear unused MTRRs |
xor eax, eax |
mov ecx, 0x204 |
mov ebx, 6 |
xor edx, edx |
@@: |
wrmsr ;disable unused MTRR |
wrmsr |
inc ecx |
cmp ecx, 0x210 |
jb @b |
; enable MTRRs |
pop eax |
or ah, 8 |
and al, 0xF0 ; default memtype = UC |
mov ecx, 0x2FF |
wrmsr |
inc ecx |
dec ebx |
jnz @b |
.skip_init: |
stdcall set_mtrr, [LFBAddress],[LFBSize],MEM_WC |
wbinvd ;again invalidate |
pop eax |
or eax, 0x800 ;set default memtype to UC |
and al, 0xF0 |
mov ecx, 0x2FF |
wrmsr ;and enable MTRR |
mov eax, cr0 |
and eax, not 0x60000000 |
mov cr0, eax ; enable caching |
1199,13 → 1341,29 |
endp |
align 4 |
proc set_mtrr stdcall, reg:dword,base:dword,size:dword,mem_type:dword |
proc set_mtrr stdcall, base:dword,size:dword,mem_type:dword |
; find unused register |
mov ecx, 0x201 |
@@: |
rdmsr |
dec ecx |
test ah, 8 |
jz .found |
rdmsr |
mov al, 0 ; clear memory type field |
cmp eax, [base] |
jz .ret |
add ecx, 3 |
cmp ecx, 0x210 |
jb @b |
; no free registers, ignore the call |
.ret: |
ret |
.found: |
; found, write values |
xor edx, edx |
mov eax, [base] |
or eax, [mem_type] |
mov ecx, [reg] |
lea ecx, [0x200+ecx*2] |
wrmsr |
mov ebx, [size] |
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/peload.inc |
---|
280,6 → 280,8 |
__exports: |
export 'KERNEL', \ |
alloc_kernel_space, 'AllocKernelSpace', \ ; stdcall |
alloc_page, 'AllocPage', \ ; gcc ABI |
alloc_pages, 'AllocPages', \ ; stdcall |
commit_pages, 'CommitPages', \ ; eax, ebx, ecx |
create_kernel_object, 'CreateObject', \ |
create_ring_buffer, 'CreateRingBuffer', \ ; stdcall |
287,17 → 289,12 |
free_kernel_space, 'FreeKernelSpace', \ ; stdcall |
kernel_alloc, 'KernelAlloc', \ ; stdcall |
kernel_free, 'KernelFree', \ ; stdcall |
alloc_pages, 'AllocPages', \ ; stdcall |
malloc, 'Kmalloc', \ |
free, 'Kfree', \ |
map_io_mem, 'MapIoMem', \ ; stdcall |
get_pg_addr, 'GetPgAddr', \ ; eax |
\ |
select_hw_cursor, 'SelectHwCursor', \ ; stdcall |
set_hw_cursor, 'SetHwCursor', \ ; stdcall |
hw_restore, 'HwCursorRestore', \ ; |
create_cursor, 'HwCursorCreate', \ ; |
\ |
get_display, 'GetDisplay', \ |
set_screen, 'SetScreen', \ |
pci_api, 'PciApi', \ |
pci_read8, 'PciRead8', \ ; stdcall |
307,6 → 304,7 |
pci_write16, 'PciWrite16', \ ; stdcall |
pci_write32, 'PciWrite32', \ ; stdcall |
\ |
get_service, 'GetService', \ ; |
reg_service, 'RegService', \ ; stdcall |
attach_int_handler, 'AttachIntHandler', \ ; stdcall |
user_alloc, 'UserAlloc', \ ; stdcall |
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/sched.inc |
---|
174,8 → 174,23 |
cmp eax, [esi+ecx] ;offset>0x7F |
je @f |
mov cr3, eax |
@@: ; set tss.esp0 |
@@: |
; set tss.esp0 |
Mov [tss._esp0],eax,[ebx+APPDATA.saved_esp0] |
mov edx, [ebx+APPDATA.tls_base] |
cmp edx, [esi+APPDATA.tls_base] |
je @f |
mov [tls_data_l+2],dx |
shr edx,16 |
mov [tls_data_l+4],dl |
mov [tls_data_l+7],dh |
mov dx, app_tls |
mov fs, dx |
@@: |
; set gs selector unconditionally |
Mov gs,ax,graph_data |
; set CR0.TS |
211,6 → 226,7 |
.arg dd ? |
} |
MAX_PROIRITY 0 ; highest, used for kernel tasks |
MAX_USER_PRIORITY 0 ; highest priority for user processes |
USER_PRIORITY 7 ; default (should correspond to nice 0) |
218,7 → 234,9 |
IDLE_PRIORITY 15 ; lowest, only IDLE process goes here |
NR_SCHED_QUEUES 16 ; MUST equal IDLE_PRIORYTY + 1 |
uglobal |
rdy_head rd 16 |
endg |
align 4 |
pick_task: |
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/string.inc |
---|
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/sync.inc |
---|
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/sys32.inc |
---|
279,14 → 279,19 |
iret |
ready_for_next_irq: |
mov [check_idle_semaphore],5 |
mov al, 0x20 |
mov eax,5 |
mov [check_idle_semaphore],eax |
; mov al, 0x20 |
add eax,(0x20-0x5) |
out 0x20, al |
ret |
;destroy eax |
ready_for_next_irq_1: |
mov [check_idle_semaphore],5 |
mov al, 0x20 |
mov eax,5 |
mov [check_idle_semaphore],eax |
; mov al, 0x20 |
add eax,(0x20-0x5) |
out 0xa0,al |
out 0x20, al |
ret |
293,7 → 298,7 |
irqD: |
push eax |
mov al,0 |
xor eax,eax |
out 0xf0,al |
mov al,0x20 |
out 0xa0,al |
396,7 → 401,8 |
cmp eax,[application_table_status] |
jne apptsl1 |
mov [application_table_status],0 |
xor eax,eax |
mov [application_table_status],eax |
apptsl1: |
pop eax |
403,30 → 409,25 |
ret |
; * eax = 64 - Ãîìåð ôóÃêöèè |
; * ebx = 1 - åäèÃñòâåÃÃà ÿ ïîäôóÃêöèÿ |
; * ecx = Ãîâûé ðà çìåð ïà ìÿòè |
;Âîçâðà ùà åìîå çÃà ÷åÃèå: |
; * eax = 0 - óñïåøÃî |
; * eax = 1 - Ãåäîñòà òî÷Ãî ïà ìÿòè |
sys_resize_app_memory: |
; eax = 1 - resize |
; ebx = new amount of memory |
; ebx = 1 - resize |
; ecx = new amount of memory |
cmp eax,1 |
jne .no_application_mem_resize |
stdcall new_mem_resize, ebx |
mov [esp+36], eax |
ret |
; cmp eax,1 |
dec ebx |
jnz .no_application_mem_resize |
stdcall new_mem_resize, ecx |
mov [esp+32], eax |
.no_application_mem_resize: |
ret |
sys_threads: |
; eax=1 create thread |
; |
; ebx=thread start |
; ecx=thread stack value |
; |
; on return : eax = pid |
jmp new_sys_threads |
iglobal |
; process_terminating db 'K : Process - terminating',13,10,0 |
; process_terminated db 'K : Process - done',13,10,0 |
497,10 → 498,10 |
pop esi |
jmp @B |
@@: |
mov eax, [.slot] |
shl eax, 8 |
mov eax,[SLOT_BASE+eax+APPDATA.dir_table] |
stdcall destroy_app_space, eax |
stdcall destroy_app_space, [SLOT_BASE+eax+APPDATA.dir_table], [SLOT_BASE+eax+APPDATA.dlls_list_ptr] |
mov esi, [.slot] |
cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 |
586,13 → 587,13 |
shl esi,5 |
add esi,window_data |
mov eax,[esi+WDATA.box.left] |
mov [dlx],eax |
mov [draw_limits.left],eax |
add eax,[esi+WDATA.box.width] |
mov [dlxe],eax |
mov [draw_limits.right],eax |
mov eax,[esi+WDATA.box.top] |
mov [dly],eax |
mov [draw_limits.top],eax |
add eax,[esi+WDATA.box.height] |
mov [dlye],eax |
mov [draw_limits.bottom],eax |
xor eax, eax |
mov [esi+WDATA.box.left],eax |
641,12 → 642,12 |
add edi,SLOT_BASE |
mov eax, [edi+APPDATA.io_map] |
cmp eax, (tss._io_map_0-OS_BASE+PG_MAP) |
cmp eax, [SLOT_BASE+256+APPDATA.io_map] |
je @F |
call free_page |
@@: |
mov eax, [edi+APPDATA.io_map+4] |
cmp eax, (tss._io_map_1-OS_BASE+PG_MAP) |
cmp eax, [SLOT_BASE+256+APPDATA.io_map+4] |
je @F |
call free_page |
@@: |
689,22 → 690,22 |
cmp [hd1_status], esi |
jnz @f |
call free_hd_channel |
mov [hd1_status], 0 |
and [hd1_status], 0 |
@@: |
cmp [cd_status], esi |
jnz @f |
call free_cd_channel |
mov [cd_status], 0 |
and [cd_status], 0 |
@@: |
cmp [flp_status], esi |
jnz @f |
mov [flp_status], 0 |
and [flp_status], 0 |
@@: |
pop esi |
cmp [bgrlockpid], esi |
jnz @f |
and [bgrlockpid], 0 |
mov [bgrlock], 0 |
and [bgrlock], 0 |
@@: |
pusha ; remove all irq reservations |
736,8 → 737,8 |
mov esi,[RESERVED_PORTS] |
cmp esi,0 |
je rmpr9 |
test esi,esi |
jz rmpr9 |
rmpr3: |
796,10 → 797,10 |
; call systest |
sti ; .. and life goes on |
mov eax, [dlx] |
mov ebx, [dly] |
mov ecx, [dlxe] |
mov edx, [dlye] |
mov eax, [draw_limits.left] |
mov ebx, [draw_limits.top] |
mov ecx, [draw_limits.right] |
mov edx, [draw_limits.bottom] |
call calculatescreen |
xor eax, eax |
xor esi, esi |
808,7 → 809,7 |
mov [MOUSE_BACKGROUND],byte 0 ; no mouse background |
mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse |
mov [application_table_status],0 |
and [application_table_status],0 |
;mov esi,process_terminated |
;call sys_msg_board_str |
add esp, 4 |
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/syscall.inc |
---|
20,7 → 20,6 |
call dword [servetable+edi*4] |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; SYSENTER ENTRY ;; |
123,17 → 122,9 |
dd 0 |
dd 0 |
dd 0 |
dd sys_midi ; 20-ResetMidi and OutputMidi |
dd sys_setup ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,. |
dd sys_settime ; 22-setting date,time,clock and alarm-clock |
dd 0 |
dd syscall_cdaudio ; 24-PlayCdTrack,StopCd and GetCdPlaylist |
dd 0 ; |
dd sys_getsetup ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,. |
dd 0 |
dd 0 ; |
dd 0 |
dd sys_current_directory ; 30-Get/SetCurrentDirectory |
dd 0 |
dd 0 |
dd 0 |
140,27 → 131,35 |
dd 0 |
dd 0 |
dd 0 |
dd readmousepos ; 37-GetMousePosition_ScreenRelative,. |
dd 0 ; 38-DrawLine |
dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,. |
dd 0 |
dd 0 |
dd 0 |
dd sys_outport ; 43-SendDeviceData |
dd 0 |
dd 0 |
dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea |
dd display_number ; 47-WriteNum |
dd display_settings ; 48-SetRedrawType and SetButtonType |
dd sys_apm ; 49-Advanced Power Management (APM) |
dd random_shaped_window ; 50-Window shape & scale |
dd syscall_threads ; 51-Threads |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd sound_interface ; 55-Sound interface |
dd 0 |
dd sys_pcibios ; 57-PCI BIOS32 |
dd 0 |
dd file_system ; 58-Common file system interface |
dd 0 |
dd sys_IPC ; 60-Inter Process Communication |
167,16 → 166,14 |
dd sys_gs ; 61-Direct graphics access |
dd sys_pci ; 62-PCI functions |
dd sys_msg_board ; 63-System message board |
dd sys_resize_app_memory ; 64-Resize application memory usage |
dd 0 |
dd syscall_putimage_palette; 65-PutImagePalette |
dd sys_process_def ; 66-Process definitions - keyboard |
dd sys_window_move ; 67-Window move or resize |
dd f68 ; 68-Some internal services |
dd sys_debug_services ; 69-Debug |
dd 0 |
dd 0 |
dd file_system_lfn ; 70-Common file system interface, version 2 |
dd syscall_windowsettings ; 71-Window settings |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; NEW SYSTEM FUNCTIONS TABLE ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
191,7 → 188,7 |
dd delay_hs ; 5-DelayHs |
dd syscall_openramdiskfile ; 6-OpenRamdiskFile |
dd syscall_putimage ; 7-PutImage |
dd sys_button ; 8-DefineButton |
dd syscall_button ; 8-DefineButton |
dd sys_cpuusage ; 9-GetProcessInfo |
dd sys_waitforevent ; 10-WaitForEvent |
dd sys_getevent ; 11-CheckForEvent |
203,17 → 200,17 |
dd sys_getbutton ; 17-GetButton |
dd sys_system ; 18-System Services |
dd paleholder ; 19-reserved |
dd cross_order ; 20-ResetMidi and OutputMidi |
dd cross_order ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,. |
dd cross_order ; 22-setting date,time,clock and alarm-clock |
dd sys_midi ; 20-ResetMidi and OutputMidi |
dd sys_setup ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,. |
dd sys_settime ; 22-setting date,time,clock and alarm-clock |
dd sys_wait_event_timeout ; 23-TimeOutWaitForEvent |
dd cross_order ; 24-PlayCdTrack,StopCd and GetCdPlaylist |
dd syscall_cdaudio ; 24-PlayCdTrack,StopCd and GetCdPlaylist |
dd undefined_syscall ; 25-reserved |
dd cross_order ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,. |
dd sys_getsetup ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,. |
dd undefined_syscall ; 27-reserved |
dd undefined_syscall ; 28-reserved |
dd sys_date ; 29-GetDate |
dd cross_order ; 30-Get/SetCurrentDirectory |
dd sys_current_directory ; 30-Get/SetCurrentDirectory |
dd undefined_syscall ; 31-reserved |
dd undefined_syscall ; 32-reserved |
dd undefined_syscall ; 33-reserved |
220,27 → 217,27 |
dd undefined_syscall ; 34-reserved |
dd syscall_getpixel ; 35-GetPixel |
dd syscall_getarea ; 36-GetArea |
dd cross_order ; 37-GetMousePosition_ScreenRelative,. |
dd readmousepos ; 37-GetMousePosition_ScreenRelative,. |
dd syscall_drawline ; 38-DrawLine |
dd cross_order ; 39-GetBackgroundSize,ReadBgrData,. |
dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,. |
dd set_app_param ; 40-WantEvents |
dd syscall_getirqowner ; 41-GetIrqOwner |
dd get_irq_data ; 42-ReadIrqData |
dd cross_order ; 43-SendDeviceData |
dd sys_outport ; 43-SendDeviceData |
dd sys_programirq ; 44-ProgramIrqs |
dd reserve_free_irq ; 45-ReserveIrq and FreeIrq |
dd cross_order ; 46-ReservePortArea and FreePortArea |
dd cross_order ; 47-WriteNum |
dd cross_order ; 48-SetRedrawType and SetButtonType |
dd cross_order ; 49-Advanced Power Management (APM) |
dd cross_order ; 50-Window shape & scale |
dd cross_order ; 51-Threads |
dd cross_order ; 52-Stack driver status |
dd cross_order ; 53-Socket interface |
dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea |
dd display_number ; 47-WriteNum |
dd syscall_display_settings ; 48-SetRedrawType and SetButtonType |
dd sys_apm ; 49-Advanced Power Management (APM) |
dd syscall_set_window_shape ; 50-Window shape & scale |
dd syscall_threads ; 51-Threads |
dd undefined_syscall ; 52-Stack driver status |
dd undefined_syscall ; 53-Socket interface |
dd undefined_syscall ; 54-reserved |
dd cross_order ; 55-Sound interface |
dd undefined_syscall ; 56-reserved |
dd cross_order ; 57-PCI BIOS32 |
dd sys_pcibios ; 57-PCI BIOS32 |
dd cross_order ; 58-Common file system interface |
dd undefined_syscall ; 59-reserved |
dd cross_order ; 60-Inter Process Communication |
247,14 → 244,14 |
dd cross_order ; 61-Direct graphics access |
dd cross_order ; 62-PCI functions |
dd cross_order ; 63-System message board |
dd cross_order ; 64-Resize application memory usage |
dd sys_resize_app_memory ; 64-Resize application memory usage |
dd cross_order ; 65-PutImagePalette |
dd cross_order ; 66-Process definitions - keyboard |
dd cross_order ; 67-Window move or resize |
dd cross_order ; 68-Some internal services |
dd cross_order ; 69-Debug |
dd f68 ; 68-Some internal services |
dd sys_debug_services ; 69-Debug |
dd cross_order ; 70-Common file system interface, version 2 |
dd cross_order ; 71-Window settings |
dd syscall_windowsettings ; 71-Window settings |
dd sys_sendwindowmsg ; 72-Send window message |
dd sys_network ; 73-Network stack |
dd sys_socket ; 74-Sockets |
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/taskman.inc |
---|
113,6 → 113,7 |
popad |
mov eax, -ERROR_FILE_NOT_FOUND |
ret |
.namecopied: |
mov [cmdline], ebx |
150,8 → 151,8 |
.get_lock: |
mov eax, 1 |
xchg eax, [application_table_status] |
cmp eax, 0 |
jne .wait_lock |
test eax, eax |
jnz .wait_lock |
call set_application_table_status |
201,6 → 202,14 |
mov eax,[hdr_mem] |
mov [ebx+APPDATA.mem_size],eax |
xor edx, edx |
cmp word [6], '02' |
jne @f |
not edx |
@@: |
mov [ebx+APPDATA.tls_base],edx |
if GREEDY_KERNEL |
else |
mov ecx, [hdr_mem] |
278,8 → 287,10 |
.check_01_header: |
cmp [eax+6],word '01' |
je @f |
cmp [eax+6], word '02' |
jne .fail |
@@: |
mov ecx,[APP_HEADER_01.start] |
mov [ebx+0x08], ecx ;app_eip |
mov edx,[APP_HEADER_01.mem_size] |
475,7 → 486,7 |
dec [pg_data.pg_mutex] |
cmp [dir_addr], 0 |
je @f |
stdcall destroy_app_space, [dir_addr] |
stdcall destroy_app_space, [dir_addr], 0 |
@@: |
xor eax, eax |
ret |
512,12 → 523,10 |
endp |
align 4 |
proc destroy_app_space stdcall, pg_dir:dword |
proc destroy_app_space stdcall, pg_dir:dword, dlls_list:dword |
mov ebx, pg_data.pg_mutex |
call wait_mutex ;ebx |
xor edx,edx |
push edx |
mov eax,0x2 |
mov ebx, [pg_dir] |
.loop: |
527,8 → 536,10 |
cmp byte [CURRENT_TASK+ecx+0xa],9 ;if process running? |
jz @f ;skip empty slots |
shl ecx,3 |
cmp [SLOT_BASE+ecx+0xB8],ebx ;compare page directory addresses |
add ecx,SLOT_BASE |
cmp [ecx+APPDATA.dir_table],ebx ;compare page directory addresses |
jnz @f |
mov [ebp-4],ecx |
inc edx ;thread found |
@@: |
inc eax |
537,13 → 548,19 |
;edx = number of threads |
;our process is zombi so it isn't counted |
pop ecx |
cmp edx,1 |
jg .exit |
jg .ret |
;if there isn't threads then clear memory. |
mov esi, [dlls_list] |
call destroy_all_hdlls |
mov ebx, pg_data.pg_mutex |
call wait_mutex ;ebx |
mov eax, [pg_dir] |
and eax, not 0xFFF |
stdcall map_page,[tmp_task_pdir],eax,dword PG_SW |
stdcall map_page,[tmp_task_pdir],eax,PG_SW |
mov esi, [tmp_task_pdir] |
mov edi, (OS_BASE shr 20)/4 |
.destroy: |
551,7 → 568,7 |
test eax, 1 |
jz .next |
and eax, not 0xFFF |
stdcall map_page,[tmp_task_ptab],eax,dword PG_SW |
stdcall map_page,[tmp_task_ptab],eax,PG_SW |
stdcall destroy_page_table, [tmp_task_ptab] |
mov eax, [esi] |
call free_page |
563,9 → 580,10 |
mov eax, [pg_dir] |
call free_page |
.exit: |
stdcall map_page,[tmp_task_ptab],dword 0,dword PG_UNMAP |
stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP |
stdcall map_page,[tmp_task_ptab],0,PG_UNMAP |
stdcall map_page,[tmp_task_pdir],0,PG_UNMAP |
dec [pg_data.pg_mutex] |
.ret: |
ret |
endp |
613,24 → 631,24 |
check_region: |
;input: |
; ebx - start of buffer |
; ecx - size of buffer |
; esi - start of buffer |
; edx - size of buffer |
;result: |
; eax = 1 region lays in app memory |
; eax = 0 region don't lays in app memory |
mov eax,[CURRENT_TASK] |
jmp check_process_region |
; jmp check_process_region |
;----------------------------------------------------------------------------- |
check_process_region: |
;check_process_region: |
;input: |
; eax - slot |
; ebx - start of buffer |
; ecx - size of buffer |
; esi - start of buffer |
; edx - size of buffer |
;result: |
; eax = 1 region lays in app memory |
; eax = 0 region don't lays in app memory |
test ecx,ecx |
test edx,edx |
jle .ok |
shl eax,5 |
cmp word [CURRENT_TASK+eax+0xa],0 |
698,9 → 716,9 |
proc read_process_memory |
;Input: |
; eax - process slot |
; ebx - buffer address |
; ecx - buffer size |
; edx - start address in other process |
; ecx - buffer address |
; edx - buffer size |
; esi - start address in other process |
;Output: |
; eax - number of bytes read. |
locals |
712,10 → 730,10 |
endl |
mov [slot], eax |
mov [buff], ebx |
mov [buff], ecx |
and [r_count], 0 |
mov [tmp_r_cnt], ecx |
mov [offset], edx |
mov [tmp_r_cnt], edx |
mov [offset], esi |
pushad |
.read_mem: |
733,18 → 751,22 |
jna @F |
mov ecx, 0x8000 |
@@: |
mov eax, [slot] |
shl eax,8 |
mov ebx, [offset] |
; add ebx, new_app_base |
push ecx |
stdcall map_memEx, [proc_mem_map],\ |
[SLOT_BASE+eax+0xB8],\ |
ebx, ecx |
[slot], ebx, ecx, PG_MAP |
pop ecx |
mov esi, [offset] |
and esi, 0xfff |
sub eax, esi |
jbe .ret |
cmp ecx, eax |
jbe @f |
mov ecx, eax |
mov [tmp_r_cnt], eax |
@@: |
add esi, [proc_mem_map] |
mov edi, [buff] |
mov edx, ecx |
754,7 → 776,7 |
add [offset], edx |
sub [tmp_r_cnt], edx |
jnz .read_mem |
.ret: |
popad |
mov eax, [r_count] |
ret |
764,9 → 786,9 |
proc write_process_memory |
;Input: |
; eax - process slot |
; ebx - buffer address |
; ecx - buffer size |
; edx - start address in other process |
; ecx - buffer address |
; edx - buffer size |
; esi - start address in other process |
;Output: |
; eax - number of bytes written |
779,10 → 801,10 |
endl |
mov [slot], eax |
mov [buff], ebx |
mov [buff], ecx |
and [w_count], 0 |
mov [tmp_w_cnt], ecx |
mov [offset], edx |
mov [tmp_w_cnt], edx |
mov [offset], esi |
pushad |
.read_mem: |
800,18 → 822,22 |
jna @F |
mov ecx, 0x8000 |
@@: |
mov eax, [slot] |
shl eax,8 |
mov ebx, [offset] |
; add ebx, new_app_base |
push ecx |
stdcall map_memEx, [proc_mem_map],\ |
[SLOT_BASE+eax+0xB8],\ |
ebx, ecx |
[slot], ebx, ecx, PG_SW |
pop ecx |
mov edi, [offset] |
and edi, 0xfff |
sub eax, edi |
jbe .ret |
cmp ecx, eax |
jbe @f |
mov ecx, eax |
mov [tmp_w_cnt], eax |
@@: |
add edi, [proc_mem_map] |
mov esi, [buff] |
mov edx, ecx |
821,7 → 847,7 |
add [offset], edx |
sub [tmp_w_cnt], edx |
jnz .read_mem |
.ret: |
popad |
mov eax, [w_count] |
ret |
838,15 → 864,14 |
app_mem dd ? ;0x10 |
endl |
cmp eax,1 |
cmp ebx,1 |
jne .failed ;other subfunctions |
xor eax,eax |
mov [app_eip], ecx |
mov [app_cmdline], eax |
mov [app_esp], edx |
mov [app_path], eax |
mov [app_eip], ebx |
mov [app_esp], ecx |
;mov esi,new_process_loading |
;call sys_msg_board_str |
.wait_lock: |
858,8 → 883,8 |
.get_lock: |
mov eax, 1 |
xchg eax, [application_table_status] |
cmp eax, 0 |
jne .wait_lock |
test eax, eax |
jnz .wait_lock |
call set_application_table_status |
897,6 → 922,21 |
mov ecx,[ebx+APPDATA.dir_table] |
mov [edx+APPDATA.dir_table],ecx ;copy page directory |
mov eax,[ebx+APPDATA.dlls_list_ptr] |
mov [edx+APPDATA.dlls_list_ptr],eax |
mov eax, [ebx+APPDATA.tls_base] |
test eax, eax |
jz @F |
push edx |
stdcall user_alloc, 4096 |
pop edx |
test eax, eax |
jz .failed1 ;eax=0 |
@@: |
mov [edx+APPDATA.tls_base], eax |
lea eax, [app_cmdline] |
stdcall set_app_params ,[slot],eax,dword 0,\ |
dword 0,dword 0 |
903,13 → 943,15 |
;mov esi,new_process_running |
;call sys_msg_board_str ;output information about succefull startup |
mov [application_table_status],0 ;unlock application_table_status mutex |
xor eax,eax |
mov [application_table_status],eax ;unlock application_table_status mutex |
mov eax,[process_number] ;set result |
ret |
.failed: |
mov [application_table_status],0 |
mov eax,-1 |
xor eax,eax |
.failed1: |
mov [application_table_status],eax |
dec eax ;-1 |
ret |
endp |
931,6 → 973,24 |
pop eax |
ret |
align 4 |
tls_app_entry: |
call init_heap |
stdcall user_alloc, 4096 |
mov edx, [current_slot] |
mov [edx+APPDATA.tls_base], eax |
mov [tls_data_l+2],ax |
shr eax,16 |
mov [tls_data_l+4],al |
mov [tls_data_l+7],ah |
mov dx, app_tls |
mov fs, dx |
popad |
iretd |
EFL_IF equ 0x0200 |
EFL_IOPL1 equ 0x1000 |
EFL_IOPL2 equ 0x2000 |
959,10 → 1019,10 |
mov [eax+SLOT_BASE+APPDATA.except_mask], 0 |
;set default io permission map |
mov [eax+SLOT_BASE+APPDATA.io_map],\ |
(tss._io_map_0-OS_BASE+PG_MAP) |
mov [eax+SLOT_BASE+APPDATA.io_map+4],\ |
(tss._io_map_1-OS_BASE+PG_MAP) |
mov ecx, [SLOT_BASE+256+APPDATA.io_map] |
mov [eax+SLOT_BASE+APPDATA.io_map], ecx |
mov ecx, [SLOT_BASE+256+APPDATA.io_map+4] |
mov [eax+SLOT_BASE+APPDATA.io_map+4], ecx |
mov esi, fpu_data |
mov ecx, 512/4 |
1037,6 → 1097,11 |
shl ebx,5 |
lea ecx,[draw_data+ebx] ;ecx - pointer to draw data |
mov edx, irq0.return |
cmp [ebx*8+SLOT_BASE+APPDATA.tls_base], -1 |
jne @F |
mov edx, tls_app_entry |
@@: |
; set window state to 'normal' (non-minimized/maximized/rolled-up) state |
mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL |
mov [ebx+window_data+WDATA.fl_redraw], 1 |
1050,9 → 1115,9 |
mov [ebx+4],eax ;set PID |
;set draw data to full screen |
mov [ecx+0],dword 0 |
mov [ecx+4],dword 0 |
xor eax,eax |
mov [ecx+0],dword eax |
mov [ecx+4],dword eax |
mov eax,[Screen_Max_X] |
mov [ecx+8],eax |
mov eax,[Screen_Max_Y] |
1063,7 → 1128,7 |
lea ecx, [ebx+REG_EIP] |
xor eax, eax |
mov [ebx+REG_RET], dword irq0.return |
mov [ebx+REG_RET], edx |
mov [ebx+REG_EDI], eax |
mov [ebx+REG_ESI], eax |
mov [ebx+REG_EBP], eax |
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/test_malloc.asm |
---|
0,0 → 1,223 |
; Tests of malloc()/free() from the kernel heap. |
; This file is not included in the kernel, it is just test application. |
use32 |
db 'MENUET01' |
dd 1, start, i_end, mem, mem, 0, 0 |
start: |
; Zero-initialize uglobals (as in kernel at boot) |
mov ecx, (zeroend - zerostart + 3) / 4 |
xor eax, eax |
mov edi, zerostart |
rep stosd |
; Initialize small heap (as in kernel at boot) |
call init_malloc |
; Run tests |
call run_test1 |
call run_test2 |
call run_test3 |
; All is OK, return |
or eax, -1 |
int 0x40 |
run_test1: |
; basic test |
mov eax, 1 |
call malloc_with_test |
mov byte [eax], 0xDD |
mov esi, eax |
mov eax, 1 |
call malloc_with_test |
cmp byte [esi], 0xDD |
jnz memory_destroyed |
mov byte [eax], 0xEE |
xchg eax, esi |
call free |
cmp byte [esi], 0xEE |
jnz memory_destroyed |
xchg eax, esi |
call free |
ret |
run_test2: |
ret |
run_test3: |
; 1024000 times run random operation. |
; Randomly select malloc(random size from 1 to 1023) |
; or free(random of previously allocated areas) |
mov edi, 0x12345678 |
xor esi, esi ; 0 areas allocated |
mov ebx, 1024000 |
.loop: |
imul edi, 1103515245 |
add edi, 12345 |
mov eax, edi |
shr eax, 16 |
test ebx, 64 |
jz .prefer_free |
.prefer_malloc: |
test eax, 3 |
jz .free |
jmp @f |
.prefer_free: |
test eax, 3 |
jnz .free |
@@: |
shr eax, 2 |
and eax, 1023 |
jz .loop |
push ebx |
push eax |
; mov ecx, [saved_state_num] |
; mov [saved_state+ecx*8], eax |
call malloc_with_test |
; mov ecx, [saved_state_num] |
; mov [saved_state+ecx*8+4], eax |
; inc [saved_state_num] |
pop ecx |
pop ebx |
inc esi |
push ecx eax |
push edi |
mov edi, eax |
mov eax, esi |
rep stosb |
pop edi |
jmp .common |
.free: |
test esi, esi |
jz .loop |
xor edx, edx |
div esi |
sub edx, esi |
neg edx |
dec edx |
mov eax, [esp+edx*8] |
; mov ecx, [saved_state_num] |
; mov [saved_state+ecx*8], -1 |
; mov [saved_state+ecx*8+4], eax |
; inc [saved_state_num] |
mov ecx, [esp+edx*8+4] |
push edi eax |
mov edi, eax |
mov al, [edi] |
repz scasb |
jnz memory_destroyed |
pop eax edi |
push ebx edx |
call free |
pop edx ebx |
dec esi |
pop eax ecx |
push edi |
lea edi, [esp+4] |
@@: |
dec edx |
js @f |
xchg eax, [edi] |
xchg ecx, [edi+4] |
add edi, 8 |
jmp @b |
@@: |
pop edi |
.common: |
dec ebx |
jnz .loop |
@@: |
dec esi |
js @f |
pop eax ecx |
call free |
jmp @b |
@@: |
ret |
malloc_with_test: |
; calls malloc() and checks returned value |
call malloc |
test eax, eax |
jz generic_malloc_fail |
call check_mutex |
call check_range |
ret |
; Stubs for kernel procedures used by heap code |
wait_mutex: |
inc dword [ebx] |
ret |
kernel_alloc: |
cmp dword [esp+4], bufsize |
jnz error1 |
mov eax, buffer |
ret 4 |
macro $Revision [args] |
{ |
} |
; Error handlers |
error1: |
mov eax, 1 |
jmp error_with_code |
generic_malloc_fail: |
mov eax, 2 |
jmp error_with_code |
check_mutex: |
cmp [mst.mutex], 0 |
jnz @f |
ret |
@@: |
mov eax, 3 |
jmp error_with_code |
check_range: |
cmp eax, buffer |
jb @f |
cmp eax, buffer+bufsize |
jae @f |
ret |
@@: |
mov eax, 4 |
jmp error_with_code |
memory_destroyed: |
mov eax, 5 |
jmp error_with_code |
error_with_code: |
mov edx, saved_state_num |
; eax = error code |
; 1 signals error in testing code (wrong bufsize) |
; 2 = malloc() returned NULL |
; 3 = mutex not released |
; 4 = weird returned value from malloc() |
; 5 = memory destroyed by malloc() or free() |
int3 ; simplest way to report error |
jmp $-1 ; just in case |
; Include main heap code |
include '../proc32.inc' |
include '../const.inc' |
include 'malloc.inc' |
i_end: |
align 4 |
zerostart: |
mst MEM_STATE |
align 16 |
bufsize = 0x40000 ; change if malloc.inc changes |
buffer rb bufsize |
zeroend: |
saved_state_num dd ? |
saved_state rd 0x10000 |
align 4 |
rb 0x10000 ; for stack |
mem: |
Property changes: |
Added: svn:mergeinfo |
/kernel/branches/net/core/v86.inc |
---|
Property changes: |
Added: svn:mergeinfo |