2009-09-17 15:55:38 +04:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2009-10-06 00:47:27 +04:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;;
|
2009-09-17 15:55:38 +04:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;; queue.inc ;;
|
|
|
|
;; ;;
|
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2009-10-12 18:39:59 +04:00
|
|
|
$Revision$
|
2009-09-17 15:55:38 +04:00
|
|
|
|
|
|
|
struct queue
|
2009-11-06 23:45:08 +03:00
|
|
|
.size dd ? ; number of queued packets in thsi queue
|
|
|
|
.w_ptr dd ? ; current writing pointer in queue
|
|
|
|
.r_ptr dd ? ; current reading pointer
|
2009-09-17 15:55:38 +04:00
|
|
|
.data:
|
|
|
|
ends
|
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
struct eth_queue_entry
|
2009-09-17 15:55:38 +04:00
|
|
|
.owner dd ?
|
|
|
|
.data_ptr dd ?
|
|
|
|
.data_size dd ?
|
|
|
|
.size:
|
|
|
|
ends
|
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
struct tcp_in_queue_entry
|
|
|
|
.data_ptr dd ?
|
|
|
|
.data_size dd ?
|
|
|
|
.offset dd ?
|
|
|
|
.size:
|
|
|
|
ends
|
2009-09-17 15:55:38 +04:00
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
struct tcp_out_queue_entry
|
|
|
|
.data_ptr dd ?
|
|
|
|
.data_size dd ?
|
|
|
|
.ttl dd ?
|
|
|
|
.retries dd ?
|
|
|
|
.owner dd ?
|
|
|
|
.sendproc dd ?
|
2009-11-08 21:00:01 +03:00
|
|
|
.seq_num dd ?
|
2009-11-06 23:45:08 +03:00
|
|
|
.size:
|
|
|
|
ends
|
2009-09-17 15:55:38 +04:00
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
struct socket_queue_entry
|
|
|
|
.data_ptr dd ?
|
|
|
|
.data_size dd ?
|
|
|
|
.offset dd ?
|
|
|
|
.size:
|
|
|
|
ends
|
2009-09-17 15:55:38 +04:00
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
macro add_to_queue ptr, size, entry_size, failaddr {
|
2009-09-17 15:55:38 +04:00
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
cmp [ptr + queue.size], size ; Check if queue isnt full
|
|
|
|
jge failaddr
|
2009-09-17 15:55:38 +04:00
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
inc [ptr + queue.size]
|
2009-09-17 15:55:38 +04:00
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
mov edi, [ptr + queue.w_ptr] ; Current write pointer (FIFO!)
|
|
|
|
mov ecx, entry_size/4 ; Write the queue entry
|
|
|
|
rep movsd ;
|
2009-09-17 15:55:38 +04:00
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
lea ecx, [size*entry_size+ptr+queue.data]
|
|
|
|
cmp edi, ecx ; entry size
|
2009-09-17 15:55:38 +04:00
|
|
|
jl .no_wrap
|
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
sub edi, size*entry_size
|
2009-09-17 15:55:38 +04:00
|
|
|
|
|
|
|
.no_wrap:
|
2009-11-06 23:45:08 +03:00
|
|
|
mov [ptr + queue.w_ptr], edi
|
2009-09-17 15:55:38 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
macro get_from_queue ptr, size, entry_size, failaddr {
|
2009-09-17 15:55:38 +04:00
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
cmp [ptr + queue.size], 0 ; any packets queued?
|
|
|
|
je failaddr
|
2009-09-17 15:55:38 +04:00
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
dec [ptr + queue.size]
|
2009-09-17 15:55:38 +04:00
|
|
|
|
|
|
|
mov esi, [ptr + queue.r_ptr]
|
2009-11-06 23:45:08 +03:00
|
|
|
push esi
|
|
|
|
|
|
|
|
add esi, entry_size
|
|
|
|
|
|
|
|
lea ecx, [size*entry_size+ptr+queue.data]
|
|
|
|
cmp esi, ecx ; entry size
|
2009-09-17 15:55:38 +04:00
|
|
|
jl .no_wrap
|
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
sub esi, size*entry_size
|
2009-09-17 15:55:38 +04:00
|
|
|
|
|
|
|
.no_wrap:
|
|
|
|
mov dword [ptr + queue.r_ptr], esi
|
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
pop esi
|
|
|
|
|
2009-09-17 15:55:38 +04:00
|
|
|
}
|
|
|
|
|
2009-11-06 23:45:08 +03:00
|
|
|
macro init_queue queue_ptr {
|
|
|
|
|
|
|
|
mov [queue_ptr + queue.size] , 0
|
|
|
|
lea esi, [queue_ptr + queue.data]
|
|
|
|
mov [queue_ptr + queue.w_ptr], esi
|
|
|
|
mov [queue_ptr + queue.r_ptr], esi
|
|
|
|
}
|