Rev 4307 | Rev 4332 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4307 | Rev 4327 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2009 Lukas Mejdrech |
2 | * Copyright (c) 2009 Lukas Mejdrech |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup dp8390 |
29 | /** @addtogroup dp8390 |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** @file |
33 | /** @file |
34 | */ |
34 | */ |
35 | 35 | ||
36 | #include <assert.h> |
36 | #include <assert.h> |
- | 37 | #include <async.h> |
|
37 | #include <ddi.h> |
38 | #include <ddi.h> |
38 | #include <errno.h> |
39 | #include <errno.h> |
39 | #include <malloc.h> |
40 | #include <malloc.h> |
40 | //#include <stdio.h> |
41 | //#include <stdio.h> |
41 | #include <ipc/ipc.h> |
42 | #include <ipc/ipc.h> |
42 | #include <ipc/services.h> |
43 | #include <ipc/services.h> |
43 | 44 | ||
44 | #include "../../err.h" |
45 | #include "../../err.h" |
45 | #include "../../messages.h" |
46 | #include "../../messages.h" |
46 | #include "../../modules.h" |
47 | #include "../../modules.h" |
47 | 48 | ||
48 | #include "../../structures/packet/packet_client.h" |
49 | #include "../../structures/packet/packet_client.h" |
49 | #include "../../structures/measured_strings.h" |
50 | #include "../../structures/measured_strings.h" |
50 | 51 | ||
51 | #include "../../include/device.h" |
52 | #include "../../include/device.h" |
52 | #include "../../include/nil_interface.h" |
53 | #include "../../include/nil_interface.h" |
53 | 54 | ||
54 | #include "../netif.h" |
55 | #include "../netif.h" |
55 | #include "../netif_module.h" |
56 | #include "../netif_module.h" |
56 | 57 | ||
57 | #include "dp8390.h" |
58 | #include "dp8390.h" |
58 | #include "dp8390_drv.h" |
59 | #include "dp8390_drv.h" |
59 | #include "dp8390_port.h" |
60 | #include "dp8390_port.h" |
60 | 61 | ||
61 | #define NAME "dp8390 network interface" |
62 | #define NAME "dp8390 network interface" |
62 | 63 | ||
63 | #define IRQ_GET_DEVICE( call ) ( device_id_t ) IPC_GET_METHOD( * call ) |
64 | #define IRQ_GET_DEVICE( call ) ( device_id_t ) IPC_GET_METHOD( * call ) |
64 | #define IPC_GET_ISR( call ) ( int ) IPC_GET_ARG2( * call ) |
65 | #define IPC_GET_ISR( call ) ( int ) IPC_GET_ARG2( * call ) |
65 | 66 | ||
66 | static irq_cmd_t dp8390_cmds[] = { |
67 | static irq_cmd_t dp8390_cmds[] = { |
67 | { .cmd = CMD_PIO_READ_8, |
68 | { .cmd = CMD_PIO_READ_8, |
68 | .addr = NULL, |
69 | .addr = NULL, |
69 | .dstarg = 2 |
70 | .dstarg = 2 |
70 | }, |
71 | }, |
71 | { |
72 | { |
72 | .cmd = CMD_PREDICATE, |
73 | .cmd = CMD_PREDICATE, |
73 | .value = 2, |
74 | .value = 1, |
74 | .srcarg = 2 |
75 | .srcarg = 2 |
75 | }, |
76 | }, |
76 | { .cmd = CMD_PIO_WRITE_8, |
77 | /* { .cmd = CMD_PIO_WRITE_8, |
77 | .addr = NULL, |
78 | .addr = NULL, |
78 | .srcarg = 2 |
79 | .value = 0 |
79 | }, |
80 | }, |
80 | { |
81 | */ { |
81 | .cmd = CMD_ACCEPT |
82 | .cmd = CMD_ACCEPT |
82 | } |
83 | } |
83 | }; |
84 | }; |
84 | 85 | ||
85 | static irq_code_t dp8390_code = { |
86 | static irq_code_t dp8390_code = { |
86 | sizeof( dp8390_cmds ) / sizeof( irq_cmd_t ), |
87 | sizeof( dp8390_cmds ) / sizeof( irq_cmd_t ), |
87 | dp8390_cmds |
88 | dp8390_cmds |
88 | }; |
89 | }; |
89 | 90 | ||
90 | netif_globals_t netif_globals; |
91 | netif_globals_t netif_globals; |
91 | 92 | ||
92 | void module_print_name( void ); |
93 | void module_print_name( void ); |
93 | 94 | ||
94 | void irq_handler( ipc_callid_t iid, ipc_call_t * call ); |
95 | void irq_handler( ipc_callid_t iid, ipc_call_t * call ); |
95 | int change_state( device_ref device, device_state_t state ); |
96 | int change_state( device_ref device, device_state_t state ); |
96 | 97 | ||
97 | int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
98 | int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
98 | return ENOTSUP; |
99 | return ENOTSUP; |
99 | } |
100 | } |
100 | 101 | ||
101 | int netif_get_device_stats( device_id_t device_id, device_stats_ref stats ){ |
102 | int netif_get_device_stats( device_id_t device_id, device_stats_ref stats ){ |
102 | ERROR_DECLARE; |
103 | ERROR_DECLARE; |
103 | 104 | ||
104 | device_ref device; |
105 | device_ref device; |
105 | eth_stat_t * de_stat; |
106 | eth_stat_t * de_stat; |
106 | 107 | ||
107 | if( ! stats ) return EBADMEM; |
108 | if( ! stats ) return EBADMEM; |
108 | ERROR_PROPAGATE( find_device( device_id, & device )); |
109 | ERROR_PROPAGATE( find_device( device_id, & device )); |
109 | de_stat = & (( dpeth_t * ) device->specific )->de_stat; |
110 | de_stat = & (( dpeth_t * ) device->specific )->de_stat; |
110 | null_device_stats( stats ); |
111 | null_device_stats( stats ); |
111 | stats->rx_errors = de_stat->ets_recvErr; |
112 | stats->rx_errors = de_stat->ets_recvErr; |
112 | stats->tx_errors = de_stat->ets_sendErr; |
113 | stats->tx_errors = de_stat->ets_sendErr; |
113 | stats->rx_crc_errors = de_stat->ets_CRCerr; |
114 | stats->rx_crc_errors = de_stat->ets_CRCerr; |
114 | stats->rx_frame_errors = de_stat->ets_frameAll; |
115 | stats->rx_frame_errors = de_stat->ets_frameAll; |
115 | stats->rx_missed_errors = de_stat->ets_missedP; |
116 | stats->rx_missed_errors = de_stat->ets_missedP; |
116 | stats->rx_packets = de_stat->ets_packetR; |
117 | stats->rx_packets = de_stat->ets_packetR; |
117 | stats->tx_packets = de_stat->ets_packetT; |
118 | stats->tx_packets = de_stat->ets_packetT; |
118 | stats->collisions = de_stat->ets_collision; |
119 | stats->collisions = de_stat->ets_collision; |
119 | stats->tx_aborted_errors = de_stat->ets_transAb; |
120 | stats->tx_aborted_errors = de_stat->ets_transAb; |
120 | stats->tx_carrier_errors = de_stat->ets_carrSense; |
121 | stats->tx_carrier_errors = de_stat->ets_carrSense; |
121 | stats->tx_heartbeat_errors = de_stat->ets_CDheartbeat; |
122 | stats->tx_heartbeat_errors = de_stat->ets_CDheartbeat; |
122 | stats->tx_window_errors = de_stat->ets_OWC; |
123 | stats->tx_window_errors = de_stat->ets_OWC; |
123 | return EOK; |
124 | return EOK; |
124 | } |
125 | } |
125 | 126 | ||
126 | void module_print_name( void ){ |
127 | void module_print_name( void ){ |
127 | printf( "%s", NAME ); |
128 | printf( "%s", NAME ); |
128 | } |
129 | } |
129 | 130 | ||
130 | int netif_get_addr_message( device_id_t device_id, measured_string_ref address ){ |
131 | int netif_get_addr_message( device_id_t device_id, measured_string_ref address ){ |
131 | ERROR_DECLARE; |
132 | ERROR_DECLARE; |
132 | 133 | ||
133 | device_ref device; |
134 | device_ref device; |
134 | 135 | ||
135 | if( ! address ) return EBADMEM; |
136 | if( ! address ) return EBADMEM; |
136 | ERROR_PROPAGATE( find_device( device_id, & device )); |
137 | ERROR_PROPAGATE( find_device( device_id, & device )); |
137 | address->value = ( char * ) ( & (( dpeth_t * ) device->specific )->de_address ); |
138 | address->value = ( char * ) ( & (( dpeth_t * ) device->specific )->de_address ); |
138 | address->length = CONVERT_SIZE( ether_addr_t, char, 1 ); |
139 | address->length = CONVERT_SIZE( ether_addr_t, char, 1 ); |
139 | return EOK; |
140 | return EOK; |
140 | } |
141 | } |
141 | 142 | ||
142 | void irq_handler( ipc_callid_t iid, ipc_call_t * call ) |
143 | void irq_handler( ipc_callid_t iid, ipc_call_t * call ) |
143 | { |
144 | { |
144 | // int irq; |
- | |
145 | device_ref device; |
145 | device_ref device; |
146 | dpeth_t * dep; |
146 | dpeth_t * dep; |
147 | packet_t received; |
147 | packet_t received; |
148 | device_id_t device_id; |
148 | device_id_t device_id; |
149 | int phone; |
149 | int phone; |
150 | 150 | ||
- | 151 | // async_serialize_start(); |
|
151 | device_id = IRQ_GET_DEVICE( call ); |
152 | device_id = IRQ_GET_DEVICE( call ); |
152 | // printf( "device %d - irq %x\n", device_id, IPC_GET_ISR( call )); |
- | |
153 | rwlock_write_lock( & netif_globals.lock ); |
153 | rwlock_write_lock( & netif_globals.lock ); |
154 | if( find_device( device_id, & device ) != EOK ){ |
154 | if( find_device( device_id, & device ) != EOK ){ |
155 | rwlock_write_unlock( & netif_globals.lock ); |
155 | rwlock_write_unlock( & netif_globals.lock ); |
- | 156 | // async_serialize_end() |
|
156 | return; |
157 | return; |
157 | } |
158 | } |
158 | dep = ( dpeth_t * ) device->specific; |
159 | dep = ( dpeth_t * ) device->specific; |
159 | // printf( "dev %d, irq %x\n\n", device->device_id, IPC_GET_ISR( call )); |
- | |
160 | if ( dep->de_mode != DEM_ENABLED){ |
160 | if ( dep->de_mode != DEM_ENABLED){ |
161 | // continue; |
- | |
162 | rwlock_write_unlock( & netif_globals.lock ); |
161 | rwlock_write_unlock( & netif_globals.lock ); |
- | 162 | // async_serialize_end() |
|
163 | return; |
163 | return; |
164 | } |
164 | } |
165 | assert( dep->de_flags & DEF_ENABLED); |
165 | assert( dep->de_flags & DEF_ENABLED); |
166 | // irq= dep.de_irq; |
- | |
167 | // assert(irq >= 0 && irq < NR_IRQ_VECTORS); |
- | |
168 | // if ( dep->de_int_pending || 1) |
- | |
169 | // { |
- | |
170 | dep->de_int_pending= 0; |
166 | dep->de_int_pending= 0; |
171 | dp_check_ints( dep ); |
167 | printf( "I%d -%d\n", device_id, IPC_GET_ISR( call )); |
172 | // do_int(dep); |
168 | /* putchar( 'I' ); |
173 | /* r= sys_irqenable(&dep->de_hook); |
169 | putchar( '0' + device_id ); |
174 | if (r != OK) |
170 | putchar( '-' ); |
175 | { |
- | |
- | 171 | putchar( '0' + IPC_GET_ISR( call ) / 100 ); |
|
- | 172 | putchar( '0' + ( IPC_GET_ISR( call ) % 100 ) / 10 ); |
|
- | 173 | putchar( '0' + IPC_GET_ISR( call ) % 10 ); |
|
176 | panic("DP8390", |
174 | putchar( '\n' ); |
177 | "unable enable interrupts", r); |
175 | */ dp_check_ints( dep, IPC_GET_ISR( call )); |
178 | } |
- | |
179 | */// } |
- | |
180 | if( dep->received_queue ){ |
176 | if( dep->received_queue ){ |
181 | received = dep->received_queue; |
177 | received = dep->received_queue; |
182 | phone = device->nil_phone; |
178 | phone = device->nil_phone; |
183 | dep->received_queue = NULL; |
179 | dep->received_queue = NULL; |
184 | rwlock_write_unlock( & netif_globals.lock ); |
180 | rwlock_write_unlock( & netif_globals.lock ); |
185 | nil_received_msg( phone, device_id, received, NULL ); |
181 | nil_received_msg( phone, device_id, received, NULL ); |
186 | }else{ |
182 | }else{ |
187 | rwlock_write_unlock( & netif_globals.lock ); |
183 | rwlock_write_unlock( & netif_globals.lock ); |
188 | } |
184 | } |
189 | ipc_answer_0( iid, EOK ); |
185 | ipc_answer_0( iid, EOK ); |
- | 186 | // async_serialize_end() |
|
190 | } |
187 | } |
191 | 188 | ||
192 | int netif_probe_auto_message( void ){ |
189 | int netif_probe_auto_message( void ){ |
193 | return ENOTSUP; |
190 | return ENOTSUP; |
194 | } |
191 | } |
195 | 192 | ||
196 | int netif_probe_message( device_id_t device_id, int irq, int io ){ |
193 | int netif_probe_message( device_id_t device_id, int irq, int io ){ |
197 | ERROR_DECLARE; |
194 | ERROR_DECLARE; |
198 | 195 | ||
199 | device_ref device; |
196 | device_ref device; |
200 | dpeth_t * dep; |
197 | dpeth_t * dep; |
201 | 198 | ||
202 | device = ( device_ref ) malloc( sizeof( device_t )); |
199 | device = ( device_ref ) malloc( sizeof( device_t )); |
203 | if( ! device ) return ENOMEM; |
200 | if( ! device ) return ENOMEM; |
204 | dep = ( dpeth_t * ) malloc( sizeof( dpeth_t )); |
201 | dep = ( dpeth_t * ) malloc( sizeof( dpeth_t )); |
205 | if( ! dep ){ |
202 | if( ! dep ){ |
206 | free( device ); |
203 | free( device ); |
207 | return ENOMEM; |
204 | return ENOMEM; |
208 | } |
205 | } |
209 | bzero( device, sizeof( device_t )); |
206 | bzero( device, sizeof( device_t )); |
210 | bzero( dep, sizeof( dpeth_t )); |
207 | bzero( dep, sizeof( dpeth_t )); |
211 | device->device_id = device_id; |
208 | device->device_id = device_id; |
212 | device->nil_phone = -1; |
209 | device->nil_phone = -1; |
213 | device->specific = ( void * ) dep; |
210 | device->specific = ( void * ) dep; |
214 | device->state = NETIF_STOPPED; |
211 | device->state = NETIF_STOPPED; |
215 | dep->de_irq = irq; |
212 | dep->de_irq = irq; |
216 | dep->de_mode = DEM_DISABLED; |
213 | dep->de_mode = DEM_DISABLED; |
217 | //TODO address? |
214 | //TODO address? |
218 | if( ERROR_OCCURRED( pio_enable(( void * ) io, DP8390_IO_SIZE, ( void ** ) & dep->de_base_port )) |
215 | if( ERROR_OCCURRED( pio_enable(( void * ) io, DP8390_IO_SIZE, ( void ** ) & dep->de_base_port )) |
219 | || ERROR_OCCURRED( do_probe( dep ))){ |
216 | || ERROR_OCCURRED( do_probe( dep ))){ |
220 | free( dep ); |
217 | free( dep ); |
221 | free( device ); |
218 | free( device ); |
222 | return ERROR_CODE; |
219 | return ERROR_CODE; |
223 | } |
220 | } |
224 | if( ERROR_OCCURRED( device_map_add( & netif_globals.device_map, device->device_id, device ))){ |
221 | if( ERROR_OCCURRED( device_map_add( & netif_globals.device_map, device->device_id, device ))){ |
225 | free( dep ); |
222 | free( dep ); |
226 | free( device ); |
223 | free( device ); |
227 | return ERROR_CODE; |
224 | return ERROR_CODE; |
228 | } |
225 | } |
229 | return EOK; |
226 | return EOK; |
230 | } |
227 | } |
231 | 228 | ||
232 | int netif_send_message( device_id_t device_id, packet_t packet, services_t sender ){ |
229 | int netif_send_message( device_id_t device_id, packet_t packet, services_t sender ){ |
233 | ERROR_DECLARE; |
230 | ERROR_DECLARE; |
234 | 231 | ||
235 | device_ref device; |
232 | device_ref device; |
236 | dpeth_t * dep; |
233 | dpeth_t * dep; |
237 | packet_t next; |
234 | packet_t next; |
238 | 235 | ||
- | 236 | ERROR_PROPAGATE( find_device( device_id, & device )); |
|
- | 237 | dep = ( dpeth_t * ) device->specific; |
|
- | 238 | // TODO remove debug dump: |
|
239 | uint8_t * data; |
239 | uint8_t * data; |
240 | data = packet_get_data( packet ); |
240 | data = packet_get_data( packet ); |
241 | printf( "Sending packet:\n\tid\t= %d\n\tlength\t= %d\n\tdata\t= %.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX\n\t\t%.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX\n", packet_get_id( packet ), packet_get_data_length( packet ), data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ], data[ 8 ], data[ 9 ], data[ 10 ], data[ 11 ], data[ 12 ], data[ 13 ], data[ 14 ], data[ 15 ], data[ 16 ], data[ 17 ], data[ 18 ], data[ 19 ], data[ 20 ], data[ 21 ], data[ 22 ], data[ 23 ], data[ 24 ], data[ 25 ], data[ 26 ], data[ 27 ], data[ 28 ], data[ 29 ], data[ 30 ], data[ 31 ], data[ 32 ], data[ 33 ], data[ 34 ], data[ 35 ], data[ 36 ], data[ 37 ], data[ 38 ], data[ 39 ], data[ 40 ], data[ 41 ], data[ 42 ], data[ 43 ], data[ 44 ], data[ 45 ], data[ 46 ], data[ 47 ], data[ 48 ], data[ 49 ], data[ 50 ], data[ 51 ], data[ 52 ], data[ 53 ], data[ 54 ], data[ 55 ], data[ 56 ], data[ 57 ], data[ 58 ], data[ 59 ] ); |
241 | printf( "Sending packet:\n\tid\t= %d\n\tlength\t= %d\n\tdata\t= %.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX\n\t\t%.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX\n", packet_get_id( packet ), packet_get_data_length( packet ), data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ], data[ 8 ], data[ 9 ], data[ 10 ], data[ 11 ], data[ 12 ], data[ 13 ], data[ 14 ], data[ 15 ], data[ 16 ], data[ 17 ], data[ 18 ], data[ 19 ], data[ 20 ], data[ 21 ], data[ 22 ], data[ 23 ], data[ 24 ], data[ 25 ], data[ 26 ], data[ 27 ], data[ 28 ], data[ 29 ], data[ 30 ], data[ 31 ], data[ 32 ], data[ 33 ], data[ 34 ], data[ 35 ], data[ 36 ], data[ 37 ], data[ 38 ], data[ 39 ], data[ 40 ], data[ 41 ], data[ 42 ], data[ 43 ], data[ 44 ], data[ 45 ], data[ 46 ], data[ 47 ], data[ 48 ], data[ 49 ], data[ 50 ], data[ 51 ], data[ 52 ], data[ 53 ], data[ 54 ], data[ 55 ], data[ 56 ], data[ 57 ], data[ 58 ], data[ 59 ] ); |
242 | 242 | ||
243 | ERROR_PROPAGATE( find_device( device_id, & device )); |
- | |
244 | dep = ( dpeth_t * ) device->specific; |
- | |
245 | // process packet queue |
243 | // process packet queue |
246 | do{ |
244 | do{ |
247 | next = pq_detach( packet ); |
245 | next = pq_detach( packet ); |
248 | if( do_pwrite( dep, packet, FALSE ) != EBUSY ){ |
246 | if( do_pwrite( dep, packet, FALSE ) != EBUSY ){ |
249 | netif_pq_release( packet_get_id( packet )); |
247 | netif_pq_release( packet_get_id( packet )); |
250 | } |
248 | } |
251 | packet = next; |
249 | packet = next; |
252 | }while( packet ); |
250 | }while( packet ); |
- | 251 | dp8390_dump( dep ); |
|
253 | return EOK; |
252 | return EOK; |
254 | } |
253 | } |
255 | 254 | ||
256 | int netif_start_message( device_ref device ){ |
255 | int netif_start_message( device_ref device ){ |
257 | ERROR_DECLARE; |
256 | ERROR_DECLARE; |
258 | 257 | ||
259 | dpeth_t * dep; |
258 | dpeth_t * dep; |
260 | 259 | ||
261 | if( device->state != NETIF_ACTIVE ){ |
260 | if( device->state != NETIF_ACTIVE ){ |
262 | dep = ( dpeth_t * ) device->specific; |
261 | dep = ( dpeth_t * ) device->specific; |
263 | dp8390_cmds[ 0 ].addr = ( void * ) ( uint32_t ) ( dep->de_dp8390_port + DP_ISR ); |
262 | dp8390_cmds[ 0 ].addr = ( void * ) ( uint32_t ) ( dep->de_dp8390_port + DP_ISR ); |
264 | dp8390_cmds[ 2 ].addr = dp8390_cmds[ 0 ].addr; |
263 | dp8390_cmds[ 2 ].addr = dp8390_cmds[ 0 ].addr; |
265 | ERROR_PROPAGATE( ipc_register_irq( dep->de_irq, device->device_id, device->device_id, & dp8390_code )); |
264 | ERROR_PROPAGATE( ipc_register_irq( dep->de_irq, device->device_id, device->device_id, & dp8390_code )); |
266 | if( ERROR_OCCURRED( do_init( dep, DL_BROAD_REQ ))){ |
265 | if( ERROR_OCCURRED( do_init( dep, DL_BROAD_REQ ))){ |
267 | ipc_unregister_irq( dep->de_irq, device->device_id ); |
266 | ipc_unregister_irq( dep->de_irq, device->device_id ); |
268 | return ERROR_CODE; |
267 | return ERROR_CODE; |
269 | } |
268 | } |
270 | return change_state( device, NETIF_ACTIVE ); |
269 | return change_state( device, NETIF_ACTIVE ); |
271 | } |
270 | } |
272 | return EOK; |
271 | return EOK; |
273 | } |
272 | } |
274 | 273 | ||
275 | int netif_stop_message( device_ref device ){ |
274 | int netif_stop_message( device_ref device ){ |
276 | dpeth_t * dep; |
275 | dpeth_t * dep; |
277 | 276 | ||
278 | if( device->state != NETIF_STOPPED ){ |
277 | if( device->state != NETIF_STOPPED ){ |
279 | dep = ( dpeth_t * ) device->specific; |
278 | dep = ( dpeth_t * ) device->specific; |
280 | do_stop( dep ); |
279 | do_stop( dep ); |
281 | ipc_unregister_irq( dep->de_irq, device->device_id ); |
280 | ipc_unregister_irq( dep->de_irq, device->device_id ); |
282 | return change_state( device, NETIF_STOPPED ); |
281 | return change_state( device, NETIF_STOPPED ); |
283 | } |
282 | } |
284 | return EOK; |
283 | return EOK; |
285 | } |
284 | } |
286 | 285 | ||
287 | int change_state( device_ref device, device_state_t state ){ |
286 | int change_state( device_ref device, device_state_t state ){ |
288 | device->state = state; |
287 | device->state = state; |
289 | printf( "State changed to %s\n", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" ); |
288 | printf( "State changed to %s\n", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" ); |
290 | return state; |
289 | return state; |
291 | } |
290 | } |
292 | 291 | ||
293 | int netif_initialize( void ){ |
292 | int netif_initialize( void ){ |
294 | ipcarg_t phonehash; |
293 | ipcarg_t phonehash; |
295 | 294 | ||
296 | async_set_interrupt_received( irq_handler ); |
295 | async_set_interrupt_received( irq_handler ); |
297 | 296 | ||
298 | return REGISTER_ME( SERVICE_DP8390, & phonehash ); |
297 | return REGISTER_ME( SERVICE_DP8390, & phonehash ); |
299 | } |
298 | } |
300 | 299 | ||
301 | /** @} |
300 | /** @} |
302 | */ |
301 | */ |
303 | 302 |