1)new memory layout

2)Infinity 1.0

git-svn-id: svn://kolibrios.org@378 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-02-27 11:47:52 +00:00
parent 02bcaaab53
commit 73c568fb03
16 changed files with 1581 additions and 796 deletions

View File

@ -59,18 +59,18 @@ os_data_l:
db 0x00 db 0x00
app_code_l: app_code_l:
dw 0xFFFF;((0x80000000-std_application_base_address) shr 12) and 0xffff dw 0xFFFF
dw 0 dw 0
db 0x40 db 0
db cpl3 db cpl3
dw G32+D32+0x6000+0x7; dw G32+D32+0x8000+0x7;
app_data_l: app_data_l:
dw 0xFFFF;(0x80000000-std_application_base_address) shr 12 and 0xffff dw 0xFFFF
dw 0 dw 0
db 0x40 db 0
db drw3 db drw3
dw G32+D32+0x6000+0x7; dw G32+D32+0x8000+0x7;
; --------------- APM --------------------- ; --------------- APM ---------------------
apm_code_32: apm_code_32:

View File

@ -231,30 +231,32 @@ resendQ equ OS_BASE+0x0770000
;skin_data equ OS_BASE+0x0778000 ;skin_data equ OS_BASE+0x0778000
tss_data equ 0x780000 tss_data equ 0x780000
draw_data equ 0x988000 draw_data equ 0x988000
HEAP_BASE equ 0x98B000 HEAP_BASE equ 0x98B000
page_tabs equ 0x60000000 LFB_BASE equ 0x7DC00000
master_tab equ 0x60180000
current_pgdir equ 0x60180000
sys_pgdir equ OS_BASE+0x00050000 page_tabs equ 0x7FC00000
sys_master_tab equ OS_BASE+0x00051000 master_tab equ 0x7FDFF000
sys_pgmap equ OS_BASE+0x00052000 app_page_tabs equ 0x7FE00000
sys_pgdir equ OS_BASE+0x00050000
sys_master_tab equ OS_BASE+0x00051000
sys_pgmap equ OS_BASE+0x00052000
new_app_base equ 0x60400000 new_app_base equ 0x80000000
twdw equ (CURRENT_TASK-window_data) twdw equ (CURRENT_TASK-window_data)
std_application_base_address equ new_app_base std_application_base_address equ new_app_base
RING0_STACK_SIZE equ 0x2000 - 512 ;512 áàéò äëÿ êîíòåêñòà FPU
RING0_STACK_SIZE equ 0x2000 - 512 ;512 áàéò äëÿ êîíòåêñòà FPU ;PAGES_USED equ 4
PAGES_USED equ 4
PG_UNMAP equ 0x000 PG_UNMAP equ 0x000
PG_MAP equ 0x001 PG_MAP equ 0x001
@ -445,11 +447,11 @@ struc PG_DATA
} }
;struc LIB ;struc LIB
;{ .lib_name rb 16 ;{ .lib_name rb 16
; .lib_base dd ? ; .lib_base dd ?
; .lib_start dd ? ; .lib_start dd ?
; .export dd ? ; .export dd ?
; .import dd ? ; .import dd ?
;} ;}
struc SRV struc SRV

View File

@ -1,8 +1,8 @@
DRV_ENTRY equ 1 DRV_ENTRY equ 1
DRV_EXIT equ -1 DRV_EXIT equ -1
DRV_COMPAT equ 3 ;minimal required drivers version DRV_COMPAT equ 4 ;minimal required drivers version
DRV_CURRENT equ 3 ;current drivers model version DRV_CURRENT equ 4 ;current drivers model version
DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT

View File

@ -36,41 +36,95 @@ init_fpu:
fnsave [fpu_data] fnsave [fpu_data]
ret ret
; param
; eax= 512 bytes memory area
align 4 align 4
proc fpu_save fpu_save:
push ecx
push esi
push edi
pushfd
cli
clts clts
mov ebx, [fpu_owner] mov edi, eax
shl ebx, 8
mov eax, [ebx+PROC_BASE+0x10] mov ecx, [fpu_owner]
mov ebx, [CURRENT_TASK] mov eax, [CURRENT_TASK]
mov [fpu_owner], ebx cmp ecx, eax
jne .save
.copy:
shl eax, 8
mov esi, [eax+PROC_BASE+APPDATA.fpu_state]
mov ecx, 512/4
cld
rep movsd
fninit
popfd
pop edi
pop esi
pop ecx
ret
.save:
mov [fpu_owner], eax
shl ecx, 8
mov ecx, [ecx+PROC_BASE+APPDATA.fpu_state]
bt [cpu_caps], CAPS_SSE bt [cpu_caps], CAPS_SSE
jnc .no_SSE jnc .no_SSE
fxsave [eax] fxsave [ecx]
fninit ;re-init fpu jmp .copy
ret
.no_SSE: .no_SSE:
fnsave [eax] fnsave [ecx]
ret jmp .copy
endp
align 4 align 4
proc fpu_restore fpu_restore:
mov ebx, [CURRENT_TASK] push ecx
shl ebx, 8 push esi
mov eax, [ebx+PROC_BASE+0x10]
mov esi, eax
pushfd
cli
mov ecx, [fpu_owner]
mov eax, [CURRENT_TASK]
cmp ecx, eax
jne .copy
clts
bt [cpu_caps], CAPS_SSE bt [cpu_caps], CAPS_SSE
jnc .no_SSE jnc .no_SSE
fxrstor [eax] fxrstor [esi]
popfd
pop esi
pop ecx
ret ret
.no_SSE: .no_SSE:
fnclex ;fix possible problems fnclex ;fix possible problems
frstor [eax] frstor [esi]
popfd
pop esi
pop ecx
ret
.copy:
shl eax, 8
mov edi, [eax+PROC_BASE+APPDATA.fpu_state]
mov ecx, 512/4
cld
rep movsd
popfd
pop esi
pop ecx
ret ret
endp
align 4 align 4
e7: ;#NM exception handler e7: ;#NM exception handler

View File

