diff --git a/kernel/trunk/core/memory.inc b/kernel/trunk/core/memory.inc index 3e29f1fe52..af66c13035 100644 --- a/kernel/trunk/core/memory.inc +++ b/kernel/trunk/core/memory.inc @@ -260,7 +260,7 @@ proc free_page mov ebx, sys_pgmap bts [ebx], eax ;that's all! cmc - adc [pg_data.pages_free], 0 + adc [pg_data.pages_free], 0 shr eax, 3 and eax, not 3 ;dword offset from page_map add eax, ebx @@ -275,16 +275,36 @@ proc free_page endp ; param -; eax= page base +; eax= page base + page flags ; ebx= liear address ; ecx= count 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 + ; param ; eax= base ; ecx= count @@ -301,8 +321,8 @@ release_pages: shr esi, 10 add esi, pages_tab - - mov ebp, [pg_data.pages_free] + + mov ebp, [pg_data.pages_free] mov ebx, [page_start] mov edx, sys_pgmap @@: @@ -316,7 +336,7 @@ release_pages: shr eax, 12 bts [edx], eax cmc - adc ebp, 0 + adc ebp, 0 shr eax, 3 and eax, -4 add eax, edx @@ -329,7 +349,7 @@ release_pages: add esi, 4 dec ecx jnz @B - mov [pg_data.pages_free], ebp + mov [pg_data.pages_free], ebp and [pg_data.pg_mutex],0 popad ret @@ -1416,15 +1436,15 @@ align 16 sys_page_map rd 1 endg - -; push eax -; push edx -; mov edx, 0x400 ;bocsh -; mov al,0xff ;bocsh -; out dx, al ;bocsh -; pop edx -; pop eax - +if 0 + push eax + push edx + mov edx, 0x400 ;bocsh + mov al,0xff ;bocsh + out dx, al ;bocsh + pop edx + pop eax +end if align 4 k_strrchr: diff --git a/kernel/trunk/drivers/infinity.asm b/kernel/trunk/drivers/infinity.asm index fd24c81599..a443ab4486 100644 --- a/kernel/trunk/drivers/infinity.asm +++ b/kernel/trunk/drivers/infinity.asm @@ -33,6 +33,7 @@ new_app_base equ 0x60400000 PROC_BASE equ OS_BASE+0x0080000 CAPS_SSE2 equ 26 +PG_SW equ 0x003 public START @@ -113,7 +114,7 @@ if ~(FORCE_MMX or FORCE_MMX_128) ;autodetect mov [mix_3_core], mmx_mix_3 mov [mix_4_core], mmx_mix_4 jmp @F -.mmx128: ;new 128-bit sse2 extensions +.mmx128: ;128-bit integer sse2 extensions mov [mix_2_core], mmx128_mix_2 mov [mix_3_core], mmx128_mix_3 mov [mix_4_core], mmx128_mix_4 @@ -209,7 +210,7 @@ restore out_size TASK_COUNT equ 0x0003004 CURRENT_TASK equ 0x0003000 -align 8 +align 4 proc CreateBuffer stdcall, format:dword locals str dd ? @@ -239,7 +240,7 @@ proc CreateBuffer stdcall, format:dword mov [edx+STREAM.str_bk], eax popf - stdcall KernelAlloc, 168*1024 + stdcall KernelAlloc, dword 72*1024 mov edi, [str] mov [edi+STREAM.base], eax @@ -256,13 +257,33 @@ proc CreateBuffer stdcall, format:dword mov [edi+STREAM.limit], 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_read], eax mov [edi+STREAM.work_write], eax mov [edi+STREAM.work_count], 0 - add eax, 0x10000 + add eax, 64*1024 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 [edi+STREAM.format], eax mov [edi+STREAM.flags], SND_STOP @@ -297,8 +318,14 @@ proc CreateBuffer stdcall, format:dword stdcall MapPage, ebx, eax, dword 3 mov edi, [edi+STREAM.base] - mov ecx, (168*1024)/4 + mov ecx, (72*1024)/4 xor eax, eax + cld + rep stosd + + mov edi, [str] + mov edi, [edi+STREAM.work_buff] + mov ecx, (64*1024)/4 rep stosd mov eax, [str] @@ -308,6 +335,7 @@ proc CreateBuffer stdcall, format:dword ret endp +if 0 align 4 pid_to_slot: @@ -337,11 +365,14 @@ pid_to_slot: pop ebx ret +end if + ;param ; eax= buffer handle align 4 DestroyBuffer: + .handle equ esp ;local cmp [eax+STREAM.magic], 'WAVE' jne .fail @@ -349,6 +380,8 @@ DestroyBuffer: cmp [eax+STREAM.size], STREAM_SIZE jne .fail .destroy: + push eax + pushf cli mov ebx, [eax+STREAM.str_fd] @@ -357,11 +390,12 @@ DestroyBuffer: mov [ecx+STREAM.str_fd], ebx popf - push eax stdcall KernelFree, [eax+STREAM.base] - pop eax + mov eax, [.handle] + stdcall KernelFree, [eax+STREAM.work_buff] + + pop eax ;restore stack call DestroyObject ;eax - ret .fail: ret @@ -526,13 +560,6 @@ prepare_playlist: cmp [edi+STREAM.size], STREAM_SIZE 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; jne .next cmp [edi+STREAM.work_count], 16384 @@ -673,7 +700,7 @@ mm80 dq 0x8080808080808080 mm_mask dq 0xFF00FF00FF00FF00 ;stream_map dd 0xFFFF ; 16 -version dd 0x00030003 +version dd 0x00030004 szInfinity db 'INFINITY',0 szSound db 'SOUND',0 diff --git a/kernel/trunk/drivers/mixer.asm b/kernel/trunk/drivers/mixer.asm index cc70e8908f..95003e3bed 100644 --- a/kernel/trunk/drivers/mixer.asm +++ b/kernel/trunk/drivers/mixer.asm @@ -123,7 +123,7 @@ proc update_stream mov eax, [esi+STREAM.work_read] cmp eax, [esi+STREAM.work_top] jb @f - mov eax, [esi+STREAM.work_buff] + sub eax, 64*1024 @@: mov [esi+STREAM.work_read], eax @@ -146,7 +146,8 @@ proc update_stream mov edi, [ebx+STREAM.work_write] cmp edi, [ebx+STREAM.work_top] jb @f - mov edi, [ebx+STREAM.work_buff] + + sub edi, 64*1024 mov [ebx+STREAM.work_write], edi @@: mov esi, [ebx+STREAM.curr_seg] @@ -210,17 +211,12 @@ proc refill stdcall, str:dword endl mov ebx, [str] - mov ecx, [ebx+STREAM.work_write] - cmp ecx, [ebx+STREAM.work_top] - jbe .m2 - mov esi, [ebx+STREAM.work_top] - sub ecx, esi - mov edi, [ebx+STREAM.work_buff] - shr ecx, 2 - rep movsd ;call memcpy - + mov edi, [ebx+STREAM.work_write] + cmp edi, [ebx+STREAM.work_top] + jb @F + sub edi, 64*1024 mov [ebx+STREAM.work_write], edi -.m2: +@@: mov esi, [ebx+STREAM.curr_seg] mov edi, [ebx+STREAM.work_write] diff --git a/kernel/trunk/drivers/unisound.asm b/kernel/trunk/drivers/unisound.asm index f33bbd7185..7966f955bd 100644 --- a/kernel/trunk/drivers/unisound.asm +++ b/kernel/trunk/drivers/unisound.asm @@ -464,7 +464,7 @@ proc ac97_irq ; end if mov edx, PCM_OUT_CR_REG - mov al, 0x14 + mov al, 0x10; 0x10 call [ctrl.ctrl_write8] mov ax, 0x1c @@ -487,7 +487,7 @@ proc ac97_irq call [ctrl.ctrl_write8] mov edx, PCM_OUT_CR_REG - mov ax, 0x1D + mov ax, 0x11 ;0x1D call [ctrl.ctrl_write8] mov eax, [civ_val] @@ -504,7 +504,7 @@ proc ac97_irq .skip: mov edx, PCM_OUT_CR_REG - mov ax, 0x1D + mov ax, 0x11 ;0x1D call [ctrl.ctrl_write8] ret endp