Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 290 → Rev 291

/kernel/trunk/core/dll.inc
987,8 → 987,8
endp
 
; param
; eax= pid
; ebx= size
; eax= size
; ebx= pid
 
align 4
create_kernel_object:
/kernel/trunk/core/memory.inc
254,10 → 254,11
;arg: eax page address
pushfd
cli
inc [pg_data.pages_free]
shr eax, 12 ;page index
mov ebx, sys_pgmap
bts [ebx], eax ;that's all!
cmc
adc [pg_data.pages_free], 0
shr eax, 3
and eax, not 3 ;dword offset from page_map
add eax, ebx
289,6 → 290,7
align 4
release_pages:
 
push ebp
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
 
298,6 → 300,7
shr esi, 10
add esi, pages_tab
 
mov ebp, [pg_data.pages_free]
mov ebx, [page_start]
mov edx, sys_pgmap
@@:
310,7 → 313,8
 
shr eax, 12
bts [edx], eax
inc [pg_data.pages_free]
cmc
adc ebp, 0
shr eax, 3
and eax, -4
add eax, edx
323,8 → 327,9
add esi, 4
dec ecx
jnz @B
 
mov [pg_data.pages_free], ebp
and [pg_data.pg_mutex],0
pop ebp
ret
 
align 4
/kernel/trunk/drivers/infinity.asm
19,6 → 19,10
include 'main.inc'
include 'imports.inc'
 
USE_MMX equ 0
USE_MMX_128 equ 0
USE_SSE equ 0
 
DEBUG equ 1
 
EVENT_NOTIFY equ 0x00000200
71,17 → 75,10
jz .out_of_mem
mov [mix_buff], eax
 
mov edi, stream_list
mov ecx, 17
xor eax, eax
cld
rep stosd
mov eax, str.fd-FD_OFFSET
mov [str.fd], eax
mov [str.bk], eax
 
mov edi, stream
mov ecx, 4*STREAM_SIZE
rep stosd
mov [stream_count],0
 
stdcall set_handler, [hSound], new_mix
stdcall RegService, szInfinity, service_proc
ret
153,8 → 150,9
cmp eax, SND_DESTROY_BUFF
jne @F
 
mov ebx, [edi+input]
stdcall DestroyBuffer, [ebx]
mov eax, [edi+input]
mov eax, [eax]
call DestroyBuffer ;eax
ret
@@:
xor eax, eax
177,20 → 175,31
str dd ?
endl
 
call alloc_stream
and eax, eax
mov ebx, [CURRENT_TASK] ;hack: direct accsess
shl ebx, 5 ;to kernel data
mov ebx, [0x3000+ebx+4]
mov eax, STREAM_SIZE
 
call CreateObject
test eax, eax
jz .fail
mov [str], eax
mov edi, eax
 
mov edx, [stream_count]
mov [stream_list+edx*4], eax
inc [stream_count]
mov [eax+STREAM.magic], 'WAVE'
mov [eax+STREAM.destroy], DestroyBuffer.destroy
mov [eax+STREAM.size], STREAM_SIZE
 
mov [edi+STREAM.magic], 'WAVE'
mov [edi+STREAM.size], STREAM_SIZE
pushf
cli
mov ebx, str.fd-FD_OFFSET
mov edx, [ebx+STREAM.str_fd]
mov [eax+STREAM.str_fd], edx
mov [eax+STREAM.str_bk], ebx
mov [ebx+STREAM.str_fd], eax
mov [edx+STREAM.str_bk], eax
popf
 
stdcall KernelAlloc, 172*1024
stdcall KernelAlloc, 168*1024
 
mov edi, [str]
mov [edi+STREAM.base], eax
214,12 → 223,6
add eax, 0x10000
mov [edi+STREAM.work_top], eax
 
mov ebx, [CURRENT_TASK]
shl ebx, 5
mov eax, [0x3000+ebx+4]
 
