Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4703 → Rev 4704

/branches/network/uspace/srv/net/structures/module_map.c
74,7 → 74,6
module_ref module;
 
module = modules_find( modules, name, 0 );
// TODO register the unknown one?
if( ! module ) return NULL;
if( ! module->task_id ){
module->task_id = spawn( module->filename );
/branches/network/uspace/srv/net/structures/generic_field.h
31,6 → 31,7
*/
 
/** @file
* Generic type field.
*/
 
#ifndef __GENERIC_FIELD_H__
41,8 → 42,14
#include <mem.h>
#include <unistd.h>
 
/** Internal magic value for a&nbsp;field consistency check.
*/
#define GENERIC_FIELD_MAGIC_VALUE 0x55667788
 
/** Generic type field declaration.
* @param name Name of the field. Input parameter.
* @param type Inner object type. Input parameter
*/
#define GENERIC_FIELD_DECLARE( name, type ) \
\
typedef struct name name##_t; \
64,6 → 71,11
int name##_initialize( name##_ref field ); \
int name##_is_valid( name##_ref field );
 
/** Generic type field implementation.
* Should follow declaration with the same parameters.
* @param name Name of the field. Input parameter.
* @param type Inner object type. Input parameter
*/
#define GENERIC_FIELD_IMPLEMENT( name, type ) \
\
int name##_add( name##_ref field, type * value ){ \
/branches/network/uspace/srv/net/structures/packet/packet_client.h
46,6 → 46,10
 
#include "packet.h"
 
/** @name Packet client interface
*/
/*@{*/
 
/** Allocates the specified type right before the actual packet content and returns its pointer.
* The wrapper of the packet_prepend() function.
* @param packet The packet to be used. Input parameter.
199,6 → 203,8
*/
void pq_release( int phone, packet_id_t packet_id );
 
/*@}*/
 
#endif
 
/** @}
/branches/network/uspace/srv/net/structures/packet/packet.h
69,6 → 69,10
PACKET_OTHERHOST
};
 
/** @name Packet management system interface
*/
/*@{*/
 
/** Finds the packet mapping.
* @param packet_id The packet identifier to be found. Input parameter.
* @returns The found packet reference.
153,6 → 157,8
*/
packet_t pq_previous( packet_t packet );
 
/*@}*/
 
#endif
 
/** @}
/branches/network/uspace/srv/net/structures/packet/packet_server.c
91,6 → 91,10
0
};
 
/** @name Packet server support functions
*/
/*@{*/
 
/** 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.
148,6 → 152,8
*/
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 );
/branches/network/uspace/srv/net/structures/dynamic_fifo.c
31,6 → 31,7
*/
 
/** @file
* Dynamic first in first out positive integer queue implementation.
*/
 
#include <errno.h>
39,10 → 40,22
 
#include "dynamic_fifo.h"
 
/** Internal magic value for a&nbsp;consistency check.
*/
#define DYN_FIFO_MAGIC_VALUE 0x58627659
 
/** Returns the next queue index.
* The queue field is circular.
* @param fifo The dynamic queue. Input parameter.
* @param index The actual index to be shifted. Input parameter.
*/
#define NEXT_INDEX( fifo, index ) ((( index ) + 1 ) % (( fifo )->size + 1 ))
 
/** Checks if the queue is valid.
* @param fifo The dynamic queue. Input parameter.
* @returns TRUE if the queue is valid.
* @returns FALSE otherwise.
*/
int dyn_fifo_is_valid( dyn_fifo_ref fifo );
 
