Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 4457 → Rev 4587

/kernel/branches/kolibri-process/network/ethernet.inc
86,11 → 86,7
push ebx
mov esi, esp
 
pushf
cli
add_to_queue ETH_queue, ETH_QUEUE_SIZE, sizeof.ETH_queue_entry, .fail
popf
 
add esp, sizeof.ETH_queue_entry
 
xor edx, edx
102,10 → 98,9
ret
 
.fail:
popf
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH incoming queue is full, discarding packet!\n"
DEBUGF DEBUG_NETWORK_ERROR, "ETH incoming queue is full, discarding packet!\n"
 
add esp, sizeof.ETH_queue_entry - 8
pop ebx
call NET_packet_free
add esp, 4
 
/kernel/branches/kolibri-process/network/queue.inc
28,7 → 28,6
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
 
47,18 → 46,12
 
local .ok, .no_wrap
 
pusha
lea ecx, [ptr + queue.mutex]
call mutex_lock
popa
spin_lock_irqsave
 
cmp [ptr + queue.size], size ; Check if queue isnt full
jb .ok
 
pusha
lea ecx, [ptr + queue.mutex]
call mutex_unlock
popa
spin_unlock_irqrestore
jmp failaddr
 
.ok:
76,10 → 69,7
.no_wrap:
mov [ptr + queue.w_ptr], edi
 
pusha
lea ecx, [ptr + queue.mutex]
call mutex_unlock
popa
spin_unlock_irqrestore
 
}
 
89,18 → 79,12
 
local .ok, .no_wrap
 
pusha
lea ecx, [ptr + queue.mutex]
call mutex_lock
popa
spin_lock_irqsave
 
cmp [ptr + queue.size], 0 ; any packets queued?
ja .ok
 
pusha
lea ecx, [ptr + queue.mutex]
call mutex_unlock
popa
spin_unlock_irqrestore
jmp failaddr
 
.ok:
122,10 → 106,7
 
pop esi
 
pusha
lea ecx, [ptr + queue.mutex]
call mutex_unlock
popa
spin_unlock_irqrestore
 
}
 
136,6 → 117,4
mov [ptr + queue.w_ptr], edi
mov [ptr + queue.r_ptr], edi
 
lea ecx, [ptr + queue.mutex]
call mutex_init
}
/kernel/branches/kolibri-process/network/socket.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Part of the TCP/IP network stack for KolibriOS ;;
293,6 → 293,7
push ecx edx esi
call SOCKET_alloc
pop esi edx ecx
test eax, eax
jz .nobuffs
 
mov [esp+32], edi ; return socketnumber
697,7 → 698,7
 
test [eax + SOCKET.state], SS_BLOCKED ; Is the socket still in blocked state?
jz @f
call SOCKET_notify.unblock ; Unblock it.
call SOCKET_notify ; Unblock it.
@@:
 
cmp [eax + SOCKET.Domain], AF_INET4
1192,6 → 1193,7
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_pair\n"
 
call SOCKET_alloc
test eax, eax
jz .nomem1
mov [esp+32], edi ; application's eax
 
1204,6 → 1206,7
mov ebx, eax
 
call SOCKET_alloc
test eax, eax
jz .nomem2
mov [esp+20], edi ; application's ebx
 
1707,8 → 1710,9
 
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_block: %x\n", eax
 
push eax
 
pushf
push eax
cli
 
; Set the 'socket is blocked' flag
1724,12 → 1728,12
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_block: suspending thread: %u\n", edx
mov [eax + SOCKET.TID], edx
pop edx
popf
 
call change_task
pop eax
popf
 
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_block: continueing\n"
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_block: continuing\n"
 
ret
 
1752,70 → 1756,54
call SOCKET_check
jz .error
 
test [eax + SOCKET.state], SS_BLOCKED
jnz .unblock
 
; test [eax + SOCKET.options], SO_NONBLOCK
; jz .error
 
push eax ecx esi
 
; socket exists and is of non blocking type.
; We'll try to flag an event to the thread
 
