Subversion Repositories Kolibri OS

Rev

Rev 1519 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1519 Rev 1529
Line 12... Line 12...
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
13
;;             Version 2, June 1991                                ;;
13
;;             Version 2, June 1991                                ;;
14
;;                                                                 ;;
14
;;                                                                 ;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 16... Line 16...
16
 
16
 
Line 17... Line 17...
17
$Revision: 1519 $
17
$Revision: 1529 $
18
 
18
 
19
struct	ETH_FRAME
19
struct	ETH_FRAME
20
	.DstMAC 	dp  ?  ; destination MAC-address
20
	.DstMAC 	dp  ?  ; destination MAC-address
Line 54... Line 54...
54
;
54
;
55
; ETH_init
55
; ETH_init
56
;
56
;
57
;  This function resets all ethernet variables
57
;  This function resets all ethernet variables
58
;
58
;
59
;  IN:  /
-
 
60
;  OUT: /
-
 
61
;
-
 
62
;-----------------------------------------------------------------
59
;-----------------------------------------------------------------
63
align 4
-
 
64
ETH_init:
60
macro	ETH_init {
Line 65... Line 61...
65
 
61
 
Line 66... Line 62...
66
	mov	[ETH_RUNNING], 0
62
	mov	[ETH_RUNNING], 0
Line 67... Line 63...
67
 
63
 
68
	ret
64
}
69
 
65
 
70
 
66
 
71
;-----------------------------------------------------------------
67
;-----------------------------------------------------------------
72
;
68
;
73
; ETH_Receiver:
69
; ETH_input
74
;
70
;
75
;  This function is called by ethernet drivers,
71
;  This function is called by ethernet drivers,
76
;  It pushes the received ethernet packets onto the eth_in_queue
72
;  It pushes the received ethernet packets onto the eth_in_queue
77
;
73
;
78
;  IN:   [esp]  = Pointer to buffer
74
;  IN:   [esp]  = Pointer to buffer
79
;       [esp-4] = size of buffer
75
;       [esp+4] = size of buffer
80
;         ebx   = pointer to eth_device
76
;         ebx   = pointer to eth_device
81
;  OUT: /
77
;  OUT: /
82
;
78
;
83
;-----------------------------------------------------------------
79
;-----------------------------------------------------------------
Line 84... Line 80...
84
align 4
80
align 4
85
ETH_receiver:
81
ETH_input:
86
	mov	eax, [esp]
82
	mov	eax, [esp]
87
	mov	ecx, [esp+4]
83
	mov	ecx, [esp+4]
Line 88... Line 84...
88
 
84
 
89
	DEBUGF	1,"ETH_Handler - size: %u\n", ecx
85
	DEBUGF	1,"ETH_input - size: %u\n", ecx
Line 90... Line 86...
90
	cmp	ecx, 60    ; check packet length
86
	cmp	ecx, 60    ; check packet length
91
	jl	.dump
87
	jl	.dump
Line 92... Line 88...
92
	sub	ecx, ETH_FRAME.Data
88
	sub	ecx, ETH_FRAME.Data
93
 
89
 
Line 94... Line 90...
94
	lea	edx, [eax + ETH_FRAME.Data]
90
	lea	edx, [eax + ETH_FRAME.Data]
95
	mov	ax , [eax + ETH_FRAME.Type]
91
	mov	ax , [eax + ETH_FRAME.Type]
Line 96... Line 92...
96
 
92
 
Line 97... Line 93...
97
	cmp	ax, ETHER_IPv4
93
	cmp	ax, ETHER_IPv4
98
	je	IPv4_handler
94
	je	IPv4_input
99
 
95
 
100
	cmp	ax, ETHER_ARP
96
	cmp	ax, ETHER_ARP
101
	je	ARP_handler
97
	je	ARP_input
Line 102... Line 98...
102
 
98
 
103
;        cmp     ax, ETHER_PPP_DISCOVERY
99
;        cmp     ax, ETHER_PPP_DISCOVERY
104
;        je      PPPOE_discovery
100
;        je      PPPOE_discovery
105
 
101
 
106
	DEBUGF	2,"Unknown ethernet packet type %x\n", ax
102
	DEBUGF	2,"Unknown ethernet packet type %x\n", ax
107
 
103
 
108
  .dump:
104
  .dump:
109
	DEBUGF	2,"ETH_Handler - dumping\n"
105
	DEBUGF	2,"ETH_input - dumping\n"
110
	call	kernel_free
106
	call	kernel_free
111
	add	esp, 4
107
	add	esp, 4
112
	ret
108
	ret
113
 
109
 
114
;-----------------------------------------------------------------
110
;-----------------------------------------------------------------
115
;
111
;
116
; ETH_create_packet
112
; ETH_output
117
;
113
;
118
; IN: eax = pointer to source mac
114
; IN: eax = pointer to source mac
119
;     ebx = pointer to destination mac
115
;     ebx = device ptr
120
;     ecx = packet size
116
;     ecx = packet size
Line 121... Line 117...
121
;     edx = device number
117
;     edx = pointer to destination mac
Line 122... Line -...
122
;      di = protocol
-
 
123
;
-
 
124
; OUT: edi = 0 on error, pointer to buffer otherwise
118
;      di = protocol
125
;      eax = buffer start
-
 
126
;      ebx = to device structure
119
;
Line -... Line 120...
-
 
120
; OUT: edi = 0 on error, pointer to buffer otherwise
127
;      ecx = unchanged (packet size of embedded data)
121
;      eax = buffer start
128
;      edx = size of complete buffer
-
 
129
;
122
;      ebx = to device structure
-
 
123
;      ecx = unchanged (packet size of embedded data)
130
;-----------------------------------------------------------------
124
;      edx = size of complete buffer
-
 
125
;
131
align 4
126
;-----------------------------------------------------------------
132
ETH_create_packet:
127
align 4
-
 
128
ETH_output:
-
 
129
 
133
 
130
	DEBUGF	1,"ETH_output: size=%u device:%x\n", ecx, ebx
134
	DEBUGF	1,"Creating Ethernet Packet (size=%u): \n", ecx
-
 
135
 
-
 
Line 136... Line 131...
136
	push	esi
131
 
137
	mov	esi, [NET_DRV_LIST]	   ;;; TODO: FIXME
-
 
Line 138... Line 132...
138
	cmp	ecx, [esi + NET_DEVICE.mtu]
132
	cmp	ecx, [ebx + NET_DEVICE.mtu]
139
	pop	esi
133
	jg	.exit
140
	jg	.exit
134
 
141
 
135
	push	ecx			; << 1
142
	push	ecx di eax ebx edx
136
	push	di eax edx		; << 2
143
 
137
	add	ecx, ETH_FRAME.Data
144
	add	ecx, ETH_FRAME.Data
138
 
145
	push	ecx
139
	push	ecx			; << 3
Line 146... Line 140...
146
	push	ecx
140
 
147
	call	kernel_alloc
141
	push	ecx			; << 4
148
	mov	edi, eax
-
 
Line 149... Line 142...
149
	test	edi, edi
142
	call	kernel_alloc		; >> 4
150
	jz	.pop_exit
-
 
Line 151... Line 143...
151
 
143
	test	eax, eax
152
	pop	ecx
144
	jz	.out_of_ram
153
	pop	edx
145
	mov	edi, eax
154
 
146
 
Line -... Line 147...
-
 
147
	pop	ecx			; >> 3
155
	pop	esi
148
 
156
	movsd
149
	pop	esi			; >> 2
Line 157... Line 150...
157
	movsw
150
	movsd
158
	pop	esi
151
	movsw
159
	movsd
152
	pop	esi			; >> 2
160
	movsw
153
	movsd
161
	pop	ax
154
	movsw
Line 162... Line 155...
162
	stosw
155
	pop	ax			; >> 2
163
 
156
	stosw
164
	lea	eax, [edi - ETH_FRAME.Data]  ; Set eax to buffer start
157
 
-
 
158
	lea	eax, [edi - ETH_FRAME.Data]  ; Set eax to buffer start
165
	mov	edx, ecx		     ; Set ebx to complete buffer size
159
	mov	edx, ecx		     ; Set edx to complete buffer size
Line 166... Line 160...
166
	pop	ecx
160