From 36ae3b7991bd865c1a9733f2eb3ba54f8ff4a9aa Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Sat, 2 Dec 2006 08:18:48 +0000 Subject: [PATCH] 1)drivers version control 2)extended events format 3)ATI hardware cursor git-svn-id: svn://kolibrios.org@227 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/boot/shutdown.inc | 23 +- kernel/trunk/const.inc | 2 +- kernel/trunk/core/dll.inc | 84 ++- kernel/trunk/core/exports.inc | 10 +- kernel/trunk/core/memory.inc | 25 +- kernel/trunk/drivers/ati2d.asm | 427 +++++++++----- kernel/trunk/drivers/infinity.asm | 472 ++++++++-------- kernel/trunk/drivers/mixer.asm | 44 +- kernel/trunk/drivers/sceletone.asm | 10 +- kernel/trunk/drivers/sis.asm | 861 ++++++++++++++--------------- kernel/trunk/drivers/unisound.asm | 17 +- kernel/trunk/gui/event.inc | 197 ++++++- kernel/trunk/kernel.asm | 6 +- kernel/trunk/kernel32.inc | 12 +- kernel/trunk/video/cursors.inc | 159 +++--- 15 files changed, 1348 insertions(+), 1001 deletions(-) diff --git a/kernel/trunk/boot/shutdown.inc b/kernel/trunk/boot/shutdown.inc index 87cd3675c6..430ca6a6d8 100644 --- a/kernel/trunk/boot/shutdown.inc +++ b/kernel/trunk/boot/shutdown.inc @@ -171,6 +171,10 @@ system_shutdown: ; shut down the system call restorefatchain + mov al, 0xFF + out 0x21, al + out 0xA1, al + mov word [0x467+0],pr_mode_exit-0x10000 mov word [0x467+2],0x1000 @@ -203,30 +207,31 @@ org $-0x10000 call rdelay out 0xA0,al call rdelay - + mov al,0x08 out 0x21,al call rdelay mov al,0x70 out 0xA1,al call rdelay - + mov al,0x04 out 0x21,al call rdelay mov al,0x02 out 0xA1,al call rdelay - + mov al,0x01 out 0x21,al call rdelay out 0xA1,al call rdelay - - mov al,0 + + mov al,0xB8 out 0x21,al call rdelay + mov al,0xBD out 0xA1,al sti @@ -238,7 +243,7 @@ org $-0x10000 jl nbw cmp al,4 jle nbw32 - + nbw: in al,0x60 call pause_key @@ -280,7 +285,7 @@ org $-0x10000 jnz restart_kernel ; 4 = restart kernel push 0x40 pop ds - mov word[0x0072],0x1234 + mov word[0x0072],0x1234 jmp 0xF000:0xFFF0 pause_key: @@ -499,7 +504,7 @@ shutdowntext: db '1) SAVE RAMDISK TO FLOPPY ' db '2) APM - POWEROFF ' db '3) REBOOT ' - db '4) RESTART KERNEL ' + db '4) RESTART KERNEL ' else if lang eq ru shutdowntext: db "Безопасное выключение компьютера или " @@ -515,7 +520,7 @@ shutdowntext: db '1) RAMDISK AUF DISK SPEICHERN ' db '2) APM - AUSSCHALTEN ' db '3) NEUSTARTEN ' - db '4) KERNEL NEU STARTEN ' + db '4) KERNEL NEU STARTEN ' end if rosef: db 'ROSE TXT' diff --git a/kernel/trunk/const.inc b/kernel/trunk/const.inc index f9a50a5507..e5fa4a6c35 100644 --- a/kernel/trunk/const.inc +++ b/kernel/trunk/const.inc @@ -296,7 +296,7 @@ EVENT_MOUSE equ 0x00000020 EVENT_IPC equ 0x00000040 EVENT_NETWORK equ 0x00000080 EVENT_DEBUG equ 0x00000100 -EVENT_NOTIFY equ 0x00000200 +EVENT_EXTENDED equ 0x00000200 EV_INTR equ 1 diff --git a/kernel/trunk/core/dll.inc b/kernel/trunk/core/dll.inc index 9b4b96213e..069ea1f679 100644 --- a/kernel/trunk/core/dll.inc +++ b/kernel/trunk/core/dll.inc @@ -1,6 +1,10 @@ -DRV_ENTRY equ 1 -DRV_EXIT equ -1 +DRV_ENTRY equ 1 +DRV_EXIT equ -1 +DRV_COMPAT equ 1 ;minimal required drivers version +DRV_CURRENT equ 1 ;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 @@ -704,7 +708,7 @@ proc load_driver stdcall, file_name:dword stdcall load_file, [file_name] test eax, eax - jz .fail + jz .exit mov [coff], eax @@ -775,23 +779,25 @@ proc load_driver stdcall, file_name:dword stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\ [strings], ebx test eax, eax - jnz @F + jz .link_fail - mov esi, msg_module - call sys_msg_board_str - mov esi, [file_name] - call sys_msg_board_str - mov esi, msg_CR - call sys_msg_board_str - - stdcall kernel_free,[coff] - xor eax, eax - ret -@@: mov ebx, [coff] add ebx, 20 stdcall fix_coff_relocs, [coff], ebx, [sym] + mov ebx, [coff] + stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szVersion + test eax, eax + jz .link_fail + + mov eax, [eax] + shr eax, 16 + cmp eax, DRV_COMPAT + jb .ver_fail + + cmp eax, DRV_CURRENT + ja .ver_fail + mov ebx, [coff] stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szSTART mov [start], eax @@ -812,7 +818,32 @@ proc load_driver stdcall, file_name:dword mov ecx, [start] mov [eax+SRV.entry], ecx ret + +.ver_fail: + mov esi, msg_CR + call sys_msg_board_str + mov esi, [file_name] + call sys_msg_board_str + mov esi, msg_CR + call sys_msg_board_str + mov esi, msg_version + call sys_msg_board_str + mov esi, msg_www + call sys_msg_board_str + jmp .cleanup + +.link_fail: + mov esi, msg_module + call sys_msg_board_str + mov esi, [file_name] + call sys_msg_board_str + mov esi, msg_CR + call sys_msg_board_str +.cleanup: + stdcall kernel_free,[img_base] .fail: + stdcall kernel_free, [coff] +.exit: xor eax, eax ret endp @@ -924,20 +955,19 @@ endp align 4 proc stop_all_services - pushf - cli - mov eax, [srv_map] - not eax - mov [srv_map], eax + not [srv_map] .next: bsf eax, [srv_map] jnz .find - popf ret .find: btr [srv_map], eax shl eax,0x02 lea eax,[srv_tab+eax+eax*8] ;srv_tab+eax*36 + cmp [eax+SRV.magic], ' SRV' + jne .next + cmp [eax+SRV.size], SRV_SIZE + jne .next mov ebx, [eax+SRV.entry] stdcall ebx, dword -1 jmp .next @@ -946,13 +976,11 @@ endp drv_sound db '/rd/1/drivers/unisound.obj', 0 drv_infinity db '/rd/1/drivers/infinity.obj', 0 -;drv_ati2d db '/rd/1/drivers/vesa.obj', 0 -;drv_cursor db '/rd/1/drivers/vesa.obj',0 +drv_hw_mouse db '/rd/1/drivers/ati2d.obj',0 szSound db 'SOUND',0 szInfinity db 'INFINITY',0 -;szHMouse db 'ATI2D',0 -;szCURSOR db 'VESACURSOR',0 +szHwMouse db 'HWCURSOR',0 szSTART db 'START',0 szEXPORTS db 'EXPORTS',0 @@ -960,9 +988,12 @@ szIMPORTS db 'IMPORTS',0 msg_unresolved db 'unresolved ',0 msg_module db 'in module ',0 +msg_version db 'incompatible driver version',13,10,0 +msg_www db 'please visit www.kolibrios.org',13,10,0 msg_CR db 13,10,0 align 4 +create_cursor dd 0 set_hw_cursor dd 0 hw_restore dd 0 @@ -970,6 +1001,5 @@ align 16 services: dd szSound, drv_sound dd szInfinity, drv_infinity -; dd szHMouse, drv_ati2d -; dd szCURSOR, drv_cursor + dd szHwMouse, drv_hw_mouse dd 0 diff --git a/kernel/trunk/core/exports.inc b/kernel/trunk/core/exports.inc index febecf36c4..0284072fe6 100644 --- a/kernel/trunk/core/exports.inc +++ b/kernel/trunk/core/exports.inc @@ -1,6 +1,7 @@ iglobal szKernel db 'KERNEL', 0 + szVersion db 'version',0 szAttachIntHandler db 'AttachIntHandler',0 szSysMsgBoardStr db 'SysMsgBoardStr', 0 szPciApi db 'PciApi', 0 @@ -20,9 +21,11 @@ iglobal szFpuRestore db 'FpuRestore',0 szLoadCursor db 'LoadCursor',0 szSetHwCursor db 'SetHwCursor',0 - szHWRestore db 'HWRestore', 0 + szHwCursorRestore db 'HwCursorRestore', 0 + szHwCursorCreate db 'HwCursorCreate', 0 szLFBAddress db 'LFBAddress',0 szLoadFile db 'LoadFile',0 + szSendEvent db 'SendEvent',0 align 16 kernel_export: @@ -45,12 +48,13 @@ kernel_export: dd szFpuRestore , fpu_restore dd szLoadCursor , load_cursor dd szSetHwCursor , set_hw_cursor - dd szHWRestore , hw_restore + dd szHwCursorRestore , hw_restore + dd szHwCursorCreate , create_cursor dd szLoadFile , load_file + dd szSendEvent , send_event exp_lfb: dd szLFBAddress , 0 dd 0 - endg diff --git a/kernel/trunk/core/memory.inc b/kernel/trunk/core/memory.inc index 4263ab1470..7521886130 100644 --- a/kernel/trunk/core/memory.inc +++ b/kernel/trunk/core/memory.inc @@ -806,12 +806,14 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword add edi, [ipc_tmp] cmp dword [edi], 0 jnz .ipc_blocked ;if dword [buffer]<>0 - ipc blocked now + mov ebx, dword [edi+4] mov edx, ebx add ebx, 8 add ebx, [msg_size] cmp ebx, [buf_size] ja .buffer_overflow ;esi<0 - not enough memory in buffer + mov dword [edi+4], ebx mov eax,[TASK_BASE] mov eax, [eax+0x04] ;eax - our PID @@ -937,10 +939,11 @@ new_services: @@: cmp eax, 14 ja @f - add ebx,new_app_base + add ebx, new_app_base cmp ebx, new_app_base jb .fail - stdcall get_notify, ebx + stdcall get_event_ex, ebx, ecx + mov [esp+36], eax ret @@: cmp eax, 15 @@ -980,14 +983,14 @@ new_services: ret @@: cmp eax, 19 - ja @f + ja .fail add ebx, new_app_base cmp ebx, new_app_base jb .fail stdcall load_library, ebx mov [esp+36], eax ret -@@: + .fail: xor eax, eax mov [esp+36], eax @@ -1293,18 +1296,21 @@ endg uglobal align 16 + dll_tab rb 32*32 srv_tab rb 36*32 + mem_block_map rb 512 + event_map rb 128 + mem_block_list rd 64 + mem_block_mask rd 2 + dll_map rd 1 srv_map rd 1 mem_used_list rd 1 - mem_block_list rd 64 - mem_block_map rb 512 mem_block_arr rd 1 mem_block_start rd 1 mem_block_end rd 1 - mem_block_mask rd 2 heap_size rd 1 heap_free rd 1 heap_blocks rd 1 @@ -1312,8 +1318,11 @@ align 16 page_start rd 1 page_end rd 1 + events rd 1 + event_start rd 1 + event_end rd 1 + sys_page_map rd 1 -; app_load rd 1 endg diff --git a/kernel/trunk/drivers/ati2d.asm b/kernel/trunk/drivers/ati2d.asm index 88b1473240..c602436f13 100644 --- a/kernel/trunk/drivers/ati2d.asm +++ b/kernel/trunk/drivers/ati2d.asm @@ -6,10 +6,47 @@ format MS COFF include 'proc32.inc' -DEBUG equ 0 +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 + +struc BITMAPINFOHEADER { + .biSize dd ? ; DWORD + .biWidth dd ? ; LONG + .biHeight dd ? ; LONG + .biPlanes dw ? ; WORD + .biBitCount dw ? ; WORD + .biCompression dd ? ; DWORD + .biSizeImage dd ? ; DWORD + .biXPelsPerMeter dd ? ; LONG + .biYPelsPerMeter dd ? ; LONG + .biClrUsed dd ? ; DWORD + .biClrImportant dd ? ; DWORD +} + +virtual at 0 + BI BITMAPINFOHEADER +end virtual + +struc CURSOR +{ .magic dd ? + .size dd ? + .pid dd ? + .base dd ? + .hot_x dd ? + .hot_y dd ? +} +virtual at 0 + CURSOR CURSOR +end virtual + +CURSOR_SIZE equ 24 + R8500 equ 0x514C ;R200 R9000 equ 0x4966 ;RV250 R9200 equ 0x5961 ;RV280 @@ -117,6 +154,7 @@ macro wrr dest, src public START public service_proc +public version extrn SysMsgBoardStr extrn PciApi @@ -125,6 +163,8 @@ extrn AllocKernelSpace extrn MapPage extrn RegService extrn SetHwCursor +extrn HwCursorRestore +extrn HwCursorCreate extrn LFBAddress extrn LoadFile @@ -137,47 +177,53 @@ section '.flat' code readable align 16 proc START stdcall, state:dword - mov eax, [state] - cmp eax, 1 - je .entry - jmp .exit -.entry: + cmp [state], 1 + jne .exit + if DEBUG mov esi, msgInit call SysMsgBoardStr end if call detect_ati - test eax, eax - jz .fail - - stdcall LoadFile, user_file test eax, eax - jz @F - mov [user_arrow], eax -@@: - stdcall ati_init_cursor, [user_arrow] + jz .fail call init_ati test eax, eax jz .fail + xor eax, eax + mov edi, cursors + mov ecx, CURSOR_SIZE*16 + cld + rep stosd + + not eax + mov [cursor_map], eax + mov [cursor_map+4], eax + mov edx, cursor_map + mov [cursor_start], edx + add edx, 4 + mov [cursor_end], edx + stdcall RegService, sz_ati_srv, service_proc test eax, eax jz .fail - mov ebx, SetHwCursor - mov dword [ebx], drvCursorPos ;enable hardware cursor - ret + mov dword [SetHwCursor], drvCursorPos ;enable hardware cursor + mov dword [HwCursorRestore], drv_restore + mov dword [HwCursorCreate], ati_cursor + ret .fail: if DEBUG - mov esi, msgFail + mov esi, msgFail call SysMsgBoardStr end if .exit: xor eax, eax - mov ebx, SetHwCursor - mov dword [ebx], eax ;force disable hardware cursor +; mov ebx, SetHwCursor +; mov dword [ebx], eax ;force disable hardware cursor ret endp @@ -194,8 +240,8 @@ proc service_proc stdcall, ioctl:dword ; mov edi, [ioctl] ; mov eax, [edi+io_code] - xor eax, eax - ret + xor eax, eax + ret endp restore handle @@ -207,53 +253,54 @@ restore out_size align 4 proc detect_ati - 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, 4 - jmp @B + 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 @@ -276,7 +323,7 @@ proc init_ati mov edx, 16 @@: stdcall MapPage,edi,esi,PG_SW+PG_NOCACHE - add edi, 0x1000 + add edi, 0x1000 add esi, 0x1000 dec edx jnz @B @@ -296,9 +343,6 @@ proc init_ati or eax, ebx mov [edi+0x50], eax - pushd 0 - pushd 0 - call drvCursorPos call drvShowCursor xor eax, eax inc eax @@ -306,6 +350,10 @@ proc init_ati ret endp +align 4 +drv_restore: + ret 8 + align 4 drvShowCursor: mov edi, [ati_io] @@ -316,25 +364,105 @@ drvShowCursor: ret align 4 -drvCursorPos: - push ebp - mov ebp, esp +proc drvCursorPos stdcall, hcursor:dword, x:dword, y:dword + mov eax, 80000000h wrr CUR_HORZ_VERT_OFF, eax - mov eax, [ebp+8] + mov eax, [x] shl eax, 16 - or eax, [ebp+12] + or eax, [y] or eax, 80000000h wrr CUR_HORZ_VERT_POSN, eax - mov eax, CURSOR_IMAGE_OFFSET + mov esi, [hcursor] + mov eax, [esi+CURSOR.base] + sub eax, LFBAddress wrr CUR_OFFSET, eax - leave - ret 8 + ret +endp align 4 -proc ati_init_cursor stdcall, arrow:dword +proc video_alloc + + pushfd + cli + mov ebx, [cursor_start] + mov ecx, [cursor_end] +.l1: + bsf eax,[ebx]; + jnz .found + add ebx,4 + cmp ebx, ecx + jb .l1 + popfd + xor eax,eax + ret +.found: + btr [ebx], eax + popfd + + mov [cursor_start],ebx + sub ebx, cursor_map + shl ebx, 3 + add eax,ebx + + shl eax,14 + add eax, LFBAddress+CURSOR_IMAGE_OFFSET + ret +endp + +align 4 +proc ati_cursor stdcall, hcursor:dword, src:dword, flags:dword + + stdcall video_alloc + + mov edi, [hcursor] + mov [edi+CURSOR.base], eax + + mov esi, [src] + mov ebx, [flags] + cmp bx, LOAD_INDIRECT + je .indirect + + movzx ecx, word [esi+10] + movzx edx, word [esi+12] + mov [edi+CURSOR.hot_x], ecx + mov [edi+CURSOR.hot_y], edx + + stdcall ati_init_cursor, eax, esi + mov eax, [hcursor] +.fail: + ret +.indirect: + shr ebx, 16 + movzx ecx, bh + movzx edx, bl + mov [eax+CURSOR.hot_x], ecx + mov [eax+CURSOR.hot_y], edx + + xchg edi, eax + push edi + mov ecx, 64*64 + xor eax,eax + rep stosd + + mov esi, [src] + pop edi + mov ebx, 32 + cld +@@: + mov ecx, 32 + rep movsd + add edi, 128 + dec ebx + jnz @B + mov eax, [hcursor] + ret +endp + +align 4 +proc ati_init_cursor stdcall, dst:dword, src:dword locals rBase dd ? pQuad dd ? @@ -345,12 +473,13 @@ proc ati_init_cursor stdcall, arrow:dword counter dd ? endl - cld - - mov esi, [arrow] - add esi,[esi+18d] - + mov esi, [src] + add esi,[esi+18] mov eax,esi + + cmp [esi+BI.biBitCount], 24 + je .img_24 +.img_4: add eax, [esi] mov [pQuad],eax add eax,64 @@ -415,30 +544,68 @@ proc ati_init_cursor stdcall, arrow:dword mov [rBase],edi sub [height],1 jnz .l1 + jmp .copy - mov edi, LFBAddress - add edi, CURSOR_IMAGE_OFFSET +.img_24: + add eax, [esi] + mov [pQuad],eax + add eax, 0xC00 + mov [pAnd],eax + mov eax,[esi+BI.biWidth] + mov [width],eax + mov ebx,[esi+BI.biHeight] + shr ebx,1 + mov [height],ebx + + mov edi, pCursor + add edi, 32*31*4 + mov [rBase],edi + + mov esi,[pAnd] + mov ebx, [pQuad] +.row_24: + mov eax, [esi] + bswap eax + mov [counter], 32 +@@: + xor edx, edx + shl eax,1 + setc dl + dec edx + + mov ecx, [ebx] + and ecx, 0x00FFFFFF + and ecx, edx + and edx, 0xFF000000 + or edx, ecx + mov [edi], edx + add ebx, 3 + add edi, 4 + dec [counter] + jnz @B + + add esi, 4 + mov edi,[rBase] + sub edi,128 + mov [rBase],edi + sub [height],1 + jnz .row_24 +.copy: + mov edi, [dst] mov ecx, 64*64 xor eax,eax rep stosd mov esi, pCursor - mov edi, LFBAddress - add edi, CURSOR_IMAGE_OFFSET + mov edi, [dst] mov ebx, 32 -lc: + cld +@@: mov ecx, 32 -lb: - mov eax, [esi] - mov [edi], eax - add esi, 4 - add edi, 4 - sub ecx, 1 - jnz lb - + rep movsd add edi, 128 - sub ebx, 1 - jnz lc + dec ebx + jnz @B ret endp @@ -489,21 +656,21 @@ cnt equ bp+8 align 4 proc engWaitForIdle - push dword 64 - call engWaitForFifo + push dword 64 + call engWaitForFifo - mov edi, [ati_io] - mov ecx ,RD_TIMEOUT + mov edi, [ati_io] + mov ecx ,RD_TIMEOUT @@: - mov eax, [edi+RD_RBBM_STATUS] - and eax,RD_RBBM_ACTIVE - jz .exit + mov eax, [edi+RD_RBBM_STATUS] + and eax,RD_RBBM_ACTIVE + jz .exit - sub ecx,1 - jnz @B + sub ecx,1 + jnz @B .exit: - call engFlush - ret + call engFlush + ret endp align 4 @@ -514,8 +681,8 @@ proc engRestore ; mov dword [MMIO+RD_RB2D_DSTCACHE_MODE], 0 - push dword 3 - call engWaitForFifo + push dword 3 + call engWaitForFifo mov edi, [ati_io] @@ -572,7 +739,6 @@ proc engRestore ret endp - align 4 engSetupSolidFill: push ebp @@ -603,28 +769,28 @@ w equ ebp+16 h equ ebp+20 color equ ebp+24 - push dword [ebp+24] - call engSetupSolidFill + push dword [ebp+24] + call engSetupSolidFill - push dword 2 - call engWaitForFifo + push dword 2 + call engWaitForFifo - mov edi, [ati_io] + mov edi, [ati_io] - mov eax, [y] - mov ebx, [x] - shl eax,16 - or eax, ebx + mov eax, [y] + mov ebx, [x] + shl eax,16 + or eax, ebx - mov ecx, [w] - mov edx, [h] - shl ecx,16 - or ecx, edx - mov [edi+RD_DST_Y_X], eax - mov [edi+RD_DST_WIDTH_HEIGHT], ecx - call engFlush - leave - ret 20 + mov ecx, [w] + mov edx, [h] + shl ecx,16 + or ecx, edx + mov [edi+RD_DST_Y_X], eax + mov [edi+RD_DST_WIDTH_HEIGHT], ecx + call engFlush + leave + ret 20 align 4 devices dd (R8500 shl 16)+VID_ATI @@ -641,28 +807,27 @@ devices dd (R8500 shl 16)+VID_ATI dd (R9800XT shl 16)+VID_ATI dd 0 ;terminator -;szKernel db 'KERNEL', 0 -sz_ati_srv db 'ATI2D',0 -user_file db '/rd/1/user.cur',0 +version dd 0x00010001 +sz_ati_srv db 'HWCURSOR',0 msgInit db 'detect hardware...',13,10,0 msgPCI db 'PCI accsess not supported',13,10,0 msgFail db 'device not found',13,10,0 -user_arrow dd pArrow - -align 16 -pArrow: - file 'arrow.cur' section '.data' data readable writable align 16 pCursor db 4096 dup(?) -bus dd ? -devfn dd ? -ati_io dd ? +cursors rb CURSOR_SIZE*64 +cursor_map rd 2 +cursor_start rd 1 +cursor_end rd 1 + +bus dd ? +devfn dd ? +ati_io dd ? diff --git a/kernel/trunk/drivers/infinity.asm b/kernel/trunk/drivers/infinity.asm index b6c625652c..6e607af78e 100644 --- a/kernel/trunk/drivers/infinity.asm +++ b/kernel/trunk/drivers/infinity.asm @@ -28,6 +28,7 @@ PROC_BASE equ OS_BASE+0x0080000 public START public service_proc +public version extrn AttachIntHandler extrn SysMsgBoardStr @@ -46,6 +47,7 @@ extrn GetService extrn ServiceHandler extrn FpuSave extrn FpuRestore +extrn SendEvent SND_CREATE_BUFF equ 2 SND_PLAY equ 3 @@ -74,11 +76,9 @@ section '.flat' code readable align 16 proc START stdcall, state:dword - mov eax, [state] - cmp eax, 1 - je .entry - jmp .exit -.entry: + cmp [state], 1 + jne .exit + stdcall GetService, szSound test eax, eax jz .fail @@ -102,22 +102,22 @@ proc START stdcall, state:dword stdcall set_handler, [hSound], new_mix stdcall RegService, szInfinity, service_proc - ret + ret .fail: if DEBUG - mov esi, msgFail + mov esi, msgFail call SysMsgBoardStr end if .exit: - xor eax, eax - ret + xor eax, eax + ret .out_of_mem: if DEBUG mov esi, msgMem call SysMsgBoardStr end if - xor eax, eax + xor eax, eax ret endp @@ -134,21 +134,21 @@ proc service_proc stdcall, ioctl:dword mov edi, [ioctl] mov eax, [edi+io_code] - cmp eax, SND_CREATE_BUFF - jne @F + cmp eax, SND_CREATE_BUFF + jne @F mov ebx, [edi+input] stdcall CreateBuffer,[ebx] - ret + ret @@: - cmp eax, SND_PLAY - jne @F + cmp eax, SND_PLAY + jne @F mov ebx, [edi+input] - stdcall play_buffer, [ebx] - ret + stdcall play_buffer, [ebx] + ret @@: - cmp eax, SND_STOP - jne @F + cmp eax, SND_STOP + jne @F ; if DEBUG ; mov esi, msgStop @@ -156,27 +156,27 @@ proc service_proc stdcall, ioctl:dword ; end if mov ebx, [edi+input] - stdcall stop_buffer, [ebx] - ret + stdcall stop_buffer, [ebx] + ret @@: - cmp eax, SND_SETBUFF - jne @F + cmp eax, SND_SETBUFF + jne @F mov ebx, [edi+input] - mov eax, [ebx+4] - add eax, new_app_base - stdcall set_buffer, [ebx],eax,[ebx+8],[ebx+12] - ret + mov eax, [ebx+4] + add eax, new_app_base + stdcall set_buffer, [ebx],eax,[ebx+8],[ebx+12] + ret @@: cmp eax, SND_DESTROY_BUFF - jne @F + jne @F mov ebx, [edi+input] stdcall DestroyBuffer, [ebx] - ret + ret @@: - xor eax, eax - ret + xor eax, eax + ret endp restore handle @@ -191,54 +191,54 @@ CURRENT_TASK equ 0x0003000 align 8 proc CreateBuffer stdcall, format:dword - locals - str dd ? - endl + locals + str dd ? + endl - call alloc_stream - and eax, eax - jz .fail - mov [str], eax + call alloc_stream + and eax, eax + jz .fail + mov [str], eax mov edi, eax - mov edx, [stream_count] - mov [stream_list+edx*4], eax - inc [stream_count] + mov edx, [stream_count] + mov [stream_list+edx*4], eax + inc [stream_count] - mov [edi+STREAM.magic], 'WAVE' - mov [edi+STREAM.size], STREAM_SIZE + mov [edi+STREAM.magic], 'WAVE' + mov [edi+STREAM.size], STREAM_SIZE stdcall KernelAlloc, 180*1024 - mov edi, [str] - mov [edi+STREAM.base], eax - mov [edi+STREAM.curr_seg], eax - mov [edi+STREAM.notify_off1], eax - add eax, 0x8000 - mov [edi+STREAM.notify_off2], eax - add eax, 0x7FFF - mov [edi+STREAM.limit], eax + mov edi, [str] + mov [edi+STREAM.base], eax + mov [edi+STREAM.curr_seg], eax + mov [edi+STREAM.notify_off1], eax + add eax, 0x8000 + mov [edi+STREAM.notify_off2], eax + add eax, 0x7FFF + mov [edi+STREAM.limit], eax - inc eax + inc eax - mov [edi+STREAM.work_buff], eax - mov [edi+STREAM.work_read], eax - mov [edi+STREAM.work_write], eax - mov [edi+STREAM.work_count], 0 - add eax, 0x10000 - mov [edi+STREAM.work_top], eax - add eax, 1024*32 - mov [edi+STREAM.r_buff], eax + mov [edi+STREAM.work_buff], eax + mov [edi+STREAM.work_read], eax + mov [edi+STREAM.work_write], eax + mov [edi+STREAM.work_count], 0 + add eax, 0x10000 + mov [edi+STREAM.work_top], eax + add eax, 1024*32 + mov [edi+STREAM.r_buff], eax - mov ebx, [CURRENT_TASK] + mov ebx, [CURRENT_TASK] shl ebx, 5 mov eax, [0x3000+ebx+4] - mov [edi+STREAM.notify_task], eax + mov [edi+STREAM.notify_task], eax - mov eax, [format] - mov [edi+STREAM.format], eax - mov [edi+STREAM.flags], SND_STOP + mov eax, [format] + mov [edi+STREAM.format], eax + mov [edi+STREAM.flags], SND_STOP xor ebx, ebx cmp eax, 19 @@ -247,7 +247,7 @@ proc CreateBuffer stdcall, format:dword @@: mov [edi+STREAM.r_silence], ebx - shl eax, 4 + shl eax, 4 mov ebx, [resampler_params+eax] mov ecx, [resampler_params+eax+4] mov edx, [resampler_params+eax+8] @@ -256,50 +256,50 @@ proc CreateBuffer stdcall, format:dword mov [edi+STREAM.r_end], ecx mov [edi+STREAM.r_dt], edx - mov ebx, [resampler_params+eax+12] - mov [edi+STREAM.resample], ebx + mov ebx, [resampler_params+eax+12] + mov [edi+STREAM.resample], ebx - mov edi, [edi+STREAM.base] - mov ecx, 180*1024/4 - xor eax, eax - rep stosd + mov edi, [edi+STREAM.base] + mov ecx, 180*1024/4 + xor eax, eax + rep stosd - mov eax, [str] - ret + mov eax, [str] + ret .fail: - xor eax, eax - ret + xor eax, eax + ret endp align 4 pid_to_slot: - push ebx - push ecx - mov ebx,[TASK_COUNT] - shl ebx,5 - mov ecx,2*32 + push ebx + push ecx + mov ebx,[TASK_COUNT] + shl ebx,5 + mov ecx,2*32 .loop: - cmp byte [CURRENT_TASK+ecx+0xa],9 - jz .endloop ;skip empty slots - cmp [CURRENT_TASK+ecx+0x4],eax ;check PID - jz .pid_found + cmp byte [CURRENT_TASK+ecx+0xa],9 + jz .endloop ;skip empty slots + cmp [CURRENT_TASK+ecx+0x4],eax ;check PID + jz .pid_found .endloop: - add ecx,32 - cmp ecx,ebx - jle .loop - pop ecx - pop ebx - xor eax,eax - ret + add ecx,32 + cmp ecx,ebx + jle .loop + pop ecx + pop ebx + xor eax,eax + ret .pid_found: - shr ecx,5 - mov eax,ecx - pop ecx - pop ebx - ret + shr ecx,5 + mov eax,ecx + pop ecx + pop ebx + ret align 4 proc DestroyBuffer stdcall, str:dword @@ -307,15 +307,15 @@ proc DestroyBuffer stdcall, str:dword mov esi, [str] cmp [esi+STREAM.magic], 'WAVE' - jne .fail + jne .fail cmp [esi+STREAM.size], STREAM_SIZE - jne .fail + jne .fail stdcall KernelFree, [esi+STREAM.base] mov eax, [str] - call free_stream + call free_stream mov edi, [str] mov ecx, STREAM_SIZE/4 @@ -333,8 +333,8 @@ proc DestroyBuffer stdcall, str:dword dec ecx jnz @B xor eax, eax - inc eax - ret + inc eax + ret .remove: mov edi, esi add esi, 4 @@ -342,208 +342,203 @@ proc DestroyBuffer stdcall, str:dword rep movsd dec [stream_count] xor eax, eax - inc eax - ret + inc eax + ret .fail: - xor eax, eax - ret + xor eax, eax + ret endp align 4 proc play_buffer stdcall, str:dword - mov ebx, [str] + mov ebx, [str] - cmp [ebx+STREAM.magic], 'WAVE' - jne .fail + cmp [ebx+STREAM.magic], 'WAVE' + jne .fail - cmp [ebx+STREAM.size], STREAM_SIZE - jne .fail + cmp [ebx+STREAM.size], STREAM_SIZE + jne .fail - mov [ebx+STREAM.flags], SND_PLAY + mov [ebx+STREAM.flags], SND_PLAY - mov eax,[ebx+STREAM.work_buff] - mov [ebx+STREAM.work_read], eax - mov [ebx+STREAM.work_write], eax - mov [ebx+STREAM.work_count], 0 + mov eax,[ebx+STREAM.work_buff] + mov [ebx+STREAM.work_read], eax + mov [ebx+STREAM.work_write], eax + mov [ebx+STREAM.work_count], 0 - mov eax, [ebx+STREAM.base] - mov [ebx+STREAM.curr_seg], eax + mov eax, [ebx+STREAM.base] + mov [ebx+STREAM.curr_seg], eax - mov esi, [ebx+STREAM.curr_seg] - mov edi, [ebx+STREAM.work_write] - mov edx, [ebx+STREAM.r_buff] + mov esi, [ebx+STREAM.curr_seg] + mov edi, [ebx+STREAM.work_write] + mov edx, [ebx+STREAM.r_buff] - mov ecx, 32 + mov ecx, 32 mov eax, [ebx+STREAM.r_silence] @@: - mov [edx], eax - add edx, 4 - dec ecx - jnz @B + mov [edx], eax + add edx, 4 + dec ecx + jnz @B - mov edx, [ebx+STREAM.r_buff] + mov edx, [ebx+STREAM.r_buff] - stdcall [ebx+STREAM.resample], edi, esi, edx,\ - [ebx+STREAM.r_dt],[ebx+STREAM.r_size],[ebx+STREAM.r_end] + stdcall [ebx+STREAM.resample], edi, esi, edx,\ + [ebx+STREAM.r_dt],[ebx+STREAM.r_size],[ebx+STREAM.r_end] - mov ebx, [str] + mov ebx, [str] - add [ebx+STREAM.work_count], eax; - add [ebx+STREAM.work_write], eax; + add [ebx+STREAM.work_count], eax; + add [ebx+STREAM.work_write], eax; - mov eax, [ebx+STREAM.r_size] - add [ebx+STREAM.curr_seg], eax + mov eax, [ebx+STREAM.r_size] + add [ebx+STREAM.curr_seg], eax ; if DEBUG ; mov esi, msgPlay ; call [SysMsgBoardStr] ; end if - stdcall dev_play, [hSound] - - xor eax, eax - inc eax - ret - + stdcall dev_play, [hSound] + xor eax, eax + inc eax + ret .fail: - xor eax, eax - ret - + xor eax, eax + ret endp align 4 proc stop_buffer stdcall, str:dword - mov edi, [str] + mov edi, [str] - cmp [edi+STREAM.magic], 'WAVE' - jne .fail + cmp [edi+STREAM.magic], 'WAVE' + jne .fail - cmp [edi+STREAM.size], STREAM_SIZE - jne .fail + cmp [edi+STREAM.size], STREAM_SIZE + jne .fail - mov [edi+STREAM.flags], SND_STOP + mov [edi+STREAM.flags], SND_STOP ; stdcall [ServiceHandler], [hSound], dword DEV_STOP, 0 - xor eax, eax - inc eax - ret - + xor eax, eax + inc eax + ret .fail: - xor eax, eax - ret - + xor eax, eax + ret endp align 4 proc set_buffer stdcall, str:dword,src:dword,offs:dword,size:dword - mov edx, [str] - test edx, edx - jz .fail + mov edx, [str] + test edx, edx + jz .fail - cmp [edx+STREAM.magic], 'WAVE' - jne .fail + cmp [edx+STREAM.magic], 'WAVE' + jne .fail - cmp [edx+STREAM.size], STREAM_SIZE - jne .fail + cmp [edx+STREAM.size], STREAM_SIZE + jne .fail - mov esi,[src] - test esi, esi - jz .fail + mov esi,[src] + test esi, esi + jz .fail cmp esi, new_app_base jb .fail - mov ecx, [size] - test ecx, ecx - jz .fail + mov ecx, [size] + test ecx, ecx + jz .fail - mov eax, [edx+STREAM.base] - add eax, [offs] + mov eax, [edx+STREAM.base] + add eax, [offs] cmp eax, [edx+STREAM.base] jb .fail - mov edi, eax - add eax, ecx - sub eax, 1 + mov edi, eax + add eax, ecx + sub eax, 1 - cmp eax, [edx+STREAM.limit] + cmp eax, [edx+STREAM.limit] ja .fail - shr ecx, 2 + shr ecx, 2 cld - rep movsd + rep movsd - xor eax, eax - inc eax - ret + xor eax, eax + inc eax + ret .fail: - xor eax, eax - ret + xor eax, eax + ret endp align 4 proc alloc_stream - mov esi, stream_map + mov esi, stream_map - pushf - cli + pushf + cli - bsf eax, [esi] - jnz .find - popf - xor eax, eax - ret - -.find: btr [esi], eax - popf - mov ebx, STREAM_SIZE - mul ebx - add eax, stream - ret + bsf eax, [esi] + jnz .find + popf + xor eax, eax + ret +.find: + btr [esi], eax + popf + mov ebx, STREAM_SIZE + mul ebx + add eax, stream + ret endp align 4 proc free_stream - sub eax, stream + sub eax, stream mov ebx, STREAM_SIZE - xor edx, edx - div ebx + xor edx, edx + div ebx - and edx, edx + and edx, edx jnz .err - bts [stream_map], eax - - ret + bts [stream_map], eax + ret .err: xor eax, eax - ret + ret endp align 4 proc check_stream - xor edx, edx - mov ecx, [play_count] + xor edx, edx + mov ecx, [play_count] .l1: - mov esi, [play_list+edx] + mov esi, [play_list+edx] - mov eax, [esi+STR.curr_seg] - cmp eax, [esi+STR.limit] - jb .next + mov eax, [esi+STR.curr_seg] + cmp eax, [esi+STR.limit] + jb .next -.m1: mov eax,[esi+STR.base] - mov [esi+STR.curr_seg], eax +.m1: + mov eax,[esi+STR.base] + mov [esi+STR.curr_seg], eax .next: - add edx, 4 - loop .l1 - ret + add edx, 4 + loop .l1 + ret endp @@ -552,9 +547,9 @@ proc prepare_playlist .restart: xor ebx, ebx - xor edx, edx - mov [play_count], 0 - mov ecx, [stream_count] + xor edx, edx + mov [play_count], 0 + mov ecx, [stream_count] jcxz .exit .l1: mov esi, [stream_list+ebx] @@ -576,18 +571,18 @@ proc prepare_playlist jz .fail cmp [esi+STREAM.flags], SND_PLAY; - jne .next + jne .next cmp [esi+STREAM.work_count], 16384 jb .next mov [play_list+edx], esi - inc [play_count] - add edx, 4 + inc [play_count] + add edx, 4 .next: - add ebx, 4 - loop .l1 + add ebx, 4 + loop .l1 .exit: - ret + ret .fail: stdcall DestroyBuffer, esi jmp .restart @@ -596,26 +591,26 @@ endp align 4 proc prepare_updatelist - xor ebx, ebx - xor edx, edx - mov [play_count], 0 - mov ecx, [stream_count] + xor ebx, ebx + xor edx, edx + mov [play_count], 0 + mov ecx, [stream_count] jcxz .exit .l1: - mov eax, [stream_list+ebx] + mov eax, [stream_list+ebx] test eax, eax jz .next - cmp [eax+STREAM.flags], SND_PLAY - jne .next + cmp [eax+STREAM.flags], SND_PLAY + jne .next - mov [play_list+edx], eax - inc [play_count] - add edx, 4 + mov [play_list+edx], eax + inc [play_count] + add edx, 4 .next: - add ebx, 4 - loop .l1 + add ebx, 4 + loop .l1 .exit: - ret + ret endp align 4 @@ -738,6 +733,7 @@ mm80 dq 0x8080808080808080 mm_mask dq 0xFF00FF00FF00FF00 stream_map dd 0xFFFF ; 16 +version dd 0x00010001 szInfinity db 'INFINITY',0 szSound db 'SOUND',0 diff --git a/kernel/trunk/drivers/mixer.asm b/kernel/trunk/drivers/mixer.asm index dc3b19f45a..84d2c8f93b 100644 --- a/kernel/trunk/drivers/mixer.asm +++ b/kernel/trunk/drivers/mixer.asm @@ -111,6 +111,9 @@ align 4 proc update_stream locals stream_index dd ? + ev_code dd ? ;EVENT + ev_offs dd ? + rd 4 endl mov [stream_index], 0 @@ -176,17 +179,19 @@ proc update_stream ret @@: + mov [ev_code], 0xFF000001 + mov [ev_offs], ecx mov eax, [ebx+STREAM.notify_task] - call pid_to_slot + + lea edx, [ev_code] + push ebx + stdcall SendEvent, eax, edx + pop ebx test eax, eax - jnz @f + jnz .l_end + not eax mov [ebx+STREAM.notify_task], eax ;-1 - jmp .l_end -@@: - shl eax, 8 - mov [eax+PROC_BASE+32],ecx - or dword [eax+PROC_BASE+0xA8],EVENT_NOTIFY .l_end: inc [stream_index] dec [play_count] @@ -196,14 +201,13 @@ endp align 4 proc refill stdcall, str:dword - -; if DEBUG -; mov esi, msgUser -; call [SysMsgBoardStr] -; end if + locals + ev_code dd ? ;EVENT + ev_offs dd ? + rd 4 + endl mov ebx, [str] - mov ecx, [ebx+STREAM.work_write] cmp ecx, [ebx+STREAM.work_top] jbe .m2 @@ -245,17 +249,19 @@ proc refill stdcall, str:dword ret @@: + mov [ev_code], 0xFF000001 + mov [ev_offs], ecx mov eax, [ebx+STREAM.notify_task] - call pid_to_slot + + lea edx, [ev_code] + push ebx + stdcall SendEvent, eax, edx + pop ebx test eax, eax - jnz @f + jnz @F not eax mov [ebx+STREAM.notify_task], eax ;-1 - ret @@: - shl eax, 8 - mov [eax+PROC_BASE+32],ecx - or dword [eax+PROC_BASE+0xA8],EVENT_NOTIFY ret endp diff --git a/kernel/trunk/drivers/sceletone.asm b/kernel/trunk/drivers/sceletone.asm index edab7dac0d..7717bd8d78 100644 --- a/kernel/trunk/drivers/sceletone.asm +++ b/kernel/trunk/drivers/sceletone.asm @@ -25,6 +25,7 @@ end virtual public START public service_proc +public version extrn AttachIntHandler extrn SysMsgBoardStr @@ -54,11 +55,10 @@ section '.flat' code readable align 16 proc START stdcall, state:dword - mov eax, [state] - cmp eax, 1 - je .entry - jmp .exit + cmp [state], 1 + jne .exit .entry: + if DEBUG mov esi, msgInit call SysMsgBoardStr @@ -161,6 +161,8 @@ align 4 devices dd (DEVICE_ID shl 16)+VENDOR_ID dd 0 ;terminator +version dd 0x00010001 + my_service db 'MY_SERVICE',0 ;max 16 chars include zero msgInit db 'detect hardware...',13,10,0 diff --git a/kernel/trunk/drivers/sis.asm b/kernel/trunk/drivers/sis.asm index 6863c4c0b8..b9588177d4 100644 --- a/kernel/trunk/drivers/sis.asm +++ b/kernel/trunk/drivers/sis.asm @@ -249,6 +249,7 @@ PROC_BASE equ OS_BASE+0x0080000 public START public service_proc +public version extrn AttachIntHandler extrn SysMsgBoardStr @@ -267,19 +268,17 @@ section '.flat' code readable align 16 proc START stdcall, state:dword - mov eax, [state] - cmp eax, 1 - je .entry - jmp .stop -.entry: + cmp [state], 1 + jne .stop + if DEBUG - mov esi, msgInit + 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] @@ -288,9 +287,9 @@ proc START stdcall, state:dword call SysMsgBoardStr end if - call init_controller - test eax, eax - jz .fail + call init_controller + test eax, eax + jz .fail if DEBUG mov esi, msgInitCodec @@ -302,20 +301,20 @@ proc START stdcall, state:dword jz .fail if DEBUG - mov esi, [codec.ac_vendor_ids] + mov esi, [codec.ac_vendor_ids] call SysMsgBoardStr - mov esi, [codec.chip_ids] + mov esi, [codec.chip_ids] call SysMsgBoardStr end if - call reset_controller + call reset_controller call setup_codec mov esi, msgPrimBuff call SysMsgBoardStr - call create_primary_buff + call create_primary_buff stdcall AttachIntHandler, [ctrl.int_line], ac97_irq @@ -323,21 +322,17 @@ proc START stdcall, state:dword mov esi, msgOk call SysMsgBoardStr - - ret + ret .fail: if DEBUG - mov esi, msgFail + mov esi, msgFail call SysMsgBoardStr end if xor eax, eax ret .stop: call stop - mov ax, 0x1c - mov edx, PCM_OUT_SR_REG - call [ctrl.ctrl_write16] - mov [ctrl.user_callback], 0 + xor eax, eax ret endp @@ -353,54 +348,54 @@ proc service_proc stdcall, ioctl:dword mov edi, [ioctl] mov eax, [edi+io_code] - cmp eax, DEV_PLAY - jne @F + cmp eax, DEV_PLAY + jne @F if DEBUG - mov esi, msgPlay + 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 + mov esi, msgStop call SysMsgBoardStr end if - call stop - ret + call stop + ret @@: - cmp eax, DEV_CALLBACK - jne @F + cmp eax, DEV_CALLBACK + jne @F mov ebx, [edi+input] stdcall set_callback, [ebx] - ret + ret @@: - cmp eax, DEV_SET_MASTERVOL - jne @F + cmp eax, DEV_SET_MASTERVOL + jne @F mov ebx, [edi+input] stdcall set_master_vol, [ebx] - ret + ret @@: - cmp eax, DEV_GET_MASTERVOL - jne @F + cmp eax, DEV_GET_MASTERVOL + jne @F mov ebx, [edi+output] test ebx, ebx jz .fail stdcall get_master_vol, ebx - ret + ret @@: - cmp eax, DEV_GET_INFO - jne @F + cmp eax, DEV_GET_INFO + jne @F mov ebx, [edi+output] - stdcall get_dev_info, ebx - ret + stdcall get_dev_info, ebx + ret @@: .fail: - xor eax, eax - ret + xor eax, eax + ret endp restore handle @@ -418,49 +413,49 @@ proc ac97_irq ; call SysMsgBoardStr ; end if - mov edx, PCM_OUT_CR_REG - mov al, 0x14 - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + mov al, 0x14 + 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] + call [ctrl.ctrl_read8] and eax, 0x1F cmp eax, [civ_val] je .skip mov [civ_val], eax - dec eax - and eax, 0x1F - mov [ctrl.lvi_reg], 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, 0x1D - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + mov ax, 0x1D + call [ctrl.ctrl_write8] mov eax, [civ_val] add eax, 2 - and eax, 31 - mov ebx, dword [buff_list+eax*4] + 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, 0x1D - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + mov ax, 0x1D + call [ctrl.ctrl_write8] ret endp @@ -468,7 +463,7 @@ align 4 proc create_primary_buff stdcall KernelAlloc, 0x10000 - mov [ctrl.buffer], eax + mov [ctrl.buffer], eax mov edi, eax mov ecx, 0x10000/4 @@ -477,67 +472,60 @@ proc create_primary_buff stdcall GetPgAddr, [ctrl.buffer] - 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+64], eax + mov [edi+4+64], ebx + mov [edi+96], eax + mov [edi+4+96], ebx + mov [edi+128], eax + mov [edi+4+128], ebx + mov [edi+160], eax + mov [edi+4+160], ebx + mov [edi+192], eax + mov [edi+4+192], ebx + mov [edi+224], eax + mov [edi+4+224], ebx - mov [edi+32], eax - mov [edi+4+32], ebx + add eax, 0x4000 + add edi, 8 + loop @B - mov [edi+64], eax - mov [edi+4+64], ebx - - mov [edi+96], eax - mov [edi+4+96], ebx - - mov [edi+128], eax - mov [edi+4+128], ebx - - mov [edi+160], eax - mov [edi+4+160], ebx - - mov [edi+192], eax - mov [edi+4+192], ebx - - mov [edi+224], eax - mov [edi+4+224], ebx - - 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 ecx, pcmout_bdl + mov ecx, pcmout_bdl stdcall GetPgAddr, ecx - and ecx, 0xFFF - add eax, ecx + and ecx, 0xFFF + add eax, ecx - 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] @@ -551,201 +539,198 @@ 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 + xor eax, eax + mov [bus], eax + inc eax call PciApi - cmp eax, -1 - je .err + cmp eax, -1 + je .err 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 - - mov edi, devices + test eax, eax + jz .next + cmp eax, -1 + je .next + 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 +.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: - 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 + mov ebx, eax + and eax, 0xFFFF + mov [ctrl.pci_cmd], eax + shr ebx, 16 + mov [ctrl.pci_stat], ebx stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 - and eax,0xFFFE - mov [ctrl.codec_io_base], eax + and eax,0xFFFE + mov [ctrl.codec_io_base], eax stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14 - and eax, 0xFFC0 - mov [ctrl.ctrl_io_base], eax + and eax, 0xFFC0 + mov [ctrl.ctrl_io_base], eax stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18 - mov [ctrl.codec_mem_base], eax + mov [ctrl.codec_mem_base], eax stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C - mov [ctrl.ctrl_mem_base], eax + mov [ctrl.ctrl_mem_base], eax stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C - and eax, 0xFF - mov [ctrl.int_line], eax + and eax, 0xFF + mov [ctrl.int_line], eax stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41 - and eax, 0xFF - mov [ctrl.cfg_reg], eax + 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 - 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 @@ -753,117 +738,116 @@ proc reset_codec call warm_reset jnc .ok .cold: - call cold_reset - jnc .ok + call cold_reset + jnc .ok if DEBUG - mov esi, msgCFail + 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 + 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 + 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, GLOB_CTRL - call [ctrl.ctrl_read32] - test eax, 4 - jz .ok - sub [counter], 1 - jnz .wait + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] + test eax, 4 + jz .ok + sub [counter], 1 + jnz .wait if DEBUG - mov esi, msgWRFail + mov esi, msgWRFail call SysMsgBoardStr end if - - stc - ret + stc + ret .ok: - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - and eax, CTRL_ST_CREADY + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + and eax, CTRL_ST_CREADY jz .fail clc - ret + ret .fail: stc - ret + ret endp align 4 proc cold_reset - locals - counter dd ? - endl + locals + counter dd ? + endl - xor eax, eax - mov edx, GLOB_CTRL - call [ctrl.ctrl_write32] + xor eax, eax + mov edx, GLOB_CTRL + call [ctrl.ctrl_write32] if DEBUG - mov esi, msgCold + mov esi, msgCold call SysMsgBoardStr end if - mov eax, 1000000 ; wait 1 s - call StallExec + mov eax, 1000000 ; wait 1 s + call StallExec - mov eax, 2 - mov edx, GLOB_CTRL - call [ctrl.ctrl_write32] + mov eax, 2 + mov edx, GLOB_CTRL + call [ctrl.ctrl_write32] - 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, GLOB_CTRL - call [ctrl.ctrl_read32] - test eax, 4 - jz .ok - sub [counter], 1 - jnz .wait + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] + test eax, 4 + jz .ok + sub [counter], 1 + jnz .wait if DEBUG - mov esi, msgCRFail + mov esi, msgCRFail call SysMsgBoardStr end if - stc - ret + stc + ret .ok: - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - and eax, CTRL_ST_CREADY + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + and eax, CTRL_ST_CREADY jz .fail clc - ret + ret .fail: stc - ret + ret endp align 4 @@ -871,30 +855,29 @@ proc play xor eax, eax mov [civ_val], eax mov edx, PCM_OUT_CIV_REG - call [ctrl.ctrl_write8] + 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] - ret + mov edx, PCM_OUT_CR_REG + mov ax, 0x1D + call [ctrl.ctrl_write8] + ret endp align 4 proc stop - mov edx, PCM_OUT_CR_REG - mov ax, 0x14 - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + mov ax, 0x0 + call [ctrl.ctrl_write8] - mov eax, 16 - mov [ctrl.lvi_reg], eax - mov edx, PCM_OUT_LVI_REG - call [ctrl.ctrl_write8] - ret + mov ax, 0x1c + mov edx, PCM_OUT_SR_REG + call [ctrl.ctrl_write16] + ret endp align 4 @@ -935,134 +918,134 @@ 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 + 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 + 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 align 4 .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 - jb @B + rdtsc + sub eax, ebx + sbb edx, ecx + jb @B - pop eax - pop ebx - pop edx - pop ecx - ret + pop eax + pop ebx + pop edx + pop ecx + ret endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1071,58 +1054,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 include "codec.inc" @@ -1131,8 +1114,10 @@ align 4 devices dd (CTRL_SIS shl 16)+VID_SIS,msg_AC, set_SIS dd 0 -msg_AC db '7012 AC97 controller',13,10, 0 -msg_SIS db 'Silicon Integrated Systems',13,10, 0 +version dd 0x00010001 + +msg_AC db '7012 AC97 controller',13,10, 0 +msg_SIS db 'Silicon Integrated Systems',13,10, 0 sz_sound_srv db 'SOUND',0 @@ -1141,7 +1126,7 @@ msgFail db 'device not found',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 diff --git a/kernel/trunk/drivers/unisound.asm b/kernel/trunk/drivers/unisound.asm index 78dc627bc9..9fbfc0c668 100644 --- a/kernel/trunk/drivers/unisound.asm +++ b/kernel/trunk/drivers/unisound.asm @@ -275,6 +275,7 @@ PROC_BASE equ OS_BASE+0x0080000 public START public service_proc +public version extrn AttachIntHandler extrn SysMsgBoardStr @@ -293,10 +294,8 @@ section '.flat' code readable align 16 proc START stdcall, state:dword - mov eax, [state] - cmp eax, 1 + cmp [state], 1 jne .stop -.entry: if DEBUG mov esi, msgInit @@ -376,6 +375,7 @@ proc START stdcall, state:dword ret .stop: call stop + xor eax, eax ret endp @@ -1010,13 +1010,8 @@ endp align 4 proc stop - mov edx, PCM_OUT_CR_REG - mov ax, 0x14 - call [ctrl.ctrl_write8] - - mov eax, 16 - mov [ctrl.lvi_reg], eax - mov edx, PCM_OUT_LVI_REG + mov edx, PCM_OUT_CR_REG + mov ax, 0x0 call [ctrl.ctrl_write8] mov ax, 0x1c @@ -1336,6 +1331,8 @@ devices dd (CTRL_ICH shl 16)+VID_INTEL,msg_ICH, set_ICH dd 0 ;terminator +version dd 0x00010001 + msg_ICH db 'Intel ICH', 13,10, 0 msg_ICH0 db 'Intel ICH0', 13,10, 0 msg_ICH2 db 'Intel ICH2', 13,10, 0 diff --git a/kernel/trunk/gui/event.inc b/kernel/trunk/gui/event.inc index ebd8000872..6f8574cc82 100644 --- a/kernel/trunk/gui/event.inc +++ b/kernel/trunk/gui/event.inc @@ -1,3 +1,169 @@ +struc EVENT +{ .code rd 1 + rd 5 + .next rd 1 ;+24 + .prev rd 1 ;+28 +} +EVENT_SIZE equ 32 + +virtual at 0 + EVENT EVENT +end virtual + +align 4 +init_events: + stdcall kernel_alloc, 1024*EVENT_SIZE + mov [events], eax + xor eax, eax + not eax + mov edi, event_map + mov [event_start], edi + mov ecx, 128/4 + cld + rep stosd + mov [event_end], edi + ret + +align 4 +proc alloc_event + + pushfd + cli + mov ebx, [event_start] + mov ecx, [event_end] +.l1: + bsf eax,[ebx] + jnz .found + add ebx,4 + cmp ebx, ecx + jb .l1 + popfd + xor eax,eax + ret +.found: + btr [ebx], eax + mov [event_start],ebx + sub ebx, event_map + shl ebx, 3 + add eax,ebx + shl eax,5 + add eax, [events] + popfd + xor ebx, ebx + mov [eax+EVENT.next], ebx + mov [eax+EVENT.prev], ebx + ret +endp + +align 4 +free_event: + pushfd + cli + sub eax, [events] + shr eax, 5 + mov ebx, event_map + bts [ebx], eax + shr eax, 3 + and eax, not 3 + add eax, ebx + cmp [event_start], eax + ja @f + popfd + ret +@@: + mov [event_start], eax + popfd + ret + +align 4 +proc send_event stdcall pid:dword, event:dword + locals + slot dd ? + endl + + mov eax, [pid] + call pid_to_slot + test eax, eax + jz .fail + + shl eax, 8 + cmp [PROC_BASE+eax+APPDATA.ev_count], 32 + ja .fail + + mov [slot], eax + call alloc_event + test eax, eax + jz .fail + + mov edi, eax + mov ecx, 6 + mov esi, [event] + cld + rep movsd + + mov esi, eax + mov eax, [slot] + mov edi, [PROC_BASE+eax+APPDATA.ev_last] + mov [esi+EVENT.prev], edi + test edi, edi + jz .set_last + mov [edi+EVENT.next], esi +.set_last: + mov edx, [PROC_BASE+eax+APPDATA.ev_first] + test edx, edx + jnz @F + mov [PROC_BASE+eax+APPDATA.ev_first], esi +@@: + mov [PROC_BASE+eax+APPDATA.ev_last], esi + inc [PROC_BASE+eax+APPDATA.ev_count] + or [PROC_BASE+eax+APPDATA.event_mask], EVENT_EXTENDED +.fail: + ret +endp + +align 4 +proc get_event_ex stdcall, p_ev:dword, timeout:dword + +; push eax +; push edx +; mov edx, 0x400 ;bocsh +; mov al,0xff ;bocsh +; out dx, al ;bocsh +; pop edx +; pop eax + +.wait: + mov ebx,[CURRENT_TASK] + shl ebx,8 + cmp [PROC_BASE+ebx+APPDATA.ev_count], 0 + je .switch + + mov esi, [PROC_BASE+ebx+APPDATA.ev_first] + mov edx, [esi+EVENT.next] + mov [PROC_BASE+ebx+APPDATA.ev_first], edx + test edx, edx + jnz @F + mov [PROC_BASE+ebx+APPDATA.ev_last], edx + and dword [PROC_BASE+ebx+APPDATA.event_mask], not EVENT_EXTENDED +@@: + mov [edx+EVENT.prev], 0 + dec [PROC_BASE+ebx+APPDATA.ev_count] + + mov eax, esi + and dword [esi], 0xFF00FFFF + mov edi, [p_ev] + mov ecx, 6 + cld + rep movsd + call free_event + ret +.switch: + mov eax, [0x3010] + mov [eax+TASKDATA.state], byte 5 + call change_task + jmp .wait +endp + sys_getevent: call get_event_for_app @@ -6,23 +172,22 @@ sys_getevent: align 4 - sys_wait_event_timeout: mov ebx,[timer_ticks] add ebx,eax cmp ebx,[timer_ticks] jna .swfet2 - .swfet1: +.swfet1: call get_event_for_app test eax,eax jne .eventoccur_time call change_task cmp ebx,[timer_ticks] jg .swfet1 - .swfet2: +.swfet2: xor eax,eax - .eventoccur_time: +.eventoccur_time: mov [esp+36],eax ret @@ -46,7 +211,6 @@ sys_waitforevent: mov [esp+36],eax ret - get_event_for_app: pushad @@ -110,8 +274,8 @@ get_event_for_app: ret no_eventoccur3: - - + + ;mov edi,[0x3010] ; mouse event test [edi+TASKDATA.event_mask],dword 00100000b jz no_mouse_event @@ -124,7 +288,7 @@ get_event_for_app: mov eax,6 ret no_mouse_event: - + ;mov edi,[0x3010] ; DESKTOP BACKGROUND REDRAW test [edi+TASKDATA.event_mask],dword 16 @@ -164,16 +328,26 @@ get_event_for_app: no_stack_event: test byte [edi+TASKDATA.event_mask+1], 1 ; DEBUG - jz no_debug_event + jz .test_ext mov eax, [0x3000] shl eax, 8 test byte [eax+0x80000+APPDATA.event_mask+1], byte 1 - jz no_debug_event + jz .test_ext and byte [eax+0x80000+APPDATA.event_mask+1], not 1 popad mov eax, 9 ret - no_debug_event: + +.test_ext: + mov eax, [0x3000] + shl eax, 8 + test dword [eax+0x80000+APPDATA.event_mask], EVENT_EXTENDED + jz .test_IRQ + mov eax, 10 + ret + +.test_IRQ: + cmp dword [edi+TASKDATA.event_mask], 0xFFFF jbe no_events @@ -213,3 +387,4 @@ get_event_for_app: ret + diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index afb93c26e2..2b91ba0a66 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -440,6 +440,8 @@ include 'detect/disks.inc' stdcall kernel_alloc, 0x1000 mov [tmp_task_data], eax + call init_events + mov [dll_map], 0xFFFFFFFF mov [srv_map], 0xFFFFFFFF @@ -550,11 +552,9 @@ include 'vmodeld.inc' call boot_log call setmouse + mov [pci_access_enabled],1 call init_cursors -; mov [pci_access_enabled],1 -; stdcall get_service, szCURSOR - ; SET PRELIMINARY WINDOW STACK AND POSITIONS mov esi,boot_windefs diff --git a/kernel/trunk/kernel32.inc b/kernel/trunk/kernel32.inc index dcc005ff58..f95e908d1a 100644 --- a/kernel/trunk/kernel32.inc +++ b/kernel/trunk/kernel32.inc @@ -173,20 +173,22 @@ struc APPDATA db 5 dup(?) .fpu_state dd ? ;+16 - dd ? ;+20 unused + .ev_count dd ? ;+20 .fpu_handler dd ? ;+24 .sse_handler dd ? ;+28 .event dd ? ;+32 .heap_base dd ? ;+36 .heap_top dd ? ;+40 .cursor dd ? ;+44 + .ev_first dd ? ;+48 + .ev_last dd ? ;+52 - db 80 dup(?) ;+48 + db 72 dup(?) ;+56 .wnd_shape dd ? ;+128 - .wnd_shape_scale dd ? - dd ? - .mem_size dd ? + .wnd_shape_scale dd ? ;+132 + dd ? ;+136 + .mem_size dd ? ;+140 .saved_box BOX .ipc_start dd ? .ipc_size dd ? diff --git a/kernel/trunk/video/cursors.inc b/kernel/trunk/video/cursors.inc index d073896b49..be25f36c29 100644 --- a/kernel/trunk/video/cursors.inc +++ b/kernel/trunk/video/cursors.inc @@ -151,7 +151,6 @@ proc vesa_init_cursor stdcall, dst:dword, src:dword sub [height],1 jnz .row_24 ret - endp align 4 @@ -172,46 +171,21 @@ proc alloc_cursor ret .found: btr [ebx], eax + popfd + mov [cursor_start],ebx sub ebx, cursor_map shl ebx, 3 add eax,ebx shl eax,3 lea eax,[cursors+eax+eax*2] - popfd - ret -endp - -align 4 -proc create_cursor - locals - h_cur dd ? - endl - - call alloc_cursor - test eax, eax - jz .fail - - mov [h_cur], eax - mov edi, eax xor ebx, ebx - - mov [edi+CURSOR.magic], 'CURS' - mov [edi+CURSOR.size], CURSOR_SIZE - mov [edi+CURSOR.pid], ebx - mov [edi+CURSOR.hot_x], ebx - mov [edi+CURSOR.hot_y], ebx - - stdcall kernel_alloc, dword 0x2000 - test eax, eax - jz .fail - - mov ebx, eax - mov eax, [h_cur] - mov [eax+CURSOR.base], ebx - ret -.fail: + mov [eax+CURSOR.magic], 'CURS' + mov [eax+CURSOR.size], CURSOR_SIZE + mov [eax+CURSOR.pid], ebx + mov [eax+CURSOR.hot_x], ebx + mov [eax+CURSOR.hot_y], ebx ret endp @@ -224,80 +198,71 @@ proc set_cursor stdcall, hcursor:dword ret endp +proc vesa_cursor stdcall, hcursor:dword, src:dword, flags:dword + + stdcall kernel_alloc, 0x1000 + test eax, eax + jz .fail + + mov edi, [hcursor] + mov [edi+CURSOR.base], eax + + mov esi, [src] + mov ebx, [flags] + cmp bx, LOAD_INDIRECT + je .indirect + + movzx ecx, word [esi+10] + movzx edx, word [esi+12] + mov [edi+CURSOR.hot_x], ecx + mov [edi+CURSOR.hot_y], edx + + stdcall vesa_init_cursor, eax, esi + mov eax, [hcursor] +.fail: + ret +.indirect: + shr ebx, 16 + movzx ecx, bh + movzx edx, bl + mov [eax+CURSOR.hot_x], ecx + mov [eax+CURSOR.hot_y], edx + + xchg edi, eax + mov ecx, 1024 + cld + rep movsd + ret +endp + align 4 proc load_cursor stdcall, src:dword, flags:dword locals handle dd ? endl - movzx eax, word [flags] - cmp eax, LOAD_FROM_FILE - jne .from_mem + xor eax, eax + mov [handle], eax + cmp word [flags], LOAD_FROM_FILE + jne @F stdcall load_file, [src] test eax, eax jz .exit mov [src], eax - - call create_cursor +@@: + call alloc_cursor test eax, eax jz .fail + stdcall [create_cursor], eax, [src], [flags] mov [handle], eax - mov esi, [src] - movzx ebx, word [esi+10] - movzx ecx, word [esi+12] - mov [eax+CURSOR.hot_x], ebx - mov [eax+CURSOR.hot_y], ecx - - stdcall vesa_init_cursor, [eax+CURSOR.base], esi - stdcall kernel_free, [src] - mov eax, [handle] - ret - -.from_mem: - cmp eax, LOAD_FROM_MEM - jne .indirect - - call create_cursor - test eax, eax - jz .exit - - mov [handle], eax - mov esi, [src] - movzx ebx, word [esi+10] - movzx ecx, word [esi+12] - mov [eax+CURSOR.hot_x], ebx - mov [eax+CURSOR.hot_y], ecx - - stdcall vesa_init_cursor, [eax+CURSOR.base], [src] - mov eax, [handle] - ret - -.indirect: - cmp eax, LOAD_INDIRECT - jne .fail - - call create_cursor - test eax, eax - jz .exit - - movzx edx, byte [flags+2] - movzx ebx, byte [flags+3] - mov [eax+CURSOR.hot_x], ebx - mov [eax+CURSOR.hot_y], edx - - mov edi, [eax+CURSOR.base] - mov esi, [src] - mov ecx, 1024 - cld - rep movsd - ret .fail: - mov ebx, [src] - stdcall kernel_free, ebx + cmp word [flags], LOAD_FROM_FILE + jne .exit + stdcall kernel_free, [src] .exit: - xor eax, eax + mov eax, [handle] ret endp @@ -330,6 +295,16 @@ proc init_cursors add edx, 4 mov [cursor_end], edx + stdcall load_driver, drv_hw_mouse + test eax, eax + jz .sw_mouse + + stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM + mov [def_cursor], eax + ret +.sw_mouse: + mov [create_cursor], vesa_cursor + stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM mov [def_cursor], eax @@ -446,7 +421,6 @@ proc cursor_24 stdcall, hcursor:dword, x:dword, y:dword sub edi, ecx cmp edi, eax - ;cmovg edi, eax jng @F mov edi, eax @@: @@ -454,7 +428,6 @@ proc cursor_24 stdcall, hcursor:dword, x:dword, y:dword sub edx, [y] cmp edx, eax - ;cmovg edx, eax jng @F mov edx, eax @@: @@ -559,7 +532,6 @@ proc cursor_32 stdcall, hcursor:dword, x:dword, y:dword sub edi, ecx cmp edi, eax -; cmovg edi, eax jng @F mov edi, eax @@: @@ -567,7 +539,6 @@ proc cursor_32 stdcall, hcursor:dword, x:dword, y:dword sub edx, [y] cmp edx, eax -; cmovg edx, eax jng @F mov edx, eax @@: