infinity: remove direct access to kernel data

git-svn-id: svn://kolibrios.org@520 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-05-24 07:36:48 +00:00
parent f111d6969f
commit 23bdfe5dc4
6 changed files with 104 additions and 35 deletions

View File

@ -39,7 +39,9 @@ iglobal
szUserFree db 'UserFree',0 szUserFree db 'UserFree',0
szKmalloc db 'Kmalloc',0 szKmalloc db 'Kmalloc',0
szKfree db 'Kfree',0 szKfree db 'Kfree',0
szCreateRingBuffer db 'CreateRingBuffer',0
szGetPid db 'GetPid',0
szCreateObject db 'CreateObject',0 szCreateObject db 'CreateObject',0
szDestroyObject db 'DestroyObject',0 szDestroyObject db 'DestroyObject',0
szCreateEvent db 'CreateEvent',0 szCreateEvent db 'CreateEvent',0
@ -101,7 +103,9 @@ kernel_export:
dd szUserFree , user_free dd szUserFree , user_free
dd szKmalloc , malloc dd szKmalloc , malloc
dd szKfree , free dd szKfree , free
dd szCreateRingBuffer, create_ring_buffer
dd szGetPid , get_pid
dd szCreateObject , create_kernel_object dd szCreateObject , create_kernel_object
dd szDestroyObject , destroy_kernel_object dd szDestroyObject , destroy_kernel_object
dd szCreateEvent , create_event dd szCreateEvent , create_event

View File

@ -1085,6 +1085,58 @@ proc stall stdcall, delay:dword
ret ret
endp endp
align 4
proc create_ring_buffer stdcall, size:dword, flags:dword
locals
buf_ptr dd ?
endl
mov eax, [size]
test eax, eax
jz .fail
add eax, eax
stdcall alloc_kernel_space, eax
test eax, eax
jz .fail
mov [buf_ptr], eax
mov ebx, [size]
shr ebx, 12
push ebx
stdcall alloc_pages, ebx
pop ecx
test eax, eax
jz .mm_fail
or eax, [flags]
mov edi, [buf_ptr]
mov ebx, [buf_ptr]
mov edx, ecx
shl edx, 2
shr edi, 10
@@:
mov [page_tabs+edi], eax
mov [page_tabs+edi+edx], eax
invlpg [ebx]
invlpg [ebx+esi]
add eax, 0x1000
add ebx, 0x1000
add edi, 4
dec ecx
jnz @B
mov eax, [buf_ptr]
ret
.mm_fail:
stdcall free_kernel_space, [buf_ptr]
xor eax, eax
.fail:
ret
endp
if 0 if 0
push eax push eax

View File

@ -544,6 +544,12 @@ proc destroy_app_space stdcall, pg_dir:dword
ret ret
endp endp
align 4
get_pid:
mov eax, [TASK_DATA]
mov eax, [eax+4]
ret
pid_to_slot: pid_to_slot:
;Input: ;Input:
; eax - pid of process ; eax - pid of process

View File

@ -88,7 +88,13 @@ end if
if used Kfree if used Kfree
extrn Kfree extrn Kfree
end if end if
if used CreateRingBuffer
extrn CreateRingBuffer
end if
if used GetPid
extrn GetPid
end if
if used CreateObject if used CreateObject
extrn CreateObject extrn CreateObject
end if end if

View File