mov [edi+STREAM.notify_task], eax
 
mov eax, [format]
mov [edi+STREAM.format], eax
mov [edi+STREAM.flags], SND_STOP
294,53 → 297,33
pop ebx
ret
 
;param
; eax= buffer handle
 
align 4
proc DestroyBuffer stdcall, str:dword
DestroyBuffer:
 
mov esi, [str]
 
cmp [esi+STREAM.magic], 'WAVE'
cmp [eax+STREAM.magic], 'WAVE'
jne .fail
 
cmp [esi+STREAM.size], STREAM_SIZE
cmp [eax+STREAM.size], STREAM_SIZE
jne .fail
.destroy:
pushf
cli
mov ebx, [eax+STREAM.str_fd]
mov ecx, [eax+STREAM.str_bk]
mov [ebx+STREAM.str_bk], ecx
mov [ecx+STREAM.str_fd], ebx
popf
 
stdcall KernelFree, [esi+STREAM.base]
 
mov eax, [str]
call free_stream
 
mov edi, [str]
mov ecx, STREAM_SIZE/4
xor eax, eax
cld
rep stosd
 
mov eax, [str]
mov esi, stream_list
mov ecx, 16
@@:
cmp [esi], eax
je .remove
add esi, 4
dec ecx
jnz @B
xor eax, eax
inc eax
push eax
stdcall KernelFree, [eax+STREAM.base]
pop eax
call DestroyObject ;eax
ret
.remove:
mov edi, esi
add esi, 4
cld
rep movsd
dec [stream_count]
xor eax, eax
inc eax
ret
.fail:
xor eax, eax
ret
endp
 
align 4
proc play_buffer stdcall, str:dword
487,116 → 470,44
endp
 
align 4
proc alloc_stream
prepare_playlist:
 
mov esi, stream_map
 
pushf
cli
 
bsf eax, [esi]
jnz .find
popf
xor eax, eax
ret
.find:
btr [esi], eax
popf
mov ebx, STREAM_SIZE
mul ebx
add eax, stream
ret
endp
 
align 4
proc free_stream
sub eax, stream
mov ebx, STREAM_SIZE
xor edx, edx
div ebx
mov [play_count], edx
mov esi, str.fd-FD_OFFSET
mov edi, [esi+STREAM.str_fd]
@@:
cmp edi, esi
je .done
 
and edx, edx
jnz .err
 
bts [stream_map], eax
ret
.err:
xor eax, eax
ret
endp
 
align 4
proc prepare_playlist
 
.restart:
xor ebx, ebx
xor edx, edx
mov [play_count], 0
mov ecx, [stream_count]
jcxz .exit
.l1:
mov esi, [stream_list+ebx]
test esi, esi
jz .next
 
cmp [esi+STREAM.magic], 'WAVE'
cmp [edi+STREAM.magic], 'WAVE'
jne .next
 
cmp [esi+STREAM.size], STREAM_SIZE
cmp [edi+STREAM.size], STREAM_SIZE
jne .next
 
mov eax,[esi+STREAM.notify_task]
cmp eax, -1
je .fail
; mov eax,[edi+STREAM.pid]
; cmp eax, -1
; je .next
; call pid_to_slot
; test eax, eax
; jz .next
 
call pid_to_slot
test eax, eax
jz .fail
 
cmp [esi+STREAM.flags], SND_PLAY;
cmp [edi+STREAM.flags], SND_PLAY;
jne .next
cmp [esi+STREAM.work_count], 16384
cmp [edi+STREAM.work_count], 16384
jb .next
 
mov [play_list+edx], esi
mov [play_list+edx], edi
inc [play_count]
add edx, 4
.next:
add ebx, 4
loop .l1
.exit:
mov edi, [edi+STREAM.str_fd]
jmp @B
.done:
ret
.fail:
stdcall DestroyBuffer, esi
jmp .restart
endp
 
align 4
proc prepare_updatelist
 