@ -106,7 +106,7 @@ proc init_mem
dec ecx dec ecx
jnz .map_kernel_tabs jnz .map_kernel_tabs
mov dword [sys_pgdir+0x600], sys_pgdir+PG_SW mov dword [sys_pgdir+(page_tabs shr 20)], sys_pgdir+PG_SW
ret ret
endp endp
@ -365,7 +365,7 @@ proc map_page_table stdcall, lin_addr:dword, phis_addr:dword
mov eax, [phis_addr] mov eax, [phis_addr]
and eax, not 0xFFF and eax, not 0xFFF
or eax, PG_UW ;+PG_NOCACHE or eax, PG_UW ;+PG_NOCACHE
mov dword [current_pgdir+ebx*4], eax mov dword [master_tab+ebx*4], eax
mov eax, [lin_addr] mov eax, [lin_addr]
shr eax, 10 shr eax, 10
add eax, page_tabs add eax, page_tabs
@ -376,6 +376,10 @@ endp
align 4 align 4
proc init_LFB proc init_LFB
locals
pg_count dd ?
endl
cmp dword [LFBAddress], -1 cmp dword [LFBAddress], -1
jne @f jne @f
mov [0x2f0000+0x901c],byte 2 mov [0x2f0000+0x901c],byte 2
@ -388,18 +392,9 @@ proc init_LFB
mov [0x2f0000+0x901c],byte 2 mov [0x2f0000+0x901c],byte 2
ret ret
@@: @@:
call map_LFB mov edx, LFB_BASE
ret
endp
align 4
proc map_LFB
locals
pg_count dd ?
endl
mov edi, [LFBSize]
mov esi, [LFBAddress] mov esi, [LFBAddress]
mov edi, [LFBSize]
mov dword [exp_lfb+4], esi mov dword [exp_lfb+4], esi
shr edi, 12 shr edi, 12
@ -408,13 +403,12 @@ proc map_LFB
bt [cpu_caps], CAPS_PSE bt [cpu_caps], CAPS_PSE
jnc .map_page_tables jnc .map_page_tables
mov ebx, esi
or esi, PG_LARGE+PG_UW or esi, PG_LARGE+PG_UW
shr ebx, 20 shr edx, 20
mov ecx, ebx mov ecx, edx
@@: @@:
mov [sys_pgdir+ebx], esi mov [sys_pgdir+edx], esi
add ebx, 4 add edx, 4
add esi, 0x00400000 add esi, 0x00400000
dec edi dec edi
jnz @B jnz @B
@ -423,6 +417,7 @@ proc map_LFB
jnc @F jnc @F
or dword [sys_pgdir+ecx], PG_GLOBAL or dword [sys_pgdir+ecx], PG_GLOBAL
@@: @@:
mov dword [LFBAddress], LFB_BASE
mov eax, cr3 ;flush TLB mov eax, cr3 ;flush TLB
mov cr3, eax mov cr3, eax
ret ret
@ -431,31 +426,19 @@ proc map_LFB
@@: @@:
call alloc_page call alloc_page
stdcall map_page_table, esi, eax stdcall map_page_table, edx, eax
add esi, 0x00400000 add esi, 0x00400000
dec edi dec edi
jnz @B jnz @B
mov eax, [LFBAddress] mov eax, [LFBAddress]
mov esi, eax mov edi, page_tabs + (LFB_BASE shr 10)
shr esi, 10
add esi, page_tabs
or eax, PG_UW or eax, PG_UW
mov ecx, [pg_count] mov ecx, [pg_count]
shr ecx, 2 cld
.map: rep stosd
mov [esi], eax
add eax, 0x1000
mov [esi+4], eax
add eax, 0x1000
mov [esi+8], eax
add eax, 0x1000
mov [esi+12], eax
add eax, 0x1000
add esi, 16
sub ecx, 1
jnz .map
mov dword [LFBAddress], LFB_BASE
mov eax, cr3 ;flush TLB mov eax, cr3 ;flush TLB
mov cr3, eax mov cr3, eax
@ -488,10 +471,10 @@ proc new_mem_resize stdcall, new_size:dword
shr edi, 12 shr edi, 12
shr esi, 12 shr esi, 12
@@: @@:
mov eax, [page_tabs+0x00181000+edi*4] mov eax, [app_page_tabs+edi*4]
test eax, 1 test eax, 1
jz .next jz .next
mov dword [page_tabs+0x00181000+edi*4], 2 mov dword [app_page_tabs+edi*4], 2
mov ebx, edi mov ebx, edi
shl ebx, 12 shl ebx, 12
invlpg [ebx+std_application_base_address] invlpg [ebx+std_application_base_address]
@ -636,18 +619,18 @@ proc page_fault_handler
mov ebx, [ebp-4] mov ebx, [ebp-4]
cmp ebx, 0xe0000000 cmp ebx, 0x80000000
jae .lfb_addr
cmp ebx, 0x60400000
jae .user_space jae .user_space
cmp ebx, master_tab+0x1000 cmp ebx, app_page_tabs
jae .alloc jae .alloc
cmp ebx, 0x60000000 cmp ebx, page_tabs
jae .tab_space jae .tab_space
cmp ebx, 0x7DC00000
jae .lfb_addr
jmp .kernel_space jmp .kernel_space
.user_space: .user_space:
@ -1075,7 +1058,7 @@ new_services:
@@: @@:
cmp eax, 17 cmp eax, 17
ja @f ja @f
stdcall srv_handlerEx, ebx call srv_handlerEx ;ebx
mov [esp+36], eax mov [esp+36], eax
ret ret
@@: @@:

View File

@ -386,23 +386,17 @@ proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword
mov esi, sys_pgdir mov esi, sys_pgdir
mov edi, [tmp_task_pdir] mov edi, [tmp_task_pdir]
mov ecx, 384 mov ecx, (page_tabs shr 20)/4
cld cld
rep movsd rep movsd
mov ecx, 384
xor eax, eax
cld
rep stosd
mov ecx, 256
mov esi, sys_pgdir+0xc00
rep movsd
mov eax, [dir_addr] mov eax, [dir_addr]
or eax, PG_SW or eax, PG_SW
mov ebx, [tmp_task_pdir] stosd ; [(page_tabs shr 20)]= eax
mov [ebx+0x600], eax
mov ecx, 0x800/4
xor eax, eax
rep stosd
mov eax, [dir_addr] mov eax, [dir_addr]
call set_cr3 call set_cr3
@ -555,8 +549,8 @@ proc destroy_app_space stdcall, pg_dir:dword
and eax, not 0xFFF and eax, not 0xFFF
stdcall map_page,[tmp_task_pdir],eax,dword PG_SW stdcall map_page,[tmp_task_pdir],eax,dword PG_SW
mov esi, [tmp_task_pdir] mov esi, [tmp_task_pdir]
add esi, 0x604 add esi, 0x800
mov edi, 383 mov edi, 0x800/4
.destroy: .destroy:
mov eax, [esi] mov eax, [esi]
test eax, 1 test eax, 1

View File

@ -65,9 +65,9 @@ R9800 equ 0x4E49 ;R350
R9800P equ 0x4E48 ;R350 R9800P equ 0x4E48 ;R350
R9800XT equ 0x4E4A ;R360 R9800XT equ 0x4E4A ;R360
OS_BASE equ 0; 0x80400000 OS_BASE equ 0
new_app_base equ 0x60400000; 0x01000000 new_app_base equ 0x80000000
PROC_BASE equ OS_BASE+0x0080000 PROC_BASE equ 0x0080000
PG_SW equ 0x003 PG_SW equ 0x003
PG_NOCACHE equ 0x018 PG_NOCACHE equ 0x018
@ -85,8 +85,8 @@ virtual at 0
IOCTL IOCTL IOCTL IOCTL
end virtual end virtual
;MMIO equ 0F9000000h ;MMIO equ 0F9000000h
RD_RB3D_CNTL equ 1c3ch RD_RB3D_CNTL equ 1c3ch
RD_MEM_CNTL equ 0140h RD_MEM_CNTL equ 0140h
RD_CRTC_GEN_CNTL equ 0050h RD_CRTC_GEN_CNTL equ 0050h
@ -232,7 +232,7 @@ proc service_proc stdcall, ioctl:dword
mov eax, [edi+input] mov eax, [edi+input]
call video_free call video_free
.fail: .fail:
xor eax, eax or eax, -1
ret ret
endp endp
@ -981,7 +981,7 @@ devices dd (R8500 shl 16)+VID_ATI
dd (R9800XT shl 16)+VID_ATI dd (R9800XT shl 16)+VID_ATI
dd 0 ;terminator dd 0 ;terminator
version dd 0x00030003 version dd 0x00040004
sz_ati_srv db 'HWCURSOR',0 sz_ati_srv db 'HWCURSOR',0

View File

