Changeset f51f193 in mainline for uspace/lib/net/generic/generic.c


Ignore:
Timestamp:
2011-07-12T03:00:14Z (13 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6817eba
Parents:
eca52a8 (diff), 026793d (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 mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/generic/generic.c

    reca52a8 rf51f193  
    3737#include <generic.h>
    3838#include <async.h>
    39 #include <async_obsolete.h>
    4039#include <ipc/services.h>
    4140#include <net/device.h>
     
    4544/** Notify the module about the device state change.
    4645 *
    47  * @param[in] phone     The service module phone.
    48  * @param[in] message   The service specific message.
    49  * @param[in] device_id The device identifier.
    50  * @param[in] state     The new device state.
    51  * @param[in] target    The target module service.
    52  * @return              EOK on success.
    53  *
    54  */
    55 int
    56 generic_device_state_msg_remote(int phone, int message, device_id_t device_id,
    57     int state, services_t target)
    58 {
    59         async_obsolete_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
    60             (sysarg_t) state, target);
     46 * @param[in] sess      Service module session.
     47 * @param[in] message   Service specific message.
     48 * @param[in] device_id Device identifier.
     49 * @param[in] state     New device state.
     50 * @param[in] target    Target module service.
     51 *
     52 * @return EOK on success.
     53 *
     54 */
     55int generic_device_state_msg_remote(async_sess_t *sess, sysarg_t message,
     56    device_id_t device_id, sysarg_t state, services_t target)
     57{
     58        async_exch_t *exch = async_exchange_begin(sess);
     59        async_msg_3(exch, message, (sysarg_t) device_id, state, target);
     60        async_exchange_end(exch);
    6161       
    6262        return EOK;
     
    6565/** Notify a module about the device.
    6666 *
    67  * @param[in] phone     The service module phone.
    68  * @param[in] message   The service specific message.
    69  * @param[in] device_id The device identifier.
    70  * @param[in] arg2      The second argument of the message.
    71  * @param[in] service   The device module service.
    72  * @return              EOK on success.
    73  * @return              Other error codes as defined for the specific service
    74  *                       message.
    75  *
    76  */
    77 int
    78 generic_device_req_remote(int phone, int message, device_id_t device_id,
    79     int arg2, services_t service)
    80 {
    81         return (int) async_obsolete_req_3_0(phone, (sysarg_t) message,
    82             (sysarg_t) device_id, (sysarg_t) arg2, (sysarg_t) service);
     67 * @param[in] sess      Service module session.
     68 * @param[in] message   Service specific message.
     69 * @param[in] device_id Device identifier.
     70 * @param[in] arg2      Second argument of the message.
     71 * @param[in] service   Device module service.
     72 *
     73 * @return EOK on success.
     74 * @return Other error codes as defined for the specific service
     75 *         message.
     76 *
     77 */
     78int generic_device_req_remote(async_sess_t *sess, sysarg_t message,
     79    device_id_t device_id, sysarg_t arg2, services_t service)
     80{
     81        async_exch_t *exch = async_exchange_begin(sess);
     82        int rc = async_req_3_0(exch, message, (sysarg_t) device_id,
     83            arg2, (sysarg_t) service);
     84        async_exchange_end(exch);
     85       
     86        return rc;
    8387}
    8488
    8589/** Returns the address.
    8690 *
    87  * @param[in] phone     The service module phone.
    88  * @param[in] message   The service specific message.
    89  * @param[in] device_id The device identifier.
    90  * @param[out] address  The desired address.
    91  * @param[out] data     The address data container.
    92  * @return              EOK on success.
    93  * @return              EBADMEM if the address parameter and/or the data
    94  *                      parameter is NULL.
    95  * @return              Other error codes as defined for the specific service
    96  *                      message.
    97  */
    98 int
    99 generic_get_addr_req(int phone, int message, device_id_t device_id,
    100     measured_string_t **address, uint8_t **data)
    101 {
    102         aid_t message_id;
     91 * @param[in] sess      Service module session.
     92 * @param[in] message   Service specific message.
     93 * @param[in] device_id Device identifier.
     94 * @param[out] address  Desired address.
     95 * @param[out] data     Address data container.
     96 *
     97 * @return EOK on success.
     98 * @return EBADMEM if the address parameter and/or the data
     99 *         parameter is NULL.
     100 * @return Other error codes as defined for the specific service
     101 *         message.
     102 *
     103 */
     104int generic_get_addr_req(async_sess_t *sess, sysarg_t message,
     105    device_id_t device_id, measured_string_t **address, uint8_t **data)
     106{
     107        if ((!address) || (!data))
     108                return EBADMEM;
     109       
     110        /* Request the address */
     111        async_exch_t *exch = async_exchange_begin(sess);
     112        aid_t message_id = async_send_1(exch, message, (sysarg_t) device_id,
     113            NULL);
     114        int rc = measured_strings_return(exch, address, data, 1);
     115        async_exchange_end(exch);
     116       
    103117        sysarg_t result;
    104         int string;
    105 
    106         if (!address || !data)
    107                 return EBADMEM;
    108 
    109         /* Request the address */
    110         message_id = async_obsolete_send_1(phone, (sysarg_t) message,
    111             (sysarg_t) device_id, NULL);
    112         string = measured_strings_return(phone, address, data, 1);
    113118        async_wait_for(message_id, &result);
    114 
     119       
    115120        /* If not successful */
    116         if ((string == EOK) && (result != EOK)) {
     121        if ((rc == EOK) && (result != EOK)) {
    117122                /* Clear the data */
    118123                free(*address);
     
    125130/** Return the device packet dimension for sending.
    126131 *
    127  * @param[in] phone     The service module phone.
    128  * @param[in] message   The service specific message.
    129  * @param[in] device_id The device identifier.
    130  * @param[out] packet_dimension The packet dimension.
    131  * @return              EOK on success.
    132  * @return              EBADMEM if the packet_dimension parameter is NULL.
    133  * @return              Other error codes as defined for the specific service
    134  *                      message.
    135  */
    136 int
    137 generic_packet_size_req_remote(int phone, int message, device_id_t device_id,
    138     packet_dimension_t *packet_dimension)
     132 * @param[in] sess              Service module session.
     133 * @param[in] message           Service specific message.
     134 * @param[in] device_id         Device identifier.
     135 * @param[out] packet_dimension Packet dimension.
     136 *
     137 * @return EOK on success.
     138 * @return EBADMEM if the packet_dimension parameter is NULL.
     139 * @return Other error codes as defined for the specific service
     140 *         message.
     141 *
     142 */
     143int generic_packet_size_req_remote(async_sess_t *sess, sysarg_t message,
     144    device_id_t device_id, packet_dimension_t *packet_dimension)
    139145{
    140146        if (!packet_dimension)
     
    146152        sysarg_t suffix;
    147153       
    148         sysarg_t result = async_obsolete_req_1_4(phone, (sysarg_t) message,
    149             (sysarg_t) device_id, &addr_len, &prefix, &content, &suffix);
     154        async_exch_t *exch = async_exchange_begin(sess);
     155        sysarg_t result = async_req_1_4(exch, message, (sysarg_t) device_id,
     156            &addr_len, &prefix, &content, &suffix);
     157        async_exchange_end(exch);
    150158       
    151159        packet_dimension->prefix = (size_t) prefix;
     
    159167/** Pass the packet queue to the module.
    160168 *
    161  * @param[in] phone     The service module phone.
    162  * @param[in] message   The service specific message.
    163  * @param[in] device_id The device identifier.
    164  * @param[in] packet_id The received packet or the received packet queue
    165  *                      identifier.
    166  * @param[in] target    The target module service.
    167  * @param[in] error     The error module service.
    168  * @return              EOK on success.
    169  */
    170 int
    171 generic_received_msg_remote(int phone, int message, device_id_t device_id,
    172     packet_id_t packet_id, services_t target, services_t error)
    173 {
     169 * @param[in] sess      Service module session.
     170 * @param[in] message   Service specific message.
     171 * @param[in] device_id Device identifier.
     172 * @param[in] packet_id Received packet or the received packet queue
     173 *                      identifier.
     174 * @param[in] target    Target module service.
     175 * @param[in] error     Error module service.
     176 *
     177 * @return EOK on success.
     178 *
     179 */
     180int generic_received_msg_remote(async_sess_t *sess, sysarg_t message,
     181    device_id_t device_id, packet_id_t packet_id, services_t target,
     182    services_t error)
     183{
     184        async_exch_t *exch = async_exchange_begin(sess);
     185       
    174186        if (error) {
    175                 async_obsolete_msg_4(phone, (sysarg_t) message, (sysarg_t) device_id,
     187                async_msg_4(exch, message, (sysarg_t) device_id,
    176188                    (sysarg_t) packet_id, (sysarg_t) target, (sysarg_t) error);
    177189        } else {
    178                 async_obsolete_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
     190                async_msg_3(exch, message, (sysarg_t) device_id,
    179191                    (sysarg_t) packet_id, (sysarg_t) target);
    180192        }
    181193       
     194        async_exchange_end(exch);
     195       
    182196        return EOK;
    183197}
     
    185199/** Send the packet queue.
    186200 *
    187  * @param[in] phone     The service module phone.
    188  * @param[in] message   The service specific message.
    189  * @param[in] device_id The device identifier.
    190  * @param[in] packet_id The packet or the packet queue identifier.
    191  * @param[in] sender    The sending module service.
    192  * @param[in] error     The error module service.
    193  * @return              EOK on success.
    194  *
    195  */
    196 int
    197 generic_send_msg_remote(int phone, int message, device_id_t device_id,
    198     packet_id_t packet_id, services_t sender, services_t error)
    199 {
     201 * @param[in] sess      Service module session.
     202 * @param[in] message   Service specific message.
     203 * @param[in] device_id Device identifier.
     204 * @param[in] packet_id Packet or the packet queue identifier.
     205 * @param[in] sender    Sending module service.
     206 * @param[in] error     Error module service.
     207 *
     208 * @return EOK on success.
     209 *
     210 */
     211int generic_send_msg_remote(async_sess_t *sess, sysarg_t message,
     212    device_id_t device_id, packet_id_t packet_id, services_t sender,
     213    services_t error)
     214{
     215        async_exch_t *exch = async_exchange_begin(sess);
     216       
    200217        if (error) {
    201                 async_obsolete_msg_4(phone, (sysarg_t) message, (sysarg_t) device_id,
     218                async_msg_4(exch, message, (sysarg_t) device_id,
    202219                    (sysarg_t) packet_id, (sysarg_t) sender, (sysarg_t) error);
    203220        } else {
    204                 async_obsolete_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
     221                async_msg_3(exch, message, (sysarg_t) device_id,
    205222                    (sysarg_t) packet_id, (sysarg_t) sender);
    206223        }
    207224       
     225        async_exchange_end(exch);
     226       
    208227        return EOK;
    209228}
     
    213232 * Allocates and returns the needed memory block as the data parameter.
    214233 *
    215  * @param[in] phone     The service module phone.
    216  * @param[in] message   The service specific message.
    217  * @param[in] device_id The device identifier.
    218  * @param[in] service   The module service.
    219  * @param[in] configuration The key strings.
    220  * @param[in] count     The number of configuration keys.
    221  * @param[out] translation The translated values.
    222  * @param[out] data     The translation data container.
    223  * @return              EOK on success.
    224  * @return              EINVAL if the configuration parameter is NULL.
    225  * @return              EINVAL if the count parameter is zero.
    226  * @return              EBADMEM if the translation or the data parameters are
    227  *                      NULL.
    228  * @return              Other error codes as defined for the specific service
    229  *                      message.
    230  */
    231 int
    232 generic_translate_req(int phone, int message, device_id_t device_id,
    233     services_t service, measured_string_t *configuration, size_t count,
     234 * @param[in] sess          Service module session.
     235 * @param[in] message       Service specific message.
     236 * @param[in] device_id     Device identifier.
     237 * @param[in] service       Module service.
     238 * @param[in] configuration Key strings.
     239 * @param[in] count         Number of configuration keys.
     240 * @param[out] translation  Translated values.
     241 * @param[out] data         Translation data container.
     242 *
     243 * @return EOK on success.
     244 * @return EINVAL if the configuration parameter is NULL.
     245 * @return EINVAL if the count parameter is zero.
     246 * @return EBADMEM if the translation or the data parameters are
     247 *         NULL.
     248 * @return Other error codes as defined for the specific service
     249 *         message.
     250 *
     251 */
     252int generic_translate_req(async_sess_t *sess, sysarg_t message,
     253    device_id_t device_id, services_t service,
     254    measured_string_t *configuration, size_t count,
    234255    measured_string_t **translation, uint8_t **data)
    235256{
    236         aid_t message_id;
     257        if ((!configuration) || (count == 0))
     258                return EINVAL;
     259       
     260        if ((!translation) || (!data))
     261                return EBADMEM;
     262       
     263        /* Request the translation */
     264        async_exch_t *exch = async_exchange_begin(sess);
     265        aid_t message_id = async_send_3(exch, message, (sysarg_t) device_id,
     266            (sysarg_t) count, (sysarg_t) service, NULL);
     267        measured_strings_send(exch, configuration, count);
     268        int rc = measured_strings_return(exch, translation, data, count);
     269        async_exchange_end(exch);
     270       
    237271        sysarg_t result;
    238         int string;
    239 
    240         if (!configuration || (count == 0))
    241                 return EINVAL;
    242         if (!translation || !data)
    243                 return EBADMEM;
    244 
    245         /* Request the translation */
    246         message_id = async_obsolete_send_3(phone, (sysarg_t) message,
    247             (sysarg_t) device_id, (sysarg_t) count, (sysarg_t) service, NULL);
    248         measured_strings_send(phone, configuration, count);
    249         string = measured_strings_return(phone, translation, data, count);
    250272        async_wait_for(message_id, &result);
    251 
     273       
    252274        /* If not successful */
    253         if ((string == EOK) && (result != EOK)) {
     275        if ((rc == EOK) && (result != EOK)) {
    254276                /* Clear the data */
    255277                free(*translation);
    256278                free(*data);
    257279        }
    258 
     280       
    259281        return (int) result;
    260282}
Note: See TracChangeset for help on using the changeset viewer.