xor ebx, ebx
xor edx, edx
mov [play_count], 0
mov ecx, [stream_count]
jcxz .exit
.l1:
mov eax, [stream_list+ebx]
test eax, eax
jz .next
cmp [eax+STREAM.flags], SND_PLAY
jne .next
 
mov [play_list+edx], eax
inc [play_count]
add edx, 4
.next:
add ebx, 4
loop .l1
.exit:
ret
endp
 
align 4
proc set_handler stdcall, hsrv:dword, handler_proc:dword
locals
handler dd ?
653,6 → 564,18
 
include 'mixer.asm'
 
;if USE_MMX
; include 'mix_mmx.inc'
;end if
 
if USE_MMX_128
include 'mix_sse2.inc'
end if
 
;if USE_SSE
; include 'mix_sse.inc'
;end if
 
align 16
resampler_params:
;r_size r_end r_dt resampler_func
715,7 → 638,7
mm80 dq 0x8080808080808080
mm_mask dq 0xFF00FF00FF00FF00
 
stream_map dd 0xFFFF ; 16
;stream_map dd 0xFFFF ; 16
version dd 0x00030003
 
szInfinity db 'INFINITY',0
727,19 → 650,21
msgStop db 'Stop',13,10,0
msgUser db 'User callback',13,10,0
msgMem db 'Not enough memory',13,10,0
msgDestroy db 'Destroy sound buffer', 13,10,0
end if
 
section '.data' data readable writable align 16
 
stream rb STREAM_SIZE*16
 
play_list rd 16
mix_input rd 16
 
stream_list rd 17
play_count rd 1
stream_count rd 1
hSound rd 1
mix_buff rd 1
mix_buff_map rd 1
str.fd rd 1
str.bk rd 1
 
mix_2_1.core rd 1
mix_3_1.core rd 1
mix_4_1.core rd 1
 
/kernel/trunk/drivers/main.inc
80,38 → 80,47
 
 
struc STREAM
{ .magic dd 0
.size dd 0
.device dd 0
.format dd 0
.flags dd 0
{
.magic dd ? ;'WAVE'
.destroy dd ? ;internal destructor
.fd dd ? ;next object in list
.bk dd ? ;prev object in list
.pid dd ? ;owner id
 
.work_buff dd 0
.work_read dd 0
.work_write dd 0
.work_count dd 0
.work_top dd 0
.r_size dd 0
.r_end dd 0
.r_dt dd 0
.r_silence dd 0
.size dd ?
.str_fd dd ?
.str_bk dd ?
.device dd ?
.format dd ?
.flags dd ?
 
.base dd 0
.limit dd 0
.seg_0 dd 0
.lim_0 dd 0
.seg_1 dd 0
.lim_1 dd 0
.curr_seg dd 0
.work_buff dd ?
.work_read dd ?
.work_write dd ?
.work_count dd ?
.work_top dd ?
.r_size dd ?
.r_end dd ?
.r_dt dd ?
.r_silence dd ?
 
.buff_size dd 0
.notify_off1 dd 0
.notify_off2 dd 0
.notify_task dd 0
.resample dd 0
.base dd ?
.limit dd ?
.seg_0 dd ?
.lim_0 dd ?
.seg_1 dd ?
.lim_1 dd ?
.curr_seg dd ?
 
.buff_size dd ?
.notify_off1 dd ?
.notify_off2 dd ?
; .notify_task dd ?
.resample dd ?
}
 
STREAM_SIZE equ 26*4
STREAM_SIZE equ 31*4
FD_OFFSET equ 24
 
virtual at 0
STREAM STREAM
/kernel/trunk/drivers/mixer.asm
183,7 → 183,7
@@:
mov [ev_code], 0xFF000001
mov [ev_offs], ecx
mov eax, [ebx+STREAM.notify_task]
mov eax, [ebx+STREAM.pid]
 
lea edx, [ev_code]
push ebx
193,7 → 193,7
jnz .l_end
 
not eax
mov [ebx+STREAM.notify_task], eax ;-1
mov [ebx+STREAM.pid], eax ;-1
.l_end:
inc [stream_index]
dec [play_count]
264,7 → 264,7
@@:
mov [ev_code], 0xFF000001
mov [ev_offs], ecx
mov eax, [ebx+STREAM.notify_task]
mov eax, [ebx+STREAM.pid]
 
lea edx, [ev_code]
push ebx
273,7 → 273,7
test eax, eax
jnz @F
not eax
mov [ebx+STREAM.notify_task], eax ;-1
mov [ebx+STREAM.pid], eax ;-1
@@:
ret
endp
784,18 → 784,22
mov edi, [output]
 
stdcall mix_2_1_mmx, edi, [str0],[str1]
; stdcall mix_2_1_sse, edi, [str0],[str1]
add edi, 128
add [str0], 128
add [str1], 128
stdcall mix_2_1_mmx, edi, [str0],[str1]
; stdcall mix_2_1_sse, edi, [str0],[str1]
add edi, 128
add [str0], 128
add [str1], 128
stdcall mix_2_1_mmx, edi, [str0],[str1]
; stdcall mix_2_1_sse, edi, [str0],[str1]
add edi, 128
add [str0], 128
add [str1], 128
stdcall mix_2_1_mmx, edi, [str0],[str1]
; stdcall mix_2_1_sse, edi, [str0],[str1]
 
ret
endp
904,87 → 908,73
 
movq mm0, [eax]
paddsw mm0, [ecx]
; psraw mm0, 1
movq [edx], mm0
 
movq mm1, [eax+8]
paddsw mm1,[ecx+8]
; psraw mm1, 1
movq [edx+8], mm1
 
movq mm2, [eax+16]
paddsw mm2, [ecx+16]
; psraw mm2, 1
movq [edx+16], mm2
 
movq mm3, [eax+24]
paddsw mm3, [ecx+24]
; psraw mm3, 1
movq [edx+24], mm3
 
movq mm0, [eax+32]
paddsw mm0, [ecx+32]
; psraw mm0, 1
movq [edx+32], mm0
 
movq mm1, [eax+40]
paddsw mm1, [ecx+40]
; psraw mm1, 1
movq [edx+40], mm1
 
movq mm2, [eax+48]
paddsw mm2, [ecx+48]
; psraw mm2, 1
movq [edx+48], mm2
 
movq mm3, [eax+56]
paddsw mm3, [ecx+56]
; psraw mm3, 1
movq [edx+56], mm3
 
movq mm0, [eax+64]
paddsw mm0, [ecx+64]
; psraw mm0, 1
movq [edx+64], mm0
 
movq mm1, [eax+72]
paddsw mm1, [ecx+72]
; psraw mm1, 1
movq [edx+72], mm1
 
movq mm2, [eax+80]
paddsw mm2, [ecx+80]
; psraw mm2, 1
movq [edx+80], mm2
 
movq mm3, [eax+88]
paddsw mm3, [ecx+88]
; psraw mm3, 1
movq [edx+88], mm3
 
movq mm0, [eax+96]
paddsw mm0, [ecx+96]
; psraw mm0, 1
movq [edx+96], mm0
 
movq mm1, [eax+104]
paddsw mm1, [ecx+104]
; psraw mm1, 1
movq [edx+104], mm1
 
movq mm2, [eax+112]
paddsw mm2, [ecx+112]
; psraw mm2, 1
movq [edx+112], mm2
 
movq mm3, [eax+120]
paddsw mm3, [ecx+120]
; psraw mm3, 1
movq [edx+120], mm3
 
ret
endp
 
 
 
align 4
proc mix_3_1_mmx stdcall, output:dword, str0:dword, str1:dword, str2:dword
 
1229,4 → 1219,3
endp