@ -15,7 +15,10 @@ SOUND_VERSION equ API_VERSION
include 'proc32.inc' include 'proc32.inc'
;include 'system.inc'
include 'main.inc' include 'main.inc'
include 'imports.inc' include 'imports.inc'
FORCE_MMX equ 0 ;set to 1 to force use mmx or FORCE_MMX equ 0 ;set to 1 to force use mmx or
@ -27,9 +30,6 @@ DEBUG equ 1
OS_BASE equ 0x80000000 OS_BASE equ 0x80000000
SLOT_BASE equ (OS_BASE+0x0080000)
TASK_COUNT equ (OS_BASE+0x0003004)
CURRENT_TASK equ (OS_BASE+0x0003000)
CAPS_SSE2 equ 26 CAPS_SSE2 equ 26
PG_SW equ 0x003 PG_SW equ 0x003
@ -334,9 +334,9 @@ proc CreateBuffer stdcall, format:dword, size:dword
test eax, PCM_OUT+PCM_STATIC test eax, PCM_OUT+PCM_STATIC
jnz .fail jnz .fail
.test_ok: .test_ok:
mov ebx, [CURRENT_TASK] ;hack: direct accsess
shl ebx, 5 ;to kernel data call GetPid
mov ebx, [CURRENT_TASK+ebx+4] mov ebx, eax
mov eax, STREAM_SIZE mov eax, STREAM_SIZE
call CreateObject call CreateObject
@ -390,9 +390,11 @@ proc CreateBuffer stdcall, format:dword, size:dword
shr ebx, 12 shr ebx, 12
mov [ring_pages], ebx mov [ring_pages], ebx
add eax, eax ;double ring size stdcall CreateRingBuffer, eax, PG_SW
stdcall AllocKernelSpace, eax
if 0
stdcall AllocKernelSpace, eax
end if
mov edi, [str] mov edi, [str]
mov ecx, [ring_size] mov ecx, [ring_size]
mov [edi+STREAM.in_base], eax mov [edi+STREAM.in_base], eax
@ -407,6 +409,7 @@ proc CreateBuffer stdcall, format:dword, size:dword
add eax, ecx add eax, ecx
mov [edi+STREAM.in_top], eax mov [edi+STREAM.in_top], eax
if 0
mov ebx, [ring_pages] mov ebx, [ring_pages]
stdcall AllocPages, ebx stdcall AllocPages, ebx
mov edi, [str] mov edi, [str]
@ -421,7 +424,7 @@ proc CreateBuffer stdcall, format:dword, size:dword
pop eax pop eax
add ebx, [ring_size] add ebx, [ring_size]
call CommitPages ;double mapped call CommitPages ;double mapped
end if
jmp .out_buff jmp .out_buff
.static: .static:
mov ecx, [size] mov ecx, [size]

View File

@ -84,7 +84,7 @@ endg
end_of_file_system_lfn: end_of_file_system_lfn:
pop edx pop edx
stdcall kernel_free, edx stdcall kernel_free, edx
ret ret
@ -103,38 +103,39 @@ file_system_lfn:
; 9 : create directory ; 9 : create directory
; çàìåíà àäðåñà âîçâðàòà ; çàìåíà àäðåñà âîçâðàòà
push eax push eax
stdcall kernel_alloc, 200 stdcall kernel_alloc, 200
mov edx,eax mov edx,eax
pop eax pop eax
push edx push edx
push end_of_file_system_lfn push end_of_file_system_lfn
mov ebx,edx mov ebx,edx
mov ecx, [eax]
mov [ebx],ecx
add ebx,4 mov ecx, [eax]
mov ecx, [eax+4] mov [ebx],ecx
mov [ebx],ecx
add ebx,4 add ebx,4
mov ecx, [eax+8] mov ecx, [eax+4]
mov [ebx],ecx mov [ebx],ecx
add ebx,4 add ebx,4
mov ecx, [eax+12] mov ecx, [eax+8]
mov [ebx],ecx mov [ebx],ecx
add ebx,4 add ebx,4
mov ecx, [eax+16] mov ecx, [eax+12]
mov [ebx],ecx mov [ebx],ecx
add ebx,4 add ebx,4
mov ecx, [eax+16]
mov [ebx],ecx
add ebx,4
push edx ; !!!!!!!!!!!!!!!!!!! push edx ; !!!!!!!!!!!!!!!!!!!
; eax - yíà÷àëî ñòàðîãî ïàêåòà ; eax - yíà÷àëî ñòàðîãî ïàêåòà
; edx - íà÷àëî íîâîãî ïàêåòà ; edx - íà÷àëî íîâîãî ïàêåòà
; ebx - <EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> ; ebx - <EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>
add eax,20 add eax,20
mov cl, [eax] mov cl, [eax]
test cl,cl test cl,cl
@ -143,10 +144,7 @@ file_system_lfn:
@@: @@:
stdcall full_file_name,eax,ebx stdcall full_file_name,eax,ebx
pop eax pop eax
; add eax, std_application_base_address ; add eax, std_application_base_address