int dyn_fifo_is_valid( dyn_fifo_ref fifo ){
/branches/network/uspace/srv/net/structures/generic_char_map.h
31,6 → 31,7
*/
 
/** @file
* Character string to generic type map.
*/
 
#ifndef __GENERIC_CHAR_MAP_H__
44,8 → 45,14
#include "char_map.h"
#include "generic_field.h"
 
/** Internal magic value for a&nbsp;map consistency check.
*/
#define GENERIC_CHAR_MAP_MAGIC_VALUE 0x12345622
 
/** Character string to generic type map declaration.
* @param name Name of the map. Input parameter.
* @param type Inner object type. Input parameter
*/
#define GENERIC_CHAR_MAP_DECLARE( name, type ) \
\
GENERIC_FIELD_DECLARE( name##_items, type ) \
68,6 → 75,11
int name##_initialize( name##_ref map ); \
int name##_is_valid( name##_ref map );
 
/** Character string to generic type map implementation.
* Should follow declaration with the same parameters.
* @param name Name of the map. Input parameter.
* @param type Inner object type. Input parameter
*/
#define GENERIC_CHAR_MAP_IMPLEMENT( name, type ) \
\
GENERIC_FIELD_IMPLEMENT( name##_items, type ) \
/branches/network/uspace/srv/net/structures/dynamic_fifo.h
31,32 → 31,86
*/
 
/** @file
* Dynamic first in first out positive integer queue.
* Possitive integer values only.
*/
 
#ifndef __NET_DYNAMIC_FIFO_H__
#define __NET_DYNAMIC_FIFO_H__
 
/* For possitive values only */
/** Type definition of the dynamic fifo queue.
* @see dyn_fifo
*/
typedef struct dyn_fifo dyn_fifo_t;
 
typedef struct dyn_fifo dyn_fifo_t;
/** Type definition of the dynamic fifo queue pointer.
* @see dyn_fifo
*/
typedef dyn_fifo_t * dyn_fifo_ref;
 
/** Dynamic first in first out positive integer queue.
* Possitive integer values only.
* The queue automatically resizes if needed.
*/
struct dyn_fifo{
/** Stored item field.
*/
int * items;
/** Actual field size.
*/
int size;
/** First item in the queue index.
*/
int head;
/** Last item in the queue index.
*/
int tail;
/** Consistency check magic value.
*/
int magic_value;
};
 
/** Initializes the dynamic queue.
* @param fifo The dynamic queue. Input/output parameter.
* @param size The initial queue size. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the queue is not valid.
* @returns EBADMEM if the fifo parameter is NULL.
* @returns ENOMEM if there is not enough memory left.
*/
int dyn_fifo_initialize( dyn_fifo_ref fifo, int size );
 
/** Appends a new item to the queue end.
* @param fifo The dynamic queue. Input/output parameter.
* @param value The new item value. Should be positive. Input parameter.
* @param max_size The maximum queue size. The queue is not resized beyound this limit. May be zero or negative (<=0) to indicate no limit. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the queue is not valid.
* @returns ENOMEM if there is not enough memory left.
*/
int dyn_fifo_push( dyn_fifo_ref fifo, int value, int max_size );
 
/** Returns and excludes the first item in the queue.
* @param fifo The dynamic queue. Input/output parameter.
* @returns Value of the first item in the queue.
* @returns EINVAL if the queue is not valid.
* @returns ENOENT if the queue is empty.
*/
int dyn_fifo_pop( dyn_fifo_ref fifo );
 
/** Returns and keeps the first item in the queue.
* @param fifo The dynamic queue. Input/output parameter.
* @returns Value of the first item in the queue.
* @returns EINVAL if the queue is not valid.
* @returns ENOENT if the queue is empty.
*/
int dyn_fifo_value( dyn_fifo_ref fifo );
 
/** Clears and destroys the queue.
* @param fifo The dynamic queue. Input/output parameter.
* @returns EOK on success.
* @returns EINVAL if the queue is not valid.
*/
int dyn_fifo_destroy( dyn_fifo_ref fifo );
 
#endif
/branches/network/uspace/srv/net/structures/int_map.h
31,6 → 31,7
*/
 
/** @file
* Integer to generic type map.
*/
 
#ifndef __NET_INT_MAP_H__
41,9 → 42,18
#include <mem.h>
#include <unistd.h>
 
/** Internal magic value for a&nbsp;map consistency check.
*/
#define INT_MAP_MAGIC_VALUE 0x11223344
 
/** Internal magic value for an item consistency check.
*/
#define INT_MAP_ITEM_MAGIC_VALUE 0x55667788
 
/** Integer to generic type map declaration.
* @param name Name of the map. Input parameter.
* @param type Inner object type. Input parameter
*/
#define INT_MAP_DECLARE( name, type ) \
\
typedef struct name name##_t; \
77,6 → 87,11
void name##_item_destroy( name##_item_ref item ); \
int name##_item_is_valid( name##_item_ref item );
 
/** Integer to generic type map implementation.
* Should follow declaration with the same parameters.
* @param name Name of the map. Input parameter.
* @param type Inner object type. Input parameter
*/
#define INT_MAP_IMPLEMENT( name, type ) \
\
int name##_add( name##_ref map, int key, type * value ){ \