Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4307 → Rev 4306

/branches/network/uspace/srv/net/structures/measured_strings.h
38,8 → 38,6
#ifndef __MEASURED_STRINGS_H__
#define __MEASURED_STRINGS_H__
 
#include <sys/types.h>
 
/** Type definition of the character string with measured length.
* @see measured_string
*/
/branches/network/uspace/srv/net/structures/packet/packet_remote.c
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/structures/packet/packet_messages.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/structures/packet/packet_client.c
50,6 → 50,18
#include "packet_header.h"
#include "packet_client.h"
 
/** Obtains the packet from the packet server as the shared memory block.
* Creates the local packet mapping as well.
* @param phone The packet server module phone. Input parameter.
* @param packet The packet reference pointer to store the received packet reference. Output parameter.
* @param packet_id The packet identifier. Input parameter.
* @param size The packet total size in bytes. Input parameter.
* @returns EOK on success.
* \todo ipc_share_in_start() error?
* @returns Other error codes as defined for the pm_add() function.
*/
int packet_return( int phone, packet_ref packet, packet_id_t packet_id, size_t size );
 
int packet_copy_data( packet_t packet, const void * data, size_t length ){
if( ! packet_is_valid( packet )) return EINVAL;
if( packet->data_start + length >= packet->length ) return ENOMEM;
123,5 → 135,68
return EOK;
}
 
int packet_translate( int phone, packet_ref packet, packet_id_t packet_id ){
ERROR_DECLARE;
 
unsigned int size;
 
if( ! packet ) return EINVAL;
* packet = pm_find( packet_id );
if( * packet ) return EOK;
ERROR_PROPAGATE( async_req_1_1( phone, NET_PACKET_GET_SIZE, packet_id, & size ));
return packet_return( phone, packet, packet_id, size );
}
 
int packet_return( int phone, packet_ref packet, packet_id_t packet_id, size_t size ){
ERROR_DECLARE;
 
aid_t message;
ipc_call_t answer;
ipcarg_t result;
 
message = async_send_1( phone, NET_PACKET_GET, packet_id, & answer );
* packet = ( packet_t ) as_get_mappable_page( size );
if( ERROR_OCCURRED( ipc_share_in_start_0_0( phone, * packet, size ))
|| ERROR_OCCURRED( pm_add( * packet ))){
munmap( * packet, size );
async_wait_for( message, NULL );
return ERROR_CODE;
}
async_wait_for( message, & result );
return result;
}
 
packet_t packet_get_4( int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix ){
ERROR_DECLARE;
 
packet_id_t packet_id;
unsigned int size;
packet_t packet;
 
if( ERROR_OCCURRED( async_req_4_2( phone, NET_PACKET_CREATE_4, max_content, addr_len, max_prefix, max_suffix, ( ipcarg_t * ) & packet_id, & size ))
|| ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
return NULL;
}
return packet;
}
 
packet_t packet_get_1( int phone, size_t content ){
ERROR_DECLARE;
 
packet_id_t packet_id;
unsigned int size;
packet_t packet;
 
if( ERROR_OCCURRED( async_req_1_2( phone, NET_PACKET_CREATE_1, content, ( ipcarg_t * ) & packet_id, & size ))
|| ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
return NULL;
}
return packet;
}
 
void pq_release( int phone, packet_id_t packet_id ){
async_msg_1( phone, NET_PACKET_RELEASE, packet_id );
}
 
/** @}
*/
/branches/network/uspace/srv/net/structures/packet/packet_server.c
48,13 → 48,9
#include "../../messages.h"
 
#include "packet.h"
#include "packet_client.h"
#include "packet_header.h"
#include "packet_messages.h"
#include "packet_server.h"
 
#define FREE_QUEUES_COUNT 7
 
/** The default address length reserved for new packets.
*/
#define DEFAULT_ADDR_LEN 32
67,6 → 63,28
*/
#define DEFAULT_SUFFIX 0
 
/** Returns the packet identifier message parameter.
*/
#define IPC_GET_ID( call ) ( packet_id_t ) IPC_GET_ARG1( * call )
 
/** Returns the maximal content length message parameter.
*/
#define IPC_GET_CONTENT( call ) ( size_t ) IPC_GET_ARG1( * call )
 
/** Returns the maximal address length message parameter.
*/
#define IPC_GET_ADDR_LEN( call ) ( size_t ) IPC_GET_ARG2( * call )
 
/** Returns the maximal prefix length message parameter.
*/
#define IPC_GET_PREFIX( call ) ( size_t ) IPC_GET_ARG3( * call )
 
/** Returns the maximal suffix length message parameter.
*/
#define IPC_GET_SUFFIX( call ) ( size_t ) IPC_GET_ARG4( * call )
 
#define FREE_QUEUES_COUNT 7
 
/** Packet server global data.
*/
static struct{
91,6 → 109,12
0
};
 
