diff --git a/drivers/mouse/ps2mouse4d/trunk/ps2mouse.asm b/drivers/mouse/ps2mouse4d/trunk/ps2mouse.asm index aa0b1969d1..7771de3137 100644 --- a/drivers/mouse/ps2mouse4d/trunk/ps2mouse.asm +++ b/drivers/mouse/ps2mouse4d/trunk/ps2mouse.asm @@ -4,12 +4,12 @@ include '../../../proc32.inc' include '../../../imports.inc' struc IOCTL -{ .handle dd ? - .io_code dd ? - .input dd ? - .inp_size dd ? - .output dd ? - .out_size dd ? +{ .handle dd ? + .io_code dd ? + .input dd ? + .inp_size dd ? + .output dd ? + .out_size dd ? } virtual at 0 @@ -22,7 +22,7 @@ public version DRV_ENTRY equ 1 DRV_EXIT equ -1 -MT_3B equ 0 +MT_3B equ 0 MT_3BScroll equ 3 MT_5BScroll equ 4 @@ -33,85 +33,85 @@ section '.flat' code readable align 16 proc START stdcall, state:dword - cmp [state], DRV_ENTRY - jne .fin + cmp [state], DRV_ENTRY + jne .fin .init: - call detect_mouse - test eax,eax - jnz .exit + call detect_mouse + test eax,eax + jnz .exit - mov [MouseType],MT_3B + mov [MouseType],MT_3B - call try_mode_ID3 - test eax,eax - jnz .stop_try - mov [MouseType],MT_3BScroll - - call try_mode_ID4 - test eax,eax - jnz .stop_try - mov [MouseType],MT_5BScroll - + call try_mode_ID3 + test eax,eax + jnz .stop_try + mov [MouseType],MT_3BScroll + + call try_mode_ID4 + test eax,eax + jnz .stop_try + mov [MouseType],MT_5BScroll + .stop_try: - mov bl, 0x20 ; read command byte - call kbd_cmd - cmp ah,1 - je .exit + mov bl, 0x20 ; read command byte + call kbd_cmd + cmp ah,1 + je .exit - call kbd_read - cmp ah,1 - je .exit + call kbd_read + cmp ah,1 + je .exit - or al, 10b - push eax - mov bl, 0x60 ; write command byte - call kbd_cmd - cmp ah,1 - je .exit + or al, 10b + push eax + mov bl, 0x60 ; write command byte + call kbd_cmd + cmp ah,1 + je .exit - pop eax - call kbd_write - cmp ah,1 - je .exit + pop eax + call kbd_write + cmp ah,1 + je .exit - mov al, 0xF4 ; enable data reporting - call mouse_cmd + mov al, 0xF4 ; enable data reporting + call mouse_cmd - mov bl, 0xAE ; enable keyboard interface - call kbd_cmd - - stdcall AttachIntHandler, 12, irq_handler - stdcall RegService, my_service, service_proc - ret + mov bl, 0xAE ; enable keyboard interface + call kbd_cmd + + stdcall AttachIntHandler, 12, irq_handler, dword 0 + stdcall RegService, my_service, service_proc + ret .fin: - ;stdcall DetachIntHandler, 12, irq_handler - mov bl, 0xA7 ; disable mouse interface - call kbd_cmd - xor eax, eax - ret + ;stdcall DetachIntHandler, 12, irq_handler + mov bl, 0xA7 ; disable mouse interface + call kbd_cmd + xor eax, eax + ret .exit: - mov bl, 0xA7 ; disable mouse interface - call kbd_cmd - mov bl, 0xAE ; enable keyboard interface - call kbd_cmd - xor eax, eax - ret + mov bl, 0xA7 ; disable mouse interface + call kbd_cmd + mov bl, 0xAE ; enable keyboard interface + call kbd_cmd + xor eax, eax + ret endp proc service_proc stdcall, ioctl:dword mov edi, [ioctl] mov eax, [edi+IOCTL.io_code] test eax, eax - jz .getversion + jz .getversion cmp eax,1 - jz .gettype + jz .gettype .err: - or eax, -1 + or eax, -1 ret .ok: @@ -120,13 +120,13 @@ proc service_proc stdcall, ioctl:dword .getversion: cmp [edi+IOCTL.out_size], 4 - jb .err + jb .err mov edi, [edi+IOCTL.output] mov dword [edi], PS2_DRV_VER ; version of driver jmp .ok .gettype: cmp [edi+IOCTL.out_size], 4 - jb .err + jb .err mov edi, [edi+IOCTL.output] mov eax,[MouseType] mov dword [edi], eax ; mouse type @@ -138,95 +138,95 @@ detect_mouse: mov bl, 0xAD ; disable keyboard interface call kbd_cmd cmp ah,1 - je .fail + je .fail mov bl, 0xA8 ; enable mouse interface call kbd_cmd cmp ah,1 - je .fail + je .fail - mov al, 0xFF ; reset + mov al, 0xFF ; reset call mouse_cmd - jc .fail + jc .fail call mouse_read - jc .fail + jc .fail cmp al, 0xAA - jne .fail ; dead mouse + jne .fail ; dead mouse ; get device ID call mouse_read - jc .fail + jc .fail cmp al, 0x00 - jne .fail ; unknown device + jne .fail ; unknown device xor eax,eax ret .fail: - or eax,-1 + or eax,-1 ret try_mode_ID3: mov al, 0xF3 ;Set Sample Rate call mouse_cmd - jc .fail + jc .fail mov al, 0xC8 ;200d call mouse_cmd - jc .fail + jc .fail mov al, 0xF3 ;Set Sample Rate call mouse_cmd - jc .fail + jc .fail mov al, 0x64 ;100d call mouse_cmd - jc .fail + jc .fail mov al, 0xF3 ;Set Sample Rate call mouse_cmd - jc .fail + jc .fail mov al, 0x50 ;80d call mouse_cmd - jc .fail + jc .fail mov al, 0xF2 ;Get device id call mouse_cmd - jc .fail + jc .fail call mouse_read - jc .fail + jc .fail cmp al, 0x03 jne .fail xor eax,eax ret .fail: - or eax,-1 + or eax,-1 ret try_mode_ID4: mov al, 0xF3 ;Set Sample Rate call mouse_cmd - jc .fail + jc .fail mov al, 0xC8 ;200d call mouse_cmd - jc .fail + jc .fail mov al, 0xF3 ;Set Sample Rate call mouse_cmd - jc .fail + jc .fail mov al, 0xC8 ;100d call mouse_cmd - jc .fail + jc .fail mov al, 0xF3 ;Set Sample Rate call mouse_cmd - jc .fail + jc .fail mov al, 0x50 ;80d call mouse_cmd - jc .fail + jc .fail mov al, 0xF2 ;Get device id call mouse_cmd - jc .fail + jc .fail call mouse_read - jc .fail + jc .fail cmp al, 0x04 jne .fail @@ -234,7 +234,7 @@ try_mode_ID4: ret .fail: - or eax,-1 + or eax,-1 ret include 'ps2m_iofuncs.inc' @@ -242,12 +242,12 @@ include 'ps2m_irqh.inc' section '.data' data readable writable align 16 -version dd 0x00050005 +version dd 0x00050005 my_service db 'ps2mouse',0 ;iofuncs data -mouse_cmd_byte db 0 -mouse_nr_tries db 0 +mouse_cmd_byte db 0 +mouse_nr_tries db 0 mouse_nr_resends db 0 ;hid data @@ -259,10 +259,10 @@ third_byte db 0 fourth_byte db 0 ;main data -MouseType dd 0 +MouseType dd 0 -XMoving dd 0 -YMoving dd 0 -ZMoving dd 0 -ButtonState dd 0 +XMoving dd 0 +YMoving dd 0 +ZMoving dd 0 +ButtonState dd 0 ;timerTicks dd 0 diff --git a/drivers/sisnbook/sis.asm b/drivers/sisnbook/sis.asm index 12a8204edb..ff5c6a0871 100644 --- a/drivers/sisnbook/sis.asm +++ b/drivers/sisnbook/sis.asm @@ -349,7 +349,7 @@ proc START stdcall, state:dword bt eax, ebx jnc .fail_msg - stdcall AttachIntHandler, ebx, ac97_irq + stdcall AttachIntHandler, ebx, ac97_irq, dword 0 .reg: stdcall RegService, sz_sound_srv, service_proc diff --git a/kernel/trunk/boot/ru.inc b/kernel/trunk/boot/ru.inc index 2e0d0cf70e..aa59d6f6a9 100644 --- a/kernel/trunk/boot/ru.inc +++ b/kernel/trunk/boot/ru.inc @@ -13,7 +13,7 @@ $Revision$ ; Modifyed by BadBugsKiller 12.01.2004 17:45 ; Шрифт уменьшен в размере и теперь состоит из 2-ух частей, ; содержащих только символы русского алфавита. -; символы в кодировке ASCII (ДОС'овская), кодовая станица 866. +; символы в кодировке ASCII (ДОС'овская), кодовая страница 866. RU_FNT1: db 0x00, 0x00, 0x1E, 0x36, 0x66, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0xFE, 0x62, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00 diff --git a/kernel/trunk/core/dll.inc b/kernel/trunk/core/dll.inc index 849b2fcd5b..54e44c8ee0 100644 --- a/kernel/trunk/core/dll.inc +++ b/kernel/trunk/core/dll.inc @@ -14,7 +14,7 @@ DRV_CURRENT equ 5 ;current drivers model version DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT align 4 -proc attach_int_handler stdcall, irq:dword, handler:dword +proc attach_int_handler stdcall, irq:dword, handler:dword, access_rights:dword mov ebx, [irq] ;irq num test ebx, ebx @@ -25,13 +25,23 @@ proc attach_int_handler stdcall, irq:dword, handler:dword test eax, eax jz .err cmp [irq_owner + 4 * ebx], 0 - jne .err + je @f + + mov ecx, [irq_rights + 4 * ebx] ; Rights : 0 - full access, 1 - read only, 2 - forbidden + test ecx, ecx + jnz .err + + @@: mov [irq_tab+ebx*4], eax + mov eax, [access_rights] + mov [irq_rights + 4 * ebx], eax ;push eax ;mov eax, [TASK_BASE] - ;mov eax, [eax + TASKDATA.pid] - mov [irq_owner + 4 * ebx], 1 + ;mov eax, [eax + TASKDATA.pid] ; faster or smaller? :) + call get_pid + + mov [irq_owner + 4 * ebx], eax ;pop eax stdcall enable_irq, [irq] @@ -41,6 +51,28 @@ proc attach_int_handler stdcall, irq:dword, handler:dword ret endp +uglobal + + irq_rights rd 16 + +endg + +proc get_int_handler stdcall, irq:dword + + mov eax, [irq] + + cmp [irq_rights + 4 * eax], dword 1 + ja .err + + mov eax, [irq_tab + 4 * eax] + ret + + .err: + xor eax, eax + ret + +endp + align 4 proc detach_int_handler diff --git a/kernel/trunk/core/exports.inc b/kernel/trunk/core/exports.inc index 4736786d33..7d199afd50 100644 --- a/kernel/trunk/core/exports.inc +++ b/kernel/trunk/core/exports.inc @@ -16,6 +16,7 @@ iglobal szGetService db 'GetService',0 szServiceHandler db 'ServiceHandler',0 szAttachIntHandler db 'AttachIntHandler',0 + szGetIntHandler db 'GetIntHandler', 0 szFpuSave db 'FpuSave',0 szFpuRestore db 'FpuRestore',0 szReservePortArea db 'ReservePortArea',0 @@ -88,6 +89,7 @@ kernel_export: dd szGetService , get_service dd szServiceHandler , srv_handler dd szAttachIntHandler, attach_int_handler + dd szGetIntHandler , get_int_handler dd szFpuSave , fpu_save dd szFpuRestore , fpu_restore dd szReservePortArea , r_f_port_area diff --git a/kernel/trunk/core/sys32.inc b/kernel/trunk/core/sys32.inc index deba3df704..d94d39a2d9 100644 --- a/kernel/trunk/core/sys32.inc +++ b/kernel/trunk/core/sys32.inc @@ -668,13 +668,18 @@ term9: shl eax, 5 mov eax,[eax+CURRENT_TASK+TASKDATA.pid] mov edi,irq_owner - mov ecx,16 + xor ebx, ebx + xor edx, edx newirqfree: - scasd + cmp [edi + 4 * ebx], eax jne nofreeirq - mov [edi-4],dword 0 + mov [edi + 4 * ebx], edx ; remove irq reservation + mov [irq_tab + 4 * ebx], edx ; remove irq handler + mov [irq_rights + 4 * ebx], edx ; set access rights to full access nofreeirq: - loop newirqfree + inc ebx + cmp ebx, 16 + jb newirqfree popa pusha ; remove all port reservations diff --git a/kernel/trunk/core/taskman.inc b/kernel/trunk/core/taskman.inc index 8ed18b3b00..941c79f765 100644 --- a/kernel/trunk/core/taskman.inc +++ b/kernel/trunk/core/taskman.inc @@ -32,11 +32,11 @@ struc APP_HEADER_01 struc APP_PARAMS -{ .app_cmdline ;0x00 - .app_path ;0x04 - .app_eip ;0x08 - .app_esp ;0x0C - .app_mem ;0x10 +{ .app_cmdline ;0x00 + .app_path ;0x04 + .app_eip ;0x08 + .app_esp ;0x0C + .app_mem ;0x10 } macro _clear_ op @@ -47,9 +47,9 @@ macro _clear_ op } fs_execute_from_sysdir: - xor ebx, ebx - xor edx, edx - mov esi, sysdir_path + xor ebx, ebx + xor edx, edx + mov esi, sysdir_path align 4 proc fs_execute @@ -61,251 +61,251 @@ proc fs_execute ; ebp - full filename ; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it - locals - cmdline rd 64 ;256/4 - filename rd 256 ;1024/4 - flags dd ? + locals + cmdline rd 64 ;256/4 + filename rd 256 ;1024/4 + flags dd ? - save_cr3 dd ? - slot dd ? - slot_base dd ? - file_base dd ? - file_size dd ? - ;app header data - hdr_cmdline dd ? ;0x00 - hdr_path dd ? ;0x04 - hdr_eip dd ? ;0x08 - hdr_esp dd ? ;0x0C - hdr_mem dd ? ;0x10 - hdr_i_end dd ? ;0x14 - endl + save_cr3 dd ? + slot dd ? + slot_base dd ? + file_base dd ? + file_size dd ? + ;app header data + hdr_cmdline dd ? ;0x00 + hdr_path dd ? ;0x04 + hdr_eip dd ? ;0x08 + hdr_esp dd ? ;0x0C + hdr_mem dd ? ;0x10 + hdr_i_end dd ? ;0x14 + endl - pushad + pushad - mov [flags], edx + mov [flags], edx ; [ebp] pointer to filename - lea edi, [filename] - lea ecx, [edi+1024] - mov al, '/' - stosb + lea edi, [filename] + lea ecx, [edi+1024] + mov al, '/' + stosb @@: - cmp edi, ecx - jae .bigfilename - lodsb - stosb - test al, al - jnz @b - mov esi, [ebp] - test esi, esi - jz .namecopied - mov byte [edi-1], '/' + cmp edi, ecx + jae .bigfilename + lodsb + stosb + test al, al + jnz @b + mov esi, [ebp] + test esi, esi + jz .namecopied + mov byte [edi-1], '/' @@: - cmp edi, ecx - jae .bigfilename - lodsb - stosb - test al, al - jnz @b - jmp .namecopied + cmp edi, ecx + jae .bigfilename + lodsb + stosb + test al, al + jnz @b + jmp .namecopied .bigfilename: - popad - mov eax, -ERROR_FILE_NOT_FOUND - ret + popad + mov eax, -ERROR_FILE_NOT_FOUND + ret .namecopied: - mov [cmdline], ebx - test ebx, ebx - jz @F + mov [cmdline], ebx + test ebx, ebx + jz @F - lea eax, [cmdline] - mov dword [eax+252], 0 - stdcall strncpy, eax, ebx, 255 + lea eax, [cmdline] + mov dword [eax+252], 0 + stdcall strncpy, eax, ebx, 255 @@: - lea eax, [filename] - stdcall load_file, eax - mov ecx, -ERROR_FILE_NOT_FOUND - test eax, eax - jz .err_file + lea eax, [filename] + stdcall load_file, eax + mov ecx, -ERROR_FILE_NOT_FOUND + test eax, eax + jz .err_file - mov [file_base], eax - mov [file_size], ebx + mov [file_base], eax + mov [file_size], ebx - lea ebx, [hdr_cmdline] - call test_app_header - mov ecx, -0x1F - test eax, eax - jz .err_hdr + lea ebx, [hdr_cmdline] + call test_app_header + mov ecx, -0x1F + test eax, eax + jz .err_hdr - ;mov esi, new_process_loading - ;call sys_msg_board_str ; write message to message board - DEBUGF 1,"%s",new_process_loading + ;mov esi, new_process_loading + ;call sys_msg_board_str ; write message to message board + DEBUGF 1,"%s",new_process_loading .wait_lock: - cmp [application_table_status],0 - je .get_lock - call change_task - jmp .wait_lock + cmp [application_table_status],0 + je .get_lock + call change_task + jmp .wait_lock .get_lock: - mov eax, 1 - xchg eax, [application_table_status] - cmp eax, 0 - jne .wait_lock + mov eax, 1 + xchg eax, [application_table_status] + cmp eax, 0 + jne .wait_lock - call set_application_table_status + call set_application_table_status - call get_new_process_place - test eax, eax - mov ecx, -0x20 ; too many processes - jz .err + call get_new_process_place + test eax, eax + mov ecx, -0x20 ; too many processes + jz .err - mov [slot], eax - shl eax, 8 - add eax, SLOT_BASE - mov [slot_base], eax - mov edi, eax - _clear_ 256 ;clean extended information about process + mov [slot], eax + shl eax, 8 + add eax, SLOT_BASE + mov [slot_base], eax + mov edi, eax + _clear_ 256 ;clean extended information about process ; write application name - lea eax, [filename] - stdcall strrchr, eax, '/' ; now eax points to name without path + lea eax, [filename] + stdcall strrchr, eax, '/' ; now eax points to name without path - lea esi, [eax+1] - test eax, eax - jnz @F - lea esi, [filename] + lea esi, [eax+1] + test eax, eax + jnz @F + lea esi, [filename] @@: - mov ecx, 8 ; 8 chars for name - mov edi, [slot_base] + mov ecx, 8 ; 8 chars for name + mov edi, [slot_base] .copy_process_name_loop: - lodsb - cmp al, '.' - jz .copy_process_name_done - test al, al - jz .copy_process_name_done - stosb - loop .copy_process_name_loop + lodsb + cmp al, '.' + jz .copy_process_name_done + test al, al + jz .copy_process_name_done + stosb + loop .copy_process_name_loop .copy_process_name_done: - mov ebx, cr3 - mov [save_cr3], ebx + mov ebx, cr3 + mov [save_cr3], ebx - stdcall create_app_space,[hdr_mem],[file_base],[file_size] - mov ecx, -30 ; no memory - test eax, eax - jz .failed + stdcall create_app_space,[hdr_mem],[file_base],[file_size] + mov ecx, -30 ; no memory + test eax, eax + jz .failed - mov ebx,[slot_base] - mov [ebx+APPDATA.dir_table],eax - mov eax,[hdr_mem] - mov [ebx+APPDATA.mem_size],eax + mov ebx,[slot_base] + mov [ebx+APPDATA.dir_table],eax + mov eax,[hdr_mem] + mov [ebx+APPDATA.mem_size],eax if GREEDY_KERNEL else - mov ecx, [hdr_mem] - mov edi, [file_size] - add edi, 4095 - and edi, not 4095 - sub ecx, edi - jna @F + mov ecx, [hdr_mem] + mov edi, [file_size] + add edi, 4095 + and edi, not 4095 + sub ecx, edi + jna @F - xor eax, eax + xor eax, eax ; add edi, new_app_base - cld - rep stosb + cld + rep stosb @@: end if ; release only virtual space, not phisical memory - stdcall free_kernel_space, [file_base] - lea eax, [hdr_cmdline] - lea ebx, [cmdline] - lea ecx, [filename] - stdcall set_app_params ,[slot],eax,ebx,ecx,[flags] + stdcall free_kernel_space, [file_base] + lea eax, [hdr_cmdline] + lea ebx, [cmdline] + lea ecx, [filename] + stdcall set_app_params ,[slot],eax,ebx,ecx,[flags] - mov eax, [save_cr3] - call set_cr3 + mov eax, [save_cr3] + call set_cr3 - xor ebx, ebx - mov [application_table_status],ebx ;unlock application_table_status mutex - mov eax,[process_number] ;set result - ret + xor ebx, ebx + mov [application_table_status],ebx ;unlock application_table_status mutex + mov eax,[process_number] ;set result + ret .failed: - mov eax, [save_cr3] - call set_cr3 + mov eax, [save_cr3] + call set_cr3 .err: .err_hdr: - stdcall kernel_free,[file_base] + stdcall kernel_free,[file_base] .err_file: - xor eax, eax - mov [application_table_status],eax - mov eax, ecx - ret + xor eax, eax + mov [application_table_status],eax + mov eax, ecx + ret endp align 4 test_app_header: - virtual at eax - APP_HEADER_00 APP_HEADER_00 - end virtual - virtual at eax - APP_HEADER_01 APP_HEADER_01 - end virtual + virtual at eax + APP_HEADER_00 APP_HEADER_00 + end virtual + virtual at eax + APP_HEADER_01 APP_HEADER_01 + end virtual - cmp dword [eax], 'MENU' - jne .fail - cmp word [eax+4],'ET' - jne .fail + cmp dword [eax], 'MENU' + jne .fail + cmp word [eax+4],'ET' + jne .fail - cmp [eax+6], word '00' - jne .check_01_header + cmp [eax+6], word '00' + jne .check_01_header - mov ecx,[APP_HEADER_00.start] - mov [ebx+0x08], ecx ;app_eip - mov edx,[APP_HEADER_00.mem_size] - mov [ebx+0x10], edx ;app_mem - shr edx,1 - sub edx,0x10 - mov [ebx+0x0C], edx ;app_esp - mov ecx,[APP_HEADER_00.i_param] - mov [ebx], ecx ;app_cmdline - mov [ebx+4], dword 0 ;app_path - mov edx, [APP_HEADER_00.i_end] - mov [ebx+0x14], edx - ret + mov ecx,[APP_HEADER_00.start] + mov [ebx+0x08], ecx ;app_eip + mov edx,[APP_HEADER_00.mem_size] + mov [ebx+0x10], edx ;app_mem + shr edx,1 + sub edx,0x10 + mov [ebx+0x0C], edx ;app_esp + mov ecx,[APP_HEADER_00.i_param] + mov [ebx], ecx ;app_cmdline + mov [ebx+4], dword 0 ;app_path + mov edx, [APP_HEADER_00.i_end] + mov [ebx+0x14], edx + ret .check_01_header: - cmp [eax+6],word '01' - jne .fail + cmp [eax+6],word '01' + jne .fail - mov ecx,[APP_HEADER_01.start] - mov [ebx+0x08], ecx ;app_eip - mov edx,[APP_HEADER_01.mem_size] + mov ecx,[APP_HEADER_01.start] + mov [ebx+0x08], ecx ;app_eip + mov edx,[APP_HEADER_01.mem_size] ; \begin{diamond}[20.08.2006] ; sanity check (functions 19,58 load app_i_end bytes and that must ; fit in allocated memory to prevent kernel faults) - cmp edx,[APP_HEADER_01.i_end] - jb .fail + cmp edx,[APP_HEADER_01.i_end] + jb .fail ; \end{diamond}[20.08.2006] - mov [ebx+0x10], edx ;app_mem - mov ecx,[APP_HEADER_01.stack_top] - mov [ebx+0x0C], ecx ;app_esp - mov edx,[APP_HEADER_01.i_param] - mov [ebx], edx ;app_cmdline - mov ecx,[APP_HEADER_01.i_icon] - mov [ebx+4], ecx ;app_path - mov edx, [APP_HEADER_01.i_end] - mov [ebx+0x14], edx - ret + mov [ebx+0x10], edx ;app_mem + mov ecx,[APP_HEADER_01.stack_top] + mov [ebx+0x0C], ecx ;app_esp + mov edx,[APP_HEADER_01.i_param] + mov [ebx], edx ;app_cmdline + mov ecx,[APP_HEADER_01.i_icon] + mov [ebx+4], ecx ;app_path + mov edx, [APP_HEADER_01.i_end] + mov [ebx+0x14], edx + ret .fail: - xor eax, eax - ret + xor eax, eax + ret align 4 proc get_new_process_place @@ -316,269 +316,270 @@ proc get_new_process_place ; 0 - failed. ;This function find least empty slot. ;It doesn't increase [TASK_COUNT]! - mov eax,CURRENT_TASK - mov ebx,[TASK_COUNT] - inc ebx - shl ebx,5 - add ebx,eax ;ebx - address of process information for (last+1) slot + mov eax,CURRENT_TASK + mov ebx,[TASK_COUNT] + inc ebx + shl ebx,5 + add ebx,eax ;ebx - address of process information for (last+1) slot .newprocessplace: ;eax = address of process information for current slot - cmp eax,ebx - jz .endnewprocessplace ;empty slot after high boundary - add eax,0x20 - cmp word [eax+0xa],9 ;check process state, 9 means that process slot is empty - jnz .newprocessplace + cmp eax,ebx + jz .endnewprocessplace ;empty slot after high boundary + add eax,0x20 + cmp word [eax+0xa],9 ;check process state, 9 means that process slot is empty + jnz .newprocessplace .endnewprocessplace: - mov ebx,eax - sub eax,CURRENT_TASK - shr eax,5 ;calculate slot index - cmp eax,256 - jge .failed ;it should be <256 - mov word [ebx+0xa],9 ;set process state to 9 (for slot after hight boundary) - ret + mov ebx,eax + sub eax,CURRENT_TASK + shr eax,5 ;calculate slot index + cmp eax,256 + jge .failed ;it should be <256 + mov word [ebx+0xa],9 ;set process state to 9 (for slot after hight boundary) + ret .failed: - xor eax,eax - ret + xor eax,eax + ret endp align 4 proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword - locals - app_pages dd ? - img_pages dd ? - dir_addr dd ? - app_tabs dd ? - endl + locals + app_pages dd ? + img_pages dd ? + dir_addr dd ? + app_tabs dd ? + endl - mov ebx, pg_data.pg_mutex - call wait_mutex ;ebx + mov ebx, pg_data.pg_mutex + call wait_mutex ;ebx - xor eax, eax - mov [dir_addr], eax + xor eax, eax + mov [dir_addr], eax - mov eax, [app_size] - add eax, 4095 - and eax, NOT(4095) - mov [app_size], eax - mov ebx, eax - shr eax, 12 - mov [app_pages], eax + mov eax, [app_size] + add eax, 4095 + and eax, NOT(4095) + mov [app_size], eax + mov ebx, eax + shr eax, 12 + mov [app_pages], eax - add ebx, 0x3FFFFF - and ebx, NOT(0x3FFFFF) - shr ebx, 22 - mov [app_tabs], ebx + add ebx, 0x3FFFFF + and ebx, NOT(0x3FFFFF) + shr ebx, 22 + mov [app_tabs], ebx - mov ecx, [img_size] - add ecx, 4095 - and ecx, NOT(4095) + mov ecx, [img_size] + add ecx, 4095 + and ecx, NOT(4095) - mov [img_size], ecx - shr ecx, 12 - mov [img_pages], ecx + mov [img_size], ecx + shr ecx, 12 + mov [img_pages], ecx if GREEDY_KERNEL - lea eax, [ecx+ebx+2] ;only image size + lea eax, [ecx+ebx+2] ;only image size else - lea eax, [eax+ebx+2] ;all requested memory + lea eax, [eax+ebx+2] ;all requested memory end if - cmp eax, [pg_data.pages_free] - ja .fail + cmp eax, [pg_data.pages_free] + ja .fail - call alloc_page - test eax, eax - jz .fail - mov [dir_addr], eax - stdcall map_page,[tmp_task_pdir],eax,dword PG_SW + call alloc_page + test eax, eax + jz .fail + mov [dir_addr], eax + stdcall map_page,[tmp_task_pdir],eax,dword PG_SW - mov edi, [tmp_task_pdir] - mov ecx, (OS_BASE shr 20)/4 - xor eax, eax - cld - rep stosd + mov edi, [tmp_task_pdir] + mov ecx, (OS_BASE shr 20)/4 + xor eax, eax + cld + rep stosd - mov ecx, (OS_BASE shr 20)/4 - mov esi, sys_pgdir+(OS_BASE shr 20) - rep movsd + mov ecx, (OS_BASE shr 20)/4 + mov esi, sys_pgdir+(OS_BASE shr 20) + rep movsd - mov eax, [dir_addr] - or eax, PG_SW - mov [edi-4096+(page_tabs shr 20)], eax + mov eax, [dir_addr] + or eax, PG_SW + mov [edi-4096+(page_tabs shr 20)], eax - and eax, -4096 - call set_cr3 + and eax, -4096 + call set_cr3 - mov edx, [app_tabs] - mov edi, new_app_base + mov edx, [app_tabs] + mov edi, new_app_base @@: - call alloc_page - test eax, eax - jz .fail + call alloc_page + test eax, eax + jz .fail - stdcall map_page_table, edi, eax - add edi, 0x00400000 - dec edx - jnz @B + stdcall map_page_table, edi, eax + add edi, 0x00400000 + dec edx + jnz @B - mov edi, new_app_base - shr edi, 10 - add edi, page_tabs + mov edi, new_app_base + shr edi, 10 + add edi, page_tabs - mov ecx, [app_tabs] - shl ecx, 10 - xor eax, eax - rep stosd + mov ecx, [app_tabs] + shl ecx, 10 + xor eax, eax + rep stosd - mov ecx, [img_pages] - mov ebx, PG_UW - mov edx, new_app_base - mov esi, [img_base] - mov edi, new_app_base - shr esi, 10 - shr edi, 10 - add esi, page_tabs - add edi, page_tabs + mov ecx, [img_pages] + mov ebx, PG_UW + mov edx, new_app_base + mov esi, [img_base] + mov edi, new_app_base + shr esi, 10 + shr edi, 10 + add esi, page_tabs + add edi, page_tabs .remap: - lodsd - or eax, ebx ; force user level r/w access - stosd - add edx, 0x1000 - dec [app_pages] - dec ecx - jnz .remap + lodsd + or eax, ebx ; force user level r/w access + stosd + add edx, 0x1000 + dec [app_pages] + dec ecx + jnz .remap - mov ecx, [app_pages] - test ecx, ecx - jz .done + mov ecx, [app_pages] + test ecx, ecx + jz .done if GREEDY_KERNEL - mov eax, 0x02 + mov eax, 0x02 .reserve: - stosd - invlpg [edx] - add edx, 4096 - dec ecx - jnz .reserve + stosd + invlpg [edx] + add edx, 4096 + dec ecx + jnz .reserve else .alloc: - call alloc_page - test eax, eax - jz .fail + call alloc_page + test eax, eax + jz .fail - stdcall map_page,edx,eax,dword PG_UW - add edx, 0x1000 - dec [app_pages] - jnz .alloc + stdcall map_page,edx,eax,dword PG_UW + add edx, 0x1000 + dec [app_pages] + jnz .alloc end if .done: - stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP + stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP - dec [pg_data.pg_mutex] - mov eax, [dir_addr] - ret + dec [pg_data.pg_mutex] + mov eax, [dir_addr] + ret .fail: - dec [pg_data.pg_mutex] - cmp [dir_addr], 0 - je @f - stdcall destroy_app_space, [dir_addr] + dec [pg_data.pg_mutex] + cmp [dir_addr], 0 + je @f + stdcall destroy_app_space, [dir_addr] @@: - xor eax, eax - ret + xor eax, eax + ret endp align 4 set_cr3: - mov ebx, [current_slot] - mov [ebx+APPDATA.dir_table], eax - mov cr3, eax - ret + mov ebx, [current_slot] + mov [ebx+APPDATA.dir_table], eax + mov cr3, eax + ret align 4 proc destroy_page_table stdcall, pg_tab:dword - push esi + push esi - mov esi, [pg_tab] - mov ecx, 1024 + mov esi, [pg_tab] + mov ecx, 1024 .free: - mov eax, [esi] - test eax, 1 - jz .next - call free_page + mov eax, [esi] + test eax, 1 + jz .next + call free_page .next: - add esi, 4 - dec ecx - jnz .free - pop esi - ret + add esi, 4 + dec ecx + jnz .free + pop esi + ret endp align 4 proc destroy_app_space stdcall, pg_dir:dword - mov ebx, pg_data.pg_mutex - call wait_mutex ;ebx + mov ebx, pg_data.pg_mutex + call wait_mutex ;ebx - xor edx,edx - mov eax,0x2 - mov ebx, [pg_dir] + xor edx,edx + mov eax,0x2 + mov ebx, [pg_dir] .loop: ;eax = current slot of process - mov ecx,eax - shl ecx,5 - cmp byte [CURRENT_TASK+ecx+0xa],9 ;if process running? - jz @f ;skip empty slots - shl ecx,3 - cmp [SLOT_BASE+ecx+0xB8],ebx ;compare page directory addresses - jnz @f - inc edx ;thread found + mov ecx,eax + shl ecx,5 + cmp byte [CURRENT_TASK+ecx+0xa],9 ;if process running? + jz @f ;skip empty slots + shl ecx,3 + cmp [SLOT_BASE+ecx+0xB8],ebx ;compare page directory addresses + jnz @f + inc edx ;thread found @@: - inc eax - cmp eax,[TASK_COUNT] ;exit loop if we look through all processes - jle .loop + inc eax + cmp eax,[TASK_COUNT] ;exit loop if we look through all processes + jle .loop ;edx = number of threads ;our process is zombi so it isn't counted - cmp edx,1 - jg .exit + cmp edx,1 + jg .exit ;if there isn't threads then clear memory. - mov eax, [pg_dir] - and eax, not 0xFFF - stdcall map_page,[tmp_task_pdir],eax,dword PG_SW - mov esi, [tmp_task_pdir] - mov edi, (OS_BASE shr 20)/4 + mov eax, [pg_dir] + and eax, not 0xFFF + stdcall map_page,[tmp_task_pdir],eax,dword PG_SW + mov esi, [tmp_task_pdir] + mov edi, (OS_BASE shr 20)/4 .destroy: - mov eax, [esi] - test eax, 1 - jz .next - and eax, not 0xFFF - stdcall map_page,[tmp_task_ptab],eax,dword PG_SW - stdcall destroy_page_table, [tmp_task_ptab] - mov eax, [esi] - call free_page + mov eax, [esi] + test eax, 1 + jz .next + and eax, not 0xFFF + stdcall map_page,[tmp_task_ptab],eax,dword PG_SW + stdcall destroy_page_table, [tmp_task_ptab] + mov eax, [esi] + call free_page .next: - add esi, 4 - dec edi - jnz .destroy + add esi, 4 + dec edi + jnz .destroy - mov eax, [pg_dir] - call free_page + mov eax, [pg_dir] + call free_page .exit: - 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] - ret + 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] + ret endp align 4 get_pid: - mov eax, [TASK_DATA] - mov eax, [eax+4] - ret + ;mov eax, [TASK_DATA] ; I think it's the bug. (Rus) + mov eax, [TASK_BASE] + mov eax, [eax+4] + ret pid_to_slot: ;Input: @@ -596,9 +597,9 @@ pid_to_slot: ;ecx=offset of current process info entry ;ebx=maximum permitted offset cmp byte [CURRENT_TASK+ecx+0xa],9 - jz .endloop ;skip empty slots + jz .endloop ;skip empty slots cmp [CURRENT_TASK+ecx+0x4],eax ;check PID - jz .pid_found + jz .pid_found .endloop: add ecx,32 cmp ecx,ebx @@ -611,7 +612,7 @@ pid_to_slot: .pid_found: shr ecx,5 - mov eax,ecx ;convert offset to index of slot + mov eax,ecx ;convert offset to index of slot pop ecx pop ebx ret @@ -708,61 +709,61 @@ proc read_process_memory ; edx - start address in other process ;Output: ; eax - number of bytes read. - locals - slot dd ? - buff dd ? - r_count dd ? - offset dd ? - tmp_r_cnt dd ? - endl + locals + slot dd ? + buff dd ? + r_count dd ? + offset dd ? + tmp_r_cnt dd ? + endl - mov [slot], eax - mov [buff], ebx - and [r_count], 0 - mov [tmp_r_cnt], ecx - mov [offset], edx + mov [slot], eax + mov [buff], ebx + and [r_count], 0 + mov [tmp_r_cnt], ecx + mov [offset], edx - pushad + pushad .read_mem: - mov edx, [offset] - mov ebx, [tmp_r_cnt] + mov edx, [offset] + mov ebx, [tmp_r_cnt] - mov ecx, 0x400000 - and edx, 0x3FFFFF - sub ecx, edx - cmp ecx, ebx - jbe @f - mov ecx, ebx + mov ecx, 0x400000 + and edx, 0x3FFFFF + sub ecx, edx + cmp ecx, ebx + jbe @f + mov ecx, ebx @@: - cmp ecx, 0x8000 - jna @F - mov ecx, 0x8000 + cmp ecx, 0x8000 + jna @F + mov ecx, 0x8000 @@: - mov eax, [slot] - shl eax,8 - mov ebx, [offset] + mov eax, [slot] + shl eax,8 + mov ebx, [offset] ; add ebx, new_app_base - push ecx - stdcall map_memEx, [proc_mem_map],\ - [SLOT_BASE+eax+0xB8],\ - ebx, ecx - pop ecx + push ecx + stdcall map_memEx, [proc_mem_map],\ + [SLOT_BASE+eax+0xB8],\ + ebx, ecx + pop ecx - mov esi, [offset] - and esi, 0xfff - add esi, [proc_mem_map] - mov edi, [buff] - mov edx, ecx - rep movsb - add [r_count], edx + mov esi, [offset] + and esi, 0xfff + add esi, [proc_mem_map] + mov edi, [buff] + mov edx, ecx + rep movsb + add [r_count], edx - add [offset], edx - sub [tmp_r_cnt], edx - jnz .read_mem + add [offset], edx + sub [tmp_r_cnt], edx + jnz .read_mem - popad - mov eax, [r_count] - ret + popad + mov eax, [r_count] + ret endp align 4 @@ -775,149 +776,149 @@ proc write_process_memory ;Output: ; eax - number of bytes written - locals - slot dd ? - buff dd ? - w_count dd ? - offset dd ? - tmp_w_cnt dd ? - endl + locals + slot dd ? + buff dd ? + w_count dd ? + offset dd ? + tmp_w_cnt dd ? + endl - mov [slot], eax - mov [buff], ebx - and [w_count], 0 - mov [tmp_w_cnt], ecx - mov [offset], edx + mov [slot], eax + mov [buff], ebx + and [w_count], 0 + mov [tmp_w_cnt], ecx + mov [offset], edx - pushad + pushad .read_mem: - mov edx, [offset] - mov ebx, [tmp_w_cnt] + mov edx, [offset] + mov ebx, [tmp_w_cnt] - mov ecx, 0x400000 - and edx, 0x3FFFFF - sub ecx, edx - cmp ecx, ebx - jbe @f - mov ecx, ebx + mov ecx, 0x400000 + and edx, 0x3FFFFF + sub ecx, edx + cmp ecx, ebx + jbe @f + mov ecx, ebx @@: - cmp ecx, 0x8000 - jna @F - mov ecx, 0x8000 + cmp ecx, 0x8000 + jna @F + mov ecx, 0x8000 @@: - mov eax, [slot] - shl eax,8 - mov ebx, [offset] + mov eax, [slot] + shl eax,8 + mov ebx, [offset] ; add ebx, new_app_base - push ecx - stdcall map_memEx, [proc_mem_map],\ - [SLOT_BASE+eax+0xB8],\ - ebx, ecx - pop ecx + push ecx + stdcall map_memEx, [proc_mem_map],\ + [SLOT_BASE+eax+0xB8],\ + ebx, ecx + pop ecx - mov edi, [offset] - and edi, 0xfff - add edi, [proc_mem_map] - mov esi, [buff] - mov edx, ecx - rep movsb + mov edi, [offset] + and edi, 0xfff + add edi, [proc_mem_map] + mov esi, [buff] + mov edx, ecx + rep movsb - add [w_count], edx - add [offset], edx - sub [tmp_w_cnt], edx - jnz .read_mem + add [w_count], edx + add [offset], edx + sub [tmp_w_cnt], edx + jnz .read_mem - popad - mov eax, [w_count] - ret + popad + mov eax, [w_count] + ret endp align 4 proc new_sys_threads - locals - slot dd ? - app_cmdline dd ? ;0x00 - app_path dd ? ;0x04 - app_eip dd ? ;0x08 - app_esp dd ? ;0x0C - app_mem dd ? ;0x10 - endl + locals + slot dd ? + app_cmdline dd ? ;0x00 + app_path dd ? ;0x04 + app_eip dd ? ;0x08 + app_esp dd ? ;0x0C + app_mem dd ? ;0x10 + endl - cmp eax,1 - jne .failed ;other subfunctions + cmp eax,1 + jne .failed ;other subfunctions - xor eax,eax - mov [app_cmdline], eax - mov [app_path], eax - mov [app_eip], ebx - mov [app_esp], ecx + xor eax,eax + mov [app_cmdline], eax + mov [app_path], eax + mov [app_eip], ebx + mov [app_esp], ecx - ;mov esi,new_process_loading - ;call sys_msg_board_str - DEBUGF 1,"%s",new_process_loading + ;mov esi,new_process_loading + ;call sys_msg_board_str + DEBUGF 1,"%s",new_process_loading .wait_lock: - cmp [application_table_status],0 - je .get_lock - call change_task - jmp .wait_lock + cmp [application_table_status],0 + je .get_lock + call change_task + jmp .wait_lock .get_lock: - mov eax, 1 - xchg eax, [application_table_status] - cmp eax, 0 - jne .wait_lock + mov eax, 1 + xchg eax, [application_table_status] + cmp eax, 0 + jne .wait_lock - call set_application_table_status + call set_application_table_status - call get_new_process_place - test eax, eax - jz .failed + call get_new_process_place + test eax, eax + jz .failed - mov [slot], eax + mov [slot], eax - mov esi,[current_slot] - mov ebx,esi ;ebx=esi - pointer to extended information about current thread + mov esi,[current_slot] + mov ebx,esi ;ebx=esi - pointer to extended information about current thread - mov edi, eax - shl edi,8 - add edi,SLOT_BASE - mov edx,edi ;edx=edi - pointer to extended infomation about new thread - mov ecx,256/4 - xor eax, eax - cld - rep stosd ;clean extended information about new thread - mov esi,ebx - mov edi,edx - mov ecx,11 - rep movsb ;copy process name + mov edi, eax + shl edi,8 + add edi,SLOT_BASE + mov edx,edi ;edx=edi - pointer to extended infomation about new thread + mov ecx,256/4 + xor eax, eax + cld + rep stosd ;clean extended information about new thread + mov esi,ebx + mov edi,edx + mov ecx,11 + rep movsb ;copy process name - mov eax,[ebx+APPDATA.heap_base] - mov [edx+APPDATA.heap_base], eax + mov eax,[ebx+APPDATA.heap_base] + mov [edx+APPDATA.heap_base], eax - mov ecx,[ebx+APPDATA.heap_top] - mov [edx+APPDATA.heap_top], ecx + mov ecx,[ebx+APPDATA.heap_top] + mov [edx+APPDATA.heap_top], ecx - mov eax,[ebx+APPDATA.mem_size] - mov [edx+APPDATA.mem_size], eax + mov eax,[ebx+APPDATA.mem_size] + mov [edx+APPDATA.mem_size], eax - mov ecx,[ebx+APPDATA.dir_table] - mov [edx+APPDATA.dir_table],ecx ;copy page directory + mov ecx,[ebx+APPDATA.dir_table] + mov [edx+APPDATA.dir_table],ecx ;copy page directory - lea eax, [app_cmdline] - stdcall set_app_params ,[slot],eax,dword 0,\ - dword 0,dword 0 + lea eax, [app_cmdline] + stdcall set_app_params ,[slot],eax,dword 0,\ + dword 0,dword 0 - ;mov esi,new_process_running - ;call sys_msg_board_str ;output information about succefull startup - DEBUGF 1,"%s",new_process_running + ;mov esi,new_process_running + ;call sys_msg_board_str ;output information about succefull startup + DEBUGF 1,"%s",new_process_running - mov [application_table_status],0 ;unlock application_table_status mutex - mov eax,[process_number] ;set result - ret + mov [application_table_status],0 ;unlock application_table_status mutex + mov eax,[process_number] ;set result + ret .failed: - mov [application_table_status],0 - mov eax,-1 - ret + mov [application_table_status],0 + mov eax,-1 + ret endp ; param @@ -925,23 +926,23 @@ endp align 4 wait_mutex: - push eax - push ebx + push eax + push ebx .do_wait: - cmp dword [ebx],0 - je .get_lock - call change_task - jmp .do_wait + cmp dword [ebx],0 + je .get_lock + call change_task + jmp .do_wait .get_lock: - mov eax, 1 - xchg eax, [ebx] - test eax, eax - jnz .do_wait - pop ebx - pop eax - ret + mov eax, 1 + xchg eax, [ebx] + test eax, eax + jnz .do_wait + pop ebx + pop eax + ret -EFL_IF equ 0x0200 +EFL_IF equ 0x0200 EFL_IOPL1 equ 0x1000 EFL_IOPL2 equ 0x2000 EFL_IOPL3 equ 0x3000 @@ -949,167 +950,167 @@ EFL_IOPL3 equ 0x3000 align 4 proc set_app_params stdcall,slot:dword, params:dword,\ - cmd_line:dword, app_path:dword, flags:dword + cmd_line:dword, app_path:dword, flags:dword - locals - pl0_stack dd ? - endl + locals + pl0_stack dd ? + endl - stdcall kernel_alloc, RING0_STACK_SIZE+512 - mov [pl0_stack], eax + stdcall kernel_alloc, RING0_STACK_SIZE+512 + mov [pl0_stack], eax - lea edi, [eax+RING0_STACK_SIZE] + lea edi, [eax+RING0_STACK_SIZE] - mov eax, [slot] - mov ebx, eax + mov eax, [slot] + mov ebx, eax - shl eax, 8 - mov [eax+SLOT_BASE+APPDATA.fpu_state], edi - mov [eax+SLOT_BASE+APPDATA.fpu_handler], 0 - mov [eax+SLOT_BASE+APPDATA.sse_handler], 0 + shl eax, 8 + mov [eax+SLOT_BASE+APPDATA.fpu_state], edi + mov [eax+SLOT_BASE+APPDATA.fpu_handler], 0 + mov [eax+SLOT_BASE+APPDATA.sse_handler], 0 ;set default io permission map - mov [eax+SLOT_BASE+APPDATA.io_map],\ - (tss._io_map_0-OS_BASE+PG_MAP) - mov [eax+SLOT_BASE+APPDATA.io_map+4],\ - (tss._io_map_1-OS_BASE+PG_MAP) + mov [eax+SLOT_BASE+APPDATA.io_map],\ + (tss._io_map_0-OS_BASE+PG_MAP) + mov [eax+SLOT_BASE+APPDATA.io_map+4],\ + (tss._io_map_1-OS_BASE+PG_MAP) - mov esi, fpu_data - mov ecx, 512/4 - rep movsd + mov esi, fpu_data + mov ecx, 512/4 + rep movsd - cmp ebx,[TASK_COUNT] - jle .noinc - inc dword [TASK_COUNT] ;update number of processes + cmp ebx,[TASK_COUNT] + jle .noinc + inc dword [TASK_COUNT] ;update number of processes .noinc: - shl ebx,8 - lea edx, [ebx+SLOT_BASE+APP_EV_OFFSET] - mov [SLOT_BASE+APPDATA.fd_ev+ebx],edx - mov [SLOT_BASE+APPDATA.bk_ev+ebx],edx + shl ebx,8 + lea edx, [ebx+SLOT_BASE+APP_EV_OFFSET] + mov [SLOT_BASE+APPDATA.fd_ev+ebx],edx + mov [SLOT_BASE+APPDATA.bk_ev+ebx],edx - add edx, APP_OBJ_OFFSET-APP_EV_OFFSET - mov [SLOT_BASE+APPDATA.fd_obj+ebx],edx - mov [SLOT_BASE+APPDATA.bk_obj+ebx],edx + add edx, APP_OBJ_OFFSET-APP_EV_OFFSET + mov [SLOT_BASE+APPDATA.fd_obj+ebx],edx + mov [SLOT_BASE+APPDATA.bk_obj+ebx],edx - mov ecx, [def_cursor] - mov [SLOT_BASE+APPDATA.cursor+ebx],ecx - mov eax, [pl0_stack] - mov [SLOT_BASE+APPDATA.pl0_stack+ebx],eax - add eax, RING0_STACK_SIZE - mov [SLOT_BASE+APPDATA.saved_esp0+ebx], eax + mov ecx, [def_cursor] + mov [SLOT_BASE+APPDATA.cursor+ebx],ecx + mov eax, [pl0_stack] + mov [SLOT_BASE+APPDATA.pl0_stack+ebx],eax + add eax, RING0_STACK_SIZE + mov [SLOT_BASE+APPDATA.saved_esp0+ebx], eax - push ebx - stdcall kernel_alloc, 0x1000 - pop ebx - mov esi,[current_slot] - mov esi,[esi+APPDATA.cur_dir] - mov ecx,0x1000/4 - mov edi,eax - mov [ebx+SLOT_BASE+APPDATA.cur_dir],eax - rep movsd + push ebx + stdcall kernel_alloc, 0x1000 + pop ebx + mov esi,[current_slot] + mov esi,[esi+APPDATA.cur_dir] + mov ecx,0x1000/4 + mov edi,eax + mov [ebx+SLOT_BASE+APPDATA.cur_dir],eax + rep movsd - shr ebx,3 - mov eax, new_app_base - mov dword [CURRENT_TASK+ebx+0x10],eax + shr ebx,3 + mov eax, new_app_base + mov dword [CURRENT_TASK+ebx+0x10],eax .add_command_line: - mov edx,[params] - mov edx,[edx] ;app_cmdline - test edx,edx - jz @f ;application doesn't need parameters + mov edx,[params] + mov edx,[edx] ;app_cmdline + test edx,edx + jz @f ;application doesn't need parameters - mov eax, edx - add eax, 256 - jc @f + mov eax, edx + add eax, 256 + jc @f - cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] - ja @f + cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] + ja @f - mov byte [edx], 0 ;force empty string if no cmdline given - mov eax, [cmd_line] - test eax, eax - jz @f - stdcall strncpy, edx, eax, 256 + mov byte [edx], 0 ;force empty string if no cmdline given + mov eax, [cmd_line] + test eax, eax + jz @f + stdcall strncpy, edx, eax, 256 @@: - mov edx,[params] - mov edx, [edx+4] ;app_path - test edx,edx - jz @F ;application don't need path of file - mov eax, edx - add eax, 1024 - jc @f - cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] - ja @f - stdcall strncpy, edx, [app_path], 1024 + mov edx,[params] + mov edx, [edx+4] ;app_path + test edx,edx + jz @F ;application don't need path of file + mov eax, edx + add eax, 1024 + jc @f + cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] + ja @f + stdcall strncpy, edx, [app_path], 1024 @@: - mov ebx,[slot] - mov eax,ebx - shl ebx,5 - lea ecx,[draw_data+ebx] ;ecx - pointer to draw data + mov ebx,[slot] + mov eax,ebx + shl ebx,5 + lea ecx,[draw_data+ebx] ;ecx - pointer to draw data ; set window state to 'normal' (non-minimized/maximized/rolled-up) state - mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL - mov [ebx+window_data+WDATA.fl_redraw], 1 - add ebx,CURRENT_TASK ;ebx - pointer to information about process - mov [ebx+TASKDATA.wnd_number],al;set window number on screen = process slot + mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL + mov [ebx+window_data+WDATA.fl_redraw], 1 + add ebx,CURRENT_TASK ;ebx - pointer to information about process + mov [ebx+TASKDATA.wnd_number],al;set window number on screen = process slot - mov [ebx+TASKDATA.event_mask],dword 1+2+4 ;set default event flags (see 40 function) + mov [ebx+TASKDATA.event_mask],dword 1+2+4 ;set default event flags (see 40 function) - inc dword [process_number] - mov eax,[process_number] - mov [ebx+4],eax ;set PID + inc dword [process_number] + mov eax,[process_number] + mov [ebx+4],eax ;set PID ;set draw data to full screen - mov [ecx+0],dword 0 - mov [ecx+4],dword 0 - mov eax,[Screen_Max_X] - mov [ecx+8],eax - mov eax,[Screen_Max_Y] - mov [ecx+12],eax + mov [ecx+0],dword 0 + mov [ecx+4],dword 0 + mov eax,[Screen_Max_X] + mov [ecx+8],eax + mov eax,[Screen_Max_Y] + mov [ecx+12],eax - mov ebx, [pl0_stack] - mov esi,[params] - lea ecx, [ebx+REG_EIP] - xor eax, eax + mov ebx, [pl0_stack] + mov esi,[params] + lea ecx, [ebx+REG_EIP] + xor eax, eax - mov [ebx+REG_RET], dword irq0.return - mov [ebx+REG_EDI], eax - mov [ebx+REG_ESI], eax - mov [ebx+REG_EBP], eax - mov [ebx+REG_ESP], ecx ;ebx+REG_EIP - mov [ebx+REG_EBX], eax - mov [ebx+REG_EDX], eax - mov [ebx+REG_ECX], eax - mov [ebx+REG_EAX], eax + mov [ebx+REG_RET], dword irq0.return + mov [ebx+REG_EDI], eax + mov [ebx+REG_ESI], eax + mov [ebx+REG_EBP], eax + mov [ebx+REG_ESP], ecx ;ebx+REG_EIP + mov [ebx+REG_EBX], eax + mov [ebx+REG_EDX], eax + mov [ebx+REG_ECX], eax + mov [ebx+REG_EAX], eax - mov eax, [esi+0x08] ;app_eip - mov [ebx+REG_EIP], eax ;app_entry - mov [ebx+REG_CS], dword app_code - mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF + mov eax, [esi+0x08] ;app_eip + mov [ebx+REG_EIP], eax ;app_entry + mov [ebx+REG_CS], dword app_code + mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF - mov eax, [esi+0x0C] ;app_esp - mov [ebx+REG_APP_ESP], eax ;app_stack - mov [ebx+REG_SS], dword app_data + mov eax, [esi+0x0C] ;app_esp + mov [ebx+REG_APP_ESP], eax ;app_stack + mov [ebx+REG_SS], dword app_data - lea ecx, [ebx+REG_RET] - mov ebx, [slot] - shl ebx, 5 - mov [ebx*8+SLOT_BASE+APPDATA.saved_esp], ecx + lea ecx, [ebx+REG_RET] + mov ebx, [slot] + shl ebx, 5 + mov [ebx*8+SLOT_BASE+APPDATA.saved_esp], ecx - xor ecx, ecx ; process state - running + xor ecx, ecx ; process state - running ; set if debuggee - test byte [flags], 1 - jz .no_debug - inc ecx ; process state - suspended - mov eax,[CURRENT_TASK] - mov [SLOT_BASE+ebx*8+APPDATA.debugger_slot],eax + test byte [flags], 1 + jz .no_debug + inc ecx ; process state - suspended + mov eax,[CURRENT_TASK] + mov [SLOT_BASE+ebx*8+APPDATA.debugger_slot],eax .no_debug: - mov [CURRENT_TASK+ebx+TASKDATA.state], cl - ;mov esi,new_process_running - ;call sys_msg_board_str ;output information about succefull startup - DEBUGF 1,"%s",new_process_running - ret + mov [CURRENT_TASK+ebx+TASKDATA.state], cl + ;mov esi,new_process_running + ;call sys_msg_board_str ;output information about succefull startup + DEBUGF 1,"%s",new_process_running + ret endp include "debug.inc" diff --git a/kernel/trunk/drivers/com_mouse.asm b/kernel/trunk/drivers/com_mouse.asm index ff9fa72034..0e1bf84262 100644 --- a/kernel/trunk/drivers/com_mouse.asm +++ b/kernel/trunk/drivers/com_mouse.asm @@ -3,6 +3,8 @@ ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; +;; Includes source code by Kulakov Vladimir Gennadievich. ;; +;; Modified by Mario79 and Rus. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;driver sceletone @@ -66,7 +68,7 @@ end if mov al, 1 out dx, al - stdcall AttachIntHandler, 4, irq4_handler + stdcall AttachIntHandler, 4, irq4_handler, dword 0 if DEBUG cmp eax, 0 jne .label1 @@ -99,7 +101,7 @@ end if ;mov [com2_mouse_detected],1 ;mov [irq_owner+3*4], 1 ; IRQ3 owner is System - stdcall AttachIntHandler, 3, irq3_handler + stdcall AttachIntHandler, 3, irq3_handler, dword 0 mov eax, 0 mov ebx, 0x2F8 @@ -358,7 +360,7 @@ COMPortBaseAddr dw 3F8h version dd (5 shl 16) or (API_VERSION and 0xFFFF) -my_service db 'MY_SERVICE',0 ;max 16 chars include zero +my_service db 'COM_Mouse',0 ;max 16 chars include zero if DEBUG msgInit db 'Preved bugoga!',13,10,0 diff --git a/kernel/trunk/drivers/ensoniq.asm b/kernel/trunk/drivers/ensoniq.asm index d9f375c170..f86a9dd05e 100644 --- a/kernel/trunk/drivers/ensoniq.asm +++ b/kernel/trunk/drivers/ensoniq.asm @@ -109,124 +109,124 @@ DEV_GET_MASTERVOL equ 7 DEV_GET_INFO equ 8 struc AC_CNTRL ;AC controller base class -{ .bus dd ? - .devfn dd ? +{ .bus dd ? + .devfn dd ? - .vendor dd ? - .dev_id dd ? - .pci_cmd dd ? - .pci_stat dd ? + .vendor dd ? + .dev_id dd ? + .pci_cmd dd ? + .pci_stat dd ? .codec_io_base dd ? .codec_mem_base dd ? .ctrl_io_base dd ? .ctrl_mem_base dd ? - .cfg_reg dd ? - .int_line dd ? + .cfg_reg dd ? + .int_line dd ? - .vendor_ids dd ? ;vendor id string - .ctrl_ids dd ? ;hub id string + .vendor_ids dd ? ;vendor id string + .ctrl_ids dd ? ;hub id string - .buffer dd ? + .buffer dd ? - .notify_pos dd ? - .notify_task dd ? + .notify_pos dd ? + .notify_task dd ? - .lvi_reg dd ? - .ctrl_setup dd ? + .lvi_reg dd ? + .ctrl_setup dd ? .user_callback dd ? .codec_read16 dd ? .codec_write16 dd ? - .ctrl_read8 dd ? - .ctrl_read16 dd ? - .ctrl_read32 dd ? + .ctrl_read8 dd ? + .ctrl_read16 dd ? + .ctrl_read32 dd ? - .ctrl_write8 dd ? + .ctrl_write8 dd ? .ctrl_write16 dd ? .ctrl_write32 dd ? } struc CODEC ;Audio Chip base class { - .chip_id dd ? - .flags dd ? - .status dd ? + .chip_id dd ? + .flags dd ? + .status dd ? .ac_vendor_ids dd ? ;ac vendor id string - .chip_ids dd ? ;chip model string + .chip_ids dd ? ;chip model string - .shadow_flag dd ? - dd ? + .shadow_flag dd ? + dd ? - .regs dw ? ; codec registers + .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_mic_vol dw ? ;0x0E .reg_line_in_vol dw ? ;0x10 - .reg_cd_vol dw ? ;0x12 + .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_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_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 + 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 + 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 ? ;virual + .reset dd ? ;virual .set_master_vol dd ? } @@ -239,16 +239,16 @@ struc CTRL_INFO .ctrl_io_base dd ? .codec_mem_base dd ? .ctrl_mem_base dd ? - .codec_id dd ? + .codec_id dd ? } struc IOCTL -{ .handle dd ? - .io_code dd ? - .input dd ? - .inp_size dd ? - .output dd ? - .out_size dd ? +{ .handle dd ? + .io_code dd ? + .input dd ? + .inp_size dd ? + .output dd ? + .out_size dd ? } virtual at 0 @@ -257,9 +257,9 @@ end virtual EVENT_NOTIFY equ 0x00000200 -OS_BASE equ 0x80000000 -SLOT_BASE equ OS_BASE+0x0080000 -new_app_base equ 0 +OS_BASE equ 0x80000000 +SLOT_BASE equ OS_BASE+0x0080000 +new_app_base equ 0 public START public service_proc @@ -269,130 +269,130 @@ section '.flat' code readable align 16 proc START stdcall, state:dword - cmp [state], 1 - jne .stop + cmp [state], 1 + jne .stop if DEBUG - mov esi, msgDetect - call SysMsgBoardStr + mov esi, msgDetect + call SysMsgBoardStr end if - call detect_controller - test eax, eax - jz .fail + call detect_controller + test eax, eax + jz .fail if DEBUG - mov esi,[ctrl.vendor_ids] - call SysMsgBoardStr - mov esi, [ctrl.ctrl_ids] - call SysMsgBoardStr + mov esi,[ctrl.vendor_ids] + call SysMsgBoardStr + mov esi, [ctrl.ctrl_ids] + call SysMsgBoardStr end if - call init_controller - test eax, eax - jz .fail + call init_controller + test eax, eax + jz .fail - jmp .fail ;force fail + jmp .fail ;force fail if DEBUG - mov esi, msgInitCodec - call SysMsgBoardStr + mov esi, msgInitCodec + call SysMsgBoardStr end if - call init_codec - test eax, eax - jz .fail + call init_codec + test eax, eax + jz .fail if DEBUG - mov esi, [codec.ac_vendor_ids] - call SysMsgBoardStr + mov esi, [codec.ac_vendor_ids] + call SysMsgBoardStr - mov esi, [codec.chip_ids] - call SysMsgBoardStr + mov esi, [codec.chip_ids] + call SysMsgBoardStr end if - call reset_controller - call setup_codec + call reset_controller + call setup_codec - mov esi, msgPrimBuff - call SysMsgBoardStr + mov esi, msgPrimBuff + call SysMsgBoardStr - call create_primary_buff + call create_primary_buff - mov eax, VALID_IRQ - mov ebx, [ctrl.int_line] - mov esi, msgInvIRQ - bt eax, ebx - jnc .fail - mov eax, ATTCH_IRQ - mov esi, msgAttchIRQ - bt eax, ebx - jnc .fail + mov eax, VALID_IRQ + mov ebx, [ctrl.int_line] + mov esi, msgInvIRQ + bt eax, ebx + jnc .fail + mov eax, ATTCH_IRQ + mov esi, msgAttchIRQ + bt eax, ebx + jnc .fail - stdcall AttachIntHandler, ebx, ac97_irq - stdcall RegService, sz_sound_srv, service_proc + stdcall AttachIntHandler, ebx, ac97_irq, dword 0 + stdcall RegService, sz_sound_srv, service_proc ret .fail: if DEBUG - mov esi, msgFail - call SysMsgBoardStr + mov esi, msgFail + call SysMsgBoardStr end if - xor eax, eax - ret + xor eax, eax + ret .stop: - call stop - xor eax, eax - ret + call stop + xor eax, eax + ret endp -handle equ IOCTL.handle -io_code equ IOCTL.io_code -input equ IOCTL.input -inp_size equ IOCTL.inp_size -output equ IOCTL.output -out_size equ IOCTL.out_size +handle equ IOCTL.handle +io_code equ IOCTL.io_code +input equ IOCTL.input +inp_size equ IOCTL.inp_size +output equ IOCTL.output +out_size equ IOCTL.out_size align 4 proc service_proc stdcall, ioctl:dword - mov edi, [ioctl] - mov eax, [edi+io_code] - cmp eax, DEV_PLAY - jne @F + mov edi, [ioctl] + mov eax, [edi+io_code] + cmp eax, DEV_PLAY + jne @F if DEBUG - mov esi, msgPlay - call SysMsgBoardStr + mov esi, msgPlay + call SysMsgBoardStr end if - call play - ret + call play + ret @@: - cmp eax, DEV_STOP - jne @F + cmp eax, DEV_STOP + jne @F if DEBUG - mov esi, msgStop - call SysMsgBoardStr + mov esi, msgStop + call SysMsgBoardStr end if - call stop - ret + call stop + ret @@: - cmp eax, DEV_CALLBACK - jne @F - mov ebx, [edi+input] - stdcall set_callback, [ebx] - ret + cmp eax, DEV_CALLBACK + jne @F + mov ebx, [edi+input] + stdcall set_callback, [ebx] + ret @@: - cmp eax, DEV_SET_MASTERVOL - jne @F - mov eax, [edi+input] - mov eax, [eax] - call set_master_vol ;eax= vol - ret + cmp eax, DEV_SET_MASTERVOL + jne @F + mov eax, [edi+input] + mov eax, [eax] + call set_master_vol ;eax= vol + ret @@: - cmp eax, DEV_GET_MASTERVOL - jne @F - mov ebx, [edi+output] - stdcall get_master_vol, ebx - ret + cmp eax, DEV_GET_MASTERVOL + jne @F + mov ebx, [edi+output] + stdcall get_master_vol, ebx + ret ;@@: ; cmp eax, DEV_GET_INFO ; jne @F @@ -401,8 +401,8 @@ proc service_proc stdcall, ioctl:dword ; ret @@: .fail: - or eax, -1 - ret + or eax, -1 + ret endp restore handle @@ -422,349 +422,349 @@ proc ac97_irq ; end if - cmp [ctrl.user_callback], 0 - je @f + cmp [ctrl.user_callback], 0 + je @f - stdcall [ctrl.user_callback], ebx + stdcall [ctrl.user_callback], ebx @@: - ret + ret .skip: - mov edx, PCM_OUT_CR_REG - mov ax, 0x11 ;0x1D - call [ctrl.ctrl_write8] - ret + mov edx, PCM_OUT_CR_REG + mov ax, 0x11 ;0x1D + call [ctrl.ctrl_write8] + ret endp align 4 proc create_primary_buff - stdcall KernelAlloc, 0x10000 - mov [ctrl.buffer], eax + stdcall KernelAlloc, 0x10000 + mov [ctrl.buffer], eax - mov edi, eax - mov ecx, 0x10000/4 - xor eax, eax - cld - rep stosd + mov edi, eax + mov ecx, 0x10000/4 + xor eax, eax + cld + rep stosd - mov eax, [ctrl.buffer] - call GetPgAddr + mov eax, [ctrl.buffer] + call GetPgAddr - mov ebx, 0xC0002000 - mov ecx, 4 - mov edi, pcmout_bdl + mov ebx, 0xC0002000 + mov ecx, 4 + mov edi, pcmout_bdl @@: - mov [edi], eax - mov [edi+4], ebx + mov [edi], eax + mov [edi+4], ebx - mov [edi+32], eax - mov [edi+4+32], ebx + mov [edi+32], eax + mov [edi+4+32], ebx - mov [edi+64], eax - mov [edi+4+64], ebx + mov [edi+64], eax + mov [edi+4+64], ebx - mov [edi+96], eax - mov [edi+4+96], ebx + mov [edi+96], eax + mov [edi+4+96], ebx - mov [edi+128], eax - mov [edi+4+128], ebx + mov [edi+128], eax + mov [edi+4+128], ebx - mov [edi+160], eax - mov [edi+4+160], ebx + mov [edi+160], eax + mov [edi+4+160], ebx - mov [edi+192], eax - mov [edi+4+192], ebx + mov [edi+192], eax + mov [edi+4+192], ebx - mov [edi+224], eax - mov [edi+4+224], ebx + mov [edi+224], eax + mov [edi+4+224], ebx - add eax, 0x4000 - add edi, 8 - loop @B + add eax, 0x4000 + add edi, 8 + loop @B - mov edi, buff_list - mov eax, [ctrl.buffer] - mov ecx, 4 + mov edi, buff_list + mov eax, [ctrl.buffer] + mov ecx, 4 @@: - mov [edi], eax - mov [edi+16], eax - mov [edi+32], eax - mov [edi+48], eax - mov [edi+64], eax - mov [edi+80], eax - mov [edi+96], eax - mov [edi+112], eax + mov [edi], eax + mov [edi+16], eax + mov [edi+32], eax + mov [edi+48], eax + mov [edi+64], eax + mov [edi+80], eax + mov [edi+96], eax + mov [edi+112], eax - add eax, 0x4000 - add edi, 4 - loop @B + add eax, 0x4000 + add edi, 4 + loop @B - mov eax, pcmout_bdl - mov ebx, eax - call GetPgAddr ;eax - and ebx, 0xFFF - add eax, ebx + mov eax, pcmout_bdl + mov ebx, eax + call GetPgAddr ;eax + and ebx, 0xFFF + add eax, ebx - mov edx, PCM_OUT_BDL - call [ctrl.ctrl_write32] + mov edx, PCM_OUT_BDL + call [ctrl.ctrl_write32] - mov eax, 16 - mov [ctrl.lvi_reg], eax - mov edx, PCM_OUT_LVI_REG - call [ctrl.ctrl_write8] - ret + mov eax, 16 + mov [ctrl.lvi_reg], eax + mov edx, PCM_OUT_LVI_REG + call [ctrl.ctrl_write8] + ret endp align 4 proc detect_controller - locals - last_bus dd ? - bus dd ? - devfn dd ? - endl + locals + last_bus dd ? + bus dd ? + devfn dd ? + endl - xor eax, eax - mov [bus], eax - inc eax - call PciApi - cmp eax, -1 - je .err + xor eax, eax + mov [bus], eax + inc eax + call PciApi + cmp eax, -1 + je .err - mov [last_bus], eax + mov [last_bus], eax .next_bus: - and [devfn], 0 + and [devfn], 0 .next_dev: - stdcall PciRead32, [bus], [devfn], dword 0 - test eax, eax - jz .next - cmp eax, -1 - je .next + stdcall PciRead32, [bus], [devfn], dword 0 + test eax, eax + jz .next + cmp eax, -1 + je .next - mov edi, devices + mov edi, devices @@: - mov ebx, [edi] - test ebx, ebx - jz .next + mov ebx, [edi] + test ebx, ebx + jz .next - cmp eax, ebx - je .found - add edi, 12 - jmp @B + cmp eax, ebx + je .found + add edi, 12 + jmp @B .next: - inc [devfn] - cmp [devfn], 256 - jb .next_dev - mov eax, [bus] - inc eax - mov [bus], eax - cmp eax, [last_bus] - jna .next_bus - xor eax, eax - ret + inc [devfn] + cmp [devfn], 256 + jb .next_dev + mov eax, [bus] + inc eax + mov [bus], eax + cmp eax, [last_bus] + jna .next_bus + xor eax, eax + ret .found: - mov ebx, [bus] - mov [ctrl.bus], ebx + mov ebx, [bus] + mov [ctrl.bus], ebx - mov ecx, [devfn] - mov [ctrl.devfn], ecx + mov ecx, [devfn] + mov [ctrl.devfn], ecx - mov edx, eax - and edx, 0xFFFF - mov [ctrl.vendor], edx - shr eax, 16 - mov [ctrl.dev_id], eax + mov edx, eax + and edx, 0xFFFF + mov [ctrl.vendor], edx + shr eax, 16 + mov [ctrl.dev_id], eax - mov ebx, [edi+4] - mov [ctrl.ctrl_ids], ebx - mov esi, [edi+8] - mov [ctrl.ctrl_setup], esi + mov ebx, [edi+4] + mov [ctrl.ctrl_ids], ebx + mov esi, [edi+8] + mov [ctrl.ctrl_setup], esi - cmp ebx, 0x1274 - jne @F - mov [ctrl.vendor_ids], msgEnsoniq - ret + cmp ebx, 0x1274 + jne @F + mov [ctrl.vendor_ids], msgEnsoniq + ret @@: - mov [ctrl.vendor_ids], 0 ;something wrong ? - ret + mov [ctrl.vendor_ids], 0 ;something wrong ? + ret .err: - xor eax, eax - ret + xor eax, eax + ret endp align 4 proc init_controller - mov esi, msgPCIcmd - call SysMsgBoardStr + mov esi, msgPCIcmd + call SysMsgBoardStr - 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 4 + mov ebx, eax + and eax, 0xFFFF + mov [ctrl.pci_cmd], eax + shr ebx, 16 + mov [ctrl.pci_stat], ebx - call dword2str - call SysMsgBoardStr + call dword2str + call SysMsgBoardStr - mov esi, msgIObase - call SysMsgBoardStr + mov esi, msgIObase + call SysMsgBoardStr - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 + stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 ; and eax, -16 - mov [ctrl.ctrl_io_base], eax + mov [ctrl.ctrl_io_base], eax - call dword2str - call SysMsgBoardStr + call dword2str + call SysMsgBoardStr - mov esi, msgIRQline - call SysMsgBoardStr + mov esi, msgIRQline + call SysMsgBoardStr - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C - and eax, 0xFF - mov [ctrl.int_line], eax + stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C + and eax, 0xFF + mov [ctrl.int_line], eax - call dword2str - call SysMsgBoardStr + call dword2str + call SysMsgBoardStr - call [ctrl.ctrl_setup] - xor eax, eax - inc eax - ret + call [ctrl.ctrl_setup] + xor eax, eax + inc eax + ret endp align 4 proc set_ICH - mov [ctrl.codec_read16], codec_io_r16 ;virtual - mov [ctrl.codec_write16], codec_io_w16 ;virtual + mov [ctrl.codec_read16], codec_io_r16 ;virtual + mov [ctrl.codec_write16], codec_io_w16 ;virtual - mov [ctrl.ctrl_read8 ], ctrl_io_r8 ;virtual - mov [ctrl.ctrl_read16], ctrl_io_r16 ;virtual - mov [ctrl.ctrl_read32], ctrl_io_r32 ;virtual + mov [ctrl.ctrl_read8 ], ctrl_io_r8 ;virtual + mov [ctrl.ctrl_read16], ctrl_io_r16 ;virtual + mov [ctrl.ctrl_read32], ctrl_io_r32 ;virtual - mov [ctrl.ctrl_write8 ], ctrl_io_w8 ;virtual - mov [ctrl.ctrl_write16], ctrl_io_w16 ;virtual - mov [ctrl.ctrl_write32], ctrl_io_w32 ;virtual - ret + mov [ctrl.ctrl_write8 ], ctrl_io_w8 ;virtual + mov [ctrl.ctrl_write16], ctrl_io_w16 ;virtual + mov [ctrl.ctrl_write32], ctrl_io_w32 ;virtual + ret endp align 4 proc reset_controller - xor eax, eax - mov edx, PCM_IN_CR_REG - call [ctrl.ctrl_write8] + xor eax, eax + mov edx, PCM_IN_CR_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + call [ctrl.ctrl_write8] - mov edx, MC_IN_CR_REG - call [ctrl.ctrl_write8] + mov edx, MC_IN_CR_REG + call [ctrl.ctrl_write8] - mov eax, RR - mov edx, PCM_IN_CR_REG - call [ctrl.ctrl_write8] + mov eax, RR + mov edx, PCM_IN_CR_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + call [ctrl.ctrl_write8] - mov edx, MC_IN_CR_REG - call [ctrl.ctrl_write8] - ret + mov edx, MC_IN_CR_REG + call [ctrl.ctrl_write8] + ret endp align 4 proc init_codec - locals - counter dd ? - endl + locals + counter dd ? + endl - mov esi, msgControl - call SysMsgBoardStr + mov esi, msgControl + call SysMsgBoardStr - mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] - call dword2str - call SysMsgBoardStr + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] + call dword2str + call SysMsgBoardStr - mov esi, msgStatus - call SysMsgBoardStr + mov esi, msgStatus + call SysMsgBoardStr - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] - call dword2str - call SysMsgBoardStr + call dword2str + call SysMsgBoardStr - test eax, CTRL_ST_CREADY - jnz .ready + test eax, CTRL_ST_CREADY + jnz .ready - call reset_codec - and eax, eax - jz .err + call reset_codec + and eax, eax + jz .err - xor edx, edx ;ac_reg_0 - call [ctrl.codec_write16] + xor edx, edx ;ac_reg_0 + call [ctrl.codec_write16] - xor eax, eax - mov edx, CODEC_REG_POWERDOWN - call [ctrl.codec_write16] + xor eax, eax + mov edx, CODEC_REG_POWERDOWN + call [ctrl.codec_write16] - mov [counter], 200 ; total 200*5 ms = 1s + mov [counter], 200 ; total 200*5 ms = 1s .wait: - mov edx, CODEC_REG_POWERDOWN - call [ctrl.codec_read16] - and eax, 0x0F - cmp eax, 0x0F - jz .ready + mov edx, CODEC_REG_POWERDOWN + call [ctrl.codec_read16] + and eax, 0x0F + cmp eax, 0x0F + jz .ready - mov eax, 5000 ; wait 5 ms - call StallExec - sub [counter] , 1 - jnz .wait + mov eax, 5000 ; wait 5 ms + call StallExec + sub [counter] , 1 + jnz .wait .err: - xor eax, eax ; timeout error - ret + xor eax, eax ; timeout error + ret .ready: - call detect_codec + call detect_codec - xor eax, eax - inc eax - ret + xor eax, eax + inc eax + ret endp align 4 proc reset_codec - mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] - test eax, 0x02 - jz .cold + test eax, 0x02 + jz .cold - call warm_reset - jnc .ok + call warm_reset + jnc .ok .cold: - call cold_reset - jnc .ok + call cold_reset + jnc .ok if DEBUG - mov esi, msgCFail - call SysMsgBoardStr + mov esi, msgCFail + call SysMsgBoardStr end if - xor eax, eax ; timeout error - ret + xor eax, eax ; timeout error + ret .ok: if DEBUG - mov esi, msgResetOk - call SysMsgBoardStr + mov esi, msgResetOk + call SysMsgBoardStr end if - xor eax, eax - inc eax - ret + xor eax, eax + inc eax + ret endp align 4 @@ -779,7 +779,7 @@ proc warm_reset if DEBUG mov esi, msgWarm - call SysMsgBoardStr + call SysMsgBoardStr end if mov [counter], 10 ; total 10*100 ms = 1s @@ -796,7 +796,7 @@ proc warm_reset if DEBUG mov esi, msgWRFail - call SysMsgBoardStr + call SysMsgBoardStr end if stc @@ -805,11 +805,11 @@ proc warm_reset mov edx, CTRL_STAT call [ctrl.ctrl_read32] and eax, CTRL_ST_CREADY - jz .fail - clc + jz .fail + clc ret .fail: - stc + stc ret endp @@ -825,7 +825,7 @@ proc cold_reset if DEBUG mov esi, msgCold - call SysMsgBoardStr + call SysMsgBoardStr end if mov eax, 1000000 ; wait 1 s @@ -849,7 +849,7 @@ proc cold_reset if DEBUG mov esi, msgCRFail - call SysMsgBoardStr + call SysMsgBoardStr end if stc ret @@ -857,37 +857,37 @@ proc cold_reset mov edx, CTRL_STAT call [ctrl.ctrl_read32] and eax, CTRL_ST_CREADY - jz .fail - clc + jz .fail + clc ret .fail: - stc + stc ret endp align 4 play: - mov eax, 16 - mov [ctrl.lvi_reg], eax - mov edx, PCM_OUT_LVI_REG - call [ctrl.ctrl_write8] + mov eax, 16 + mov [ctrl.lvi_reg], eax + mov edx, PCM_OUT_LVI_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - mov ax, 0x1D - call [ctrl.ctrl_write8] - xor eax, eax - ret + mov edx, PCM_OUT_CR_REG + mov ax, 0x1D + call [ctrl.ctrl_write8] + xor eax, eax + ret align 4 stop: - mov edx, PCM_OUT_CR_REG - mov ax, 0x0 - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + mov ax, 0x0 + call [ctrl.ctrl_write8] - mov ax, 0x1c - mov edx, PCM_OUT_SR_REG - call [ctrl.ctrl_write16] - xor eax, eax + mov ax, 0x1c + mov edx, PCM_OUT_SR_REG + call [ctrl.ctrl_write16] + xor eax, eax ret align 4 @@ -909,15 +909,15 @@ proc get_dev_info stdcall, p_info:dword mov [CTRL_INFO.codec_mem_base], edx mov [CTRL_INFO.ctrl_mem_base], edi - mov eax, [codec.chip_id] - mov [CTRL_INFO.codec_id], eax + mov eax, [codec.chip_id] + mov [CTRL_INFO.codec_id], eax mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] + call [ctrl.ctrl_read32] mov [CTRL_INFO.glob_cntrl], eax mov edx, CTRL_STAT - call [ctrl.ctrl_read32] + call [ctrl.ctrl_read32] mov [CTRL_INFO.glob_sta], eax mov ebx, [ctrl.pci_cmd] @@ -989,17 +989,17 @@ endp align 4 proc codec_check_ready - mov edx, CTRL_ST - call [ctrl.ctrl_read32] - and eax, CTRL_ST_CREADY - jz .not_ready + mov edx, CTRL_ST + call [ctrl.ctrl_read32] + and eax, CTRL_ST_CREADY + jz .not_ready - xor eax, wax - inc eax - ret + xor eax, wax + inc eax + ret .not_ready: - xor eax, eax - ret + xor eax, eax + ret endp align 4 @@ -1044,7 +1044,7 @@ proc StallExec rdtsc sub eax, ebx sbb edx, ecx - js @B + js @B pop eax pop ebx @@ -1059,66 +1059,66 @@ endp align 4 codec_io_r16: - add edx, [ctrl.codec_io_base] - in ax, dx - ret + add edx, [ctrl.codec_io_base] + in ax, dx + ret align 4 codec_io_w16: - add edx, [ctrl.codec_io_base] - out dx, ax - ret + add edx, [ctrl.codec_io_base] + out dx, ax + ret align 4 ctrl_io_r8: - add edx, [ctrl.ctrl_io_base] - in al, dx - ret + add edx, [ctrl.ctrl_io_base] + in al, dx + ret align 4 ctrl_io_r16: - add edx, [ctrl.ctrl_io_base] - in ax, dx - ret + add edx, [ctrl.ctrl_io_base] + in ax, dx + ret align 4 ctrl_io_r32: - add edx, [ctrl.ctrl_io_base] - in eax, dx - ret + add edx, [ctrl.ctrl_io_base] + in eax, dx + ret align 4 ctrl_io_w8: - add edx, [ctrl.ctrl_io_base] - out dx, al - ret + add edx, [ctrl.ctrl_io_base] + out dx, al + ret align 4 ctrl_io_w16: - add edx, [ctrl.ctrl_io_base] - out dx, ax - ret + add edx, [ctrl.ctrl_io_base] + out dx, ax + ret align 4 ctrl_io_w32: - add edx, [ctrl.ctrl_io_base] - out dx, eax - ret + add edx, [ctrl.ctrl_io_base] + out dx, eax + ret align 4 dword2str: - mov esi, hex_buff - mov ecx, -8 + mov esi, hex_buff + mov ecx, -8 @@: - rol eax, 4 - mov ebx, eax - and ebx, 0x0F - mov bl, [ebx+hexletters] - mov [8+esi+ecx], bl - inc ecx - jnz @B - ret + rol eax, 4 + mov ebx, eax + and ebx, 0x0F + mov bl, [ebx+hexletters] + mov [8+esi+ecx], bl + inc ecx + jnz @B + ret hexletters db '0123456789ABCDEF' hex_buff db 8 dup(0),13,10,0 @@ -1128,8 +1128,8 @@ include "codec.inc" align 4 devices dd (0x5000 shl 16)+0x1274,msgEnsoniq,set_ICH - dd (0x5880 shl 16)+0x1274,msgVibra128,set_ICH - dd 0 ;terminator + dd (0x5880 shl 16)+0x1274,msgVibra128,set_ICH + dd 0 ;terminator version dd 0x00040004 @@ -1145,12 +1145,12 @@ msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0 msgPlay db 'start play', 13,10,0 msgStop db 'stop play', 13,10,0 msgNotify db 'call notify',13,10,0 -msgIRQ db 'AC97 IRQ', 13,10,0 +msgIRQ db 'AC97 IRQ', 13,10,0 msgInitCtrl db 'init controller',13,10,0 msgInitCodec db 'init codec',13,10,0 msgPrimBuff db 'create primary buffer',13,10,0 -msgReg db 'set service handler',13,10,0 -msgOk db 'service installed',13,10,0 +msgReg db 'set service handler',13,10,0 +msgOk db 'service installed',13,10,0 msgCold db 'cold reset',13,10,0 msgWarm db 'warm reset',13,10,0 msgWRFail db 'warm reset failed',13,10,0 @@ -1165,8 +1165,8 @@ msgIRQline db 'IRQ line ',0 section '.data' data readable writable align 16 -pcmout_bdl rq 32 -buff_list rd 32 +pcmout_bdl rq 32 +buff_list rd 32 codec CODEC ctrl AC_CNTRL diff --git a/kernel/trunk/drivers/ps2mouse.asm b/kernel/trunk/drivers/ps2mouse.asm index f4bd50e4ee..920d45b83a 100644 --- a/kernel/trunk/drivers/ps2mouse.asm +++ b/kernel/trunk/drivers/ps2mouse.asm @@ -4,12 +4,12 @@ include 'proc32.inc' include 'imports.inc' struc IOCTL -{ .handle dd ? - .io_code dd ? - .input dd ? - .inp_size dd ? - .output dd ? - .out_size dd ? +{ .handle dd ? + .io_code dd ? + .input dd ? + .inp_size dd ? + .output dd ? + .out_size dd ? } virtual at 0 @@ -22,7 +22,7 @@ public version DRV_ENTRY equ 1 DRV_EXIT equ -1 -MT_3B equ 0 +MT_3B equ 0 MT_3BScroll equ 1 MT_5BScroll equ 2 @@ -33,85 +33,85 @@ section '.flat' code readable align 16 proc START stdcall, state:dword - cmp [state], DRV_ENTRY - jne .fin + cmp [state], DRV_ENTRY + jne .fin .init: - call detect_mouse - test eax,eax - jnz .exit + call detect_mouse + test eax,eax + jnz .exit - mov [MouseType],MT_3B + mov [MouseType],MT_3B - call try_mode_ID3 - test eax,eax - jnz .stop_try - mov [MouseType],MT_3BScroll - - call try_mode_ID4 - test eax,eax - jnz .stop_try - mov [MouseType],MT_5BScroll - + call try_mode_ID3 + test eax,eax + jnz .stop_try + mov [MouseType],MT_3BScroll + + call try_mode_ID4 + test eax,eax + jnz .stop_try + mov [MouseType],MT_5BScroll + .stop_try: - mov bl, 0x20 ; read command byte - call kbd_cmd - cmp ah,1 - je .exit + mov bl, 0x20 ; read command byte + call kbd_cmd + cmp ah,1 + je .exit - call kbd_read - cmp ah,1 - je .exit + call kbd_read + cmp ah,1 + je .exit - or al, 10b - push eax - mov bl, 0x60 ; write command byte - call kbd_cmd - cmp ah,1 - je .exit + or al, 10b + push eax + mov bl, 0x60 ; write command byte + call kbd_cmd + cmp ah,1 + je .exit - pop eax - call kbd_write - cmp ah,1 - je .exit + pop eax + call kbd_write + cmp ah,1 + je .exit - mov al, 0xF4 ; enable data reporting - call mouse_cmd + mov al, 0xF4 ; enable data reporting + call mouse_cmd - mov bl, 0xAE ; enable keyboard interface - call kbd_cmd - - stdcall AttachIntHandler, 12, irq_handler - stdcall RegService, my_service, service_proc - ret + mov bl, 0xAE ; enable keyboard interface + call kbd_cmd + + stdcall AttachIntHandler, 12, irq_handler, dword 0 + stdcall RegService, my_service, service_proc + ret .fin: - ;stdcall DetachIntHandler, 12, irq_handler - mov bl, 0xA7 ; disable mouse interface - call kbd_cmd - xor eax, eax - ret + ;stdcall DetachIntHandler, 12, irq_handler + mov bl, 0xA7 ; disable mouse interface + call kbd_cmd + xor eax, eax + ret .exit: - mov bl, 0xA7 ; disable mouse interface - call kbd_cmd - mov bl, 0xAE ; enable keyboard interface - call kbd_cmd - xor eax, eax - ret + mov bl, 0xA7 ; disable mouse interface + call kbd_cmd + mov bl, 0xAE ; enable keyboard interface + call kbd_cmd + xor eax, eax + ret endp proc service_proc stdcall, ioctl:dword mov edi, [ioctl] mov eax, [edi+IOCTL.io_code] test eax, eax - jz .getversion + jz .getversion cmp eax,1 - jz .gettype + jz .gettype .err: - or eax, -1 + or eax, -1 ret .ok: @@ -120,13 +120,13 @@ proc service_proc stdcall, ioctl:dword .getversion: cmp [edi+IOCTL.out_size], 4 - jb .err + jb .err mov edi, [edi+IOCTL.output] mov dword [edi], PS2_DRV_VER ; version of driver jmp .ok .gettype: cmp [edi+IOCTL.out_size], 4 - jb .err + jb .err mov edi, [edi+IOCTL.output] mov eax,[MouseType] mov dword [edi], eax ; mouse type @@ -138,95 +138,95 @@ detect_mouse: mov bl, 0xAD ; disable keyboard interface call kbd_cmd cmp ah,1 - je .fail + je .fail mov bl, 0xA8 ; enable mouse interface call kbd_cmd cmp ah,1 - je .fail + je .fail - mov al, 0xFF ; reset + mov al, 0xFF ; reset call mouse_cmd - jc .fail + jc .fail call mouse_read - jc .fail + jc .fail cmp al, 0xAA - jne .fail ; dead mouse + jne .fail ; dead mouse ; get device ID call mouse_read - jc .fail + jc .fail cmp al, 0x00 - jne .fail ; unknown device + jne .fail ; unknown device xor eax,eax ret .fail: - or eax,-1 + or eax,-1 ret try_mode_ID3: mov al, 0xF3 ;Set Sample Rate call mouse_cmd - jc .fail + jc .fail mov al, 0xC8 ;200d call mouse_cmd - jc .fail + jc .fail mov al, 0xF3 ;Set Sample Rate call mouse_cmd - jc .fail + jc .fail mov al, 0x64 ;100d call mouse_cmd - jc .fail + jc .fail mov al, 0xF3 ;Set Sample Rate call mouse_cmd - jc .fail + jc .fail mov al, 0x50 ;80d call mouse_cmd - jc .fail + jc .fail mov al, 0xF2 ;Get device id call mouse_cmd - jc .fail + jc .fail call mouse_read - jc .fail + jc .fail cmp al, 0x03 jne .fail xor eax,eax ret .fail: - or eax,-1 + or eax,-1 ret try_mode_ID4: mov al, 0xF3 ;Set Sample Rate call mouse_cmd - jc .fail + jc .fail mov al, 0xC8 ;200d call mouse_cmd - jc .fail + jc .fail mov al, 0xF3 ;Set Sample Rate call mouse_cmd - jc .fail + jc .fail mov al, 0xC8 ;100d call mouse_cmd - jc .fail + jc .fail mov al, 0xF3 ;Set Sample Rate call mouse_cmd - jc .fail + jc .fail mov al, 0x50 ;80d call mouse_cmd - jc .fail + jc .fail mov al, 0xF2 ;Get device id call mouse_cmd - jc .fail + jc .fail call mouse_read - jc .fail + jc .fail cmp al, 0x04 jne .fail @@ -234,7 +234,7 @@ try_mode_ID4: ret .fail: - or eax,-1 + or eax,-1 ret include 'ps2m_iofuncs.inc' @@ -242,12 +242,12 @@ include 'ps2m_irqh.inc' section '.data' data readable writable align 16 -version dd 0x00050005 +version dd 0x00050005 my_service db 'ps2mouse',0 ;iofuncs data -mouse_cmd_byte db 0 -mouse_nr_tries db 0 +mouse_cmd_byte db 0 +mouse_nr_tries db 0 mouse_nr_resends db 0 ;hid data @@ -259,10 +259,10 @@ third_byte db 0 fourth_byte db 0 ;main data -MouseType dd 0 +MouseType dd 0 -XMoving dd 0 -YMoving dd 0 -ZMoving dd 0 -ButtonState dd 0 +XMoving dd 0 +YMoving dd 0 +ZMoving dd 0 +ButtonState dd 0 ;timerTicks dd 0 diff --git a/kernel/trunk/drivers/sis.asm b/kernel/trunk/drivers/sis.asm index e54545fc22..76d324c8c1 100644 --- a/kernel/trunk/drivers/sis.asm +++ b/kernel/trunk/drivers/sis.asm @@ -10,26 +10,26 @@ format MS COFF include 'proc32.inc' include 'imports.inc' -API_VERSION equ 0x01000100 +API_VERSION equ 0x01000100 -DEBUG equ 1 -DEBUG_IRQ equ 0 +DEBUG equ 1 +DEBUG_IRQ equ 0 -USE_COM_IRQ equ 0 ;make irq 3 and irq 4 available for PCI devices -IRQ_REMAP equ 0 -IRQ_LINE equ 0 +USE_COM_IRQ equ 0 ;make irq 3 and irq 4 available for PCI devices +IRQ_REMAP equ 0 +IRQ_LINE equ 0 ;irq 0,1,2,8,12,13 недоступны ; FEDCBA9876543210 -VALID_IRQ equ 1100111011111000b -ATTCH_IRQ equ 0000111010100000b +VALID_IRQ equ 1100111011111000b +ATTCH_IRQ equ 0000111010100000b if USE_COM_IRQ -ATTCH_IRQ equ 0000111010111000b +ATTCH_IRQ equ 0000111010111000b end if -CPU_FREQ equ 2600d +CPU_FREQ equ 2600d BIT0 EQU 0x00000001 BIT1 EQU 0x00000002 @@ -64,199 +64,199 @@ BIT29 EQU 0x20000000 BIT30 EQU 0x40000000 BIT31 EQU 0x80000000 -VID_SIS equ 0x1039 -CTRL_SIS equ 0x7012 +VID_SIS equ 0x1039 +CTRL_SIS equ 0x7012 -PCM_OUT_BDL equ 0x10 ; PCM out buffer descriptors list -PCM_OUT_CR_REG equ 0x1b ; PCM out Control Register +PCM_OUT_BDL equ 0x10 ; PCM out buffer descriptors list +PCM_OUT_CR_REG equ 0x1b ; PCM out Control Register 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_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 -MC_IN_CR_REG equ 0x2b ; MIC in Control Register +PCM_IN_CR_REG equ 0x0b ; PCM in Control Register +MC_IN_CR_REG equ 0x2b ; MIC in Control Register RR equ BIT1 ; reset registers. Nukes all regs -CODEC_MASTER_VOL_REG equ 0x02 -CODEC_AUX_VOL equ 0x04 ; -CODEC_PCM_OUT_REG equ 0x18 ; PCM output volume -CODEC_EXT_AUDIO_REG equ 0x28 ; extended audio +CODEC_MASTER_VOL_REG equ 0x02 +CODEC_AUX_VOL equ 0x04 ; +CODEC_PCM_OUT_REG equ 0x18 ; PCM output volume +CODEC_EXT_AUDIO_REG equ 0x28 ; extended audio CODEC_EXT_AUDIO_CTRL_REG equ 0x2a ; extended audio control CODEC_PCM_FRONT_DACRATE_REG equ 0x2c ; PCM out sample rate CODEC_PCM_SURND_DACRATE_REG equ 0x2e ; surround sound sample rate CODEC_PCM_LFE_DACRATE_REG equ 0x30 ; LFE sample rate -GLOB_CTRL equ 0x2C ; Global Control -CTRL_STAT equ 0x30 ; Global Status -CTRL_CAS equ 0x34 ; Codec Access Semiphore +GLOB_CTRL equ 0x2C ; Global Control +CTRL_STAT equ 0x30 ; Global Status +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_WARM equ 0x00000004 ; AC97 Warm Reset -CTRL_CNT_COLD equ 0x00000002 ; AC97 Cold Reset -CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable +CTRL_CNT_WARM equ 0x00000004 ; AC97 Warm Reset +CTRL_CNT_COLD equ 0x00000002 ; AC97 Cold Reset +CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable CODEC_REG_POWERDOWN equ 0x26 -CODEC_REG_ST equ 0x26 +CODEC_REG_ST equ 0x26 -SRV_GETVERSION equ 0 -DEV_PLAY equ 1 -DEV_STOP equ 2 -DEV_CALLBACK equ 3 -DEV_SET_BUFF equ 4 -DEV_NOTIFY equ 5 +SRV_GETVERSION equ 0 +DEV_PLAY equ 1 +DEV_STOP equ 2 +DEV_CALLBACK equ 3 +DEV_SET_BUFF equ 4 +DEV_NOTIFY equ 5 DEV_SET_MASTERVOL equ 6 DEV_GET_MASTERVOL equ 7 -DEV_GET_INFO equ 8 +DEV_GET_INFO equ 8 struc AC_CNTRL ;AC controller base class -{ .bus dd ? - .devfn dd ? +{ .bus dd ? + .devfn dd ? - .vendor dd ? - .dev_id dd ? - .pci_cmd dd ? - .pci_stat dd ? + .vendor dd ? + .dev_id dd ? + .pci_cmd dd ? + .pci_stat dd ? .codec_io_base dd ? .codec_mem_base dd ? .ctrl_io_base dd ? .ctrl_mem_base dd ? - .cfg_reg dd ? - .int_line dd ? + .cfg_reg dd ? + .int_line dd ? - .vendor_ids dd ? ;vendor id string - .ctrl_ids dd ? ;hub id string + .vendor_ids dd ? ;vendor id string + .ctrl_ids dd ? ;hub id string - .buffer dd ? + .buffer dd ? - .notify_pos dd ? - .notify_task dd ? + .notify_pos dd ? + .notify_task dd ? - .lvi_reg dd ? - .ctrl_setup dd ? + .lvi_reg dd ? + .ctrl_setup dd ? .user_callback dd ? .codec_read16 dd ? .codec_write16 dd ? - .ctrl_read8 dd ? - .ctrl_read16 dd ? - .ctrl_read32 dd ? + .ctrl_read8 dd ? + .ctrl_read16 dd ? + .ctrl_read32 dd ? - .ctrl_write8 dd ? + .ctrl_write8 dd ? .ctrl_write16 dd ? .ctrl_write32 dd ? } struc CODEC ;Audio Chip base class { - .chip_id dd ? - .flags dd ? - .status dd ? + .chip_id dd ? + .flags dd ? + .status dd ? .ac_vendor_ids dd ? ;ac vendor id string - .chip_ids dd ? ;chip model string + .chip_ids dd ? ;chip model string - .shadow_flag dd ? - dd ? + .shadow_flag dd ? + dd ? - .regs dw ? ; codec registers + .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_mic_vol dw ? ;0x0E .reg_line_in_vol dw ? ;0x10 - .reg_cd_vol dw ? ;0x12 + .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_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_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 + 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 + 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 ? ;virual + .reset dd ? ;virual .set_master_vol dd ? } struc CTRL_INFO -{ .pci_cmd dd ? - .irq dd ? +{ .pci_cmd dd ? + .irq dd ? .glob_cntrl dd ? - .glob_sta dd ? + .glob_sta dd ? .codec_io_base dd ? .ctrl_io_base dd ? .codec_mem_base dd ? .ctrl_mem_base dd ? - .codec_id dd ? + .codec_id dd ? } struc IOCTL -{ .handle dd ? - .io_code dd ? - .input dd ? - .inp_size dd ? - .output dd ? - .out_size dd ? +{ .handle dd ? + .io_code dd ? + .input dd ? + .inp_size dd ? + .output dd ? + .out_size dd ? } virtual at 0 @@ -273,163 +273,163 @@ section '.flat' code readable align 16 proc START stdcall, state:dword - cmp [state], 1 - jne .stop + cmp [state], 1 + jne .stop if DEBUG - mov esi, msgInit - call SysMsgBoardStr + mov esi, msgInit + call SysMsgBoardStr end if - call detect_controller - test eax, eax - jz .fail + call detect_controller + test eax, eax + jz .fail if DEBUG - mov esi,[ctrl.vendor_ids] - call SysMsgBoardStr - mov esi, [ctrl.ctrl_ids] - call SysMsgBoardStr + mov esi,[ctrl.vendor_ids] + call SysMsgBoardStr + mov esi, [ctrl.ctrl_ids] + call SysMsgBoardStr end if - call init_controller - test eax, eax - jz .fail + call init_controller + test eax, eax + jz .fail call init_codec - test eax, eax - jz .fail + test eax, eax + jz .fail - call reset_controller - call setup_codec + call reset_controller + call setup_codec - mov esi, msgPrimBuff - call SysMsgBoardStr - call create_primary_buff - mov esi, msgDone - call SysMsgBoardStr + mov esi, msgPrimBuff + call SysMsgBoardStr + call create_primary_buff + mov esi, msgDone + call SysMsgBoardStr if IRQ_REMAP - pushf - cli + pushf + cli - mov ebx, [ctrl.int_line] - in al, 0xA1 - mov ah, al - in al, 0x21 - test ebx, ebx - jz .skip - bts ax, bx ;mask old line + mov ebx, [ctrl.int_line] + in al, 0xA1 + mov ah, al + in al, 0x21 + test ebx, ebx + jz .skip + bts ax, bx ;mask old line .skip - bts ax, IRQ_LINE ;mask new ine - out 0x21, al - mov al, ah - out 0xA1, al - ;remap IRQ - stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE + bts ax, IRQ_LINE ;mask new ine + out 0x21, al + mov al, ah + out 0xA1, al + ;remap IRQ + stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE - mov dx, 0x4d0 ;8259 ELCR1 - in al, dx - bts ax, IRQ_LINE - out dx, al ;set level-triggered mode - mov [ctrl.int_line], IRQ_LINE - popf - mov esi, msgRemap - call SysMsgBoardStr + mov dx, 0x4d0 ;8259 ELCR1 + in al, dx + bts ax, IRQ_LINE + out dx, al ;set level-triggered mode + mov [ctrl.int_line], IRQ_LINE + popf + mov esi, msgRemap + call SysMsgBoardStr end if - mov eax, VALID_IRQ - mov ebx, [ctrl.int_line] - mov esi, msgInvIRQ - bt eax, ebx - jnc .fail_msg - mov eax, ATTCH_IRQ - mov esi, msgAttchIRQ - bt eax, ebx - jnc .fail_msg + mov eax, VALID_IRQ + mov ebx, [ctrl.int_line] + mov esi, msgInvIRQ + bt eax, ebx + jnc .fail_msg + mov eax, ATTCH_IRQ + mov esi, msgAttchIRQ + bt eax, ebx + jnc .fail_msg - stdcall AttachIntHandler, ebx, ac97_irq + stdcall AttachIntHandler, ebx, ac97_irq, dword 0 .reg: - stdcall RegService, sz_sound_srv, service_proc - ret + stdcall RegService, sz_sound_srv, service_proc + ret .fail: if DEBUG - mov esi, msgFail - call SysMsgBoardStr + mov esi, msgFail + call SysMsgBoardStr end if - xor eax, eax - ret + xor eax, eax + ret .fail_msg: - call SysMsgBoardStr - xor eax, eax - ret + call SysMsgBoardStr + xor eax, eax + ret .stop: - call stop - xor eax, eax - ret + call stop + xor eax, eax + ret endp -handle equ IOCTL.handle -io_code equ IOCTL.io_code -input equ IOCTL.input -inp_size equ IOCTL.inp_size -output equ IOCTL.output -out_size equ IOCTL.out_size +handle equ IOCTL.handle +io_code equ IOCTL.io_code +input equ IOCTL.input +inp_size equ IOCTL.inp_size +output equ IOCTL.output +out_size equ IOCTL.out_size align 4 proc service_proc stdcall, ioctl:dword - mov edi, [ioctl] - mov eax, [edi+io_code] + mov edi, [ioctl] + mov eax, [edi+io_code] - cmp eax, SRV_GETVERSION - jne @F + cmp eax, SRV_GETVERSION + jne @F - mov eax, [edi+output] - cmp [edi+out_size], 4 - jne .fail + mov eax, [edi+output] + cmp [edi+out_size], 4 + jne .fail - mov [eax], dword API_VERSION - xor eax, eax - ret + mov [eax], dword API_VERSION + xor eax, eax + ret @@: - cmp eax, DEV_PLAY - jne @F + cmp eax, DEV_PLAY + jne @F if DEBUG - mov esi, msgPlay - call SysMsgBoardStr + mov esi, msgPlay + call SysMsgBoardStr end if - call play - ret + call play + ret @@: - cmp eax, DEV_STOP - jne @F + cmp eax, DEV_STOP + jne @F if DEBUG - mov esi, msgStop - call SysMsgBoardStr + mov esi, msgStop + call SysMsgBoardStr end if - call stop - ret + call stop + ret @@: - cmp eax, DEV_CALLBACK - jne @F - mov ebx, [edi+input] - stdcall set_callback, [ebx] - ret + cmp eax, DEV_CALLBACK + jne @F + mov ebx, [edi+input] + stdcall set_callback, [ebx] + ret @@: - cmp eax, DEV_SET_MASTERVOL - jne @F - mov eax, [edi+input] - mov eax, [eax] - call set_master_vol ;eax= vol - ret + cmp eax, DEV_SET_MASTERVOL + jne @F + mov eax, [edi+input] + mov eax, [eax] + call set_master_vol ;eax= vol + ret @@: - cmp eax, DEV_GET_MASTERVOL - jne @F - mov ebx, [edi+output] - stdcall get_master_vol, ebx - ret + cmp eax, DEV_GET_MASTERVOL + jne @F + mov ebx, [edi+output] + stdcall get_master_vol, ebx + ret ;@@: ; cmp eax, DEV_GET_INFO ; jne @F @@ -438,8 +438,8 @@ proc service_proc stdcall, ioctl:dword ; ret @@: .fail: - or eax, -1 - ret + or eax, -1 + ret endp restore handle @@ -453,724 +453,724 @@ align 4 proc ac97_irq if DEBUG_IRQ - mov esi, msgIRQ - call SysMsgBoardStr + mov esi, msgIRQ + call SysMsgBoardStr end if - mov edx, PCM_OUT_CR_REG - mov al, 0x10 - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + mov al, 0x10 + call [ctrl.ctrl_write8] - mov ax, 0x1c - mov edx, PCM_OUT_SR_REG - call [ctrl.ctrl_write16] + mov ax, 0x1c + mov edx, PCM_OUT_SR_REG + call [ctrl.ctrl_write16] - mov edx, PCM_OUT_CIV_REG - call [ctrl.ctrl_read8] + mov edx, PCM_OUT_CIV_REG + call [ctrl.ctrl_read8] - and eax, 0x1F - cmp eax, [civ_val] - je .skip + and eax, 0x1F + cmp eax, [civ_val] + je .skip - mov [civ_val], eax - dec eax - and eax, 0x1F - mov [ctrl.lvi_reg], eax + mov [civ_val], eax + dec eax + and eax, 0x1F + mov [ctrl.lvi_reg], eax - mov edx, PCM_OUT_LVI_REG - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_LVI_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - mov ax, 0x11 - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + mov ax, 0x11 + call [ctrl.ctrl_write8] - mov eax, [civ_val] - add eax, 1 - and eax, 31 - mov ebx, dword [buff_list+eax*4] + mov eax, [civ_val] + add eax, 1 + and eax, 31 + mov ebx, dword [buff_list+eax*4] - cmp [ctrl.user_callback], 0 - je @f + cmp [ctrl.user_callback], 0 + je @f - stdcall [ctrl.user_callback], ebx + stdcall [ctrl.user_callback], ebx @@: - ret + ret .skip: - mov edx, PCM_OUT_CR_REG - mov ax, 0x11 - call [ctrl.ctrl_write8] - ret + mov edx, PCM_OUT_CR_REG + mov ax, 0x11 + call [ctrl.ctrl_write8] + ret endp align 4 proc create_primary_buff - stdcall KernelAlloc, 0x10000 - mov [ctrl.buffer], eax + stdcall KernelAlloc, 0x10000 + mov [ctrl.buffer], eax - mov edi, eax - mov ecx, 0x10000/4 - xor eax, eax - cld - rep stosd + mov edi, eax + mov ecx, 0x10000/4 + xor eax, eax + cld + rep stosd - mov eax, [ctrl.buffer] - call GetPgAddr + mov eax, [ctrl.buffer] + call GetPgAddr - mov ebx, 0xC0004000 - mov ecx, 4 - mov edi, pcmout_bdl + mov ebx, 0xC0004000 + mov ecx, 4 + mov edi, pcmout_bdl @@: - mov [edi], eax - mov [edi+4], ebx + mov [edi], eax + mov [edi+4], ebx - mov [edi+32], eax - mov [edi+4+32], ebx + mov [edi+32], eax + mov [edi+4+32], ebx - mov [edi+64], eax - mov [edi+4+64], ebx + mov [edi+64], eax + mov [edi+4+64], ebx - mov [edi+96], eax - mov [edi+4+96], ebx + mov [edi+96], eax + mov [edi+4+96], ebx - mov [edi+128], eax - mov [edi+4+128], ebx + mov [edi+128], eax + mov [edi+4+128], ebx - mov [edi+160], eax - mov [edi+4+160], ebx + mov [edi+160], eax + mov [edi+4+160], ebx - mov [edi+192], eax - mov [edi+4+192], ebx + mov [edi+192], eax + mov [edi+4+192], ebx - mov [edi+224], eax - mov [edi+4+224], ebx + mov [edi+224], eax + mov [edi+4+224], ebx - add eax, 0x4000 - add edi, 8 - loop @B + add eax, 0x4000 + add edi, 8 + loop @B - mov edi, buff_list - mov eax, [ctrl.buffer] - mov ecx, 4 + mov edi, buff_list + mov eax, [ctrl.buffer] + mov ecx, 4 @@: - mov [edi], eax - mov [edi+16], eax - mov [edi+32], eax - mov [edi+48], eax - mov [edi+64], eax - mov [edi+80], eax - mov [edi+96], eax - mov [edi+112], eax + mov [edi], eax + mov [edi+16], eax + mov [edi+32], eax + mov [edi+48], eax + mov [edi+64], eax + mov [edi+80], eax + mov [edi+96], eax + mov [edi+112], eax - add eax, 0x4000 - add edi, 4 - loop @B + add eax, 0x4000 + add edi, 4 + loop @B - mov eax, pcmout_bdl - mov ebx, eax - call GetPgAddr ;eax - and ebx, 0xFFF - add eax, ebx + mov eax, pcmout_bdl + mov ebx, eax + call GetPgAddr ;eax + and ebx, 0xFFF + add eax, ebx - mov edx, PCM_OUT_BDL - call [ctrl.ctrl_write32] + mov edx, PCM_OUT_BDL + call [ctrl.ctrl_write32] - mov eax, 16 - mov [ctrl.lvi_reg], eax - mov edx, PCM_OUT_LVI_REG - call [ctrl.ctrl_write8] + mov eax, 16 + mov [ctrl.lvi_reg], eax + mov edx, PCM_OUT_LVI_REG + call [ctrl.ctrl_write8] - mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] - and eax, not 0x000000C0 - mov edx, GLOB_CTRL - call [ctrl.ctrl_write32] + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] + and eax, not 0x000000C0 + mov edx, GLOB_CTRL + call [ctrl.ctrl_write32] ret endp align 4 proc detect_controller - locals - last_bus dd ? - bus dd ? - devfn dd ? - endl + locals + last_bus dd ? + bus dd ? + devfn dd ? + endl - xor eax, eax - mov [bus], eax - inc eax - call PciApi - cmp eax, -1 - je .err + xor eax, eax + mov [bus], eax + inc eax + call PciApi + cmp eax, -1 + je .err - mov [last_bus], eax + mov [last_bus], eax .next_bus: - and [devfn], 0 + and [devfn], 0 .next_dev: - stdcall PciRead32, [bus], [devfn], dword 0 - test eax, eax - jz .next - cmp eax, -1 - je .next + stdcall PciRead32, [bus], [devfn], dword 0 + test eax, eax + jz .next + cmp eax, -1 + je .next - mov edi, devices + mov edi, devices @@: - mov ebx, [edi] - test ebx, ebx - jz .next + mov ebx, [edi] + test ebx, ebx + jz .next - cmp eax, ebx - je .found - add edi, 12 - jmp @B + cmp eax, ebx + je .found + add edi, 12 + jmp @B .next: - inc [devfn] - cmp [devfn], 256 - jb .next_dev - mov eax, [bus] - inc eax - mov [bus], eax - cmp eax, [last_bus] - jna .next_bus - xor eax, eax - ret + inc [devfn] + cmp [devfn], 256 + jb .next_dev + mov eax, [bus] + inc eax + mov [bus], eax + cmp eax, [last_bus] + jna .next_bus + xor eax, eax + ret .found: - mov ebx, [bus] - mov [ctrl.bus], ebx + mov ebx, [bus] + mov [ctrl.bus], ebx - mov ecx, [devfn] - mov [ctrl.devfn], ecx + mov ecx, [devfn] + mov [ctrl.devfn], ecx - mov edx, eax - and edx, 0xFFFF - mov [ctrl.vendor], edx - shr eax, 16 - mov [ctrl.dev_id], eax + mov edx, eax + and edx, 0xFFFF + mov [ctrl.vendor], edx + shr eax, 16 + mov [ctrl.dev_id], eax - mov ebx, [edi+4] - mov [ctrl.ctrl_ids], ebx - mov [ctrl.vendor_ids], msg_SIS + mov ebx, [edi+4] + mov [ctrl.ctrl_ids], ebx + mov [ctrl.vendor_ids], msg_SIS - mov esi, [edi+8] - mov [ctrl.ctrl_setup], esi - ret + mov esi, [edi+8] + mov [ctrl.ctrl_setup], esi + ret .err: - xor eax, eax - ret + xor eax, eax + ret endp align 4 proc init_controller - 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 4 + mov ebx, eax + and eax, 0xFFFF + mov [ctrl.pci_cmd], eax + shr ebx, 16 + mov [ctrl.pci_stat], ebx - mov esi, msgPciCmd - call SysMsgBoardStr - call dword2str - call SysMsgBoardStr + mov esi, msgPciCmd + call SysMsgBoardStr + call dword2str + call SysMsgBoardStr - mov esi, msgPciStat - call SysMsgBoardStr - mov eax, [ctrl.pci_stat] - call dword2str - call SysMsgBoardStr + mov esi, msgPciStat + call SysMsgBoardStr + mov eax, [ctrl.pci_stat] + call dword2str + call SysMsgBoardStr - mov esi, msgMixIsaIo - call SysMsgBoardStr + mov esi, msgMixIsaIo + call SysMsgBoardStr - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 + stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 - call dword2str - call SysMsgBoardStr + call dword2str + call SysMsgBoardStr - and eax,0xFFFE - mov [ctrl.codec_io_base], eax + and eax,0xFFFE + mov [ctrl.codec_io_base], eax - mov esi, msgCtrlIsaIo - call SysMsgBoardStr + mov esi, msgCtrlIsaIo + call SysMsgBoardStr - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14 + stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14 - call dword2str - call SysMsgBoardStr + call dword2str + call SysMsgBoardStr - and eax, 0xFFC0 - mov [ctrl.ctrl_io_base], eax + and eax, 0xFFC0 + mov [ctrl.ctrl_io_base], eax - mov esi, msgMixMMIo - call SysMsgBoardStr + mov esi, msgMixMMIo + call SysMsgBoardStr - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18 - mov [ctrl.codec_mem_base], eax + stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18 + mov [ctrl.codec_mem_base], eax - call dword2str - call SysMsgBoardStr + call dword2str + call SysMsgBoardStr - mov esi, msgCtrlMMIo - call SysMsgBoardStr + mov esi, msgCtrlMMIo + call SysMsgBoardStr - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C - mov [ctrl.ctrl_mem_base], eax + stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C + mov [ctrl.ctrl_mem_base], eax - call dword2str - call SysMsgBoardStr + call dword2str + call SysMsgBoardStr .default: - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C - and eax, 0xFF + stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C + and eax, 0xFF @@: - mov [ctrl.int_line], eax + mov [ctrl.int_line], eax - stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41 - and eax, 0xFF - mov [ctrl.cfg_reg], eax + stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41 + and eax, 0xFF + mov [ctrl.cfg_reg], eax - call [ctrl.ctrl_setup] - xor eax, eax - inc eax - ret + call [ctrl.ctrl_setup] + xor eax, eax + inc eax + ret endp align 4 proc set_SIS - mov [ctrl.codec_read16], codec_io_r16 ;virtual - mov [ctrl.codec_write16], codec_io_w16 ;virtual + mov [ctrl.codec_read16], codec_io_r16 ;virtual + mov [ctrl.codec_write16], codec_io_w16 ;virtual - mov [ctrl.ctrl_read8 ], ctrl_io_r8 ;virtual - mov [ctrl.ctrl_read16], ctrl_io_r16 ;virtual - mov [ctrl.ctrl_read32], ctrl_io_r32 ;virtual + mov [ctrl.ctrl_read8 ], ctrl_io_r8 ;virtual + mov [ctrl.ctrl_read16], ctrl_io_r16 ;virtual + mov [ctrl.ctrl_read32], ctrl_io_r32 ;virtual - mov [ctrl.ctrl_write8 ], ctrl_io_w8 ;virtual - mov [ctrl.ctrl_write16], ctrl_io_w16 ;virtual - mov [ctrl.ctrl_write32], ctrl_io_w32 ;virtual - ret + mov [ctrl.ctrl_write8 ], ctrl_io_w8 ;virtual + mov [ctrl.ctrl_write16], ctrl_io_w16 ;virtual + mov [ctrl.ctrl_write32], ctrl_io_w32 ;virtual + ret endp align 4 proc reset_controller - xor eax, eax - mov edx, PCM_IN_CR_REG - call [ctrl.ctrl_write8] + xor eax, eax + mov edx, PCM_IN_CR_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + call [ctrl.ctrl_write8] - mov edx, MC_IN_CR_REG - call [ctrl.ctrl_write8] + mov edx, MC_IN_CR_REG + call [ctrl.ctrl_write8] - mov eax, RR - mov edx, PCM_IN_CR_REG - call [ctrl.ctrl_write8] + mov eax, RR + mov edx, PCM_IN_CR_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + call [ctrl.ctrl_write8] - mov edx, MC_IN_CR_REG - call [ctrl.ctrl_write8] - ret + mov edx, MC_IN_CR_REG + call [ctrl.ctrl_write8] + ret endp align 4 proc init_codec - locals - counter dd ? - endl + locals + counter dd ? + endl - mov esi, msgControl - call SysMsgBoardStr + mov esi, msgControl + call SysMsgBoardStr - mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] - call dword2str - call SysMsgBoardStr + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] + call dword2str + call SysMsgBoardStr - mov esi, msgStatus - call SysMsgBoardStr + mov esi, msgStatus + call SysMsgBoardStr - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - push eax - call dword2str - call SysMsgBoardStr - pop eax - cmp eax, 0xFFFFFFFF - je .err + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + push eax + call dword2str + call SysMsgBoardStr + pop eax + cmp eax, 0xFFFFFFFF + je .err - test eax, CTRL_ST_CREADY - jnz .done ;;;;;.ready + test eax, CTRL_ST_CREADY + jnz .done ;;;;;.ready - call reset_codec - test eax, eax - jz .err + call reset_codec + test eax, eax + jz .err .ready: - xor edx, edx ;ac_reg_0 - call [ctrl.codec_write16] + xor edx, edx ;ac_reg_0 + call [ctrl.codec_write16] - xor eax, eax - mov edx, CODEC_REG_POWERDOWN - call [ctrl.codec_write16] + xor eax, eax + mov edx, CODEC_REG_POWERDOWN + call [ctrl.codec_write16] - mov [counter], 200 ; total 200*5 ms = 1s + mov [counter], 200 ; total 200*5 ms = 1s .wait: - mov eax, 5000 ; wait 5 ms - call StallExec + mov eax, 5000 ; wait 5 ms + call StallExec - mov edx, CODEC_REG_POWERDOWN - call [ctrl.codec_read16] - and eax, 0x0F - cmp eax, 0x0F - je .done + mov edx, CODEC_REG_POWERDOWN + call [ctrl.codec_read16] + and eax, 0x0F + cmp eax, 0x0F + je .done - sub [counter] , 1 - jnz .wait + sub [counter] , 1 + jnz .wait .err: - xor eax, eax ; timeout error - ret + xor eax, eax ; timeout error + ret .done: - mov eax, 2 ;force set 16-bit 2-channel PCM - mov edx, GLOB_CTRL - call [ctrl.ctrl_write32] - mov eax, 5000 ; wait 5 ms - call StallExec + mov eax, 2 ;force set 16-bit 2-channel PCM + mov edx, GLOB_CTRL + call [ctrl.ctrl_write32] + mov eax, 5000 ; wait 5 ms + call StallExec - call detect_codec + call detect_codec - xor eax, eax - inc eax - ret + xor eax, eax + inc eax + ret endp align 4 proc reset_codec - mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] - test eax, 0x02 - jz .cold + test eax, 0x02 + jz .cold - call warm_reset - jnc .ok + call warm_reset + jnc .ok .cold: - call cold_reset - jnc .ok + call cold_reset + jnc .ok if DEBUG - mov esi, msgCFail - call SysMsgBoardStr + mov esi, msgCFail + call SysMsgBoardStr end if - xor eax, eax ; timeout error - ret + xor eax, eax ; timeout error + ret .ok: - xor eax, eax - inc eax - ret + xor eax, eax + inc eax + ret endp align 4 proc warm_reset - locals - counter dd ? - endl + locals + counter dd ? + endl - mov eax, 0x06 - mov edx, GLOB_CTRL - call [ctrl.ctrl_write32] + mov eax, 0x06 + mov edx, GLOB_CTRL + call [ctrl.ctrl_write32] if DEBUG - mov esi, msgWarm - call SysMsgBoardStr + mov esi, msgWarm + call SysMsgBoardStr end if - mov [counter], 10 ; total 10*100 ms = 1s + mov [counter], 10 ; total 10*100 ms = 1s .wait: - mov eax, 100000 ; wait 100 ms - call StallExec + mov eax, 100000 ; wait 100 ms + call StallExec - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - test eax, CTRL_ST_CREADY - jnz .ok + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + test eax, CTRL_ST_CREADY + jnz .ok - dec [counter] - jnz .wait + dec [counter] + jnz .wait if DEBUG - mov esi, msgWRFail - call SysMsgBoardStr + mov esi, msgWRFail + call SysMsgBoardStr end if .fail: - stc - ret + stc + ret .ok: - clc - ret + clc + ret endp align 4 proc cold_reset - locals - counter dd ? - endl + locals + counter dd ? + endl - mov eax, 0x02 - mov edx, GLOB_CTRL - call [ctrl.ctrl_write32] + mov eax, 0x02 + mov edx, GLOB_CTRL + call [ctrl.ctrl_write32] if DEBUG - mov esi, msgCold - call SysMsgBoardStr + mov esi, msgCold + call SysMsgBoardStr end if - mov eax, 400000 ; wait 400 ms - call StallExec + mov eax, 400000 ; wait 400 ms + call StallExec - mov [counter], 16 ; total 20*100 ms = 2s + mov [counter], 16 ; total 20*100 ms = 2s .wait: - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - test eax, CTRL_ST_CREADY - jnz .ok + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + test eax, CTRL_ST_CREADY + jnz .ok - mov eax, 100000 ; wait 100 ms - call StallExec + mov eax, 100000 ; wait 100 ms + call StallExec - dec [counter] - jnz .wait + dec [counter] + jnz .wait if DEBUG - mov esi, msgCRFail - call SysMsgBoardStr + mov esi, msgCRFail + call SysMsgBoardStr end if .fail: - stc - ret + stc + ret .ok: - mov esi, msgControl - call SysMsgBoardStr + mov esi, msgControl + call SysMsgBoardStr - mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] - call dword2str - call SysMsgBoardStr + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] + call dword2str + call SysMsgBoardStr - mov esi, msgStatus - call SysMsgBoardStr + mov esi, msgStatus + call SysMsgBoardStr - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - push eax - call dword2str - call SysMsgBoardStr - pop eax + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + push eax + call dword2str + call SysMsgBoardStr + pop eax - test eax, CTRL_ST_CREADY - jz .fail - clc - ret + test eax, CTRL_ST_CREADY + jz .fail + clc + ret endp align 4 play: - xor eax, eax - mov [civ_val], eax - mov edx, PCM_OUT_CIV_REG - call [ctrl.ctrl_write8] + xor eax, eax + mov [civ_val], eax + mov edx, PCM_OUT_CIV_REG + call [ctrl.ctrl_write8] - mov eax, 16 - mov [ctrl.lvi_reg], eax - mov edx, PCM_OUT_LVI_REG - call [ctrl.ctrl_write8] + mov eax, 16 + mov [ctrl.lvi_reg], eax + mov edx, PCM_OUT_LVI_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - mov ax, 0x1D - call [ctrl.ctrl_write8] - xor eax, eax - ret + mov edx, PCM_OUT_CR_REG + mov ax, 0x1D + call [ctrl.ctrl_write8] + xor eax, eax + ret align 4 stop: - mov edx, PCM_OUT_CR_REG - mov ax, 0x0 - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + mov ax, 0x0 + call [ctrl.ctrl_write8] - mov ax, 0x1c - mov edx, PCM_OUT_SR_REG - call [ctrl.ctrl_write16] - xor eax, eax - ret + mov ax, 0x1c + mov edx, PCM_OUT_SR_REG + call [ctrl.ctrl_write16] + xor eax, eax + ret align 4 proc get_dev_info stdcall, p_info:dword - virtual at esi - CTRL_INFO CTRL_INFO - end virtual + virtual at esi + CTRL_INFO CTRL_INFO + end virtual - mov esi, [p_info] - mov eax, [ctrl.int_line] - mov ebx, [ctrl.codec_io_base] - mov ecx, [ctrl.ctrl_io_base] - mov edx, [ctrl.codec_mem_base] - mov edi, [ctrl.ctrl_mem_base] + mov esi, [p_info] + mov eax, [ctrl.int_line] + mov ebx, [ctrl.codec_io_base] + mov ecx, [ctrl.ctrl_io_base] + mov edx, [ctrl.codec_mem_base] + mov edi, [ctrl.ctrl_mem_base] - mov [CTRL_INFO.irq], eax - mov [CTRL_INFO.codec_io_base], ebx - mov [CTRL_INFO.ctrl_io_base], ecx - mov [CTRL_INFO.codec_mem_base], edx - mov [CTRL_INFO.ctrl_mem_base], edi + mov [CTRL_INFO.irq], eax + mov [CTRL_INFO.codec_io_base], ebx + mov [CTRL_INFO.ctrl_io_base], ecx + mov [CTRL_INFO.codec_mem_base], edx + mov [CTRL_INFO.ctrl_mem_base], edi - mov eax, [codec.chip_id] - mov [CTRL_INFO.codec_id], eax + mov eax, [codec.chip_id] + mov [CTRL_INFO.codec_id], eax - mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] - mov [CTRL_INFO.glob_cntrl], eax + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] + mov [CTRL_INFO.glob_cntrl], eax - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - mov [CTRL_INFO.glob_sta], eax + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + mov [CTRL_INFO.glob_sta], eax - mov ebx, [ctrl.pci_cmd] - mov [CTRL_INFO.pci_cmd], ebx - ret + mov ebx, [ctrl.pci_cmd] + mov [CTRL_INFO.pci_cmd], ebx + ret endp align 4 proc set_callback stdcall, handler:dword - mov eax, [handler] - mov [ctrl.user_callback], eax - ret + mov eax, [handler] + mov [ctrl.user_callback], eax + ret endp align 4 proc codec_read stdcall, ac_reg:dword ; reg = edx, reval = eax - mov edx, [ac_reg] + mov edx, [ac_reg] - mov ebx, edx - shr ebx, 1 - bt [codec.shadow_flag], ebx - jc .use_shadow + mov ebx, edx + shr ebx, 1 + bt [codec.shadow_flag], ebx + jc .use_shadow - call [ctrl.codec_read16] ;change edx !!! - mov ecx, eax + call [ctrl.codec_read16] ;change edx !!! + mov ecx, eax - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - test eax, CTRL_ST_RCS - jz .read_ok + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + test eax, CTRL_ST_RCS + jz .read_ok - mov edx, CTRL_STAT - call [ctrl.ctrl_write32] - xor eax,eax - not eax ;timeout - ret + mov edx, CTRL_STAT + call [ctrl.ctrl_write32] + xor eax,eax + not eax ;timeout + ret .read_ok: - mov edx, [ac_reg] - mov [codec.regs+edx], cx - bts [codec.shadow_flag], ebx - mov eax, ecx - ret + mov edx, [ac_reg] + mov [codec.regs+edx], cx + bts [codec.shadow_flag], ebx + mov eax, ecx + ret .use_shadow: - movzx eax, word [codec.regs+edx] - ret + movzx eax, word [codec.regs+edx] + ret endp align 4 proc codec_write stdcall, ac_reg:dword - push eax - call check_semafore - and eax, eax - jz .err - pop eax + push eax + call check_semafore + and eax, eax + jz .err + pop eax - mov esi, [ac_reg] - mov edx, esi - call [ctrl.codec_write16] - mov [codec.regs+esi], ax - shr esi, 1 - bts [codec.shadow_flag], esi - ret + mov esi, [ac_reg] + mov edx, esi + call [ctrl.codec_write16] + mov [codec.regs+esi], ax + shr esi, 1 + bts [codec.shadow_flag], esi + ret .err: - pop eax - ret + pop eax + ret endp align 4 proc codec_check_ready - mov edx, CTRL_ST - call [ctrl.ctrl_read32] - and eax, CTRL_ST_CREADY - jz .not_ready + mov edx, CTRL_ST + call [ctrl.ctrl_read32] + and eax, CTRL_ST_CREADY + jz .not_ready - xor eax, wax - inc eax - ret + xor eax, wax + inc eax + ret .not_ready: - xor eax, eax - ret + xor eax, eax + ret endp align 4 proc check_semafore - local counter:DWORD + local counter:DWORD - mov [counter], 100 + mov [counter], 100 .l1: - mov edx, CTRL_CAS - call [ctrl.ctrl_read8] - and eax, CAS_FLAG - jz .ok + mov edx, CTRL_CAS + call [ctrl.ctrl_read8] + and eax, CAS_FLAG + jz .ok - mov eax, 1 - call StallExec - sub [counter], 1 - jnz .l1 - xor eax, eax - ret + mov eax, 1 + call StallExec + sub [counter], 1 + jnz .l1 + xor eax, eax + ret align 4 .ok: - xor eax,eax - inc eax - ret + xor eax,eax + inc eax + ret endp align 4 proc StallExec - push ecx - push edx - push ebx - push eax + push ecx + push edx + push ebx + push eax - mov ecx, CPU_FREQ - mul ecx - mov ebx, eax ;low - mov ecx, edx ;high - rdtsc - add ebx, eax - adc ecx, edx + mov ecx, CPU_FREQ + mul ecx + mov ebx, eax ;low + mov ecx, edx ;high + rdtsc + add ebx, eax + adc ecx, edx @@: - rdtsc - sub eax, ebx - sbb edx, ecx - js @B + rdtsc + sub eax, ebx + sbb edx, ecx + js @B - pop eax - pop ebx - pop edx - pop ecx - ret + pop eax + pop ebx + pop edx + pop ecx + ret endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1179,58 +1179,58 @@ endp align 4 proc codec_io_r16 - add edx, [ctrl.codec_io_base] - in ax, dx - ret + add edx, [ctrl.codec_io_base] + in ax, dx + ret endp align 4 proc codec_io_w16 - add edx, [ctrl.codec_io_base] - out dx, ax - ret + add edx, [ctrl.codec_io_base] + out dx, ax + ret endp align 4 proc ctrl_io_r8 - add edx, [ctrl.ctrl_io_base] - in al, dx - ret + add edx, [ctrl.ctrl_io_base] + in al, dx + ret endp align 4 proc ctrl_io_r16 - add edx, [ctrl.ctrl_io_base] - in ax, dx - ret + add edx, [ctrl.ctrl_io_base] + in ax, dx + ret endp align 4 proc ctrl_io_r32 - add edx, [ctrl.ctrl_io_base] - in eax, dx - ret + add edx, [ctrl.ctrl_io_base] + in eax, dx + ret endp align 4 proc ctrl_io_w8 - add edx, [ctrl.ctrl_io_base] - out dx, al - ret + add edx, [ctrl.ctrl_io_base] + out dx, al + ret endp align 4 proc ctrl_io_w16 - add edx, [ctrl.ctrl_io_base] - out dx, ax - ret + add edx, [ctrl.ctrl_io_base] + out dx, ax + ret endp align 4 proc ctrl_io_w32 - add edx, [ctrl.ctrl_io_base] - out dx, eax - ret + add edx, [ctrl.ctrl_io_base] + out dx, eax + ret endp align 4 @@ -1254,11 +1254,11 @@ include "codec.inc" align 4 devices dd (CTRL_SIS shl 16)+VID_SIS,msg_AC, set_SIS - dd 0 + dd 0 version dd (5 shl 16) or (API_VERSION and 0xFFFF) -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 sz_sound_srv db 'SOUND',0 @@ -1270,14 +1270,14 @@ msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0 msgPlay db 'start play', 13,10,0 msgStop db 'stop play', 13,10,0 ;msgNotify db 'call notify',13,10,0 -msgIRQ db 'AC97 IRQ', 13,10,0 +msgIRQ db 'AC97 IRQ', 13,10,0 msgInitCtrl db 'init controller',13,10,0 ;msgInitCodec db 'init codec',13,10,0 msgPrimBuff db 'create primary buffer ...',0 msgDone db 'done',13,10,0 msgRemap db 'Remap IRQ',13,10,0 ;msgReg db 'set service handler',13,10,0 -msgOk db 'service installed',13,10,0 +msgOk db 'service installed',13,10,0 msgCold db 'cold reset',13,10,0 msgWarm db 'warm reset',13,10,0 msgWRFail db 'warm reset failed',13,10,0 @@ -1296,8 +1296,8 @@ msgIrqMap db 'AC97 irq map as ',0 section '.data' data readable writable align 16 -pcmout_bdl rq 32 -buff_list rd 32 +pcmout_bdl rq 32 +buff_list rd 32 codec CODEC ctrl AC_CNTRL diff --git a/kernel/trunk/drivers/sound.asm b/kernel/trunk/drivers/sound.asm index 2248cf4262..34bb79ec17 100644 --- a/kernel/trunk/drivers/sound.asm +++ b/kernel/trunk/drivers/sound.asm @@ -11,26 +11,26 @@ format MS COFF include 'proc32.inc' include 'imports.inc' -API_VERSION equ 0x01000100 +API_VERSION equ 0x01000100 -DEBUG equ 1 -DEBUG_IRQ equ 0 +DEBUG equ 1 +DEBUG_IRQ equ 0 -USE_COM_IRQ equ 0 ;make irq 3 and irq 4 available for PCI devices -IRQ_REMAP equ 0 -IRQ_LINE equ 0 +USE_COM_IRQ equ 0 ;make irq 3 and irq 4 available for PCI devices +IRQ_REMAP equ 0 +IRQ_LINE equ 0 ;irq 0,1,2,8,12,13 недоступны ; FEDCBA9876543210 -VALID_IRQ equ 1100111011111000b -ATTCH_IRQ equ 0000111010100000b +VALID_IRQ equ 1100111011111000b +ATTCH_IRQ equ 0000111010100000b if USE_COM_IRQ -ATTCH_IRQ equ 0000111010111000b +ATTCH_IRQ equ 0000111010111000b end if -CPU_FREQ equ 2600d +CPU_FREQ equ 2600d BIT0 EQU 0x00000001 BIT1 EQU 0x00000002 @@ -68,225 +68,225 @@ BIT31 EQU 0x80000000 PCM_4 equ BIT20 PCM_6 equ BIT21 -VID_INTEL equ 0x8086 -VID_NVIDIA equ 0x10DE +VID_INTEL equ 0x8086 +VID_NVIDIA equ 0x10DE -CTRL_ICH equ 0x2415 -CTRL_ICH0 equ 0x2425 -CTRL_ICH2 equ 0x2435 -CTRL_ICH3 equ 0x2445 -CTRL_ICH4 equ 0x24C5 -CTRL_ICH5 equ 0x24D5 -CTRL_ICH6 equ 0x266E -CTRL_ICH7 equ 0x27DE +CTRL_ICH equ 0x2415 +CTRL_ICH0 equ 0x2425 +CTRL_ICH2 equ 0x2435 +CTRL_ICH3 equ 0x2445 +CTRL_ICH4 equ 0x24C5 +CTRL_ICH5 equ 0x24D5 +CTRL_ICH6 equ 0x266E +CTRL_ICH7 equ 0x27DE -CTRL_NFORCE equ 0x01B1 -CTRL_NFORCE2 equ 0x006A -CTRL_NFORCE3 equ 0x00DA -CTRL_MCP04 equ 0x003A -CTRL_CK804 equ 0x0059 -CTRL_CK8 equ 0x008A -CTRL_CK8S equ 0x00EA -CTRL_MCP51 equ 0x026B +CTRL_NFORCE equ 0x01B1 +CTRL_NFORCE2 equ 0x006A +CTRL_NFORCE3 equ 0x00DA +CTRL_MCP04 equ 0x003A +CTRL_CK804 equ 0x0059 +CTRL_CK8 equ 0x008A +CTRL_CK8S equ 0x00EA +CTRL_MCP51 equ 0x026B -PCM_OUT_BDL equ 0x10 ; PCM out buffer descriptors list -PCM_OUT_CR_REG equ 0x1b ; PCM out Control Register +PCM_OUT_BDL equ 0x10 ; PCM out buffer descriptors list +PCM_OUT_CR_REG equ 0x1b ; PCM out Control Register 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_CIV_REG equ 0x14 ; PCM out current index -PCM_IN_CR_REG equ 0x0b ; PCM in Control Register -MC_IN_CR_REG equ 0x2b ; MIC in Control Register -RR equ BIT1 ; reset registers. Nukes all regs +PCM_IN_CR_REG equ 0x0b ; PCM in Control Register +MC_IN_CR_REG equ 0x2b ; MIC in Control Register +RR equ BIT1 ; reset registers. Nukes all regs -CODEC_MASTER_VOL_REG equ 0x02 -CODEC_AUX_VOL equ 0x04 ; -CODEC_PCM_OUT_REG equ 0x18 ; PCM output volume -CODEC_EXT_AUDIO_REG equ 0x28 ; extended audio +CODEC_MASTER_VOL_REG equ 0x02 +CODEC_AUX_VOL equ 0x04 ; +CODEC_PCM_OUT_REG equ 0x18 ; PCM output volume +CODEC_EXT_AUDIO_REG equ 0x28 ; extended audio CODEC_EXT_AUDIO_CTRL_REG equ 0x2a ; extended audio control CODEC_PCM_FRONT_DACRATE_REG equ 0x2c ; PCM out sample rate CODEC_PCM_SURND_DACRATE_REG equ 0x2e ; surround sound sample rate CODEC_PCM_LFE_DACRATE_REG equ 0x30 ; LFE sample rate -GLOB_CTRL equ 0x2C ; Global Control -CTRL_STAT equ 0x30 ; Global Status -CTRL_CAS equ 0x34 ; Codec Access Semiphore +GLOB_CTRL equ 0x2C ; Global Control +CTRL_STAT equ 0x30 ; Global Status +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_WARM equ 0x00000004 ; AC97 Warm Reset -CTRL_CNT_COLD equ 0x00000002 ; AC97 Cold Reset -CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable +CTRL_CNT_WARM equ 0x00000004 ; AC97 Warm Reset +CTRL_CNT_COLD equ 0x00000002 ; AC97 Cold Reset +CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable CODEC_REG_POWERDOWN equ 0x26 -CODEC_REG_ST equ 0x26 +CODEC_REG_ST equ 0x26 -SRV_GETVERSION equ 0 -DEV_PLAY equ 1 -DEV_STOP equ 2 -DEV_CALLBACK equ 3 -DEV_SET_BUFF equ 4 -DEV_NOTIFY equ 5 +SRV_GETVERSION equ 0 +DEV_PLAY equ 1 +DEV_STOP equ 2 +DEV_CALLBACK equ 3 +DEV_SET_BUFF equ 4 +DEV_NOTIFY equ 5 DEV_SET_MASTERVOL equ 6 DEV_GET_MASTERVOL equ 7 -DEV_GET_INFO equ 8 +DEV_GET_INFO equ 8 struc AC_CNTRL ;AC controller base class -{ .bus dd ? - .devfn dd ? +{ .bus dd ? + .devfn dd ? - .vendor dd ? - .dev_id dd ? - .pci_cmd dd ? - .pci_stat dd ? + .vendor dd ? + .dev_id dd ? + .pci_cmd dd ? + .pci_stat dd ? .codec_io_base dd ? .codec_mem_base dd ? .ctrl_io_base dd ? .ctrl_mem_base dd ? - .cfg_reg dd ? - .int_line dd ? + .cfg_reg dd ? + .int_line dd ? - .vendor_ids dd ? ;vendor id string - .ctrl_ids dd ? ;hub id string + .vendor_ids dd ? ;vendor id string + .ctrl_ids dd ? ;hub id string - .buffer dd ? + .buffer dd ? - .notify_pos dd ? - .notify_task dd ? + .notify_pos dd ? + .notify_task dd ? - .lvi_reg dd ? - .ctrl_setup dd ? + .lvi_reg dd ? + .ctrl_setup dd ? .user_callback dd ? .codec_read16 dd ? .codec_write16 dd ? - .ctrl_read8 dd ? - .ctrl_read16 dd ? - .ctrl_read32 dd ? + .ctrl_read8 dd ? + .ctrl_read16 dd ? + .ctrl_read32 dd ? - .ctrl_write8 dd ? + .ctrl_write8 dd ? .ctrl_write16 dd ? .ctrl_write32 dd ? } struc CODEC ;Audio Chip base class { - .chip_id dd ? - .flags dd ? - .status dd ? + .chip_id dd ? + .flags dd ? + .status dd ? .ac_vendor_ids dd ? ;ac vendor id string - .chip_ids dd ? ;chip model string + .chip_ids dd ? ;chip model string - .shadow_flag dd ? - dd ? + .shadow_flag dd ? + dd ? - .regs dw ? ; codec registers + .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_mic_vol dw ? ;0x0E .reg_line_in_vol dw ? ;0x10 - .reg_cd_vol dw ? ;0x12 + .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_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_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 + 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 + 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 ? ;virual + .reset dd ? ;virual .set_master_vol dd ? } struc CTRL_INFO -{ .pci_cmd dd ? - .irq dd ? +{ .pci_cmd dd ? + .irq dd ? .glob_cntrl dd ? - .glob_sta dd ? + .glob_sta dd ? .codec_io_base dd ? .ctrl_io_base dd ? .codec_mem_base dd ? .ctrl_mem_base dd ? - .codec_id dd ? + .codec_id dd ? } struc IOCTL -{ .handle dd ? - .io_code dd ? - .input dd ? - .inp_size dd ? - .output dd ? - .out_size dd ? +{ .handle dd ? + .io_code dd ? + .input dd ? + .inp_size dd ? + .output dd ? + .out_size dd ? } virtual at 0 IOCTL IOCTL end virtual -EVENT_NOTIFY equ 0x00000200 +EVENT_NOTIFY equ 0x00000200 public START public service_proc @@ -296,163 +296,163 @@ section '.flat' code readable align 16 proc START stdcall, state:dword - cmp [state], 1 - jne .stop + cmp [state], 1 + jne .stop if DEBUG - mov esi, msgInit - call SysMsgBoardStr + mov esi, msgInit + call SysMsgBoardStr end if - call detect_controller - test eax, eax - jz .fail + call detect_controller + test eax, eax + jz .fail if DEBUG - mov esi,[ctrl.vendor_ids] - call SysMsgBoardStr - mov esi, [ctrl.ctrl_ids] - call SysMsgBoardStr + mov esi,[ctrl.vendor_ids] + call SysMsgBoardStr + mov esi, [ctrl.ctrl_ids] + call SysMsgBoardStr end if - call init_controller - test eax, eax - jz .fail + call init_controller + test eax, eax + jz .fail - call init_codec - test eax, eax - jz .fail + call init_codec + test eax, eax + jz .fail - call reset_controller - call setup_codec + call reset_controller + call setup_codec - mov esi, msgPrimBuff - call SysMsgBoardStr - call create_primary_buff - mov esi, msgDone - call SysMsgBoardStr + mov esi, msgPrimBuff + call SysMsgBoardStr + call create_primary_buff + mov esi, msgDone + call SysMsgBoardStr if IRQ_REMAP - pushf - cli + pushf + cli - mov ebx, [ctrl.int_line] - in al, 0xA1 - mov ah, al - in al, 0x21 - test ebx, ebx - jz .skip - bts ax, bx ;mask old line + mov ebx, [ctrl.int_line] + in al, 0xA1 + mov ah, al + in al, 0x21 + test ebx, ebx + jz .skip + bts ax, bx ;mask old line .skip - bts ax, IRQ_LINE ;mask new ine - out 0x21, al - mov al, ah - out 0xA1, al - ;remap IRQ - stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE + bts ax, IRQ_LINE ;mask new ine + out 0x21, al + mov al, ah + out 0xA1, al + ;remap IRQ + stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE - mov dx, 0x4d0 ;8259 ELCR1 - in al, dx - bts ax, IRQ_LINE - out dx, al ;set level-triggered mode - mov [ctrl.int_line], IRQ_LINE - popf - mov esi, msgRemap - call SysMsgBoardStr + mov dx, 0x4d0 ;8259 ELCR1 + in al, dx + bts ax, IRQ_LINE + out dx, al ;set level-triggered mode + mov [ctrl.int_line], IRQ_LINE + popf + mov esi, msgRemap + call SysMsgBoardStr end if - mov eax, VALID_IRQ - mov ebx, [ctrl.int_line] - mov esi, msgInvIRQ - bt eax, ebx - jnc .fail_msg - mov eax, ATTCH_IRQ - mov esi, msgAttchIRQ - bt eax, ebx - jnc .fail_msg + mov eax, VALID_IRQ + mov ebx, [ctrl.int_line] + mov esi, msgInvIRQ + bt eax, ebx + jnc .fail_msg + mov eax, ATTCH_IRQ + mov esi, msgAttchIRQ + bt eax, ebx + jnc .fail_msg - stdcall AttachIntHandler, ebx, ac97_irq + stdcall AttachIntHandler, ebx, ac97_irq, dword 0 .reg: - stdcall RegService, sz_sound_srv, service_proc - ret + stdcall RegService, sz_sound_srv, service_proc + ret .fail: if DEBUG - mov esi, msgFail - call SysMsgBoardStr + mov esi, msgFail + call SysMsgBoardStr end if - xor eax, eax - ret + xor eax, eax + ret .fail_msg: - call SysMsgBoardStr - xor eax, eax - ret + call SysMsgBoardStr + xor eax, eax + ret .stop: - call stop - xor eax, eax - ret + call stop + xor eax, eax + ret endp -handle equ IOCTL.handle -io_code equ IOCTL.io_code -input equ IOCTL.input -inp_size equ IOCTL.inp_size -output equ IOCTL.output -out_size equ IOCTL.out_size +handle equ IOCTL.handle +io_code equ IOCTL.io_code +input equ IOCTL.input +inp_size equ IOCTL.inp_size +output equ IOCTL.output +out_size equ IOCTL.out_size align 4 proc service_proc stdcall, ioctl:dword - mov edi, [ioctl] - mov eax, [edi+io_code] + mov edi, [ioctl] + mov eax, [edi+io_code] - cmp eax, SRV_GETVERSION - jne @F + cmp eax, SRV_GETVERSION + jne @F - mov eax, [edi+output] - cmp [edi+out_size], 4 - jne .fail + mov eax, [edi+output] + cmp [edi+out_size], 4 + jne .fail - mov [eax], dword API_VERSION - xor eax, eax - ret + mov [eax], dword API_VERSION + xor eax, eax + ret @@: - cmp eax, DEV_PLAY - jne @F + cmp eax, DEV_PLAY + jne @F if DEBUG - mov esi, msgPlay - call SysMsgBoardStr + mov esi, msgPlay + call SysMsgBoardStr end if - call play - ret + call play + ret @@: - cmp eax, DEV_STOP - jne @F + cmp eax, DEV_STOP + jne @F if DEBUG - mov esi, msgStop - call SysMsgBoardStr + mov esi, msgStop + call SysMsgBoardStr end if - call stop - ret + call stop + ret @@: - cmp eax, DEV_CALLBACK - jne @F - mov ebx, [edi+input] - stdcall set_callback, [ebx] - ret + cmp eax, DEV_CALLBACK + jne @F + mov ebx, [edi+input] + stdcall set_callback, [ebx] + ret @@: - cmp eax, DEV_SET_MASTERVOL - jne @F - mov eax, [edi+input] - mov eax, [eax] - call set_master_vol ;eax= vol - ret + cmp eax, DEV_SET_MASTERVOL + jne @F + mov eax, [edi+input] + mov eax, [eax] + call set_master_vol ;eax= vol + ret @@: - cmp eax, DEV_GET_MASTERVOL - jne @F - mov ebx, [edi+output] - stdcall get_master_vol, ebx - ret + cmp eax, DEV_GET_MASTERVOL + jne @F + mov ebx, [edi+output] + stdcall get_master_vol, ebx + ret ;@@: ; cmp eax, DEV_GET_INFO ; jne @F @@ -461,8 +461,8 @@ proc service_proc stdcall, ioctl:dword ; ret @@: .fail: - or eax, -1 - ret + or eax, -1 + ret endp restore handle @@ -476,770 +476,770 @@ align 4 proc ac97_irq if DEBUG_IRQ - mov esi, msgIRQ - call SysMsgBoardStr + mov esi, msgIRQ + call SysMsgBoardStr end if - mov edx, PCM_OUT_CR_REG - mov al, 0x10; 0x10 - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + mov al, 0x10; 0x10 + call [ctrl.ctrl_write8] - mov ax, 0x1c - mov edx, PCM_OUT_SR_REG - call [ctrl.ctrl_write16] + mov ax, 0x1c + mov edx, PCM_OUT_SR_REG + call [ctrl.ctrl_write16] - mov edx, PCM_OUT_CIV_REG - call [ctrl.ctrl_read8] + mov edx, PCM_OUT_CIV_REG + call [ctrl.ctrl_read8] - and eax, 0x1F - cmp eax, [civ_val] - je .skip + and eax, 0x1F + cmp eax, [civ_val] + je .skip - mov [civ_val], eax - dec eax - and eax, 0x1F - mov [ctrl.lvi_reg], eax + mov [civ_val], eax + dec eax + and eax, 0x1F + mov [ctrl.lvi_reg], eax - mov edx, PCM_OUT_LVI_REG - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_LVI_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - mov ax, 0x11 ;0x1D - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + mov ax, 0x11 ;0x1D + call [ctrl.ctrl_write8] - mov eax, [civ_val] - add eax, 1 - and eax, 31 - mov ebx, dword [buff_list+eax*4] + mov eax, [civ_val] + add eax, 1 + and eax, 31 + mov ebx, dword [buff_list+eax*4] - cmp [ctrl.user_callback], 0 - je @f + cmp [ctrl.user_callback], 0 + je @f - stdcall [ctrl.user_callback], ebx + stdcall [ctrl.user_callback], ebx @@: - ret + ret .skip: - mov edx, PCM_OUT_CR_REG - mov ax, 0x11 ;0x1D - call [ctrl.ctrl_write8] - ret + mov edx, PCM_OUT_CR_REG + mov ax, 0x11 ;0x1D + call [ctrl.ctrl_write8] + ret endp align 4 proc create_primary_buff - stdcall KernelAlloc, 0x10000 - mov [ctrl.buffer], eax + stdcall KernelAlloc, 0x10000 + mov [ctrl.buffer], eax - mov edi, eax - mov ecx, 0x10000/4 - xor eax, eax - cld - rep stosd + mov edi, eax + mov ecx, 0x10000/4 + xor eax, eax + cld + rep stosd - mov eax, [ctrl.buffer] - call GetPgAddr + mov eax, [ctrl.buffer] + call GetPgAddr - mov ebx, 0xC0002000 - mov ecx, 4 - mov edi, pcmout_bdl + mov ebx, 0xC0002000 + mov ecx, 4 + mov edi, pcmout_bdl @@: - mov [edi], eax - mov [edi+4], ebx + mov [edi], eax + mov [edi+4], ebx - mov [edi+32], eax - mov [edi+4+32], ebx + mov [edi+32], eax + mov [edi+4+32], ebx - mov [edi+64], eax - mov [edi+4+64], ebx + mov [edi+64], eax + mov [edi+4+64], ebx - mov [edi+96], eax - mov [edi+4+96], ebx + mov [edi+96], eax + mov [edi+4+96], ebx - mov [edi+128], eax - mov [edi+4+128], ebx + mov [edi+128], eax + mov [edi+4+128], ebx - mov [edi+160], eax - mov [edi+4+160], ebx + mov [edi+160], eax + mov [edi+4+160], ebx - mov [edi+192], eax - mov [edi+4+192], ebx + mov [edi+192], eax + mov [edi+4+192], ebx - mov [edi+224], eax - mov [edi+4+224], ebx + mov [edi+224], eax + mov [edi+4+224], ebx - add eax, 0x4000 - add edi, 8 - loop @B + add eax, 0x4000 + add edi, 8 + loop @B - mov edi, buff_list - mov eax, [ctrl.buffer] - mov ecx, 4 + mov edi, buff_list + mov eax, [ctrl.buffer] + mov ecx, 4 @@: - mov [edi], eax - mov [edi+16], eax - mov [edi+32], eax - mov [edi+48], eax - mov [edi+64], eax - mov [edi+80], eax - mov [edi+96], eax - mov [edi+112], eax + mov [edi], eax + mov [edi+16], eax + mov [edi+32], eax + mov [edi+48], eax + mov [edi+64], eax + mov [edi+80], eax + mov [edi+96], eax + mov [edi+112], eax - add eax, 0x4000 - add edi, 4 - loop @B + add eax, 0x4000 + add edi, 4 + loop @B - mov eax, pcmout_bdl - mov ebx, eax - call GetPgAddr ;eax - and ebx, 0xFFF - add eax, ebx + mov eax, pcmout_bdl + mov ebx, eax + call GetPgAddr ;eax + and ebx, 0xFFF + add eax, ebx - mov edx, PCM_OUT_BDL - call [ctrl.ctrl_write32] + mov edx, PCM_OUT_BDL + call [ctrl.ctrl_write32] - mov eax, 16 - mov [ctrl.lvi_reg], eax - mov edx, PCM_OUT_LVI_REG - call [ctrl.ctrl_write8] - ret + mov eax, 16 + mov [ctrl.lvi_reg], eax + mov edx, PCM_OUT_LVI_REG + call [ctrl.ctrl_write8] + ret endp align 4 proc detect_controller - locals - last_bus dd ? - bus dd ? - devfn dd ? - endl + locals + last_bus dd ? + bus dd ? + devfn dd ? + endl - xor eax, eax - mov [bus], eax - inc eax - call PciApi - cmp eax, -1 - je .err + xor eax, eax + mov [bus], eax + inc eax + call PciApi + cmp eax, -1 + je .err - mov [last_bus], eax + mov [last_bus], eax .next_bus: - and [devfn], 0 + and [devfn], 0 .next_dev: - stdcall PciRead32, [bus], [devfn], dword 0 - test eax, eax - jz .next - cmp eax, -1 - je .next + stdcall PciRead32, [bus], [devfn], dword 0 + test eax, eax + jz .next + cmp eax, -1 + je .next - mov edi, devices + mov edi, devices @@: - mov ebx, [edi] - test ebx, ebx - jz .next + mov ebx, [edi] + test ebx, ebx + jz .next - cmp eax, ebx - je .found - add edi, 12 - jmp @B + cmp eax, ebx + je .found + add edi, 12 + jmp @B .next: - inc [devfn] - cmp [devfn], 256 - jb .next_dev - mov eax, [bus] - inc eax - mov [bus], eax - cmp eax, [last_bus] - jna .next_bus - xor eax, eax - ret + inc [devfn] + cmp [devfn], 256 + jb .next_dev + mov eax, [bus] + inc eax + mov [bus], eax + cmp eax, [last_bus] + jna .next_bus + xor eax, eax + ret .found: - mov ebx, [bus] - mov [ctrl.bus], ebx + mov ebx, [bus] + mov [ctrl.bus], ebx - mov ecx, [devfn] - mov [ctrl.devfn], ecx + mov ecx, [devfn] + mov [ctrl.devfn], ecx - mov edx, eax - and edx, 0xFFFF - mov [ctrl.vendor], edx - shr eax, 16 - mov [ctrl.dev_id], eax + mov edx, eax + and edx, 0xFFFF + mov [ctrl.vendor], edx + shr eax, 16 + mov [ctrl.dev_id], eax - mov ebx, [edi+4] - mov [ctrl.ctrl_ids], ebx - mov esi, [edi+8] - mov [ctrl.ctrl_setup], esi + mov ebx, [edi+4] + mov [ctrl.ctrl_ids], ebx + mov esi, [edi+8] + mov [ctrl.ctrl_setup], esi - cmp edx, VID_INTEL - jne @F - mov [ctrl.vendor_ids], msg_Intel - ret + cmp edx, VID_INTEL + jne @F + mov [ctrl.vendor_ids], msg_Intel + ret @@: - cmp edx, VID_NVIDIA - jne @F - mov [ctrl.vendor_ids], msg_NVidia - ret + cmp edx, VID_NVIDIA + jne @F + mov [ctrl.vendor_ids], msg_NVidia + ret @@: .err: - xor eax, eax - mov [ctrl.vendor_ids], eax ;something wrong ? - ret + xor eax, eax + mov [ctrl.vendor_ids], eax ;something wrong ? + ret endp align 4 proc init_controller - 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 4 + mov ebx, eax + and eax, 0xFFFF + mov [ctrl.pci_cmd], eax + shr ebx, 16 + mov [ctrl.pci_stat], ebx - mov esi, msgPciCmd - call SysMsgBoardStr - call dword2str - call SysMsgBoardStr + mov esi, msgPciCmd + call SysMsgBoardStr + call dword2str + call SysMsgBoardStr - mov esi, msgPciStat - call SysMsgBoardStr - mov eax, [ctrl.pci_stat] - call dword2str - call SysMsgBoardStr + mov esi, msgPciStat + call SysMsgBoardStr + mov eax, [ctrl.pci_stat] + call dword2str + call SysMsgBoardStr - mov esi, msgMixIsaIo - call SysMsgBoardStr + mov esi, msgMixIsaIo + call SysMsgBoardStr - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 + stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 - call dword2str - call SysMsgBoardStr + call dword2str + call SysMsgBoardStr - and eax,0xFFFE - mov [ctrl.codec_io_base], eax + and eax,0xFFFE + mov [ctrl.codec_io_base], eax - mov esi, msgCtrlIsaIo - call SysMsgBoardStr + mov esi, msgCtrlIsaIo + call SysMsgBoardStr - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14 + stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14 - call dword2str - call SysMsgBoardStr + call dword2str + call SysMsgBoardStr - and eax, 0xFFC0 - mov [ctrl.ctrl_io_base], eax + and eax, 0xFFC0 + mov [ctrl.ctrl_io_base], eax - mov esi, msgMixMMIo - call SysMsgBoardStr + mov esi, msgMixMMIo + call SysMsgBoardStr - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18 - mov [ctrl.codec_mem_base], eax + stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18 + mov [ctrl.codec_mem_base], eax - call dword2str - call SysMsgBoardStr + call dword2str + call SysMsgBoardStr - mov esi, msgCtrlMMIo - call SysMsgBoardStr + mov esi, msgCtrlMMIo + call SysMsgBoardStr - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C - mov [ctrl.ctrl_mem_base], eax + stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C + mov [ctrl.ctrl_mem_base], eax - call dword2str - call SysMsgBoardStr + call dword2str + call SysMsgBoardStr if 0 ;;patch for some ugly BIOS ICH-ICH5 compatible - cmp [ctrl.vendor], VID_INTEL - jne .default + cmp [ctrl.vendor], VID_INTEL + jne .default - mov esi, msgIrqMap - call SysMsgBoardStr - stdcall PciRead8, 0, 0xF8, 0x61 - and eax, 0xFF - call dword2str - call SysMsgBoardStr - btr eax, 7 ;when bit 7 set remap disabled - jnc @F - xor eax, eax - jmp @F + mov esi, msgIrqMap + call SysMsgBoardStr + stdcall PciRead8, 0, 0xF8, 0x61 + and eax, 0xFF + call dword2str + call SysMsgBoardStr + btr eax, 7 ;when bit 7 set remap disabled + jnc @F + xor eax, eax + jmp @F end if .default: - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C - and eax, 0xFF + stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C + and eax, 0xFF @@: - mov [ctrl.int_line], eax + mov [ctrl.int_line], eax - stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41 - and eax, 0xFF - mov [ctrl.cfg_reg], eax + stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41 + and eax, 0xFF + mov [ctrl.cfg_reg], eax - call [ctrl.ctrl_setup] - xor eax, eax - inc eax - ret + call [ctrl.ctrl_setup] + xor eax, eax + inc eax + ret endp align 4 proc set_ICH - mov [ctrl.codec_read16], codec_io_r16 ;virtual - mov [ctrl.codec_write16], codec_io_w16 ;virtual + mov [ctrl.codec_read16], codec_io_r16 ;virtual + mov [ctrl.codec_write16], codec_io_w16 ;virtual - mov [ctrl.ctrl_read8 ], ctrl_io_r8 ;virtual - mov [ctrl.ctrl_read16], ctrl_io_r16 ;virtual - mov [ctrl.ctrl_read32], ctrl_io_r32 ;virtual + mov [ctrl.ctrl_read8 ], ctrl_io_r8 ;virtual + mov [ctrl.ctrl_read16], ctrl_io_r16 ;virtual + mov [ctrl.ctrl_read32], ctrl_io_r32 ;virtual - mov [ctrl.ctrl_write8 ], ctrl_io_w8 ;virtual - mov [ctrl.ctrl_write16], ctrl_io_w16 ;virtual - mov [ctrl.ctrl_write32], ctrl_io_w32 ;virtual - ret + mov [ctrl.ctrl_write8 ], ctrl_io_w8 ;virtual + mov [ctrl.ctrl_write16], ctrl_io_w16 ;virtual + mov [ctrl.ctrl_write32], ctrl_io_w32 ;virtual + ret endp -PG_SW equ 0x003 -PG_NOCACHE equ 0x018 +PG_SW equ 0x003 +PG_NOCACHE equ 0x018 align 4 proc set_ICH4 - stdcall MapIoMem,[ctrl.codec_mem_base],0x1000,PG_SW+PG_NOCACHE - mov [ctrl.codec_mem_base], eax + stdcall MapIoMem,[ctrl.codec_mem_base],0x1000,PG_SW+PG_NOCACHE + mov [ctrl.codec_mem_base], eax - stdcall MapIoMem,[ctrl.ctrl_mem_base],0x1000,PG_SW+PG_NOCACHE - mov [ctrl.ctrl_mem_base], eax + stdcall MapIoMem,[ctrl.ctrl_mem_base],0x1000,PG_SW+PG_NOCACHE + mov [ctrl.ctrl_mem_base], eax - mov [ctrl.codec_read16], codec_mem_r16 ;virtual - mov [ctrl.codec_write16], codec_mem_w16 ;virtual + mov [ctrl.codec_read16], codec_mem_r16 ;virtual + mov [ctrl.codec_write16], codec_mem_w16 ;virtual - mov [ctrl.ctrl_read8 ], ctrl_mem_r8 ;virtual - mov [ctrl.ctrl_read16], ctrl_mem_r16 ;virtual - mov [ctrl.ctrl_read32], ctrl_mem_r32 ;virtual + mov [ctrl.ctrl_read8 ], ctrl_mem_r8 ;virtual + mov [ctrl.ctrl_read16], ctrl_mem_r16 ;virtual + mov [ctrl.ctrl_read32], ctrl_mem_r32 ;virtual - mov [ctrl.ctrl_write8 ], ctrl_mem_w8 ;virtual - mov [ctrl.ctrl_write16], ctrl_mem_w16 ;virtual - mov [ctrl.ctrl_write32], ctrl_mem_w32 ;virtual - ret + mov [ctrl.ctrl_write8 ], ctrl_mem_w8 ;virtual + mov [ctrl.ctrl_write16], ctrl_mem_w16 ;virtual + mov [ctrl.ctrl_write32], ctrl_mem_w32 ;virtual + ret endp align 4 proc reset_controller - xor eax, eax - mov edx, PCM_IN_CR_REG - call [ctrl.ctrl_write8] + xor eax, eax + mov edx, PCM_IN_CR_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + call [ctrl.ctrl_write8] - mov edx, MC_IN_CR_REG - call [ctrl.ctrl_write8] + mov edx, MC_IN_CR_REG + call [ctrl.ctrl_write8] - mov eax, RR - mov edx, PCM_IN_CR_REG - call [ctrl.ctrl_write8] + mov eax, RR + mov edx, PCM_IN_CR_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + call [ctrl.ctrl_write8] - mov edx, MC_IN_CR_REG - call [ctrl.ctrl_write8] - ret + mov edx, MC_IN_CR_REG + call [ctrl.ctrl_write8] + ret endp align 4 proc init_codec - locals - counter dd ? - endl + locals + counter dd ? + endl - mov esi, msgControl - call SysMsgBoardStr + mov esi, msgControl + call SysMsgBoardStr - mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] - call dword2str - call SysMsgBoardStr + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] + call dword2str + call SysMsgBoardStr - mov esi, msgStatus - call SysMsgBoardStr + mov esi, msgStatus + call SysMsgBoardStr - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - push eax - call dword2str - call SysMsgBoardStr - pop eax - cmp eax, 0xFFFFFFFF - je .err + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + push eax + call dword2str + call SysMsgBoardStr + pop eax + cmp eax, 0xFFFFFFFF + je .err - test eax, CTRL_ST_CREADY - jnz .ready + test eax, CTRL_ST_CREADY + jnz .ready - call reset_codec - test eax, eax - jz .err + call reset_codec + test eax, eax + jz .err .ready: - xor edx, edx ;ac_reg_0 - call [ctrl.codec_write16] + xor edx, edx ;ac_reg_0 + call [ctrl.codec_write16] - xor eax, eax - mov edx, CODEC_REG_POWERDOWN - call [ctrl.codec_write16] + xor eax, eax + mov edx, CODEC_REG_POWERDOWN + call [ctrl.codec_write16] - mov [counter], 200 ; total 200*5 ms = 1s + mov [counter], 200 ; total 200*5 ms = 1s .wait: - mov eax, 5000 ; wait 5 ms - call StallExec + mov eax, 5000 ; wait 5 ms + call StallExec - mov edx, CODEC_REG_POWERDOWN - call [ctrl.codec_read16] - and eax, 0x0F - cmp eax, 0x0F - jz .done + mov edx, CODEC_REG_POWERDOWN + call [ctrl.codec_read16] + and eax, 0x0F + cmp eax, 0x0F + jz .done - sub [counter] , 1 - jnz .wait + sub [counter] , 1 + jnz .wait .err: - xor eax, eax ; timeout error - ret + xor eax, eax ; timeout error + ret .done: - mov eax, 2 ;force set 16-bit 2-channel PCM - mov edx, GLOB_CTRL - call [ctrl.ctrl_write32] - mov eax, 5000 ; wait 5 ms - call StallExec + mov eax, 2 ;force set 16-bit 2-channel PCM + mov edx, GLOB_CTRL + call [ctrl.ctrl_write32] + mov eax, 5000 ; wait 5 ms + call StallExec - call detect_codec + call detect_codec - xor eax, eax - inc eax - ret + xor eax, eax + inc eax + ret endp align 4 proc reset_codec - mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] - test eax, 0x02 - jz .cold + test eax, 0x02 + jz .cold - call warm_reset - jnc .ok + call warm_reset + jnc .ok .cold: - call cold_reset - jnc .ok + call cold_reset + jnc .ok if DEBUG - mov esi, msgCFail - call SysMsgBoardStr - end if - xor eax, eax ; timeout error - ret + mov esi, msgCFail + call SysMsgBoardStr + end if + xor eax, eax ; timeout error + ret .ok: if DEBUG - mov esi, msgResetOk - call SysMsgBoardStr + mov esi, msgResetOk + call SysMsgBoardStr end if - xor eax, eax - inc eax - ret + xor eax, eax + inc eax + ret endp align 4 proc warm_reset - locals - counter dd ? - endl + locals + counter dd ? + endl - mov eax, 0x06 - mov edx, GLOB_CTRL - call [ctrl.ctrl_write32] + mov eax, 0x06 + mov edx, GLOB_CTRL + call [ctrl.ctrl_write32] if DEBUG - mov esi, msgWarm - call SysMsgBoardStr + mov esi, msgWarm + call SysMsgBoardStr end if - mov [counter], 10 ; total 10*100 ms = 1s + mov [counter], 10 ; total 10*100 ms = 1s .wait: - mov eax, 100000 ; wait 100 ms - call StallExec + mov eax, 100000 ; wait 100 ms + call StallExec - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - test eax, CTRL_ST_CREADY - jnz .ok + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + test eax, CTRL_ST_CREADY + jnz .ok - dec [counter] - jnz .wait + dec [counter] + jnz .wait if DEBUG - mov esi, msgWRFail - call SysMsgBoardStr + mov esi, msgWRFail + call SysMsgBoardStr end if .fail: - stc - ret + stc + ret .ok: - clc - ret + clc + ret endp align 4 proc cold_reset - locals - counter dd ? - endl + locals + counter dd ? + endl - mov eax, 0x02 - mov edx, GLOB_CTRL - call [ctrl.ctrl_write32] + mov eax, 0x02 + mov edx, GLOB_CTRL + call [ctrl.ctrl_write32] if DEBUG - mov esi, msgCold - call SysMsgBoardStr + mov esi, msgCold + call SysMsgBoardStr end if - mov eax, 400000 ; wait 400 ms - call StallExec + mov eax, 400000 ; wait 400 ms + call StallExec - mov [counter], 16 ; total 20*100 ms = 2s + mov [counter], 16 ; total 20*100 ms = 2s .wait: - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - test eax, CTRL_ST_CREADY - jnz .ok + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + test eax, CTRL_ST_CREADY + jnz .ok - mov eax, 100000 ; wait 100 ms - call StallExec + mov eax, 100000 ; wait 100 ms + call StallExec - dec [counter] - jnz .wait + dec [counter] + jnz .wait if DEBUG - mov esi, msgCRFail - call SysMsgBoardStr + mov esi, msgCRFail + call SysMsgBoardStr end if .fail: - stc - ret + stc + ret .ok: - mov esi, msgControl - call SysMsgBoardStr + mov esi, msgControl + call SysMsgBoardStr - mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] - call dword2str - call SysMsgBoardStr + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] + call dword2str + call SysMsgBoardStr - mov esi, msgStatus - call SysMsgBoardStr + mov esi, msgStatus + call SysMsgBoardStr - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - push eax - call dword2str - call SysMsgBoardStr - pop eax + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + push eax + call dword2str + call SysMsgBoardStr + pop eax - test eax, CTRL_ST_CREADY - jz .fail - clc - ret + test eax, CTRL_ST_CREADY + jz .fail + clc + ret endp align 4 play: - mov eax, 16 - mov [ctrl.lvi_reg], eax - mov edx, PCM_OUT_LVI_REG - call [ctrl.ctrl_write8] + mov eax, 16 + mov [ctrl.lvi_reg], eax + mov edx, PCM_OUT_LVI_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - mov ax, 0x1D - call [ctrl.ctrl_write8] - xor eax, eax - ret + mov edx, PCM_OUT_CR_REG + mov ax, 0x1D + call [ctrl.ctrl_write8] + xor eax, eax + ret align 4 stop: - mov edx, PCM_OUT_CR_REG - mov ax, 0x0 - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + mov ax, 0x0 + call [ctrl.ctrl_write8] - mov ax, 0x1c - mov edx, PCM_OUT_SR_REG - call [ctrl.ctrl_write16] - xor eax, eax - ret + mov ax, 0x1c + mov edx, PCM_OUT_SR_REG + call [ctrl.ctrl_write16] + xor eax, eax + ret align 4 proc get_dev_info stdcall, p_info:dword - virtual at esi - CTRL_INFO CTRL_INFO - end virtual + virtual at esi + CTRL_INFO CTRL_INFO + end virtual - mov esi, [p_info] - mov eax, [ctrl.int_line] - mov ebx, [ctrl.codec_io_base] - mov ecx, [ctrl.ctrl_io_base] - mov edx, [ctrl.codec_mem_base] - mov edi, [ctrl.ctrl_mem_base] + mov esi, [p_info] + mov eax, [ctrl.int_line] + mov ebx, [ctrl.codec_io_base] + mov ecx, [ctrl.ctrl_io_base] + mov edx, [ctrl.codec_mem_base] + mov edi, [ctrl.ctrl_mem_base] - mov [CTRL_INFO.irq], eax - mov [CTRL_INFO.codec_io_base], ebx - mov [CTRL_INFO.ctrl_io_base], ecx - mov [CTRL_INFO.codec_mem_base], edx - mov [CTRL_INFO.ctrl_mem_base], edi + mov [CTRL_INFO.irq], eax + mov [CTRL_INFO.codec_io_base], ebx + mov [CTRL_INFO.ctrl_io_base], ecx + mov [CTRL_INFO.codec_mem_base], edx + mov [CTRL_INFO.ctrl_mem_base], edi - mov eax, [codec.chip_id] - mov [CTRL_INFO.codec_id], eax + mov eax, [codec.chip_id] + mov [CTRL_INFO.codec_id], eax - mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] - mov [CTRL_INFO.glob_cntrl], eax + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] + mov [CTRL_INFO.glob_cntrl], eax - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - mov [CTRL_INFO.glob_sta], eax + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + mov [CTRL_INFO.glob_sta], eax - mov ebx, [ctrl.pci_cmd] - mov [CTRL_INFO.pci_cmd], ebx - ret + mov ebx, [ctrl.pci_cmd] + mov [CTRL_INFO.pci_cmd], ebx + ret endp align 4 proc set_callback stdcall, handler:dword - mov eax, [handler] - mov [ctrl.user_callback], eax - ret + mov eax, [handler] + mov [ctrl.user_callback], eax + ret endp align 4 proc codec_read stdcall, ac_reg:dword ; reg = edx, reval = eax - mov edx, [ac_reg] + mov edx, [ac_reg] - mov ebx, edx - shr ebx, 1 - bt [codec.shadow_flag], ebx - jc .use_shadow + mov ebx, edx + shr ebx, 1 + bt [codec.shadow_flag], ebx + jc .use_shadow - call [ctrl.codec_read16] ;change edx !!! - mov ecx, eax + call [ctrl.codec_read16] ;change edx !!! + mov ecx, eax - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - test eax, CTRL_ST_RCS - jz .read_ok + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + test eax, CTRL_ST_RCS + jz .read_ok - mov edx, CTRL_STAT - call [ctrl.ctrl_write32] - xor eax,eax - not eax ;timeout - ret + mov edx, CTRL_STAT + call [ctrl.ctrl_write32] + xor eax,eax + not eax ;timeout + ret .read_ok: - mov edx, [ac_reg] - mov [codec.regs+edx], cx - bts [codec.shadow_flag], ebx - mov eax, ecx - ret + mov edx, [ac_reg] + mov [codec.regs+edx], cx + bts [codec.shadow_flag], ebx + mov eax, ecx + ret .use_shadow: - movzx eax, word [codec.regs+edx] - ret + movzx eax, word [codec.regs+edx] + ret endp align 4 proc codec_write stdcall, ac_reg:dword - push eax - call check_semafore - and eax, eax - jz .err - pop eax + push eax + call check_semafore + and eax, eax + jz .err + pop eax - mov esi, [ac_reg] - mov edx, esi - call [ctrl.codec_write16] - mov [codec.regs+esi], ax - shr esi, 1 - bts [codec.shadow_flag], esi - ret + mov esi, [ac_reg] + mov edx, esi + call [ctrl.codec_write16] + mov [codec.regs+esi], ax + shr esi, 1 + bts [codec.shadow_flag], esi + ret .err: - pop eax - ret + pop eax + ret endp align 4 proc codec_check_ready - mov edx, CTRL_ST - call [ctrl.ctrl_read32] - and eax, CTRL_ST_CREADY - jz .not_ready + mov edx, CTRL_ST + call [ctrl.ctrl_read32] + and eax, CTRL_ST_CREADY + jz .not_ready - xor eax, wax - inc eax - ret + xor eax, wax + inc eax + ret .not_ready: - xor eax, eax - ret + xor eax, eax + ret endp align 4 proc check_semafore - local counter:DWORD + local counter:DWORD - mov [counter], 100 + mov [counter], 100 .l1: - mov edx, CTRL_CAS - call [ctrl.ctrl_read8] - and eax, CAS_FLAG - jz .ok + mov edx, CTRL_CAS + call [ctrl.ctrl_read8] + and eax, CAS_FLAG + jz .ok - mov eax, 1 - call StallExec - sub [counter], 1 - jnz .l1 - xor eax, eax - ret + mov eax, 1 + call StallExec + sub [counter], 1 + jnz .l1 + xor eax, eax + ret align 4 .ok: - xor eax,eax - inc eax - ret + xor eax,eax + inc eax + ret endp align 4 proc StallExec - push ecx - push edx - push ebx - push eax + push ecx + push edx + push ebx + push eax - mov ecx, CPU_FREQ - mul ecx - mov ebx, eax ;low - mov ecx, edx ;high - rdtsc - add ebx, eax - adc ecx,edx + mov ecx, CPU_FREQ + mul ecx + mov ebx, eax ;low + mov ecx, edx ;high + rdtsc + add ebx, eax + adc ecx,edx @@: - rdtsc - sub eax, ebx - sbb edx, ecx - js @B + rdtsc + sub eax, ebx + sbb edx, ecx + js @B - pop eax - pop ebx - pop edx - pop ecx - ret + pop eax + pop ebx + pop edx + pop ecx + ret endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1248,58 +1248,58 @@ endp align 4 proc codec_io_r16 - add edx, [ctrl.codec_io_base] - in ax, dx - ret + add edx, [ctrl.codec_io_base] + in ax, dx + ret endp align 4 proc codec_io_w16 - add edx, [ctrl.codec_io_base] - out dx, ax - ret + add edx, [ctrl.codec_io_base] + out dx, ax + ret endp align 4 proc ctrl_io_r8 - add edx, [ctrl.ctrl_io_base] - in al, dx - ret + add edx, [ctrl.ctrl_io_base] + in al, dx + ret endp align 4 proc ctrl_io_r16 - add edx, [ctrl.ctrl_io_base] - in ax, dx - ret + add edx, [ctrl.ctrl_io_base] + in ax, dx + ret endp align 4 proc ctrl_io_r32 - add edx, [ctrl.ctrl_io_base] - in eax, dx - ret + add edx, [ctrl.ctrl_io_base] + in eax, dx + ret endp align 4 proc ctrl_io_w8 - add edx, [ctrl.ctrl_io_base] - out dx, al - ret + add edx, [ctrl.ctrl_io_base] + out dx, al + ret endp align 4 proc ctrl_io_w16 - add edx, [ctrl.ctrl_io_base] - out dx, ax - ret + add edx, [ctrl.ctrl_io_base] + out dx, ax + ret endp align 4 proc ctrl_io_w32 - add edx, [ctrl.ctrl_io_base] - out dx, eax - ret + add edx, [ctrl.ctrl_io_base] + out dx, eax + ret endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1308,58 +1308,58 @@ endp align 4 proc codec_mem_r16 - add edx, [ctrl.codec_mem_base] - mov ax, word [edx] - ret + add edx, [ctrl.codec_mem_base] + mov ax, word [edx] + ret endp align 4 proc codec_mem_w16 - add edx, [ctrl.codec_mem_base] - mov word [edx], ax - ret + add edx, [ctrl.codec_mem_base] + mov word [edx], ax + ret endp align 4 proc ctrl_mem_r8 - add edx, [ctrl.ctrl_mem_base] - mov al, [edx] - ret + add edx, [ctrl.ctrl_mem_base] + mov al, [edx] + ret endp align 4 proc ctrl_mem_r16 - add edx, [ctrl.ctrl_mem_base] - mov ax, [edx] - ret + add edx, [ctrl.ctrl_mem_base] + mov ax, [edx] + ret endp align 4 proc ctrl_mem_r32 - add edx, [ctrl.ctrl_mem_base] - mov eax, [edx] - ret + add edx, [ctrl.ctrl_mem_base] + mov eax, [edx] + ret endp align 4 proc ctrl_mem_w8 - add edx, [ctrl.ctrl_mem_base] - mov [edx], al - ret + add edx, [ctrl.ctrl_mem_base] + mov [edx], al + ret endp align 4 proc ctrl_mem_w16 - add edx, [ctrl.ctrl_mem_base] - mov [edx], ax - ret + add edx, [ctrl.ctrl_mem_base] + mov [edx], ax + ret endp align 4 proc ctrl_mem_w32 - add edx, [ctrl.ctrl_mem_base] - mov [edx], eax - ret + add edx, [ctrl.ctrl_mem_base] + mov [edx], eax + ret endp align 4 @@ -1384,24 +1384,24 @@ include "codec.inc" 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 - dd (CTRL_ICH3 shl 16)+VID_INTEL,msg_ICH3,set_ICH - dd (CTRL_ICH4 shl 16)+VID_INTEL,msg_ICH4,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_ICH7 shl 16)+VID_INTEL,msg_ICH7,set_ICH4 + dd (CTRL_ICH0 shl 16)+VID_INTEL,msg_ICH0,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_ICH4 shl 16)+VID_INTEL,msg_ICH4,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_ICH7 shl 16)+VID_INTEL,msg_ICH7,set_ICH4 - dd (CTRL_NFORCE shl 16)+VID_NVIDIA,msg_NForce, set_ICH - dd (CTRL_NFORCE2 shl 16)+VID_NVIDIA,msg_NForce2,set_ICH - dd (CTRL_NFORCE3 shl 16)+VID_NVIDIA,msg_NForce3,set_ICH - dd (CTRL_MCP04 shl 16)+VID_NVIDIA,msg_MCP04,set_ICH - dd (CTRL_CK804 shl 16)+VID_NVIDIA,msg_CK804,set_ICH - dd (CTRL_CK8 shl 16)+VID_NVIDIA,msg_CK8,set_ICH - dd (CTRL_CK8S shl 16)+VID_NVIDIA,msg_CK8S,set_ICH - dd (CTRL_MCP51 shl 16)+VID_NVIDIA,msg_MCP51,set_ICH + dd (CTRL_NFORCE shl 16)+VID_NVIDIA,msg_NForce, set_ICH + dd (CTRL_NFORCE2 shl 16)+VID_NVIDIA,msg_NForce2,set_ICH + dd (CTRL_NFORCE3 shl 16)+VID_NVIDIA,msg_NForce3,set_ICH + dd (CTRL_MCP04 shl 16)+VID_NVIDIA,msg_MCP04,set_ICH + dd (CTRL_CK804 shl 16)+VID_NVIDIA,msg_CK804,set_ICH + dd (CTRL_CK8 shl 16)+VID_NVIDIA,msg_CK8,set_ICH + dd (CTRL_CK8S shl 16)+VID_NVIDIA,msg_CK8S,set_ICH + dd (CTRL_MCP51 shl 16)+VID_NVIDIA,msg_MCP51,set_ICH - dd 0 ;terminator + dd 0 ;terminator version dd (5 shl 16) or (API_VERSION and 0xFFFF) @@ -1437,14 +1437,14 @@ msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0 msgPlay db 'start play', 13,10,0 msgStop db 'stop play', 13,10,0 ;msgNotify db 'call notify',13,10,0 -msgIRQ db 'AC97 IRQ', 13,10,0 +msgIRQ db 'AC97 IRQ', 13,10,0 msgInitCtrl db 'init controller',13,10,0 ;msgInitCodec db 'init codec',13,10,0 msgPrimBuff db 'create primary buffer ...',0 msgDone db 'done',13,10,0 msgRemap db 'Remap IRQ',13,10,0 ;msgReg db 'set service handler',13,10,0 -msgOk db 'service installed',13,10,0 +msgOk db 'service installed',13,10,0 msgCold db 'cold reset',13,10,0 msgWarm db 'warm reset',13,10,0 msgWRFail db 'warm reset failed',13,10,0 @@ -1463,8 +1463,8 @@ msgIrqMap db 'AC97 irq map as ',0 section '.data' data readable writable align 16 -pcmout_bdl rq 32 -buff_list rd 32 +pcmout_bdl rq 32 +buff_list rd 32 codec CODEC ctrl AC_CNTRL diff --git a/kernel/trunk/drivers/uart.asm b/kernel/trunk/drivers/uart.asm index 83458819ac..8502b4f589 100644 --- a/kernel/trunk/drivers/uart.asm +++ b/kernel/trunk/drivers/uart.asm @@ -10,25 +10,25 @@ format MS COFF include 'proc32.inc' include 'imports.inc' -API_VERSION equ 0 -UART_VERSION equ API_VERSION +API_VERSION equ 0 +UART_VERSION equ API_VERSION -PG_SW equ 0x003 -page_tabs equ 0xFDC00000 ;hack +PG_SW equ 0x003 +page_tabs equ 0xFDC00000 ;hack -OS_BASE equ 0x80000000 -SLOT_BASE equ (OS_BASE+0x0080000) -TASK_COUNT equ (OS_BASE+0x0003004) -CURRENT_TASK equ (OS_BASE+0x0003000) +OS_BASE equ 0x80000000 +SLOT_BASE equ (OS_BASE+0x0080000) +TASK_COUNT equ (OS_BASE+0x0003004) +CURRENT_TASK equ (OS_BASE+0x0003000) -struc APPOBJ ;common object header +struc APPOBJ ;common object header { - .magic dd ? ; - .destroy dd ? ;internal destructor - .fd dd ? ;next object in list - .bk dd ? ;prev object in list - .pid dd ? ;owner id + .magic dd ? ; + .destroy dd ? ;internal destructor + .fd dd ? ;next object in list + .bk dd ? ;prev object in list + .pid dd ? ;owner id }; virtual at 0 @@ -36,138 +36,138 @@ virtual at 0 end virtual struc IOCTL -{ .handle dd ? - .io_code dd ? - .input dd ? - .inp_size dd ? - .output dd ? - .out_size dd ? +{ .handle dd ? + .io_code dd ? + .input dd ? + .inp_size dd ? + .output dd ? + .out_size dd ? } virtual at 0 IOCTL IOCTL end virtual -DEBUG equ 1 +DEBUG equ 1 -DRV_ENTRY equ 1 -DRV_EXIT equ -1 +DRV_ENTRY equ 1 +DRV_EXIT equ -1 -THR_REG equ 0; x3f8 ;transtitter/reciever -IER_REG equ 1; x3f9 ;interrupt enable -IIR_REG equ 2; x3fA ;interrupt info -LCR_REG equ 3; x3FB ;line control -MCR_REG equ 4; x3FC ;modem control -LSR_REG equ 5; x3FD ;line status -MSR_REG equ 6; x3FE ;modem status +THR_REG equ 0; x3f8 ;transtitter/reciever +IER_REG equ 1; x3f9 ;interrupt enable +IIR_REG equ 2; x3fA ;interrupt info +LCR_REG equ 3; x3FB ;line control +MCR_REG equ 4; x3FC ;modem control +LSR_REG equ 5; x3FD ;line status +MSR_REG equ 6; x3FE ;modem status -LCR_5BIT equ 0x00 -LCR_6BIT equ 0x01 -LCR_7BIT equ 0x02 -LCR_8BIT equ 0x03 -LCR_STOP_1 equ 0x00 -LCR_STOP_2 equ 0x04 -LCR_PARITY equ 0x08 -LCR_EVEN equ 0x10 -LCR_STICK equ 0x20 -LCR_BREAK equ 0x40 -LCR_DLAB equ 0x80 +LCR_5BIT equ 0x00 +LCR_6BIT equ 0x01 +LCR_7BIT equ 0x02 +LCR_8BIT equ 0x03 +LCR_STOP_1 equ 0x00 +LCR_STOP_2 equ 0x04 +LCR_PARITY equ 0x08 +LCR_EVEN equ 0x10 +LCR_STICK equ 0x20 +LCR_BREAK equ 0x40 +LCR_DLAB equ 0x80 -LSR_DR equ 0x01 ;data ready -LSR_OE equ 0x02 ;overrun error -LSR_PE equ 0x04 ;parity error -LSR_FE equ 0x08 ;framing error -LSR_BI equ 0x10 ;break interrupt -LSR_THRE equ 0x20 ;transmitter holding empty -LSR_TEMT equ 0x40 ;transmitter empty -LSR_FER equ 0x80 ;FIFO error +LSR_DR equ 0x01 ;data ready +LSR_OE equ 0x02 ;overrun error +LSR_PE equ 0x04 ;parity error +LSR_FE equ 0x08 ;framing error +LSR_BI equ 0x10 ;break interrupt +LSR_THRE equ 0x20 ;transmitter holding empty +LSR_TEMT equ 0x40 ;transmitter empty +LSR_FER equ 0x80 ;FIFO error -FCR_EFIFO equ 0x01 ;enable FIFO -FCR_CRB equ 0x02 ;clear reciever FIFO -FCR_CXMIT equ 0x04 ;clear transmitter FIFO -FCR_RDY equ 0x08 ;set RXRDY and TXRDY pins -FCR_FIFO_1 equ 0x00 ;1 byte trigger -FCR_FIFO_4 equ 0x40 ;4 bytes trigger -FCR_FIFO_8 equ 0x80 ;8 bytes trigger -FCR_FIFO_14 equ 0xC0 ;14 bytes trigger +FCR_EFIFO equ 0x01 ;enable FIFO +FCR_CRB equ 0x02 ;clear reciever FIFO +FCR_CXMIT equ 0x04 ;clear transmitter FIFO +FCR_RDY equ 0x08 ;set RXRDY and TXRDY pins +FCR_FIFO_1 equ 0x00 ;1 byte trigger +FCR_FIFO_4 equ 0x40 ;4 bytes trigger +FCR_FIFO_8 equ 0x80 ;8 bytes trigger +FCR_FIFO_14 equ 0xC0 ;14 bytes trigger -IIR_INTR equ 0x01 ;1= no interrupts +IIR_INTR equ 0x01 ;1= no interrupts -IER_RDAI equ 0x01 ;reciever data interrupt -IER_THRI equ 0x02 ;transmitter empty interrupt -IER_LSI equ 0x04 ;line status interrupt -IER_MSI equ 0x08 ;modem status interrupt +IER_RDAI equ 0x01 ;reciever data interrupt +IER_THRI equ 0x02 ;transmitter empty interrupt +IER_LSI equ 0x04 ;line status interrupt +IER_MSI equ 0x08 ;modem status interrupt -MCR_DTR equ 0x01 ;0-> DTR=1, 1-> DTR=0 -MCR_RTS equ 0x02 ;0-> RTS=1, 1-> RTS=0 -MCR_OUT_1 equ 0x04 ;0-> OUT1=1, 1-> OUT1=0 -MCR_OUT_2 equ 0x08 ;0-> OUT2=1, 1-> OUT2=0; enable intr -MCR_LOOP equ 0x10 ;lopback mode +MCR_DTR equ 0x01 ;0-> DTR=1, 1-> DTR=0 +MCR_RTS equ 0x02 ;0-> RTS=1, 1-> RTS=0 +MCR_OUT_1 equ 0x04 ;0-> OUT1=1, 1-> OUT1=0 +MCR_OUT_2 equ 0x08 ;0-> OUT2=1, 1-> OUT2=0; enable intr +MCR_LOOP equ 0x10 ;lopback mode -MSR_DCTS equ 0x01 ;delta clear to send -MSR_DDSR equ 0x02 ;delta data set redy -MSR_TERI equ 0x04 ;trailinh edge of ring -MSR_DDCD equ 0x08 ;delta carrier detect +MSR_DCTS equ 0x01 ;delta clear to send +MSR_DDSR equ 0x02 ;delta data set redy +MSR_TERI equ 0x04 ;trailinh edge of ring +MSR_DDCD equ 0x08 ;delta carrier detect -RATE_50 equ 0 -RATE_75 equ 1 -RATE_110 equ 2 -RATE_134 equ 3 -RATE_150 equ 4 -RATE_300 equ 5 -RATE_600 equ 6 -RATE_1200 equ 7 -RATE_1800 equ 8 -RATE_2000 equ 9 -RATE_2400 equ 10 -RATE_3600 equ 11 -RATE_4800 equ 12 -RATE_7200 equ 13 -RATE_9600 equ 14 -RATE_19200 equ 15 -RATE_38400 equ 16 -RATE_57600 equ 17 -RATE_115200 equ 18 +RATE_50 equ 0 +RATE_75 equ 1 +RATE_110 equ 2 +RATE_134 equ 3 +RATE_150 equ 4 +RATE_300 equ 5 +RATE_600 equ 6 +RATE_1200 equ 7 +RATE_1800 equ 8 +RATE_2000 equ 9 +RATE_2400 equ 10 +RATE_3600 equ 11 +RATE_4800 equ 12 +RATE_7200 equ 13 +RATE_9600 equ 14 +RATE_19200 equ 15 +RATE_38400 equ 16 +RATE_57600 equ 17 +RATE_115200 equ 18 -COM_1 equ 1 -COM_2 equ 2 -COM_3 equ 3 -COM_4 equ 4 -COM_MAX equ 2 ;only two port supported +COM_1 equ 1 +COM_2 equ 2 +COM_3 equ 3 +COM_4 equ 4 +COM_MAX equ 2 ;only two port supported -COM_1_BASE equ 0x3F8 -COM_2_BASE equ 0x2F8 +COM_1_BASE equ 0x3F8 +COM_2_BASE equ 0x2F8 -COM_1_IRQ equ 4 -COM_2_IRQ equ 3 +COM_1_IRQ equ 4 +COM_2_IRQ equ 3 -UART_CLOSED equ 0 -UART_TRANSMIT equ 1 -UART_STOP equ 2 +UART_CLOSED equ 0 +UART_TRANSMIT equ 1 +UART_STOP equ 2 struc UART { - .lock dd ? - .base dd ? - .lcr_reg dd ? - .mcr_reg dd ? - .rate dd ? - .mode dd ? - .state dd ? + .lock dd ? + .base dd ? + .lcr_reg dd ? + .mcr_reg dd ? + .rate dd ? + .mode dd ? + .state dd ? - .rcvr_buff dd ? - .rcvr_rp dd ? - .rcvr_wp dd ? - .rcvr_count dd ? - .rcvr_top dd ? + .rcvr_buff dd ? + .rcvr_rp dd ? + .rcvr_wp dd ? + .rcvr_count dd ? + .rcvr_top dd ? - .xmit_buff dd ? - .xmit_rp dd ? - .xmit_wp dd ? - .xmit_count dd ? - .xmit_free dd ? - .xmit_top dd ? + .xmit_buff dd ? + .xmit_rp dd ? + .xmit_wp dd ? + .xmit_count dd ? + .xmit_free dd ? + .xmit_top dd ? } virtual at 0 UART UART @@ -177,14 +177,14 @@ UART_SIZE equ 18*4 struc CONNECTION { - .magic dd ? ;'CNCT' - .destroy dd ? ;internal destructor - .fd dd ? ;next object in list - .bk dd ? ;prev object in list - .pid dd ? ;owner id + .magic dd ? ;'CNCT' + .destroy dd ? ;internal destructor + .fd dd ? ;next object in list + .bk dd ? ;prev object in list + .pid dd ? ;owner id - .id dd ? ;reserved - .uart dd ? ;uart pointer + .id dd ? ;reserved + .uart dd ? ;uart pointer } virtual at 0 @@ -201,150 +201,150 @@ section '.flat' code readable align 16 proc START stdcall, state:dword - cmp [state], 1 - jne .stop + cmp [state], 1 + jne .stop - mov eax, UART_SIZE - call Kmalloc - test eax, eax - jz .fail + mov eax, UART_SIZE + call Kmalloc + test eax, eax + jz .fail - mov [com1], eax - mov edi, eax - mov ecx, UART_SIZE/4 - xor eax, eax - cld - rep stosd + mov [com1], eax + mov edi, eax + mov ecx, UART_SIZE/4 + xor eax, eax + cld + rep stosd - mov eax, [com1] - mov [eax+UART.base], COM_1_BASE + mov eax, [com1] + mov [eax+UART.base], COM_1_BASE - stdcall AllocKernelSpace, 32768 + stdcall AllocKernelSpace, 32768 - mov edi, [com1] - mov edx, eax + mov edi, [com1] + mov edx, eax - mov [edi+UART.rcvr_buff], eax - add eax, 8192 - mov [edi+UART.rcvr_top], eax - add eax, 8192 - mov [edi+UART.xmit_buff], eax - add eax, 8192 - mov [edi+UART.xmit_top], eax + mov [edi+UART.rcvr_buff], eax + add eax, 8192 + mov [edi+UART.rcvr_top], eax + add eax, 8192 + mov [edi+UART.xmit_buff], eax + add eax, 8192 + mov [edi+UART.xmit_top], eax - call AllocPage - test eax, eax - jz .fail + call AllocPage + test eax, eax + jz .fail - shr edx, 12 - or eax, PG_SW - mov [page_tabs+edx*4], eax - mov [page_tabs+edx*4+8], eax + shr edx, 12 + or eax, PG_SW + mov [page_tabs+edx*4], eax + mov [page_tabs+edx*4+8], eax - call AllocPage - test eax, eax - jz .fail + call AllocPage + test eax, eax + jz .fail - or eax, PG_SW - mov [page_tabs+edx*4+4], eax - mov [page_tabs+edx*4+12], eax + or eax, PG_SW + mov [page_tabs+edx*4+4], eax + mov [page_tabs+edx*4+12], eax - call AllocPage - test eax, eax - jz .fail + call AllocPage + test eax, eax + jz .fail - or eax, PG_SW - mov [page_tabs+edx*4+16], eax - mov [page_tabs+edx*4+24], eax + or eax, PG_SW + mov [page_tabs+edx*4+16], eax + mov [page_tabs+edx*4+24], eax - call AllocPage - test eax, eax - jz .fail + call AllocPage + test eax, eax + jz .fail - or eax, PG_SW - mov [page_tabs+edx*4+20], eax - mov [page_tabs+edx*4+28], eax + or eax, PG_SW + mov [page_tabs+edx*4+20], eax + mov [page_tabs+edx*4+28], eax - mov eax, [edi+UART.rcvr_buff] - invlpg [eax] - invlpg [eax+0x1000] - invlpg [eax+0x2000] - invlpg [eax+0x3000] - invlpg [eax+0x4000] - invlpg [eax+0x5000] - invlpg [eax+0x6000] - invlpg [eax+0x7000] + mov eax, [edi+UART.rcvr_buff] + invlpg [eax] + invlpg [eax+0x1000] + invlpg [eax+0x2000] + invlpg [eax+0x3000] + invlpg [eax+0x4000] + invlpg [eax+0x5000] + invlpg [eax+0x6000] + invlpg [eax+0x7000] - mov eax, edi - call uart_reset.internal ;eax= uart + mov eax, edi + call uart_reset.internal ;eax= uart - stdcall AttachIntHandler, COM_1_IRQ, com_1_isr - stdcall RegService, sz_uart_srv, service_proc - ret + stdcall AttachIntHandler, COM_1_IRQ, com_1_isr, dword 0 + stdcall RegService, sz_uart_srv, service_proc + ret .fail: .stop: - xor eax, eax - ret + xor eax, eax + ret endp -handle equ IOCTL.handle -io_code equ IOCTL.io_code -input equ IOCTL.input -inp_size equ IOCTL.inp_size -output equ IOCTL.output -out_size equ IOCTL.out_size +handle equ IOCTL.handle +io_code equ IOCTL.io_code +input equ IOCTL.input +inp_size equ IOCTL.inp_size +output equ IOCTL.output +out_size equ IOCTL.out_size -SRV_GETVERSION equ 0 -PORT_OPEN equ 1 -PORT_CLOSE equ 2 -PORT_RESET equ 3 -PORT_SETMODE equ 4 -PORT_GETMODE equ 5 -PORT_SETMCR equ 6 -PORT_GETMCR equ 7 -PORT_READ equ 8 -PORT_WRITE equ 9 +SRV_GETVERSION equ 0 +PORT_OPEN equ 1 +PORT_CLOSE equ 2 +PORT_RESET equ 3 +PORT_SETMODE equ 4 +PORT_GETMODE equ 5 +PORT_SETMCR equ 6 +PORT_GETMCR equ 7 +PORT_READ equ 8 +PORT_WRITE equ 9 align 4 proc service_proc stdcall, ioctl:dword - mov ebx, [ioctl] - mov eax, [ebx+io_code] - cmp eax, PORT_WRITE - ja .fail + mov ebx, [ioctl] + mov eax, [ebx+io_code] + cmp eax, PORT_WRITE + ja .fail - cmp eax, SRV_GETVERSION - jne @F + cmp eax, SRV_GETVERSION + jne @F - mov eax, [ebx+output] - cmp [ebx+out_size], 4 - jne .fail - mov [eax], dword UART_VERSION - xor eax, eax - ret + mov eax, [ebx+output] + cmp [ebx+out_size], 4 + jne .fail + mov [eax], dword UART_VERSION + xor eax, eax + ret @@: - cmp eax, PORT_OPEN - jne @F + cmp eax, PORT_OPEN + jne @F - cmp [ebx+out_size], 4 - jne .fail + cmp [ebx+out_size], 4 + jne .fail - mov ebx, [ebx+input] - mov eax, [ebx] - call uart_open - mov ebx, [ioctl] - mov ebx, [ebx+output] - mov [ebx], ecx - ret + mov ebx, [ebx+input] + mov eax, [ebx] + call uart_open + mov ebx, [ioctl] + mov ebx, [ebx+output] + mov [ebx], ecx + ret @@: - mov esi, [ebx+input] ;input buffer - mov edi, [ebx+output] - call [uart_func+eax*4] - ret + mov esi, [ebx+input] ;input buffer + mov edi, [ebx+output] + call [uart_func+eax*4] + ret .fail: - or eax, -1 - ret + or eax, -1 + ret endp @@ -365,16 +365,16 @@ restore out_size align 4 uart_reset: - mov eax, [esi] - cmp [eax+APPOBJ.magic], 'CNCT' - jne .fail + mov eax, [esi] + cmp [eax+APPOBJ.magic], 'CNCT' + jne .fail - cmp [eax+APPOBJ.destroy], uart_close.destroy - jne .fail + cmp [eax+APPOBJ.destroy], uart_close.destroy + jne .fail - mov eax, [eax+CONNECTION.uart] - test eax, eax - jz .fail + mov eax, [eax+CONNECTION.uart] + test eax, eax + jz .fail ; set mode 2400 bod 8-bit ; disable DTR & RTS @@ -386,92 +386,92 @@ uart_reset: align 4 .internal: - mov esi, eax - mov [eax+UART.state], UART_CLOSED - mov edx, [eax+UART.base] - add edx, MCR_REG - xor eax, eax - out dx, al ;clear DTR & RTS + mov esi, eax + mov [eax+UART.state], UART_CLOSED + mov edx, [eax+UART.base] + add edx, MCR_REG + xor eax, eax + out dx, al ;clear DTR & RTS - mov eax, esi - mov ebx, RATE_2400 - mov ecx, LCR_8BIT+LCR_STOP_1 - call uart_set_mode.internal + mov eax, esi + mov ebx, RATE_2400 + mov ecx, LCR_8BIT+LCR_STOP_1 + call uart_set_mode.internal - mov edx, [esi+UART.base] - add edx, IIR_REG - mov eax,FCR_EFIFO+FCR_CRB+FCR_CXMIT+FCR_FIFO_14 - out dx, al + mov edx, [esi+UART.base] + add edx, IIR_REG + mov eax,FCR_EFIFO+FCR_CRB+FCR_CXMIT+FCR_FIFO_14 + out dx, al .clear_RB: - mov edx, [esi+UART.base] - add edx, LSR_REG - in al, dx - test eax, LSR_DR - jz @F + mov edx, [esi+UART.base] + add edx, LSR_REG + in al, dx + test eax, LSR_DR + jz @F - mov edx, [esi+UART.base] - in al, dx - jmp .clear_RB + mov edx, [esi+UART.base] + in al, dx + jmp .clear_RB @@: - mov edx, [esi+UART.base] - add edx, IER_REG - mov eax,IER_RDAI+IER_THRI+IER_LSI - out dx, al + mov edx, [esi+UART.base] + add edx, IER_REG + mov eax,IER_RDAI+IER_THRI+IER_LSI + out dx, al .clear_IIR: - mov edx, [esi+UART.base] - add edx, IIR_REG - in al, dx - test al, IIR_INTR - jnz .done + mov edx, [esi+UART.base] + add edx, IIR_REG + in al, dx + test al, IIR_INTR + jnz .done - shr eax, 1 - and eax, 3 - jnz @F + shr eax, 1 + and eax, 3 + jnz @F - mov edx, [esi+UART.base] - add edx, MSR_REG - in al, dx - jmp .clear_IIR + mov edx, [esi+UART.base] + add edx, MSR_REG + in al, dx + jmp .clear_IIR @@: - cmp eax, 1 - je .clear_IIR + cmp eax, 1 + je .clear_IIR - cmp eax, 2 - jne @F + cmp eax, 2 + jne @F - mov edx, [esi+UART.base] - in al, dx - jmp .clear_IIR + mov edx, [esi+UART.base] + in al, dx + jmp .clear_IIR @@: - mov edx, [esi+UART.base] - add edx, LSR_REG - in al, dx - jmp .clear_IIR + mov edx, [esi+UART.base] + add edx, LSR_REG + in al, dx + jmp .clear_IIR .done: - mov edi, [esi+UART.rcvr_buff] - mov ecx, 8192/4 - xor eax, eax + mov edi, [esi+UART.rcvr_buff] + mov ecx, 8192/4 + xor eax, eax - mov [esi+UART.rcvr_rp], edi - mov [esi+UART.rcvr_wp], edi - mov [esi+UART.rcvr_count], eax + mov [esi+UART.rcvr_rp], edi + mov [esi+UART.rcvr_wp], edi + mov [esi+UART.rcvr_count], eax - cld - rep stosd + cld + rep stosd - mov edi, [esi+UART.xmit_buff] - mov ecx, 8192/4 + mov edi, [esi+UART.xmit_buff] + mov ecx, 8192/4 - mov [esi+UART.xmit_rp], edi - mov [esi+UART.xmit_wp], edi - mov [esi+UART.xmit_count], eax - mov [esi+UART.xmit_free], 8192 + mov [esi+UART.xmit_rp], edi + mov [esi+UART.xmit_wp], edi + mov [esi+UART.xmit_count], eax + mov [esi+UART.xmit_free], 8192 - rep stosd - ret ;eax= 0 + rep stosd + ret ;eax= 0 .fail: - or eax, -1 - ret + or eax, -1 + ret ; param ; esi= input buffer @@ -484,19 +484,19 @@ align 4 align 4 uart_set_mode: - mov eax, [esi] - cmp [eax+APPOBJ.magic], 'CNCT' - jne .fail + mov eax, [esi] + cmp [eax+APPOBJ.magic], 'CNCT' + jne .fail - cmp [eax+APPOBJ.destroy], uart_close.destroy - jne .fail + cmp [eax+APPOBJ.destroy], uart_close.destroy + jne .fail - mov eax, [eax+CONNECTION.uart] - test eax, eax - jz .fail + mov eax, [eax+CONNECTION.uart] + test eax, eax + jz .fail - mov ebx, [esi+4] - mov ecx, [esi+8] + mov ebx, [esi+4] + mov ecx, [esi+8] ; param ; eax= uart @@ -505,41 +505,41 @@ uart_set_mode: align 4 .internal: - cmp ebx, RATE_115200 - ja .fail + cmp ebx, RATE_115200 + ja .fail - cmp ecx, LCR_BREAK - jae .fail + cmp ecx, LCR_BREAK + jae .fail - mov [eax+UART.rate], ebx - mov [eax+UART.mode], ecx + mov [eax+UART.rate], ebx + mov [eax+UART.mode], ecx - mov esi, eax - mov bx, [divisor+ebx*2] + mov esi, eax + mov bx, [divisor+ebx*2] - mov edx, [esi+UART.base] - push edx - add edx, LCR_REG - in al, dx - or al, 0x80 - out dx, al + mov edx, [esi+UART.base] + push edx + add edx, LCR_REG + in al, dx + or al, 0x80 + out dx, al - pop edx - mov al, bl - out dx, al + pop edx + mov al, bl + out dx, al - inc dx - mov al, bh - out dx, al + inc dx + mov al, bh + out dx, al - add edx, LCR_REG-1 - mov eax, ecx - out dx, al - xor eax, eax - ret + add edx, LCR_REG-1 + mov eax, ecx + out dx, al + xor eax, eax + ret .fail: - or eax, -1 - ret + or eax, -1 + ret ; param ; esi= input buffer @@ -552,29 +552,29 @@ align 4 align 4 uart_set_mcr: - mov eax, [esi] - cmp [eax+APPOBJ.magic], 'CNCT' - jne .fail + mov eax, [esi] + cmp [eax+APPOBJ.magic], 'CNCT' + jne .fail - cmp [eax+APPOBJ.destroy], uart_close.destroy - jne .fail + cmp [eax+APPOBJ.destroy], uart_close.destroy + jne .fail - mov eax, [eax+CONNECTION.uart] - test eax, eax - jz .fail + mov eax, [eax+CONNECTION.uart] + test eax, eax + jz .fail - mov ebx, [esi+4] + mov ebx, [esi+4] - mov [eax+UART.mcr_reg], ebx - mov edx, [eax+UART.base] - add edx, MCR_REG - mov al, bl - out dx, al - xor eax, eax - ret + mov [eax+UART.mcr_reg], ebx + mov edx, [eax+UART.base] + add edx, MCR_REG + mov al, bl + out dx, al + xor eax, eax + ret .fail: - or eax, -1 - ret + or eax, -1 + ret ; param ; eax= port @@ -585,44 +585,44 @@ uart_set_mcr: align 4 uart_open: - dec eax - cmp eax, COM_MAX - jae .fail + dec eax + cmp eax, COM_MAX + jae .fail - mov esi, [com1+eax*4] ;uart - push esi + mov esi, [com1+eax*4] ;uart + push esi .do_wait: - cmp dword [esi+UART.lock],0 - je .get_lock + cmp dword [esi+UART.lock],0 + je .get_lock ; call change_task - jmp .do_wait + jmp .do_wait .get_lock: - mov eax, 1 - xchg eax, [esi+UART.lock] - test eax, eax - jnz .do_wait + mov eax, 1 + xchg eax, [esi+UART.lock] + test eax, eax + jnz .do_wait - mov eax, esi ;uart - call uart_reset.internal + mov eax, esi ;uart + call uart_reset.internal - mov ebx, [CURRENT_TASK] - shl ebx, 5 - mov ebx, [CURRENT_TASK+ebx+4] - mov eax, CONNECTION_SIZE - call CreateObject - pop esi ;uart - test eax, eax - jz .fail + mov ebx, [CURRENT_TASK] + shl ebx, 5 + mov ebx, [CURRENT_TASK+ebx+4] + mov eax, CONNECTION_SIZE + call CreateObject + pop esi ;uart + test eax, eax + jz .fail - mov [eax+APPOBJ.magic], 'CNCT' - mov [eax+APPOBJ.destroy], uart_close.destroy - mov [eax+CONNECTION.uart], esi - mov ecx, eax - xor eax, eax - ret + mov [eax+APPOBJ.magic], 'CNCT' + mov [eax+APPOBJ.destroy], uart_close.destroy + mov [eax+CONNECTION.uart], esi + mov ecx, eax + xor eax, eax + ret .fail: - or eax, -1 - ret + or eax, -1 + ret restore .uart ; param @@ -630,26 +630,26 @@ restore .uart align 4 uart_close: - mov eax, [esi] - cmp [eax+APPOBJ.magic], 'CNCT' - jne .fail + mov eax, [esi] + cmp [eax+APPOBJ.magic], 'CNCT' + jne .fail - cmp [eax+APPOBJ.destroy], uart_close.destroy - jne .fail + cmp [eax+APPOBJ.destroy], uart_close.destroy + jne .fail .destroy: - push [eax+CONNECTION.uart] - call DestroyObject ;eax= object - pop eax ;eax= uart - test eax, eax - jz .fail + push [eax+CONNECTION.uart] + call DestroyObject ;eax= object + pop eax ;eax= uart + test eax, eax + jz .fail - mov [eax+UART.state], UART_CLOSED - mov [eax+UART.lock], 0 ;release port - xor eax, eax - ret + mov [eax+UART.state], UART_CLOSED + mov [eax+UART.lock], 0 ;release port + xor eax, eax + ret .fail: - or eax, -1 - ret + or eax, -1 + ret ; param @@ -658,32 +658,32 @@ uart_close: align 4 set_rate: - cmp ebx, RATE_115200 - ja .fail + cmp ebx, RATE_115200 + ja .fail - mov [eax+UART.rate], ebx - mov bx, [divisor+ebx*2] + mov [eax+UART.rate], ebx + mov bx, [divisor+ebx*2] - mov edx, [eax+UART.base] - add edx, LCR_REG - in al, dx - push eax - or al, 0x80 - out dx, al + mov edx, [eax+UART.base] + add edx, LCR_REG + in al, dx + push eax + or al, 0x80 + out dx, al - sub edx, LCR_REG - mov al, bl - out dx, al + sub edx, LCR_REG + mov al, bl + out dx, al - inc edx - mov al, bh - out dx, al + inc edx + mov al, bh + out dx, al - pop eax - add edx, LCR_REG-1 - out dx, al + pop eax + add edx, LCR_REG-1 + out dx, al .fail: - ret + ret ; param @@ -691,50 +691,50 @@ set_rate: align 4 transmit: - push esi - push edi + push esi + push edi - mov edx, [ebx+UART.base] + mov edx, [ebx+UART.base] - pushfd - cli + pushfd + cli - mov esi, [ebx+UART.xmit_rp] - mov ecx, [ebx+UART.xmit_count] - test ecx, ecx - je .stop + mov esi, [ebx+UART.xmit_rp] + mov ecx, [ebx+UART.xmit_count] + test ecx, ecx + je .stop - cmp ecx, 16 - jbe @F - mov ecx, 16 + cmp ecx, 16 + jbe @F + mov ecx, 16 @@: - sub [ebx+UART.xmit_count], ecx - add [ebx+UART.xmit_free], ecx - cld + sub [ebx+UART.xmit_count], ecx + add [ebx+UART.xmit_free], ecx + cld @@: - lodsb - out dx, al - dec ecx - jnz @B + lodsb + out dx, al + dec ecx + jnz @B - cmp esi,[ebx+UART.xmit_top] - jb @F - sub esi, 8192 + cmp esi,[ebx+UART.xmit_top] + jb @F + sub esi, 8192 @@: - mov [ebx+UART.xmit_rp], esi + mov [ebx+UART.xmit_rp], esi - cmp [ebx+UART.xmit_count], 0 - je .stop + cmp [ebx+UART.xmit_count], 0 + je .stop - mov [ebx+UART.state], UART_TRANSMIT - jmp @F + mov [ebx+UART.state], UART_TRANSMIT + jmp @F .stop: - mov [ebx+UART.state], UART_STOP + mov [ebx+UART.state], UART_STOP @@: - popfd - pop edi - pop esi - ret + popfd + pop edi + pop esi + ret ; param @@ -750,47 +750,47 @@ transmit: align 4 uart_read: - mov eax, [esi] - cmp [eax+APPOBJ.magic], 'CNCT' - jne .fail + mov eax, [esi] + cmp [eax+APPOBJ.magic], 'CNCT' + jne .fail - cmp [eax+APPOBJ.destroy], uart_close.destroy - jne .fail + cmp [eax+APPOBJ.destroy], uart_close.destroy + jne .fail - mov eax, [eax+CONNECTION.uart] - test eax, eax - jz .fail + mov eax, [eax+CONNECTION.uart] + test eax, eax + jz .fail - mov ebx, [esi+8] ;dst size - mov ecx, [eax+UART.rcvr_count] - cmp ecx, ebx - jbe @F - mov ecx, ebx + mov ebx, [esi+8] ;dst size + mov ecx, [eax+UART.rcvr_count] + cmp ecx, ebx + jbe @F + mov ecx, ebx @@: - mov [edi], ecx ;bytes read - test ecx, ecx - jz .done + mov [edi], ecx ;bytes read + test ecx, ecx + jz .done - push ecx + push ecx - mov edi, [esi+4] ;dst - mov esi, [eax+UART.rcvr_rp] - cld - rep movsb - pop ecx + mov edi, [esi+4] ;dst + mov esi, [eax+UART.rcvr_rp] + cld + rep movsb + pop ecx - cmp esi, [eax+UART.rcvr_top] - jb @F - sub esi, 8192 + cmp esi, [eax+UART.rcvr_top] + jb @F + sub esi, 8192 @@: - mov [eax+UART.rcvr_rp], esi - sub [eax+UART.rcvr_count], ecx + mov [eax+UART.rcvr_rp], esi + sub [eax+UART.rcvr_count], ecx .done: - xor eax, eax - ret + xor eax, eax + ret .fail: - or eax, -1 - ret + or eax, -1 + ret ; param ; esi= input buffer @@ -803,19 +803,19 @@ uart_read: align 4 uart_write: - mov eax, [esi] - cmp [eax+APPOBJ.magic], 'CNCT' - jne .fail + mov eax, [esi] + cmp [eax+APPOBJ.magic], 'CNCT' + jne .fail - cmp [eax+APPOBJ.destroy], uart_close.destroy - jne .fail + cmp [eax+APPOBJ.destroy], uart_close.destroy + jne .fail - mov eax, [eax+CONNECTION.uart] - test eax, eax - jz .fail + mov eax, [eax+CONNECTION.uart] + test eax, eax + jz .fail - mov ebx, [esi+4] - mov edx, [esi+8] + mov ebx, [esi+4] + mov edx, [esi+8] ; param ; eax= uart @@ -824,142 +824,142 @@ uart_write: align 4 .internal: - mov esi, ebx - mov edi, [eax+UART.xmit_wp] + mov esi, ebx + mov edi, [eax+UART.xmit_wp] .write: - test edx, edx - jz .fail + test edx, edx + jz .fail .wait: - cmp [eax+UART.xmit_free], 0 - jne .fill + cmp [eax+UART.xmit_free], 0 + jne .fill - cmp [eax+UART.state], UART_TRANSMIT - je .wait + cmp [eax+UART.state], UART_TRANSMIT + je .wait - mov ebx, eax - push edx - call transmit - pop edx - mov eax, ebx - jmp .write + mov ebx, eax + push edx + call transmit + pop edx + mov eax, ebx + jmp .write .fill: - mov ecx, [eax+UART.xmit_free] - cmp ecx, edx - jbe @F - mov ecx, edx + mov ecx, [eax+UART.xmit_free] + cmp ecx, edx + jbe @F + mov ecx, edx @@: - push ecx - cld - rep movsb - pop ecx - sub [eax+UART.xmit_free], ecx - add [eax+UART.xmit_count], ecx - sub edx, ecx - jnz .wait + push ecx + cld + rep movsb + pop ecx + sub [eax+UART.xmit_free], ecx + add [eax+UART.xmit_count], ecx + sub edx, ecx + jnz .wait .done: - cmp edi, [eax+UART.xmit_top] - jb @F - sub edi, 8192 + cmp edi, [eax+UART.xmit_top] + jb @F + sub edi, 8192 @@: - mov [eax+UART.xmit_wp], edi - cmp [eax+UART.state], UART_TRANSMIT - je @F - mov ebx, eax - call transmit + mov [eax+UART.xmit_wp], edi + cmp [eax+UART.state], UART_TRANSMIT + je @F + mov ebx, eax + call transmit @@: - xor eax, eax - ret + xor eax, eax + ret .fail: - or eax, -1 - ret + or eax, -1 + ret align 4 com_2_isr: - mov ebx, [com2] - jmp com_1_isr.get_info + mov ebx, [com2] + jmp com_1_isr.get_info align 4 com_1_isr: - mov ebx, [com1] + mov ebx, [com1] .get_info: - mov edx, [ebx+UART.base] - add edx, IIR_REG - in al, dx + mov edx, [ebx+UART.base] + add edx, IIR_REG + in al, dx - test al, IIR_INTR - jnz .done + test al, IIR_INTR + jnz .done - shr eax, 1 - and eax, 3 + shr eax, 1 + and eax, 3 - call [isr_action+eax*4] - jmp .get_info + call [isr_action+eax*4] + jmp .get_info .done: - ret + ret align 4 isr_line: - mov edx, [ebx+UART.base] - add edx, LSR_REG - in al, dx - ret + mov edx, [ebx+UART.base] + add edx, LSR_REG + in al, dx + ret align 4 isr_recieve: - mov esi, [ebx+UART.base] - add esi, LSR_REG - mov edi, [ebx+UART.rcvr_wp] - xor ecx, ecx - cld + mov esi, [ebx+UART.base] + add esi, LSR_REG + mov edi, [ebx+UART.rcvr_wp] + xor ecx, ecx + cld .read: - mov edx, esi - in al, dx - test eax, LSR_DR - jz .done + mov edx, esi + in al, dx + test eax, LSR_DR + jz .done - mov edx, [ebx+UART.base] - in al, dx - stosb - inc ecx - jmp .read + mov edx, [ebx+UART.base] + in al, dx + stosb + inc ecx + jmp .read .done: - cmp edi, [ebx+UART.rcvr_top] - jb @F - sub edi, 8192 + cmp edi, [ebx+UART.rcvr_top] + jb @F + sub edi, 8192 @@: - mov [ebx+UART.rcvr_wp], edi - add [ebx+UART.rcvr_count], ecx - ret + mov [ebx+UART.rcvr_wp], edi + add [ebx+UART.rcvr_count], ecx + ret align 4 isr_modem: - mov edx, [ebx+UART.base] - add edx, MSR_REG - in al, dx - ret + mov edx, [ebx+UART.base] + add edx, MSR_REG + in al, dx + ret align 4 divisor dw 2304, 1536, 1047, 857, 768, 384 - dw 192, 96, 64, 58, 48, 32 - dw 24, 16, 12, 6, 3, 2, 1 + dw 192, 96, 64, 58, 48, 32 + dw 24, 16, 12, 6, 3, 2, 1 align 4 -uart_func dd 0 ;SRV_GETVERSION - dd 0 ;PORT_OPEN - dd uart_close ;PORT_CLOSE - dd uart_reset ;PORT_RESET - dd uart_set_mode ;PORT_SETMODE - dd 0 ;PORT_GETMODE - dd uart_set_mcr ;PORT_SETMODEM - dd 0 ;PORT_GETMODEM - dd uart_read ;PORT_READ - dd uart_write ;PORT_WRITE +uart_func dd 0 ;SRV_GETVERSION + dd 0 ;PORT_OPEN + dd uart_close ;PORT_CLOSE + dd uart_reset ;PORT_RESET + dd uart_set_mode ;PORT_SETMODE + dd 0 ;PORT_GETMODE + dd uart_set_mcr ;PORT_SETMODEM + dd 0 ;PORT_GETMODEM + dd uart_read ;PORT_READ + dd uart_write ;PORT_WRITE isr_action dd isr_modem - dd transmit - dd isr_recieve - dd isr_line + dd transmit + dd isr_recieve + dd isr_line version dd (5 shl 16) or (UART_VERSION and 0xFFFF) @@ -967,6 +967,6 @@ sz_uart_srv db 'UART',0 align 4 -com1 rd 1 -com2 rd 1 +com1 rd 1 +com2 rd 1 diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index f34b73a7ae..ae19165e0d 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -638,16 +638,6 @@ no_lib_load: mov [pci_access_enabled],1 - ;call detect_devices - stdcall load_driver, szPS2MDriver - stdcall load_driver, szCOM_MDriver - -; SET MOUSE - - mov esi,boot_setmouse - call boot_log - call setmouse - ; SET PRELIMINARY WINDOW STACK AND POSITIONS @@ -748,6 +738,17 @@ no_lib_load: call set_variables +; SET MOUSE + + ;call detect_devices + stdcall load_driver, szPS2MDriver + stdcall load_driver, szCOM_MDriver + + mov esi,boot_setmouse + call boot_log + call setmouse + + ; STACK AND FDC call stack_init @@ -884,7 +885,7 @@ end if loop ready_for_irqs ; flush the queue - stdcall attach_int_handler, dword 1, irq1 + stdcall attach_int_handler, dword 1, irq1, dword 0 ; mov [dma_hdd],1 cmp [IDEContrRegsBaseAddr], 0 @@ -4205,7 +4206,7 @@ reserve_free_irq: mov ebx, [f_irqs + 4 * eax] - stdcall attach_int_handler, eax, ebx + stdcall attach_int_handler, eax, ebx, dword 0 mov [ecx], edi @@ -5034,6 +5035,9 @@ syscall_getirqowner: ; GetIrqOwner cmp ebx,16 jae .err + cmp [irq_rights + 4 * ebx], dword 2 + je .err + mov eax,[4 * ebx + irq_owner] mov [esp+32],eax