@ -67,7 +67,7 @@ proc setup_codec
xor eax, eax xor eax, eax
stdcall codec_write, dword CODEC_AUX_VOL stdcall codec_write, dword CODEC_AUX_VOL
mov eax, 0x1010 mov eax, 0x0B0B
stdcall codec_write, dword CODEC_MASTER_VOL_REG stdcall codec_write, dword CODEC_MASTER_VOL_REG
mov ax, 0x08 mov ax, 0x08
@ -98,43 +98,40 @@ proc setup_codec
xor eax, eax ; exit with error xor eax, eax ; exit with error
ret ret
endp endp
; param
; eax= volume -10000 - 0 for both channels
align 4 align 4
proc set_master_vol stdcall, vol:dword set_master_vol:
cmp eax, 0
mov ebx, 63 jl @F
mov ecx, 20644 xor eax, eax
mov eax, [vol] jmp .set
cmp eax, 90
jna @f
mov eax, 90
@@: @@:
mul ecx cmp eax, -9450
shr eax, 15 jg .set
sub ebx, eax mov eax, -9450 ;clamp into 6 bits
mov ah, bl .set:
mov al, bl cdq
mov ebx, -150
idiv ebx
mov ah, al
stdcall codec_write, dword CODEC_MASTER_VOL_REG stdcall codec_write, dword CODEC_MASTER_VOL_REG
xor eax, eax
ret ret
endp
align 4 align 4
proc get_master_vol stdcall, pvol:dword proc get_master_vol stdcall, pvol:dword
stdcall codec_read, dword CODEC_MASTER_VOL_REG stdcall codec_read, dword CODEC_MASTER_VOL_REG
and eax, 0x3F and eax, 0x3F
mov ebx, 63 imul eax, -150
mov ecx, 20644
xchg eax, ebx
sub eax, ebx
shl eax, 15
xor edx, edx
div ecx
mov ebx, [pvol] mov ebx, [pvol]
mov [ebx], eax mov [ebx], eax
xor eax, eax
ret ret
endp endp

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
; ;
; This file is part of the Infinity sound AC97 driver. ; This file is part of the Infinity sound driver.
; (C) copyright Serge 2006 ; (C) copyright Serge 2006-2007
; email: infinity_sound@mail.ru ; email: infinity_sound@mail.ru
; ;
; This program is free software; you can redistribute it and/or modify ; This program is free software; you can redistribute it and/or modify
@ -13,6 +13,20 @@
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details. ; GNU General Public License for more details.
SOUND_VERSION equ 0x01000100
PLAY_SYNC equ 0x80000000
PCM_ALL equ 0
PCM_OUT equ 0x08000000
PCM_RING equ 0x10000000
PCM_STATIC equ 0x20000000
PCM_FLOAT equ 0x40000000 ;reserved
PCM_FILTER equ 0x80000000 ;reserved
PCM_2_16_48 equ 1 PCM_2_16_48 equ 1
PCM_1_16_48 equ 2 PCM_1_16_48 equ 2
@ -37,47 +51,53 @@ PCM_1_16_12 equ 14
PCM_2_16_11 equ 15 PCM_2_16_11 equ 15
PCM_1_16_11 equ 16 PCM_1_16_11 equ 16
PCM_2_8_48 equ 17 PCM_2_16_8 equ 17
PCM_1_8_48 equ 18 PCM_1_16_8 equ 18
PCM_2_8_44 equ 19 PCM_2_8_48 equ 19
PCM_1_8_44 equ 20 PCM_1_8_48 equ 20
PCM_2_8_32 equ 21 PCM_2_8_44 equ 21
PCM_1_8_32 equ 22 PCM_1_8_44 equ 22
PCM_2_8_24 equ 23 PCM_2_8_32 equ 23
PCM_1_8_24 equ 24 PCM_1_8_32 equ 24
PCM_2_8_22 equ 25 PCM_2_8_24 equ 25
PCM_1_8_22 equ 26 PCM_1_8_24 equ 26
PCM_2_8_16 equ 27 PCM_2_8_22 equ 27
PCM_1_8_16 equ 28 PCM_1_8_22 equ 28
PCM_2_8_12 equ 29 PCM_2_8_16 equ 29
PCM_1_8_12 equ 30 PCM_1_8_16 equ 30
PCM_2_8_11 equ 31 PCM_2_8_12 equ 31
PCM_1_8_11 equ 32 PCM_1_8_12 equ 32
SND_PLAY equ 1 PCM_2_8_11 equ 33
SND_STOP equ 2 PCM_1_8_11 equ 34
; struc SND_DEV PCM_2_8_8 equ 35
;{ .magic dd 0 PCM_1_8_8 equ 36
; .size dd 0
; .count dd 0
; dd 0
; .snd_buff dd 16 dup (0)
;}
;virtual at 0
; SND_DEV SND_DEV
;end virtual
;SND_DEV_SIZE equ 80
SRV_GETVERSION equ 0
SND_CREATE_BUFF equ 1
SND_DESTROY_BUFF equ 2
SND_SETFORMAT equ 3
SND_GETFORMAT equ 4
SND_RESET equ 5
SND_SETPOS equ 6
SND_GETPOS equ 7
SND_SETBUFF equ 8
SND_OUT equ 9
SND_PLAY equ 10
SND_STOP equ 11
SND_SETVOLUME equ 12
SND_GETVOLUME equ 13
SND_SETPAN equ 14
SND_GETPAN equ 15
SND_GETBUFFSIZE equ 16
struc STREAM struc STREAM
{ {
@ -94,32 +114,35 @@ struc STREAM
.format dd ? .format dd ?
.flags dd ? .flags dd ?
.work_buff dd ? .out_base dd ?
.work_read dd ? .out_wp dd ?
.work_write dd ? .out_rp dd ?
.work_count dd ? .out_count dd ?
.work_top dd ? .out_top dd ?
.r_size dd ? .r_size dd ?
.r_end dd ?
.r_dt dd ? .r_dt dd ?
.r_silence dd ? .r_silence dd ?
.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 ? .resample dd ?
.l_vol dd ?
.r_vol dd ?
.l_amp dw ?
.r_amp dw ?
.pan dd ?
.in_base dd ?
.in_size dd ?
.in_wp dd ?
.in_rp dd ?
.in_count dd ?
.in_free dd ?
.in_top dd ?
.notify_event dd ?
.notify_id dd ?
} }
STREAM_SIZE equ 31*4 STREAM_SIZE equ 34*4
FD_OFFSET equ 24 FD_OFFSET equ 24
virtual at 0 virtual at 0

View File

