Small fix in RTL8139 driver regarding stats

Fixes and updates in stack for function 75
+ some other small fixes

Netstat program

Deleting of some unrelated files

Coming up next: fixes and updates in ARP code

git-svn-id: svn://kolibrios.org@1171 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2009-09-22 16:42:54 +00:00
parent e3cdb8950b
commit bb5ed21ec9
24 changed files with 582 additions and 13040 deletions

View File

@ -0,0 +1,504 @@
;
; Netstat for KolibriOS v0.1
;
; hidnplayr@gmail.com
;
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd IM_END ; memory for app
dd IM_END ; esp
dd I_PARAM , 0x0 ; I_Param , I_Icon
__DEBUG__ equ 1
__DEBUG_LEVEL__ equ 1
include '..\macros.inc'
include '..\debug-fdo.inc'
START: ; start of execution
; TODO: check Parameters
DEBUGF 1, 'Hello!\n'
redraw:
mcall 12, 1
mcall 0, 100 shl 16 + 520, 100 shl 16 + 240, 0x34bcbcbc, ,name
mov edx, 101
mov esi, 0x00aaaaff
mov edi, 0x00aaffff
cmp dl, [mode]
cmove esi, edi
mcall 8, 25 shl 16 + 65, 25 shl 16 + 20
@@:
inc edx
add ebx, 75 shl 16
mov esi, 0x00aaaaff
cmp dl, [mode]
cmove esi, edi
mcall
cmp edx, 105
jle @r
mcall 4, 28 shl 16 + 31, 0x80000000, modes
cmp [mode], 101
jne @f
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx
add ebx, 18
mov edx, str_packets_rx
mcall
add ebx, 18
mov edx, str_bytes_tx
mcall
add ebx, 18
mov edx, str_bytes_rx
mcall
add ebx, 18
mov edx, str_MAC
mcall
add ebx, 18
mov edx, str_queue_in
mcall
add ebx, 18
mov edx, str_queue_out
mcall
push end_of_draw
mov ebx,1337 shl 16 + 4
mov bh, [device]
mcall 75
push eax
push bx
mov edx, 135 shl 16 + 75 + 4*18
jmp draw_mac
@@:
cmp [mode], 102
jne @f
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx
add ebx, 18
mov edx, str_packets_rx
mcall
add ebx, 18
mov edx, str_ip
mcall
add ebx, 18
mov edx, str_dns
mcall
add ebx, 18
mov edx, str_subnet
mcall
add ebx, 18
mov edx, str_gateway
mcall
mov ebx, 0 shl 16 + 8
mov bh, [device]
mcall 75
push eax
dec bl
dec bl
mcall 75
push eax
dec bl
dec bl
mcall 75
push eax
dec bl
dec bl
mcall 75
push eax
mov edx, 135 shl 16 + 75 + 2*18
call draw_ip
add edx, 18
call draw_ip
add edx, 18
call draw_ip
add edx, 18
call draw_ip
jmp end_of_draw
@@:
cmp [mode], 103
jne @f
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx
add ebx, 18
mov edx, str_packets_rx
mcall
add ebx, 18
mov edx, str_arp
mcall
jmp end_of_draw
@@:
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx
add ebx, 18
mov edx, str_packets_rx
mcall
end_of_draw:
mcall 12, 2
jmp draw_stats
mainloop:
mcall 23,50 ; wait for event with timeout (0,5 s)
cmp eax, 1
je redraw
cmp eax, 2
je key
cmp eax, 3
je button
;-------------------------------
;
;------------------------------
draw_stats:
cmp [mode], 101
jne not_101
mov ebx, 1337 shl 16 + 0
mov bh, [device]
@@:
mcall 75
push eax
inc bl
cmp bl, 3
jle @r
inc bl
inc bl
@@:
mcall 75
push eax
inc bl
cmp bl, 7
jle @r
mov eax, 47
mov ebx, 0x000a0000
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mov edx, 135 shl 16 + 75 + 6*18
pop ecx
mcall
sub edx, 18
pop ecx
mcall
sub edx, 2*18
pop ecx
mcall
sub edx, 18
pop ecx
mcall
sub edx, 18
pop ecx
mcall
sub edx, 18
pop ecx
mcall
jmp mainloop
not_101:
cmp [mode], 102
jne not_102
mov ebx, 0 shl 16
mov bh, [device]
mcall 75
push eax
inc bl
mcall 75
push eax
inc bl
mov eax, 47
mov ebx, 0x000a0000
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mov edx, 135 shl 16 + 75 + 18
pop ecx
mcall
sub edx, 18
pop ecx
mcall
jmp mainloop
not_102:
cmp [mode], 103
jne not_103
mov ebx, 0x0608 shl 16 + 0
mov bh, [device]
mcall 75
push eax
inc bl
mcall 75
push eax
inc bl
mcall 75
push eax
inc bl
mov eax, 47
mov ebx, 0x000a0000
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mov edx, 135 shl 16 + 75 + 2*18
pop ecx
mcall
sub edx, 18
pop ecx
mcall
sub edx, 18
pop ecx
mcall
jmp mainloop
not_103:
cmp [mode], 104
jne not_104
mov ebx, 1 shl 16 + 0
mov bh, [device]
mcall 75
push eax
inc bl
mcall 75
push eax
inc bl
mov eax, 47
mov ebx, 0x000a0000
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mov edx, 135 shl 16 + 75 + 18
pop ecx
mcall
sub edx, 18
pop ecx
mcall
jmp mainloop
not_104:
cmp [mode], 105
jne not_105
mov ebx, 17 shl 16 + 0
mov bh, [device]
mcall 75
push eax
inc bl
mcall 75
push eax
inc bl
mov eax, 47
mov ebx, 0x000a0000
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mov edx, 135 shl 16 + 75 + 18
pop ecx
mcall
sub edx, 18
pop ecx
mcall
jmp mainloop
not_105:
cmp [mode], 106
jne not_106
mov ebx, 6 shl 16 + 0
mov bh, [device]
mcall 75
push eax
inc bl
mcall 75
push eax
inc bl
mov eax, 47
mov ebx, 0x000a0000
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mov edx, 135 shl 16 + 75 + 18
pop ecx
mcall
sub edx, 18
pop ecx
mcall
jmp mainloop
not_106:
jmp mainloop
key:
mcall 2
jmp mainloop
button: ; button
mcall 17 ; get id
cmp ah, 1
je close
mov [mode], ah
jmp redraw
close:
mcall -1
draw_mac:
mov eax, 47
mov ebx, 0x00020100
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mov cl, [esp]
mcall
mov cl, [esp+1]
add edx, 15 shl 16
mcall
mov cl, [esp+2]
add edx, 15 shl 16
mcall
mov cl, [esp+3]
add edx, 15 shl 16
mcall
mov cl, [esp+4]
add edx, 15 shl 16
mcall
mov cl, [esp+5]
add edx, 15 shl 16
mcall
add esp, 6
sub edx, 5*15 shl 16
ret
draw_ip:
mov eax, 47
mov ebx, 0x00030000
mov esi, 0x40000000
mov edi, 0x00bcbcbc
xor ecx, ecx
mov cl, [esp+4]
mcall
mov cl, [esp+4+1]
add edx, 30 shl 16
mcall
mov cl, [esp+4+2]
add edx, 30 shl 16
mcall
mov cl, [esp+4+3]
add edx, 30 shl 16
mcall
sub edx, 3*30 shl 16
mov eax, [esp]
add esp, 8
jmp eax
; DATA AREA
I_END:
name db 'Netstat',0
mode db 101
device db 0
modes db 'Ethernet IPv4 ARP ICMP UDP TCP',0
str_packets_tx db 'Packets sent:',0
str_packets_rx db 'Packets received:',0
str_bytes_tx db 'Bytes sent:',0
str_bytes_rx db 'Bytes received:',0
str_MAC db 'MAC address:',0
str_queue_in db 'IN-queue size:',0
str_queue_out db 'OUT-queue size:',0
str_ip db 'IP address:',0
str_dns db 'DNS address:',0
str_subnet db 'Subnet mask:',0
str_gateway db 'Standard gateway:',0
str_arp db 'ARP entrys:',0
include_debug_strings ; ALWAYS present in data section
I_PARAM rb 1024
IM_END:

View File

@ -701,6 +701,12 @@ reset:
mov [ebx+device.rx_data_offset], eax
mov [ebx+device.curr_tx_desc], al
; clear packet/byte counters
lea edi, [ebx+device.bytes_tx] ; TODO: check if destroying edi, ecx doesnt harm anything
mov ecx, 6
rep stosd
; clear missing packet counter
add edx, REG_MPC - REG_9346CR
@ -818,8 +824,8 @@ transmit:
inc [ebx+device.packets_tx] ;
mov eax, [esp+4] ; Get packet size in eax
add dword [ebx + device.bytes_tx], eax
adc dword [ebx + device.bytes_tx + 4], 0
add dword [ebx + device.bytes_tx + 4], eax
adc dword [ebx + device.bytes_tx], 0
; or eax, (ERTXTH shl BIT_ERTXTH) ; Set descriptor size and the early tx treshold into the correct Transmission status register (TSD0, TSD1, TSD2 or TSD3)
out dx , eax ;
@ -900,8 +906,8 @@ int_handler:
jz .reset_rx
; packet is ok, copy it
movzx ecx, word [eax+2] ; packet length
add dword [ebx + device.bytes_rx], ecx ; Update stats
adc dword [ebx + device.bytes_rx + 4], 0
add dword [ebx + device.bytes_rx + 4], ecx ; Update stats
adc dword [ebx + device.bytes_rx], 0
inc dword [ebx + device.packets_rx] ;
sub ecx, 4 ; don't copy CRC
DEBUGF 1,"Received %u bytes\n", ecx

File diff suppressed because it is too large Load Diff

View File

