RTL8139 fixes from heavyiron and new system function from me: read data from stack

input:
eax = 53
ebx = 11
ecx = socket number
edx = pointer to where data must be written
esi = buffer size (max bytes of data to copy)
int  0x40  (offcourse)

returned: 
eax = number of bytes copied

if buffer size is zero, all data will be copied (this will be max 4096 bytes)

git-svn-id: svn://kolibrios.org@323 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2007-02-06 19:29:54 +00:00
parent 5121a68d46
commit a6c8d276c3
4 changed files with 179 additions and 104 deletions

View File

@ -460,11 +460,11 @@ rtl8139_transmit:
lea edx, [edx+ecx*4+RTL8139_REG_TSD0]
push edx ebx
in ax, dx
test ax, 0x1fff ; or no size given
jz .send_packet
and ax, (1 shl RTL8139_BIT_TOK) or (1 shl RTL8139_BIT_OWN)
cmp ax, (1 shl RTL8139_BIT_TOK) or (1 shl RTL8139_BIT_OWN)
jz .send_packet
test ax, 0x1fff ; or no size given
jz .send_packet
; wait for timeout
mov ebx, RTL8139_TX_TIMEOUT
mov eax, 0x5 ; delay x/100 secs

View File

@ -97,6 +97,7 @@ include "drivers/rtl8139.inc"
include "drivers/3c59x.inc"
include "drivers/sis900.inc"
include "drivers/pcnet32.inc"
;include "drivers/mtd80x.inc"
; PCICards
; ========
@ -180,8 +181,14 @@ dd 0x09001039, SIS900_probe, SIS900_reset, SIS900_poll, SIS900_transmit, 0
dd 0x20001022, pcnet32_probe, pcnet32_reset, pcnet32_poll, pcnet32_xmit, 0
dd 0x26251022, pcnet32_probe, pcnet32_reset, pcnet32_poll, pcnet32_xmit, 0
dd 0x20011022, pcnet32_probe, pcnet32_reset, pcnet32_poll, pcnet32_xmit, 0
; following card is untested
;dd 0x08031516, mtd80x_probe, mtd80x_reset, mtd80x_poll, mtd80x_transmit, mtd80x_cable
; following cards are untested
dd 0x70161039, SIS900_probe, SIS900_reset, SIS900_poll, SIS900_transmit, 0
;dd 0x08001516, mtd80x_probe, mtd80x_reset, mtd80x_poll, mtd80x_transmit, mtd80x_cable
;dd 0x08911516, mtd80x_probe, mtd80x_reset, mtd80x_poll, mtd80x_transmit, mtd80x_cable
rb PCICARDS_ENTRY_SIZE ; end of list marker, do not remove
endg

View File

@ -207,12 +207,8 @@ socket_open:
xchg bh, bl
mov [eax + SOCKET.LocalPort], bx
; mov [eax + 12], byte bh ; Local port ( LS 16 bits )
; mov [eax + 13], byte bl ; Local port ( LS 16 bits )
xchg ch, cl
mov [eax + SOCKET.RemotePort], cx
; mov [eax + 20], ch ; Remote Port ( LS 16 bits )
; mov [eax + 21], cl ; Remote Port ( LS 16 bits )
mov ebx, [stack_ip]
mov [eax + SOCKET.LocalIP], ebx
@ -547,6 +543,73 @@ sor_exit:
ret
;***************************************************************************
; Function
; socket_read_packet
;
; Description
; socket # in ebx
; datapointer # in ecx
; buffer size in edx
; returns # of bytes copied in eax
;
;***************************************************************************
socket_read_packet:
Index2RealAddr ebx ; get real socket address
mov eax, [ebx + SOCKET.rxDataCount] ; get count of bytes
test eax, eax ; if count of bytes is zero..
jz .exit ; exit function (eax will be zero)
test edx, edx ; if buffer size is zero, copy all data
jz .copyallbytes
cmp edx, eax ; if buffer size is larger then the bytes of data, copy all data
jge .copyallbytes
sub eax, edx ; store new count (data bytes in buffer - bytes we're about to copy)
mov [ebx + SOCKET.rxDataCount], eax ;
push eax
mov eax, edx ; number of bytes we want to copy must be in eax
call .startcopy ; copy to the application
mov esi, ebx ; now we're going to copy the remaining bytes to the beginning
add esi, SOCKETHEADERSIZE ; we dont need to copy the header
mov edi, esi ; edi is where we're going to copy to
add esi, edx ; esi is from where we copy
pop ecx ; count of bytes we have left
push ecx ; push it again so we can re-use it later
shr ecx, 2 ; divide eax by 4
cld
rep movsd ; copy all full dwords
pop ecx
and ecx, 3
rep movsb ; copy remaining bytes
ret ; at last, exit
.copyallbytes:
xor esi, esi
mov [ebx + SOCKET.rxDataCount], esi ; store new count (zero)
.startcopy:
mov edi, ecx ;
add edi, std_application_base_address ; get data pointer to buffer in application
mov esi, ebx ;
add esi, SOCKETHEADERSIZE ; we dont need to copy the header
mov ecx, eax ; eax is count of bytes
push ecx
shr ecx, 2 ; divide eax by 4
cld ; copy all full dwords
rep movsd ;
pop ecx
and ecx, 3
rep movsb ; copy the rest bytes
.exit:
ret ; exit, or go back to shift remaining bytes if any
;***************************************************************************
; Function

View File

@ -269,15 +269,13 @@ endp
checksum:
pusha
mov eax, [checkAdd1]
xor edx, edx ; edx is the accumulative checksum
xor ebx, ebx
mov cx, [checkSize1]
shr cx, 1
jz cs1_1
mov eax, [checkAdd1]
cs1:
mov bh, [eax]
mov bl, [eax + 1]
@ -301,11 +299,11 @@ cs_test2:
cmp cx, 0
jz cs_exit ; Finished if no 2nd buffer
mov eax, [checkAdd2]
shr cx, 1
jz cs2_1
mov eax, [checkAdd2]
cs2:
mov bh, [eax]
mov bl, [eax + 1]
@ -673,6 +671,13 @@ nots9:
nots10:
cmp eax, 11
jnz nots11
call socket_read_packet
ret
nots11:
cmp eax, 254
jnz notdump