mov eax, [eax + SOCKET.TID]
test eax, eax
jz .done
mov ecx, 1
mov esi, TASK_DATA + TASKDATA.pid
 
.next_pid:
cmp [esi], eax
je .found_pid
; Find the associated thread's TASK_DATA
push ebx ecx esi
mov ebx, [eax + SOCKET.TID]
test ebx, ebx
jz .error2
xor ecx, ecx
inc ecx
mov esi, TASK_DATA
.next:
cmp [esi + TASKDATA.pid], ebx
je .found
inc ecx
add esi, 0x20
cmp ecx, [TASK_COUNT]
jbe .next_pid
jbe .next
 
.error2:
; PID not found, TODO: close socket!
jmp .done
DEBUGF DEBUG_NETWORK_ERROR, "SOCKET_notify: error finding thread 0x%x !\n", ebx
pop esi ecx ebx
ret
 
.found_pid:
.error:
DEBUGF DEBUG_NETWORK_ERROR, "SOCKET_notify: invalid socket ptr: 0x%x !\n", eax
ret
 
.found:
test [eax + SOCKET.state], SS_BLOCKED
jnz .un_block
 
; socket and thread exists and socket is of non blocking type.
; We'll try to flag an event to the thread.
shl ecx, 8
or [ecx + SLOT_BASE + APPDATA.event_mask], EVENT_NETWORK
 
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: poking thread %u!\n", eax
jmp .done
pop esi ecx ebx
ret
 
.unblock:
push eax ecx esi
; Clear the 'socket is blocked' flag
and [eax + SOCKET.state], not SS_BLOCKED
 
; Find the thread's TASK_DATA
mov eax, [eax + SOCKET.TID]
test eax, eax
jz .error
xor ecx, ecx
inc ecx
mov esi, TASK_DATA
.next:
cmp [esi + TASKDATA.pid], eax
je .found
inc ecx
add esi, 0x20
cmp ecx, [TASK_COUNT]
jbe .next
jmp .error
.found:
.un_block:
; socket and thread exists and socket is of blocking type
; We'll try to unblock it.
and [eax + SOCKET.state], not SS_BLOCKED ; Clear the 'socket is blocked' flag
mov [esi + TASKDATA.state], 0 ; Run the thread
 
; Run the thread
mov [esi + TASKDATA.state], 0 ; Running
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n"
 
.done:
pop esi ecx eax
 
.error:
pop esi ecx ebx
ret
 
 
1830,7 → 1818,6
; IN: /
; OUT: eax = 0 on error, socket ptr otherwise
; edi = socket number
; ZF = cleared on error
;
;--------------------------------------------------------------------
align 4
1917,7 → 1904,6
@@:
 
mov [net_sockets + SOCKET.NextPtr], eax
or eax, eax ; used to clear zero flag
 
pusha
mov ecx, socket_mutex
2022,6 → 2008,7
push ebx
call SOCKET_alloc
pop ebx
test eax, eax
jz .fail
 
push eax
2101,7 → 2088,8
call mutex_unlock
popa
 
DEBUGF DEBUG_NETWORK_ERROR, "SOCKET_num_to_ptr: not found\n", eax
DEBUGF DEBUG_NETWORK_ERROR, "SOCKET_num_to_ptr: socket %u not found!\n", eax
DEBUGF DEBUG_NETWORK_ERROR, "SOCKET_num_to_ptr: caller = 0x%x\n", [esp]
ret
 
 
/kernel/branches/kolibri-process/network/tcp_input.inc
43,11 → 43,7
push ebx ecx esi edi ; mind the order
mov esi, esp
 
pushf
cli
add_to_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .fail
popf
 
add esp, sizeof.TCP_queue_entry
 
call NET_ptr_to_num4
/kernel/branches/kolibri-process/network/tcp_usreq.inc
186,7 → 186,7
mov eax, [esp+4]
mov [eax + SOCKET.errorcode], ETIMEDOUT
and [eax + SOCKET.state], not SS_ISCONNECTING
call SOCKET_notify.unblock
call SOCKET_notify
ret 4
 
.fail: