kolibri-process: complete

git-svn-id: svn://kolibrios.org@5121 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2014-09-13 19:11:22 +00:00
parent 933e63dccf
commit 305be12d23
2 changed files with 39 additions and 68 deletions

View File

@ -833,7 +833,7 @@ proc map_mem_ipc stdcall, lin_addr:dword,slot:dword,\
.map: .map:
stdcall safe_map_page, [slot], [req_access], [ofs] stdcall safe_map_page, [slot], [req_access], [ofs]
jnc .exit jnc .exit
add dword [ebp-4], PAGE_SIZE add [count], PAGE_SIZE
add [ofs], PAGE_SIZE add [ofs], PAGE_SIZE
dec ecx dec ecx
jz .exit jz .exit
@ -852,60 +852,71 @@ proc map_mem_ipc stdcall, lin_addr:dword,slot:dword,\
stdcall map_page, esi, eax, PG_SW stdcall map_page, esi, eax, PG_SW
xor edx, edx xor edx, edx
jmp .map jmp .map
.exit: .exit:
pop eax mov eax, [count]
ret ret
endp endp
proc map_memEx stdcall, lin_addr:dword,slot:dword,\ proc map_memEx stdcall, lin_addr:dword,slot:dword,\
ofs:dword,buf_size:dword,req_access: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 cmp [buf_size], 0
jz .exit jz .exit
mov eax, [slot] mov eax, [slot]
shl eax, 8 shl eax, 8
mov eax, [SLOT_BASE+eax+APPDATA.process] mov eax, [SLOT_BASE+eax+APPDATA.process]
mov eax, [eax+PROC.pdt_0_phys]
and eax, 0xFFFFF000
stdcall map_page, [proc_mem_pdir], eax, PG_UW
mov ebx, [ofs]
shr ebx, 22
mov esi, [proc_mem_pdir]
mov edi, [proc_mem_tab]
mov eax, [esi+ebx*4]
and eax, 0xFFFFF000
test eax, eax test eax, eax
jz .exit jz .exit
stdcall map_page, edi, eax, PG_UW
mov [process], eax
mov ebx, [ofs]
shr ebx, 22
mov eax, [eax+PROC.pdt_0+ebx*4] ;get page table
mov esi, [proc_mem_tab]
and eax, 0xFFFFF000
jz .exit
stdcall map_page, esi, eax, PG_SW
@@: @@:
mov edi, [lin_addr] mov edi, [lin_addr]
and edi, 0xFFFFF000 and edi, 0xFFFFF000
mov ecx, [buf_size] mov ecx, [buf_size]
add ecx, 4095 add ecx, 4095
shr ecx, 12 shr ecx, 12
inc ecx inc ecx ; ???????????
mov edx, [ofs] mov edx, [ofs]
shr edx, 12 shr edx, 12
and edx, 0x3FF and edx, 0x3FF
mov esi, [proc_mem_tab]
.map: .map:
stdcall safe_map_page, [slot], [req_access], [ofs] stdcall safe_map_page, [slot], [req_access], [ofs]
jnc .exit jnc .exit
add dword [ebp-4], 0x1000 add [count], PAGE_SIZE
add edi, 0x1000 add [ofs], PAGE_SIZE
add [ofs], 0x1000
inc edx
dec ecx dec ecx
jz .exit
add edi, PAGE_SIZE
inc edx
cmp edx, 1024
jnz .map jnz .map
inc ebx
mov eax, [process]
mov eax, [eax+PROC.pdt_0+ebx*4]
and eax, 0xFFFFF000
jz .exit
stdcall map_page, esi, eax, PG_SW
xor edx, edx
jmp .map
.exit: .exit:
pop eax mov eax, [count]
ret ret
endp endp

View File

@ -701,6 +701,10 @@ check_region:
;result: ;result:
; eax = 1 region lays in app memory ; eax = 1 region lays in app memory
; eax = 0 region don't lays in app memory ; eax = 0 region don't lays in app memory
mov eax, 1
ret
if 0
mov eax, [CURRENT_TASK] mov eax, [CURRENT_TASK]
; jmp check_process_region ; jmp check_process_region
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@ -725,57 +729,13 @@ check_region:
mov eax, 1 mov eax, 1
ret ret
; call MEM_Get_Linear_Address
; push ebx
; push ecx
; push edx
; mov edx,ebx
; and edx,not (4096-1)
; sub ebx,edx
; add ecx,ebx
; mov ebx,edx
; add ecx,(4096-1)
; and ecx,not (4096-1)
;.loop:
;;eax - linear address of page directory
;;ebx - current page
;;ecx - current size
; mov edx,ebx
; shr edx,22
; mov edx,[eax+4*edx]
; and edx,not (4096-1)
; test edx,edx
; jz .failed1
; push eax
; mov eax,edx
; call MEM_Get_Linear_Address
; mov edx,ebx
; shr edx,12
; and edx,(1024-1)
; mov eax,[eax+4*edx]
; and eax,not (4096-1)
; test eax,eax
; pop eax
; jz .failed1
; add ebx,4096
; sub ecx,4096
; jg .loop
; pop edx
; pop ecx
; pop ebx
.ok: .ok:
mov eax, 1 mov eax, 1
ret ret
;
;.failed1:
; pop edx
; pop ecx
; pop ebx
.failed: .failed:
xor eax, eax xor eax, eax
ret ret
end if
align 4 align 4
proc read_process_memory proc read_process_memory