Fixed alignment for data in network stack. Alqo, network queue uses a mutex now.
git-svn-id: svn://kolibrios.org@3698 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
a5c3784aca
commit
1ca5fecb5c
@ -55,9 +55,8 @@ struct ARP_header
|
||||
|
||||
ends
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
|
||||
align 4
|
||||
|
||||
ARP_table rb NET_DEVICES_MAX*(ARP_TABLE_SIZE * sizeof.ARP_entry)
|
||||
|
||||
|
@ -55,8 +55,8 @@ struct FRAGMENT_entry ; This structure will replace the ethern
|
||||
ends
|
||||
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
align 4
|
||||
|
||||
IP_LIST rd NET_DEVICES_MAX
|
||||
SUBNET_LIST rd NET_DEVICES_MAX
|
||||
@ -69,6 +69,7 @@ uglobal
|
||||
IP_packets_dumped rd NET_DEVICES_MAX
|
||||
|
||||
FRAGMENT_LIST rb MAX_FRAGMENTS * sizeof.FRAGMENT_slot
|
||||
|
||||
endg
|
||||
|
||||
|
||||
|
@ -30,8 +30,8 @@ struct IPv6_header
|
||||
ends
|
||||
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
align 4
|
||||
|
||||
IPv6:
|
||||
.addresses rd 4*NET_DEVICES_MAX
|
||||
|
@ -23,8 +23,11 @@ struct PPPoE_frame
|
||||
ends
|
||||
|
||||
uglobal
|
||||
align 4
|
||||
|
||||
PPPoE_SID dw ?
|
||||
PPPoE_MAC dp ?
|
||||
|
||||
endg
|
||||
|
||||
;-----------------------------------------------------------------
|
||||
|
@ -32,8 +32,8 @@ struct ETH_DEVICE NET_DEVICE
|
||||
|
||||
ends
|
||||
|
||||
align 4
|
||||
iglobal
|
||||
align 4
|
||||
|
||||
ETH_BROADCAST dp 0xffffffffffff
|
||||
endg
|
||||
|
@ -97,10 +97,12 @@ struct ICMP_header
|
||||
ends
|
||||
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
align 4
|
||||
|
||||
ICMP_PACKETS_TX rd NET_DEVICES_MAX
|
||||
ICMP_PACKETS_RX rd NET_DEVICES_MAX
|
||||
|
||||
endg
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
$Revision: 2891 $
|
||||
|
||||
iglobal
|
||||
align 4
|
||||
|
||||
LOOPBACK_DEVICE:
|
||||
|
||||
|
@ -23,11 +23,12 @@ $Revision: 2305 $
|
||||
; (you can see some examples below)
|
||||
|
||||
|
||||
struct queue
|
||||
struct queue
|
||||
|
||||
size dd ? ; number of queued packets in this queue
|
||||
w_ptr dd ? ; current writing pointer in queue
|
||||
r_ptr dd ? ; current reading pointer
|
||||
size dd ? ; number of queued packets in this queue
|
||||
w_ptr dd ? ; current writing pointer in queue
|
||||
r_ptr dd ? ; current reading pointer
|
||||
mutex MUTEX
|
||||
|
||||
ends
|
||||
|
||||
@ -44,23 +45,41 @@ ends
|
||||
|
||||
macro add_to_queue ptr, size, entry_size, failaddr {
|
||||
|
||||
cmp [ptr + queue.size], size ; Check if queue isnt full
|
||||
jae failaddr
|
||||
local .ok, .no_wrap
|
||||
|
||||
inc [ptr + queue.size] ; if not full, queue one more
|
||||
pusha
|
||||
lea ecx, [ptr + queue.mutex]
|
||||
call mutex_lock
|
||||
popa
|
||||
|
||||
mov edi, [ptr + queue.w_ptr] ; Current write pointer (FIFO!)
|
||||
mov ecx, entry_size/4 ; Write the queue entry
|
||||
rep movsd ;
|
||||
cmp [ptr + queue.size], size ; Check if queue isnt full
|
||||
jb .ok
|
||||
|
||||
lea ecx, [size*entry_size+ptr+sizeof.queue]
|
||||
cmp edi, ecx ; entry size
|
||||
jb .no_wrap
|
||||
pusha
|
||||
lea ecx, [ptr + queue.mutex]
|
||||
call mutex_unlock
|
||||
popa
|
||||
jmp failaddr
|
||||
|
||||
sub edi, size*entry_size
|
||||
.ok:
|
||||
inc [ptr + queue.size] ; if not full, queue one more
|
||||
|
||||
mov edi, [ptr + queue.w_ptr] ; Current write pointer (FIFO!)
|
||||
mov ecx, entry_size/4 ; Write the queue entry
|
||||
rep movsd ;
|
||||
|
||||
lea ecx, [size*entry_size+ptr+sizeof.queue]
|
||||
cmp edi, ecx ; entry size
|
||||
jb .no_wrap
|
||||
|
||||
sub edi, size*entry_size
|
||||
.no_wrap:
|
||||
mov [ptr + queue.w_ptr], edi
|
||||
mov [ptr + queue.w_ptr], edi
|
||||
|
||||
pusha
|
||||
lea ecx, [ptr + queue.mutex]
|
||||
call mutex_unlock
|
||||
popa
|
||||
|
||||
}
|
||||
|
||||
@ -68,33 +87,55 @@ macro add_to_queue ptr, size, entry_size, failaddr {
|
||||
|
||||
macro get_from_queue ptr, size, entry_size, failaddr {
|
||||
|
||||
cmp [ptr + queue.size], 0 ; any packets queued?
|
||||
je failaddr
|
||||
local .ok, .no_wrap
|
||||
|
||||
dec [ptr + queue.size] ; if so, dequeue one
|
||||
pusha
|
||||
lea ecx, [ptr + queue.mutex]
|
||||
call mutex_lock
|
||||
popa
|
||||
|
||||
mov esi, [ptr + queue.r_ptr]
|
||||
push esi
|
||||
cmp [ptr + queue.size], 0 ; any packets queued?
|
||||
ja .ok
|
||||
|
||||
add esi, entry_size
|
||||
pusha
|
||||
lea ecx, [ptr + queue.mutex]
|
||||
call mutex_unlock
|
||||
popa
|
||||
jmp failaddr
|
||||
|
||||
lea ecx, [size*entry_size+ptr+sizeof.queue]
|
||||
cmp esi, ecx ; entry size
|
||||
jb .no_wrap
|
||||
.ok:
|
||||
dec [ptr + queue.size] ; if so, dequeue one
|
||||
|
||||
sub esi, size*entry_size
|
||||
mov esi, [ptr + queue.r_ptr]
|
||||
push esi
|
||||
|
||||
add esi, entry_size
|
||||
|
||||
lea ecx, [size*entry_size+ptr+sizeof.queue]
|
||||
cmp esi, ecx ; entry size
|
||||
jb .no_wrap
|
||||
|
||||
sub esi, size*entry_size
|
||||
|
||||
.no_wrap:
|
||||
mov dword [ptr + queue.r_ptr], esi
|
||||
mov dword [ptr + queue.r_ptr], esi
|
||||
|
||||
pop esi
|
||||
pop esi
|
||||
|
||||
pusha
|
||||
lea ecx, [ptr + queue.mutex]
|
||||
call mutex_unlock
|
||||
popa
|
||||
|
||||
}
|
||||
|
||||
macro init_queue ptr {
|
||||
|
||||
mov [ptr + queue.size] , 0
|
||||
lea edi, [ptr + sizeof.queue]
|
||||
mov [ptr + queue.w_ptr], edi
|
||||
mov [ptr + queue.r_ptr], edi
|
||||
mov [ptr + queue.size] , 0
|
||||
lea edi, [ptr + sizeof.queue]
|
||||
mov [ptr + queue.w_ptr], edi
|
||||
mov [ptr + queue.r_ptr], edi
|
||||
|
||||
lea ecx, [ptr + queue.mutex]
|
||||
call mutex_init
|
||||
}
|
@ -194,11 +194,14 @@ SOCKET_QUEUE_SIZE = 10 ; maximum number of incoming packets queued f
|
||||
SOCKET_QUEUE_LOCATION = (SOCKETBUFFSIZE - SOCKET_QUEUE_SIZE*sizeof.socket_queue_entry - sizeof.queue)
|
||||
|
||||
uglobal
|
||||
align 4
|
||||
|
||||
net_sockets rd 4
|
||||
last_socket_num dd ?
|
||||
last_UDP_port dw ? ; These values give the number of the last used ephemeral port
|
||||
last_TCP_port dw ? ;
|
||||
socket_mutex MUTEX
|
||||
|
||||
endg
|
||||
|
||||
|
||||
@ -614,8 +617,9 @@ align 4
|
||||
.loop:
|
||||
cmp [eax + TCP_SOCKET.t_state], TCPS_CLOSED
|
||||
je .fail
|
||||
cmp [eax + TCP_SOCKET.t_state], TCPS_SYN_SENT
|
||||
jne .syn_received
|
||||
cmp [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
||||
je .established
|
||||
ja .fail
|
||||
|
||||
call SOCKET_block
|
||||
jmp .loop
|
||||
@ -626,7 +630,7 @@ align 4
|
||||
mov dword[esp+32], -1
|
||||
ret
|
||||
|
||||
.syn_received:
|
||||
.established:
|
||||
mov dword[esp+32], 0
|
||||
ret
|
||||
|
||||
|
@ -221,8 +221,8 @@ include "socket.inc"
|
||||
|
||||
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
align 4
|
||||
|
||||
NET_RUNNING dd ?
|
||||
NET_DRV_LIST rd NET_DEVICES_MAX
|
||||
|
@ -27,10 +27,12 @@ struct UDP_header
|
||||
ends
|
||||
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
align 4
|
||||
|
||||
UDP_PACKETS_TX rd NET_DEVICES_MAX
|
||||
UDP_PACKETS_RX rd NET_DEVICES_MAX
|
||||
|
||||
endg
|
||||
|
||||
|
||||
@ -114,6 +116,7 @@ macro UDP_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size
|
||||
;
|
||||
;-----------------------------------------------------------------
|
||||
align 4
|
||||
diff16 "UDP packetgfgfgfgfs", 0, $
|
||||
UDP_input:
|
||||
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: size=%u\n", ecx
|
||||
|
Loading…
Reference in New Issue
Block a user