Changeset 1ffa73b in mainline for uspace/lib


Ignore:
Timestamp:
2011-01-10T16:33:08Z (15 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b207803
Parents:
863d45e (diff), 6610565b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge development/ changes

Location:
uspace/lib
Files:
1 deleted
56 edited
11 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r863d45e r1ffa73b  
    5959        generic/devman.c \
    6060        generic/device/hw_res.c \
    61         generic/device/char.c \
     61        generic/device/char_dev.c \
    6262        generic/event.c \
    6363        generic/errno.c \
  • uspace/lib/c/generic/adt/char_map.c

    r863d45e r1ffa73b  
    6565 */
    6666static int
    67 char_map_add_item(char_map_t *map, const char *identifier, size_t length,
     67char_map_add_item(char_map_t *map, const uint8_t *identifier, size_t length,
    6868    const int value)
    6969{
     
    139139 */
    140140int
    141 char_map_add(char_map_t *map, const char *identifier, size_t length,
     141char_map_add(char_map_t *map, const uint8_t *identifier, size_t length,
    142142    const int value)
    143143{
     
    200200 */
    201201static char_map_t *
    202 char_map_find_node(const char_map_t *map, const char *identifier,
     202char_map_find_node(const char_map_t *map, const uint8_t *identifier,
    203203    size_t length)
    204204{
     
    241241 * @return              CHAR_MAP_NULL if the key is not assigned a value.
    242242 */
    243 int char_map_exclude(char_map_t *map, const char *identifier, size_t length)
     243int char_map_exclude(char_map_t *map, const uint8_t *identifier, size_t length)
    244244{
    245245        char_map_t *node;
     
    269269 *  @return             CHAR_MAP_NULL if the key is not assigned a value.
    270270 */
    271 int char_map_find(const char_map_t *map, const char *identifier, size_t length)
     271int char_map_find(const char_map_t *map, const uint8_t *identifier, size_t length)
    272272{
    273273        char_map_t *node;
     
    329329 */
    330330int
    331 char_map_update(char_map_t *map, const char *identifier, const size_t length,
     331char_map_update(char_map_t *map, const uint8_t *identifier, const size_t length,
    332332    const int value)
    333333{
  • uspace/lib/c/generic/adt/measured_strings.c

    r863d45e r1ffa73b  
    5959 */
    6060measured_string_t *
    61 measured_string_create_bulk(const char *string, size_t length)
     61measured_string_create_bulk(const uint8_t *string, size_t length)
    6262{
    6363        measured_string_t *new;
     
    6868        }
    6969        new = (measured_string_t *) malloc(sizeof(measured_string_t) +
    70             (sizeof(char) * (length + 1)));
     70            (sizeof(uint8_t) * (length + 1)));
    7171        if (!new)
    7272                return NULL;
    7373
    7474        new->length = length;
    75         new->value = ((char *) new) + sizeof(measured_string_t);
     75        new->value = ((uint8_t *) new) + sizeof(measured_string_t);
    7676        // append terminating zero explicitly - to be safe
    7777        memcpy(new->value, string, new->length);
     
    9797        new = (measured_string_t *) malloc(sizeof(measured_string_t));
    9898        if (new) {
    99                 new->value = (char *) malloc(source->length + 1);
     99                new->value = (uint8_t *) malloc(source->length + 1);
    100100                if (new->value) {
    101101                        new->length = source->length;
     
    131131 */
    132132int
    133 measured_strings_receive(measured_string_t **strings, char **data,
     133measured_strings_receive(measured_string_t **strings, uint8_t **data,
    134134    size_t count)
    135135{
     
    137137        size_t index;
    138138        size_t length;
    139         char *next;
     139        uint8_t *next;
    140140        ipc_callid_t callid;
    141141        int rc;
     
    311311 */
    312312int
    313 measured_strings_return(int phone, measured_string_t **strings, char **data,
     313measured_strings_return(int phone, measured_string_t **strings, uint8_t **data,
    314314    size_t count)
    315315{
    316316        size_t *lengths;
    317317        size_t index;
    318         char *next;
     318        uint8_t *next;
    319319        int rc;
    320320
  • uspace/lib/c/generic/async_sess.c

    r863d45e r1ffa73b  
    110110typedef struct {
    111111        link_t sess_link;       /**< Link for the session list of inactive connections. */
    112         link_t global_link;     /**< Link for the global list of inactive connectinos. */
     112        link_t global_link;     /**< Link for the global list of inactive connections. */
    113113        int data_phone;         /**< Connected data phone. */
    114114} conn_node_t;
    115115
    116116/**
    117  * Mutex protecting the inactive_conn_head list and the session list.
     117 * Mutex protecting the inactive_conn_head list, the session list and the
     118 * avail_phone condition variable.
    118119 */
    119120static fibril_mutex_t async_sess_mutex;
     
    128129 */
    129130static LIST_INITIALIZE(session_list_head);
     131
     132/**
     133 * Condition variable used to wait for a phone to become available.
     134 */
     135static FIBRIL_CONDVAR_INITIALIZE(avail_phone_cv);
    130136
    131137/** Initialize the async_sess subsystem.
     
    150156 * @param sess  Session structure provided by caller, will be filled in.
    151157 * @param phone Phone connected to the desired server task.
    152  */
    153 void async_session_create(async_sess_t *sess, int phone)
     158 * @param arg1  Value to pass as first argument upon creating a new
     159 *              connection. Typical use is to identify a resource within
     160 *              the server that the caller wants to access (port ID,
     161 *              interface ID, device ID, etc.).
     162 */
     163void async_session_create(async_sess_t *sess, int phone, sysarg_t arg1)
    154164{
    155165        sess->sess_phone = phone;
     166        sess->connect_arg1 = arg1;
    156167        list_initialize(&sess->conn_head);
    157168       
     
    192203                free(conn);
    193204        }
     205       
     206        fibril_condvar_broadcast(&avail_phone_cv);
    194207}
    195208
     
    231244                 */
    232245retry:
    233                 data_phone = async_connect_me_to(sess->sess_phone, 0, 0, 0);
     246                data_phone = async_connect_me_to(sess->sess_phone,
     247                    sess->connect_arg1, 0, 0);
    234248                if (data_phone >= 0) {
    235249                        /* success, do nothing */
     
    250264                } else {
    251265                        /*
    252                          * This is unfortunate. We failed both to find a cached
    253                          * connection or to create a new one even after cleaning up
    254                          * the cache. This is most likely due to too many
    255                          * open sessions (connected session phones).
     266                         * Wait for a phone to become available.
    256267                         */
    257                         data_phone = ELIMIT;
     268                        fibril_condvar_wait(&avail_phone_cv, &async_sess_mutex);
     269                        goto retry;
    258270                }
    259271        }
     
    273285
    274286        fibril_mutex_lock(&async_sess_mutex);
     287        fibril_condvar_signal(&avail_phone_cv);
    275288        conn = (conn_node_t *) malloc(sizeof(conn_node_t));
    276289        if (!conn) {
     
    279292                 * means that we simply hang up.
    280293                 */
     294                ipc_hangup(data_phone);
    281295                fibril_mutex_unlock(&async_sess_mutex);
    282                 ipc_hangup(data_phone);
    283296                return;
    284297        }
  • uspace/lib/c/generic/device/char_dev.c

    r863d45e r1ffa73b  
    3434
    3535#include <ipc/dev_iface.h>
    36 #include <device/char.h>
     36#include <device/char_dev.h>
    3737#include <errno.h>
    3838#include <async.h>
     
    4545 * using its character interface.
    4646 *
    47  * @param dev_phone Phone to the device.
    48  * @param buf       Buffer for the data read
    49  *                  from or written to the device.
    50  * @param len       Maximum length of the data to be
    51  *                  read or written.
    52  * @param read      Read from the device if true,
    53  *                  write to it otherwise.
     47 * @param dev_phone     Phone to the device.
     48 * @param buf           Buffer for the data read from or written to the device.
     49 * @param size          Maximum size of data (in bytes) to be read or written.
     50 * @param read          Read from the device if true, write to it otherwise.
    5451 *
    55  * @return Non-negative number of bytes actually read
    56  *         from or written to the device on success,
    57  *         negative error number otherwise.
    58  *
     52 * @return              Non-negative number of bytes actually read from or
     53 *                      written to the device on success, negative error number
     54 *                      otherwise.
    5955 */
    60 static ssize_t rw_dev(int dev_phone, void *buf, size_t len, bool read)
     56static ssize_t char_dev_rw(int dev_phone, void *buf, size_t size, bool read)
    6157{
    6258        async_serialize_start();
     
    6864        if (read) {
    6965                req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE),
    70                     CHAR_READ_DEV, &answer);
    71                 ret = async_data_read_start(dev_phone, buf, len);
     66                    CHAR_DEV_READ, &answer);
     67                ret = async_data_read_start(dev_phone, buf, size);
    7268        } else {
    7369                req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE),
    74                     CHAR_WRITE_DEV, &answer);
    75                 ret = async_data_write_start(dev_phone, buf, len);
     70                    CHAR_DEV_WRITE, &answer);
     71                ret = async_data_write_start(dev_phone, buf, size);
    7672        }
    7773       
     
    8278                if (rc == EOK)
    8379                        return (ssize_t) ret;
    84                        
     80               
    8581                return (ssize_t) rc;
    8682        }
     
    9692}
    9793
    98 /** Read from device using its character interface.
     94/** Read from character device.
    9995 *
    100  * @param dev_phone Phone to the device.
    101  * @param buf       Output buffer for the data
    102  *                  read from the device.
    103  * @param len       Maximum length of the data to be read.
     96 * @param dev_phone     Phone to the device.
     97 * @param buf           Output buffer for the data read from the device.
     98 * @param size          Maximum size (in bytes) of the data to be read.
    10499 *
    105  * @return Non-negative number of bytes actually read
    106  *         from the device on success, negative error
    107  *         number otherwise.
    108  *
     100 * @return              Non-negative number of bytes actually read from the
     101 *                      device on success, negative error number otherwise.
    109102 */
    110 ssize_t read_dev(int dev_phone, void *buf, size_t len)
     103ssize_t char_dev_read(int dev_phone, void *buf, size_t size)
    111104{
    112         return rw_dev(dev_phone, buf, len, true);
     105        return char_dev_rw(dev_phone, buf, size, true);
    113106}
    114107
    115 /** Write to device using its character interface.
     108/** Write to character device.
    116109 *
    117  * @param dev_phone Phone to the device.
    118  * @param buf       Input buffer containg the data
    119  *                  to be written to the device.
    120  * @param len       Maximum length of the data to be written.
     110 * @param dev_phone     Phone to the device.
     111 * @param buf           Input buffer containg the data to be written to the
     112 *                      device.
     113 * @param size          Maximum size (in bytes) of the data to be written.
    121114 *
    122  * @return Non-negative number of bytes actually written
    123  *         to the device on success, negative error number
    124  *         otherwise.
    125  *
     115 * @return              Non-negative number of bytes actually written to the
     116 *                      device on success, negative error number otherwise.
    126117 */
    127 ssize_t write_dev(int dev_phone, void *buf, size_t len)
     118ssize_t char_dev_write(int dev_phone, void *buf, size_t size)
    128119{
    129         return rw_dev(dev_phone, buf, len, false);
     120        return char_dev_rw(dev_phone, buf, size, false);
    130121}
    131122
  • uspace/lib/c/generic/device/hw_res.c

    r863d45e r1ffa73b  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929 /** @addtogroup libc
    3030 * @{
     
    3232/** @file
    3333 */
    34  
     34
    3535#include <device/hw_res.h>
    3636#include <errno.h>
     
    3838#include <malloc.h>
    3939
    40 int get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources)
     40int hw_res_get_resource_list(int dev_phone, hw_resource_list_t *hw_resources)
    4141{
    4242        sysarg_t count = 0;
    43         int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), GET_RESOURCE_LIST, &count);
     43
     44        int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     45            HW_RES_GET_RESOURCE_LIST, &count);
     46
    4447        hw_resources->count = count;
    4548        if (rc != EOK)
     
    5760                return rc;
    5861        }
    59                  
     62       
    6063        return EOK;
    6164}
    6265
    63 bool enable_interrupt(int dev_phone)
     66bool hw_res_enable_interrupt(int dev_phone)
    6467{
    65         int rc = async_req_1_0(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), ENABLE_INTERRUPT);
     68        int rc = async_req_1_0(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     69            HW_RES_ENABLE_INTERRUPT);
     70
    6671        return rc == EOK;
    6772}
    68  
    69  
    70  
    71  /** @}
     73
     74/** @}
    7275 */
  • uspace/lib/c/generic/devman.c

    r863d45e r1ffa73b  
    4242#include <devman.h>
    4343#include <async.h>
     44#include <fibril_synch.h>
    4445#include <errno.h>
    4546#include <malloc.h>
     
    5051static int devman_phone_client = -1;
    5152
     53static FIBRIL_MUTEX_INITIALIZE(devman_phone_mutex);
     54
    5255int devman_get_phone(devman_interface_t iface, unsigned int flags)
    5356{
    5457        switch (iface) {
    5558        case DEVMAN_DRIVER:
    56                 if (devman_phone_driver >= 0)
     59                fibril_mutex_lock(&devman_phone_mutex);
     60                if (devman_phone_driver >= 0) {
     61                        fibril_mutex_unlock(&devman_phone_mutex);
    5762                        return devman_phone_driver;
     63                }
    5864               
    5965                if (flags & IPC_FLAG_BLOCKING)
    60                         devman_phone_driver = ipc_connect_me_to_blocking(PHONE_NS,
     66                        devman_phone_driver = async_connect_me_to_blocking(
     67                            PHONE_NS, SERVICE_DEVMAN, DEVMAN_DRIVER, 0);
     68                else
     69                        devman_phone_driver = async_connect_me_to(PHONE_NS,
    6170                            SERVICE_DEVMAN, DEVMAN_DRIVER, 0);
    62                 else
    63                         devman_phone_driver = ipc_connect_me_to(PHONE_NS,
    64                             SERVICE_DEVMAN, DEVMAN_DRIVER, 0);
    65                
     71               
     72                fibril_mutex_unlock(&devman_phone_mutex);
    6673                return devman_phone_driver;
    6774        case DEVMAN_CLIENT:
    68                 if (devman_phone_client >= 0)
     75                fibril_mutex_lock(&devman_phone_mutex);
     76                if (devman_phone_client >= 0) {
     77                        fibril_mutex_unlock(&devman_phone_mutex);
    6978                        return devman_phone_client;
     79                }
    7080               
    7181                if (flags & IPC_FLAG_BLOCKING)
    72                         devman_phone_client = ipc_connect_me_to_blocking(PHONE_NS,
     82                        devman_phone_client = async_connect_me_to_blocking(
     83                            PHONE_NS, SERVICE_DEVMAN, DEVMAN_CLIENT, 0);
     84                else
     85                        devman_phone_client = async_connect_me_to(PHONE_NS,
    7386                            SERVICE_DEVMAN, DEVMAN_CLIENT, 0);
    74                 else
    75                         devman_phone_client = ipc_connect_me_to(PHONE_NS,
    76                             SERVICE_DEVMAN, DEVMAN_CLIENT, 0);
    77                
     87               
     88                fibril_mutex_unlock(&devman_phone_mutex);
    7889                return devman_phone_client;
    7990        default:
     
    245256       
    246257        if (flags & IPC_FLAG_BLOCKING) {
    247                 phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAN,
     258                phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAN,
    248259                    DEVMAN_CONNECT_TO_PARENTS_DEVICE, handle);
    249260        } else {
    250                 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAN,
     261                phone = async_connect_me_to(PHONE_NS, SERVICE_DEVMAN,
    251262                    DEVMAN_CONNECT_TO_PARENTS_DEVICE, handle);
    252263        }
  • uspace/lib/c/generic/fibril.c

    r863d45e r1ffa73b  
    361361}
    362362
     363int fibril_get_sercount(void)
     364{
     365        return serialization_count;
     366}
     367
    363368/** @}
    364369 */
  • uspace/lib/c/generic/fibril_synch.c

    r863d45e r1ffa73b  
    104104        fibril_t *f = (fibril_t *) fibril_get_id();
    105105
     106        if (fibril_get_sercount() != 0)
     107                core();
     108
    106109        futex_down(&async_futex);
    107110        if (fm->counter-- <= 0) {
     
    194197        fibril_t *f = (fibril_t *) fibril_get_id();
    195198       
     199        if (fibril_get_sercount() != 0)
     200                core();
     201
    196202        futex_down(&async_futex);
    197203        if (frw->writers) {
     
    219225        fibril_t *f = (fibril_t *) fibril_get_id();
    220226       
     227        if (fibril_get_sercount() != 0)
     228                core();
     229
    221230        futex_down(&async_futex);
    222231        if (frw->writers || frw->readers) {
  • uspace/lib/c/generic/io/vprintf.c

    r863d45e r1ffa73b  
    3737#include <unistd.h>
    3838#include <io/printf_core.h>
    39 #include <futex.h>
     39#include <fibril_synch.h>
    4040#include <async.h>
    4141#include <str.h>
    4242
    43 static atomic_t printf_futex = FUTEX_INITIALIZER;
     43static FIBRIL_MUTEX_INITIALIZE(printf_mutex);
    4444
    4545static int vprintf_str_write(const char *str, size_t size, void *stream)
     
    8585         * Prevent other threads to execute printf_core()
    8686         */
    87         futex_down(&printf_futex);
    88        
    89         /*
    90          * Prevent other fibrils of the same thread
    91          * to execute printf_core()
    92          */
    93         async_serialize_start();
     87        fibril_mutex_lock(&printf_mutex);
    9488       
    9589        int ret = printf_core(fmt, &ps, ap);
    9690       
    97         async_serialize_end();
    98         futex_up(&printf_futex);
     91        fibril_mutex_unlock(&printf_mutex);
    9992       
    10093        return ret;
  • uspace/lib/c/generic/mem.c

    r863d45e r1ffa73b  
    222222/** Compare two memory areas.
    223223 *
    224  * @param s1            Pointer to the first area to compare.
    225  * @param s2            Pointer to the second area to compare.
    226  * @param len           Size of the first area in bytes. Both areas must have
    227  *                      the same length.
    228  * @return              If len is 0, return zero. If the areas match, return
    229  *                      zero. Otherwise return non-zero.
    230  */
    231 int bcmp(const char *s1, const char *s2, size_t len)
    232 {
    233         for (; len && *s1++ == *s2++; len--)
    234                 ;
     224 * @param s1  Pointer to the first area to compare.
     225 * @param s2  Pointer to the second area to compare.
     226 * @param len Size of the first area in bytes. Both areas must have
     227 *            the same length.
     228 *
     229 * @return If len is 0, return zero. If the areas match, return
     230 *         zero. Otherwise return non-zero.
     231 *
     232 */
     233int bcmp(const void *s1, const void *s2, size_t len)
     234{
     235        uint8_t *u1 = (uint8_t *) s1;
     236        uint8_t *u2 = (uint8_t *) s2;
     237       
     238        for (; (len != 0) && (*u1++ == *u2++); len--);
     239       
    235240        return len;
    236241}
  • uspace/lib/c/generic/net/modules.c

    r863d45e r1ffa73b  
    3232
    3333/** @file
    34  * Generic module functions implementation. 
     34 * Generic module functions implementation.
    3535 *
    3636 * @todo MAKE IT POSSIBLE TO REMOVE THIS FILE VIA EITHER REPLACING PART OF ITS
     
    5252#define MODULE_WAIT_TIME        (10 * 1000)
    5353
    54 /** Answers the call.
    55  *
    56  * @param[in] callid    The call identifier.
    57  * @param[in] result    The message processing result.
    58  * @param[in] answer    The message processing answer.
    59  * @param[in] answer_count The number of answer parameters.
    60  */
    61 void
    62 answer_call(ipc_callid_t callid, int result, ipc_call_t *answer,
    63     int answer_count)
    64 {
    65         /* Choose the most efficient answer function */
    66         if (answer || (!answer_count)) {
    67                 switch (answer_count) {
     54/** Answer a call.
     55 *
     56 * @param[in] callid Call identifier.
     57 * @param[in] result Message processing result.
     58 * @param[in] answer Message processing answer.
     59 * @param[in] count  Number of answer parameters.
     60 *
     61 */
     62void answer_call(ipc_callid_t callid, int result, ipc_call_t *answer,
     63    size_t count)
     64{
     65        /* Choose the most efficient function */
     66        if ((answer != NULL) || (count == 0)) {
     67                switch (count) {
    6868                case 0:
    6969                        ipc_answer_0(callid, (sysarg_t) result);
     
    228228}
    229229
    230 /** Refreshes answer structure and parameters count.
    231  *
    232  * Erases all attributes.
    233  *
    234  * @param[in,out] answer The message processing answer structure.
    235  * @param[in,out] answer_count The number of answer parameters.
    236  */
    237 void refresh_answer(ipc_call_t *answer, int *answer_count)
    238 {
    239         if (answer_count)
    240                 *answer_count = 0;
    241 
    242         if (answer) {
     230/** Refresh answer structure and argument count.
     231 *
     232 * Erase all arguments.
     233 *
     234 * @param[in,out] answer Message processing answer structure.
     235 * @param[in,out] count  Number of answer arguments.
     236 *
     237 */
     238void refresh_answer(ipc_call_t *answer, size_t *count)
     239{
     240        if (count != NULL)
     241                *count = 0;
     242       
     243        if (answer != NULL) {
    243244                IPC_SET_RETVAL(*answer, 0);
    244                 /* Just to be precise */
    245245                IPC_SET_IMETHOD(*answer, 0);
    246246                IPC_SET_ARG1(*answer, 0);
  • uspace/lib/c/include/adt/char_map.h

    r863d45e r1ffa73b  
    4141
    4242/** Invalid assigned value used also if an&nbsp;entry does not exist. */
    43 #define CHAR_MAP_NULL   (-1)
     43#define CHAR_MAP_NULL  (-1)
    4444
    4545/** Type definition of the character string to integer map.
    4646 *  @see char_map
    4747 */
    48 typedef struct char_map char_map_t;
     48typedef struct char_map char_map_t;
    4949
    5050/** Character string to integer map item.
     
    5656struct char_map {
    5757        /** Actually mapped character. */
    58         char c;
     58        uint8_t c;
    5959        /** Stored integral value. */
    6060        int value;
     
    7171extern int char_map_initialize(char_map_t *);
    7272extern void char_map_destroy(char_map_t *);
    73 extern int char_map_exclude(char_map_t *, const char *, size_t);
    74 extern int char_map_add(char_map_t *, const char *, size_t, const int);
    75 extern int char_map_find(const char_map_t *, const char *, size_t);
    76 extern int char_map_update(char_map_t *, const char *, size_t, const int);
     73extern int char_map_exclude(char_map_t *, const uint8_t *, size_t);
     74extern int char_map_add(char_map_t *, const uint8_t *, size_t, const int);
     75extern int char_map_find(const char_map_t *, const uint8_t *, size_t);
     76extern int char_map_update(char_map_t *, const uint8_t *, size_t, const int);
    7777
    7878#endif
  • uspace/lib/c/include/adt/generic_char_map.h

    r863d45e r1ffa73b  
    6262        }; \
    6363        \
    64         int name##_add(name##_t *, const char *, const size_t, type *); \
     64        int name##_add(name##_t *, const uint8_t *, const size_t, type *); \
    6565        int name##_count(name##_t *); \
    6666        void name##_destroy(name##_t *); \
    67         void name##_exclude(name##_t *, const char *, const size_t); \
    68         type *name##_find(name##_t *, const char *, const size_t); \
     67        void name##_exclude(name##_t *, const uint8_t *, const size_t); \
     68        type *name##_find(name##_t *, const uint8_t *, const size_t); \
    6969        int name##_initialize(name##_t *); \
    7070        int name##_is_valid(name##_t *);
     
    7474 * Should follow declaration with the same parameters.
    7575 *
    76  * @param[in] name      Name of the map.
    77  * @param[in] type      Inner object type.
     76 * @param[in] name Name of the map.
     77 * @param[in] type Inner object type.
     78 *
    7879 */
    7980#define GENERIC_CHAR_MAP_IMPLEMENT(name, type) \
    8081        GENERIC_FIELD_IMPLEMENT(name##_items, type) \
    8182        \
    82         int name##_add(name##_t *map, const char *name, const size_t length, \
     83        int name##_add(name##_t *map, const uint8_t *name, const size_t length, \
    8384             type *value) \
    8485        { \
     
    112113        } \
    113114        \
    114         void name##_exclude(name##_t *map, const char *name, \
     115        void name##_exclude(name##_t *map, const uint8_t *name, \
    115116            const size_t length) \
    116117        { \
     
    124125        } \
    125126        \
    126         type *name##_find(name##_t *map, const char *name, \
     127        type *name##_find(name##_t *map, const uint8_t *name, \
    127128            const size_t length) \
    128129        { \
  • uspace/lib/c/include/adt/measured_strings.h

    r863d45e r1ffa73b  
    5454struct measured_string {
    5555        /** Character string data. */
    56         char *value;
     56        uint8_t *value;
    5757        /** Character string length. */
    5858        size_t length;
    5959};
    6060
    61 extern measured_string_t *measured_string_create_bulk(const char *, size_t);
     61extern measured_string_t *measured_string_create_bulk(const uint8_t *, size_t);
    6262extern measured_string_t *measured_string_copy(measured_string_t *);
    63 extern int measured_strings_receive(measured_string_t **, char **, size_t);
     63extern int measured_strings_receive(measured_string_t **, uint8_t **, size_t);
    6464extern int measured_strings_reply(const measured_string_t *, size_t);
    65 extern int measured_strings_return(int, measured_string_t **, char **, size_t);
     65extern int measured_strings_return(int, measured_string_t **, uint8_t **, size_t);
    6666extern int measured_strings_send(int, const measured_string_t *, size_t);
    6767
  • uspace/lib/c/include/assert.h

    r863d45e r1ffa73b  
    5757                        printf("Assertion failed (%s) at file '%s', " \
    5858                            "line %d.\n", #expr, __FILE__, __LINE__); \
     59                        stacktrace_print(); \
     60                        core(); \
    5961                        abort(); \
    6062                } \
  • uspace/lib/c/include/async_sess.h

    r863d45e r1ffa73b  
    4040typedef struct {
    4141        int sess_phone;         /**< Phone for cloning off the connections. */
     42        sysarg_t connect_arg1;  /**< Argument for CONNECT_ME_TO. */
    4243        link_t conn_head;       /**< List of open data connections. */
    4344        link_t sess_link;       /**< Link in global list of open sessions. */
     
    4546
    4647extern void _async_sess_init(void);
    47 extern void async_session_create(async_sess_t *, int);
     48extern void async_session_create(async_sess_t *, int, sysarg_t);
    4849extern void async_session_destroy(async_sess_t *);
    4950extern int async_exchange_begin(async_sess_t *);
  • uspace/lib/c/include/device/char_dev.h

    r863d45e r1ffa73b  
    2727 */
    2828
    29  /** @addtogroup libc
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef LIBC_DEVICE_HW_RES_H_
    36 #define LIBC_DEVICE_HW_RES_H_
     35#ifndef LIBC_DEVICE_CHAR_DEV_H_
     36#define LIBC_DEVICE_CHAR_DEV_H_
    3737
    3838typedef enum {
    39         CHAR_READ_DEV = 0,
    40         CHAR_WRITE_DEV
    41 } hw_res_funcs_t;
     39        CHAR_DEV_READ = 0,
     40        CHAR_DEV_WRITE
     41} char_dev_method_t;
    4242
    43 ssize_t read_dev(int dev_phone, void *buf, size_t len);
    44 ssize_t write_dev(int dev_phone, void *buf, size_t len);
     43ssize_t char_dev_read(int dev_phone, void *buf, size_t len);
     44ssize_t char_dev_write(int dev_phone, void *buf, size_t len);
    4545
    4646#endif
  • uspace/lib/c/include/device/hw_res.h

    r863d45e r1ffa73b  
    2727 */
    2828 
    29  /** @addtogroup libc
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3939#include <bool.h>
    4040
    41 // HW resource provider interface
     41/** HW resource provider interface */
     42typedef enum {
     43        HW_RES_GET_RESOURCE_LIST = 0,
     44        HW_RES_ENABLE_INTERRUPT
     45} hw_res_method_t;
    4246
    43 typedef enum {
    44         GET_RESOURCE_LIST = 0,
    45         ENABLE_INTERRUPT       
    46 } hw_res_funcs_t;
    47 
    48 /** HW resource types. */
     47/** HW resource types */
    4948typedef enum {
    5049        INTERRUPT,
     
    5857} endianness_t;
    5958
    60 
    61 /** HW resource (e.g. interrupt, memory register, i/o register etc.). */
    62 typedef struct hw_resource {
     59/** HW resource (e.g. interrupt, memory register, i/o register etc.) */
     60typedef struct {
    6361        hw_res_type_t type;
    6462        union {
    6563                struct {
    6664                        uint64_t address;
    67                         endianness_t endianness;                       
    68                         size_t size;                   
     65                        endianness_t endianness;
     66                        size_t size;
    6967                } mem_range;
     68
    7069                struct {
    7170                        uint64_t address;
    72                         endianness_t endianness;                       
    73                         size_t size;                   
     71                        endianness_t endianness;
     72                        size_t size;
    7473                } io_range;
     74
    7575                struct {
    76                         int irq;                       
    77                 } interrupt;           
    78         } res; 
     76                        int irq;
     77                } interrupt;
     78        } res;
    7979} hw_resource_t;
    8080
    81 typedef struct hw_resource_list {
     81typedef struct {
    8282        size_t count;
    83         hw_resource_t *resources;       
     83        hw_resource_t *resources;
    8484} hw_resource_list_t;
    8585
    86 static inline void clean_hw_resource_list(hw_resource_list_t *hw_res)
     86static inline void hw_res_clean_resource_list(hw_resource_list_t *hw_res)
    8787{
    88         if(NULL != hw_res->resources) {
     88        if (hw_res->resources != NULL) {
    8989                free(hw_res->resources);
     90
    9091                hw_res->resources = NULL;
    9192        }
    92         hw_res->count = 0;     
     93
     94        hw_res->count = 0;
    9395}
    9496
    95 
    96 
    97 extern int get_hw_resources(int, hw_resource_list_t *);
    98 extern bool enable_interrupt(int);
    99 
     97extern int hw_res_get_resource_list(int, hw_resource_list_t *);
     98extern bool hw_res_enable_interrupt(int);
    10099
    101100#endif
  • uspace/lib/c/include/fibril.h

    r863d45e r1ffa73b  
    9494extern void fibril_inc_sercount(void);
    9595extern void fibril_dec_sercount(void);
     96extern int fibril_get_sercount(void);
    9697
    9798static inline int fibril_yield(void)
  • uspace/lib/c/include/ipc/arp.h

    r863d45e r1ffa73b  
    6969/*@{*/
    7070
    71 /** Returns the protocol service message parameter.
    72  * @param[in] call The message call structure.
     71/** Return the protocol service message parameter.
     72 *
     73 * @param[in] call Message call structure.
     74 *
    7375 */
    74 #define ARP_GET_NETIF(call) \
    75         ({ \
    76                 services_t service = (services_t) IPC_GET_ARG2(*call); \
    77                 service; \
    78         })
     76#define ARP_GET_NETIF(call) ((services_t) IPC_GET_ARG2(call))
    7977
    8078/*@}*/
  • uspace/lib/c/include/ipc/dev_iface.h

    r863d45e r1ffa73b  
    3535#include <libarch/types.h>
    3636
    37 typedef enum { 
    38         HW_RES_DEV_IFACE = 0,   
     37typedef enum {
     38        HW_RES_DEV_IFACE = 0,
    3939        CHAR_DEV_IFACE,
    4040
     
    4444        USBHC_DEV_IFACE,
    4545
    46         // TODO add more interfaces
    4746        DEV_IFACE_MAX
    4847} dev_inferface_idx_t;
  • uspace/lib/c/include/ipc/icmp.h

    r863d45e r1ffa73b  
    8282/*@{*/
    8383
    84 /** Returns the ICMP code message parameter.
     84/** Return the ICMP code message parameter.
    8585 *
    86  * @param[in] call      The message call structure.
     86 * @param[in] call Message call structure.
     87 *
    8788 */
    88 #define ICMP_GET_CODE(call) \
    89         ({ \
    90                 icmp_code_t code = (icmp_code_t) IPC_GET_ARG1(*call); \
    91                 code; \
    92         })
     89#define ICMP_GET_CODE(call)  ((icmp_code_t) IPC_GET_ARG1(call))
    9390
    94 /** Returns the ICMP link MTU message parameter.
     91/** Return the ICMP link MTU message parameter.
    9592 *
    96  * @param[in] call      The message call structure.
     93 * @param[in] call Message call structure.
     94 *
    9795 */
    98 #define ICMP_GET_MTU(call) \
    99         ({ \
    100                 icmp_param_t mtu = (icmp_param_t) IPC_GET_ARG3(*call); \
    101                 mtu; \
    102         })
     96#define ICMP_GET_MTU(call)  ((icmp_param_t) IPC_GET_ARG3(call))
    10397
    104 /** Returns the pointer message parameter.
     98/** Return the pointer message parameter.
    10599 *
    106  * @param[in] call      The message call structure.
     100 * @param[in] call Message call structure.
     101 *
    107102 */
    108 #define ICMP_GET_POINTER(call) \
    109         ({ \
    110                 icmp_param_t pointer = (icmp_param_t) IPC_GET_ARG3(*call); \
    111                 pointer; \
    112         })
     103#define ICMP_GET_POINTER(call)  ((icmp_param_t) IPC_GET_ARG3(call))
    113104
    114 /** Returns the size message parameter.
     105/** Return the size message parameter.
    115106 *
    116  * @param[in] call      The message call structure.
     107 * @param[in] call Message call structure.
     108 *
    117109 */
    118 #define ICMP_GET_SIZE(call) \
    119         ({ \
    120                 size_t size = (size_t) IPC_GET_ARG1(call); \
    121                 size; \
    122         })
     110#define ICMP_GET_SIZE(call)  ((size_t) IPC_GET_ARG1(call))
    123111
    124 /** Returns the timeout message parameter.
     112/** Return the timeout message parameter.
    125113 *
    126  * @param[in] call      The message call structure.
     114 * @param[in] call Message call structure.
     115 *
    127116 */
    128 #define ICMP_GET_TIMEOUT(call) \
    129         ({ \
    130                 suseconds_t timeout = (suseconds_t) IPC_GET_ARG2(call); \
    131                 timeout; \
    132         })
     117#define ICMP_GET_TIMEOUT(call)  ((suseconds_t) IPC_GET_ARG2(call))
    133118
    134 /** Returns the time to live message parameter.
     119/** Return the time to live message parameter.
    135120 *
    136  * @param[in] call      The message call structure.
     121 * @param[in] call Message call structure.
     122 *
    137123 */
    138 #define ICMP_GET_TTL(call) \
    139         ({ \
    140                 ip_ttl_t ttl = (ip_ttl_t) IPC_GET_ARG3(call); \
    141                 ttl; \
    142         })
     124#define ICMP_GET_TTL(call)  ((ip_ttl_t) IPC_GET_ARG3(call))
    143125
    144 /** Returns the type of service message parameter.
     126/** Return the type of service message parameter.
    145127 *
    146  * @param[in] call      The message call structure.
     128 * @param[in] call Message call structure.
     129 *
    147130 */
    148 #define ICMP_GET_TOS(call) \
    149         ({ \
    150                 ip_tos_t tos = (ip_tos_t) IPC_GET_ARG4(call); \
    151                 tos; \
    152         })
     131#define ICMP_GET_TOS(call)  ((ip_tos_t) IPC_GET_ARG4(call))
    153132
    154 /** Returns the dont fragment message parameter.
     133/** Return the dont fragment message parameter.
    155134 *
    156  * @param[in] call      The message call structure.
     135 * @param[in] call Message call structure.
    157136 */
    158 #define ICMP_GET_DONT_FRAGMENT(call) \
    159         ({ \
    160                 int dont_fragment = (int) IPC_GET_ARG5(call); \
    161                 dont_fragment; \
    162         })
     137#define ICMP_GET_DONT_FRAGMENT(call)  ((int) IPC_GET_ARG5(call))
    163138
    164139/*@}*/
  • uspace/lib/c/include/ipc/il.h

    r863d45e r1ffa73b  
    7575
    7676/** Return the protocol number message parameter.
    77  * @param[in] call The message call structure.
     77 *
     78 * @param[in] call Message call structure.
     79 *
    7880 */
    79 #define IL_GET_PROTO(call)      (int) IPC_GET_ARG1(*call)
     81#define IL_GET_PROTO(call)  ((int) IPC_GET_ARG1(call))
    8082
    8183/** Return the registering service message parameter.
    82  * @param[in] call The message call structure.
     84 *
     85 * @param[in] call Message call structure.
     86 *
    8387 */
    84 #define IL_GET_SERVICE(call)    (services_t) IPC_GET_ARG2(*call)
     88#define IL_GET_SERVICE(call)  ((services_t) IPC_GET_ARG2(call))
    8589
    8690/*@}*/
  • uspace/lib/c/include/ipc/ip.h

    r863d45e r1ffa73b  
    5151         */
    5252        NET_IP_ADD_ROUTE = NET_IP_FIRST,
     53       
    5354        /** Gets the actual route information.
    5455         * @see ip_get_route()
    5556         */
    5657        NET_IP_GET_ROUTE,
     58       
    5759        /** Processes the received error notification.
    5860         * @see ip_received_error_msg()
    5961         */
    6062        NET_IP_RECEIVED_ERROR,
     63       
    6164        /** Sets the default gateway.
    6265         * @see ip_set_default_gateway()
     
    6871/*@{*/
    6972
    70 /** Returns the address message parameter.
    71  * @param[in] call The message call structure.
     73/** Return the address message parameter.
     74 *
     75 * @param[in] call Message call structure.
     76 *
    7277 */
    7378#define IP_GET_ADDRESS(call) \
    7479        ({ \
    7580                in_addr_t addr; \
    76                 addr.s_addr = IPC_GET_ARG3(*call); \
     81                addr.s_addr = IPC_GET_ARG3(call); \
    7782                addr; \
    7883        })
    7984
    80 /** Returns the gateway message parameter.
    81  * @param[in] call The message call structure.
     85/** Return the gateway message parameter.
     86 *
     87 * @param[in] call Message call structure.
     88 *
    8289 */
    8390#define IP_GET_GATEWAY(call) \
    8491        ({ \
    8592                in_addr_t addr; \
    86                 addr.s_addr = IPC_GET_ARG2(*call); \
     93                addr.s_addr = IPC_GET_ARG2(call); \
    8794                addr; \
    8895        })
    8996
    90 /** Sets the header length in the message answer.
    91  * @param[out] answer The message answer structure.
     97/** Set the header length in the message answer.
     98 *
     99 * @param[out] answer Message answer structure.
     100 *
    92101 */
    93 #define IP_SET_HEADERLEN(answer, value) \
    94         do { \
    95                 sysarg_t argument = (sysarg_t) (value); \
    96                 IPC_SET_ARG2(*answer, argument); \
    97         } while (0)
     102#define IP_SET_HEADERLEN(answer, value)  IPC_SET_ARG2(answer, (sysarg_t) (value))
    98103
    99 /** Returns the network mask message parameter.
    100  * @param[in] call The message call structure.
     104/** Return the network mask message parameter.
     105 *
     106 * @param[in] call Message call structure.
     107 *
    101108 */
    102109#define IP_GET_NETMASK(call) \
    103110        ({ \
    104111                in_addr_t addr; \
    105                 addr.s_addr = IPC_GET_ARG4(*call); \
     112                addr.s_addr = IPC_GET_ARG4(call); \
    106113                addr; \
    107114        })
    108115
    109 /** Returns the protocol message parameter.
    110  * @param[in] call The message call structure.
     116/** Return the protocol message parameter.
     117 *
     118 * @param[in] call Message call structure.
     119 *
    111120 */
    112 #define IP_GET_PROTOCOL(call) \
    113         ({ \
    114                 ip_protocol_t protocol = (ip_protocol_t) IPC_GET_ARG1(*call); \
    115                 protocol; \
    116         })
     121#define IP_GET_PROTOCOL(call)  ((ip_protocol_t) IPC_GET_ARG1(call))
    117122
    118123/*@}*/
  • uspace/lib/c/include/ipc/irc.h

    r863d45e r1ffa73b  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    35 #ifndef LIBC_BUS_H_
    36 #define LIBC_BUS_H_
     35#ifndef LIBC_IRC_H_
     36#define LIBC_IRC_H_
    3737
    3838#include <ipc/ipc.h>
    3939
    4040typedef enum {
    41         BUS_CLEAR_INTERRUPT = IPC_FIRST_USER_METHOD
    42 } bus_request_t;
     41        IRC_ENABLE_INTERRUPT = IPC_FIRST_USER_METHOD,
     42        IRC_CLEAR_INTERRUPT
     43} irc_request_t;
    4344
    4445#endif
  • uspace/lib/c/include/ipc/net.h

    r863d45e r1ffa73b  
    4444#include <net/packet.h>
    4545
    46 /** Returns a value indicating whether the value is in the interval.
    47  * @param[in] item      The value to be checked.
    48  * @param[in] first_inclusive The first value in the interval inclusive.
    49  * @param[in] last_exclusive The first value after the interval.
     46/** Return a value indicating whether the value is in the interval.
     47 *
     48 * @param[in] item            Value to be checked.
     49 * @param[in] first_inclusive First value in the interval inclusive.
     50 * @param[in] last_exclusive  First value after the interval.
     51 *
    5052 */
    5153#define IS_IN_INTERVAL(item, first_inclusive, last_exclusive) \
     
    5557/*@{*/
    5658
    57 /** The number of ARP messages. */
    58 #define NET_ARP_COUNT           5
    59 
    60 /** The number of Ethernet messages. */
    61 #define NET_ETH_COUNT           0
    62 
    63 /** The number of ICMP messages. */
    64 #define NET_ICMP_COUNT          6
    65 
    66 /** The number of inter-network messages. */
    67 #define NET_IL_COUNT            6
    68 
    69 /** The number of IP messages. */
    70 #define NET_IP_COUNT            4
    71 
    72 /** The number of general networking messages. */
    73 #define NET_NET_COUNT           3
    74 
    75 /** The number of network interface driver messages. */
    76 #define NET_NETIF_COUNT         6
    77 
    78 /** The number of network interface layer messages. */
    79 #define NET_NIL_COUNT           7
    80 
    81 /** The number of packet management system messages. */
    82 #define NET_PACKET_COUNT        5
    83 
    84 /** The number of socket messages. */
    85 #define NET_SOCKET_COUNT        14
    86 
    87 /** The number of TCP messages. */
    88 #define NET_TCP_COUNT           0
    89 
    90 /** The number of transport layer messages. */
    91 #define NET_TL_COUNT            1
    92 
    93 /** The number of UDP messages. */
    94 #define NET_UDP_COUNT           0
     59#define NET_ARP_COUNT     5   /**< Number of ARP messages. */
     60#define NET_ETH_COUNT     0   /**< Number of Ethernet messages. */
     61#define NET_ICMP_COUNT    6   /**< Number of ICMP messages. */
     62#define NET_IL_COUNT      6   /**< Number of inter-network messages. */
     63#define NET_IP_COUNT      4   /**< Number of IP messages. */
     64#define NET_NET_COUNT     3   /**< Number of general networking messages. */
     65#define NET_NETIF_COUNT   6   /**< Number of network interface driver messages. */
     66#define NET_NIL_COUNT     7   /**< Number of network interface layer messages. */
     67#define NET_PACKET_COUNT  5   /**< Number of packet management system messages. */
     68#define NET_SOCKET_COUNT  14  /**< Number of socket messages. */
     69#define NET_TCP_COUNT     0   /**< Number of TCP messages. */
     70#define NET_TL_COUNT      1   /**< Number of transport layer messages. */
     71#define NET_UDP_COUNT     0   /**< Number of UDP messages. */
    9572
    9673/*@}*/
     
    10077/*@{*/
    10178
    102 /** The first networking message. */
    103 #define NET_FIRST               2000
    104 
    105 /** The first network interface layer message. */
    106 #define NET_NETIF_FIRST         NET_FIRST
    107 
    108 /** The last network interface layer message. */
    109 #define NET_NETIF_LAST          (NET_NETIF_FIRST + NET_NETIF_COUNT)
    110 
    111 /** The first general networking message. */
    112 #define NET_NET_FIRST           (NET_NETIF_LAST + 0)
    113 
    114 /** The last general networking message. */
    115 #define NET_NET_LAST            (NET_NET_FIRST + NET_NET_COUNT)
    116 
    117 /** The first network interface layer message. */
    118 #define NET_NIL_FIRST           (NET_NET_LAST + 0)
    119 
    120 /** The last network interface layer message. */
    121 #define NET_NIL_LAST            (NET_NIL_FIRST + NET_NIL_COUNT)
    122 
    123 /** The first Ethernet message. */
    124 #define NET_ETH_FIRST           (NET_NIL_LAST + 0)
    125 
    126 /** The last Ethernet message. */
    127 #define NET_ETH_LAST            (NET_ETH_FIRST + NET_ETH_COUNT)
    128 
    129 /** The first inter-network message. */
    130 #define NET_IL_FIRST            (NET_ETH_LAST + 0)
    131 
    132 /** The last inter-network message. */
    133 #define NET_IL_LAST             (NET_IL_FIRST + NET_IL_COUNT)
    134 
    135 /** The first IP message. */
    136 #define NET_IP_FIRST            (NET_IL_LAST + 0)
    137 
    138 /** The last IP message. */
    139 #define NET_IP_LAST             (NET_IP_FIRST + NET_IP_COUNT)
    140 
    141 /** The first ARP message. */
    142 #define NET_ARP_FIRST           (NET_IP_LAST + 0)
    143 
    144 /** The last ARP message. */
    145 #define NET_ARP_LAST            (NET_ARP_FIRST + NET_ARP_COUNT)
    146 
    147 /** The first ICMP message. */
    148 #define NET_ICMP_FIRST          (NET_ARP_LAST + 0)
    149 
    150 /** The last ICMP message. */
    151 #define NET_ICMP_LAST           (NET_ICMP_FIRST + NET_ICMP_COUNT)
    152 
    153 /** The first ICMP message. */
    154 #define NET_TL_FIRST            (NET_ICMP_LAST + 0)
    155 
    156 /** The last ICMP message. */
    157 #define NET_TL_LAST             (NET_TL_FIRST + NET_TL_COUNT)
    158 
    159 /** The first UDP message. */
    160 #define NET_UDP_FIRST           (NET_TL_LAST + 0)
    161 
    162 /** The last UDP message. */
    163 #define NET_UDP_LAST            (NET_UDP_FIRST + NET_UDP_COUNT)
    164 
    165 /** The first TCP message. */
    166 #define NET_TCP_FIRST           (NET_UDP_LAST + 0)
    167 
    168 /** The last TCP message. */
    169 #define NET_TCP_LAST            (NET_TCP_FIRST + NET_TCP_COUNT)
    170 
    171 /** The first socket message. */
    172 #define NET_SOCKET_FIRST        (NET_TCP_LAST + 0)
    173 
    174 /** The last socket message. */
    175 #define NET_SOCKET_LAST         (NET_SOCKET_FIRST + NET_SOCKET_COUNT)
    176 
    177 /** The first packet management system message. */
    178 #define NET_PACKET_FIRST        (NET_SOCKET_LAST + 0)
    179 
    180 /** The last packet management system message. */
    181 #define NET_PACKET_LAST         (NET_PACKET_FIRST + NET_PACKET_COUNT)
    182 
    183 /** The last networking message. */
    184 #define NET_LAST                NET_PACKET_LAST
    185 
    186 /** The number of networking messages. */
    187 #define NET_COUNT               (NET_LAST - NET_FIRST)
    188 
    189 /** Returns a value indicating whether the IPC call is a generic networking
    190  * message.
    191  * @param[in] call The IPC call to be checked.
     79
     80/** First networking message. */
     81#define NET_FIRST  2000
     82
     83/** First network interface layer message. */
     84#define NET_NETIF_FIRST  NET_FIRST
     85
     86/** Last network interface layer message. */
     87#define NET_NETIF_LAST  (NET_NETIF_FIRST + NET_NETIF_COUNT)
     88
     89/** First general networking message. */
     90#define NET_NET_FIRST  (NET_NETIF_LAST + 0)
     91
     92/** Last general networking message. */
     93#define NET_NET_LAST  (NET_NET_FIRST + NET_NET_COUNT)
     94
     95/** First network interface layer message. */
     96#define NET_NIL_FIRST  (NET_NET_LAST + 0)
     97
     98/** Last network interface layer message. */
     99#define NET_NIL_LAST  (NET_NIL_FIRST + NET_NIL_COUNT)
     100
     101/** First Ethernet message. */
     102#define NET_ETH_FIRST  (NET_NIL_LAST + 0)
     103
     104/** Last Ethernet message. */
     105#define NET_ETH_LAST  (NET_ETH_FIRST + NET_ETH_COUNT)
     106
     107/** First inter-network message. */
     108#define NET_IL_FIRST  (NET_ETH_LAST + 0)
     109
     110/** Last inter-network message. */
     111#define NET_IL_LAST  (NET_IL_FIRST + NET_IL_COUNT)
     112
     113/** First IP message. */
     114#define NET_IP_FIRST  (NET_IL_LAST + 0)
     115
     116/** Last IP message. */
     117#define NET_IP_LAST  (NET_IP_FIRST + NET_IP_COUNT)
     118
     119/** First ARP message. */
     120#define NET_ARP_FIRST  (NET_IP_LAST + 0)
     121
     122/** Last ARP message. */
     123#define NET_ARP_LAST  (NET_ARP_FIRST + NET_ARP_COUNT)
     124
     125/** First ICMP message. */
     126#define NET_ICMP_FIRST  (NET_ARP_LAST + 0)
     127
     128/** Last ICMP message. */
     129#define NET_ICMP_LAST  (NET_ICMP_FIRST + NET_ICMP_COUNT)
     130
     131/** First ICMP message. */
     132#define NET_TL_FIRST  (NET_ICMP_LAST + 0)
     133
     134/** Last ICMP message. */
     135#define NET_TL_LAST  (NET_TL_FIRST + NET_TL_COUNT)
     136
     137/** First UDP message. */
     138#define NET_UDP_FIRST  (NET_TL_LAST + 0)
     139
     140/** Last UDP message. */
     141#define NET_UDP_LAST  (NET_UDP_FIRST + NET_UDP_COUNT)
     142
     143/** First TCP message. */
     144#define NET_TCP_FIRST  (NET_UDP_LAST + 0)
     145
     146/** Last TCP message. */
     147#define NET_TCP_LAST  (NET_TCP_FIRST + NET_TCP_COUNT)
     148
     149/** First socket message. */
     150#define NET_SOCKET_FIRST  (NET_TCP_LAST + 0)
     151
     152/** Last socket message. */
     153#define NET_SOCKET_LAST  (NET_SOCKET_FIRST + NET_SOCKET_COUNT)
     154
     155/** First packet management system message. */
     156#define NET_PACKET_FIRST  (NET_SOCKET_LAST + 0)
     157
     158/** Last packet management system message. */
     159#define NET_PACKET_LAST  (NET_PACKET_FIRST + NET_PACKET_COUNT)
     160
     161/** Last networking message. */
     162#define NET_LAST  NET_PACKET_LAST
     163
     164/** Number of networking messages. */
     165#define NET_COUNT  (NET_LAST - NET_FIRST)
     166
     167/** Check if the IPC call is a generic networking message.
     168 *
     169 * @param[in] call IPC call to be checked.
     170 *
    192171 */
    193172#define IS_NET_MESSAGE(call) \
    194         IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_FIRST, NET_LAST)
    195 
    196 /** Returns a value indicating whether the IPC call is an ARP message.
    197  * @param[in] call The IPC call to be checked.
     173        IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_FIRST, NET_LAST)
     174
     175/** Check if the IPC call is an ARP message.
     176 *
     177 * @param[in] call IPC call to be checked.
     178 *
    198179 */
    199180#define IS_NET_ARP_MESSAGE(call) \
    200         IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ARP_FIRST, NET_ARP_LAST)
    201 
    202 /** Returns a value indicating whether the IPC call is an Ethernet message.
    203  * @param[in] call The IPC call to be checked.
     181        IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ARP_FIRST, NET_ARP_LAST)
     182
     183/** Check if the IPC call is an Ethernet message.
     184 *
     185 * @param[in] call IPC call to be checked.
     186 *
    204187 */
    205188#define IS_NET_ETH_MESSAGE(call) \
    206         IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ETH_FIRST, NET_ETH_LAST)
    207 
    208 /** Returns a value indicating whether the IPC call is an ICMP message.
    209  * @param[in] call The IPC call to be checked.
     189        IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ETH_FIRST, NET_ETH_LAST)
     190
     191/** Check if the IPC call is an ICMP message.
     192 *
     193 * @param[in] call IPC call to be checked.
     194 *
    210195 */
    211196#define IS_NET_ICMP_MESSAGE(call) \
    212         IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ICMP_FIRST, NET_ICMP_LAST)
    213 
    214 /** Returns a value indicating whether the IPC call is an inter-network layer
    215  * message.
    216  * @param[in] call The IPC call to be checked.
     197        IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ICMP_FIRST, NET_ICMP_LAST)
     198
     199/** Check if the IPC call is an inter-network layer message.
     200 *
     201 * @param[in] call IPC call to be checked.
     202 *
    217203 */
    218204#define IS_NET_IL_MESSAGE(call) \
    219         IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_IL_FIRST, NET_IL_LAST)
    220 
    221 /** Returns a value indicating whether the IPC call is an IP message.
    222  * @param[in] call The IPC call to be checked.
     205        IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_IL_FIRST, NET_IL_LAST)
     206
     207/** Check if the IPC call is an IP message.
     208 *
     209 * @param[in] call IPC call to be checked.
     210 *
    223211 */
    224212#define IS_NET_IP_MESSAGE(call) \
    225         IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_IP_FIRST, NET_IP_LAST)
    226 
    227 /** Returns a value indicating whether the IPC call is a generic networking
    228  * message.
    229  * @param[in] call The IPC call to be checked.
     213        IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_IP_FIRST, NET_IP_LAST)
     214
     215/** Check if the IPC call is a generic networking message.
     216 *
     217 * @param[in] call IPC call to be checked.
     218 *
    230219 */
    231220#define IS_NET_NET_MESSAGE(call) \
    232         IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_NET_FIRST, NET_NET_LAST)
    233 
    234 /** Returns a value indicating whether the IPC call is a network interface layer
    235  * message.
    236  * @param[in] call The IPC call to be checked.
     221        IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_NET_FIRST, NET_NET_LAST)
     222
     223/** Check if the IPC call is a network interface layer message.
     224 *
     225 * @param[in] call IPC call to be checked.
     226 *
    237227 */
    238228#define IS_NET_NIL_MESSAGE(call) \
    239         IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_NIL_FIRST, NET_NIL_LAST)
    240 
    241 /** Returns a value indicating whether the IPC call is a packet manaagement
    242  * system message.
    243  * @param[in] call The IPC call to be checked.
     229        IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_NIL_FIRST, NET_NIL_LAST)
     230
     231/** Check if the IPC call is a packet manaagement system message.
     232 *
     233 * @param[in] call IPC call to be checked.
     234 *
    244235 */
    245236#define IS_NET_PACKET_MESSAGE(call) \
    246         IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_PACKET_FIRST, NET_PACKET_LAST)
    247 
    248 /** Returns a value indicating whether the IPC call is a socket message.
    249  * @param[in] call The IPC call to be checked.
     237        IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_PACKET_FIRST, NET_PACKET_LAST)
     238
     239/** Check if the IPC call is a socket message.
     240 *
     241 * @param[in] call IPC call to be checked.
     242 *
    250243 */
    251244#define IS_NET_SOCKET_MESSAGE(call) \
    252         IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_SOCKET_FIRST, NET_SOCKET_LAST)
    253 
    254 /** Returns a value indicating whether the IPC call is a TCP message.
    255  * @param[in] call The IPC call to be checked.
     245        IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_SOCKET_FIRST, NET_SOCKET_LAST)
     246
     247/** Check if the IPC call is a TCP message.
     248 *
     249 * @param[in] call IPC call to be checked.
     250 *
    256251 */
    257252#define IS_NET_TCP_MESSAGE(call) \
    258         IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_TCP_FIRST, NET_TCP_LAST)
    259 
    260 /** Returns a value indicating whether the IPC call is a transport layer message.
    261  * @param[in] call The IPC call to be checked.
     253        IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_TCP_FIRST, NET_TCP_LAST)
     254
     255/** Check if the IPC call is a transport layer message.
     256 *
     257 * @param[in] call IPC call to be checked.
     258 *
    262259 */
    263260#define IS_NET_TL_MESSAGE(call) \
    264         IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_TL_FIRST, NET_TL_LAST)
    265 
    266 /** Returns a value indicating whether the IPC call is a UDP message.
    267  * @param[in] call The IPC call to be checked.
     261        IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_TL_FIRST, NET_TL_LAST)
     262
     263/** Check if the IPC call is a UDP message.
     264 *
     265 * @param[in] call IPC call to be checked.
     266 *
    268267 */
    269268#define IS_NET_UDP_MESSAGE(call) \
    270         IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_UDP_FIRST, NET_UDP_LAST)
     269        IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_UDP_FIRST, NET_UDP_LAST)
    271270
    272271/*@}*/
     
    275274/*@{*/
    276275
    277 /** Returns the device identifier message argument.
    278  * @param[in] call The message call structure.
    279  */
    280 #define IPC_GET_DEVICE(call) \
    281         ({ \
    282                 device_id_t device_id = (device_id_t) IPC_GET_ARG1(*call); \
    283                 device_id; \
    284         })
    285 
    286 /** Returns the packet identifier message argument.
    287  * @param[in] call The message call structure.
    288  */
    289 #define IPC_GET_PACKET(call) \
    290         ({ \
    291                 packet_id_t packet_id = (packet_id_t) IPC_GET_ARG2(*call); \
    292                 packet_id; \
    293         })
    294 
    295 /** Returns the count message argument.
    296  * @param[in] call The message call structure.
    297  */
    298 #define IPC_GET_COUNT(call) \
    299         ({ \
    300                 size_t size = (size_t) IPC_GET_ARG2(*call); \
    301                 size; \
    302         })
    303 
    304 /** Returns the device state message argument.
    305  * @param[in] call The message call structure.
    306  */
    307 #define IPC_GET_STATE(call) \
    308         ({ \
    309                 device_state_t state = (device_state_t) IPC_GET_ARG2(*call); \
    310                 state; \
    311         })
    312 
    313 /** Returns the maximum transmission unit message argument.
    314  * @param[in] call The message call structure.
    315  */
    316 #define IPC_GET_MTU(call) \
    317         ({ \
    318                 size_t size = (size_t) IPC_GET_ARG2(*call); \
    319                 size; \
    320         })
    321 
    322 /** Returns the device driver service message argument.
    323  * @param[in] call The message call structure.
    324  */
    325 #define IPC_GET_SERVICE(call) \
    326         ({ \
    327                 services_t service = (services_t) IPC_GET_ARG3(*call); \
    328                 service; \
    329         })
    330 
    331 /** Returns the target service message argument.
    332  * @param[in] call The message call structure.
    333  */
    334 #define IPC_GET_TARGET(call) \
    335         ({ \
    336                 services_t service = (services_t) IPC_GET_ARG3(*call); \
    337                 service; \
    338         })
    339 
    340 /** Returns the sender service message argument.
    341  * @param[in] call The message call structure.
    342  */
    343 #define IPC_GET_SENDER(call) \
    344         ({ \
    345                 services_t service = (services_t) IPC_GET_ARG3(*call); \
    346                 service; \
    347         })
    348 
    349 /** Returns the error service message argument.
    350  * @param[in] call The message call structure.
    351  */
    352 #define IPC_GET_ERROR(call) \
    353         ({ \
    354                 services_t service = (services_t) IPC_GET_ARG4(*call); \
    355                 service; \
    356         })
    357 
    358 /** Returns the phone message argument.
    359  * @param[in] call The message call structure.
    360  */
    361 #define IPC_GET_PHONE(call) \
    362         ({ \
    363                 int phone = (int) IPC_GET_ARG5(*call); \
    364                 phone; \
    365         })
    366 
    367 /** Sets the device identifier in the message answer.
    368  * @param[out] answer The message answer structure.
    369  */
    370 #define IPC_SET_DEVICE(answer, value) \
    371         do { \
    372                 sysarg_t argument = (sysarg_t) (value); \
    373                 IPC_SET_ARG1(*answer, argument); \
    374         } while (0)
    375 
    376 /** Sets the minimum address length in the message answer.
    377  * @param[out] answer The message answer structure.
    378  */
    379 #define IPC_SET_ADDR(answer, value) \
    380         do { \
    381                 sysarg_t argument = (sysarg_t) (value); \
    382                 IPC_SET_ARG1(*answer, argument); \
    383         } while (0)
    384 
    385 /** Sets the minimum prefix size in the message answer.
    386  * @param[out] answer The message answer structure.
    387  */
    388 #define IPC_SET_PREFIX(answer, value) \
    389         do { \
    390                 sysarg_t argument = (sysarg_t) (value); \
    391                 IPC_SET_ARG2(*answer, argument); \
    392         } while (0)
    393 
    394 /** Sets the maximum content size in the message answer.
    395  * @param[out] answer The message answer structure.
    396  */
    397 #define IPC_SET_CONTENT(answer, value) \
    398         do { \
    399                 sysarg_t argument = (sysarg_t) (value); \
    400                 IPC_SET_ARG3(*answer, argument); \
    401         } while (0)
    402 
    403 /** Sets the minimum suffix size in the message answer.
    404  * @param[out] answer The message answer structure.
    405  */
    406 #define IPC_SET_SUFFIX(answer, value) \
    407         do { \
    408                 sysarg_t argument = (sysarg_t) (value); \
    409                 IPC_SET_ARG4(*answer, argument); \
    410         } while (0)
     276/** Return the device identifier message argument.
     277 *
     278 * @param[in] call Message call structure.
     279 *
     280 */
     281#define IPC_GET_DEVICE(call)  ((device_id_t) IPC_GET_ARG1(call))
     282
     283/** Return the packet identifier message argument.
     284 *
     285 * @param[in] call Message call structure.
     286 *
     287 */
     288#define IPC_GET_PACKET(call)  ((packet_id_t) IPC_GET_ARG2(call))
     289
     290/** Return the count message argument.
     291 *
     292 * @param[in] call Message call structure.
     293 *
     294 */
     295#define IPC_GET_COUNT(call)  ((size_t) IPC_GET_ARG2(call))
     296
     297/** Return the device state message argument.
     298 *
     299 * @param[in] call Message call structure.
     300 *
     301 */
     302#define IPC_GET_STATE(call)  ((device_state_t) IPC_GET_ARG2(call))
     303
     304/** Return the maximum transmission unit message argument.
     305 *
     306 * @param[in] call Message call structure.
     307 *
     308 */
     309#define IPC_GET_MTU(call)  ((size_t) IPC_GET_ARG2(call))
     310
     311/** Return the device driver service message argument.
     312 *
     313 * @param[in] call Message call structure.
     314 *
     315 */
     316#define IPC_GET_SERVICE(call)  ((services_t) IPC_GET_ARG3(call))
     317
     318/** Return the target service message argument.
     319 *
     320 * @param[in] call Message call structure.
     321 *
     322 */
     323#define IPC_GET_TARGET(call)  ((services_t) IPC_GET_ARG3(call))
     324
     325/** Return the sender service message argument.
     326 *
     327 * @param[in] call Message call structure.
     328 *
     329 */
     330#define IPC_GET_SENDER(call)  ((services_t) IPC_GET_ARG3(call))
     331
     332/** Return the error service message argument.
     333 &
     334 * @param[in] call Message call structure.
     335 *
     336 */
     337#define IPC_GET_ERROR(call)  ((services_t) IPC_GET_ARG4(call))
     338
     339/** Return the phone message argument.
     340 *
     341 * @param[in] call Message call structure.
     342 *
     343 */
     344#define IPC_GET_PHONE(call)  ((int) IPC_GET_ARG5(call))
     345
     346/** Set the device identifier in the message answer.
     347 *
     348 * @param[out] answer Message answer structure.
     349 * @param[in]  value  Value to set.
     350 *
     351 */
     352#define IPC_SET_DEVICE(answer, value)  IPC_SET_ARG1(answer, (sysarg_t) (value))
     353
     354/** Set the minimum address length in the message answer.
     355 *
     356 * @param[out] answer Message answer structure.
     357 * @param[in]  value  Value to set.
     358 *
     359 */
     360#define IPC_SET_ADDR(answer, value)  IPC_SET_ARG1(answer, (sysarg_t) (value))
     361
     362/** Set the minimum prefix size in the message answer.
     363 *
     364 * @param[out] answer Message answer structure.
     365 * @param[in]  value  Value to set.
     366 *
     367 */
     368#define IPC_SET_PREFIX(answer, value)  IPC_SET_ARG2(answer, (sysarg_t) (value))
     369
     370/** Set the maximum content size in the message answer.
     371 *
     372 * @param[out] answer Message answer structure.
     373 * @param[in]  value  Value to set.
     374 *
     375 */
     376#define IPC_SET_CONTENT(answer, value)  IPC_SET_ARG3(answer, (sysarg_t) (value))
     377
     378/** Set the minimum suffix size in the message answer.
     379 *
     380 * @param[out] answer Message answer structure.
     381 * @param[in]  value  Value to set.
     382 *
     383 */
     384#define IPC_SET_SUFFIX(answer, value)  IPC_SET_ARG4(answer, (sysarg_t) (value))
    411385
    412386/*@}*/
  • uspace/lib/c/include/ipc/netif.h

    r863d45e r1ffa73b  
    4747         */
    4848        NET_NETIF_PROBE = NET_NETIF_FIRST,
     49       
    4950        /** Send packet message.
    5051         * @see netif_send_msg()
    5152         */
    5253        NET_NETIF_SEND,
     54       
    5355        /** Start device message.
    5456         * @see netif_start_req()
    5557         */
    5658        NET_NETIF_START,
     59       
    5760        /** Get device usage statistics message.
    5861         * @see netif_stats_req()
    5962         */
    6063        NET_NETIF_STATS,
     64       
    6165        /** Stop device message.
    6266         * @see netif_stop_req()
    6367         */
    6468        NET_NETIF_STOP,
     69       
    6570        /** Get device address message.
    6671         * @see netif_get_addr_req()
     
    7378
    7479/** Return the interrupt number message parameter.
    75  * @param[in] call The message call structure.
     80 *
     81 * @param[in] call Mmessage call structure.
     82 *
    7683 */
    77 #define NETIF_GET_IRQ(call) \
    78         ({ \
    79                 int irq = (int) IPC_GET_ARG2(*call); \
    80                 irq; \
    81         })
     84#define NETIF_GET_IRQ(call) ((int) IPC_GET_ARG2(call))
    8285
    8386/** Return the input/output address message parameter.
    84  * @param[in] call The message call structure.
     87 *
     88 * @param[in] call Message call structure.
     89 *
    8590 */
    86 #define NETIF_GET_IO(call) \
    87         ({ \
    88                 int io = (int) IPC_GET_ARG3(*call); \
    89                 io; \
    90         })
     91#define NETIF_GET_IO(call) ((void *) IPC_GET_ARG3(call))
    9192
    9293/*@}*/
  • uspace/lib/c/include/ipc/nil.h

    r863d45e r1ffa73b  
    7777
    7878/** Return the protocol service message parameter. */
    79 #define NIL_GET_PROTO(call) \
    80         ({ \
    81                 services_t service = (services_t) IPC_GET_ARG2(*call); \
    82                 service; \
    83         })
     79#define NIL_GET_PROTO(call)  ((services_t) IPC_GET_ARG2(call))
    8480
    8581/*@}*/
  • uspace/lib/c/include/ipc/packet.h

    r863d45e r1ffa73b  
    7070} packet_messages;
    7171
    72 /** Returns the protocol service message parameter. */
    73 #define ARP_GET_PROTO(call)     (services_t) IPC_GET_ARG2(*call)
     72/** Return the protocol service message parameter. */
     73#define ARP_GET_PROTO(call)  ((services_t) IPC_GET_ARG2(call))
    7474
    75 /** Returns the packet identifier message parameter. */
    76 #define IPC_GET_ID(call)        (packet_id_t) IPC_GET_ARG1(*call)
     75/** Return the packet identifier message parameter. */
     76#define IPC_GET_ID(call)  ((packet_id_t) IPC_GET_ARG1(call))
    7777
    78 /** Returns the maximal content length message parameter. */
    79 #define IPC_GET_CONTENT(call)   (size_t) IPC_GET_ARG1(*call)
     78/** Return the maximal content length message parameter. */
     79#define IPC_GET_CONTENT(call)  ((size_t) IPC_GET_ARG1(call))
    8080
    81 /** Returns the maximal address length message parameter. */
    82 #define IPC_GET_ADDR_LEN(call)  (size_t) IPC_GET_ARG2(*call)
     81/** Return the maximal address length message parameter. */
     82#define IPC_GET_ADDR_LEN(call)  ((size_t) IPC_GET_ARG2(call))
    8383
    84 /** Returns the maximal prefix length message parameter. */
    85 #define IPC_GET_PREFIX(call)    (size_t) IPC_GET_ARG3(*call)
     84/** Return the maximal prefix length message parameter. */
     85#define IPC_GET_PREFIX(call)  ((size_t) IPC_GET_ARG3(call))
    8686
    87 /** Returns the maximal suffix length message parameter. */
    88 #define IPC_GET_SUFFIX(call)    (size_t) IPC_GET_ARG4(*call)
     87/** Return the maximal suffix length message parameter. */
     88#define IPC_GET_SUFFIX(call)  ((size_t) IPC_GET_ARG4(call))
    8989
    9090#endif
  • uspace/lib/c/include/ipc/services.h

    r863d45e r1ffa73b  
    4949        SERVICE_FHC,
    5050        SERVICE_OBIO,
     51        SERVICE_APIC,
     52        SERVICE_I8259,
    5153        SERVICE_CLIPBOARD,
    5254        SERVICE_NETWORKING,
  • uspace/lib/c/include/mem.h

    r863d45e r1ffa73b  
    4444extern void *memmove(void *, const void *, size_t);
    4545
    46 extern int bcmp(const char *, const char *, size_t);
     46extern int bcmp(const void *, const void *, size_t);
    4747
    4848#endif
  • uspace/lib/c/include/net/in.h

    r863d45e r1ffa73b  
    4343
    4444/** INET string address maximum length. */
    45 #define INET_ADDRSTRLEN         (4 * 3 + 3 + 1)
     45#define INET_ADDRSTRLEN  (4 * 3 + 3 + 1)
    4646
    4747/** Type definition of the INET address.
    4848 * @see in_addr
    4949 */
    50 typedef struct in_addr          in_addr_t;
     50typedef struct in_addr in_addr_t;
    5151
    5252/** Type definition of the INET socket address.
  • uspace/lib/c/include/net/modules.h

    r863d45e r1ffa73b  
    5151/** Connect to the needed module function type definition.
    5252 *
    53  * @param[in] need      The needed module service.
    54  * @return              The phone of the needed service.
     53 * @param[in] need The needed module service.
     54 *
     55 * @return The phone of the needed service.
     56 *
    5557 */
    5658typedef int connect_module_t(services_t need);
    5759
    58 extern void answer_call(ipc_callid_t, int, ipc_call_t *, int);
     60extern void answer_call(ipc_callid_t, int, ipc_call_t *, size_t);
    5961extern int bind_service(services_t, sysarg_t, sysarg_t, sysarg_t,
    6062    async_client_conn_t);
     
    6466extern int connect_to_service_timeout(services_t, suseconds_t);
    6567extern int data_reply(void *, size_t);
    66 extern void refresh_answer(ipc_call_t *, int *);
     68extern void refresh_answer(ipc_call_t *, size_t *);
    6769
    6870#endif
  • uspace/lib/c/include/stdlib.h

    r863d45e r1ffa73b  
    4646        } while (0)
    4747
     48#define core() \
     49        *((int *) 0) = 0xbadbad;
     50
    4851#define exit(status)  _exit((status))
    4952
  • uspace/lib/drv/Makefile

    r863d45e r1ffa73b  
    3535        generic/driver.c \
    3636        generic/dev_iface.c \
    37         generic/remote_res.c \
     37        generic/remote_char_dev.c \
     38        generic/remote_hw_res.c \
    3839        generic/remote_usb.c \
    39         generic/remote_usbhc.c \
    40         generic/remote_char.c
     40        generic/remote_usbhc.c
    4141
    4242include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/drv/generic/dev_iface.c

    r863d45e r1ffa73b  
    3636 */
    3737
     38#include <assert.h>
     39
    3840#include "dev_iface.h"
    39 #include "remote_res.h"
    40 #include "remote_char.h"
     41#include "remote_hw_res.h"
     42#include "remote_char_dev.h"
    4143#include "remote_usb.h"
    4244#include "remote_usbhc.h"
     
    4446static iface_dipatch_table_t remote_ifaces = {
    4547        .ifaces = {
    46                 &remote_res_iface,
    47                 &remote_char_iface,
     48                &remote_hw_res_iface,
     49                &remote_char_dev_iface,
    4850                &remote_usb_iface,
    4951                &remote_usbhc_iface
     
    5153};
    5254
    53 remote_iface_t* get_remote_iface(int idx)
    54 {       
     55remote_iface_t *get_remote_iface(int idx)
     56{
    5557        assert(is_valid_iface_idx(idx));
    5658        return remote_ifaces.ifaces[idx];
     
    6365                return NULL;
    6466        }
     67
    6568        return rem_iface->methods[iface_method_idx];
     69}
     70
     71bool is_valid_iface_idx(int idx)
     72{
     73        return (0 <= idx) && (idx < DEV_IFACE_MAX);
    6674}
    6775
  • uspace/lib/drv/generic/driver.c

    r863d45e r1ffa73b  
    5252#include <ipc/driver.h>
    5353
     54#include "dev_iface.h"
    5455#include "driver.h"
    5556
    56 /* driver structure */
    57 
     57/** Driver structure */
    5858static driver_t *driver;
    5959
    60 /* devices */
    61 
     60/** Devices */
    6261LIST_INITIALIZE(devices);
    6362FIBRIL_MUTEX_INITIALIZE(devices_mutex);
    6463
    65 /* interrupts */
    66 
     64/** Interrupts */
    6765static interrupt_context_list_t interrupt_contexts;
    6866
     
    8583       
    8684        ctx = find_interrupt_context_by_id(&interrupt_contexts, id);
    87         if (NULL != ctx && NULL != ctx->handler)
     85        if (ctx != NULL && ctx->handler != NULL)
    8886                (*ctx->handler)(ctx->dev, iid, icall);
    8987}
     88
     89interrupt_context_t *create_interrupt_context(void)
     90{
     91        interrupt_context_t *ctx;
     92       
     93        ctx = (interrupt_context_t *) malloc(sizeof(interrupt_context_t));
     94        if (ctx != NULL)
     95                memset(ctx, 0, sizeof(interrupt_context_t));
     96       
     97        return ctx;
     98}
     99
     100void delete_interrupt_context(interrupt_context_t *ctx)
     101{
     102        if (ctx != NULL)
     103                free(ctx);
     104}
     105
     106void init_interrupt_context_list(interrupt_context_list_t *list)
     107{
     108        memset(list, 0, sizeof(interrupt_context_list_t));
     109        fibril_mutex_initialize(&list->mutex);
     110        list_initialize(&list->contexts);
     111}
     112
     113void
     114add_interrupt_context(interrupt_context_list_t *list, interrupt_context_t *ctx)
     115{
     116        fibril_mutex_lock(&list->mutex);
     117        ctx->id = list->curr_id++;
     118        list_append(&ctx->link, &list->contexts);
     119        fibril_mutex_unlock(&list->mutex);
     120}
     121
     122void remove_interrupt_context(interrupt_context_list_t *list,
     123    interrupt_context_t *ctx)
     124{
     125        fibril_mutex_lock(&list->mutex);
     126        list_remove(&ctx->link);
     127        fibril_mutex_unlock(&list->mutex);
     128}
     129
     130interrupt_context_t *
     131find_interrupt_context_by_id(interrupt_context_list_t *list, int id)
     132{
     133        fibril_mutex_lock(&list->mutex);
     134       
     135        link_t *link = list->contexts.next;
     136        interrupt_context_t *ctx;
     137       
     138        while (link != &list->contexts) {
     139                ctx = list_get_instance(link, interrupt_context_t, link);
     140                if (ctx->id == id) {
     141                        fibril_mutex_unlock(&list->mutex);
     142                        return ctx;
     143                }
     144                link = link->next;
     145        }
     146       
     147        fibril_mutex_unlock(&list->mutex);
     148        return NULL;
     149}
     150
     151interrupt_context_t *
     152find_interrupt_context(interrupt_context_list_t *list, device_t *dev, int irq)
     153{
     154        fibril_mutex_lock(&list->mutex);
     155       
     156        link_t *link = list->contexts.next;
     157        interrupt_context_t *ctx;
     158       
     159        while (link != &list->contexts) {
     160                ctx = list_get_instance(link, interrupt_context_t, link);
     161                if (ctx->irq == irq && ctx->dev == dev) {
     162                        fibril_mutex_unlock(&list->mutex);
     163                        return ctx;
     164                }
     165                link = link->next;
     166        }
     167       
     168        fibril_mutex_unlock(&list->mutex);
     169        return NULL;
     170}
     171
    90172
    91173int
     
    101183        add_interrupt_context(&interrupt_contexts, ctx);
    102184       
    103         if (NULL == pseudocode)
     185        if (pseudocode == NULL)
    104186                pseudocode = &default_pseudocode;
    105187       
    106188        int res = ipc_register_irq(irq, dev->handle, ctx->id, pseudocode);
    107         if (0 != res) {
     189        if (res != EOK) {
    108190                remove_interrupt_context(&interrupt_contexts, ctx);
    109191                delete_interrupt_context(ctx);
     
    118200            dev, irq);
    119201        int res = ipc_unregister_irq(irq, dev->handle);
    120 
    121         if (NULL != ctx) {
     202       
     203        if (ctx != NULL) {
    122204                remove_interrupt_context(&interrupt_contexts, ctx);
    123205                delete_interrupt_context(ctx);
    124206        }
     207       
    125208        return res;
    126209}
     
    140223}
    141224
    142 static device_t * driver_get_device(link_t *devices, devman_handle_t handle)
     225static device_t *driver_get_device(link_t *devices, devman_handle_t handle)
    143226{
    144227        device_t *dev = NULL;
     
    146229        fibril_mutex_lock(&devices_mutex);
    147230        link_t *link = devices->next;
     231       
    148232        while (link != devices) {
    149233                dev = list_get_instance(link, device_t, link);
    150                 if (handle == dev->handle) {
     234                if (dev->handle == handle) {
    151235                        fibril_mutex_unlock(&devices_mutex);
    152236                        return dev;
     
    154238                link = link->next;
    155239        }
     240       
    156241        fibril_mutex_unlock(&devices_mutex);
    157 
     242       
    158243        return NULL;
    159244}
     
    162247{
    163248        char *dev_name = NULL;
    164         int res = EOK;
    165        
    166         devman_handle_t dev_handle =  IPC_GET_ARG1(*icall);
     249        int res;
     250       
     251        devman_handle_t dev_handle = IPC_GET_ARG1(*icall);
    167252        devman_handle_t parent_dev_handle = IPC_GET_ARG2(*icall);
    168    
     253       
    169254        device_t *dev = create_device();
    170255        dev->handle = dev_handle;
     
    177262       
    178263        res = driver->driver_ops->add_device(dev);
    179         if (0 == res) {
     264        if (res == EOK) {
    180265                printf("%s: new device with handle=%" PRIun " was added.\n",
    181266                    driver->name, dev_handle);
     
    194279        /* Accept connection */
    195280        ipc_answer_0(iid, EOK);
    196 
     281       
    197282        bool cont = true;
    198283        while (cont) {
    199284                ipc_call_t call;
    200285                ipc_callid_t callid = async_get_call(&call);
    201 
     286               
    202287                switch (IPC_GET_IMETHOD(call)) {
    203288                case IPC_M_PHONE_HUNGUP:
     
    240325         * use the device.
    241326         */
    242 
     327       
    243328        int ret = EOK;
    244329        /* open the device */
    245         if (NULL != dev->ops && NULL != dev->ops->open)
     330        if (dev->ops != NULL && dev->ops->open != NULL)
    246331                ret = (*dev->ops->open)(dev);
    247332       
    248         ipc_answer_0(iid, ret); 
    249         if (EOK != ret)
     333        ipc_answer_0(iid, ret);
     334        if (ret != EOK)
    250335                return;
    251 
     336       
    252337        while (1) {
    253338                ipc_callid_t callid;
     
    258343               
    259344                switch  (method) {
    260                 case IPC_M_PHONE_HUNGUP:               
     345                case IPC_M_PHONE_HUNGUP:
    261346                        /* close the device */
    262                         if (NULL != dev->ops && NULL != dev->ops->close)
     347                        if (dev->ops != NULL && dev->ops->close != NULL)
    263348                                (*dev->ops->close)(dev);
    264349                        ipc_answer_0(callid, EOK);
    265350                        return;
    266                 default:               
     351                default:
    267352                        /* convert ipc interface id to interface index */
    268353                       
     
    272357                                remote_handler_t *default_handler =
    273358                                    device_get_default_handler(dev);
    274                                 if (NULL != default_handler) {
     359                                if (default_handler != NULL) {
    275360                                        (*default_handler)(dev, callid, &call);
    276361                                        break;
     
    286371                                break;
    287372                        }
    288 
     373                       
    289374                        /* calling one of the device's interfaces */
    290375                       
    291                         /* get the device interface structure */
    292                         void *iface = device_get_iface(dev, iface_idx);
    293                         if (NULL == iface) {
     376                        /* Get the interface ops structure. */
     377                        void *ops = device_get_ops(dev, iface_idx);
     378                        if (ops == NULL) {
    294379                                printf("%s: driver_connection_gen error - ",
    295380                                    driver->name);
     
    299384                                break;
    300385                        }
    301 
     386                       
    302387                        /*
    303388                         * Get the corresponding interface for remote request
    304389                         * handling ("remote interface").
    305390                         */
    306                         remote_iface_t* rem_iface = get_remote_iface(iface_idx);
    307                         assert(NULL != rem_iface);
    308 
     391                        remote_iface_t *rem_iface = get_remote_iface(iface_idx);
     392                        assert(rem_iface != NULL);
     393                       
    309394                        /* get the method of the remote interface */
    310395                        sysarg_t iface_method_idx = IPC_GET_ARG1(call);
    311396                        remote_iface_func_ptr_t iface_method_ptr =
    312397                            get_remote_method(rem_iface, iface_method_idx);
    313                         if (NULL == iface_method_ptr) {
     398                        if (iface_method_ptr == NULL) {
    314399                                // the interface has not such method
    315400                                printf("%s: driver_connection_gen error - "
     
    325410                         * associated with the device by its driver.
    326411                         */
    327                         (*iface_method_ptr)(dev, iface, callid, &call);
     412                        (*iface_method_ptr)(dev, ops, callid, &call);
    328413                        break;
    329414                }
     
    348433        switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
    349434        case DRIVER_DEVMAN:
    350                 /* handle PnP events from device manager */
     435                /* Handle request from device manager */
    351436                driver_connection_devman(iid, icall);
    352437                break;
    353438        case DRIVER_DRIVER:
    354                 /* handle request from drivers of child devices */
     439                /* Handle request from drivers of child devices */
    355440                driver_connection_driver(iid, icall);
    356441                break;
    357442        case DRIVER_CLIENT:
    358                 /* handle requests from client applications */
     443                /* Handle request from client applications */
    359444                driver_connection_client(iid, icall);
    360445                break;
    361 
    362446        default:
    363447                /* No such interface */
     
    366450}
    367451
     452/** Create new device structure.
     453 *
     454 * @return              The device structure.
     455 */
     456device_t *create_device(void)
     457{
     458        device_t *dev = malloc(sizeof(device_t));
     459
     460        if (dev != NULL) {
     461                memset(dev, 0, sizeof(device_t));
     462                init_match_ids(&dev->match_ids);
     463        }
     464
     465        return dev;
     466}
     467
     468/** Delete device structure.
     469 *
     470 * @param dev           The device structure.
     471 */
     472void delete_device(device_t *dev)
     473{
     474        clean_match_ids(&dev->match_ids);
     475        if (dev->name != NULL)
     476                free(dev->name);
     477        free(dev);
     478}
     479
     480void *device_get_ops(device_t *dev, dev_inferface_idx_t idx)
     481{
     482        assert(is_valid_iface_idx(idx));
     483        if (dev->ops == NULL)
     484                return NULL;
     485        return dev->ops->interfaces[idx];
     486}
     487
    368488int child_device_register(device_t *child, device_t *parent)
    369489{
    370         assert(NULL != child->name);
    371 
     490        assert(child->name != NULL);
     491       
    372492        int res;
    373493       
     
    375495        res = devman_child_device_register(child->name, &child->match_ids,
    376496            parent->handle, &child->handle);
    377         if (EOK == res)
     497        if (res != EOK) {
     498                remove_from_devices_list(child);
    378499                return res;
    379         remove_from_devices_list(child);       
     500        }
     501       
    380502        return res;
    381503}
     
    396518        match_id_t *match_id = NULL;
    397519        int rc;
    398 
     520       
    399521        child = create_device();
    400522        if (child == NULL) {
     
    402524                goto failure;
    403525        }
    404 
     526       
    405527        child->name = child_name;
    406 
     528       
    407529        match_id = create_match_id();
    408530        if (match_id == NULL) {
     
    410532                goto failure;
    411533        }
    412 
     534       
    413535        match_id->id = child_match_id;
    414536        match_id->score = child_match_score;
    415537        add_match_id(&child->match_ids, match_id);
    416 
     538       
    417539        rc = child_device_register(child, parent);
    418         if (EOK != rc)
     540        if (rc != EOK)
    419541                goto failure;
    420542
     
    422544                *child_handle = child->handle;
    423545        }
     546
    424547        return EOK;
    425 
     548       
    426549failure:
    427550        if (match_id != NULL) {
     
    429552                delete_match_id(match_id);
    430553        }
    431 
     554       
    432555        if (child != NULL) {
    433556                child->name = NULL;
    434557                delete_device(child);
    435558        }
    436 
     559       
    437560        return rc;
     561}
     562
     563/** Get default handler for client requests */
     564remote_handler_t *device_get_default_handler(device_t *dev)
     565{
     566        if (dev->ops == NULL)
     567                return NULL;
     568        return dev->ops->default_handler;
     569}
     570
     571int add_device_to_class(device_t *dev, const char *class_name)
     572{
     573        return devman_add_device_to_class(dev->handle, class_name);
    438574}
    439575
     
    445581         */
    446582        driver = drv;
    447 
     583       
    448584        /* Initialize the list of interrupt contexts. */
    449585        init_interrupt_context_list(&interrupt_contexts);
     
    457593         */
    458594        devman_driver_register(driver->name, driver_connection);
    459 
     595       
    460596        async_manager();
    461 
     597       
    462598        /* Never reached. */
    463599        return 0;
  • uspace/lib/drv/generic/remote_char_dev.c

    r863d45e r1ffa73b  
    3737#include <errno.h>
    3838
    39 #include "char.h"
     39#include "ops/char_dev.h"
    4040#include "driver.h"
    4141
     
    4646
    4747/** Remote character interface operations. */
    48 static remote_iface_func_ptr_t remote_char_iface_ops [] = {
     48static remote_iface_func_ptr_t remote_char_dev_iface_ops[] = {
    4949        &remote_char_read,
    5050        &remote_char_write
     
    5656 * character interface.
    5757 */
    58 remote_iface_t remote_char_iface = {
    59         .method_count = sizeof(remote_char_iface_ops) /
     58remote_iface_t remote_char_dev_iface = {
     59        .method_count = sizeof(remote_char_dev_iface_ops) /
    6060            sizeof(remote_iface_func_ptr_t),
    61         .methods = remote_char_iface_ops
     61        .methods = remote_char_dev_iface_ops
    6262};
    6363
     
    6969 *
    7070 * @param dev           The device from which the data are read.
    71  * @param iface         The local interface structure.
     71 * @param ops           The local ops structure.
    7272 */
    7373static void
    74 remote_char_read(device_t *dev, void *iface, ipc_callid_t callid,
     74remote_char_read(device_t *dev, void *ops, ipc_callid_t callid,
    7575    ipc_call_t *call)
    76 {       
    77         char_iface_t *char_iface = (char_iface_t *) iface;
     76{
     77        char_dev_ops_t *char_dev_ops = (char_dev_ops_t *) ops;
    7878        ipc_callid_t cid;
    7979       
     
    8585        }
    8686       
    87         if (!char_iface->read) {
     87        if (!char_dev_ops->read) {
    8888                async_data_read_finalize(cid, NULL, 0);
    8989                ipc_answer_0(callid, ENOTSUP);
     
    9595       
    9696        char buf[MAX_CHAR_RW_COUNT];
    97         int ret = (*char_iface->read)(dev, buf, len);
     97        int ret = (*char_dev_ops->read)(dev, buf, len);
    9898       
    9999        if (ret < 0) {
     
    116116 *
    117117 * @param dev           The device to which the data are written.
    118  * @param iface         The local interface structure.
     118 * @param ops           The local ops structure.
    119119 */
    120120static void
    121 remote_char_write(device_t *dev, void *iface, ipc_callid_t callid,
     121remote_char_write(device_t *dev, void *ops, ipc_callid_t callid,
    122122    ipc_call_t *call)
    123123{
    124         char_iface_t *char_iface = (char_iface_t *) iface;
     124        char_dev_ops_t *char_dev_ops = (char_dev_ops_t *) ops;
    125125        ipc_callid_t cid;
    126126        size_t len;
     
    132132        }
    133133       
    134         if (!char_iface->write) {
     134        if (!char_dev_ops->write) {
    135135                async_data_write_finalize(cid, NULL, 0);
    136136                ipc_answer_0(callid, ENOTSUP);
    137137                return;
    138         }       
     138        }
    139139       
    140140        if (len > MAX_CHAR_RW_COUNT)
     
    145145        async_data_write_finalize(cid, buf, len);
    146146       
    147         int ret = (*char_iface->write)(dev, buf, len);
     147        int ret = (*char_dev_ops->write)(dev, buf, len);
    148148        if (ret < 0) {
    149149                /* Some error occured. */
  • uspace/lib/drv/generic/remote_hw_res.c

    r863d45e r1ffa73b  
    3737#include <errno.h>
    3838
     39#include "ops/hw_res.h"
    3940#include "driver.h"
    40 #include "resource.h"
    4141
    42 static void remote_res_get_resources(device_t *, void *, ipc_callid_t,
     42static void remote_hw_res_get_resource_list(device_t *, void *, ipc_callid_t,
    4343    ipc_call_t *);
    44 static void remote_res_enable_interrupt(device_t *, void *, ipc_callid_t,
     44static void remote_hw_res_enable_interrupt(device_t *, void *, ipc_callid_t,
    4545    ipc_call_t *);
    4646
    47 static remote_iface_func_ptr_t remote_res_iface_ops [] = {
    48         &remote_res_get_resources,
    49         &remote_res_enable_interrupt
     47static remote_iface_func_ptr_t remote_hw_res_iface_ops [] = {
     48        &remote_hw_res_get_resource_list,
     49        &remote_hw_res_enable_interrupt
    5050};
    5151
    52 remote_iface_t remote_res_iface = {
    53         .method_count = sizeof(remote_res_iface_ops) /
     52remote_iface_t remote_hw_res_iface = {
     53        .method_count = sizeof(remote_hw_res_iface_ops) /
    5454            sizeof(remote_iface_func_ptr_t),
    55         .methods = remote_res_iface_ops
     55        .methods = remote_hw_res_iface_ops
    5656};
    5757
    58 static void remote_res_enable_interrupt(device_t *dev, void *iface,
     58static void remote_hw_res_enable_interrupt(device_t *dev, void *ops,
    5959    ipc_callid_t callid, ipc_call_t *call)
    6060{
    61         resource_iface_t *ires = (resource_iface_t *) iface;
     61        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
    6262       
    63         if (NULL == ires->enable_interrupt)
     63        if (hw_res_ops->enable_interrupt == NULL)
    6464                ipc_answer_0(callid, ENOTSUP);
    65         else if (ires->enable_interrupt(dev))
     65        else if (hw_res_ops->enable_interrupt(dev))
    6666                ipc_answer_0(callid, EOK);
    6767        else
     
    6969}
    7070
    71 static void remote_res_get_resources(device_t *dev, void *iface,
     71static void remote_hw_res_get_resource_list(device_t *dev, void *ops,
    7272    ipc_callid_t callid, ipc_call_t *call)
    7373{
    74         resource_iface_t *ires = (resource_iface_t *) iface;
    75         if (NULL == ires->get_resources) {
     74        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
     75
     76        if (hw_res_ops->get_resource_list == NULL) {
    7677                ipc_answer_0(callid, ENOTSUP);
    7778                return;
    7879        }
    7980       
    80         hw_resource_list_t *hw_resources = ires->get_resources(dev);
    81         if (NULL == hw_resources){
     81        hw_resource_list_t *hw_resources = hw_res_ops->get_resource_list(dev);
     82        if (hw_resources == NULL){
    8283                ipc_answer_0(callid, ENOENT);
    8384                return;
    84         }       
     85        }
    8586       
    86         ipc_answer_1(callid, EOK, hw_resources->count); 
     87        ipc_answer_1(callid, EOK, hw_resources->count);
    8788
    8889        size_t len;
    8990        if (!async_data_read_receive(&callid, &len)) {
    90                 /* protocol error - the recipient is not accepting data */
     91                /* Protocol error - the recipient is not accepting data */
    9192                return;
    9293        }
  • uspace/lib/drv/include/dev_iface.h

    r863d45e r1ffa73b  
    3636#define LIBDRV_DEV_IFACE_H_
    3737
    38 #include "driver.h"
     38#include <ipc/dev_iface.h>
    3939
    40 /* TODO declare device interface structures here */
     40/*
     41 * Device interface
     42 */
     43
     44struct device;
     45
     46/*
     47 * First two parameters: device and interface structure registered by the
     48 * devices driver.
     49 */
     50typedef void remote_iface_func_t(struct device *, void *, ipc_callid_t,
     51    ipc_call_t *);
     52typedef remote_iface_func_t *remote_iface_func_ptr_t;
     53typedef void remote_handler_t(struct device *, ipc_callid_t, ipc_call_t *);
     54
     55typedef struct {
     56        size_t method_count;
     57        remote_iface_func_ptr_t *methods;
     58} remote_iface_t;
     59
     60typedef struct {
     61        remote_iface_t *ifaces[DEV_IFACE_COUNT];
     62} iface_dipatch_table_t;
     63
     64extern remote_iface_t *get_remote_iface(int);
     65extern remote_iface_func_ptr_t get_remote_method(remote_iface_t *, sysarg_t);
     66
     67
     68extern bool is_valid_iface_idx(int);
    4169
    4270#endif
  • uspace/lib/drv/include/driver.h

    r863d45e r1ffa73b  
    4141#include <ipc/devman.h>
    4242#include <ipc/dev_iface.h>
    43 #include <device/hw_res.h>
    44 #include <device/char.h>
    4543#include <assert.h>
    4644#include <ddi.h>
     
    4947#include <malloc.h>
    5048
     49#include "dev_iface.h"
     50
    5151struct device;
    5252typedef struct device device_t;
    5353
    54 /* device interface */
     54/*
     55 * Device class
     56 */
    5557
    56 /*
    57  * First two parameters: device and interface structure registered by the
    58  * devices driver.
    59  */
    60 typedef void remote_iface_func_t(device_t *, void *, ipc_callid_t,
    61     ipc_call_t *);
    62 typedef remote_iface_func_t *remote_iface_func_ptr_t;
    63 typedef void remote_handler_t(device_t *, ipc_callid_t, ipc_call_t *);
    64 
    65 typedef struct {
    66         size_t method_count;
    67         remote_iface_func_ptr_t *methods;
    68 } remote_iface_t;
    69 
    70 typedef struct {
    71         remote_iface_t *ifaces[DEV_IFACE_COUNT];
    72 } iface_dipatch_table_t;
    73 
    74 
    75 static inline bool is_valid_iface_idx(int idx)
    76 {
    77         return 0 <= idx && idx < DEV_IFACE_MAX;
    78 }
    79 
    80 remote_iface_t *get_remote_iface(int);
    81 remote_iface_func_ptr_t get_remote_method(remote_iface_t *, sysarg_t);
    82 
    83 
    84 /* device class */
    85 
    86 /** Devices operations. */
     58/** Devices operations */
    8759typedef struct device_ops {
    8860        /**
     
    11082
    11183
    112 /* device */
     84/*
     85 * Device
     86 */
    11387
    114 /** The device. */
     88/** Device structure */
    11589struct device {
    11690        /**
     
    12195       
    12296        /**
    123          * The phone to the parent device driver (if it is different from this
    124          * driver).
     97         * Phone to the parent device driver (if it is different from this
     98         * driver)
    12599         */
    126100        int parent_phone;
    127101       
    128         /** Parent device if handled by this driver, NULL otherwise. */
     102        /** Parent device if handled by this driver, NULL otherwise */
    129103        device_t *parent;
    130         /** The device's name. */
     104        /** Device name */
    131105        const char *name;
    132         /** The list of device ids for device-to-driver matching. */
     106        /** List of device ids for device-to-driver matching */
    133107        match_id_list_t match_ids;
    134         /** The device driver's data associated with this device. */
     108        /** Driver-specific data associated with this device */
    135109        void *driver_data;
    136         /** The implementation of operations provided by this device. */
     110        /** The implementation of operations provided by this device */
    137111        device_ops_t *ops;
    138112       
    139         /**
    140          * Pointer to the previous and next device in the list of devices
    141          * handled by the driver.
    142          */
     113        /** Link in the list of devices handled by the driver */
    143114        link_t link;
    144115};
    145116
     117/*
     118 * Driver
     119 */
    146120
    147 /* driver */
    148 
    149 /** Generic device driver operations. */
     121/** Generic device driver operations */
    150122typedef struct driver_ops {
    151         /** Callback method for passing a new device to the device driver.*/
     123        /** Callback method for passing a new device to the device driver */
    152124        int (*add_device)(device_t *dev);
    153         /* TODO add other generic driver operations */
     125        /* TODO: add other generic driver operations */
    154126} driver_ops_t;
    155127
    156 /** The driver structure.*/
     128/** Driver structure */
    157129typedef struct driver {
    158         /** The name of the device driver. */
     130        /** Name of the device driver */
    159131        const char *name;
    160         /** Generic device driver operations. */
     132        /** Generic device driver operations */
    161133        driver_ops_t *driver_ops;
    162134} driver_t;
     
    168140 * @return              The device structure.
    169141 */
    170 static inline device_t *create_device(void)
    171 {
    172         device_t *dev = malloc(sizeof(device_t));
    173         if (NULL != dev) {
    174                 memset(dev, 0, sizeof(device_t));
    175                 init_match_ids(&dev->match_ids);
    176         }       
    177         return dev;
    178 }
     142extern device_t *create_device(void);
     143extern void delete_device(device_t *);
     144extern void *device_get_ops(device_t *, dev_inferface_idx_t);
    179145
    180 /** Delete device structure.
    181  *
    182  * @param dev           The device structure.
     146extern int child_device_register(device_t *, device_t *);
     147extern int child_device_register_wrapper(device_t *, const char *, const char *,
     148    int, devman_handle_t *);
     149
     150/*
     151 * Interrupts
    183152 */
    184 static inline void delete_device(device_t *dev)
    185 {
    186         clean_match_ids(&dev->match_ids);
    187         if (NULL != dev->name)
    188                 free(dev->name);
    189         free(dev);
    190 }
    191 
    192 static inline void *device_get_iface(device_t *dev, dev_inferface_idx_t idx)
    193 {
    194         assert(is_valid_iface_idx(idx));
    195         if (NULL == dev->ops)
    196                 return NULL;
    197         return dev->ops->interfaces[idx];
    198 }
    199 
    200 int child_device_register(device_t *, device_t *);
    201 int child_device_register_wrapper(device_t *, const char *, const char *, int,
    202     devman_handle_t *);
    203 
    204 
    205 /* interrupts */
    206153
    207154typedef void interrupt_handler_t(device_t *, ipc_callid_t, ipc_call_t *);
     
    221168} interrupt_context_list_t;
    222169
    223 static inline interrupt_context_t *create_interrupt_context(void)
    224 {
    225         interrupt_context_t *ctx;
    226        
    227         ctx = (interrupt_context_t *) malloc(sizeof(interrupt_context_t));
    228         if (NULL != ctx)
    229                 memset(ctx, 0, sizeof(interrupt_context_t));
    230        
    231         return ctx;
    232 }
     170extern interrupt_context_t *create_interrupt_context(void);
     171extern void delete_interrupt_context(interrupt_context_t *);
     172extern void init_interrupt_context_list(interrupt_context_list_t *);
     173extern void add_interrupt_context(interrupt_context_list_t *,
     174    interrupt_context_t *);
     175extern void remove_interrupt_context(interrupt_context_list_t *,
     176    interrupt_context_t *);
     177extern interrupt_context_t *find_interrupt_context_by_id(
     178    interrupt_context_list_t *, int);
     179extern interrupt_context_t *find_interrupt_context(
     180    interrupt_context_list_t *, device_t *, int);
    233181
    234 static inline void delete_interrupt_context(interrupt_context_t *ctx)
    235 {
    236         if (NULL != ctx)
    237                 free(ctx);
    238 }
     182extern int register_interrupt_handler(device_t *, int, interrupt_handler_t *,
     183    irq_code_t *);
     184extern int unregister_interrupt_handler(device_t *, int);
    239185
    240 static inline void init_interrupt_context_list(interrupt_context_list_t *list)
    241 {
    242         memset(list, 0, sizeof(interrupt_context_list_t));
    243         fibril_mutex_initialize(&list->mutex);
    244         list_initialize(&list->contexts);
    245 }
    246 
    247 static inline void
    248 add_interrupt_context(interrupt_context_list_t *list, interrupt_context_t *ctx)
    249 {
    250         fibril_mutex_lock(&list->mutex);
    251         ctx->id = list->curr_id++;
    252         list_append(&ctx->link, &list->contexts);
    253         fibril_mutex_unlock(&list->mutex);
    254 }
    255 
    256 static inline void
    257 remove_interrupt_context(interrupt_context_list_t *list,
    258     interrupt_context_t *ctx)
    259 {
    260         fibril_mutex_lock(&list->mutex);
    261         list_remove(&ctx->link);
    262         fibril_mutex_unlock(&list->mutex);
    263 }
    264 
    265 static inline interrupt_context_t *
    266 find_interrupt_context_by_id(interrupt_context_list_t *list, int id)
    267 {
    268         fibril_mutex_lock(&list->mutex);
    269        
    270         link_t *link = list->contexts.next;
    271         interrupt_context_t *ctx;
    272        
    273         while (link != &list->contexts) {
    274                 ctx = list_get_instance(link, interrupt_context_t, link);
    275                 if (id == ctx->id) {
    276                         fibril_mutex_unlock(&list->mutex);
    277                         return ctx;
    278                 }
    279                 link = link->next;
    280         }
    281        
    282         fibril_mutex_unlock(&list->mutex);
    283         return NULL;
    284 }
    285 
    286 static inline interrupt_context_t *
    287 find_interrupt_context(interrupt_context_list_t *list, device_t *dev, int irq)
    288 {
    289         fibril_mutex_lock(&list->mutex);
    290        
    291         link_t *link = list->contexts.next;
    292         interrupt_context_t *ctx;
    293        
    294         while (link != &list->contexts) {
    295                 ctx = list_get_instance(link, interrupt_context_t, link);
    296                 if (irq == ctx->irq && dev == ctx->dev) {
    297                         fibril_mutex_unlock(&list->mutex);
    298                         return ctx;
    299                 }
    300                 link = link->next;
    301         }
    302        
    303         fibril_mutex_unlock(&list->mutex);
    304         return NULL;
    305 }
    306 
    307 int register_interrupt_handler(device_t *, int, interrupt_handler_t *,
    308     irq_code_t *);
    309 int unregister_interrupt_handler(device_t *, int);
    310 
    311 
    312 /* default handler for client requests */
    313 
    314 static inline remote_handler_t *device_get_default_handler(device_t *dev)
    315 {
    316         if (NULL == dev->ops)
    317                 return NULL;
    318         return dev->ops->default_handler;
    319 }
    320 
    321 static inline int add_device_to_class(device_t *dev, const char *class_name)
    322 {
    323         return devman_add_device_to_class(dev->handle, class_name);
    324 }
     186extern remote_handler_t *device_get_default_handler(device_t *);
     187extern int add_device_to_class(device_t *, const char *);
    325188
    326189#endif
  • uspace/lib/drv/include/ops/char_dev.h

    r863d45e r1ffa73b  
    3333 */
    3434
    35 #ifndef LIBDRV_CHAR_H_
    36 #define LIBDRV_CHAR_H_
     35#ifndef LIBDRV_OPS_CHAR_DEV_H_
     36#define LIBDRV_OPS_CHAR_DEV_H_
    3737
    38 #include "driver.h"
     38#include "../driver.h"
    3939
    40 typedef struct char_iface {
     40typedef struct {
    4141        int (*read)(device_t *, char *, size_t);
    4242        int (*write)(device_t *, char *, size_t);
    43 } char_iface_t;
     43} char_dev_ops_t;
    4444
    4545#endif
  • uspace/lib/drv/include/ops/hw_res.h

    r863d45e r1ffa73b  
    3333 */
    3434
    35 #ifndef LIBDRV_RESOURCE_H_
    36 #define LIBDRV_RESOURCE_H_
     35#ifndef LIBDRV_OPS_HW_RES_H_
     36#define LIBDRV_OPS_HW_RES_H_
    3737
    38 #include "driver.h"
     38#include <device/hw_res.h>
     39#include <sys/types.h>
    3940
    40 typedef struct resource_iface {
    41          hw_resource_list_t *(* get_resources)(device_t *);
     41#include "../driver.h"
     42
     43typedef struct {
     44         hw_resource_list_t *(*get_resource_list)(device_t *);
    4245         bool (*enable_interrupt)(device_t *);
    43 } resource_iface_t;
    44 
     46} hw_res_ops_t;
    4547
    4648#endif
  • uspace/lib/drv/include/remote_char_dev.h

    r863d45e r1ffa73b  
    3333 */
    3434
    35 #ifndef LIBDRV_REMOTE_RES_H_
    36 #define LIBDRV_REMOTE_RES_H_
     35#ifndef LIBDRV_REMOTE_CHAR_DEV_H_
     36#define LIBDRV_REMOTE_CHAR_DEV_H_
    3737
    38 remote_iface_t remote_res_iface;
     38extern remote_iface_t remote_char_dev_iface;
    3939
    4040#endif
  • uspace/lib/drv/include/remote_hw_res.h

    r863d45e r1ffa73b  
    3333 */
    3434
    35 #ifndef LIBDRV_REMOTE_CHAR_H_
    36 #define LIBDRV_REMOTE_CHAR_H_
     35#ifndef LIBDRV_REMOTE_HW_RES_H_
     36#define LIBDRV_REMOTE_HW_RES_H_
    3737
    38 remote_iface_t remote_char_iface;
     38extern remote_iface_t remote_hw_res_iface;
    3939
    4040#endif
  • uspace/lib/net/Makefile

    r863d45e r1ffa73b  
    4040        generic/protocol_map.c \
    4141        adt/module_map.c \
    42         netif/netif_local.c \
    4342        netif/netif_remote.c \
     43        netif/netif_skel.c \
    4444        nil/nil_remote.c \
    4545        il/il_interface.c \
  • uspace/lib/net/adt/module_map.c

    r863d45e r1ffa73b  
    6363 */
    6464int
    65 add_module(module_t **module, modules_t *modules, const char *name,
    66     const char *filename, services_t service, task_id_t task_id,
     65add_module(module_t **module, modules_t *modules, const uint8_t *name,
     66    const uint8_t *filename, services_t service, task_id_t task_id,
    6767    connect_module_t connect_module)
    6868{
     
    104104 * @return              NULL if there is no such module.
    105105 */
    106 module_t *get_running_module(modules_t *modules, char *name)
     106module_t *get_running_module(modules_t *modules, uint8_t *name)
    107107{
    108108        module_t *module;
     
    113113
    114114        if (!module->task_id) {
    115                 module->task_id = spawn(module->filename);
     115                module->task_id = net_spawn(module->filename);
    116116                if (!module->task_id)
    117117                        return NULL;
     
    123123}
    124124
    125 /** Starts the given module.
     125/** Start the given module.
    126126 *
    127  * @param[in] fname     The module full or relative path filename.
    128  * @return              The new module task identifier on success.
    129  * @return              Zero if there is no such module.
     127 * @param[in] fname The module full or relative path filename.
     128 *
     129 * @return The new module task identifier on success.
     130 * @return Zero if there is no such module.
     131 *
    130132 */
    131 task_id_t spawn(const char *fname)
     133task_id_t net_spawn(const uint8_t *fname)
    132134{
    133135        task_id_t id;
    134136        int rc;
    135137       
    136         rc = task_spawnl(&id, fname, fname, NULL);
     138        rc = task_spawnl(&id, (const char *) fname, (const char *) fname, NULL);
    137139        if (rc != EOK)
    138140                return 0;
  • uspace/lib/net/generic/generic.c

    r863d45e r1ffa73b  
    100100int
    101101generic_get_addr_req(int phone, int message, device_id_t device_id,
    102     measured_string_t **address, char ** data)
     102    measured_string_t **address, uint8_t **data)
    103103{
    104104        aid_t message_id;
     
    234234generic_translate_req(int phone, int message, device_id_t device_id,
    235235    services_t service, measured_string_t *configuration, size_t count,
    236     measured_string_t **translation, char **data)
     236    measured_string_t **translation, uint8_t **data)
    237237{
    238238        aid_t message_id;
  • uspace/lib/net/generic/net_remote.c

    r863d45e r1ffa73b  
    6363 * @see net_get_conf_req()
    6464 */
    65 void net_free_settings(measured_string_t *settings, char *data)
     65void net_free_settings(measured_string_t *settings, uint8_t *data)
    6666{
    6767        if (settings)
     
    9191int
    9292net_get_conf_req(int net_phone, measured_string_t **configuration,
    93     size_t count, char **data)
     93    size_t count, uint8_t **data)
    9494{
    9595        return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 0, 0,
     
    118118int
    119119net_get_device_conf_req(int net_phone, device_id_t device_id,
    120     measured_string_t **configuration, size_t count, char **data)
     120    measured_string_t **configuration, size_t count, uint8_t **data)
    121121{
    122122        return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF,
  • uspace/lib/net/il/arp_remote.c

    r863d45e r1ffa73b  
    165165int
    166166arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol,
    167     measured_string_t *address, measured_string_t **translation, char **data)
     167    measured_string_t *address, measured_string_t **translation, uint8_t **data)
    168168{
    169169        return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id,
  • uspace/lib/net/il/ip_remote.c

    r863d45e r1ffa73b  
    170170                free(*header);
    171171        else
    172                 *device_id = IPC_GET_DEVICE(&answer);
     172                *device_id = IPC_GET_DEVICE(answer);
    173173       
    174174        return (int) result;
  • uspace/lib/net/include/adt/module_map.h

    r863d45e r1ffa73b  
    6565        int usage;
    6666        /** Module name. */
    67         const char *name;
     67        const uint8_t *name;
    6868        /** Module full path filename. */
    69         const char *filename;
     69        const uint8_t *filename;
    7070        /** Connecting function. */
    7171        connect_module_t *connect_module;
    7272};
    7373
    74 extern int add_module(module_t **, modules_t *, const char *, const char *,
    75     services_t, task_id_t, connect_module_t *);
    76 extern module_t *get_running_module(modules_t *, char *);
    77 extern task_id_t spawn(const char *);
     74extern int add_module(module_t **, modules_t *, const uint8_t *,
     75    const uint8_t *, services_t, task_id_t, connect_module_t *);
     76extern module_t *get_running_module(modules_t *, uint8_t *);
     77extern task_id_t net_spawn(const uint8_t *);
    7878
    7979#endif
  • uspace/lib/net/include/arp_interface.h

    r863d45e r1ffa73b  
    5050    measured_string_t *);
    5151extern int arp_translate_req(int, device_id_t, services_t, measured_string_t *,
    52     measured_string_t **, char **);
     52    measured_string_t **, uint8_t **);
    5353extern int arp_clear_device_req(int, device_id_t);
    5454extern int arp_clear_address_req(int, device_id_t, services_t,
  • uspace/lib/net/include/generic.h

    r863d45e r1ffa73b  
    5050extern int generic_device_req_remote(int, int, device_id_t, int, services_t);
    5151extern int generic_get_addr_req(int, int, device_id_t, measured_string_t **,
    52     char **);
     52    uint8_t **);
    5353extern int generic_packet_size_req_remote(int, int, device_id_t,
    5454    packet_dimension_t *);
     
    5858    services_t, services_t);
    5959extern int generic_translate_req(int, int, device_id_t, services_t,
    60     measured_string_t *, size_t, measured_string_t **, char **);
     60    measured_string_t *, size_t, measured_string_t **, uint8_t **);
    6161
    6262#endif
  • uspace/lib/net/include/il_local.h

    r863d45e r1ffa73b  
    4949 */
    5050extern int il_module_message_standalone(ipc_callid_t callid, ipc_call_t *call,
    51     ipc_call_t *answer, int *answer_count);
     51    ipc_call_t *answer, size_t *answer_count);
    5252
    5353/** Starts the Internet layer module.
  • uspace/lib/net/include/net_interface.h

    r863d45e r1ffa73b  
    4545
    4646extern int net_get_device_conf_req(int, device_id_t, measured_string_t **,
    47     size_t, char **);
    48 extern int net_get_conf_req(int, measured_string_t **, size_t, char **);
    49 extern void net_free_settings(measured_string_t *, char *);
     47    size_t, uint8_t **);
     48extern int net_get_conf_req(int, measured_string_t **, size_t, uint8_t **);
     49extern void net_free_settings(measured_string_t *, uint8_t *);
    5050extern int net_connect_module(void);
    5151
  • uspace/lib/net/include/netif_remote.h

    r863d45e r1ffa73b  
    4141#include <net/packet.h>
    4242
    43 extern int netif_get_addr_req_remote(int, device_id_t, measured_string_t **,
    44     char **);
    45 extern int netif_probe_req_remote(int, device_id_t, int, int);
    46 extern int netif_send_msg_remote(int, device_id_t, packet_t *, services_t);
    47 extern int netif_start_req_remote(int, device_id_t);
    48 extern int netif_stop_req_remote(int, device_id_t);
    49 extern int netif_stats_req_remote(int, device_id_t, device_stats_t *);
    50 extern int netif_bind_service_remote(services_t, device_id_t, services_t,
     43extern int netif_get_addr_req(int, device_id_t, measured_string_t **,
     44    uint8_t **);
     45extern int netif_probe_req(int, device_id_t, int, void *);
     46extern int netif_send_msg(int, device_id_t, packet_t *, services_t);
     47extern int netif_start_req(int, device_id_t);
     48extern int netif_stop_req(int, device_id_t);
     49extern int netif_stats_req(int, device_id_t, device_stats_t *);
     50extern int netif_bind_service(services_t, device_id_t, services_t,
    5151    async_client_conn_t);
    5252
  • uspace/lib/net/include/netif_skel.h

    r863d45e r1ffa73b  
    3636 */
    3737
    38 #ifndef NET_NETIF_LOCAL_H_
    39 #define NET_NETIF_LOCAL_H_
     38#ifndef NET_NETIF_SKEL_H_
     39#define NET_NETIF_SKEL_H_
    4040
    4141#include <async.h>
     
    7676 *
    7777 * This function has to be implemented in user code.
     78 *
    7879 */
    7980extern int netif_initialize(void);
     
    8384 * This has to be implemented in user code.
    8485 *
    85  * @param[in] device_id The device identifier.
    86  * @param[in] irq       The device interrupt number.
    87  * @param[in] io        The device input/output address.
    88  *
    89  * @return              EOK on success.
    90  * @return              Other error codes as defined for the find_device()
    91  *                      function.
    92  * @return              Other error codes as defined for the specific module
    93  *                      message implementation.
    94  */
    95 extern int netif_probe_message(device_id_t device_id, int irq, uintptr_t io);
     86 * @param[in] device_id Device identifier.
     87 * @param[in] irq       Device interrupt number.
     88 * @param[in] io        Device input/output address.
     89 *
     90 * @return EOK on success.
     91 * @return Other error codes as defined for the find_device()
     92 *         function.
     93 * @return Other error codes as defined for the specific module
     94 *         message implementation.
     95 *
     96 */
     97extern int netif_probe_message(device_id_t device_id, int irq, void *io);
    9698
    9799/** Send the packet queue.
     
    99101 * This has to be implemented in user code.
    100102 *
    101  * @param[in] device_id The device identifier.
    102  * @param[in] packet    The packet queue.
    103  * @param[in] sender    The sending module service.
    104  *
    105  * @return              EOK on success.
    106  * @return              EFORWARD if the device is not active (in the
    107  *                      NETIF_ACTIVE state).
    108  * @return              Other error codes as defined for the find_device()
    109  *                      function.
    110  * @return              Other error codes as defined for the specific module
    111  *                      message implementation.
     103 * @param[in] device_id Device identifier.
     104 * @param[in] packet    Packet queue.
     105 * @param[in] sender    Sending module service.
     106 *
     107 * @return EOK on success.
     108 * @return EFORWARD if the device is not active (in the
     109 *         NETIF_ACTIVE state).
     110 * @return Other error codes as defined for the find_device()
     111 *         function.
     112 * @return Other error codes as defined for the specific module
     113 *         message implementation.
     114 *
    112115 */
    113116extern int netif_send_message(device_id_t device_id, packet_t *packet,
     
    118121 * This has to be implemented in user code.
    119122 *
    120  * @param[in] device    The device structure.
    121  *
    122  * @return              EOK on success.
    123  * @return              Other error codes as defined for the find_device()
    124  *                      function.
    125  * @return              Other error codes as defined for the specific module
    126  *                      message implementation.
     123 * @param[in] device Device structure.
     124 *
     125 * @return New network interface state (non-negative values).
     126 * @return Other error codes as defined for the find_device()
     127 *         function.
     128 * @return Other error codes as defined for the specific module
     129 *         message implementation.
     130 
     131 *
    127132 */
    128133extern int netif_start_message(netif_device_t *device);
     
    132137 * This has to be implemented in user code.
    133138 *
    134  * @param[in] device    The device structure.
    135  *
    136  * @return              EOK on success.
    137  * @return              Other error codes as defined for the find_device()
    138  *                      function.
    139  * @return              Other error codes as defined for the specific module
    140  *                      message implementation.
     139 * @param[in] device Device structure.
     140 *
     141 * @return EOK on success.
     142 * @return Other error codes as defined for the find_device()
     143 *         function.
     144 * @return Other error codes as defined for the specific module
     145 *         message implementation.
     146 *
    141147 */
    142148extern int netif_stop_message(netif_device_t *device);
     
    146152 * This has to be implemented in user code.
    147153 *
    148  * @param[in] device_id The device identifier.
    149  * @param[out] address  The device local hardware address.
    150  *
    151  * @return              EOK on success.
    152  * @return              EBADMEM if the address parameter is NULL.
    153  * @return              ENOENT if there no such device.
    154  * @return              Other error codes as defined for the find_device()
    155  *                      function.
    156  * @return              Other error codes as defined for the specific module
    157  *                      message implementation.
     154 * @param[in] device_id Device identifier.
     155 * @param[out] address  Device local hardware address.
     156 *
     157 * @return EOK on success.
     158 * @return EBADMEM if the address parameter is NULL.
     159 * @return ENOENT if there no such device.
     160 * @return Other error codes as defined for the find_device()
     161 *         function.
     162 * @return Other error codes as defined for the specific module
     163 *         message implementation.
     164 *
    158165 */
    159166extern int netif_get_addr_message(device_id_t device_id,
     
    165172 * skeleton. This has to be implemented in user code.
    166173 *
    167  * @param[in] callid    The message identifier.
    168  * @param[in] call      The message parameters.
    169  * @param[out] answer   The message answer parameters.
    170  * @param[out] answer_count The last parameter for the actual answer in
    171  *                      the answer parameter.
    172  *
    173  * @return              EOK on success.
    174  * @return              ENOTSUP if the message is not known.
    175  * @return              Other error codes as defined for the specific module
    176  *                      message implementation.
     174 * @param[in]  callid Message identifier.
     175 * @param[in]  call   Message.
     176 * @param[out] answer Answer.
     177 * @param[out] count  Number of answer arguments.
     178 *
     179 * @return EOK on success.
     180 * @return ENOTSUP if the message is not known.
     181 * @return Other error codes as defined for the specific module
     182 *         message implementation.
     183 *
    177184 */
    178185extern int netif_specific_message(ipc_callid_t callid, ipc_call_t *call,
    179     ipc_call_t *answer, int *answer_count);
     186    ipc_call_t *answer, size_t *count);
    180187
    181188/** Return the device usage statistics.
     
    183190 * This has to be implemented in user code.
    184191 *
    185  * @param[in] device_id The device identifier.
    186  * @param[out] stats    The device usage statistics.
    187  *
    188  * @return              EOK on success.
    189  * @return              Other error codes as defined for the find_device()
    190  *                      function.
    191  * @return              Other error codes as defined for the specific module
    192  *                      message implementation.
     192 * @param[in]  device_id Device identifier.
     193 * @param[out] stats     Device usage statistics.
     194 *
     195 * @return EOK on success.
     196 * @return Other error codes as defined for the find_device()
     197 *         function.
     198 * @return Other error codes as defined for the specific module
     199 *         message implementation.
     200 *
    193201 */
    194202extern int netif_get_device_stats(device_id_t device_id,
    195203    device_stats_t *stats);
    196 
    197 extern int netif_get_addr_req_local(int, device_id_t, measured_string_t **,
    198     char **);
    199 extern int netif_probe_req_local(int, device_id_t, int, int);
    200 extern int netif_send_msg_local(int, device_id_t, packet_t *, services_t);
    201 extern int netif_start_req_local(int, device_id_t);
    202 extern int netif_stop_req_local(int, device_id_t);
    203 extern int netif_stats_req_local(int, device_id_t, device_stats_t *);
    204 extern int netif_bind_service_local(services_t, device_id_t, services_t,
    205     async_client_conn_t);
    206204
    207205extern int find_device(device_id_t, netif_device_t **);
     
    209207extern void netif_pq_release(packet_id_t);
    210208extern packet_t *netif_packet_get_1(size_t);
    211 extern int netif_init_module(async_client_conn_t);
    212 
    213 extern int netif_module_message_standalone(const char *, ipc_callid_t,
    214     ipc_call_t *, ipc_call_t *, int *);
    215 extern int netif_module_start_standalone(async_client_conn_t);
     209
     210extern int netif_module_start(void);
    216211
    217212#endif
  • uspace/lib/net/include/nil_local.h

    r863d45e r1ffa73b  
    9696 */
    9797extern int nil_message_standalone(const char *, ipc_callid_t, ipc_call_t *,
    98     ipc_call_t *, int *);
     98    ipc_call_t *, size_t *);
    9999
    100100/** Pass the parameters to the module specific nil_message() function.
     
    112112 */
    113113extern int nil_module_message_standalone(const char *, ipc_callid_t,
    114     ipc_call_t *, ipc_call_t *, int *);
     114    ipc_call_t *, ipc_call_t *, size_t *);
    115115
    116116/** Start the standalone nil layer module.
  • uspace/lib/net/include/socket_core.h

    r863d45e r1ffa73b  
    8686        void *specific_data;
    8787        /** Socket ports map key. */
    88         const char *key;
     88        const uint8_t *key;
    8989        /** Length of the Socket ports map key. */
    9090        size_t key_length;
     
    118118    void (*)(socket_core_t *));
    119119extern int socket_reply_packets(packet_t *, size_t *);
    120 extern socket_core_t *socket_port_find(socket_ports_t *, int, const char *,
     120extern socket_core_t *socket_port_find(socket_ports_t *, int, const uint8_t *,
    121121    size_t);
    122122extern void socket_port_release(socket_ports_t *, socket_core_t *);
    123123extern int socket_port_add(socket_ports_t *, int, socket_core_t *,
    124     const char *, size_t);
     124    const uint8_t *, size_t);
    125125
    126126#endif
  • uspace/lib/net/include/tl_local.h

    r863d45e r1ffa73b  
    5252 */
    5353extern int tl_module_message_standalone(ipc_callid_t, ipc_call_t *,
    54     ipc_call_t *, int *);
    55 
     54    ipc_call_t *, size_t *);
    5655
    5756/** Processes the TL module message.
  • uspace/lib/net/netif/netif_remote.c

    r863d45e r1ffa73b  
    2727 */
    2828
    29 /** @addtogroup libnet 
     29/** @addtogroup libnet
    3030 * @{
    3131 */
     
    4949/** Return the device local hardware address.
    5050 *
    51  * @param[in] netif_phone The network interface phone.
    52  * @param[in] device_id The device identifier.
    53  * @param[out] address  The device local hardware address.
    54  * @param[out] data     The address data.
    55  * @return              EOK on success.
    56  * @return              EBADMEM if the address parameter is NULL.
    57  * @return              ENOENT if there no such device.
    58  * @return              Other error codes as defined for the
    59  *                      netif_get_addr_message() function.
     51 * @param[in]  netif_phone Network interface phone.
     52 * @param[in]  device_id   Device identifier.
     53 * @param[out] address     Device local hardware address.
     54 * @param[out] data        Address data.
     55 *
     56 * @return EOK on success.
     57 * @return EBADMEM if the address parameter is NULL.
     58 * @return ENOENT if there no such device.
     59 * @return Other error codes as defined for the
     60 *         netif_get_addr_message() function.
     61 *
    6062 */
    61 int netif_get_addr_req_remote(int netif_phone, device_id_t device_id,
    62     measured_string_t **address, char **data)
     63int netif_get_addr_req(int netif_phone, device_id_t device_id,
     64    measured_string_t **address, uint8_t **data)
    6365{
    6466        return generic_get_addr_req(netif_phone, NET_NETIF_GET_ADDR, device_id,
     
    6870/** Probe the existence of the device.
    6971 *
    70  * @param[in] netif_phone The network interface phone.
    71  * @param[in] device_id The device identifier.
    72  * @param[in] irq       The device interrupt number.
    73  * @param[in] io        The device input/output address.
    74  * @return              EOK on success.
    75  * @return              Other error codes as defined for the
    76  *                      netif_probe_message().
     72 * @param[in] netif_phone Network interface phone.
     73 * @param[in] device_id   Device identifier.
     74 * @param[in] irq         Device interrupt number.
     75 * @param[in] io          Device input/output address.
     76 *
     77 * @return EOK on success.
     78 * @return Other error codes as defined for the
     79 *         netif_probe_message().
     80 *
    7781 */
    78 int
    79 netif_probe_req_remote(int netif_phone, device_id_t device_id, int irq, int io)
     82int netif_probe_req(int netif_phone, device_id_t device_id, int irq, void *io)
    8083{
    81         return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, io);
     84        return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq,
     85            (sysarg_t) io);
    8286}
    8387
    8488/** Send the packet queue.
    8589 *
    86  * @param[in] netif_phone The network interface phone.
    87  * @param[in] device_id The device identifier.
    88  * @param[in] packet    The packet queue.
    89  * @param[in] sender    The sending module service.
    90  * @return              EOK on success.
    91  * @return              Other error codes as defined for the generic_send_msg()
    92  *                      function.
     90 * @param[in] netif_phone Network interface phone.
     91 * @param[in] device_id   Device identifier.
     92 * @param[in] packet      Packet queue.
     93 * @param[in] sender      Sending module service.
     94 *
     95 * @return EOK on success.
     96 * @return Other error codes as defined for the generic_send_msg()
     97 *         function.
     98 *
    9399 */
    94 int
    95 netif_send_msg_remote(int netif_phone, device_id_t device_id, packet_t *packet,
     100int netif_send_msg(int netif_phone, device_id_t device_id, packet_t *packet,
    96101    services_t sender)
    97102{
     
    102107/** Start the device.
    103108 *
    104  * @param[in] netif_phone The network interface phone.
    105  * @param[in] device_id The device identifier.
    106  * @return              EOK on success.
    107  * @return              Other error codes as defined for the find_device()
    108  *                      function.
    109  * @return              Other error codes as defined for the
    110  *                      netif_start_message() function.
     109 * @param[in] netif_phone Network interface phone.
     110 * @param[in] device_id   Device identifier.
     111 *
     112 * @return EOK on success.
     113 * @return Other error codes as defined for the find_device()
     114 *         function.
     115 * @return Other error codes as defined for the
     116 *         netif_start_message() function.
     117 *
    111118 */
    112 int netif_start_req_remote(int netif_phone, device_id_t device_id)
     119int netif_start_req(int netif_phone, device_id_t device_id)
    113120{
    114121        return async_req_1_0(netif_phone, NET_NETIF_START, device_id);
     
    117124/** Stop the device.
    118125 *
    119  * @param[in] netif_phone The network interface phone.
    120  * @param[in] device_id The device identifier.
    121  * @return              EOK on success.
    122  * @return              Other error codes as defined for the find_device()
    123  *                      function.
    124  * @return              Other error codes as defined for the
    125  *                      netif_stop_message() function.
     126 * @param[in] netif_phone Network interface phone.
     127 * @param[in] device_id   Device identifier.
     128 *
     129 * @return EOK on success.
     130 * @return Other error codes as defined for the find_device()
     131 *         function.
     132 * @return Other error codes as defined for the
     133 *         netif_stop_message() function.
     134 *
    126135 */
    127 int netif_stop_req_remote(int netif_phone, device_id_t device_id)
     136int netif_stop_req(int netif_phone, device_id_t device_id)
    128137{
    129138        return async_req_1_0(netif_phone, NET_NETIF_STOP, device_id);
     
    132141/** Return the device usage statistics.
    133142 *
    134  * @param[in] netif_phone The network interface phone.
    135  * @param[in] device_id The device identifier.
    136  * @param[out] stats    The device usage statistics.
     143 * @param[in] netif_phone Network interface phone.
     144 * @param[in] device_id   Device identifier.
     145 * @param[out] stats      Device usage statistics.
     146 *
    137147 * @return EOK on success.
     148 *
    138149 */
    139 int netif_stats_req_remote(int netif_phone, device_id_t device_id,
     150int netif_stats_req(int netif_phone, device_id_t device_id,
    140151    device_stats_t *stats)
    141152{
     
    153164}
    154165
    155 /** Create bidirectional connection with the network interface module and
    156  * registers the message receiver.
     166/** Create bidirectional connection with the network interface module
     167 *
     168 * Create bidirectional connection with the network interface module and
     169 * register the message receiver.
    157170 *
    158171 * @param[in] service   The network interface module service.
     
    161174 * @param[in] receiver  The message receiver.
    162175 *
    163  * @return              The phone of the needed service.
    164  * @return              EOK on success.
    165  * @return              Other error codes as defined for the bind_service()
    166  *                      function.
     176 * @return The phone of the needed service.
     177 * @return EOK on success.
     178 * @return Other error codes as defined for the bind_service()
     179 *         function.
     180 *
    167181 */
    168 int
    169 netif_bind_service_remote(services_t service, device_id_t device_id,
     182int netif_bind_service(services_t service, device_id_t device_id,
    170183    services_t me, async_client_conn_t receiver)
    171184{
  • uspace/lib/net/netif/netif_skel.c

    r863d45e r1ffa73b  
    2727 */
    2828
    29 /** @addtogroup libnet 
     29/** @addtogroup libnet
    3030 * @{
    3131 */
     
    5353#include <net/device.h>
    5454#include <nil_interface.h>
    55 #include <netif_local.h>
    56 #include <netif_interface.h>
     55#include <netif_skel.h>
    5756
    5857DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t);
     
    6362/** Probe the existence of the device.
    6463 *
    65  * @param[in] netif_phone The network interface phone.
    66  * @param[in] device_id The device identifier.
    67  * @param[in] irq       The device interrupt number.
    68  * @param[in] io        The device input/output address.
    69  * @return              EOK on success.
    70  * @return              Other error codes as defined for the
    71  *                      netif_probe_message().
    72  */
    73 int
    74 netif_probe_req_local(int netif_phone, device_id_t device_id, int irq, int io)
     64 * @param[in] netif_phone Network interface phone.
     65 * @param[in] device_id   Device identifier.
     66 * @param[in] irq         Device interrupt number.
     67 * @param[in] io          Device input/output address.
     68 *
     69 * @return EOK on success.
     70 * @return Other error codes as defined for the
     71 *         netif_probe_message().
     72 *
     73 */
     74static int netif_probe_req_local(int netif_phone, device_id_t device_id,
     75    int irq, void *io)
    7576{
    7677        fibril_rwlock_write_lock(&netif_globals.lock);
     
    8384/** Send the packet queue.
    8485 *
    85  * @param[in] netif_phone The network interface phone.
    86  * @param[in] device_id The device identifier.
    87  * @param[in] packet    The packet queue.
    88  * @param[in] sender    The sending module service.
    89  * @return              EOK on success.
    90  * @return              Other error codes as defined for the generic_send_msg()
    91  *                      function.
    92  */
    93 int netif_send_msg_local(int netif_phone, device_id_t device_id,
     86 * @param[in] netif_phone Network interface phone.
     87 * @param[in] device_id   Device identifier.
     88 * @param[in] packet      Packet queue.
     89 * @param[in] sender      Sending module service.
     90 *
     91 * @return EOK on success.
     92 * @return Other error codes as defined for the generic_send_msg()
     93 *         function.
     94 *
     95 */
     96static int netif_send_msg_local(int netif_phone, device_id_t device_id,
    9497    packet_t *packet, services_t sender)
    9598{
     
    103106/** Start the device.
    104107 *
    105  * @param[in] netif_phone The network interface phone.
    106  * @param[in] device_id The device identifier.
    107  * @return              EOK on success.
    108  * @return              Other error codes as defined for the find_device()
    109  *                      function.
    110  * @return              Other error codes as defined for the
    111  *                      netif_start_message() function.
    112  */
    113 int netif_start_req_local(int netif_phone, device_id_t device_id)
    114 {
    115         int rc;
    116        
     108 * @param[in] netif_phone Network interface phone.
     109 * @param[in] device_id   Device identifier.
     110 *
     111 * @return EOK on success.
     112 * @return Other error codes as defined for the find_device()
     113 *         function.
     114 * @return Other error codes as defined for the
     115 *         netif_start_message() function.
     116 *
     117 */
     118static int netif_start_req_local(int netif_phone, device_id_t device_id)
     119{
    117120        fibril_rwlock_write_lock(&netif_globals.lock);
    118121       
    119122        netif_device_t *device;
    120         rc = find_device(device_id, &device);
     123        int rc = find_device(device_id, &device);
    121124        if (rc != EOK) {
    122125                fibril_rwlock_write_unlock(&netif_globals.lock);
     
    139142/** Stop the device.
    140143 *
    141  * @param[in] netif_phone The network interface phone.
    142  * @param[in] device_id The device identifier.
    143  * @return              EOK on success.
    144  * @return              Other error codes as defined for the find_device()
    145  *                      function.
    146  * @return              Other error codes as defined for the
    147  *                      netif_stop_message() function.
    148  */
    149 int netif_stop_req_local(int netif_phone, device_id_t device_id)
    150 {
    151         int rc;
    152        
     144 * @param[in] netif_phone Network interface phone.
     145 * @param[in] device_id   Device identifier.
     146 *
     147 * @return EOK on success.
     148 * @return Other error codes as defined for the find_device()
     149 *         function.
     150 * @return Other error codes as defined for the
     151 *         netif_stop_message() function.
     152 *
     153 */
     154static int netif_stop_req_local(int netif_phone, device_id_t device_id)
     155{
    153156        fibril_rwlock_write_lock(&netif_globals.lock);
    154157       
    155158        netif_device_t *device;
    156         rc = find_device(device_id, &device);
     159        int rc = find_device(device_id, &device);
    157160        if (rc != EOK) {
    158161                fibril_rwlock_write_unlock(&netif_globals.lock);
     
    173176}
    174177
    175 /** Return the device usage statistics.
    176  *
    177  * @param[in] netif_phone The network interface phone.
    178  * @param[in] device_id The device identifier.
    179  * @param[out] stats    The device usage statistics.
    180  * @return EOK on success.
    181  */
    182 int netif_stats_req_local(int netif_phone, device_id_t device_id,
    183     device_stats_t *stats)
    184 {
    185         fibril_rwlock_read_lock(&netif_globals.lock);
    186         int res = netif_get_device_stats(device_id, stats);
    187         fibril_rwlock_read_unlock(&netif_globals.lock);
    188        
    189         return res;
    190 }
    191 
    192 /** Return the device local hardware address.
    193  *
    194  * @param[in] netif_phone The network interface phone.
    195  * @param[in] device_id The device identifier.
    196  * @param[out] address  The device local hardware address.
    197  * @param[out] data     The address data.
    198  * @return              EOK on success.
    199  * @return              EBADMEM if the address parameter is NULL.
    200  * @return              ENOENT if there no such device.
    201  * @return              Other error codes as defined for the
    202  *                      netif_get_addr_message() function.
    203  */
    204 int netif_get_addr_req_local(int netif_phone, device_id_t device_id,
    205     measured_string_t **address, char **data)
    206 {
    207         int rc;
    208        
    209         if (!address || !data)
    210                 return EBADMEM;
    211        
    212         fibril_rwlock_read_lock(&netif_globals.lock);
    213        
    214         measured_string_t translation;
    215         rc = netif_get_addr_message(device_id, &translation);
    216         if (rc == EOK) {
    217                 *address = measured_string_copy(&translation);
    218                 rc = (*address) ? EOK : ENOMEM;
    219         }
    220        
    221         fibril_rwlock_read_unlock(&netif_globals.lock);
    222        
    223         *data = (**address).value;
    224        
    225         return rc;
    226 }
    227 
    228178/** Find the device specific data.
    229179 *
    230  * @param[in] device_id The device identifier.
    231  * @param[out] device   The device specific data.
    232  * @return              EOK on success.
    233  * @return              ENOENT if device is not found.
    234  * @return              EPERM if the device is not initialized.
     180 * @param[in]  device_id Device identifier.
     181 * @param[out] device    Device specific data.
     182 *
     183 * @return EOK on success.
     184 * @return ENOENT if device is not found.
     185 * @return EPERM if the device is not initialized.
     186 *
    235187 */
    236188int find_device(device_id_t device_id, netif_device_t **device)
     
    251203/** Clear the usage statistics.
    252204 *
    253  * @param[in] stats     The usage statistics.
     205 * @param[in] stats The usage statistics.
     206 *
    254207 */
    255208void null_device_stats(device_stats_t *stats)
     
    258211}
    259212
    260 /** Initialize the netif module.
    261  *
    262  * @param[in] client_connection The client connection functio to be registered.
    263  * @return              EOK on success.
    264  * @return              Other error codes as defined for each specific module
    265  *                      message function.
    266  */
    267 int netif_init_module(async_client_conn_t client_connection)
    268 {
    269         int rc;
    270        
    271         async_set_client_connection(client_connection);
    272        
    273         netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING);
    274         netif_device_map_initialize(&netif_globals.device_map);
    275        
    276         rc = pm_init();
     213/** Release the given packet.
     214 *
     215 * Prepared for future optimization.
     216 *
     217 * @param[in] packet_id The packet identifier.
     218 *
     219 */
     220void netif_pq_release(packet_id_t packet_id)
     221{
     222        pq_release_remote(netif_globals.net_phone, packet_id);
     223}
     224
     225/** Allocate new packet to handle the given content size.
     226 *
     227 * @param[in] content Minimum content size.
     228 *
     229 * @return The allocated packet.
     230 * @return NULL on error.
     231 *
     232 */
     233packet_t *netif_packet_get_1(size_t content)
     234{
     235        return packet_get_1_remote(netif_globals.net_phone, content);
     236}
     237
     238/** Register the device notification receiver,
     239 *
     240 * Register a  network interface layer module as the device
     241 * notification receiver.
     242 *
     243 * @param[in] device_id Device identifier.
     244 * @param[in] phone     Network interface layer module phone.
     245 *
     246 * @return EOK on success.
     247 * @return ENOENT if there is no such device.
     248 * @return ELIMIT if there is another module registered.
     249 *
     250 */
     251static int register_message(device_id_t device_id, int phone)
     252{
     253        netif_device_t *device;
     254        int rc = find_device(device_id, &device);
    277255        if (rc != EOK)
    278256                return rc;
    279257       
    280         fibril_rwlock_initialize(&netif_globals.lock);
    281        
    282         rc = netif_initialize();
    283         if (rc != EOK) {
    284                 pm_destroy();
    285                 return rc;
    286         }
    287        
     258        if (device->nil_phone >= 0)
     259                return ELIMIT;
     260       
     261        device->nil_phone = phone;
    288262        return EOK;
    289263}
    290264
    291 /** Release the given packet.
    292  *
    293  * Prepared for future optimization.
    294  *
    295  * @param[in] packet_id The packet identifier.
    296  */
    297 void netif_pq_release(packet_id_t packet_id)
    298 {
    299         pq_release_remote(netif_globals.net_phone, packet_id);
    300 }
    301 
    302 /** Allocate new packet to handle the given content size.
    303  *
    304  * @param[in] content   The minimum content size.
    305  * @return              The allocated packet.
    306  * @return              NULL if there is an error.
    307  *
    308  */
    309 packet_t *netif_packet_get_1(size_t content)
    310 {
    311         return packet_get_1_remote(netif_globals.net_phone, content);
    312 }
    313 
    314 /** Register the device notification receiver, the network interface layer
    315  * module.
    316  *
    317  * @param[in] name      Module name.
    318  * @param[in] device_id The device identifier.
    319  * @param[in] phone     The network interface layer module phone.
    320  * @return              EOK on success.
    321  * @return              ENOENT if there is no such device.
    322  * @return              ELIMIT if there is another module registered.
    323  */
    324 static int register_message(const char *name, device_id_t device_id, int phone)
    325 {
    326         netif_device_t *device;
    327         int rc;
    328        
    329         rc = find_device(device_id, &device);
    330         if (rc != EOK)
    331                 return rc;
    332        
    333         if (device->nil_phone > 0)
    334                 return ELIMIT;
    335        
    336         device->nil_phone = phone;
    337         printf("%s: Receiver of device %d registered (phone: %d)\n",
    338             name, device->device_id, device->nil_phone);
    339         return EOK;
    340 }
    341 
    342265/** Process the netif module messages.
    343266 *
    344  * @param[in] name      Module name.
    345  * @param[in] callid    The message identifier.
    346  * @param[in] call      The message parameters.
    347  * @param[out] answer   The message answer parameters.
    348  * @param[out] answer_count The last parameter for the actual answer in the
    349  *                      answer parameter.
    350  * @return              EOK on success.
    351  * @return              ENOTSUP if the message is not known.
    352  * @return              Other error codes as defined for each specific module
    353  *                      message function.
     267 * @param[in]  callid Mmessage identifier.
     268 * @param[in]  call   Message.
     269 * @param[out] answer Answer.
     270 * @param[out] count  Number of arguments of the answer.
     271 *
     272 * @return EOK on success.
     273 * @return ENOTSUP if the message is unknown.
     274 * @return Other error codes as defined for each specific module
     275 *         message function.
    354276 *
    355277 * @see IS_NET_NETIF_MESSAGE()
    356278 *
    357279 */
    358 int netif_module_message_standalone(const char *name, ipc_callid_t callid,
    359     ipc_call_t *call, ipc_call_t *answer, int *answer_count)
     280static int netif_module_message(ipc_callid_t callid, ipc_call_t *call,
     281    ipc_call_t *answer, size_t *count)
    360282{
    361283        size_t length;
     
    365287        int rc;
    366288       
    367         *answer_count = 0;
     289        *count = 0;
     290       
    368291        switch (IPC_GET_IMETHOD(*call)) {
    369292        case IPC_M_PHONE_HUNGUP:
     
    371294       
    372295        case NET_NETIF_PROBE:
    373                 return netif_probe_req_local(0, IPC_GET_DEVICE(call),
    374                     NETIF_GET_IRQ(call), NETIF_GET_IO(call));
    375                    
     296                return netif_probe_req_local(0, IPC_GET_DEVICE(*call),
     297                    NETIF_GET_IRQ(*call), NETIF_GET_IO(*call));
     298       
    376299        case IPC_M_CONNECT_TO_ME:
    377300                fibril_rwlock_write_lock(&netif_globals.lock);
    378                 rc = register_message(name, IPC_GET_DEVICE(call),
    379                     IPC_GET_PHONE(call));
     301               
     302                rc = register_message(IPC_GET_DEVICE(*call), IPC_GET_PHONE(*call));
     303               
    380304                fibril_rwlock_write_unlock(&netif_globals.lock);
    381305                return rc;
    382                
     306       
    383307        case NET_NETIF_SEND:
    384308                rc = packet_translate_remote(netif_globals.net_phone, &packet,
    385                     IPC_GET_PACKET(call));
     309                    IPC_GET_PACKET(*call));
    386310                if (rc != EOK)
    387311                        return rc;
    388                 return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet,
    389                     IPC_GET_SENDER(call));
    390                
     312               
     313                return netif_send_msg_local(0, IPC_GET_DEVICE(*call), packet,
     314                    IPC_GET_SENDER(*call));
     315       
    391316        case NET_NETIF_START:
    392                 return netif_start_req_local(0, IPC_GET_DEVICE(call));
    393                
     317                return netif_start_req_local(0, IPC_GET_DEVICE(*call));
     318       
    394319        case NET_NETIF_STATS:
    395320                fibril_rwlock_read_lock(&netif_globals.lock);
    396 
     321               
    397322                rc = async_data_read_receive(&callid, &length);
    398323                if (rc != EOK) {
     
    400325                        return rc;
    401326                }
     327               
    402328                if (length < sizeof(device_stats_t)) {
    403329                        fibril_rwlock_read_unlock(&netif_globals.lock);
    404330                        return EOVERFLOW;
    405331                }
    406 
    407                 rc = netif_get_device_stats(IPC_GET_DEVICE(call), &stats);
     332               
     333                rc = netif_get_device_stats(IPC_GET_DEVICE(*call), &stats);
    408334                if (rc == EOK) {
    409335                        rc = async_data_read_finalize(callid, &stats,
    410336                            sizeof(device_stats_t));
    411337                }
    412 
     338               
    413339                fibril_rwlock_read_unlock(&netif_globals.lock);
    414340                return rc;
    415 
     341       
    416342        case NET_NETIF_STOP:
    417                 return netif_stop_req_local(0, IPC_GET_DEVICE(call));
    418                
     343                return netif_stop_req_local(0, IPC_GET_DEVICE(*call));
     344       
    419345        case NET_NETIF_GET_ADDR:
    420346                fibril_rwlock_read_lock(&netif_globals.lock);
    421                 rc = netif_get_addr_message(IPC_GET_DEVICE(call), &address);
     347               
     348                rc = netif_get_addr_message(IPC_GET_DEVICE(*call), &address);
    422349                if (rc == EOK)
    423350                        rc = measured_strings_reply(&address, 1);
     351               
    424352                fibril_rwlock_read_unlock(&netif_globals.lock);
    425353                return rc;
    426354        }
    427355       
    428         return netif_specific_message(callid, call, answer, answer_count);
     356        return netif_specific_message(callid, call, answer, count);
     357}
     358
     359/** Default fibril for new module connections.
     360 *
     361 * @param[in] iid   Initial message identifier.
     362 * @param[in] icall Initial message call structure.
     363 *
     364 */
     365static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall)
     366{
     367        /*
     368         * Accept the connection by answering
     369         * the initial IPC_M_CONNECT_ME_TO call.
     370         */
     371        ipc_answer_0(iid, EOK);
     372       
     373        while (true) {
     374                ipc_call_t answer;
     375                size_t count;
     376               
     377                /* Clear the answer structure */
     378                refresh_answer(&answer, &count);
     379               
     380                /* Fetch the next message */
     381                ipc_call_t call;
     382                ipc_callid_t callid = async_get_call(&call);
     383               
     384                /* Process the message */
     385                int res = netif_module_message(callid, &call, &answer, &count);
     386               
     387                /* End if said to either by the message or the processing result */
     388                if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
     389                    (res == EHANGUP))
     390                        return;
     391               
     392                /* Answer the message */
     393                answer_call(callid, res, &answer, count);
     394        }
    429395}
    430396
     
    435401 * messages in an infinite loop.
    436402 *
    437  * @param[in] client_connection The client connection processing function.
    438  *                      The module skeleton propagates its own one.
    439  * @return              EOK on success.
    440  * @return              Other error codes as defined for each specific module
    441  *                      message function.
    442  */
    443 int netif_module_start_standalone(async_client_conn_t client_connection)
    444 {
    445         int rc;
    446        
    447         rc = netif_init_module(client_connection);
     403 * @return EOK on success.
     404 * @return Other error codes as defined for each specific module
     405 *         message function.
     406 *
     407 */
     408int netif_module_start(void)
     409{
     410        async_set_client_connection(netif_client_connection);
     411       
     412        netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING);
     413        netif_device_map_initialize(&netif_globals.device_map);
     414       
     415        int rc = pm_init();
    448416        if (rc != EOK)
    449417                return rc;
     418       
     419        fibril_rwlock_initialize(&netif_globals.lock);
     420       
     421        rc = netif_initialize();
     422        if (rc != EOK) {
     423                pm_destroy();
     424                return rc;
     425        }
    450426       
    451427        async_manager();
  • uspace/lib/net/tl/socket_core.c

    r863d45e r1ffa73b  
    161161static int
    162162socket_port_add_core(socket_port_t *socket_port, socket_core_t *socket,
    163     const char *key, size_t key_length)
     163    const uint8_t *key, size_t key_length)
    164164{
    165165        socket_core_t **socket_ref;
     
    216216                goto fail;
    217217       
    218         rc = socket_port_add_core(socket_port, socket, SOCKET_MAP_KEY_LISTENING,
    219             0);
     218        rc = socket_port_add_core(socket_port, socket,
     219            (const uint8_t *) SOCKET_MAP_KEY_LISTENING, 0);
    220220        if (rc != EOK)
    221221                goto fail;
     
    602602 */
    603603socket_core_t *
    604 socket_port_find(socket_ports_t *global_sockets, int port, const char *key,
     604socket_port_find(socket_ports_t *global_sockets, int port, const uint8_t *key,
    605605    size_t key_length)
    606606{
     
    680680int
    681681socket_port_add(socket_ports_t *global_sockets, int port,
    682     socket_core_t *socket, const char *key, size_t key_length)
     682    socket_core_t *socket, const uint8_t *key, size_t key_length)
    683683{
    684684        socket_port_t *socket_port;
  • uspace/lib/packet/generic/packet_server.c

    r863d45e r1ffa73b  
    322322int
    323323packet_server_message(ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer,
    324     int *answer_count)
     324    size_t *answer_count)
    325325{
    326326        packet_t *packet;
     
    333333        case NET_PACKET_CREATE_1:
    334334                packet = packet_get_local(DEFAULT_ADDR_LEN, DEFAULT_PREFIX,
    335                     IPC_GET_CONTENT(call), DEFAULT_SUFFIX);
     335                    IPC_GET_CONTENT(*call), DEFAULT_SUFFIX);
    336336                if (!packet)
    337337                        return ENOMEM;
     
    343343        case NET_PACKET_CREATE_4:
    344344                packet = packet_get_local(
    345                     ((DEFAULT_ADDR_LEN < IPC_GET_ADDR_LEN(call)) ?
    346                     IPC_GET_ADDR_LEN(call) : DEFAULT_ADDR_LEN),
    347                     DEFAULT_PREFIX + IPC_GET_PREFIX(call),
    348                     IPC_GET_CONTENT(call),
    349                     DEFAULT_SUFFIX + IPC_GET_SUFFIX(call));
     345                    ((DEFAULT_ADDR_LEN < IPC_GET_ADDR_LEN(*call)) ?
     346                    IPC_GET_ADDR_LEN(*call) : DEFAULT_ADDR_LEN),
     347                    DEFAULT_PREFIX + IPC_GET_PREFIX(*call),
     348                    IPC_GET_CONTENT(*call),
     349                    DEFAULT_SUFFIX + IPC_GET_SUFFIX(*call));
    350350                if (!packet)
    351351                        return ENOMEM;
     
    356356       
    357357        case NET_PACKET_GET:
    358                 packet = pm_find(IPC_GET_ID(call));
     358                packet = pm_find(IPC_GET_ID(*call));
    359359                if (!packet_is_valid(packet))
    360360                        return ENOENT;
     
    362362       
    363363        case NET_PACKET_GET_SIZE:
    364                 packet = pm_find(IPC_GET_ID(call));
     364                packet = pm_find(IPC_GET_ID(*call));
    365365                if (!packet_is_valid(packet))
    366366                        return ENOENT;
     
    370370       
    371371        case NET_PACKET_RELEASE:
    372                 return packet_release_wrapper(IPC_GET_ID(call));
     372                return packet_release_wrapper(IPC_GET_ID(*call));
    373373        }
    374374       
  • uspace/lib/packet/include/packet_server.h

    r863d45e r1ffa73b  
    4848
    4949extern int packet_server_message(ipc_callid_t, ipc_call_t *, ipc_call_t *,
    50     int *);
     50    size_t *);
    5151
    5252#endif
Note: See TracChangeset for help on using the changeset viewer.