forked from KolibriOS/kolibrios
1.new drivers loader
2.changes in 68.11 init_heap git-svn-id: svn://kolibrios.org@188 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
7d1826758e
commit
ad55c9aee2
@ -162,7 +162,7 @@ KEY_BUFF equ OS_BASE+0x000F401
|
||||
BTN_COUNT equ OS_BASE+0x000F500
|
||||
BTN_BUFF equ OS_BASE+0x000F501
|
||||
|
||||
TSC equ OS_BASE+0x000F600
|
||||
CPU_FREQ equ OS_BASE+0x000F600
|
||||
MOUSE_PORT equ OS_BASE+0x000F604
|
||||
|
||||
PS2_CHUNK equ OS_BASE+0x000FB00
|
||||
@ -226,47 +226,44 @@ stack_data_end equ OS_BASE+0x071ffff
|
||||
VMODE_BASE equ OS_BASE+0x0760000
|
||||
resendQ equ OS_BASE+0x0770000
|
||||
|
||||
;skin_data equ OS_BASE+0x0778000
|
||||
;skin_data equ OS_BASE+0x0778000
|
||||
|
||||
draw_data equ OS_BASE+0x0800000
|
||||
sysint_stack_data equ OS_BASE+0x0803000
|
||||
|
||||
tss_data equ OS_BASE+0x0920000
|
||||
|
||||
;tmp_pg_dir equ OS_BASE+0x00050000
|
||||
;tmp_page_map equ 0x00051000
|
||||
;master_tab equ 0x80200000
|
||||
pages_tab equ 0x60000000
|
||||
master_tab equ 0x60180000
|
||||
current_pgdir equ 0x60180000
|
||||
|
||||
pages_tab equ 0x60000000
|
||||
master_tab equ 0x60180000
|
||||
sys_pgdir equ OS_BASE+0x00050000
|
||||
sys_master_tab equ OS_BASE+0x00051000
|
||||
sys_pgmap equ OS_BASE+0x00052000
|
||||
|
||||
sys_pgdir equ OS_BASE+0x00050000
|
||||
sys_master_tab equ OS_BASE+0x00051000
|
||||
sys_pgmap equ OS_BASE+0x00052000
|
||||
|
||||
;lfb_start equ 0x00800000
|
||||
;lfb_start equ 0x00800000
|
||||
|
||||
;new_app_pdir equ OS_BASE+0x01000000
|
||||
;new_app_master_table equ OS_BASE+0x01001000
|
||||
;new_app_ptable equ OS_BASE+0x01002000
|
||||
|
||||
new_app_base equ 0x60400000
|
||||
new_app_base equ 0x60400000
|
||||
|
||||
twdw equ (CURRENT_TASK-window_data)
|
||||
twdw equ (CURRENT_TASK-window_data)
|
||||
|
||||
std_application_base_address equ new_app_base
|
||||
|
||||
PAGES_USED equ 4
|
||||
PAGES_USED equ 4
|
||||
|
||||
PG_UNMAP equ 0x000
|
||||
PG_MAP equ 0x001
|
||||
PG_WRITE equ 0x002
|
||||
PG_SW equ 0x003
|
||||
PG_USER equ 0x005
|
||||
PG_UW equ 0x007
|
||||
PG_NOCACHE equ 0x018
|
||||
PG_LARGE equ 0x080
|
||||
PG_GLOBAL equ 0x100
|
||||
PG_UNMAP equ 0x000
|
||||
PG_MAP equ 0x001
|
||||
PG_WRITE equ 0x002
|
||||
PG_SW equ 0x003
|
||||
PG_USER equ 0x005
|
||||
PG_UW equ 0x007
|
||||
PG_NOCACHE equ 0x018
|
||||
PG_LARGE equ 0x080
|
||||
PG_GLOBAL equ 0x100
|
||||
|
||||
;;;;;;;;;;;boot time variables
|
||||
|
||||
@ -379,7 +376,7 @@ struc SRV
|
||||
{ .srv_name rb 16
|
||||
.magic dd ?
|
||||
.size dd ?
|
||||
.lib dd ?
|
||||
.base dd ?
|
||||
.srv_proc dd ?
|
||||
}
|
||||
|
||||
@ -421,6 +418,7 @@ struc COFF_SYM
|
||||
.StorageClass db ?
|
||||
.NumAuxSymbols db ?
|
||||
}
|
||||
CSYM_SIZE equ 18
|
||||
|
||||
struc IOCTL
|
||||
{ .handle dd ?
|
||||
@ -446,6 +444,10 @@ virtual at 0
|
||||
SRV SRV
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
CFH COFF_HEADER
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
CFS COFF_SECTION
|
||||
end virtual
|
||||
@ -458,8 +460,3 @@ virtual at 0
|
||||
CSYM COFF_SYM
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
CFH COFF_HEADER
|
||||
end virtual
|
||||
|
||||
|
||||
|
@ -291,48 +291,34 @@ proc get_service stdcall, sz_name:dword
|
||||
locals
|
||||
srv_ptr dd ?
|
||||
counter dd ?
|
||||
endl
|
||||
endl
|
||||
|
||||
mov eax, [sz_name]
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
mov [srv_ptr], srv_tab
|
||||
mov [counter], 16
|
||||
mov eax, [sz_name]
|
||||
test eax, eax
|
||||
jnz @F
|
||||
ret
|
||||
@@:
|
||||
stdcall strncmp, [srv_ptr], [sz_name], 16
|
||||
test eax, eax
|
||||
je .ok
|
||||
mov [srv_ptr], srv_tab
|
||||
mov [counter], 16
|
||||
@@:
|
||||
stdcall strncmp, [srv_ptr], [sz_name], 16
|
||||
test eax, eax
|
||||
je .ok
|
||||
|
||||
add [srv_ptr], SRV_SIZE
|
||||
dec [counter]
|
||||
jnz @B
|
||||
add [srv_ptr], SRV_SIZE
|
||||
dec [counter]
|
||||
jnz @B
|
||||
.not_load:
|
||||
|
||||
stdcall find_service, [sz_name]
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
stdcall load_lib, eax
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
mov [srv_ptr], srv_tab
|
||||
mov [counter], 16
|
||||
jnz @F
|
||||
ret
|
||||
@@:
|
||||
stdcall strncmp, [srv_ptr], [sz_name], 16
|
||||
test eax, eax
|
||||
je .ok
|
||||
|
||||
add [srv_ptr], SRV_SIZE
|
||||
dec [counter]
|
||||
jnz @B
|
||||
.fail:
|
||||
xor eax, eax
|
||||
ret
|
||||
stdcall load_driver, eax
|
||||
ret
|
||||
.ok:
|
||||
mov eax, [srv_ptr]
|
||||
ret
|
||||
mov eax, [srv_ptr]
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
@ -422,29 +408,6 @@ proc get_proc stdcall, exp:dword, sz_name:dword
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc link_dll stdcall, exp:dword, imp:dword
|
||||
mov esi, [imp]
|
||||
.next:
|
||||
mov eax, [esi]
|
||||
test eax, eax
|
||||
jz .end
|
||||
|
||||
push esi
|
||||
stdcall get_proc, [exp], eax
|
||||
pop esi
|
||||
|
||||
test eax, eax
|
||||
jz @F
|
||||
|
||||
mov [esi], eax
|
||||
@@:
|
||||
add esi, 4
|
||||
jmp .next
|
||||
.end:
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc get_coff_sym stdcall, pSym:dword,count:dword, sz_sym:dword
|
||||
|
||||
@ -464,143 +427,387 @@ proc get_coff_sym stdcall, pSym:dword,count:dword, sz_sym:dword
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc load_lib stdcall, name:dword
|
||||
locals
|
||||
lib dd ?
|
||||
base dd ?
|
||||
pSym dd ?
|
||||
endl
|
||||
|
||||
mov eax, [name]
|
||||
mov ebx, 1 ;index of first block
|
||||
mov ecx, 32 ;number of blocks
|
||||
mov edx, TMP_BUFF ;temp area
|
||||
mov esi, 12 ;file name length
|
||||
|
||||
call fileread ;read file from RD
|
||||
|
||||
cmp eax,0
|
||||
jne .err
|
||||
|
||||
; mov eax, [TMP_BUFF+CFH.pSymTable]
|
||||
; add eax, TMP_BUFF
|
||||
; mov [pSym], eax
|
||||
|
||||
; mov [TMP_BUFF+20+CFS.VirtualAddress], eax
|
||||
|
||||
stdcall kernel_alloc, [TMP_BUFF+20+CFS.SizeOfRawData]
|
||||
mov [base], eax
|
||||
|
||||
test eax, eax
|
||||
jnz @f
|
||||
@@:
|
||||
mov [TMP_BUFF+20+CFS.VirtualAddress], eax
|
||||
mov ebx, [TMP_BUFF+CFH.pSymTable]
|
||||
add ebx, TMP_BUFF
|
||||
mov [pSym], ebx
|
||||
|
||||
stdcall LinkSection, TMP_BUFF, TMP_BUFF+20, ebx
|
||||
|
||||
mov edi, [base]
|
||||
test edi, edi
|
||||
jnz @f
|
||||
@@:
|
||||
mov esi, [TMP_BUFF+20+CFS.PtrRawData]
|
||||
add esi, TMP_BUFF
|
||||
mov ecx, [TMP_BUFF+20+CFS.SizeOfRawData]
|
||||
rep movsb
|
||||
|
||||
call alloc_dll
|
||||
test eax, eax
|
||||
jnz @f
|
||||
@@:
|
||||
mov [lib], eax
|
||||
|
||||
mov edi, eax
|
||||
mov esi, [name]
|
||||
mov ecx, 16
|
||||
rep movsb
|
||||
|
||||
stdcall get_coff_sym,[pSym],[TMP_BUFF+CFH.nSymbols],szSTART
|
||||
mov edi, [lib]
|
||||
add eax, [base]
|
||||
mov [edi+LIB.lib_start], eax
|
||||
mov ebx, [base]
|
||||
mov [edi+LIB.lib_base], ebx
|
||||
|
||||
stdcall get_coff_sym,[pSym],[TMP_BUFF+CFH.nSymbols], szEXPORTS
|
||||
mov edi, [lib]
|
||||
add eax, [base]
|
||||
mov [edi+LIB.export], eax
|
||||
|
||||
stdcall get_coff_sym,[pSym],[TMP_BUFF+CFH.nSymbols], szIMPORTS
|
||||
mov edi, [lib]
|
||||
add eax, [base]
|
||||
mov [edi+LIB.import], eax
|
||||
|
||||
stdcall link_dll, kernel_export, eax
|
||||
|
||||
mov edi, [lib]
|
||||
call [edi+LIB.lib_start]
|
||||
|
||||
mov eax, [lib]
|
||||
ret
|
||||
.err:
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc LinkSection stdcall, pCoff:dword, pSec:dword, pSym:dword
|
||||
locals
|
||||
pCode dd ?
|
||||
endl
|
||||
|
||||
mov esi, [pSec]
|
||||
mov eax, [esi+CFS.PtrRawData]
|
||||
add eax, [pCoff]
|
||||
mov [pCode], eax
|
||||
|
||||
mov edi, [esi+CFS.PtrReloc]
|
||||
add edi, [pCoff]
|
||||
|
||||
movzx edx, [esi+CFS.NumReloc]
|
||||
mov eax, edx
|
||||
lea edx, [edx+edx*8]
|
||||
add edx, eax
|
||||
add edx, edi
|
||||
.l_0:
|
||||
cmp edi, edx
|
||||
jae .exit
|
||||
|
||||
mov ebx, [edi+CRELOC.SymIndex]
|
||||
add ebx,ebx
|
||||
lea ebx,[ebx+ebx*8]
|
||||
|
||||
add ebx, [pSym]
|
||||
|
||||
mov ecx, [ebx+CSYM.Value]
|
||||
add ecx, [esi+CFS.VirtualAddress]
|
||||
|
||||
mov eax, [edi+CRELOC.VirtualAddress]
|
||||
add eax, [pCode]
|
||||
add [eax], ecx
|
||||
add edi, 10
|
||||
jmp .l_0
|
||||
|
||||
.exit:
|
||||
ret
|
||||
endp
|
||||
|
||||
proc get_curr_task
|
||||
mov eax,[CURRENT_TASK]
|
||||
shl eax, 8
|
||||
ret
|
||||
endp
|
||||
|
||||
drv_sound db 'UNISOUNDOBJ', 0
|
||||
drv_infinity db 'INFINITYOBJ', 0
|
||||
align 4
|
||||
proc get_fileinfo stdcall, file_name:dword, info:dword
|
||||
locals
|
||||
cmd dd ?
|
||||
offset dd ?
|
||||
dd ?
|
||||
count dd ?
|
||||
buff dd ?
|
||||
db ?
|
||||
name dd ?
|
||||
endl
|
||||
|
||||
xor eax, eax
|
||||
mov ebx, [file_name]
|
||||
sub ebx, new_app_base
|
||||
mov ecx, [info]
|
||||
sub ecx, new_app_base
|
||||
|
||||
mov [cmd], 5
|
||||
mov [offset], eax
|
||||
mov [offset+4], eax
|
||||
mov [count], eax
|
||||
mov [buff], ecx
|
||||
mov byte [buff+4], al
|
||||
mov [name], ebx
|
||||
|
||||
mov eax, 70
|
||||
lea ebx, [cmd]
|
||||
sub ebx, new_app_base
|
||||
int 0x40
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc read_file stdcall,file_name:dword, buffer:dword, off:dword,\
|
||||
bytes:dword
|
||||
locals
|
||||
cmd dd ?
|
||||
offset dd ?
|
||||
dd ?
|
||||
count dd ?
|
||||
buff dd ?
|
||||
db ?
|
||||
name dd ?
|
||||
endl
|
||||
|
||||
xor eax, eax
|
||||
mov ebx, [file_name]
|
||||
mov ecx, [off]
|
||||
mov edx, [bytes]
|
||||
mov esi, [buffer]
|
||||
sub ebx, new_app_base
|
||||
sub esi, new_app_base
|
||||
|
||||
mov [cmd], eax
|
||||
mov [offset], ecx
|
||||
mov [offset+4], eax
|
||||
mov [count], edx
|
||||
mov [buff], esi
|
||||
mov byte [buff+4], al
|
||||
mov [name], ebx
|
||||
|
||||
mov eax, 70
|
||||
lea ebx, [cmd]
|
||||
sub ebx, new_app_base
|
||||
int 0x40
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc load_file stdcall, file_name:dword
|
||||
locals
|
||||
attr dd ?
|
||||
flags dd ?
|
||||
cr_time dd ?
|
||||
cr_date dd ?
|
||||
acc_time dd ?
|
||||
acc_date dd ?
|
||||
mod_time dd ?
|
||||
mod_date dd ?
|
||||
file_size dd ?
|
||||
|
||||
file dd ?
|
||||
endl
|
||||
|
||||
lea eax, [attr]
|
||||
stdcall get_fileinfo, [file_name], eax
|
||||
test eax, eax
|
||||
jnz .fail
|
||||
|
||||
stdcall kernel_alloc, [file_size]
|
||||
mov [file], eax
|
||||
|
||||
stdcall read_file, [file_name], eax, dword 0, [file_size]
|
||||
cmp ebx, [file_size]
|
||||
jne .cleanup
|
||||
mov eax, [file]
|
||||
ret
|
||||
.cleanup:
|
||||
stdcall kernel_free, [file]
|
||||
.fail:
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc get_proc_ex stdcall, proc_name:dword, imports:dword
|
||||
|
||||
.look_up:
|
||||
mov edx, [imports]
|
||||
mov edx, [edx]
|
||||
test edx, edx
|
||||
jz .end
|
||||
.next:
|
||||
mov eax, [edx]
|
||||
test eax, eax
|
||||
jz .next_table
|
||||
|
||||
push edx
|
||||
stdcall strncmp, eax, [proc_name], 16
|
||||
pop edx
|
||||
test eax, eax
|
||||
jz .ok
|
||||
|
||||
add edx,8
|
||||
jmp .next
|
||||
.next_table:
|
||||
add [imports], 4
|
||||
jmp .look_up
|
||||
.ok:
|
||||
mov eax, [edx+4]
|
||||
ret
|
||||
.end:
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc fix_coff_symbols stdcall, sec:dword, symbols:dword,\
|
||||
sym_count:dword, strings:dword, imports:dword
|
||||
locals
|
||||
retval dd ?
|
||||
endl
|
||||
|
||||
mov edi, [symbols]
|
||||
mov [retval], 1
|
||||
.fix:
|
||||
movzx ebx, [edi+CSYM.SectionNumber]
|
||||
test ebx, ebx
|
||||
jnz .internal
|
||||
mov eax, dword [edi+CSYM.Name]
|
||||
test eax, eax
|
||||
jnz @F
|
||||
|
||||
mov edi, [edi+4]
|
||||
add edi, [strings]
|
||||
@@:
|
||||
push edi
|
||||
stdcall get_proc_ex, edi,[imports]
|
||||
pop edi
|
||||
|
||||
xor ebx, ebx
|
||||
test eax, eax
|
||||
jnz @F
|
||||
|
||||
mov esi, msg_unresolved
|
||||
call sys_msg_board_str
|
||||
mov esi, edi
|
||||
call sys_msg_board_str
|
||||
mov esi, msg_CR
|
||||
call sys_msg_board_str
|
||||
|
||||
mov [retval],0
|
||||
@@:
|
||||
mov edi, [symbols]
|
||||
mov [edi+CSYM.Value], eax
|
||||
jmp .next
|
||||
.internal:
|
||||
dec ebx
|
||||
shl ebx, 3
|
||||
lea ebx, [ebx+ebx*4]
|
||||
add ebx, [sec]
|
||||
|
||||
mov eax, [ebx+CFS.VirtualAddress]
|
||||
add [edi+CSYM.Value], eax
|
||||
.next:
|
||||
add edi, CSYM_SIZE
|
||||
mov [symbols], edi
|
||||
dec [sym_count]
|
||||
jnz .fix
|
||||
mov eax, [retval]
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc fix_coff_relocs stdcall, coff:dword, sec:dword, sym:dword
|
||||
locals
|
||||
n_sec dd ?
|
||||
endl
|
||||
|
||||
mov eax, [coff]
|
||||
movzx ebx, [eax+CFH.nSections]
|
||||
mov [n_sec], ebx
|
||||
.fix_sec:
|
||||
mov esi, [sec]
|
||||
mov edi, [esi+CFS.PtrReloc]
|
||||
add edi, [coff]
|
||||
|
||||
movzx ecx, [esi+CFS.NumReloc]
|
||||
test ecx, ecx
|
||||
jz .next
|
||||
.next_reloc:
|
||||
mov ebx, [edi+CRELOC.SymIndex]
|
||||
add ebx,ebx
|
||||
lea ebx,[ebx+ebx*8]
|
||||
add ebx, [sym]
|
||||
|
||||
mov edx, [ebx+CSYM.Value]
|
||||
|
||||
cmp [edi+CRELOC.Type], 6
|
||||
je .dir_32
|
||||
|
||||
cmp [edi+CRELOC.Type], 20
|
||||
jne .next_reloc
|
||||
.rel_32:
|
||||
mov eax, [edi+CRELOC.VirtualAddress]
|
||||
add eax, [esi+CFS.VirtualAddress]
|
||||
sub edx, eax
|
||||
sub edx, 4
|
||||
jmp .fix
|
||||
.dir_32:
|
||||
mov eax, [edi+CRELOC.VirtualAddress]
|
||||
add eax, [esi+CFS.VirtualAddress]
|
||||
.fix:
|
||||
add [eax], edx
|
||||
add edi, 10
|
||||
dec ecx
|
||||
jnz .next_reloc
|
||||
.next:
|
||||
add [sec], 40
|
||||
dec [n_sec]
|
||||
jnz .fix_sec
|
||||
.exit:
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc load_driver stdcall, file_name:dword
|
||||
locals
|
||||
coff dd ?
|
||||
sym dd ?
|
||||
strings dd ?
|
||||
img_size dd ?
|
||||
img_base dd ?
|
||||
start dd ?
|
||||
|
||||
exports dd ? ;fake exports table
|
||||
dd ?
|
||||
endl
|
||||
|
||||
stdcall load_file, [file_name]
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
mov [coff], eax
|
||||
|
||||
movzx ecx, [eax+CFH.nSections]
|
||||
xor ebx, ebx
|
||||
|
||||
lea edx, [eax+20]
|
||||
@@:
|
||||
add ebx, [edx+CFS.SizeOfRawData]
|
||||
add ebx, 15
|
||||
and ebx, not 15
|
||||
add edx, 18
|
||||
dec ecx
|
||||
jnz @B
|
||||
mov [img_size], ebx
|
||||
|
||||
stdcall kernel_alloc, ebx
|
||||
test eax, eax
|
||||
jz .fail
|
||||
mov [img_base], eax
|
||||
|
||||
mov edi, eax
|
||||
xor eax, eax
|
||||
mov ecx, [img_size]
|
||||
add ecx, 4095
|
||||
and ecx, not 4095
|
||||
shr ecx, 2
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
mov edx, [coff]
|
||||
movzx ebx, [edx+CFH.nSections]
|
||||
mov edi, [img_base]
|
||||
lea eax, [edx+20]
|
||||
@@:
|
||||
mov [eax+CFS.VirtualAddress], edi
|
||||
mov esi, [eax+CFS.PtrRawData]
|
||||
test esi, esi
|
||||
jnz .copy
|
||||
add edi, [eax+CFS.SizeOfRawData]
|
||||
jmp .next
|
||||
.copy:
|
||||
add esi, edx
|
||||
mov ecx, [eax+CFS.SizeOfRawData]
|
||||
cld
|
||||
rep movsb
|
||||
.next:
|
||||
add edi, 15
|
||||
and edi, not 15
|
||||
add eax, 40
|
||||
dec ebx
|
||||
jnz @B
|
||||
|
||||
mov ebx, [edx+CFH.pSymTable]
|
||||
add ebx, edx
|
||||
mov [sym], ebx
|
||||
mov ecx, [edx+CFH.nSymbols]
|
||||
add ecx,ecx
|
||||
lea ecx,[ecx+ecx*8] ;ecx*=18 = nSymbols*CSYM_SIZE
|
||||
add ecx, [sym]
|
||||
mov [strings], ecx
|
||||
|
||||
lea ebx, [exports]
|
||||
mov dword [ebx], kernel_export
|
||||
mov dword [ebx+4], 0
|
||||
lea eax, [edx+20]
|
||||
|
||||
stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\
|
||||
[strings], ebx
|
||||
test eax, eax
|
||||
jnz @F
|
||||
|
||||
mov esi, msg_module
|
||||
call sys_msg_board_str
|
||||
mov esi, [file_name]
|
||||
call sys_msg_board_str
|
||||
mov esi, msg_CR
|
||||
call sys_msg_board_str
|
||||
|
||||
stdcall kernel_free,[coff]
|
||||
xor eax, eax
|
||||
ret
|
||||
@@:
|
||||
mov ebx, [coff]
|
||||
add ebx, 20
|
||||
stdcall fix_coff_relocs, [coff], ebx, [sym]
|
||||
|
||||
mov ebx, [coff]
|
||||
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szSTART
|
||||
mov [start], eax
|
||||
|
||||
stdcall kernel_free, [coff]
|
||||
|
||||
mov ebx, [start]
|
||||
call ebx
|
||||
test eax, eax
|
||||
jnz .ok
|
||||
|
||||
stdcall kernel_free, [img_base]
|
||||
xor eax, eax
|
||||
ret
|
||||
.ok:
|
||||
mov ebx, [img_base]
|
||||
mov [eax+SRV.base], ebx
|
||||
ret
|
||||
.fail:
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
drv_sound db '/rd/1/unisound.obj', 0
|
||||
drv_infinity db '/rd/1/infinity.obj', 0
|
||||
|
||||
szSound db 'SOUND',0
|
||||
szInfinity db 'INFINITY',0
|
||||
@ -609,6 +816,10 @@ szSTART db 'START',0
|
||||
szEXPORTS db 'EXPORTS',0
|
||||
szIMPORTS db 'IMPORTS',0
|
||||
|
||||
msg_unresolved db 'unresolved ',0
|
||||
msg_module db 'in module ',0
|
||||
msg_CR db 13,10,0
|
||||
|
||||
align 16
|
||||
services:
|
||||
dd szSound, drv_sound
|
||||
|
@ -35,7 +35,7 @@ kernel_export:
|
||||
szKernelAlloc db 'KernelAlloc',0
|
||||
szKernelFree db 'KernelFree',0
|
||||
szGetPgAddr db 'GetPgAddr',0
|
||||
szGetCurrentTask db 'GetCurrentTask ',0
|
||||
szGetCurrentTask db 'GetCurrentTask',0
|
||||
szGetService db 'GetService',0
|
||||
szServiceHandler db 'ServiceHandler',0
|
||||
szFpuSave db 'FpuSave',0
|
||||
|
@ -101,7 +101,6 @@ proc init_kernel_heap
|
||||
mov ecx, 32
|
||||
mov edx, eax
|
||||
mov edi, HEAP_BASE
|
||||
|
||||
.l1:
|
||||
stdcall map_page,edi,edx,PG_SW
|
||||
add edi, 0x1000
|
||||
@ -626,11 +625,10 @@ restore block_flags
|
||||
|
||||
;;;;;;;;;;;;;; USER ;;;;;;;;;;;;;;;;;
|
||||
|
||||
HEAP_TOP equ 0x5FC00000
|
||||
|
||||
align 4
|
||||
proc init_heap stdcall, heap_size:dword
|
||||
locals
|
||||
tab_count dd ?
|
||||
endl
|
||||
proc init_heap
|
||||
|
||||
mov ebx,[CURRENT_TASK]
|
||||
shl ebx,8
|
||||
@ -641,60 +639,20 @@ proc init_heap stdcall, heap_size:dword
|
||||
sub eax, 4096
|
||||
ret
|
||||
@@:
|
||||
mov edx, [heap_size]
|
||||
and edx, edx
|
||||
jz .exit
|
||||
add edx, (4095+4096)
|
||||
and edx, not 4095
|
||||
mov [heap_size], edx
|
||||
add edx, 0x003FFFFF
|
||||
and edx, not 0x003FFFFF
|
||||
shr edx, 22
|
||||
mov [tab_count], edx
|
||||
|
||||
mov esi, [PROC_BASE+APPDATA.mem_size+ebx]
|
||||
add esi, 0x003FFFFF
|
||||
and esi, not 0x003FFFFF
|
||||
mov edi, esi
|
||||
add esi, 4095
|
||||
and esi, not 4095
|
||||
mov eax, HEAP_TOP
|
||||
mov [PROC_BASE+APPDATA.heap_base+ebx], esi
|
||||
add esi, [heap_size]
|
||||
mov [PROC_BASE+APPDATA.heap_top+ebx], esi
|
||||
mov [PROC_BASE+APPDATA.heap_top+ebx], eax
|
||||
|
||||
mov eax, cr3
|
||||
and eax, not 0xFFF
|
||||
stdcall map_page,[current_pdir],eax,dword PG_SW
|
||||
|
||||
add edi, new_app_base
|
||||
@@:
|
||||
call alloc_page
|
||||
test eax, eax
|
||||
jz .exit
|
||||
|
||||
stdcall map_page_table, [current_pdir], edi, eax
|
||||
add edi, 0x00400000
|
||||
dec edx
|
||||
jnz @B
|
||||
|
||||
mov ecx, [tab_count]
|
||||
shl ecx, 12-2
|
||||
mov ebx,[CURRENT_TASK]
|
||||
shl ebx,8
|
||||
mov edi, [PROC_BASE+APPDATA.heap_base+ebx]
|
||||
add edi, new_app_base
|
||||
shr edi, 10
|
||||
mov esi, edi
|
||||
add edi, pages_tab
|
||||
xor eax, eax
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
stdcall map_page,[current_pdir],dword PG_UNMAP
|
||||
|
||||
mov ebx, [heap_size]
|
||||
mov eax, ebx
|
||||
sub eax, esi
|
||||
add esi, new_app_base
|
||||
shr esi, 10
|
||||
mov ecx, eax
|
||||
sub eax, 4096
|
||||
or ebx, FREE_BLOCK
|
||||
mov [pages_tab+esi], ebx
|
||||
or ecx, FREE_BLOCK
|
||||
mov [pages_tab+esi], ecx
|
||||
ret
|
||||
.exit:
|
||||
xor eax, eax
|
||||
@ -776,7 +734,7 @@ proc user_free stdcall, base:dword
|
||||
shr esi, 12
|
||||
mov eax, [pages_tab+esi*4]
|
||||
test eax, USED_BLOCK
|
||||
jz @f
|
||||
jz .not_used
|
||||
|
||||
and eax, not 4095
|
||||
mov ecx, eax
|
||||
@ -786,12 +744,16 @@ proc user_free stdcall, base:dword
|
||||
sub ecx, 4096
|
||||
shr ecx, 12
|
||||
.release:
|
||||
mov eax, [pages_tab+esi*4]
|
||||
xor eax, eax
|
||||
xchg eax, [pages_tab+esi*4]
|
||||
test eax, 1
|
||||
jz @F
|
||||
call free_page
|
||||
@@:
|
||||
inc esi
|
||||
dec ecx
|
||||
jnz .release
|
||||
@@:
|
||||
.not_used:
|
||||
mov ebx, [CURRENT_TASK]
|
||||
shl ebx, 8
|
||||
mov esi, dword [ebx+PROC_BASE+APPDATA.heap_base]; heap_base
|
||||
|
@ -52,14 +52,12 @@ proc init_memEx
|
||||
add eax, 0x00400000
|
||||
mov dword [sys_pgdir+12], eax
|
||||
|
||||
mov dword [sys_pgdir+0x600], sys_master_tab+PG_SW
|
||||
mov dword [sys_master_tab+0x600], sys_master_tab+PG_SW
|
||||
mov dword [sys_pgdir+0x600], sys_pgdir+PG_SW
|
||||
|
||||
mov ecx, [pg_data.kernel_tables]
|
||||
sub ecx, 4
|
||||
mov eax, tmp_page_tab+PG_SW
|
||||
mov edi, sys_pgdir+16
|
||||
mov esi, sys_master_tab+16
|
||||
|
||||
jmp .map_kernel_tabs
|
||||
.no_PSE:
|
||||
@ -82,15 +80,12 @@ proc init_memEx
|
||||
mov ecx, [pg_data.kernel_tables]
|
||||
mov eax, tmp_page_tab+PG_SW
|
||||
mov edi, sys_pgdir
|
||||
mov esi, sys_master_tab
|
||||
|
||||
.map_kernel_tabs:
|
||||
|
||||
mov [edi], eax
|
||||
mov [esi], eax
|
||||
add eax, 0x1000
|
||||
add edi, 4
|
||||
add esi, 4
|
||||
dec ecx
|
||||
jnz .map_kernel_tabs
|
||||
|
||||
@ -106,8 +101,8 @@ proc init_memEx
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
mov dword [sys_pgdir+0x600], sys_master_tab+PG_SW
|
||||
mov dword [sys_master_tab+0x600], sys_master_tab+PG_SW
|
||||
mov dword [sys_pgdir+0x600], sys_pgdir+PG_SW
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
@ -201,7 +196,6 @@ proc alloc_pages stdcall, count:dword
|
||||
.find:
|
||||
mov edx, [count]
|
||||
mov edi, ecx
|
||||
|
||||
.match:
|
||||
cmp byte [ecx], 0xFF
|
||||
jne .next
|
||||
@ -272,15 +266,13 @@ proc free_page
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc map_page_table stdcall,page_dir:dword, lin_addr:dword, phis_addr:dword
|
||||
proc map_page_table stdcall, lin_addr:dword, phis_addr:dword
|
||||
mov ebx, [lin_addr]
|
||||
shr ebx, 22
|
||||
mov eax, [phis_addr]
|
||||
and eax, not 0xFFF
|
||||
or eax, PG_UW ;+PG_NOCACHE
|
||||
mov ecx, [page_dir]
|
||||
mov dword [ecx+ebx*4], eax
|
||||
mov dword [master_tab+ebx*4], eax
|
||||
mov dword [current_pgdir+ebx*4], eax
|
||||
mov eax, [lin_addr]
|
||||
shr eax, 10
|
||||
add eax, pages_tab
|
||||
@ -339,7 +331,7 @@ proc map_LFB
|
||||
|
||||
@@:
|
||||
call alloc_page
|
||||
stdcall map_page_table,sys_pgdir, esi, eax
|
||||
stdcall map_page_table, esi, eax
|
||||
add esi, 0x00400000
|
||||
dec edi
|
||||
jnz @B
|
||||
@ -457,15 +449,12 @@ proc new_mem_resize stdcall, new_size:dword
|
||||
|
||||
xchg esi, edi
|
||||
|
||||
mov eax, cr3
|
||||
stdcall map_page,[tmp_task_pdir],eax,dword PG_SW+PG_NOCACHE
|
||||
|
||||
@@:
|
||||
call alloc_page
|
||||
test eax, eax
|
||||
jz .exit
|
||||
|
||||
stdcall map_page_table,[tmp_task_pdir], edi, eax
|
||||
stdcall map_page_table, edi, eax
|
||||
|
||||
push edi
|
||||
shr edi, 10
|
||||
@ -479,8 +468,6 @@ proc new_mem_resize stdcall, new_size:dword
|
||||
add edi, 0x00400000
|
||||
cmp edi, esi
|
||||
jb @B
|
||||
|
||||
stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP
|
||||
.grow:
|
||||
pop edi
|
||||
pop esi
|
||||
@ -519,7 +506,7 @@ proc get_pg_addr stdcall, lin_addr:dword
|
||||
ret
|
||||
endp
|
||||
|
||||
align 16
|
||||
align 4
|
||||
proc page_fault_handler
|
||||
pushad
|
||||
|
||||
@ -527,9 +514,13 @@ proc page_fault_handler
|
||||
mov eax, cr2
|
||||
push eax
|
||||
push ds
|
||||
push es
|
||||
|
||||
mov ax, 0x10
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
inc [pg_data.pages_faults]
|
||||
|
||||
mov ebx, [ebp-4]
|
||||
|
||||
@ -539,14 +530,15 @@ proc page_fault_handler
|
||||
cmp ebx, 0x60400000
|
||||
jae .user_space
|
||||
|
||||
cmp ebx, master_tab+0x1000
|
||||
jae .alloc
|
||||
|
||||
cmp ebx, 0x60000000
|
||||
jae .tab_space
|
||||
|
||||
jmp .kernel_space
|
||||
|
||||
.user_space:
|
||||
inc [pg_data.pages_faults]
|
||||
|
||||
shr ebx, 12
|
||||
mov ecx, ebx
|
||||
shr ecx, 10
|
||||
@ -557,29 +549,28 @@ proc page_fault_handler
|
||||
mov eax, [pages_tab+ebx*4]
|
||||
test eax, 2
|
||||
jz .fail
|
||||
|
||||
.alloc:
|
||||
call alloc_page
|
||||
and eax, eax
|
||||
jz .exit
|
||||
|
||||
stdcall map_page,[ebp-4],eax,dword PG_UW
|
||||
|
||||
mov esi, [ebp-4]
|
||||
and esi, 0xFFFFF000
|
||||
mov edi, [ebp-4]
|
||||
and edi, 0xFFFFF000
|
||||
mov ecx, 1024
|
||||
xor eax, eax
|
||||
@@:
|
||||
mov [esi], eax
|
||||
add esi, 4
|
||||
dec ecx
|
||||
jnz @B
|
||||
cld
|
||||
rep stosd
|
||||
.exit:
|
||||
pop es
|
||||
pop ds
|
||||
mov esp, ebp
|
||||
popad
|
||||
add esp, 4
|
||||
iretd
|
||||
.fail:
|
||||
pop es
|
||||
pop ds
|
||||
mov esp, ebp
|
||||
popad
|
||||
@ -592,52 +583,29 @@ proc page_fault_handler
|
||||
iretd
|
||||
|
||||
.kernel_space:
|
||||
shr ebx, 12
|
||||
mov eax, [pages_tab+ebx*4]
|
||||
shr ebx, 10
|
||||
mov eax, [master_tab+ebx*4]
|
||||
|
||||
pop ds
|
||||
mov esp, ebp
|
||||
popad
|
||||
add esp, 4
|
||||
iretd
|
||||
|
||||
; shr ebx, 12
|
||||
; mov eax, [pages_tab+ebx*4]
|
||||
; shr ebx, 10
|
||||
; mov eax, [master_tab+ebx*4]
|
||||
jmp .exit
|
||||
.old_addr:
|
||||
shr ebx, 12
|
||||
; shr ebx, 12
|
||||
; mov eax, [pages_tab+ebx*4]
|
||||
shr ebx, 10
|
||||
mov eax, [master_tab+ebx*4]
|
||||
|
||||
pop ds
|
||||
mov esp, ebp
|
||||
popad
|
||||
add esp, 4
|
||||
iretd
|
||||
|
||||
; shr ebx, 10
|
||||
; mov eax, [master_tab+ebx*4]
|
||||
jmp .exit
|
||||
.lfb_addr:
|
||||
shr ebx, 22
|
||||
;mov ecx, [sys_page_dir]
|
||||
mov eax, [master_tab+ebx*4]
|
||||
|
||||
pop ds
|
||||
mov esp, ebp
|
||||
popad
|
||||
add esp, 4
|
||||
iretd
|
||||
|
||||
; shr ebx, 22
|
||||
; ;mov ecx, [sys_page_dir]
|
||||
; mov eax, [master_tab+ebx*4]
|
||||
jmp .exit
|
||||
.tab_space:
|
||||
shr ebx, 12
|
||||
; shr ebx, 12
|
||||
; mov eax, [pages_tab+ebx*4]
|
||||
shr ebx, 10
|
||||
;mov ecx, [sys_page_dir]
|
||||
mov eax, [master_tab+ebx*4]
|
||||
|
||||
pop ds
|
||||
mov esp, ebp
|
||||
popad
|
||||
add esp, 4
|
||||
iretd
|
||||
; shr ebx, 10
|
||||
; ;mov ecx, [sys_page_dir]
|
||||
; mov eax, [master_tab+ebx*4]
|
||||
jmp .exit
|
||||
endp
|
||||
|
||||
align 4
|
||||
@ -758,14 +726,12 @@ sys_IPC:
|
||||
call set_ipc_buff
|
||||
mov [esp+36], eax
|
||||
ret
|
||||
|
||||
@@:
|
||||
cmp eax, 2
|
||||
jne @f
|
||||
stdcall sys_ipc_send, ebx, ecx, edx
|
||||
mov [esp+36], eax
|
||||
ret
|
||||
|
||||
@@:
|
||||
xor eax, eax
|
||||
not eax
|
||||
@ -945,7 +911,7 @@ new_services:
|
||||
jb .fail
|
||||
ja @f
|
||||
|
||||
stdcall init_heap, ebx
|
||||
call init_heap
|
||||
mov [esp+36], eax
|
||||
ret
|
||||
@@:
|
||||
@ -958,7 +924,7 @@ new_services:
|
||||
@@:
|
||||
cmp eax, 13
|
||||
ja @f
|
||||
|
||||
add ebx, new_app_base
|
||||
stdcall user_free, ebx
|
||||
mov [esp+36], eax
|
||||
ret
|
||||
@ -983,6 +949,8 @@ new_services:
|
||||
cmp eax, 16
|
||||
ja @f
|
||||
|
||||
test ebx, ebx
|
||||
jz .fail
|
||||
add ebx, new_app_base
|
||||
cmp ebx, new_app_base
|
||||
jb .fail
|
||||
@ -1299,7 +1267,7 @@ align 16
|
||||
tmp_task_ptab rd 1
|
||||
tmp_task_data rd 1
|
||||
|
||||
current_pdir rd 1
|
||||
; current_pdir rd 1
|
||||
|
||||
fpu_data rd 1
|
||||
fdd_buff rd 1
|
||||
|
@ -119,7 +119,6 @@ proc create_app_space stdcall, app_size:dword,img_size:dword
|
||||
app_pages dd ?
|
||||
img_pages dd ?
|
||||
dir_addr dd ?
|
||||
master_addr dd ?
|
||||
app_tabs dd ?
|
||||
endl
|
||||
|
||||
@ -127,7 +126,6 @@ proc create_app_space stdcall, app_size:dword,img_size:dword
|
||||
|
||||
xor eax, eax
|
||||
mov [dir_addr], eax
|
||||
mov [master_addr], eax
|
||||
|
||||
mov eax, [app_size]
|
||||
add eax, 4095
|
||||
@ -179,32 +177,10 @@ proc create_app_space stdcall, app_size:dword,img_size:dword
|
||||
mov esi, sys_pgdir+0xc00
|
||||
rep movsd
|
||||
|
||||
call alloc_page
|
||||
test eax, eax
|
||||
jz .fail
|
||||
mov [master_addr], eax
|
||||
stdcall map_page,[tmp_task_ptab],eax,dword PG_SW
|
||||
|
||||
mov ecx, 384
|
||||
mov edi, [tmp_task_ptab]
|
||||
mov esi, master_tab
|
||||
cld
|
||||
rep movsd
|
||||
|
||||
mov ecx, 384
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
|
||||
mov ecx, 256
|
||||
mov esi, master_tab+0xc00
|
||||
rep movsd
|
||||
|
||||
mov eax, [master_addr]
|
||||
mov eax, [dir_addr]
|
||||
or eax, PG_SW
|
||||
mov ebx, [tmp_task_pdir]
|
||||
mov [ebx+0x600], eax
|
||||
mov ecx, [tmp_task_ptab]
|
||||
mov [ecx+0x600],eax
|
||||
|
||||
mov eax, [dir_addr]
|
||||
call set_cr3
|
||||
@ -216,7 +192,7 @@ proc create_app_space stdcall, app_size:dword,img_size:dword
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
stdcall map_page_table,[tmp_task_pdir], edi, eax
|
||||
stdcall map_page_table, edi, eax
|
||||
add edi, 0x00400000
|
||||
dec edx
|
||||
jnz @B
|
||||
@ -230,7 +206,6 @@ proc create_app_space stdcall, app_size:dword,img_size:dword
|
||||
rep stosd
|
||||
|
||||
mov edx, new_app_base
|
||||
|
||||
.alloc:
|
||||
call alloc_page
|
||||
test eax, eax
|
||||
@ -262,7 +237,6 @@ proc create_app_space stdcall, app_size:dword,img_size:dword
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
stdcall map_page,[tmp_task_ptab],dword 0,dword PG_UNMAP
|
||||
stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP
|
||||
|
||||
dec [pg_data.pg_mutex]
|
||||
@ -344,10 +318,7 @@ proc destroy_app_space stdcall, pg_dir:dword
|
||||
and eax, not 0xFFF
|
||||
stdcall map_page,[tmp_task_pdir],eax,dword PG_SW
|
||||
mov esi, [tmp_task_pdir]
|
||||
add esi, 0x600
|
||||
mov eax, [esi]
|
||||
call free_page ;destroy master table
|
||||
add esi, 4
|
||||
add esi, 0x604
|
||||
mov edi, 383
|
||||
.destroy:
|
||||
mov eax, [esi]
|
||||
|
@ -3708,14 +3708,13 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
|
||||
<EFBFBD> à ¬¥âàë:
|
||||
* eax = 68 - ®¬¥à äãªæ¨¨
|
||||
* ebx = 11 - ®¬¥à ¯®¤äãªæ¨¨
|
||||
* ecx = à §¬¥à ªãç¨ (¢ ¡ ©â å)
|
||||
‚®§¢à é ¥¬®¥ § 票¥:
|
||||
* eax = 0 - ¥ãᯥå
|
||||
* ¨ ç¥ à §¬¥à ᮧ¤ ®© ªãç¨
|
||||
‡ ¬¥ç ¨ï:
|
||||
* <20> §¬¥à ªãç¨ ¢ëà ¢¨¢ ¥âáï ¢ ¡®«ìèãî áâ®à®ã £à ¨æã áâà ¨æë.
|
||||
* ‚맮¢ äãªæ¨¨ ¨¨æ¨ «¨§¨àã¥â ªãçã, ¨§ ª®â®à®© ¢¯®á«¥¤á⢨¨ ¬®¦®
|
||||
¢ë¤¥«ïâì ¨ ®á¢®¡®¦¤ âì ¡«®ª¨ ¯ ¬ï⨠¯®¤äãªæ¨ï¬¨ 12 ¨ 13.
|
||||
<20> §¬¥à ªãç¨ à ¢¥ à §¬¥à㠢ᥩ ᢮¡®¤®© ¯ ¬ï⨠¯à¨«®¦¥¨ï.
|
||||
* <20>ਠ¯®¢â®à®¬ ¢ë§®¢¥ äãªæ¨¨ ⥬ ¦¥ ¯à®æ¥áᮬ äãªæ¨ï ¢¥àñâ à §¬¥à
|
||||
áãé¥áâ¢ãî饩 ªãç¨.
|
||||
* <20>®á«¥ ᮧ¤ ¨ï ªãç¨ ¢ë§®¢ë äãªæ¨¨ 64.1 ¨£®à¨àãîâáï.
|
||||
|
@ -26,9 +26,27 @@ OS_BASE equ 0; 0x80400000
|
||||
new_app_base equ 0x60400000; 0x01000000
|
||||
PROC_BASE equ OS_BASE+0x0080000
|
||||
|
||||
public service_proc
|
||||
public START
|
||||
public IMPORTS
|
||||
public STOP
|
||||
public service_proc
|
||||
|
||||
extrn AttachIntHandler
|
||||
extrn SysMsgBoardStr
|
||||
extrn PciApi
|
||||
extrn PciRead32
|
||||
extrn PciRead8
|
||||
extrn PciWrite8
|
||||
extrn AllocKernelSpace
|
||||
extrn MapPage
|
||||
extrn RegService
|
||||
extrn KernelAlloc
|
||||
extrn KernelFree
|
||||
extrn GetPgAddr
|
||||
extrn GetCurrentTask
|
||||
extrn GetService
|
||||
extrn ServiceHandler
|
||||
extrn FpuSave
|
||||
extrn FpuRestore
|
||||
|
||||
SND_CREATE_BUFF equ 2
|
||||
SND_PLAY equ 3
|
||||
@ -53,15 +71,15 @@ virtual at 0
|
||||
IOCTL IOCTL
|
||||
end virtual
|
||||
|
||||
section '.flat' align 16
|
||||
section '.flat' code readable align 16
|
||||
|
||||
START:
|
||||
stdcall [GetService], szSound
|
||||
stdcall GetService, szSound
|
||||
test eax, eax
|
||||
jz .fail
|
||||
mov [hSound], eax
|
||||
|
||||
stdcall [KernelAlloc], 16*512
|
||||
stdcall KernelAlloc, 16*512
|
||||
test eax, eax
|
||||
jz .out_of_mem
|
||||
mov [mix_buff], eax
|
||||
@ -75,17 +93,15 @@ START:
|
||||
mov edi, stream
|
||||
mov ecx, 4*STREAM_SIZE
|
||||
rep stosd
|
||||
|
||||
stdcall set_handler, [hSound], new_mix
|
||||
|
||||
stdcall [RegService], szInfinity, service_proc
|
||||
mov [stream_count],0
|
||||
|
||||
stdcall set_handler, [hSound], new_mix
|
||||
stdcall RegService, szInfinity, service_proc
|
||||
ret
|
||||
.fail:
|
||||
if DEBUG
|
||||
mov esi, msgFail
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
xor eax, eax
|
||||
ret
|
||||
@ -93,10 +109,11 @@ START:
|
||||
.out_of_mem:
|
||||
if DEBUG
|
||||
mov esi, msgMem
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
xor eax, eax
|
||||
ret
|
||||
STOP:
|
||||
ret
|
||||
|
||||
handle equ IOCTL.handle
|
||||
io_code equ IOCTL.io_code
|
||||
@ -166,7 +183,6 @@ restore out_size
|
||||
TASK_COUNT equ 0x0003004
|
||||
CURRENT_TASK equ 0x0003000
|
||||
|
||||
|
||||
align 8
|
||||
proc CreateBuffer stdcall, format:dword
|
||||
locals
|
||||
@ -186,7 +202,7 @@ proc CreateBuffer stdcall, format:dword
|
||||
mov [edi+STREAM.magic], 'WAVE'
|
||||
mov [edi+STREAM.size], STREAM_SIZE
|
||||
|
||||
stdcall [KernelAlloc], 180*1024
|
||||
stdcall KernelAlloc, 180*1024
|
||||
|
||||
mov edi, [str]
|
||||
mov [edi+STREAM.base], eax
|
||||
@ -279,8 +295,6 @@ pid_to_slot:
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
|
||||
|
||||
align 4
|
||||
proc DestroyBuffer stdcall, str:dword
|
||||
|
||||
@ -292,7 +306,7 @@ proc DestroyBuffer stdcall, str:dword
|
||||
cmp [esi+STREAM.size], STREAM_SIZE
|
||||
jne .fail
|
||||
|
||||
stdcall [KernelFree], [esi+STREAM.base]
|
||||
stdcall KernelFree, [esi+STREAM.base]
|
||||
|
||||
mov eax, [str]
|
||||
call free_stream
|
||||
@ -625,7 +639,7 @@ proc set_handler stdcall, hsrv:dword, handler_proc:dword
|
||||
mov [out_size], 0
|
||||
|
||||
lea eax, [handler]
|
||||
stdcall [ServiceHandler], eax
|
||||
stdcall ServiceHandler, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
@ -652,16 +666,12 @@ proc dev_play stdcall, hsrv:dword
|
||||
mov [out_size], ebx
|
||||
|
||||
lea eax, [handle]
|
||||
stdcall [ServiceHandler], eax
|
||||
stdcall ServiceHandler, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
include 'mixer.asm'
|
||||
|
||||
align 16
|
||||
play_list dd 16 dup(0)
|
||||
stream_list dd 17 dup(0)
|
||||
|
||||
align 16
|
||||
resampler_params:
|
||||
;r_size r_end r_dt resampler_func
|
||||
@ -720,68 +730,11 @@ resampler_params:
|
||||
dd 2048, 0x02000000, 5462, resample_28 ;35 PCM_2_8_8
|
||||
dd 1024, 0x02000000, 5462, resample_18 ;36 PCM_1_8_8
|
||||
|
||||
|
||||
play_count dd 0
|
||||
|
||||
stream_count dd 0
|
||||
|
||||
align 8
|
||||
hSound dd 0
|
||||
|
||||
m7 dw 0x8000,0x8000,0x8000,0x8000
|
||||
mm80 dq 0x8080808080808080
|
||||
mm_mask dq 0xFF00FF00FF00FF00
|
||||
|
||||
mix_input dd 16 dup(0)
|
||||
|
||||
align 16
|
||||
;fpu_state db 512 dup(0)
|
||||
|
||||
align 16
|
||||
stream db STREAM_SIZE*16 dup(0)
|
||||
stream_map dd 0xFFFF ; 16
|
||||
mix_buff dd 0
|
||||
mix_buff_map dd 0
|
||||
|
||||
align 16
|
||||
IMPORTS:
|
||||
|
||||
AttachIntHandler dd szAttachIntHandler
|
||||
SysMsgBoardStr dd szSysMsgBoardStr
|
||||
PciApi dd szPciApi
|
||||
PciRead32 dd szPciRead32
|
||||
PciRead8 dd szPciRead8
|
||||
AllocKernelSpace dd szAllocKernelSpace
|
||||
MapPage dd szMapPage
|
||||
KernelAlloc dd szKernelAlloc
|
||||
KernelFree dd szKernelFree
|
||||
GetPgAddr dd szGetPgAddr
|
||||
RegService dd szRegService
|
||||
GetCurrentTask dd szGetCurrentTask
|
||||
GetService dd szGetService
|
||||
ServiceHandler dd szServiceHandler
|
||||
FpuSave dd szFpuSave
|
||||
FpuRestore dd szFpuRestore
|
||||
dd 0
|
||||
|
||||
szKernel db 'KERNEL', 0
|
||||
szAttachIntHandler db 'AttachIntHandler',0
|
||||
szSysMsgBoardStr db 'SysMsgBoardStr', 0
|
||||
szPciApi db 'PciApi', 0
|
||||
szPciRead32 db 'PciRead32', 0
|
||||
szPciRead8 db 'PciRead8', 0
|
||||
szAllocKernelSpace db 'AllocKernelSpace',0
|
||||
szMapPage db 'MapPage',0
|
||||
szRegService db 'RegService',0
|
||||
szKernelAlloc db 'KernelAlloc',0
|
||||
szGetPgAddr db 'GetPgAddr',0
|
||||
szGetCurrentTask db 'GetCurrentTask ',0
|
||||
szGetService db 'GetService',0
|
||||
szServiceHandler db 'ServiceHandler',0
|
||||
szKernelFree db 'KernelFree',0
|
||||
szFpuSave db 'FpuSave',0
|
||||
szFpuRestore db 'FpuRestore',0
|
||||
|
||||
|
||||
szInfinity db 'INFINITY',0
|
||||
szSound db 'SOUND',0
|
||||
@ -793,3 +746,18 @@ msgStop db 'Stop',13,10,0
|
||||
msgUser db 'User callback',13,10,0
|
||||
msgMem db 'Not enough memory',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
|
||||
|
||||
|
@ -31,7 +31,7 @@ proc new_mix stdcall, output:dword
|
||||
je .exit
|
||||
; mov eax, fpu_state
|
||||
; fnsave [eax]
|
||||
call [FpuSave]
|
||||
call FpuSave
|
||||
emms
|
||||
mov [main_count], 32;
|
||||
|
||||
@ -98,7 +98,7 @@ proc new_mix stdcall, output:dword
|
||||
jnz .l00
|
||||
|
||||
call update_stream
|
||||
call [FpuRestore]
|
||||
call FpuRestore
|
||||
ret
|
||||
.exit:
|
||||
mov edi, [output]
|
||||
|
@ -95,125 +95,125 @@ DEV_GET_MASTERVOL equ 7
|
||||
DEV_GET_INFO equ 8
|
||||
|
||||
struc AC_CNTRL ;AC controller base class
|
||||
{ .bus dd 0
|
||||
.devfn dd 0
|
||||
{ .bus dd ?
|
||||
.devfn dd ?
|
||||
|
||||
.vendor dd 0
|
||||
.dev_id dd 0
|
||||
.pci_cmd dd 0
|
||||
.pci_stat dd 0
|
||||
.vendor dd ?
|
||||
.dev_id dd ?
|
||||
.pci_cmd dd ?
|
||||
.pci_stat dd ?
|
||||
|
||||
.codec_io_base dd 0
|
||||
.codec_mem_base dd 0
|
||||
.codec_io_base dd ?
|
||||
.codec_mem_base dd ?
|
||||
|
||||
.ctrl_io_base dd 0
|
||||
.ctrl_mem_base dd 0
|
||||
.cfg_reg dd 0
|
||||
.int_line dd 0
|
||||
.ctrl_io_base dd ?
|
||||
.ctrl_mem_base dd ?
|
||||
.cfg_reg dd ?
|
||||
.int_line dd ?
|
||||
|
||||
.vendor_ids dd 0 ;vendor id string
|
||||
.ctrl_ids dd 0 ;hub id string
|
||||
.vendor_ids dd ? ;vendor id string
|
||||
.ctrl_ids dd ? ;hub id string
|
||||
|
||||
.buffer dd 0
|
||||
.buffer dd ?
|
||||
|
||||
.notify_pos dd 0
|
||||
.notify_task dd 0
|
||||
.notify_pos dd ?
|
||||
.notify_task dd ?
|
||||
|
||||
.lvi_reg dd 0
|
||||
.ctrl_setup dd 0
|
||||
.user_callback dd 0
|
||||
.codec_read16 dd 0
|
||||
.codec_write16 dd 0
|
||||
.lvi_reg dd ?
|
||||
.ctrl_setup dd ?
|
||||
.user_callback dd ?
|
||||
.codec_read16 dd ?
|
||||
.codec_write16 dd ?
|
||||
|
||||
.ctrl_read8 dd 0
|
||||
.ctrl_read16 dd 0
|
||||
.ctrl_read32 dd 0
|
||||
.ctrl_read8 dd ?
|
||||
.ctrl_read16 dd ?
|
||||
.ctrl_read32 dd ?
|
||||
|
||||
.ctrl_write8 dd 0
|
||||
.ctrl_write16 dd 0
|
||||
.ctrl_write32 dd 0
|
||||
.ctrl_write8 dd ?
|
||||
.ctrl_write16 dd ?
|
||||
.ctrl_write32 dd ?
|
||||
}
|
||||
|
||||
struc CODEC ;Audio Chip base class
|
||||
{
|
||||
.chip_id dd 0
|
||||
.flags dd 0
|
||||
.status dd 0
|
||||
.chip_id dd ?
|
||||
.flags dd ?
|
||||
.status dd ?
|
||||
|
||||
.ac_vendor_ids dd 0 ;ac vendor id string
|
||||
.chip_ids dd 0 ;chip model string
|
||||
.ac_vendor_ids dd ? ;ac vendor id string
|
||||
.chip_ids dd ? ;chip model string
|
||||
|
||||
.shadow_flag dd 0
|
||||
dd 0
|
||||
.shadow_flag dd ?
|
||||
dd ?
|
||||
|
||||
.regs dw 0 ; codec registers
|
||||
.reg_master_vol dw 0 ;0x02
|
||||
.reg_aux_out_vol dw 0 ;0x04
|
||||
.reg_mone_vol dw 0 ;0x06
|
||||
.reg_master_tone dw 0 ;0x08
|
||||
.reg_beep_vol dw 0 ;0x0A
|
||||
.reg_phone_vol dw 0 ;0x0C
|
||||
.reg_mic_vol dw 0 ;0x0E
|
||||
.reg_line_in_vol dw 0 ;0x10
|
||||
.reg_cd_vol dw 0 ;0x12
|
||||
.reg_video_vol dw 0 ;0x14
|
||||
.reg_aux_in_vol dw 0 ;0x16
|
||||
.reg_pcm_out_vol dw 0 ;0x18
|
||||
.reg_rec_select dw 0 ;0x1A
|
||||
.reg_rec_gain dw 0 ;0x1C
|
||||
.reg_rec_gain_mic dw 0 ;0x1E
|
||||
.reg_gen dw 0 ;0x20
|
||||
.reg_3d_ctrl dw 0 ;0X22
|
||||
.reg_page dw 0 ;0X24
|
||||
.reg_powerdown dw 0 ;0x26
|
||||
.reg_ext_audio dw 0 ;0x28
|
||||
.reg_ext_st dw 0 ;0x2a
|
||||
.reg_pcm_front_rate dw 0 ;0x2c
|
||||
.reg_pcm_surr_rate dw 0 ;0x2e
|
||||
.reg_lfe_rate dw 0 ;0x30
|
||||
.reg_pcm_in_rate dw 0 ;0x32
|
||||
dw 0 ;0x34
|
||||
.reg_cent_lfe_vol dw 0 ;0x36
|
||||
.reg_surr_vol dw 0 ;0x38
|
||||
.reg_spdif_ctrl dw 0 ;0x3A
|
||||
dw 0 ;0x3C
|
||||
dw 0 ;0x3E
|
||||
dw 0 ;0x40
|
||||
dw 0 ;0x42
|
||||
dw 0 ;0x44
|
||||
dw 0 ;0x46
|
||||
dw 0 ;0x48
|
||||
dw 0 ;0x4A
|
||||
dw 0 ;0x4C
|
||||
dw 0 ;0x4E
|
||||
dw 0 ;0x50
|
||||
dw 0 ;0x52
|
||||
dw 0 ;0x54
|
||||
dw 0 ;0x56
|
||||
dw 0 ;0x58
|
||||
dw 0 ;0x5A
|
||||
dw 0 ;0x5C
|
||||
dw 0 ;0x5E
|
||||
.reg_page_0 dw 0 ;0x60
|
||||
.reg_page_1 dw 0 ;0x62
|
||||
.reg_page_2 dw 0 ;0x64
|
||||
.reg_page_3 dw 0 ;0x66
|
||||
.reg_page_4 dw 0 ;0x68
|
||||
.reg_page_5 dw 0 ;0x6A
|
||||
.reg_page_6 dw 0 ;0x6C
|
||||
.reg_page_7 dw 0 ;0x6E
|
||||
dw 0 ;0x70
|
||||
dw 0 ;0x72
|
||||
dw 0 ;0x74
|
||||
dw 0 ;0x76
|
||||
dw 0 ;0x78
|
||||
dw 0 ;0x7A
|
||||
.reg_vendor_id_1 dw 0 ;0x7C
|
||||
.reg_vendor_id_2 dw 0 ;0x7E
|
||||
.regs dw ? ; codec registers
|
||||
.reg_master_vol dw ? ;0x02
|
||||
.reg_aux_out_vol dw ? ;0x04
|
||||
.reg_mone_vol dw ? ;0x06
|
||||
.reg_master_tone dw ? ;0x08
|
||||
.reg_beep_vol dw ? ;0x0A
|
||||
.reg_phone_vol dw ? ;0x0C
|
||||
.reg_mic_vol dw ? ;0x0E
|
||||
.reg_line_in_vol dw ? ;0x10
|
||||
.reg_cd_vol dw ? ;0x12
|
||||
.reg_video_vol dw ? ;0x14
|
||||
.reg_aux_in_vol dw ? ;0x16
|
||||
.reg_pcm_out_vol dw ? ;0x18
|
||||
.reg_rec_select dw ? ;0x1A
|
||||
.reg_rec_gain dw ? ;0x1C
|
||||
.reg_rec_gain_mic dw ? ;0x1E
|
||||
.reg_gen dw ? ;0x20
|
||||
.reg_3d_ctrl dw ? ;0X22
|
||||
.reg_page dw ? ;0X24
|
||||
.reg_powerdown dw ? ;0x26
|
||||
.reg_ext_audio dw ? ;0x28
|
||||
.reg_ext_st dw ? ;0x2a
|
||||
.reg_pcm_front_rate dw ? ;0x2c
|
||||
.reg_pcm_surr_rate dw ? ;0x2e
|
||||
.reg_lfe_rate dw ? ;0x30
|
||||
.reg_pcm_in_rate dw ? ;0x32
|
||||
dw ? ;0x34
|
||||
.reg_cent_lfe_vol dw ? ;0x36
|
||||
.reg_surr_vol dw ? ;0x38
|
||||
.reg_spdif_ctrl dw ? ;0x3A
|
||||
dw ? ;0x3C
|
||||
dw ? ;0x3E
|
||||
dw ? ;0x40
|
||||
dw ? ;0x42
|
||||
dw ? ;0x44
|
||||
dw ? ;0x46
|
||||
dw ? ;0x48
|
||||
dw ? ;0x4A
|
||||
dw ? ;0x4C
|
||||
dw ? ;0x4E
|
||||
dw ? ;0x50
|
||||
dw ? ;0x52
|
||||
dw ? ;0x54
|
||||
dw ? ;0x56
|
||||
dw ? ;0x58
|
||||
dw ? ;0x5A
|
||||
dw ? ;0x5C
|
||||
dw ? ;0x5E
|
||||
.reg_page_0 dw ? ;0x60
|
||||
.reg_page_1 dw ? ;0x62
|
||||
.reg_page_2 dw ? ;0x64
|
||||
.reg_page_3 dw ? ;0x66
|
||||
.reg_page_4 dw ? ;0x68
|
||||
.reg_page_5 dw ? ;0x6A
|
||||
.reg_page_6 dw ? ;0x6C
|
||||
.reg_page_7 dw ? ;0x6E
|
||||
dw ? ;0x70
|
||||
dw ? ;0x72
|
||||
dw ? ;0x74
|
||||
dw ? ;0x76
|
||||
dw ? ;0x78
|
||||
dw ? ;0x7A
|
||||
.reg_vendor_id_1 dw ? ;0x7C
|
||||
.reg_vendor_id_2 dw ? ;0x7E
|
||||
|
||||
|
||||
.reset dd 0 ;virual
|
||||
.set_master_vol dd 0
|
||||
.reset dd ? ;virual
|
||||
.set_master_vol dd ?
|
||||
}
|
||||
|
||||
struc CTRL_INFO
|
||||
@ -247,17 +247,29 @@ OS_BASE equ 0; 0x80400000
|
||||
new_app_base equ 0x60400000; 0x01000000
|
||||
PROC_BASE equ OS_BASE+0x0080000
|
||||
|
||||
|
||||
public service_proc
|
||||
public START
|
||||
public IMPORTS
|
||||
public STOP
|
||||
public service_proc
|
||||
|
||||
section '.flat' align 16
|
||||
extrn AttachIntHandler
|
||||
extrn SysMsgBoardStr
|
||||
extrn PciApi
|
||||
extrn PciRead32
|
||||
extrn PciRead8
|
||||
extrn PciWrite8
|
||||
extrn AllocKernelSpace
|
||||
extrn MapPage
|
||||
extrn RegService
|
||||
extrn KernelAlloc
|
||||
extrn GetPgAddr
|
||||
extrn GetCurrentTask
|
||||
|
||||
section '.flat' code readable align 16
|
||||
|
||||
START:
|
||||
if DEBUG
|
||||
mov esi, msgInit
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
call detect_controller
|
||||
@ -266,9 +278,9 @@ START:
|
||||
|
||||
if DEBUG
|
||||
mov esi,[ctrl.vendor_ids]
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
mov esi, [ctrl.ctrl_ids]
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
call init_controller
|
||||
@ -277,7 +289,7 @@ START:
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgInitCodec
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
call init_codec
|
||||
@ -286,35 +298,35 @@ START:
|
||||
|
||||
if DEBUG
|
||||
mov esi, [codec.ac_vendor_ids]
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
|
||||
mov esi, [codec.chip_ids]
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
call reset_controller
|
||||
call setup_codec
|
||||
|
||||
mov esi, msgPrimBuff
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
|
||||
call create_primary_buff
|
||||
|
||||
stdcall [AttachIntHandler], [ctrl.int_line], ac97_irq
|
||||
stdcall AttachIntHandler, [ctrl.int_line], ac97_irq
|
||||
|
||||
stdcall [RegService], sz_sound_srv, service_proc
|
||||
stdcall RegService, sz_sound_srv, service_proc
|
||||
|
||||
mov esi, msgOk
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
|
||||
ret
|
||||
|
||||
.fail:
|
||||
if DEBUG
|
||||
mov esi, msgFail
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
STOP:
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
@ -334,7 +346,7 @@ proc service_proc stdcall, ioctl:dword
|
||||
jne @F
|
||||
if DEBUG
|
||||
mov esi, msgPlay
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
call play
|
||||
ret
|
||||
@ -343,7 +355,7 @@ proc service_proc stdcall, ioctl:dword
|
||||
jne @F
|
||||
if DEBUG
|
||||
mov esi, msgStop
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
call stop
|
||||
ret
|
||||
@ -392,7 +404,7 @@ proc ac97_irq
|
||||
|
||||
; if DEBUG
|
||||
; mov esi, msgIRQ
|
||||
; call [SysMsgBoardStr]
|
||||
; call SysMsgBoardStr
|
||||
; end if
|
||||
|
||||
mov edx, PCM_OUT_CR_REG
|
||||
@ -444,7 +456,7 @@ endp
|
||||
align 4
|
||||
proc create_primary_buff
|
||||
|
||||
stdcall [KernelAlloc], 0x10000
|
||||
stdcall KernelAlloc, 0x10000
|
||||
mov [ctrl.buffer], eax
|
||||
|
||||
mov edi, eax
|
||||
@ -452,7 +464,7 @@ proc create_primary_buff
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
|
||||
stdcall [GetPgAddr], [ctrl.buffer]
|
||||
stdcall GetPgAddr, [ctrl.buffer]
|
||||
|
||||
mov ebx, 0xC0004000
|
||||
mov ecx, 4
|
||||
@ -504,7 +516,7 @@ proc create_primary_buff
|
||||
loop @B
|
||||
|
||||
mov ecx, pcmout_bdl
|
||||
stdcall [GetPgAddr], ecx
|
||||
stdcall GetPgAddr, ecx
|
||||
and ecx, 0xFFF
|
||||
add eax, ecx
|
||||
|
||||
@ -537,7 +549,7 @@ proc detect_controller
|
||||
xor eax, eax
|
||||
mov [bus], eax
|
||||
inc eax
|
||||
call [PciApi]
|
||||
call PciApi
|
||||
cmp eax, -1
|
||||
je .err
|
||||
|
||||
@ -546,7 +558,7 @@ proc detect_controller
|
||||
.next_bus:
|
||||
and [devfn], 0
|
||||
.next_dev:
|
||||
stdcall [PciRead32], [bus], [devfn], dword 0
|
||||
stdcall PciRead32, [bus], [devfn], dword 0
|
||||
test eax, eax
|
||||
jz .next
|
||||
cmp eax, -1
|
||||
@ -602,32 +614,32 @@ endp
|
||||
align 4
|
||||
proc init_controller
|
||||
|
||||
stdcall [PciRead32], [ctrl.bus], [ctrl.devfn], dword 4
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
|
||||
mov ebx, eax
|
||||
and eax, 0xFFFF
|
||||
mov [ctrl.pci_cmd], eax
|
||||
shr ebx, 16
|
||||
mov [ctrl.pci_stat], ebx
|
||||
|
||||
stdcall [PciRead32], [ctrl.bus], [ctrl.devfn], dword 0x10
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
|
||||
and eax,0xFFFE
|
||||
mov [ctrl.codec_io_base], eax
|
||||
|
||||
stdcall [PciRead32], [ctrl.bus], [ctrl.devfn], dword 0x14
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
|
||||
and eax, 0xFFC0
|
||||
mov [ctrl.ctrl_io_base], eax
|
||||
|
||||
stdcall [PciRead32], [ctrl.bus], [ctrl.devfn], dword 0x18
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18
|
||||
mov [ctrl.codec_mem_base], eax
|
||||
|
||||
stdcall [PciRead32], [ctrl.bus], [ctrl.devfn], dword 0x1C
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C
|
||||
mov [ctrl.ctrl_mem_base], eax
|
||||
|
||||
stdcall [PciRead32], [ctrl.bus], [ctrl.devfn], dword 0x3C
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
|
||||
and eax, 0xFF
|
||||
mov [ctrl.int_line], eax
|
||||
|
||||
stdcall [PciRead8], [ctrl.bus], [ctrl.devfn], dword 0x41
|
||||
stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41
|
||||
and eax, 0xFF
|
||||
mov [ctrl.cfg_reg], eax
|
||||
|
||||
@ -735,7 +747,7 @@ proc reset_codec
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgCFail
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
xor eax, eax ; timeout error
|
||||
ret
|
||||
@ -757,7 +769,7 @@ proc warm_reset
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgWarm
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
mov [counter], 10 ; total 10*100 ms = 1s
|
||||
@ -774,7 +786,7 @@ proc warm_reset
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgWRFail
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
stc
|
||||
@ -803,7 +815,7 @@ proc cold_reset
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgCold
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
mov eax, 1000000 ; wait 1 s
|
||||
@ -827,7 +839,7 @@ proc cold_reset
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgCRFail
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
stc
|
||||
ret
|
||||
@ -1105,58 +1117,13 @@ endp
|
||||
|
||||
include "codec.inc"
|
||||
|
||||
|
||||
align 16
|
||||
pcmout_bdl dq 32 dup(0)
|
||||
buff_list dd 32 dup(0)
|
||||
|
||||
align 16
|
||||
ctrl AC_CNTRL
|
||||
|
||||
align 16
|
||||
codec CODEC
|
||||
|
||||
civ_val dd 0
|
||||
|
||||
align 16
|
||||
align 4
|
||||
devices dd (CTRL_SIS shl 16)+VID_SIS,msg_AC, set_SIS
|
||||
dd 0
|
||||
|
||||
align 16
|
||||
imp_table:
|
||||
IMPORTS:
|
||||
|
||||
AttachIntHandler dd szAttachIntHandler
|
||||
SysMsgBoardStr dd szSysMsgBoardStr
|
||||
PciApi dd szPciApi
|
||||
PciRead32 dd szPciRead32
|
||||
PciRead8 dd szPciRead8
|
||||
PciWrite8 dd szPciWrite8
|
||||
AllocKernelSpace dd szAllocKernelSpace
|
||||
MapPage dd szMapPage
|
||||
KernelAlloc dd szKernelAlloc
|
||||
GetPgAddr dd szGetPgAddr
|
||||
RegService dd szRegService
|
||||
GetCurrentTask dd szGetCurrentTask
|
||||
dd 0
|
||||
|
||||
msg_AC db '7012 AC97 controller',13,10, 0
|
||||
msg_SIS db 'Silicon Integrated Systems',13,10, 0
|
||||
|
||||
szKernel db 'KERNEL', 0
|
||||
szAttachIntHandler db 'AttachIntHandler',0
|
||||
szSysMsgBoardStr db 'SysMsgBoardStr', 0
|
||||
szPciApi db 'PciApi', 0
|
||||
szPciRead32 db 'PciRead32', 0
|
||||
szPciRead8 db 'PciRead8', 0
|
||||
szPciWrite8 db 'PciWrite8',0
|
||||
szAllocKernelSpace db 'AllocKernelSpace',0
|
||||
szMapPage db 'MapPage',0
|
||||
szRegService db 'RegService',0
|
||||
szKernelAlloc db 'KernelAlloc',0
|
||||
szGetPgAddr db 'GetPgAddr',0
|
||||
szGetCurrentTask db 'GetCurrentTask ',0
|
||||
|
||||
sz_sound_srv db 'SOUND',0
|
||||
|
||||
msgInit db 'detect hardware...',13,10,0
|
||||
@ -1175,3 +1142,14 @@ msgWarm db 'warm reset',13,10,0
|
||||
msgWRFail db 'warm reset failed',13,10,0
|
||||
msgCRFail db 'cold reset failed',13,10,0
|
||||
msgCFail db 'codec not ready',13,10,0
|
||||
|
||||
section '.data' data readable writable align 16
|
||||
|
||||
pcmout_bdl rq 32
|
||||
buff_list rd 32
|
||||
|
||||
codec CODEC
|
||||
ctrl AC_CNTRL
|
||||
|
||||
lpc_bus rd 1
|
||||
civ_val rd 1
|
||||
|
@ -116,125 +116,125 @@ DEV_GET_MASTERVOL equ 7
|
||||
DEV_GET_INFO equ 8
|
||||
|
||||
struc AC_CNTRL ;AC controller base class
|
||||
{ .bus dd 0
|
||||
.devfn dd 0
|
||||
{ .bus dd ?
|
||||
.devfn dd ?
|
||||
|
||||
.vendor dd 0
|
||||
.dev_id dd 0
|
||||
.pci_cmd dd 0
|
||||
.pci_stat dd 0
|
||||
.vendor dd ?
|
||||
.dev_id dd ?
|
||||
.pci_cmd dd ?
|
||||
.pci_stat dd ?
|
||||
|
||||
.codec_io_base dd 0
|
||||
.codec_mem_base dd 0
|
||||
.codec_io_base dd ?
|
||||
.codec_mem_base dd ?
|
||||
|
||||
.ctrl_io_base dd 0
|
||||
.ctrl_mem_base dd 0
|
||||
.cfg_reg dd 0
|
||||
.int_line dd 0
|
||||
.ctrl_io_base dd ?
|
||||
.ctrl_mem_base dd ?
|
||||
.cfg_reg dd ?
|
||||
.int_line dd ?
|
||||
|
||||
.vendor_ids dd 0 ;vendor id string
|
||||
.ctrl_ids dd 0 ;hub id string
|
||||
.vendor_ids dd ? ;vendor id string
|
||||
.ctrl_ids dd ? ;hub id string
|
||||
|
||||
.buffer dd 0
|
||||
.buffer dd ?
|
||||
|
||||
.notify_pos dd 0
|
||||
.notify_task dd 0
|
||||
.notify_pos dd ?
|
||||
.notify_task dd ?
|
||||
|
||||
.lvi_reg dd 0
|
||||
.ctrl_setup dd 0
|
||||
.user_callback dd 0
|
||||
.codec_read16 dd 0
|
||||
.codec_write16 dd 0
|
||||
.lvi_reg dd ?
|
||||
.ctrl_setup dd ?
|
||||
.user_callback dd ?
|
||||
.codec_read16 dd ?
|
||||
.codec_write16 dd ?
|
||||
|
||||
.ctrl_read8 dd 0
|
||||
.ctrl_read16 dd 0
|
||||
.ctrl_read32 dd 0
|
||||
.ctrl_read8 dd ?
|
||||
.ctrl_read16 dd ?
|
||||
.ctrl_read32 dd ?
|
||||
|
||||
.ctrl_write8 dd 0
|
||||
.ctrl_write16 dd 0
|
||||
.ctrl_write32 dd 0
|
||||
.ctrl_write8 dd ?
|
||||
.ctrl_write16 dd ?
|
||||
.ctrl_write32 dd ?
|
||||
}
|
||||
|
||||
struc CODEC ;Audio Chip base class
|
||||
{
|
||||
.chip_id dd 0
|
||||
.flags dd 0
|
||||
.status dd 0
|
||||
.chip_id dd ?
|
||||
.flags dd ?
|
||||
.status dd ?
|
||||
|
||||
.ac_vendor_ids dd 0 ;ac vendor id string
|
||||
.chip_ids dd 0 ;chip model string
|
||||
.ac_vendor_ids dd ? ;ac vendor id string
|
||||
.chip_ids dd ? ;chip model string
|
||||
|
||||
.shadow_flag dd 0
|
||||
dd 0
|
||||
.shadow_flag dd ?
|
||||
dd ?
|
||||
|
||||
.regs dw 0 ; codec registers
|
||||
.reg_master_vol dw 0 ;0x02
|
||||
.reg_aux_out_vol dw 0 ;0x04
|
||||
.reg_mone_vol dw 0 ;0x06
|
||||
.reg_master_tone dw 0 ;0x08
|
||||
.reg_beep_vol dw 0 ;0x0A
|
||||
.reg_phone_vol dw 0 ;0x0C
|
||||
.reg_mic_vol dw 0 ;0x0E
|
||||
.reg_line_in_vol dw 0 ;0x10
|
||||
.reg_cd_vol dw 0 ;0x12
|
||||
.reg_video_vol dw 0 ;0x14
|
||||
.reg_aux_in_vol dw 0 ;0x16
|
||||
.reg_pcm_out_vol dw 0 ;0x18
|
||||
.reg_rec_select dw 0 ;0x1A
|
||||
.reg_rec_gain dw 0 ;0x1C
|
||||
.reg_rec_gain_mic dw 0 ;0x1E
|
||||
.reg_gen dw 0 ;0x20
|
||||
.reg_3d_ctrl dw 0 ;0X22
|
||||
.reg_page dw 0 ;0X24
|
||||
.reg_powerdown dw 0 ;0x26
|
||||
.reg_ext_audio dw 0 ;0x28
|
||||
.reg_ext_st dw 0 ;0x2a
|
||||
.reg_pcm_front_rate dw 0 ;0x2c
|
||||
.reg_pcm_surr_rate dw 0 ;0x2e
|
||||
.reg_lfe_rate dw 0 ;0x30
|
||||
.reg_pcm_in_rate dw 0 ;0x32
|
||||
dw 0 ;0x34
|
||||
.reg_cent_lfe_vol dw 0 ;0x36
|
||||
.reg_surr_vol dw 0 ;0x38
|
||||
.reg_spdif_ctrl dw 0 ;0x3A
|
||||
dw 0 ;0x3C
|
||||
dw 0 ;0x3E
|
||||
dw 0 ;0x40
|
||||
dw 0 ;0x42
|
||||
dw 0 ;0x44
|
||||
dw 0 ;0x46
|
||||
dw 0 ;0x48
|
||||
dw 0 ;0x4A
|
||||
dw 0 ;0x4C
|
||||
dw 0 ;0x4E
|
||||
dw 0 ;0x50
|
||||
dw 0 ;0x52
|
||||
dw 0 ;0x54
|
||||
dw 0 ;0x56
|
||||
dw 0 ;0x58
|
||||
dw 0 ;0x5A
|
||||
dw 0 ;0x5C
|
||||
dw 0 ;0x5E
|
||||
.reg_page_0 dw 0 ;0x60
|
||||
.reg_page_1 dw 0 ;0x62
|
||||
.reg_page_2 dw 0 ;0x64
|
||||
.reg_page_3 dw 0 ;0x66
|
||||
.reg_page_4 dw 0 ;0x68
|
||||
.reg_page_5 dw 0 ;0x6A
|
||||
.reg_page_6 dw 0 ;0x6C
|
||||
.reg_page_7 dw 0 ;0x6E
|
||||
dw 0 ;0x70
|
||||
dw 0 ;0x72
|
||||
dw 0 ;0x74
|
||||
dw 0 ;0x76
|
||||
dw 0 ;0x78
|
||||
dw 0 ;0x7A
|
||||
.reg_vendor_id_1 dw 0 ;0x7C
|
||||
.reg_vendor_id_2 dw 0 ;0x7E
|
||||
.regs dw ? ; codec registers
|
||||
.reg_master_vol dw ? ;0x02
|
||||
.reg_aux_out_vol dw ? ;0x04
|
||||
.reg_mone_vol dw ? ;0x06
|
||||
.reg_master_tone dw ? ;0x08
|
||||
.reg_beep_vol dw ? ;0x0A
|
||||
.reg_phone_vol dw ? ;0x0C
|
||||
.reg_mic_vol dw ? ;0x0E
|
||||
.reg_line_in_vol dw ? ;0x10
|
||||
.reg_cd_vol dw ? ;0x12
|
||||
.reg_video_vol dw ? ;0x14
|
||||
.reg_aux_in_vol dw ? ;0x16
|
||||
.reg_pcm_out_vol dw ? ;0x18
|
||||
.reg_rec_select dw ? ;0x1A
|
||||
.reg_rec_gain dw ? ;0x1C
|
||||
.reg_rec_gain_mic dw ? ;0x1E
|
||||
.reg_gen dw ? ;0x20
|
||||
.reg_3d_ctrl dw ? ;0X22
|
||||
.reg_page dw ? ;0X24
|
||||
.reg_powerdown dw ? ;0x26
|
||||
.reg_ext_audio dw ? ;0x28
|
||||
.reg_ext_st dw ? ;0x2a
|
||||
.reg_pcm_front_rate dw ? ;0x2c
|
||||
.reg_pcm_surr_rate dw ? ;0x2e
|
||||
.reg_lfe_rate dw ? ;0x30
|
||||
.reg_pcm_in_rate dw ? ;0x32
|
||||
dw ? ;0x34
|
||||
.reg_cent_lfe_vol dw ? ;0x36
|
||||
.reg_surr_vol dw ? ;0x38
|
||||
.reg_spdif_ctrl dw ? ;0x3A
|
||||
dw ? ;0x3C
|
||||
dw ? ;0x3E
|
||||
dw ? ;0x40
|
||||
dw ? ;0x42
|
||||
dw ? ;0x44
|
||||
dw ? ;0x46
|
||||
dw ? ;0x48
|
||||
dw ? ;0x4A
|
||||
dw ? ;0x4C
|
||||
dw ? ;0x4E
|
||||
dw ? ;0x50
|
||||
dw ? ;0x52
|
||||
dw ? ;0x54
|
||||
dw ? ;0x56
|
||||
dw ? ;0x58
|
||||
dw ? ;0x5A
|
||||
dw ? ;0x5C
|
||||
dw ? ;0x5E
|
||||
.reg_page_0 dw ? ;0x60
|
||||
.reg_page_1 dw ? ;0x62
|
||||
.reg_page_2 dw ? ;0x64
|
||||
.reg_page_3 dw ? ;0x66
|
||||
.reg_page_4 dw ? ;0x68
|
||||
.reg_page_5 dw ? ;0x6A
|
||||
.reg_page_6 dw ? ;0x6C
|
||||
.reg_page_7 dw ? ;0x6E
|
||||
dw ? ;0x70
|
||||
dw ? ;0x72
|
||||
dw ? ;0x74
|
||||
dw ? ;0x76
|
||||
dw ? ;0x78
|
||||
dw ? ;0x7A
|
||||
.reg_vendor_id_1 dw ? ;0x7C
|
||||
.reg_vendor_id_2 dw ? ;0x7E
|
||||
|
||||
|
||||
.reset dd 0 ;virual
|
||||
.set_master_vol dd 0
|
||||
.reset dd ? ;virual
|
||||
.set_master_vol dd ?
|
||||
}
|
||||
|
||||
struc CTRL_INFO
|
||||
@ -268,16 +268,29 @@ OS_BASE equ 0; 0x80400000
|
||||
new_app_base equ 0x60400000; 0x01000000
|
||||
PROC_BASE equ OS_BASE+0x0080000
|
||||
|
||||
public service_proc
|
||||
public START
|
||||
public IMPORTS
|
||||
public STOP
|
||||
public service_proc
|
||||
|
||||
section '.flat' align 16
|
||||
extrn AttachIntHandler
|
||||
extrn SysMsgBoardStr
|
||||
extrn PciApi
|
||||
extrn PciRead32
|
||||
extrn PciRead8
|
||||
extrn PciWrite8
|
||||
extrn AllocKernelSpace
|
||||
extrn MapPage
|
||||
extrn RegService
|
||||
extrn KernelAlloc
|
||||
extrn GetPgAddr
|
||||
extrn GetCurrentTask
|
||||
|
||||
section '.flat' code readable align 16
|
||||
|
||||
START:
|
||||
if DEBUG
|
||||
mov esi, msgInit
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
call detect_controller
|
||||
@ -286,9 +299,9 @@ START:
|
||||
|
||||
if DEBUG
|
||||
mov esi,[ctrl.vendor_ids]
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
mov esi, [ctrl.ctrl_ids]
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
|
||||
end if
|
||||
|
||||
@ -298,7 +311,7 @@ START:
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgInitCodec
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
call init_codec
|
||||
@ -307,17 +320,17 @@ START:
|
||||
|
||||
if DEBUG
|
||||
mov esi, [codec.ac_vendor_ids]
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
|
||||
mov esi, [codec.chip_ids]
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
call reset_controller
|
||||
call setup_codec
|
||||
|
||||
mov esi, msgPrimBuff
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
|
||||
call create_primary_buff
|
||||
|
||||
@ -341,23 +354,17 @@ START:
|
||||
bt eax, ebx
|
||||
jnc .fail
|
||||
|
||||
stdcall [AttachIntHandler], ebx, ac97_irq
|
||||
|
||||
stdcall [RegService], sz_sound_srv, service_proc
|
||||
|
||||
mov esi, msgOk
|
||||
call [SysMsgBoardStr]
|
||||
|
||||
stdcall AttachIntHandler, ebx, ac97_irq
|
||||
stdcall RegService, sz_sound_srv, service_proc
|
||||
ret
|
||||
|
||||
.fail:
|
||||
if DEBUG
|
||||
mov esi, msgFail
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
xor eax, eax
|
||||
ret
|
||||
STOP:
|
||||
ret
|
||||
|
||||
handle equ IOCTL.handle
|
||||
io_code equ IOCTL.io_code
|
||||
@ -375,7 +382,7 @@ proc service_proc stdcall, ioctl:dword
|
||||
jne @F
|
||||
if DEBUG
|
||||
mov esi, msgPlay
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
call play
|
||||
ret
|
||||
@ -384,7 +391,7 @@ proc service_proc stdcall, ioctl:dword
|
||||
jne @F
|
||||
if DEBUG
|
||||
mov esi, msgStop
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
call stop
|
||||
ret
|
||||
@ -440,7 +447,7 @@ proc remap_irq ;for Intel chipsets ONLY !!!
|
||||
bts ax, IRQ_LINE
|
||||
out dx, aX
|
||||
|
||||
stdcall [PciWrite8], dword 0, dword 0xF8, dword 0x61, dword IRQ_LINE
|
||||
stdcall PciWrite8, dword 0, dword 0xF8, dword 0x61, dword IRQ_LINE
|
||||
mov [ctrl.int_line], IRQ_LINE
|
||||
|
||||
.exit:
|
||||
@ -452,7 +459,7 @@ proc ac97_irq
|
||||
|
||||
; if DEBUG
|
||||
; mov esi, msgIRQ
|
||||
; call [SysMsgBoardStr]
|
||||
; call SysMsgBoardStr
|
||||
; end if
|
||||
|
||||
mov edx, PCM_OUT_CR_REG
|
||||
@ -504,7 +511,7 @@ endp
|
||||
align 4
|
||||
proc create_primary_buff
|
||||
|
||||
stdcall [KernelAlloc], 0x10000
|
||||
stdcall KernelAlloc, 0x10000
|
||||
mov [ctrl.buffer], eax
|
||||
|
||||
mov edi, eax
|
||||
@ -513,7 +520,7 @@ proc create_primary_buff
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
stdcall [GetPgAddr], [ctrl.buffer]
|
||||
stdcall GetPgAddr, [ctrl.buffer]
|
||||
|
||||
mov ebx, 0xC0002000
|
||||
mov ecx, 4
|
||||
@ -565,7 +572,7 @@ proc create_primary_buff
|
||||
loop @B
|
||||
|
||||
mov ecx, pcmout_bdl
|
||||
stdcall [GetPgAddr], ecx
|
||||
stdcall GetPgAddr, ecx
|
||||
and ecx, 0xFFF
|
||||
add eax, ecx
|
||||
|
||||
@ -591,7 +598,7 @@ proc detect_controller
|
||||
xor eax, eax
|
||||
mov [bus], eax
|
||||
inc eax
|
||||
call [PciApi]
|
||||
call PciApi
|
||||
cmp eax, -1
|
||||
je .err
|
||||
|
||||
@ -600,7 +607,7 @@ proc detect_controller
|
||||
.next_bus:
|
||||
and [devfn], 0
|
||||
.next_dev:
|
||||
stdcall [PciRead32], [bus], [devfn], dword 0
|
||||
stdcall PciRead32, [bus], [devfn], dword 0
|
||||
test eax, eax
|
||||
jz .next
|
||||
cmp eax, -1
|
||||
@ -677,7 +684,7 @@ proc get_LPC_bus ;for Intel chipsets ONLY !!!
|
||||
|
||||
mov [last_bus], eax
|
||||
.next_bus:
|
||||
stdcall [PciRead32], [bus], dword 0xF8, dword 0
|
||||
stdcall PciRead32, [bus], dword 0xF8, dword 0
|
||||
test eax, eax
|
||||
jz .next
|
||||
cmp eax, -1
|
||||
@ -703,32 +710,32 @@ endp
|
||||
align 4
|
||||
proc init_controller
|
||||
|
||||
stdcall [PciRead32], [ctrl.bus], [ctrl.devfn], dword 4
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
|
||||
mov ebx, eax
|
||||
and eax, 0xFFFF
|
||||
mov [ctrl.pci_cmd], eax
|
||||
shr ebx, 16
|
||||
mov [ctrl.pci_stat], ebx
|
||||
|
||||
stdcall [PciRead32], [ctrl.bus], [ctrl.devfn], dword 0x10
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
|
||||
and eax,0xFFFE
|
||||
mov [ctrl.codec_io_base], eax
|
||||
|
||||
stdcall [PciRead32], [ctrl.bus], [ctrl.devfn], dword 0x14
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
|
||||
and eax, 0xFFC0
|
||||
mov [ctrl.ctrl_io_base], eax
|
||||
|
||||
stdcall [PciRead32], [ctrl.bus], [ctrl.devfn], dword 0x18
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18
|
||||
mov [ctrl.codec_mem_base], eax
|
||||
|
||||
stdcall [PciRead32], [ctrl.bus], [ctrl.devfn], dword 0x1C
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C
|
||||
mov [ctrl.ctrl_mem_base], eax
|
||||
|
||||
stdcall [PciRead32], [ctrl.bus], [ctrl.devfn], dword 0x3C
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
|
||||
and eax, 0xFF
|
||||
mov [ctrl.int_line], eax
|
||||
|
||||
stdcall [PciRead8], [ctrl.bus], [ctrl.devfn], dword 0x41
|
||||
stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41
|
||||
and eax, 0xFF
|
||||
mov [ctrl.cfg_reg], eax
|
||||
|
||||
@ -758,12 +765,12 @@ PG_NOCACHE equ 0x018
|
||||
|
||||
align 4
|
||||
proc set_ICH4
|
||||
stdcall [AllocKernelSpace], dword 0x2000
|
||||
stdcall AllocKernelSpace, dword 0x2000
|
||||
mov edi, eax
|
||||
stdcall [MapPage], edi,[ctrl.codec_mem_base],PG_SW+PG_NOCACHE
|
||||
stdcall MapPage, edi,[ctrl.codec_mem_base],PG_SW+PG_NOCACHE
|
||||
mov [ctrl.codec_mem_base], edi
|
||||
add edi, 0x1000
|
||||
stdcall [MapPage], edi, [ctrl.ctrl_mem_base],PG_SW+PG_NOCACHE
|
||||
stdcall MapPage, edi, [ctrl.ctrl_mem_base],PG_SW+PG_NOCACHE
|
||||
mov [ctrl.ctrl_mem_base], edi
|
||||
|
||||
mov [ctrl.codec_read16], codec_mem_r16 ;virtual
|
||||
@ -861,14 +868,14 @@ proc reset_codec
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgCFail
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
xor eax, eax ; timeout error
|
||||
ret
|
||||
.ok:
|
||||
if DEBUG
|
||||
mov esi, msgResetOk
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
xor eax, eax
|
||||
@ -888,7 +895,7 @@ proc warm_reset
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgWarm
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
mov [counter], 10 ; total 10*100 ms = 1s
|
||||
@ -905,7 +912,7 @@ proc warm_reset
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgWRFail
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
stc
|
||||
@ -934,7 +941,7 @@ proc cold_reset
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgCold
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
mov eax, 1000000 ; wait 1 s
|
||||
@ -958,7 +965,7 @@ proc cold_reset
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgCRFail
|
||||
call [SysMsgBoardStr]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
stc
|
||||
ret
|
||||
@ -1292,21 +1299,7 @@ endp
|
||||
|
||||
include "codec.inc"
|
||||
|
||||
|
||||
align 16
|
||||
pcmout_bdl dq 32 dup(0)
|
||||
buff_list dd 32 dup(0)
|
||||
|
||||
align 16
|
||||
ctrl AC_CNTRL
|
||||
|
||||
align 16
|
||||
codec CODEC
|
||||
|
||||
lpc_bus dd 0
|
||||
civ_val dd 0
|
||||
|
||||
align 16
|
||||
align 4
|
||||
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_ICH2 shl 16)+VID_INTEL,msg_ICH2,set_ICH
|
||||
@ -1322,24 +1315,6 @@ devices dd (CTRL_ICH shl 16)+VID_INTEL,msg_ICH, set_ICH
|
||||
|
||||
dd 0 ;terminator
|
||||
|
||||
align 16
|
||||
imp_table:
|
||||
IMPORTS:
|
||||
|
||||
AttachIntHandler dd szAttachIntHandler
|
||||
SysMsgBoardStr dd szSysMsgBoardStr
|
||||
PciApi dd szPciApi
|
||||
PciRead32 dd szPciRead32
|
||||
PciRead8 dd szPciRead8
|
||||
PciWrite8 dd szPciWrite8
|
||||
AllocKernelSpace dd szAllocKernelSpace
|
||||
MapPage dd szMapPage
|
||||
KernelAlloc dd szKernelAlloc
|
||||
GetPgAddr dd szGetPgAddr
|
||||
RegService dd szRegService
|
||||
GetCurrentTask dd szGetCurrentTask
|
||||
dd 0
|
||||
|
||||
msg_ICH db 'Intel ICH', 13,10, 0
|
||||
msg_ICH0 db 'Intel ICH0', 13,10, 0
|
||||
msg_ICH2 db 'Intel ICH2', 13,10, 0
|
||||
@ -1355,21 +1330,7 @@ msg_NForce2 db 'NForce 2', 13,10, 0
|
||||
msg_NForce3 db 'NForce 3', 13,10, 0
|
||||
msg_NVidia db 'NVidea', 0
|
||||
|
||||
|
||||
szKernel db 'KERNEL', 0
|
||||
szAttachIntHandler db 'AttachIntHandler',0
|
||||
szSysMsgBoardStr db 'SysMsgBoardStr', 0
|
||||
szPciApi db 'PciApi', 0
|
||||
szPciRead32 db 'PciRead32', 0
|
||||
szPciRead8 db 'PciRead8', 0
|
||||
szPciWrite8 db 'PciWrite8',0
|
||||
szAllocKernelSpace db 'AllocKernelSpace',0
|
||||
szMapPage db 'MapPage',0
|
||||
szRegService db 'RegService',0
|
||||
szKernelAlloc db 'KernelAlloc',0
|
||||
szGetPgAddr db 'GetPgAddr',0
|
||||
szGetCurrentTask db 'GetCurrentTask ',0
|
||||
|
||||
sz_sound_srv db 'SOUND',0
|
||||
|
||||
msgInit db 'detect hardware...',13,10,0
|
||||
@ -1392,3 +1353,15 @@ msgCRFail db 'cold reset failed',13,10,0
|
||||
msgCFail db 'codec not ready',13,10,0
|
||||
msgResetOk db 'reset complete',13,10,0
|
||||
|
||||
section '.data' data readable writable align 16
|
||||
|
||||
pcmout_bdl rq 32
|
||||
buff_list rd 32
|
||||
|
||||
codec CODEC
|
||||
ctrl AC_CNTRL
|
||||
|
||||
lpc_bus rd 1
|
||||
civ_val rd 1
|
||||
|
||||
|
||||
|
@ -16,8 +16,6 @@ include "lang.inc"
|
||||
|
||||
include "const.inc"
|
||||
|
||||
NEW equ 0
|
||||
|
||||
;WinMapAddress equ 0x460000
|
||||
;display_data = 0x460000
|
||||
|
||||
@ -412,7 +410,7 @@ include 'detect/disks.inc'
|
||||
call init_LFB
|
||||
call init_mtrr
|
||||
|
||||
stdcall alloc_kernel_space, 0x50000
|
||||
stdcall alloc_kernel_space, 0x4F000
|
||||
mov [ipc_tmp], eax
|
||||
mov ebx, 0x1000
|
||||
|
||||
@ -425,9 +423,6 @@ include 'detect/disks.inc'
|
||||
add eax, ebx
|
||||
mov [proc_mem_tab], eax
|
||||
|
||||
add eax, ebx
|
||||
mov [current_pdir], eax
|
||||
|
||||
add eax, ebx
|
||||
mov [tmp_task_pdir], eax
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user