/kernel/branches/kolibri-process/kernel.mnt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/kernel/branches/kolibri-process/const.inc |
---|
273,6 → 273,8 |
REG_RET equ (RING0_STACK_SIZE-56) ;irq0.return |
PAGE_SIZE equ 4096 |
PG_UNMAP equ 0x000 |
PG_MAP equ 0x001 |
PG_WRITE equ 0x002 |
/kernel/branches/kolibri-process/core/heap.inc |
---|
566,25 → 566,26 |
proc init_heap |
mov ebx, [current_slot] |
mov eax, [ebx+APPDATA.heap_top] |
mov ebx, [ebx+APPDATA.process] |
mov eax, [ebx+PROC.heap_top] |
test eax, eax |
jz @F |
sub eax, [ebx+APPDATA.heap_base] |
sub eax, 4096 |
sub eax, [ebx+PROC.heap_base] |
sub eax, PAGE_SIZE |
ret |
@@: |
mov esi, [ebx+APPDATA.mem_size] |
mov esi, [ebx+PROC.mem_used] |
add esi, 4095 |
and esi, not 4095 |
mov [ebx+APPDATA.mem_size], esi |
mov [ebx+PROC.mem_used], esi |
mov eax, HEAP_TOP |
mov [ebx+APPDATA.heap_base], esi |
mov [ebx+APPDATA.heap_top], eax |
mov [ebx+PROC.heap_base], esi |
mov [ebx+PROC.heap_top], eax |
sub eax, esi |
shr esi, 10 |
mov ecx, eax |
sub eax, 4096 |
sub eax, PAGE_SIZE |
or ecx, FREE_BLOCK |
mov [page_tabs+esi], ecx |
ret |
598,24 → 599,25 |
push edi |
mov ecx, [alloc_size] |
add ecx, (4095+4096) |
add ecx, (4095+PAGE_SIZE) |
and ecx, not 4095 |
mov ebx, [current_slot] |
mov esi, dword [ebx+APPDATA.heap_base] ; heap_base |
mov edi, dword [ebx+APPDATA.heap_top] ; heap_top |
l_0: |
mov ebx, [ebx+APPDATA.process] |
mov esi, dword [ebx+PROC.heap_base] ; heap_base |
mov edi, dword [ebx+PROC.heap_top] ; heap_top |
.scan: |
cmp esi, edi |
jae m_exit |
jae .m_exit |
mov ebx, esi |
shr ebx, 12 |
mov eax, [page_tabs+ebx*4] |
test al, FREE_BLOCK |
jz test_used |
jz .test_used |
and eax, 0xFFFFF000 |
cmp eax, ecx ;alloc_size |
jb m_next |
jb .m_next |
jz @f |
lea edx, [esi+ecx] |
638,11 → 640,12 |
.no: |
mov edx, [current_slot] |
mov edx, [edx+APPDATA.process] |
mov ebx, [alloc_size] |
add ebx, 0xFFF |
and ebx, not 0xFFF |
add ebx, [edx+APPDATA.mem_size] |
call update_mem_size |
add [edx+PROC.mem_used], ebx |
lea eax, [esi+4096] |
650,15 → 653,15 |
pop esi |
pop ebx |
ret |
test_used: |
.test_used: |
test al, USED_BLOCK |
jz m_exit |
jz .m_exit |
and eax, 0xFFFFF000 |
m_next: |
.m_next: |
add esi, eax |
jmp l_0 |
m_exit: |
jmp .scan |
.m_exit: |
xor eax, eax |
pop edi |
pop esi |
674,13 → 677,15 |
push edi |
mov ebx, [current_slot] |
mov ebx, [ebx+APPDATA.process] |
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] |
mov esi, [ebx+PROC.heap_base] |
mov edi, [ebx+PROC.heap_top] |
cmp edx, esi |
jb .error |
.scan: |
748,13 → 753,13 |
mov [page_tabs+ebx*4], ecx |
.nothird: |
mov edx, [current_slot] |
mov edx, [edx+APPDATA.process] |
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 |
add [edx+PROC.mem_used], ebx |
mov eax, [address] |
811,11 → 816,12 |
push edi |
mov edx, [current_slot] |
mov esi, dword [edx+APPDATA.heap_base] |
mov edi, dword [edx+APPDATA.heap_top] |
sub ebx, [edx+APPDATA.mem_size] |
mov edx, [edx+APPDATA.process] |
mov esi, dword [edx+PROC.heap_base] |
mov edi, dword [edx+PROC.heap_top] |
sub ebx, [edx+PROC.mem_used] |
neg ebx |
call update_mem_size |
mov [edx+PROC.mem_used], ebx |
call user_normalize |
pop edi |
pop ebx |
999,15 → 1005,16 |
mov eax, [page_tabs+ecx*4] |
and eax, not 0xFFF |
mov edx, [current_slot] |
mov ebx, [APPDATA.mem_size+edx] |
mov edx, [edx+APPDATA.process] |
mov ebx, [edx+PROC.mem_used] |
sub ebx, eax |
add ebx, 0x1000 |
or al, FREE_BLOCK |
mov [page_tabs+ecx*4], eax |
push esi edi |
mov esi, [APPDATA.heap_base+edx] |
mov edi, [APPDATA.heap_top+edx] |
call update_mem_size |
mov esi, [edx+PROC.heap_base] |
mov edi, [edx+PROC.heap_top] |
mov [edx+PROC.mem_used], ebx |
call user_normalize |
pop edi esi |
jmp .ret0 ; all freed |
1020,10 → 1027,11 |
sub ebx, edx |
push ebx ecx edx |
mov edx, [current_slot] |
mov edx, [edx+APPDATA.process] |
shl ebx, 12 |
sub ebx, [APPDATA.mem_size+edx] |
sub ebx, [edx+PROC.mem_used] |
neg ebx |
call update_mem_size |
mov [edx+PROC.mem_used], ebx |
pop edx ecx ebx |
lea eax, [ecx+1] |
shl eax, 12 |
1034,7 → 1042,8 |
jz .ret |
push esi |
mov esi, [current_slot] |
mov esi, [APPDATA.heap_top+esi] |
mov esi, [esi+APPDATA.process] |
mov esi, [esi+PROC.heap_top] |
shr esi, 12 |
@@: |
cmp edx, esi |
1058,7 → 1067,8 |
.realloc_add: |
; get some additional memory |
mov eax, [current_slot] |
mov eax, [APPDATA.heap_top+eax] |
mov eax, [eax+APPDATA.process] |
mov eax, [eax+PROC.heap_top] |
shr eax, 12 |
cmp edx, eax |
jae .cant_inplace |
1091,16 → 1101,17 |
rep stosd |
pop edi |
mov edx, [current_slot] |
mov edx, [edx+APPDATA.process] |
shl ebx, 12 |
add ebx, [APPDATA.mem_size+edx] |
call update_mem_size |
add [edx+PROC.mem_used], ebx |
pop eax edx ecx |
ret |
.cant_inplace: |
push esi edi |
mov eax, [current_slot] |
mov esi, [APPDATA.heap_base+eax] |
mov edi, [APPDATA.heap_top+eax] |
mov eax, [eax+APPDATA.process] |
mov esi, [eax+PROC.heap_base] |
mov edi, [eax+PROC.heap_top] |
shr esi, 12 |
shr edi, 12 |
sub ebx, ecx |
1164,9 → 1175,9 |
.no: |
push ebx |
mov edx, [current_slot] |
mov edx, [eax+APPDATA.process] |
shl ebx, 12 |
add ebx, [APPDATA.mem_size+edx] |
call update_mem_size |
add [edx+PROC.mem_used], ebx |
pop ebx |
@@: |
mov dword [page_tabs+esi*4], 2 |
1176,47 → 1187,11 |
pop eax edi esi edx ecx |
ret |
if 0 |
align 4 |
proc alloc_dll |
pushf |
cli |
bsf eax, [dll_map] |
jnz .find |
popf |
xor eax, eax |
ret |
.find: |
btr [dll_map], eax |
popf |
shl eax, 5 |
add eax, dll_tab |
ret |
endp |
align 4 |
proc alloc_service |
pushf |
cli |
bsf eax, [srv_map] |
jnz .find |
popf |
xor eax, eax |
ret |
.find: |
btr [srv_map], eax |
popf |
shl eax, 0x02 |
lea eax, [srv_tab+eax+eax*8] ;srv_tab+eax*36 |
ret |
endp |
end if |
;;;;;;;;;;;;;; SHARED MEMORY ;;;;;;;;;;;;;;;;; |
;;;;;;;;;;;;;; SHARED ;;;;;;;;;;;;;;;;; |
; param |
; eax= shm_map object |
/kernel/branches/kolibri-process/core/memory.inc |
---|
447,7 → 447,9 |
push edi |
mov edx, [current_slot] |
cmp [edx+APPDATA.heap_base], 0 |
mov ebx, [edx+APPDATA.process] |
cmp [ebx+PROC.heap_base], 0 |
jne .exit |
mov edi, [new_size] |
455,7 → 457,7 |
and edi, not 4095 |
mov [new_size], edi |
mov esi, [edx+APPDATA.mem_size] |
mov esi, [ebx+PROC.mem_used] |
add esi, 4095 |
and esi, not 4095 |
490,7 → 492,8 |
.update_size: |
mov edx, [current_slot] |
mov ebx, [new_size] |
call update_mem_size |
mov edx, [edx+APPDATA.process] |
mov [edx+PROC.mem_used], ebx |
.exit: |
pop edi |
pop esi |
566,38 → 569,6 |
endp |
align 4 |
update_mem_size: |
; in: edx = slot base |
; ebx = new memory size |
; destroys eax,ecx,edx |
mov [APPDATA.mem_size+edx], ebx |
;search threads and update |
;application memory size infomation |
mov ecx, [APPDATA.process+edx] |
mov eax, 2 |
.search_threads: |
;eax = current slot |
;ebx = new memory size |
;ecx = page directory |
cmp eax, [TASK_COUNT] |
jg .search_threads_end |
mov edx, eax |
shl edx, 5 |
cmp word [CURRENT_TASK+edx+TASKDATA.state], 9 ;if slot empty? |
jz .search_threads_next |
shl edx, 3 |
cmp [SLOT_BASE+edx+APPDATA.process], ecx ;if it is our thread? |
jnz .search_threads_next |
mov [SLOT_BASE+edx+APPDATA.mem_size], ebx ;update memory size |
.search_threads_next: |
inc eax |
jmp .search_threads |
.search_threads_end: |
ret |
; param |
; eax= linear address |
; |
776,10 → 747,14 |
endp |
; returns number of mapped bytes |
proc map_mem stdcall, lin_addr:dword,slot:dword,\ |
proc map_mem_ipc stdcall, lin_addr:dword,slot:dword,\ |
ofs:dword,buf_size:dword,req_access:dword |
push 0 ; initialize number of mapped bytes |
locals |
count dd ? |
process dd ? |
endl |
mov [count], 0 |
cmp [buf_size], 0 |
jz .exit |
786,19 → 761,17 |
mov eax, [slot] |
shl eax, 8 |
mov eax, [SLOT_BASE+eax+APPDATA.process] |
mov eax, [eax+PROC.pdt_0_phys] |
and eax, 0xFFFFF000 |
test eax, eax |
jz .exit |
stdcall map_page, [ipc_pdir], eax, PG_UW |
mov [process], eax |
mov ebx, [ofs] |
shr ebx, 22 |
mov esi, [ipc_pdir] |
mov edi, [ipc_ptab] |
mov eax, [esi+ebx*4] |
mov eax, [eax+PROC.pdt_0+ebx*4] ;get page table |
mov esi, [ipc_ptab] |
and eax, 0xFFFFF000 |
jz .exit |
stdcall map_page, edi, eax, PG_UW |
stdcall map_page, esi, eax, PG_SW |
@@: |
mov edi, [lin_addr] |
and edi, 0xFFFFF000 |
805,30 → 778,31 |
mov ecx, [buf_size] |
add ecx, 4095 |
shr ecx, 12 |
inc ecx |
inc ecx ; ??????????? |
mov edx, [ofs] |
shr edx, 12 |
and edx, 0x3FF |
mov esi, [ipc_ptab] |
.map: |
stdcall safe_map_page, [slot], [req_access], [ofs] |
jnc .exit |
add dword [ebp-4], 4096 |
add [ofs], 4096 |
add dword [ebp-4], PAGE_SIZE |
add [ofs], PAGE_SIZE |
dec ecx |
jz .exit |
add edi, 0x1000 |
add edi, PAGE_SIZE |
inc edx |
cmp edx, 0x400 |
cmp edx, 1024 |
jnz .map |
inc ebx |
mov eax, [ipc_pdir] |
mov eax, [eax+ebx*4] |
mov eax, [process] |
mov eax, [eax+PROC.pdt_0+ebx*4] |
and eax, 0xFFFFF000 |
jz .exit |
stdcall map_page, esi, eax, PG_UW |
stdcall map_page, esi, eax, PG_SW |
xor edx, edx |
jmp .map |
1017,29 → 991,6 |
mov [esp+32], eax |
ret |
;align 4 |
;proc set_ipc_buff |
; mov eax,[current_slot] |
; pushf |
; cli |
; mov [eax+APPDATA.ipc_start],ebx ;set fields in extended information area |
; mov [eax+APPDATA.ipc_size],ecx |
; |
; add ecx, ebx |
; add ecx, 4095 |
; and ecx, not 4095 |
; |
;.touch: mov eax, [ebx] |
; add ebx, 0x1000 |
; cmp ebx, ecx |
; jb .touch |
; |
; popf |
; xor eax, eax |
; ret |
;endp |
proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword |
locals |
dst_slot dd ? |
1058,7 → 1009,7 |
mov [dst_slot], eax |
shl eax, 8 |
mov edi, [eax+SLOT_BASE+0xa0] ;is ipc area defined? |
mov edi, [eax+SLOT_BASE+APPDATA.ipc_start] ;is ipc area defined? |
test edi, edi |
jz .no_ipc_area |
1066,7 → 1017,7 |
and ebx, 0xFFF |
mov [dst_offset], ebx |
mov esi, [eax+SLOT_BASE+0xa4] |
mov esi, [eax+SLOT_BASE+APPDATA.ipc_size] |
mov [buf_size], esi |
mov ecx, [ipc_tmp] |
1079,7 → 1030,7 |
pop edi esi |
@@: |
mov [used_buf], ecx |
stdcall map_mem, ecx, [dst_slot], \ |
stdcall map_mem_ipc, ecx, [dst_slot], \ |
edi, esi, PG_SW |
mov edi, [dst_offset] |
1150,7 → 1101,7 |
.ret: |
mov eax, [used_buf] |
cmp eax, [ipc_tmp] |
jz @f |
je @f |
stdcall free_kernel_space, eax |
@@: |
pop eax |
/kernel/branches/kolibri-process/core/taskman.inc |
---|
257,10 → 257,11 |
test eax, eax |
jz .failed |
mov ebx, [hdr_mem] |
mov [eax+PROC.mem_used], ebx |
mov ebx, [slot_base] |
mov [ebx+APPDATA.process], eax |
mov eax, [hdr_mem] |
mov [ebx+APPDATA.mem_size], eax |
xor edx, edx |
cmp word [6], '02' |
976,18 → 977,9 |
mov ecx, 11 |
rep movsb ;copy process name |
mov eax, [ebx+APPDATA.heap_base] |
mov [edx+APPDATA.heap_base], eax |
mov eax, [ebx+APPDATA.process] |
mov [edx+APPDATA.process], eax |
mov ecx, [ebx+APPDATA.heap_top] |
mov [edx+APPDATA.heap_top], ecx |
mov eax, [ebx+APPDATA.mem_size] |
mov [edx+APPDATA.mem_size], eax |
mov ecx, [ebx+APPDATA.process] |
mov [edx+APPDATA.process], ecx;copy page directory |
mov eax, [ebx+APPDATA.dlls_list_ptr] |
mov [edx+APPDATA.dlls_list_ptr], eax |
1118,8 → 1110,8 |
add eax, 256 |
jc @f |
cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] |
ja @f |
; cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] |
; ja @f |
mov eax, [cmd_line] |
1158,8 → 1150,8 |
mov eax, edx |
add eax, 1024 |
jc @f |
cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] |
ja @f |
; cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] |
; ja @f |
stdcall strncpy, edx, [app_path], 1024 |
@@: |
mov ebx, [slot] |
/kernel/branches/kolibri-process/kernel.asm |
---|
3264,7 → 3264,8 |
mov edx, 0x100000*16 |
cmp ecx, 1 shl 5 |
je .os_mem |
mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
mov edx, [edx+PROC.mem_used] |
mov eax, std_application_base_address |
.os_mem: |
stosd |
/kernel/branches/kolibri-process/kernel32.inc |
---|
123,8 → 123,8 |
exc_handler dd ? ;+24 |
except_mask dd ? ;+28 |
pl0_stack dd ? ;+32 |
heap_base dd ? ;+36 |
heap_top dd ? ;+40 |
dd ? ;+36 |
dd ? ;+40 |
cursor dd ? ;+44 |
fd_ev dd ? ;+48 |
bk_ev dd ? ;+52 |
149,7 → 149,7 |
wnd_shape dd ? ;+128 |
wnd_shape_scale dd ? ;+132 |
dd ? ;+136 |
mem_size dd ? ;+140 |
dd ? ;+140 |
saved_box BOX ;+144 |
ipc_start dd ? ;+160 |
ipc_size dd ? ;+164 |