@ -1,283 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
AD_LOSEL equ BIT5
AD_HPSEL equ BIT10
align 4
proc detect_codec
locals
codec_id dd ?
endl
stdcall codec_read, dword 0x7C
shl eax, 16
mov [codec_id], eax
stdcall codec_read, dword 0x7E
or eax, [codec_id]
mov [codec.chip_id], eax
and eax, 0xFFFFFF00
mov edi, codecs
@@:
mov ebx, [edi]
test ebx, ebx
jz .unknown
cmp eax, ebx
jne .next
mov eax, [edi+4]
mov [codec.ac_vendor_ids], eax
mov esi, eax
call SysMsgBoardStr
stdcall detect_chip, [edi+8]
ret
.next:
add edi, 12
jmp @B
.unknown:
mov [codec.ac_vendor_ids], ac_unknown
mov [codec.chip_ids], chip_unknown
mov esi, chip_unknown
call SysMsgBoardStr
mov eax, [codec.chip_id]
call dword2str
call SysMsgBoardStr
ret
endp
align 4
proc detect_chip stdcall, chip_tab:dword
mov eax, [codec.chip_id]
and eax, 0xFF
mov edi, [chip_tab]
@@:
mov ebx, [edi]
cmp ebx, 0xFF
je .unknown
cmp eax,ebx
jne .next
mov eax, [edi+4]
mov [codec.chip_ids], eax
mov esi, eax
call SysMsgBoardStr
ret
.next:
add edi, 8
jmp @b
.unknown:
mov [codec.chip_ids], chip_unknown
mov esi, chip_unknown
call SysMsgBoardStr
mov eax, [codec.chip_id]
call dword2str
call SysMsgBoardStr
ret
endp
align 4
proc setup_codec
xor eax, eax
stdcall codec_write, dword CODEC_AUX_VOL
mov eax, 0x0B0B
stdcall codec_write, dword CODEC_MASTER_VOL_REG
mov ax, 0x08
stdcall codec_write, dword 0x0C
mov ax, 0x0808
stdcall codec_write, dword CODEC_PCM_OUT_REG
mov ax, 0x0808
stdcall codec_write, dword 0x10
mov ax, 0x0808
stdcall codec_write, dword 0x12
mov ax, 0x0808
stdcall codec_write, dword 0x16
stdcall codec_read, dword CODEC_EXT_AUDIO_CTRL_REG
and eax, 0FFFFh - BIT1 ; clear DRA (BIT1)
or eax, BIT0 ; set VRA (BIT0)
stdcall codec_write, dword CODEC_EXT_AUDIO_CTRL_REG
stdcall set_sample_rate, dword 48000
.init_error:
xor eax, eax ; exit with error
ret
endp
; param
; eax= volume -10000 - 0 for both channels
align 4
set_master_vol:
cmp eax, 0
jl @F
xor eax, eax
jmp .set
@@:
cmp eax, -9450
jg .set
mov eax, -9450 ;clamp into 6 bits
.set:
cdq
mov ebx, -150
idiv ebx
mov ah, al
stdcall codec_write, dword CODEC_MASTER_VOL_REG
xor eax, eax
ret
align 4
proc get_master_vol stdcall, pvol:dword
stdcall codec_read, dword CODEC_MASTER_VOL_REG
and eax, 0x3F
imul eax, -150
mov ebx, [pvol]
mov [ebx], eax
xor eax, eax
ret
endp
align 4
proc set_sample_rate stdcall, rate:dword
mov eax, [rate]
stdcall codec_write, dword CODEC_PCM_FRONT_DACRATE_REG
ret
endp
patch_AD:
stdcall codec_read, 0x76
or ax, BIT5+BIT10
stdcall codec_write, 0x76
ret
align 16
ac_unknown db 'unknown manufacturer',13,10,0
ac_Realtek db 'Realtek Semiconductor',13,10,0
ac_Analog db 'Analog Devices',13,10,0
ac_CMedia db 'C-Media Electronics',13,10,0
ac_Cirrus db 'Cirrus Logic',13,10,0
chip_unknown db 'unknown codec id ', 0
CHIP_ANALOG equ 0x41445300
CHIP_REALTEK equ 0x414C4700
CHIP_CMEDIA equ 0x434D4900
CHIP_CIRRUS equ 0x43525900
align 16
codecs dd CHIP_ANALOG, ac_Analog, chips_Analog
dd CHIP_CMEDIA, ac_CMedia, chips_CMedia
dd CHIP_REALTEK,ac_Realtek, chips_Realtek
dd CHIP_CIRRUS, ac_Cirrus, chips_Cirrus
dd 0
align 16
chips_Analog dd 0x03, chip_AD1819
dd 0x40, chip_AD1881
dd 0x48, chip_AD1881A
dd 0x60, chip_AD1884
dd 0x61, chip_AD1886
dd 0x62, chip_AD1887
dd 0x63, chip_AD1886A
dd 0x70, chip_AD1980
dd 0x75, chip_AD1985
dd 0xFF
chips_Realtek:
dd 0x20, chip_ALC650
dd 0x21, chip_ALC650D
dd 0x22, chip_ALC650E
dd 0x23, chip_ALC650F
dd 0x60, chip_ALC655
dd 0x80, chip_ALC658
dd 0x81, chip_ALC658D
dd 0x90, chip_ALC850
dd 0xFF
chips_CMedia dd 0x41, chip_CM9738
dd 0x61, chip_CM9739
dd 0x69, chip_CM9780
dd 0x78, chip_CM9761
dd 0x82, chip_CM9761
dd 0x83, chip_CM9761
dd 0xFF
chips_Cirrus dd 0x00, chip_CS4297
dd 0x10, chip_CS4297A
dd 0x20, chip_CS4298
dd 0x28, chip_CS4294
dd 0x30, chip_CS4299
dd 0x34, chip_CS4299D
dd 0x48, chip_CS4201
dd 0x58, chip_CS4205
dd 0x60, chip_CS4291
dd 0x70, chip_CS4202
dd 0xFF
align 16
;Analog Devices
chip_AD1819 db 'AD1819 ',0dh,0ah,00h
chip_AD1881 db 'AD1881 ',0dh,0ah,00h
chip_AD1881A db 'AD1881A',0dh,0ah,00h
chip_AD1884 db 'AD1885 ',0dh,0ah,00h
chip_AD1885 db 'AD1885 ',0dh,0ah,00h
chip_AD1886 db 'AD1886 ',0dh,0ah,00h
chip_AD1886A db 'AD1886A',0dh,0ah,00h
chip_AD1887 db 'AD1887 ',0dh,0ah,00h
chip_AD1980 db 'AD1980 ',0dh,0ah,00h
chip_AD1985 db 'AD1985 ',0dh,0ah,00h
;Realtek
chip_ALC650 db 'ALC650 ',0dh,0ah,00h
chip_ALC650D db 'ALC650D',0dh,0ah,00h
chip_ALC650E db 'ALC650E',0dh,0ah,00h
chip_ALC650F db 'ALC650F',0dh,0ah,00h
chip_ALC655 db 'ALC655 ',0dh,0ah,00h
chip_ALC658 db 'ALC658 ',0dh,0ah,00h
chip_ALC658D db 'ALC658D',0dh,0ah,00h
chip_ALC850 db 'ALC850 ',0dh,0ah,00h
;CMedia
chip_CM9738 db 'CMI9738', 0dh,0ah,0
chip_CM9739 db 'CMI9739', 0dh,0ah,0
chip_CM9780 db 'CMI9780', 0dh,0ah,0
chip_CM9761 db 'CMI9761', 0dh,0ah,0
;Cirrus
chip_CS4297 db 'CS4297',13,10,0
chip_CS4297A db 'CS4297A',13,10,0
chip_CS4298 db 'CS4298',13,10,0
chip_CS4294 db 'CS4294',13,10,0
chip_CS4299 db 'CS4299',13,10,0
chip_CS4299D db 'CS4299D',13,10,0
chip_CS4201 db 'CS4201',13,10,0
chip_CS4205 db 'CS4205',13,10,0
chip_CS4291 db 'CS4291',13,10,0
chip_CS4202 db 'CS4202',13,10,0

View File

