Ignore:
File:
1 edited

Legend:

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

    r00d7e1b r28a3e74  
    4444/** Notify the module about the device state change.
    4545 *
    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  */
    55 int generic_device_state_msg_remote(async_sess_t *sess, sysarg_t message,
    56     nic_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);
     46 * @param[in] phone     The service module phone.
     47 * @param[in] message   The service specific message.
     48 * @param[in] device_id The device identifier.
     49 * @param[in] state     The new device state.
     50 * @param[in] target    The target module service.
     51 * @return              EOK on success.
     52 *
     53 */
     54int
     55generic_device_state_msg_remote(int phone, int message, device_id_t device_id,
     56    int state, services_t target)
     57{
     58        async_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
     59            (sysarg_t) state, target);
    6160       
    6261        return EOK;
     
    6564/** Notify a module about the device.
    6665 *
    67  * @param[in] sess      Service module session.
    68  * @param[in] message   Service specific message.
    69  * @param[in] device_id Device identifier.
    70  * @param[in] service   Device module service.
    71  *
    72  * @return EOK on success.
    73  * @return Other error codes as defined for the specific service
    74  *         message.
    75  *
    76  */
    77 int generic_device_req_remote(async_sess_t *sess, sysarg_t message,
    78     nic_device_id_t device_id, services_t service)
    79 {
    80         async_exch_t *exch = async_exchange_begin(sess);
    81         int rc = async_req_3_0(exch, message, (sysarg_t) device_id, 0,
    82             (sysarg_t) service);
    83         async_exchange_end(exch);
    84        
    85         return rc;
     66 * @param[in] phone     The service module phone.
     67 * @param[in] message   The service specific message.
     68 * @param[in] device_id The device identifier.
     69 * @param[in] arg2      The second argument of the message.
     70 * @param[in] service   The device module service.
     71 * @return              EOK on success.
     72 * @return              Other error codes as defined for the specific service
     73 *                       message.
     74 *
     75 */
     76int
     77generic_device_req_remote(int phone, int message, device_id_t device_id,
     78    int arg2, services_t service)
     79{
     80        return (int) async_req_3_0(phone, (sysarg_t) message,
     81            (sysarg_t) device_id, (sysarg_t) arg2, (sysarg_t) service);
    8682}
    8783
    8884/** Returns the address.
    8985 *
    90  * @param[in] sess      Service module session.
    91  * @param[in] message   Service specific message.
    92  * @param[in] device_id Device identifier.
    93  * @param[out] address  Desired address.
    94  * @param[out] data     Address data container.
    95  *
    96  * @return EOK on success.
    97  * @return EBADMEM if the address parameter and/or the data
    98  *         parameter is NULL.
    99  * @return Other error codes as defined for the specific service
    100  *         message.
    101  *
    102  */
    103 int generic_get_addr_req(async_sess_t *sess, sysarg_t message,
    104     nic_device_id_t device_id, uint8_t *address, size_t max_len)
    105 {
    106         if (!address)
     86 * @param[in] phone     The service module phone.
     87 * @param[in] message   The service specific message.
     88 * @param[in] device_id The device identifier.
     89 * @param[out] address  The desired address.
     90 * @param[out] data     The address data container.
     91 * @return              EOK on success.
     92 * @return              EBADMEM if the address parameter and/or the data
     93 *                      parameter is NULL.
     94 * @return              Other error codes as defined for the specific service
     95 *                      message.
     96 */
     97int
     98generic_get_addr_req(int phone, int message, device_id_t device_id,
     99    measured_string_t **address, uint8_t **data)
     100{
     101        aid_t message_id;
     102        sysarg_t result;
     103        int string;
     104
     105        if (!address || !data)
    107106                return EBADMEM;
    108        
     107
    109108        /* Request the address */
    110         async_exch_t *exch = async_exchange_begin(sess);
    111         aid_t aid = async_send_1(exch, message, (sysarg_t) device_id,
    112             NULL);
    113         int rc = async_data_read_start(exch, address, max_len);
    114         async_exchange_end(exch);
    115        
    116         sysarg_t result;
    117         async_wait_for(aid, &result);
    118        
    119         if (rc != EOK)
    120                 return rc;
     109        message_id = async_send_1(phone, (sysarg_t) message,
     110            (sysarg_t) device_id, NULL);
     111        string = measured_strings_return(phone, address, data, 1);
     112        async_wait_for(message_id, &result);
     113
     114        /* If not successful */
     115        if ((string == EOK) && (result != EOK)) {
     116                /* Clear the data */
     117                free(*address);
     118                free(*data);
     119        }
    121120       
    122121        return (int) result;
     
    125124/** Return the device packet dimension for sending.
    126125 *
    127  * @param[in] sess              Service module session.
    128  * @param[in] message           Service specific message.
    129  * @param[in] device_id         Device identifier.
    130  * @param[out] packet_dimension Packet dimension.
    131  *
    132  * @return EOK on success.
    133  * @return EBADMEM if the packet_dimension parameter is NULL.
    134  * @return Other error codes as defined for the specific service
    135  *         message.
    136  *
    137  */
    138 int generic_packet_size_req_remote(async_sess_t *sess, sysarg_t message,
    139     nic_device_id_t device_id, packet_dimension_t *packet_dimension)
     126 * @param[in] phone     The service module phone.
     127 * @param[in] message   The service specific message.
     128 * @param[in] device_id The device identifier.
     129 * @param[out] packet_dimension The packet dimension.
     130 * @return              EOK on success.
     131 * @return              EBADMEM if the packet_dimension parameter is NULL.
     132 * @return              Other error codes as defined for the specific service
     133 *                      message.
     134 */
     135int
     136generic_packet_size_req_remote(int phone, int message, device_id_t device_id,
     137    packet_dimension_t *packet_dimension)
    140138{
    141139        if (!packet_dimension)
     
    147145        sysarg_t suffix;
    148146       
    149         async_exch_t *exch = async_exchange_begin(sess);
    150         sysarg_t result = async_req_1_4(exch, message, (sysarg_t) device_id,
    151             &addr_len, &prefix, &content, &suffix);
    152         async_exchange_end(exch);
     147        sysarg_t result = async_req_1_4(phone, (sysarg_t) message,
     148            (sysarg_t) device_id, &addr_len, &prefix, &content, &suffix);
    153149       
    154150        packet_dimension->prefix = (size_t) prefix;
     
    162158/** Pass the packet queue to the module.
    163159 *
    164  * @param[in] sess      Service module session.
    165  * @param[in] message   Service specific message.
    166  * @param[in] device_id Device identifier.
    167  * @param[in] packet_id Received packet or the received packet queue
    168  *                      identifier.
    169  * @param[in] target    Target module service.
    170  * @param[in] error     Error module service.
    171  *
    172  * @return EOK on success.
    173  *
    174  */
    175 int generic_received_msg_remote(async_sess_t *sess, sysarg_t message,
    176     nic_device_id_t device_id, packet_id_t packet_id, services_t target,
    177     services_t error)
    178 {
    179         async_exch_t *exch = async_exchange_begin(sess);
    180        
     160 * @param[in] phone     The service module phone.
     161 * @param[in] message   The service specific message.
     162 * @param[in] device_id The device identifier.
     163 * @param[in] packet_id The received packet or the received packet queue
     164 *                      identifier.
     165 * @param[in] target    The target module service.
     166 * @param[in] error     The error module service.
     167 * @return              EOK on success.
     168 */
     169int
     170generic_received_msg_remote(int phone, int message, device_id_t device_id,
     171    packet_id_t packet_id, services_t target, services_t error)
     172{
    181173        if (error) {
    182                 async_msg_4(exch, message, (sysarg_t) device_id,
     174                async_msg_4(phone, (sysarg_t) message, (sysarg_t) device_id,
    183175                    (sysarg_t) packet_id, (sysarg_t) target, (sysarg_t) error);
    184176        } else {
    185                 async_msg_3(exch, message, (sysarg_t) device_id,
     177                async_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
    186178                    (sysarg_t) packet_id, (sysarg_t) target);
    187179        }
    188180       
    189         async_exchange_end(exch);
    190        
    191181        return EOK;
    192182}
     
    194184/** Send the packet queue.
    195185 *
    196  * @param[in] sess      Service module session.
    197  * @param[in] message   Service specific message.
    198  * @param[in] device_id Device identifier.
    199  * @param[in] packet_id Packet or the packet queue identifier.
    200  * @param[in] sender    Sending module service.
    201  * @param[in] error     Error module service.
    202  *
    203  * @return EOK on success.
    204  *
    205  */
    206 int generic_send_msg_remote(async_sess_t *sess, sysarg_t message,
    207     nic_device_id_t device_id, packet_id_t packet_id, services_t sender,
    208     services_t error)
    209 {
    210         async_exch_t *exch = async_exchange_begin(sess);
    211        
     186 * @param[in] phone     The service module phone.
     187 * @param[in] message   The service specific message.
     188 * @param[in] device_id The device identifier.
     189 * @param[in] packet_id The packet or the packet queue identifier.
     190 * @param[in] sender    The sending module service.
     191 * @param[in] error     The error module service.
     192 * @return              EOK on success.
     193 *
     194 */
     195int
     196generic_send_msg_remote(int phone, int message, device_id_t device_id,
     197    packet_id_t packet_id, services_t sender, services_t error)
     198{
    212199        if (error) {
    213                 async_msg_4(exch, message, (sysarg_t) device_id,
     200                async_msg_4(phone, (sysarg_t) message, (sysarg_t) device_id,
    214201                    (sysarg_t) packet_id, (sysarg_t) sender, (sysarg_t) error);
    215202        } else {
    216                 async_msg_3(exch, message, (sysarg_t) device_id,
     203                async_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
    217204                    (sysarg_t) packet_id, (sysarg_t) sender);
    218205        }
    219206       
    220         async_exchange_end(exch);
    221        
    222207        return EOK;
    223208}
     
    227212 * Allocates and returns the needed memory block as the data parameter.
    228213 *
    229  * @param[in] sess          Service module session.
    230  * @param[in] message       Service specific message.
    231  * @param[in] device_id     Device identifier.
    232  * @param[in] service       Module service.
    233  * @param[in] configuration Key strings.
    234  * @param[in] count         Number of configuration keys.
    235  * @param[out] translation  Translated values.
    236  * @param[out] data         Translation data container.
    237  *
    238  * @return EOK on success.
    239  * @return EINVAL if the configuration parameter is NULL.
    240  * @return EINVAL if the count parameter is zero.
    241  * @return EBADMEM if the translation or the data parameters are
    242  *         NULL.
    243  * @return Other error codes as defined for the specific service
    244  *         message.
    245  *
    246  */
    247 int generic_translate_req(async_sess_t *sess, sysarg_t message,
    248     nic_device_id_t device_id, services_t service,
    249     measured_string_t *configuration, size_t count,
     214 * @param[in] phone     The service module phone.
     215 * @param[in] message   The service specific message.
     216 * @param[in] device_id The device identifier.
     217 * @param[in] service   The module service.
     218 * @param[in] configuration The key strings.
     219 * @param[in] count     The number of configuration keys.
     220 * @param[out] translation The translated values.
     221 * @param[out] data     The translation data container.
     222 * @return              EOK on success.
     223 * @return              EINVAL if the configuration parameter is NULL.
     224 * @return              EINVAL if the count parameter is zero.
     225 * @return              EBADMEM if the translation or the data parameters are
     226 *                      NULL.
     227 * @return              Other error codes as defined for the specific service
     228 *                      message.
     229 */
     230int
     231generic_translate_req(int phone, int message, device_id_t device_id,
     232    services_t service, measured_string_t *configuration, size_t count,
    250233    measured_string_t **translation, uint8_t **data)
    251234{
    252         if ((!configuration) || (count == 0))
     235        aid_t message_id;
     236        sysarg_t result;
     237        int string;
     238
     239        if (!configuration || (count == 0))
    253240                return EINVAL;
    254        
    255         if ((!translation) || (!data))
     241        if (!translation || !data)
    256242                return EBADMEM;
    257        
     243
    258244        /* Request the translation */
    259         async_exch_t *exch = async_exchange_begin(sess);
    260         aid_t message_id = async_send_3(exch, message, (sysarg_t) device_id,
    261             (sysarg_t) count, (sysarg_t) service, NULL);
    262         measured_strings_send(exch, configuration, count);
    263         int rc = measured_strings_return(exch, translation, data, count);
    264         async_exchange_end(exch);
    265        
    266         sysarg_t result;
     245        message_id = async_send_3(phone, (sysarg_t) message,
     246            (sysarg_t) device_id, (sysarg_t) count, (sysarg_t) service, NULL);
     247        measured_strings_send(phone, configuration, count);
     248        string = measured_strings_return(phone, translation, data, count);
    267249        async_wait_for(message_id, &result);
    268        
     250
    269251        /* If not successful */
    270         if ((rc == EOK) && (result != EOK)) {
     252        if ((string == EOK) && (result != EOK)) {
    271253                /* Clear the data */
    272254                free(*translation);
    273255                free(*data);
    274256        }
    275        
     257
    276258        return (int) result;
    277259}
Note: See TracChangeset for help on using the changeset viewer.