diff --git a/kernel/branches/flat_kernel/core/dll.inc b/kernel/branches/flat_kernel/core/dll.inc index 4016a681dc..1fd3be6d30 100644 --- a/kernel/branches/flat_kernel/core/dll.inc +++ b/kernel/branches/flat_kernel/core/dll.inc @@ -6,8 +6,8 @@ $Revision: 431 $ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -DRV_COMPAT equ 4 ;minimal required drivers version -DRV_CURRENT equ 4 ;current drivers model version +DRV_COMPAT equ 5 ;minimal required drivers version +DRV_CURRENT equ 5 ;current drivers model version DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT diff --git a/kernel/branches/flat_kernel/drivers/ati2d.asm b/kernel/branches/flat_kernel/drivers/ati2d.asm index 0537c67a35..728a62b288 100644 --- a/kernel/branches/flat_kernel/drivers/ati2d.asm +++ b/kernel/branches/flat_kernel/drivers/ati2d.asm @@ -10,16 +10,18 @@ format MS COFF include 'proc32.inc' include 'imports.inc' -DEBUG equ 1 +API_VERSION equ 0x01000100 -VID_ATI equ 0x1002 +DEBUG equ 1 + +VID_ATI equ 0x1002 LOAD_FROM_FILE equ 0 LOAD_FROM_MEM equ 1 LOAD_INDIRECT equ 2 LOAD_SYSTEM equ 3 -VIDEO_FREE equ 2 +SRV_GETVERSION equ 0 struc BITMAPINFOHEADER { .biSize dd ? ; DWORD @@ -229,13 +231,16 @@ out_size equ IOCTL.out_size align 4 proc service_proc stdcall, ioctl:dword - mov edi, [ioctl] - mov ebx, [edi+io_code] - cmp ebx, VIDEO_FREE + mov ebx, [ioctl] + cmp [ebx+io_code], SRV_GETVERSION jne .fail - mov eax, [edi+input] - call video_free + mov eax, [ebx+output] + cmp [ebx+out_size], 4 + jne .fail + mov [eax], dword API_VERSION + xor eax, eax + ret .fail: or eax, -1 ret @@ -986,7 +991,7 @@ devices dd (R8500 shl 16)+VID_ATI dd (R9800XT shl 16)+VID_ATI dd 0 ;terminator -version dd 0x00040004 +version dd (5 shl 16) or (API_VERSION and 0xFFFF) sz_ati_srv db 'HWCURSOR',0 diff --git a/kernel/branches/flat_kernel/drivers/infinity.asm b/kernel/branches/flat_kernel/drivers/infinity.asm index 559743f509..57be5d2ceb 100644 --- a/kernel/branches/flat_kernel/drivers/infinity.asm +++ b/kernel/branches/flat_kernel/drivers/infinity.asm @@ -10,6 +10,10 @@ format MS COFF +API_VERSION equ 0x01000100 +SOUND_VERSION equ API_VERSION + + include 'proc32.inc' include 'main.inc' include 'imports.inc' @@ -160,6 +164,8 @@ proc service_proc stdcall, ioctl:dword cmp eax, SRV_GETVERSION jne @F mov eax, [edi+output] + cmp [edi+out_size], 4 + jne .fail mov eax, [eax] mov [eax], dword SOUND_VERSION xor eax, eax @@ -1245,7 +1251,7 @@ vol_min dd 0x0000D8F0,0x0000D8F0 pan_max dd 0x00002710,0x00002710 ;stream_map dd 0xFFFF ; 16 -version dd (4 shl 16) or (SOUND_VERSION and 0xFFFF) +version dd (5 shl 16) or (SOUND_VERSION and 0xFFFF) szInfinity db 'INFINITY',0 szSound db 'SOUND',0 @@ -1277,3 +1283,8 @@ mix_2_core rd 1 mix_3_core rd 1 mix_4_core rd 1 + + + + + diff --git a/kernel/branches/flat_kernel/drivers/main.inc b/kernel/branches/flat_kernel/drivers/main.inc index 51c2e0ef4d..d4b2588b5c 100644 --- a/kernel/branches/flat_kernel/drivers/main.inc +++ b/kernel/branches/flat_kernel/drivers/main.inc @@ -8,11 +8,9 @@ ; (C) copyright Serge 2006-2007 ; email: infinity_sound@mail.ru -SOUND_VERSION equ 0x01000100 PLAY_SYNC equ 0x80000000 - PCM_ALL equ 0 PCM_OUT equ 0x08000000 diff --git a/kernel/branches/flat_kernel/drivers/sceletone.asm b/kernel/branches/flat_kernel/drivers/sceletone.asm index 72d7f0e2d8..dfbb5ee499 100644 --- a/kernel/branches/flat_kernel/drivers/sceletone.asm +++ b/kernel/branches/flat_kernel/drivers/sceletone.asm @@ -9,6 +9,8 @@ format MS COFF +API_VERSION equ 0 ;debug + include 'proc32.inc' include 'imports.inc' @@ -33,11 +35,13 @@ public START public service_proc public version -DEBUG equ 1 +DEBUG equ 1 -DRV_ENTRY equ 1 -DRV_EXIT equ -1 -STRIDE equ 4 ;size of row in devices table +DRV_ENTRY equ 1 +DRV_EXIT equ -1 +STRIDE equ 4 ;size of row in devices table + +SRV_GETVERSION equ 0 section '.flat' code readable align 16 @@ -53,7 +57,7 @@ proc START stdcall, state:dword end if stdcall RegService, my_service, service_proc - ret + ret .fail: .exit: xor eax, eax @@ -70,11 +74,21 @@ out_size equ IOCTL.out_size align 4 proc service_proc stdcall, ioctl:dword -; mov edi, [ioctl] -; mov eax, [edi+io_code] + mov ebx, [ioctl] + mov eax, [ebx+io_code] + cmp eax, SRV_GETVERSION + jne @F - xor eax, eax - ret + mov eax, [ebx+output] + cmp [ebx+out_size], 4 + jne .fail + mov [eax], dword API_VERSION + xor eax, eax + ret +@@: +.fail: + or eax, -1 + ret endp restore handle @@ -86,70 +100,70 @@ restore out_size align 4 proc detect - locals - last_bus dd ? - endl + locals + last_bus dd ? + endl - xor eax, eax - mov [bus], eax - inc eax + xor eax, eax + mov [bus], eax + inc eax call PciApi - cmp eax, -1 + 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 + 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 - cmp eax, ebx - je .found add edi, STRIDE 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 -.found: - xor eax, eax +.next: + inc [devfn] + cmp [devfn], 256 + jb .next_dev + mov eax, [bus] inc eax - ret + mov [bus], eax + cmp eax, [last_bus] + jna .next_bus + xor eax, eax + ret +.found: + xor eax, eax + inc eax + ret .err: xor eax, eax ret endp - -;DEVICE_ID equ ; pci device id -;VENDOR_ID equ ; device vendor id +DEVICE_ID equ 1234; pci device id +VENDOR_ID equ 5678; device vendor id ;all initialized data place here align 4 -devices dd (DEVICE_ID shl 16)+VENDOR_ID - dd 0 ;terminator +devices dd (DEVICE_ID shl 16)+VENDOR_ID + dd 0 ;terminator -version dd 0x00030003 +version dd (5 shl 16) or (API_VERSION and 0xFFFF) my_service db 'MY_SERVICE',0 ;max 16 chars include zero diff --git a/kernel/branches/flat_kernel/drivers/sis.asm b/kernel/branches/flat_kernel/drivers/sis.asm index 834c1a59bb..50aa3314b8 100644 --- a/kernel/branches/flat_kernel/drivers/sis.asm +++ b/kernel/branches/flat_kernel/drivers/sis.asm @@ -10,6 +10,8 @@ format MS COFF include 'proc32.inc' include 'imports.inc' +API_VERSION equ 0x01000100 + DEBUG equ 1 CPU_FREQ equ 2000d ;cpu freq in MHz @@ -90,6 +92,7 @@ CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable CODEC_REG_POWERDOWN equ 0x26 CODEC_REG_ST equ 0x26 +SRV_GETVERSION equ 0 DEV_PLAY equ 1 DEV_STOP equ 2 DEV_CALLBACK equ 3 @@ -339,6 +342,18 @@ proc service_proc stdcall, ioctl:dword mov edi, [ioctl] mov eax, [edi+io_code] + + cmp eax, SRV_GETVERSION + jne @F + + mov eax, [edi+output] + cmp [edi+out_size], 4 + jne .fail + + mov [eax], dword API_VERSION + xor eax, eax + ret +@@: cmp eax, DEV_PLAY jne @F if DEBUG @@ -1135,7 +1150,7 @@ align 4 devices dd (CTRL_SIS shl 16)+VID_SIS,msg_AC, set_SIS dd 0 -version dd 0x00040004 +version dd (5 shl 16) or (API_VERSION and 0xFFFF) msg_AC db '7012 AC97 controller',13,10, 0 msg_SIS db 'Silicon Integrated Systems',13,10, 0 diff --git a/kernel/branches/flat_kernel/drivers/sound.asm b/kernel/branches/flat_kernel/drivers/sound.asm index 1f6099b64d..227cda1cc5 100644 --- a/kernel/branches/flat_kernel/drivers/sound.asm +++ b/kernel/branches/flat_kernel/drivers/sound.asm @@ -11,6 +11,8 @@ format MS COFF include 'proc32.inc' include 'imports.inc' +API_VERSION equ 0x01000100 + DEBUG equ 1 REMAP_IRQ equ 0 @@ -57,6 +59,9 @@ BIT29 EQU 0x20000000 BIT30 EQU 0x40000000 BIT31 EQU 0x80000000 +PCM_4 equ BIT20 +PCM_6 equ BIT21 + VID_INTEL equ 0x8086 VID_NVIDIA equ 0x10DE @@ -90,16 +95,16 @@ 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 18h ; PCM output volume -CODEC_EXT_AUDIO_REG equ 28h ; extended audio -CODEC_EXT_AUDIO_CTRL_REG equ 2ah ; extended audio control -CODEC_PCM_FRONT_DACRATE_REG equ 2ch ; PCM out sample rate -CODEC_PCM_SURND_DACRATE_REG equ 2eh ; surround sound sample rate -CODEC_PCM_LFE_DACRATE_REG equ 30h ; LFE sample rate +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 +GLOB_CTRL equ 0x2C ; Global Control CTRL_STAT equ 0x30 ; Global Status CTRL_CAS equ 0x34 ; Codec Access Semiphore @@ -118,6 +123,7 @@ CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable CODEC_REG_POWERDOWN equ 0x26 CODEC_REG_ST equ 0x26 +SRV_GETVERSION equ 0 DEV_PLAY equ 1 DEV_STOP equ 2 DEV_CALLBACK equ 3 @@ -250,24 +256,24 @@ struc CODEC ;Audio Chip base class } struc CTRL_INFO -{ .pci_cmd dd ? - .irq dd ? - .glob_cntrl dd ? - .glob_sta dd ? - .codec_io_base dd ? - .ctrl_io_base dd ? - .codec_mem_base dd ? - .ctrl_mem_base dd ? - .codec_id dd ? +{ .pci_cmd dd ? + .irq dd ? + .glob_cntrl dd ? + .glob_sta dd ? + .codec_io_base dd ? + .ctrl_io_base dd ? + .codec_mem_base dd ? + .ctrl_mem_base 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 @@ -385,6 +391,18 @@ proc service_proc stdcall, ioctl:dword mov edi, [ioctl] mov eax, [edi+io_code] + + cmp eax, SRV_GETVERSION + jne @F + + mov eax, [edi+output] + cmp [edi+out_size], 4 + jne .fail + + mov [eax], dword API_VERSION + xor eax, eax + ret +@@: cmp eax, DEV_PLAY jne @F if DEBUG @@ -871,6 +889,12 @@ proc init_codec xor eax, eax ; timeout error ret .ready: + 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 xor eax, eax @@ -1356,7 +1380,8 @@ devices dd (CTRL_ICH shl 16)+VID_INTEL,msg_ICH, set_ICH dd 0 ;terminator -version dd 0x00040004 + +version dd (5 shl 16) or (API_VERSION and 0xFFFF) msg_ICH db 'Intel ICH', 13,10, 0 msg_ICH0 db 'Intel ICH0', 13,10, 0 diff --git a/kernel/branches/flat_kernel/drivers/uart.asm b/kernel/branches/flat_kernel/drivers/uart.asm index ef491ef364..83458819ac 100644 --- a/kernel/branches/flat_kernel/drivers/uart.asm +++ b/kernel/branches/flat_kernel/drivers/uart.asm @@ -10,6 +10,9 @@ format MS COFF include 'proc32.inc' include 'imports.inc' +API_VERSION equ 0 +UART_VERSION equ API_VERSION + PG_SW equ 0x003 page_tabs equ 0xFDC00000 ;hack @@ -190,8 +193,6 @@ end virtual CONNECTION_SIZE equ 7*4 -UART_VERSION equ 0x12345678 ;debug - public START public service_proc public version @@ -317,6 +318,8 @@ proc service_proc stdcall, ioctl:dword jne @F mov eax, [ebx+output] + cmp [ebx+out_size], 4 + jne .fail mov [eax], dword UART_VERSION xor eax, eax ret @@ -324,6 +327,9 @@ proc service_proc stdcall, ioctl:dword cmp eax, PORT_OPEN jne @F + cmp [ebx+out_size], 4 + jne .fail + mov ebx, [ebx+input] mov eax, [ebx] call uart_open @@ -955,7 +961,7 @@ isr_action dd isr_modem dd isr_recieve dd isr_line -version dd 0x00040000 +version dd (5 shl 16) or (UART_VERSION and 0xFFFF) sz_uart_srv db 'UART',0 diff --git a/kernel/branches/flat_kernel/video/cursors.inc b/kernel/branches/flat_kernel/video/cursors.inc index 13993f86e6..68eba0ead8 100644 --- a/kernel/branches/flat_kernel/video/cursors.inc +++ b/kernel/branches/flat_kernel/video/cursors.inc @@ -10,7 +10,6 @@ LOAD_FROM_FILE equ 0 LOAD_FROM_MEM equ 1 LOAD_INDIRECT equ 2 LOAD_SYSTEM equ 3 -VIDEO_FREE equ 2 struc BITMAPINFOHEADER { .biSize dd ? ; DWORD