/branches/network/uspace/srv/net/netif/device.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
Deleted: svn:mergeinfo |
/branches/network/uspace/srv/net/netif/netif.c |
---|
49,16 → 49,13 |
#include "../structures/packet/packet_client.h" |
#include "../structures/measured_strings.h" |
#include "device.h" |
#include "../include/device.h" |
#include "../include/netif_messages.h" |
#include "netif.h" |
#include "netif_interface.h" |
#include "netif_wrappers.h" |
#define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call ) |
#define IPC_GET_PACKET( call ) ( packet_id_t ) IPC_GET_ARG2( * call ) |
#define IPC_GET_IRQ( call ) ( int ) IPC_GET_ARG2( * call ) |
#define IPC_GET_IO( call ) ( int ) IPC_GET_ARG3( * call ) |
#define IPC_GET_PHONE( call ) ( int ) IPC_GET_ARG5( * call ) |
extern netif_globals_t netif_globals; |
DEVICE_MAP_IMPLEMENT( device_map, device_t ) |
67,6 → 64,57 |
int netif_start_module( async_client_conn_t client_connection ); |
int register_message( device_id_t device_id, int phone ); |
int netif_probe_wrapper( device_id_t device_id, int irq, int io ){ |
int result; |
rwlock_write_lock( & netif_globals.lock ); |
result = netif_probe_message( device_id, irq, io ); |
rwlock_write_unlock( & netif_globals.lock ); |
return result; |
} |
int netif_send_wrapper( device_id_t device_id, packet_t packet ){ |
int result; |
rwlock_write_lock( & netif_globals.lock ); |
result = netif_send_message( device_id, packet ); |
rwlock_write_unlock( & netif_globals.lock ); |
return result; |
} |
int netif_start_wrapper( device_id_t device_id ){ |
int result; |
rwlock_write_lock( & netif_globals.lock ); |
result = netif_start_message( device_id ); |
rwlock_write_unlock( & netif_globals.lock ); |
return result; |
} |
int netif_stop_wrapper( device_id_t device_id ){ |
int result; |
rwlock_write_lock( & netif_globals.lock ); |
result = netif_stop_message( device_id ); |
rwlock_write_unlock( & netif_globals.lock ); |
return result; |
} |
int netif_get_addr_wrapper( device_id_t device_id, measured_string_ref * address ){ |
ERROR_DECLARE; |
measured_string_t translation; |
if( ! address ) return EBADMEM; |
rwlock_read_lock( & netif_globals.lock ); |
if( ! ERROR_OCCURRED( netif_get_addr_message( device_id, & translation ))){ |
* address = measured_string_create_bulk( translation.value, translation.length ); |
ERROR_CODE = ( * address ) ? EOK : ENOMEM; |
} |
rwlock_read_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
} |
int find_device( device_id_t device_id, device_ref * device ){ |
if( ! device ) return EBADMEM; |
* device = device_map_find( & netif_globals.device_map, device_id ); |
105,31 → 153,21 |
return EOK; |
case NET_NETIF_PROBE_AUTO: |
rwlock_write_lock( & netif_globals.lock ); |
ERROR_CODE = probe_auto_message(); |
ERROR_CODE = netif_probe_auto_message(); |
rwlock_write_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
case NET_NETIF_PROBE: |
rwlock_write_lock( & netif_globals.lock ); |
ERROR_CODE = probe_message( IPC_GET_DEVICE( call ), IPC_GET_IRQ( call ), IPC_GET_IO( call )); |
rwlock_write_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
return netif_probe_wrapper( NETIF_GET_DEVICE( call ), NETIF_GET_IRQ( call ), NETIF_GET_IO( call )); |
case IPC_M_CONNECT_TO_ME: |
rwlock_write_lock( & netif_globals.lock ); |
ERROR_CODE = register_message( IPC_GET_DEVICE( call ), IPC_GET_PHONE( call )); |
ERROR_CODE = register_message( NETIF_GET_DEVICE( call ), IPC_GET_PHONE( call )); |
rwlock_write_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
case NET_NETIF_SEND: |
rwlock_write_lock( & netif_globals.lock ); |
if( ! ERROR_OCCURRED( packet_translate( netif_globals.networking_phone, & packet, IPC_GET_PACKET( call )))){ |
ERROR_CODE = send_message( IPC_GET_DEVICE( call ), packet ); |
} |
rwlock_write_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
ERROR_PROPAGATE( packet_translate( netif_globals.networking_phone, & packet, NETIF_GET_PACKET( call ))); |
return netif_send_wrapper( NETIF_GET_DEVICE( call ), packet ); |
case NET_NETIF_START: |
rwlock_write_lock( & netif_globals.lock ); |
ERROR_CODE = start_message( IPC_GET_DEVICE( call )); |
rwlock_write_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
return netif_start_wrapper( NETIF_GET_DEVICE( call )); |
case NET_NETIF_STATS: |
rwlock_read_lock( & netif_globals.lock ); |
if( ! ERROR_OCCURRED( ipc_data_read_receive( & callid, & length ))){ |
136,7 → 174,7 |
if( length < sizeof( device_stats_t )){ |
ERROR_CODE = EOVERFLOW; |
}else{ |
if( ! ERROR_OCCURRED( get_device_stats( IPC_GET_DEVICE( call ), & stats ))){ |
if( ! ERROR_OCCURRED( netif_get_device_stats( NETIF_GET_DEVICE( call ), & stats ))){ |
ERROR_CODE = ipc_data_read_finalize( callid, & stats, sizeof( device_stats_t )); |
} |
} |
144,19 → 182,16 |
rwlock_read_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
case NET_NETIF_STOP: |
rwlock_write_lock( & netif_globals.lock ); |
ERROR_CODE = stop_message( IPC_GET_DEVICE( call )); |
rwlock_write_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
return netif_stop_wrapper( NETIF_GET_DEVICE( call )); |
case NET_NETIF_GET_ADDR: |
rwlock_read_lock( & netif_globals.lock ); |
if( ! ERROR_OCCURRED( get_addr_message( IPC_GET_DEVICE( call ), & address ))){ |
if( ! ERROR_OCCURRED( netif_get_addr_message( NETIF_GET_DEVICE( call ), & address ))){ |
ERROR_CODE = measured_strings_reply( & address, 1 ); |
} |
rwlock_read_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
} |
return specific_message( callid, call, answer, answer_count ); |
return netif_specific_message( callid, call, answer, answer_count ); |
} |
int netif_start_module( async_client_conn_t client_connection ){ |
167,7 → 202,7 |
device_map_initialize( & netif_globals.device_map ); |
ERROR_PROPAGATE( pm_init()); |
rwlock_initialize( & netif_globals.lock ); |
if( ERROR_OCCURRED( initialize())){ |
if( ERROR_OCCURRED( netif_initialize())){ |
pm_destroy(); |
return ERROR_CODE; |
} |
/branches/network/uspace/srv/net/netif/dp8390/dp8390.c |
---|
1524,7 → 1524,7 |
static void insb(port_t port, void *buf, size_t size) |
{ |
int i; |
size_t i; |
for( i = 0; i < size; ++ i ){ |
*(( uint8_t * )( buf + i )) = inb( port ); |
1533,7 → 1533,7 |
static void insw(port_t port, void *buf, size_t size) |
{ |
int i; |
size_t i; |
for( i = 0; i < size; i += 2 ){ |
*(( uint16_t * )( buf + i )) = inw( port ); |
1542,7 → 1542,7 |
static void outsb(port_t port, void *buf, size_t size) |
{ |
int i; |
size_t i; |
for( i = 0; i < size; ++ i ){ |
outb( port, *(( uint8_t * )( buf + i ))); |
1551,7 → 1551,7 |
static void outsw(port_t port, void *buf, size_t size) |
{ |
int i; |
size_t i; |
for( i = 0; i < size; i += 2 ){ |
outw( port, *(( uint16_t * )( buf + i ))); |
/branches/network/uspace/srv/net/netif/dp8390/Makefile |
---|
46,4 → 46,6 |
$(STRUCTURES)packet/packet_client.c \ |
$(STRUCTURES)packet/packet.c |
NET_DEFS += -D NETIF_BUNDLE=1 |
include $(NET_BASE)Makefile.module |
/branches/network/uspace/srv/net/netif/dp8390/dp8390_module.c |
---|
48,7 → 48,8 |
#include "../../structures/packet/packet_client.h" |
#include "../../structures/measured_strings.h" |
#include "../device.h" |
#include "../../include/device.h" |
#include "../netif.h" |
#include "../netif_interface.h" |
93,11 → 94,11 |
void irq_handler( ipc_callid_t iid, ipc_call_t * call ); |
void change_state( device_ref device, device_state_t state ); |
int specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
return ENOTSUP; |
} |
int get_device_stats( device_id_t device_id, device_stats_ref stats ){ |
int netif_get_device_stats( device_id_t device_id, device_stats_ref stats ){ |
ERROR_DECLARE; |
device_ref device; |
126,7 → 127,7 |
printf( "%s", NAME ); |
} |
int get_addr_message( device_id_t device_id, measured_string_ref address ){ |
int netif_get_addr_message( device_id_t device_id, measured_string_ref address ){ |
ERROR_DECLARE; |
device_ref device; |
166,13 → 167,14 |
"unable enable interrupts", r); |
} |
*/// } |
ipc_answer_0( iid, EOK ); |
} |
int probe_auto_message( void ){ |
int netif_probe_auto_message( void ){ |
return ENOTSUP; |
} |
int probe_message( device_id_t device_id, int irq, int io ){ |
int netif_probe_message( device_id_t device_id, int irq, int io ){ |
ERROR_DECLARE; |
device_ref device; |
210,7 → 212,7 |
return EOK; |
} |
int send_message( device_id_t device_id, packet_t packet ){ |
int netif_send_message( device_id_t device_id, packet_t packet ){ |
ERROR_DECLARE; |
device_ref device; |
217,6 → 219,10 |
dpeth_t * dep; |
packet_t next; |
uint8_t * data; |
data = packet_get_data( packet ); |
printf( "\nSending 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", 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 ] ); |
ERROR_PROPAGATE( find_device( device_id, & device )); |
dep = ( dpeth_t * ) device->specific; |
// process packet queue |
230,7 → 236,7 |
return EOK; |
} |
int start_message( device_id_t device_id ){ |
int netif_start_message( device_id_t device_id ){ |
ERROR_DECLARE; |
device_ref device; |
251,7 → 257,7 |
return EOK; |
} |
int stop_message( device_id_t device_id ){ |
int netif_stop_message( device_id_t device_id ){ |
ERROR_DECLARE; |
device_ref device; |
273,7 → 279,7 |
printf( "\nState changed to %s", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" ); |
} |
int initialize( void ){ |
int netif_initialize( void ){ |
ipcarg_t phonehash; |
async_set_interrupt_received( irq_handler ); |
/branches/network/uspace/srv/net/netif/lo/lo.c |
---|
47,6 → 47,8 |
#include "../../structures/measured_strings.h" |
#include "../../structures/packet/packet_client.h" |
#include "../../include/device.h" |
#include "../netif.h" |
#include "../netif_interface.h" |
63,21 → 65,23 |
int mtu; |
} lo_globals; |
int change_state_message( device_id_t device_id, device_state_t state ); |
int create( device_id_t device_id, device_ref * device ); |
static int change_state_message( device_id_t device_id, device_state_t state ); |
static int create( device_id_t device_id, device_ref * device ); |
void netif_print_name( void ); |
int specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
//TODO nil send message |
return ENOTSUP; |
} |
int get_addr_message( device_id_t device_id, measured_string_ref address ){ |
int netif_get_addr_message( device_id_t device_id, measured_string_ref address ){ |
if( ! address ) return EBADMEM; |
address->value = DEFAULT_ADDR; |
address->length = DEFAULT_ADDR_LEN; |
return EOK; |
} |
int get_device_stats( device_id_t device_id, device_stats_ref stats ){ |
int netif_get_device_stats( device_id_t device_id, device_stats_ref stats ){ |
ERROR_DECLARE; |
device_ref device; |
88,7 → 92,7 |
return EOK; |
} |
int change_state_message( device_id_t device_id, device_state_t state ){ |
static int change_state_message( device_id_t device_id, device_state_t state ){ |
ERROR_DECLARE; |
device_ref device; |
102,7 → 106,7 |
return EOK; |
} |
int create( device_id_t device_id, device_ref * device ){ |
static int create( device_id_t device_id, device_ref * device ){ |
int index; |
if( device_map_count( & netif_globals.device_map ) > 0 ){ |
130,7 → 134,7 |
return EOK; |
} |
int initialize( void ){ |
int netif_initialize( void ){ |
ipcarg_t phonehash; |
return REGISTER_ME( SERVICE_LO, & phonehash ); |
140,7 → 144,7 |
printf( "%s", NAME ); |
} |
int probe_auto_message( void ){ |
int netif_probe_auto_message( void ){ |
/* ERROR_DECLARE; |
device_ref device; |
150,7 → 154,7 |
*/ return ENOTSUP; |
} |
int probe_message( device_id_t device_id, int irq, int io ){ |
int netif_probe_message( device_id_t device_id, int irq, int io ){ |
ERROR_DECLARE; |
device_ref device; |
194,7 → 198,7 |
return EOK; |
} |
int send_message( device_id_t device_id, packet_t packet ){ |
int netif_send_message( device_id_t device_id, packet_t packet ){ |
ERROR_DECLARE; |
device_ref device; |
216,11 → 220,11 |
return EOK; |
} |
int start_message( device_id_t device_id ){ |
int netif_start_message( device_id_t device_id ){ |
return change_state_message( device_id, NETIF_ACTIVE ); |
} |
int stop_message( device_id_t device_id ){ |
int netif_stop_message( device_id_t device_id ){ |
return change_state_message( device_id, NETIF_STOPPED ); |
} |
/branches/network/uspace/srv/net/netif/lo/Makefile |
---|
44,4 → 44,6 |
$(STRUCTURES)packet/packet_client.c \ |
$(STRUCTURES)packet/packet.c |
NET_DEFS += -D NETIF_BUNDLE=1 |
include $(NET_BASE)Makefile.module |
/branches/network/uspace/srv/net/netif/netif.h |
---|
39,7 → 39,7 |
#include <rwlock.h> |
#include "device.h" |
#include "../include/device.h" |
/** Sends the notification message to the registered network interface layer module. |
* Wrapper of the async_msg_3(). |
/branches/network/uspace/srv/net/netif/netif_interface.h |
---|
38,17 → 38,17 |
#include "../structures/measured_strings.h" |
#include "../structures/packet/packet.h" |
#include "device.h" |
#include "../include/device.h" |
int initialize( void ); |
int probe_auto_message( void ); |
int probe_message( device_id_t device_id, int irq, int io ); |
int send_message( device_id_t device_id, packet_t packet ); |
int start_message( device_id_t device_id ); |
int stop_message( device_id_t device_id ); |
int get_addr_message( device_id_t device_id, measured_string_ref address ); |
int specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ); |
int get_device_stats( device_id_t device_id, device_stats_ref stats ); |
int netif_initialize( void ); |
int netif_probe_auto_message( void ); |
int netif_probe_message( device_id_t device_id, int irq, int io ); |
int netif_send_message( device_id_t device_id, packet_t packet ); |
int netif_start_message( device_id_t device_id ); |
int netif_stop_message( device_id_t device_id ); |
int netif_get_addr_message( device_id_t device_id, measured_string_ref address ); |
int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ); |
int netif_get_device_stats( device_id_t device_id, device_stats_ref stats ); |
#endif |
/branches/network/uspace/srv/net/netif/netif_wrappers.h |
---|
0,0 → 1,52 |
/* |
* Copyright (c) 2009 Lukas Mejdrech |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup netif |
* @{ |
*/ |
#ifndef __NET_NETIF_WRAPPERS_H__ |
#define __NET_NETIF_WRAPPERS_H__ |
#include <ipc/ipc.h> |
#include "../structures/measured_strings.h" |
#include "../structures/packet/packet.h" |
#include "../include/device.h" |
int netif_probe_wrapper( device_id_t device_id, int irq, int io ); |
int netif_send_wrapper( device_id_t device_id, packet_t packet ); |
int netif_start_wrapper( device_id_t device_id ); |
int netif_stop_wrapper( device_id_t device_id ); |
int netif_get_addr_wrapper( device_id_t device_id, measured_string_ref * address ); |
#endif |
/** @} |
*/ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |