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 |