/** Releases the packet and returns it to the appropriate free packet queue.
* Should be used only when the global data are locked.
* @param packet The packet to be released. Input parameter.
*/
void packet_release( packet_t packet );
 
/** Returns the packet of dimensions at least as given.
* Tries to reuse free packets first.
* Creates a&nbsp;new packet aligned to the memory page size if none available.
102,18 → 126,8
* @returns The packet of dimensions at least as given.
* @returns NULL if there is not enough memory left.
*/
packet_t packet_get( size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix );
packet_t packet_get( size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix );
 
/** \todo
*/
int packet_release_wrapper( packet_id_t packet_id );
 
/** Releases the packet and returns it to the appropriate free packet queue.
* Should be used only when the global data are locked.
* @param packet The packet to be released. Input parameter.
*/
void packet_release( packet_t packet );
 
/** Creates a&nbsp;new packet of dimensions at least as given.
* Should be used only when the global data are locked.
* @param length The total length of the packet, including the header, the addresses and the data of the packet. Input parameter.
145,24 → 159,6
*/
int packet_reply( const packet_t packet );
 
int packet_translate( int phone, packet_ref packet, packet_id_t packet_id ){
if( ! packet ) return EINVAL;
* packet = pm_find( packet_id );
return ( * packet ) ? EOK : ENOENT;
}
 
packet_t packet_get_4( int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix ){
return packet_get( addr_len, max_prefix, max_content, max_suffix );
}
 
packet_t packet_get_1( int phone, size_t content ){
return packet_get( DEFAULT_ADDR_LEN, DEFAULT_PREFIX, content, DEFAULT_SUFFIX );
}
 
void pq_release( int phone, packet_id_t packet_id ){
( void ) packet_release_wrapper( packet_id );
}
 
int packet_server_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
packet_t packet;
 
195,22 → 191,16
IPC_SET_ARG1( * answer, packet->length );
return EOK;
case NET_PACKET_RELEASE:
return packet_release_wrapper( IPC_GET_ID( call ));
packet = pm_find( IPC_GET_ID( call ));
if( ! packet_is_valid( packet )) return ENOENT;
futex_down( & ps_globals.lock );
pq_destroy( packet, packet_release );
futex_up( & ps_globals.lock );
return EOK;
}
return ENOTSUP;
}
 
int packet_release_wrapper( packet_id_t packet_id ){
packet_t packet;
 
packet = pm_find( packet_id );
if( ! packet_is_valid( packet )) return ENOENT;
futex_down( & ps_globals.lock );
pq_destroy( packet, packet_release );
futex_up( & ps_globals.lock );
return EOK;
}
 
void packet_release( packet_t packet ){
int index;
 
/branches/network/uspace/srv/net/structures/packet/packet_header.h
37,8 → 37,6
#ifndef __NET_PACKET_HEADER_H__
#define __NET_PACKET_HEADER_H__
 
#include "../../messages.h"
 
#include "packet.h"
 
/** Packet integrity check magic value.
/branches/network/uspace/srv/net/structures/module_map.c
26,7 → 26,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
/** @addtogroup netif
* @{
*/
 
48,7 → 48,7
 
GENERIC_CHAR_MAP_IMPLEMENT( modules, module_t )
 
int add_module( module_ref * module, modules_ref modules, char * name, char * filename, services_t service, task_id_t task_id, connect_module_t connect_module ){
int add_module( module_ref * module, modules_ref modules, char * name, char * filename, services_t service, task_id_t task_id ){
ERROR_DECLARE;
 
module_ref tmp_module;
61,7 → 61,6
tmp_module->name = name;
tmp_module->filename = filename;
tmp_module->service = service;
tmp_module->connect_module = connect_module;
if( ERROR_OCCURRED( modules_add( modules, tmp_module->name, 0, tmp_module ))){
free( tmp_module );
return ERROR_CODE;
81,7 → 80,7
if( ! module->task_id ) return NULL;
}
if( ! module->phone ){
module->phone = module->connect_module( module->service );
module->phone = connect_to_service( module->service );
}
return module;
}
/branches/network/uspace/srv/net/structures/module_map.h
26,7 → 26,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
/** @addtogroup netif
* @{
*/
 
41,8 → 41,6
 
#include <ipc/services.h>
 
#include "../modules.h"
 
#include "generic_char_map.h"
 
typedef struct module_struct module_t;
57,10 → 55,9
int usage;
char * name;
char * filename;
connect_module_t * connect_module;
};
 
int add_module( module_ref * module, modules_ref modules, char * name, char * filename, services_t service, task_id_t task_id, connect_module_t * connect_module );
int add_module( module_ref * module, modules_ref modules, char * name, char * filename, services_t service, task_id_t task_id );
module_ref get_running_module( modules_ref modules, char * name );
task_id_t spawn( char * fname );