@ -1,374 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; 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
format MS COFF
DEBUG equ 0
include 'proc32.inc'
include 'imports.inc'
API_VERSION equ 5 ;debug
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
public START
public version
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
proc START stdcall, state:dword
cmp [state], 1
jne .exit
.entry:
;Detect_COM_Mouse:
if DEBUG
mov esi, msgInit
call Boot_Log
end if
mov bx, 0x3f8
call MSMouseSearch
cmp AL,'M'
jne @f
;mov [com1_mouse_detected],1
;mov [irq_owner+4*4], 1 ; IRQ4 owner is System
mov dx, bx
inc dx ; 0x3f8 + 1
mov al, 1
out dx, al
stdcall AttachIntHandler, 4, irq4_handler, dword 0
if DEBUG
cmp eax, 0
jne .label1
mov esi, msg_error_attach_int_handler
call Boot_Log
end if
.label1:
mov eax, 0
mov ebx, 0x3F8
mov ecx, 0x3FF
call ReservePortArea
if DEBUG
cmp eax, 1
jne .go
mov esi, msg_error_reserve_ports
call Boot_Log
.go:
mov esi,boot_setmouse_type
call Boot_Log
end if
@@:
mov bx, 0x2f8
call MSMouseSearch
cmp AL,'M'
jne .resume
;mov [com2_mouse_detected],1
;mov [irq_owner+3*4], 1 ; IRQ3 owner is System
stdcall AttachIntHandler, 3, irq3_handler, dword 0
mov eax, 0
mov ebx, 0x2F8
mov ecx, 0x3F8
call ReservePortArea
if DEBUG
cmp eax, 1
jne @f
mov esi, msg_error_reserve_ports
call Boot_Log
@@:
mov esi,boot_setmouse_type + 22
call Boot_Log
end if
.resume:
stdcall RegService, my_service, service_proc
if DEBUG
cmp eax, 0
jne @f
mov esi, msg_exit
call Boot_Log
end if
@@:
ret
.fail:
.exit:
if DEBUG
mov esi, msg_exit
call Boot_Log
end if
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
align 4
proc service_proc stdcall, ioctl:dword
mov ebx, [ioctl]
mov eax, [ebx+io_code]
cmp eax, SRV_GETVERSION
jne @F
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
align 4
MSMouseSearch:
; ÏÎÈÑÊ ÌÛØÈ ×ÅÐÅÇ COM-ÏÎÐÒÛ
MouseSearch:
; Óñòàíàâëèâàåì ñêîðîñòü
; ïðèåìà/ïåðåäà÷è 1200 áîä
; in bx COM Port Base Address
mov DX, bx
add DX,3
in AL,DX
or AL,80h ;óñòàíîâèòü áèò DLAB
out DX,AL
mov DX, bx
mov AL,60h ;1200 áîä
out DX,AL
inc DX
mov AL,0
out DX,AL
; Óñòàíîâèòü äëèíó ñëîâà 7 áèò, 1 ñòîïîâûé áèò,
; ÷åòíîñòü íå êîíòðîëèðîâàòü
mov DX, bx
add DX,3
mov AL,00000010b
out DX,AL
; Çàïðåòèòü âñå ïðåðûâàíè
mov dx, bx
inc dx
mov AL,0
out DX,AL
; Ïðîâåðèòü, ÷òî óñòðîéñòâî ïîäêëþ÷åíî è ÿâëÿåòñ
; ìûøüþ òèïà MSMouse
; Îòêëþ÷èòü ïèòàíèå ìûøè è ïðåðûâàíè
mov DX, bx
add EDX,4 ;ðåãèñòð óïðàâëåíèÿ ìîäåìîì
mov AL,0 ;ñáðîñèòü DTR, RTS è OUT2
out DX,AL
; Îæèäàòü 5 "òèêîâ" (0,2 ñ)
mov ecx, 0xFFFF
loop $
; Âêëþ÷èòü ïèòàíèå ìûøè
mov al, 1
out dx, al
mov ecx, 0xFFFF
loop $
; Î÷èñòèòü ðåãèñòð äàííûõ
mov dx, bx
in AL,DX
add edx, 4
mov AL, 1011b ;óñòàíîâèòü DTR è RTS è OUT2
out DX,AL
mov ecx, 0x1FFFF
; Öèêë îïðîñà ïîðòà
WaitData:
; Îæèäàòü åùå 10 "òèêîâ"
dec ecx
cmp ecx,0
je NoMouse
; Ïðîâåðèòü íàëè÷èå èäåíòèôèêàöèîííîãî áàéòà
mov DX, bx
add DX,5
in AL,DX
test AL,1 ;Äàííûå ãîòîâû?
jz WaitData
; Ââåñòè äàííûå
mov DX, bx
in AL,DX
NoMouse:
ret
align 4
irq3_handler:
mov dx, 0x2f8
mov esi, com2_mouse
jmp irq_handler
align 4
irq4_handler:
mov dx, 0x3f8
mov esi, com1_mouse
irq_handler:
; in: esi -> COM_MOUSE_DATA struc, dx = base port (xF8h)
add edx, 5 ; xFDh
in al, dx
test al, 1 ; Äàííûå ãîòîâû?
jz .Error
; Ââåñòè äàííûå
sub edx, 5
in al, dx
; Ñáðîñèòü ñòàðøèé íåçíà÷àùèé áèò
and al, 01111111b
; Îïðåäåëèòü ïîðÿäêîâûé íîìåð ïðèíèìàåìîãî áàéòà
cmp [esi+COM_MOUSE_DATA.MouseByteNumber], 2
ja .Error
jz .ThirdByte
jp .SecondByte
; Ñîõðàíèòü ïåðâûé áàéò äàííûõ
.FirstByte:
test al, 1000000b ; Ïåðâûé áàéò ïîñûëêè?
jz .Error
mov [esi+COM_MOUSE_DATA.FirstByte], al
inc [esi+COM_MOUSE_DATA.MouseByteNumber]
jmp .EndMouseInterrupt
; Ñîõðàíèòü âòîðîé áàéò äàííûõ
.SecondByte:
test al, 1000000b
jnz .Error
mov [esi+COM_MOUSE_DATA.SecondByte], al
inc [esi+COM_MOUSE_DATA.MouseByteNumber]
jmp .EndMouseInterrupt
; Ñîõðàíèòü òðåòèé áàéò äàííûõ
.ThirdByte:
test al, 1000000b
jnz .Error
mov [esi+COM_MOUSE_DATA.ThirdByte], al
mov [esi+COM_MOUSE_DATA.MouseByteNumber], 0
; (Ïàêåò äàííûõ îò ìûøè ïðèíÿò ïîëíîñòüþ).
; Çàïèñàòü íîâîå çíà÷åíèå ñîñòîÿíèÿ êíîïîê ìûøè
mov al, [esi+COM_MOUSE_DATA.FirstByte]
mov ah, al
shr al, 3
and al, 2
shr ah, 5
and ah, 1
add al, ah
movzx eax, al
mov [BTN_DOWN], eax
; Ïðèáàâèòü ïåðåìåùåíèå ïî X ê êîîðäèíàòå X
mov al, [esi+COM_MOUSE_DATA.FirstByte]
shl al, 6
or al, [esi+COM_MOUSE_DATA.SecondByte]
cbw
movzx eax, ax
mov [MOUSE_X], eax
; Ïðèáàâèòü ïåðåìåùåíèå ïî Y ê êîîðäèíàòå Y
mov al, [esi+COM_MOUSE_DATA.FirstByte]
and al, 00001100b
shl al, 4
or al, [esi+COM_MOUSE_DATA.ThirdByte]
cbw
movzx eax, ax
neg eax
mov [MOUSE_Y], eax
stdcall SetMouseData, [BTN_DOWN], [MOUSE_X], [MOUSE_Y], 0, 0
jmp .EndMouseInterrupt
.Error:
; Ïðîèçîøåë ñáîé â ïîðÿäêå ïåðåäà÷è èíôîðìàöèè îò
; ìûøè, îáíóëèòü ñ÷åò÷èê áàéòîâ ïàêåòà äàííûõ
mov [esi+COM_MOUSE_DATA.MouseByteNumber],0
.EndMouseInterrupt:
ret
;all initialized data place here
align 4
struc COM_MOUSE_DATA {
; Íîìåð ïðèíèìàåìîãî îò ìûøè áàéòà
.MouseByteNumber db ?
; Òðåõáàéòîâàÿ ñòðóêòóðà äàííûõ, ïåðåäàâàåìàÿ ìûøüþ
.FirstByte db ?
.SecondByte db ?
.ThirdByte db ?
;.timer_ticks_com dd ?
}
virtual at 0
COM_MOUSE_DATA COM_MOUSE_DATA
end virtual
com1_mouse COM_MOUSE_DATA
com2_mouse COM_MOUSE_DATA
MOUSE_X dd 0
MOUSE_Y dd 0
BTN_DOWN dd 0
COMPortBaseAddr dw 3F8h
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
my_service db 'COM_Mouse',0 ;max 16 chars include zero
if DEBUG
msgInit db 'Preved bugoga!',13,10,0
boot_setmouse_type db 'Detected - COM1 mouse',13,10,0
db 'Detected - COM2 mouse',13,10,0
msg_error_reserve_ports db 'Error reserving ports!',13,10,0
msg_error_attach_int_handler db 'Error attach interrupt handler!',13,10,0
msg_exit db 'Exit!',13,10,0
end if
section '.data' data readable writable align 16
;all uninitialized data place here

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,164 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2006-2008. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Serge 2006-2008
; email: infinity_sound@mail.ru
PLAY_SYNC equ 0x80000000
PCM_ALL equ 0
PCM_OUT equ 0x08000000
PCM_RING equ 0x10000000
PCM_STATIC equ 0x20000000
PCM_FLOAT equ 0x40000000 ;reserved
PCM_FILTER equ 0x80000000 ;reserved
PCM_2_16_48 equ 1
PCM_1_16_48 equ 2
PCM_2_16_44 equ 3
PCM_1_16_44 equ 4
PCM_2_16_32 equ 5
PCM_1_16_32 equ 6
PCM_2_16_24 equ 7
PCM_1_16_24 equ 8
PCM_2_16_22 equ 9
PCM_1_16_22 equ 10
PCM_2_16_16 equ 11
PCM_1_16_16 equ 12
PCM_2_16_12 equ 13
PCM_1_16_12 equ 14
PCM_2_16_11 equ 15
PCM_1_16_11 equ 16
PCM_2_16_8 equ 17
PCM_1_16_8 equ 18
PCM_2_8_48 equ 19
PCM_1_8_48 equ 20
PCM_2_8_44 equ 21
PCM_1_8_44 equ 22
PCM_2_8_32 equ 23
PCM_1_8_32 equ 24
PCM_2_8_24 equ 25
PCM_1_8_24 equ 26
PCM_2_8_22 equ 27
PCM_1_8_22 equ 28
PCM_2_8_16 equ 29
PCM_1_8_16 equ 30
PCM_2_8_12 equ 31
PCM_1_8_12 equ 32
PCM_2_8_11 equ 33
PCM_1_8_11 equ 34
PCM_2_8_8 equ 35
PCM_1_8_8 equ 36
SRV_GETVERSION equ 0
SND_CREATE_BUFF equ 1
SND_DESTROY_BUFF equ 2
SND_SETFORMAT equ 3
SND_GETFORMAT equ 4
SND_RESET equ 5
SND_SETPOS equ 6
SND_GETPOS equ 7
SND_SETBUFF equ 8
SND_OUT equ 9
SND_PLAY equ 10
SND_STOP equ 11
SND_SETVOLUME equ 12
SND_GETVOLUME equ 13
SND_SETPAN equ 14
SND_GETPAN equ 15
SND_GETBUFFSIZE equ 16
SND_GETFREESPACE equ 17
struc STREAM
{
.magic dd ? ;'WAVE'
.destroy dd ? ;internal destructor
.fd dd ? ;next object in list
.bk dd ? ;prev object in list
.pid dd ? ;owner id
.size dd ?
.str_fd dd ?
.str_bk dd ?
.device dd ?
.format dd ?
.flags dd ?
.out_base dd ?
.out_wp dd ?
.out_rp dd ?
.out_count dd ?
.out_top dd ? ;16*4
.r_size dd ?
.r_dt dd ?
.r_silence dd ?
.resample dd ?
.l_vol dd ?
.r_vol dd ?
.l_amp dw ?
.r_amp dw ?
.pan dd ?
.l_amp_f dd ? ;float point left
.r_amp_f dd ? ;float point right
.in_base dd ?
.in_size dd ?
.in_wp dd ?
.in_rp dd ?
.in_count dd ?
.in_free dd ?
.in_top dd ?
.notify_event dd ?
.notify_id dd ?
}
STREAM_SIZE equ 36*4
FD_OFFSET equ 24
virtual at 0
STREAM STREAM
end virtual
struc WAVE_HEADER
{ .riff_id dd ?
.riff_size dd ?
.riff_format dd ?
.fmt_id dd ?
.fmt_size dd ?
.format_tag dw ?
.channels dw ?
.freq dd ?
.bytes_sec dd ?
.block_align dw ?
.bits_sample dw ?
.data_id dd ?
.data_size dd ?
}