@ -13,93 +13,64 @@
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details. ; GNU General Public License for more details.
align 4
mix_list rq 32
align 4 align 4
proc new_mix stdcall, output:dword proc new_mix stdcall, output:dword
locals locals
mixCounter dd ? main_count rd 1
mixIndex dd ? fpu_state rb 528 ;512+16
streamIndex dd ?
inputCount dd ?
main_count dd ?
blockCount dd ?
mix_out dd ?
endl endl
mov [main_count], 32
call prepare_playlist call prepare_playlist
cmp [play_count], 0 cmp [play_count], 0
je .exit je .clear
lea eax, [fpu_state+16]
and eax, -16 ;must be 16b aligned
call FpuSave call FpuSave
mov [main_count], 32;
.l00:
mov [mix_buff_map], 0x0000FFFF;
xor eax, eax
mov [mixCounter], eax
mov [mixIndex],eax
mov [streamIndex], eax;
mov ebx, [play_count]
mov [inputCount], ebx
.l0:
mov ecx, 4
.l1:
mov ebx, [streamIndex]
mov esi, [play_list+ebx*4]
mov eax, [esi+STREAM.work_read]
add [esi+STREAM.work_read], 512
mov ebx, [mixIndex]
mov [mix_input+ebx*4], eax
inc [mixCounter]
inc [mixIndex]
inc [streamIndex]
dec [inputCount]
jz .m2
dec ecx
jnz .l1
cmp [mixCounter], 4
jnz .m2
stdcall mix_4_1, [mix_input],[mix_input+4],[mix_input+8],[mix_input+12]
sub [mixIndex],4
mov ebx, [mixIndex]
mov [mix_input+ebx*4], eax
inc [mixIndex]
mov [mixCounter], 0
cmp [inputCount], 0
jnz .l0
.m2:
cmp [mixIndex], 1
jne @f
stdcall copy_mem, [output], [mix_input]
jmp .m3
@@:
cmp [mixIndex], 2
jne @f
stdcall mix_2_1, [output], [mix_input], [mix_input+4]
jmp .m3
@@:
cmp [mixIndex], 3
jne @f
stdcall mix_3_1, [output],[mix_input],[mix_input+4],[mix_input+8]
jmp .m3
@@:
stdcall final_mix, [output],[mix_input],[mix_input+4],[mix_input+8], [mix_input+12]
.m3:
add [output],512
dec [main_count]
jnz .l00
call update_stream call update_stream
emms .mix:
lea eax, [mix_list]
call do_mix_list
test eax, eax
je .done
; cmp eax, 1
; je .copy
lea ebx, [mix_list]
stdcall mix_all, [output], ebx, eax
@@:
add [output], 512
dec [main_count]
jnz .mix
.exit:
lea eax, [fpu_state+16]
and eax, -16
call FpuRestore call FpuRestore
ret ret
.exit: .copy:
lea eax, [mix_list]
stdcall copy_mem, [output], [eax]
jmp @B
.done:
mov ecx, [main_count]
shl ecx, 7 ;ecx*= 512/4
mov edi, [output] mov edi, [output]
mov ecx, 0x1000 xor eax, eax
cld
rep stosd
jmp .exit
.clear:
mov edi, [output]
mov ecx, 4096
xor eax, eax xor eax, eax
cld cld
rep stosd rep stosd
@ -120,81 +91,62 @@ proc update_stream
mov edx, [stream_index] mov edx, [stream_index]
mov esi, [play_list+edx*4] mov esi, [play_list+edx*4]
mov eax, [esi+STREAM.work_read] mov eax, [esi+STREAM.out_rp]
cmp eax, [esi+STREAM.work_top] cmp eax, [esi+STREAM.out_top]
jb @f jb @f
sub eax, 64*1024 sub eax, 64*1024
@@: @@:
mov [esi+STREAM.work_read], eax mov [esi+STREAM.out_rp], eax
cmp [esi+STREAM.format], PCM_2_16_48 cmp word [esi+STREAM.format], PCM_2_16_48
je .copy je .copy
sub [esi+STREAM.work_count], 16384 cmp [esi+STREAM.out_count], 16384
ja .skip
cmp [esi+STREAM.work_count], 32768 test [esi+STREAM.format], PCM_RING
ja @f jnz .ring
stdcall refill, esi stdcall refill, esi
@@: .skip:
inc [stream_index] inc [stream_index]
dec [play_count] dec [play_count]
jnz .l1 jnz .l1
ret ret
.ring:
stdcall refill_ring, esi
jmp .skip
.copy: .copy:
mov ebx, esi mov ebx, esi
mov edi, [ebx+STREAM.work_write] mov edi, [ebx+STREAM.out_wp]
cmp edi, [ebx+STREAM.work_top] cmp edi, [ebx+STREAM.out_top]
jb @f jb @f
sub edi, 64*1024 sub edi, 64*1024
mov [ebx+STREAM.work_write], edi mov [ebx+STREAM.out_wp], edi
@@: @@:
mov esi, [ebx+STREAM.curr_seg] mov esi, [ebx+STREAM.in_rp]
mov ecx, 16384/4 mov ecx, 16384/4
cld cld
rep movsd rep movsd
mov [ebx+STREAM.work_write], edi mov [ebx+STREAM.out_wp], edi
cmp esi, [ebx+STREAM.lim_0] cmp esi, [ebx+STREAM.in_top]
jb @f jb @f
mov esi, [ebx+STREAM.seg_0] sub esi, 0x10000
mov eax, [ebx+STREAM.lim_0]
xchg esi, [ebx+STREAM.seg_1]
xchg eax, [ebx+STREAM.lim_1]
mov [ebx+STREAM.seg_0], esi
mov [ebx+STREAM.lim_0], eax
@@: @@:
mov [ebx+STREAM.curr_seg], esi mov [ebx+STREAM.in_rp], esi
xor ecx, ecx
cmp esi, [ebx+STREAM.notify_off2]
je @f
mov ecx,0x8000
cmp esi, [ebx+STREAM.notify_off1]
je @f
inc [stream_index]
dec [play_count]
jnz .l1
ret
@@:
mov [ev_code], 0xFF000001
mov [ev_offs], ecx
mov eax, [ebx+STREAM.pid]
lea edx, [ev_code]
push ebx
stdcall SendEvent, eax, edx
pop ebx
test eax, eax test eax, eax
jnz .l_end jz .l_end
mov eax, [ebx+STREAM.notify_event]
not eax mov ebx, [ebx+STREAM.notify_id]
mov [ebx+STREAM.pid], eax ;-1 mov ecx, EVENT_WATCHED
xor edx, edx
call RaiseEvent ;eax, ebx, ecx, edx
.l_end: .l_end:
inc [stream_index] inc [stream_index]
dec [play_count] dec [play_count]
@ -205,72 +157,186 @@ endp
align 4 align 4
proc refill stdcall, str:dword proc refill stdcall, str:dword
locals locals
ev_code dd ? ;EVENT r_size rd 1
ev_offs dd ? event rd 6
rd 4
endl endl
mov ebx, [str] mov ebx, [str]
mov edi, [ebx+STREAM.work_write] mov edi, [ebx+STREAM.out_wp]
cmp edi, [ebx+STREAM.work_top] cmp edi, [ebx+STREAM.out_top]
jb @F jb @F
sub edi, 64*1024 sub edi, 0x10000
mov [ebx+STREAM.work_write], edi mov [ebx+STREAM.out_wp], edi
@@: @@:
mov esi, [ebx+STREAM.curr_seg] mov eax, [ebx+STREAM.in_count]
mov edi, [ebx+STREAM.work_write] test eax, eax
jz .done
mov ecx, [ebx+STREAM.r_size]
cmp eax, ecx
jle @F
mov eax, ecx
@@:
mov ecx, eax
cmp word [ebx+STREAM.format], PCM_1_16_8
ja @F
shr eax, 1 ;two channles
@@:
test [ebx+STREAM.format], 1 ;even formats mono
jz @F
shr eax, 1 ;eax= samples
@@:
shl eax, 15 ;eax*=32768 =r_end
mov [r_size], ecx
mov esi, [ebx+STREAM.in_rp]
mov edi, [ebx+STREAM.out_wp]
stdcall [ebx+STREAM.resample], edi, esi, \ stdcall [ebx+STREAM.resample], edi, esi, \
[ebx+STREAM.r_dt],[ebx+STREAM.r_size],[ebx+STREAM.r_end] [ebx+STREAM.r_dt], ecx, eax
mov ebx, [str] mov ebx, [str]
add [ebx+STREAM.work_count], eax; add [ebx+STREAM.out_count], eax;
add [ebx+STREAM.work_write], eax; add [ebx+STREAM.out_wp], eax;
mov eax, [ebx+STREAM.curr_seg] mov eax, [ebx+STREAM.in_rp]
add eax, [ebx+STREAM.r_size] mov ecx, [r_size]
cmp eax, [ebx+STREAM.lim_0] add eax, ecx
add [ebx+STREAM.in_free], ecx
sub [ebx+STREAM.in_count], ecx
cmp eax, [ebx+STREAM.in_top]
jb @f jb @f
mov esi, [ebx+STREAM.seg_0] sub eax, [ebx+STREAM.in_size]
lea edi, [esi-128]
add esi, 0x7F80
mov ecx, 128/4
cld
rep movsd
mov eax, [ebx+STREAM.seg_0]
mov ecx, [ebx+STREAM.lim_0]
xchg eax, [ebx+STREAM.seg_1]
xchg ecx, [ebx+STREAM.lim_1]
mov [ebx+STREAM.seg_0], eax
mov [ebx+STREAM.lim_0], ecx
@@: @@:
mov [ebx+STREAM.curr_seg], eax mov [ebx+STREAM.in_rp], eax
xor ecx, ecx .done:
cmp eax, [ebx+STREAM.notify_off2] mov eax, [ebx+STREAM.notify_event]
je @f
mov ecx,0x8000
cmp eax, [ebx+STREAM.notify_off1]
je @f
ret
@@:
mov [ev_code], 0xFF000001
mov [ev_offs], ecx
mov eax, [ebx+STREAM.pid]
lea edx, [ev_code]
push ebx
stdcall SendEvent, eax, edx
pop ebx
test eax, eax test eax, eax
jnz @F jz .exit
not eax
mov [ebx+STREAM.pid], eax ;-1 mov ebx, [ebx+STREAM.notify_id]
mov ecx, EVENT_WATCHED
xor edx, edx
call RaiseEvent ;eax, ebx, ecx, edx
.exit:
ret
endp
align 4
proc refill_ring stdcall, str:dword
locals
event rd 6
endl
mov ebx, [str]
mov edi, [ebx+STREAM.out_wp]
cmp edi, [ebx+STREAM.out_top]
jb @F
sub edi, 0x10000
mov [ebx+STREAM.out_wp], edi
@@: @@:
mov ecx, [ebx+STREAM.r_size]
mov eax, ecx
cmp word [ebx+STREAM.format], PCM_1_16_8
ja @F
shr eax, 1 ;two channles
@@:
test [ebx+STREAM.format], 1 ;even formats mono
jz @F
shr eax, 1 ;eax= samples
@@:
shl eax, 15 ;eax*=32768 =r_end
mov esi, [ebx+STREAM.in_rp]
mov edi, [ebx+STREAM.out_wp]
stdcall [ebx+STREAM.resample], edi, esi, \
[ebx+STREAM.r_dt], ecx, eax
mov ebx, [str]
add [ebx+STREAM.out_count], eax;
add [ebx+STREAM.out_wp], eax;
mov eax, [ebx+STREAM.in_rp]
mov ecx, [ebx+STREAM.r_size]
add eax, ecx
add [ebx+STREAM.in_free], ecx
sub [ebx+STREAM.in_count], ecx
cmp eax, [ebx+STREAM.in_top]
jb @f
sub eax, [ebx+STREAM.in_size]
@@:
mov [ebx+STREAM.in_rp], eax
sub eax, [ebx+STREAM.in_base]
sub eax, 128
lea edx, [event]
mov dword [edx], RT_INP_EMPTY
mov dword [edx+4], 0
mov dword [edx+8], ebx
mov dword [edx+12], eax
mov eax, [ebx+STREAM.notify_event]
test eax, eax
jz .exit
mov ebx, [ebx+STREAM.notify_id]
xor ecx, ecx
call RaiseEvent ;eax, ebx, ecx, edx
.exit:
ret
endp
align 4
proc mix_all stdcall, dest:dword, list:dword, count:dword
mov edi, [dest]
mov ebx, 64
.mix:
mov edx, [list]
mov ecx, [count]
mov eax, [edx]
movq mm0, [eax]
movd mm1, [edx+4]
punpckldq mm1,mm1
pmulhw mm0, mm1
psllw mm0, 1
.mix_loop:
add dword [edx], 8
add edx, 8
dec ecx
jz @F
mov eax, [edx]
movq mm1, [eax]
movd mm2, [edx+4]
punpckldq mm2,mm2
pmulhw mm1, mm2
psllw mm1, 1
paddsw mm0, mm1
jmp .mix_loop
@@:
movq [edi], mm0
add edi, 8
dec ebx
jnz .mix
ret ret
endp endp
@ -282,14 +348,14 @@ proc resample_1 stdcall, dest:dword,src:dword,\
; src equ esp+12 ; src equ esp+12
; r_dt equ esp+16 ; r_dt equ esp+16
; r_size equ esp+20 ; r_size equ esp+20
;r_end equ esp+24 ; r_end equ esp+24
mov edi, [dest] mov edi, [dest]
mov edx, [src] mov edx, [src]
sub edx, 32*2 sub edx, 32*2
mov eax, 16 mov eax, 16
align 16 align 4
.l1: .l1:
mov ecx, eax mov ecx, eax
mov esi, eax mov esi, eax
@ -342,7 +408,7 @@ proc resample_18 stdcall, dest:dword,src:dword,\
mov esi, 16 mov esi, 16
align 16 align 4
.l1: .l1:
mov ecx, esi mov ecx, esi
mov eax, esi mov eax, esi
@ -413,7 +479,7 @@ proc resample_2 stdcall, dest:dword,src:dword,\
mov eax, 16 mov eax, 16
emms emms
align 16 align 4
.l1: .l1:
mov ecx, eax mov ecx, eax
mov esi, eax mov esi, eax
@ -466,7 +532,7 @@ proc resample_28 stdcall, dest:dword,src:dword,\
movq mm7,[mm80] movq mm7,[mm80]
movq mm6,[mm_mask] movq mm6,[mm_mask]
align 16 align 4
.l1: .l1:
mov ecx, eax mov ecx, eax
mov esi, eax mov esi, eax
@ -840,6 +906,8 @@ proc mix_4_1 stdcall, str0:dword, str1:dword,\
and eax, eax and eax, eax
jz .err jz .err
mov [output], eax
mov edi, eax mov edi, eax
mov eax, [str0] mov eax, [str0]
mov ebx, [str1] mov ebx, [str1]
@ -939,4 +1007,100 @@ proc memcpy
ret ret
endp endp
if 0
align 4
proc new_mix stdcall, output:dword
locals
mixCounter dd ?
mixIndex dd ?
streamIndex dd ?
inputCount dd ?
main_count dd ?
blockCount dd ?
mix_out dd ?
endl
call prepare_playlist
cmp [play_count], 0
je .exit
call FpuSave
mov [main_count], 32;
.l00:
mov [mix_buff_map], 0x0000FFFF;
xor eax, eax
mov [mixCounter], eax
mov [mixIndex],eax
mov [streamIndex], eax;
mov ebx, [play_count]
mov [inputCount], ebx
.l0:
mov ecx, 4
.l1:
mov ebx, [streamIndex]
mov esi, [play_list+ebx*4]
mov eax, [esi+STREAM.work_read]
add [esi+STREAM.work_read], 512
mov ebx, [mixIndex]
mov [mix_input+ebx*4], eax
inc [mixCounter]
inc [mixIndex]
inc [streamIndex]
dec [inputCount]
jz .m2
dec ecx
jnz .l1
cmp [mixCounter], 4
jnz .m2
stdcall mix_4_1, [mix_input],[mix_input+4],[mix_input+8],[mix_input+12]
sub [mixIndex],4
mov ebx, [mixIndex]
mov [mix_input+ebx*4], eax
inc [mixIndex]
mov [mixCounter], 0
cmp [inputCount], 0
jnz .l0
.m2:
cmp [mixIndex], 1
jne @f
stdcall copy_mem, [output], [mix_input]
jmp .m3
@@:
cmp [mixIndex], 2
jne @f
stdcall mix_2_1, [output], [mix_input], [mix_input+4]
jmp .m3
@@:
cmp [mixIndex], 3
jne @f
stdcall mix_3_1, [output],[mix_input],[mix_input+4],[mix_input+8]
jmp .m3
@@:
stdcall final_mix, [output],[mix_input],[mix_input+4],[mix_input+8], [mix_input+12]
.m3:
add [output],512
dec [main_count]
jnz .l00
call update_stream
emms
call FpuRestore
ret
.exit:
mov edi, [output]
mov ecx, 0x1000
xor eax, eax
cld
rep stosd
ret
endp
end if

