37,7 → 37,7 |
|
#include <async.h> |
#include <mem.h> |
#include <rwlock.h> |
#include <fibril_sync.h> |
#include <stdio.h> |
|
#include <ipc/ipc.h> |
77,9 → 77,9 |
int netif_probe_req( int netif_phone, device_id_t device_id, int irq, int io ){ |
int result; |
|
rwlock_write_lock( & netif_globals.lock ); |
fibril_rwlock_write_lock( & netif_globals.lock ); |
result = netif_probe_message( device_id, irq, io ); |
rwlock_write_unlock( & netif_globals.lock ); |
fibril_rwlock_write_unlock( & netif_globals.lock ); |
return result; |
} |
|
86,9 → 86,9 |
int netif_send_msg( int netif_phone, device_id_t device_id, packet_t packet, services_t sender ){ |
int result; |
|
rwlock_write_lock( & netif_globals.lock ); |
fibril_rwlock_write_lock( & netif_globals.lock ); |
result = netif_send_message( device_id, packet, sender ); |
rwlock_write_unlock( & netif_globals.lock ); |
fibril_rwlock_write_unlock( & netif_globals.lock ); |
return result; |
} |
|
99,19 → 99,19 |
int result; |
int phone; |
|
rwlock_write_lock( & netif_globals.lock ); |
fibril_rwlock_write_lock( & netif_globals.lock ); |
if( ERROR_OCCURRED( find_device( device_id, & device ))){ |
rwlock_write_unlock( & netif_globals.lock ); |
fibril_rwlock_write_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
} |
result = netif_start_message( device ); |
if( result > NETIF_NULL ){ |
phone = device->nil_phone; |
rwlock_write_unlock( & netif_globals.lock ); |
fibril_rwlock_write_unlock( & netif_globals.lock ); |
nil_device_state_msg( phone, device_id, result ); |
return EOK; |
}else{ |
rwlock_write_unlock( & netif_globals.lock ); |
fibril_rwlock_write_unlock( & netif_globals.lock ); |
} |
return result; |
} |
123,19 → 123,19 |
int result; |
int phone; |
|
rwlock_write_lock( & netif_globals.lock ); |
fibril_rwlock_write_lock( & netif_globals.lock ); |
if( ERROR_OCCURRED( find_device( device_id, & device ))){ |
rwlock_write_unlock( & netif_globals.lock ); |
fibril_rwlock_write_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
} |
result = netif_stop_message( device ); |
if( result > NETIF_NULL ){ |
phone = device->nil_phone; |
rwlock_write_unlock( & netif_globals.lock ); |
fibril_rwlock_write_unlock( & netif_globals.lock ); |
nil_device_state_msg( phone, device_id, result ); |
return EOK; |
}else{ |
rwlock_write_unlock( & netif_globals.lock ); |
fibril_rwlock_write_unlock( & netif_globals.lock ); |
} |
return result; |
} |
146,12 → 146,12 |
measured_string_t translation; |
|
if( !( address && data )) return EBADMEM; |
rwlock_read_lock( & netif_globals.lock ); |
fibril_rwlock_read_lock( & netif_globals.lock ); |
if( ! ERROR_OCCURRED( netif_get_addr_message( device_id, & translation ))){ |
* address = measured_string_copy( & translation ); |
ERROR_CODE = ( * address ) ? EOK : ENOMEM; |
} |
rwlock_read_unlock( & netif_globals.lock ); |
fibril_rwlock_read_unlock( & netif_globals.lock ); |
* data = ( ** address ).value; |
return ERROR_CODE; |
} |
198,16 → 198,16 |
case IPC_M_PHONE_HUNGUP: |
return EOK; |
case NET_NETIF_PROBE_AUTO: |
rwlock_write_lock( & netif_globals.lock ); |
fibril_rwlock_write_lock( & netif_globals.lock ); |
ERROR_CODE = netif_probe_auto_message(); |
rwlock_write_unlock( & netif_globals.lock ); |
fibril_rwlock_write_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
case NET_NETIF_PROBE: |
return netif_probe_req( 0, IPC_GET_DEVICE( call ), NETIF_GET_IRQ( call ), NETIF_GET_IO( call )); |
case IPC_M_CONNECT_TO_ME: |
rwlock_write_lock( & netif_globals.lock ); |
fibril_rwlock_write_lock( & netif_globals.lock ); |
ERROR_CODE = register_message( IPC_GET_DEVICE( call ), IPC_GET_PHONE( call )); |
rwlock_write_unlock( & netif_globals.lock ); |
fibril_rwlock_write_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
case NET_NETIF_SEND: |
case NET_NIL_SEND: |
216,7 → 216,7 |
case NET_NETIF_START: |
return netif_start_req( 0, IPC_GET_DEVICE( call )); |
case NET_NETIF_STATS: |
rwlock_read_lock( & netif_globals.lock ); |
fibril_rwlock_read_lock( & netif_globals.lock ); |
if( ! ERROR_OCCURRED( ipc_data_read_receive( & callid, & length ))){ |
if( length < sizeof( device_stats_t )){ |
ERROR_CODE = EOVERFLOW; |
226,17 → 226,17 |
} |
} |
} |
rwlock_read_unlock( & netif_globals.lock ); |
fibril_rwlock_read_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
case NET_NETIF_STOP: |
return netif_stop_req( 0, IPC_GET_DEVICE( call )); |
case NET_NETIF_GET_ADDR: |
case NET_NIL_ADDR: |
rwlock_read_lock( & netif_globals.lock ); |
fibril_rwlock_read_lock( & netif_globals.lock ); |
if( ! ERROR_OCCURRED( netif_get_addr_message( IPC_GET_DEVICE( call ), & address ))){ |
ERROR_CODE = measured_strings_reply( & address, 1 ); |
} |
rwlock_read_unlock( & netif_globals.lock ); |
fibril_rwlock_read_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
} |
return netif_specific_message( callid, call, answer, answer_count ); |
249,7 → 249,7 |
netif_globals.net_phone = connect_to_service( SERVICE_NETWORKING ); |
device_map_initialize( & netif_globals.device_map ); |
ERROR_PROPAGATE( pm_init()); |
rwlock_initialize( & netif_globals.lock ); |
fibril_rwlock_initialize( & netif_globals.lock ); |
if( ERROR_OCCURRED( netif_initialize())){ |
pm_destroy(); |
return ERROR_CODE; |