View File

@ -1,247 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; params
; edi= output
; eax= input stream 1
; ebx= input stream 2
if used mmx_mix_2
align 4
mmx_mix_2:
movq mm0, [eax]
movq mm1, [eax+8]
movq mm2, [eax+16]
movq mm3, [eax+24]
movq mm4, [eax+32]
movq mm5, [eax+40]
movq mm6, [eax+48]
movq mm7, [eax+56]
paddsw mm0, [ebx]
movq [edi], mm0
paddsw mm1,[ebx+8]
movq [edi+8], mm1
paddsw mm2, [ebx+16]
movq [edi+16], mm2
paddsw mm3, [ebx+24]
movq [edi+24], mm3
paddsw mm4, [ebx+32]
movq [edi+32], mm4
paddsw mm5, [ebx+40]
movq [edi+40], mm5
paddsw mm6, [ebx+48]
movq [edi+48], mm6
paddsw mm7, [ebx+56]
movq [edi+56], mm7
movq mm0, [eax+64]
movq mm1, [eax+72]
movq mm2, [eax+80]
movq mm3, [eax+88]
movq mm4, [eax+96]
movq mm5, [eax+104]
movq mm6, [eax+112]
movq mm7, [eax+120]
paddsw mm0, [ebx+64]
movq [edi+64], mm0
paddsw mm1, [ebx+72]
movq [edi+72], mm1
paddsw mm2, [ebx+80]
movq [edi+80], mm2
paddsw mm3, [ebx+88]
movq [edi+88], mm3
paddsw mm4, [ebx+96]
movq [edi+96], mm4
paddsw mm5, [ecx+104]
movq [edx+104], mm5
paddsw mm6, [ebx+112]
movq [edi+112], mm6
paddsw mm7, [ebx+120]
movq [edi+120], mm7
ret
align 4
mmx_mix_3:
movq mm0, [eax]
movq mm1, [eax+8]
movq mm2, [eax+16]
movq mm3, [eax+24]
movq mm4, [eax+32]
movq mm5, [eax+40]
movq mm6, [eax+48]
movq mm7, [eax+56]
paddsw mm0, [ebx]
paddsw mm1, [ebx+8]
paddsw mm2, [ebx+16]
paddsw mm3, [ebx+24]
paddsw mm4, [ebx+32]
paddsw mm5, [ebx+40]
paddsw mm6, [ebx+48]
paddsw mm7, [ebx+56]
paddsw mm0, [ecx]
movq [edi], mm0
paddsw mm1,[ecx+8]
movq [edi+8], mm1
paddsw mm2, [ecx+16]
movq [edi+16], mm2
paddsw mm3, [ecx+24]
movq [edi+24], mm3
paddsw mm4, [ecx+32]
movq [edi+32], mm4
paddsw mm5, [ecx+40]
movq [edi+40], mm5
paddsw mm6, [ecx+48]
movq [edi+48], mm6
paddsw mm7, [ecx+56]
movq [edi+56], mm7
movq mm0, [eax+64]
movq mm1, [eax+72]
movq mm2, [eax+80]
movq mm3, [eax+88]
movq mm4, [eax+96]
movq mm5, [eax+104]
movq mm6, [eax+112]
movq mm7, [eax+120]
paddsw mm0, [ebx+64]
paddsw mm1, [ebx+72]
paddsw mm2, [ebx+80]
paddsw mm3, [ebx+88]
paddsw mm4, [ebx+96]
paddsw mm5, [ebx+104]
paddsw mm6, [ebx+112]
paddsw mm7, [ebx+120]
paddsw mm0, [ecx+64]
movq [edi+64], mm0
paddsw mm1, [ecx+72]
movq [edi+72], mm1
paddsw mm2, [ecx+80]
movq [edi+80], mm2
paddsw mm3, [ecx+88]
movq [edi+88], mm3
paddsw mm4, [ecx+96]
movq [edi+96], mm4
paddsw mm5, [ecx+104]
movq [edi+104], mm5
paddsw mm6, [ecx+112]
movq [edi+112], mm6
paddsw mm7, [ecx+120]
movq [edi+120], mm7
ret
align 4
mmx_mix_4:
movq mm0, [eax]
movq mm2, [eax+8]
movq mm4, [eax+16]
movq mm6, [eax+24]
movq mm1, [ebx]
movq mm3, [ebx+8]
movq mm5, [ebx+16]
movq mm7, [ebx+24]
paddsw mm0, [ecx]
paddsw mm2, [ecx+8]
paddsw mm4, [ecx+16]
paddsw mm6, [ecx+24]
paddsw mm1, [edx]
paddsw mm3, [edx+8]
paddsw mm5, [edx+16]
paddsw mm7, [edx+24]
paddsw mm0, mm1
movq [edi], mm0
paddsw mm2, mm3
movq [edi+8], mm2
paddsw mm4, mm5
movq [edi+16], mm4
paddsw mm5, mm6
movq [edi+24], mm6
movq mm0, [eax+32]
movq mm2, [eax+40]
movq mm4, [eax+48]
movq mm6, [eax+56]
movq mm1, [ebx+32]
movq mm3, [ebx+40]
movq mm5, [ebx+48]
movq mm7, [ebx+56]
paddsw mm0, [ecx+32]
paddsw mm2, [ecx+40]
paddsw mm4, [ecx+48]
paddsw mm6, [ecx+56]
paddsw mm1, [edx+32]
paddsw mm3, [edx+40]
paddsw mm5, [edx+48]
paddsw mm7, [edx+56]
paddsw mm0, mm1
movq [edi+32], mm0
paddsw mm2, mm2
movq [edi+40], mm2
paddsw mm4, mm5
movq [edi+48], mm4
paddsw mm6, mm7
movq [edi+56], mm6
movq mm0, [eax+64]
movq mm2, [eax+72]
movq mm4, [eax+80]
movq mm6, [eax+88]
movq mm1, [ebx+64]
movq mm3, [ebx+72]
movq mm5, [ebx+80]
movq mm7, [ebx+88]
paddsw mm0, [ecx+64]
paddsw mm2, [ecx+72]
paddsw mm4, [ecx+80]
paddsw mm6, [ecx+88]
paddsw mm1, [edx+64]
paddsw mm3, [edx+72]
paddsw mm5, [edx+80]
paddsw mm7, [edx+88]
paddsw mm0, mm1
movq [edi+64], mm0
paddsw mm2, mm3
movq [edi+72], mm2
paddsw mm4, mm5
movq [edi+80], mm4
paddsw mm6, mm5
movq [edi+88], mm7
movq mm0, [eax+96]
movq mm2, [eax+104]
movq mm4, [eax+112]
movq mm6, [eax+120]
movq mm1, [ebx+96]
movq mm3, [ebx+104]
movq mm5, [ebx+112]
movq mm7, [ebx+120]
paddsw mm0, [ecx+96]
paddsw mm2, [ecx+104]
paddsw mm4, [ecx+112]
paddsw mm6, [ecx+120]
paddsw mm1, [edx+96]
paddsw mm3, [edx+104]
paddsw mm5, [edx+112]
paddsw mm7, [edx+120]
paddsw mm0, mm1
movq [eax+96], mm0
paddsw mm2, mm3
movq [edi+104], mm2
paddsw mm4, mm5
movq [edi+112], mm4
paddsw mm6, mm7
movq [edi+120], mm6
ret
end if

View File

@ -1,145 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if used mmx128_mix_2
align 4
mmx128_mix_2:
prefetcht1 [eax+128]
prefetcht1 [ebx+128]
movaps xmm0, [eax]
movaps xmm1, [eax+16]
movaps xmm2, [eax+32]
movaps xmm3, [eax+48]
movaps xmm4, [eax+64]
movaps xmm5, [eax+80]
movaps xmm6, [eax+96]
movaps xmm7, [eax+112]
paddsw xmm0, [ebx]
movaps [edi], xmm0
paddsw xmm1,[ebx+16]
movaps [edi+16], xmm1
paddsw xmm2, [ebx+32]
movaps [edi+32], xmm2
paddsw xmm3, [ebx+48]
movaps [edi+48], xmm3
paddsw xmm4, [ebx+64]
movaps [edi+64], xmm4
paddsw xmm5, [ebx+80]
movaps [edi+80], xmm5
paddsw xmm6, [ebx+96]
movaps [edi+96], xmm6
paddsw xmm7, [ebx+112]
movaps [edi+112], xmm7
ret
align 4
mmx128_mix_3:
prefetcht1 [eax+128]
prefetcht1 [ebx+128]
prefetcht1 [ecx+128]
movaps xmm0, [eax]
movaps xmm1, [eax+16]
movaps xmm2, [eax+32]
movaps xmm3, [eax+48]
movaps xmm4, [eax+64]
movaps xmm5, [eax+80]
movaps xmm6, [eax+96]
movaps xmm7, [eax+112]
paddsw xmm0, [ebx]
paddsw xmm1, [ebx+16]
paddsw xmm2, [ebx+32]
paddsw xmm3, [ebx+48]
paddsw xmm4, [ebx+64]
paddsw xmm5, [ebx+80]
paddsw xmm6, [ebx+96]
paddsw xmm7, [ebx+112]
paddsw xmm0, [ecx]
movaps [edi], xmm0
paddsw xmm1, [ecx+16]
movaps [edi+16], xmm1
paddsw xmm2, [ecx+32]
movaps [edi+32], xmm2
paddsw xmm3, [ecx+48]
movaps [edi+48], xmm3
paddsw xmm4, [ecx+64]
movaps [edi+64], xmm4
paddsw xmm5, [ecx+80]
movaps [edi+80], xmm5
paddsw xmm6, [ecx+96]
movaps [edi+96], xmm6
paddsw xmm7, [ecx+112]
movaps [edi+112], xmm7
ret
align 4
mmx128_mix_4:
prefetcht1 [eax+128]
prefetcht1 [ebx+128]
prefetcht1 [ecx+128]
prefetcht1 [edx+128]
movaps xmm0, [eax]
movaps xmm2, [eax+16]
movaps xmm4, [eax+32]
movaps xmm6, [eax+48]
movaps xmm1, [ebx]
movaps xmm3, [ebx+16]
movaps xmm5, [ebx+32]
movaps xmm7, [ebx+48]
paddsw xmm0, [ecx]
paddsw xmm2, [ecx+16]
paddsw xmm4, [ecx+32]
paddsw xmm6, [ecx+48]
paddsw xmm1, [edx]
paddsw xmm3, [edx+16]
paddsw xmm5, [edx+32]
paddsw xmm7, [edx+48]
paddsw xmm0, xmm1
movaps [edi], xmm0
paddsw xmm2, xmm3
movaps [edi+16], xmm2
paddsw xmm4, xmm5
movaps [edi+32], xmm4
paddsw xmm6, xmm7
movaps [edi+48], xmm6
movaps xmm0, [eax+64]
movaps xmm2, [eax+80]
movaps xmm4, [eax+96]
movaps xmm6, [eax+112]
movaps xmm1, [ebx+64]
movaps xmm3, [ebx+80]
movaps xmm5, [ebx+96]
movaps xmm7, [ebx+112]
paddsw xmm0, [ecx+64]
paddsw xmm2, [ecx+80]
paddsw xmm4, [ecx+96]
paddsw xmm6, [ecx+112]
paddsw xmm1, [edx+64]
paddsw xmm3, [edx+80]
paddsw xmm5, [edx+96]
paddsw xmm7, [edx+112]
paddsw xmm0, xmm1
movaps [edi+64], xmm0
paddsw xmm2, xmm3
movaps [edi+80], xmm2
paddsw xmm4, xmm5
movaps [edi+96], xmm4
paddsw xmm6, xmm7
movaps [edi+112], xmm6
ret
end if

File diff suppressed because it is too large Load Diff

View File

@ -1,141 +0,0 @@
kbd_read:
push ecx edx
mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
kr_loop:
in al,0x64
test al,1
jnz kr_ready
loop kr_loop
mov ah,1
jmp kr_exit
kr_ready:
push ecx
mov ecx,32
kr_delay:
loop kr_delay
pop ecx
in al,0x60
xor ah,ah
kr_exit:
pop edx ecx
ret
kbd_write:
push ecx edx
mov dl,al
in al,0x60
mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
kw_loop:
in al,0x64
test al,2
jz kw_ok
loop kw_loop
mov ah,1
jmp kw_exit
kw_ok:
mov al,dl
out 0x60,al
mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
kw_loop3:
in al,0x64
test al,2
jz kw_ok3
loop kw_loop3
mov ah,1
jmp kw_exit
kw_ok3:
mov ah,8
kw_loop4:
mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
kw_loop5:
in al,0x64
test al,1
jnz kw_ok4
loop kw_loop5
dec ah
jnz kw_loop4
kw_ok4:
xor ah,ah
kw_exit:
pop edx ecx
ret
kbd_cmd:
mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
c_wait:
in al,0x64
test al,2
jz c_send
loop c_wait
jmp c_error
c_send:
mov al,bl
out 0x64,al
mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
c_accept:
in al,0x64
test al,2
jz c_ok
loop c_accept
c_error:
mov ah,1
jmp c_exit
c_ok:
xor ah,ah
c_exit:
ret
mouse_cmd:
mov [mouse_cmd_byte], al
mov [mouse_nr_resends], 5
.resend:
mov bl, 0xd4
call kbd_cmd
cmp ah,1
je .fail
mov al, [mouse_cmd_byte]
call kbd_write
cmp ah, 1
je .fail
call mouse_read
cmp al, 0xFA
jne .noack
clc
ret
.noack:
cmp al, 0xFE ; resend
jne .noresend
dec [mouse_nr_resends]
jnz .resend
.noresend:
.fail:
stc
ret
mouse_read:
mov [mouse_nr_tries], 100
.repeat:
call kbd_read
cmp ah, 1
jne .fin
mov esi, 10
call Sleep
dec [mouse_nr_tries]
jnz .repeat
stc
ret
.fin:
clc
ret

View File

@ -1,120 +0,0 @@
;**************************************
;* IRQ HANDLER FOR PS/2 MOUSE *
;**************************************
proc irq_handler
call Wait8042BufferEmpty ;clear buffer
in al,0x60 ;get scan-code
cmp [mouse_byte],0
je .byte1
cmp [mouse_byte],1
je .byte2
cmp [mouse_byte],2
je .byte3
cmp [mouse_byte],3
je .byte4
jmp .error
.byte1:
test al,1000b ;first byte?
jz .error
mov [first_byte],al
inc [mouse_byte]
jmp .exit
.byte2:
mov [second_byte],al
inc [mouse_byte]
jmp .exit
.byte3:
mov [third_byte],al
cmp [MouseType],MT_3B
je .full_packet
inc [mouse_byte]
jmp .exit
.byte4:
mov [fourth_byte],al
.full_packet:
mov [mouse_byte],0
mov al,byte [first_byte]
and eax,7
mov byte [ButtonState],al
cmp [MouseType],MT_3B
je .xy_moving
mov al,[fourth_byte]
cmp [MouseType],MT_3BScroll
je .z_moving
mov ah,al
and ah,00110000b
shr ah,1
or byte [ButtonState],ah
and al,00001111b
bt eax,3
jnc .z_moving
or al,11110000b
.z_moving:
movsx eax,al
mov [ZMoving],eax
.xy_moving:
mov ah,0
mov al,[first_byte]
test al,10000b
jz @f
mov ah,0FFh
@@:
mov al,[second_byte]
cwd
mov [XMoving],eax
mov ah,0
mov al,[first_byte]
test al,100000b
jz @f
mov ah,0FFh
@@:
mov al,[third_byte]
cwd
@@:
mov [YMoving],eax
stdcall SetMouseData, [ButtonState], [XMoving], [YMoving], [ZMoving], 0
jmp .exit
.error:
mov [mouse_byte],0
.exit:
ret
endp
;***********************************************
;* Waiting for clearing I8042 buffer *
;* Retutned state: *
;* ZF is set - good ending, *
;* ZF is cleared - time-out error. *
;***********************************************
Wait8042BufferEmpty:
push ecx
xor ecx,ecx
@@:
in al,64h
test al,00000010b
loopnz @b
pop ecx
ret

View File