View File

@ -44,15 +44,15 @@ BIT31 EQU 0x80000000
VID_SIS equ 0x1039 VID_SIS equ 0x1039
CTRL_SIS equ 0x7012 CTRL_SIS equ 0x7012
PCM_OUT_BDL equ 0x10 ; PCM out buffer descriptors list PCM_OUT_BDL equ 0x10 ; PCM out buffer descriptors list
PCM_OUT_CR_REG equ 0x1b ; PCM out Control Register PCM_OUT_CR_REG equ 0x1b ; PCM out Control Register
PCM_OUT_LVI_REG equ 0x15 ; PCM last valid index PCM_OUT_LVI_REG equ 0x15 ; PCM last valid index
PCM_OUT_SR_REG equ 0x18 ; PCM out Status register PCM_OUT_SR_REG equ 0x18 ; PCM out Status register
PCM_OUT_PIV_REG equ 0x1a ; PCM out prefetched index PCM_OUT_PIV_REG equ 0x1a ; PCM out prefetched index
PCM_OUT_CIV_REG equ 0x14 ; PCM out current index PCM_OUT_CIV_REG equ 0x14 ; PCM out current index
PCM_IN_CR_REG equ 0x0b ; PCM in Control Register PCM_IN_CR_REG equ 0x0b ; PCM in Control Register
MC_IN_CR_REG equ 0x2b ; MIC in Control Register MC_IN_CR_REG equ 0x2b ; MIC in Control Register
RR equ BIT1 ; reset registers. Nukes all regs RR equ BIT1 ; reset registers. Nukes all regs
CODEC_MASTER_VOL_REG equ 0x02 CODEC_MASTER_VOL_REG equ 0x02
@ -65,24 +65,24 @@ CODEC_PCM_SURND_DACRATE_REG equ 2eh ; surround sound sample rate
CODEC_PCM_LFE_DACRATE_REG equ 30h ; LFE sample rate CODEC_PCM_LFE_DACRATE_REG equ 30h ; LFE sample rate
GLOB_CTRL equ 0x2C ; Global Control GLOB_CTRL equ 0x2C ; Global Control
CTRL_STAT equ 0x30 ; Global Status CTRL_STAT equ 0x30 ; Global Status
CTRL_CAS equ 0x34 ; Codec Access Semiphore CTRL_CAS equ 0x34 ; Codec Access Semiphore
CAS_FLAG equ 0x01 ; Codec Access Semiphore Bit CAS_FLAG equ 0x01 ; Codec Access Semiphore Bit
CTRL_ST_CREADY equ BIT8+BIT9+BIT28 ; Primary Codec Ready CTRL_ST_CREADY equ BIT8+BIT9+BIT28 ; Primary Codec Ready
CTRL_ST_RCS equ 0x00008000 ; Read Completion Status CTRL_ST_RCS equ 0x00008000 ; Read Completion Status
CTRL_CNT_CRIE equ BIT4+BIT5+BIT6 ; Codecs Resume Interrupt Enable CTRL_CNT_CRIE equ BIT4+BIT5+BIT6 ; Codecs Resume Interrupt Enable
CTRL_CNT_AC_OFF equ 0x00000008 ; ACLINK Off CTRL_CNT_AC_OFF equ 0x00000008 ; ACLINK Off
CTRL_CNT_WARM equ 0x00000004 ; AC97 Warm Reset CTRL_CNT_WARM equ 0x00000004 ; AC97 Warm Reset
CTRL_CNT_COLD equ 0x00000002 ; AC97 Cold Reset CTRL_CNT_COLD equ 0x00000002 ; AC97 Cold Reset
CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable
CODEC_REG_POWERDOWN equ 0x26 CODEC_REG_POWERDOWN equ 0x26
CODEC_REG_ST equ 0x26 CODEC_REG_ST equ 0x26
DEV_PLAY equ 1 DEV_PLAY equ 1
@ -217,24 +217,24 @@ struc CODEC ;Audio Chip base class
} }
struc CTRL_INFO struc CTRL_INFO
{ .pci_cmd dd ? { .pci_cmd dd ?
.irq dd ? .irq dd ?
.glob_cntrl dd ? .glob_cntrl dd ?
.glob_sta dd ? .glob_sta dd ?
.codec_io_base dd ? .codec_io_base dd ?
.ctrl_io_base dd ? .ctrl_io_base dd ?
.codec_mem_base dd ? .codec_mem_base dd ?
.ctrl_mem_base dd ? .ctrl_mem_base dd ?
.codec_id dd ? .codec_id dd ?
} }
struc IOCTL struc IOCTL
{ .handle dd ? { .handle dd ?
.io_code dd ? .io_code dd ?
.input dd ? .input dd ?
.inp_size dd ? .inp_size dd ?
.output dd ? .output dd ?
.out_size dd ? .out_size dd ?
} }
virtual at 0 virtual at 0
@ -243,9 +243,9 @@ end virtual
EVENT_NOTIFY equ 0x00000200 EVENT_NOTIFY equ 0x00000200
OS_BASE equ 0; 0x80400000 OS_BASE equ 0; 0x80400000
new_app_base equ 0x60400000; 0x01000000 PROC_BASE equ OS_BASE+0x0080000
PROC_BASE equ OS_BASE+0x0080000 new_app_base equ 0x80000000
public START public START
public service_proc public service_proc
@ -361,16 +361,15 @@ proc service_proc stdcall, ioctl:dword
@@: @@:
cmp eax, DEV_SET_MASTERVOL cmp eax, DEV_SET_MASTERVOL
jne @F jne @F
mov ebx, [edi+input] mov eax, [edi+input]
stdcall set_master_vol, [ebx] mov eax, [eax]
call set_master_vol ;eax= vol
ret ret
@@: @@:
cmp eax, DEV_GET_MASTERVOL cmp eax, DEV_GET_MASTERVOL
jne @F jne @F
mov ebx, [edi+output] mov ebx, [edi+output]
test ebx, ebx add ebx, new_app_base
jz .fail
stdcall get_master_vol, ebx stdcall get_master_vol, ebx
ret ret
@@: @@:
@ -381,7 +380,7 @@ proc service_proc stdcall, ioctl:dword
ret ret
@@: @@:
.fail: .fail:
xor eax, eax or eax, -1
ret ret
endp endp
@ -401,7 +400,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
call [ctrl.ctrl_write8] call [ctrl.ctrl_write8]
mov ax, 0x1c mov ax, 0x1c
@ -424,11 +423,11 @@ 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
call [ctrl.ctrl_write8] call [ctrl.ctrl_write8]
mov eax, [civ_val] mov eax, [civ_val]
add eax, 2 add eax, 1
and eax, 31 and eax, 31
mov ebx, dword [buff_list+eax*4] mov ebx, dword [buff_list+eax*4]
@ -441,7 +440,7 @@ proc ac97_irq
.skip: .skip:
mov edx, PCM_OUT_CR_REG mov edx, PCM_OUT_CR_REG
mov ax, 0x1D mov ax, 0x11
call [ctrl.ctrl_write8] call [ctrl.ctrl_write8]
ret ret
endp endp
@ -455,6 +454,7 @@ proc create_primary_buff
mov edi, eax mov edi, eax
mov ecx, 0x10000/4 mov ecx, 0x10000/4
xor eax, eax xor eax, eax
cld
rep stosd rep stosd
mov eax, [ctrl.buffer] mov eax, [ctrl.buffer]
@ -1132,7 +1132,7 @@ align 4
devices dd (CTRL_SIS shl 16)+VID_SIS,msg_AC, set_SIS devices dd (CTRL_SIS shl 16)+VID_SIS,msg_AC, set_SIS
dd 0 dd 0
version dd 0x00030003 version dd 0x00040004
msg_AC db '7012 AC97 controller',13,10, 0 msg_AC db '7012 AC97 controller',13,10, 0
msg_SIS db 'Silicon Integrated Systems',13,10, 0 msg_SIS db 'Silicon Integrated Systems',13,10, 0

