added commit_pages()

ring buffer for resamplers

git-svn-id: svn://kolibrios.org@328 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-02-08 01:02:14 +00:00
parent dfe81eb28d
commit 5a467f60e3
4 changed files with 90 additions and 47 deletions

View File

@ -275,16 +275,36 @@ proc free_page
endp endp
; param ; param
; eax= page base ; eax= page base + page flags
; ebx= liear address ; ebx= liear address
; ecx= count ; ecx= count
align 4 align 4
commit_pages: ;not implemented commit_pages:
test ecx, ecx
jz .fail
mov edi, ebx
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
mov edx, 0x1000
mov ebx, edi
shr ebx, 12
@@:
mov [pages_tab+ebx*4], eax
invlpg [edi]
add edi, edx
add eax, edx
inc ebx
dec ecx
jnz @B
mov [pg_data.pg_mutex],ecx
.fail:
ret ret
; param ; param
; eax= base ; eax= base
; ecx= count ; ecx= count
@ -1416,15 +1436,15 @@ align 16
sys_page_map rd 1 sys_page_map rd 1
endg endg
if 0
; push eax push eax
; push edx push edx
; mov edx, 0x400 ;bocsh mov edx, 0x400 ;bocsh
; mov al,0xff ;bocsh mov al,0xff ;bocsh
; out dx, al ;bocsh out dx, al ;bocsh
; pop edx pop edx
; pop eax pop eax
end if
align 4 align 4
k_strrchr: k_strrchr:

View File

@ -33,6 +33,7 @@ new_app_base equ 0x60400000
PROC_BASE equ OS_BASE+0x0080000 PROC_BASE equ OS_BASE+0x0080000
CAPS_SSE2 equ 26 CAPS_SSE2 equ 26
PG_SW equ 0x003
public START public START
@ -113,7 +114,7 @@ if ~(FORCE_MMX or FORCE_MMX_128) ;autodetect
mov [mix_3_core], mmx_mix_3 mov [mix_3_core], mmx_mix_3
mov [mix_4_core], mmx_mix_4 mov [mix_4_core], mmx_mix_4
jmp @F jmp @F
.mmx128: ;new 128-bit sse2 extensions .mmx128: ;128-bit integer sse2 extensions
mov [mix_2_core], mmx128_mix_2 mov [mix_2_core], mmx128_mix_2
mov [mix_3_core], mmx128_mix_3 mov [mix_3_core], mmx128_mix_3
mov [mix_4_core], mmx128_mix_4 mov [mix_4_core], mmx128_mix_4
@ -209,7 +210,7 @@ restore out_size
TASK_COUNT equ 0x0003004 TASK_COUNT equ 0x0003004
CURRENT_TASK equ 0x0003000 CURRENT_TASK equ 0x0003000
align 8 align 4
proc CreateBuffer stdcall, format:dword proc CreateBuffer stdcall, format:dword
locals locals
str dd ? str dd ?
@ -239,7 +240,7 @@ proc CreateBuffer stdcall, format:dword
mov [edx+STREAM.str_bk], eax mov [edx+STREAM.str_bk], eax
popf popf
stdcall KernelAlloc, 168*1024 stdcall KernelAlloc, dword 72*1024
mov edi, [str] mov edi, [str]
mov [edi+STREAM.base], eax mov [edi+STREAM.base], eax
@ -256,13 +257,33 @@ proc CreateBuffer stdcall, format:dword
mov [edi+STREAM.limit], eax mov [edi+STREAM.limit], eax
mov [edi+STREAM.lim_1], eax mov [edi+STREAM.lim_1], eax
; create ring buffer
stdcall AllocKernelSpace, dword 128*1024
mov edi, [str]
mov [edi+STREAM.work_buff], eax mov [edi+STREAM.work_buff], eax
mov [edi+STREAM.work_read], eax mov [edi+STREAM.work_read], eax
mov [edi+STREAM.work_write], eax mov [edi+STREAM.work_write], eax
mov [edi+STREAM.work_count], 0 mov [edi+STREAM.work_count], 0
add eax, 0x10000 add eax, 64*1024
mov [edi+STREAM.work_top], eax mov [edi+STREAM.work_top], eax
stdcall AllocPages, dword 64/4
mov edi, [str]
mov ebx, [edi+STREAM.work_buff]
mov ecx, 16
or eax, PG_SW
push eax
push ebx
call CommitPages ;eax, ebx, ecx
mov ecx, 16
pop ebx
pop eax
add ebx, 64*1024
call CommitPages ;double mapped
mov edi, [str]
mov eax, [format] mov eax, [format]
mov [edi+STREAM.format], eax mov [edi+STREAM.format], eax
mov [edi+STREAM.flags], SND_STOP mov [edi+STREAM.flags], SND_STOP
@ -297,8 +318,14 @@ proc CreateBuffer stdcall, format:dword
stdcall MapPage, ebx, eax, dword 3 stdcall MapPage, ebx, eax, dword 3
mov edi, [edi+STREAM.base] mov edi, [edi+STREAM.base]
mov ecx, (168*1024)/4 mov ecx, (72*1024)/4
xor eax, eax xor eax, eax
cld
rep stosd
mov edi, [str]
mov edi, [edi+STREAM.work_buff]
mov ecx, (64*1024)/4
rep stosd rep stosd
mov eax, [str] mov eax, [str]
@ -308,6 +335,7 @@ proc CreateBuffer stdcall, format:dword
ret ret
endp endp
if 0
align 4 align 4
pid_to_slot: pid_to_slot:
@ -337,11 +365,14 @@ pid_to_slot:
pop ebx pop ebx
ret ret
end if
;param ;param
; eax= buffer handle ; eax= buffer handle
align 4 align 4
DestroyBuffer: DestroyBuffer:
.handle equ esp ;local
cmp [eax+STREAM.magic], 'WAVE' cmp [eax+STREAM.magic], 'WAVE'
jne .fail jne .fail
@ -349,6 +380,8 @@ DestroyBuffer:
cmp [eax+STREAM.size], STREAM_SIZE cmp [eax+STREAM.size], STREAM_SIZE
jne .fail jne .fail
.destroy: .destroy:
push eax
pushf pushf
cli cli
mov ebx, [eax+STREAM.str_fd] mov ebx, [eax+STREAM.str_fd]
@ -357,11 +390,12 @@ DestroyBuffer:
mov [ecx+STREAM.str_fd], ebx mov [ecx+STREAM.str_fd], ebx
popf popf
push eax
stdcall KernelFree, [eax+STREAM.base] stdcall KernelFree, [eax+STREAM.base]
pop eax mov eax, [.handle]
stdcall KernelFree, [eax+STREAM.work_buff]
pop eax ;restore stack
call DestroyObject ;eax call DestroyObject ;eax
ret
.fail: .fail:
ret ret
@ -526,13 +560,6 @@ prepare_playlist:
cmp [edi+STREAM.size], STREAM_SIZE cmp [edi+STREAM.size], STREAM_SIZE
jne .next jne .next
; mov eax,[edi+STREAM.pid]
; cmp eax, -1
; je .next
; call pid_to_slot
; test eax, eax
; jz .next
cmp [edi+STREAM.flags], SND_PLAY; cmp [edi+STREAM.flags], SND_PLAY;
jne .next jne .next
cmp [edi+STREAM.work_count], 16384 cmp [edi+STREAM.work_count], 16384
@ -673,7 +700,7 @@ mm80 dq 0x8080808080808080
mm_mask dq 0xFF00FF00FF00FF00 mm_mask dq 0xFF00FF00FF00FF00
;stream_map dd 0xFFFF ; 16 ;stream_map dd 0xFFFF ; 16
version dd 0x00030003 version dd 0x00030004
szInfinity db 'INFINITY',0 szInfinity db 'INFINITY',0
szSound db 'SOUND',0 szSound db 'SOUND',0

View File

@ -123,7 +123,7 @@ proc update_stream
mov eax, [esi+STREAM.work_read] mov eax, [esi+STREAM.work_read]
cmp eax, [esi+STREAM.work_top] cmp eax, [esi+STREAM.work_top]
jb @f jb @f
mov eax, [esi+STREAM.work_buff] sub eax, 64*1024
@@: @@:
mov [esi+STREAM.work_read], eax mov [esi+STREAM.work_read], eax
@ -146,7 +146,8 @@ proc update_stream
mov edi, [ebx+STREAM.work_write] mov edi, [ebx+STREAM.work_write]
cmp edi, [ebx+STREAM.work_top] cmp edi, [ebx+STREAM.work_top]
jb @f jb @f
mov edi, [ebx+STREAM.work_buff]
sub edi, 64*1024
mov [ebx+STREAM.work_write], edi mov [ebx+STREAM.work_write], edi
@@: @@:
mov esi, [ebx+STREAM.curr_seg] mov esi, [ebx+STREAM.curr_seg]
@ -210,17 +211,12 @@ proc refill stdcall, str:dword
endl endl
mov ebx, [str] mov ebx, [str]
mov ecx, [ebx+STREAM.work_write] mov edi, [ebx+STREAM.work_write]
cmp ecx, [ebx+STREAM.work_top] cmp edi, [ebx+STREAM.work_top]
jbe .m2 jb @F
mov esi, [ebx+STREAM.work_top] sub edi, 64*1024
sub ecx, esi
mov edi, [ebx+STREAM.work_buff]
shr ecx, 2
rep movsd ;call memcpy
mov [ebx+STREAM.work_write], edi mov [ebx+STREAM.work_write], edi
.m2: @@:
mov esi, [ebx+STREAM.curr_seg] mov esi, [ebx+STREAM.curr_seg]
mov edi, [ebx+STREAM.work_write] mov edi, [ebx+STREAM.work_write]

View File

@ -464,7 +464,7 @@ proc ac97_irq
; end if ; end if
mov edx, PCM_OUT_CR_REG mov edx, PCM_OUT_CR_REG
mov al, 0x14 mov al, 0x10; 0x10
call [ctrl.ctrl_write8] call [ctrl.ctrl_write8]
mov ax, 0x1c mov ax, 0x1c
@ -487,7 +487,7 @@ proc ac97_irq
call [ctrl.ctrl_write8] call [ctrl.ctrl_write8]
mov edx, PCM_OUT_CR_REG mov edx, PCM_OUT_CR_REG
mov ax, 0x1D mov ax, 0x11 ;0x1D
call [ctrl.ctrl_write8] call [ctrl.ctrl_write8]
mov eax, [civ_val] mov eax, [civ_val]
@ -504,7 +504,7 @@ proc ac97_irq
.skip: .skip:
mov edx, PCM_OUT_CR_REG mov edx, PCM_OUT_CR_REG
mov ax, 0x1D mov ax, 0x11 ;0x1D
call [ctrl.ctrl_write8] call [ctrl.ctrl_write8]
ret ret
endp endp