@ -1,270 +0,0 @@
format MS COFF
DEBUG equ 0
include 'proc32.inc'
include 'imports.inc'
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
public START
public version
DRV_ENTRY equ 1
DRV_EXIT equ -1
MT_3B equ 0
MT_3BScroll equ 1
MT_5BScroll equ 2
PS2_DRV_VER equ 1
section '.flat' code readable align 16
proc START stdcall, state:dword
cmp [state], DRV_ENTRY
jne .fin
.init:
call detect_mouse
test eax,eax
jnz .exit
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
.stop_try:
mov bl, 0x20 ; read command byte
call kbd_cmd
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
pop eax
call kbd_write
cmp ah,1
je .exit
mov al, 0xF4 ; enable data reporting
call mouse_cmd
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
.exit:
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
cmp eax,1
jz .gettype
.err:
or eax, -1
ret
.ok:
xor eax, eax
ret
.getversion:
cmp [edi+IOCTL.out_size], 4
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
mov edi, [edi+IOCTL.output]
mov eax,[MouseType]
mov dword [edi], eax ; mouse type
jmp .ok
endp
detect_mouse:
mov bl, 0xAD ; disable keyboard interface
call kbd_cmd
cmp ah,1
je .fail
mov bl, 0xA8 ; enable mouse interface
call kbd_cmd
cmp ah,1
je .fail
mov al, 0xFF ; reset
call mouse_cmd
jc .fail
call mouse_read
jc .fail
cmp al, 0xAA
jne .fail ; dead mouse
; get device ID
call mouse_read
jc .fail
cmp al, 0x00
jne .fail ; unknown device
xor eax,eax
ret
.fail:
or eax,-1
ret
try_mode_ID3:
mov al, 0xF3 ;Set Sample Rate
call mouse_cmd
jc .fail
mov al, 0xC8 ;200d
call mouse_cmd
jc .fail
mov al, 0xF3 ;Set Sample Rate
call mouse_cmd
jc .fail
mov al, 0x64 ;100d
call mouse_cmd
jc .fail
mov al, 0xF3 ;Set Sample Rate
call mouse_cmd
jc .fail
mov al, 0x50 ;80d
call mouse_cmd
jc .fail
mov al, 0xF2 ;Get device id
call mouse_cmd
jc .fail
call mouse_read
jc .fail
cmp al, 0x03
jne .fail
xor eax,eax
ret
.fail:
or eax,-1
ret
try_mode_ID4:
mov al, 0xF3 ;Set Sample Rate
call mouse_cmd
jc .fail
mov al, 0xC8 ;200d
call mouse_cmd
jc .fail
mov al, 0xF3 ;Set Sample Rate
call mouse_cmd
jc .fail
mov al, 0xC8 ;100d
call mouse_cmd
jc .fail
mov al, 0xF3 ;Set Sample Rate
call mouse_cmd
jc .fail
mov al, 0x50 ;80d
call mouse_cmd
jc .fail
mov al, 0xF2 ;Get device id
call mouse_cmd
jc .fail
call mouse_read
jc .fail
cmp al, 0x04
jne .fail
xor eax,eax
ret
.fail:
or eax,-1
ret
include 'ps2m_iofuncs.inc'
include 'ps2m_irqh.inc'
section '.data' data readable writable align 16
version dd 0x00050005
my_service db 'ps2mouse',0
;iofuncs data
mouse_cmd_byte db 0
mouse_nr_tries db 0
mouse_nr_resends db 0
;hid data
mouse_byte dd 0
first_byte db 0
second_byte db 0
third_byte db 0
fourth_byte db 0
;main data
MouseType dd 0
XMoving dd 0
YMoving dd 0
ZMoving dd 0
ButtonState dd 0
;timerTicks dd 0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,976 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format MS COFF
DEBUG equ 1
include 'proc32.inc'
include 'imports.inc'
API_VERSION equ 0
UART_VERSION equ API_VERSION
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)
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
};
virtual at 0
APPOBJ APPOBJ
end virtual
struc IOCTL
{ .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
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
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
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
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
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
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_IRQ equ 4
COM_2_IRQ equ 3
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 ?
.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 ?
}
virtual at 0
UART UART
end virtual
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
.id dd ? ;reserved
.uart dd ? ;uart pointer
}
virtual at 0
CONNECTION CONNECTION
end virtual
CONNECTION_SIZE equ 7*4
public START
public service_proc
public version
section '.flat' code readable align 16
proc START stdcall, state:dword
cmp [state], 1
jne .stop
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 eax, [com1]
mov [eax+UART.base], COM_1_BASE
stdcall AllocKernelSpace, 32768
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
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
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
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
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
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
stdcall AttachIntHandler, COM_1_IRQ, com_1_isr, dword 0
stdcall RegService, sz_uart_srv, service_proc
ret
.fail:
.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
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
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
@@:
cmp eax, PORT_OPEN
jne @F
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 esi, [ebx+input] ;input buffer
mov edi, [ebx+output]
call [uart_func+eax*4]
ret
.fail:
or eax, -1
ret
endp
restore handle
restore io_code
restore input
restore inp_size
restore output
restore out_size
; param
; esi= input buffer
; +0 connection
;
; retval
; eax= error code
align 4
uart_reset:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
; set mode 2400 bod 8-bit
; disable DTR & RTS
; clear FIFO
; clear pending interrupts
;
; param
; eax= uart
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 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
.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]
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
.clear_IIR:
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
mov edx, [esi+UART.base]
add edx, MSR_REG
in al, dx
jmp .clear_IIR
@@:
cmp eax, 1
je .clear_IIR
cmp eax, 2
jne @F
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
.done:
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
cld
rep stosd
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
rep stosd
ret ;eax= 0
.fail:
or eax, -1
ret
; param
; esi= input buffer
; +0 connection
; +4 rate
; +8 mode
;
; retval
; eax= error code
align 4
uart_set_mode:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
mov ebx, [esi+4]
mov ecx, [esi+8]
; param
; eax= uart
; ebx= baud rate
; ecx= mode
align 4
.internal:
cmp ebx, RATE_115200
ja .fail
cmp ecx, LCR_BREAK
jae .fail
mov [eax+UART.rate], ebx
mov [eax+UART.mode], ecx
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
pop edx
mov al, bl
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
.fail:
or eax, -1
ret
; param
; esi= input buffer
; +0 connection
; +4 modem control reg valie
;
; retval
; eax= error code
align 4
uart_set_mcr:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
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
.fail:
or eax, -1
ret
; param
; eax= port
;
; retval
; ecx= connection
; eax= error code
align 4
uart_open:
dec eax
cmp eax, COM_MAX
jae .fail
mov esi, [com1+eax*4] ;uart
push esi
.do_wait:
cmp dword [esi+UART.lock],0
je .get_lock
; call change_task
jmp .do_wait
.get_lock:
mov eax, 1
xchg eax, [esi+UART.lock]
test eax, eax
jnz .do_wait
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 [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
restore .uart
; param
; esi= input buffer
align 4
uart_close:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
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
mov [eax+UART.state], UART_CLOSED
mov [eax+UART.lock], 0 ;release port
xor eax, eax
ret
.fail:
or eax, -1
ret
; param
; eax= uart
; ebx= baud rate
align 4
set_rate:
cmp ebx, RATE_115200
ja .fail
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
sub edx, LCR_REG
mov al, bl
out dx, al
inc edx
mov al, bh
out dx, al
pop eax
add edx, LCR_REG-1
out dx, al
.fail:
ret
; param
; ebx= uart
align 4
transmit:
push esi
push edi
mov edx, [ebx+UART.base]
pushfd
cli
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
@@:
sub [ebx+UART.xmit_count], ecx
add [ebx+UART.xmit_free], ecx
cld
@@:
lodsb
out dx, al
dec ecx
jnz @B
cmp esi,[ebx+UART.xmit_top]
jb @F
sub esi, 8192
@@:
mov [ebx+UART.xmit_rp], esi
cmp [ebx+UART.xmit_count], 0
je .stop
mov [ebx+UART.state], UART_TRANSMIT
jmp @F
.stop:
mov [ebx+UART.state], UART_STOP
@@:
popfd
pop edi
pop esi
ret
; param
; esi= input buffer
; +0 connection
; +4 dst buffer
; +8 dst size
; edi= output buffer
; +0 bytes read
; retval
; eax= error code
align 4
uart_read:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .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 [edi], ecx ;bytes read
test ecx, ecx
jz .done
push 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
@@:
mov [eax+UART.rcvr_rp], esi
sub [eax+UART.rcvr_count], ecx
.done:
xor eax, eax
ret
.fail:
or eax, -1
ret
; param
; esi= input buffer
; +0 connection
; +4 src buffer
; +8 src size
;
; retval
; eax= error code
align 4
uart_write:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
mov ebx, [esi+4]
mov edx, [esi+8]
; param
; eax= uart
; ebx= src
; edx= count
align 4
.internal:
mov esi, ebx
mov edi, [eax+UART.xmit_wp]
.write:
test edx, edx
jz .fail
.wait:
cmp [eax+UART.xmit_free], 0
jne .fill
cmp [eax+UART.state], UART_TRANSMIT
je .wait
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
@@:
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
@@:
mov [eax+UART.xmit_wp], edi
cmp [eax+UART.state], UART_TRANSMIT
je @F
mov ebx, eax
call transmit
@@:
xor eax, eax
ret
.fail:
or eax, -1
ret
align 4
com_2_isr:
mov ebx, [com2]
jmp com_1_isr.get_info
align 4
com_1_isr:
mov ebx, [com1]
.get_info:
mov edx, [ebx+UART.base]
add edx, IIR_REG
in al, dx
test al, IIR_INTR
jnz .done
shr eax, 1
and eax, 3
call [isr_action+eax*4]
jmp .get_info
.done:
ret
align 4
isr_line:
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
.read:
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
.done:
cmp edi, [ebx+UART.rcvr_top]
jb @F
sub edi, 8192
@@:
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
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
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
isr_action dd isr_modem
dd transmit
dd isr_recieve
dd isr_line
version dd (5 shl 16) or (UART_VERSION and 0xFFFF)
sz_uart_srv db 'UART',0
align 4
com1 rd 1
com2 rd 1

View File

@ -1,736 +0,0 @@
;
; MenuetOS Driver (vmode.mdr)
; Target: Vertical Refresh Rate programming and videomode changing
;
; Author: Trans <<<<<13>>>>>
; Date: 20.07.2003
;
; Version: 1.0
; OS: MenuetOS
; Compiler: FASM
;
OS_BASE equ 0x80000000
use32
macro align value { rb (value-1) - ($ + value-1) mod value }
org OS_BASE+0x0328000
headerstart=$
mdid db 'MDAZ' ; 4 byte id
mdhver dd 0x00 ; header version
mdcode dd MDSTART ; start of code
mdver dd 0x00000001 ; driver version (subversion*65536+version)
mdname db 'Trans VideoDriver' ; 32 bytes of full driver name
times (32-($-mdname)) db ' ' ;
headerlen=$-headerstart
times (256-headerlen) db 0 ; reserved area for future
MDSTART: ; start of driver code ( base_adr+256 bytes)
; ebx(=ecx in program):
; 1 - Get DriverInfo and Driver Initial Set
; 2 - Get Current Video Mode With Vertical Refresh Rate
; 3 - Change Video Mode
; 4 - Return at Start System Video Mode
; 5 - Change vertical and horizontal size of visible screen area
; 6 - Change Vert/Hor position visible area on screen (not complete yet)
;
; MAXF - ...
MAXF=5
;-------Main Manager-------------
pushad
cmp ebx,1
jb mdvm_00
cmp ebx,MAXF
ja mdvm_00
shl ebx,2
add ebx,mdvm_func_table
call dword [ebx]
mov [esp+28],eax
mov [esp+24],ecx
mov [esp+20],edx
mov [esp+16],ebx
popad
retn
mdvm_00:
popad
xor eax,eax
dec eax
retn
; ------Drivers Functions----------
align 4
; EBX=1 (in applications ECX=1)- Get DriverInfo and Driver Initial Set
;
; IN: ecx (in app. edx) - pointer to 512-bytes info area in application
; OUT:
;
vm_info_init:
push ecx
cmp [mdrvm],dword 0
jnz .vmii_00
call vm_safe_reg
call vm_get_initial_videomode
mov eax,[initvm]
mov [currvm],eax
call vm_search_sys_func_table
call vm_get_cur_vert_rate
mov [initrr],eax
call vm_calc_pixelclock
call vm_calc_refrate
inc [mdrvm]
.vmii_00:
pop ecx
call vm_transfer_drv_info
mov ebx,dword [refrate]
mov eax,dword [mdid] ;dword [systlb]
retn
align 4
; EBX=2 (in applications ECX=2)- Get Current Video Mode
;
; OUT: eax = X_screen*65536+Y_screen
; ebx = current vertical rate
; ecx = current video mode (number)
vm_get_cur_mode:
cmp [mdrvm],dword 0
jz .vmgcm_00
call vm_get_cur_vert_rate
mov eax,[OS_BASE+0FE00h]
mov ebx,[OS_BASE+0FE04h]
shl eax,16
add eax,ebx
add eax,00010001h
mov ebx,[refrate]
mov ecx,[currvm]
retn
.vmgcm_00:
xor eax,eax
dec eax
retn
align 4
; EBX=3 (in applications ECX=3)- Change Video Mode
;
; IN: ecx = VertRate*65536+VideoMode
; OUT: eax = 0 if no error
;
vm_set_video_mode:
cmp [mdrvm],dword 0
jz .vmsvm_00
call vm_set_selected_mode
; xor eax,eax
retn
.vmsvm_00:
xor eax,eax
dec eax
retn
align 4
; EBX=4 (in applications ECX=4)- Return at Start System Video Mode
;
; IN:
; OUT: eax = = 0 if no error
;
vm_restore_init_video_mode:
cmp [mdrvm],dword 0
jz .vmrivm_00
call vm_restore_reg
xor eax,eax
retn
.vmrivm_00:
xor eax,eax
dec eax
retn
align 4
; EBX=5 (in applications ECX=5)- Change vertical and horizontal size
; of visible screen area
; IN: ecx (in app. edx) = 0/1 - -/+ horizontal size on 1 position
; = 2/3 - -/+ vertical size on 1 position (8 pixels)
; ^-^----- not complete yet
; OUT: eax = = 0 if no error
;
vm_change_screen_size:
cmp [mdrvm],dword 0
jz .vmcss_00
cmp cl,1
ja .vmcss_01
mov eax,ecx
call vm_inc_dec_width
xor eax,eax
retn
.vmcss_01:
and ecx,01h
mov eax,ecx
; call vm_inc_dec_high ; not complete yet
xor eax,eax
retn
.vmcss_00:
xor eax,eax
dec eax
retn
align 4
; EBX=6 (in applications ECX=6)- Change Vert/Hor position visible area on screen
;
; IN: ecx (in app. edx) = 0/1 - -/+ horizontal position on 1 point
; = 2/3 - -/+ vertical position on 1 pixel
; ^-^----- not complete yet
; OUT: eax = 0 if no error
;
vm_change_position_screen:
cmp [mdrvm],dword 0
jz .vmcps_00
; ...
xor eax,eax
retn
.vmcps_00:
xor eax,eax
dec eax
retn
;-----Drivers Subfunctions---------
;
; Searching i40 system functions pointer table in kernel area location
;
vm_search_sys_func_table:
push eax ; eax - current value
push ecx ; ecx - will be counter of equevalent value
push edx ; edx - last value
push esi ; esi - current address
xor ecx,ecx
mov esi,OS_BASE+010000h ; Start address of kernel location
lodsd
mov edx,eax
cld
.vmssft_00:
cmp esi,OS_BASE+30000h
ja .vmssft_03
inc ecx
lodsd
cmp edx,eax
mov edx,eax
je .vmssft_00
cmp ecx,128
ja .vmssft_02
.vmssft_01:
xor ecx,ecx
jmp .vmssft_00
.vmssft_02:
cmp edx,0
je .vmssft_01
sub esi,256*4-1
mov [systlb],esi
xor ecx,ecx
.vmssft_03_0:
inc ecx
lodsd
cmp edx,eax
mov edx,eax
jne .vmssft_03_0
mov esi,dword [systlb]
cmp cx,60
jae .vmssft_03
add esi,256*4-4
lodsb
mov edx,eax
jmp .vmssft_01
.vmssft_03:
mov [systlb],esi
pop esi
pop edx
pop ecx
pop eax
retn
; IN:
; OUT: eax= vertical rate in Hz
vm_get_cur_vert_rate:
push edx
push ebx
xor eax,eax
mov edx,eax
mov ebx,eax
mov dx,03DAh
.vmgcvt_00:
in al,dx
test al,8
jz .vmgcvt_00
.vmgcvt_01:
in al,dx
test al,8
jnz .vmgcvt_01
mov ebx,edx
rdtsc
mov edx,ebx
mov ebx,eax
.vmgcvt_02:
in al,dx
test al,8
jz .vmgcvt_02
.vmgcvt_03:
in al,dx
test al,8
jnz .vmgcvt_03
rdtsc
sub eax,ebx
mov ebx,eax
mov eax,[OS_BASE+0F600h]
xor edx,edx
div ebx
inc eax
mov [refrate],eax
pop ebx
pop edx
retn
vm_calc_pixelclock:
push ebx
push edx
xor eax,eax
mov al,[_00]
add ax,5
shl eax,3
xor ebx,ebx
mov bl,[_06]
mov bh,[_07]
and bh,00100001b
btr bx,13
jnc .vmcpc_00
or bh,2
.vmcpc_00:
xor edx,edx
mul ebx
xor edx,edx
mul [initrr]
mov [pclock],eax
pop edx
pop ebx
retn
;
; Safe of initial CRTC state
;
vm_safe_reg:
push edx
push ebx
push ecx
push edi
cli
mov dx,3d4h ; CRTC
mov al,11h
out dx,al
inc dx
in al,dx
and al,7fh
out dx,al ; Clear protection bit
dec dx
xor ecx,ecx
mov cl,19h
xor bl,bl
mov edi,CRTCreg
.vmsr_00:
mov al,bl
out dx,al
inc dx
in al,dx
dec dx
stosb
inc bl
loop .vmsr_00
sti
pop edi
pop ecx
pop ebx
pop edx
retn
;
; Restore of initial CRTC state
;
vm_restore_reg:
push eax
push ebx
push edx
push esi
mov eax,[oldX]
mov [OS_BASE+0FE00h],eax
mov eax,[oldY]
mov [OS_BASE+0FE04h],eax
mov dx,03dah
.vmrr_00:
in al,dx
test al,8
jnz .vmrr_00
.vmrr_01:
in al,dx
test al,8
jnz .vmrr_01
cli
mov dx,03c4h
mov ax,0101h
out dx,ax
mov dx,3d4h ; CRTC
mov al,11h
out dx,al
inc dx
in al,dx
and al,7fh ; Clear Protection bit
out dx,al
dec dx
xor ecx,ecx
mov cl,19h
mov esi,CRTCreg
xor bl,bl
.vmrr_02:
lodsb
mov ah,al
mov al,bl
out dx,ax
inc bl
loop .vmrr_02
sti
; call ref_screen
pop esi
pop edx
pop ecx
pop eax
retn
; Calculate of possible vertical refrash rate
; (light version of function)
vm_calc_refrate:
push ebx
push ecx
push edx
push edi
push esi
mov eax,[pclock]
xor edx,edx
mov edi,_m1
mov ebx,eax
mov ecx,(1696*1065)
div ecx
xor edx,edx
stosw
add edi,8
mov eax,ebx
mov ecx,(1344*804)
div ecx
xor edx,edx
stosw
add edi,8
mov eax,ebx
mov ecx,(1056*636)
div ecx
xor edx,edx
stosw
add edi,8
mov eax,ebx
mov ecx,(800*524)
div ecx
xor edx,edx
stosw
mov edi,_m1
mov esi,edi
mov ecx,5*4
.vmcrr_00:
lodsw
cmp ax,55
jb .vmcrr_01
stosw
loop .vmcrr_00
pop esi
pop edi
pop edx
pop ecx
pop ebx
retn
.vmcrr_01:
xor ax,ax
stosw
loop .vmcrr_00
pop esi
pop edi
pop edx
pop ecx
pop ebx
retn
vm_get_initial_videomode:
push eax
mov eax,dword [OS_BASE+0FE00h]
mov [oldX],eax
mov eax,dword [OS_BASE+0FE04h]
mov [oldY],eax
mov eax,dword [OS_BASE+0FE0Ch] ; initial video mode
and ax,01FFh
mov dword [initvm],eax
pop eax
retn
; IN: eax = 0/1 - -/+ 1 position of width
vm_inc_dec_width:
push ebx
push edx
mov ebx,eax
mov dx,3d4h ; CRTC
mov al,11h
out dx,al
inc dx
in al,dx
and al,7fh ; Clear Protection bit
out dx,al
dec dx
xor al,al
out dx,al
inc dx
in al,dx
dec al
cmp bl,0
jnz .vmidr_00
inc al
inc al
.vmidr_00:
out dx,al
pop edx
pop ebx
retn
;
; Copy driver info to application area
;
; IN: ecx (in app. edx) - pointer to 512-bytes info area in application
; OUT:
vm_transfer_drv_info:
push ecx
push edi
push esi
mov eax,ecx
xor ecx,ecx
mov cl,32/4
mov esi,mdname
mov edi,drvname
rep movsd
mov ecx,eax
mov eax,[mdver]
mov [drvver],eax
mov edi,[OS_BASE+3010h]
mov edi,[edi+10h]
add edi,ecx
mov esi,drvinfo
xor ecx,ecx
mov cx,512
rep movsb
pop esi
pop edi
pop ecx
retn
;
; Set selected video mode
; (light version)
;
; IN: ecx = VertRate*65536+VideoMode
;
vm_set_selected_mode:
push edx
push ecx
push esi
ror ecx,16
cmp cx,00h
je .vmssm_03
rol ecx,16
mov eax,ecx
shl eax,16
shr eax,16
mov [currvm],eax
cmp cx,112h
jne .vmssm_00
mov esi,mode0
mov ecx,639
mov edx,479
jmp .vmssm_st00
.vmssm_00:
cmp cx,115h
jne .vmssm_01
mov esi,mode1
mov ecx,799
mov edx,599
jmp .vmssm_st00
.vmssm_01:
cmp cx,118h
jne .vmssm_02
mov esi,mode2
mov ecx,1023
mov edx,767
jmp .vmssm_st00
.vmssm_02:
cmp cx,11Bh
jne .vmssm_03
mov esi,mode2
mov ecx,1279
mov edx,1023
jmp .vmssm_st00
.vmssm_03:
xor eax,eax
dec eax
pop esi
pop ecx
pop edx
retn
.vmssm_st00:
mov [OS_BASE+0FE00h],ecx
mov [OS_BASE+0FE04h],edx
cli
mov dx,03c4h
lodsw
out dx,ax
mov dx,03d4h
mov al,11h
out dx,al
inc dx
in al,dx
and al,7fh
out dx,al
dec dx
mov ecx,13
.vmssm_st01:
lodsw
out dx,ax
loop .vmssm_st01
sti
xor eax,eax
pop esi
pop ecx
pop edx
retn
;------------DATA AREA---------------
align 4
mdvm_func_table:
dd MDSTART
dd vm_info_init, vm_get_cur_mode
dd vm_set_video_mode, vm_restore_init_video_mode
dd vm_change_screen_size, vm_change_position_screen
CRTCreg:
_00 db ?
_01 db ?
_02 db ?
_03 db ?
_04 db ?
_05 db ?
_06 db ?
_07 db ?
_08 db ?
_09 db ?
_0a db ?
_0b db ?
_0c db ?
_0d db ?
_0e db ?
_0f db ?
_10 db ?
_11 db ?
_12 db ?
_13 db ?
_14 db ?
_15 db ?
_16 db ?
_17 db ?
_18 db ?
_19 db ?
align 4
oldX dd ?
oldY dd ?
initvm dd ?
currvm dd 0
refrate dd 0
initrr dd 0
systlb dd 0
pclock dd ?
mdrvm dd 0 ; 0 - not drv init yet, 1 - already drv init
drvinfo:
drvname: times 32 db ' '
drvver dd 0
times (32-($-drvver))/4 dd 0
drvmode dw 011Bh,0118h,0115h,0112h
times (64-($-drvmode))/2 dw 00h
_m1 dw 0,0,0,0,0
_m2 dw 0,0,0,0,0
_m3 dw 0,0,0,0,0
_m4 dw 0,0,0,0,0
_m5 dw 0,0,0,0,0
times (512-($-drvinfo)) db 0
drvinfoend:
;1280x1024 - 11Bh
mode3:
dw 0101h
dw 0d000h,9f01h,9f02h,9303h,0a904h,1905h,2806h,5a07h
dw 0110h,8411h,0ff12h,0ff15h,2916h
;1024x768 - 118h
mode2:
dw 0101h
dw 0a400h,7f01h,7f02h,8703h,8404h,9505h,2406h,0f507h
dw 0310h,8911h,0ff12h,0ff15h,2516h
;800x600 - 115h
mode1:
dw 0101h
dw 8000h,6301h,6302h,8303h,6a04h,1a05h,7206h,0f007h
dw 5910h,8d11h,5712h,5715h,7316h
;640x480 - 112h, 12h
mode0:
dw 0101h
dw 6000h,4f01h,4f02h,8303h,5304h,9f05h,00b06h,3e07h
dw 0ea10h,8c11h,0df12h,0df15h,0c16h
; 640x400
;mymode0:
; dw 0101h
;_0_7 dw 5f00h,4f01h,4f02h,8303h,5304h,9f05h,0BF06h,1f07h
; dw 9c10h,8e11h,8f12h,9615h,0B916h ;,4013h
; 640x800
;mymode1:
; dw 0101h
; dw 5f00h,4f01h,4f02h,8003h,5004h,9f05h,06006h,0FF07h
; dw 2d10h,8f11h,2012h,2615h,05716h ;,4013h
DRVM_END:

View File

@ -531,6 +531,8 @@ proc arp_request stdcall uses ebx esi edi,\
xor edx, edx
shl edx, 2
inc [ARP_PACKETS_TX+edx]
push dword .returnaddr
push dword 60
push ebx
@ -598,7 +600,8 @@ ARP_Handler:
jne .exit
call ETH_struc2dev
DEBUGF 1,"Packet came from device: %u\n", edi
DEBUGF 1,"ARP Packet came from device: %u\n", edi
inc [ARP_PACKETS_RX+4*edi]
cmp edi, -1
jz .exit

View File

@ -149,7 +149,8 @@ IPv4_Handler:
jmp .dump
.ip_ok:
call ETH_struc2dev ; TODO: make this work on other protocols too!
inc [IP_PACKETS_RX+4*edi]
DEBUGF 1,"IP_Handler - packet from %u.%u.%u.%u\n",\
[edx + IPv4_Packet.SourceAddress]:1,[edx + IPv4_Packet.SourceAddress + 1]:1,[edx + IPv4_Packet.SourceAddress + 2]:1,[edx + IPv4_Packet.SourceAddress + 3]:1
@ -390,10 +391,10 @@ IPv4_Handler:
mov al , [edx + IPv4_Packet.Protocol]
pop edx ; Offset to data (tcp/udp/icmp/.. Packet)
; cmp al , PROTOCOL_TCP
; cmp al , IP_PROTO_TCP
; je TCP_Handler
cmp al , PROTOCOL_UDP
cmp al , IP_PROTO_UDP
je UDP_Handler
cmp al , IP_PROTO_ICMP
@ -535,6 +536,7 @@ IPv4_create_Packet:
.send:
push ecx eax ebx dx di
call IPv4_dest_to_dev
inc [IP_PACKETS_TX+4*edi]
mov edi, [ETH_DRV_LIST + 4*edi]
lea eax, [edi + ETH_DEVICE.mac]
mov ebx, temp_dstmac
@ -581,7 +583,7 @@ IPv4_create_Packet:
uglobal
temp_dstmac dp ?
temp_dstmac dp ? ; TODO: place this in stack instead!
endg

View File

@ -449,32 +449,32 @@ ETH_API:
dec bl
jz .out_queue ; 7
.error:
mov eax, -1
ret
.packets_tx:
add eax, ETH_DRV_LIST
mov eax, [eax]
mov eax, [eax + ETH_DEVICE.packets_tx]
mov eax, dword [eax]
mov eax, dword [eax + ETH_DEVICE.packets_tx]
ret
.packets_rx:
add eax, ETH_DRV_LIST
mov eax, [eax]
mov eax, [eax + ETH_DEVICE.packets_rx]
mov eax, dword [eax]
mov eax, dword [eax + ETH_DEVICE.packets_rx]
ret
.bytes_tx:
add eax, ETH_DRV_LIST
mov eax, [eax]
mov eax, dword [eax]
mov eax, dword [eax + ETH_DEVICE.bytes_tx + 4]
ret
.bytes_rx:
add eax, ETH_DRV_LIST
mov eax, [eax]
mov eax, dword [eax]
mov eax, dword [eax + ETH_DEVICE.bytes_rx + 4]
ret

View File

@ -125,6 +125,14 @@ ICMP_init:
ret
;--------------------------------
;
; ICMP_Handler:
@ -151,6 +159,11 @@ ICMP_Handler: ;TODO: works only on pure ethernet right now !
mov byte [edx + ICMP_Packet.Type], ICMP_ECHOREPLY ; Change Packet type to reply
mov word [edx + ICMP_Packet.Checksum], 0 ; Set checksum to 0, needed to calculate new checksum
call ETH_struc2dev
cmp edi,-1
je .dump
inc [ICMP_PACKETS_RX+4*edi]
; exchange dest and source address in IP header
; exchange dest and source MAC in ETH header
mov esi, [esp]
@ -197,7 +210,11 @@ ICMP_Handler: ;TODO: works only on pure ethernet right now !
xchg al, ah ; Convert to intel byte order
mov word [edx + ICMP_Packet.Checksum], ax
jmp ETH_Sender
jmp ETH_Sender ; Send the reply
.check_sockets:
; TODO: validate the header & checksum. Discard buffer if error
@ -222,6 +239,11 @@ ICMP_Handler: ;TODO: works only on pure ethernet right now !
cmp ecx, SOCKETBUFFSIZE - SOCKETHEADERSIZE; TODO: fix this problem !
jg .dump
call IPv4_dest_to_dev
cmp edi,-1
je .dump
inc [ICMP_PACKETS_RX+4*edi]
DEBUGF 1,"Found valid ICMP packet for socket %x\n", esi
lea ebx, [esi + SOCKET.lock]

View File

@ -1,23 +1,21 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; STACK.INC ;;
;; ;;
;; TCP/IP stack for Menuet OS ;;
;; BASIC TCP/IP stack for KolibriOS ;;
;; ;;
;; Copyright 2002 Mike Hibbett, mikeh@oceanfree.net ;;
;; Written by hidnplayr@kolibrios.org ;;
;; ;;
;; See file COPYING for details ;;
;; based on the work of Mike Hibbett, mikeh@oceanfree.net ;;
;; but also Paolo Franchetti ;;
;; ;;
;; Version 0.7 ;;
;; Added a timer per socket to allow delays when rx window ;;
;; gets below 1KB ;;
;; GNU GENERAL PUBLIC LICENSE ;;
;; Version 2, June 1991 ;;
;; ;;
;;10.01.2007 Bugfix for checksum function from Paolo Franchetti ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 983 $
@ -192,7 +190,7 @@ endp
;----------------------------------------------------------------
;
;
; System function to work with network devices (73)
;
;----------------------------------------------------------------
@ -242,21 +240,19 @@ sys_network:
;----------------------------------------------------------------
;
;
; System Function To work with Protocols (75)
;
;----------------------------------------------------------------
align 4
sys_protocols:
cmp bh, MAX_NET_DEVICES ; Check if device number exists
jge .doesnt_exist
mov esi, ebx
and esi, 0x0000ff00
shr esi, 6
cmp dword [esi + ETH_DRV_LIST], 0 ; check if driver is running TODO: check otehr lists too
cmp dword [esi + ETH_DRV_LIST], 0 ; check if driver is running TODO: check other lists too
je .doesnt_exist
push .return ; return address (we will be using jumps instead of calls)
@ -273,7 +269,7 @@ sys_protocols:
cmp ax , IP_PROTO_UDP
je UDP_API
; cmp ax , IP_PROTO_TCP
cmp ax , IP_PROTO_TCP
; je TCP_API
cmp ax , ETHER_ARP
@ -285,9 +281,9 @@ sys_protocols:
add esp, 4 ; if we reached here, no function was called, so we need to balance stack
.doesnt_exist:
DEBUGF 1,"sys_protocols: invalid device specified!\n"
DEBUGF 1,"sys_protocols: protocol %u doesnt exist on device %u!\n",ax, bh
mov eax, -1
.return:
mov [esp+32], eax
mov [esp+28+4], eax
ret