View File

@ -51,38 +51,38 @@ BIT29 EQU 0x20000000
BIT30 EQU 0x40000000 BIT30 EQU 0x40000000
BIT31 EQU 0x80000000 BIT31 EQU 0x80000000
VID_INTEL equ 0x8086 VID_INTEL equ 0x8086
VID_NVIDIA equ 0x10DE VID_NVIDIA equ 0x10DE
CTRL_ICH equ 0x2415 CTRL_ICH equ 0x2415
CTRL_ICH0 equ 0x2425 CTRL_ICH0 equ 0x2425
CTRL_ICH2 equ 0x2435 CTRL_ICH2 equ 0x2435
CTRL_ICH3 equ 0x2445 CTRL_ICH3 equ 0x2445
CTRL_ICH4 equ 0x24C5 CTRL_ICH4 equ 0x24C5
CTRL_ICH5 equ 0x24D5 CTRL_ICH5 equ 0x24D5
CTRL_ICH6 equ 0x266E CTRL_ICH6 equ 0x266E
CTRL_ICH7 equ 0x27DE CTRL_ICH7 equ 0x27DE
CTRL_NFORCE equ 0x01B1 CTRL_NFORCE equ 0x01B1
CTRL_NFORCE2 equ 0x006A CTRL_NFORCE2 equ 0x006A
CTRL_NFORCE3 equ 0x00DA CTRL_NFORCE3 equ 0x00DA
CTRL_MCP04 equ 0x003A CTRL_MCP04 equ 0x003A
CTRL_CK804 equ 0x0059 CTRL_CK804 equ 0x0059
CTRL_CK8 equ 0x008A CTRL_CK8 equ 0x008A
CTRL_CK8S equ 0x00EA CTRL_CK8S equ 0x00EA
CTRL_MCP51 equ 0x026B CTRL_MCP51 equ 0x026B
PCM_OUT_BDL equ 0x10 ; PCM out buffer descriptors list PCM_OUT_BDL equ 0x10 ; PCM out buffer descriptors list
PCM_OUT_CR_REG equ 0x1b ; PCM out Control Register PCM_OUT_CR_REG equ 0x1b ; PCM out Control Register
PCM_OUT_LVI_REG equ 0x15 ; PCM last valid index PCM_OUT_LVI_REG equ 0x15 ; PCM last valid index
PCM_OUT_SR_REG equ 0x16 ; PCM out Status register PCM_OUT_SR_REG equ 0x16 ; PCM out Status register
PCM_OUT_PIV_REG equ 0x1a PCM_OUT_PIV_REG equ 0x1a
PCM_OUT_CIV_REG equ 0x14 ; PCM out current index PCM_OUT_CIV_REG equ 0x14 ; PCM out current index
PCM_IN_CR_REG equ 0x0b ; PCM in Control Register PCM_IN_CR_REG equ 0x0b ; PCM in Control Register
MC_IN_CR_REG equ 0x2b ; MIC in Control Register MC_IN_CR_REG equ 0x2b ; MIC in Control Register
RR equ BIT1 ; reset registers. Nukes all regs RR equ BIT1 ; reset registers. Nukes all regs
CODEC_MASTER_VOL_REG equ 0x02 CODEC_MASTER_VOL_REG equ 0x02
CODEC_AUX_VOL equ 0x04 ; CODEC_AUX_VOL equ 0x04 ;
@ -93,21 +93,21 @@ CODEC_PCM_FRONT_DACRATE_REG equ 2ch ; PCM out sample rate
CODEC_PCM_SURND_DACRATE_REG equ 2eh ; surround sound sample rate CODEC_PCM_SURND_DACRATE_REG equ 2eh ; surround sound sample rate
CODEC_PCM_LFE_DACRATE_REG equ 30h ; LFE sample rate CODEC_PCM_LFE_DACRATE_REG equ 30h ; LFE sample rate
GLOB_CTRL equ 0x2C ; Global Control GLOB_CTRL equ 0x2C ; Global Control
CTRL_STAT equ 0x30 ; Global Status CTRL_STAT equ 0x30 ; Global Status
CTRL_CAS equ 0x34 ; Codec Access Semiphore CTRL_CAS equ 0x34 ; Codec Access Semiphore
CAS_FLAG equ 0x01 ; Codec Access Semiphore Bit CAS_FLAG equ 0x01 ; Codec Access Semiphore Bit
CTRL_ST_CREADY equ BIT8+BIT9+BIT28 ; Primary Codec Ready CTRL_ST_CREADY equ BIT8+BIT9+BIT28 ; Primary Codec Ready
CTRL_ST_RCS equ 0x00008000 ; Read Completion Status CTRL_ST_RCS equ 0x00008000 ; Read Completion Status
CTRL_CNT_CRIE equ BIT4+BIT5+BIT6 ; Codecs Resume Interrupt Enable CTRL_CNT_CRIE equ BIT4+BIT5+BIT6 ; Codecs Resume Interrupt Enable
CTRL_CNT_AC_OFF equ 0x00000008 ; ACLINK Off CTRL_CNT_AC_OFF equ 0x00000008 ; ACLINK Off
CTRL_CNT_WARM equ 0x00000004 ; AC97 Warm Reset CTRL_CNT_WARM equ 0x00000004 ; AC97 Warm Reset
CTRL_CNT_COLD equ 0x00000002 ; AC97 Cold Reset CTRL_CNT_COLD equ 0x00000002 ; AC97 Cold Reset
CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable
CODEC_REG_POWERDOWN equ 0x26 CODEC_REG_POWERDOWN equ 0x26
CODEC_REG_ST equ 0x26 CODEC_REG_ST equ 0x26
@ -271,8 +271,8 @@ end virtual
EVENT_NOTIFY equ 0x00000200 EVENT_NOTIFY equ 0x00000200
OS_BASE equ 0; OS_BASE equ 0;
new_app_base equ 0x60400000 PROC_BASE equ OS_BASE+0x0080000
PROC_BASE equ OS_BASE+0x0080000 new_app_base equ 0x80000000
public START public START
public service_proc public service_proc
@ -405,27 +405,26 @@ proc service_proc stdcall, ioctl:dword
@@: @@:
cmp eax, DEV_SET_MASTERVOL cmp eax, DEV_SET_MASTERVOL
jne @F jne @F
mov ebx, [edi+input] mov eax, [edi+input]
stdcall set_master_vol, [ebx] mov eax, [eax]
call set_master_vol ;eax= vol
ret ret
@@: @@:
cmp eax, DEV_GET_MASTERVOL cmp eax, DEV_GET_MASTERVOL
jne @F jne @F
mov ebx, [edi+output] mov ebx, [edi+output]
test ebx, ebx add ebx, new_app_base
jz .fail
stdcall get_master_vol, ebx stdcall get_master_vol, ebx
ret ret
@@: ;@@:
cmp eax, DEV_GET_INFO ; cmp eax, DEV_GET_INFO
jne @F ; jne @F
mov ebx, [edi+output] ; mov ebx, [edi+output]
stdcall get_dev_info, ebx ; stdcall get_dev_info, ebx
ret ; ret
@@: @@:
.fail: .fail:
xor eax, eax or eax, -1
ret ret
endp endp
@ -763,8 +762,8 @@ proc set_ICH
ret ret
endp endp
PG_SW equ 0x003 PG_SW equ 0x003
PG_NOCACHE equ 0x018 PG_NOCACHE equ 0x018
align 4 align 4
proc set_ICH4 proc set_ICH4
@ -1004,8 +1003,7 @@ proc cold_reset
endp endp
align 4 align 4
proc play play:
mov eax, 16 mov eax, 16
mov [ctrl.lvi_reg], eax mov [ctrl.lvi_reg], eax
mov edx, PCM_OUT_LVI_REG mov edx, PCM_OUT_LVI_REG
@ -1014,11 +1012,11 @@ proc play
mov edx, PCM_OUT_CR_REG mov edx, PCM_OUT_CR_REG
mov ax, 0x1D mov ax, 0x1D
call [ctrl.ctrl_write8] call [ctrl.ctrl_write8]
xor eax, eax
ret ret
endp
align 4 align 4
proc stop stop:
mov edx, PCM_OUT_CR_REG mov edx, PCM_OUT_CR_REG
mov ax, 0x0 mov ax, 0x0
call [ctrl.ctrl_write8] call [ctrl.ctrl_write8]
@ -1026,8 +1024,8 @@ proc stop
mov ax, 0x1c mov ax, 0x1c
mov edx, PCM_OUT_SR_REG mov edx, PCM_OUT_SR_REG
call [ctrl.ctrl_write16] call [ctrl.ctrl_write16]
xor eax, eax
ret ret
endp
align 4 align 4
proc get_dev_info stdcall, p_info:dword proc get_dev_info stdcall, p_info:dword
@ -1334,9 +1332,9 @@ include "codec.inc"
align 4 align 4
devices dd (CTRL_ICH shl 16)+VID_INTEL,msg_ICH, set_ICH devices dd (CTRL_ICH shl 16)+VID_INTEL,msg_ICH, set_ICH
dd (CTRL_ICH0 shl 16)+VID_INTEL,msg_ICH0,set_ICH dd (CTRL_ICH0 shl 16)+VID_INTEL,msg_ICH0,set_ICH
dd (CTRL_ICH2 shl 16)+VID_INTEL,msg_ICH2,set_ICH dd (CTRL_ICH2 shl 16)+VID_INTEL,msg_ICH2,set_ICH
dd (CTRL_ICH3 shl 16)+VID_INTEL,msg_ICH3,set_ICH dd (CTRL_ICH3 shl 16)+VID_INTEL,msg_ICH3,set_ICH
dd (CTRL_ICH4 shl 16)+VID_INTEL,msg_ICH4,set_ICH4 dd (CTRL_ICH4 shl 16)+VID_INTEL,msg_ICH4,set_ICH4
dd (CTRL_ICH5 shl 16)+VID_INTEL,msg_ICH5,set_ICH4 dd (CTRL_ICH5 shl 16)+VID_INTEL,msg_ICH5,set_ICH4
dd (CTRL_ICH6 shl 16)+VID_INTEL,msg_ICH6,set_ICH4 dd (CTRL_ICH6 shl 16)+VID_INTEL,msg_ICH6,set_ICH4
@ -1353,7 +1351,7 @@ devices dd (CTRL_ICH shl 16)+VID_INTEL,msg_ICH, set_ICH
dd 0 ;terminator dd 0 ;terminator
version dd 0x00030003 version dd 0x00040004
msg_ICH db 'Intel ICH', 13,10, 0 msg_ICH db 'Intel ICH', 13,10, 0
msg_ICH0 db 'Intel ICH0', 13,10, 0 msg_ICH0 db 'Intel ICH0', 13,10, 0

View File

@ -169,7 +169,7 @@ include 'unpacker.inc'
__DEBUG__ fix 1 __DEBUG__ fix 1
__DEBUG_LEVEL__ fix 1 __DEBUG_LEVEL__ fix 1
include 'debug-fdo.inc' include 'fdo.inc'
iglobal iglobal
boot_memdetect db 'Determining amount of memory',0 boot_memdetect db 'Determining amount of memory',0
@ -372,31 +372,31 @@ B32:
bts [cpu_caps], CAPS_TSC ;force use rdtsc bts [cpu_caps], CAPS_TSC ;force use rdtsc
; -------- Fast System Call init ---------- ; -------- Fast System Call init ----------
; Intel SYSENTER/SYSEXIT (AMD CPU support it too) ; Intel SYSENTER/SYSEXIT (AMD CPU support it too)
bt [cpu_caps], CAPS_SEP bt [cpu_caps], CAPS_SEP
jnc .SEnP ; SysEnter not Present jnc .SEnP ; SysEnter not Present
xor edx, edx xor edx, edx
mov ecx, MSR_SYSENTER_CS mov ecx, MSR_SYSENTER_CS
mov eax, os_code mov eax, os_code
wrmsr wrmsr
mov ecx, MSR_SYSENTER_ESP mov ecx, MSR_SYSENTER_ESP
mov eax, sysenter_stack ; Check it mov eax, sysenter_stack ; Check it
wrmsr wrmsr
mov ecx, MSR_SYSENTER_EIP mov ecx, MSR_SYSENTER_EIP
mov eax, sysenter_entry mov eax, sysenter_entry
wrmsr wrmsr
.SEnP: .SEnP:
; AMD SYSCALL/SYSRET ; AMD SYSCALL/SYSRET
cmp byte[cpu_vendor], 'A' cmp byte[cpu_vendor], 'A'
jne .noSYSCALL jne .noSYSCALL
mov eax, 0x80000001 mov eax, 0x80000001
cpuid cpuid
test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support
jz .noSYSCALL jz .noSYSCALL
mov ecx, MSR_AMD_EFER mov ecx, MSR_AMD_EFER
rdmsr rdmsr
or eax, 1 ; bit_0 - System Call Extension (SCE) or eax, 1 ; bit_0 - System Call Extension (SCE)
wrmsr wrmsr
; !!!! It`s dirty hack, fix it !!! ; !!!! It`s dirty hack, fix it !!!
; Bits of EDX : ; Bits of EDX :
@ -406,16 +406,19 @@ B32:
; and the contents of this field, plus 8, are copied into the SS register. ; and the contents of this field, plus 8, are copied into the SS register.
; mov edx, (os_code + 16) * 65536 + os_code ; mov edx, (os_code + 16) * 65536 + os_code
mov edx, 0x1B0013 mov edx, 0x1B0013
mov eax, syscall_entry mov eax, syscall_entry
mov ecx, MSR_AMD_STAR mov ecx, MSR_AMD_STAR
wrmsr wrmsr
.noSYSCALL: .noSYSCALL:
; ----------------------------------------- ; -----------------------------------------
; MEMORY MODEL ; MEMORY MODEL
call mem_test call mem_test
call init_mtrr
call init_mem call init_mem
call init_page_map call init_page_map
@ -430,8 +433,8 @@ B32:
call init_kernel_heap call init_kernel_heap
stdcall kernel_alloc, 0x2000 stdcall kernel_alloc, 0x2000
mov [os_stack], eax mov [os_stack], eax
call init_LFB call init_LFB
call init_mtrr
call init_fpu call init_fpu
call init_malloc call init_malloc
@ -4872,6 +4875,7 @@ read_from_hd: ; Read from hd - fn not in use
align 4 align 4
paleholder: paleholder:
ret ret
; --------------- APM --------------------- ; --------------- APM ---------------------
apm_entry dp 0 apm_entry dp 0
apm_vf dd 0 apm_vf dd 0

View File

@ -211,8 +211,14 @@
; ;
; ;
; 0x0098B000 -> kernel heap ; 0x0098B000 -> kernel heap
;
; 0x01FFFFFF heam min limit
; 0x7DBFFFFF heap max limit
; 0x7DC00000 -> 0x7FBFFFFF LFB 32Mb
; 0x7DC00000 -> 0x7E3FFFFF application available LFB 8Mb
; 0x7E400000 -> 0x7FBFFFFF kernel LFB part 24 Mb
; 0x7FC00000 -> 0x7FFFFFFF page tables 4Mb
; 0x80000000 -> 0xFFFFFFFF application 2Gb